sootsim 0.1.92 → 0.1.93

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 (142) hide show
  1. package/dist-cli/bin.js +3 -3
  2. package/dist-cli/chunks/{agent-NLUI4O7V.js → agent-L6HIJY56.js} +2 -2
  3. package/dist-cli/chunks/{agent-wrapper-KPGUM7NZ.js → agent-wrapper-E46RJGKZ.js} +2 -2
  4. package/dist-cli/chunks/{assert-FJQ67TVS.js → assert-E35SQTDG.js} +2 -2
  5. package/dist-cli/chunks/auto-bootstrap-KTVZAENF.js +2 -0
  6. package/dist-cli/chunks/beta-AMLREMEK.js +2 -0
  7. package/dist-cli/chunks/{chunk-THZNZO3H.js → chunk-2JFC45SX.js} +2 -2
  8. package/dist-cli/chunks/{chunk-N7GBP6IK.js → chunk-352UPR2W.js} +2 -2
  9. package/dist-cli/chunks/{chunk-OJSVBBKS.js → chunk-3IFMI2MH.js} +1 -1
  10. package/dist-cli/chunks/{chunk-UCKGFOMN.js → chunk-3NEAT5UU.js} +2 -2
  11. package/dist-cli/chunks/{chunk-Q5424DRY.js → chunk-4DUFZAOO.js} +2 -2
  12. package/dist-cli/chunks/{chunk-Q25DKLP6.js → chunk-6MKI2ZHC.js} +2 -2
  13. package/dist-cli/chunks/{chunk-QWPMILSP.js → chunk-6T6RZPWU.js} +3 -3
  14. package/dist-cli/chunks/chunk-ALNQTDSH.js +1 -0
  15. package/dist-cli/chunks/{chunk-P5ZSDO3L.js → chunk-BXZDXBUA.js} +12 -12
  16. package/dist-cli/chunks/{chunk-53Q365IC.js → chunk-C343OFIG.js} +2 -2
  17. package/dist-cli/chunks/{chunk-WOUGDBHR.js → chunk-CCKZR7BU.js} +2 -2
  18. package/dist-cli/chunks/{chunk-G5RTPKMF.js → chunk-D62KWBZG.js} +2 -2
  19. package/dist-cli/chunks/{chunk-3NSZQ5I3.js → chunk-DIWDDWNK.js} +1 -1
  20. package/dist-cli/chunks/{chunk-2C6ZEOSP.js → chunk-DSHYPD5A.js} +2 -2
  21. package/dist-cli/chunks/{chunk-OERYXTZA.js → chunk-EOEORGPV.js} +1 -1
  22. package/dist-cli/chunks/{chunk-QI2OP27K.js → chunk-F5FIYZXA.js} +2 -2
  23. package/dist-cli/chunks/{chunk-CKQD5R75.js → chunk-FGWNYFSK.js} +1 -1
  24. package/dist-cli/chunks/{chunk-N4MF6AQR.js → chunk-FRFSAMOW.js} +2 -2
  25. package/dist-cli/chunks/chunk-G2SZI7US.js +2 -0
  26. package/dist-cli/chunks/{chunk-U3SHSZHL.js → chunk-HVOCWWIV.js} +1 -1
  27. package/dist-cli/chunks/{chunk-ARNVGMSD.js → chunk-I4M7NBKY.js} +3 -3
  28. package/dist-cli/chunks/{chunk-IGNHT6DT.js → chunk-IAR2LAOG.js} +2 -2
  29. package/dist-cli/chunks/{chunk-5EJHVAMZ.js → chunk-IQJE2PBU.js} +2 -2
  30. package/dist-cli/chunks/chunk-IWEKZVXW.js +2 -0
  31. package/dist-cli/chunks/{chunk-YV4PVT5P.js → chunk-JLEZDTOL.js} +3 -3
  32. package/dist-cli/chunks/{chunk-ZJ3GSKBY.js → chunk-JLFCHU45.js} +2 -2
  33. package/dist-cli/chunks/chunk-K3A7IH77.js +1 -0
  34. package/dist-cli/chunks/{chunk-J56Q4UGK.js → chunk-K4DWGJO2.js} +2 -2
  35. package/dist-cli/chunks/{chunk-FIVCAZN5.js → chunk-LWCVNHLT.js} +2 -2
  36. package/dist-cli/chunks/{chunk-FONTNW4J.js → chunk-M4QXOCCY.js} +1 -1
  37. package/dist-cli/chunks/{chunk-BFOGODVZ.js → chunk-M5P3ULHQ.js} +2 -2
  38. package/dist-cli/chunks/chunk-QHPFVK62.js +1 -0
  39. package/dist-cli/chunks/{chunk-4JH54GEL.js → chunk-RVUQAUXP.js} +1 -1
  40. package/dist-cli/chunks/{chunk-64DJFEK2.js → chunk-S3QCEBTB.js} +2 -2
  41. package/dist-cli/chunks/{chunk-YKDHVRVG.js → chunk-TRS52XH4.js} +1 -1
  42. package/dist-cli/chunks/{chunk-VFCSRW52.js → chunk-TZFDBDEI.js} +1 -1
  43. package/dist-cli/chunks/{chunk-MMPZMFFN.js → chunk-W5ET7GSK.js} +1 -1
  44. package/dist-cli/chunks/{chunk-4GI5BITR.js → chunk-WPPSP6UG.js} +1 -1
  45. package/dist-cli/chunks/{chunk-IHPNQBHL.js → chunk-WTUKAQUP.js} +2 -2
  46. package/dist-cli/chunks/{chunk-VTVQXZYR.js → chunk-WVNXRYKC.js} +2 -2
  47. package/dist-cli/chunks/{chunk-IISL4IFJ.js → chunk-XFBHJCF3.js} +1 -1
  48. package/dist-cli/chunks/{chunk-6BCZHTH6.js → chunk-XPLBMRUI.js} +1 -1
  49. package/dist-cli/chunks/{chunk-L2BJNX2E.js → chunk-YQRBB7YC.js} +2 -2
  50. package/dist-cli/chunks/cli-version-KG6WCABJ.js +2 -0
  51. package/dist-cli/chunks/{compat-VNOXPA3U.js → compat-E6YM3TJZ.js} +3 -3
  52. package/dist-cli/chunks/{config-N2GO3RXG.js → config-5QYHIZDT.js} +2 -2
  53. package/dist-cli/chunks/{control-ZTPKRBDY.js → control-JIXJTCK4.js} +2 -2
  54. package/dist-cli/chunks/{cpu-profile-ARWAKQCS.js → cpu-profile-M3TNUJW3.js} +2 -2
  55. package/dist-cli/chunks/{daemon-4MYXXXFY.js → daemon-POLLGYA2.js} +2 -2
  56. package/dist-cli/chunks/{debug-SRBNEU4R.js → debug-P6IGEYZR.js} +3 -3
  57. package/dist-cli/chunks/{detox-YP23O47K.js → detox-HIP5JDSQ.js} +2 -2
  58. package/dist-cli/chunks/{device-4RKD3ART.js → device-GL2LVHJD.js} +2 -2
  59. package/dist-cli/chunks/{diagnose-MDNGEQ4D.js → diagnose-JGJF6QJ2.js} +2 -2
  60. package/dist-cli/chunks/drivers-4CENGVIM.js +2 -0
  61. package/dist-cli/chunks/{electron-52YSIIZW.js → electron-HO2O3U5S.js} +3 -3
  62. package/dist-cli/chunks/flow-HC36VZGL.js +2 -0
  63. package/dist-cli/chunks/help-57FSVG47.js +2 -0
  64. package/dist-cli/chunks/{hints-3I7TU3SW.js → hints-K5KHWU2I.js} +2 -2
  65. package/dist-cli/chunks/{home-paths-IBLVLRBK.js → home-paths-VTUAIJ4X.js} +2 -2
  66. package/dist-cli/chunks/{inspect-URZKK2O7.js → inspect-5QTZ4446.js} +38 -38
  67. package/dist-cli/chunks/install-QHY443P7.js +2 -0
  68. package/dist-cli/chunks/{install-desktop-UTRYCIC4.js → install-desktop-P5IOBTJA.js} +3 -3
  69. package/dist-cli/chunks/{keys-G44ZUQPI.js → keys-H65MGEIF.js} +2 -2
  70. package/dist-cli/chunks/{launch-KFJ5JYJ3.js → launch-LGV3G4IE.js} +3 -3
  71. package/dist-cli/chunks/{login-XMJZWV32.js → login-SXC6PXZA.js} +4 -4
  72. package/dist-cli/chunks/{logout-UCTG6KKE.js → logout-JQVXXJQJ.js} +2 -2
  73. package/dist-cli/chunks/{maestro-QXGQ4PVN.js → maestro-LLK45LHK.js} +2 -2
  74. package/dist-cli/chunks/{preview-FO5A3WHP.js → preview-PCHLQQWW.js} +2 -2
  75. package/dist-cli/chunks/{profile-FOM2Q6ZB.js → profile-5SUWLDAA.js} +2 -2
  76. package/dist-cli/chunks/{react-YRVJNO5O.js → react-ASFY75YW.js} +2 -2
  77. package/dist-cli/chunks/{record-D3KCAA2Z.js → record-NYEORAUL.js} +2 -2
  78. package/dist-cli/chunks/runtime-KZJNKYOB.js +2 -0
  79. package/dist-cli/chunks/{runtime-delivery-KCIHX2BK.js → runtime-delivery-YQVEY753.js} +2 -2
  80. package/dist-cli/chunks/{screenshot-YDMCOI47.js → screenshot-GCT4HM3M.js} +2 -2
  81. package/dist-cli/chunks/{screenshot-mode-TRG2F27T.js → screenshot-mode-AV2UYPI2.js} +2 -2
  82. package/dist-cli/chunks/{screenshots-US7T7ADG.js → screenshots-25JTW3MK.js} +2 -2
  83. package/dist-cli/chunks/{server-C7ZKVYEN.js → server-EMV5ZU3B.js} +2 -2
  84. package/dist-cli/chunks/setup-repo-MHZ7ELJO.js +2 -0
  85. package/dist-cli/chunks/{skills-AECFWJY6.js → skills-2MLJI75W.js} +2 -2
  86. package/dist-cli/chunks/{start-ZGWAKDNC.js → start-4MINIBCZ.js} +4 -4
  87. package/dist-cli/chunks/store-NKMSNUBC.js +2 -0
  88. package/dist-cli/chunks/telemetry-IJO3ZRR5.js +2 -0
  89. package/dist-cli/chunks/{test-2SYSK5H4.js → test-662YO2IZ.js} +3 -3
  90. package/dist-cli/chunks/{three-mode-YAKLIIN5.js → three-mode-VPDWTIYX.js} +2 -2
  91. package/dist-cli/chunks/{timeline-NROKUQ5E.js → timeline-4UOJQCTI.js} +2 -2
  92. package/dist-cli/chunks/{upgrade-ZZARTNNC.js → upgrade-NV4PNXNY.js} +2 -2
  93. package/dist-cli/chunks/upload-AJURIKDZ.js +2 -0
  94. package/dist-cli/chunks/web-6VVCC7QO.js +2 -0
  95. package/dist-cli/chunks/{what-happened-75XRWASG.js → what-happened-C7OMH2CO.js} +2 -2
  96. package/dist-cli/chunks/{whoami-MC6HJI5T.js → whoami-PO5M2KCL.js} +2 -2
  97. package/dist-lib/agent-daemon-client.cjs +1 -1
  98. package/dist-lib/agent-events.cjs +1 -1
  99. package/dist-lib/agent-sessions.cjs +1 -1
  100. package/dist-lib/attached-projects.cjs +1 -1
  101. package/dist-lib/auth/shared-session.cjs +1 -1
  102. package/dist-lib/backend-origin.cjs +1 -1
  103. package/dist-lib/beta.cjs +1 -1
  104. package/dist-lib/beta.mjs +1 -1
  105. package/dist-lib/bridge-constants.cjs +1 -1
  106. package/dist-lib/cli-constants.cjs +1 -1
  107. package/dist-lib/config.cjs +1 -1
  108. package/dist-lib/detox/index.cjs +1 -1
  109. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  110. package/dist-lib/home-paths.cjs +1 -1
  111. package/dist-lib/host/bridge-host.cjs +1 -1
  112. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  113. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  114. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  115. package/dist-lib/host/websocket-proxy.cjs +1 -1
  116. package/dist-lib/index.cjs +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/demo-app-registry.cjs +1 -1
  121. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  122. package/dist-lib/skills.cjs +18 -4
  123. package/dist-lib/vite.cjs +1 -1
  124. package/package.json +1 -1
  125. package/dist-cli/chunks/auto-bootstrap-EAQHPWBH.js +0 -2
  126. package/dist-cli/chunks/beta-SWIGZTS7.js +0 -2
  127. package/dist-cli/chunks/chunk-6DAMSZFH.js +0 -1
  128. package/dist-cli/chunks/chunk-IFDIEAVZ.js +0 -1
  129. package/dist-cli/chunks/chunk-ISEYLN2N.js +0 -2
  130. package/dist-cli/chunks/chunk-NOD6DFSL.js +0 -2
  131. package/dist-cli/chunks/chunk-OE4Z6WGR.js +0 -1
  132. package/dist-cli/chunks/cli-version-3YXCAPTC.js +0 -2
  133. package/dist-cli/chunks/drivers-MQCDXQRI.js +0 -2
  134. package/dist-cli/chunks/flow-HT24JTDR.js +0 -2
  135. package/dist-cli/chunks/help-IU4RMZGO.js +0 -2
  136. package/dist-cli/chunks/install-3MSXLVMF.js +0 -2
  137. package/dist-cli/chunks/runtime-TIWRPSKS.js +0 -2
  138. package/dist-cli/chunks/setup-repo-HJQLCO7W.js +0 -2
  139. package/dist-cli/chunks/store-VTNB7WEH.js +0 -2
  140. package/dist-cli/chunks/telemetry-V6K2OLDO.js +0 -2
  141. package/dist-cli/chunks/upload-CYB6HOFW.js +0 -2
  142. package/dist-cli/chunks/web-KHUEEKAW.js +0 -2
