sootsim 0.1.86 → 0.1.87

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 (140) hide show
  1. package/dist-cli/bin.js +4 -4
  2. package/dist-cli/chunks/{agent-S3WLX5Z4.js → agent-JVF2PSHI.js} +2 -2
  3. package/dist-cli/chunks/{agent-wrapper-PFPEQTPG.js → agent-wrapper-F2F4AOBI.js} +2 -2
  4. package/dist-cli/chunks/{assert-RQD66YGE.js → assert-YYD6OU4X.js} +2 -2
  5. package/dist-cli/chunks/auto-bootstrap-NUDEO3WI.js +2 -0
  6. package/dist-cli/chunks/beta-KQR3AUDC.js +2 -0
  7. package/dist-cli/chunks/{chunk-5ZYANOOI.js → chunk-356M3TGV.js} +2 -2
  8. package/dist-cli/chunks/{chunk-OBHJKTWA.js → chunk-4QWGWI5X.js} +2 -2
  9. package/dist-cli/chunks/{chunk-7YZHI7V6.js → chunk-5UEPOBEU.js} +1 -1
  10. package/dist-cli/chunks/{chunk-CMAANHYQ.js → chunk-6JITQIIF.js} +1 -1
  11. package/dist-cli/chunks/{chunk-NBBH2PVW.js → chunk-7KZTQHB3.js} +2 -2
  12. package/dist-cli/chunks/{chunk-TSNBQ4ZV.js → chunk-7SX73XWN.js} +2 -2
  13. package/dist-cli/chunks/{chunk-3GCSX5H5.js → chunk-BDMAV7YE.js} +1 -1
  14. package/dist-cli/chunks/{chunk-STHMWSVN.js → chunk-BGA7UNHQ.js} +2 -2
  15. package/dist-cli/chunks/{chunk-XFJYEKYK.js → chunk-BREFZK7S.js} +3 -3
  16. package/dist-cli/chunks/chunk-CIRLGKNJ.js +2 -0
  17. package/dist-cli/chunks/{chunk-CQAQTU5K.js → chunk-CQGEFQ2O.js} +1 -1
  18. package/dist-cli/chunks/{chunk-OCTDP37S.js → chunk-F2V2RDSF.js} +2 -2
  19. package/dist-cli/chunks/chunk-FYFVAKLG.js +1 -0
  20. package/dist-cli/chunks/{chunk-UWSP2AT7.js → chunk-G4DPGAY7.js} +1 -1
  21. package/dist-cli/chunks/{chunk-535UNERF.js → chunk-HSIKVDO7.js} +2 -2
  22. package/dist-cli/chunks/{chunk-VUYCS6QI.js → chunk-HUL7SDXP.js} +2 -2
  23. package/dist-cli/chunks/{chunk-M6GOCS27.js → chunk-IFTNXJFC.js} +1 -1
  24. package/dist-cli/chunks/{chunk-3TNIXR6J.js → chunk-JIGBO7T2.js} +1 -1
  25. package/dist-cli/chunks/{chunk-JITAVV2G.js → chunk-JNC2KM5L.js} +1 -1
  26. package/dist-cli/chunks/{chunk-EDWDFOPL.js → chunk-KHCGD2SK.js} +22 -10
  27. package/dist-cli/chunks/{chunk-XB4QIINM.js → chunk-KOJH7M2Y.js} +5 -5
  28. package/dist-cli/chunks/{chunk-6A7IWFXR.js → chunk-KRG3TVPS.js} +5 -5
  29. package/dist-cli/chunks/{chunk-P7IKKZTG.js → chunk-L7NMKMAC.js} +2 -2
  30. package/dist-cli/chunks/{chunk-V7CFSKMC.js → chunk-LAFA2UUY.js} +2 -2
  31. package/dist-cli/chunks/{chunk-JBYW57OA.js → chunk-LKF24E4V.js} +2 -2
  32. package/dist-cli/chunks/{chunk-CSJS4MRN.js → chunk-MAFNPEGR.js} +2 -2
  33. package/dist-cli/chunks/{chunk-5NW6W7YF.js → chunk-MDZ6HMDB.js} +1 -1
  34. package/dist-cli/chunks/chunk-NNBW2HSI.js +1 -0
  35. package/dist-cli/chunks/{chunk-FF5KD3BS.js → chunk-OB6UTULM.js} +2 -2
  36. package/dist-cli/chunks/{chunk-DKW7Q4F3.js → chunk-OOMEG6UD.js} +2 -2
  37. package/dist-cli/chunks/{chunk-JB467MUR.js → chunk-P7TSRSCR.js} +2 -2
  38. package/dist-cli/chunks/{chunk-FO52BFW4.js → chunk-PJA4MECT.js} +2 -2
  39. package/dist-cli/chunks/{chunk-VFGAEMSI.js → chunk-PQ64ESHO.js} +2 -2
  40. package/dist-cli/chunks/{chunk-XZE53P4L.js → chunk-PQIWV724.js} +2 -2
  41. package/dist-cli/chunks/{chunk-KQYOS5SM.js → chunk-PRQGETWQ.js} +1 -1
  42. package/dist-cli/chunks/{chunk-6LG7WJMD.js → chunk-PV7UPMMH.js} +2 -2
  43. package/dist-cli/chunks/{chunk-NLH7FNSG.js → chunk-QFHW7D44.js} +1 -1
  44. package/dist-cli/chunks/{chunk-JMILXXI4.js → chunk-QI3CAQIS.js} +2 -2
  45. package/dist-cli/chunks/{chunk-5DFVKWYQ.js → chunk-RFES5JTB.js} +3 -3
  46. package/dist-cli/chunks/chunk-SFGIFF2S.js +2 -0
  47. package/dist-cli/chunks/chunk-TRLVCBYL.js +1 -0
  48. package/dist-cli/chunks/{chunk-2IYMBWHL.js → chunk-Y2H2L6L7.js} +1 -1
  49. package/dist-cli/chunks/{chunk-PVMX5UNR.js → chunk-ZKJ42ZMK.js} +2 -2
  50. package/dist-cli/chunks/cli-version-QYZHMOJT.js +2 -0
  51. package/dist-cli/chunks/{compat-I2U3P4KP.js → compat-46LSYJLF.js} +3 -3
  52. package/dist-cli/chunks/{config-S73CCGP5.js → config-P5NLMUL2.js} +2 -2
  53. package/dist-cli/chunks/{control-QR6MY7RA.js → control-3O7JEUFC.js} +2 -2
  54. package/dist-cli/chunks/{cpu-profile-RFYCTVAF.js → cpu-profile-LDMMDC7S.js} +2 -2
  55. package/dist-cli/chunks/{daemon-D5MV2B22.js → daemon-BL3MXXR3.js} +3 -3
  56. package/dist-cli/chunks/{debug-ZYEI75AG.js → debug-SQA6GG37.js} +3 -3
  57. package/dist-cli/chunks/{detox-J5IH52RV.js → detox-TY6AOSA7.js} +2 -2
  58. package/dist-cli/chunks/{device-NOBLSUOD.js → device-QWFX4556.js} +2 -2
  59. package/dist-cli/chunks/{diagnose-B6J5ZUHV.js → diagnose-P2UVBUN6.js} +2 -2
  60. package/dist-cli/chunks/drivers-HPRXOC6D.js +2 -0
  61. package/dist-cli/chunks/{electron-PSX4KDCC.js → electron-U3KDMBJM.js} +3 -3
  62. package/dist-cli/chunks/flow-XGMUH4JT.js +2 -0
  63. package/dist-cli/chunks/help-HZCKWAH5.js +2 -0
  64. package/dist-cli/chunks/{hints-ZE4I3YO3.js → hints-2IYL3NF4.js} +2 -2
  65. package/dist-cli/chunks/{home-paths-N76MJE3D.js → home-paths-5SZOYDCC.js} +2 -2
  66. package/dist-cli/chunks/{inspect-V2TXTDOG.js → inspect-FA4L7WIE.js} +107 -107
  67. package/dist-cli/chunks/install-SYVS2T2T.js +2 -0
  68. package/dist-cli/chunks/{install-desktop-6ZRTRRCU.js → install-desktop-OLT6LS5L.js} +3 -3
  69. package/dist-cli/chunks/{keys-L2RN4URM.js → keys-3OXB23J4.js} +2 -2
  70. package/dist-cli/chunks/{launch-BJGXPNZR.js → launch-HEXKSA3X.js} +3 -3
  71. package/dist-cli/chunks/{login-HYNEMAYR.js → login-DKQYESDF.js} +4 -4
  72. package/dist-cli/chunks/{logout-AO4YS27T.js → logout-FMJJ3BR2.js} +2 -2
  73. package/dist-cli/chunks/{maestro-PRACYFKV.js → maestro-Z24ESGQW.js} +2 -2
  74. package/dist-cli/chunks/{preview-ZTANXVEK.js → preview-ODKBHTV5.js} +2 -2
  75. package/dist-cli/chunks/{profile-FNMAGUDB.js → profile-2PIY7B3L.js} +2 -2
  76. package/dist-cli/chunks/{react-6ZV2FQIM.js → react-HL4CHJS4.js} +2 -2
  77. package/dist-cli/chunks/{record-MLFVJZ6Y.js → record-4LYFSZUK.js} +2 -2
  78. package/dist-cli/chunks/runtime-JML6VARG.js +2 -0
  79. package/dist-cli/chunks/{runtime-delivery-ATYW2SQR.js → runtime-delivery-U7WIYI7J.js} +2 -2
  80. package/dist-cli/chunks/{screenshot-UOMYMFZ4.js → screenshot-YUA2BHDF.js} +2 -2
  81. package/dist-cli/chunks/{screenshot-mode-MWSVD4YG.js → screenshot-mode-UIL75CHP.js} +2 -2
  82. package/dist-cli/chunks/{screenshots-GSA3VCWB.js → screenshots-YJWODQGP.js} +2 -2
  83. package/dist-cli/chunks/{server-YPFC6POG.js → server-J644PTIB.js} +9 -9
  84. package/dist-cli/chunks/setup-repo-GSEZY74V.js +2 -0
  85. package/dist-cli/chunks/{skills-YE5OPWMQ.js → skills-PEBZZZTL.js} +2 -2
  86. package/dist-cli/chunks/{start-BSSQ5U2V.js → start-JCJQRDDQ.js} +4 -4
  87. package/dist-cli/chunks/store-XGTUSOGS.js +2 -0
  88. package/dist-cli/chunks/telemetry-Y3IESY7P.js +2 -0
  89. package/dist-cli/chunks/{test-5JMLBH2O.js → test-Z3NU6IN7.js} +3 -3
  90. package/dist-cli/chunks/{three-mode-TRBWZJQY.js → three-mode-CFSZ2ZOW.js} +2 -2
  91. package/dist-cli/chunks/{timeline-YMZPIEB4.js → timeline-GEND6OI3.js} +2 -2
  92. package/dist-cli/chunks/{upgrade-JLAS7FIF.js → upgrade-6GFR2ZB7.js} +3 -3
  93. package/dist-cli/chunks/upload-OPMPP35I.js +2 -0
  94. package/dist-cli/chunks/{web-D6S5UXOO.js → web-7A27OUAC.js} +2 -2
  95. package/dist-cli/chunks/{what-happened-65NXWU2S.js → what-happened-57G5T2GM.js} +2 -2
  96. package/dist-cli/chunks/{whoami-6BSB6FQC.js → whoami-3ICC26FV.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 +1 -1
  123. package/dist-lib/vite.cjs +1 -1
  124. package/package.json +1 -1
  125. package/dist-cli/chunks/auto-bootstrap-PWF7OYCV.js +0 -2
  126. package/dist-cli/chunks/beta-2HH7F2DQ.js +0 -2
  127. package/dist-cli/chunks/chunk-I3JMONYJ.js +0 -2
  128. package/dist-cli/chunks/chunk-KGYC4SZA.js +0 -2
  129. package/dist-cli/chunks/chunk-NIRJVBXJ.js +0 -1
  130. package/dist-cli/chunks/chunk-QUYC7CVV.js +0 -1
  131. package/dist-cli/chunks/chunk-Y7BXSTVX.js +0 -1
  132. package/dist-cli/chunks/cli-version-TGWWTYQX.js +0 -2
  133. package/dist-cli/chunks/drivers-RRHVOU6S.js +0 -2
  134. package/dist-cli/chunks/flow-FWNVFKMP.js +0 -2
  135. package/dist-cli/chunks/install-4PINRR2O.js +0 -2
  136. package/dist-cli/chunks/runtime-5762IE56.js +0 -2
  137. package/dist-cli/chunks/setup-repo-QBQ4VWFO.js +0 -2
  138. package/dist-cli/chunks/store-EG4SONAH.js +0 -2
  139. package/dist-cli/chunks/telemetry-XXN4LRDS.js +0 -2
  140. package/dist-cli/chunks/upload-K6UNCFQH.js +0 -2
@@ -1,14 +1,14 @@
1
- /*! sootsim v0.1.86 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as Q}from"./chunk-FO52BFW4.js";import{a as pt,b as ft}from"./chunk-7YZHI7V6.js";import{a as He,h as ye,k as ee}from"./chunk-JMILXXI4.js";import{b as gt,c as yt,i as ht}from"./chunk-VFGAEMSI.js";import"./chunk-TSNBQ4ZV.js";import{a as Z,b as j,c as J,d as ne,e as V,f as ge,g as de,h as dt,i as ut,j as _e,k as mt}from"./chunk-CSJS4MRN.js";import{B as at,D as le,E as lt,K as ct,a as fe,b as Ue,c as Ke,d as ze,e as Ye,f as Ge,g as Xe,h as Me,i as Ie,n as Ne,o as Ve,p as Qe,q as Ze,r as et,s as tt,t as ot,u as st,v as nt,w as rt,x as it}from"./chunk-EDWDFOPL.js";import"./chunk-STHMWSVN.js";import"./chunk-5NW6W7YF.js";import"./chunk-VUYCS6QI.js";import"./chunk-Y7BXSTVX.js";import"./chunk-CQAQTU5K.js";import{a as Be}from"./chunk-M6GOCS27.js";import{a as Se,c as ke}from"./chunk-JB467MUR.js";import{a as De}from"./chunk-KGYC4SZA.js";import{c as Je,e as Le,f as qe,g as We,h as Te}from"./chunk-5ZYANOOI.js";import{b as je}from"./chunk-3TNIXR6J.js";import"./chunk-I3JMONYJ.js";import"./chunk-2IYMBWHL.js";import"./chunk-KQYOS5SM.js";import{existsSync as eo,mkdirSync as to,readFileSync as oo,rmSync as bt,writeFileSync as so}from"fs";import{tmpdir as no}from"os";import{dirname as ro,join as io,resolve as ao}from"path";var ue=1,lo="SOOTSIM_INSPECT_NOTICE_PATH",co=300*1e3,uo=15e3;function wt(){return ao(process.env[lo]||io(no(),"sootsim-inspect-notice-state.json"))}function mo(o,c){return Object.fromEntries(Object.entries(o).filter(([,i])=>typeof i?.signature=="string"&&Number.isFinite(i?.updatedAt)&&c-i.updatedAt<=co))}function po(o){let c=wt();if(!eo(c))return{version:ue,entries:{}};try{let i=JSON.parse(oo(c,"utf8"));return i.version!==ue||!i.entries||typeof i.entries!="object"?(bt(c,{force:!0}),{version:ue,entries:{}}):{version:ue,entries:mo(i.entries,o)}}catch{return bt(c,{force:!0}),{version:ue,entries:{}}}}function fo(o){let c=wt();to(ro(c),{recursive:!0}),so(c,JSON.stringify(o,null,2)+`
3
- `)}function go(o,c){let i=c.trim()||"default";return`${o}:${i}`}function Fe(o,c,i,l={}){let f=l.nowMs??Date.now(),a=l.cooldownMs??uo,g=po(f),h=go(o,c),M=g.entries[h];return M&&M.signature===i&&f-M.updatedAt<a?!1:(g.entries[h]={signature:i,updatedAt:f},fo(g),!0)}async function xt(o,c={args:[]}){let i=await Ue(o);if(j(c.args)){J(i);return}console.log(` nodes: ${i.nodes}`)}function Ae(o,c){let i=o.indexOf(c);return i>=0&&i+1<o.length?o[i+1]:null}async function $t(o){let{bridge:c,args:i,positional:l}=o,f=i.includes("--verbose")||i.includes("-v"),a=j(i),g=f&&!a,h=i.includes("--watch")||i.includes("-w"),M=1e3,k=i.includes("--compact"),w=i.includes("--no-xy"),S=i.includes("--no-clipped"),I=Ae(i,"--testid-like"),N=Ae(i,"--only"),O=Ae(i,"--subtree"),D=l[1],u=D?/[*?]/.test(D):!1,H=!u&&!N?D:void 0,B=N??(u?D:void 0),C=async()=>{await ge(c,{verbose:g});let Y=await Ye(c,{describe:!0,verbose:f,filter:H||"",testIdLike:I||void 0,onlyGlob:B||void 0,subtreeRoot:O||void 0,compact:k,hideXy:w}),$=Y?.tree,T=Y?.shell,q=Y?.keyboard;if(a){J({shell:T,tree:$??"",keyboard:q});return}if(T&&typeof T=="object"){let E=[T.state?`state=${T.state}`:null,T.activeApp?`app=${T.activeApp}`:null,T.showSwitcher?"switcher":null,T.switcherPhase&&T.switcherPhase!=="idle"?`phase=${T.switcherPhase}`:null].filter(Boolean);E.length>0&&console.log(` shell: ${E.join(" ")}`)}if(typeof $=="string"&&$.startsWith("__SUBTREE_NOT_FOUND__:")){let E=$.slice(22);console.log(` subtree root not found: ${E}`),Q("subtree-root-not-found",E);return}if(!$){let E=Y?.nodeCount??0;console.log(" no matching nodes found"),!(H||I||B||O)&&E<10&&Q("app-still-loading",E);return}let z=$,G=0;if(S&&typeof z=="string"){let E=z.split(`
4
- `),se=[];for(let pe of E){if(pe.includes("(clipped:")){G+=1;continue}se.push(pe)}z=se.join(`
5
- `)}console.log(z),G>0&&console.log(` ${G} clipped row(s) hidden (omit --no-clipped to see)`);let re=H||I||B||O;if((H||I||B)&&!h&&Q("describe-filter-context"),!re&&!h&&$.split(`
6
- `).length>=80&&Q("describe-use-filters"),q&&q.visible){let E=q.spec,se=[E?.keyboardType?`type=${E.keyboardType}`:null,E?.returnKeyType&&E.returnKeyType!=="default"?`return=${E.returnKeyType}`:null,q.mode!=="letters"?`mode=${q.mode}`:null,q.shifted?"shift":null,q.capsLock?"caps":null,E?.autoCapitalize&&E.autoCapitalize!=="sentences"?`autoCap=${E.autoCapitalize}`:null,q.accessoryBarId?`accessory=${q.accessoryBarId}`:null].filter(Boolean);console.log(`
7
- keyboard: ${se.join(" ")||"visible"}`)}};if(h)for(console.log(` watching... (Ctrl+C to stop)
8
- `);;)console.clear(),await C(),await Z(M);else await C()}var yo=["SOOTSIM_AGENT","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function he(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let o of yo){let c=process.env[o];if(c&&c.trim()&&c!=="0")return!0}return!1}async function vt(o){let{bridge:c,args:i,effectiveArgs:l,positional:f,inspectUsage:a}=o,g=$=>{let T=l.indexOf($);return T>=0&&T+1<l.length?l[T+1]:null},h=$=>l.includes($),M=g("--testid")||g("--test-id"),k=g("--role"),w=g("--type"),S=g("--text"),I=h("--pressable"),N=h("--visible"),O=h("--interactive-targets")||h("--actions"),D=!M&&!k&&!w&&!S&&!I&&!N&&!O?f[1]:null,u=S??D,H=await Xe(c,{testId:M,role:k,type:w,text:u,pressable:I,visible:N,interactive:O});H||(console.error(a("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:B,result:C}=H,oe=j(i),Y=i.includes("--verbose")||i.includes("--dump");if(oe)B==="interactive-targets"&&Array.isArray(C)?J(Me(C).map($=>({...$,tap:Ie($)}))):J(C??null);else if(Array.isArray(C))if(C.length===0){console.log(` no ${B} nodes found`);let $=await c.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof $=="number"&&$<10&&Q("app-still-loading",$)}else if(B==="interactive-targets"){let $=Me(C);console.log(` found ${$.length} interactive target${$.length===1?"":"s"} (sorted by score):`);for(let T of $.slice(0,20)){let q=T.absolutePosition?`@(${Math.round(T.absolutePosition.x)},${Math.round(T.absolutePosition.y)})`:"",z=T.layout?`${Math.round(T.layout.width)}x${Math.round(T.layout.height)}`:"?x?",G=T.text?` "${T.text.slice(0,30)}"`:"",re=T.testID?` #${T.testID}`:"",ie=T.accessibilityLabel?` \u24D8"${String(T.accessibilityLabel).slice(0,24)}"`:"",E=T.accessibilityRole?`[${T.accessibilityRole}]`:T.type,se=Ie(T);console.log(` ${E}${G}${ie}${re} ${z} ${q}`),console.log(` \u2192 ${se}`),Y&&console.log(Pe(JSON.stringify(T,null,2)," "))}$.length>20&&console.log(` ... and ${$.length-20} more`)}else{console.log(` found ${C.length} node${C.length===1?"":"s"} (${B}):`);for(let $ of C.slice(0,20)){let T=$.absolutePosition?`@(${Math.round($.absolutePosition.x)},${Math.round($.absolutePosition.y)})`:"",q=$.layout?`${Math.round($.layout.width)}x${Math.round($.layout.height)}`:"?x?",z=$.text?` "${$.text.slice(0,30)}"`:"",G=$.testID?` #${$.testID}`:"",re=$.pressable?" (tap)":"",ie=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ie}${z}${G} ${q} ${T}${re}`),Y&&console.log(Pe(JSON.stringify($,null,2)," "))}C.length>20&&console.log(` ... and ${C.length-20} more`)}else if(C==null)console.log(` not found: ${u||M||k||w||""||B}`),M&&Q("wait-selector-for-missing-testid",M);else{let $=C;if($.type&&$.absolutePosition){let T=`@(${Math.round($.absolutePosition.x)},${Math.round($.absolutePosition.y)})`,q=$.layout?`${Math.round($.layout.width)}x${Math.round($.layout.height)}`:"?x?",z=$.text?` "${$.text.slice(0,40)}"`:"",G=$.testID?` #${$.testID}`:"",re=$.pressable?" (tap)":"",ie=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ie}${z}${G} ${q} ${T}${re}`),Y&&console.log(Pe(JSON.stringify($,null,2)," "))}else console.log(JSON.stringify(C,null,2))}}function Pe(o,c){return o.split(`
1
+ /*! sootsim v0.1.87 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as V}from"./chunk-PJA4MECT.js";import{a as pt,b as ft}from"./chunk-5UEPOBEU.js";import{a as He,h as he,k as oe}from"./chunk-QI3CAQIS.js";import{b as gt,c as yt,i as ht}from"./chunk-PQ64ESHO.js";import"./chunk-7SX73XWN.js";import{a as Q,b as B,c as L,d as re,e as X,f as ye,g as ue,h as dt,i as ut,j as Fe,k as mt}from"./chunk-MAFNPEGR.js";import{B as at,D as le,E as lt,K as ct,a as ge,b as Ue,c as Ke,d as ze,e as Ye,f as Ge,g as Xe,h as Ie,i as Ne,n as _e,o as Ve,p as Qe,q as Ze,r as et,s as tt,t as ot,u as st,v as nt,w as rt,x as it}from"./chunk-KHCGD2SK.js";import{c as Je,e as Le,f as qe,g as We,h as Me}from"./chunk-356M3TGV.js";import{b as je}from"./chunk-JIGBO7T2.js";import"./chunk-BGA7UNHQ.js";import"./chunk-MDZ6HMDB.js";import"./chunk-FYFVAKLG.js";import"./chunk-HUL7SDXP.js";import"./chunk-CQGEFQ2O.js";import{a as De}from"./chunk-IFTNXJFC.js";import{a as ke,c as Te}from"./chunk-P7TSRSCR.js";import{a as Be}from"./chunk-CIRLGKNJ.js";import"./chunk-SFGIFF2S.js";import"./chunk-Y2H2L6L7.js";import"./chunk-PRQGETWQ.js";import{existsSync as eo,mkdirSync as to,readFileSync as oo,rmSync as bt,writeFileSync as so}from"fs";import{tmpdir as no}from"os";import{dirname as ro,join as io,resolve as ao}from"path";var me=1,lo="SOOTSIM_INSPECT_NOTICE_PATH",co=300*1e3,uo=15e3;function wt(){return ao(process.env[lo]||io(no(),"sootsim-inspect-notice-state.json"))}function mo(o,c){return Object.fromEntries(Object.entries(o).filter(([,i])=>typeof i?.signature=="string"&&Number.isFinite(i?.updatedAt)&&c-i.updatedAt<=co))}function po(o){let c=wt();if(!eo(c))return{version:me,entries:{}};try{let i=JSON.parse(oo(c,"utf8"));return i.version!==me||!i.entries||typeof i.entries!="object"?(bt(c,{force:!0}),{version:me,entries:{}}):{version:me,entries:mo(i.entries,o)}}catch{return bt(c,{force:!0}),{version:me,entries:{}}}}function fo(o){let c=wt();to(ro(c),{recursive:!0}),so(c,JSON.stringify(o,null,2)+`
3
+ `)}function go(o,c){let i=c.trim()||"default";return`${o}:${i}`}function Ae(o,c,i,l={}){let f=l.nowMs??Date.now(),a=l.cooldownMs??uo,g=po(f),b=go(o,c),k=g.entries[b];return k&&k.signature===i&&f-k.updatedAt<a?!1:(g.entries[b]={signature:i,updatedAt:f},fo(g),!0)}async function xt(o,c={args:[]}){let i=await Ue(o);if(B(c.args)){L(i);return}console.log(` nodes: ${i.nodes}`)}function Pe(o,c){let i=o.indexOf(c);return i>=0&&i+1<o.length?o[i+1]:null}async function $t(o){let{bridge:c,args:i,positional:l}=o,f=i.includes("--verbose")||i.includes("-v"),a=B(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=Pe(i,"--testid-like"),R=Pe(i,"--only"),j=Pe(i,"--subtree"),u=l[1]&&!l[1].startsWith("-")?l[1]:void 0,Y=u?/[*?]/.test(u):!1,D=!Y&&!R?u:void 0,E=R??(Y?u:void 0),Z=async()=>{await ye(c,{verbose:g});let $=await Ye(c,{describe:!0,verbose:f,filter:D||"",testIdLike:T||void 0,onlyGlob:E||void 0,subtreeRoot:j||void 0,compact:M,hideXy:h,includeOccluded:F}),I=$?.tree,W=$?.shell,J=$?.keyboard;if(a){L({shell:W,tree:I??"",keyboard:J});return}if(W&&typeof W=="object"){let C=[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);C.length>0&&console.log(` shell: ${C.join(" ")}`)}if(typeof I=="string"&&I.startsWith("__SUBTREE_NOT_FOUND__:")){let C=I.slice(22);console.log(` subtree root not found: ${C}`),V("subtree-root-not-found",C);return}if(!I){let C=$?.nodeCount??0;console.log(" no matching nodes found"),!(D||T||E||j)&&C<10&&V("app-still-loading",C);return}let z=I,te=0;if(S&&typeof z=="string"){let C=z.split(`
4
+ `),ae=[];for(let ce of C){if(ce.includes("(clipped:")){te+=1;continue}ae.push(ce)}z=ae.join(`
5
+ `)}console.log(z),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let ne=D||T||E||j;if((D||T||E)&&!b&&V("describe-filter-context"),!ne&&!b&&I.split(`
6
+ `).length>=80&&V("describe-use-filters"),J&&J.visible){let C=J.spec,ae=[C?.keyboardType?`type=${C.keyboardType}`:null,C?.returnKeyType&&C.returnKeyType!=="default"?`return=${C.returnKeyType}`:null,J.mode!=="letters"?`mode=${J.mode}`:null,J.shifted?"shift":null,J.capsLock?"caps":null,C?.autoCapitalize&&C.autoCapitalize!=="sentences"?`autoCap=${C.autoCapitalize}`:null,J.accessoryBarId?`accessory=${J.accessoryBarId}`:null].filter(Boolean);console.log(`
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 yo=["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 yo){let c=process.env[o];if(c&&c.trim()&&c!=="0")return!0}return!1}async function vt(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 Xe(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:D,result:E}=Y,Z=B(i),ee=i.includes("--verbose")||i.includes("--dump");if(Z)D==="interactive-targets"&&Array.isArray(E)?L(Ie(E).map($=>({...$,tap:Ne($)}))):L(E??null);else if(Array.isArray(E))if(E.length===0){console.log(` no ${D} nodes found`);let $=await c.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof $=="number"&&$<10&&V("app-still-loading",$)}else if(D==="interactive-targets"){let $=Ie(E);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)})`:"",J=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,C=Ne(I);console.log(` ${fe}${z}${ne}${te} ${J} ${W}`),console.log(` \u2192 ${C}`),ee&&console.log(Oe(JSON.stringify(I,null,2)," "))}$.length>20&&console.log(` ... and ${$.length-20} more`)}else{console.log(` found ${E.length} node${E.length===1?"":"s"} (${D}):`);for(let $ of E.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?",J=$.text?` "${$.text.slice(0,30)}"`:"",z=$.testID?` #${$.testID}`:"",te=$.pressable?" (tap)":"",ne=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ne}${J}${z} ${W} ${I}${te}`),ee&&console.log(Oe(JSON.stringify($,null,2)," "))}E.length>20&&console.log(` ... and ${E.length-20} more`)}else if(E==null)console.log(` not found: ${u||k||M||h||""||D}`),k&&V("wait-selector-for-missing-testid",k);else{let $=E;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?",J=$.text?` "${$.text.slice(0,40)}"`:"",z=$.testID?` #${$.testID}`:"",te=$.pressable?" (tap)":"",ne=$.accessibilityRole?`[${$.accessibilityRole}]`:$.type;console.log(` ${ne}${J}${z} ${W} ${I}${te}`),ee&&console.log(Oe(JSON.stringify($,null,2)," "))}else console.log(JSON.stringify(E,null,2))}}function Oe(o,c){return o.split(`
9
9
  `).map(i=>c+i).join(`
10
- `)}async function St(o,c={}){let i=await at(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:h,accessoryBarId:M}=i,k=[];k.push(`keyboard: ${l?"visible":"hidden"}`),f?(k.push(` type: ${f.keyboardType}`),k.push(` returnKey: ${f.returnKeyType}`),k.push(` autoCap: ${f.autoCapitalize}`),k.push(` autoCorrect: ${f.autoCorrect?"on":"off"}`),k.push(` appearance: ${f.keyboardAppearance}`),f.secureTextEntry&&k.push(" secureTextEntry: true"),f.enablesReturnKeyAutomatically&&k.push(` return: ${f.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):k.push(" spec: <none> (shown via dev-tools with no TextInput)"),k.push(` mode: ${a}${g?" (shifted)":""}${h?" (caps)":""}`),M&&k.push(` accessoryBar: ${M}`),console.log(k.join(`
11
- `))}async function kt(o){let c=await o.bridge.listSims(),i=o.args.includes("--all"),l=o.args.find((h,M)=>o.args[M-1]==="--bundle"),f=o.args.find((h,M)=>o.args[M-1]==="--app-port"),a=o.args.includes("--primary"),g=c.filter(h=>!(a&&!h.isPrimary||l&&!(h.url??"").includes(l)||f&&!(h.url??"").includes(`/rn/${f}`)||!i&&!l&&!f&&!a&&!(h.url&&(h.url.includes("bundle=")||h.url.includes("/index.bundle")))&&h.id!==o.simId));if(j(o.args)){J(g.map(h=>({...h,active:h.id===o.simId})));return}ht(g,o.simId),g.length<c.length&&!j(o.args)&&console.log(` (${c.length-g.length} more hidden \u2014 pass --all to show)`)}function ae(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/1024/1024).toFixed(1)}MB`}function be(o,c){return c<=0?"?":`${(o/c*100).toFixed(0)}%`}async function Tt(o,c={args:[]}){let i=await ct(o);if(j(c.args)){J(i);return}if(console.log(" memory:"),i.imageLoader){let l=i.imageLoader;console.log(" image-loader cache"),console.log(` entries: ${l.cacheEntries} / ${l.cacheMaxEntries} (${be(l.cacheEntries,l.cacheMaxEntries)})`),console.log(` pixel bytes: ${ae(l.cachePixelBytes)} / ${ae(l.cachePixelBudget)} (${be(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: ${ae(l.usedJSHeapSize)} / ${ae(l.jsHeapSizeLimit)} (${be(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ae(l.totalJSHeapSize)}`)}if(i.hostHeap){let l=i.hostHeap;console.log(" host heap (chrome only)"),console.log(` used: ${ae(l.usedJSHeapSize)} / ${ae(l.jsHeapSizeLimit)} (${be(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ae(l.totalJSHeapSize)}`)}}function me(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 we(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 St(o,c={}){let i=await at(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 kt(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(B(o.args)){L(g.map(b=>({...b,active:b.id===o.simId})));return}ht(g,o.simId),g.length<c.length&&!B(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 Tt(o,c={args:[]}){let i=await ct(o);if(B(c.args)){L(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,12 +33,12 @@ import{a as Q}from"./chunk-FO52BFW4.js";import{a as pt,b as ft}from"./chunk-7YZH
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 Mt(o,c={}){let{nav:i,keyboard:l,shell:f}=await lt(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>",h=f.showSwitcher?" (app switcher open)":"",M=typeof f.launchProgress=="number"&&f.launchProgress<.98?` launching (${Math.round(f.launchProgress*100)}%)`:"";a.push(`shell: ${g}${h}${M}`)}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 h of i.screens){let M=h.isActive?"\u25B6":" ",k=h.routeName?` ${h.routeName}`:"",w=h.headerHeight>0?` header=${h.headerHeight}`:"",S=h.largeTitleState&&h.largeTitleState!=="expanded"?` large-title=${h.largeTitleState}`:"";a.push(` ${M} #${h.id}${k}${w}${S}`)}}else a.push("nav: <runtime not available>");if(l&&l.visible){let g=l.spec?.keyboardType??"default",h=l.spec?.returnKeyType??"default";a.push(`keyboard: visible (${g}, return=${h}, mode=${l.mode??"?"})`)}else a.push("keyboard: hidden");console.log(a.join(`
37
- `))}async function It(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1])*1e3:3e3,a=i.includes("--strict"),{elapsed:g,settled:h}=await ee({bridge:c,maxMs:f,strict:a});console.log(h?` settled in ${g}ms`:` timed out after ${g}ms (may still be animating)`)}async function Nt(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 Z(c*1e3),console.log(` slept ${c}s`)}async function _t(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1]):5,{tree:a}=await Ke(c,f);if(j(i)){J({depth:f,tree:a??null});return}console.log(typeof a=="string"?a:JSON.stringify(a,null,2))}async function Ft(o,c={args:[]}){let i=await ze(o);if(j(c.args)){J(i);return}console.log(i.url)}async function At(o){let{wsPort:c,commandTimeoutMs:i,simId:l,simIdSource:f,positional:a}=o,g=a[1]?Number(a[1]):30,h=Math.max(1e3,(Number.isFinite(g)?g:30)*1e3),M=Math.max(1,Math.ceil(h/500));console.log(" waiting for sim reconnect...");let k=await dt(c,i,l,{attempts:M,simIdSource:f});k||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),k.bridge.close(),ye({source:"inspect wait",step:{wait:h},summary:`wait ${Math.round(h/1e3)}s`}),console.log(` ready: ${k.count} nodes`)}var Pt=new Set(["app-launch","toast","keyboard","screen","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function xe(o,c){let i=o.indexOf(c);if(i>=0&&i+1<o.length)return o[i+1]}function ho(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 Ot(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)),Pt.has(a)||console.error(` warning: '${a}' is not a known timeline kind \u2014 waiting anyway. known: ${[...Pt].sort().join(", ")}`);let g=xe(i,"--max-ms"),h=g&&Number.isFinite(Number(g))?Math.max(100,Number(g)):5e3,M=xe(i,"--filter"),k=xe(i,"--equals"),w=xe(i,"--since")??"now",S=i.includes("--json"),I=Date.now(),N=I+h,O=200,D=I;for(;Date.now()<N;){let H={kinds:[a],since:w==="cursor"?void 0:D,limit:50},B=await c.send({type:"evaluate",code:`(async () => {
36
+ })()`})??null}async function Mt(o,c={}){let{nav:i,keyboard:l,shell:f}=await lt(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 It(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 Nt(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 _t(o){let{bridge:c,args:i,positional:l}=o,f=l[1]?Number(l[1]):5,{tree:a}=await Ke(c,f);if(B(i)){L({depth:f,tree:a??null});return}console.log(typeof a=="string"?a:JSON.stringify(a,null,2))}async function Ft(o,c={args:[]}){let i=await ze(o);if(B(c.args)){L(i);return}console.log(i.url)}async function At(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 dt(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 Pt=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 ho(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 Ot(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)),Pt.has(a)||console.error(` warning: '${a}' is not a known timeline kind \u2014 waiting anyway. known: ${[...Pt].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},D=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
- return { ok: true, result: await t.recent(${JSON.stringify(H)}) }
41
- })()`});(!B||!B.ok)&&(console.error(` could not query timeline: ${B&&"error"in B?B.error:"unknown"}`),process.exit(1));let C=B.result.events??[];for(let oe of C)if(ho(oe,{filter:M,equals:k})){let Y=Date.now()-I;console.log(S?JSON.stringify({found:!0,elapsedMs:Y,event:oe}):` ${a} event after ${Y}ms${M?` (filter: ${M})`:""}${k?` (equals: ${k})`:""}`);return}B.result.watermark&&B.result.watermark>D&&(D=B.result.watermark),await new Promise(oe=>setTimeout(oe,O))}let u=Date.now()-I;S?console.log(JSON.stringify({found:!1,elapsedMs:u,kind:a,filter:M,equals:k})):console.error(` \u26A0 wait event ${a} timed out after ${u}ms${M?` (filter: ${M})`:""}${k?` (equals: ${k})`:""}`),process.exit(1)}async function Rt(o){let{bridge:c,args:i}=o,l=i.includes("--strict"),f=fe(i,3e3),{elapsed:a,settled:g}=await ee({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 Et(o){let{bridge:c,args:i}=o,l=fe(i,2e4),{ready:f,elapsedMs:a,nodes:g,targets:h,flag:M,loadingText:k,externalReady:w,externalError:S,errors:I}=await Ve(c,l,{onProgress(O){console.error(` still waiting after ${O.elapsedMs}ms \u2014 ${Ne(O)} (nodes: ${O.nodes}, targets: ${O.targets}, errors: ${O.errors})`)}});if(f){let O=l-a,D=Math.max(100,Math.min(1e4,O)),u=await ee({bridge:c,maxMs:D,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: ${h})`),process.exit(1)),console.log(` ready in ${a+u.elapsed}ms: ${g} nodes, ${h} targets`);return}let N=Ne({externalError:S,loadingText:k,externalReady:w,flag:M,targets:h});console.error(` \u26A0 wait ready timed out after ${a}ms \u2014 ${N} (nodes: ${g}, targets: ${h}, errors: ${I})`),process.exit(1)}async function Ct(o){let{bridge:c,args:i,positional:l,inspectUsage:f}=o,a=l[1];a||(console.error(f("wait selector","<testid> [--max-ms 5000]")),process.exit(1));let g=i.indexOf("--max-ms"),h=g>=0&&i[g+1]?Math.max(100,Number(i[g+1])):5e3,{found:M,node:k,elapsed:w}=await Qe(c,a,h);if(M&&k){let S=k.absolutePosition?`@(${Math.round(k.absolutePosition.x)},${Math.round(k.absolutePosition.y)})`:"",I=k.layout?`${Math.round(k.layout.width)}x${Math.round(k.layout.height)}`:"?x?";console.log(` found #${a} in ${w}ms ${I} ${S}`)}else console.error(` \u26A0 wait selector #${a} timed out after ${w??h}ms`),process.exit(1)}function Wt(o){return o==null?"\u2014":o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}K`:`${(o/1024/1024).toFixed(1)}M`}function Ht(o){return o==null?" \u2026":o<1e3?`${o}ms`.padStart(5):`${(o/1e3).toFixed(2)}s`.padStart(5)}async function wo(o,c){try{let i=await o.send({type:"evaluate",code:`(async () => {
40
+ return { ok: true, result: await t.recent(${JSON.stringify(Y)}) }
41
+ })()`});(!D||!D.ok)&&(console.error(` could not query timeline: ${D&&"error"in D?D.error:"unknown"}`),process.exit(1));let E=D.result.events??[];for(let Z of E)if(ho(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}D.result.watermark&&D.result.watermark>j&&(j=D.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 Rt(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 Et(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 Ve(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 Ct(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 Qe(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 Wt(o){return o==null?"\u2014":o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}K`:`${(o/1024/1024).toFixed(1)}M`}function Ht(o){return o==null?" \u2026":o<1e3?`${o}ms`.padStart(5):`${(o/1e3).toFixed(2)}s`.padStart(5)}async function wo(o,c){try{let i=await o.send({type:"evaluate",code:`(async () => {
42
42
  const t = window.__sootsimTest
43
43
  if (!t || typeof t.queryAll !== 'function') return []
44
44
  try {
@@ -57,8 +57,8 @@ import{a as Q}from"./chunk-FO52BFW4.js";import{a as pt,b as ft}from"./chunk-7YZH
57
57
  } catch {
58
58
  return []
59
59
  }
60
- })()`});if(!Array.isArray(i)||i.length===0)return;let l=c.toLowerCase(),f=i.map(a=>({id:a,score:xo(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 xo(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 $o(o,c)-i}function $o(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 vo(o){return o.error?"err":o.status==null?" \u2026 ":String(o.status)}function So(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 Dt(o){let c=ne(o.startTs),i=vo(o).padEnd(3),l=o.method.padEnd(5),f=Wt(o.size).padStart(6),a=Ht(o.durationMs);console.log(` [${c}] ${i} ${l} ${f} ${a} ${o.displayUrl}`),o.error&&console.log(` error: ${o.error}`)}function ko(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",ne(o.startTs)],["duration",Ht(o.durationMs).trim()],["size",Wt(o.size)],["content-type",o.type??"\u2014"]];for(let[i,l]of c)console.log(` ${i.padEnd(13)} ${l}`)}var To={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},Bt="\x1B[0m",Mo="\x1B[2m";function jt(o,c){let i=ne(o.ts),l=o.level.toUpperCase().padEnd(5),f=o.args.join(" ");if(c){let a=To[o.level];console.log(` ${Mo}[${i}]${Bt} ${a}${l}${Bt} ${f}`)}else console.log(` [${i}] ${l} ${f}`);if(o.stack&&o.level==="error"){let a=o.stack.split(`
61
- `).slice(0,5);for(let g of a)console.log(` ${g.trim()}`)}}var te="__sootsimCliPerf",Io=120;async function Jt(o,c){let i=o.find((I,N)=>o[N-1]==="--id"),l=o.find((I,N)=>o[N-1]==="--text");if(i||l){let I=await c.send({type:"evaluate",code:pt({id:i,text:l})});if(!I)throw new Error(i?`no node with id "${i}"`:`no node matching text "${l}"`);let{x:N,y:O,w:D,h:u}=I;return{x:N,y:O,w:D,h:u}}let f=o.find((I,N)=>o[N-1]==="--area");if(f){let I=f.split(",").map(H=>Number(H.trim()));if(I.length!==4||I.some(H=>!Number.isFinite(H)))throw new Error(`--area expects x,y,w,h (got "${f}")`);let[N,O,D,u]=I;return{x:N,y:O,w:D,h:u}}let a=I=>{let N=o.find((D,u)=>o[u-1]===I);if(N==null)return null;let O=Number(N);return Number.isFinite(O)?O:null},g=a("--x"),h=a("--y"),M=a("--w"),k=a("--h");if(g!=null||h!=null||M!=null||k!=null)return{x:g??0,y:h??0,w:M??1,h:k??1};let S=o.filter((I,N)=>N>0&&!I.startsWith("-")&&o[N-1]!=="--output"&&o[N-1]!=="--area"&&o[N-1]!=="--id"&&o[N-1]!=="--text"&&o[N-1]!=="--x"&&o[N-1]!=="--y"&&o[N-1]!=="--w"&&o[N-1]!=="--h").map(Number).filter(I=>Number.isFinite(I));if(S.length>=2){let[I,N,O=1,D=1]=S;return{x:I,y:N,w:O,h:D}}return null}function Oe(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 $e(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 Z(16),f=await le(o)}}async function Ee(o){return o.send({type:"evaluate",code:`(async () => {
60
+ })()`});if(!Array.isArray(i)||i.length===0)return;let l=c.toLowerCase(),f=i.map(a=>({id:a,score:xo(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 xo(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 $o(o,c)-i}function $o(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 vo(o){return o.error?"err":o.status==null?" \u2026 ":String(o.status)}function So(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 Dt(o){let c=re(o.startTs),i=vo(o).padEnd(3),l=o.method.padEnd(5),f=Wt(o.size).padStart(6),a=Ht(o.durationMs);console.log(` [${c}] ${i} ${l} ${f} ${a} ${o.displayUrl}`),o.error&&console.log(` error: ${o.error}`)}function ko(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",Ht(o.durationMs).trim()],["size",Wt(o.size)],["content-type",o.type??"\u2014"]];for(let[i,l]of c)console.log(` ${i.padEnd(13)} ${l}`)}var To={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},Bt="\x1B[0m",Mo="\x1B[2m";function jt(o,c){let i=re(o.ts),l=o.level.toUpperCase().padEnd(5),f=o.args.join(" ");if(c){let a=To[o.level];console.log(` ${Mo}[${i}]${Bt} ${a}${l}${Bt} ${f}`)}else console.log(` [${i}] ${l} ${f}`);if(o.stack&&o.level==="error"){let a=o.stack.split(`
61
+ `).slice(0,5);for(let g of a)console.log(` ${g.trim()}`)}}var se="__sootsimCliPerf",Io=120;async function Jt(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:pt({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 Re(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 Ce(o){return o.send({type:"evaluate",code:`(async () => {
62
62
  const kb = window.__sootsimKeyboard
63
63
  const test = window.__sootsimTest
64
64
  if (!kb) return { error: 'keyboard bridge not available' }
@@ -90,7 +90,7 @@ import{a as Q}from"./chunk-FO52BFW4.js";import{a as pt,b as ft}from"./chunk-7YZH
90
90
  frame: runtimeSnapshot?.keyboard?.frame ?? null,
91
91
  focusedRect: runtimeSnapshot?.focused?.rect ?? null,
92
92
  }
93
- })()`})}async function No(o,c=600){let i=Date.now()+c;for(;Date.now()<=i;){let l=await Ee(o);if(l.visible)return l;await Z(30)}return Ee(o)}async function ve(o,c){let i=await Ee(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 Lt(o,c,i){return c==="appearance"?o.send({type:"evaluate",code:`(async () => {
93
+ })()`})}async function No(o,c=600){let i=Date.now()+c;for(;Date.now()<=i;){let l=await Ce(o);if(l.visible)return l;await Q(30)}return Ce(o)}async function Se(o,c){let i=await Ce(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 Lt(o,c,i){return c==="appearance"?o.send({type:"evaluate",code:`(async () => {
94
94
  const requested = ${JSON.stringify(i??"toggle")}
95
95
  const rootBg = (document.documentElement?.style?.background || '').toLowerCase()
96
96
  const inferredCurrent = rootBg.includes('33') ? 'dark' : 'light'
@@ -107,25 +107,25 @@ import{a as Q}from"./chunk-FO52BFW4.js";import{a as pt,b as ft}from"./chunk-7YZH
107
107
  })()`}):o.send({type:"evaluate",code:`(async () => {
108
108
  window.dispatchEvent(new CustomEvent(${JSON.stringify(c==="lock"?"sootsim:toggleLock":"sootsim:shake")}))
109
109
  return { ok: true, action: ${JSON.stringify(c)} }
110
- })()`})}function _o(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 Fo(o){if(typeof o!="string")return null;let c=o.replace(/\s+/g," ").trim();return c?c.slice(0,80):null}function Ut(...o){for(let c of o){if(typeof c!="string")continue;let i=c.trim();if(i)return i}return null}function Ao(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 L(o,c,i){let l=ye({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 qt(o,c,i){if(!i||i.hit===!1)return null;let l=Ut(i.responderTestID,i.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let f=Fo(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 Re(o,c,i){let l=Ut(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 pn(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=Je(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"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--node-id","--max-ms","--filter","--limit","--level","--threshold","--equals","--since"]}),a=f.positional,g=a[0],h=i==="get"||i==="do"||i==="debug"||i==="wait"?i:"inspect",M=typeof l[0]=="string"&&Be.has(l[0]),k=M?l[0]:null,w=e=>M&&e===l[0]?`sootsim ${e}`:`sootsim ${h} ${e}`,S=(e,t)=>` usage: ${w(e)}${t?` ${t}`:""}`;if(!g||o.includes("--help")||o.includes("-h")){let e={bridgePort:7668,defaultShellUrl:De};if(h==="do"||h==="get"||h==="debug"||h==="wait"){let r=Se(h,e);r&&(console.log(`${r}
111
- `),process.exit(0))}if(k==="shell"){let r=ke("shell",e);r&&(console.log(`${r}
112
- `),process.exit(0))}let t=ke("inspect",e),n=["do","get","debug","wait"].map(r=>Se(r,e)).filter(r=>r!=null).join(`
110
+ })()`})}function _o(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 Fo(o){if(typeof o!="string")return null;let c=o.replace(/\s+/g," ").trim();return c?c.slice(0,80):null}function Ut(...o){for(let c of o){if(typeof c!="string")continue;let i=c.trim();if(i)return i}return null}function Ao(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 qt(o,c,i){if(!i||i.hit===!1)return null;let l=Ut(i.responderTestID,i.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let f=Fo(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 Ee(o,c,i){let l=Ut(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 pn(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=Je(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"&&De.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:Be};if(b==="do"||b==="get"||b==="debug"||b==="wait"){let r=ke(b,e);r&&(console.log(`${r}
111
+ `),process.exit(0))}if(M==="shell"){let r=Te("shell",e);r&&(console.log(`${r}
112
+ `),process.exit(0))}let t=Te("inspect",e),n=["do","get","debug","wait"].map(r=>ke(r,e)).filter(r=>r!=null).join(`
113
113
 
114
114
  `);console.log(`${t??""}
115
115
 
116
116
  ${n}
117
- `),process.exit(0)}let I=f.wsPort,N=f.simId,O=f.simIdSource,D=f.commandTimeoutMs;if(g==="list"&&l.some(e=>e==="--drivers"||e==="-D")){let{buildDriverListRows:e}=await import("./drivers-RRHVOU6S.js"),t=e();console.log(` available drivers (${t.length}):
118
- `);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=Le(f),H=N||"default",B=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","list","wait","sleep"]),C=200;function oe(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<=C?t:`${t.slice(0,C)}\u2026 (+${t.length-C} more bytes)`}function Y(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=he()?5e3:1500;try{let{settled:n,elapsed:r}=await ee({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.
119
- `)}catch{}}function T(e){return!(!e||e.hit===!1||e.ok===!1||e.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function q(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 z(e){let t=0,n=null,r=null;try{await ee({bridge:u,maxMs:he()?3e3:1200,pollMs:32,stablePolls:2})}catch{}let s=Date.now()+(he()?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:q(d,e.textFallback)});if(r=y,T(y))return{payload:d,result:y,attempts:t}}let m=s-Date.now();if(m<=0)break;try{await ee({bridge:u,maxMs:Math.min(m,700),pollMs:32,stablePolls:2})}catch{await Z(Math.min(120,m))}}return{payload:n,result:r,attempts:t,failure:n&&typeof n.cx=="number"?"missed":"not-found"}}function G(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 re(){try{return await u.send({type:"evaluate",code:`(() => ({
117
+ `),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-HPRXOC6D.js"),t=e();console.log(` available drivers (${t.length}):
118
+ `);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=Le(f),Y=T||"default",D=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","list","wait","sleep"]),E=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<=E?t:`${t.slice(0,E)}\u2026 (+${t.length-E} 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.
119
+ `)}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 J(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:`(() => ({
120
120
  console: window.__sootsimConsole?.count?.() || null,
121
121
  requests: window.__sootsimTest?.getRequestCounts?.() || null,
122
- }))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function ie(e={}){let t=e.counts!==void 0?e.counts:await V(u,"getRequestCounts");if(!t||typeof t!="object")return;let n=Math.max(0,Number(t.failed)||0);if(n===0||!e.includeTail&&!Fe("requests",H,String(n))||(console.log(`
123
- network: ${n} failed request${n===1?"":"s"}`),console.log(` inspect: ${w("requests")} 5`),!e.includeTail))return;let r=await V(u,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
122
+ }))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function ne(e={}){let t=e.counts!==void 0?e.counts:await X(u,"getRequestCounts");if(!t||typeof t!="object")return;let n=Math.max(0,Number(t.failed)||0);if(n===0||!e.includeTail&&!Ae("requests",Y,String(n))||(console.log(`
123
+ network: ${n} failed request${n===1?"":"s"}`),console.log(` inspect: ${h("requests")} 5`),!e.includeTail))return;let r=await X(u,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
124
124
  recent failed requests:
125
- `);for(let s of r){let d=ne(s.timestamp);console.log(` [${d}] ${Y(s)}`),s.responseBody?console.log(` ${oe(s.responseBody)}`):s.error&&console.log(` ${s.error}`)}}}async function E(e={}){let t=e.counts!==void 0?e.counts:await u.send({type:"evaluate",code:"window.__sootsimConsole?.count?.() || { errors: 0, warnings: 0, total: 0 }"});if(!t||typeof t!="object")return;let n=t,r=Math.max(0,Number(n.errors)||0),s=Math.max(0,Number(n.warnings)||0);if(r===0&&s===0||!e.includeTail&&!Fe("console",H,`${r}:${s}`))return;let d=[];if(r>0&&d.push(`${r} console error${r===1?"":"s"}`),s>0&&d.push(`${s} console warning${s===1?"":"s"}`),console.log(`
126
- console: ${d.join(", ")}`),console.log(` inspect: ${w("errors")} 5`),s>0&&console.log(` inspect: ${w("warnings")} 5`),!e.includeTail||r===0)return;let m=await u.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors?.(5) || []"});if(!(!Array.isArray(m)||m.length===0)){console.log(`
125
+ `);for(let s of r){let d=re(s.timestamp);console.log(` [${d}] ${ee(s)}`),s.responseBody?console.log(` ${Z(s.responseBody)}`):s.error&&console.log(` ${s.error}`)}}}async function fe(e={}){let t=e.counts!==void 0?e.counts:await u.send({type:"evaluate",code:"window.__sootsimConsole?.count?.() || { errors: 0, warnings: 0, total: 0 }"});if(!t||typeof t!="object")return;let n=t,r=Math.max(0,Number(n.errors)||0),s=Math.max(0,Number(n.warnings)||0);if(r===0&&s===0||!e.includeTail&&!Ae("console",Y,`${r}:${s}`))return;let d=[];if(r>0&&d.push(`${r} console error${r===1?"":"s"}`),s>0&&d.push(`${s} console warning${s===1?"":"s"}`),console.log(`
126
+ console: ${d.join(", ")}`),console.log(` inspect: ${h("errors")} 5`),s>0&&console.log(` inspect: ${h("warnings")} 5`),!e.includeTail||r===0)return;let m=await u.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors?.(5) || []"});if(!(!Array.isArray(m)||m.length===0)){console.log(`
127
127
  recent console errors:
128
- `);for(let y of m){let p=ne(y.timestamp),x=Array.isArray(y.args)?y.args.map(A=>typeof A=="object"?JSON.stringify(A):String(A)).join(" "):String(y);console.log(` [${p}] ${x}`)}}}let se=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function pe(e){let t=je(),n=null;try{n=await We(e,`(() => {
128
+ `);for(let y of m){let p=re(y.timestamp),x=Array.isArray(y.args)?y.args.map(A=>typeof A=="object"?JSON.stringify(A):String(A)).join(" "):String(y);console.log(` [${p}] ${x}`)}}}let C=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function ae(e){let t=je(),n=null;try{n=await We(e,`(() => {
129
129
  const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
130
130
  if (!tl || typeof tl.summary !== 'function') return null
131
131
  const cursorKey = ${JSON.stringify(t)}
@@ -141,9 +141,9 @@ ${n}
141
141
  }
142
142
  }
143
143
  return summary ? { summary, consoleSplit } : null
144
- })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},s=[],d=new Set;for(let m of se){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(`
145
- since last: ${s.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await Te(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"]),Kt=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"]),zt=(o.includes("--verbose")||o.includes("-v"))&&!o.includes("--json");h==="do"&&g==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),Ce.has(g)&&await qe(u),Kt.has(g)&&await ge(u,{verbose:zt});try{switch(g){case"list":{await kt({bridge:u,simId:N,args:l});break}case"tree":{await _t({bridge:u,args:l,positional:a});break}case"a11y":{let e=await Ge(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):
146
- `);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 vt({bridge:u,args:o,effectiveArgs:l,positional:a,inspectUsage:S});break}case"count":{await xt(u,{args:l});break}case"keyboard":{await St(u,{json:o.includes("--json")});break}case"screens":{await Mt(u,{json:o.includes("--json")});break}case"memory":{await Tt(u,{args:l});break}case"wait":{await At({wsPort:I,commandTimeoutMs:D,simId:N,simIdSource:O,positional:a});break}case"sleep":{await Nt({positional:a,inspectUsage:S});break}case"settle":{await It({bridge:u,args:o,positional:a});break}case"ready":{await Et({bridge:u,args:o});break}case"idle":{await Rt({bridge:u,args:o,positional:a});break}case"selector":{await Ct({bridge:u,args:o,positional:a,inspectUsage:S});break}case"event":{await Ot({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 Jt(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 Jt(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:ft(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 () => {
144
+ })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},s=[],d=new Set;for(let m of C){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(`
145
+ 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"]),Kt=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"]),zt=(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 qe(u),Kt.has(g)&&await ye(u,{verbose:zt});try{switch(g){case"list":{await kt({bridge:u,simId:T,args:l});break}case"tree":{await _t({bridge:u,args:l,positional:a});break}case"a11y":{let e=await Ge(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):
146
+ `);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 vt({bridge:u,args:o,effectiveArgs:l,positional:a,inspectUsage:S});break}case"count":{await xt(u,{args:l});break}case"keyboard":{await St(u,{json:o.includes("--json")});break}case"screens":{await Mt(u,{json:o.includes("--json")});break}case"memory":{await Tt(u,{args:l});break}case"wait":{await At({wsPort:F,commandTimeoutMs:j,simId:T,simIdSource:R,positional:a});break}case"sleep":{await Nt({positional:a,inspectUsage:S});break}case"settle":{await It({bridge:u,args:o,positional:a});break}case"ready":{await Et({bridge:u,args:o});break}case"idle":{await Rt({bridge:u,args:o,positional:a});break}case"selector":{await Ct({bridge:u,args:o,positional:a,inspectUsage:S});break}case"event":{await Ot({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 Jt(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 Jt(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:ft(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 () => {
147
147
  const t = window.__sootsimTest
148
148
  const q = ${JSON.stringify(e)}
149
149
  let node = null
@@ -199,20 +199,20 @@ ${n}
199
199
  transform,
200
200
  parentChain,
201
201
  }
202
- })()`});console.log(JSON.stringify(t,null,2));break}case"tap":{let e=Number(a[1]),t=Number(a[2]),n=me(o);if(n){let d=await z({textFallback:n.mode==="text"?n.value:void 0,resolve:async()=>{let p=await we(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"&&Q("wait-selector-for-missing-testid",n.value),process.exit(1)),T(d.result)||(G(`${n.mode} "${n.value}"`,d),process.exit(1));let y=qt(m.cx,m.cy,d.result);y&&await L("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=qt(e,t,r);s&&await L("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 () => {
202
+ })()`});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 J({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=qt(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=qt(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 () => {
203
203
  const interact = window.__sootsimInteract
204
204
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
205
205
  const value = await interact.drag(${e}, ${t}, ${n}, ${r}, ${Math.max(1,Math.round(m))}, ${Math.max(0,Math.round(y))})
206
206
  return { ok: !!value, value }
207
- })()`});if(p?.ok){let x=Math.max(1,Math.round(Math.max(1,m)*Math.max(0,y)));await L(`inspect ${g}`,{swipe:{start:`${e}, ${t}`,end:`${n}, ${r}`,duration:x}},`${g} ${e},${t} -> ${n},${r}`)}console.log(JSON.stringify(p,null,2));break}case"pinch":{let e=Number(a[1]),t=Number(a[2]),n=Number(a[3]),r=Number(a[4]),s=Number(a[5]),d=Number(a[6]),m=Number(a[7]),y=Number(a[8]),p=a[9]?Number(a[9]):12,x=a[10]?Number(a[10]):16;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(d)||!Number.isFinite(m)||!Number.isFinite(y)||!Number.isFinite(p)||!Number.isFinite(x))&&(console.error(S("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let A=await u.send({type:"evaluate",code:`(async () => {
207
+ })()`});if(p?.ok){let x=Math.max(1,Math.round(Math.max(1,m)*Math.max(0,y)));await q(`inspect ${g}`,{swipe:{start:`${e}, ${t}`,end:`${n}, ${r}`,duration:x}},`${g} ${e},${t} -> ${n},${r}`)}console.log(JSON.stringify(p,null,2));break}case"pinch":{let e=Number(a[1]),t=Number(a[2]),n=Number(a[3]),r=Number(a[4]),s=Number(a[5]),d=Number(a[6]),m=Number(a[7]),y=Number(a[8]),p=a[9]?Number(a[9]):12,x=a[10]?Number(a[10]):16;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(d)||!Number.isFinite(m)||!Number.isFinite(y)||!Number.isFinite(p)||!Number.isFinite(x))&&(console.error(S("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let A=await u.send({type:"evaluate",code:`(async () => {
208
208
  const interact = window.__sootsimInteract
209
209
  if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
210
210
  const value = await interact.pinch(${e}, ${t}, ${n}, ${r}, ${s}, ${d}, ${m}, ${y}, ${Math.max(1,Math.round(p))}, ${Math.max(0,Math.round(x))})
211
211
  return { ok: !!value, value }
212
- })()`});A?.ok&&await L("inspect pinch",{pinch:{from:[e,t,n,r],to:[s,d,m,y],steps:Math.max(1,Math.round(p)),stepMs:Math.max(0,Math.round(x))}},`pinch (${e},${t}) (${n},${r}) -> (${s},${d}) (${m},${y})`),console.log(JSON.stringify(A,null,2));break}case"tap-text":{let e=a[1];e||(console.error(S("tap-text","<text>")),process.exit(1));let t=X=>{let R=o.indexOf(X);return R>=0&&R+1<o.length?o[R+1]:null},n=X=>o.includes(X),r=t("--nth")??t("--index"),s=r!==null?Number(r):null;s!==null&&!Number.isFinite(s)&&(console.error(` --nth/--index requires an integer, got: ${r}`),process.exit(1));let d=t("--within"),m=t("--role"),y=n("--exact"),p=n("--first"),x=t("--min-y"),A=t("--max-y"),W=t("--min-x"),U=t("--max-x");for(let[X,R]of[["--min-y",x],["--max-y",A],["--min-x",W],["--max-x",U]])R!==null&&!Number.isFinite(Number(R))&&(console.error(` ${X} requires a number, got: ${R}`),process.exit(1));let K=o.indexOf("--near"),_=null;if(K>=0){let X=Number(o[K+1]),R=Number(o[K+2]);(!Number.isFinite(X)||!Number.isFinite(R))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),_={x:X,y:R}}let b=JSON.stringify({query:e,exact:y,role:m,within:d,minX:W!==null?Number(W):null,maxX:U!==null?Number(U):null,minY:x!==null?Number(x):null,maxY:A!==null?Number(A):null,near:_,nth:s,first:p}),P=await z({textFallback:e,resolve:()=>u.send({type:"evaluate",code:`(async () => {
212
+ })()`});A?.ok&&await q("inspect pinch",{pinch:{from:[e,t,n,r],to:[s,d,m,y],steps:Math.max(1,Math.round(p)),stepMs:Math.max(0,Math.round(x))}},`pinch (${e},${t}) (${n},${r}) -> (${s},${d}) (${m},${y})`),console.log(JSON.stringify(A,null,2));break}case"tap-text":{let e=a[1];e||(console.error(S("tap-text","<text>")),process.exit(1));let t=G=>{let O=o.indexOf(G);return O>=0&&O+1<o.length?o[O+1]:null},n=G=>o.includes(G),r=t("--nth")??t("--index"),s=r!==null?Number(r):null;s!==null&&!Number.isFinite(s)&&(console.error(` --nth/--index requires an integer, got: ${r}`),process.exit(1));let d=t("--within"),m=t("--role"),y=n("--exact"),p=n("--first"),x=t("--min-y"),A=t("--max-y"),H=t("--min-x"),U=t("--max-x");for(let[G,O]of[["--min-y",x],["--max-y",A],["--min-x",H],["--max-x",U]])O!==null&&!Number.isFinite(Number(O))&&(console.error(` ${G} requires a number, got: ${O}`),process.exit(1));let K=o.indexOf("--near"),N=null;if(K>=0){let G=Number(o[K+1]),O=Number(o[K+2]);(!Number.isFinite(G)||!Number.isFinite(O))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),N={x:G,y:O}}let w=JSON.stringify({query:e,exact:y,role:m,within:d,minX:H!==null?Number(H):null,maxX:U!==null?Number(U):null,minY:x!==null?Number(x):null,maxY:A!==null?Number(A):null,near:N,nth:s,first:p}),P=await J({textFallback:e,resolve:()=>u.send({type:"evaluate",code:`(async () => {
213
213
  const t = window.__sootsimTest
214
214
  if (!t) return { error: 'bridge-not-ready' }
215
- const F = ${b}
215
+ const F = ${w}
216
216
 
217
217
  const res = await t.queryTextCandidates({
218
218
  query: F.query,
@@ -329,7 +329,7 @@ ${n}
329
329
  total,
330
330
  idx,
331
331
  }
332
- })()`})}),F=P.payload;if(F?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),F?.ambiguous){let X=F.candidates;console.error(` ambiguous: ${F.total} matches for "${e}"`);for(let R of X){let Yt=R.abs?`@(${Math.round(R.abs.x)},${Math.round(R.abs.y)})`:"",Gt=R.layout?` ${R.layout.width}x${R.layout.height}`:"",Xt=R.testID?` #${R.testID}`:"",Vt=R.text?` "${R.text}"`:"",Qt=R.ancestorTestIDs.length>0?` within ${R.ancestorTestIDs.slice(0,3).map(Zt=>`#${Zt}`).join(" > ")}`:"";console.error(` [${R.idx}] <${R.type}>${Vt}${Xt} ${Yt}${Gt}${Qt}`)}F.total>X.length&&console.error(` ... and ${F.total-X.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)),T(P.result)||(G(`text "${e}"`,P),process.exit(1));let ce=Re(e,{id:F.target?.id??null,testID:F.target?.testID??null,type:F.target?.type??null,cx:F.cx,cy:F.cy},"text");await L("inspect tap-text",ce.step,ce.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 z({textFallback:e,resolve:async()=>{let y=await u.send({type:"evaluate",code:`(async () => {
332
+ })()`})}),_=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 Yt=O.abs?`@(${Math.round(O.abs.x)},${Math.round(O.abs.y)})`:"",Gt=O.layout?` ${O.layout.width}x${O.layout.height}`:"",Xt=O.testID?` #${O.testID}`:"",Vt=O.text?` "${O.text}"`:"",Qt=O.ancestorTestIDs.length>0?` within ${O.ancestorTestIDs.slice(0,3).map(Zt=>`#${Zt}`).join(" > ")}`:"";console.error(` [${O.idx}] <${O.type}>${Vt}${Xt} ${Yt}${Gt}${Qt}`)}_.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=Ee(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 J({textFallback:e,resolve:async()=>{let y=await u.send({type:"evaluate",code:`(async () => {
333
333
  const t = window.__sootsimTest
334
334
  if (!t) return { error: 'bridge-not-ready' }
335
335
  // try testID first \u2014 strongest signal of "this is the
@@ -370,7 +370,7 @@ ${n}
370
370
  }
371
371
  }
372
372
  return { strategy: 'none' }
373
- })()`});if(!("node"in y))return y;let p=y.node,x=p.absolutePosition.x+p.layout.width/2,A=p.absolutePosition.y+p.layout.height/2;return{...y,cx:x,cy:A,target:{id:p.id,testID:p.testID,text:y.strategy==="text"?e:p.text,type:p.type}}}}),s=r.payload;s||(console.error(` tap-best: no testID or visible text matched "${e}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1)),"error"in s&&(console.error(` ${s.error}`),process.exit(1)),s.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${e}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1));let d=s.node;T(r.result)||(G(`best "${e}"`,r),process.exit(1));let m=Re(e,{id:d.id,testID:d.testID,type:d.type,cx:s.cx,cy:s.cy},s.strategy==="testid"?"id":"text");await L("inspect tap-best",m.step,m.summary),console.log(JSON.stringify({matched:{strategy:s.strategy,nodeId:d.nodeId,id:d.id,testID:d.testID,type:d.type,text:d.text},tapped:{cx:s.cx,cy:s.cy},...r.attempts>1?{attempts:r.attempts}:{},result:r.result},null,2));break}case"tap-id":{let e=a[1];e||(console.error(S("tap-id","<id>")),process.exit(1));let t=JSON.stringify(e),r=await z({resolve:()=>u.send({type:"evaluate",code:`(async () => {
373
+ })()`});if(!("node"in y))return y;let p=y.node,x=p.absolutePosition.x+p.layout.width/2,A=p.absolutePosition.y+p.layout.height/2;return{...y,cx:x,cy:A,target:{id:p.id,testID:p.testID,text:y.strategy==="text"?e:p.text,type:p.type}}}}),s=r.payload;s||(console.error(` tap-best: no testID or visible text matched "${e}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1)),"error"in s&&(console.error(` ${s.error}`),process.exit(1)),s.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${e}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1));let d=s.node;I(r.result)||(z(`best "${e}"`,r),process.exit(1));let m=Ee(e,{id:d.id,testID:d.testID,type:d.type,cx:s.cx,cy:s.cy},s.strategy==="testid"?"id":"text");await q("inspect tap-best",m.step,m.summary),console.log(JSON.stringify({matched:{strategy:s.strategy,nodeId:d.nodeId,id:d.id,testID:d.testID,type:d.type,text:d.text},tapped:{cx:s.cx,cy:s.cy},...r.attempts>1?{attempts:r.attempts}:{},result:r.result},null,2));break}case"tap-id":{let e=a[1];e||(console.error(S("tap-id","<id>")),process.exit(1));let t=JSON.stringify(e),r=await J({resolve:()=>u.send({type:"evaluate",code:`(async () => {
374
374
  const t = window.__sootsimTest
375
375
  if (!t) return null
376
376
  const n = (await t.findByTestId(${t})) || (await t.findById(${t}))
@@ -412,7 +412,7 @@ ${n}
412
412
  },
413
413
  strategy: (resolved && resolved.strategy) || 'matched-node',
414
414
  }
415
- })()`})}),s=r.payload;(!s||typeof s.cx!="number")&&(console.error(` not found: ${e}`),await wo(u,e),process.exit(1)),T(r.result)||(G(`id "${e}"`,r),process.exit(1));let d=Re(e,{id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},"id");await L("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 () => {
415
+ })()`})}),s=r.payload;(!s||typeof s.cx!="number")&&(console.error(` not found: ${e}`),await wo(u,e),process.exit(1)),I(r.result)||(z(`id "${e}"`,r),process.exit(1));let d=Ee(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 () => {
416
416
  const t = window.__sootsimTest
417
417
  if (!t) return null
418
418
  const n = await (t.findByTestId(${n}) || t.findById(${n}))
@@ -426,7 +426,7 @@ ${n}
426
426
  isTextInput: !!n.isTextInput,
427
427
  placeholder: n.placeholder || null,
428
428
  }
429
- })()`});(!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 No(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 L("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 ve(u,"type"),await u.send({type:"keyboard",action:"type",text:e}),await L("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 ve(u,"key"),await u.send({type:"keyboard",action:"press",text:e}),await L("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 ve(u,"key-sequence");for(let t of e)await u.send({type:"keyboard",action:"press",text:t});await L("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:_o(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 ve(u,"keycode");for(let r of t)await u.send({type:"keyboard",action:"press",text:r.key});await L("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 L("inspect dispatch",{dispatchKey:e},`dispatch ${JSON.stringify(e)}`),console.log(` dispatched: ${e}`);break}case"dismiss":{await u.send({type:"keyboard",action:"dismiss"}),await L("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let e=Number(a[1]),t=Number(a[2]),n=me(o);if(n){let m=await we(u,n);m||(console.error(` not found: ${n.value}`),n.mode==="testid"&&Q("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 () => {
429
+ })()`});(!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 No(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:_o(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 () => {
430
430
  const interact = window.__sootsimInteract
431
431
  if (interact?.doubleTap) {
432
432
  return {
@@ -449,18 +449,18 @@ ${n}
449
449
  first,
450
450
  second,
451
451
  }
452
- })()`});d?.ok&&await L("inspect double-tap",{doubleTapAtCoords:{x:e,y:t,gapMs:s}},`double-tap @${e},${t}`),console.log(JSON.stringify(d,null,2));break}case"long-press":{let e=Number(a[1]),t=Number(a[2]),n=me(o);if(n){let d=await we(u,n);d||(console.error(` not found: ${n.value}`),n.mode==="testid"&&Q("wait-selector-for-missing-testid",n.value),process.exit(1)),e=d.x,t=d.y}let r=a[3]?Number(a[3]):600;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&(console.error(S("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let s=await u.send({type:"evaluate",code:`(async () => {
452
+ })()`});d?.ok&&await q("inspect double-tap",{doubleTapAtCoords:{x:e,y:t,gapMs:s}},`double-tap @${e},${t}`),console.log(JSON.stringify(d,null,2));break}case"long-press":{let e=Number(a[1]),t=Number(a[2]),n=pe(o);if(n){let d=await xe(u,n);d||(console.error(` not found: ${n.value}`),n.mode==="testid"&&V("wait-selector-for-missing-testid",n.value),process.exit(1)),e=d.x,t=d.y}let r=a[3]?Number(a[3]):600;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&(console.error(S("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let s=await u.send({type:"evaluate",code:`(async () => {
453
453
  const interact = window.__sootsimInteract
454
454
  if (!interact?.longPress) return { ok: false, reason: 'no interact.longPress' }
455
455
  const value = await interact.longPress(${e}, ${t}, ${Math.max(0,Math.round(r))})
456
456
  return { ok: !!value, value }
457
- })()`});s?.ok&&await L("inspect long-press",{tapAtCoords:{x:e,y:t}},`long-press @${e},${t}`),console.log(JSON.stringify(s,null,2));break}case"touch":{let e=a[1],t=Number(a[2]),n=Number(a[3]),r=a[4]?Number(a[4]):999,s=e==="down"?"touchDown":e==="move"?"touchMove":e==="up"?"touchUp":e==="cancel"?"touchCancel":null;s||(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),e!=="cancel"&&(!Number.isFinite(t)||!Number.isFinite(n))&&(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let d=e==="down"?"tap":e==="move"?"move":null,m=d&&Number.isFinite(t)&&Number.isFinite(n)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${d}', x: ${t}, y: ${n} } }));`:"",y=await u.send({type:"evaluate",code:`(async () => {
457
+ })()`});s?.ok&&await q("inspect long-press",{tapAtCoords:{x:e,y:t}},`long-press @${e},${t}`),console.log(JSON.stringify(s,null,2));break}case"touch":{let e=a[1],t=Number(a[2]),n=Number(a[3]),r=a[4]?Number(a[4]):999,s=e==="down"?"touchDown":e==="move"?"touchMove":e==="up"?"touchUp":e==="cancel"?"touchCancel":null;s||(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),e!=="cancel"&&(!Number.isFinite(t)||!Number.isFinite(n))&&(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let d=e==="down"?"tap":e==="move"?"move":null,m=d&&Number.isFinite(t)&&Number.isFinite(n)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${d}', x: ${t}, y: ${n} } }));`:"",y=await u.send({type:"evaluate",code:`(async () => {
458
458
  ${m}
459
459
  const interact = window.__sootsimInteract
460
460
  if (!interact?.${s}) return { ok: false, reason: 'no interact.${s}' }
461
461
  const value = ${e==="cancel"?`await interact.${s}(${Math.max(1,Math.round(r))})`:`await interact.${s}(${t}, ${n}, ${Math.max(1,Math.round(r))})`}
462
462
  return { ok: !!value, value }
463
- })()`});y?.ok&&e!=="cancel"&&await L("inspect touch",{tapAtCoords:{x:t,y:n}},`touch ${e} @${t},${n}`),console.log(JSON.stringify(y,null,2));break}case"gesture":{let e=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],t=a[1],n=a[2]?Number(a[2]):220;(!t||!Number.isFinite(n))&&(console.error(S("gesture","<preset> [durationMs]")),console.error(` presets: ${e.join(", ")}`),process.exit(1)),e.includes(t)||(console.error(` unknown gesture preset: ${t}`),console.error(` presets: ${e.join(", ")}`),process.exit(1));let r=await u.send({type:"evaluate",code:`(async () => {
463
+ })()`});y?.ok&&e!=="cancel"&&await q("inspect touch",{tapAtCoords:{x:t,y:n}},`touch ${e} @${t},${n}`),console.log(JSON.stringify(y,null,2));break}case"gesture":{let e=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],t=a[1],n=a[2]?Number(a[2]):220;(!t||!Number.isFinite(n))&&(console.error(S("gesture","<preset> [durationMs]")),console.error(` presets: ${e.join(", ")}`),process.exit(1)),e.includes(t)||(console.error(` unknown gesture preset: ${t}`),console.error(` presets: ${e.join(", ")}`),process.exit(1));let r=await u.send({type:"evaluate",code:`(async () => {
464
464
  const spec = globalThis.__sootsimDeviceSpec || {}
465
465
  return {
466
466
  width: spec.width || window.innerWidth || 393,
@@ -468,12 +468,12 @@ ${n}
468
468
  statusBarHeight: spec.statusBarHeight || 0,
469
469
  homeIndicatorHeight: spec.homeIndicatorHeight || 0,
470
470
  }
471
- })()`}),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),W=Math.max(24,y+18),U=18,K=Math.min(220,Math.round(d*.24)),_=Math.min(180,Math.round(s*.32)),b=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":b=p+Math.round(_/2),P=p-Math.round(_/2);break;case"scroll-right":b=p-Math.round(_/2),P=p+Math.round(_/2);break;case"swipe-from-left-edge":b=U,v=x,P=Math.min(s-U,U+_);break;case"swipe-from-right-edge":b=s-U,v=x,P=Math.max(U,s-U-_);break;case"swipe-from-top-edge":b=p,v=A,F=Math.min(d-W,A+K);break;case"swipe-from-bottom-edge":b=p,v=d-W,F=Math.max(A,d-W-K);break}let ce=Math.max(8,Math.round(n/16)),X=Math.max(1,Math.round(n/ce)),R=await u.send({type:"evaluate",code:`(async () => {
471
+ })()`}),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 () => {
472
472
  const interact = window.__sootsimInteract
473
473
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
474
- const value = await interact.drag(${b}, ${v}, ${P}, ${F}, ${ce}, ${X})
474
+ const value = await interact.drag(${w}, ${v}, ${P}, ${_}, ${de}, ${G})
475
475
  return { ok: !!value, value }
476
- })()`});R?.ok&&await L("inspect gesture",{swipe:{start:`${b}, ${v}`,end:`${P}, ${F}`,duration:Math.max(1,Math.round(n))}},`gesture ${t}`),console.log(JSON.stringify({preset:t,from:{x:b,y:v},to:{x:P,y:F},result:R},null,2));break}case"scroll":{let e=me(o),t=Ao(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 () => {
476
+ })()`});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=Ao(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 () => {
477
477
  const t = window.__sootsimTest
478
478
  if (!t) return null
479
479
  const n = ${t!=null?`await t.inspectByNodeId(${JSON.stringify(t)})`:`await t.findByTestId(${JSON.stringify(n)})
@@ -483,11 +483,11 @@ ${n}
483
483
  cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
484
484
  cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
485
485
  }
486
- })()`}),y=await V(u,"scrollTo",t!=null?{nodeId:t}:n,s,d,!1);if(y?.ok){let p=t!=null?`node ${t}`:`#${n}`;await L("inspect scroll",{scrollTo:{...t!=null?{nodeId:t}:{id:n},x:s,y:d}},`scroll ${p} -> ${s},${d}`)}console.log(JSON.stringify({...y,...m?{at:{x:m.cx,y:m.cy}}:{}},null,2));break}case"state":{let e=a[1];if(i==="get"&&!e){let n=await V(u,"getRuntimeState"),r=await u.send({type:"evaluate",code:`({
486
+ })()`}),y=await X(u,"scrollTo",t!=null?{nodeId:t}:n,s,d,!1);if(y?.ok){let p=t!=null?`node ${t}`:`#${n}`;await q("inspect scroll",{scrollTo:{...t!=null?{nodeId:t}:{id:n},x:s,y:d}},`scroll ${p} -> ${s},${d}`)}console.log(JSON.stringify({...y,...m?{at:{x:m.cx,y:m.cy}}:{}},null,2));break}case"state":{let e=a[1];if(i==="get"&&!e){let n=await X(u,"getRuntimeState"),r=await u.send({type:"evaluate",code:`({
487
487
  errors: window.__sootsimConsole?.getErrors?.()?.length ?? 0,
488
488
  warnings: window.__sootsimConsole?.getWarnings?.()?.length ?? 0,
489
489
  })`});if(n&&typeof n=="object"&&n.diagnostics&&(n.diagnostics.errors=r?.errors??0,n.diagnostics.warnings=r?.warnings??0),n&&typeof n=="object"&&n.shell==null)try{let s=await le(u);s&&(n.shell=s)}catch{}console.log(JSON.stringify(n,null,2));break}if(!e||e==="--help"||e==="-h"){console.log(`
490
- ${w("state")} \u2014 dump raw runtime state
490
+ ${h("state")} \u2014 dump raw runtime state
491
491
 
492
492
  subcommands:
493
493
  shell dump shell transition/layout state
@@ -501,15 +501,15 @@ ${n}
501
501
  gesture <x> <y> dump gesture routing/debug info at coordinates
502
502
 
503
503
  examples:
504
- ${w("state")} shell
505
- ${w("state")} worker
506
- ${w("state")} keyboard
507
- ${w("state")} ownership
508
- ${w("state")} node photos
509
- ${w("state")} scroll feed
510
- ${w("state")} scroll-hit 360 420
511
- ${w("state")} hit 200 720
512
- `);break}let t;switch(e){case"shell":t=await le(u,500);break;case"worker":t=await Te(u,"__sootsimRenderHost.queryStats");break;case"ownership":t=await u.send({type:"evaluate",code:`(() => {
504
+ ${h("state")} shell
505
+ ${h("state")} worker
506
+ ${h("state")} keyboard
507
+ ${h("state")} ownership
508
+ ${h("state")} node photos
509
+ ${h("state")} scroll feed
510
+ ${h("state")} scroll-hit 360 420
511
+ ${h("state")} hit 200 720
512
+ `);break}let t;switch(e){case"shell":t=await le(u,500);break;case"worker":t=await Me(u,"__sootsimRenderHost.queryStats");break;case"ownership":t=await u.send({type:"evaluate",code:`(() => {
513
513
  const h = window.__sootsimRenderHost
514
514
  if (!h || typeof h.getOwnershipSnapshot !== 'function') {
515
515
  return { error: 'getOwnershipSnapshot not available' }
@@ -540,8 +540,8 @@ ${n}
540
540
  text: focused.text || null,
541
541
  } : null,
542
542
  }
543
- })()`});break;case"node":{let n=a[2];n||(console.error(` usage: ${w("state")} node <id>`),process.exit(1)),t=await V(u,"findByTestId",n)||await V(u,"findById",n);break}case"scroll":{let n=a[2];n||(console.error(` usage: ${w("state")} scroll <id>`),process.exit(1)),t=await V(u,"getScrollState",n);break}case"scroll-hit":{let n=Number(a[2]),r=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(` usage: ${w("state")} scroll-hit <x> <y>`),process.exit(1)),t=await V(u,"getScrollStateAt",n,r);break}case"hit":{let n=Number(a[2]),r=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(` usage: ${w("state")} hit <x> <y>`),process.exit(1)),t=await V(u,"debugHitAt",n,r);break}case"gesture":{let n=Number(a[2]),r=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(` usage: ${w("state")} gesture <x> <y>`),process.exit(1)),t=await V(u,"debugGestureAt",n,r);break}default:console.error(` unknown state subcommand: ${e}`),process.exit(1)}console.log(JSON.stringify(t,null,2));break}case"shell":{let e=a[1];if(!e||e==="--help"||e==="-h"){console.log(`
544
- ${w("shell")} \u2014 run built-in shell commands
543
+ })()`});break;case"node":{let n=a[2];n||(console.error(` usage: ${h("state")} node <id>`),process.exit(1)),t=await X(u,"findByTestId",n)||await X(u,"findById",n);break}case"scroll":{let n=a[2];n||(console.error(` usage: ${h("state")} scroll <id>`),process.exit(1)),t=await X(u,"getScrollState",n);break}case"scroll-hit":{let n=Number(a[2]),r=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(` usage: ${h("state")} scroll-hit <x> <y>`),process.exit(1)),t=await X(u,"getScrollStateAt",n,r);break}case"hit":{let n=Number(a[2]),r=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(` usage: ${h("state")} hit <x> <y>`),process.exit(1)),t=await X(u,"debugHitAt",n,r);break}case"gesture":{let n=Number(a[2]),r=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(` usage: ${h("state")} gesture <x> <y>`),process.exit(1)),t=await X(u,"debugGestureAt",n,r);break}default:console.error(` unknown state subcommand: ${e}`),process.exit(1)}console.log(JSON.stringify(t,null,2));break}case"shell":{let e=a[1];if(!e||e==="--help"||e==="-h"){console.log(`
544
+ ${h("shell")} \u2014 run built-in shell commands
545
545
 
546
546
  subcommands:
547
547
  launch <appId> [waitMs] [--clear-state]
@@ -556,15 +556,15 @@ ${n}
556
556
  shake trigger the simulator shake gesture
557
557
 
558
558
  examples:
559
- ${w("shell")} launch photos
560
- ${w("shell")} launch rn --clear-state
561
- ${w("shell")} launch photos 1500
562
- ${w("shell")} home 500
563
- ${w("shell")} switcher 800
564
- ${w("shell")} open-card clock 800
565
- ${w("shell")} appearance dark
566
- ${w("shell")} lock
567
- `);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:He}),s=!!await de(u,"launchApp",r,p),{settled:d,state:m}=await $e(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 L("inspect shell launch",y?{launchApp:{clearState:!0}}:{launchApp:{}},y?"launch app (clear state)":"launch app")}else if(e==="home")s=!!await de(u,"goHome",r),{settled:d,state:m}=await $e(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 de(u,"openSwitcher",r),{settled:d,state:m}=await $e(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 Z(Io),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 de(u,"openSwitcherCard",r,p),{settled:d,state:m}=await $e(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 L("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 Lt(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 Lt(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 Ft(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:`;(() => {
559
+ ${h("shell")} launch photos
560
+ ${h("shell")} launch rn --clear-state
561
+ ${h("shell")} launch photos 1500
562
+ ${h("shell")} home 500
563
+ ${h("shell")} switcher 800
564
+ ${h("shell")} open-card clock 800
565
+ ${h("shell")} appearance dark
566
+ ${h("shell")} lock
567
+ `);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:He}),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(Io),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 Lt(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 Lt(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 Ft(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:`;(() => {
568
568
  const reloadExternalApp = window.SootSim?.bridges?.hotRemount?.reloadExternalApp
569
569
  if (typeof reloadExternalApp === 'function') {
570
570
  reloadExternalApp()
@@ -572,10 +572,10 @@ ${n}
572
572
  }
573
573
  window.location.reload()
574
574
  return { kind: 'page' }
575
- })()`});r=!!m&&m.kind==="external-app",n=!0}catch{}console.log(" reloading...");let s=u,d=null;if(r)d=await _e(u,{timeoutMs:1e4,errorGraceMs:3e3});else{n&&await Z(300);let m=await ut(I,D,N,{timeoutMs:1e4,simIdSource:O});m?(s=m,d=await _e(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=So(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(`
575
+ })()`});r=!!m&&m.kind==="external-app",n=!0}catch{}console.log(" reloading...");let s=u,d=null;if(r)d=await Fe(u,{timeoutMs:1e4,errorGraceMs:3e3});else{n&&await Q(300);let m=await ut(F,j,T,{timeoutMs:1e4,simIdSource:R});m?(s=m,d=await Fe(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=So(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(`
576
576
  \u26A0 ${m.length} error(s) during mount:
577
577
  `);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(`
578
- `).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(` ${w("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${w("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${w("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${w("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&&Q("prefer-cli-over-eval",s);break}case"globals":{let e=await u.send({type:"evaluate",code:`(async () => {
578
+ `).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 () => {
579
579
  const globals = {}
580
580
 
581
581
  // test bridge (proxy in worker mode)
@@ -613,8 +613,8 @@ ${n}
613
613
 
614
614
  return globals
615
615
  })()`});console.log(` sootsim JS API:
616
- `);for(let[t,n]of Object.entries(e)){console.log(` ${t}:`);for(let r of n)console.log(` .${r}`);console.log("")}console.log(` use: ${w("js")} <expression>`),console.log(` example: ${w("js")} test.findByText("Sign in")`);break}case"describe":{await $t({bridge:u,args:o,positional:a});break}case"perf":{let e=a[1];if(!e||e==="--help"||e==="-h"){console.log(`
617
- ${w("perf")} \u2014 performance profiling
616
+ `);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 $t({bridge:u,args:o,positional:a});break}case"perf":{let e=a[1];if(!e||e==="--help"||e==="-h"){console.log(`
617
+ ${h("perf")} \u2014 performance profiling
618
618
 
619
619
  subcommands:
620
620
  stats one-shot stats (zero overhead query)
@@ -624,11 +624,11 @@ ${n}
624
624
  transition <e> profile a shell transition (goHome, appSwitcher, lockScreen)
625
625
 
626
626
  examples:
627
- ${w("perf")} stats
628
- ${w("perf")} start
627
+ ${h("perf")} stats
628
+ ${h("perf")} start
629
629
  # ... interact with the app ...
630
- ${w("perf")} stop
631
- ${w("perf")} transition goHome
630
+ ${h("perf")} stop
631
+ ${h("perf")} transition goHome
632
632
  `);break}switch(e){case"stats":{let t=await u.send({type:"evaluate",code:`(async () => {
633
633
  // worker mode (host exposes these)
634
634
  if (window.__sootsimPerfStats) {
@@ -664,7 +664,7 @@ ${n}
664
664
  // worker mode
665
665
  if (window.__sootsimPerfStart && window.__sootsimRenderHost) {
666
666
  const result = window.__sootsimPerfStart()
667
- window.${te} = {
667
+ window.${se} = {
668
668
  active: true,
669
669
  mode: 'render-worker',
670
670
  lastSamples: [],
@@ -675,23 +675,23 @@ ${n}
675
675
  // main-thread mode
676
676
  window.__sootsimPerf?.enableFrameStats?.(true)
677
677
  window.__sootsimA11y?.resetProfile?.()
678
- window.${te} = {
678
+ window.${se} = {
679
679
  active: true,
680
680
  mode: 'main-thread',
681
681
  lastSamples: [],
682
682
  startedAt: performance.now(),
683
683
  }
684
684
  return { started: true }
685
- })()`}),console.log(` profiling started \u2014 interact with the app, then run '${w("perf")} stop'`);break}case"stop":{let t=await u.send({type:"evaluate",code:`(async () => {
685
+ })()`}),console.log(` profiling started \u2014 interact with the app, then run '${h("perf")} stop'`);break}case"stop":{let t=await u.send({type:"evaluate",code:`(async () => {
686
686
  // worker mode
687
687
  if (window.__sootsimRenderHost) {
688
- const session = window.${te} || {}
688
+ const session = window.${se} || {}
689
689
  const priorSamples = session.active && Array.isArray(session.lastSamples)
690
690
  ? session.lastSamples
691
691
  : []
692
692
  const flushedSamples = await window.__sootsimRenderHost.flushSamples()
693
693
  const samples = priorSamples.concat(flushedSamples)
694
- window.${te} = {
694
+ window.${se} = {
695
695
  ...session,
696
696
  active: false,
697
697
  mode: 'render-worker',
@@ -755,8 +755,8 @@ ${n}
755
755
 
756
756
  // disable collection
757
757
  perf?.disableFrameStats?.()
758
- window.${te} = {
759
- ...(window.${te} || {}),
758
+ window.${se} = {
759
+ ...(window.${se} || {}),
760
760
  active: false,
761
761
  mode: 'main-thread',
762
762
  lastSamples: recent.map((ms, index) => [index, ms, 0, 0, 0, 0, 0]),
@@ -779,13 +779,13 @@ ${n}
779
779
  })()`});t.error&&(console.error(` error: ${t.error}`),process.exit(1));let n=t.avgMs>0?(1e3/t.avgMs).toFixed(1):"?",r=t.sampleCount>0?(t.jankFrames/t.sampleCount*100).toFixed(1):"0";console.log(` profiling stopped:
780
780
  `),console.log(` frames: ${t.frames}`),console.log(` total: ${t.totalMs.toFixed(1)}ms`),console.log(` avg: ${t.avgMs.toFixed(2)}ms (${n} fps)`),console.log(` max: ${t.maxMs.toFixed(2)}ms`),console.log(""),t.layoutAvgMs!==void 0&&(console.log(" breakdown (avg per frame):"),console.log(` layout: ${t.layoutAvgMs.toFixed(2)}ms`),console.log(` render: ${t.renderAvgMs.toFixed(2)}ms`),console.log(` copy: ${t.copyAvgMs.toFixed(2)}ms`),t.auxAvgMs!==void 0&&console.log(` aux: ${t.auxAvgMs.toFixed(2)}ms`),t.otherAvgMs!==void 0&&console.log(` other: ${t.otherAvgMs.toFixed(2)}ms`),console.log("")),console.log(` distribution (${t.sampleCount} samples):`),console.log(` p50: ${t.p50.toFixed(2)}ms`),console.log(` p95: ${t.p95.toFixed(2)}ms`),console.log(` p99: ${t.p99.toFixed(2)}ms`),console.log(` jank: ${t.jankFrames} frames (${r}%) >16.67ms`);break}case"frames":{let t=a[2]?Number(a[2]):50;(!Number.isFinite(t)||t<=0)&&(console.error(` error: expected a positive frame count, got "${a[2]}"`),process.exit(1));let n=await u.send({type:"evaluate",code:`(async () => {
781
781
  if (window.__sootsimRenderHost) {
782
- const session = window.${te} || {}
782
+ const session = window.${se} || {}
783
783
  if (session.active) {
784
784
  const priorSamples = Array.isArray(session.lastSamples) ? session.lastSamples : []
785
785
  const flushedSamples = await window.__sootsimRenderHost.flushSamples()
786
786
  const samples = priorSamples.concat(flushedSamples)
787
787
  window.__sootsimRenderHost.startSampling()
788
- window.${te} = {
788
+ window.${se} = {
789
789
  ...session,
790
790
  active: true,
791
791
  mode: 'render-worker',
@@ -812,15 +812,15 @@ ${n}
812
812
  mode: 'main-thread',
813
813
  frames: (stats.recentFrames || []).slice(-${t}),
814
814
  }
815
- })()`});if(n.error&&(console.error(` error: ${n.error}`),process.exit(1)),n.mode==="render-worker"){let s=Array.isArray(n.samples)?n.samples:[];if(s.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` last ${s.length} sampled frames (ms):`),console.log(" total layout render copy aux other t+");for(let[d,m,y,p,x,A,W]of s)console.log(` ${m.toFixed(2).padStart(7)} ${y.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${x.toFixed(2).padStart(7)} ${A.toFixed(2).padStart(6)} ${W.toFixed(2).padStart(7)} ${String(d).padStart(5)}`);console.log(""),Oe(s.map(d=>d[1])),n.live&&console.log(" sampling continues");break}let r=Array.isArray(n.frames)?n.frames:Array.isArray(n)?n:[];if(r.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` last ${r.length} frame times (ms):`),console.log(` ${r.map(s=>s.toFixed(2)).join(", ")}`),Oe(r);break}case"worst":{let t=a[2]?Number(a[2]):20;(!Number.isFinite(t)||t<=0)&&(console.error(` error: expected a positive frame count, got "${a[2]}"`),process.exit(1));let n=await u.send({type:"evaluate",code:`(async () => {
815
+ })()`});if(n.error&&(console.error(` error: ${n.error}`),process.exit(1)),n.mode==="render-worker"){let s=Array.isArray(n.samples)?n.samples:[];if(s.length===0){console.log(` no frame data \u2014 run '${h("perf")} start' first`);break}console.log(` last ${s.length} sampled frames (ms):`),console.log(" total layout render copy aux other t+");for(let[d,m,y,p,x,A,H]of s)console.log(` ${m.toFixed(2).padStart(7)} ${y.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${x.toFixed(2).padStart(7)} ${A.toFixed(2).padStart(6)} ${H.toFixed(2).padStart(7)} ${String(d).padStart(5)}`);console.log(""),Re(s.map(d=>d[1])),n.live&&console.log(" sampling continues");break}let r=Array.isArray(n.frames)?n.frames:Array.isArray(n)?n:[];if(r.length===0){console.log(` no frame data \u2014 run '${h("perf")} start' first`);break}console.log(` last ${r.length} frame times (ms):`),console.log(` ${r.map(s=>s.toFixed(2)).join(", ")}`),Re(r);break}case"worst":{let t=a[2]?Number(a[2]):20;(!Number.isFinite(t)||t<=0)&&(console.error(` error: expected a positive frame count, got "${a[2]}"`),process.exit(1));let n=await u.send({type:"evaluate",code:`(async () => {
816
816
  if (window.__sootsimRenderHost) {
817
- const session = window.${te} || {}
817
+ const session = window.${se} || {}
818
818
  if (session.active) {
819
819
  const priorSamples = Array.isArray(session.lastSamples) ? session.lastSamples : []
820
820
  const flushedSamples = await window.__sootsimRenderHost.flushSamples()
821
821
  const samples = priorSamples.concat(flushedSamples)
822
822
  window.__sootsimRenderHost.startSampling()
823
- window.${te} = {
823
+ window.${se} = {
824
824
  ...session,
825
825
  active: true,
826
826
  mode: 'render-worker',
@@ -854,8 +854,8 @@ ${n}
854
854
  mode: 'main-thread',
855
855
  frames: recent.slice().sort((a, b) => b - a).slice(0, ${t}),
856
856
  }
857
- })()`});if(n.error&&(console.error(` error: ${n.error}`),process.exit(1)),n.mode==="render-worker"){let s=Array.isArray(n.samples)?n.samples:[];if(s.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` worst ${s.length} sampled frames (ms):`),console.log(" total layout render copy aux other t+");for(let[d,m,y,p,x,A,W]of s)console.log(` ${m.toFixed(2).padStart(7)} ${y.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${x.toFixed(2).padStart(7)} ${A.toFixed(2).padStart(6)} ${W.toFixed(2).padStart(7)} ${String(d).padStart(5)}`);n.live&&(console.log(""),console.log(" sampling continues"));break}let r=Array.isArray(n.frames)?n.frames:Array.isArray(n)?n:[];if(r.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` worst ${r.length} frame times (ms):`),console.log(` ${r.map(s=>s.toFixed(2)).join(", ")}`);break}case"transition":{let t=a[2];if(!t||!["goHome","appSwitcher","lockScreen"].includes(t)){console.log(`
858
- ${w("perf")} transition <event> \u2014 profile a shell transition
857
+ })()`});if(n.error&&(console.error(` error: ${n.error}`),process.exit(1)),n.mode==="render-worker"){let s=Array.isArray(n.samples)?n.samples:[];if(s.length===0){console.log(` no frame data \u2014 run '${h("perf")} start' first`);break}console.log(` worst ${s.length} sampled frames (ms):`),console.log(" total layout render copy aux other t+");for(let[d,m,y,p,x,A,H]of s)console.log(` ${m.toFixed(2).padStart(7)} ${y.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${x.toFixed(2).padStart(7)} ${A.toFixed(2).padStart(6)} ${H.toFixed(2).padStart(7)} ${String(d).padStart(5)}`);n.live&&(console.log(""),console.log(" sampling continues"));break}let r=Array.isArray(n.frames)?n.frames:Array.isArray(n)?n:[];if(r.length===0){console.log(` no frame data \u2014 run '${h("perf")} start' first`);break}console.log(` worst ${r.length} frame times (ms):`),console.log(` ${r.map(s=>s.toFixed(2)).join(", ")}`);break}case"transition":{let t=a[2];if(!t||!["goHome","appSwitcher","lockScreen"].includes(t)){console.log(`
858
+ ${h("perf")} transition <event> \u2014 profile a shell transition
859
859
 
860
860
  events:
861
861
  goHome swipe-to-home animation
@@ -865,8 +865,8 @@ ${n}
865
865
  note: uses 600ms capture window \u2014 may need --timeout 10000 flag
866
866
 
867
867
  examples:
868
- ${w("perf")} transition goHome --timeout 10000
869
- ${w("perf")} transition appSwitcher
868
+ ${h("perf")} transition goHome --timeout 10000
869
+ ${h("perf")} transition appSwitcher
870
870
  `);break}let r=`sootsim:${t}`;console.log(` profiling ${t} transition...`),console.log(" (use --timeout 10000 if this times out)");let s=await u.send({type:"evaluate",code:`(async () => {
871
871
  // only supported in render-worker mode
872
872
  if (!window.__sootsimRenderHost) {
@@ -944,27 +944,27 @@ ${n}
944
944
  p50: ${s.p50.toFixed(2)}ms
945
945
  p95: ${s.p95.toFixed(2)}ms
946
946
  p99: ${s.p99.toFixed(2)}ms
947
- jank: ${s.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(s.samples)&&s.samples.length>0&&(console.log(""),Oe(s.samples.map(y=>y[1])));break}default:console.error(` unknown perf subcommand: ${e}`),process.exit(1)}break}case"errors":{let e=a[1];if(e==="clear"){await tt(u),j(l)?J({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,n=await Ze(u,t);if(j(l)){J(n);break}if(n.length===0){console.log(" no errors captured");break}console.log(` ${n.length} error(s):
948
- `);for(let r of n){let s=ne(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(`
949
- `).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 et(u,e);if(j(l)){J(t);break}if(t.length===0){console.log(" no warnings captured");break}console.log(` ${t.length} warning(s):
950
- `);for(let n of t){let r=ne(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 V(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):
951
- `);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: ${w("animation")} <id>`),process.exit(1));let t=Number(e);Number.isFinite(t)||(console.error(` invalid id: ${e}`),process.exit(1));let n=await V(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: ${w("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 V(u,"stopAnimation",t);console.log(` stopped ${n??0} animation(s)`);break}case"requests":{let e=a[1];if(e==="clear"){await st(u),j(l)?J({cleared:!0}):console.log(" request buffer cleared");break}let t=e==="all",n=t?a[2]:e,r=n?Number(n):20,s=await ot(u,{failed:!t,limit:r});if(j(l)){J(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)"}:
952
- `);for(let d of s){let m=ne(d.timestamp);console.log(` [${m}] ${Y(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 _=0;_<l.length;_++){let b=l[_];if(b==="--filter")t=l[_+1]??null,_++;else if(b==="--limit"){let v=Number(l[_+1]);Number.isFinite(v)&&(n=v),_++}else if(b==="--threshold"){let v=Number(l[_+1]);Number.isFinite(v)&&v>0&&(d=v),_++}else b==="--failed"?r=!0:b==="--slow"?s=!0:b==="--tail"||b==="-f"?m=!0:b==="--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 _=a[2];_||(console.error(" usage: sootsim network get <id>"),process.exit(1));let b=await u.send({type:"evaluate",code:`(() => {
947
+ jank: ${s.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(s.samples)&&s.samples.length>0&&(console.log(""),Re(s.samples.map(y=>y[1])));break}default:console.error(` unknown perf subcommand: ${e}`),process.exit(1)}break}case"errors":{let e=a[1];if(e==="clear"){await tt(u),B(l)?L({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,n=await Ze(u,t);if(B(l)){L(n);break}if(n.length===0){console.log(" no errors captured");break}console.log(` ${n.length} error(s):
948
+ `);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(`
949
+ `).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 et(u,e);if(B(l)){L(t);break}if(t.length===0){console.log(" no warnings captured");break}console.log(` ${t.length} warning(s):
950
+ `);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):
951
+ `);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 st(u),B(l)?L({cleared:!0}):console.log(" request buffer cleared");break}let t=e==="all",n=t?a[2]:e,r=n?Number(n):20,s=await ot(u,{failed:!t,limit:r});if(B(l)){L(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)"}:
952
+ `);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:`(() => {
953
953
  const obs = window.__sootsimObservability;
954
954
  if (!obs) return null;
955
- return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(_)}) || null;
956
- })()`});b||(console.error(` no entry with id ${_}`),process.exit(1)),y?console.log(JSON.stringify(b,null,2)):ko(b);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. ${w("network")} 100).
957
- to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let x=async()=>{let _=await u.send({type:"evaluate",code:`(() => {
955
+ return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(N)}) || null;
956
+ })()`});w||(console.error(` no entry with id ${N}`),process.exit(1)),y?console.log(JSON.stringify(w,null,2)):ko(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).
957
+ to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let x=async()=>{let N=await u.send({type:"evaluate",code:`(() => {
958
958
  const obs = window.__sootsimObservability;
959
959
  if (!obs) return { ok: false };
960
960
  return { ok: true, entries: obs.network.getSnapshot() };
961
- })()`});if(!_||!_.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return _.entries??[]},A=_=>{let b=_;if(r&&(b=b.filter(v=>!!v.error||v.status!=null&&v.status>=400)),s&&(b=b.filter(v=>v.durationMs!=null&&v.durationMs>=d)),t){let v=t.toLowerCase();b=b.filter(P=>(P.displayUrl||P.url).toLowerCase().includes(v))}return s&&!m&&(b=[...b].sort((v,P)=>(P.durationMs??0)-(v.durationMs??0))),b};if(!m){let _=await x(),b=A(_).slice(-p);if(y){console.log(JSON.stringify(b,null,2));break}if(b.length===0){_.length===0?console.log(" no network requests captured"):console.log(s?` no requests slower than ${d}ms (${_.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(s?` ${b.length} request(s) slower than ${d}ms (sorted by duration desc):
962
- `:` ${b.length} request(s):
963
- `);for(let v of b)Dt(v);break}console.log(` tailing network (ctrl-c to stop)...
964
- `);let W=new Set,U=!0,K=()=>{U=!1};process.on("SIGINT",K);try{for(;U;){let _=await x(),b=A(_);for(let v of b)v.durationMs!=null&&(W.has(v.id)||(W.add(v.id),y?console.log(JSON.stringify(v)):Dt(v)));await Z(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 b=0;b<l.length;b++){let v=l[b];if(v==="--filter")t=l[b+1]??null,b++;else if(v==="--limit"){let P=Number(l[b+1]);Number.isFinite(P)&&(n=P),b++}else v==="--level"?(r=l[b+1]??null,b++):v==="--tail"||v==="-f"?s=!0:v==="--json"?d=!0:(v==="--internal"||v==="--all")&&(m=!0)}let y=r?new Set(r.split(",").map(b=>b.trim()).filter(b=>b==="log"||b==="info"||b==="warn"||b==="error"||b==="debug")):null;if(e==="clear"){await rt(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. ${w("logs")} 100).
965
- to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let A=()=>nt(u),W=b=>it(b,{level:y,filter:t,showInternal:m});if(!s){let b=await A(),v=W(b).slice(-x);if(d){console.log(JSON.stringify(v,null,2));break}if(v.length===0){console.log(b.length===0?" no logs captured":" no matching logs");break}console.log(` ${v.length} log(s):
961
+ })()`});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):
962
+ `:` ${w.length} request(s):
963
+ `);for(let v of w)Dt(v);break}console.log(` tailing network (ctrl-c to stop)...
964
+ `);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)):Dt(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 rt(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).
965
+ to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let A=()=>nt(u),H=w=>it(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):
966
966
  `);for(let P of v)jt(P,p);break}console.log(` tailing logs (ctrl-c to stop)...
967
- `);let U=new Set,K=!0,_=()=>{K=!1};process.on("SIGINT",_);try{for(;K;){let b=await A(),v=W(b);for(let P of v)U.has(P.id)||(U.add(P.id),d?console.log(JSON.stringify(P)):jt(P,p));await Z(250)}}finally{process.off("SIGINT",_)}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),!B.has(g)&&!j(l))try{await pe(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$/.test(t)||t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await yt(u,I,n[1]);else if(/^no sim connected$/.test(t))gt(I);else if(r)process.stderr.write(` the sim is not responding. recover it with:
967
+ `);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)):jt(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),!D.has(g)&&!B(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$/.test(t)||t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await yt(u,F,n[1]);else if(/^no sim connected$/.test(t))gt(F);else if(r)process.stderr.write(` the sim is not responding. recover it with:
968
968
  sootsim close --sim <id> # force-close the wedged sim
969
969
  sootsim list # confirm it's gone
970
- `);else{try{await mt(u)}catch{}try{await E({includeTail:!0})}catch{}try{await ie({includeTail:!0})}catch{}}process.exit(1)}finally{u.close()}}export{pn as runInspect};
970
+ `);else{try{await mt(u)}catch{}try{await fe({includeTail:!0})}catch{}try{await ne({includeTail:!0})}catch{}}process.exit(1)}finally{u.close()}}export{pn as runInspect};