sootsim 0.1.239 → 0.1.241

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 (146) hide show
  1. package/dist-cli/bin.js +4 -4
  2. package/dist-cli/chunks/{agent-5KVGVFXJ.js → agent-7Z3WG3YJ.js} +2 -2
  3. package/dist-cli/chunks/{agent-wrapper-YVXMSV3X.js → agent-wrapper-IMTGEJ7T.js} +2 -2
  4. package/dist-cli/chunks/{app-fonts-IXF6YPQZ.js → app-fonts-7E66PSAV.js} +2 -2
  5. package/dist-cli/chunks/{assert-FMNM5VTT.js → assert-IEBAQZC7.js} +2 -2
  6. package/dist-cli/chunks/{auth-LNSDYZU4.js → auth-FRMHPA2X.js} +2 -2
  7. package/dist-cli/chunks/beta-AMMCLKHD.js +2 -0
  8. package/dist-cli/chunks/{camera-INMAD3CG.js → camera-O67TQUAH.js} +2 -2
  9. package/dist-cli/chunks/{chunk-WXYRA447.js → chunk-2DY3JHFK.js} +1 -1
  10. package/dist-cli/chunks/{chunk-ZL2KSYJP.js → chunk-4JSCYLLH.js} +1 -1
  11. package/dist-cli/chunks/{chunk-HV2ZRFGP.js → chunk-4V6MFWDY.js} +1 -1
  12. package/dist-cli/chunks/{chunk-BWKVAEAJ.js → chunk-5COOJUTE.js} +1 -1
  13. package/dist-cli/chunks/{chunk-XWPQVHOL.js → chunk-5ZNYFTOB.js} +2 -2
  14. package/dist-cli/chunks/{chunk-QHJLYAOH.js → chunk-7I3PV2RE.js} +2 -2
  15. package/dist-cli/chunks/{chunk-JBUMYCFR.js → chunk-AROVTS3P.js} +2 -2
  16. package/dist-cli/chunks/{chunk-LWE27HF7.js → chunk-BIHEU677.js} +3 -3
  17. package/dist-cli/chunks/{chunk-UZRZGXQ4.js → chunk-CAOW2O5V.js} +2 -2
  18. package/dist-cli/chunks/{chunk-SOZIIFPY.js → chunk-CSZOZRKB.js} +3 -3
  19. package/dist-cli/chunks/{chunk-VIM3WDAA.js → chunk-DS2KFLBO.js} +1 -1
  20. package/dist-cli/chunks/chunk-ECRSTV5C.js +118 -0
  21. package/dist-cli/chunks/{chunk-NJQSCTFC.js → chunk-EY3ZQWUQ.js} +52 -52
  22. package/dist-cli/chunks/{chunk-544G2PCM.js → chunk-F5YD4BLA.js} +2 -2
  23. package/dist-cli/chunks/{chunk-X7JZ4KTU.js → chunk-FR7JCFAR.js} +1 -1
  24. package/dist-cli/chunks/{chunk-YIS2RXPE.js → chunk-GFZLDVLE.js} +1 -1
  25. package/dist-cli/chunks/{chunk-PVIUYYIS.js → chunk-GVTSKLLS.js} +2 -2
  26. package/dist-cli/chunks/{chunk-KCS6OYQV.js → chunk-H7G2QGUG.js} +2 -2
  27. package/dist-cli/chunks/{chunk-NDU5EJFW.js → chunk-H7SP6J3H.js} +2 -2
  28. package/dist-cli/chunks/{chunk-CJRALJVV.js → chunk-HNI6U6M5.js} +1 -1
  29. package/dist-cli/chunks/{chunk-P5JIE7R6.js → chunk-IF5VXL45.js} +2 -2
  30. package/dist-cli/chunks/{chunk-BKDHODNB.js → chunk-JMTQBHQY.js} +1 -1
  31. package/dist-cli/chunks/{chunk-CUDTQFGP.js → chunk-JX4N376W.js} +2 -2
  32. package/dist-cli/chunks/{chunk-FOTAUF7Q.js → chunk-KFI26HW5.js} +1 -1
  33. package/dist-cli/chunks/chunk-KLXLOMI6.js +1 -0
  34. package/dist-cli/chunks/{chunk-JPNTLGLA.js → chunk-KN3Q6VSC.js} +2 -2
  35. package/dist-cli/chunks/{chunk-JOSDTQZ3.js → chunk-LVUOVKJO.js} +2 -2
  36. package/dist-cli/chunks/{chunk-VBO7OQLR.js → chunk-MCAJBAWD.js} +2 -2
  37. package/dist-cli/chunks/{chunk-R5I2OBQM.js → chunk-MGLTIS7P.js} +2 -2
  38. package/dist-cli/chunks/{chunk-SLIYVKRX.js → chunk-PR6AOTP5.js} +1 -1
  39. package/dist-cli/chunks/{chunk-5VCOEPSJ.js → chunk-PVUUG5YW.js} +2 -2
  40. package/dist-cli/chunks/{chunk-EQYRXSBE.js → chunk-R3EZVIEM.js} +2 -2
  41. package/dist-cli/chunks/{chunk-HE5NBBLH.js → chunk-U7XJNNGI.js} +3 -3
  42. package/dist-cli/chunks/{chunk-ECPEYFHV.js → chunk-UF333CGY.js} +2 -2
  43. package/dist-cli/chunks/{chunk-QYVGMN3I.js → chunk-VVUANJFA.js} +72 -23
  44. package/dist-cli/chunks/{chunk-SBSL3DUQ.js → chunk-WFB3ICCN.js} +1 -1
  45. package/dist-cli/chunks/{chunk-6XF2EHL2.js → chunk-WIHKSZM4.js} +1 -1
  46. package/dist-cli/chunks/{chunk-MDOTB5DP.js → chunk-WPWLJFKF.js} +2 -2
  47. package/dist-cli/chunks/{chunk-GI2S43VF.js → chunk-YLWUYESW.js} +1 -1
  48. package/dist-cli/chunks/{chunk-D4YH5KNQ.js → chunk-YX7S6N42.js} +2 -2
  49. package/dist-cli/chunks/{chunk-44WCYVFQ.js → chunk-Z72IF5FC.js} +2 -2
  50. package/dist-cli/chunks/chunk-ZGSGMGE3.js +1 -0
  51. package/dist-cli/chunks/{chunk-SRMYUHBI.js → chunk-ZUZLQ4ZJ.js} +1 -1
  52. package/dist-cli/chunks/{chunk-DJIWF2SR.js → chunk-ZYJCVJFP.js} +1 -1
  53. package/dist-cli/chunks/cli-version-DIYZFJMN.js +2 -0
  54. package/dist-cli/chunks/{compat-VYOIJUW6.js → compat-ZRUVBIK7.js} +3 -3
  55. package/dist-cli/chunks/{config-ZJIIQF6K.js → config-VKQDFC5Z.js} +2 -2
  56. package/dist-cli/chunks/{control-KFAL3LD7.js → control-OYK2J4JW.js} +2 -2
  57. package/dist-cli/chunks/daemon-YQLY7PVM.js +2 -0
  58. package/dist-cli/chunks/{debug-RCY6BSLW.js → debug-3WEO7ZRW.js} +3 -3
  59. package/dist-cli/chunks/{desktop-FRZILY3U.js → desktop-DVOFHJKU.js} +3 -3
  60. package/dist-cli/chunks/{detox-W2HOZRDP.js → detox-GAGC276D.js} +2 -2
  61. package/dist-cli/chunks/{device-WRWT7SEE.js → device-256KFP2G.js} +2 -2
  62. package/dist-cli/chunks/{diagnose-3KSX2NJC.js → diagnose-GYKUU3N5.js} +2 -2
  63. package/dist-cli/chunks/drivers-FHWFHVQF.js +2 -0
  64. package/dist-cli/chunks/{film-QN7NUW6Z.js → film-WAV3WPQK.js} +3 -3
  65. package/dist-cli/chunks/flow-WKPPIDM6.js +2 -0
  66. package/dist-cli/chunks/help-P4A7NNSC.js +2 -0
  67. package/dist-cli/chunks/{hidden-runtime-alias-NIH62HCH.js → hidden-runtime-alias-DODMMNOJ.js} +2 -2
  68. package/dist-cli/chunks/{home-paths-3CPTCZDU.js → home-paths-QU5UX3MT.js} +2 -2
  69. package/dist-cli/chunks/inspect-NIHY67NU.js +2 -0
  70. package/dist-cli/chunks/install-desktop-NA53KD6G.js +2 -0
  71. package/dist-cli/chunks/{login-HQ3356B6.js → login-OURQ3DVM.js} +4 -4
  72. package/dist-cli/chunks/{logout-LVVXQS5S.js → logout-ZYVJAPBO.js} +2 -2
  73. package/dist-cli/chunks/{maestro-34Y7GOG5.js → maestro-H2NGXNF4.js} +3 -3
  74. package/dist-cli/chunks/{maestro-generate-XBIZ7Z6U.js → maestro-generate-DA2IZPK2.js} +3 -3
  75. package/dist-cli/chunks/{mode-VXZR6I46.js → mode-QTK3ERUW.js} +2 -2
  76. package/dist-cli/chunks/optional-demo-registry-ZLN23OYV.js +2 -0
  77. package/dist-cli/chunks/{perf-IBHKDDFN.js → perf-WZ4OPYXV.js} +2 -2
  78. package/dist-cli/chunks/{record-S5WYHPNR.js → record-ZQSUHQJU.js} +3 -3
  79. package/dist-cli/chunks/runtime-RM67M6H3.js +2 -0
  80. package/dist-cli/chunks/{screenshot-command-T65M2SYC.js → screenshot-command-UDJ6TEAM.js} +3 -3
  81. package/dist-cli/chunks/{screenshots-capture-75AHIYWA.js → screenshots-capture-4FK4NYXG.js} +2 -2
  82. package/dist-cli/chunks/serve-MCT4HKR7.js +41 -0
  83. package/dist-cli/chunks/{setup-TLQ2VM3F.js → setup-I2IELNJN.js} +3 -3
  84. package/dist-cli/chunks/{skills-LZZDB6V5.js → skills-PVXI7LM6.js} +2 -2
  85. package/dist-cli/chunks/{storage-G2IZ2WAD.js → storage-KZFCVRGD.js} +2 -2
  86. package/dist-cli/chunks/store-CEMC5MTK.js +2 -0
  87. package/dist-cli/chunks/telemetry-LFIQWPZD.js +2 -0
  88. package/dist-cli/chunks/{timeline-L4CFSXX3.js → timeline-YAULXFEC.js} +2 -2
  89. package/dist-cli/chunks/{upgrade-5USALUAU.js → upgrade-63TVREBM.js} +2 -2
  90. package/dist-cli/chunks/upload-APW46WK3.js +2 -0
  91. package/dist-cli/chunks/{version-RQZPUNJO.js → version-JWWEGZS7.js} +2 -2
  92. package/dist-cli/chunks/{web-YQ6XAB5F.js → web-XO724HJL.js} +2 -2
  93. package/dist-cli/chunks/{what-happened-JLAM7TBD.js → what-happened-DQ4MXAPJ.js} +2 -2
  94. package/dist-lib/agent-daemon-client.cjs +1 -1
  95. package/dist-lib/agent-events.cjs +1 -1
  96. package/dist-lib/agent-identity.cjs +1 -1
  97. package/dist-lib/agent-sessions.cjs +1 -1
  98. package/dist-lib/attached-projects.cjs +1 -1
  99. package/dist-lib/auth/shared-session.cjs +1 -1
  100. package/dist-lib/backend-origin.cjs +1 -1
  101. package/dist-lib/beta.cjs +1 -1
  102. package/dist-lib/beta.mjs +1 -1
  103. package/dist-lib/bridge-constants.cjs +1 -1
  104. package/dist-lib/cli-constants.cjs +1 -1
  105. package/dist-lib/config.cjs +1 -1
  106. package/dist-lib/detox/index.cjs +1 -1
  107. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  108. package/dist-lib/home-paths.cjs +1 -1
  109. package/dist-lib/host/bridge-host.cjs +77 -33
  110. package/dist-lib/host/fetch-proxy-handler.cjs +77 -33
  111. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  112. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  113. package/dist-lib/host/websocket-proxy.cjs +1 -1
  114. package/dist-lib/index.cjs +1 -1
  115. package/dist-lib/jump-to-source-babel.cjs +1 -1
  116. package/dist-lib/menu.cjs +1 -1
  117. package/dist-lib/menu.mjs +1 -1
  118. package/dist-lib/metro.cjs +1 -1
  119. package/dist-lib/profiles.cjs +1 -1
  120. package/dist-lib/render-mode.cjs +1 -1
  121. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  122. package/dist-lib/sdk.cjs +157 -5
  123. package/dist-lib/sdk.mjs +156 -5
  124. package/dist-lib/skills.cjs +221 -37
  125. package/dist-lib/vite.cjs +1 -1
  126. package/package.json +1 -1
  127. package/skills/contrast/SKILL.md +1 -1
  128. package/skills/sootsim-debug/SKILL.md +21 -12
  129. package/src/host/fetch-proxy-handler.ts +104 -52
  130. package/dist-cli/chunks/beta-BH6RPXQU.js +0 -2
  131. package/dist-cli/chunks/chunk-HJW6SASW.js +0 -118
  132. package/dist-cli/chunks/chunk-J7SEKMNI.js +0 -1
  133. package/dist-cli/chunks/chunk-NO6RQXYN.js +0 -1
  134. package/dist-cli/chunks/cli-version-7KCROGJR.js +0 -2
  135. package/dist-cli/chunks/daemon-TJXAVVUE.js +0 -2
  136. package/dist-cli/chunks/drivers-SJOWPOA3.js +0 -2
  137. package/dist-cli/chunks/flow-Q4XCAPIT.js +0 -2
  138. package/dist-cli/chunks/help-FRVJH7SB.js +0 -2
  139. package/dist-cli/chunks/inspect-5ZZN4UJN.js +0 -2
  140. package/dist-cli/chunks/install-desktop-MIY6DLN6.js +0 -2
  141. package/dist-cli/chunks/optional-demo-registry-5JSIUIMF.js +0 -2
  142. package/dist-cli/chunks/runtime-5K5JFYOZ.js +0 -2
  143. package/dist-cli/chunks/serve-OJVA6PNV.js +0 -41
  144. package/dist-cli/chunks/store-X6HDJ5SE.js +0 -2
  145. package/dist-cli/chunks/telemetry-AHMOJS6L.js +0 -2
  146. package/dist-cli/chunks/upload-OWMPT3Z7.js +0 -2
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.239 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./chunk-NDU5EJFW.js";import{a as oe,b as A,c as D,d as Ie,e as ie,f as X,g as ue,h as ye,i as Nt,j as Ft,k as Te,l as Ot}from"./chunk-XWPQVHOL.js";import{A as wt,B as $t,E as xt,G as St,I as de,J as vt,P as Le,a as ke,b as nt,c as rt,d as it,e as at,f as lt,g as ct,h as dt,i as ut,j as pt,k as Be,l as Ce,q as je,r as mt,s as ft,t as fe,u as gt,v as _e,w as qe,x as yt,y as ht,z as bt}from"./chunk-QYVGMN3I.js";import{e as kt,g as _t,i as It,j as Tt,k as Mt,l as ge}from"./chunk-544G2PCM.js";import{a as tt}from"./chunk-WXYRA447.js";import{a as Q}from"./chunk-ECPEYFHV.js";import{c as ot}from"./chunk-HV2ZRFGP.js";import{c as st}from"./chunk-SLIYVKRX.js";import{c as Ae,e as De}from"./chunk-HJW6SASW.js";function We(e){return`(async () => {
1
+ /*! sootsim v0.1.241 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as ce}from"./chunk-IF5VXL45.js";import{b as Et,c as Pt,k as Rt}from"./chunk-H7SP6J3H.js";import{a as oe,b as A,c as D,d as Ie,e as ie,f as X,g as ue,h as ye,i as Nt,j as Ft,k as Te,l as Ot}from"./chunk-5ZNYFTOB.js";import{A as wt,B as $t,E as xt,G as St,I as de,J as vt,P as Le,a as ke,b as nt,c as rt,d as it,e as at,f as lt,g as ct,h as dt,i as ut,j as pt,k as Be,l as Ce,q as je,r as mt,s as ft,t as fe,u as gt,v as _e,w as qe,x as yt,y as ht,z as bt}from"./chunk-VVUANJFA.js";import{e as kt,g as _t,i as It,j as Tt,k as Mt,l as ge}from"./chunk-F5YD4BLA.js";import{a as tt}from"./chunk-2DY3JHFK.js";import{a as Q}from"./chunk-UF333CGY.js";import{c as ot}from"./chunk-4V6MFWDY.js";import{c as st}from"./chunk-PR6AOTP5.js";import{c as Ae,e as De}from"./chunk-ECRSTV5C.js";function We(e){return`(async () => {
3
3
  const bridge = globalThis.SootSim && globalThis.SootSim.bridges && globalThis.SootSim.bridges.hotRemount
4
4
  if (!bridge || typeof bridge.reloadExternalApp !== 'function') return false
5
5
  await bridge.reloadExternalApp({ resetStorage: ${e?"true":"false"} })
@@ -71,14 +71,14 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
71
71
  deviceWidth: __w / __dpr,
72
72
  deviceHeight: __h / __dpr,
73
73
  }
74
- })()`}import{existsSync as Po,mkdirSync as Ct,readFileSync as Ro,rmSync as He,writeFileSync as jt}from"fs";import{tmpdir as Ao}from"os";import{dirname as qt,join as Do,resolve as Lt}from"path";import*as Me from"fs";function Eo(e){let o={},s=e,i=p=>Array.isArray(p)?p:[],d=e.match(/^---\n([\s\S]*?)\n---\n?/);if(d){try{o=ce.parse(d[1])??{}}catch(y){console.warn(` warn: could not parse frontmatter: ${y.message}`)}s=e.slice(d[0].length);let p=ce.parse(s);return{frontmatter:o,steps:i(p)}}if(/\n---\s*\n/.test(e))try{let p=ce.parseAllDocuments(e);if(p.length>=2){let y=p[0].toJS(),f=p[p.length-1].toJS();return{frontmatter:y&&typeof y=="object"?y:{},steps:i(f)}}}catch(p){console.warn(` warn: could not parse multi-doc flow: ${p.message}`)}let l=ce.parse(s);return{frontmatter:o,steps:i(l)}}var Bt=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function Je(e){let o=[];if(!Array.isArray(e)||e.length===0)return o.push("flow body must be a non-empty YAML array of steps"),o;let s=0;for(let i of e)i&&typeof i=="object"?Object.keys(i).some(l=>Bt.has(l))&&(s+=1):typeof i=="string"&&Bt.has(i)&&(s+=1);return s===0&&o.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),o}function Ms(e){if(!Me.existsSync(e))return[`file not found: ${e}`];let o;try{o=Me.readFileSync(e,"utf8")}catch(s){return[`cannot read file: ${s.message}`]}if(o.trim().length===0)return["file is empty"];try{let s=Eo(o);return Je(s.steps)}catch(s){return[`yaml parse error: ${s.message}`]}}var Ke=1;function Ne(){return Lt(process.env.SOOTSIM_FLOW_SESSION_PATH||Do(Ao(),"sootsim-flow-session.json"))}function Ue(e){let o=Ne();Ct(qt(o),{recursive:!0}),jt(o,JSON.stringify(e,null,2)+`
74
+ })()`}import{existsSync as Po,mkdirSync as Ct,readFileSync as Ro,rmSync as He,writeFileSync as jt}from"fs";import{tmpdir as Ao}from"os";import{dirname as qt,join as Do,resolve as Lt}from"path";import*as Me from"fs";function Eo(e){let o={},s=e,i=d=>Array.isArray(d)?d:[],p=e.match(/^---\n([\s\S]*?)\n---\n?/);if(p){try{o=ce.parse(p[1])??{}}catch(h){console.warn(` warn: could not parse frontmatter: ${h.message}`)}s=e.slice(p[0].length);let d=ce.parse(s);return{frontmatter:o,steps:i(d)}}if(/\n---\s*\n/.test(e))try{let d=ce.parseAllDocuments(e);if(d.length>=2){let h=d[0].toJS(),f=d[d.length-1].toJS();return{frontmatter:h&&typeof h=="object"?h:{},steps:i(f)}}}catch(d){console.warn(` warn: could not parse multi-doc flow: ${d.message}`)}let l=ce.parse(s);return{frontmatter:o,steps:i(l)}}var Bt=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function Je(e){let o=[];if(!Array.isArray(e)||e.length===0)return o.push("flow body must be a non-empty YAML array of steps"),o;let s=0;for(let i of e)i&&typeof i=="object"?Object.keys(i).some(l=>Bt.has(l))&&(s+=1):typeof i=="string"&&Bt.has(i)&&(s+=1);return s===0&&o.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),o}function Ms(e){if(!Me.existsSync(e))return[`file not found: ${e}`];let o;try{o=Me.readFileSync(e,"utf8")}catch(s){return[`cannot read file: ${s.message}`]}if(o.trim().length===0)return["file is empty"];try{let s=Eo(o);return Je(s.steps)}catch(s){return[`yaml parse error: ${s.message}`]}}var Ke=1;function Ne(){return Lt(process.env.SOOTSIM_FLOW_SESSION_PATH||Do(Ao(),"sootsim-flow-session.json"))}function Ue(e){let o=Ne();Ct(qt(o),{recursive:!0}),jt(o,JSON.stringify(e,null,2)+`
75
75
  `)}function Ge(){let e=Ne();if(!Po(e))return null;try{let o=JSON.parse(Ro(e,"utf8"));return o.version!==Ke||!Array.isArray(o.steps)||typeof o.startedAt!="string"||typeof o.updatedAt!="string"?(He(e,{force:!0}),null):{version:Ke,startedAt:o.startedAt,updatedAt:o.updatedAt,steps:o.steps,candidate:o.candidate??null}}catch{return He(e,{force:!0}),null}}function As(){let e=new Date().toISOString(),o={version:Ke,startedAt:e,updatedAt:e,steps:[],candidate:null};return Ue(o),{path:Ne(),state:o}}function Bo(){He(Ne(),{force:!0})}function Ds(){Bo()}function Fe(e){let o=Ge();if(!o)return{active:!1};let s=o.candidate,i={...o,updatedAt:new Date().toISOString(),candidate:{step:e.step,summary:e.summary,source:e.source,recordedAt:new Date().toISOString()}};return Ue(i),{active:!0,candidate:i.candidate,replaced:s}}function Bs(){let e=Ge();if(!e)return{active:!1,kept:!1,reason:"no-session"};if(!e.candidate)return{active:!0,kept:!1,reason:"no-candidate"};let o=e.candidate,s={...e,updatedAt:new Date().toISOString(),steps:[...e.steps,o.step],candidate:null};return Ue(s),{active:!0,kept:!0,candidate:o,stepCount:s.steps.length}}function Co(e){return ce.stringify(e).trimEnd()+`
76
- `}function Cs(e){let o=Ge();if(!o)return{active:!1};let s=Co(o.steps),i=Je(o.steps);if(i.length>0)return{active:!0,valid:!1,issues:i,yaml:s,stepCount:o.steps.length,outputPath:null};let d=null;return e&&(d=Lt(e),Ct(qt(d),{recursive:!0}),jt(d,s)),{active:!0,valid:!0,issues:[],yaml:s,stepCount:o.steps.length,outputPath:d}}import{existsSync as jo,mkdirSync as qo,readFileSync as Lo,rmSync as Wt,writeFileSync as Wo}from"fs";import{tmpdir as Jo}from"os";import{dirname as Ho,join as Ko,resolve as Uo}from"path";var he=1,Go="SOOTSIM_INSPECT_NOTICE_PATH",Yo=300*1e3,zo=15e3;function Jt(){return Uo(process.env[Go]||Ko(Jo(),"sootsim-inspect-notice-state.json"))}function Xo(e,o){return Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s?.signature=="string"&&Number.isFinite(s?.updatedAt)&&o-s.updatedAt<=Yo))}function Vo(e){let o=Jt();if(!jo(o))return{version:he,entries:{}};try{let s=JSON.parse(Lo(o,"utf8"));return s.version!==he||!s.entries||typeof s.entries!="object"?(Wt(o,{force:!0}),{version:he,entries:{}}):{version:he,entries:Xo(s.entries,e)}}catch{return Wt(o,{force:!0}),{version:he,entries:{}}}}function Qo(e){let o=Jt();qo(Ho(o),{recursive:!0}),Wo(o,JSON.stringify(e,null,2)+`
77
- `)}function Zo(e,o){let s=o.trim()||"default";return`${e}:${s}`}function Ye(e,o,s,i={}){let d=i.nowMs??Date.now(),l=i.cooldownMs??zo,p=Vo(d),y=Zo(e,o),f=p.entries[y];return f&&f.signature===s&&d-f.updatedAt<l?!1:(p.entries[y]={signature:s,updatedAt:d},Qo(p),!0)}async function se({bridge:e,simId:o,maxMs:s,pollMs:i=50,stablePolls:d=3,strict:l=!1}){let p=await e.send({type:"evaluate",simId:o,code:`(async () => {
76
+ `}function Cs(e){let o=Ge();if(!o)return{active:!1};let s=Co(o.steps),i=Je(o.steps);if(i.length>0)return{active:!0,valid:!1,issues:i,yaml:s,stepCount:o.steps.length,outputPath:null};let p=null;return e&&(p=Lt(e),Ct(qt(p),{recursive:!0}),jt(p,s)),{active:!0,valid:!0,issues:[],yaml:s,stepCount:o.steps.length,outputPath:p}}import{existsSync as jo,mkdirSync as qo,readFileSync as Lo,rmSync as Wt,writeFileSync as Wo}from"fs";import{tmpdir as Jo}from"os";import{dirname as Ho,join as Ko,resolve as Uo}from"path";var he=1,Go="SOOTSIM_INSPECT_NOTICE_PATH",Yo=300*1e3,zo=15e3;function Jt(){return Uo(process.env[Go]||Ko(Jo(),"sootsim-inspect-notice-state.json"))}function Xo(e,o){return Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s?.signature=="string"&&Number.isFinite(s?.updatedAt)&&o-s.updatedAt<=Yo))}function Vo(e){let o=Jt();if(!jo(o))return{version:he,entries:{}};try{let s=JSON.parse(Lo(o,"utf8"));return s.version!==he||!s.entries||typeof s.entries!="object"?(Wt(o,{force:!0}),{version:he,entries:{}}):{version:he,entries:Xo(s.entries,e)}}catch{return Wt(o,{force:!0}),{version:he,entries:{}}}}function Qo(e){let o=Jt();qo(Ho(o),{recursive:!0}),Wo(o,JSON.stringify(e,null,2)+`
77
+ `)}function Zo(e,o){let s=o.trim()||"default";return`${e}:${s}`}function Ye(e,o,s,i={}){let p=i.nowMs??Date.now(),l=i.cooldownMs??zo,d=Vo(p),h=Zo(e,o),f=d.entries[h];return f&&f.signature===s&&p-f.updatedAt<l?!1:(d.entries[h]={signature:s,updatedAt:p},Qo(d),!0)}async function se({bridge:e,simId:o,maxMs:s,pollMs:i=50,stablePolls:p=3,strict:l=!1}){let d=await e.send({type:"evaluate",simId:o,code:`(async () => {
78
78
  const start = Date.now()
79
79
  const deadline = start + ${Math.max(0,Math.round(s))}
80
80
  const pollMs = ${Math.max(1,Math.round(i))}
81
- const requiredStablePolls = ${Math.max(1,Math.round(d))}
81
+ const requiredStablePolls = ${Math.max(1,Math.round(p))}
82
82
  const strict = ${l?"true":"false"}
83
83
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
84
84
 
@@ -191,7 +191,7 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
191
191
  await sleep(pollMs)
192
192
  }
193
193
  return { settled: false, elapsed: Date.now() - start }
194
- })()`},{timeoutMs:s+1e3}),{elapsed:y,settled:f}=p??{};return{elapsed:typeof y=="number"?y:s,settled:f===!0}}var es={initialWaitMs:3e3,deadlineMs:5e3,retryWaitMs:700},ts={initialWaitMs:1200,deadlineMs:2500,retryWaitMs:700};function os(e,o={}){return{...e?es:ts,...o}}function pe(e){return!(!e||e.hit===!1||e.ok===!1||e.requestedTargetMatched===!1||e.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function ss(e,o){return{nodeId:e.target?.nodeId??e.match?.nodeId??e.node?.nodeId??null,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??o??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function be(e,o){let s=os(!!o.agent,o.timing),i=0,d=null,l=null;try{await se({bridge:e,maxMs:s.initialWaitMs,pollMs:32,stablePolls:2})}catch{}let p=Date.now()+s.deadlineMs,y=null;for(;Date.now()<=p||i===0;){i++;let f=await o.resolve();if(d=f,f?.error==="bridge-not-ready"||f?.ambiguous||f?.nthOutOfRange)return{payload:f,result:null,attempts:i,failure:"special"};if(f&&typeof f.cx=="number"&&typeof f.cy=="number")if(f.offscreen){l={hit:!1,reason:"offscreen",x:f.cx,y:f.cy,screen:f.screen};let b=`${Math.round(f.cx)},${Math.round(f.cy)}`;if(y===b)return{payload:f,result:l,attempts:i,failure:"missed"};y=b}else{y=null;let b=ss(f,o.textFallback),S=await e.send({type:"evaluate",code:`(async () => {
194
+ })()`},{timeoutMs:s+1e3}),{elapsed:h,settled:f}=d??{};return{elapsed:typeof h=="number"?h:s,settled:f===!0}}var es={initialWaitMs:3e3,deadlineMs:5e3,retryWaitMs:700},ts={initialWaitMs:1200,deadlineMs:2500,retryWaitMs:700};function os(e,o={}){return{...e?es:ts,...o}}function pe(e){return!(!e||e.hit===!1||e.ok===!1||e.requestedTargetMatched===!1||e.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function ss(e,o){return{nodeId:e.target?.nodeId??e.match?.nodeId??e.node?.nodeId??null,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??o??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function be(e,o){let s=os(!!o.agent,o.timing),i=0,p=null,l=null;try{await se({bridge:e,maxMs:s.initialWaitMs,pollMs:32,stablePolls:2})}catch{}let d=Date.now()+s.deadlineMs,h=null;for(;Date.now()<=d||i===0;){i++;let f=await o.resolve();if(p=f,f?.error==="bridge-not-ready"||f?.ambiguous||f?.nthOutOfRange)return{payload:f,result:null,attempts:i,failure:"special"};if(f&&typeof f.cx=="number"&&typeof f.cy=="number")if(f.offscreen){l={hit:!1,reason:"offscreen",x:f.cx,y:f.cy,screen:f.screen};let b=`${Math.round(f.cx)},${Math.round(f.cy)}`;if(h===b)return{payload:f,result:l,attempts:i,failure:"missed"};h=b}else{h=null;let b=ss(f,o.textFallback),S=await e.send({type:"evaluate",code:`(async () => {
195
195
  const t = window.__sootsimTest
196
196
  if (
197
197
  !t ||
@@ -232,7 +232,7 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
232
232
  requestedTarget,
233
233
  coordinateTarget,
234
234
  }
235
- })()`});if(S?.error)return{payload:f,result:{hit:!1,reason:S.error,requestedTarget:b},attempts:i,failure:"special"};if(S?.requestedTargetMatched===!1)return{payload:f,result:{hit:!1,reason:"target-covered",...S},attempts:i,failure:"missed"};let N=await e.send({type:"tap",x:f.cx,y:f.cy,target:b}),M=N&&typeof N=="object"?{...N,...S}:{hit:!!N,...S};if(l=M,pe(M))return{payload:f,result:M,attempts:i}}let _=p-Date.now();if(_<=0)break;try{await se({bridge:e,maxMs:Math.min(_,s.retryWaitMs),pollMs:32,stablePolls:2})}catch{await new Promise(b=>setTimeout(b,Math.min(120,_)))}}return{payload:d,result:l,attempts:i,failure:d&&typeof d.cx=="number"?"missed":"not-found"}}async function Ht(e,o,s,i){return e.send({type:"tap",x:o,y:s,...i?{target:i}:{}})}async function Kt(e,o,s={}){let i=JSON.stringify(o);return be(e,{agent:s.agent,timing:s.timing,resolve:()=>e.send({type:"evaluate",code:`(async () => {
235
+ })()`});if(S?.error)return{payload:f,result:{hit:!1,reason:S.error,requestedTarget:b},attempts:i,failure:"special"};if(S?.requestedTargetMatched===!1)return{payload:f,result:{hit:!1,reason:"target-covered",...S},attempts:i,failure:"missed"};let N=await e.send({type:"tap",x:f.cx,y:f.cy,target:b}),M=N&&typeof N=="object"?{...N,...S}:{hit:!!N,...S};if(l=M,pe(M))return{payload:f,result:M,attempts:i}}let k=d-Date.now();if(k<=0)break;try{await se({bridge:e,maxMs:Math.min(k,s.retryWaitMs),pollMs:32,stablePolls:2})}catch{await new Promise(b=>setTimeout(b,Math.min(120,k)))}}return{payload:p,result:l,attempts:i,failure:p&&typeof p.cx=="number"?"missed":"not-found"}}async function Ht(e,o,s,i){return e.send({type:"tap",x:o,y:s,...i?{target:i}:{}})}async function Kt(e,o,s={}){let i=JSON.stringify(o);return be(e,{agent:s.agent,timing:s.timing,resolve:()=>e.send({type:"evaluate",code:`(async () => {
236
236
  const t = window.__sootsimTest
237
237
  if (!t) return null
238
238
  const n = (await t.findByTestId(${i})) || (await t.findById(${i}))
@@ -282,10 +282,10 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
282
282
  },
283
283
  strategy: (resolved && resolved.strategy) || 'matched-node',
284
284
  }
285
- })()`})})}async function Ut(e,o,s={},i={}){let d=JSON.stringify({query:o,exact:!!s.exact,role:s.role??null,within:s.within??null,minX:s.minX??null,maxX:s.maxX??null,minY:s.minY??null,maxY:s.maxY??null,near:s.near??null,nth:s.nth??null,first:!!s.first});return be(e,{agent:i.agent,timing:i.timing,textFallback:o,resolve:()=>e.send({type:"evaluate",code:`(async () => {
285
+ })()`})})}async function Ut(e,o,s={},i={}){let p=JSON.stringify({query:o,exact:!!s.exact,role:s.role??null,within:s.within??null,minX:s.minX??null,maxX:s.maxX??null,minY:s.minY??null,maxY:s.maxY??null,near:s.near??null,nth:s.nth??null,first:!!s.first});return be(e,{agent:i.agent,timing:i.timing,textFallback:o,resolve:()=>e.send({type:"evaluate",code:`(async () => {
286
286
  const t = window.__sootsimTest
287
287
  if (!t) return { error: 'bridge-not-ready' }
288
- const F = ${d}
288
+ const F = ${p}
289
289
 
290
290
  const res = await t.queryTextCandidates({
291
291
  query: F.query,
@@ -410,7 +410,7 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
410
410
  total,
411
411
  idx,
412
412
  }
413
- })()`})})}async function Gt(e,o,s={}){let i=JSON.stringify(o);return be(e,{agent:s.agent,timing:s.timing,textFallback:o,resolve:async()=>{let d=await e.send({type:"evaluate",code:`(async () => {
413
+ })()`})})}async function Gt(e,o,s={}){let i=JSON.stringify(o);return be(e,{agent:s.agent,timing:s.timing,textFallback:o,resolve:async()=>{let p=await e.send({type:"evaluate",code:`(async () => {
414
414
  const t = window.__sootsimTest
415
415
  if (!t) return { error: 'bridge-not-ready' }
416
416
  const byTestId =
@@ -457,16 +457,16 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
457
457
  }
458
458
  }
459
459
  return { strategy: 'none' }
460
- })()`});if(!d||!("node"in d))return d;let l=d.node,p=l.absolutePosition.x+l.layout.width/2,y=l.absolutePosition.y+l.layout.height/2,f=d.screen??null,_=!!f&&(p<0||y<0||p>f.width||y>f.height);return{...d,cx:p,cy:y,..._?{offscreen:!0,screen:f}:{},target:{id:l.id,testID:l.testID,text:d.strategy==="text"?o:l.text,type:l.type}}}})}async function Yt(e,o={args:[]}){let s=await rt(e);if(A(o.args)){D(s);return}console.log(` nodes: ${s.nodes}`)}function ze(e,o){let s=e.indexOf(o);return s>=0&&s+1<e.length?e[s+1]:null}async function zt(e){let{bridge:o,args:s,positional:i}=e,d=s.includes("--verbose")||s.includes("-v"),l=A(s),p=d&&!l,y=s.includes("--watch")||s.includes("-w"),f=1e3,_=s.includes("--compact"),b=s.includes("--no-xy"),S=s.includes("--no-clipped"),N=s.includes("--include-occluded"),M=ze(s,"--testid-like"),j=ze(s,"--only"),O=ze(s,"--subtree"),c=i[1]&&!i[1].startsWith("-")?i[1]:void 0,q=c?/[*?]/.test(c):!1,R=!q&&!j?c:void 0,P=j??(q?c:void 0),K=async()=>{await ue(o,{verbose:p});let k=await lt(o,{describe:!0,verbose:d,filter:R||"",testIdLike:M||void 0,onlyGlob:P||void 0,subtreeRoot:O||void 0,compact:_,hideXy:b,includeOccluded:N}),F=k?.tree,J=k?.shell,H=k?.keyboard;if(l){D({shell:J,tree:F??"",keyboard:H});return}if(J&&typeof J=="object"){let C=[J.state?`state=${J.state}`:null,J.activeApp?`app=${J.activeApp}`:null,J.showSwitcher?"switcher":null,J.switcherPhase&&J.switcherPhase!=="idle"?`phase=${J.switcherPhase}`:null].filter(Boolean);C.length>0&&console.log(` shell: ${C.join(" ")}`)}if(typeof F=="string"&&F.startsWith("__SUBTREE_NOT_FOUND__:")){let C=F.slice(22);console.log(` subtree root not found: ${C}`),Q("subtree-root-not-found",C);return}if(!F){let C=k?.nodeCount??0;console.log(" no matching nodes found"),!(R||M||P||O)&&C<10&&Q("app-still-loading",C);return}let ee=F,te=0;if(S&&typeof ee=="string"){let C=ee.split(`
460
+ })()`});if(!p||!("node"in p))return p;let l=p.node,d=l.absolutePosition.x+l.layout.width/2,h=l.absolutePosition.y+l.layout.height/2,f=p.screen??null,k=!!f&&(d<0||h<0||d>f.width||h>f.height);return{...p,cx:d,cy:h,...k?{offscreen:!0,screen:f}:{},target:{id:l.id,testID:l.testID,text:p.strategy==="text"?o:l.text,type:l.type}}}})}async function Yt(e,o={args:[]}){let s=await rt(e);if(A(o.args)){D(s);return}console.log(` nodes: ${s.nodes}`)}function ze(e,o){let s=e.indexOf(o);return s>=0&&s+1<e.length?e[s+1]:null}async function zt(e){let{bridge:o,args:s,positional:i}=e,p=s.includes("--verbose")||s.includes("-v"),l=A(s),d=p&&!l,h=s.includes("--watch")||s.includes("-w"),f=1e3,k=s.includes("--compact"),b=s.includes("--no-xy"),S=s.includes("--no-clipped"),N=s.includes("--include-occluded"),M=ze(s,"--testid-like"),j=ze(s,"--only"),O=ze(s,"--subtree"),c=i[1]&&!i[1].startsWith("-")?i[1]:void 0,q=c?/[*?]/.test(c):!1,R=!q&&!j?c:void 0,P=j??(q?c:void 0),K=async()=>{await ue(o,{verbose:d});let _=await lt(o,{describe:!0,verbose:p,filter:R||"",testIdLike:M||void 0,onlyGlob:P||void 0,subtreeRoot:O||void 0,compact:k,hideXy:b,includeOccluded:N}),F=_?.tree,J=_?.shell,H=_?.keyboard;if(l){D({shell:J,tree:F??"",keyboard:H});return}if(J&&typeof J=="object"){let C=[J.state?`state=${J.state}`:null,J.activeApp?`app=${J.activeApp}`:null,J.showSwitcher?"switcher":null,J.switcherPhase&&J.switcherPhase!=="idle"?`phase=${J.switcherPhase}`:null].filter(Boolean);C.length>0&&console.log(` shell: ${C.join(" ")}`)}if(typeof F=="string"&&F.startsWith("__SUBTREE_NOT_FOUND__:")){let C=F.slice(22);console.log(` subtree root not found: ${C}`),Q("subtree-root-not-found",C);return}if(!F){let C=_?.nodeCount??0;console.log(" no matching nodes found"),!(R||M||P||O)&&C<10&&Q("app-still-loading",C);return}let ee=F,te=0;if(S&&typeof ee=="string"){let C=ee.split(`
461
461
  `),le=[];for(let Se of C){if(Se.includes("(clipped:")){te+=1;continue}le.push(Se)}ee=le.join(`
462
- `)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let re=R||M||P||O;if((R||M||P)&&!y&&Q("describe-filter-context"),!re&&!y&&F.split(`
462
+ `)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let re=R||M||P||O;if((R||M||P)&&!h&&Q("describe-filter-context"),!re&&!h&&F.split(`
463
463
  `).length>=80&&Q("describe-use-filters"),H&&H.visible){let C=H.spec,le=[C?.keyboardType?`type=${C.keyboardType}`:null,C?.returnKeyType&&C.returnKeyType!=="default"?`return=${C.returnKeyType}`:null,H.mode!=="letters"?`mode=${H.mode}`:null,H.shifted?"shift":null,H.capsLock?"caps":null,C?.autoCapitalize&&C.autoCapitalize!=="sentences"?`autoCap=${C.autoCapitalize}`:null,H.accessoryBarId?`accessory=${H.accessoryBarId}`:null].filter(Boolean);console.log(`
464
- keyboard: ${le.join(" ")||"visible"}`)}};if(y)for(console.log(` watching... (Ctrl+C to stop)
465
- `);;)console.clear(),await K(),await oe(f);else await K()}var ns=["SOOTSIM_AGENT","AGENTBUS_SESSION","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function me(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let e of ns){let o=process.env[e];if(o&&o.trim()&&o!=="0")return!0}return!1}async function Xt(e){let{bridge:o,args:s,effectiveArgs:i,positional:d,inspectUsage:l}=e,p=k=>{let F=i.indexOf(k);return F>=0&&F+1<i.length?i[F+1]:null},y=k=>i.includes(k),f=p("--testid")||p("--test-id"),_=p("--role"),b=p("--type"),S=p("--text"),N=y("--pressable"),M=y("--visible"),j=y("--interactive-targets")||y("--actions"),O=!f&&!_&&!b&&!S&&!N&&!M&&!j?d[1]:null,c=S??O,q=await pt(o,{testId:f,role:_,type:b,text:c,pressable:N,visible:M,interactive:j});q||(console.error(l("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:R,result:P}=q,K=A(s),U=s.includes("--verbose")||s.includes("--dump");if(K)R==="interactive-targets"&&Array.isArray(P)?D(Be(P).map(k=>({...k,tap:Ce(k)}))):D(P??null);else if(Array.isArray(P))if(P.length===0){console.log(` no ${R} nodes found`);let k=await o.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof k=="number"&&k<10&&Q("app-still-loading",k)}else if(R==="interactive-targets"){let k=Be(P);console.log(` found ${k.length} interactive target${k.length===1?"":"s"} (sorted by score):`);for(let F of k.slice(0,20)){let J=F.absolutePosition?`@(${Math.round(F.absolutePosition.x)},${Math.round(F.absolutePosition.y)})`:"",H=F.layout?`${Math.round(F.layout.width)}x${Math.round(F.layout.height)}`:"?x?",ee=F.text?` "${F.text.slice(0,30)}"`:"",te=F.testID?` #${F.testID}`:"",re=F.accessibilityLabel?` \u24D8"${String(F.accessibilityLabel).slice(0,24)}"`:"",xe=F.accessibilityRole?`[${F.accessibilityRole}]`:F.type,C=Ce(F);console.log(` ${xe}${ee}${re}${te} ${H} ${J}`),console.log(` \u2192 ${C}`),U&&console.log(Xe(JSON.stringify(F,null,2)," "))}k.length>20&&console.log(` ... and ${k.length-20} more`)}else{console.log(` found ${P.length} node${P.length===1?"":"s"} (${R}):`);for(let k of P.slice(0,20)){let F=k.absolutePosition?`@(${Math.round(k.absolutePosition.x)},${Math.round(k.absolutePosition.y)})`:"",J=k.layout?`${Math.round(k.layout.width)}x${Math.round(k.layout.height)}`:"?x?",H=k.text?` "${k.text.slice(0,30)}"`:"",ee=k.testID?` #${k.testID}`:"",te=k.pressable?" (tap)":"",re=k.accessibilityRole?`[${k.accessibilityRole}]`:k.type;console.log(` ${re}${H}${ee} ${J} ${F}${te}`),U&&console.log(Xe(JSON.stringify(k,null,2)," "))}P.length>20&&console.log(` ... and ${P.length-20} more`)}else if(P==null)console.log(` not found: ${c||f||_||b||""||R}`),f&&Q("wait-selector-for-missing-testid",f);else{let k=P;if(k.type&&k.absolutePosition){let F=`@(${Math.round(k.absolutePosition.x)},${Math.round(k.absolutePosition.y)})`,J=k.layout?`${Math.round(k.layout.width)}x${Math.round(k.layout.height)}`:"?x?",H=k.text?` "${k.text.slice(0,40)}"`:"",ee=k.testID?` #${k.testID}`:"",te=k.pressable?" (tap)":"",re=k.accessibilityRole?`[${k.accessibilityRole}]`:k.type;console.log(` ${re}${H}${ee} ${J} ${F}${te}`),U&&console.log(Xe(JSON.stringify(k,null,2)," "))}else console.log(JSON.stringify(P,null,2))}}function Xe(e,o){return e.split(`
464
+ keyboard: ${le.join(" ")||"visible"}`)}};if(h)for(console.log(` watching... (Ctrl+C to stop)
465
+ `);;)console.clear(),await K(),await oe(f);else await K()}var ns=["SOOTSIM_AGENT","AGENTBUS_SESSION","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function me(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let e of ns){let o=process.env[e];if(o&&o.trim()&&o!=="0")return!0}return!1}async function Xt(e){let{bridge:o,args:s,effectiveArgs:i,positional:p,inspectUsage:l}=e,d=_=>{let F=i.indexOf(_);return F>=0&&F+1<i.length?i[F+1]:null},h=_=>i.includes(_),f=d("--testid")||d("--test-id"),k=d("--role"),b=d("--type"),S=d("--text"),N=h("--pressable"),M=h("--visible"),j=h("--interactive-targets")||h("--actions"),O=!f&&!k&&!b&&!S&&!N&&!M&&!j?p[1]:null,c=S??O,q=await pt(o,{testId:f,role:k,type:b,text:c,pressable:N,visible:M,interactive:j});q||(console.error(l("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:R,result:P}=q,K=A(s),U=s.includes("--verbose")||s.includes("--dump");if(K)R==="interactive-targets"&&Array.isArray(P)?D(Be(P).map(_=>({..._,tap:Ce(_)}))):D(P??null);else if(Array.isArray(P))if(P.length===0){console.log(` no ${R} nodes found`);let _=await o.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof _=="number"&&_<10&&Q("app-still-loading",_)}else if(R==="interactive-targets"){let _=Be(P);console.log(` found ${_.length} interactive target${_.length===1?"":"s"} (sorted by score):`);for(let F of _.slice(0,20)){let J=F.absolutePosition?`@(${Math.round(F.absolutePosition.x)},${Math.round(F.absolutePosition.y)})`:"",H=F.layout?`${Math.round(F.layout.width)}x${Math.round(F.layout.height)}`:"?x?",ee=F.text?` "${F.text.slice(0,30)}"`:"",te=F.testID?` #${F.testID}`:"",re=F.accessibilityLabel?` \u24D8"${String(F.accessibilityLabel).slice(0,24)}"`:"",xe=F.accessibilityRole?`[${F.accessibilityRole}]`:F.type,C=Ce(F);console.log(` ${xe}${ee}${re}${te} ${H} ${J}`),console.log(` \u2192 ${C}`),U&&console.log(Xe(JSON.stringify(F,null,2)," "))}_.length>20&&console.log(` ... and ${_.length-20} more`)}else{console.log(` found ${P.length} node${P.length===1?"":"s"} (${R}):`);for(let _ of P.slice(0,20)){let F=_.absolutePosition?`@(${Math.round(_.absolutePosition.x)},${Math.round(_.absolutePosition.y)})`:"",J=_.layout?`${Math.round(_.layout.width)}x${Math.round(_.layout.height)}`:"?x?",H=_.text?` "${_.text.slice(0,30)}"`:"",ee=_.testID?` #${_.testID}`:"",te=_.pressable?" (tap)":"",re=_.accessibilityRole?`[${_.accessibilityRole}]`:_.type;console.log(` ${re}${H}${ee} ${J} ${F}${te}`),U&&console.log(Xe(JSON.stringify(_,null,2)," "))}P.length>20&&console.log(` ... and ${P.length-20} more`)}else if(P==null)console.log(` not found: ${c||f||k||b||""||R}`),f&&Q("wait-selector-for-missing-testid",f);else{let _=P;if(_.type&&_.absolutePosition){let F=`@(${Math.round(_.absolutePosition.x)},${Math.round(_.absolutePosition.y)})`,J=_.layout?`${Math.round(_.layout.width)}x${Math.round(_.layout.height)}`:"?x?",H=_.text?` "${_.text.slice(0,40)}"`:"",ee=_.testID?` #${_.testID}`:"",te=_.pressable?" (tap)":"",re=_.accessibilityRole?`[${_.accessibilityRole}]`:_.type;console.log(` ${re}${H}${ee} ${J} ${F}${te}`),U&&console.log(Xe(JSON.stringify(_,null,2)," "))}else console.log(JSON.stringify(P,null,2))}}function Xe(e,o){return e.split(`
466
466
  `).map(s=>o+s).join(`
467
- `)}async function Vt(e){let{bridge:o,args:s}=e,i=A(s);await ue(o,{verbose:!i});let d=s.includes("--styling"),l=s.indexOf("--filter"),p=l>=0?s[l+1]:void 0,y=await ct(o,{styling:d,filter:p});if(i){D({count:y.length,elements:y});return}console.log(` layout (${y.length} element${y.length===1?"":"s"}):
468
- `),console.log(dt(y,{styling:d}))}async function Qt(e,o={}){let s=await St(e);if("error"in s&&(console.error(s.error),process.exit(1)),o.json){console.log(JSON.stringify(s,null,2));return}let{visible:i,spec:d,mode:l,shifted:p,capsLock:y,accessoryBarId:f}=s,_=[];_.push(`keyboard: ${i?"visible":"hidden"}`),d?(_.push(` type: ${d.keyboardType}`),_.push(` returnKey: ${d.returnKeyType}`),_.push(` autoCap: ${d.autoCapitalize}`),_.push(` autoCorrect: ${d.autoCorrect?"on":"off"}`),_.push(` appearance: ${d.keyboardAppearance}`),d.secureTextEntry&&_.push(" secureTextEntry: true"),d.enablesReturnKeyAutomatically&&_.push(` return: ${d.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):_.push(" spec: <none> (shown via dev-tools with no TextInput)"),_.push(` mode: ${l}${p?" (shifted)":""}${y?" (caps)":""}`),f&&_.push(` accessoryBar: ${f}`),console.log(_.join(`
469
- `))}async function Zt(e){let o=await e.bridge.listSims(),s=e.args.includes("--all"),i=e.args.find((y,f)=>e.args[f-1]==="--bundle"),d=e.args.find((y,f)=>e.args[f-1]==="--app-port"),l=e.args.includes("--primary"),p=o.filter(y=>!(l&&!y.isPrimary||i&&!(y.url??"").includes(i)||d&&!(y.url??"").includes(`/rn/${d}`)||!s&&!i&&!d&&!l&&!(y.url&&(y.url.includes("bundle=")||y.url.includes("/index.bundle")))&&y.id!==e.simId));if(A(e.args)){D(p.map(y=>({...y,active:y.id===e.simId})));return}Rt(p,e.simId),p.length<o.length&&!A(e.args)&&console.log(` (${o.length-p.length} more hidden \u2014 pass --all to show)`)}function ae(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function rs(e,o){return o<=0?"?":`${(e/o*100).toFixed(0)}%`}function is(e){let o={},s=(i,d)=>{d&&(d.nodesRegistered!=null&&(o[`${i}.nodes`]=d.nodesRegistered),d.nodesDetached!=null&&(o[`${i}.detached`]=d.nodesDetached),d.objects&&(o[`${i}.paragraphs`]=d.objects.paragraphs,o[`${i}.yogaNodes`]=d.objects.yogaNodes,o[`${i}.pictures`]=d.objects.pictures,o[`${i}.rasterImages`]=d.objects.rasterImages),d.imageLoader&&(o[`${i}.imageCacheEntries`]=d.imageLoader.cacheEntries,o[`${i}.imagePixelBytes`]=d.imageLoader.cachePixelBytes),d.workerHeap&&(o[`${i}.heapBytes`]=d.workerHeap.usedJSHeapSize))};return s("tenant",e.tenant),s("shell",e.shell),e.hostHeap&&(o["host.heapBytes"]=e.hostHeap.usedJSHeapSize),o}function eo(e,o){return e.endsWith("Bytes")?ae(o):String(o)}function to(e,o){if(!o){console.log(` ${e}: not available`);return}let s=o.objects;if(console.log(` ${e}`),o.nodesRegistered!=null&&console.log(` nodes registered: ${o.nodesRegistered}`),o.nodesDetached!=null){let i=Object.entries(o.detachedTypes??{}).map(([d,l])=>`${d}:${l}`).join(" ");console.log(` nodes detached: ${o.nodesDetached}${i?` (${i})`:""}`)}if(s&&(console.log(` paragraphs: ${s.paragraphs}`),console.log(` yoga nodes: ${s.yogaNodes}`),console.log(` pictures: ${s.pictures}`),console.log(` raster images: ${s.rasterImages}`)),o.activeNativeAnimations!=null&&console.log(` native anims: ${o.activeNativeAnimations}`),o.imageLoader){let i=o.imageLoader;console.log(` image cache: ${i.cacheEntries}/${i.cacheMaxEntries} entries, ${ae(i.cachePixelBytes)}/${ae(i.cachePixelBudget)} (${rs(i.cachePixelBytes,i.cachePixelBudget)})`)}o.workerHeap&&console.log(` js heap: ${ae(o.workerHeap.usedJSHeapSize)} used / ${ae(o.workerHeap.totalJSHeapSize)} total`)}function as(e){console.log(" memory:"),to("tenant worker",e.tenant),to("shell worker",e.shell),e.hostHeap?(console.log(" host"),console.log(` js heap: ${ae(e.hostHeap.usedJSHeapSize)} used / ${ae(e.hostHeap.totalJSHeapSize)} total`)):console.log(" host js heap: not available (chrome only)")}function ls(e,o,s){let i=e.indexOf(o);if(i===-1)return s;let d=Number(e[i+1]);return Number.isFinite(d)&&d>0?d:s}async function oo(e,o={args:[]}){let s=A(o.args),i=o.args.indexOf("--watch");if(i===-1){let O=await Le(e);if(s){D(O);return}as(O);return}let d=Number(o.args[i+1]),l=Number.isFinite(d)&&d>0?d:60,p=ls(o.args,"--interval",5),y=[],f=Date.now(),_=null;for(s||console.log(` sampling every ${p}s for ${l}s \u2014 deltas per tick:`);;){let O=await Le(e),c=(Date.now()-f)/1e3,q=is(O);if(y.push({tSec:c,counters:q}),!s){let R=[];for(let[P,K]of Object.entries(q)){let U=_&&P in _?K-_[P]:null;if(U===null||U===0)continue;let k=U>0?"+":"-",F=P.endsWith("Bytes")?`${k}${ae(Math.abs(U))}`:`${k}${Math.abs(U)}`;R.push(`${P} ${eo(P,K)} (${F})`)}console.log(` t+${c.toFixed(0)}s ${R.length?R.join(" "):_?"no change":Object.entries(q).map(([P,K])=>`${P} ${eo(P,K)}`).join(" ")}`)}if(_=q,c>=l)break;await new Promise(R=>setTimeout(R,p*1e3))}let b=y[0],S=y[y.length-1],N=Math.max(S.tSec-b.tSec,.001),M={};for(let O of Object.keys(S.counters))O in b.counters&&(M[O]=(S.counters[O]-b.counters[O])/N);if(s){D({samples:y,perSecond:M,elapsedSec:N});return}console.log(`
467
+ `)}async function Vt(e){let{bridge:o,args:s}=e,i=A(s);await ue(o,{verbose:!i});let p=s.includes("--styling"),l=s.indexOf("--filter"),d=l>=0?s[l+1]:void 0,h=await ct(o,{styling:p,filter:d});if(i){D({count:h.length,elements:h});return}console.log(` layout (${h.length} element${h.length===1?"":"s"}):
468
+ `),console.log(dt(h,{styling:p}))}async function Qt(e,o={}){let s=await St(e);if("error"in s&&(console.error(s.error),process.exit(1)),o.json){console.log(JSON.stringify(s,null,2));return}let{visible:i,spec:p,mode:l,shifted:d,capsLock:h,accessoryBarId:f}=s,k=[];k.push(`keyboard: ${i?"visible":"hidden"}`),p?(k.push(` type: ${p.keyboardType}`),k.push(` returnKey: ${p.returnKeyType}`),k.push(` autoCap: ${p.autoCapitalize}`),k.push(` autoCorrect: ${p.autoCorrect?"on":"off"}`),k.push(` appearance: ${p.keyboardAppearance}`),p.secureTextEntry&&k.push(" secureTextEntry: true"),p.enablesReturnKeyAutomatically&&k.push(` return: ${p.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):k.push(" spec: <none> (shown via dev-tools with no TextInput)"),k.push(` mode: ${l}${d?" (shifted)":""}${h?" (caps)":""}`),f&&k.push(` accessoryBar: ${f}`),console.log(k.join(`
469
+ `))}async function Zt(e){let o=await e.bridge.listSims(),s=e.args.includes("--all"),i=e.args.find((h,f)=>e.args[f-1]==="--bundle"),p=e.args.find((h,f)=>e.args[f-1]==="--app-port"),l=e.args.includes("--primary"),d=o.filter(h=>!(l&&!h.isPrimary||i&&!(h.url??"").includes(i)||p&&!(h.url??"").includes(`/rn/${p}`)||!s&&!i&&!p&&!l&&!(h.url&&(h.url.includes("bundle=")||h.url.includes("/index.bundle")))&&h.id!==e.simId));if(A(e.args)){D(d.map(h=>({...h,active:h.id===e.simId})));return}Rt(d,e.simId),d.length<o.length&&!A(e.args)&&console.log(` (${o.length-d.length} more hidden \u2014 pass --all to show)`)}function ae(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function rs(e,o){return o<=0?"?":`${(e/o*100).toFixed(0)}%`}function is(e){let o={},s=(i,p)=>{p&&(p.nodesRegistered!=null&&(o[`${i}.nodes`]=p.nodesRegistered),p.nodesDetached!=null&&(o[`${i}.detached`]=p.nodesDetached),p.objects&&(o[`${i}.paragraphs`]=p.objects.paragraphs,o[`${i}.yogaNodes`]=p.objects.yogaNodes,o[`${i}.pictures`]=p.objects.pictures,o[`${i}.rasterImages`]=p.objects.rasterImages),p.imageLoader&&(o[`${i}.imageCacheEntries`]=p.imageLoader.cacheEntries,o[`${i}.imagePixelBytes`]=p.imageLoader.cachePixelBytes),p.workerHeap&&(o[`${i}.heapBytes`]=p.workerHeap.usedJSHeapSize))};return s("tenant",e.tenant),s("shell",e.shell),e.hostHeap&&(o["host.heapBytes"]=e.hostHeap.usedJSHeapSize),o}function eo(e,o){return e.endsWith("Bytes")?ae(o):String(o)}function to(e,o){if(!o){console.log(` ${e}: not available`);return}let s=o.objects;if(console.log(` ${e}`),o.nodesRegistered!=null&&console.log(` nodes registered: ${o.nodesRegistered}`),o.nodesDetached!=null){let i=Object.entries(o.detachedTypes??{}).map(([p,l])=>`${p}:${l}`).join(" ");console.log(` nodes detached: ${o.nodesDetached}${i?` (${i})`:""}`)}if(s&&(console.log(` paragraphs: ${s.paragraphs}`),console.log(` yoga nodes: ${s.yogaNodes}`),console.log(` pictures: ${s.pictures}`),console.log(` raster images: ${s.rasterImages}`)),o.activeNativeAnimations!=null&&console.log(` native anims: ${o.activeNativeAnimations}`),o.imageLoader){let i=o.imageLoader;console.log(` image cache: ${i.cacheEntries}/${i.cacheMaxEntries} entries, ${ae(i.cachePixelBytes)}/${ae(i.cachePixelBudget)} (${rs(i.cachePixelBytes,i.cachePixelBudget)})`)}o.workerHeap&&console.log(` js heap: ${ae(o.workerHeap.usedJSHeapSize)} used / ${ae(o.workerHeap.totalJSHeapSize)} total`)}function as(e){console.log(" memory:"),to("tenant worker",e.tenant),to("shell worker",e.shell),e.hostHeap?(console.log(" host"),console.log(` js heap: ${ae(e.hostHeap.usedJSHeapSize)} used / ${ae(e.hostHeap.totalJSHeapSize)} total`)):console.log(" host js heap: not available (chrome only)")}function ls(e,o,s){let i=e.indexOf(o);if(i===-1)return s;let p=Number(e[i+1]);return Number.isFinite(p)&&p>0?p:s}async function oo(e,o={args:[]}){let s=A(o.args),i=o.args.indexOf("--watch");if(i===-1){let O=await Le(e);if(s){D(O);return}as(O);return}let p=Number(o.args[i+1]),l=Number.isFinite(p)&&p>0?p:60,d=ls(o.args,"--interval",5),h=[],f=Date.now(),k=null;for(s||console.log(` sampling every ${d}s for ${l}s \u2014 deltas per tick:`);;){let O=await Le(e),c=(Date.now()-f)/1e3,q=is(O);if(h.push({tSec:c,counters:q}),!s){let R=[];for(let[P,K]of Object.entries(q)){let U=k&&P in k?K-k[P]:null;if(U===null||U===0)continue;let _=U>0?"+":"-",F=P.endsWith("Bytes")?`${_}${ae(Math.abs(U))}`:`${_}${Math.abs(U)}`;R.push(`${P} ${eo(P,K)} (${F})`)}console.log(` t+${c.toFixed(0)}s ${R.length?R.join(" "):k?"no change":Object.entries(q).map(([P,K])=>`${P} ${eo(P,K)}`).join(" ")}`)}if(k=q,c>=l)break;await new Promise(R=>setTimeout(R,d*1e3))}let b=h[0],S=h[h.length-1],N=Math.max(S.tSec-b.tSec,.001),M={};for(let O of Object.keys(S.counters))O in b.counters&&(M[O]=(S.counters[O]-b.counters[O])/N);if(s){D({samples:h,perSecond:M,elapsedSec:N});return}console.log(`
470
470
  slope over ${N.toFixed(0)}s:`);let j=Object.entries(M).filter(([,O])=>O!==0).sort((O,c)=>Math.abs(c[1])-Math.abs(O[1]));if(j.length===0){console.log(" all counters flat");return}for(let[O,c]of j){let q=O.endsWith("Bytes")?`${ae(Math.abs(c))}/s${c<0?" (shrinking)":""}`:`${c>0?"+":""}${c.toFixed(2)}/s`;console.log(` ${O.padEnd(28)}${q}`)}}var Z="<redacted secure text>";function we(e){let o=e?.layout?.spec??e?.spec??null;return!!o?.secureTextEntry&&o.keyboardType!=="visible-password"}function Ve(e,o){return we(o)?Z:e}function Qe(e){if(!e||!we(e))return e;let o=e.focusedInput;return!o||typeof o!="object"?e:{...e,focusedInput:{...o,secureTextEntry:!0,text:typeof o.text=="string"?Z:o.text}}}function $e(e){let o=e.indexOf("--testid");if(o>=0&&e[o+1])return{mode:"testid",value:e[o+1]};let s=e.indexOf("--test-id");if(s>=0&&e[s+1])return{mode:"testid",value:e[s+1]};let i=e.indexOf("--text");return i>=0&&e[i+1]?{mode:"text",value:e[i+1]}:null}async function Oe(e,o){let s=JSON.stringify(o.value),i=o.mode==="testid"?`(await t.findByTestId(${s})) || (await t.findById(${s}))`:`await t.findByText(${s})`;return await e.send({type:"evaluate",code:`(async () => {
471
471
  const t = window.__sootsimTest
472
472
  if (!t) return null
@@ -492,12 +492,12 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
492
492
  text: ${JSON.stringify(o.mode==="text")} ? ${s} : (n.text ?? n.accessibilityLabel ?? null),
493
493
  type: n.type ?? null,
494
494
  }
495
- })()`})??null}async function so(e,o={}){let{nav:s,keyboard:i,shell:d}=await vt(e);if(o.json){console.log(JSON.stringify({shell:d??null,nav:s,keyboard:i},null,2));return}let l=[];if(d){let p=d.activeApp??d.state??"<none>",y=d.showSwitcher?" (app switcher open)":"",f=typeof d.launchProgress=="number"&&d.launchProgress<.98?` launching (${Math.round(d.launchProgress*100)}%)`:"";l.push(`shell: ${p}${y}${f}`)}else l.push("shell: <unavailable>");if(s){let p=s.transitionPhase!=="idle"?` (${s.transitionPhase}, ${s.activeTransitionCount} active)`:"";if(l.push(`nav: phase=${s.transitionPhase}${p}`),s.screens.length===0)l.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let y of s.screens){let f=y.isActive?"\u25B6":" ",_=y.routeName?` ${y.routeName}`:"",b=y.headerHeight>0?` header=${y.headerHeight}`:"",S=y.largeTitleState&&y.largeTitleState!=="expanded"?` large-title=${y.largeTitleState}`:"";l.push(` ${f} #${y.id}${_}${b}${S}`)}}else l.push("nav: <runtime not available>");if(i&&i.visible){let p=i.spec?.keyboardType??"default",y=i.spec?.returnKeyType??"default";l.push(`keyboard: visible (${p}, return=${y}, mode=${i.mode??"?"})`)}else l.push("keyboard: hidden");console.log(l.join(`
496
- `))}async function no(e){let{bridge:o,args:s,positional:i}=e,d=i[1]?Number(i[1])*1e3:3e3,l=s.includes("--strict"),{elapsed:p,settled:y}=await se({bridge:o,maxMs:d,strict:l});console.log(y?` settled in ${p}ms`:` timed out after ${p}ms (may still be animating)`)}async function ro(e){let o=e.positional[1]?Number(e.positional[1]):.5;(!Number.isFinite(o)||o<0)&&(console.error(e.inspectUsage("sleep","[seconds]")),process.exit(1)),await oe(o*1e3),console.log(` slept ${o}s`)}async function io(e){let{bridge:o,args:s,positional:i}=e,d=s.includes("--boxes"),l=i[1]?Number(i[1]):d?50:5,{tree:p}=await it(o,l,d?{format:"boxes"}:void 0);if(A(s)){D({depth:l,tree:p??null});return}console.log(typeof p=="string"?p:JSON.stringify(p,null,2))}async function ao(e,o={args:[]}){let s=await at(e);if(A(o.args)){D(s);return}console.log(s.url)}async function lo(e){let{wsPort:o,commandTimeoutMs:s,simId:i,simIdSource:d,positional:l}=e,p=l[1]?Number(l[1]):30,y=Math.max(1e3,(Number.isFinite(p)?p:30)*1e3),f=Math.max(1,Math.ceil(y/500));console.log(" waiting for sim reconnect...");let _=await Nt(o,s,i,{attempts:f,simIdSource:d});_||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),_.bridge.close(),Fe({source:"inspect wait",step:{wait:y},summary:`wait ${Math.round(y/1e3)}s`}),console.log(` ready: ${_.count} nodes`)}var co=new Set(["app-launch","toast","keyboard","screen","flow-step","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function Ee(e,o){let s=e.indexOf(o);if(s>=0&&s+1<e.length)return e[s+1]}function cs(e,o){if(!o.filter&&!o.equals)return!0;let s=e.data,i=[];if(s&&typeof s=="object")for(let l of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let p=s[l];typeof p=="string"&&p.length>0&&i.push(p)}let d=i.join(" ");return o.equals?i.some(l=>l===o.equals):o.filter?d.toLowerCase().includes(o.filter.toLowerCase()):!0}async function uo(e){let{bridge:o,args:s,positional:i,inspectUsage:d}=e,l=i[1];l||(console.error(d("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),co.has(l)||console.error(` warning: '${l}' is not a known timeline kind \u2014 waiting anyway. known: ${[...co].sort().join(", ")}`);let p=Ee(s,"--max-ms"),y=p&&Number.isFinite(Number(p))?Math.max(100,Number(p)):5e3,f=Ee(s,"--filter"),_=Ee(s,"--equals"),b=Ee(s,"--since")??"now",S=s.includes("--json"),N=Date.now(),M=N+y,j=200,O=N;for(;Date.now()<M;){let q={kinds:[l],since:b==="cursor"?void 0:O,limit:50},R=await o.send({type:"evaluate",code:`(async () => {
495
+ })()`})??null}async function so(e,o={}){let{nav:s,route:i,keyboard:p,shell:l}=await vt(e);if(o.json){console.log(JSON.stringify({shell:l??null,nav:s,route:i,keyboard:p},null,2));return}let d=[];if(l){let h=l.activeApp??l.state??"<none>",f=l.showSwitcher?" (app switcher open)":"",k=typeof l.launchProgress=="number"&&l.launchProgress<.98?` launching (${Math.round(l.launchProgress*100)}%)`:"";d.push(`shell: ${h}${f}${k}`)}else d.push("shell: <unavailable>");if(s){let h=s.transitionPhase!=="idle"?` (${s.transitionPhase}, ${s.activeTransitionCount} active)`:"";if(d.push(`nav: phase=${s.transitionPhase}${h}`),s.screens.length===0)d.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let f of s.screens){let k=f.isActive?"\u25B6":" ",b=f.routeName?` ${f.routeName}`:"",S=f.headerHeight>0?` header=${f.headerHeight}`:"",N=f.largeTitleState&&f.largeTitleState!=="expanded"?` large-title=${f.largeTitleState}`:"";d.push(` ${k} #${f.id}${b}${S}${N}`)}}else d.push("nav: <runtime not available>");if(d.push(`route: ${i?.currentPath??"<unavailable>"}`),p&&p.visible){let h=p.spec?.keyboardType??"default",f=p.spec?.returnKeyType??"default";d.push(`keyboard: visible (${h}, return=${f}, mode=${p.mode??"?"})`)}else d.push("keyboard: hidden");console.log(d.join(`
496
+ `))}async function no(e){let{bridge:o,args:s,positional:i}=e,p=i[1]?Number(i[1])*1e3:3e3,l=s.includes("--strict"),{elapsed:d,settled:h}=await se({bridge:o,maxMs:p,strict:l});console.log(h?` settled in ${d}ms`:` timed out after ${d}ms (may still be animating)`)}async function ro(e){let o=e.positional[1]?Number(e.positional[1]):.5;(!Number.isFinite(o)||o<0)&&(console.error(e.inspectUsage("sleep","[seconds]")),process.exit(1)),await oe(o*1e3),console.log(` slept ${o}s`)}async function io(e){let{bridge:o,args:s,positional:i}=e,p=s.includes("--boxes"),l=i[1]?Number(i[1]):p?50:5,{tree:d}=await it(o,l,p?{format:"boxes"}:void 0);if(A(s)){D({depth:l,tree:d??null});return}console.log(typeof d=="string"?d:JSON.stringify(d,null,2))}async function ao(e,o={args:[]}){let s=await at(e);if(A(o.args)){D(s);return}console.log(s.url)}async function lo(e){let{wsPort:o,commandTimeoutMs:s,simId:i,simIdSource:p,positional:l}=e,d=l[1]?Number(l[1]):30,h=Math.max(1e3,(Number.isFinite(d)?d:30)*1e3),f=Math.max(1,Math.ceil(h/500));console.log(" waiting for sim reconnect...");let k=await Nt(o,s,i,{attempts:f,simIdSource:p});k||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),k.bridge.close(),Fe({source:"inspect wait",step:{wait:h},summary:`wait ${Math.round(h/1e3)}s`}),console.log(` ready: ${k.count} nodes`)}var co=new Set(["app-launch","toast","keyboard","screen","flow-step","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function Ee(e,o){let s=e.indexOf(o);if(s>=0&&s+1<e.length)return e[s+1]}function cs(e,o){if(!o.filter&&!o.equals)return!0;let s=e.data,i=[];if(s&&typeof s=="object")for(let l of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let d=s[l];typeof d=="string"&&d.length>0&&i.push(d)}let p=i.join(" ");return o.equals?i.some(l=>l===o.equals):o.filter?p.toLowerCase().includes(o.filter.toLowerCase()):!0}async function uo(e){let{bridge:o,args:s,positional:i,inspectUsage:p}=e,l=i[1];l||(console.error(p("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),co.has(l)||console.error(` warning: '${l}' is not a known timeline kind \u2014 waiting anyway. known: ${[...co].sort().join(", ")}`);let d=Ee(s,"--max-ms"),h=d&&Number.isFinite(Number(d))?Math.max(100,Number(d)):5e3,f=Ee(s,"--filter"),k=Ee(s,"--equals"),b=Ee(s,"--since")??"now",S=s.includes("--json"),N=Date.now(),M=N+h,j=200,O=N;for(;Date.now()<M;){let q={kinds:[l],since:b==="cursor"?void 0:O,limit:50},R=await o.send({type:"evaluate",code:`(async () => {
497
497
  const t = window.SootSim?.bridges?.timeline
498
498
  if (!t) return { ok: false, error: 'timeline bridge missing' }
499
499
  return { ok: true, result: await t.recent(${JSON.stringify(q)}) }
500
- })()`});(!R||!R.ok)&&(console.error(` could not query timeline: ${R&&"error"in R?R.error:"unknown"}`),process.exit(1));let P=R.result.events??[];for(let K of P)if(cs(K,{filter:f,equals:_})){let U=Date.now()-N;console.log(S?JSON.stringify({found:!0,elapsedMs:U,event:K}):` ${l} event after ${U}ms${f?` (filter: ${f})`:""}${_?` (equals: ${_})`:""}`);return}R.result.watermark&&R.result.watermark>O&&(O=R.result.watermark),await new Promise(K=>setTimeout(K,j))}let c=Date.now()-N;S?console.log(JSON.stringify({found:!1,elapsedMs:c,kind:l,filter:f,equals:_})):console.error(` \u26A0 wait event ${l} timed out after ${c}ms${f?` (filter: ${f})`:""}${_?` (equals: ${_})`:""}`),process.exit(1)}async function po(e){let{bridge:o,args:s}=e,i=s.includes("--strict"),d=ke(s,3e3),{elapsed:l,settled:p}=await se({bridge:o,maxMs:d,strict:i});p?console.log(` idle in ${l}ms`):(console.error(` \u26A0 wait idle timed out after ${l}ms (may still be animating)`),process.exit(1))}async function mo(e){let{bridge:o,args:s}=e,i=ke(s,2e4),{ready:d,elapsedMs:l,nodes:p,targets:y,flag:f,loadingText:_,externalReady:b,externalError:S,suppressedEntryError:N,errors:M,bridgeError:j}=await mt(o,i,{onProgress(c){console.error(` still waiting after ${c.elapsedMs}ms \u2014 ${je(c)} (nodes: ${c.nodes}, targets: ${c.targets}, errors: ${c.errors})`)}});if(d){let c=i-l,q=Math.max(100,Math.min(1e4,c)),R=await se({bridge:o,maxMs:q,pollMs:32,stablePolls:2});R.settled||(console.error(` \u26A0 wait ready timed out after ${l+R.elapsed}ms \u2014 app mounted but did not settle (nodes: ${p}, targets: ${y})`),process.exit(1)),console.log(` ready in ${l+R.elapsed}ms: ${p} nodes, ${y} targets`);return}let O=je({externalError:S,loadingText:_,externalReady:b,flag:f,targets:y,suppressedEntryError:N,bridgeError:j});console.error(` \u26A0 wait ready timed out after ${l}ms \u2014 ${O} (nodes: ${p}, targets: ${y}, errors: ${M})`),process.exit(1)}async function fo(e){let{bridge:o,args:s,positional:i,inspectUsage:d}=e,l=i[1];l||(console.error(d("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let p=s.indexOf("--max-ms"),y=p>=0&&s[p+1]?Math.max(100,Number(s[p+1])):5e3,f=s.includes("--gone"),{found:_,node:b,elapsed:S}=await ft(o,l,y,{gone:f});if(f){_?console.log(` #${l} gone after ${S}ms`):(console.error(` \u26A0 wait selector #${l} --gone timed out after ${S??y}ms (still present)`),process.exit(1));return}if(_&&b){let N=b.absolutePosition?`@(${Math.round(b.absolutePosition.x)},${Math.round(b.absolutePosition.y)})`:"",M=b.layout?`${Math.round(b.layout.width)}x${Math.round(b.layout.height)}`:"?x?";console.log(` found #${l} in ${S}ms ${M} ${N}`)}else console.error(` \u26A0 wait selector #${l} timed out after ${S??y}ms`),process.exit(1)}function ko(e){return e==null?"\u2014":e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}function _o(e){return e==null?" \u2026":e<1e3?`${e}ms`.padStart(5):`${(e/1e3).toFixed(2)}s`.padStart(5)}function go(){process.stderr.write(` the sim is not responding. recover it with:
500
+ })()`});(!R||!R.ok)&&(console.error(` could not query timeline: ${R&&"error"in R?R.error:"unknown"}`),process.exit(1));let P=R.result.events??[];for(let K of P)if(cs(K,{filter:f,equals:k})){let U=Date.now()-N;console.log(S?JSON.stringify({found:!0,elapsedMs:U,event:K}):` ${l} event after ${U}ms${f?` (filter: ${f})`:""}${k?` (equals: ${k})`:""}`);return}R.result.watermark&&R.result.watermark>O&&(O=R.result.watermark),await new Promise(K=>setTimeout(K,j))}let c=Date.now()-N;S?console.log(JSON.stringify({found:!1,elapsedMs:c,kind:l,filter:f,equals:k})):console.error(` \u26A0 wait event ${l} timed out after ${c}ms${f?` (filter: ${f})`:""}${k?` (equals: ${k})`:""}`),process.exit(1)}async function po(e){let{bridge:o,args:s}=e,i=s.includes("--strict"),p=ke(s,3e3),{elapsed:l,settled:d}=await se({bridge:o,maxMs:p,strict:i});d?console.log(` idle in ${l}ms`):(console.error(` \u26A0 wait idle timed out after ${l}ms (may still be animating)`),process.exit(1))}async function mo(e){let{bridge:o,args:s}=e,i=ke(s,2e4),{ready:p,elapsedMs:l,nodes:d,targets:h,flag:f,loadingText:k,externalReady:b,externalError:S,suppressedEntryError:N,errors:M,bridgeError:j}=await mt(o,i,{onProgress(c){console.error(` still waiting after ${c.elapsedMs}ms \u2014 ${je(c)} (nodes: ${c.nodes}, targets: ${c.targets}, errors: ${c.errors})`)}});if(p){let c=i-l,q=Math.max(100,Math.min(1e4,c)),R=await se({bridge:o,maxMs:q,pollMs:32,stablePolls:2});R.settled||(console.error(` \u26A0 wait ready timed out after ${l+R.elapsed}ms \u2014 app mounted but did not settle (nodes: ${d}, targets: ${h})`),process.exit(1)),console.log(` ready in ${l+R.elapsed}ms: ${d} nodes, ${h} targets`);return}let O=je({externalError:S,loadingText:k,externalReady:b,flag:f,targets:h,suppressedEntryError:N,bridgeError:j});console.error(` \u26A0 wait ready timed out after ${l}ms \u2014 ${O} (nodes: ${d}, targets: ${h}, errors: ${M})`),process.exit(1)}async function fo(e){let{bridge:o,args:s,positional:i,inspectUsage:p}=e,l=i[1];l||(console.error(p("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let d=s.indexOf("--max-ms"),h=d>=0&&s[d+1]?Math.max(100,Number(s[d+1])):5e3,f=s.includes("--gone"),{found:k,node:b,elapsed:S}=await ft(o,l,h,{gone:f});if(f){k?console.log(` #${l} gone after ${S}ms`):(console.error(` \u26A0 wait selector #${l} --gone timed out after ${S??h}ms (still present)`),process.exit(1));return}if(k&&b){let N=b.absolutePosition?`@(${Math.round(b.absolutePosition.x)},${Math.round(b.absolutePosition.y)})`:"",M=b.layout?`${Math.round(b.layout.width)}x${Math.round(b.layout.height)}`:"?x?";console.log(` found #${l} in ${S}ms ${M} ${N}`)}else console.error(` \u26A0 wait selector #${l} timed out after ${S??h}ms`),process.exit(1)}function ko(e){return e==null?"\u2014":e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}function _o(e){return e==null?" \u2026":e<1e3?`${e}ms`.padStart(5):`${(e/1e3).toFixed(2)}s`.padStart(5)}function go(){process.stderr.write(` the sim is not responding. recover it with:
501
501
  sootsim close --sim <id> # force-close the wedged sim
502
502
  sootsim list # confirm it's gone
503
503
  `)}async function us(e){try{return await e.send({type:"evaluate",code:"1"},{timeoutMs:3e3}),!0}catch{return!1}}async function ps(e,o){try{let s=await e.send({type:"evaluate",code:`(async () => {
@@ -519,9 +519,9 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
519
519
  } catch {
520
520
  return []
521
521
  }
522
- })()`});if(!Array.isArray(s)||s.length===0)return;let i=o.toLowerCase(),d=s.map(l=>({id:l,score:ms(i,l.toLowerCase())})).filter(l=>l.score<i.length+4).sort((l,p)=>l.score-p.score).slice(0,5);if(d.length===0)return;console.error(" similar testIDs:");for(let l of d)console.error(` ${l.id}`)}catch{}}function ms(e,o){if(o===e)return 0;if(o.includes(e))return 1;if(e.includes(o))return 2;let s=0;for(;s<e.length&&s<o.length&&e[s]===o[s];)s+=1;return fs(e,o)-s}function fs(e,o){if(e===o)return 0;if(!e.length)return o.length;if(!o.length)return e.length;let s=new Array(o.length+1),i=new Array(o.length+1);for(let d=0;d<=o.length;d++)s[d]=d;for(let d=1;d<=e.length;d++){i[0]=d;for(let p=1;p<=o.length;p++)i[p]=Math.min(s[p]+1,i[p-1]+1,s[p-1]+(e[d-1]===o[p-1]?0:1));let l=s;s=i,i=l}return s[o.length]}function gs(e){return e.error?"err":e.status==null?" \u2026 ":String(e.status)}function yo(e){return e.externalError?`guest app errored: ${e.externalError}`:e.loadingText?`still showing "${e.loadingText}"`:e.externalReady===!1?"guest app is still loading":e.flag!==!0?"guest app has not emitted sootsim:externalAppReady":e.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}function ho(e){let o=ie(e.startTs),s=gs(e).padEnd(3),i=e.method.padEnd(5),d=ko(e.size).padStart(6),l=_o(e.durationMs);console.log(` [${o}] ${s} ${i} ${d} ${l} ${e.displayUrl}`),e.error&&console.log(` error: ${e.error}`)}function ys(e){let o=[["id",e.id],["source",e.source],["kind",e.kind],["method",e.method],["status",e.error?`error: ${e.error}`:`${e.status??"\u2014"} ${e.statusText??""}`.trim()],["url",e.url],["started",ie(e.startTs)],["duration",_o(e.durationMs).trim()],["size",ko(e.size)],["content-type",e.type??"\u2014"]];for(let[s,i]of o)console.log(` ${s.padEnd(13)} ${i}`)}var hs={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},bo="\x1B[0m",bs="\x1B[2m";function wo(e,o){let s=ie(e.ts),i=e.level.toUpperCase().padEnd(5),d=e.args.join(" ");if(o){let l=hs[e.level];console.log(` ${bs}[${s}]${bo} ${l}${i}${bo} ${d}`)}else console.log(` [${s}] ${i} ${d}`);if(e.stack&&e.level==="error"){let l=e.stack.split(`
523
- `).slice(0,5);for(let p of l)console.log(` ${p.trim()}`)}}var ws=120;async function $o(e,o){let s=e.find((N,M)=>e[M-1]==="--id"),i=e.find((N,M)=>e[M-1]==="--text");if(s||i){let N=await o.send({type:"evaluate",code:At({id:s,text:i})});if(!N)throw new Error(s?`no node with id "${s}"`:`no node matching text "${i}"`);let{x:M,y:j,w:O,h:c}=N;return{x:M,y:j,w:O,h:c}}let d=e.find((N,M)=>e[M-1]==="--area");if(d){let N=d.split(",").map(q=>Number(q.trim()));if(N.length!==4||N.some(q=>!Number.isFinite(q)))throw new Error(`--area expects x,y,w,h (got "${d}")`);let[M,j,O,c]=N;return{x:M,y:j,w:O,h:c}}let l=N=>{let M=e.find((O,c)=>e[c-1]===N);if(M==null)return null;let j=Number(M);return Number.isFinite(j)?j:null},p=l("--x"),y=l("--y"),f=l("--w"),_=l("--h");if(p!=null||y!=null||f!=null||_!=null)return{x:p??0,y:y??0,w:f??1,h:_??1};let S=e.filter((N,M)=>M>0&&!N.startsWith("-")&&e[M-1]!=="--output"&&e[M-1]!=="--area"&&e[M-1]!=="--id"&&e[M-1]!=="--text"&&e[M-1]!=="--x"&&e[M-1]!=="--y"&&e[M-1]!=="--w"&&e[M-1]!=="--h").map(Number).filter(N=>Number.isFinite(N));if(S.length>=2){let[N,M,j=1,O=1]=S;return{x:N,y:M,w:j,h:O}}return null}function xo(e){let o=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?",s=e.jank&&typeof e.jank=="object"?e.jank:null;if(console.log(` shell frame profile:
524
- `),s){let _=(Array.isArray(s.compositor)?s.compositor:[]).reduce((b,S)=>b+(S.jankPaints??0),0);console.log(` health: ${s.detected?"jank or cadence gaps observed":"no jank or cadence gaps observed"} \xB7 shell ${s.shell?.jankFrames??0} \xB7 compositor ${_} \xB7 host clock gaps ${s.hostGaps??0}`),console.log(" series: independent worker clocks, no per-frame pairing")}if(console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` shell work avg: ${e.avgMs}ms (${o} fps) \xB7 worst observed ${e.maxMs}ms`),console.log(` shell p50/95/99:${e.p50} / ${e.p95} / ${e.p99} ms`),s){console.log(` shell jank: ${s.shell?.jankFrames??0}/${s.shell?.sampledFrames??0} (${s.shell?.jankPct??0}%) >16.67ms \xB7 max ${s.shell?.maxMs??0}ms`);for(let f of Array.isArray(s.compositor)?s.compositor:[])console.log(` ${String(f.surfaceId).padEnd(12)} ${f.jankPaints}/${f.sampledPaints} compositor paints (${f.jankPct}%) >16.67ms \xB7 max ${f.maxMs}ms`)}else console.log(` jank: ${e.jankFrames} frames (${e.jankPct}%) >16.67ms`);console.log(` avg per frame: overlay ${e.avgOverlayMs}ms \xB7 aux ${e.avgAuxMs}ms \xB7 layout ${e.avgLayoutMs}ms`);let i=e.cadence;i&&typeof i=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${i.vsyncTicks} vsync ticks):`),console.log(` display clock: ${i.displayHz}hz \xB7 host rAF interval p50 ${i.hostIntervalP50} / p95 ${i.hostIntervalP95} / max ${i.hostIntervalMax} ms${i.hostGaps?` \xB7 ${i.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${i.deliveryLagP50} / p95 ${i.deliveryLagP95} / max ${i.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${i.paintIntervalP50} / p95 ${i.paintIntervalP95} / max ${i.paintIntervalMax} ms${i.idleBreaks?` \xB7 ${i.idleBreaks} idle breaks excluded`:""}`));let d=e.compositorCadence;d&&typeof d=="object"&&console.log(` compositor rAF: p50 ${d.p50} / p95 ${d.p95} / max ${d.max} ms \xB7 ${d.gaps} gaps >1.5x`);let l=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[];if(l.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let f of l)console.log(` ${String(f.surfaceId).padEnd(10)} ${String(f.frames).padStart(4)} paints avg ${f.avgMs}ms (layout ${f.avgLayoutMs}, render ${f.avgRenderMs}, flush ${f.avgFlushMs}) max ${f.maxMs}ms`),typeof f.gpuCacheBytes=="number"&&typeof f.gpuCacheLimitBytes=="number"&&console.log(` ${"".padEnd(10)} gpu cache ${(f.gpuCacheBytes/1024/1024).toFixed(1)}MB/${(f.gpuCacheLimitBytes/1024/1024).toFixed(1)}MB`)}let p=e.renderProfile;if(p&&typeof p=="object"){console.log(""),console.log(" render profile (per frame):"),console.log(` node visits: ${p.nodeVisitsPerFrame}`),console.log(` boundaries: ${p.recordsPerFrame} records (${p.avgBoundaryRecordMs}ms) / ${p.replaysPerFrame} replays`),console.log(` raster tier: ${p.rasterPromotionsPerFrame} promotions / ${p.rasterBlitsPerFrame} blits`);let f=[p.rasterRejectRebuild?`rebuild ${p.rasterRejectRebuild}`:"",p.rasterRejectLinear?`linear ${p.rasterRejectLinear}`:"",p.rasterRejectAnimated?`animated ${p.rasterRejectAnimated}`:"",p.rasterRejectTransform?`transform ${p.rasterRejectTransform}`:"",p.rasterRejectOpacity?`opacity ${p.rasterRejectOpacity}`:"",p.rasterRejectCacheable?`cacheable ${p.rasterRejectCacheable}`:"",p.rasterRejectBounds?`bounds ${p.rasterRejectBounds}`:"",p.rasterRejectPixels?`pixels ${p.rasterRejectPixels}`:"",p.rasterRejectBudget?`budget ${p.rasterRejectBudget}`:"",p.rasterWarming?`warming ${p.rasterWarming}`:""].filter(Boolean).join(" \xB7 ");f&&console.log(` raster skips: ${f} (total across run)`),console.log(` blur: ${p.avgBlurMs}ms`),console.log(` draw calls: text ${p.textDrawsPerFrame} \xB7 image ${p.imageDrawsPerFrame} \xB7 path ${p.pathDrawsPerFrame} \xB7 saveLayer ${p.saveLayersPerFrame}`)}let y=Array.isArray(e.worstFrames)?e.worstFrames:[];if(y.length>0){console.log(""),console.log(" worst observations (shell and compositor series are unpaired):");for(let f of y){if(f.source==="compositor"){console.log(` ${String(f.totalMs).padStart(7)}ms compositor ${f.surfaceId} paint ${f.paint} \xB7 layout ${f.layoutMs} \xB7 render ${f.renderMs} \xB7 flush ${f.flushMs}`);continue}let _=(f.auxSurfaces??[]).map(b=>`${b.surfaceId} ${b.totalMs}ms (layout ${b.layoutMs}, render ${b.renderMs})`).join(" \xB7 ");console.log(` ${String(f.totalMs).padStart(7)}ms overlay ${f.overlayMs} \xB7 aux ${f.auxMs} \xB7 layout ${f.layoutMs}${_?` [${_}]`:""}`)}}}async function Pe(e,o,s){let i=Date.now()+o,d=await de(e,o);for(;;){if(s(d))return{settled:!0,state:d};if(Date.now()>=i)return{settled:!1,state:d};await oe(16),d=await de(e)}}async function et(e){return e.send({type:"evaluate",code:`(async () => {
522
+ })()`});if(!Array.isArray(s)||s.length===0)return;let i=o.toLowerCase(),p=s.map(l=>({id:l,score:ms(i,l.toLowerCase())})).filter(l=>l.score<i.length+4).sort((l,d)=>l.score-d.score).slice(0,5);if(p.length===0)return;console.error(" similar testIDs:");for(let l of p)console.error(` ${l.id}`)}catch{}}function ms(e,o){if(o===e)return 0;if(o.includes(e))return 1;if(e.includes(o))return 2;let s=0;for(;s<e.length&&s<o.length&&e[s]===o[s];)s+=1;return fs(e,o)-s}function fs(e,o){if(e===o)return 0;if(!e.length)return o.length;if(!o.length)return e.length;let s=new Array(o.length+1),i=new Array(o.length+1);for(let p=0;p<=o.length;p++)s[p]=p;for(let p=1;p<=e.length;p++){i[0]=p;for(let d=1;d<=o.length;d++)i[d]=Math.min(s[d]+1,i[d-1]+1,s[d-1]+(e[p-1]===o[d-1]?0:1));let l=s;s=i,i=l}return s[o.length]}function gs(e){return e.error?"err":e.status==null?" \u2026 ":String(e.status)}function yo(e){return e.externalError?`guest app errored: ${e.externalError}`:e.loadingText?`still showing "${e.loadingText}"`:e.externalReady===!1?"guest app is still loading":e.flag!==!0?"guest app has not emitted sootsim:externalAppReady":e.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}function ho(e){let o=ie(e.startTs),s=gs(e).padEnd(3),i=e.method.padEnd(5),p=ko(e.size).padStart(6),l=_o(e.durationMs);console.log(` [${o}] ${s} ${i} ${p} ${l} ${e.displayUrl}`),e.error&&console.log(` error: ${e.error}`)}function ys(e){let o=[["id",e.id],["source",e.source],["kind",e.kind],["method",e.method],["status",e.error?`error: ${e.error}`:`${e.status??"\u2014"} ${e.statusText??""}`.trim()],["url",e.url],["started",ie(e.startTs)],["duration",_o(e.durationMs).trim()],["size",ko(e.size)],["content-type",e.type??"\u2014"]];for(let[s,i]of o)console.log(` ${s.padEnd(13)} ${i}`)}var hs={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},bo="\x1B[0m",bs="\x1B[2m";function wo(e,o){let s=ie(e.ts),i=e.level.toUpperCase().padEnd(5),p=e.args.join(" ");if(o){let l=hs[e.level];console.log(` ${bs}[${s}]${bo} ${l}${i}${bo} ${p}`)}else console.log(` [${s}] ${i} ${p}`);if(e.stack&&e.level==="error"){let l=e.stack.split(`
523
+ `).slice(0,5);for(let d of l)console.log(` ${d.trim()}`)}}var ws=120;async function $o(e,o){let s=e.find((N,M)=>e[M-1]==="--id"),i=e.find((N,M)=>e[M-1]==="--text");if(s||i){let N=await o.send({type:"evaluate",code:At({id:s,text:i})});if(!N)throw new Error(s?`no node with id "${s}"`:`no node matching text "${i}"`);let{x:M,y:j,w:O,h:c}=N;return{x:M,y:j,w:O,h:c}}let p=e.find((N,M)=>e[M-1]==="--area");if(p){let N=p.split(",").map(q=>Number(q.trim()));if(N.length!==4||N.some(q=>!Number.isFinite(q)))throw new Error(`--area expects x,y,w,h (got "${p}")`);let[M,j,O,c]=N;return{x:M,y:j,w:O,h:c}}let l=N=>{let M=e.find((O,c)=>e[c-1]===N);if(M==null)return null;let j=Number(M);return Number.isFinite(j)?j:null},d=l("--x"),h=l("--y"),f=l("--w"),k=l("--h");if(d!=null||h!=null||f!=null||k!=null)return{x:d??0,y:h??0,w:f??1,h:k??1};let S=e.filter((N,M)=>M>0&&!N.startsWith("-")&&e[M-1]!=="--output"&&e[M-1]!=="--area"&&e[M-1]!=="--id"&&e[M-1]!=="--text"&&e[M-1]!=="--x"&&e[M-1]!=="--y"&&e[M-1]!=="--w"&&e[M-1]!=="--h").map(Number).filter(N=>Number.isFinite(N));if(S.length>=2){let[N,M,j=1,O=1]=S;return{x:N,y:M,w:j,h:O}}return null}function xo(e){let o=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?",s=e.jank&&typeof e.jank=="object"?e.jank:null;if(console.log(` shell frame profile:
524
+ `),s){let k=(Array.isArray(s.compositor)?s.compositor:[]).reduce((b,S)=>b+(S.jankPaints??0),0);console.log(` health: ${s.detected?"jank or cadence gaps observed":"no jank or cadence gaps observed"} \xB7 shell ${s.shell?.jankFrames??0} \xB7 compositor ${k} \xB7 host clock gaps ${s.hostGaps??0}`),console.log(" series: independent worker clocks, no per-frame pairing")}if(console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` shell work avg: ${e.avgMs}ms (${o} fps) \xB7 worst observed ${e.maxMs}ms`),console.log(` shell p50/95/99:${e.p50} / ${e.p95} / ${e.p99} ms`),s){console.log(` shell jank: ${s.shell?.jankFrames??0}/${s.shell?.sampledFrames??0} (${s.shell?.jankPct??0}%) >16.67ms \xB7 max ${s.shell?.maxMs??0}ms`);for(let f of Array.isArray(s.compositor)?s.compositor:[])console.log(` ${String(f.surfaceId).padEnd(12)} ${f.jankPaints}/${f.sampledPaints} compositor paints (${f.jankPct}%) >16.67ms \xB7 max ${f.maxMs}ms`)}else console.log(` jank: ${e.jankFrames} frames (${e.jankPct}%) >16.67ms`);console.log(` avg per frame: overlay ${e.avgOverlayMs}ms \xB7 aux ${e.avgAuxMs}ms \xB7 layout ${e.avgLayoutMs}ms`);let i=e.cadence;i&&typeof i=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${i.vsyncTicks} vsync ticks):`),console.log(` display clock: ${i.displayHz}hz \xB7 host rAF interval p50 ${i.hostIntervalP50} / p95 ${i.hostIntervalP95} / max ${i.hostIntervalMax} ms${i.hostGaps?` \xB7 ${i.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${i.deliveryLagP50} / p95 ${i.deliveryLagP95} / max ${i.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${i.paintIntervalP50} / p95 ${i.paintIntervalP95} / max ${i.paintIntervalMax} ms${i.idleBreaks?` \xB7 ${i.idleBreaks} idle breaks excluded`:""}`));let p=e.compositorCadence;p&&typeof p=="object"&&console.log(` compositor rAF: p50 ${p.p50} / p95 ${p.p95} / max ${p.max} ms \xB7 ${p.gaps} gaps >1.5x`);let l=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[];if(l.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let f of l)console.log(` ${String(f.surfaceId).padEnd(10)} ${String(f.frames).padStart(4)} paints avg ${f.avgMs}ms (layout ${f.avgLayoutMs}, render ${f.avgRenderMs}, flush ${f.avgFlushMs}) max ${f.maxMs}ms`),typeof f.gpuCacheBytes=="number"&&typeof f.gpuCacheLimitBytes=="number"&&console.log(` ${"".padEnd(10)} gpu cache ${(f.gpuCacheBytes/1024/1024).toFixed(1)}MB/${(f.gpuCacheLimitBytes/1024/1024).toFixed(1)}MB`)}let d=e.renderProfile;if(d&&typeof d=="object"){console.log(""),console.log(" render profile (per frame):"),console.log(` node visits: ${d.nodeVisitsPerFrame}`),console.log(` boundaries: ${d.recordsPerFrame} records (${d.avgBoundaryRecordMs}ms) / ${d.replaysPerFrame} replays`),console.log(` raster tier: ${d.rasterPromotionsPerFrame} promotions / ${d.rasterBlitsPerFrame} blits`);let f=[d.rasterRejectRebuild?`rebuild ${d.rasterRejectRebuild}`:"",d.rasterRejectLinear?`linear ${d.rasterRejectLinear}`:"",d.rasterRejectAnimated?`animated ${d.rasterRejectAnimated}`:"",d.rasterRejectTransform?`transform ${d.rasterRejectTransform}`:"",d.rasterRejectOpacity?`opacity ${d.rasterRejectOpacity}`:"",d.rasterRejectCacheable?`cacheable ${d.rasterRejectCacheable}`:"",d.rasterRejectBounds?`bounds ${d.rasterRejectBounds}`:"",d.rasterRejectPixels?`pixels ${d.rasterRejectPixels}`:"",d.rasterRejectBudget?`budget ${d.rasterRejectBudget}`:"",d.rasterWarming?`warming ${d.rasterWarming}`:""].filter(Boolean).join(" \xB7 ");f&&console.log(` raster skips: ${f} (total across run)`),console.log(` blur: ${d.avgBlurMs}ms`),console.log(` draw calls: text ${d.textDrawsPerFrame} \xB7 image ${d.imageDrawsPerFrame} \xB7 path ${d.pathDrawsPerFrame} \xB7 saveLayer ${d.saveLayersPerFrame}`)}let h=Array.isArray(e.worstFrames)?e.worstFrames:[];if(h.length>0){console.log(""),console.log(" worst observations (shell and compositor series are unpaired):");for(let f of h){if(f.source==="compositor"){console.log(` ${String(f.totalMs).padStart(7)}ms compositor ${f.surfaceId} paint ${f.paint} \xB7 layout ${f.layoutMs} \xB7 render ${f.renderMs} \xB7 flush ${f.flushMs}`);continue}let k=(f.auxSurfaces??[]).map(b=>`${b.surfaceId} ${b.totalMs}ms (layout ${b.layoutMs}, render ${b.renderMs})`).join(" \xB7 ");console.log(` ${String(f.totalMs).padStart(7)}ms overlay ${f.overlayMs} \xB7 aux ${f.auxMs} \xB7 layout ${f.layoutMs}${k?` [${k}]`:""}`)}}}async function Pe(e,o,s){let i=Date.now()+o,p=await de(e,o);for(;;){if(s(p))return{settled:!0,state:p};if(Date.now()>=i)return{settled:!1,state:p};await oe(16),p=await de(e)}}async function et(e){return e.send({type:"evaluate",code:`(async () => {
525
525
  const kb = window.__sootsimKeyboard
526
526
  const test = window.__sootsimTest
527
527
  if (!kb) return { error: 'keyboard bridge not available' }
@@ -558,7 +558,7 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
558
558
  frame: runtimeSnapshot?.keyboard?.frame ?? null,
559
559
  focusedRect: runtimeSnapshot?.focused?.rect ?? null,
560
560
  }
561
- })()`}).then(o=>Qe(o))}function $s(e,o,s){if(!e.visible)return!1;let i=e.focusedInput;return!(o&&i&&!(i.testID===o||i.id===o)||s!==null&&we(e)!==s)}async function xs(e,o=600,s={}){let i=Date.now()+o;for(;Date.now()<=i;){let d=await et(e);if($s(d,s.targetId??null,s.secureTextEntry??null))return d;await oe(30)}return et(e)}async function Re(e,o){let s=await et(e);if(s.visible&&s.focusedInput)return s;s.visible&&(console.error(` ${o} requires a focused TextInput. the iOS keyboard is visible, but no input owns focus.`),process.exit(1)),console.error(` ${o} 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 So(e,o,s){return o==="appearance"?e.send({type:"evaluate",code:`(async () => {
561
+ })()`}).then(o=>Qe(o))}function $s(e,o,s){if(!e.visible)return!1;let i=e.focusedInput;return!(o&&i&&!(i.testID===o||i.id===o)||s!==null&&we(e)!==s)}async function xs(e,o=600,s={}){let i=Date.now()+o;for(;Date.now()<=i;){let p=await et(e);if($s(p,s.targetId??null,s.secureTextEntry??null))return p;await oe(30)}return et(e)}async function Re(e,o){let s=await et(e);if(s.visible&&s.focusedInput)return s;s.visible&&(console.error(` ${o} requires a focused TextInput. the iOS keyboard is visible, but no input owns focus.`),process.exit(1)),console.error(` ${o} 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 So(e,o,s){return o==="appearance"?e.send({type:"evaluate",code:`(async () => {
562
562
  const requested = ${JSON.stringify(s??"toggle")}
563
563
  // the engine owns toggle + auto resolution (settingsStore is the single
564
564
  // source of truth). never infer the current scheme client-side \u2014 the old
@@ -581,15 +581,15 @@ import{a as ce}from"./chunk-P5JIE7R6.js";import{b as Et,c as Pt,k as Rt}from"./c
581
581
  })()`}):e.send({type:"evaluate",code:`(async () => {
582
582
  window.dispatchEvent(new CustomEvent('sootsim:shake'))
583
583
  return { ok: true, action: 'shake' }
584
- })()`})}function Ss(e){let o={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(o[e])return o[e];let s=e.match(/^Digit([0-9])$/);if(s)return s[1];let i=e.match(/^Key([A-Z])$/);return i?i[1].toLowerCase():null}function vs(e){if(typeof e!="string")return null;let o=e.replace(/\s+/g," ").trim();return o?o.slice(0,80):null}function Io(...e){for(let o of e){if(typeof o!="string")continue;let s=o.trim();if(s)return s}return null}function ks(e){let o=e.indexOf("--node-id");if(o<0)return null;let s=e[o+1];if(!s)return null;let i=Number(s);return Number.isInteger(i)&&i>0?i:null}async function W(e,o,s){let i=Fe({source:e,step:o,summary:s});i.active&&(i.replaced?console.error(` draft: replaced unkept action "${i.replaced.summary}" \u2014 \`maestro keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `sootsim maestro keep` to commit"))}function vo(e,o,s){if(!s||s.hit===!1)return null;let i=Io(s.responderTestID,s.testID);if(i)return{step:{tapOn:{id:i}},summary:`tap #${i}`};let d=vs(s.text);return d?{step:{tapOn:d},summary:`tap "${d}"`}:{step:{tapAtCoords:{x:e,y:o}},summary:`tap @${Math.round(e)},${Math.round(o)}`}}function Ze(e,o,s){let i=Io(o?.testID,o?.id);return i?{step:{tapOn:{id:i}},summary:`tap #${i}`}:s==="id"?{step:{tapOn:{id:e}},summary:`tap #${e}`}:{step:{tapOn:e},summary:`tap "${e}"`}}async function Or(e,o){let s=e[0]==="get"||e[0]==="do"||e[0]==="debug"||e[0]==="wait"?e[0]:null,i=s?e.slice(1):e,d=_t(i,{port:o.port,commandTimeoutMs:o.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"]}),l=d.positional,p=l[0],y=s==="get"||s==="do"||s==="debug"||s==="wait"?s:"inspect",f=typeof i[0]=="string"&&tt.has(i[0]),_=f?i[0]:null,b=$=>o.internalPerfCommand&&$==="perf"?`sootsim perf ${o.internalPerfCommand}`:f&&$===i[0]?`sootsim ${$}`:`sootsim ${y} ${$}`,S=($,t)=>` usage: ${b($)}${t?` ${t}`:""}`;if(!p||e.includes("--help")||e.includes("-h")){let $={bridgePort:7668,defaultShellUrl:ot};if(y==="do"||y==="get"||y==="debug"||y==="wait"){let r=Ae(y,$);r&&(console.log(`${r}
585
- `),process.exit(0))}if(_==="shell"){let r=De("shell",$);r&&(console.log(`${r}
584
+ })()`})}function Ss(e){let o={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(o[e])return o[e];let s=e.match(/^Digit([0-9])$/);if(s)return s[1];let i=e.match(/^Key([A-Z])$/);return i?i[1].toLowerCase():null}function vs(e){if(typeof e!="string")return null;let o=e.replace(/\s+/g," ").trim();return o?o.slice(0,80):null}function Io(...e){for(let o of e){if(typeof o!="string")continue;let s=o.trim();if(s)return s}return null}function ks(e){let o=e.indexOf("--node-id");if(o<0)return null;let s=e[o+1];if(!s)return null;let i=Number(s);return Number.isInteger(i)&&i>0?i:null}async function W(e,o,s){let i=Fe({source:e,step:o,summary:s});i.active&&(i.replaced?console.error(` draft: replaced unkept action "${i.replaced.summary}" \u2014 \`maestro keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `sootsim maestro keep` to commit"))}function vo(e,o,s){if(!s||s.hit===!1)return null;let i=Io(s.responderTestID,s.testID);if(i)return{step:{tapOn:{id:i}},summary:`tap #${i}`};let p=vs(s.text);return p?{step:{tapOn:p},summary:`tap "${p}"`}:{step:{tapAtCoords:{x:e,y:o}},summary:`tap @${Math.round(e)},${Math.round(o)}`}}function Ze(e,o,s){let i=Io(o?.testID,o?.id);return i?{step:{tapOn:{id:i}},summary:`tap #${i}`}:s==="id"?{step:{tapOn:{id:e}},summary:`tap #${e}`}:{step:{tapOn:e},summary:`tap "${e}"`}}async function Or(e,o){let s=e[0]==="get"||e[0]==="do"||e[0]==="debug"||e[0]==="wait"?e[0]:null,i=s?e.slice(1):e,p=_t(i,{port:o.port,commandTimeoutMs:o.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"]}),l=p.positional,d=l[0],h=s==="get"||s==="do"||s==="debug"||s==="wait"?s:"inspect",f=typeof i[0]=="string"&&tt.has(i[0]),k=f?i[0]:null,b=$=>o.internalPerfCommand&&$==="perf"?`sootsim perf ${o.internalPerfCommand}`:f&&$===i[0]?`sootsim ${$}`:`sootsim ${h} ${$}`,S=($,t)=>` usage: ${b($)}${t?` ${t}`:""}`;if(!d||e.includes("--help")||e.includes("-h")){let $={bridgePort:7668,defaultShellUrl:ot};if(h==="do"||h==="get"||h==="debug"||h==="wait"){let r=Ae(h,$);r&&(console.log(`${r}
585
+ `),process.exit(0))}if(k==="shell"){let r=De("shell",$);r&&(console.log(`${r}
586
586
  `),process.exit(0))}let t=De("inspect",$),n=["do","get","debug","wait"].map(r=>Ae(r,$)).filter(r=>r!=null).join(`
587
587
 
588
588
  `);console.log(`${t??""}
589
589
 
590
590
  ${n}
591
- `),process.exit(0)}let N=d.wsPort,M=d.simId,j=d.simIdSource,O=d.commandTimeoutMs;if(y==="get"&&p==="diagnosis"){let $=i.indexOf("diagnosis"),t=$>=0?[...i.slice(0,$),...i.slice($+1)]:i,{runDiagnose:n}=await import("./diagnose-3KSX2NJC.js"),r=await n(["recent",...t],o);process.exitCode=r;return}if(y==="do"&&p==="scan"){let{runCamera:$}=await import("./camera-INMAD3CG.js");await $(i,{port:o.port});return}if(p==="list"&&i.some($=>$==="--drivers"||$==="-D")){let{buildDriverListRows:$}=await import("./drivers-SJOWPOA3.js"),t=$();console.log(` available drivers (${t.length}):
592
- `);let n=Math.max(...t.map(a=>a.id.length),6),r=Math.max(...t.map(a=>a.kind.length),4);for(let a of t){let u=a.available?"\u2713":"\u2717",m=a.id.padEnd(n),g=a.kind.padEnd(r);console.log(` ${u} ${m} ${g} ${a.description}`),a.available&&a.detail?console.log(` ${a.detail}`):!a.available&&a.reason&&console.log(` unavailable: ${a.reason}`)}return}let c=It(d),q=M||"default",R=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","storage-clear","list","wait","sleep"]),P=200;function K($){let t=$.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec($)?.[1]?.trim(),a=/<body[^>]*>([\s\S]*?)<\//i.exec($)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),u=r||a||"html error page";return`<html ${$.length}B> "${u}" (body elided \u2014 add --json for the full payload)`}return t.length<=P?t:`${t.slice(0,P)}\u2026 (+${t.length-P} more bytes)`}function U($){let t=$.displayUrl||$.url;return $.status!=null?`${$.method} ${t} -> ${$.status}${$.statusText?` ${$.statusText}`:""}`:$.error?`${$.method} ${t} -> ${$.error}`:`${$.method} ${t}`}async function k($){let t=me()?400:200;try{let{settled:n,elapsed:r}=await se({bridge:$,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.
591
+ `),process.exit(0)}let N=p.wsPort,M=p.simId,j=p.simIdSource,O=p.commandTimeoutMs;if(h==="get"&&d==="diagnosis"){let $=i.indexOf("diagnosis"),t=$>=0?[...i.slice(0,$),...i.slice($+1)]:i,{runDiagnose:n}=await import("./diagnose-GYKUU3N5.js"),r=await n(["recent",...t],o);process.exitCode=r;return}if(h==="do"&&d==="scan"){let{runCamera:$}=await import("./camera-O67TQUAH.js");await $(i,{port:o.port});return}if(d==="list"&&i.some($=>$==="--drivers"||$==="-D")){let{buildDriverListRows:$}=await import("./drivers-FHWFHVQF.js"),t=$();console.log(` available drivers (${t.length}):
592
+ `);let n=Math.max(...t.map(a=>a.id.length),6),r=Math.max(...t.map(a=>a.kind.length),4);for(let a of t){let u=a.available?"\u2713":"\u2717",m=a.id.padEnd(n),g=a.kind.padEnd(r);console.log(` ${u} ${m} ${g} ${a.description}`),a.available&&a.detail?console.log(` ${a.detail}`):!a.available&&a.reason&&console.log(` unavailable: ${a.reason}`)}return}let c=It(p),q=M||"default",R=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","storage-clear","list","wait","sleep"]),P=200;function K($){let t=$.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec($)?.[1]?.trim(),a=/<body[^>]*>([\s\S]*?)<\//i.exec($)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),u=r||a||"html error page";return`<html ${$.length}B> "${u}" (body elided \u2014 add --json for the full payload)`}return t.length<=P?t:`${t.slice(0,P)}\u2026 (+${t.length-P} more bytes)`}function U($){let t=$.displayUrl||$.url;return $.status!=null?`${$.method} ${t} -> ${$.status}${$.statusText?` ${$.statusText}`:""}`:$.error?`${$.method} ${t} -> ${$.error}`:`${$.method} ${t}`}async function _($){let t=me()?400:200;try{let{settled:n,elapsed:r}=await se({bridge:$,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.
593
593
  `)}catch{}}function F($,t){if(t.result?.reason==="offscreen"){let{x:n,y:r,screen:a}=t.result;console.error(` tap failed: ${$} resolved to (${Math.round(n)},${Math.round(r)}), outside the ${a?.width}x${a?.height} screen`),console.error(" the node exists but is scrolled out of view \u2014 scroll it on-screen first (sootsim do scroll / swipe), then tap.");return}console.error(` tap failed: ${$} 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 J(){try{return await c.send({type:"evaluate",code:`(() => ({
594
594
  console: ${_e},
595
595
  requests: window.__sootsimTest?.getRequestCounts?.() || null,
@@ -600,7 +600,7 @@ ${n}
600
600
  note: ${t.label} is open${n} \u2014 taps/drags hit it, not the app`)}}async function te($={}){let t=$.counts!==void 0?$.counts:await c.send({type:"evaluate",code:_e});if(!t||typeof t!="object")return;let n=t,r=Math.max(0,Number(n.errors)||0),a=Math.max(0,Number(n.warnings)||0);if(r===0&&a===0||!$.includeTail&&!Ye("console",q,`${r}:${a}`))return;let u=[];if(r>0&&u.push(`${r} console error${r===1?"":"s"}`),a>0&&u.push(`${a} console warning${a===1?"":"s"}`),console.log(`
601
601
  console: ${u.join(", ")}`),console.log(` inspect: ${b("errors")} 5`),a>0&&console.log(` inspect: ${b("warnings")} 5`),!$.includeTail||r===0)return;let m=await fe(c,5);if(!(!Array.isArray(m)||m.length===0)){console.log(`
602
602
  recent console errors:
603
- `);for(let g of m){let w=ie(g.timestamp),h=Array.isArray(g.args)?g.args.map(v=>typeof v=="object"?JSON.stringify(v):String(v)).join(" "):String(g);console.log(` [${w}] ${h}`)}}}let re=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function xe($){let t=st(),n=null;try{n=await Mt($,`(() => {
603
+ `);for(let g of m){let w=ie(g.timestamp),y=Array.isArray(g.args)?g.args.map(v=>typeof v=="object"?JSON.stringify(v):String(v)).join(" "):String(g);console.log(` [${w}] ${y}`)}}}let re=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function xe($){let t=st(),n=null;try{n=await Mt($,`(() => {
604
604
  const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
605
605
  if (!tl || typeof tl.summary !== 'function') return null
606
606
  const cursorKey = ${JSON.stringify(t)}
@@ -616,9 +616,9 @@ ${n}
616
616
  }
617
617
  }
618
618
  return summary ? { summary, consoleSplit } : null
619
- })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},a=[],u=new Set;for(let m of re){let g=r[m];if(g)if(u.add(m),m==="console"&&n.consoleSplit){let{error:w,warn:h}=n.consoleSplit;w>0&&a.push(`${w} error${w===1?"":"s"}`),h>0&&a.push(`${h} warning${h===1?"":"s"}`)}else a.push(`${g} ${m}${g===1?"":"s"}`)}for(let[m,g]of Object.entries(r))!u.has(m)&&g&&a.push(`${g} ${m}${g===1?"":"s"}`);if(a.length!==0&&(console.log(`
620
- since last: ${a.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await ge($,"SootSim.bridges.timeline.cursorAdvance",t,n.summary.lastAt)}catch{}}let C=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","storage-clear"]),le=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"]),Se=(e.includes("--verbose")||e.includes("-v"))&&!e.includes("--json");y==="do"&&p==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),C.has(p)&&await Tt(c),le.has(p)&&await ue(c,{verbose:Se});try{let $=C.has(p)&&!A(i)?await xt(c):[];switch(p){case"list":{kt(d.wsPort),await Zt({bridge:c,simId:M,args:i});break}case"tree":{await io({bridge:c,args:i,positional:l});break}case"a11y":{let t=await ut(c);if(!Array.isArray(t)||t.length===0){console.log(" no accessible nodes found");break}if(e.includes("--json"))console.log(JSON.stringify(t,null,2));else{console.log(` accessibility tree (${t.length} nodes):
621
- `);for(let n of t){let r=[];if(r.push(`[${n.role}]`),n.label){let a=n.label.length>50?n.label.slice(0,47)+"...":n.label;r.push(`"${a}"`)}if(n.hint&&r.push(`(hint: "${n.hint}")`),n.testID&&r.push(`#${n.testID}`),n.state){let a=[];n.state.disabled&&a.push("disabled"),n.state.selected&&a.push("selected"),n.state.checked===!0&&a.push("checked"),n.state.checked==="mixed"&&a.push("mixed"),n.state.busy&&a.push("busy"),n.state.expanded===!0&&a.push("expanded"),n.state.expanded===!1&&a.push("collapsed"),a.length&&r.push(`{${a.join(", ")}}`)}n.position&&r.push(`@(${n.position.x},${n.position.y})`),n.size&&r.push(`${n.size.w}x${n.size.h}`),console.log(" "+r.join(" "))}}break}case"find":{await Xt({bridge:c,args:e,effectiveArgs:i,positional:l,inspectUsage:S});break}case"count":{await Yt(c,{args:i});break}case"keyboard":{await Qt(c,{json:e.includes("--json")});break}case"screens":{await so(c,{json:e.includes("--json")});break}case"memory":{await oo(c,{args:i});break}case"wait":{await lo({wsPort:N,commandTimeoutMs:O,simId:M,simIdSource:j,positional:l});break}case"sleep":{await ro({positional:l,inspectUsage:S});break}case"settle":{await no({bridge:c,args:e,positional:l});break}case"ready":{await mo({bridge:c,args:e});break}case"idle":{await po({bridge:c,args:e,positional:l});break}case"selector":{await fo({bridge:c,args:e,positional:l,inspectUsage:S});break}case"event":{await uo({bridge:c,args:e,positional:l,inspectUsage:S});break}case"layout":{let t=l[1];if(!t){await Vt({bridge:c,args:i});break}let n=await c.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(t)}))()`});console.log(JSON.stringify(n,null,2));break}case"capture":case"screenshot":{let n=e.find((w,h)=>e[h-1]==="--output")||"/tmp/sootsim-inspect.png",r=await $o(e,c),a={type:"screenshot"};r&&(a.crop=r);let m=(await c.send(a)).replace(/^data:image\/png;base64,/,"");r&&console.log(` area: x=${r.x} y=${r.y} w=${r.w} h=${r.h}`),(await import("fs")).writeFileSync(n,Buffer.from(m,"base64")),console.log(` saved: ${n}`);break}case"sample-color":{let t=await $o(e,c);t||(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 n=await c.send({type:"evaluate",code:Dt(t)});if(e.includes("--json"))console.log(JSON.stringify(n,null,2));else{let{r,g:a,b:u,a:m,hex:g,samples:w}=n,h=t.w===1&&t.h===1?`@(${t.x},${t.y})`:`@(${t.x},${t.y}) ${t.w}x${t.h}`;console.log(` ${g} rgba(${r}, ${a}, ${u}, ${m}) ${h} ${w} samples`)}break}case"node":{let t=l[1];t||(console.error(S("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let n=await c.send({type:"evaluate",code:`(async () => {
619
+ })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},a=[],u=new Set;for(let m of re){let g=r[m];if(g)if(u.add(m),m==="console"&&n.consoleSplit){let{error:w,warn:y}=n.consoleSplit;w>0&&a.push(`${w} error${w===1?"":"s"}`),y>0&&a.push(`${y} warning${y===1?"":"s"}`)}else a.push(`${g} ${m}${g===1?"":"s"}`)}for(let[m,g]of Object.entries(r))!u.has(m)&&g&&a.push(`${g} ${m}${g===1?"":"s"}`);if(a.length!==0&&(console.log(`
620
+ since last: ${a.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await ge($,"SootSim.bridges.timeline.cursorAdvance",t,n.summary.lastAt)}catch{}}let C=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","storage-clear"]),le=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"]),Se=(e.includes("--verbose")||e.includes("-v"))&&!e.includes("--json");h==="do"&&d==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),C.has(d)&&await Tt(c),le.has(d)&&await ue(c,{verbose:Se});try{let $=C.has(d)&&!A(i)?await xt(c):[];switch(d){case"list":{kt(p.wsPort),await Zt({bridge:c,simId:M,args:i});break}case"tree":{await io({bridge:c,args:i,positional:l});break}case"a11y":{let t=await ut(c);if(!Array.isArray(t)||t.length===0){console.log(" no accessible nodes found");break}if(e.includes("--json"))console.log(JSON.stringify(t,null,2));else{console.log(` accessibility tree (${t.length} nodes):
621
+ `);for(let n of t){let r=[];if(r.push(`[${n.role}]`),n.label){let a=n.label.length>50?n.label.slice(0,47)+"...":n.label;r.push(`"${a}"`)}if(n.hint&&r.push(`(hint: "${n.hint}")`),n.testID&&r.push(`#${n.testID}`),n.state){let a=[];n.state.disabled&&a.push("disabled"),n.state.selected&&a.push("selected"),n.state.checked===!0&&a.push("checked"),n.state.checked==="mixed"&&a.push("mixed"),n.state.busy&&a.push("busy"),n.state.expanded===!0&&a.push("expanded"),n.state.expanded===!1&&a.push("collapsed"),a.length&&r.push(`{${a.join(", ")}}`)}n.position&&r.push(`@(${n.position.x},${n.position.y})`),n.size&&r.push(`${n.size.w}x${n.size.h}`),console.log(" "+r.join(" "))}}break}case"find":{await Xt({bridge:c,args:e,effectiveArgs:i,positional:l,inspectUsage:S});break}case"count":{await Yt(c,{args:i});break}case"keyboard":{await Qt(c,{json:e.includes("--json")});break}case"screens":{await so(c,{json:e.includes("--json")});break}case"memory":{await oo(c,{args:i});break}case"wait":{await lo({wsPort:N,commandTimeoutMs:O,simId:M,simIdSource:j,positional:l});break}case"sleep":{await ro({positional:l,inspectUsage:S});break}case"settle":{await no({bridge:c,args:e,positional:l});break}case"ready":{await mo({bridge:c,args:e});break}case"idle":{await po({bridge:c,args:e,positional:l});break}case"selector":{await fo({bridge:c,args:e,positional:l,inspectUsage:S});break}case"event":{await uo({bridge:c,args:e,positional:l,inspectUsage:S});break}case"layout":{let t=l[1];if(!t){await Vt({bridge:c,args:i});break}let n=await c.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(t)}))()`});console.log(JSON.stringify(n,null,2));break}case"capture":case"screenshot":{let n=e.find((w,y)=>e[y-1]==="--output")||"/tmp/sootsim-inspect.png",r=await $o(e,c),a={type:"screenshot"};r&&(a.crop=r);let m=(await c.send(a)).replace(/^data:image\/png;base64,/,"");r&&console.log(` area: x=${r.x} y=${r.y} w=${r.w} h=${r.h}`),(await import("fs")).writeFileSync(n,Buffer.from(m,"base64")),console.log(` saved: ${n}`);break}case"sample-color":{let t=await $o(e,c);t||(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 n=await c.send({type:"evaluate",code:Dt(t)});if(e.includes("--json"))console.log(JSON.stringify(n,null,2));else{let{r,g:a,b:u,a:m,hex:g,samples:w}=n,y=t.w===1&&t.h===1?`@(${t.x},${t.y})`:`@(${t.x},${t.y}) ${t.w}x${t.h}`;console.log(` ${g} rgba(${r}, ${a}, ${u}, ${m}) ${y} ${w} samples`)}break}case"node":{let t=l[1];t||(console.error(S("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let n=await c.send({type:"evaluate",code:`(async () => {
622
622
  const t = window.__sootsimTest
623
623
  const q = ${JSON.stringify(t)}
624
624
  let node = null
@@ -674,17 +674,17 @@ ${n}
674
674
  transform,
675
675
  parentChain,
676
676
  }
677
- })()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let t=Number(l[1]),n=Number(l[2]),r=$e(e);if(r){let m=await be(c,{agent:me(),textFallback:r.mode==="text"?r.value:void 0,resolve:async()=>{let h=await Oe(c,r);return h?{cx:h.x,cy:h.y,match:{id:r.mode==="testid"?r.value:h.id??null,testID:r.mode==="testid"?r.value:h.testID??null,text:r.mode==="text"?r.value:h.text??null,type:h.type??null},target:{id:h.id??null,testID:h.testID??null,text:h.text??null,type:h.type??null}}:null}}),g=m.payload;(!g||typeof g.cx!="number")&&(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),pe(m.result)||(F(`${r.mode} "${r.value}"`,m),process.exit(1));let w=vo(g.cx,g.cy,m.result);w&&await W("inspect tap",w.step,w.summary),console.log(JSON.stringify({...m.attempts>1?{attempts:m.attempts}:{},...m.result},null,2));break}(!Number.isFinite(t)||!Number.isFinite(n))&&(console.error(S("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let a=await Ht(c,t,n),u=vo(t,n,a);u&&await W("inspect tap",u.step,u.summary),console.log(JSON.stringify(a,null,2));break}case"drag":case"swipe":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),a=Number(l[4]),u=p==="swipe"?10:12,m=p==="swipe"?8:16,g=l[5]?Number(l[5]):u,w=l[6]?Number(l[6]):m;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(g)||!Number.isFinite(w))&&(console.error(S(p,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let h=await c.send({type:"evaluate",code:`(async () => {
677
+ })()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let t=Number(l[1]),n=Number(l[2]),r=$e(e);if(r){let m=await be(c,{agent:me(),textFallback:r.mode==="text"?r.value:void 0,resolve:async()=>{let y=await Oe(c,r);return y?{cx:y.x,cy:y.y,match:{id:r.mode==="testid"?r.value:y.id??null,testID:r.mode==="testid"?r.value:y.testID??null,text:r.mode==="text"?r.value:y.text??null,type:y.type??null},target:{id:y.id??null,testID:y.testID??null,text:y.text??null,type:y.type??null}}:null}}),g=m.payload;(!g||typeof g.cx!="number")&&(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),pe(m.result)||(F(`${r.mode} "${r.value}"`,m),process.exit(1));let w=vo(g.cx,g.cy,m.result);w&&await W("inspect tap",w.step,w.summary),console.log(JSON.stringify({...m.attempts>1?{attempts:m.attempts}:{},...m.result},null,2));break}(!Number.isFinite(t)||!Number.isFinite(n))&&(console.error(S("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let a=await Ht(c,t,n),u=vo(t,n,a);u&&await W("inspect tap",u.step,u.summary),console.log(JSON.stringify(a,null,2));break}case"drag":case"swipe":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),a=Number(l[4]),u=d==="swipe"?10:12,m=d==="swipe"?8:16,g=l[5]?Number(l[5]):u,w=l[6]?Number(l[6]):m;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(g)||!Number.isFinite(w))&&(console.error(S(d,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let y=await c.send({type:"evaluate",code:`(async () => {
678
678
  const interact = window.__sootsimInteract
679
679
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
680
680
  const value = await interact.drag(${t}, ${n}, ${r}, ${a}, ${Math.max(1,Math.round(g))}, ${Math.max(0,Math.round(w))})
681
681
  return { ok: !!value, value }
682
- })()`});if(h?.ok){let v=Math.max(1,Math.round(Math.max(1,g)*Math.max(0,w)));await W(`inspect ${p}`,{swipe:{start:`${t}, ${n}`,end:`${r}, ${a}`,duration:v}},`${p} ${t},${n} -> ${r},${a}`)}console.log(JSON.stringify(h,null,2));break}case"pinch":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),a=Number(l[4]),u=Number(l[5]),m=Number(l[6]),g=Number(l[7]),w=Number(l[8]),h=l[9]?Number(l[9]):12,v=l[10]?Number(l[10]):16;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(u)||!Number.isFinite(m)||!Number.isFinite(g)||!Number.isFinite(w)||!Number.isFinite(h)||!Number.isFinite(v))&&(console.error(S("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let L=await c.send({type:"evaluate",code:`(async () => {
682
+ })()`});if(y?.ok){let v=Math.max(1,Math.round(Math.max(1,g)*Math.max(0,w)));await W(`inspect ${d}`,{swipe:{start:`${t}, ${n}`,end:`${r}, ${a}`,duration:v}},`${d} ${t},${n} -> ${r},${a}`)}console.log(JSON.stringify(y,null,2));break}case"pinch":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),a=Number(l[4]),u=Number(l[5]),m=Number(l[6]),g=Number(l[7]),w=Number(l[8]),y=l[9]?Number(l[9]):12,v=l[10]?Number(l[10]):16;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(u)||!Number.isFinite(m)||!Number.isFinite(g)||!Number.isFinite(w)||!Number.isFinite(y)||!Number.isFinite(v))&&(console.error(S("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let L=await c.send({type:"evaluate",code:`(async () => {
683
683
  const interact = window.__sootsimInteract
684
684
  if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
685
- const value = await interact.pinch(${t}, ${n}, ${r}, ${a}, ${u}, ${m}, ${g}, ${w}, ${Math.max(1,Math.round(h))}, ${Math.max(0,Math.round(v))})
685
+ const value = await interact.pinch(${t}, ${n}, ${r}, ${a}, ${u}, ${m}, ${g}, ${w}, ${Math.max(1,Math.round(y))}, ${Math.max(0,Math.round(v))})
686
686
  return { ok: !!value, value }
687
- })()`});L?.ok&&await W("inspect pinch",{pinch:{from:[t,n,r,a],to:[u,m,g,w],steps:Math.max(1,Math.round(h)),stepMs:Math.max(0,Math.round(v))}},`pinch (${t},${n}) (${r},${a}) -> (${u},${m}) (${g},${w})`),console.log(JSON.stringify(L,null,2));break}case"tap-text":{let t=l[1];t||(console.error(S("tap-text","<text>")),process.exit(1));let n=z=>{let B=e.indexOf(z);return B>=0&&B+1<e.length?e[B+1]:null},r=z=>e.includes(z),a=n("--nth")??n("--index"),u=a!==null?Number(a):null;u!==null&&!Number.isFinite(u)&&(console.error(` --nth/--index requires an integer, got: ${a}`),process.exit(1));let m=n("--within"),g=n("--role"),w=r("--exact"),h=r("--first"),v=n("--min-y"),L=n("--max-y"),V=n("--min-x"),G=n("--max-x");for(let[z,B]of[["--min-y",v],["--max-y",L],["--min-x",V],["--max-x",G]])B!==null&&!Number.isFinite(Number(B))&&(console.error(` ${z} requires a number, got: ${B}`),process.exit(1));let Y=e.indexOf("--near"),E=null;if(Y>=0){let z=Number(e[Y+1]),B=Number(e[Y+2]);(!Number.isFinite(z)||!Number.isFinite(B))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),E={x:z,y:B}}let x={exact:w,role:g,within:m,minX:V!==null?Number(V):null,maxX:G!==null?Number(G):null,minY:v!==null?Number(v):null,maxY:L!==null?Number(L):null,near:E,nth:u,first:h},I=await Ut(c,t,x,{agent:me()}),T=I.payload;if(T?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),T?.ambiguous){let z=T.candidates;console.error(` ambiguous: ${T.total} matches for "${t}"`);for(let B of z){let ve=B.abs?`@(${Math.round(B.abs.x)},${Math.round(B.abs.y)})`:"",To=B.layout?` ${B.layout.width}x${B.layout.height}`:"",Mo=B.testID?` #${B.testID}`:"",No=B.text?` "${B.text}"`:"",Fo=B.ancestorTestIDs.length>0?` within ${B.ancestorTestIDs.slice(0,3).map(Oo=>`#${Oo}`).join(" > ")}`:"";console.error(` [${B.idx}] <${B.type}>${No}${Mo} ${ve}${To}${Fo}`)}T.total>z.length&&console.error(` ... and ${T.total-z.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)}T?.nthOutOfRange&&(console.error(` not found: nth ${T.nth} of ${T.total} match${T.total===1?"":"es"} for "${t}"`),process.exit(1)),(!T||typeof T.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),pe(I.result)||(F(`text "${t}"`,I),process.exit(1));let ne=Ze(t,{id:T.target?.id??null,testID:T.target?.testID??null,type:T.target?.type??null,cx:T.cx,cy:T.cy},"text");await W("inspect tap-text",ne.step,ne.summary),console.log(JSON.stringify({matched:T.match,tapped:{nodeId:T.target?.nodeId??null,id:T.target?.id??null,testID:T.target?.testID??null,type:T.target?.type??null,cx:T.cx,cy:T.cy},...T.strategy&&T.strategy!=="matched-node"?{strategy:T.strategy}:{},...T.total>1||u!==null?{nth:{index:T.idx,total:T.total}}:{},...I.attempts>1?{attempts:I.attempts}:{},result:I.result},null,2));break}case"tap-best":{let t=l[1];t||(console.error(S("tap-best","<query>")),process.exit(1));let n=await Gt(c,t,{agent:me()}),r=n.payload;r||(console.error(` tap-best: no testID or visible text matched "${t}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1)),"error"in r&&(console.error(` ${r.error}`),process.exit(1)),r.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${t}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1));let a=r.node;pe(n.result)||(F(`best "${t}"`,n),process.exit(1));let u=Ze(t,{id:a.id,testID:a.testID,type:a.type,cx:r.cx,cy:r.cy},r.strategy==="testid"?"id":"text");await W("inspect tap-best",u.step,u.summary),console.log(JSON.stringify({matched:{strategy:r.strategy,nodeId:a.nodeId,id:a.id,testID:a.testID,type:a.type,text:a.text},tapped:{cx:r.cx,cy:r.cy},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"tap-id":{let t=l[1];t||(console.error(S("tap-id","<id>")),process.exit(1));let n=await Kt(c,t,{agent:me()}),r=n.payload;(!r||typeof r.cx!="number")&&(console.error(` not found: ${t}`),await ps(c,t),process.exit(1)),pe(n.result)||(F(`id "${t}"`,n),process.exit(1));let a=Ze(t,{id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},"id");await W("inspect tap-id",a.step,a.summary),console.log(JSON.stringify({matched:r.match,tapped:{nodeId:r.target?.nodeId??null,id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},...r.strategy&&r.strategy!=="matched-node"?{strategy:r.strategy}:{},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"type-into":{let t=l[1],n=l.slice(2).join(" ");(!t||!n)&&(console.error(S("type-into","<id> <text>")),process.exit(1));let r=JSON.stringify(t),a=await c.send({type:"evaluate",code:`(async () => {
687
+ })()`});L?.ok&&await W("inspect pinch",{pinch:{from:[t,n,r,a],to:[u,m,g,w],steps:Math.max(1,Math.round(y)),stepMs:Math.max(0,Math.round(v))}},`pinch (${t},${n}) (${r},${a}) -> (${u},${m}) (${g},${w})`),console.log(JSON.stringify(L,null,2));break}case"tap-text":{let t=l[1];t||(console.error(S("tap-text","<text>")),process.exit(1));let n=z=>{let B=e.indexOf(z);return B>=0&&B+1<e.length?e[B+1]:null},r=z=>e.includes(z),a=n("--nth")??n("--index"),u=a!==null?Number(a):null;u!==null&&!Number.isFinite(u)&&(console.error(` --nth/--index requires an integer, got: ${a}`),process.exit(1));let m=n("--within"),g=n("--role"),w=r("--exact"),y=r("--first"),v=n("--min-y"),L=n("--max-y"),V=n("--min-x"),G=n("--max-x");for(let[z,B]of[["--min-y",v],["--max-y",L],["--min-x",V],["--max-x",G]])B!==null&&!Number.isFinite(Number(B))&&(console.error(` ${z} requires a number, got: ${B}`),process.exit(1));let Y=e.indexOf("--near"),E=null;if(Y>=0){let z=Number(e[Y+1]),B=Number(e[Y+2]);(!Number.isFinite(z)||!Number.isFinite(B))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),E={x:z,y:B}}let x={exact:w,role:g,within:m,minX:V!==null?Number(V):null,maxX:G!==null?Number(G):null,minY:v!==null?Number(v):null,maxY:L!==null?Number(L):null,near:E,nth:u,first:y},I=await Ut(c,t,x,{agent:me()}),T=I.payload;if(T?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),T?.ambiguous){let z=T.candidates;console.error(` ambiguous: ${T.total} matches for "${t}"`);for(let B of z){let ve=B.abs?`@(${Math.round(B.abs.x)},${Math.round(B.abs.y)})`:"",To=B.layout?` ${B.layout.width}x${B.layout.height}`:"",Mo=B.testID?` #${B.testID}`:"",No=B.text?` "${B.text}"`:"",Fo=B.ancestorTestIDs.length>0?` within ${B.ancestorTestIDs.slice(0,3).map(Oo=>`#${Oo}`).join(" > ")}`:"";console.error(` [${B.idx}] <${B.type}>${No}${Mo} ${ve}${To}${Fo}`)}T.total>z.length&&console.error(` ... and ${T.total-z.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)}T?.nthOutOfRange&&(console.error(` not found: nth ${T.nth} of ${T.total} match${T.total===1?"":"es"} for "${t}"`),process.exit(1)),(!T||typeof T.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),pe(I.result)||(F(`text "${t}"`,I),process.exit(1));let ne=Ze(t,{id:T.target?.id??null,testID:T.target?.testID??null,type:T.target?.type??null,cx:T.cx,cy:T.cy},"text");await W("inspect tap-text",ne.step,ne.summary),console.log(JSON.stringify({matched:T.match,tapped:{nodeId:T.target?.nodeId??null,id:T.target?.id??null,testID:T.target?.testID??null,type:T.target?.type??null,cx:T.cx,cy:T.cy},...T.strategy&&T.strategy!=="matched-node"?{strategy:T.strategy}:{},...T.total>1||u!==null?{nth:{index:T.idx,total:T.total}}:{},...I.attempts>1?{attempts:I.attempts}:{},result:I.result},null,2));break}case"tap-best":{let t=l[1];t||(console.error(S("tap-best","<query>")),process.exit(1));let n=await Gt(c,t,{agent:me()}),r=n.payload;r||(console.error(` tap-best: no testID or visible text matched "${t}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1)),"error"in r&&(console.error(` ${r.error}`),process.exit(1)),r.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${t}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1));let a=r.node;pe(n.result)||(F(`best "${t}"`,n),process.exit(1));let u=Ze(t,{id:a.id,testID:a.testID,type:a.type,cx:r.cx,cy:r.cy},r.strategy==="testid"?"id":"text");await W("inspect tap-best",u.step,u.summary),console.log(JSON.stringify({matched:{strategy:r.strategy,nodeId:a.nodeId,id:a.id,testID:a.testID,type:a.type,text:a.text},tapped:{cx:r.cx,cy:r.cy},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"tap-id":{let t=l[1];t||(console.error(S("tap-id","<id>")),process.exit(1));let n=await Kt(c,t,{agent:me()}),r=n.payload;(!r||typeof r.cx!="number")&&(console.error(` not found: ${t}`),await ps(c,t),process.exit(1)),pe(n.result)||(F(`id "${t}"`,n),process.exit(1));let a=Ze(t,{id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},"id");await W("inspect tap-id",a.step,a.summary),console.log(JSON.stringify({matched:r.match,tapped:{nodeId:r.target?.nodeId??null,id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},...r.strategy&&r.strategy!=="matched-node"?{strategy:r.strategy}:{},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"type-into":{let t=l[1],n=l.slice(2).join(" ");(!t||!n)&&(console.error(S("type-into","<id> <text>")),process.exit(1));let r=JSON.stringify(t),a=await c.send({type:"evaluate",code:`(async () => {
688
688
  const t = window.__sootsimTest
689
689
  if (!t) return null
690
690
  const n = await (t.findByTestId(${r}) || t.findById(${r}))
@@ -699,7 +699,7 @@ ${n}
699
699
  secureTextEntry: !!n.secureTextEntry,
700
700
  placeholder: n.placeholder || null,
701
701
  }
702
- })()`});(!a||typeof a.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),a.isTextInput||console.error(` warning: ${t} is not a text input (isTextInput: false)`);let u=await c.send({type:"tap",x:a.cx,y:a.cy,target:{id:a.id??t,testID:a.testID??t,text:null,type:a.type??null}}),m=a.secureTextEntry===!0,g=await xs(c,1e3,{targetId:t,secureTextEntry:m});g.visible||(console.error(` keyboard did not open after tapping ${t}`),process.exit(1));let w=g.focusedInput;w&&(w.testID===t||w.id===t||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(t)} but focus is on ${JSON.stringify(w.testID??w.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await c.send({type:"keyboard",action:"type",text:n});let h=m||we(g),v=h?Z:Ve(n,g),L=h&&g.focusedInput?{...g.focusedInput,secureTextEntry:!0,text:typeof g.focusedInput.text=="string"?Z:g.focusedInput.text}:g.focusedInput??null;await W("inspect type-into",{tapOn:{id:t},inputText:v},v===Z?`type-into #${t} ${Z}`:`type-into #${t} ${JSON.stringify(n)}`),console.log(JSON.stringify({target:t,isTextInput:a.isTextInput,secureTextEntry:h,keyboardOpened:g.visible??u?.keyboardOpened??!1,focusedInput:L,typed:v},null,2));break}case"type":{let t=l.slice(1).join(" ");t||(console.error(S("type","<text>")),process.exit(1));let n=await Re(c,"type");await c.send({type:"keyboard",action:"type",text:t});let r=Ve(t,n);await W("inspect type",{inputText:r},r===Z?`type ${Z}`:`type ${JSON.stringify(t)}`),console.log(r===Z?` typed: ${Z}`:` typed: ${JSON.stringify(t)}`);break}case"key":{let t=l[1];t||(console.error(S("key","<name>")),process.exit(1)),await Re(c,"key"),await c.send({type:"keyboard",action:"press",text:t}),await W("inspect key",{pressKey:t},`key ${t}`),console.log(` pressed: ${t}`);break}case"key-sequence":{let t=l.slice(1);t.length===0&&(console.error(S("key-sequence","<key> [<key> ...]")),process.exit(1)),await Re(c,"key-sequence");for(let n of t)await c.send({type:"keyboard",action:"press",text:n});await W("inspect key-sequence",{pressKey:t.join(" ")},`key-sequence ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"keycode":{let t=l.slice(1);t.length===0&&(console.error(S("keycode","<code> [<code> ...]")),process.exit(1));let n=t.map(a=>({code:a,key:Ss(a)})),r=n.filter(a=>!a.key);r.length>0&&(console.error(` unsupported keycode(s): ${r.map(a=>a.code).join(", ")}`),process.exit(1)),await Re(c,"keycode");for(let a of n)await c.send({type:"keyboard",action:"press",text:a.key});await W("inspect keycode",{pressKey:n.map(a=>a.key).join(" ")},`keycode ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"dispatch":{let t=l[1];t||(console.error(S("dispatch","<char>")),process.exit(1)),await c.send({type:"keyboard",action:"dispatchKey",text:t}),await W("inspect dispatch",{dispatchKey:t},`dispatch ${JSON.stringify(t)}`),console.log(` dispatched: ${t}`);break}case"dismiss":{await c.send({type:"keyboard",action:"dismiss"}),await W("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let t=Number(l[1]),n=Number(l[2]),r=$e(e);if(r){let g=await Oe(c,r);g||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=g.x,n=g.y}let a=l[3]?Number(l[3]):80;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(a))&&(console.error(S("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let u=Math.max(0,Math.round(a)),m=await c.send({type:"evaluate",code:`(async () => {
702
+ })()`});(!a||typeof a.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),a.isTextInput||console.error(` warning: ${t} is not a text input (isTextInput: false)`);let u=await c.send({type:"tap",x:a.cx,y:a.cy,target:{id:a.id??t,testID:a.testID??t,text:null,type:a.type??null}}),m=a.secureTextEntry===!0,g=await xs(c,1e3,{targetId:t,secureTextEntry:m});g.visible||(console.error(` keyboard did not open after tapping ${t}`),process.exit(1));let w=g.focusedInput;w&&(w.testID===t||w.id===t||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(t)} but focus is on ${JSON.stringify(w.testID??w.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await c.send({type:"keyboard",action:"type",text:n});let y=m||we(g),v=y?Z:Ve(n,g),L=y&&g.focusedInput?{...g.focusedInput,secureTextEntry:!0,text:typeof g.focusedInput.text=="string"?Z:g.focusedInput.text}:g.focusedInput??null;await W("inspect type-into",{tapOn:{id:t},inputText:v},v===Z?`type-into #${t} ${Z}`:`type-into #${t} ${JSON.stringify(n)}`),console.log(JSON.stringify({target:t,isTextInput:a.isTextInput,secureTextEntry:y,keyboardOpened:g.visible??u?.keyboardOpened??!1,focusedInput:L,typed:v},null,2));break}case"type":{let t=l.slice(1).join(" ");t||(console.error(S("type","<text>")),process.exit(1));let n=await Re(c,"type");await c.send({type:"keyboard",action:"type",text:t});let r=Ve(t,n);await W("inspect type",{inputText:r},r===Z?`type ${Z}`:`type ${JSON.stringify(t)}`),console.log(r===Z?` typed: ${Z}`:` typed: ${JSON.stringify(t)}`);break}case"key":{let t=l[1];t||(console.error(S("key","<name>")),process.exit(1)),await Re(c,"key"),await c.send({type:"keyboard",action:"press",text:t}),await W("inspect key",{pressKey:t},`key ${t}`),console.log(` pressed: ${t}`);break}case"key-sequence":{let t=l.slice(1);t.length===0&&(console.error(S("key-sequence","<key> [<key> ...]")),process.exit(1)),await Re(c,"key-sequence");for(let n of t)await c.send({type:"keyboard",action:"press",text:n});await W("inspect key-sequence",{pressKey:t.join(" ")},`key-sequence ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"keycode":{let t=l.slice(1);t.length===0&&(console.error(S("keycode","<code> [<code> ...]")),process.exit(1));let n=t.map(a=>({code:a,key:Ss(a)})),r=n.filter(a=>!a.key);r.length>0&&(console.error(` unsupported keycode(s): ${r.map(a=>a.code).join(", ")}`),process.exit(1)),await Re(c,"keycode");for(let a of n)await c.send({type:"keyboard",action:"press",text:a.key});await W("inspect keycode",{pressKey:n.map(a=>a.key).join(" ")},`keycode ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"dispatch":{let t=l[1];t||(console.error(S("dispatch","<char>")),process.exit(1)),await c.send({type:"keyboard",action:"dispatchKey",text:t}),await W("inspect dispatch",{dispatchKey:t},`dispatch ${JSON.stringify(t)}`),console.log(` dispatched: ${t}`);break}case"dismiss":{await c.send({type:"keyboard",action:"dismiss"}),await W("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let t=Number(l[1]),n=Number(l[2]),r=$e(e);if(r){let g=await Oe(c,r);g||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=g.x,n=g.y}let a=l[3]?Number(l[3]):80;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(a))&&(console.error(S("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let u=Math.max(0,Math.round(a)),m=await c.send({type:"evaluate",code:`(async () => {
703
703
  const interact = window.__sootsimInteract
704
704
  if (interact?.doubleTap) {
705
705
  return {
@@ -722,7 +722,7 @@ ${n}
722
722
  first,
723
723
  second,
724
724
  }
725
- })()`});m?.ok&&await W("inspect double-tap",{doubleTapAtCoords:{x:t,y:n,gapMs:u}},`double-tap @${t},${n}`),console.log(JSON.stringify(m,null,2));break}case"long-press":{let t=Number(l[1]),n=Number(l[2]),r=$e(e),a=null;if(r){let h=await Oe(c,r);h||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=h.x,n=h.y,a={id:h.id??null,testID:h.testID??null,text:h.text??null,type:h.type??null}}let u=r?l[1]:l[3],m=u?Number(u):600;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(m))&&(console.error(S("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let g=Math.max(0,Math.round(m)),w=await c.send({type:"longPress",x:t,y:n,durationMs:g,target:a});w?.ok&&await W("inspect long-press",{tapAtCoords:{x:t,y:n}},`long-press @${t},${n}`),console.log(JSON.stringify(w,null,2));break}case"touch":{let t=l[1],n=Number(l[2]),r=Number(l[3]),a=l[4]?Number(l[4]):999,u=t==="down"?"touchDown":t==="move"?"touchMove":t==="up"?"touchUp":t==="cancel"?"touchCancel":null;u||(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),t!=="cancel"&&(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let m=t==="down"?"tap":t==="move"?"move":null,g=m&&Number.isFinite(n)&&Number.isFinite(r)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${m}', x: ${n}, y: ${r} } }));`:"",w=await c.send({type:"evaluate",code:`(async () => {
725
+ })()`});m?.ok&&await W("inspect double-tap",{doubleTapAtCoords:{x:t,y:n,gapMs:u}},`double-tap @${t},${n}`),console.log(JSON.stringify(m,null,2));break}case"long-press":{let t=Number(l[1]),n=Number(l[2]),r=$e(e),a=null;if(r){let y=await Oe(c,r);y||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=y.x,n=y.y,a={id:y.id??null,testID:y.testID??null,text:y.text??null,type:y.type??null}}let u=r?l[1]:l[3],m=u?Number(u):600;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(m))&&(console.error(S("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let g=Math.max(0,Math.round(m)),w=await c.send({type:"longPress",x:t,y:n,durationMs:g,target:a});w?.ok&&await W("inspect long-press",{tapAtCoords:{x:t,y:n}},`long-press @${t},${n}`),console.log(JSON.stringify(w,null,2));break}case"touch":{let t=l[1],n=Number(l[2]),r=Number(l[3]),a=l[4]?Number(l[4]):999,u=t==="down"?"touchDown":t==="move"?"touchMove":t==="up"?"touchUp":t==="cancel"?"touchCancel":null;u||(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),t!=="cancel"&&(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(S("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let m=t==="down"?"tap":t==="move"?"move":null,g=m&&Number.isFinite(n)&&Number.isFinite(r)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${m}', x: ${n}, y: ${r} } }));`:"",w=await c.send({type:"evaluate",code:`(async () => {
726
726
  ${g}
727
727
  const interact = window.__sootsimInteract
728
728
  if (!interact?.${u}) return { ok: false, reason: 'no interact.${u}' }
@@ -736,7 +736,7 @@ ${n}
736
736
  statusBarHeight: spec.statusBarHeight || 0,
737
737
  homeIndicatorHeight: spec.homeIndicatorHeight || 0,
738
738
  }
739
- })()`}),u=Number(a?.width)||393,m=Number(a?.height)||852,g=Number(a?.statusBarHeight)||0,w=Number(a?.homeIndicatorHeight)||0,h=Math.round(u/2),v=Math.round(m/2),L=Math.max(24,g+18),V=Math.max(24,w+18),G=18,Y=Math.min(220,Math.round(m*.24)),E=Math.min(180,Math.round(u*.32)),x=h,I=v,T=h,ne=v;switch(n){case"scroll-up":I=v+Math.round(Y/2),ne=v-Math.round(Y/2);break;case"scroll-down":I=v-Math.round(Y/2),ne=v+Math.round(Y/2);break;case"scroll-left":x=h+Math.round(E/2),T=h-Math.round(E/2);break;case"scroll-right":x=h-Math.round(E/2),T=h+Math.round(E/2);break;case"swipe-from-left-edge":x=G,I=v,T=Math.min(u-G,G+E);break;case"swipe-from-right-edge":x=u-G,I=v,T=Math.max(G,u-G-E);break;case"swipe-from-top-edge":x=h,I=L,ne=Math.min(m-V,L+Y);break;case"swipe-from-bottom-edge":x=h,I=m-V,ne=Math.max(L,m-V-Y);break}let z=Math.max(8,Math.round(r/16)),B=Math.max(1,Math.round(r/z)),ve=await c.send({type:"evaluate",code:`(async () => {
739
+ })()`}),u=Number(a?.width)||393,m=Number(a?.height)||852,g=Number(a?.statusBarHeight)||0,w=Number(a?.homeIndicatorHeight)||0,y=Math.round(u/2),v=Math.round(m/2),L=Math.max(24,g+18),V=Math.max(24,w+18),G=18,Y=Math.min(220,Math.round(m*.24)),E=Math.min(180,Math.round(u*.32)),x=y,I=v,T=y,ne=v;switch(n){case"scroll-up":I=v+Math.round(Y/2),ne=v-Math.round(Y/2);break;case"scroll-down":I=v-Math.round(Y/2),ne=v+Math.round(Y/2);break;case"scroll-left":x=y+Math.round(E/2),T=y-Math.round(E/2);break;case"scroll-right":x=y-Math.round(E/2),T=y+Math.round(E/2);break;case"swipe-from-left-edge":x=G,I=v,T=Math.min(u-G,G+E);break;case"swipe-from-right-edge":x=u-G,I=v,T=Math.max(G,u-G-E);break;case"swipe-from-top-edge":x=y,I=L,ne=Math.min(m-V,L+Y);break;case"swipe-from-bottom-edge":x=y,I=m-V,ne=Math.max(L,m-V-Y);break}let z=Math.max(8,Math.round(r/16)),B=Math.max(1,Math.round(r/z)),ve=await c.send({type:"evaluate",code:`(async () => {
740
740
  const interact = window.__sootsimInteract
741
741
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
742
742
  const value = await interact.drag(${x}, ${I}, ${T}, ${ne}, ${z}, ${B})
@@ -751,7 +751,7 @@ ${n}
751
751
  cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
752
752
  cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
753
753
  }
754
- })()`}),w=await X(c,"scrollTo",n!=null?{nodeId:n}:r,u,m,!1);if(w?.ok){let h=n!=null?`node ${n}`:`#${r}`;await W("inspect scroll",{scrollTo:{...n!=null?{nodeId:n}:{id:r},x:u,y:m}},`scroll ${h} -> ${u},${m}`)}console.log(JSON.stringify({...w,...g?{at:{x:g.cx,y:g.cy}}:{}},null,2));break}case"state":{let t=l[1];if(s==="get"&&!t){let r=await X(c,"getRuntimeState"),a=await c.send({type:"evaluate",code:_e});if(r&&typeof r=="object"&&r.diagnostics&&(r.diagnostics.errors=a?.errors??0,r.diagnostics.warnings=a?.warnings??0),r&&typeof r=="object"&&r.shell==null)try{let u=await de(c);u&&(r.shell=u)}catch{}console.log(JSON.stringify(r,null,2));break}if(!t||t==="--help"||t==="-h"){console.log(`
754
+ })()`}),w=await X(c,"scrollTo",n!=null?{nodeId:n}:r,u,m,!1);if(w?.ok){let y=n!=null?`node ${n}`:`#${r}`;await W("inspect scroll",{scrollTo:{...n!=null?{nodeId:n}:{id:r},x:u,y:m}},`scroll ${y} -> ${u},${m}`)}console.log(JSON.stringify({...w,...g?{at:{x:g.cx,y:g.cy}}:{}},null,2));break}case"state":{let t=l[1];if(s==="get"&&!t){let r=await X(c,"getRuntimeState"),a=await c.send({type:"evaluate",code:_e});if(r&&typeof r=="object"&&r.diagnostics&&(r.diagnostics.errors=a?.errors??0,r.diagnostics.warnings=a?.warnings??0),r&&typeof r=="object"&&r.shell==null)try{let u=await de(c);u&&(r.shell=u)}catch{}console.log(JSON.stringify(r,null,2));break}if(!t||t==="--help"||t==="-h"){console.log(`
755
755
  ${b("state")} \u2014 dump raw runtime state
756
756
 
757
757
  subcommands:
@@ -835,7 +835,7 @@ ${n}
835
835
  ${b("shell")} open-card clock 800
836
836
  ${b("shell")} appearance dark
837
837
  ${b("shell")} lock
838
- `);break}let n=t==="launch"||t==="open-card"||t==="home"||t==="switcher",r=t==="launch"||t==="open-card"?l[3]:l[2],a=r?Number(r):350;n&&(!Number.isFinite(a)||a<0)&&(console.error(S("shell",t==="launch"||t==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let u=!1,m=!1,g=null,w=e.includes("--clear-state");if(t==="launch"){let h=l[2];h||(console.error(S("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),w&&await c.send({type:"evaluate",code:We(!0)}),u=!!await ye(c,"launchApp",a,h),{settled:m,state:g}=await Pe(c,Math.round(a),v=>!!v&&v.state==="app"&&v.activeApp===h&&v.showSwitcher===!1&&v.switcherPhase==="idle"&&typeof v.launchProgress=="number"&&v.launchProgress>=.98),u&&await W("inspect shell launch",w?{launchApp:{clearState:!0}}:{launchApp:{}},w?"launch app (clear state)":"launch app")}else if(t==="home")u=!!await ye(c,"goHome",a),{settled:m,state:g}=await Pe(c,Math.round(a),h=>!!h&&h.state==="home"&&h.activeApp==null&&h.showSwitcher===!1&&h.switcherPhase==="idle"&&typeof h.launchProgress=="number"&&h.launchProgress>=.98);else if(t==="switcher")u=!!await ye(c,"openSwitcher",a),{settled:m,state:g}=await Pe(c,Math.round(a),h=>!!h&&h.state==="app"&&h.showSwitcher===!0&&h.switcherPhase==="idle"&&typeof h.zoomLevel=="number"&&Math.abs(h.zoomLevel)<=.02&&typeof h.horizontalZoom=="number"&&Math.abs(h.horizontalZoom)<=.02),m&&(await oe(ws),g=await de(c));else if(t==="open-card"){let h=l[2];h||(console.error(S("shell","open-card <appId> [settleMs]")),process.exit(1)),u=!!await ye(c,"openSwitcherCard",a,h),{settled:m,state:g}=await Pe(c,Math.round(a),v=>!!v&&v.state==="app"&&v.activeApp===h&&v.showSwitcher===!1&&v.switcherPhase==="idle"&&typeof v.zoomLevel=="number"&&v.zoomLevel>=.98&&typeof v.horizontalZoom=="number"&&v.horizontalZoom>=.98),u&&await W("inspect shell open-card",{openSwitcherCard:{appId:h}},`open switcher card ${h}`)}else if(t==="appearance"){let h=l[2];(!h||!["light","dark","auto","toggle"].includes(h))&&(console.error(S("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let v=await So(c,"appearance",h);if(u=!!v?.ok,g={appearance:v},u){let L=v?.applied??h;console.log(` appearance: ${L}`)}}else if(t==="lock"||t==="shake"){let h=await So(c,t);u=!!h?.ok,g={[t]:h}}else console.error(` unknown shell subcommand: ${t}`),process.exit(1);console.log(JSON.stringify({ok:u,settled:m,state:g},null,2));break}case"url":{await ao(c,{args:i});break}case"reload":{let r=!1,a=!1;try{await c.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let g=await c.send({type:"evaluate",code:`;(async () => {
838
+ `);break}let n=t==="launch"||t==="open-card"||t==="home"||t==="switcher",r=t==="launch"||t==="open-card"?l[3]:l[2],a=r?Number(r):350;n&&(!Number.isFinite(a)||a<0)&&(console.error(S("shell",t==="launch"||t==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let u=!1,m=!1,g=null,w=e.includes("--clear-state");if(t==="launch"){let y=l[2];y||(console.error(S("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),w&&await c.send({type:"evaluate",code:We(!0)}),u=!!await ye(c,"launchApp",a,y),{settled:m,state:g}=await Pe(c,Math.round(a),v=>!!v&&v.state==="app"&&v.activeApp===y&&v.showSwitcher===!1&&v.switcherPhase==="idle"&&typeof v.launchProgress=="number"&&v.launchProgress>=.98),u&&await W("inspect shell launch",w?{launchApp:{clearState:!0}}:{launchApp:{}},w?"launch app (clear state)":"launch app")}else if(t==="home")u=!!await ye(c,"goHome",a),{settled:m,state:g}=await Pe(c,Math.round(a),y=>!!y&&y.state==="home"&&y.activeApp==null&&y.showSwitcher===!1&&y.switcherPhase==="idle"&&typeof y.launchProgress=="number"&&y.launchProgress>=.98);else if(t==="switcher")u=!!await ye(c,"openSwitcher",a),{settled:m,state:g}=await Pe(c,Math.round(a),y=>!!y&&y.state==="app"&&y.showSwitcher===!0&&y.switcherPhase==="idle"&&typeof y.zoomLevel=="number"&&Math.abs(y.zoomLevel)<=.02&&typeof y.horizontalZoom=="number"&&Math.abs(y.horizontalZoom)<=.02),m&&(await oe(ws),g=await de(c));else if(t==="open-card"){let y=l[2];y||(console.error(S("shell","open-card <appId> [settleMs]")),process.exit(1)),u=!!await ye(c,"openSwitcherCard",a,y),{settled:m,state:g}=await Pe(c,Math.round(a),v=>!!v&&v.state==="app"&&v.activeApp===y&&v.showSwitcher===!1&&v.switcherPhase==="idle"&&typeof v.zoomLevel=="number"&&v.zoomLevel>=.98&&typeof v.horizontalZoom=="number"&&v.horizontalZoom>=.98),u&&await W("inspect shell open-card",{openSwitcherCard:{appId:y}},`open switcher card ${y}`)}else if(t==="appearance"){let y=l[2];(!y||!["light","dark","auto","toggle"].includes(y))&&(console.error(S("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let v=await So(c,"appearance",y);if(u=!!v?.ok,g={appearance:v},u){let L=v?.applied??y;console.log(` appearance: ${L}`)}}else if(t==="lock"||t==="shake"){let y=await So(c,t);u=!!y?.ok,g={[t]:y}}else console.error(` unknown shell subcommand: ${t}`),process.exit(1);console.log(JSON.stringify({ok:u,settled:m,state:g},null,2));break}case"url":{await ao(c,{args:i});break}case"reload":{let r=!1,a=!1;try{await c.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let g=await c.send({type:"evaluate",code:`;(async () => {
839
839
  // in-place guest reload is only valid while the page still runs
840
840
  // the engine build the server would serve NOW. the shell dev
841
841
  // server has no HMR client, so a long-lived sim tab otherwise
@@ -861,11 +861,11 @@ ${n}
861
861
  return { kind: 'page', engineStale }
862
862
  })()`});a=!!g&&g.kind==="external-app",r=!0,g&&g.engineStale&&console.log(" engine build changed since page load \u2014 full page reload")}catch{}console.log(" reloading...");let u=c,m=null;if(a)m=await Te(c,{timeoutMs:1e4,errorGraceMs:3e3});else{r&&await oe(300);let w=await Ft(N,O,M,{timeoutMs:3e4,simIdSource:j});w?(u=w,m=await Te(w,{timeoutMs:3e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 30000ms"),u=null)}if(m)if(m.ready){let g=m.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${m.elapsedMs}ms: ${m.nodes} nodes${g}`)}else if(m.source==="error-bail")console.log(` \u26A0 reload bailed after ${m.elapsedMs}ms: ${m.errors} console error(s), ready signal never fired`);else{let g=yo(m);console.log(` \u26A0 reload timed out after ${m.elapsedMs}ms \u2014 ${g} (nodes: ${m.nodes}, targets: ${m.targets}, errors: ${m.errors})`)}if(u)try{let g=await fe(u,10);if(u!==c&&u.close(),Array.isArray(g)&&g.length>0){console.log(`
863
863
  \u26A0 ${g.length} error(s) during mount:
864
- `);for(let w of g){let h=w.args.map(v=>typeof v=="object"?JSON.stringify(v):v).join(" ");if(console.log(` ${h}`),w.stack){let v=w.stack.split(`
864
+ `);for(let w of g){let y=w.args.map(v=>typeof v=="object"?JSON.stringify(v):v).join(" ");if(console.log(` ${y}`),w.stack){let v=w.stack.split(`
865
865
  `).slice(0,2);for(let L of v)console.log(` ${L.trim()}`)}}}}catch{}m&&!m.ready&&(process.exitCode=1);break}case"storage-clear":{if(await qe(c),await c.send({type:"evaluate",code:We(!0)})!==!0){A(i)?D({cleared:!1,ready:!1,error:"external app reload bridge is unavailable"}):console.error(" storage clear failed: external app reload bridge is unavailable"),process.exitCode=1;break}let a=await Te(c,{timeoutMs:1e4,errorGraceMs:3e3});if(A(i)){D({cleared:!0,ready:a.ready,reload:a}),a.ready||(process.exitCode=1);break}if(a.ready){let u=a.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` cleared tenant storage; ready in ${a.elapsedMs}ms: ${a.nodes} nodes${u}`)}else if(a.source==="error-bail")console.log(` \u26A0 storage clear reloaded but bailed after ${a.elapsedMs}ms: ${a.errors} console error(s), ready signal never fired`);else{let u=yo(a);console.log(` \u26A0 storage clear reloaded but timed out after ${a.elapsedMs}ms \u2014 ${u} (nodes: ${a.nodes}, targets: ${a.targets}, errors: ${a.errors})`)}try{let u=await fe(c,10);if(Array.isArray(u)&&u.length>0){console.log(`
866
866
  \u26A0 ${u.length} error(s) during mount:
867
867
  `);for(let m of u){let g=m.args.map(w=>typeof w=="object"?JSON.stringify(w):w).join(" ");if(console.log(` ${g}`),m.stack){let w=m.stack.split(`
868
- `).slice(0,2);for(let h of w)console.log(` ${h.trim()}`)}}}}catch{}a.ready||(process.exitCode=1);break}case"eval":case"js":{let t=l.slice(1).join(" ");if(t||(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(` ${b("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${b("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${b("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${b("js")} SootSim.state.root.children.length`),process.exit(1)),e.includes("--tenant")){let m=l.slice(1).filter(w=>w!=="--tenant").join(" "),g=await c.send({type:"evaluate",code:`(async () => SootSim.bridges.test.evalInTenant(${JSON.stringify(m)}))()`});console.log(JSON.stringify(g,null,2));break}let n=t;n.startsWith("(async")||(n=`(async () => ${n})()`);let r=await c.send({type:"evaluate",code:n});console.log(JSON.stringify(r,null,2));let a=t.toLowerCase(),u=[];(a.includes("sootsim:gohome")||a.includes("gohome"))&&u.push("sootsim shell home"),(a.includes("sootsim:appswitcher")||a.includes("appswitcher"))&&u.push("sootsim shell switcher"),(a.includes("keyboard.isvisible")||a.includes("keyboard.getmode"))&&u.push("sootsim debug state keyboard"),a.includes("interact.tap")&&u.push("sootsim do tap <x> <y>"),a.includes("keyboard.type")&&u.push("sootsim do type <text>"),(a.includes("keyboard.press")||a.includes("keyboard.dispatchkey"))&&u.push("sootsim do key <name>"),a.includes("keyboard.dismiss")&&u.push("sootsim do dismiss"),a.includes("dumptree")&&u.push("sootsim get tree"),a.includes("dumpaccessibilitytree")&&u.push("sootsim get a11y"),a.includes("getnodecount")&&u.push("sootsim get count"),a.includes("findbytext")&&u.push("sootsim find <text>"),(a.includes("findbytestid")||a.includes("findbyid"))&&u.push("sootsim find --testid <id>"),a.includes("document.hidden")&&u.push("sootsim debug state keyboard (includes tab health)"),u.length>0&&Q("prefer-cli-over-eval",u);break}case"globals":{let t=await c.send({type:"evaluate",code:`(async () => {
868
+ `).slice(0,2);for(let y of w)console.log(` ${y.trim()}`)}}}}catch{}a.ready||(process.exitCode=1);break}case"eval":case"js":{let t=l.slice(1).join(" ");if(t||(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(` ${b("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${b("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${b("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${b("js")} SootSim.state.root.children.length`),process.exit(1)),e.includes("--tenant")){let m=l.slice(1).filter(w=>w!=="--tenant").join(" "),g=await c.send({type:"evaluate",code:`(async () => SootSim.bridges.test.evalInTenant(${JSON.stringify(m)}))()`});console.log(JSON.stringify(g,null,2));break}let n=t;n.startsWith("(async")||(n=`(async () => ${n})()`);let r=await c.send({type:"evaluate",code:n});console.log(JSON.stringify(r,null,2));let a=t.toLowerCase(),u=[];(a.includes("sootsim:gohome")||a.includes("gohome"))&&u.push("sootsim shell home"),(a.includes("sootsim:appswitcher")||a.includes("appswitcher"))&&u.push("sootsim shell switcher"),(a.includes("keyboard.isvisible")||a.includes("keyboard.getmode"))&&u.push("sootsim debug state keyboard"),a.includes("interact.tap")&&u.push("sootsim do tap <x> <y>"),a.includes("keyboard.type")&&u.push("sootsim do type <text>"),(a.includes("keyboard.press")||a.includes("keyboard.dispatchkey"))&&u.push("sootsim do key <name>"),a.includes("keyboard.dismiss")&&u.push("sootsim do dismiss"),a.includes("dumptree")&&u.push("sootsim get tree"),a.includes("dumpaccessibilitytree")&&u.push("sootsim get a11y"),a.includes("getnodecount")&&u.push("sootsim get count"),a.includes("findbytext")&&u.push("sootsim find <text>"),(a.includes("findbytestid")||a.includes("findbyid"))&&u.push("sootsim find --testid <id>"),a.includes("document.hidden")&&u.push("sootsim debug state keyboard (includes tab health)"),u.length>0&&Q("prefer-cli-over-eval",u);break}case"globals":{let t=await c.send({type:"evaluate",code:`(async () => {
869
869
  const globals = {}
870
870
 
871
871
  // test bridge (proxy in worker mode)
@@ -903,7 +903,7 @@ ${n}
903
903
 
904
904
  return globals
905
905
  })()`});console.log(` sootsim JS API:
906
- `);for(let[n,r]of Object.entries(t)){console.log(` ${n}:`);for(let a of r)console.log(` .${a}`);console.log("")}console.log(` use: ${b("js")} <expression>`),console.log(` example: ${b("js")} test.findByText("Sign in")`);break}case"describe":{await zt({bridge:c,args:e,positional:l});break}case"perf":{y==="debug"&&!o.internalPerfCommand&&(console.error(" `sootsim debug perf` was removed. use `sootsim perf shell ...`."),process.exit(1));let t=l[1];if(o.internalPerfCommand==="scroll"){if(!t||t==="--help"||t==="-h"){console.log(`
906
+ `);for(let[n,r]of Object.entries(t)){console.log(` ${n}:`);for(let a of r)console.log(` .${a}`);console.log("")}console.log(` use: ${b("js")} <expression>`),console.log(` example: ${b("js")} test.findByText("Sign in")`);break}case"describe":{await zt({bridge:c,args:e,positional:l});break}case"perf":{h==="debug"&&!o.internalPerfCommand&&(console.error(" `sootsim debug perf` was removed. use `sootsim perf shell ...`."),process.exit(1));let t=l[1];if(o.internalPerfCommand==="scroll"){if(!t||t==="--help"||t==="-h"){console.log(`
907
907
  ${b("perf")} <start|stop> [options]
908
908
 
909
909
  records per-frame scroll offsets from the tenant worker, shell worker,
@@ -929,7 +929,7 @@ ${n}
929
929
  if (!perf) return { error: 'scroll performance profile unavailable' }
930
930
  return await perf.stop()
931
931
  })()`});n?.error&&(console.error(` error: ${n.error}`),process.exit(1));let r=n;if(A(i)){D(r);break}console.log(` scroll performance trace:
932
- `),console.log(` duration: ${r.stoppedAt-r.startedAt}ms (worker series are timestamp-aligned, not frame-paired)`),console.log(` samples: tenant ${r.layers.tenant.length} \xB7 shell ${r.layers.shell.length} \xB7 compositor ${r.layers.compositor.length}`),console.log(""),console.log(" offset and phase changes (--json includes every per-frame sample):"),console.log(" t(ms) layer surface node offsetY slotY phase paint");let a=[];for(let u of Object.values(r.layers)){let m=new Map;for(let g of u){let w=`${g.surfaceId}:${g.nodeId}`,h=`${g.offsetY}:${g.slotY??""}:${g.phase??""}`;m.get(w)!==h&&(m.set(w,h),a.push(g))}}a.sort((u,m)=>u.t-m.t||u.seq-m.seq);for(let u of a)console.log(` ${String(u.t-r.startedAt).padStart(5)} ${u.layer.padEnd(10)} ${u.surfaceId.padEnd(8)} ${String(u.nodeId).padStart(5)} ${u.offsetY.toFixed(2).padStart(8)} ${u.slotY===void 0?" -":u.slotY.toFixed(2).padStart(8)} ${(u.phase??"-").padEnd(8)} ${u.paint===void 0?"-":u.paint}`);break}console.error(` unknown scroll perf command: ${t}`),process.exit(1)}if(!t||t==="--help"||t==="-h"){console.log(`
932
+ `),console.log(` duration: ${r.stoppedAt-r.startedAt}ms (worker series are timestamp-aligned, not frame-paired)`),console.log(` samples: tenant ${r.layers.tenant.length} \xB7 shell ${r.layers.shell.length} \xB7 compositor ${r.layers.compositor.length}`),console.log(""),console.log(" offset and phase changes (--json includes every per-frame sample):"),console.log(" t(ms) layer surface node offsetY slotY phase paint");let a=[];for(let u of Object.values(r.layers)){let m=new Map;for(let g of u){let w=`${g.surfaceId}:${g.nodeId}`,y=`${g.offsetY}:${g.slotY??""}:${g.phase??""}`;m.get(w)!==y&&(m.set(w,y),a.push(g))}}a.sort((u,m)=>u.t-m.t||u.seq-m.seq);for(let u of a)console.log(` ${String(u.t-r.startedAt).padStart(5)} ${u.layer.padEnd(10)} ${u.surfaceId.padEnd(8)} ${String(u.nodeId).padStart(5)} ${u.offsetY.toFixed(2).padStart(8)} ${u.slotY===void 0?" -":u.slotY.toFixed(2).padStart(8)} ${(u.phase??"-").padEnd(8)} ${u.paint===void 0?"-":u.paint}`);break}console.error(` unknown scroll perf command: ${t}`),process.exit(1)}if(!t||t==="--help"||t==="-h"){console.log(`
933
933
  ${b("perf")} \u2014 shell frame profiling (the worker that paints)
934
934
 
935
935
  records per-painted-frame timing in the shell worker \u2014 the surface that
@@ -989,23 +989,23 @@ ${n}
989
989
  `);for(let a of r){let u=ie(a.timestamp),m=a.args.map(g=>typeof g=="object"?JSON.stringify(g):g).join(" ");if(console.log(` [${u}] ${m}`),a.stack){let g=a.stack.split(`
990
990
  `).slice(0,3);for(let w of g)console.log(` ${w.trim()}`)}}break}case"warnings":{let t=l[1]?Number(l[1]):20,n=await gt(c,t);if(A(i)){D(n);break}if(n.length===0){console.log(" no warnings captured");break}console.log(` ${n.length} warning(s):
991
991
  `);for(let r of n){let a=ie(r.timestamp),u=r.args.map(m=>typeof m=="object"?JSON.stringify(m):m).join(" ");console.log(` [${a}] ${u}`)}break}case"animations":{let t=await X(c,"listAnimations")??[];if(e.includes("--json")){console.log(JSON.stringify(t,null,2));break}if(t.length===0){console.log(" no active animations");break}console.log(` ${t.length} active animation(s):
992
- `);for(let n of t){let r=String(n.kind).padEnd(6),a=`${Number(n.from).toFixed(2)}\u2192${Number(n.to).toFixed(2)}`,u=Number(n.current??0).toFixed(2),m=`${Math.round((n.progress??0)*100)}%`,g=`${Math.round(n.elapsedMs??0)}ms`,w=n.loop?" loop":"",h=n.layoutBound?" layout":"";console.log(` #${n.id} ${r} ${a.padEnd(14)} cur=${u.padEnd(7)} ${m.padStart(4)} ${g}${w}${h}`)}break}case"animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${b("animation")} <id>`),process.exit(1));let n=Number(t);Number.isFinite(n)||(console.error(` invalid id: ${t}`),process.exit(1));let r=await X(c,"getAnimation",n);console.log(JSON.stringify(r,null,2));break}case"stop-animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${b("stop-animation")} <id|all>`),process.exit(1));let n=t==="all"?"all":Number(t);n!=="all"&&!Number.isFinite(n)&&(console.error(` invalid id: ${t}`),process.exit(1));let r=await X(c,"stopAnimation",n);console.log(` stopped ${r??0} animation(s)`);break}case"requests":{let t=l[1];if(t==="clear"){await ht(c),A(i)?D({cleared:!0}):console.log(" request buffer cleared");break}let n=t==="all",r=n?l[2]:t,a=r?Number(r):20,u=await yt(c,{failed:!n,limit:a});if(A(i)){D(u);break}if(u.length===0){console.log(n?" no requests captured":" no failed requests captured");break}console.log(` ${u.length} ${n?"request(s)":"failed request(s)"}:
992
+ `);for(let n of t){let r=String(n.kind).padEnd(6),a=`${Number(n.from).toFixed(2)}\u2192${Number(n.to).toFixed(2)}`,u=Number(n.current??0).toFixed(2),m=`${Math.round((n.progress??0)*100)}%`,g=`${Math.round(n.elapsedMs??0)}ms`,w=n.loop?" loop":"",y=n.layoutBound?" layout":"";console.log(` #${n.id} ${r} ${a.padEnd(14)} cur=${u.padEnd(7)} ${m.padStart(4)} ${g}${w}${y}`)}break}case"animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${b("animation")} <id>`),process.exit(1));let n=Number(t);Number.isFinite(n)||(console.error(` invalid id: ${t}`),process.exit(1));let r=await X(c,"getAnimation",n);console.log(JSON.stringify(r,null,2));break}case"stop-animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${b("stop-animation")} <id|all>`),process.exit(1));let n=t==="all"?"all":Number(t);n!=="all"&&!Number.isFinite(n)&&(console.error(` invalid id: ${t}`),process.exit(1));let r=await X(c,"stopAnimation",n);console.log(` stopped ${r??0} animation(s)`);break}case"requests":{let t=l[1];if(t==="clear"){await ht(c),A(i)?D({cleared:!0}):console.log(" request buffer cleared");break}let n=t==="all",r=n?l[2]:t,a=r?Number(r):20,u=await yt(c,{failed:!n,limit:a});if(A(i)){D(u);break}if(u.length===0){console.log(n?" no requests captured":" no failed requests captured");break}console.log(` ${u.length} ${n?"request(s)":"failed request(s)"}:
993
993
  `);for(let m of u){let g=ie(m.timestamp);console.log(` [${g}] ${U(m)}`),m.responseBody?console.log(` ${m.responseBody}`):m.error&&console.log(` ${m.error}`)}break}case"network":{let t=l[1],n=null,r=null,a=!1,u=!1,m=1e3,g=!1,w=!1;for(let E=0;E<i.length;E++){let x=i[E];if(x==="--filter")n=i[E+1]??null,E++;else if(x==="--limit"){let I=Number(i[E+1]);Number.isFinite(I)&&(r=I),E++}else if(x==="--threshold"){let I=Number(i[E+1]);Number.isFinite(I)&&I>0&&(m=I),E++}else x==="--failed"?a=!0:x==="--slow"?u=!0:x==="--tail"||x==="-f"?g=!0:x==="--json"&&(w=!0)}if(t==="clear"){await c.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(t==="get"){let E=l[2];E||(console.error(" usage: sootsim network get <id>"),process.exit(1));let x=await c.send({type:"evaluate",code:`(() => {
994
994
  const obs = window.__sootsimObservability;
995
995
  if (!obs) return null;
996
996
  return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(E)}) || null;
997
- })()`});x||(console.error(` no entry with id ${E}`),process.exit(1)),w?console.log(JSON.stringify(x,null,2)):ys(x);break}let h=r??(g?200:t?Number(t):20);Number.isFinite(h)||(console.error(` invalid limit: ${t} \u2014 \`network\` takes a numeric count (e.g. ${b("network")} 100).
997
+ })()`});x||(console.error(` no entry with id ${E}`),process.exit(1)),w?console.log(JSON.stringify(x,null,2)):ys(x);break}let y=r??(g?200:t?Number(t):20);Number.isFinite(y)||(console.error(` invalid limit: ${t} \u2014 \`network\` takes a numeric count (e.g. ${b("network")} 100).
998
998
  to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let v=async()=>{let E=await c.send({type:"evaluate",code:`(() => {
999
999
  const obs = window.__sootsimObservability;
1000
1000
  if (!obs) return { ok: false };
1001
1001
  return { ok: true, entries: obs.network.getSnapshot() };
1002
- })()`});if(!E||!E.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return E.entries??[]},L=E=>{let x=E;if(a&&(x=x.filter(I=>!!I.error||I.status!=null&&I.status>=400)),u&&(x=x.filter(I=>I.durationMs!=null&&I.durationMs>=m)),n){let I=n.toLowerCase();x=x.filter(T=>(T.displayUrl||T.url).toLowerCase().includes(I))}return u&&!g&&(x=[...x].sort((I,T)=>(T.durationMs??0)-(I.durationMs??0))),x};if(!g){let E=await v(),x=L(E).slice(-h);if(w){console.log(JSON.stringify(x,null,2));break}if(x.length===0){E.length===0?console.log(" no network requests captured"):console.log(u?` no requests slower than ${m}ms (${E.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(u?` ${x.length} request(s) slower than ${m}ms (sorted by duration desc):
1002
+ })()`});if(!E||!E.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return E.entries??[]},L=E=>{let x=E;if(a&&(x=x.filter(I=>!!I.error||I.status!=null&&I.status>=400)),u&&(x=x.filter(I=>I.durationMs!=null&&I.durationMs>=m)),n){let I=n.toLowerCase();x=x.filter(T=>(T.displayUrl||T.url).toLowerCase().includes(I))}return u&&!g&&(x=[...x].sort((I,T)=>(T.durationMs??0)-(I.durationMs??0))),x};if(!g){let E=await v(),x=L(E).slice(-y);if(w){console.log(JSON.stringify(x,null,2));break}if(x.length===0){E.length===0?console.log(" no network requests captured"):console.log(u?` no requests slower than ${m}ms (${E.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(u?` ${x.length} request(s) slower than ${m}ms (sorted by duration desc):
1003
1003
  `:` ${x.length} request(s):
1004
1004
  `);for(let I of x)ho(I);break}console.log(` tailing network (ctrl-c to stop)...
1005
- `);let V=new Set,G=!0,Y=()=>{G=!1};process.on("SIGINT",Y);try{for(;G;){let E=await v(),x=L(E);for(let I of x)I.durationMs!=null&&(V.has(I.id)||(V.add(I.id),w?console.log(JSON.stringify(I)):ho(I)));await oe(250)}}finally{process.off("SIGINT",Y)}break}case"logs":{let t=l[1],n=null,r=null,a=null,u=!1,m=!1,g=!1;for(let x=0;x<i.length;x++){let I=i[x];if(I==="--filter")n=i[x+1]??null,x++;else if(I==="--limit"){let T=Number(i[x+1]);Number.isFinite(T)&&(r=T),x++}else I==="--level"?(a=i[x+1]??null,x++):I==="--tail"||I==="-f"?u=!0:I==="--json"?m=!0:(I==="--internal"||I==="--all")&&(g=!0)}let w=a?new Set(a.split(",").map(x=>x.trim()).filter(x=>x==="log"||x==="info"||x==="warn"||x==="error"||x==="debug")):null;if(t==="clear"){await wt(c),console.log(" log buffer cleared");break}let h=!m&&process.stdout.isTTY===!0,v=r??(u?500:t?Number(t):50);Number.isFinite(v)||(console.error(` invalid limit: ${t} \u2014 \`logs\` takes a numeric count (e.g. ${b("logs")} 100).
1005
+ `);let V=new Set,G=!0,Y=()=>{G=!1};process.on("SIGINT",Y);try{for(;G;){let E=await v(),x=L(E);for(let I of x)I.durationMs!=null&&(V.has(I.id)||(V.add(I.id),w?console.log(JSON.stringify(I)):ho(I)));await oe(250)}}finally{process.off("SIGINT",Y)}break}case"logs":{let t=l[1],n=null,r=null,a=null,u=!1,m=!1,g=!1;for(let x=0;x<i.length;x++){let I=i[x];if(I==="--filter")n=i[x+1]??null,x++;else if(I==="--limit"){let T=Number(i[x+1]);Number.isFinite(T)&&(r=T),x++}else I==="--level"?(a=i[x+1]??null,x++):I==="--tail"||I==="-f"?u=!0:I==="--json"?m=!0:(I==="--internal"||I==="--all")&&(g=!0)}let w=a?new Set(a.split(",").map(x=>x.trim()).filter(x=>x==="log"||x==="info"||x==="warn"||x==="error"||x==="debug")):null;if(t==="clear"){await wt(c),console.log(" log buffer cleared");break}let y=!m&&process.stdout.isTTY===!0,v=r??(u?500:t?Number(t):50);Number.isFinite(v)||(console.error(` invalid limit: ${t} \u2014 \`logs\` takes a numeric count (e.g. ${b("logs")} 100).
1006
1006
  to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let L=()=>bt(c),V=x=>$t(x,{level:w,filter:n,showInternal:g});if(!u){let x=await L(),I=V(x).slice(-v);if(m){console.log(JSON.stringify(I,null,2));break}if(I.length===0){console.log(x.length===0?" no logs captured":" no matching logs");break}console.log(` ${I.length} log(s):
1007
- `);for(let T of I)wo(T,h);break}console.log(` tailing logs (ctrl-c to stop)...
1008
- `);let G=new Set,Y=!0,E=()=>{Y=!1};process.on("SIGINT",E);try{for(;Y;){let x=await L(),I=V(x);for(let T of I)G.has(T.id)||(G.add(T.id),m?console.log(JSON.stringify(T)):wo(T,h));await oe(250)}}finally{process.off("SIGINT",E)}break}default:console.error(` unknown subcommand: ${p}`),process.exit(1)}if(C.has(p)&&!e.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&!await nt(c,p)&&await k(c),$.length>0&&ee($),!R.has(p)&&!A(i))try{await xe(c)}catch{}}catch($){let t=$ instanceof Error?$.message:String($);console.error(` ${p??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),a=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await Pt(c,N,n[1]);else if(/^no sim connected$/.test(t))Et(N);else if(r)if(await us(c)){let m=p??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
1007
+ `);for(let T of I)wo(T,y);break}console.log(` tailing logs (ctrl-c to stop)...
1008
+ `);let G=new Set,Y=!0,E=()=>{Y=!1};process.on("SIGINT",E);try{for(;Y;){let x=await L(),I=V(x);for(let T of I)G.has(T.id)||(G.add(T.id),m?console.log(JSON.stringify(T)):wo(T,y));await oe(250)}}finally{process.off("SIGINT",E)}break}default:console.error(` unknown subcommand: ${d}`),process.exit(1)}if(C.has(d)&&!e.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&!await nt(c,d)&&await _(c),$.length>0&&ee($),!R.has(d)&&!A(i))try{await xe(c)}catch{}}catch($){let t=$ instanceof Error?$.message:String($);console.error(` ${d??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),a=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await Pt(c,N,n[1]);else if(/^no sim connected$/.test(t))Et(N);else if(r)if(await us(c)){let m=d??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
1009
1009
  the screen's node tree is large; narrow the query or raise the budget:
1010
1010
  sootsim ${m} --testid <id> # scope to one subtree
1011
1011
  sootsim find --testid <id> # targeted single-node lookup