@@ -1,14 +1,14 @@
1
- /*! sootsim v0.1.92 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as V}from"./chunk-N7GBP6IK.js";import{a as ft,b as gt}from"./chunk-VFCSRW52.js";import{a as Ue,h as he,k as oe}from"./chunk-G5RTPKMF.js";import{b as yt,c as ht,i as bt}from"./chunk-Q5424DRY.js";import"./chunk-5EJHVAMZ.js";import{a as Q,b as E,c as C,d as Fe,e as re,f as X,g as ye,h as ue,i as ut,j as mt,k as Ae,l as pt}from"./chunk-WOUGDBHR.js";import{B as lt,D as le,E as ct,K as dt,a as ge,b as Ke,c as ze,d as Ye,e as Ge,f as Xe,g as Ve,h as Ie,i as Ne,n as _e,o as Qe,p as Ze,q as et,r as tt,s as ot,t as st,u as nt,v as rt,w as it,x as at}from"./chunk-P5ZSDO3L.js";import{c as Le,e as qe,f as We,g as He,h as Me}from"./chunk-ZJ3GSKBY.js";import{b as Je}from"./chunk-4GI5BITR.js";import"./chunk-2C6ZEOSP.js";import"./chunk-YKDHVRVG.js";import"./chunk-6DAMSZFH.js";import"./chunk-N4MF6AQR.js";import"./chunk-OJSVBBKS.js";import{a as Be}from"./chunk-CKQD5R75.js";import{a as ke,c as Te}from"./chunk-6BCZHTH6.js";import{a as je}from"./chunk-ISEYLN2N.js";import"./chunk-NOD6DFSL.js";import"./chunk-FONTNW4J.js";import"./chunk-OERYXTZA.js";import{existsSync as oo,mkdirSync as so,readFileSync as no,rmSync as wt,writeFileSync as ro}from"fs";import{tmpdir as io}from"os";import{dirname as ao,join as lo,resolve as co}from"path";var me=1,uo="SOOTSIM_INSPECT_NOTICE_PATH",mo=300*1e3,po=15e3;function xt(){return co(process.env[uo]||lo(io(),"sootsim-inspect-notice-state.json"))}function fo(o,c){return Object.fromEntries(Object.entries(o).filter(([,i])=>typeof i?.signature=="string"&&Number.isFinite(i?.updatedAt)&&c-i.updatedAt<=mo))}function go(o){let c=xt();if(!oo(c))return{version:me,entries:{}};try{let i=JSON.parse(no(c,"utf8"));return i.version!==me||!i.entries||typeof i.entries!="object"?(wt(c,{force:!0}),{version:me,entries:{}}):{version:me,entries:fo(i.entries,o)}}catch{return wt(c,{force:!0}),{version:me,entries:{}}}}function yo(o){let c=xt();so(ao(c),{recursive:!0}),ro(c,JSON.stringify(o,null,2)+`
3
- `)}function ho(o,c){let i=c.trim()||"default";return`${o}:${i}`}function Pe(o,c,i,l={}){let f=l.nowMs??Date.now(),a=l.cooldownMs??po,g=go(f),b=ho(o,c),k=g.entries[b];return k&&k.signature===i&&f-k.updatedAt<a?!1:(g.entries[b]={signature:i,updatedAt:f},yo(g),!0)}async function $t(o,c={args:[]}){let i=await Ke(o);if(E(c.args)){C(i);return}console.log(` nodes: ${i.nodes}`)}function Oe(o,c){let i=o.indexOf(c);return i>=0&&i+1<o.length?o[i+1]:null}async function vt(o){let{bridge:c,args:i,positional:l}=o,f=i.includes("--verbose")||i.includes("-v"),a=E(i),g=f&&!a,b=i.includes("--watch")||i.includes("-w"),k=1e3,M=i.includes("--compact"),h=i.includes("--no-xy"),S=i.includes("--no-clipped"),F=i.includes("--include-occluded"),T=Oe(i,"--testid-like"),R=Oe(i,"--only"),J=Oe(i,"--subtree"),u=l[1]&&!l[1].startsWith("-")?l[1]:void 0,Y=u?/[*?]/.test(u):!1,j=!Y&&!R?u:void 0,D=R??(Y?u:void 0),Z=async()=>{await ye(c,{verbose:g});let $=await Ge(c,{describe:!0,verbose:f,filter:j||"",testIdLike:T||void 0,onlyGlob:D||void 0,subtreeRoot:J||void 0,compact:M,hideXy:h,includeOccluded:F}),I=$?.tree,W=$?.shell,L=$?.keyboard;if(a){C({shell:W,tree:I??"",keyboard:L});return}if(W&&typeof W=="object"){let B=[W.state?`state=${W.state}`:null,W.activeApp?`app=${W.activeApp}`:null,W.showSwitcher?"switcher":null,W.switcherPhase&&W.switcherPhase!=="idle"?`phase=${W.switcherPhase}`:null].filter(Boolean);B.length>0&&console.log(` shell: ${B.join(" ")}`)}if(typeof I=="string"&&I.startsWith("__SUBTREE_NOT_FOUND__:")){let B=I.slice(22);console.log(` subtree root not found: ${B}`),V("subtree-root-not-found",B);return}if(!I){let B=$?.nodeCount??0;console.log(" no matching nodes found"),!(j||T||D||J)&&B<10&&V("app-still-loading",B);return}let z=I,te=0;if(S&&typeof z=="string"){let B=z.split(`
1
+ /*! sootsim v0.1.93 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as V}from"./chunk-352UPR2W.js";import{a as gt,b as yt}from"./chunk-TZFDBDEI.js";import{a as Ue,h as he,k as oe}from"./chunk-D62KWBZG.js";import{b as ht,c as bt,i as wt}from"./chunk-4DUFZAOO.js";import"./chunk-IQJE2PBU.js";import{a as Q,b as E,c as C,d as _e,e as re,f as X,g as ye,h as ue,i as mt,j as pt,k as Ae,l as ft}from"./chunk-CCKZR7BU.js";import{C as ct,E as le,F as dt,L as ut,a as ge,b as Ke,c as ze,d as Ye,e as Ge,f as Xe,g as Ve,h as Qe,i as Ie,j as Ne,o as Fe,p as Ze,q as et,r as tt,s as ot,t as st,u as nt,v as rt,w as it,x as at,y as lt}from"./chunk-BXZDXBUA.js";import{c as Le,e as qe,f as We,g as He,h as Me}from"./chunk-JLFCHU45.js";import{b as Je}from"./chunk-WPPSP6UG.js";import"./chunk-DSHYPD5A.js";import"./chunk-TRS52XH4.js";import"./chunk-ALNQTDSH.js";import"./chunk-FRFSAMOW.js";import"./chunk-3IFMI2MH.js";import{a as Be}from"./chunk-FGWNYFSK.js";import{a as ke,c as Te}from"./chunk-XPLBMRUI.js";import{a as je}from"./chunk-G2SZI7US.js";import"./chunk-IWEKZVXW.js";import"./chunk-M4QXOCCY.js";import"./chunk-EOEORGPV.js";import{existsSync as so,mkdirSync as no,readFileSync as ro,rmSync as xt,writeFileSync as io}from"fs";import{tmpdir as ao}from"os";import{dirname as lo,join as co,resolve as uo}from"path";var me=1,mo="SOOTSIM_INSPECT_NOTICE_PATH",po=300*1e3,fo=15e3;function $t(){return uo(process.env[mo]||co(ao(),"sootsim-inspect-notice-state.json"))}function go(o,c){return Object.fromEntries(Object.entries(o).filter(([,i])=>typeof i?.signature=="string"&&Number.isFinite(i?.updatedAt)&&c-i.updatedAt<=po))}function yo(o){let c=$t();if(!so(c))return{version:me,entries:{}};try{let i=JSON.parse(ro(c,"utf8"));return i.version!==me||!i.entries||typeof i.entries!="object"?(xt(c,{force:!0}),{version:me,entries:{}}):{version:me,entries:go(i.entries,o)}}catch{return xt(c,{force:!0}),{version:me,entries:{}}}}function ho(o){let c=$t();no(lo(c),{recursive:!0}),io(c,JSON.stringify(o,null,2)+`
3
+ `)}function bo(o,c){let i=c.trim()||"default";return`${o}:${i}`}function Pe(o,c,i,l={}){let f=l.nowMs??Date.now(),a=l.cooldownMs??fo,g=yo(f),b=bo(o,c),k=g.entries[b];return k&&k.signature===i&&f-k.updatedAt<a?!1:(g.entries[b]={signature:i,updatedAt:f},ho(g),!0)}async function vt(o,c={args:[]}){let i=await ze(o);if(E(c.args)){C(i);return}console.log(` nodes: ${i.nodes}`)}function Oe(o,c){let i=o.indexOf(c);return i>=0&&i+1<o.length?o[i+1]:null}async function St(o){let{bridge:c,args:i,positional:l}=o,f=i.includes("--verbose")||i.includes("-v"),a=E(i),g=f&&!a,b=i.includes("--watch")||i.includes("-w"),k=1e3,M=i.includes("--compact"),h=i.includes("--no-xy"),S=i.includes("--no-clipped"),_=i.includes("--include-occluded"),T=Oe(i,"--testid-like"),R=Oe(i,"--only"),J=Oe(i,"--subtree"),u=l[1]&&!l[1].startsWith("-")?l[1]:void 0,Y=u?/[*?]/.test(u):!1,j=!Y&&!R?u:void 0,D=R??(Y?u:void 0),Z=async()=>{await ye(c,{verbose:g});let $=await Xe(c,{describe:!0,verbose:f,filter:j||"",testIdLike:T||void 0,onlyGlob:D||void 0,subtreeRoot:J||void 0,compact:M,hideXy:h,includeOccluded:_}),I=$?.tree,W=$?.shell,L=$?.keyboard;if(a){C({shell:W,tree:I??"",keyboard:L});return}if(W&&typeof W=="object"){let B=[W.state?`state=${W.state}`:null,W.activeApp?`app=${W.activeApp}`:null,W.showSwitcher?"switcher":null,W.switcherPhase&&W.switcherPhase!=="idle"?`phase=${W.switcherPhase}`:null].filter(Boolean);B.length>0&&console.log(` shell: ${B.join(" ")}`)}if(typeof I=="string"&&I.startsWith("__SUBTREE_NOT_FOUND__:")){let B=I.slice(22);console.log(` subtree root not found: ${B}`),V("subtree-root-not-found",B);return}if(!I){let B=$?.nodeCount??0;console.log(" no matching nodes found"),!(j||T||D||J)&&B<10&&V("app-still-loading",B);return}let z=I,te=0;if(S&&typeof z=="string"){let B=z.split(`
4
4
  `),ae=[];for(let ce of B){if(ce.includes("(clipped:")){te+=1;continue}ae.push(ce)}z=ae.join(`
5
5
  `)}console.log(z),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let ne=j||T||D||J;if((j||T||D)&&!b&&V("describe-filter-context"),!ne&&!b&&I.split(`
6
6
  `).length>=80&&V("describe-use-filters"),L&&L.visible){let B=L.spec,ae=[B?.keyboardType?`type=${B.keyboardType}`:null,B?.returnKeyType&&B.returnKeyType!=="default"?`return=${B.returnKeyType}`:null,L.mode!=="letters"?`mode=${L.mode}`:null,L.shifted?"shift":null,L.capsLock?"caps":null,B?.autoCapitalize&&B.autoCapitalize!=="sentences"?`autoCap=${B.autoCapitalize}`:null,L.accessoryBarId?`accessory=${L.accessoryBarId}`:null].filter(Boolean);console.log(`
7
7
  keyboard: ${ae.join(" ")||"visible"}`)}};if(b)for(console.log(` watching... (Ctrl+C to stop)
8
- `);;)console.clear(),await Z(),await Q(k);else await Z()}var bo=["SOOTSIM_AGENT","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function be(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let o of bo){let c=process.env[o];if(c&&c.trim()&&c!=="0")return!0}return!1}async function St(o){let{bridge:c,args:i,effectiveArgs:l,positional:f,inspectUsage:a}=o,g=$=>{let I=l.indexOf($);return I>=0&&I+1<l.length?l[I+1]:null},b=$=>l.includes($),k=g("--testid")||g("--test-id"),M=g("--role"),h=g("--type"),S=g("--text"),F=b("--pressable"),T=b("--visible"),R=b("--interactive-targets")||b("--actions"),J=!k&&!M&&!h&&!S&&!F&&!T&&!R?f[1]:null,u=S??J,Y=await Ve(c,{testId:k,role:M,type:h,text:u,pressable:F,visible:T,interactive:R});Y||(console.error(a("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:j,result:D}=Y,Z=E(i),ee=i.includes("--verbose")||i.includes("--dump");if(Z)j==="interactive-targets"&&Array.isArray(D)?C(Ie(D).map($=>({...$,tap:Ne($)}))):C(D??null);else if(Array.isArray(D))if(D.length===0){console.log(` no ${j} nodes found`);let $=await c.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof $=="number"&&$<10&&V("app-still-loading",$)}else if(j==="interactive-targets"){let $=Ie(D);console.log(` found ${$.length} interactive target${$.length===1?"":"s"} (sorted by score):`);for(let I of $.slice(0,20)){let W=I.absolutePosition?`@(${Math.round(I.absolutePosition.x)},${Math.round(I.absolutePosition.y)})`:"",L=I.layout?`${Math.round(I.layout.width)}x${Math.round(I.layout.height)}`:"?x?",z=I.text?` "${I.text.slice(0,30)}"`:"",te=I.testID?` #${I.testID}`:"",ne=I.accessibilityLabel?` \u24D8"${String(I.accessibilityLabel).slice(0,24)}"`:"",fe=I.accessibilityRole?`[${I.accessibilityRole}]`:I.type,B=Ne(I);console.log(` ${fe}${z}${ne}${te} ${L} ${W}`),console.log(` \u2192 ${B}`),ee&&console.log(Re(JSON.stringify(I,null,2)," "))}$.length>20&&console.log(` ... and ${$.length-20} more`)}else{console.log(` found ${D.length} node${D.length===1?"":"s"} (${j}):`);for(let $ of D.slice(0,20)){let I=$.absolutePosition?`@(${Math.round($.absolutePosition.x)},${Math.round($.absolutePosition.y)})`:"",W=$.layout?`${Math.round($.layout.width)}x${Math.round($.layout.height)}`:"?x?",L=$.text?` "${$.text.slice(0,30)}"`:"",z=$.testID?` #${$.testID}`:"",te=$.pressable?" (tap)":"",ne=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ne}${L}${z} ${W} ${I}${te}`),ee&&console.log(Re(JSON.stringify($,null,2)," "))}D.length>20&&console.log(` ... and ${D.length-20} more`)}else if(D==null)console.log(` not found: ${u||k||M||h||""||j}`),k&&V("wait-selector-for-missing-testid",k);else{let $=D;if($.type&&$.absolutePosition){let I=`@(${Math.round($.absolutePosition.x)},${Math.round($.absolutePosition.y)})`,W=$.layout?`${Math.round($.layout.width)}x${Math.round($.layout.height)}`:"?x?",L=$.text?` "${$.text.slice(0,40)}"`:"",z=$.testID?` #${$.testID}`:"",te=$.pressable?" (tap)":"",ne=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ne}${L}${z} ${W} ${I}${te}`),ee&&console.log(Re(JSON.stringify($,null,2)," "))}else console.log(JSON.stringify(D,null,2))}}function Re(o,c){return o.split(`
8
+ `);;)console.clear(),await Z(),await Q(k);else await Z()}var wo=["SOOTSIM_AGENT","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function be(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let o of wo){let c=process.env[o];if(c&&c.trim()&&c!=="0")return!0}return!1}async function kt(o){let{bridge:c,args:i,effectiveArgs:l,positional:f,inspectUsage:a}=o,g=$=>{let I=l.indexOf($);return I>=0&&I+1<l.length?l[I+1]:null},b=$=>l.includes($),k=g("--testid")||g("--test-id"),M=g("--role"),h=g("--type"),S=g("--text"),_=b("--pressable"),T=b("--visible"),R=b("--interactive-targets")||b("--actions"),J=!k&&!M&&!h&&!S&&!_&&!T&&!R?f[1]:null,u=S??J,Y=await Qe(c,{testId:k,role:M,type:h,text:u,pressable:_,visible:T,interactive:R});Y||(console.error(a("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:j,result:D}=Y,Z=E(i),ee=i.includes("--verbose")||i.includes("--dump");if(Z)j==="interactive-targets"&&Array.isArray(D)?C(Ie(D).map($=>({...$,tap:Ne($)}))):C(D??null);else if(Array.isArray(D))if(D.length===0){console.log(` no ${j} nodes found`);let $=await c.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof $=="number"&&$<10&&V("app-still-loading",$)}else if(j==="interactive-targets"){let $=Ie(D);console.log(` found ${$.length} interactive target${$.length===1?"":"s"} (sorted by score):`);for(let I of $.slice(0,20)){let W=I.absolutePosition?`@(${Math.round(I.absolutePosition.x)},${Math.round(I.absolutePosition.y)})`:"",L=I.layout?`${Math.round(I.layout.width)}x${Math.round(I.layout.height)}`:"?x?",z=I.text?` "${I.text.slice(0,30)}"`:"",te=I.testID?` #${I.testID}`:"",ne=I.accessibilityLabel?` \u24D8"${String(I.accessibilityLabel).slice(0,24)}"`:"",fe=I.accessibilityRole?`[${I.accessibilityRole}]`:I.type,B=Ne(I);console.log(` ${fe}${z}${ne}${te} ${L} ${W}`),console.log(` \u2192 ${B}`),ee&&console.log(Re(JSON.stringify(I,null,2)," "))}$.length>20&&console.log(` ... and ${$.length-20} more`)}else{console.log(` found ${D.length} node${D.length===1?"":"s"} (${j}):`);for(let $ of D.slice(0,20)){let I=$.absolutePosition?`@(${Math.round($.absolutePosition.x)},${Math.round($.absolutePosition.y)})`:"",W=$.layout?`${Math.round($.layout.width)}x${Math.round($.layout.height)}`:"?x?",L=$.text?` "${$.text.slice(0,30)}"`:"",z=$.testID?` #${$.testID}`:"",te=$.pressable?" (tap)":"",ne=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ne}${L}${z} ${W} ${I}${te}`),ee&&console.log(Re(JSON.stringify($,null,2)," "))}D.length>20&&console.log(` ... and ${D.length-20} more`)}else if(D==null)console.log(` not found: ${u||k||M||h||""||j}`),k&&V("wait-selector-for-missing-testid",k);else{let $=D;if($.type&&$.absolutePosition){let I=`@(${Math.round($.absolutePosition.x)},${Math.round($.absolutePosition.y)})`,W=$.layout?`${Math.round($.layout.width)}x${Math.round($.layout.height)}`:"?x?",L=$.text?` "${$.text.slice(0,40)}"`:"",z=$.testID?` #${$.testID}`:"",te=$.pressable?" (tap)":"",ne=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ne}${L}${z} ${W} ${I}${te}`),ee&&console.log(Re(JSON.stringify($,null,2)," "))}else console.log(JSON.stringify(D,null,2))}}function Re(o,c){return o.split(`
9
9
  `).map(i=>c+i).join(`
10
- `)}async function kt(o,c={}){let i=await lt(o);if("error"in i&&(console.error(i.error),process.exit(1)),c.json){console.log(JSON.stringify(i,null,2));return}let{visible:l,spec:f,mode:a,shifted:g,capsLock:b,accessoryBarId:k}=i,M=[];M.push(`keyboard: ${l?"visible":"hidden"}`),f?(M.push(` type: ${f.keyboardType}`),M.push(` returnKey: ${f.returnKeyType}`),M.push(` autoCap: ${f.autoCapitalize}`),M.push(` autoCorrect: ${f.autoCorrect?"on":"off"}`),M.push(` appearance: ${f.keyboardAppearance}`),f.secureTextEntry&&M.push(" secureTextEntry: true"),f.enablesReturnKeyAutomatically&&M.push(` return: ${f.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):M.push(" spec: <none> (shown via dev-tools with no TextInput)"),M.push(` mode: ${a}${g?" (shifted)":""}${b?" (caps)":""}`),k&&M.push(` accessoryBar: ${k}`),console.log(M.join(`
11
- `))}async function Tt(o){let c=await o.bridge.listSims(),i=o.args.includes("--all"),l=o.args.find((b,k)=>o.args[k-1]==="--bundle"),f=o.args.find((b,k)=>o.args[k-1]==="--app-port"),a=o.args.includes("--primary"),g=c.filter(b=>!(a&&!b.isPrimary||l&&!(b.url??"").includes(l)||f&&!(b.url??"").includes(`/rn/${f}`)||!i&&!l&&!f&&!a&&!(b.url&&(b.url.includes("bundle=")||b.url.includes("/index.bundle")))&&b.id!==o.simId));if(E(o.args)){C(g.map(b=>({...b,active:b.id===o.simId})));return}bt(g,o.simId),g.length<c.length&&!E(o.args)&&console.log(` (${c.length-g.length} more hidden \u2014 pass --all to show)`)}function ie(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/1024/1024).toFixed(1)}MB`}function we(o,c){return c<=0?"?":`${(o/c*100).toFixed(0)}%`}async function Mt(o,c={args:[]}){let i=await dt(o);if(E(c.args)){C(i);return}if(console.log(" memory:"),i.imageLoader){let l=i.imageLoader;console.log(" image-loader cache"),console.log(` entries: ${l.cacheEntries} / ${l.cacheMaxEntries} (${we(l.cacheEntries,l.cacheMaxEntries)})`),console.log(` pixel bytes: ${ie(l.cachePixelBytes)} / ${ie(l.cachePixelBudget)} (${we(l.cachePixelBytes,l.cachePixelBudget)})`),console.log(` pending: ${l.pendingFetches} fetches, ${l.pendingBytes} bytes`),console.log(` failed uris: ${l.failedUris}`),console.log(` snapshots: ${l.snapshots}`),console.log(` camera frames: ${l.cameraFrames}`)}else console.log(" image-loader cache: not available (engine pre-rebuild?)");if(i.workerHeap){let l=i.workerHeap;console.log(" worker heap (chrome only)"),console.log(` used: ${ie(l.usedJSHeapSize)} / ${ie(l.jsHeapSizeLimit)} (${we(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ie(l.totalJSHeapSize)}`)}if(i.hostHeap){let l=i.hostHeap;console.log(" host heap (chrome only)"),console.log(` used: ${ie(l.usedJSHeapSize)} / ${ie(l.jsHeapSizeLimit)} (${we(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ie(l.totalJSHeapSize)}`)}}function pe(o){let c=o.indexOf("--testid");if(c>=0&&o[c+1])return{mode:"testid",value:o[c+1]};let i=o.indexOf("--test-id");if(i>=0&&o[i+1])return{mode:"testid",value:o[i+1]};let l=o.indexOf("--text");return l>=0&&o[l+1]?{mode:"text",value:o[l+1]}:null}async function xe(o,c){let i=JSON.stringify(c.value),l=c.mode==="testid"?`(await t.findByTestId(${i})) || (await t.findById(${i}))`:`await t.findByText(${i})`;return await o.send({type:"evaluate",code:`(async () => {
10
+ `)}async function Tt(o,c={}){let i=await ct(o);if("error"in i&&(console.error(i.error),process.exit(1)),c.json){console.log(JSON.stringify(i,null,2));return}let{visible:l,spec:f,mode:a,shifted:g,capsLock:b,accessoryBarId:k}=i,M=[];M.push(`keyboard: ${l?"visible":"hidden"}`),f?(M.push(` type: ${f.keyboardType}`),M.push(` returnKey: ${f.returnKeyType}`),M.push(` autoCap: ${f.autoCapitalize}`),M.push(` autoCorrect: ${f.autoCorrect?"on":"off"}`),M.push(` appearance: ${f.keyboardAppearance}`),f.secureTextEntry&&M.push(" secureTextEntry: true"),f.enablesReturnKeyAutomatically&&M.push(` return: ${f.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):M.push(" spec: <none> (shown via dev-tools with no TextInput)"),M.push(` mode: ${a}${g?" (shifted)":""}${b?" (caps)":""}`),k&&M.push(` accessoryBar: ${k}`),console.log(M.join(`
11
+ `))}async function Mt(o){let c=await o.bridge.listSims(),i=o.args.includes("--all"),l=o.args.find((b,k)=>o.args[k-1]==="--bundle"),f=o.args.find((b,k)=>o.args[k-1]==="--app-port"),a=o.args.includes("--primary"),g=c.filter(b=>!(a&&!b.isPrimary||l&&!(b.url??"").includes(l)||f&&!(b.url??"").includes(`/rn/${f}`)||!i&&!l&&!f&&!a&&!(b.url&&(b.url.includes("bundle=")||b.url.includes("/index.bundle")))&&b.id!==o.simId));if(E(o.args)){C(g.map(b=>({...b,active:b.id===o.simId})));return}wt(g,o.simId),g.length<c.length&&!E(o.args)&&console.log(` (${c.length-g.length} more hidden \u2014 pass --all to show)`)}function ie(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/1024/1024).toFixed(1)}MB`}function we(o,c){return c<=0?"?":`${(o/c*100).toFixed(0)}%`}async function It(o,c={args:[]}){let i=await ut(o);if(E(c.args)){C(i);return}if(console.log(" memory:"),i.imageLoader){let l=i.imageLoader;console.log(" image-loader cache"),console.log(` entries: ${l.cacheEntries} / ${l.cacheMaxEntries} (${we(l.cacheEntries,l.cacheMaxEntries)})`),console.log(` pixel bytes: ${ie(l.cachePixelBytes)} / ${ie(l.cachePixelBudget)} (${we(l.cachePixelBytes,l.cachePixelBudget)})`),console.log(` pending: ${l.pendingFetches} fetches, ${l.pendingBytes} bytes`),console.log(` failed uris: ${l.failedUris}`),console.log(` snapshots: ${l.snapshots}`),console.log(` camera frames: ${l.cameraFrames}`)}else console.log(" image-loader cache: not available (engine pre-rebuild?)");if(i.workerHeap){let l=i.workerHeap;console.log(" worker heap (chrome only)"),console.log(` used: ${ie(l.usedJSHeapSize)} / ${ie(l.jsHeapSizeLimit)} (${we(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ie(l.totalJSHeapSize)}`)}if(i.hostHeap){let l=i.hostHeap;console.log(" host heap (chrome only)"),console.log(` used: ${ie(l.usedJSHeapSize)} / ${ie(l.jsHeapSizeLimit)} (${we(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ie(l.totalJSHeapSize)}`)}}function pe(o){let c=o.indexOf("--testid");if(c>=0&&o[c+1])return{mode:"testid",value:o[c+1]};let i=o.indexOf("--test-id");if(i>=0&&o[i+1])return{mode:"testid",value:o[i+1]};let l=o.indexOf("--text");return l>=0&&o[l+1]?{mode:"text",value:o[l+1]}:null}async function xe(o,c){let i=JSON.stringify(c.value),l=c.mode==="testid"?`(await t.findByTestId(${i})) || (await t.findById(${i}))`:`await t.findByText(${i})`;return await o.send({type:"evaluate",code:`(async () => {
12
12
  const t = window.__sootsimTest
13
13
  if (!t) return null
14
14
  const n = ${l}
@@ -33,15 +33,15 @@ import{a as V}from"./chunk-N7GBP6IK.js";import{a as ft,b as gt}from"./chunk-VFCS
33
33
  text: ${JSON.stringify(c.mode==="text")} ? ${i} : (n.text ?? n.accessibilityLabel ?? null),
34
34
  type: n.type ?? null,
35
35
  }
36
- })()`})??null}async function It(o,c={}){let{nav:i,keyboard:l,shell:f}=await ct(o);if(c.json){console.log(JSON.stringify({shell:f??null,nav:i,keyboard:l},null,2));return}let a=[];if(f){let g=f.activeApp??f.state??"<none>",b=f.showSwitcher?" (app switcher open)":"",k=typeof f.launchProgress=="number"&&f.launchProgress<.98?` launching (${Math.round(f.launchProgress*100)}%)`:"";a.push(`shell: ${g}${b}${k}`)}else a.push("shell: <unavailable>");if(i){let g=i.transitionPhase!=="idle"?` (${i.transitionPhase}, ${i.activeTransitionCount} active)`:"";if(a.push(`nav: phase=${i.transitionPhase}${g}`),i.screens.length===0)a.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let b of i.screens){let k=b.isActive?"\u25B6":" ",M=b.routeName?` ${b.routeName}`:"",h=b.headerHeight>0?` header=${b.headerHeight}`:"",S=b.largeTitleState&&b.largeTitleState!=="expanded"?` large-title=${b.largeTitleState}`:"";a.push(` ${k} #${b.id}${M}${h}${S}`)}}else a.push("nav: <runtime not available>");if(l&&l.visible){let g=l.spec?.keyboardType??"default",b=l.spec?.returnKeyType??"default";a.push(`keyboard: visible (${g}, return=${b}, mode=${l.mode??"?"})`)}else a.push("keyboard: hidden");console.log(a.join(`
37
- `))}async function Nt(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1])*1e3:3e3,a=i.includes("--strict"),{elapsed:g,settled:b}=await oe({bridge:c,maxMs:f,strict:a});console.log(b?` settled in ${g}ms`:` timed out after ${g}ms (may still be animating)`)}async function _t(o){let c=o.positional[1]?Number(o.positional[1]):.5;(!Number.isFinite(c)||c<0)&&(console.error(o.inspectUsage("sleep","[seconds]")),process.exit(1)),await Q(c*1e3),console.log(` slept ${c}s`)}async function Ft(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1]):5,{tree:a}=await ze(c,f);if(E(i)){C({depth:f,tree:a??null});return}console.log(typeof a=="string"?a:JSON.stringify(a,null,2))}async function At(o,c={args:[]}){let i=await Ye(o);if(E(c.args)){C(i);return}console.log(i.url)}async function Pt(o){let{wsPort:c,commandTimeoutMs:i,simId:l,simIdSource:f,positional:a}=o,g=a[1]?Number(a[1]):30,b=Math.max(1e3,(Number.isFinite(g)?g:30)*1e3),k=Math.max(1,Math.ceil(b/500));console.log(" waiting for sim reconnect...");let M=await ut(c,i,l,{attempts:k,simIdSource:f});M||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),M.bridge.close(),he({source:"inspect wait",step:{wait:b},summary:`wait ${Math.round(b/1e3)}s`}),console.log(` ready: ${M.count} nodes`)}var Ot=new Set(["app-launch","toast","keyboard","screen","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function $e(o,c){let i=o.indexOf(c);if(i>=0&&i+1<o.length)return o[i+1]}function wo(o,c){if(!c.filter&&!c.equals)return!0;let i=o.data,l=[];if(i&&typeof i=="object")for(let a of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let g=i[a];typeof g=="string"&&g.length>0&&l.push(g)}let f=l.join(" ");return c.equals?l.some(a=>a===c.equals):c.filter?f.toLowerCase().includes(c.filter.toLowerCase()):!0}async function Rt(o){let{bridge:c,args:i,positional:l,inspectUsage:f}=o,a=l[1];a||(console.error(f("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),Ot.has(a)||console.error(` warning: '${a}' is not a known timeline kind \u2014 waiting anyway. known: ${[...Ot].sort().join(", ")}`);let g=$e(i,"--max-ms"),b=g&&Number.isFinite(Number(g))?Math.max(100,Number(g)):5e3,k=$e(i,"--filter"),M=$e(i,"--equals"),h=$e(i,"--since")??"now",S=i.includes("--json"),F=Date.now(),T=F+b,R=200,J=F;for(;Date.now()<T;){let Y={kinds:[a],since:h==="cursor"?void 0:J,limit:50},j=await c.send({type:"evaluate",code:`(async () => {
36
+ })()`})??null}async function Nt(o,c={}){let{nav:i,keyboard:l,shell:f}=await dt(o);if(c.json){console.log(JSON.stringify({shell:f??null,nav:i,keyboard:l},null,2));return}let a=[];if(f){let g=f.activeApp??f.state??"<none>",b=f.showSwitcher?" (app switcher open)":"",k=typeof f.launchProgress=="number"&&f.launchProgress<.98?` launching (${Math.round(f.launchProgress*100)}%)`:"";a.push(`shell: ${g}${b}${k}`)}else a.push("shell: <unavailable>");if(i){let g=i.transitionPhase!=="idle"?` (${i.transitionPhase}, ${i.activeTransitionCount} active)`:"";if(a.push(`nav: phase=${i.transitionPhase}${g}`),i.screens.length===0)a.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let b of i.screens){let k=b.isActive?"\u25B6":" ",M=b.routeName?` ${b.routeName}`:"",h=b.headerHeight>0?` header=${b.headerHeight}`:"",S=b.largeTitleState&&b.largeTitleState!=="expanded"?` large-title=${b.largeTitleState}`:"";a.push(` ${k} #${b.id}${M}${h}${S}`)}}else a.push("nav: <runtime not available>");if(l&&l.visible){let g=l.spec?.keyboardType??"default",b=l.spec?.returnKeyType??"default";a.push(`keyboard: visible (${g}, return=${b}, mode=${l.mode??"?"})`)}else a.push("keyboard: hidden");console.log(a.join(`
37
+ `))}async function Ft(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1])*1e3:3e3,a=i.includes("--strict"),{elapsed:g,settled:b}=await oe({bridge:c,maxMs:f,strict:a});console.log(b?` settled in ${g}ms`:` timed out after ${g}ms (may still be animating)`)}async function _t(o){let c=o.positional[1]?Number(o.positional[1]):.5;(!Number.isFinite(c)||c<0)&&(console.error(o.inspectUsage("sleep","[seconds]")),process.exit(1)),await Q(c*1e3),console.log(` slept ${c}s`)}async function At(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1]):5,{tree:a}=await Ye(c,f);if(E(i)){C({depth:f,tree:a??null});return}console.log(typeof a=="string"?a:JSON.stringify(a,null,2))}async function Pt(o,c={args:[]}){let i=await Ge(o);if(E(c.args)){C(i);return}console.log(i.url)}async function Ot(o){let{wsPort:c,commandTimeoutMs:i,simId:l,simIdSource:f,positional:a}=o,g=a[1]?Number(a[1]):30,b=Math.max(1e3,(Number.isFinite(g)?g:30)*1e3),k=Math.max(1,Math.ceil(b/500));console.log(" waiting for sim reconnect...");let M=await mt(c,i,l,{attempts:k,simIdSource:f});M||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),M.bridge.close(),he({source:"inspect wait",step:{wait:b},summary:`wait ${Math.round(b/1e3)}s`}),console.log(` ready: ${M.count} nodes`)}var Rt=new Set(["app-launch","toast","keyboard","screen","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function $e(o,c){let i=o.indexOf(c);if(i>=0&&i+1<o.length)return o[i+1]}function xo(o,c){if(!c.filter&&!c.equals)return!0;let i=o.data,l=[];if(i&&typeof i=="object")for(let a of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let g=i[a];typeof g=="string"&&g.length>0&&l.push(g)}let f=l.join(" ");return c.equals?l.some(a=>a===c.equals):c.filter?f.toLowerCase().includes(c.filter.toLowerCase()):!0}async function Et(o){let{bridge:c,args:i,positional:l,inspectUsage:f}=o,a=l[1];a||(console.error(f("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),Rt.has(a)||console.error(` warning: '${a}' is not a known timeline kind \u2014 waiting anyway. known: ${[...Rt].sort().join(", ")}`);let g=$e(i,"--max-ms"),b=g&&Number.isFinite(Number(g))?Math.max(100,Number(g)):5e3,k=$e(i,"--filter"),M=$e(i,"--equals"),h=$e(i,"--since")??"now",S=i.includes("--json"),_=Date.now(),T=_+b,R=200,J=_;for(;Date.now()<T;){let Y={kinds:[a],since:h==="cursor"?void 0:J,limit:50},j=await c.send({type:"evaluate",code:`(async () => {
38
38
  const t = window.SootSim?.bridges?.timeline
39
39
  if (!t) return { ok: false, error: 'timeline bridge missing' }
40
40
  return { ok: true, result: await t.recent(${JSON.stringify(Y)}) }
41
- })()`});(!j||!j.ok)&&(console.error(` could not query timeline: ${j&&"error"in j?j.error:"unknown"}`),process.exit(1));let D=j.result.events??[];for(let Z of D)if(wo(Z,{filter:k,equals:M})){let ee=Date.now()-F;console.log(S?JSON.stringify({found:!0,elapsedMs:ee,event:Z}):` ${a} event after ${ee}ms${k?` (filter: ${k})`:""}${M?` (equals: ${M})`:""}`);return}j.result.watermark&&j.result.watermark>J&&(J=j.result.watermark),await new Promise(Z=>setTimeout(Z,R))}let u=Date.now()-F;S?console.log(JSON.stringify({found:!1,elapsedMs:u,kind:a,filter:k,equals:M})):console.error(` \u26A0 wait event ${a} timed out after ${u}ms${k?` (filter: ${k})`:""}${M?` (equals: ${M})`:""}`),process.exit(1)}async function Et(o){let{bridge:c,args:i}=o,l=i.includes("--strict"),f=ge(i,3e3),{elapsed:a,settled:g}=await oe({bridge:c,maxMs:f,strict:l});g?console.log(` idle in ${a}ms`):(console.error(` \u26A0 wait idle timed out after ${a}ms (may still be animating)`),process.exit(1))}async function Ct(o){let{bridge:c,args:i}=o,l=ge(i,2e4),{ready:f,elapsedMs:a,nodes:g,targets:b,flag:k,loadingText:M,externalReady:h,externalError:S,errors:F}=await Qe(c,l,{onProgress(R){console.error(` still waiting after ${R.elapsedMs}ms \u2014 ${_e(R)} (nodes: ${R.nodes}, targets: ${R.targets}, errors: ${R.errors})`)}});if(f){let R=l-a,J=Math.max(100,Math.min(1e4,R)),u=await oe({bridge:c,maxMs:J,pollMs:32,stablePolls:2});u.settled||(console.error(` \u26A0 wait ready timed out after ${a+u.elapsed}ms \u2014 app mounted but did not settle (nodes: ${g}, targets: ${b})`),process.exit(1)),console.log(` ready in ${a+u.elapsed}ms: ${g} nodes, ${b} targets`);return}let T=_e({externalError:S,loadingText:M,externalReady:h,flag:k,targets:b});console.error(` \u26A0 wait ready timed out after ${a}ms \u2014 ${T} (nodes: ${g}, targets: ${b}, errors: ${F})`),process.exit(1)}async function Dt(o){let{bridge:c,args:i,positional:l,inspectUsage:f}=o,a=l[1];a||(console.error(f("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let g=i.indexOf("--max-ms"),b=g>=0&&i[g+1]?Math.max(100,Number(i[g+1])):5e3,k=i.includes("--gone"),{found:M,node:h,elapsed:S}=await Ze(c,a,b,{gone:k});if(k){M?console.log(` #${a} gone after ${S}ms`):(console.error(` \u26A0 wait selector #${a} --gone timed out after ${S??b}ms (still present)`),process.exit(1));return}if(M&&h){let F=h.absolutePosition?`@(${Math.round(h.absolutePosition.x)},${Math.round(h.absolutePosition.y)})`:"",T=h.layout?`${Math.round(h.layout.width)}x${Math.round(h.layout.height)}`:"?x?";console.log(` found #${a} in ${S}ms ${T} ${F}`)}else console.error(` \u26A0 wait selector #${a} timed out after ${S??b}ms`),process.exit(1)}function Ut(o){return o==null?"\u2014":o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}K`:`${(o/1024/1024).toFixed(1)}M`}function Kt(o){return o==null?" \u2026":o<1e3?`${o}ms`.padStart(5):`${(o/1e3).toFixed(2)}s`.padStart(5)}function Bt(){process.stderr.write(` the sim is not responding. recover it with:
41
+ })()`});(!j||!j.ok)&&(console.error(` could not query timeline: ${j&&"error"in j?j.error:"unknown"}`),process.exit(1));let D=j.result.events??[];for(let Z of D)if(xo(Z,{filter:k,equals:M})){let ee=Date.now()-_;console.log(S?JSON.stringify({found:!0,elapsedMs:ee,event:Z}):` ${a} event after ${ee}ms${k?` (filter: ${k})`:""}${M?` (equals: ${M})`:""}`);return}j.result.watermark&&j.result.watermark>J&&(J=j.result.watermark),await new Promise(Z=>setTimeout(Z,R))}let u=Date.now()-_;S?console.log(JSON.stringify({found:!1,elapsedMs:u,kind:a,filter:k,equals:M})):console.error(` \u26A0 wait event ${a} timed out after ${u}ms${k?` (filter: ${k})`:""}${M?` (equals: ${M})`:""}`),process.exit(1)}async function Ct(o){let{bridge:c,args:i}=o,l=i.includes("--strict"),f=ge(i,3e3),{elapsed:a,settled:g}=await oe({bridge:c,maxMs:f,strict:l});g?console.log(` idle in ${a}ms`):(console.error(` \u26A0 wait idle timed out after ${a}ms (may still be animating)`),process.exit(1))}async function Dt(o){let{bridge:c,args:i}=o,l=ge(i,2e4),{ready:f,elapsedMs:a,nodes:g,targets:b,flag:k,loadingText:M,externalReady:h,externalError:S,errors:_}=await Ze(c,l,{onProgress(R){console.error(` still waiting after ${R.elapsedMs}ms \u2014 ${Fe(R)} (nodes: ${R.nodes}, targets: ${R.targets}, errors: ${R.errors})`)}});if(f){let R=l-a,J=Math.max(100,Math.min(1e4,R)),u=await oe({bridge:c,maxMs:J,pollMs:32,stablePolls:2});u.settled||(console.error(` \u26A0 wait ready timed out after ${a+u.elapsed}ms \u2014 app mounted but did not settle (nodes: ${g}, targets: ${b})`),process.exit(1)),console.log(` ready in ${a+u.elapsed}ms: ${g} nodes, ${b} targets`);return}let T=Fe({externalError:S,loadingText:M,externalReady:h,flag:k,targets:b});console.error(` \u26A0 wait ready timed out after ${a}ms \u2014 ${T} (nodes: ${g}, targets: ${b}, errors: ${_})`),process.exit(1)}async function Bt(o){let{bridge:c,args:i,positional:l,inspectUsage:f}=o,a=l[1];a||(console.error(f("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let g=i.indexOf("--max-ms"),b=g>=0&&i[g+1]?Math.max(100,Number(i[g+1])):5e3,k=i.includes("--gone"),{found:M,node:h,elapsed:S}=await et(c,a,b,{gone:k});if(k){M?console.log(` #${a} gone after ${S}ms`):(console.error(` \u26A0 wait selector #${a} --gone timed out after ${S??b}ms (still present)`),process.exit(1));return}if(M&&h){let _=h.absolutePosition?`@(${Math.round(h.absolutePosition.x)},${Math.round(h.absolutePosition.y)})`:"",T=h.layout?`${Math.round(h.layout.width)}x${Math.round(h.layout.height)}`:"?x?";console.log(` found #${a} in ${S}ms ${T} ${_}`)}else console.error(` \u26A0 wait selector #${a} timed out after ${S??b}ms`),process.exit(1)}function Kt(o){return o==null?"\u2014":o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}K`:`${(o/1024/1024).toFixed(1)}M`}function zt(o){return o==null?" \u2026":o<1e3?`${o}ms`.padStart(5):`${(o/1e3).toFixed(2)}s`.padStart(5)}function jt(){process.stderr.write(` the sim is not responding. recover it with:
42
42
  sootsim close --sim <id> # force-close the wedged sim
43
43
  sootsim list # confirm it's gone
44
- `)}async function $o(o){try{return await o.send({type:"evaluate",code:"1"},{timeoutMs:3e3}),!0}catch{return!1}}async function vo(o,c){try{let i=await o.send({type:"evaluate",code:`(async () => {
44
+ `)}async function vo(o){try{return await o.send({type:"evaluate",code:"1"},{timeoutMs:3e3}),!0}catch{return!1}}async function So(o,c){try{let i=await o.send({type:"evaluate",code:`(async () => {
45
45
  const t = window.__sootsimTest
46
46
  if (!t || typeof t.queryAll !== 'function') return []
47
47
  try {
@@ -60,8 +60,8 @@ import{a as V}from"./chunk-N7GBP6IK.js";import{a as ft,b as gt}from"./chunk-VFCS
60
60
  } catch {
61
61
  return []
62
62
  }
63
- })()`});if(!Array.isArray(i)||i.length===0)return;let l=c.toLowerCase(),f=i.map(a=>({id:a,score:So(l,a.toLowerCase())})).filter(a=>a.score<l.length+4).sort((a,g)=>a.score-g.score).slice(0,5);if(f.length===0)return;console.error(" similar testIDs:");for(let a of f)console.error(` ${a.id}`)}catch{}}function So(o,c){if(c===o)return 0;if(c.includes(o))return 1;if(o.includes(c))return 2;let i=0;for(;i<o.length&&i<c.length&&o[i]===c[i];)i+=1;return ko(o,c)-i}function ko(o,c){if(o===c)return 0;if(!o.length)return c.length;if(!c.length)return o.length;let i=new Array(c.length+1),l=new Array(c.length+1);for(let f=0;f<=c.length;f++)i[f]=f;for(let f=1;f<=o.length;f++){l[0]=f;for(let g=1;g<=c.length;g++)l[g]=Math.min(i[g]+1,l[g-1]+1,i[g-1]+(o[f-1]===c[g-1]?0:1));let a=i;i=l,l=a}return i[c.length]}function To(o){return o.error?"err":o.status==null?" \u2026 ":String(o.status)}function Mo(o){return o.externalError?`guest app errored: ${o.externalError}`:o.loadingText?`still showing "${o.loadingText}"`:o.externalReady===!1?"guest app is still loading":o.flag!==!0?"guest app has not emitted sootsim:externalAppReady":o.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}function jt(o){let c=re(o.startTs),i=To(o).padEnd(3),l=o.method.padEnd(5),f=Ut(o.size).padStart(6),a=Kt(o.durationMs);console.log(` [${c}] ${i} ${l} ${f} ${a} ${o.displayUrl}`),o.error&&console.log(` error: ${o.error}`)}function Io(o){let c=[["id",o.id],["source",o.source],["kind",o.kind],["method",o.method],["status",o.error?`error: ${o.error}`:`${o.status??"\u2014"} ${o.statusText??""}`.trim()],["url",o.url],["started",re(o.startTs)],["duration",Kt(o.durationMs).trim()],["size",Ut(o.size)],["content-type",o.type??"\u2014"]];for(let[i,l]of c)console.log(` ${i.padEnd(13)} ${l}`)}var No={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},Jt="\x1B[0m",_o="\x1B[2m";function Lt(o,c){let i=re(o.ts),l=o.level.toUpperCase().padEnd(5),f=o.args.join(" ");if(c){let a=No[o.level];console.log(` ${_o}[${i}]${Jt} ${a}${l}${Jt} ${f}`)}else console.log(` [${i}] ${l} ${f}`);if(o.stack&&o.level==="error"){let a=o.stack.split(`
64
- `).slice(0,5);for(let g of a)console.log(` ${g.trim()}`)}}var se="__sootsimCliPerf",Fo=120;async function qt(o,c){let i=o.find((F,T)=>o[T-1]==="--id"),l=o.find((F,T)=>o[T-1]==="--text");if(i||l){let F=await c.send({type:"evaluate",code:ft({id:i,text:l})});if(!F)throw new Error(i?`no node with id "${i}"`:`no node matching text "${l}"`);let{x:T,y:R,w:J,h:u}=F;return{x:T,y:R,w:J,h:u}}let f=o.find((F,T)=>o[T-1]==="--area");if(f){let F=f.split(",").map(Y=>Number(Y.trim()));if(F.length!==4||F.some(Y=>!Number.isFinite(Y)))throw new Error(`--area expects x,y,w,h (got "${f}")`);let[T,R,J,u]=F;return{x:T,y:R,w:J,h:u}}let a=F=>{let T=o.find((J,u)=>o[u-1]===F);if(T==null)return null;let R=Number(T);return Number.isFinite(R)?R:null},g=a("--x"),b=a("--y"),k=a("--w"),M=a("--h");if(g!=null||b!=null||k!=null||M!=null)return{x:g??0,y:b??0,w:k??1,h:M??1};let S=o.filter((F,T)=>T>0&&!F.startsWith("-")&&o[T-1]!=="--output"&&o[T-1]!=="--area"&&o[T-1]!=="--id"&&o[T-1]!=="--text"&&o[T-1]!=="--x"&&o[T-1]!=="--y"&&o[T-1]!=="--w"&&o[T-1]!=="--h").map(Number).filter(F=>Number.isFinite(F));if(S.length>=2){let[F,T,R=1,J=1]=S;return{x:F,y:T,w:R,h:J}}return null}function Ee(o){let c={"<8":0,"8-12":0,"12-16":0,"16-20":0,"20-33":0,">33":0};for(let i of o)i<8?c["<8"]++:i<12?c["8-12"]++:i<16?c["12-16"]++:i<20?c["16-20"]++:i<33?c["20-33"]++:c[">33"]++;console.log(" histogram:");for(let[i,l]of Object.entries(c)){let f="\u2588".repeat(Math.ceil(l/o.length*40));console.log(` ${i.padEnd(6)} ${f} ${l}`)}}async function ve(o,c,i){let l=Date.now()+c,f=await le(o,c);for(;;){if(i(f))return{settled:!0,state:f};if(Date.now()>=l)return{settled:!1,state:f};await Q(16),f=await le(o)}}async function De(o){return o.send({type:"evaluate",code:`(async () => {
63
+ })()`});if(!Array.isArray(i)||i.length===0)return;let l=c.toLowerCase(),f=i.map(a=>({id:a,score:ko(l,a.toLowerCase())})).filter(a=>a.score<l.length+4).sort((a,g)=>a.score-g.score).slice(0,5);if(f.length===0)return;console.error(" similar testIDs:");for(let a of f)console.error(` ${a.id}`)}catch{}}function ko(o,c){if(c===o)return 0;if(c.includes(o))return 1;if(o.includes(c))return 2;let i=0;for(;i<o.length&&i<c.length&&o[i]===c[i];)i+=1;return To(o,c)-i}function To(o,c){if(o===c)return 0;if(!o.length)return c.length;if(!c.length)return o.length;let i=new Array(c.length+1),l=new Array(c.length+1);for(let f=0;f<=c.length;f++)i[f]=f;for(let f=1;f<=o.length;f++){l[0]=f;for(let g=1;g<=c.length;g++)l[g]=Math.min(i[g]+1,l[g-1]+1,i[g-1]+(o[f-1]===c[g-1]?0:1));let a=i;i=l,l=a}return i[c.length]}function Mo(o){return o.error?"err":o.status==null?" \u2026 ":String(o.status)}function Io(o){return o.externalError?`guest app errored: ${o.externalError}`:o.loadingText?`still showing "${o.loadingText}"`:o.externalReady===!1?"guest app is still loading":o.flag!==!0?"guest app has not emitted sootsim:externalAppReady":o.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}function Jt(o){let c=re(o.startTs),i=Mo(o).padEnd(3),l=o.method.padEnd(5),f=Kt(o.size).padStart(6),a=zt(o.durationMs);console.log(` [${c}] ${i} ${l} ${f} ${a} ${o.displayUrl}`),o.error&&console.log(` error: ${o.error}`)}function No(o){let c=[["id",o.id],["source",o.source],["kind",o.kind],["method",o.method],["status",o.error?`error: ${o.error}`:`${o.status??"\u2014"} ${o.statusText??""}`.trim()],["url",o.url],["started",re(o.startTs)],["duration",zt(o.durationMs).trim()],["size",Kt(o.size)],["content-type",o.type??"\u2014"]];for(let[i,l]of c)console.log(` ${i.padEnd(13)} ${l}`)}var Fo={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},Lt="\x1B[0m",_o="\x1B[2m";function qt(o,c){let i=re(o.ts),l=o.level.toUpperCase().padEnd(5),f=o.args.join(" ");if(c){let a=Fo[o.level];console.log(` ${_o}[${i}]${Lt} ${a}${l}${Lt} ${f}`)}else console.log(` [${i}] ${l} ${f}`);if(o.stack&&o.level==="error"){let a=o.stack.split(`
64
+ `).slice(0,5);for(let g of a)console.log(` ${g.trim()}`)}}var se="__sootsimCliPerf",Ao=120;async function Wt(o,c){let i=o.find((_,T)=>o[T-1]==="--id"),l=o.find((_,T)=>o[T-1]==="--text");if(i||l){let _=await c.send({type:"evaluate",code:gt({id:i,text:l})});if(!_)throw new Error(i?`no node with id "${i}"`:`no node matching text "${l}"`);let{x:T,y:R,w:J,h:u}=_;return{x:T,y:R,w:J,h:u}}let f=o.find((_,T)=>o[T-1]==="--area");if(f){let _=f.split(",").map(Y=>Number(Y.trim()));if(_.length!==4||_.some(Y=>!Number.isFinite(Y)))throw new Error(`--area expects x,y,w,h (got "${f}")`);let[T,R,J,u]=_;return{x:T,y:R,w:J,h:u}}let a=_=>{let T=o.find((J,u)=>o[u-1]===_);if(T==null)return null;let R=Number(T);return Number.isFinite(R)?R:null},g=a("--x"),b=a("--y"),k=a("--w"),M=a("--h");if(g!=null||b!=null||k!=null||M!=null)return{x:g??0,y:b??0,w:k??1,h:M??1};let S=o.filter((_,T)=>T>0&&!_.startsWith("-")&&o[T-1]!=="--output"&&o[T-1]!=="--area"&&o[T-1]!=="--id"&&o[T-1]!=="--text"&&o[T-1]!=="--x"&&o[T-1]!=="--y"&&o[T-1]!=="--w"&&o[T-1]!=="--h").map(Number).filter(_=>Number.isFinite(_));if(S.length>=2){let[_,T,R=1,J=1]=S;return{x:_,y:T,w:R,h:J}}return null}function Ee(o){let c={"<8":0,"8-12":0,"12-16":0,"16-20":0,"20-33":0,">33":0};for(let i of o)i<8?c["<8"]++:i<12?c["8-12"]++:i<16?c["12-16"]++:i<20?c["16-20"]++:i<33?c["20-33"]++:c[">33"]++;console.log(" histogram:");for(let[i,l]of Object.entries(c)){let f="\u2588".repeat(Math.ceil(l/o.length*40));console.log(` ${i.padEnd(6)} ${f} ${l}`)}}async function ve(o,c,i){let l=Date.now()+c,f=await le(o,c);for(;;){if(i(f))return{settled:!0,state:f};if(Date.now()>=l)return{settled:!1,state:f};await Q(16),f=await le(o)}}async function De(o){return o.send({type:"evaluate",code:`(async () => {
65
65
  const kb = window.__sootsimKeyboard
66
66
  const test = window.__sootsimTest
67
67
  if (!kb) return { error: 'keyboard bridge not available' }
@@ -93,7 +93,7 @@ import{a as V}from"./chunk-N7GBP6IK.js";import{a as ft,b as gt}from"./chunk-VFCS
93
93
  frame: runtimeSnapshot?.keyboard?.frame ?? null,
94
94
  focusedRect: runtimeSnapshot?.focused?.rect ?? null,
95
95
  }
96
- })()`})}async function Ao(o,c=600){let i=Date.now()+c;for(;Date.now()<=i;){let l=await De(o);if(l.visible)return l;await Q(30)}return De(o)}async function Se(o,c){let i=await De(o);if(i.visible)return i;console.error(` ${c} requires the iOS keyboard to be visible. focus an input first with sootsim do tap-id/tap-text or sootsim do type-into.`),process.exit(1)}async function Wt(o,c,i){return c==="appearance"?o.send({type:"evaluate",code:`(async () => {
96
+ })()`})}async function Po(o,c=600){let i=Date.now()+c;for(;Date.now()<=i;){let l=await De(o);if(l.visible)return l;await Q(30)}return De(o)}async function Se(o,c){let i=await De(o);if(i.visible)return i;console.error(` ${c} requires the iOS keyboard to be visible. focus an input first with sootsim do tap-id/tap-text or sootsim do type-into.`),process.exit(1)}async function Ht(o,c,i){return c==="appearance"?o.send({type:"evaluate",code:`(async () => {
97
97
  const requested = ${JSON.stringify(i??"toggle")}
98
98
  const rootBg = (document.documentElement?.style?.background || '').toLowerCase()
99
99
  const inferredCurrent = rootBg.includes('33') ? 'dark' : 'light'
@@ -110,14 +110,14 @@ import{a as V}from"./chunk-N7GBP6IK.js";import{a as ft,b as gt}from"./chunk-VFCS
110
110
  })()`}):o.send({type:"evaluate",code:`(async () => {
111
111
  window.dispatchEvent(new CustomEvent(${JSON.stringify(c==="lock"?"sootsim:toggleLock":"sootsim:shake")}))
112
112
  return { ok: true, action: ${JSON.stringify(c)} }
113
- })()`})}function Po(o){let c={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(c[o])return c[o];let i=o.match(/^Digit([0-9])$/);if(i)return i[1];let l=o.match(/^Key([A-Z])$/);return l?l[1].toLowerCase():null}function Oo(o){if(typeof o!="string")return null;let c=o.replace(/\s+/g," ").trim();return c?c.slice(0,80):null}function zt(...o){for(let c of o){if(typeof c!="string")continue;let i=c.trim();if(i)return i}return null}function Ro(o){let c=o.indexOf("--node-id");if(c<0)return null;let i=o[c+1];if(!i)return null;let l=Number(i);return Number.isInteger(l)&&l>0?l:null}async function q(o,c,i){let l=he({source:o,step:c,summary:i});l.active&&(l.replaced?console.error(` draft: replaced unkept action "${l.replaced.summary}" \u2014 \`flow keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `sootsim flow keep` to commit"))}function Ht(o,c,i){if(!i||i.hit===!1)return null;let l=zt(i.responderTestID,i.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let f=Oo(i.text);return f?{step:{tapOn:f},summary:`tap "${f}"`}:{step:{tapAtCoords:{x:o,y:c}},summary:`tap @${Math.round(o)},${Math.round(c)}`}}function Ce(o,c,i){let l=zt(c?.testID,c?.id);return l?{step:{tapOn:{id:l}},summary:`tap #${l}`}:i==="id"?{step:{tapOn:{id:o}},summary:`tap #${o}`}:{step:{tapOn:o},summary:`tap "${o}"`}}async function yn(o,c){let i=o[0]==="get"||o[0]==="do"||o[0]==="debug"||o[0]==="wait"?o[0]:null,l=i?o.slice(1):o,f=Le(l,{port:c.port,commandTimeoutMs:c.timeoutMs,stripBooleanFlags:["--verbose","-v","--help","-h","--clear-state","--json","--all","--watch","-w","--strict","--no-wait","--dump","--failed","--slow","--tail","-f","--interactive-targets","--actions","--internal","--compact","--no-xy","--no-clipped","--include-occluded"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--node-id","--max-ms","--filter","--limit","--level","--threshold","--equals","--since","--testid-like","--only","--subtree"]}),a=f.positional,g=a[0],b=i==="get"||i==="do"||i==="debug"||i==="wait"?i:"inspect",k=typeof l[0]=="string"&&Be.has(l[0]),M=k?l[0]:null,h=e=>k&&e===l[0]?`sootsim ${e}`:`sootsim ${b} ${e}`,S=(e,t)=>` usage: ${h(e)}${t?` ${t}`:""}`;if(!g||o.includes("--help")||o.includes("-h")){let e={bridgePort:7668,defaultShellUrl:je};if(b==="do"||b==="get"||b==="debug"||b==="wait"){let r=ke(b,e);r&&(console.log(`${r}
113
+ })()`})}function Oo(o){let c={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(c[o])return c[o];let i=o.match(/^Digit([0-9])$/);if(i)return i[1];let l=o.match(/^Key([A-Z])$/);return l?l[1].toLowerCase():null}function Ro(o){if(typeof o!="string")return null;let c=o.replace(/\s+/g," ").trim();return c?c.slice(0,80):null}function Yt(...o){for(let c of o){if(typeof c!="string")continue;let i=c.trim();if(i)return i}return null}function Eo(o){let c=o.indexOf("--node-id");if(c<0)return null;let i=o[c+1];if(!i)return null;let l=Number(i);return Number.isInteger(l)&&l>0?l:null}async function q(o,c,i){let l=he({source:o,step:c,summary:i});l.active&&(l.replaced?console.error(` draft: replaced unkept action "${l.replaced.summary}" \u2014 \`flow keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `sootsim flow keep` to commit"))}function Ut(o,c,i){if(!i||i.hit===!1)return null;let l=Yt(i.responderTestID,i.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let f=Ro(i.text);return f?{step:{tapOn:f},summary:`tap "${f}"`}:{step:{tapAtCoords:{x:o,y:c}},summary:`tap @${Math.round(o)},${Math.round(c)}`}}function Ce(o,c,i){let l=Yt(c?.testID,c?.id);return l?{step:{tapOn:{id:l}},summary:`tap #${l}`}:i==="id"?{step:{tapOn:{id:o}},summary:`tap #${o}`}:{step:{tapOn:o},summary:`tap "${o}"`}}async function hn(o,c){let i=o[0]==="get"||o[0]==="do"||o[0]==="debug"||o[0]==="wait"?o[0]:null,l=i?o.slice(1):o,f=Le(l,{port:c.port,commandTimeoutMs:c.timeoutMs,stripBooleanFlags:["--verbose","-v","--help","-h","--clear-state","--json","--all","--watch","-w","--strict","--no-wait","--dump","--failed","--slow","--tail","-f","--interactive-targets","--actions","--internal","--compact","--no-xy","--no-clipped","--include-occluded"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--node-id","--max-ms","--filter","--limit","--level","--threshold","--equals","--since","--testid-like","--only","--subtree"]}),a=f.positional,g=a[0],b=i==="get"||i==="do"||i==="debug"||i==="wait"?i:"inspect",k=typeof l[0]=="string"&&Be.has(l[0]),M=k?l[0]:null,h=e=>k&&e===l[0]?`sootsim ${e}`:`sootsim ${b} ${e}`,S=(e,t)=>` usage: ${h(e)}${t?` ${t}`:""}`;if(!g||o.includes("--help")||o.includes("-h")){let e={bridgePort:7668,defaultShellUrl:je};if(b==="do"||b==="get"||b==="debug"||b==="wait"){let r=ke(b,e);r&&(console.log(`${r}
114
114
  `),process.exit(0))}if(M==="shell"){let r=Te("shell",e);r&&(console.log(`${r}
115
115
  `),process.exit(0))}let t=Te("inspect",e),n=["do","get","debug","wait"].map(r=>ke(r,e)).filter(r=>r!=null).join(`
116
116
 
117
117
  `);console.log(`${t??""}
118
118
 
119
119
  ${n}
120
- `),process.exit(0)}let F=f.wsPort,T=f.simId,R=f.simIdSource,J=f.commandTimeoutMs;if(g==="list"&&l.some(e=>e==="--drivers"||e==="-D")){let{buildDriverListRows:e}=await import("./drivers-MQCDXQRI.js"),t=e();console.log(` available drivers (${t.length}):
120
+ `),process.exit(0)}let _=f.wsPort,T=f.simId,R=f.simIdSource,J=f.commandTimeoutMs;if(g==="list"&&l.some(e=>e==="--drivers"||e==="-D")){let{buildDriverListRows:e}=await import("./drivers-4CENGVIM.js"),t=e();console.log(` available drivers (${t.length}):
121
121
  `);let n=Math.max(...t.map(s=>s.id.length),6),r=Math.max(...t.map(s=>s.kind.length),4);for(let s of t){let d=s.available?"\u2713":"\u2717",m=s.id.padEnd(n),y=s.kind.padEnd(r);console.log(` ${d} ${m} ${y} ${s.description}`),s.available&&s.detail?console.log(` ${s.detail}`):!s.available&&s.reason&&console.log(` unavailable: ${s.reason}`)}return}let u=qe(f),Y=T||"default",j=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","list","wait","sleep"]),D=200;function Z(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec(e)?.[1]?.trim(),s=/<body[^>]*>([\s\S]*?)<\//i.exec(e)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),d=r||s||"html error page";return`<html ${e.length}B> "${d}" (body elided \u2014 add --json for the full payload)`}return t.length<=D?t:`${t.slice(0,D)}\u2026 (+${t.length-D} more bytes)`}function ee(e){let t=e.displayUrl||e.url;return e.status!=null?`${e.method} ${t} -> ${e.status}${e.statusText?` ${e.statusText}`:""}`:e.error?`${e.method} ${t} -> ${e.error}`:`${e.method} ${t}`}async function $(e){let t=be()?5e3:1500;try{let{settled:n,elapsed:r}=await oe({bridge:e,maxMs:t,pollMs:32,stablePolls:2});n||process.stderr.write(` \u26A0 auto-wait timed out after ${r??t}ms \u2014 next command may see mid-animation state. use \`sootsim do settle\` for a longer wait.
122
122
  `)}catch{}}function I(e){return!(!e||e.hit===!1||e.ok===!1||e.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function W(e,t){return{id:e.target?.id??e.match?.id??e.node?.id??null,testID:e.target?.testID??e.match?.testID??e.node?.testID??null,text:e.target?.text??e.target?.accessibilityLabel??e.match?.text??e.match?.accessibilityLabel??e.node?.text??t??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function L(e){let t=0,n=null,r=null;try{await oe({bridge:u,maxMs:be()?3e3:1200,pollMs:32,stablePolls:2})}catch{}let s=Date.now()+(be()?5e3:2500);for(;Date.now()<=s||t===0;){t++;let d=await e.resolve();if(n=d,d?.error==="bridge-not-ready"||d?.ambiguous||d?.nthOutOfRange)return{payload:d,result:null,attempts:t,failure:"special"};if(d&&typeof d.cx=="number"&&typeof d.cy=="number"){let y=await u.send({type:"tap",x:d.cx,y:d.cy,target:W(d,e.textFallback)});if(r=y,I(y))return{payload:d,result:y,attempts:t}}let m=s-Date.now();if(m<=0)break;try{await oe({bridge:u,maxMs:Math.min(m,700),pollMs:32,stablePolls:2})}catch{await Q(Math.min(120,m))}}return{payload:n,result:r,attempts:t,failure:n&&typeof n.cx=="number"?"missed":"not-found"}}function z(e,t){console.error(` tap failed: ${e} stayed visible but did not receive a hittable press after ${t.attempts} attempt${t.attempts===1?"":"s"}`),t.result&&console.error(` last result: ${JSON.stringify(t.result)}`)}async function te(){try{return await u.send({type:"evaluate",code:`(() => ({
123
123
  console: window.__sootsimConsole?.count?.() || null,
@@ -145,8 +145,8 @@ ${n}
145
145
  }
146
146
  return summary ? { summary, consoleSplit } : null
147
147
  })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},s=[],d=new Set;for(let m of B){let y=r[m];if(y)if(d.add(m),m==="console"&&n.consoleSplit){let{error:p,warn:x}=n.consoleSplit;p>0&&s.push(`${p} error${p===1?"":"s"}`),x>0&&s.push(`${x} warning${x===1?"":"s"}`)}else s.push(`${y} ${m}${y===1?"":"s"}`)}for(let[m,y]of Object.entries(r))!d.has(m)&&y&&s.push(`${y} ${m}${y===1?"":"s"}`);if(s.length!==0&&(console.log(`
148
- since last: ${s.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await Me(e,"SootSim.bridges.timeline.cursorAdvance",t,n.summary.lastAt)}catch{}}let ce=new Set(["tap","double-tap","tap-text","tap-id","type","type-into","key","key-sequence","keycode","drag","swipe","long-press","touch","gesture","pinch","scroll","shell"]),Yt=new Set(["a11y","capture","count","double-tap","drag","find","gesture","layout","long-press","node","pinch","sample-color","scroll","screenshot","swipe","tap","tap-id","tap-text","touch","tree","type-into"]),Gt=(o.includes("--verbose")||o.includes("-v"))&&!o.includes("--json");b==="do"&&g==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),ce.has(g)&&await We(u),Yt.has(g)&&await ye(u,{verbose:Gt});try{switch(g){case"list":{await Tt({bridge:u,simId:T,args:l});break}case"tree":{await Ft({bridge:u,args:l,positional:a});break}case"a11y":{let e=await Xe(u);if(!Array.isArray(e)||e.length===0){console.log(" no accessible nodes found");break}if(o.includes("--json"))console.log(JSON.stringify(e,null,2));else{console.log(` accessibility tree (${e.length} nodes):
149
- `);for(let t of e){let n=[];if(n.push(`[${t.role}]`),t.label){let r=t.label.length>50?t.label.slice(0,47)+"...":t.label;n.push(`"${r}"`)}if(t.hint&&n.push(`(hint: "${t.hint}")`),t.testID&&n.push(`#${t.testID}`),t.state){let r=[];t.state.disabled&&r.push("disabled"),t.state.selected&&r.push("selected"),t.state.checked===!0&&r.push("checked"),t.state.checked==="mixed"&&r.push("mixed"),t.state.busy&&r.push("busy"),t.state.expanded===!0&&r.push("expanded"),t.state.expanded===!1&&r.push("collapsed"),r.length&&n.push(`{${r.join(", ")}}`)}t.position&&n.push(`@(${t.position.x},${t.position.y})`),t.size&&n.push(`${t.size.w}x${t.size.h}`),console.log(" "+n.join(" "))}}break}case"find":{await St({bridge:u,args:o,effectiveArgs:l,positional:a,inspectUsage:S});break}case"count":{await $t(u,{args:l});break}case"keyboard":{await kt(u,{json:o.includes("--json")});break}case"screens":{await It(u,{json:o.includes("--json")});break}case"memory":{await Mt(u,{args:l});break}case"wait":{await Pt({wsPort:F,commandTimeoutMs:J,simId:T,simIdSource:R,positional:a});break}case"sleep":{await _t({positional:a,inspectUsage:S});break}case"settle":{await Nt({bridge:u,args:o,positional:a});break}case"ready":{await Ct({bridge:u,args:o});break}case"idle":{await Et({bridge:u,args:o,positional:a});break}case"selector":{await Dt({bridge:u,args:o,positional:a,inspectUsage:S});break}case"event":{await Rt({bridge:u,args:o,positional:a,inspectUsage:S});break}case"layout":{let e=a[1];e||(console.error(S("layout","<id>")),process.exit(1));let t=await u.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(e)}))()`});console.log(JSON.stringify(t,null,2));break}case"capture":case"screenshot":{let t=o.find((y,p)=>o[p-1]==="--output")||"/tmp/sootsim-inspect.png",n=await qt(o,u),r={type:"screenshot"};n&&(r.crop=n);let d=(await u.send(r)).replace(/^data:image\/png;base64,/,"");n&&console.log(` area: x=${n.x} y=${n.y} w=${n.w} h=${n.h}`),(await import("fs")).writeFileSync(t,Buffer.from(d,"base64")),console.log(` saved: ${t}`);break}case"sample-color":{let e=await qt(o,u);e||(console.error(S("sample-color","<x> <y> [w] [h] | --id <testID> | --text <text>")),console.error(" samples an averaged color from the canvas. coords are logical sootsim units."),process.exit(1));let t=await u.send({type:"evaluate",code:gt(e)});if(o.includes("--json"))console.log(JSON.stringify(t,null,2));else{let{r:n,g:r,b:s,a:d,hex:m,samples:y}=t,p=e.w===1&&e.h===1?`@(${e.x},${e.y})`:`@(${e.x},${e.y}) ${e.w}x${e.h}`;console.log(` ${m} rgba(${n}, ${r}, ${s}, ${d}) ${p} ${y} samples`)}break}case"node":{let e=a[1];e||(console.error(S("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let t=await u.send({type:"evaluate",code:`(async () => {
148
+ since last: ${s.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await Me(e,"SootSim.bridges.timeline.cursorAdvance",t,n.summary.lastAt)}catch{}}let ce=new Set(["tap","double-tap","tap-text","tap-id","type","type-into","key","key-sequence","keycode","drag","swipe","long-press","touch","gesture","pinch","scroll","shell"]),Gt=new Set(["a11y","capture","count","double-tap","drag","find","gesture","layout","long-press","node","pinch","sample-color","scroll","screenshot","swipe","tap","tap-id","tap-text","touch","tree","type-into"]),Xt=(o.includes("--verbose")||o.includes("-v"))&&!o.includes("--json");b==="do"&&g==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),ce.has(g)&&await We(u),Gt.has(g)&&await ye(u,{verbose:Xt});try{switch(g){case"list":{await Mt({bridge:u,simId:T,args:l});break}case"tree":{await At({bridge:u,args:l,positional:a});break}case"a11y":{let e=await Ve(u);if(!Array.isArray(e)||e.length===0){console.log(" no accessible nodes found");break}if(o.includes("--json"))console.log(JSON.stringify(e,null,2));else{console.log(` accessibility tree (${e.length} nodes):
149
+ `);for(let t of e){let n=[];if(n.push(`[${t.role}]`),t.label){let r=t.label.length>50?t.label.slice(0,47)+"...":t.label;n.push(`"${r}"`)}if(t.hint&&n.push(`(hint: "${t.hint}")`),t.testID&&n.push(`#${t.testID}`),t.state){let r=[];t.state.disabled&&r.push("disabled"),t.state.selected&&r.push("selected"),t.state.checked===!0&&r.push("checked"),t.state.checked==="mixed"&&r.push("mixed"),t.state.busy&&r.push("busy"),t.state.expanded===!0&&r.push("expanded"),t.state.expanded===!1&&r.push("collapsed"),r.length&&n.push(`{${r.join(", ")}}`)}t.position&&n.push(`@(${t.position.x},${t.position.y})`),t.size&&n.push(`${t.size.w}x${t.size.h}`),console.log(" "+n.join(" "))}}break}case"find":{await kt({bridge:u,args:o,effectiveArgs:l,positional:a,inspectUsage:S});break}case"count":{await vt(u,{args:l});break}case"keyboard":{await Tt(u,{json:o.includes("--json")});break}case"screens":{await Nt(u,{json:o.includes("--json")});break}case"memory":{await It(u,{args:l});break}case"wait":{await Ot({wsPort:_,commandTimeoutMs:J,simId:T,simIdSource:R,positional:a});break}case"sleep":{await _t({positional:a,inspectUsage:S});break}case"settle":{await Ft({bridge:u,args:o,positional:a});break}case"ready":{await Dt({bridge:u,args:o});break}case"idle":{await Ct({bridge:u,args:o,positional:a});break}case"selector":{await Bt({bridge:u,args:o,positional:a,inspectUsage:S});break}case"event":{await Et({bridge:u,args:o,positional:a,inspectUsage:S});break}case"layout":{let e=a[1];e||(console.error(S("layout","<id>")),process.exit(1));let t=await u.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(e)}))()`});console.log(JSON.stringify(t,null,2));break}case"capture":case"screenshot":{let t=o.find((y,p)=>o[p-1]==="--output")||"/tmp/sootsim-inspect.png",n=await Wt(o,u),r={type:"screenshot"};n&&(r.crop=n);let d=(await u.send(r)).replace(/^data:image\/png;base64,/,"");n&&console.log(` area: x=${n.x} y=${n.y} w=${n.w} h=${n.h}`),(await import("fs")).writeFileSync(t,Buffer.from(d,"base64")),console.log(` saved: ${t}`);break}case"sample-color":{let e=await Wt(o,u);e||(console.error(S("sample-color","<x> <y> [w] [h] | --id <testID> | --text <text>")),console.error(" samples an averaged color from the canvas. coords are logical sootsim units."),process.exit(1));let t=await u.send({type:"evaluate",code:yt(e)});if(o.includes("--json"))console.log(JSON.stringify(t,null,2));else{let{r:n,g:r,b:s,a:d,hex:m,samples:y}=t,p=e.w===1&&e.h===1?`@(${e.x},${e.y})`:`@(${e.x},${e.y}) ${e.w}x${e.h}`;console.log(` ${m} rgba(${n}, ${r}, ${s}, ${d}) ${p} ${y} samples`)}break}case"node":{let e=a[1];e||(console.error(S("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let t=await u.send({type:"evaluate",code:`(async () => {
150
150
  const t = window.__sootsimTest
151
151
  const q = ${JSON.stringify(e)}
152
152
  let node = null
@@ -202,7 +202,7 @@ ${n}
202
202
  transform,
203
203
  parentChain,
204
204
  }
205
- })()`});console.log(JSON.stringify(t,null,2));break}case"tap":{let e=Number(a[1]),t=Number(a[2]),n=pe(o);if(n){let d=await L({textFallback:n.mode==="text"?n.value:void 0,resolve:async()=>{let p=await xe(u,n);return p?{cx:p.x,cy:p.y,match:{id:n.mode==="testid"?n.value:p.id??null,testID:n.mode==="testid"?n.value:p.testID??null,text:n.mode==="text"?n.value:p.text??null,type:p.type??null},target:{id:p.id??null,testID:p.testID??null,text:p.text??null,type:p.type??null}}:null}}),m=d.payload;(!m||typeof m.cx!="number")&&(console.error(` not found: ${n.value}`),n.mode==="testid"&&V("wait-selector-for-missing-testid",n.value),process.exit(1)),I(d.result)||(z(`${n.mode} "${n.value}"`,d),process.exit(1));let y=Ht(m.cx,m.cy,d.result);y&&await q("inspect tap",y.step,y.summary),console.log(JSON.stringify({...d.attempts>1?{attempts:d.attempts}:{},...d.result},null,2));break}(!Number.isFinite(e)||!Number.isFinite(t))&&(console.error(S("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let r=await u.send({type:"tap",x:e,y:t}),s=Ht(e,t,r);s&&await q("inspect tap",s.step,s.summary),console.log(JSON.stringify(r,null,2));break}case"drag":case"swipe":{let e=Number(a[1]),t=Number(a[2]),n=Number(a[3]),r=Number(a[4]),s=g==="swipe"?10:12,d=g==="swipe"?8:16,m=a[5]?Number(a[5]):s,y=a[6]?Number(a[6]):d;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(m)||!Number.isFinite(y))&&(console.error(S(g,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let p=await u.send({type:"evaluate",code:`(async () => {
205
+ })()`});console.log(JSON.stringify(t,null,2));break}case"tap":{let e=Number(a[1]),t=Number(a[2]),n=pe(o);if(n){let d=await L({textFallback:n.mode==="text"?n.value:void 0,resolve:async()=>{let p=await xe(u,n);return p?{cx:p.x,cy:p.y,match:{id:n.mode==="testid"?n.value:p.id??null,testID:n.mode==="testid"?n.value:p.testID??null,text:n.mode==="text"?n.value:p.text??null,type:p.type??null},target:{id:p.id??null,testID:p.testID??null,text:p.text??null,type:p.type??null}}:null}}),m=d.payload;(!m||typeof m.cx!="number")&&(console.error(` not found: ${n.value}`),n.mode==="testid"&&V("wait-selector-for-missing-testid",n.value),process.exit(1)),I(d.result)||(z(`${n.mode} "${n.value}"`,d),process.exit(1));let y=Ut(m.cx,m.cy,d.result);y&&await q("inspect tap",y.step,y.summary),console.log(JSON.stringify({...d.attempts>1?{attempts:d.attempts}:{},...d.result},null,2));break}(!Number.isFinite(e)||!Number.isFinite(t))&&(console.error(S("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let r=await u.send({type:"tap",x:e,y:t}),s=Ut(e,t,r);s&&await q("inspect tap",s.step,s.summary),console.log(JSON.stringify(r,null,2));break}case"drag":case"swipe":{let e=Number(a[1]),t=Number(a[2]),n=Number(a[3]),r=Number(a[4]),s=g==="swipe"?10:12,d=g==="swipe"?8:16,m=a[5]?Number(a[5]):s,y=a[6]?Number(a[6]):d;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(m)||!Number.isFinite(y))&&(console.error(S(g,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let p=await u.send({type:"evaluate",code:`(async () => {
206
206
  const interact = window.__sootsimInteract
207
207
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
208
208
  const value = await interact.drag(${e}, ${t}, ${n}, ${r}, ${Math.max(1,Math.round(m))}, ${Math.max(0,Math.round(y))})
@@ -332,7 +332,7 @@ ${n}
332
332
  total,
333
333
  idx,
334
334
  }
335
- })()`})}),_=P.payload;if(_?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),_?.ambiguous){let G=_.candidates;console.error(` ambiguous: ${_.total} matches for "${e}"`);for(let O of G){let Xt=O.abs?`@(${Math.round(O.abs.x)},${Math.round(O.abs.y)})`:"",Vt=O.layout?` ${O.layout.width}x${O.layout.height}`:"",Qt=O.testID?` #${O.testID}`:"",Zt=O.text?` "${O.text}"`:"",eo=O.ancestorTestIDs.length>0?` within ${O.ancestorTestIDs.slice(0,3).map(to=>`#${to}`).join(" > ")}`:"";console.error(` [${O.idx}] <${O.type}>${Zt}${Qt} ${Xt}${Vt}${eo}`)}_.total>G.length&&console.error(` ... and ${_.total-G.length} more`),console.error(" pick one:"),console.error(" --nth <index> pick the nth match (top-to-bottom, left-to-right; negatives from end)"),console.error(" --within <testID> narrow to descendants of a node"),console.error(" --min-y / --max-y geometric filter (pixels, absolute)"),console.error(" --min-x / --max-x geometric filter (pixels, absolute)"),console.error(" --near <x> <y> pick the closest match to a point"),console.error(" --exact exact text match (default is substring)"),console.error(" --role <role> narrow to accessibilityRole"),console.error(" --first keep the old pick-first-silently behavior"),process.exit(2)}_?.nthOutOfRange&&(console.error(` not found: nth ${_.nth} of ${_.total} match${_.total===1?"":"es"} for "${e}"`),process.exit(1)),(!_||typeof _.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1)),I(P.result)||(z(`text "${e}"`,P),process.exit(1));let de=Ce(e,{id:_.target?.id??null,testID:_.target?.testID??null,type:_.target?.type??null,cx:_.cx,cy:_.cy},"text");await q("inspect tap-text",de.step,de.summary),console.log(JSON.stringify({matched:_.match,tapped:{nodeId:_.target?.nodeId??null,id:_.target?.id??null,testID:_.target?.testID??null,type:_.target?.type??null,cx:_.cx,cy:_.cy},..._.strategy&&_.strategy!=="matched-node"?{strategy:_.strategy}:{},..._.total>1||s!==null?{nth:{index:_.idx,total:_.total}}:{},...P.attempts>1?{attempts:P.attempts}:{},result:P.result},null,2));break}case"tap-best":{let e=a[1];e||(console.error(S("tap-best","<query>")),process.exit(1));let t=JSON.stringify(e),r=await L({textFallback:e,resolve:async()=>{let y=await u.send({type:"evaluate",code:`(async () => {
335
+ })()`})}),F=P.payload;if(F?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),F?.ambiguous){let G=F.candidates;console.error(` ambiguous: ${F.total} matches for "${e}"`);for(let O of G){let Vt=O.abs?`@(${Math.round(O.abs.x)},${Math.round(O.abs.y)})`:"",Qt=O.layout?` ${O.layout.width}x${O.layout.height}`:"",Zt=O.testID?` #${O.testID}`:"",eo=O.text?` "${O.text}"`:"",to=O.ancestorTestIDs.length>0?` within ${O.ancestorTestIDs.slice(0,3).map(oo=>`#${oo}`).join(" > ")}`:"";console.error(` [${O.idx}] <${O.type}>${eo}${Zt} ${Vt}${Qt}${to}`)}F.total>G.length&&console.error(` ... and ${F.total-G.length} more`),console.error(" pick one:"),console.error(" --nth <index> pick the nth match (top-to-bottom, left-to-right; negatives from end)"),console.error(" --within <testID> narrow to descendants of a node"),console.error(" --min-y / --max-y geometric filter (pixels, absolute)"),console.error(" --min-x / --max-x geometric filter (pixels, absolute)"),console.error(" --near <x> <y> pick the closest match to a point"),console.error(" --exact exact text match (default is substring)"),console.error(" --role <role> narrow to accessibilityRole"),console.error(" --first keep the old pick-first-silently behavior"),process.exit(2)}F?.nthOutOfRange&&(console.error(` not found: nth ${F.nth} of ${F.total} match${F.total===1?"":"es"} for "${e}"`),process.exit(1)),(!F||typeof F.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1)),I(P.result)||(z(`text "${e}"`,P),process.exit(1));let de=Ce(e,{id:F.target?.id??null,testID:F.target?.testID??null,type:F.target?.type??null,cx:F.cx,cy:F.cy},"text");await q("inspect tap-text",de.step,de.summary),console.log(JSON.stringify({matched:F.match,tapped:{nodeId:F.target?.nodeId??null,id:F.target?.id??null,testID:F.target?.testID??null,type:F.target?.type??null,cx:F.cx,cy:F.cy},...F.strategy&&F.strategy!=="matched-node"?{strategy:F.strategy}:{},...F.total>1||s!==null?{nth:{index:F.idx,total:F.total}}:{},...P.attempts>1?{attempts:P.attempts}:{},result:P.result},null,2));break}case"tap-best":{let e=a[1];e||(console.error(S("tap-best","<query>")),process.exit(1));let t=JSON.stringify(e),r=await L({textFallback:e,resolve:async()=>{let y=await u.send({type:"evaluate",code:`(async () => {
336
336
  const t = window.__sootsimTest
337
337
  if (!t) return { error: 'bridge-not-ready' }
338
338
  // try testID first \u2014 strongest signal of "this is the
@@ -415,7 +415,7 @@ ${n}
415
415
  },
416
416
  strategy: (resolved && resolved.strategy) || 'matched-node',
417
417
  }
418
- })()`})}),s=r.payload;(!s||typeof s.cx!="number")&&(console.error(` not found: ${e}`),await vo(u,e),process.exit(1)),I(r.result)||(z(`id "${e}"`,r),process.exit(1));let d=Ce(e,{id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},"id");await q("inspect tap-id",d.step,d.summary),console.log(JSON.stringify({matched:s.match,tapped:{nodeId:s.target?.nodeId??null,id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},...s.strategy&&s.strategy!=="matched-node"?{strategy:s.strategy}:{},...r.attempts>1?{attempts:r.attempts}:{},result:r.result},null,2));break}case"type-into":{let e=a[1],t=a.slice(2).join(" ");(!e||!t)&&(console.error(S("type-into","<id> <text>")),process.exit(1));let n=JSON.stringify(e),r=await u.send({type:"evaluate",code:`(async () => {
418
+ })()`})}),s=r.payload;(!s||typeof s.cx!="number")&&(console.error(` not found: ${e}`),await So(u,e),process.exit(1)),I(r.result)||(z(`id "${e}"`,r),process.exit(1));let d=Ce(e,{id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},"id");await q("inspect tap-id",d.step,d.summary),console.log(JSON.stringify({matched:s.match,tapped:{nodeId:s.target?.nodeId??null,id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},...s.strategy&&s.strategy!=="matched-node"?{strategy:s.strategy}:{},...r.attempts>1?{attempts:r.attempts}:{},result:r.result},null,2));break}case"type-into":{let e=a[1],t=a.slice(2).join(" ");(!e||!t)&&(console.error(S("type-into","<id> <text>")),process.exit(1));let n=JSON.stringify(e),r=await u.send({type:"evaluate",code:`(async () => {
419
419
  const t = window.__sootsimTest
420
420
  if (!t) return null
421
421
  const n = await (t.findByTestId(${n}) || t.findById(${n}))
@@ -429,7 +429,7 @@ ${n}
429
429
  isTextInput: !!n.isTextInput,
430
430
  placeholder: n.placeholder || null,
431
431
  }
432
- })()`});(!r||typeof r.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1)),r.isTextInput||console.error(` warning: ${e} is not a text input (isTextInput: false)`);let s=await u.send({type:"tap",x:r.cx,y:r.cy,target:{id:r.id??e,testID:r.testID??e,text:null,type:r.type??null}}),d=await Ao(u);d.visible||(console.error(` keyboard did not open after tapping ${e}`),process.exit(1));let m=d.focusedInput;m&&(m.testID===e||m.id===e||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(e)} but focus is on ${JSON.stringify(m.testID??m.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await u.send({type:"keyboard",action:"type",text:t}),await q("inspect type-into",{tapOn:{id:e},inputText:t},`type-into #${e} ${JSON.stringify(t)}`),console.log(JSON.stringify({target:e,isTextInput:r.isTextInput,keyboardOpened:d.visible??s?.keyboardOpened??!1,focusedInput:d.focusedInput??null,typed:t},null,2));break}case"type":{let e=a.slice(1).join(" ");e||(console.error(S("type","<text>")),process.exit(1)),await Se(u,"type"),await u.send({type:"keyboard",action:"type",text:e}),await q("inspect type",{inputText:e},`type ${JSON.stringify(e)}`),console.log(` typed: ${JSON.stringify(e)}`);break}case"key":{let e=a[1];e||(console.error(S("key","<name>")),process.exit(1)),await Se(u,"key"),await u.send({type:"keyboard",action:"press",text:e}),await q("inspect key",{pressKey:e},`key ${e}`),console.log(` pressed: ${e}`);break}case"key-sequence":{let e=a.slice(1);e.length===0&&(console.error(S("key-sequence","<key> [<key> ...]")),process.exit(1)),await Se(u,"key-sequence");for(let t of e)await u.send({type:"keyboard",action:"press",text:t});await q("inspect key-sequence",{pressKey:e.join(" ")},`key-sequence ${e.join(" ")}`),console.log(` pressed: ${e.join(", ")}`);break}case"keycode":{let e=a.slice(1);e.length===0&&(console.error(S("keycode","<code> [<code> ...]")),process.exit(1));let t=e.map(r=>({code:r,key:Po(r)})),n=t.filter(r=>!r.key);n.length>0&&(console.error(` unsupported keycode(s): ${n.map(r=>r.code).join(", ")}`),process.exit(1)),await Se(u,"keycode");for(let r of t)await u.send({type:"keyboard",action:"press",text:r.key});await q("inspect keycode",{pressKey:t.map(r=>r.key).join(" ")},`keycode ${e.join(" ")}`),console.log(` pressed: ${e.join(", ")}`);break}case"dispatch":{let e=a[1];e||(console.error(S("dispatch","<char>")),process.exit(1)),await u.send({type:"keyboard",action:"dispatchKey",text:e}),await q("inspect dispatch",{dispatchKey:e},`dispatch ${JSON.stringify(e)}`),console.log(` dispatched: ${e}`);break}case"dismiss":{await u.send({type:"keyboard",action:"dismiss"}),await q("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let e=Number(a[1]),t=Number(a[2]),n=pe(o);if(n){let m=await xe(u,n);m||(console.error(` not found: ${n.value}`),n.mode==="testid"&&V("wait-selector-for-missing-testid",n.value),process.exit(1)),e=m.x,t=m.y}let r=a[3]?Number(a[3]):80;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&(console.error(S("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let s=Math.max(0,Math.round(r)),d=await u.send({type:"evaluate",code:`(async () => {
432
+ })()`});(!r||typeof r.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1)),r.isTextInput||console.error(` warning: ${e} is not a text input (isTextInput: false)`);let s=await u.send({type:"tap",x:r.cx,y:r.cy,target:{id:r.id??e,testID:r.testID??e,text:null,type:r.type??null}}),d=await Po(u);d.visible||(console.error(` keyboard did not open after tapping ${e}`),process.exit(1));let m=d.focusedInput;m&&(m.testID===e||m.id===e||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(e)} but focus is on ${JSON.stringify(m.testID??m.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await u.send({type:"keyboard",action:"type",text:t}),await q("inspect type-into",{tapOn:{id:e},inputText:t},`type-into #${e} ${JSON.stringify(t)}`),console.log(JSON.stringify({target:e,isTextInput:r.isTextInput,keyboardOpened:d.visible??s?.keyboardOpened??!1,focusedInput:d.focusedInput??null,typed:t},null,2));break}case"type":{let e=a.slice(1).join(" ");e||(console.error(S("type","<text>")),process.exit(1)),await Se(u,"type"),await u.send({type:"keyboard",action:"type",text:e}),await q("inspect type",{inputText:e},`type ${JSON.stringify(e)}`),console.log(` typed: ${JSON.stringify(e)}`);break}case"key":{let e=a[1];e||(console.error(S("key","<name>")),process.exit(1)),await Se(u,"key"),await u.send({type:"keyboard",action:"press",text:e}),await q("inspect key",{pressKey:e},`key ${e}`),console.log(` pressed: ${e}`);break}case"key-sequence":{let e=a.slice(1);e.length===0&&(console.error(S("key-sequence","<key> [<key> ...]")),process.exit(1)),await Se(u,"key-sequence");for(let t of e)await u.send({type:"keyboard",action:"press",text:t});await q("inspect key-sequence",{pressKey:e.join(" ")},`key-sequence ${e.join(" ")}`),console.log(` pressed: ${e.join(", ")}`);break}case"keycode":{let e=a.slice(1);e.length===0&&(console.error(S("keycode","<code> [<code> ...]")),process.exit(1));let t=e.map(r=>({code:r,key:Oo(r)})),n=t.filter(r=>!r.key);n.length>0&&(console.error(` unsupported keycode(s): ${n.map(r=>r.code).join(", ")}`),process.exit(1)),await Se(u,"keycode");for(let r of t)await u.send({type:"keyboard",action:"press",text:r.key});await q("inspect keycode",{pressKey:t.map(r=>r.key).join(" ")},`keycode ${e.join(" ")}`),console.log(` pressed: ${e.join(", ")}`);break}case"dispatch":{let e=a[1];e||(console.error(S("dispatch","<char>")),process.exit(1)),await u.send({type:"keyboard",action:"dispatchKey",text:e}),await q("inspect dispatch",{dispatchKey:e},`dispatch ${JSON.stringify(e)}`),console.log(` dispatched: ${e}`);break}case"dismiss":{await u.send({type:"keyboard",action:"dismiss"}),await q("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let e=Number(a[1]),t=Number(a[2]),n=pe(o);if(n){let m=await xe(u,n);m||(console.error(` not found: ${n.value}`),n.mode==="testid"&&V("wait-selector-for-missing-testid",n.value),process.exit(1)),e=m.x,t=m.y}let r=a[3]?Number(a[3]):80;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&(console.error(S("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let s=Math.max(0,Math.round(r)),d=await u.send({type:"evaluate",code:`(async () => {
433
433
  const interact = window.__sootsimInteract
434
434
  if (interact?.doubleTap) {
435
435
  return {
@@ -471,12 +471,12 @@ ${n}
471
471
  statusBarHeight: spec.statusBarHeight || 0,
472
472
  homeIndicatorHeight: spec.homeIndicatorHeight || 0,
473
473
  }
474
- })()`}),s=Number(r?.width)||393,d=Number(r?.height)||852,m=Number(r?.statusBarHeight)||0,y=Number(r?.homeIndicatorHeight)||0,p=Math.round(s/2),x=Math.round(d/2),A=Math.max(24,m+18),H=Math.max(24,y+18),U=18,K=Math.min(220,Math.round(d*.24)),N=Math.min(180,Math.round(s*.32)),w=p,v=x,P=p,_=x;switch(t){case"scroll-up":v=x+Math.round(K/2),_=x-Math.round(K/2);break;case"scroll-down":v=x-Math.round(K/2),_=x+Math.round(K/2);break;case"scroll-left":w=p+Math.round(N/2),P=p-Math.round(N/2);break;case"scroll-right":w=p-Math.round(N/2),P=p+Math.round(N/2);break;case"swipe-from-left-edge":w=U,v=x,P=Math.min(s-U,U+N);break;case"swipe-from-right-edge":w=s-U,v=x,P=Math.max(U,s-U-N);break;case"swipe-from-top-edge":w=p,v=A,_=Math.min(d-H,A+K);break;case"swipe-from-bottom-edge":w=p,v=d-H,_=Math.max(A,d-H-K);break}let de=Math.max(8,Math.round(n/16)),G=Math.max(1,Math.round(n/de)),O=await u.send({type:"evaluate",code:`(async () => {
474
+ })()`}),s=Number(r?.width)||393,d=Number(r?.height)||852,m=Number(r?.statusBarHeight)||0,y=Number(r?.homeIndicatorHeight)||0,p=Math.round(s/2),x=Math.round(d/2),A=Math.max(24,m+18),H=Math.max(24,y+18),U=18,K=Math.min(220,Math.round(d*.24)),N=Math.min(180,Math.round(s*.32)),w=p,v=x,P=p,F=x;switch(t){case"scroll-up":v=x+Math.round(K/2),F=x-Math.round(K/2);break;case"scroll-down":v=x-Math.round(K/2),F=x+Math.round(K/2);break;case"scroll-left":w=p+Math.round(N/2),P=p-Math.round(N/2);break;case"scroll-right":w=p-Math.round(N/2),P=p+Math.round(N/2);break;case"swipe-from-left-edge":w=U,v=x,P=Math.min(s-U,U+N);break;case"swipe-from-right-edge":w=s-U,v=x,P=Math.max(U,s-U-N);break;case"swipe-from-top-edge":w=p,v=A,F=Math.min(d-H,A+K);break;case"swipe-from-bottom-edge":w=p,v=d-H,F=Math.max(A,d-H-K);break}let de=Math.max(8,Math.round(n/16)),G=Math.max(1,Math.round(n/de)),O=await u.send({type:"evaluate",code:`(async () => {
475
475
  const interact = window.__sootsimInteract
476
476
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
477
- const value = await interact.drag(${w}, ${v}, ${P}, ${_}, ${de}, ${G})
477
+ const value = await interact.drag(${w}, ${v}, ${P}, ${F}, ${de}, ${G})
478
478
  return { ok: !!value, value }
479
- })()`});O?.ok&&await q("inspect gesture",{swipe:{start:`${w}, ${v}`,end:`${P}, ${_}`,duration:Math.max(1,Math.round(n))}},`gesture ${t}`),console.log(JSON.stringify({preset:t,from:{x:w,y:v},to:{x:P,y:_},result:O},null,2));break}case"scroll":{let e=pe(o),t=Ro(o),n=e?.mode==="testid"?e.value:t==null?a[1]:null,r=e||t!=null?1:2,s=Number(a[r]),d=Number(a[r+1]);(!n&&t==null||!Number.isFinite(s)||!Number.isFinite(d))&&(console.error(S("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),process.exit(1));let m=await u.send({type:"evaluate",code:`(async () => {
479
+ })()`});O?.ok&&await q("inspect gesture",{swipe:{start:`${w}, ${v}`,end:`${P}, ${F}`,duration:Math.max(1,Math.round(n))}},`gesture ${t}`),console.log(JSON.stringify({preset:t,from:{x:w,y:v},to:{x:P,y:F},result:O},null,2));break}case"scroll":{let e=pe(o),t=Eo(o),n=e?.mode==="testid"?e.value:t==null?a[1]:null,r=e||t!=null?1:2,s=Number(a[r]),d=Number(a[r+1]);(!n&&t==null||!Number.isFinite(s)||!Number.isFinite(d))&&(console.error(S("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),process.exit(1));let m=await u.send({type:"evaluate",code:`(async () => {
480
480
  const t = window.__sootsimTest
481
481
  if (!t) return null
482
482
  const n = ${t!=null?`await t.inspectByNodeId(${JSON.stringify(t)})`:`await t.findByTestId(${JSON.stringify(n)})
@@ -567,7 +567,7 @@ ${n}
567
567
  ${h("shell")} open-card clock 800
568
568
  ${h("shell")} appearance dark
569
569
  ${h("shell")} lock
570
- `);break}let t=e==="launch"||e==="open-card"||e==="home"||e==="switcher",n=e==="launch"||e==="open-card"?a[3]:a[2],r=n?Number(n):350;t&&(!Number.isFinite(r)||r<0)&&(console.error(S("shell",e==="launch"||e==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let s=!1,d=!1,m=null,y=o.includes("--clear-state");if(e==="launch"){let p=a[2];p||(console.error(S("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),y&&await u.send({type:"evaluate",code:Ue}),s=!!await ue(u,"launchApp",r,p),{settled:d,state:m}=await ve(u,Math.round(r),x=>!!x&&x.state==="app"&&x.activeApp===p&&x.showSwitcher===!1&&x.switcherPhase==="idle"&&typeof x.launchProgress=="number"&&x.launchProgress>=.98),s&&await q("inspect shell launch",y?{launchApp:{clearState:!0}}:{launchApp:{}},y?"launch app (clear state)":"launch app")}else if(e==="home")s=!!await ue(u,"goHome",r),{settled:d,state:m}=await ve(u,Math.round(r),p=>!!p&&p.state==="home"&&p.activeApp==null&&p.showSwitcher===!1&&p.switcherPhase==="idle"&&typeof p.launchProgress=="number"&&p.launchProgress>=.98);else if(e==="switcher")s=!!await ue(u,"openSwitcher",r),{settled:d,state:m}=await ve(u,Math.round(r),p=>!!p&&p.state==="app"&&p.showSwitcher===!0&&p.switcherPhase==="idle"&&typeof p.zoomLevel=="number"&&Math.abs(p.zoomLevel)<=.02&&typeof p.horizontalZoom=="number"&&Math.abs(p.horizontalZoom)<=.02),d&&(await Q(Fo),m=await le(u));else if(e==="open-card"){let p=a[2];p||(console.error(S("shell","open-card <appId> [settleMs]")),process.exit(1)),s=!!await ue(u,"openSwitcherCard",r,p),{settled:d,state:m}=await ve(u,Math.round(r),x=>!!x&&x.state==="app"&&x.activeApp===p&&x.showSwitcher===!1&&x.switcherPhase==="idle"&&typeof x.zoomLevel=="number"&&x.zoomLevel>=.98&&typeof x.horizontalZoom=="number"&&x.horizontalZoom>=.98),s&&await q("inspect shell open-card",{openSwitcherCard:{appId:p}},`open switcher card ${p}`)}else if(e==="appearance"){let p=a[2];(!p||!["light","dark","auto","toggle"].includes(p))&&(console.error(S("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let x=await Wt(u,"appearance",p);if(s=!!x?.ok,m={appearance:x},s){let A=x?.applied??p;console.log(` appearance: ${A}`)}}else if(e==="lock"||e==="shake"){let p=await Wt(u,e);s=!!p?.ok,m={[e]:p}}else console.error(` unknown shell subcommand: ${e}`),process.exit(1);console.log(JSON.stringify({ok:s,settled:d,state:m},null,2));break}case"url":{await At(u,{args:l});break}case"reload":{let n=!1,r=!1;try{await u.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let m=await u.send({type:"evaluate",code:`;(() => {
570
+ `);break}let t=e==="launch"||e==="open-card"||e==="home"||e==="switcher",n=e==="launch"||e==="open-card"?a[3]:a[2],r=n?Number(n):350;t&&(!Number.isFinite(r)||r<0)&&(console.error(S("shell",e==="launch"||e==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let s=!1,d=!1,m=null,y=o.includes("--clear-state");if(e==="launch"){let p=a[2];p||(console.error(S("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),y&&await u.send({type:"evaluate",code:Ue}),s=!!await ue(u,"launchApp",r,p),{settled:d,state:m}=await ve(u,Math.round(r),x=>!!x&&x.state==="app"&&x.activeApp===p&&x.showSwitcher===!1&&x.switcherPhase==="idle"&&typeof x.launchProgress=="number"&&x.launchProgress>=.98),s&&await q("inspect shell launch",y?{launchApp:{clearState:!0}}:{launchApp:{}},y?"launch app (clear state)":"launch app")}else if(e==="home")s=!!await ue(u,"goHome",r),{settled:d,state:m}=await ve(u,Math.round(r),p=>!!p&&p.state==="home"&&p.activeApp==null&&p.showSwitcher===!1&&p.switcherPhase==="idle"&&typeof p.launchProgress=="number"&&p.launchProgress>=.98);else if(e==="switcher")s=!!await ue(u,"openSwitcher",r),{settled:d,state:m}=await ve(u,Math.round(r),p=>!!p&&p.state==="app"&&p.showSwitcher===!0&&p.switcherPhase==="idle"&&typeof p.zoomLevel=="number"&&Math.abs(p.zoomLevel)<=.02&&typeof p.horizontalZoom=="number"&&Math.abs(p.horizontalZoom)<=.02),d&&(await Q(Ao),m=await le(u));else if(e==="open-card"){let p=a[2];p||(console.error(S("shell","open-card <appId> [settleMs]")),process.exit(1)),s=!!await ue(u,"openSwitcherCard",r,p),{settled:d,state:m}=await ve(u,Math.round(r),x=>!!x&&x.state==="app"&&x.activeApp===p&&x.showSwitcher===!1&&x.switcherPhase==="idle"&&typeof x.zoomLevel=="number"&&x.zoomLevel>=.98&&typeof x.horizontalZoom=="number"&&x.horizontalZoom>=.98),s&&await q("inspect shell open-card",{openSwitcherCard:{appId:p}},`open switcher card ${p}`)}else if(e==="appearance"){let p=a[2];(!p||!["light","dark","auto","toggle"].includes(p))&&(console.error(S("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let x=await Ht(u,"appearance",p);if(s=!!x?.ok,m={appearance:x},s){let A=x?.applied??p;console.log(` appearance: ${A}`)}}else if(e==="lock"||e==="shake"){let p=await Ht(u,e);s=!!p?.ok,m={[e]:p}}else console.error(` unknown shell subcommand: ${e}`),process.exit(1);console.log(JSON.stringify({ok:s,settled:d,state:m},null,2));break}case"url":{await Pt(u,{args:l});break}case"reload":{let n=!1,r=!1;try{await u.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let m=await u.send({type:"evaluate",code:`;(() => {
571
571
  const reloadExternalApp = window.SootSim?.bridges?.hotRemount?.reloadExternalApp
572
572
  if (typeof reloadExternalApp === 'function') {
573
573
  reloadExternalApp()
@@ -575,7 +575,7 @@ ${n}
575
575
  }
576
576
  window.location.reload()
577
577
  return { kind: 'page' }
578
- })()`});r=!!m&&m.kind==="external-app",n=!0}catch{}console.log(" reloading...");let s=u,d=null;if(r)d=await Ae(u,{timeoutMs:1e4,errorGraceMs:3e3});else{n&&await Q(300);let m=await mt(F,J,T,{timeoutMs:1e4,simIdSource:R});m?(s=m,d=await Ae(m,{timeoutMs:1e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 10000ms"),s=null)}if(d)if(d.ready){let m=d.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${d.elapsedMs}ms: ${d.nodes} nodes${m}`)}else if(d.source==="error-bail")console.log(` \u26A0 reload bailed after ${d.elapsedMs}ms: ${d.errors} console error(s), ready signal never fired`);else{let m=Mo(d);console.log(` \u26A0 reload timed out after ${d.elapsedMs}ms \u2014 ${m} (nodes: ${d.nodes}, targets: ${d.targets}, errors: ${d.errors})`)}if(s)try{let m=await s.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors(10) || []"});if(s!==u&&s.close(),Array.isArray(m)&&m.length>0){console.log(`
578
+ })()`});r=!!m&&m.kind==="external-app",n=!0}catch{}console.log(" reloading...");let s=u,d=null;if(r)d=await Ae(u,{timeoutMs:1e4,errorGraceMs:3e3});else{n&&await Q(300);let m=await pt(_,J,T,{timeoutMs:1e4,simIdSource:R});m?(s=m,d=await Ae(m,{timeoutMs:1e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 10000ms"),s=null)}if(d)if(d.ready){let m=d.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${d.elapsedMs}ms: ${d.nodes} nodes${m}`)}else if(d.source==="error-bail")console.log(` \u26A0 reload bailed after ${d.elapsedMs}ms: ${d.errors} console error(s), ready signal never fired`);else{let m=Io(d);console.log(` \u26A0 reload timed out after ${d.elapsedMs}ms \u2014 ${m} (nodes: ${d.nodes}, targets: ${d.targets}, errors: ${d.errors})`)}if(s)try{let m=await s.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors(10) || []"});if(s!==u&&s.close(),Array.isArray(m)&&m.length>0){console.log(`
579
579
  \u26A0 ${m.length} error(s) during mount:
580
580
  `);for(let y of m){let p=y.args.map(x=>typeof x=="object"?JSON.stringify(x):x).join(" ");if(console.log(` ${p}`),y.stack){let x=y.stack.split(`
581
581
  `).slice(0,2);for(let A of x)console.log(` ${A.trim()}`)}}}}catch{}d&&!d.ready&&(process.exitCode=1);break}case"eval":case"js":{let e=a.slice(1).join(" ");e||(console.error(S("js","<javascript>")),console.error(""),console.error(" runs the snippet in the engine realm. SootSim is the"),console.error(" canonical state surface \u2014 reach into it directly."),console.error(""),console.error(" examples:"),console.error(` ${h("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${h("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${h("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${h("js")} SootSim.state.root.children.length`),process.exit(1));let t=e;t.startsWith("(async")||(t=`(async () => ${t})()`);let n=await u.send({type:"evaluate",code:t});console.log(JSON.stringify(n,null,2));let r=e.toLowerCase(),s=[];(r.includes("sootsim:gohome")||r.includes("gohome"))&&s.push("sootsim shell home"),(r.includes("sootsim:appswitcher")||r.includes("appswitcher"))&&s.push("sootsim shell switcher"),(r.includes("keyboard.isvisible")||r.includes("keyboard.getmode"))&&s.push("sootsim debug state keyboard"),r.includes("interact.tap")&&s.push("sootsim do tap <x> <y>"),r.includes("keyboard.type")&&s.push("sootsim do type <text>"),(r.includes("keyboard.press")||r.includes("keyboard.dispatchkey"))&&s.push("sootsim do key <name>"),r.includes("keyboard.dismiss")&&s.push("sootsim do dismiss"),r.includes("dumptree")&&s.push("sootsim get tree"),r.includes("dumpaccessibilitytree")&&s.push("sootsim get a11y"),r.includes("getnodecount")&&s.push("sootsim get count"),r.includes("findbytext")&&s.push("sootsim find <text>"),(r.includes("findbytestid")||r.includes("findbyid"))&&s.push("sootsim find --testid <id>"),r.includes("document.hidden")&&s.push("sootsim debug state keyboard (includes tab health)"),s.length>0&&V("prefer-cli-over-eval",s);break}case"globals":{let e=await u.send({type:"evaluate",code:`(async () => {
@@ -616,7 +616,7 @@ ${n}
616
616
 
617
617
  return globals
618
618
  })()`});console.log(` sootsim JS API:
619
- `);for(let[t,n]of Object.entries(e)){console.log(` ${t}:`);for(let r of n)console.log(` .${r}`);console.log("")}console.log(` use: ${h("js")} <expression>`),console.log(` example: ${h("js")} test.findByText("Sign in")`);break}case"describe":{await vt({bridge:u,args:o,positional:a});break}case"perf":{let e=a[1];if(!e||e==="--help"||e==="-h"){console.log(`
619
+ `);for(let[t,n]of Object.entries(e)){console.log(` ${t}:`);for(let r of n)console.log(` .${r}`);console.log("")}console.log(` use: ${h("js")} <expression>`),console.log(` example: ${h("js")} test.findByText("Sign in")`);break}case"describe":{await St({bridge:u,args:o,positional:a});break}case"perf":{let e=a[1];if(!e||e==="--help"||e==="-h"){console.log(`
620
620
  ${h("perf")} \u2014 performance profiling
621
621
 
622
622
  subcommands:
@@ -875,7 +875,7 @@ ${n}
875
875
  examples:
876
876
  ${h("perf")} transition goHome --timeout 10000
877
877
  ${h("perf")} transition appSwitcher
878
- `);break}let r=`sootsim:${t}`;Fe(` profiling ${t} transition...`),Fe(" (use --timeout 10000 if this times out)");let s=await u.send({type:"evaluate",code:`(async () => {
878
+ `);break}let r=`sootsim:${t}`;_e(` profiling ${t} transition...`),_e(" (use --timeout 10000 if this times out)");let s=await u.send({type:"evaluate",code:`(async () => {
879
879
  // only supported in render-worker mode
880
880
  if (!window.__sootsimRenderHost) {
881
881
  return { error: 'transition profiling requires render-worker mode' }
@@ -952,29 +952,29 @@ ${n}
952
952
  p50: ${s.p50.toFixed(2)}ms
953
953
  p95: ${s.p95.toFixed(2)}ms
954
954
  p99: ${s.p99.toFixed(2)}ms
955
- jank: ${s.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(s.samples)&&s.samples.length>0&&(console.log(""),Ee(s.samples.map(y=>y[1])));break}default:console.error(` unknown perf subcommand: ${e}`),console.error(" valid: stats, start, stop, frames, worst, transition"),/^--?reset$/.test(e)&&console.error(" note: 'perf start' already clears prior frames \u2014 no reset needed"),process.exit(1)}break}case"errors":{let e=a[1];if(e==="clear"){await ot(u),E(l)?C({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,n=await et(u,t);if(E(l)){C(n);break}if(n.length===0){console.log(" no errors captured");break}console.log(` ${n.length} error(s):
955
+ jank: ${s.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(s.samples)&&s.samples.length>0&&(console.log(""),Ee(s.samples.map(y=>y[1])));break}default:console.error(` unknown perf subcommand: ${e}`),console.error(" valid: stats, start, stop, frames, worst, transition"),/^--?reset$/.test(e)&&console.error(" note: 'perf start' already clears prior frames \u2014 no reset needed"),process.exit(1)}break}case"errors":{let e=a[1];if(e==="clear"){await st(u),E(l)?C({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,n=await tt(u,t);if(E(l)){C(n);break}if(n.length===0){console.log(" no errors captured");break}console.log(` ${n.length} error(s):
956
956
  `);for(let r of n){let s=re(r.timestamp),d=r.args.map(m=>typeof m=="object"?JSON.stringify(m):m).join(" ");if(console.log(` [${s}] ${d}`),r.stack){let m=r.stack.split(`
957
- `).slice(0,3);for(let y of m)console.log(` ${y.trim()}`)}}break}case"warnings":{let e=a[1]?Number(a[1]):20,t=await tt(u,e);if(E(l)){C(t);break}if(t.length===0){console.log(" no warnings captured");break}console.log(` ${t.length} warning(s):
957
+ `).slice(0,3);for(let y of m)console.log(` ${y.trim()}`)}}break}case"warnings":{let e=a[1]?Number(a[1]):20,t=await ot(u,e);if(E(l)){C(t);break}if(t.length===0){console.log(" no warnings captured");break}console.log(` ${t.length} warning(s):
958
958
  `);for(let n of t){let r=re(n.timestamp),s=n.args.map(d=>typeof d=="object"?JSON.stringify(d):d).join(" ");console.log(` [${r}] ${s}`)}break}case"animations":{let e=await X(u,"listAnimations")??[];if(o.includes("--json")){console.log(JSON.stringify(e,null,2));break}if(e.length===0){console.log(" no active animations");break}console.log(` ${e.length} active animation(s):
959
- `);for(let t of e){let n=String(t.kind).padEnd(6),r=`${Number(t.from).toFixed(2)}\u2192${Number(t.to).toFixed(2)}`,s=Number(t.current??0).toFixed(2),d=`${Math.round((t.progress??0)*100)}%`,m=`${Math.round(t.elapsedMs??0)}ms`,y=t.loop?" loop":"",p=t.layoutBound?" layout":"";console.log(` #${t.id} ${n} ${r.padEnd(14)} cur=${s.padEnd(7)} ${d.padStart(4)} ${m}${y}${p}`)}break}case"animation":{let e=a[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${h("animation")} <id>`),process.exit(1));let t=Number(e);Number.isFinite(t)||(console.error(` invalid id: ${e}`),process.exit(1));let n=await X(u,"getAnimation",t);console.log(JSON.stringify(n,null,2));break}case"stop-animation":{let e=a[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${h("stop-animation")} <id|all>`),process.exit(1));let t=e==="all"?"all":Number(e);t!=="all"&&!Number.isFinite(t)&&(console.error(` invalid id: ${e}`),process.exit(1));let n=await X(u,"stopAnimation",t);console.log(` stopped ${n??0} animation(s)`);break}case"requests":{let e=a[1];if(e==="clear"){await nt(u),E(l)?C({cleared:!0}):console.log(" request buffer cleared");break}let t=e==="all",n=t?a[2]:e,r=n?Number(n):20,s=await st(u,{failed:!t,limit:r});if(E(l)){C(s);break}if(s.length===0){console.log(t?" no requests captured":" no failed requests captured");break}console.log(` ${s.length} ${t?"request(s)":"failed request(s)"}:
959
+ `);for(let t of e){let n=String(t.kind).padEnd(6),r=`${Number(t.from).toFixed(2)}\u2192${Number(t.to).toFixed(2)}`,s=Number(t.current??0).toFixed(2),d=`${Math.round((t.progress??0)*100)}%`,m=`${Math.round(t.elapsedMs??0)}ms`,y=t.loop?" loop":"",p=t.layoutBound?" layout":"";console.log(` #${t.id} ${n} ${r.padEnd(14)} cur=${s.padEnd(7)} ${d.padStart(4)} ${m}${y}${p}`)}break}case"animation":{let e=a[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${h("animation")} <id>`),process.exit(1));let t=Number(e);Number.isFinite(t)||(console.error(` invalid id: ${e}`),process.exit(1));let n=await X(u,"getAnimation",t);console.log(JSON.stringify(n,null,2));break}case"stop-animation":{let e=a[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${h("stop-animation")} <id|all>`),process.exit(1));let t=e==="all"?"all":Number(e);t!=="all"&&!Number.isFinite(t)&&(console.error(` invalid id: ${e}`),process.exit(1));let n=await X(u,"stopAnimation",t);console.log(` stopped ${n??0} animation(s)`);break}case"requests":{let e=a[1];if(e==="clear"){await rt(u),E(l)?C({cleared:!0}):console.log(" request buffer cleared");break}let t=e==="all",n=t?a[2]:e,r=n?Number(n):20,s=await nt(u,{failed:!t,limit:r});if(E(l)){C(s);break}if(s.length===0){console.log(t?" no requests captured":" no failed requests captured");break}console.log(` ${s.length} ${t?"request(s)":"failed request(s)"}:
960
960
  `);for(let d of s){let m=re(d.timestamp);console.log(` [${m}] ${ee(d)}`),d.responseBody?console.log(` ${d.responseBody}`):d.error&&console.log(` ${d.error}`)}break}case"network":{let e=a[1],t=null,n=null,r=!1,s=!1,d=1e3,m=!1,y=!1;for(let N=0;N<l.length;N++){let w=l[N];if(w==="--filter")t=l[N+1]??null,N++;else if(w==="--limit"){let v=Number(l[N+1]);Number.isFinite(v)&&(n=v),N++}else if(w==="--threshold"){let v=Number(l[N+1]);Number.isFinite(v)&&v>0&&(d=v),N++}else w==="--failed"?r=!0:w==="--slow"?s=!0:w==="--tail"||w==="-f"?m=!0:w==="--json"&&(y=!0)}if(e==="clear"){await u.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(e==="get"){let N=a[2];N||(console.error(" usage: sootsim network get <id>"),process.exit(1));let w=await u.send({type:"evaluate",code:`(() => {
961
961
  const obs = window.__sootsimObservability;
962
962
  if (!obs) return null;
963
963
  return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(N)}) || null;
964
- })()`});w||(console.error(` no entry with id ${N}`),process.exit(1)),y?console.log(JSON.stringify(w,null,2)):Io(w);break}let p=n??(m?200:e?Number(e):20);Number.isFinite(p)||(console.error(` invalid limit: ${e} \u2014 \`network\` takes a numeric count (e.g. ${h("network")} 100).
964
+ })()`});w||(console.error(` no entry with id ${N}`),process.exit(1)),y?console.log(JSON.stringify(w,null,2)):No(w);break}let p=n??(m?200:e?Number(e):20);Number.isFinite(p)||(console.error(` invalid limit: ${e} \u2014 \`network\` takes a numeric count (e.g. ${h("network")} 100).
965
965
  to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let x=async()=>{let N=await u.send({type:"evaluate",code:`(() => {
966
966
  const obs = window.__sootsimObservability;
967
967
  if (!obs) return { ok: false };
968
968
  return { ok: true, entries: obs.network.getSnapshot() };
969
969
  })()`});if(!N||!N.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return N.entries??[]},A=N=>{let w=N;if(r&&(w=w.filter(v=>!!v.error||v.status!=null&&v.status>=400)),s&&(w=w.filter(v=>v.durationMs!=null&&v.durationMs>=d)),t){let v=t.toLowerCase();w=w.filter(P=>(P.displayUrl||P.url).toLowerCase().includes(v))}return s&&!m&&(w=[...w].sort((v,P)=>(P.durationMs??0)-(v.durationMs??0))),w};if(!m){let N=await x(),w=A(N).slice(-p);if(y){console.log(JSON.stringify(w,null,2));break}if(w.length===0){N.length===0?console.log(" no network requests captured"):console.log(s?` no requests slower than ${d}ms (${N.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(s?` ${w.length} request(s) slower than ${d}ms (sorted by duration desc):
970
970
  `:` ${w.length} request(s):
971
- `);for(let v of w)jt(v);break}console.log(` tailing network (ctrl-c to stop)...
972
- `);let H=new Set,U=!0,K=()=>{U=!1};process.on("SIGINT",K);try{for(;U;){let N=await x(),w=A(N);for(let v of w)v.durationMs!=null&&(H.has(v.id)||(H.add(v.id),y?console.log(JSON.stringify(v)):jt(v)));await Q(250)}}finally{process.off("SIGINT",K)}break}case"logs":{let e=a[1],t=null,n=null,r=null,s=!1,d=!1,m=!1;for(let w=0;w<l.length;w++){let v=l[w];if(v==="--filter")t=l[w+1]??null,w++;else if(v==="--limit"){let P=Number(l[w+1]);Number.isFinite(P)&&(n=P),w++}else v==="--level"?(r=l[w+1]??null,w++):v==="--tail"||v==="-f"?s=!0:v==="--json"?d=!0:(v==="--internal"||v==="--all")&&(m=!0)}let y=r?new Set(r.split(",").map(w=>w.trim()).filter(w=>w==="log"||w==="info"||w==="warn"||w==="error"||w==="debug")):null;if(e==="clear"){await it(u),console.log(" log buffer cleared");break}let p=!d&&process.stdout.isTTY===!0,x=n??(s?500:e?Number(e):50);Number.isFinite(x)||(console.error(` invalid limit: ${e} \u2014 \`logs\` takes a numeric count (e.g. ${h("logs")} 100).
973
- to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let A=()=>rt(u),H=w=>at(w,{level:y,filter:t,showInternal:m});if(!s){let w=await A(),v=H(w).slice(-x);if(d){console.log(JSON.stringify(v,null,2));break}if(v.length===0){console.log(w.length===0?" no logs captured":" no matching logs");break}console.log(` ${v.length} log(s):
974
- `);for(let P of v)Lt(P,p);break}console.log(` tailing logs (ctrl-c to stop)...
975
- `);let U=new Set,K=!0,N=()=>{K=!1};process.on("SIGINT",N);try{for(;K;){let w=await A(),v=H(w);for(let P of v)U.has(P.id)||(U.add(P.id),d?console.log(JSON.stringify(P)):Lt(P,p));await Q(250)}}finally{process.off("SIGINT",N)}break}default:console.error(` unknown subcommand: ${g}`),process.exit(1)}if(ce.has(g)&&!o.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&await $(u),!j.has(g)&&!E(l))try{await ae(u)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);console.error(` ${g??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),s=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await ht(u,F,n[1]);else if(/^no sim connected$/.test(t))yt(F);else if(r)if(await $o(u)){let m=g??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
971
+ `);for(let v of w)Jt(v);break}console.log(` tailing network (ctrl-c to stop)...
972
+ `);let H=new Set,U=!0,K=()=>{U=!1};process.on("SIGINT",K);try{for(;U;){let N=await x(),w=A(N);for(let v of w)v.durationMs!=null&&(H.has(v.id)||(H.add(v.id),y?console.log(JSON.stringify(v)):Jt(v)));await Q(250)}}finally{process.off("SIGINT",K)}break}case"logs":{let e=a[1],t=null,n=null,r=null,s=!1,d=!1,m=!1;for(let w=0;w<l.length;w++){let v=l[w];if(v==="--filter")t=l[w+1]??null,w++;else if(v==="--limit"){let P=Number(l[w+1]);Number.isFinite(P)&&(n=P),w++}else v==="--level"?(r=l[w+1]??null,w++):v==="--tail"||v==="-f"?s=!0:v==="--json"?d=!0:(v==="--internal"||v==="--all")&&(m=!0)}let y=r?new Set(r.split(",").map(w=>w.trim()).filter(w=>w==="log"||w==="info"||w==="warn"||w==="error"||w==="debug")):null;if(e==="clear"){await at(u),console.log(" log buffer cleared");break}let p=!d&&process.stdout.isTTY===!0,x=n??(s?500:e?Number(e):50);Number.isFinite(x)||(console.error(` invalid limit: ${e} \u2014 \`logs\` takes a numeric count (e.g. ${h("logs")} 100).
973
+ to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let A=()=>it(u),H=w=>lt(w,{level:y,filter:t,showInternal:m});if(!s){let w=await A(),v=H(w).slice(-x);if(d){console.log(JSON.stringify(v,null,2));break}if(v.length===0){console.log(w.length===0?" no logs captured":" no matching logs");break}console.log(` ${v.length} log(s):
974
+ `);for(let P of v)qt(P,p);break}console.log(` tailing logs (ctrl-c to stop)...
975
+ `);let U=new Set,K=!0,N=()=>{K=!1};process.on("SIGINT",N);try{for(;K;){let w=await A(),v=H(w);for(let P of v)U.has(P.id)||(U.add(P.id),d?console.log(JSON.stringify(P)):qt(P,p));await Q(250)}}finally{process.off("SIGINT",N)}break}default:console.error(` unknown subcommand: ${g}`),process.exit(1)}if(ce.has(g)&&!o.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&!await Ke(u,g)&&await $(u),!j.has(g)&&!E(l))try{await ae(u)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);console.error(` ${g??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),s=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await bt(u,_,n[1]);else if(/^no sim connected$/.test(t))ht(_);else if(r)if(await vo(u)){let m=g??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
976
976
  the screen's node tree is large; narrow the query or raise the budget:
977
977
  sootsim ${m} --testid <id> # scope to one subtree
978
978
  sootsim find --testid <id> # targeted single-node lookup
979
979
  sootsim ${m} --timeout 60000 # raise per-command budget (ms)
980
- `)}else Bt();else if(s)Bt();else{try{await pt(u)}catch{}try{await fe({includeTail:!0})}catch{}try{await ne({includeTail:!0})}catch{}}process.exit(1)}finally{u.close()}}export{yn as runInspect};
980
+ `)}else jt();else if(s)jt();else{try{await ft(u)}catch{}try{await fe({includeTail:!0})}catch{}try{await ne({includeTail:!0})}catch{}}process.exit(1)}finally{u.close()}}export{hn as runInspect};
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.93 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as o}from"./chunk-WVNXRYKC.js";import"./chunk-HVOCWWIV.js";import"./chunk-I4M7NBKY.js";import"./chunk-JLFCHU45.js";import"./chunk-WPPSP6UG.js";import"./chunk-M5P3ULHQ.js";import"./chunk-LWCVNHLT.js";import"./chunk-IWEKZVXW.js";import"./chunk-M4QXOCCY.js";import"./chunk-EOEORGPV.js";async function t(n){console.error(" note: `sootsim install` is now `sootsim setup-repo`. forwarding\u2026\n"),await o(n)}export{t as runInstall};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.92 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as b}from"./chunk-U3SHSZHL.js";import{a as x}from"./chunk-YKDHVRVG.js";import"./chunk-OERYXTZA.js";import{spawn as v,spawnSync as u}from"child_process";import{chmodSync as S,copyFileSync as T,createWriteStream as E,existsSync as w,mkdirSync as y,rmSync as g,statSync as P,unlinkSync as D}from"fs";import{tmpdir as M}from"os";import{dirname as A,join as f,resolve as k}from"path";var h="https://sootbean.com/api/electron-release";function O(){let n=process.arch;if(process.platform==="darwin"){let o=n==="arm64"?"mac-arm64":"mac-x64",e=`sootsim-latest-${o}.dmg`;return{platform:o,filename:e,url:`${h}/${e}`,install:L}}if(process.platform==="linux"){let o=n==="arm64"?"linux-arm64":"linux-x64",e=`sootsim-latest-${o}.AppImage`;return{platform:o,filename:e,url:`${h}/${e}`,install:C}}if(process.platform==="win32"){let o="sootsim-latest-win-x64.exe";return{platform:"win-x64",filename:o,url:`${h}/${o}`,install:B}}return null}async function _({url:n,dest:o,onProgress:e}){let s=await fetch(n,{redirect:"follow"});if(!s.ok)throw new Error(`download failed: ${s.status} ${s.statusText} (${n})`);let t=s.headers.get("content-length"),a=t?Number(t):null;if(!s.body)throw new Error("download failed: empty response body");y(A(o),{recursive:!0});let i=E(o),d=s.body.getReader(),c=0;try{for(;;){let{done:l,value:p}=await d.read();if(l)break;i.write(Buffer.from(p)),c+=p.byteLength,e?.(c,a)}}finally{await new Promise((l,p)=>{i.end(r=>r?p(r):l())})}}function I(n,o){let e=(n/1048576).toFixed(1);if(!o)return` ${e} MB`;let s=Math.min(100,Math.round(n/o*100)),t=(o/(1024*1024)).toFixed(1),a=24,i=Math.round(s/100*a);return` ${"\u2588".repeat(i)+"\u2591".repeat(a-i)} ${s}% ${e} / ${t} MB`}async function L(n){let o=u("hdiutil",["attach","-nobrowse","-readonly",n],{encoding:"utf8"});if(o.status!==0)throw new Error(`hdiutil attach failed: ${o.stderr||o.stdout}`.trim());let e=o.stdout.trim().split(`
1
+ /*! sootsim v0.1.93 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as b}from"./chunk-HVOCWWIV.js";import{a as x}from"./chunk-TRS52XH4.js";import"./chunk-EOEORGPV.js";import{spawn as v,spawnSync as u}from"child_process";import{chmodSync as S,copyFileSync as T,createWriteStream as E,existsSync as w,mkdirSync as y,rmSync as g,statSync as P,unlinkSync as D}from"fs";import{tmpdir as M}from"os";import{dirname as A,join as f,resolve as k}from"path";var h="https://sootbean.com/api/electron-release";function O(){let n=process.arch;if(process.platform==="darwin"){let o=n==="arm64"?"mac-arm64":"mac-x64",e=`sootsim-latest-${o}.dmg`;return{platform:o,filename:e,url:`${h}/${e}`,install:L}}if(process.platform==="linux"){let o=n==="arm64"?"linux-arm64":"linux-x64",e=`sootsim-latest-${o}.AppImage`;return{platform:o,filename:e,url:`${h}/${e}`,install:C}}if(process.platform==="win32"){let o="sootsim-latest-win-x64.exe";return{platform:"win-x64",filename:o,url:`${h}/${o}`,install:B}}return null}async function _({url:n,dest:o,onProgress:e}){let s=await fetch(n,{redirect:"follow"});if(!s.ok)throw new Error(`download failed: ${s.status} ${s.statusText} (${n})`);let t=s.headers.get("content-length"),a=t?Number(t):null;if(!s.body)throw new Error("download failed: empty response body");y(A(o),{recursive:!0});let i=E(o),d=s.body.getReader(),c=0;try{for(;;){let{done:l,value:p}=await d.read();if(l)break;i.write(Buffer.from(p)),c+=p.byteLength,e?.(c,a)}}finally{await new Promise((l,p)=>{i.end(r=>r?p(r):l())})}}function I(n,o){let e=(n/1048576).toFixed(1);if(!o)return` ${e} MB`;let s=Math.min(100,Math.round(n/o*100)),t=(o/(1024*1024)).toFixed(1),a=24,i=Math.round(s/100*a);return` ${"\u2588".repeat(i)+"\u2591".repeat(a-i)} ${s}% ${e} / ${t} MB`}async function L(n){let o=u("hdiutil",["attach","-nobrowse","-readonly",n],{encoding:"utf8"});if(o.status!==0)throw new Error(`hdiutil attach failed: ${o.stderr||o.stdout}`.trim());let e=o.stdout.trim().split(`
3
3
  `),t=e[e.length-1].split(" ").pop()?.trim();if(!t||!w(t))throw new Error(`could not determine dmg mount point (output: ${o.stdout})`);let a=f(t,"sootsim.app");if(!w(a))throw u("hdiutil",["detach","-force",t]),new Error(`sootsim.app not found inside ${t}`);let i="/Applications",d=k(process.env.HOME||"","Applications"),c=i;try{let m=f(i,`.sootsim-write-probe-${process.pid}`);u("touch",[m]),w(m)?g(m,{force:!0}):c=d}catch{c=d}c===d&&y(c,{recursive:!0});let l=f(c,"sootsim.app");w(l)&&g(l,{recursive:!0,force:!0});let p=u("cp",["-R",a,l]),r=u("hdiutil",["detach","-force",t]);if(p.status!==0)throw new Error(`copy to ${l} failed: ${p.stderr?.toString()||""}`.trim());return r.status!==0&&console.warn(` warning: failed to unmount ${t} (${r.stderr?.toString().trim()||"unknown error"})`),u("xattr",["-dr","com.apple.quarantine",l]),l}async function C(n){let o=k(process.env.HOME||"","Applications");y(o,{recursive:!0});let e=f(o,"sootsim.AppImage");return w(e)&&g(e,{force:!0}),T(n,e),D(n),S(e,493),e}async function B(n){return await new Promise((o,e)=>{let s=v("cmd",["/c","start",'""',"/wait",n],{stdio:"inherit"});s.once("error",e),s.once("exit",t=>{t===0?o():e(new Error(`installer exited with code ${t}`))})}),n}async function G(n){(n.includes("--help")||n.includes("-h"))&&(console.log(`
4
4
  sootsim install-desktop \u2014 download and install the optional desktop GUI
5
5
 
@@ -20,4 +20,4 @@ examples:
20
20
  `),process.exit(0));let o=n.includes("--yes")||n.includes("-y")||process.env.SOOTSIM_NO_PROMPT==="1"||process.env.CI==="1"||!process.stdin.isTTY,e=n.includes("--force"),s=x();if(s&&!e){console.log(` sootsim desktop already installed at: ${s.path}`),console.log(" pass --force to reinstall.");return}let t=O();if(t||(console.error(` no desktop build available for ${process.platform}/${process.arch}.`),console.error(" supported: darwin-arm64, darwin-x64, linux-x64, win32-x64"),process.exit(1)),console.log(` platform: ${t.platform}`),console.log(` download: ${t.url}`),console.log(),!o){if(!await b("download and install now?",!0)){console.log(" cancelled.");return}console.log()}let a=f(M(),`sootsim-install-${Date.now()}`),i=f(a,t.filename),d=0;process.stdout.write(` downloading ${t.filename}...
21
21
  `);try{await _({url:t.url,dest:i,onProgress:(r,m)=>{let $=Date.now();$-d<100&&r<(m??1/0)||(d=$,process.stdout.isTTY&&process.stdout.write(`\r\x1B[2K${I(r,m)}`))}})}catch(r){g(a,{recursive:!0,force:!0}),console.error(`
22
22
  download failed: ${r instanceof Error?r.message:String(r)}`),process.exit(1)}process.stdout.isTTY&&process.stdout.write(`
23
- `);let c=P(i).size;console.log(` downloaded ${(c/(1024*1024)).toFixed(1)} MB`),console.log(),console.log(" installing...");let{trackCliEvent:l,flushCliTelemetry:p}=await import("./telemetry-V6K2OLDO.js");try{let r=await t.install(i);l({event:"cli_install_desktop_succeeded",properties:{platform:t.platform,size_bytes:c}}),console.log(` installed: ${r}`)}catch(r){l({event:"cli_install_desktop_failed",properties:{platform:t.platform,error:r instanceof Error?r.message:String(r)}}),await p(),console.error(` install failed: ${r instanceof Error?r.message:String(r)}`),console.error(` keeping download at ${i} for manual install.`),process.exit(1)}finally{g(a,{recursive:!0,force:!0})}console.log(),console.log(" next steps:"),console.log(" sootsim electron launch the desktop app"),console.log(" sootsim open <target> open a demo or bundle in it")}export{G as runInstallDesktop};
23
+ `);let c=P(i).size;console.log(` downloaded ${(c/(1024*1024)).toFixed(1)} MB`),console.log(),console.log(" installing...");let{trackCliEvent:l,flushCliTelemetry:p}=await import("./telemetry-IJO3ZRR5.js");try{let r=await t.install(i);l({event:"cli_install_desktop_succeeded",properties:{platform:t.platform,size_bytes:c}}),console.log(` installed: ${r}`)}catch(r){l({event:"cli_install_desktop_failed",properties:{platform:t.platform,error:r instanceof Error?r.message:String(r)}}),await p(),console.error(` install failed: ${r instanceof Error?r.message:String(r)}`),console.error(` keeping download at ${i} for manual install.`),process.exit(1)}finally{g(a,{recursive:!0,force:!0})}console.log(),console.log(" next steps:"),console.log(" sootsim electron launch the desktop app"),console.log(" sootsim open <target> open a demo or bundle in it")}export{G as runInstallDesktop};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.92 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as l,b as d,c as k,d as y,e as g}from"./chunk-QI2OP27K.js";import{d as c}from"./chunk-FIVCAZN5.js";import"./chunk-FONTNW4J.js";import"./chunk-OERYXTZA.js";async function a(){let s=await c();return s?.token||(process.stderr.write(" sootsim keys ... needs you to be signed in.\n run `sootsim login` first.\n"),process.exit(1)),{origin:s.origin,token:s.token}}function f(s){if(!s)return"never";try{return new Date(s).toLocaleString()}catch{return s}}async function h(s){let i=s[0];if(!i||i==="--help"||i==="-h"){u();return}if(i==="list"){let{origin:o,token:e}=await a(),n=await fetch(`${o.replace(/\/$/,"")}/api/sootsim/billing/keys`,{headers:{authorization:`Bearer ${e}`}});n.ok||(console.error(` keys list failed (${n.status})`),process.exit(1));let{keys:r}=await n.json();if(r.length===0){console.log(" no keys. create one with `sootsim keys create <label>`.");return}for(let t of r)console.log(` ${t.keyPrefix}\u2026 ${t.label.padEnd(24)} scopes=${t.scopes.join(",")} last=${f(t.lastUsedAt)} id=${t.id}`);return}if(i==="create"){let o=s[1]?.trim();o||(console.error(" usage: sootsim keys create <label>"),process.exit(1));let{origin:e,token:n}=await a(),r=await fetch(`${e.replace(/\/$/,"")}/api/sootsim/billing/keys`,{method:"POST",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({label:o})});r.ok||(console.error(` keys create failed (${r.status}): ${await r.text()}`),process.exit(1));let t=await r.json();console.log(`
1
+ /*! sootsim v0.1.93 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as l,b as d,c as k,d as y,e as g}from"./chunk-F5FIYZXA.js";import{d as c}from"./chunk-LWCVNHLT.js";import"./chunk-M4QXOCCY.js";import"./chunk-EOEORGPV.js";async function a(){let s=await c();return s?.token||(process.stderr.write(" sootsim keys ... needs you to be signed in.\n run `sootsim login` first.\n"),process.exit(1)),{origin:s.origin,token:s.token}}function f(s){if(!s)return"never";try{return new Date(s).toLocaleString()}catch{return s}}async function h(s){let i=s[0];if(!i||i==="--help"||i==="-h"){u();return}if(i==="list"){let{origin:o,token:e}=await a(),n=await fetch(`${o.replace(/\/$/,"")}/api/sootsim/billing/keys`,{headers:{authorization:`Bearer ${e}`}});n.ok||(console.error(` keys list failed (${n.status})`),process.exit(1));let{keys:r}=await n.json();if(r.length===0){console.log(" no keys. create one with `sootsim keys create <label>`.");return}for(let t of r)console.log(` ${t.keyPrefix}\u2026 ${t.label.padEnd(24)} scopes=${t.scopes.join(",")} last=${f(t.lastUsedAt)} id=${t.id}`);return}if(i==="create"){let o=s[1]?.trim();o||(console.error(" usage: sootsim keys create <label>"),process.exit(1));let{origin:e,token:n}=await a(),r=await fetch(`${e.replace(/\/$/,"")}/api/sootsim/billing/keys`,{method:"POST",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({label:o})});r.ok||(console.error(` keys create failed (${r.status}): ${await r.text()}`),process.exit(1));let t=await r.json();console.log(`
3
3
  created: ${t.record.label} (${t.record.keyPrefix}\u2026)`),console.log(` scopes: ${t.record.scopes.join(",")}`),console.log(`
4
4
  secret: ${t.secret}
5
5
  `),console.log(` copy this now \u2014 we can't show it again.
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.92 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-OE4Z6WGR.js";import{b as m}from"./chunk-2C6ZEOSP.js";import{a as u}from"./chunk-YKDHVRVG.js";import"./chunk-6DAMSZFH.js";import"./chunk-N4MF6AQR.js";import"./chunk-OJSVBBKS.js";import{D as c,E as r,F as l,y as s,z as a}from"./chunk-FONTNW4J.js";import"./chunk-OERYXTZA.js";import{spawn as p}from"child_process";import{existsSync as h}from"fs";async function I(n){if(n.includes("--help")||n.includes("-h")){console.log(`
1
+ /*! sootsim v0.1.93 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-QHPFVK62.js";import{b as m}from"./chunk-DSHYPD5A.js";import{a as u}from"./chunk-TRS52XH4.js";import"./chunk-ALNQTDSH.js";import"./chunk-FRFSAMOW.js";import"./chunk-3IFMI2MH.js";import{D as c,E as r,F as l,y as s,z as a}from"./chunk-M4QXOCCY.js";import"./chunk-EOEORGPV.js";import{spawn as p}from"child_process";import{existsSync as h}from"fs";async function I(n){if(n.includes("--help")||n.includes("-h")){console.log(`
3
3
  sootsim launch \u2014 one-shot: install runtime if needed, start daemon, open app
4
4
 
5
5
  usage:
@@ -13,4 +13,4 @@ options:
13
13
  examples:
14
14
  sootsim launch
15
15
  sootsim launch --version 1.2.3
16
- `);return}let e=n.includes("--no-runtime-install"),i=n.indexOf("--channel"),t=i>=0&&n[i+1]?n[i+1]:"stable",o=n.indexOf("--version"),f=o>=0&&n[o+1]?n[o+1]:void 0;s(),await v({skipAutoInstall:e,channel:t,explicitVersion:f}),await d(),await x()}async function v(n){let e=a(),i=c();if(e&&i)return;n.skipAutoInstall&&(console.error(" no sootsim runtime installed. run `sootsim runtime install` first, or drop --no-runtime-install."),process.exit(1)),console.log("sootsim: first run \u2014 installing runtime");let{runRuntime:t}=await import("./runtime-TIWRPSKS.js"),o=[];n.explicitVersion&&o.push(n.explicitVersion),n.channel!=="stable"&&o.push("--channel",n.channel),await t(["install",...o],{channel:n.channel})}async function d(){let n=r();if(l(n))return;console.log("sootsim: starting daemon");let e=w();p(e,["server","--quiet"],{detached:!0,stdio:"ignore",env:process.env}).unref();let t=Date.now()+8e3;for(;Date.now()<t;){let o=r();if(l(o))return;await g(150)}console.error(" daemon didn't become ready within 8s \u2014 check ~/.sootsim/ or run `sootsim server` in a terminal to see errors"),process.exit(1)}async function x(){u()||(console.error(" no sootsim desktop companion installed. run `sootsim install-desktop` to download electron + the shell."),process.exit(1));let e=await m.launch({});e.launched||(console.error(` ${e.message}`),process.exit(1)),console.log(` ${e.message}`)}function w(){let n=process.argv[1];return n&&h(n)?n:"sootsim"}function g(n){return new Promise(e=>setTimeout(e,n))}async function R(){s(),await d()}export{R as ensureDaemonRunning,I as runLaunch};
16
+ `);return}let e=n.includes("--no-runtime-install"),i=n.indexOf("--channel"),t=i>=0&&n[i+1]?n[i+1]:"stable",o=n.indexOf("--version"),f=o>=0&&n[o+1]?n[o+1]:void 0;s(),await v({skipAutoInstall:e,channel:t,explicitVersion:f}),await d(),await x()}async function v(n){let e=a(),i=c();if(e&&i)return;n.skipAutoInstall&&(console.error(" no sootsim runtime installed. run `sootsim runtime install` first, or drop --no-runtime-install."),process.exit(1)),console.log("sootsim: first run \u2014 installing runtime");let{runRuntime:t}=await import("./runtime-KZJNKYOB.js"),o=[];n.explicitVersion&&o.push(n.explicitVersion),n.channel!=="stable"&&o.push("--channel",n.channel),await t(["install",...o],{channel:n.channel})}async function d(){let n=r();if(l(n))return;console.log("sootsim: starting daemon");let e=w();p(e,["server","--quiet"],{detached:!0,stdio:"ignore",env:process.env}).unref();let t=Date.now()+8e3;for(;Date.now()<t;){let o=r();if(l(o))return;await g(150)}console.error(" daemon didn't become ready within 8s \u2014 check ~/.sootsim/ or run `sootsim server` in a terminal to see errors"),process.exit(1)}async function x(){u()||(console.error(" no sootsim desktop companion installed. run `sootsim install-desktop` to download electron + the shell."),process.exit(1));let e=await m.launch({});e.launched||(console.error(` ${e.message}`),process.exit(1)),console.log(` ${e.message}`)}function w(){let n=process.argv[1];return n&&h(n)?n:"sootsim"}function g(n){return new Promise(e=>setTimeout(e,n))}async function R(){s(),await d()}export{R as ensureDaemonRunning,I as runLaunch};