sootsim 0.1.214 → 0.1.216

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/detox/index.ts +30 -16
  2. package/dist-cli/bin.js +4 -4
  3. package/dist-cli/chunks/{agent-QE4ZAHV2.js → agent-RMGUE35J.js} +2 -2
  4. package/dist-cli/chunks/{agent-wrapper-E5HCJNYH.js → agent-wrapper-PNKMWDVX.js} +2 -2
  5. package/dist-cli/chunks/{app-fonts-4ADYMRQO.js → app-fonts-Z6SGSVKJ.js} +2 -2
  6. package/dist-cli/chunks/{assert-QZSX66RW.js → assert-ELIDRXY7.js} +2 -2
  7. package/dist-cli/chunks/{auth-LW224VBS.js → auth-2NJA7QI6.js} +2 -2
  8. package/dist-cli/chunks/beta-MTYUL7U7.js +2 -0
  9. package/dist-cli/chunks/{camera-MPIQ3JAA.js → camera-XICNRGGO.js} +2 -2
  10. package/dist-cli/chunks/{chunk-3CNHHY7U.js → chunk-2FNN7T63.js} +1 -1
  11. package/dist-cli/chunks/{chunk-USSUXBPG.js → chunk-4BUASWNE.js} +1 -1
  12. package/dist-cli/chunks/{chunk-I4UH6RI5.js → chunk-4XCGYTBN.js} +2 -2
  13. package/dist-cli/chunks/chunk-5LT4NR6Y.js +1 -0
  14. package/dist-cli/chunks/chunk-6KRC622O.js +1 -0
  15. package/dist-cli/chunks/{chunk-Z6X2QRA3.js → chunk-6TZMBHQ5.js} +3 -3
  16. package/dist-cli/chunks/{chunk-4RHFQCED.js → chunk-7SPHDLSB.js} +2 -2
  17. package/dist-cli/chunks/{chunk-6QMGV5H7.js → chunk-AWSL2LAA.js} +2 -2
  18. package/dist-cli/chunks/{chunk-L3CQVAWX.js → chunk-BGDEZZWT.js} +2 -2
  19. package/dist-cli/chunks/{chunk-DUGNFSB5.js → chunk-CCFLATUR.js} +2 -2
  20. package/dist-cli/chunks/{chunk-USW3U45B.js → chunk-CQSIRKJ2.js} +2 -2
  21. package/dist-cli/chunks/{chunk-KHIKG5LO.js → chunk-CRU7UL5Q.js} +1 -1
  22. package/dist-cli/chunks/{chunk-CZZZC3BU.js → chunk-CU3LQUJD.js} +2 -2
  23. package/dist-cli/chunks/chunk-DA7KPSMF.js +2 -0
  24. package/dist-cli/chunks/{chunk-SLX3HZPR.js → chunk-DRFWZ74H.js} +1 -1
  25. package/dist-cli/chunks/{chunk-XJEIT5CH.js → chunk-G6VHJWGQ.js} +1 -1
  26. package/dist-cli/chunks/{chunk-RRFWPEQ6.js → chunk-GIZDZKHC.js} +1 -1
  27. package/dist-cli/chunks/{chunk-IUTSWOUM.js → chunk-GPLW7IL5.js} +2 -2
  28. package/dist-cli/chunks/{chunk-QPZW76ZB.js → chunk-HBCEGJQH.js} +2 -2
  29. package/dist-cli/chunks/chunk-HIDDRHAN.js +99 -0
  30. package/dist-cli/chunks/chunk-HKKKZRKS.js +89 -0
  31. package/dist-cli/chunks/{chunk-DABWOLOT.js → chunk-HZCW6RRE.js} +2 -2
  32. package/dist-cli/chunks/{chunk-2344ZBLD.js → chunk-J4GDWHXE.js} +2 -2
  33. package/dist-cli/chunks/{chunk-TI2ZOHON.js → chunk-J74AW22R.js} +1 -1
  34. package/dist-cli/chunks/{chunk-6LJUMA3J.js → chunk-LWECTC6A.js} +2 -2
  35. package/dist-cli/chunks/{chunk-6EP67RW7.js → chunk-M2DYRSIS.js} +2 -2
  36. package/dist-cli/chunks/chunk-P5JY275Q.js +119 -0
  37. package/dist-cli/chunks/{chunk-XQP4TU6P.js → chunk-P735P65P.js} +93 -65
  38. package/dist-cli/chunks/{chunk-R35AOOU4.js → chunk-QNRORBZE.js} +2 -2
  39. package/dist-cli/chunks/{chunk-TX53NA5W.js → chunk-RESHDGBU.js} +1 -1
  40. package/dist-cli/chunks/{chunk-Y3T4POUK.js → chunk-S3C2S27B.js} +2 -2
  41. package/dist-cli/chunks/{chunk-AYY7JBXA.js → chunk-SBP46OOV.js} +1 -1
  42. package/dist-cli/chunks/{chunk-5LD4QHER.js → chunk-SPKRGAWR.js} +6 -6
  43. package/dist-cli/chunks/{chunk-YVIUYF5U.js → chunk-SSLFXUZQ.js} +1 -1
  44. package/dist-cli/chunks/chunk-TNPHXSMV.js +2 -0
  45. package/dist-cli/chunks/{chunk-AXXJSIT3.js → chunk-U7UICUB4.js} +2 -2
  46. package/dist-cli/chunks/{chunk-LRIZ5ACL.js → chunk-UGNYHNBN.js} +3 -3
  47. package/dist-cli/chunks/{chunk-GTRGDGRK.js → chunk-UPLXEL4D.js} +1 -1
  48. package/dist-cli/chunks/{chunk-2HCVCJB7.js → chunk-URGNAE7V.js} +31 -31
  49. package/dist-cli/chunks/{chunk-5P6QAHAI.js → chunk-VDONTXCB.js} +1 -1
  50. package/dist-cli/chunks/{chunk-L5XB3GRM.js → chunk-VSGSEQE7.js} +2 -2
  51. package/dist-cli/chunks/{chunk-BNUZWRON.js → chunk-VURHG6DO.js} +1 -1
  52. package/dist-cli/chunks/{chunk-KPRSDBWU.js → chunk-YN44PKW5.js} +1 -1
  53. package/dist-cli/chunks/cli-version-BP5GKAZ6.js +2 -0
  54. package/dist-cli/chunks/{compat-IZXTAA6Q.js → compat-MF7YZPCS.js} +3 -3
  55. package/dist-cli/chunks/{config-KV7J63HM.js → config-WJSCJ622.js} +2 -2
  56. package/dist-cli/chunks/{control-CRJA7SXC.js → control-AZFQJXJ5.js} +2 -2
  57. package/dist-cli/chunks/daemon-MU77JEAP.js +2 -0
  58. package/dist-cli/chunks/{debug-ZCPDU23K.js → debug-LIXGHFHV.js} +3 -3
  59. package/dist-cli/chunks/{desktop-HKTZX7OT.js → desktop-T7GTXHL4.js} +3 -3
  60. package/dist-cli/chunks/{detox-LNWHCNFM.js → detox-WV5FD4G6.js} +2 -2
  61. package/dist-cli/chunks/{device-AV34WOXK.js → device-GPHUF3BL.js} +2 -2
  62. package/dist-cli/chunks/{diagnose-7INR3HKD.js → diagnose-OAXHSPXW.js} +2 -2
  63. package/dist-cli/chunks/drivers-LJAA7XSZ.js +2 -0
  64. package/dist-cli/chunks/film-ZBYERRWW.js +69 -0
  65. package/dist-cli/chunks/flow-TXG46ARF.js +2 -0
  66. package/dist-cli/chunks/help-BVVLN5KL.js +2 -0
  67. package/dist-cli/chunks/{home-paths-ML5HT67C.js → home-paths-T3SY5QGR.js} +2 -2
  68. package/dist-cli/chunks/inspect-7SHQVCCL.js +2 -0
  69. package/dist-cli/chunks/install-desktop-RFGXCZRS.js +2 -0
  70. package/dist-cli/chunks/{login-IND3C7NP.js → login-QS2GVTJJ.js} +4 -4
  71. package/dist-cli/chunks/{logout-H6R4RQK7.js → logout-I752SSKU.js} +2 -2
  72. package/dist-cli/chunks/{maestro-IVTBNNF6.js → maestro-RDBKRP4O.js} +3 -3
  73. package/dist-cli/chunks/{maestro-generate-WCFBU5JM.js → maestro-generate-JOTQKAEH.js} +3 -3
  74. package/dist-cli/chunks/mode-Z4W3XXXU.js +24 -0
  75. package/dist-cli/chunks/optional-demo-registry-JTRVZB45.js +2 -0
  76. package/dist-cli/chunks/{perf-TNLPQUZI.js → perf-RXXW5GRA.js} +2 -2
  77. package/dist-cli/chunks/{record-MBJMHM23.js → record-527ZYKHE.js} +3 -3
  78. package/dist-cli/chunks/runtime-DOAHJLEK.js +2 -0
  79. package/dist-cli/chunks/{screenshot-command-Q5TFWB2R.js → screenshot-command-OBPEZJLR.js} +3 -3
  80. package/dist-cli/chunks/{screenshots-capture-AW5VYVOF.js → screenshots-capture-VC752Q3V.js} +2 -2
  81. package/dist-cli/chunks/{serve-L5XOVSCM.js → serve-NU6WWN2K.js} +2 -2
  82. package/dist-cli/chunks/{setup-TKXVNVBX.js → setup-6BJWI3PC.js} +3 -3
  83. package/dist-cli/chunks/{skills-GFZ5Z46I.js → skills-L7JPAJEZ.js} +2 -2
  84. package/dist-cli/chunks/{storage-SW3CLSLM.js → storage-XIZZSPC3.js} +2 -2
  85. package/dist-cli/chunks/store-3UAGOXD4.js +2 -0
  86. package/dist-cli/chunks/telemetry-IXCWQVEB.js +2 -0
  87. package/dist-cli/chunks/{timeline-LVV6HPFG.js → timeline-3MAGSV2V.js} +2 -2
  88. package/dist-cli/chunks/{upgrade-B22ZDON2.js → upgrade-YDHOHVYZ.js} +2 -2
  89. package/dist-cli/chunks/upload-YQVEPIO7.js +2 -0
  90. package/dist-cli/chunks/{version-G2X5AZHL.js → version-QDGDS5P2.js} +2 -2
  91. package/dist-cli/chunks/web-BK6VHH5W.js +2 -0
  92. package/dist-cli/chunks/{what-happened-2DEQUI25.js → what-happened-4GGACNI4.js} +2 -2
  93. package/dist-lib/agent-daemon-client.cjs +1 -1
  94. package/dist-lib/agent-events.cjs +1 -1
  95. package/dist-lib/agent-identity.cjs +1 -1
  96. package/dist-lib/agent-sessions.cjs +1 -1
  97. package/dist-lib/attached-projects.cjs +1 -1
  98. package/dist-lib/auth/shared-session.cjs +1 -1
  99. package/dist-lib/backend-origin.cjs +1 -1
  100. package/dist-lib/beta.cjs +1 -1
  101. package/dist-lib/beta.mjs +1 -1
  102. package/dist-lib/bridge-constants.cjs +1 -1
  103. package/dist-lib/cli-constants.cjs +1 -1
  104. package/dist-lib/config.cjs +1 -1
  105. package/dist-lib/detox/index.cjs +108 -12
  106. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  107. package/dist-lib/home-paths.cjs +1 -1
  108. package/dist-lib/host/bridge-host.cjs +1 -1
  109. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  110. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  111. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  112. package/dist-lib/host/websocket-proxy.cjs +1 -1
  113. package/dist-lib/index.cjs +1 -1
  114. package/dist-lib/jump-to-source-babel.cjs +1 -1
  115. package/dist-lib/menu.cjs +1 -1
  116. package/dist-lib/menu.mjs +1 -1
  117. package/dist-lib/metro.cjs +1 -1
  118. package/dist-lib/profiles.cjs +1 -1
  119. package/dist-lib/render-mode.cjs +1 -1
  120. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  121. package/dist-lib/sdk.cjs +57 -9
  122. package/dist-lib/sdk.mjs +57 -9
  123. package/dist-lib/skills.cjs +41 -15
  124. package/dist-lib/vite.cjs +1 -1
  125. package/package.json +1 -1
  126. package/skills/soot/SKILL.md +1 -0
  127. package/skills/sootsim-debug/SKILL.md +6 -8
  128. package/skills/sootsim-perf/SKILL.md +4 -4
  129. package/dist-cli/chunks/beta-VXRR4GRU.js +0 -2
  130. package/dist-cli/chunks/chunk-FZPRFSTA.js +0 -2
  131. package/dist-cli/chunks/chunk-NQDDEWYD.js +0 -1
  132. package/dist-cli/chunks/chunk-T7CWPTU7.js +0 -2
  133. package/dist-cli/chunks/chunk-TQ7WAA2M.js +0 -119
  134. package/dist-cli/chunks/chunk-WEBUMXLD.js +0 -97
  135. package/dist-cli/chunks/chunk-WF6AY4K4.js +0 -1
  136. package/dist-cli/chunks/cli-version-5DZ5FKJC.js +0 -2
  137. package/dist-cli/chunks/daemon-LOYTWGGF.js +0 -2
  138. package/dist-cli/chunks/drivers-Z2TX4DMF.js +0 -2
  139. package/dist-cli/chunks/flow-7XFQKTBU.js +0 -2
  140. package/dist-cli/chunks/help-ODEIEVZ6.js +0 -2
  141. package/dist-cli/chunks/inspect-KFGNZ2E3.js +0 -2
  142. package/dist-cli/chunks/install-desktop-GTMDR7D5.js +0 -2
  143. package/dist-cli/chunks/mode-OXPEBMF2.js +0 -111
  144. package/dist-cli/chunks/optional-demo-registry-CHOUOWFF.js +0 -2
  145. package/dist-cli/chunks/runtime-NCWCN66Y.js +0 -2
  146. package/dist-cli/chunks/store-5AQQ6HKE.js +0 -2
  147. package/dist-cli/chunks/telemetry-L2M7NRKA.js +0 -2
  148. package/dist-cli/chunks/upload-UQRYTSL2.js +0 -2
  149. package/dist-cli/chunks/web-YCDMLF4V.js +0 -2
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./chunk-4RHFQCED.js";import{a as oe,b as P,c as D,d as Ie,e as ie,f as V,g as de,h as ge,i as Mt,j as Ft,k as Te,l as Ot}from"./chunk-IUTSWOUM.js";import{A as wt,B as xt,E as $t,G as St,I as ue,J as vt,P as We,a as ve,b as nt,c as rt,d as it,e as at,f as lt,g as ct,h as ut,i as dt,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 ke,w as Le,x as yt,y as ht,z as bt}from"./chunk-XJEIT5CH.js";import{e as kt,g as _t,i as It,j as Tt,k as Nt,l as _e}from"./chunk-5LD4QHER.js";import{a as tt}from"./chunk-FZPRFSTA.js";import{a as Ae,c as De,d as Q}from"./chunk-TQ7WAA2M.js";import{c as ot}from"./chunk-BNUZWRON.js";import{b as st}from"./chunk-KPRSDBWU.js";function qe(e){return`(async () => {
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as ce}from"./chunk-HBCEGJQH.js";import{b as Et,c as Rt,k as Pt}from"./chunk-7SPHDLSB.js";import{a as oe,b as P,c as D,d as Ie,e as ie,f as V,g as de,h as ge,i as Mt,j as Ft,k as Te,l as Ot}from"./chunk-GPLW7IL5.js";import{A as wt,B as xt,E as $t,G as St,I as ue,J as vt,P as We,a as ve,b as nt,c as rt,d as it,e as at,f as lt,g as ct,h as ut,i as dt,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 ke,w as Le,x as yt,y as ht,z as bt}from"./chunk-G6VHJWGQ.js";import{e as kt,g as _t,i as It,j as Tt,k as Nt,l as _e}from"./chunk-SPKRGAWR.js";import{a as tt}from"./chunk-TNPHXSMV.js";import{a as Ae,c as De,d as Q}from"./chunk-P5JY275Q.js";import{c as ot}from"./chunk-VURHG6DO.js";import{b as st}from"./chunk-YN44PKW5.js";function qe(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,10 +71,10 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
71
71
  deviceWidth: __w / __dpr,
72
72
  deviceHeight: __h / __dpr,
73
73
  }
74
- })()`}import{existsSync as Eo,mkdirSync as Ct,readFileSync as Po,rmSync as Ke,writeFileSync as jt}from"fs";import{tmpdir as Ao}from"os";import{dirname as Lt,join as Do,resolve as Wt}from"path";import*as Ne from"fs";function Ro(e){let o={},s=e,a=p=>Array.isArray(p)?p:[],c=e.match(/^---\n([\s\S]*?)\n---\n?/);if(c){try{o=ce.parse(c[1])??{}}catch(f){console.warn(` warn: could not parse frontmatter: ${f.message}`)}s=e.slice(c[0].length);let p=ce.parse(s);return{frontmatter:o,steps:a(p)}}if(/\n---\s*\n/.test(e))try{let p=ce.parseAllDocuments(e);if(p.length>=2){let f=p[0].toJS(),v=p[p.length-1].toJS();return{frontmatter:f&&typeof f=="object"?f:{},steps:a(v)}}}catch(p){console.warn(` warn: could not parse multi-doc flow: ${p.message}`)}let l=ce.parse(s);return{frontmatter:o,steps:a(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 a of e)a&&typeof a=="object"?Object.keys(a).some(l=>Bt.has(l))&&(s+=1):typeof a=="string"&&Bt.has(a)&&(s+=1);return s===0&&o.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),o}function Ns(e){if(!Ne.existsSync(e))return[`file not found: ${e}`];let o;try{o=Ne.readFileSync(e,"utf8")}catch(s){return[`cannot read file: ${s.message}`]}if(o.trim().length===0)return["file is empty"];try{let s=Ro(o);return Je(s.steps)}catch(s){return[`yaml parse error: ${s.message}`]}}var He=1;function Me(){return Wt(process.env.SOOTSIM_FLOW_SESSION_PATH||Do(Ao(),"sootsim-flow-session.json"))}function Ue(e){let o=Me();Ct(Lt(o),{recursive:!0}),jt(o,JSON.stringify(e,null,2)+`
75
- `)}function Ge(){let e=Me();if(!Eo(e))return null;try{let o=JSON.parse(Po(e,"utf8"));return o.version!==He||!Array.isArray(o.steps)||typeof o.startedAt!="string"||typeof o.updatedAt!="string"?(Ke(e,{force:!0}),null):{version:He,startedAt:o.startedAt,updatedAt:o.updatedAt,steps:o.steps,candidate:o.candidate??null}}catch{return Ke(e,{force:!0}),null}}function As(){let e=new Date().toISOString(),o={version:He,startedAt:e,updatedAt:e,steps:[],candidate:null};return Ue(o),{path:Me(),state:o}}function Bo(){Ke(Me(),{force:!0})}function Ds(){Bo()}function Fe(e){let o=Ge();if(!o)return{active:!1};let s=o.candidate,a={...o,updatedAt:new Date().toISOString(),candidate:{step:e.step,summary:e.summary,source:e.source,recordedAt:new Date().toISOString()}};return Ue(a),{active:!0,candidate:a.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),a=Je(o.steps);if(a.length>0)return{active:!0,valid:!1,issues:a,yaml:s,stepCount:o.steps.length,outputPath:null};let c=null;return e&&(c=Wt(e),Ct(Lt(c),{recursive:!0}),jt(c,s)),{active:!0,valid:!0,issues:[],yaml:s,stepCount:o.steps.length,outputPath:c}}import{existsSync as jo,mkdirSync as Lo,readFileSync as Wo,rmSync as qt,writeFileSync as qo}from"fs";import{tmpdir as Jo}from"os";import{dirname as Ko,join as Ho,resolve as Uo}from"path";var ye=1,Go="SOOTSIM_INSPECT_NOTICE_PATH",zo=300*1e3,Yo=15e3;function Jt(){return Uo(process.env[Go]||Ho(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<=zo))}function Vo(e){let o=Jt();if(!jo(o))return{version:ye,entries:{}};try{let s=JSON.parse(Wo(o,"utf8"));return s.version!==ye||!s.entries||typeof s.entries!="object"?(qt(o,{force:!0}),{version:ye,entries:{}}):{version:ye,entries:Xo(s.entries,e)}}catch{return qt(o,{force:!0}),{version:ye,entries:{}}}}function Qo(e){let o=Jt();Lo(Ko(o),{recursive:!0}),qo(o,JSON.stringify(e,null,2)+`
77
- `)}function Zo(e,o){let s=o.trim()||"default";return`${e}:${s}`}function ze(e,o,s,a={}){let c=a.nowMs??Date.now(),l=a.cooldownMs??Yo,p=Vo(c),f=Zo(e,o),v=p.entries[f];return v&&v.signature===s&&c-v.updatedAt<l?!1:(p.entries[f]={signature:s,updatedAt:c},Qo(p),!0)}async function se({bridge:e,simId:o,maxMs:s,pollMs:a=50,stablePolls:c=3,strict:l=!1}){let p=await e.send({type:"evaluate",simId:o,code:`(async () => {
74
+ })()`}import{existsSync as Ro,mkdirSync as Ct,readFileSync as Po,rmSync as He,writeFileSync as jt}from"fs";import{tmpdir as Ao}from"os";import{dirname as Lt,join as Do,resolve as Wt}from"path";import*as Ne from"fs";function Eo(e){let o={},s=e,a=p=>Array.isArray(p)?p:[],c=e.match(/^---\n([\s\S]*?)\n---\n?/);if(c){try{o=ce.parse(c[1])??{}}catch(y){console.warn(` warn: could not parse frontmatter: ${y.message}`)}s=e.slice(c[0].length);let p=ce.parse(s);return{frontmatter:o,steps:a(p)}}if(/\n---\s*\n/.test(e))try{let p=ce.parseAllDocuments(e);if(p.length>=2){let y=p[0].toJS(),b=p[p.length-1].toJS();return{frontmatter:y&&typeof y=="object"?y:{},steps:a(b)}}}catch(p){console.warn(` warn: could not parse multi-doc flow: ${p.message}`)}let l=ce.parse(s);return{frontmatter:o,steps:a(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 a of e)a&&typeof a=="object"?Object.keys(a).some(l=>Bt.has(l))&&(s+=1):typeof a=="string"&&Bt.has(a)&&(s+=1);return s===0&&o.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),o}function Ns(e){if(!Ne.existsSync(e))return[`file not found: ${e}`];let o;try{o=Ne.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 Me(){return Wt(process.env.SOOTSIM_FLOW_SESSION_PATH||Do(Ao(),"sootsim-flow-session.json"))}function Ue(e){let o=Me();Ct(Lt(o),{recursive:!0}),jt(o,JSON.stringify(e,null,2)+`
75
+ `)}function Ge(){let e=Me();if(!Ro(e))return null;try{let o=JSON.parse(Po(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:Me(),state:o}}function Bo(){He(Me(),{force:!0})}function Ds(){Bo()}function Fe(e){let o=Ge();if(!o)return{active:!1};let s=o.candidate,a={...o,updatedAt:new Date().toISOString(),candidate:{step:e.step,summary:e.summary,source:e.source,recordedAt:new Date().toISOString()}};return Ue(a),{active:!0,candidate:a.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),a=Je(o.steps);if(a.length>0)return{active:!0,valid:!1,issues:a,yaml:s,stepCount:o.steps.length,outputPath:null};let c=null;return e&&(c=Wt(e),Ct(Lt(c),{recursive:!0}),jt(c,s)),{active:!0,valid:!0,issues:[],yaml:s,stepCount:o.steps.length,outputPath:c}}import{existsSync as jo,mkdirSync as Lo,readFileSync as Wo,rmSync as qt,writeFileSync as qo}from"fs";import{tmpdir as Jo}from"os";import{dirname as Ho,join as Ko,resolve as Uo}from"path";var ye=1,Go="SOOTSIM_INSPECT_NOTICE_PATH",zo=300*1e3,Yo=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<=zo))}function Vo(e){let o=Jt();if(!jo(o))return{version:ye,entries:{}};try{let s=JSON.parse(Wo(o,"utf8"));return s.version!==ye||!s.entries||typeof s.entries!="object"?(qt(o,{force:!0}),{version:ye,entries:{}}):{version:ye,entries:Xo(s.entries,e)}}catch{return qt(o,{force:!0}),{version:ye,entries:{}}}}function Qo(e){let o=Jt();Lo(Ho(o),{recursive:!0}),qo(o,JSON.stringify(e,null,2)+`
77
+ `)}function Zo(e,o){let s=o.trim()||"default";return`${e}:${s}`}function ze(e,o,s,a={}){let c=a.nowMs??Date.now(),l=a.cooldownMs??Yo,p=Vo(c),y=Zo(e,o),b=p.entries[y];return b&&b.signature===s&&c-b.updatedAt<l?!1:(p.entries[y]={signature:s,updatedAt:c},Qo(p),!0)}async function se({bridge:e,simId:o,maxMs:s,pollMs:a=50,stablePolls:c=3,strict:l=!1}){let p=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(a))}
@@ -191,7 +191,7 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
191
191
  await sleep(pollMs)
192
192
  }
193
193
  return { settled: false, elapsed: Date.now() - start }
194
- })()`},{timeoutMs:s+1e3}),{elapsed:f,settled:v}=p??{};return{elapsed:typeof f=="number"?f:s,settled:v===!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.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function ss(e,o){return{id:e.target?.id??e.match?.id??e.node?.id??null,testID:e.target?.testID??e.match?.testID??e.node?.testID??null,text:e.target?.text??e.target?.accessibilityLabel??e.match?.text??e.match?.accessibilityLabel??e.node?.text??o??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function he(e,o){let s=os(!!o.agent,o.timing),a=0,c=null,l=null;try{await se({bridge:e,maxMs:s.initialWaitMs,pollMs:32,stablePolls:2})}catch{}let p=Date.now()+s.deadlineMs;for(;Date.now()<=p||a===0;){a++;let f=await o.resolve();if(c=f,f?.error==="bridge-not-ready"||f?.ambiguous||f?.nthOutOfRange)return{payload:f,result:null,attempts:a,failure:"special"};if(f&&typeof f.cx=="number"&&typeof f.cy=="number"){let _=await e.send({type:"tap",x:f.cx,y:f.cy,target:ss(f,o.textFallback)});if(l=_,pe(_))return{payload:f,result:_,attempts:a}}let v=p-Date.now();if(v<=0)break;try{await se({bridge:e,maxMs:Math.min(v,s.retryWaitMs),pollMs:32,stablePolls:2})}catch{await new Promise(_=>setTimeout(_,Math.min(120,v)))}}return{payload:c,result:l,attempts:a,failure:c&&typeof c.cx=="number"?"missed":"not-found"}}async function Kt(e,o,s,a){return e.send({type:"tap",x:o,y:s,...a?{target:a}:{}})}async function Ht(e,o,s={}){let a=JSON.stringify(o);return he(e,{agent:s.agent,timing:s.timing,resolve:()=>e.send({type:"evaluate",code:`(async () => {
194
+ })()`},{timeoutMs:s+1e3}),{elapsed:y,settled:b}=p??{};return{elapsed:typeof y=="number"?y:s,settled:b===!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.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function ss(e,o){return{id:e.target?.id??e.match?.id??e.node?.id??null,testID:e.target?.testID??e.match?.testID??e.node?.testID??null,text:e.target?.text??e.target?.accessibilityLabel??e.match?.text??e.match?.accessibilityLabel??e.node?.text??o??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function he(e,o){let s=os(!!o.agent,o.timing),a=0,c=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||a===0;){a++;let b=await o.resolve();if(c=b,b?.error==="bridge-not-ready"||b?.ambiguous||b?.nthOutOfRange)return{payload:b,result:null,attempts:a,failure:"special"};if(b&&typeof b.cx=="number"&&typeof b.cy=="number")if(b.offscreen){l={hit:!1,reason:"offscreen",x:b.cx,y:b.cy,screen:b.screen};let h=`${Math.round(b.cx)},${Math.round(b.cy)}`;if(y===h)return{payload:b,result:l,attempts:a,failure:"missed"};y=h}else{y=null;let h=await e.send({type:"tap",x:b.cx,y:b.cy,target:ss(b,o.textFallback)});if(l=h,pe(h))return{payload:b,result:h,attempts:a}}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(h=>setTimeout(h,Math.min(120,_)))}}return{payload:c,result:l,attempts:a,failure:c&&typeof c.cx=="number"?"missed":"not-found"}}async function Ht(e,o,s,a){return e.send({type:"tap",x:o,y:s,...a?{target:a}:{}})}async function Kt(e,o,s={}){let a=JSON.stringify(o);return he(e,{agent:s.agent,timing:s.timing,resolve:()=>e.send({type:"evaluate",code:`(async () => {
195
195
  const t = window.__sootsimTest
196
196
  if (!t) return null
197
197
  const n = (await t.findByTestId(${a})) || (await t.findById(${a}))
@@ -209,9 +209,17 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
209
209
  resolved && typeof resolved.cy === 'number'
210
210
  ? resolved.cy
211
211
  : n.absolutePosition.y + (n.layout.height || 0) / 2
212
+ const scrEl = document.querySelector('canvas[data-surface-id]')
213
+ const scr =
214
+ scrEl && scrEl.clientWidth > 40 && scrEl.clientHeight > 40
215
+ ? { width: scrEl.clientWidth, height: scrEl.clientHeight }
216
+ : null
217
+ const offscreen =
218
+ !!scr && (cx < 0 || cy < 0 || cx > scr.width || cy > scr.height)
212
219
  return {
213
220
  cx,
214
221
  cy,
222
+ ...(offscreen ? { offscreen: true, screen: scr } : {}),
215
223
  match: {
216
224
  nodeId: n.nodeId ?? null,
217
225
  id: n.id,
@@ -328,9 +336,17 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
328
336
  resolved && typeof resolved.cy === 'number'
329
337
  ? resolved.cy
330
338
  : n.absolutePosition.y + (n.layout.height || 0) / 2
339
+ const scrEl = document.querySelector('canvas[data-surface-id]')
340
+ const scr =
341
+ scrEl && scrEl.clientWidth > 40 && scrEl.clientHeight > 40
342
+ ? { width: scrEl.clientWidth, height: scrEl.clientHeight }
343
+ : null
344
+ const offscreen =
345
+ !!scr && (cx < 0 || cy < 0 || cx > scr.width || cy > scr.height)
331
346
  return {
332
347
  cx,
333
348
  cy,
349
+ ...(offscreen ? { offscreen: true, screen: scr } : {}),
334
350
  match: {
335
351
  nodeId: n.nodeId ?? null,
336
352
  id: n.id,
@@ -370,6 +386,12 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
370
386
  absolutePosition: byTestId.absolutePosition,
371
387
  layout: byTestId.layout,
372
388
  },
389
+ screen: (() => {
390
+ const el = document.querySelector('canvas[data-surface-id]')
391
+ return el && el.clientWidth > 40 && el.clientHeight > 40
392
+ ? { width: el.clientWidth, height: el.clientHeight }
393
+ : null
394
+ })(),
373
395
  }
374
396
  }
375
397
  const byText = await t.findByText(${a})
@@ -385,19 +407,25 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
385
407
  absolutePosition: byText.absolutePosition,
386
408
  layout: byText.layout,
387
409
  },
410
+ screen: (() => {
411
+ const el = document.querySelector('canvas[data-surface-id]')
412
+ return el && el.clientWidth > 40 && el.clientHeight > 40
413
+ ? { width: el.clientWidth, height: el.clientHeight }
414
+ : null
415
+ })(),
388
416
  }
389
417
  }
390
418
  return { strategy: 'none' }
391
- })()`});if(!c||!("node"in c))return c;let l=c.node,p=l.absolutePosition.x+l.layout.width/2,f=l.absolutePosition.y+l.layout.height/2;return{...c,cx:p,cy:f,target:{id:l.id,testID:l.testID,text:c.strategy==="text"?o:l.text,type:l.type}}}})}async function zt(e,o={args:[]}){let s=await rt(e);if(P(o.args)){D(s);return}console.log(` nodes: ${s.nodes}`)}function Ye(e,o){let s=e.indexOf(o);return s>=0&&s+1<e.length?e[s+1]:null}async function Yt(e){let{bridge:o,args:s,positional:a}=e,c=s.includes("--verbose")||s.includes("-v"),l=P(s),p=c&&!l,f=s.includes("--watch")||s.includes("-w"),v=1e3,_=s.includes("--compact"),h=s.includes("--no-xy"),I=s.includes("--no-clipped"),F=s.includes("--include-occluded"),N=Ye(s,"--testid-like"),L=Ye(s,"--only"),M=Ye(s,"--subtree"),u=a[1]&&!a[1].startsWith("-")?a[1]:void 0,j=u?/[*?]/.test(u):!1,A=!j&&!L?u:void 0,E=L??(j?u:void 0),H=async()=>{await de(o,{verbose:p});let S=await lt(o,{describe:!0,verbose:c,filter:A||"",testIdLike:N||void 0,onlyGlob:E||void 0,subtreeRoot:M||void 0,compact:_,hideXy:h,includeOccluded:F}),O=S?.tree,J=S?.shell,K=S?.keyboard;if(l){D({shell:J,tree:O??"",keyboard:K});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 O=="string"&&O.startsWith("__SUBTREE_NOT_FOUND__:")){let C=O.slice(22);console.log(` subtree root not found: ${C}`),Q("subtree-root-not-found",C);return}if(!O){let C=S?.nodeCount??0;console.log(" no matching nodes found"),!(A||N||E||M)&&C<10&&Q("app-still-loading",C);return}let ee=O,te=0;if(I&&typeof ee=="string"){let C=ee.split(`
419
+ })()`});if(!c||!("node"in c))return c;let l=c.node,p=l.absolutePosition.x+l.layout.width/2,y=l.absolutePosition.y+l.layout.height/2,b=c.screen??null,_=!!b&&(p<0||y<0||p>b.width||y>b.height);return{...c,cx:p,cy:y,..._?{offscreen:!0,screen:b}:{},target:{id:l.id,testID:l.testID,text:c.strategy==="text"?o:l.text,type:l.type}}}})}async function zt(e,o={args:[]}){let s=await rt(e);if(P(o.args)){D(s);return}console.log(` nodes: ${s.nodes}`)}function Ye(e,o){let s=e.indexOf(o);return s>=0&&s+1<e.length?e[s+1]:null}async function Yt(e){let{bridge:o,args:s,positional:a}=e,c=s.includes("--verbose")||s.includes("-v"),l=P(s),p=c&&!l,y=s.includes("--watch")||s.includes("-w"),b=1e3,_=s.includes("--compact"),h=s.includes("--no-xy"),I=s.includes("--no-clipped"),F=s.includes("--include-occluded"),N=Ye(s,"--testid-like"),L=Ye(s,"--only"),M=Ye(s,"--subtree"),u=a[1]&&!a[1].startsWith("-")?a[1]:void 0,j=u?/[*?]/.test(u):!1,A=!j&&!L?u:void 0,R=L??(j?u:void 0),K=async()=>{await de(o,{verbose:p});let v=await lt(o,{describe:!0,verbose:c,filter:A||"",testIdLike:N||void 0,onlyGlob:R||void 0,subtreeRoot:M||void 0,compact:_,hideXy:h,includeOccluded:F}),O=v?.tree,J=v?.shell,H=v?.keyboard;if(l){D({shell:J,tree:O??"",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 O=="string"&&O.startsWith("__SUBTREE_NOT_FOUND__:")){let C=O.slice(22);console.log(` subtree root not found: ${C}`),Q("subtree-root-not-found",C);return}if(!O){let C=v?.nodeCount??0;console.log(" no matching nodes found"),!(A||N||R||M)&&C<10&&Q("app-still-loading",C);return}let ee=O,te=0;if(I&&typeof ee=="string"){let C=ee.split(`
392
420
  `),le=[];for(let $e of C){if($e.includes("(clipped:")){te+=1;continue}le.push($e)}ee=le.join(`
393
- `)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let re=A||N||E||M;if((A||N||E)&&!f&&Q("describe-filter-context"),!re&&!f&&O.split(`
394
- `).length>=80&&Q("describe-use-filters"),K&&K.visible){let C=K.spec,le=[C?.keyboardType?`type=${C.keyboardType}`:null,C?.returnKeyType&&C.returnKeyType!=="default"?`return=${C.returnKeyType}`:null,K.mode!=="letters"?`mode=${K.mode}`:null,K.shifted?"shift":null,K.capsLock?"caps":null,C?.autoCapitalize&&C.autoCapitalize!=="sentences"?`autoCap=${C.autoCapitalize}`:null,K.accessoryBarId?`accessory=${K.accessoryBarId}`:null].filter(Boolean);console.log(`
395
- keyboard: ${le.join(" ")||"visible"}`)}};if(f)for(console.log(` watching... (Ctrl+C to stop)
396
- `);;)console.clear(),await H(),await oe(v);else await H()}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:a,positional:c,inspectUsage:l}=e,p=S=>{let O=a.indexOf(S);return O>=0&&O+1<a.length?a[O+1]:null},f=S=>a.includes(S),v=p("--testid")||p("--test-id"),_=p("--role"),h=p("--type"),I=p("--text"),F=f("--pressable"),N=f("--visible"),L=f("--interactive-targets")||f("--actions"),M=!v&&!_&&!h&&!I&&!F&&!N&&!L?c[1]:null,u=I??M,j=await pt(o,{testId:v,role:_,type:h,text:u,pressable:F,visible:N,interactive:L});j||(console.error(l("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:A,result:E}=j,H=P(s),U=s.includes("--verbose")||s.includes("--dump");if(H)A==="interactive-targets"&&Array.isArray(E)?D(Be(E).map(S=>({...S,tap:Ce(S)}))):D(E??null);else if(Array.isArray(E))if(E.length===0){console.log(` no ${A} nodes found`);let S=await o.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof S=="number"&&S<10&&Q("app-still-loading",S)}else if(A==="interactive-targets"){let S=Be(E);console.log(` found ${S.length} interactive target${S.length===1?"":"s"} (sorted by score):`);for(let O of S.slice(0,20)){let J=O.absolutePosition?`@(${Math.round(O.absolutePosition.x)},${Math.round(O.absolutePosition.y)})`:"",K=O.layout?`${Math.round(O.layout.width)}x${Math.round(O.layout.height)}`:"?x?",ee=O.text?` "${O.text.slice(0,30)}"`:"",te=O.testID?` #${O.testID}`:"",re=O.accessibilityLabel?` \u24D8"${String(O.accessibilityLabel).slice(0,24)}"`:"",xe=O.accessibilityRole?`[${O.accessibilityRole}]`:O.type,C=Ce(O);console.log(` ${xe}${ee}${re}${te} ${K} ${J}`),console.log(` \u2192 ${C}`),U&&console.log(Xe(JSON.stringify(O,null,2)," "))}S.length>20&&console.log(` ... and ${S.length-20} more`)}else{console.log(` found ${E.length} node${E.length===1?"":"s"} (${A}):`);for(let S of E.slice(0,20)){let O=S.absolutePosition?`@(${Math.round(S.absolutePosition.x)},${Math.round(S.absolutePosition.y)})`:"",J=S.layout?`${Math.round(S.layout.width)}x${Math.round(S.layout.height)}`:"?x?",K=S.text?` "${S.text.slice(0,30)}"`:"",ee=S.testID?` #${S.testID}`:"",te=S.pressable?" (tap)":"",re=S.accessibilityRole?`[${S.accessibilityRole}]`:S.type;console.log(` ${re}${K}${ee} ${J} ${O}${te}`),U&&console.log(Xe(JSON.stringify(S,null,2)," "))}E.length>20&&console.log(` ... and ${E.length-20} more`)}else if(E==null)console.log(` not found: ${u||v||_||h||""||A}`),v&&Q("wait-selector-for-missing-testid",v);else{let S=E;if(S.type&&S.absolutePosition){let O=`@(${Math.round(S.absolutePosition.x)},${Math.round(S.absolutePosition.y)})`,J=S.layout?`${Math.round(S.layout.width)}x${Math.round(S.layout.height)}`:"?x?",K=S.text?` "${S.text.slice(0,40)}"`:"",ee=S.testID?` #${S.testID}`:"",te=S.pressable?" (tap)":"",re=S.accessibilityRole?`[${S.accessibilityRole}]`:S.type;console.log(` ${re}${K}${ee} ${J} ${O}${te}`),U&&console.log(Xe(JSON.stringify(S,null,2)," "))}else console.log(JSON.stringify(E,null,2))}}function Xe(e,o){return e.split(`
421
+ `)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let re=A||N||R||M;if((A||N||R)&&!y&&Q("describe-filter-context"),!re&&!y&&O.split(`
422
+ `).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(`
423
+ keyboard: ${le.join(" ")||"visible"}`)}};if(y)for(console.log(` watching... (Ctrl+C to stop)
424
+ `);;)console.clear(),await K(),await oe(b);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:a,positional:c,inspectUsage:l}=e,p=v=>{let O=a.indexOf(v);return O>=0&&O+1<a.length?a[O+1]:null},y=v=>a.includes(v),b=p("--testid")||p("--test-id"),_=p("--role"),h=p("--type"),I=p("--text"),F=y("--pressable"),N=y("--visible"),L=y("--interactive-targets")||y("--actions"),M=!b&&!_&&!h&&!I&&!F&&!N&&!L?c[1]:null,u=I??M,j=await pt(o,{testId:b,role:_,type:h,text:u,pressable:F,visible:N,interactive:L});j||(console.error(l("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:A,result:R}=j,K=P(s),U=s.includes("--verbose")||s.includes("--dump");if(K)A==="interactive-targets"&&Array.isArray(R)?D(Be(R).map(v=>({...v,tap:Ce(v)}))):D(R??null);else if(Array.isArray(R))if(R.length===0){console.log(` no ${A} nodes found`);let v=await o.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof v=="number"&&v<10&&Q("app-still-loading",v)}else if(A==="interactive-targets"){let v=Be(R);console.log(` found ${v.length} interactive target${v.length===1?"":"s"} (sorted by score):`);for(let O of v.slice(0,20)){let J=O.absolutePosition?`@(${Math.round(O.absolutePosition.x)},${Math.round(O.absolutePosition.y)})`:"",H=O.layout?`${Math.round(O.layout.width)}x${Math.round(O.layout.height)}`:"?x?",ee=O.text?` "${O.text.slice(0,30)}"`:"",te=O.testID?` #${O.testID}`:"",re=O.accessibilityLabel?` \u24D8"${String(O.accessibilityLabel).slice(0,24)}"`:"",xe=O.accessibilityRole?`[${O.accessibilityRole}]`:O.type,C=Ce(O);console.log(` ${xe}${ee}${re}${te} ${H} ${J}`),console.log(` \u2192 ${C}`),U&&console.log(Xe(JSON.stringify(O,null,2)," "))}v.length>20&&console.log(` ... and ${v.length-20} more`)}else{console.log(` found ${R.length} node${R.length===1?"":"s"} (${A}):`);for(let v of R.slice(0,20)){let O=v.absolutePosition?`@(${Math.round(v.absolutePosition.x)},${Math.round(v.absolutePosition.y)})`:"",J=v.layout?`${Math.round(v.layout.width)}x${Math.round(v.layout.height)}`:"?x?",H=v.text?` "${v.text.slice(0,30)}"`:"",ee=v.testID?` #${v.testID}`:"",te=v.pressable?" (tap)":"",re=v.accessibilityRole?`[${v.accessibilityRole}]`:v.type;console.log(` ${re}${H}${ee} ${J} ${O}${te}`),U&&console.log(Xe(JSON.stringify(v,null,2)," "))}R.length>20&&console.log(` ... and ${R.length-20} more`)}else if(R==null)console.log(` not found: ${u||b||_||h||""||A}`),b&&Q("wait-selector-for-missing-testid",b);else{let v=R;if(v.type&&v.absolutePosition){let O=`@(${Math.round(v.absolutePosition.x)},${Math.round(v.absolutePosition.y)})`,J=v.layout?`${Math.round(v.layout.width)}x${Math.round(v.layout.height)}`:"?x?",H=v.text?` "${v.text.slice(0,40)}"`:"",ee=v.testID?` #${v.testID}`:"",te=v.pressable?" (tap)":"",re=v.accessibilityRole?`[${v.accessibilityRole}]`:v.type;console.log(` ${re}${H}${ee} ${J} ${O}${te}`),U&&console.log(Xe(JSON.stringify(v,null,2)," "))}else console.log(JSON.stringify(R,null,2))}}function Xe(e,o){return e.split(`
397
425
  `).map(s=>o+s).join(`
398
426
  `)}async function Vt(e){let{bridge:o,args:s}=e,a=P(s);await de(o,{verbose:!a});let c=s.includes("--styling"),l=await ct(o,{styling:c});if(a){D({count:l.length,elements:l});return}console.log(` layout (${l.length} element${l.length===1?"":"s"}):
399
- `),console.log(ut(l,{styling:c}))}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:a,spec:c,mode:l,shifted:p,capsLock:f,accessoryBarId:v}=s,_=[];_.push(`keyboard: ${a?"visible":"hidden"}`),c?(_.push(` type: ${c.keyboardType}`),_.push(` returnKey: ${c.returnKeyType}`),_.push(` autoCap: ${c.autoCapitalize}`),_.push(` autoCorrect: ${c.autoCorrect?"on":"off"}`),_.push(` appearance: ${c.keyboardAppearance}`),c.secureTextEntry&&_.push(" secureTextEntry: true"),c.enablesReturnKeyAutomatically&&_.push(` return: ${c.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):_.push(" spec: <none> (shown via dev-tools with no TextInput)"),_.push(` mode: ${l}${p?" (shifted)":""}${f?" (caps)":""}`),v&&_.push(` accessoryBar: ${v}`),console.log(_.join(`
400
- `))}async function Zt(e){let o=await e.bridge.listSims(),s=e.args.includes("--all"),a=e.args.find((f,v)=>e.args[v-1]==="--bundle"),c=e.args.find((f,v)=>e.args[v-1]==="--app-port"),l=e.args.includes("--primary"),p=o.filter(f=>!(l&&!f.isPrimary||a&&!(f.url??"").includes(a)||c&&!(f.url??"").includes(`/rn/${c}`)||!s&&!a&&!c&&!l&&!(f.url&&(f.url.includes("bundle=")||f.url.includes("/index.bundle")))&&f.id!==e.simId));if(P(e.args)){D(p.map(f=>({...f,active:f.id===e.simId})));return}Pt(p,e.simId),p.length<o.length&&!P(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=(a,c)=>{c&&(c.nodesRegistered!=null&&(o[`${a}.nodes`]=c.nodesRegistered),c.nodesDetached!=null&&(o[`${a}.detached`]=c.nodesDetached),c.objects&&(o[`${a}.paragraphs`]=c.objects.paragraphs,o[`${a}.yogaNodes`]=c.objects.yogaNodes,o[`${a}.pictures`]=c.objects.pictures,o[`${a}.rasterImages`]=c.objects.rasterImages),c.imageLoader&&(o[`${a}.imageCacheEntries`]=c.imageLoader.cacheEntries,o[`${a}.imagePixelBytes`]=c.imageLoader.cachePixelBytes),c.workerHeap&&(o[`${a}.heapBytes`]=c.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 a=Object.entries(o.detachedTypes??{}).map(([c,l])=>`${c}:${l}`).join(" ");console.log(` nodes detached: ${o.nodesDetached}${a?` (${a})`:""}`)}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 a=o.imageLoader;console.log(` image cache: ${a.cacheEntries}/${a.cacheMaxEntries} entries, ${ae(a.cachePixelBytes)}/${ae(a.cachePixelBudget)} (${rs(a.cachePixelBytes,a.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 a=e.indexOf(o);if(a===-1)return s;let c=Number(e[a+1]);return Number.isFinite(c)&&c>0?c:s}async function oo(e,o={args:[]}){let s=P(o.args),a=o.args.indexOf("--watch");if(a===-1){let M=await We(e);if(s){D(M);return}as(M);return}let c=Number(o.args[a+1]),l=Number.isFinite(c)&&c>0?c:60,p=ls(o.args,"--interval",5),f=[],v=Date.now(),_=null;for(s||console.log(` sampling every ${p}s for ${l}s \u2014 deltas per tick:`);;){let M=await We(e),u=(Date.now()-v)/1e3,j=is(M);if(f.push({tSec:u,counters:j}),!s){let A=[];for(let[E,H]of Object.entries(j)){let U=_&&E in _?H-_[E]:null;if(U===null||U===0)continue;let S=U>0?"+":"-",O=E.endsWith("Bytes")?`${S}${ae(Math.abs(U))}`:`${S}${Math.abs(U)}`;A.push(`${E} ${eo(E,H)} (${O})`)}console.log(` t+${u.toFixed(0)}s ${A.length?A.join(" "):_?"no change":Object.entries(j).map(([E,H])=>`${E} ${eo(E,H)}`).join(" ")}`)}if(_=j,u>=l)break;await new Promise(A=>setTimeout(A,p*1e3))}let h=f[0],I=f[f.length-1],F=Math.max(I.tSec-h.tSec,.001),N={};for(let M of Object.keys(I.counters))M in h.counters&&(N[M]=(I.counters[M]-h.counters[M])/F);if(s){D({samples:f,perSecond:N,elapsedSec:F});return}console.log(`
427
+ `),console.log(ut(l,{styling:c}))}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:a,spec:c,mode:l,shifted:p,capsLock:y,accessoryBarId:b}=s,_=[];_.push(`keyboard: ${a?"visible":"hidden"}`),c?(_.push(` type: ${c.keyboardType}`),_.push(` returnKey: ${c.returnKeyType}`),_.push(` autoCap: ${c.autoCapitalize}`),_.push(` autoCorrect: ${c.autoCorrect?"on":"off"}`),_.push(` appearance: ${c.keyboardAppearance}`),c.secureTextEntry&&_.push(" secureTextEntry: true"),c.enablesReturnKeyAutomatically&&_.push(` return: ${c.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):_.push(" spec: <none> (shown via dev-tools with no TextInput)"),_.push(` mode: ${l}${p?" (shifted)":""}${y?" (caps)":""}`),b&&_.push(` accessoryBar: ${b}`),console.log(_.join(`
428
+ `))}async function Zt(e){let o=await e.bridge.listSims(),s=e.args.includes("--all"),a=e.args.find((y,b)=>e.args[b-1]==="--bundle"),c=e.args.find((y,b)=>e.args[b-1]==="--app-port"),l=e.args.includes("--primary"),p=o.filter(y=>!(l&&!y.isPrimary||a&&!(y.url??"").includes(a)||c&&!(y.url??"").includes(`/rn/${c}`)||!s&&!a&&!c&&!l&&!(y.url&&(y.url.includes("bundle=")||y.url.includes("/index.bundle")))&&y.id!==e.simId));if(P(e.args)){D(p.map(y=>({...y,active:y.id===e.simId})));return}Pt(p,e.simId),p.length<o.length&&!P(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=(a,c)=>{c&&(c.nodesRegistered!=null&&(o[`${a}.nodes`]=c.nodesRegistered),c.nodesDetached!=null&&(o[`${a}.detached`]=c.nodesDetached),c.objects&&(o[`${a}.paragraphs`]=c.objects.paragraphs,o[`${a}.yogaNodes`]=c.objects.yogaNodes,o[`${a}.pictures`]=c.objects.pictures,o[`${a}.rasterImages`]=c.objects.rasterImages),c.imageLoader&&(o[`${a}.imageCacheEntries`]=c.imageLoader.cacheEntries,o[`${a}.imagePixelBytes`]=c.imageLoader.cachePixelBytes),c.workerHeap&&(o[`${a}.heapBytes`]=c.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 a=Object.entries(o.detachedTypes??{}).map(([c,l])=>`${c}:${l}`).join(" ");console.log(` nodes detached: ${o.nodesDetached}${a?` (${a})`:""}`)}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 a=o.imageLoader;console.log(` image cache: ${a.cacheEntries}/${a.cacheMaxEntries} entries, ${ae(a.cachePixelBytes)}/${ae(a.cachePixelBudget)} (${rs(a.cachePixelBytes,a.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 a=e.indexOf(o);if(a===-1)return s;let c=Number(e[a+1]);return Number.isFinite(c)&&c>0?c:s}async function oo(e,o={args:[]}){let s=P(o.args),a=o.args.indexOf("--watch");if(a===-1){let M=await We(e);if(s){D(M);return}as(M);return}let c=Number(o.args[a+1]),l=Number.isFinite(c)&&c>0?c:60,p=ls(o.args,"--interval",5),y=[],b=Date.now(),_=null;for(s||console.log(` sampling every ${p}s for ${l}s \u2014 deltas per tick:`);;){let M=await We(e),u=(Date.now()-b)/1e3,j=is(M);if(y.push({tSec:u,counters:j}),!s){let A=[];for(let[R,K]of Object.entries(j)){let U=_&&R in _?K-_[R]:null;if(U===null||U===0)continue;let v=U>0?"+":"-",O=R.endsWith("Bytes")?`${v}${ae(Math.abs(U))}`:`${v}${Math.abs(U)}`;A.push(`${R} ${eo(R,K)} (${O})`)}console.log(` t+${u.toFixed(0)}s ${A.length?A.join(" "):_?"no change":Object.entries(j).map(([R,K])=>`${R} ${eo(R,K)}`).join(" ")}`)}if(_=j,u>=l)break;await new Promise(A=>setTimeout(A,p*1e3))}let h=y[0],I=y[y.length-1],F=Math.max(I.tSec-h.tSec,.001),N={};for(let M of Object.keys(I.counters))M in h.counters&&(N[M]=(I.counters[M]-h.counters[M])/F);if(s){D({samples:y,perSecond:N,elapsedSec:F});return}console.log(`
401
429
  slope over ${F.toFixed(0)}s:`);let L=Object.entries(N).filter(([,M])=>M!==0).sort((M,u)=>Math.abs(u[1])-Math.abs(M[1]));if(L.length===0){console.log(" all counters flat");return}for(let[M,u]of L){let j=M.endsWith("Bytes")?`${ae(Math.abs(u))}/s${u<0?" (shrinking)":""}`:`${u>0?"+":""}${u.toFixed(2)}/s`;console.log(` ${M.padEnd(28)}${j}`)}}var Z="<redacted secure text>";function be(e){let o=e?.layout?.spec??e?.spec??null;return!!o?.secureTextEntry&&o.keyboardType!=="visible-password"}function Ve(e,o){return be(o)?Z:e}function Qe(e){if(!e||!be(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 we(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 a=e.indexOf("--text");return a>=0&&e[a+1]?{mode:"text",value:e[a+1]}:null}async function Oe(e,o){let s=JSON.stringify(o.value),a=o.mode==="testid"?`(await t.findByTestId(${s})) || (await t.findById(${s}))`:`await t.findByText(${s})`;return await e.send({type:"evaluate",code:`(async () => {
402
430
  const t = window.__sootsimTest
403
431
  if (!t) return null
@@ -423,12 +451,12 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
423
451
  text: ${JSON.stringify(o.mode==="text")} ? ${s} : (n.text ?? n.accessibilityLabel ?? null),
424
452
  type: n.type ?? null,
425
453
  }
426
- })()`})??null}async function so(e,o={}){let{nav:s,keyboard:a,shell:c}=await vt(e);if(o.json){console.log(JSON.stringify({shell:c??null,nav:s,keyboard:a},null,2));return}let l=[];if(c){let p=c.activeApp??c.state??"<none>",f=c.showSwitcher?" (app switcher open)":"",v=typeof c.launchProgress=="number"&&c.launchProgress<.98?` launching (${Math.round(c.launchProgress*100)}%)`:"";l.push(`shell: ${p}${f}${v}`)}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 f of s.screens){let v=f.isActive?"\u25B6":" ",_=f.routeName?` ${f.routeName}`:"",h=f.headerHeight>0?` header=${f.headerHeight}`:"",I=f.largeTitleState&&f.largeTitleState!=="expanded"?` large-title=${f.largeTitleState}`:"";l.push(` ${v} #${f.id}${_}${h}${I}`)}}else l.push("nav: <runtime not available>");if(a&&a.visible){let p=a.spec?.keyboardType??"default",f=a.spec?.returnKeyType??"default";l.push(`keyboard: visible (${p}, return=${f}, mode=${a.mode??"?"})`)}else l.push("keyboard: hidden");console.log(l.join(`
427
- `))}async function no(e){let{bridge:o,args:s,positional:a}=e,c=a[1]?Number(a[1])*1e3:3e3,l=s.includes("--strict"),{elapsed:p,settled:f}=await se({bridge:o,maxMs:c,strict:l});console.log(f?` 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:a}=e,c=s.includes("--boxes"),l=a[1]?Number(a[1]):c?50:5,{tree:p}=await it(o,l,c?{format:"boxes"}:void 0);if(P(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(P(o.args)){D(s);return}console.log(s.url)}async function lo(e){let{wsPort:o,commandTimeoutMs:s,simId:a,simIdSource:c,positional:l}=e,p=l[1]?Number(l[1]):30,f=Math.max(1e3,(Number.isFinite(p)?p:30)*1e3),v=Math.max(1,Math.ceil(f/500));console.log(" waiting for sim reconnect...");let _=await Mt(o,s,a,{attempts:v,simIdSource:c});_||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),_.bridge.close(),Fe({source:"inspect wait",step:{wait:f},summary:`wait ${Math.round(f/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 Re(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,a=[];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&&a.push(p)}let c=a.join(" ");return o.equals?a.some(l=>l===o.equals):o.filter?c.toLowerCase().includes(o.filter.toLowerCase()):!0}async function uo(e){let{bridge:o,args:s,positional:a,inspectUsage:c}=e,l=a[1];l||(console.error(c("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=Re(s,"--max-ms"),f=p&&Number.isFinite(Number(p))?Math.max(100,Number(p)):5e3,v=Re(s,"--filter"),_=Re(s,"--equals"),h=Re(s,"--since")??"now",I=s.includes("--json"),F=Date.now(),N=F+f,L=200,M=F;for(;Date.now()<N;){let j={kinds:[l],since:h==="cursor"?void 0:M,limit:50},A=await o.send({type:"evaluate",code:`(async () => {
454
+ })()`})??null}async function so(e,o={}){let{nav:s,keyboard:a,shell:c}=await vt(e);if(o.json){console.log(JSON.stringify({shell:c??null,nav:s,keyboard:a},null,2));return}let l=[];if(c){let p=c.activeApp??c.state??"<none>",y=c.showSwitcher?" (app switcher open)":"",b=typeof c.launchProgress=="number"&&c.launchProgress<.98?` launching (${Math.round(c.launchProgress*100)}%)`:"";l.push(`shell: ${p}${y}${b}`)}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 b=y.isActive?"\u25B6":" ",_=y.routeName?` ${y.routeName}`:"",h=y.headerHeight>0?` header=${y.headerHeight}`:"",I=y.largeTitleState&&y.largeTitleState!=="expanded"?` large-title=${y.largeTitleState}`:"";l.push(` ${b} #${y.id}${_}${h}${I}`)}}else l.push("nav: <runtime not available>");if(a&&a.visible){let p=a.spec?.keyboardType??"default",y=a.spec?.returnKeyType??"default";l.push(`keyboard: visible (${p}, return=${y}, mode=${a.mode??"?"})`)}else l.push("keyboard: hidden");console.log(l.join(`
455
+ `))}async function no(e){let{bridge:o,args:s,positional:a}=e,c=a[1]?Number(a[1])*1e3:3e3,l=s.includes("--strict"),{elapsed:p,settled:y}=await se({bridge:o,maxMs:c,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:a}=e,c=s.includes("--boxes"),l=a[1]?Number(a[1]):c?50:5,{tree:p}=await it(o,l,c?{format:"boxes"}:void 0);if(P(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(P(o.args)){D(s);return}console.log(s.url)}async function lo(e){let{wsPort:o,commandTimeoutMs:s,simId:a,simIdSource:c,positional:l}=e,p=l[1]?Number(l[1]):30,y=Math.max(1e3,(Number.isFinite(p)?p:30)*1e3),b=Math.max(1,Math.ceil(y/500));console.log(" waiting for sim reconnect...");let _=await Mt(o,s,a,{attempts:b,simIdSource:c});_||(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,a=[];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&&a.push(p)}let c=a.join(" ");return o.equals?a.some(l=>l===o.equals):o.filter?c.toLowerCase().includes(o.filter.toLowerCase()):!0}async function uo(e){let{bridge:o,args:s,positional:a,inspectUsage:c}=e,l=a[1];l||(console.error(c("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,b=Ee(s,"--filter"),_=Ee(s,"--equals"),h=Ee(s,"--since")??"now",I=s.includes("--json"),F=Date.now(),N=F+y,L=200,M=F;for(;Date.now()<N;){let j={kinds:[l],since:h==="cursor"?void 0:M,limit:50},A=await o.send({type:"evaluate",code:`(async () => {
428
456
  const t = window.SootSim?.bridges?.timeline
429
457
  if (!t) return { ok: false, error: 'timeline bridge missing' }
430
458
  return { ok: true, result: await t.recent(${JSON.stringify(j)}) }
431
- })()`});(!A||!A.ok)&&(console.error(` could not query timeline: ${A&&"error"in A?A.error:"unknown"}`),process.exit(1));let E=A.result.events??[];for(let H of E)if(cs(H,{filter:v,equals:_})){let U=Date.now()-F;console.log(I?JSON.stringify({found:!0,elapsedMs:U,event:H}):` ${l} event after ${U}ms${v?` (filter: ${v})`:""}${_?` (equals: ${_})`:""}`);return}A.result.watermark&&A.result.watermark>M&&(M=A.result.watermark),await new Promise(H=>setTimeout(H,L))}let u=Date.now()-F;I?console.log(JSON.stringify({found:!1,elapsedMs:u,kind:l,filter:v,equals:_})):console.error(` \u26A0 wait event ${l} timed out after ${u}ms${v?` (filter: ${v})`:""}${_?` (equals: ${_})`:""}`),process.exit(1)}async function po(e){let{bridge:o,args:s}=e,a=s.includes("--strict"),c=ve(s,3e3),{elapsed:l,settled:p}=await se({bridge:o,maxMs:c,strict:a});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,a=ve(s,2e4),{ready:c,elapsedMs:l,nodes:p,targets:f,flag:v,loadingText:_,externalReady:h,externalError:I,suppressedEntryError:F,errors:N}=await mt(o,a,{onProgress(M){console.error(` still waiting after ${M.elapsedMs}ms \u2014 ${je(M)} (nodes: ${M.nodes}, targets: ${M.targets}, errors: ${M.errors})`)}});if(c){let M=a-l,u=Math.max(100,Math.min(1e4,M)),j=await se({bridge:o,maxMs:u,pollMs:32,stablePolls:2});j.settled||(console.error(` \u26A0 wait ready timed out after ${l+j.elapsed}ms \u2014 app mounted but did not settle (nodes: ${p}, targets: ${f})`),process.exit(1)),console.log(` ready in ${l+j.elapsed}ms: ${p} nodes, ${f} targets`);return}let L=je({externalError:I,loadingText:_,externalReady:h,flag:v,targets:f,suppressedEntryError:F});console.error(` \u26A0 wait ready timed out after ${l}ms \u2014 ${L} (nodes: ${p}, targets: ${f}, errors: ${N})`),process.exit(1)}async function fo(e){let{bridge:o,args:s,positional:a,inspectUsage:c}=e,l=a[1];l||(console.error(c("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let p=s.indexOf("--max-ms"),f=p>=0&&s[p+1]?Math.max(100,Number(s[p+1])):5e3,v=s.includes("--gone"),{found:_,node:h,elapsed:I}=await ft(o,l,f,{gone:v});if(v){_?console.log(` #${l} gone after ${I}ms`):(console.error(` \u26A0 wait selector #${l} --gone timed out after ${I??f}ms (still present)`),process.exit(1));return}if(_&&h){let F=h.absolutePosition?`@(${Math.round(h.absolutePosition.x)},${Math.round(h.absolutePosition.y)})`:"",N=h.layout?`${Math.round(h.layout.width)}x${Math.round(h.layout.height)}`:"?x?";console.log(` found #${l} in ${I}ms ${N} ${F}`)}else console.error(` \u26A0 wait selector #${l} timed out after ${I??f}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:
459
+ })()`});(!A||!A.ok)&&(console.error(` could not query timeline: ${A&&"error"in A?A.error:"unknown"}`),process.exit(1));let R=A.result.events??[];for(let K of R)if(cs(K,{filter:b,equals:_})){let U=Date.now()-F;console.log(I?JSON.stringify({found:!0,elapsedMs:U,event:K}):` ${l} event after ${U}ms${b?` (filter: ${b})`:""}${_?` (equals: ${_})`:""}`);return}A.result.watermark&&A.result.watermark>M&&(M=A.result.watermark),await new Promise(K=>setTimeout(K,L))}let u=Date.now()-F;I?console.log(JSON.stringify({found:!1,elapsedMs:u,kind:l,filter:b,equals:_})):console.error(` \u26A0 wait event ${l} timed out after ${u}ms${b?` (filter: ${b})`:""}${_?` (equals: ${_})`:""}`),process.exit(1)}async function po(e){let{bridge:o,args:s}=e,a=s.includes("--strict"),c=ve(s,3e3),{elapsed:l,settled:p}=await se({bridge:o,maxMs:c,strict:a});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,a=ve(s,2e4),{ready:c,elapsedMs:l,nodes:p,targets:y,flag:b,loadingText:_,externalReady:h,externalError:I,suppressedEntryError:F,errors:N}=await mt(o,a,{onProgress(M){console.error(` still waiting after ${M.elapsedMs}ms \u2014 ${je(M)} (nodes: ${M.nodes}, targets: ${M.targets}, errors: ${M.errors})`)}});if(c){let M=a-l,u=Math.max(100,Math.min(1e4,M)),j=await se({bridge:o,maxMs:u,pollMs:32,stablePolls:2});j.settled||(console.error(` \u26A0 wait ready timed out after ${l+j.elapsed}ms \u2014 app mounted but did not settle (nodes: ${p}, targets: ${y})`),process.exit(1)),console.log(` ready in ${l+j.elapsed}ms: ${p} nodes, ${y} targets`);return}let L=je({externalError:I,loadingText:_,externalReady:h,flag:b,targets:y,suppressedEntryError:F});console.error(` \u26A0 wait ready timed out after ${l}ms \u2014 ${L} (nodes: ${p}, targets: ${y}, errors: ${N})`),process.exit(1)}async function fo(e){let{bridge:o,args:s,positional:a,inspectUsage:c}=e,l=a[1];l||(console.error(c("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,b=s.includes("--gone"),{found:_,node:h,elapsed:I}=await ft(o,l,y,{gone:b});if(b){_?console.log(` #${l} gone after ${I}ms`):(console.error(` \u26A0 wait selector #${l} --gone timed out after ${I??y}ms (still present)`),process.exit(1));return}if(_&&h){let F=h.absolutePosition?`@(${Math.round(h.absolutePosition.x)},${Math.round(h.absolutePosition.y)})`:"",N=h.layout?`${Math.round(h.layout.width)}x${Math.round(h.layout.height)}`:"?x?";console.log(` found #${l} in ${I}ms ${N} ${F}`)}else console.error(` \u26A0 wait selector #${l} timed out after ${I??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:
432
460
  sootsim close --sim <id> # force-close the wedged sim
433
461
  sootsim list # confirm it's gone
434
462
  `)}async function ds(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 () => {
@@ -451,8 +479,8 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
451
479
  return []
452
480
  }
453
481
  })()`});if(!Array.isArray(s)||s.length===0)return;let a=o.toLowerCase(),c=s.map(l=>({id:l,score:ms(a,l.toLowerCase())})).filter(l=>l.score<a.length+4).sort((l,p)=>l.score-p.score).slice(0,5);if(c.length===0)return;console.error(" similar testIDs:");for(let l of c)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),a=new Array(o.length+1);for(let c=0;c<=o.length;c++)s[c]=c;for(let c=1;c<=e.length;c++){a[0]=c;for(let p=1;p<=o.length;p++)a[p]=Math.min(s[p]+1,a[p-1]+1,s[p-1]+(e[c-1]===o[p-1]?0:1));let l=s;s=a,a=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),a=e.method.padEnd(5),c=ko(e.size).padStart(6),l=_o(e.durationMs);console.log(` [${o}] ${s} ${a} ${c} ${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,a]of o)console.log(` ${s.padEnd(13)} ${a}`)}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),a=e.level.toUpperCase().padEnd(5),c=e.args.join(" ");if(o){let l=hs[e.level];console.log(` ${bs}[${s}]${bo} ${l}${a}${bo} ${c}`)}else console.log(` [${s}] ${a} ${c}`);if(e.stack&&e.level==="error"){let l=e.stack.split(`
454
- `).slice(0,5);for(let p of l)console.log(` ${p.trim()}`)}}var ws=120;async function xo(e,o){let s=e.find((F,N)=>e[N-1]==="--id"),a=e.find((F,N)=>e[N-1]==="--text");if(s||a){let F=await o.send({type:"evaluate",code:At({id:s,text:a})});if(!F)throw new Error(s?`no node with id "${s}"`:`no node matching text "${a}"`);let{x:N,y:L,w:M,h:u}=F;return{x:N,y:L,w:M,h:u}}let c=e.find((F,N)=>e[N-1]==="--area");if(c){let F=c.split(",").map(j=>Number(j.trim()));if(F.length!==4||F.some(j=>!Number.isFinite(j)))throw new Error(`--area expects x,y,w,h (got "${c}")`);let[N,L,M,u]=F;return{x:N,y:L,w:M,h:u}}let l=F=>{let N=e.find((M,u)=>e[u-1]===F);if(N==null)return null;let L=Number(N);return Number.isFinite(L)?L:null},p=l("--x"),f=l("--y"),v=l("--w"),_=l("--h");if(p!=null||f!=null||v!=null||_!=null)return{x:p??0,y:f??0,w:v??1,h:_??1};let I=e.filter((F,N)=>N>0&&!F.startsWith("-")&&e[N-1]!=="--output"&&e[N-1]!=="--area"&&e[N-1]!=="--id"&&e[N-1]!=="--text"&&e[N-1]!=="--x"&&e[N-1]!=="--y"&&e[N-1]!=="--w"&&e[N-1]!=="--h").map(Number).filter(F=>Number.isFinite(F));if(I.length>=2){let[F,N,L=1,M=1]=I;return{x:F,y:N,w:L,h:M}}return null}function $o(e){let o=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?";console.log(` shell frame profile:
455
- `),console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` avg: ${e.avgMs}ms (${o} fps) \xB7 max ${e.maxMs}ms`),console.log(` p50/p95/p99: ${e.p50} / ${e.p95} / ${e.p99} ms`),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 s=e.cadence;s&&typeof s=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${s.vsyncTicks} vsync ticks):`),console.log(` display clock: ${s.displayHz}hz \xB7 host rAF interval p50 ${s.hostIntervalP50} / p95 ${s.hostIntervalP95} / max ${s.hostIntervalMax} ms${s.hostGaps?` \xB7 ${s.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${s.deliveryLagP50} / p95 ${s.deliveryLagP95} / max ${s.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${s.paintIntervalP50} / p95 ${s.paintIntervalP95} / max ${s.paintIntervalMax} ms${s.idleBreaks?` \xB7 ${s.idleBreaks} idle breaks excluded`:""}`));let a=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[];if(a.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let p of a)console.log(` ${String(p.surfaceId).padEnd(10)} ${String(p.frames).padStart(4)} paints avg ${p.avgMs}ms (layout ${p.avgLayoutMs}, render ${p.avgRenderMs}, flush ${p.avgFlushMs}) max ${p.maxMs}ms`)}let c=e.renderProfile;if(c&&typeof c=="object"){console.log(""),console.log(" render profile (per frame):"),console.log(` node visits: ${c.nodeVisitsPerFrame}`),console.log(` boundaries: ${c.recordsPerFrame} records (${c.avgBoundaryRecordMs}ms) / ${c.replaysPerFrame} replays`),console.log(` raster tier: ${c.rasterPromotionsPerFrame} promotions / ${c.rasterBlitsPerFrame} blits`);let p=[c.rasterRejectRebuild?`rebuild ${c.rasterRejectRebuild}`:"",c.rasterRejectLinear?`linear ${c.rasterRejectLinear}`:"",c.rasterRejectAnimated?`animated ${c.rasterRejectAnimated}`:"",c.rasterRejectTransform?`transform ${c.rasterRejectTransform}`:"",c.rasterRejectOpacity?`opacity ${c.rasterRejectOpacity}`:"",c.rasterRejectCacheable?`cacheable ${c.rasterRejectCacheable}`:"",c.rasterRejectBounds?`bounds ${c.rasterRejectBounds}`:"",c.rasterRejectPixels?`pixels ${c.rasterRejectPixels}`:"",c.rasterWarming?`warming ${c.rasterWarming}`:""].filter(Boolean).join(" \xB7 ");p&&console.log(` raster skips: ${p} (total across run)`),console.log(` blur: ${c.avgBlurMs}ms`),console.log(` draw calls: text ${c.textDrawsPerFrame} \xB7 image ${c.imageDrawsPerFrame} \xB7 path ${c.pathDrawsPerFrame} \xB7 saveLayer ${c.saveLayersPerFrame}`)}let l=Array.isArray(e.worstFrames)?e.worstFrames:[];if(l.length>0){console.log(""),console.log(" worst frames (of last 100):");for(let p of l){let f=(p.auxSurfaces??[]).map(v=>`${v.surfaceId} ${v.totalMs}ms (layout ${v.layoutMs}, render ${v.renderMs})`).join(" \xB7 ");console.log(` ${String(p.totalMs).padStart(7)}ms overlay ${p.overlayMs} \xB7 aux ${p.auxMs} \xB7 layout ${p.layoutMs}${f?` [${f}]`:""}`)}}}async function Ee(e,o,s){let a=Date.now()+o,c=await ue(e,o);for(;;){if(s(c))return{settled:!0,state:c};if(Date.now()>=a)return{settled:!1,state:c};await oe(16),c=await ue(e)}}async function et(e){return e.send({type:"evaluate",code:`(async () => {
482
+ `).slice(0,5);for(let p of l)console.log(` ${p.trim()}`)}}var ws=120;async function xo(e,o){let s=e.find((F,N)=>e[N-1]==="--id"),a=e.find((F,N)=>e[N-1]==="--text");if(s||a){let F=await o.send({type:"evaluate",code:At({id:s,text:a})});if(!F)throw new Error(s?`no node with id "${s}"`:`no node matching text "${a}"`);let{x:N,y:L,w:M,h:u}=F;return{x:N,y:L,w:M,h:u}}let c=e.find((F,N)=>e[N-1]==="--area");if(c){let F=c.split(",").map(j=>Number(j.trim()));if(F.length!==4||F.some(j=>!Number.isFinite(j)))throw new Error(`--area expects x,y,w,h (got "${c}")`);let[N,L,M,u]=F;return{x:N,y:L,w:M,h:u}}let l=F=>{let N=e.find((M,u)=>e[u-1]===F);if(N==null)return null;let L=Number(N);return Number.isFinite(L)?L:null},p=l("--x"),y=l("--y"),b=l("--w"),_=l("--h");if(p!=null||y!=null||b!=null||_!=null)return{x:p??0,y:y??0,w:b??1,h:_??1};let I=e.filter((F,N)=>N>0&&!F.startsWith("-")&&e[N-1]!=="--output"&&e[N-1]!=="--area"&&e[N-1]!=="--id"&&e[N-1]!=="--text"&&e[N-1]!=="--x"&&e[N-1]!=="--y"&&e[N-1]!=="--w"&&e[N-1]!=="--h").map(Number).filter(F=>Number.isFinite(F));if(I.length>=2){let[F,N,L=1,M=1]=I;return{x:F,y:N,w:L,h:M}}return null}function $o(e){let o=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?";console.log(` shell frame profile:
483
+ `),console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` avg: ${e.avgMs}ms (${o} fps) \xB7 max ${e.maxMs}ms`),console.log(` p50/p95/p99: ${e.p50} / ${e.p95} / ${e.p99} ms`),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 s=e.cadence;s&&typeof s=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${s.vsyncTicks} vsync ticks):`),console.log(` display clock: ${s.displayHz}hz \xB7 host rAF interval p50 ${s.hostIntervalP50} / p95 ${s.hostIntervalP95} / max ${s.hostIntervalMax} ms${s.hostGaps?` \xB7 ${s.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${s.deliveryLagP50} / p95 ${s.deliveryLagP95} / max ${s.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${s.paintIntervalP50} / p95 ${s.paintIntervalP95} / max ${s.paintIntervalMax} ms${s.idleBreaks?` \xB7 ${s.idleBreaks} idle breaks excluded`:""}`));let a=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[];if(a.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let p of a)console.log(` ${String(p.surfaceId).padEnd(10)} ${String(p.frames).padStart(4)} paints avg ${p.avgMs}ms (layout ${p.avgLayoutMs}, render ${p.avgRenderMs}, flush ${p.avgFlushMs}) max ${p.maxMs}ms`)}let c=e.renderProfile;if(c&&typeof c=="object"){console.log(""),console.log(" render profile (per frame):"),console.log(` node visits: ${c.nodeVisitsPerFrame}`),console.log(` boundaries: ${c.recordsPerFrame} records (${c.avgBoundaryRecordMs}ms) / ${c.replaysPerFrame} replays`),console.log(` raster tier: ${c.rasterPromotionsPerFrame} promotions / ${c.rasterBlitsPerFrame} blits`);let p=[c.rasterRejectRebuild?`rebuild ${c.rasterRejectRebuild}`:"",c.rasterRejectLinear?`linear ${c.rasterRejectLinear}`:"",c.rasterRejectAnimated?`animated ${c.rasterRejectAnimated}`:"",c.rasterRejectTransform?`transform ${c.rasterRejectTransform}`:"",c.rasterRejectOpacity?`opacity ${c.rasterRejectOpacity}`:"",c.rasterRejectCacheable?`cacheable ${c.rasterRejectCacheable}`:"",c.rasterRejectBounds?`bounds ${c.rasterRejectBounds}`:"",c.rasterRejectPixels?`pixels ${c.rasterRejectPixels}`:"",c.rasterRejectBudget?`budget ${c.rasterRejectBudget}`:"",c.rasterWarming?`warming ${c.rasterWarming}`:""].filter(Boolean).join(" \xB7 ");p&&console.log(` raster skips: ${p} (total across run)`),console.log(` blur: ${c.avgBlurMs}ms`),console.log(` draw calls: text ${c.textDrawsPerFrame} \xB7 image ${c.imageDrawsPerFrame} \xB7 path ${c.pathDrawsPerFrame} \xB7 saveLayer ${c.saveLayersPerFrame}`)}let l=Array.isArray(e.worstFrames)?e.worstFrames:[];if(l.length>0){console.log(""),console.log(" worst frames (of last 100):");for(let p of l){let y=(p.auxSurfaces??[]).map(b=>`${b.surfaceId} ${b.totalMs}ms (layout ${b.layoutMs}, render ${b.renderMs})`).join(" \xB7 ");console.log(` ${String(p.totalMs).padStart(7)}ms overlay ${p.overlayMs} \xB7 aux ${p.auxMs} \xB7 layout ${p.layoutMs}${y?` [${y}]`:""}`)}}}async function Re(e,o,s){let a=Date.now()+o,c=await ue(e,o);for(;;){if(s(c))return{settled:!0,state:c};if(Date.now()>=a)return{settled:!1,state:c};await oe(16),c=await ue(e)}}async function et(e){return e.send({type:"evaluate",code:`(async () => {
456
484
  const kb = window.__sootsimKeyboard
457
485
  const test = window.__sootsimTest
458
486
  if (!kb) return { error: 'keyboard bridge not available' }
@@ -512,26 +540,26 @@ import{a as ce}from"./chunk-QPZW76ZB.js";import{b as Rt,c as Et,k as Pt}from"./c
512
540
  })()`}):e.send({type:"evaluate",code:`(async () => {
513
541
  window.dispatchEvent(new CustomEvent('sootsim:shake'))
514
542
  return { ok: true, action: 'shake' }
515
- })()`})}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 a=e.match(/^Key([A-Z])$/);return a?a[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 a=Number(s);return Number.isInteger(a)&&a>0?a:null}async function q(e,o,s){let a=Fe({source:e,step:o,summary:s});a.active&&(a.replaced?console.error(` draft: replaced unkept action "${a.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 a=Io(s.responderTestID,s.testID);if(a)return{step:{tapOn:{id:a}},summary:`tap #${a}`};let c=vs(s.text);return c?{step:{tapOn:c},summary:`tap "${c}"`}:{step:{tapAtCoords:{x:e,y:o}},summary:`tap @${Math.round(e)},${Math.round(o)}`}}function Ze(e,o,s){let a=Io(o?.testID,o?.id);return a?{step:{tapOn:{id:a}},summary:`tap #${a}`}: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,a=s?e.slice(1):e,c=_t(a,{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=c.positional,p=l[0],f=s==="get"||s==="do"||s==="debug"||s==="wait"?s:"inspect",v=typeof a[0]=="string"&&tt.has(a[0]),_=v?a[0]:null,h=x=>o.internalShellPerf&&x==="perf"?"sootsim perf shell":v&&x===a[0]?`sootsim ${x}`:`sootsim ${f} ${x}`,I=(x,t)=>` usage: ${h(x)}${t?` ${t}`:""}`;if(!p||e.includes("--help")||e.includes("-h")){let x={bridgePort:7668,defaultShellUrl:ot};if(f==="do"||f==="get"||f==="debug"||f==="wait"){let r=Ae(f,x);r&&(console.log(`${r}
543
+ })()`})}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 a=e.match(/^Key([A-Z])$/);return a?a[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 a=Number(s);return Number.isInteger(a)&&a>0?a:null}async function q(e,o,s){let a=Fe({source:e,step:o,summary:s});a.active&&(a.replaced?console.error(` draft: replaced unkept action "${a.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 a=Io(s.responderTestID,s.testID);if(a)return{step:{tapOn:{id:a}},summary:`tap #${a}`};let c=vs(s.text);return c?{step:{tapOn:c},summary:`tap "${c}"`}:{step:{tapAtCoords:{x:e,y:o}},summary:`tap @${Math.round(e)},${Math.round(o)}`}}function Ze(e,o,s){let a=Io(o?.testID,o?.id);return a?{step:{tapOn:{id:a}},summary:`tap #${a}`}: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,a=s?e.slice(1):e,c=_t(a,{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=c.positional,p=l[0],y=s==="get"||s==="do"||s==="debug"||s==="wait"?s:"inspect",b=typeof a[0]=="string"&&tt.has(a[0]),_=b?a[0]:null,h=x=>o.internalShellPerf&&x==="perf"?"sootsim perf shell":b&&x===a[0]?`sootsim ${x}`:`sootsim ${y} ${x}`,I=(x,t)=>` usage: ${h(x)}${t?` ${t}`:""}`;if(!p||e.includes("--help")||e.includes("-h")){let x={bridgePort:7668,defaultShellUrl:ot};if(y==="do"||y==="get"||y==="debug"||y==="wait"){let r=Ae(y,x);r&&(console.log(`${r}
516
544
  `),process.exit(0))}if(_==="shell"){let r=De("shell",x);r&&(console.log(`${r}
517
545
  `),process.exit(0))}let t=De("inspect",x),n=["do","get","debug","wait"].map(r=>Ae(r,x)).filter(r=>r!=null).join(`
518
546
 
519
547
  `);console.log(`${t??""}
520
548
 
521
549
  ${n}
522
- `),process.exit(0)}let F=c.wsPort,N=c.simId,L=c.simIdSource,M=c.commandTimeoutMs;if(f==="get"&&p==="diagnosis"){let x=a.indexOf("diagnosis"),t=x>=0?[...a.slice(0,x),...a.slice(x+1)]:a,{runDiagnose:n}=await import("./diagnose-7INR3HKD.js"),r=await n(["recent",...t],o);process.exitCode=r;return}if(f==="do"&&p==="scan"){let{runCamera:x}=await import("./camera-MPIQ3JAA.js");await x(a,{port:o.port});return}if(p==="list"&&a.some(x=>x==="--drivers"||x==="-D")){let{buildDriverListRows:x}=await import("./drivers-Z2TX4DMF.js"),t=x();console.log(` available drivers (${t.length}):
523
- `);let n=Math.max(...t.map(i=>i.id.length),6),r=Math.max(...t.map(i=>i.kind.length),4);for(let i of t){let d=i.available?"\u2713":"\u2717",m=i.id.padEnd(n),g=i.kind.padEnd(r);console.log(` ${d} ${m} ${g} ${i.description}`),i.available&&i.detail?console.log(` ${i.detail}`):!i.available&&i.reason&&console.log(` unavailable: ${i.reason}`)}return}let u=It(c),j=N||"default",A=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","storage-clear","list","wait","sleep"]),E=200;function H(x){let t=x.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec(x)?.[1]?.trim(),i=/<body[^>]*>([\s\S]*?)<\//i.exec(x)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),d=r||i||"html error page";return`<html ${x.length}B> "${d}" (body elided \u2014 add --json for the full payload)`}return t.length<=E?t:`${t.slice(0,E)}\u2026 (+${t.length-E} more bytes)`}function U(x){let t=x.displayUrl||x.url;return x.status!=null?`${x.method} ${t} -> ${x.status}${x.statusText?` ${x.statusText}`:""}`:x.error?`${x.method} ${t} -> ${x.error}`:`${x.method} ${t}`}async function S(x){let t=me()?400:200;try{let{settled:n,elapsed:r}=await se({bridge:x,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.
524
- `)}catch{}}function O(x,t){console.error(` tap failed: ${x} 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 u.send({type:"evaluate",code:`(() => ({
550
+ `),process.exit(0)}let F=c.wsPort,N=c.simId,L=c.simIdSource,M=c.commandTimeoutMs;if(y==="get"&&p==="diagnosis"){let x=a.indexOf("diagnosis"),t=x>=0?[...a.slice(0,x),...a.slice(x+1)]:a,{runDiagnose:n}=await import("./diagnose-OAXHSPXW.js"),r=await n(["recent",...t],o);process.exitCode=r;return}if(y==="do"&&p==="scan"){let{runCamera:x}=await import("./camera-XICNRGGO.js");await x(a,{port:o.port});return}if(p==="list"&&a.some(x=>x==="--drivers"||x==="-D")){let{buildDriverListRows:x}=await import("./drivers-LJAA7XSZ.js"),t=x();console.log(` available drivers (${t.length}):
551
+ `);let n=Math.max(...t.map(i=>i.id.length),6),r=Math.max(...t.map(i=>i.kind.length),4);for(let i of t){let d=i.available?"\u2713":"\u2717",m=i.id.padEnd(n),f=i.kind.padEnd(r);console.log(` ${d} ${m} ${f} ${i.description}`),i.available&&i.detail?console.log(` ${i.detail}`):!i.available&&i.reason&&console.log(` unavailable: ${i.reason}`)}return}let u=It(c),j=N||"default",A=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","storage-clear","list","wait","sleep"]),R=200;function K(x){let t=x.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec(x)?.[1]?.trim(),i=/<body[^>]*>([\s\S]*?)<\//i.exec(x)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),d=r||i||"html error page";return`<html ${x.length}B> "${d}" (body elided \u2014 add --json for the full payload)`}return t.length<=R?t:`${t.slice(0,R)}\u2026 (+${t.length-R} more bytes)`}function U(x){let t=x.displayUrl||x.url;return x.status!=null?`${x.method} ${t} -> ${x.status}${x.statusText?` ${x.statusText}`:""}`:x.error?`${x.method} ${t} -> ${x.error}`:`${x.method} ${t}`}async function v(x){let t=me()?400:200;try{let{settled:n,elapsed:r}=await se({bridge:x,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.
552
+ `)}catch{}}function O(x,t){if(t.result?.reason==="offscreen"){let{x:n,y:r,screen:i}=t.result;console.error(` tap failed: ${x} resolved to (${Math.round(n)},${Math.round(r)}), outside the ${i?.width}x${i?.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: ${x} 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 u.send({type:"evaluate",code:`(() => ({
525
553
  console: ${ke},
526
554
  requests: window.__sootsimTest?.getRequestCounts?.() || null,
527
- }))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function K(x={}){let t=x.counts!==void 0?x.counts:await V(u,"getRequestCounts");if(!t||typeof t!="object")return;let n=Math.max(0,Number(t.failed)||0);if(n===0||!x.includeTail&&!ze("requests",j,String(n))||(console.log(`
555
+ }))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function H(x={}){let t=x.counts!==void 0?x.counts:await V(u,"getRequestCounts");if(!t||typeof t!="object")return;let n=Math.max(0,Number(t.failed)||0);if(n===0||!x.includeTail&&!ze("requests",j,String(n))||(console.log(`
528
556
  network: ${n} failed request${n===1?"":"s"}`),console.log(` inspect: ${h("requests")} 5`),!x.includeTail))return;let r=await V(u,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
529
557
  recent failed requests:
530
- `);for(let i of r){let d=ie(i.timestamp);console.log(` [${d}] ${U(i)}`),i.responseBody?console.log(` ${H(i.responseBody)}`):i.error&&console.log(` ${i.error}`)}}}function ee(x){for(let t of x){let n=t.title?` (\u201C${t.title}\u201D)`:"";console.log(`
558
+ `);for(let i of r){let d=ie(i.timestamp);console.log(` [${d}] ${U(i)}`),i.responseBody?console.log(` ${K(i.responseBody)}`):i.error&&console.log(` ${i.error}`)}}}function ee(x){for(let t of x){let n=t.title?` (\u201C${t.title}\u201D)`:"";console.log(`
531
559
  note: ${t.label} is open${n} \u2014 taps/drags hit it, not the app`)}}async function te(x={}){let t=x.counts!==void 0?x.counts:await u.send({type:"evaluate",code:ke});if(!t||typeof t!="object")return;let n=t,r=Math.max(0,Number(n.errors)||0),i=Math.max(0,Number(n.warnings)||0);if(r===0&&i===0||!x.includeTail&&!ze("console",j,`${r}:${i}`))return;let d=[];if(r>0&&d.push(`${r} console error${r===1?"":"s"}`),i>0&&d.push(`${i} console warning${i===1?"":"s"}`),console.log(`
532
560
  console: ${d.join(", ")}`),console.log(` inspect: ${h("errors")} 5`),i>0&&console.log(` inspect: ${h("warnings")} 5`),!x.includeTail||r===0)return;let m=await fe(u,5);if(!(!Array.isArray(m)||m.length===0)){console.log(`
533
561
  recent console errors:
534
- `);for(let g of m){let b=ie(g.timestamp),y=Array.isArray(g.args)?g.args.map($=>typeof $=="object"?JSON.stringify($):String($)).join(" "):String(g);console.log(` [${b}] ${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(x){let t=st(),n=null;try{n=await Nt(x,`(() => {
562
+ `);for(let f of m){let w=ie(f.timestamp),g=Array.isArray(f.args)?f.args.map(S=>typeof S=="object"?JSON.stringify(S):String(S)).join(" "):String(f);console.log(` [${w}] ${g}`)}}}let re=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function xe(x){let t=st(),n=null;try{n=await Nt(x,`(() => {
535
563
  const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
536
564
  if (!tl || typeof tl.summary !== 'function') return null
537
565
  const cursorKey = ${JSON.stringify(t)}
@@ -547,9 +575,9 @@ ${n}
547
575
  }
548
576
  }
549
577
  return summary ? { summary, consoleSplit } : null
550
- })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},i=[],d=new Set;for(let m of re){let g=r[m];if(g)if(d.add(m),m==="console"&&n.consoleSplit){let{error:b,warn:y}=n.consoleSplit;b>0&&i.push(`${b} error${b===1?"":"s"}`),y>0&&i.push(`${y} warning${y===1?"":"s"}`)}else i.push(`${g} ${m}${g===1?"":"s"}`)}for(let[m,g]of Object.entries(r))!d.has(m)&&g&&i.push(`${g} ${m}${g===1?"":"s"}`);if(i.length!==0&&(console.log(`
551
- since last: ${i.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await _e(x,"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"]),$e=(e.includes("--verbose")||e.includes("-v"))&&!e.includes("--json");f==="do"&&p==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),C.has(p)&&await Tt(u),le.has(p)&&await de(u,{verbose:$e});try{let x=C.has(p)&&!P(a)?await $t(u):[];switch(p){case"list":{kt(c.wsPort),await Zt({bridge:u,simId:N,args:a});break}case"tree":{await io({bridge:u,args:a,positional:l});break}case"a11y":{let t=await dt(u);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):
552
- `);for(let n of t){let r=[];if(r.push(`[${n.role}]`),n.label){let i=n.label.length>50?n.label.slice(0,47)+"...":n.label;r.push(`"${i}"`)}if(n.hint&&r.push(`(hint: "${n.hint}")`),n.testID&&r.push(`#${n.testID}`),n.state){let i=[];n.state.disabled&&i.push("disabled"),n.state.selected&&i.push("selected"),n.state.checked===!0&&i.push("checked"),n.state.checked==="mixed"&&i.push("mixed"),n.state.busy&&i.push("busy"),n.state.expanded===!0&&i.push("expanded"),n.state.expanded===!1&&i.push("collapsed"),i.length&&r.push(`{${i.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:u,args:e,effectiveArgs:a,positional:l,inspectUsage:I});break}case"count":{await zt(u,{args:a});break}case"keyboard":{await Qt(u,{json:e.includes("--json")});break}case"screens":{await so(u,{json:e.includes("--json")});break}case"memory":{await oo(u,{args:a});break}case"wait":{await lo({wsPort:F,commandTimeoutMs:M,simId:N,simIdSource:L,positional:l});break}case"sleep":{await ro({positional:l,inspectUsage:I});break}case"settle":{await no({bridge:u,args:e,positional:l});break}case"ready":{await mo({bridge:u,args:e});break}case"idle":{await po({bridge:u,args:e,positional:l});break}case"selector":{await fo({bridge:u,args:e,positional:l,inspectUsage:I});break}case"event":{await uo({bridge:u,args:e,positional:l,inspectUsage:I});break}case"layout":{let t=l[1];if(!t){await Vt({bridge:u,args:a});break}let n=await u.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((b,y)=>e[y-1]==="--output")||"/tmp/sootsim-inspect.png",r=await xo(e,u),i={type:"screenshot"};r&&(i.crop=r);let m=(await u.send(i)).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 xo(e,u);t||(console.error(I("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 u.send({type:"evaluate",code:Dt(t)});if(e.includes("--json"))console.log(JSON.stringify(n,null,2));else{let{r,g:i,b:d,a:m,hex:g,samples:b}=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}, ${i}, ${d}, ${m}) ${y} ${b} samples`)}break}case"node":{let t=l[1];t||(console.error(I("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let n=await u.send({type:"evaluate",code:`(async () => {
578
+ })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},i=[],d=new Set;for(let m of re){let f=r[m];if(f)if(d.add(m),m==="console"&&n.consoleSplit){let{error:w,warn:g}=n.consoleSplit;w>0&&i.push(`${w} error${w===1?"":"s"}`),g>0&&i.push(`${g} warning${g===1?"":"s"}`)}else i.push(`${f} ${m}${f===1?"":"s"}`)}for(let[m,f]of Object.entries(r))!d.has(m)&&f&&i.push(`${f} ${m}${f===1?"":"s"}`);if(i.length!==0&&(console.log(`
579
+ since last: ${i.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await _e(x,"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"]),$e=(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(u),le.has(p)&&await de(u,{verbose:$e});try{let x=C.has(p)&&!P(a)?await $t(u):[];switch(p){case"list":{kt(c.wsPort),await Zt({bridge:u,simId:N,args:a});break}case"tree":{await io({bridge:u,args:a,positional:l});break}case"a11y":{let t=await dt(u);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):
580
+ `);for(let n of t){let r=[];if(r.push(`[${n.role}]`),n.label){let i=n.label.length>50?n.label.slice(0,47)+"...":n.label;r.push(`"${i}"`)}if(n.hint&&r.push(`(hint: "${n.hint}")`),n.testID&&r.push(`#${n.testID}`),n.state){let i=[];n.state.disabled&&i.push("disabled"),n.state.selected&&i.push("selected"),n.state.checked===!0&&i.push("checked"),n.state.checked==="mixed"&&i.push("mixed"),n.state.busy&&i.push("busy"),n.state.expanded===!0&&i.push("expanded"),n.state.expanded===!1&&i.push("collapsed"),i.length&&r.push(`{${i.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:u,args:e,effectiveArgs:a,positional:l,inspectUsage:I});break}case"count":{await zt(u,{args:a});break}case"keyboard":{await Qt(u,{json:e.includes("--json")});break}case"screens":{await so(u,{json:e.includes("--json")});break}case"memory":{await oo(u,{args:a});break}case"wait":{await lo({wsPort:F,commandTimeoutMs:M,simId:N,simIdSource:L,positional:l});break}case"sleep":{await ro({positional:l,inspectUsage:I});break}case"settle":{await no({bridge:u,args:e,positional:l});break}case"ready":{await mo({bridge:u,args:e});break}case"idle":{await po({bridge:u,args:e,positional:l});break}case"selector":{await fo({bridge:u,args:e,positional:l,inspectUsage:I});break}case"event":{await uo({bridge:u,args:e,positional:l,inspectUsage:I});break}case"layout":{let t=l[1];if(!t){await Vt({bridge:u,args:a});break}let n=await u.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,g)=>e[g-1]==="--output")||"/tmp/sootsim-inspect.png",r=await xo(e,u),i={type:"screenshot"};r&&(i.crop=r);let m=(await u.send(i)).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 xo(e,u);t||(console.error(I("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 u.send({type:"evaluate",code:Dt(t)});if(e.includes("--json"))console.log(JSON.stringify(n,null,2));else{let{r,g:i,b:d,a:m,hex:f,samples:w}=n,g=t.w===1&&t.h===1?`@(${t.x},${t.y})`:`@(${t.x},${t.y}) ${t.w}x${t.h}`;console.log(` ${f} rgba(${r}, ${i}, ${d}, ${m}) ${g} ${w} samples`)}break}case"node":{let t=l[1];t||(console.error(I("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let n=await u.send({type:"evaluate",code:`(async () => {
553
581
  const t = window.__sootsimTest
554
582
  const q = ${JSON.stringify(t)}
555
583
  let node = null
@@ -605,17 +633,17 @@ ${n}
605
633
  transform,
606
634
  parentChain,
607
635
  }
608
- })()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let t=Number(l[1]),n=Number(l[2]),r=we(e);if(r){let m=await he(u,{agent:me(),textFallback:r.mode==="text"?r.value:void 0,resolve:async()=>{let y=await Oe(u,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)||(O(`${r.mode} "${r.value}"`,m),process.exit(1));let b=vo(g.cx,g.cy,m.result);b&&await q("inspect tap",b.step,b.summary),console.log(JSON.stringify({...m.attempts>1?{attempts:m.attempts}:{},...m.result},null,2));break}(!Number.isFinite(t)||!Number.isFinite(n))&&(console.error(I("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let i=await Kt(u,t,n),d=vo(t,n,i);d&&await q("inspect tap",d.step,d.summary),console.log(JSON.stringify(i,null,2));break}case"drag":case"swipe":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),i=Number(l[4]),d=p==="swipe"?10:12,m=p==="swipe"?8:16,g=l[5]?Number(l[5]):d,b=l[6]?Number(l[6]):m;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(g)||!Number.isFinite(b))&&(console.error(I(p,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let y=await u.send({type:"evaluate",code:`(async () => {
636
+ })()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let t=Number(l[1]),n=Number(l[2]),r=we(e);if(r){let m=await he(u,{agent:me(),textFallback:r.mode==="text"?r.value:void 0,resolve:async()=>{let g=await Oe(u,r);return g?{cx:g.x,cy:g.y,match:{id:r.mode==="testid"?r.value:g.id??null,testID:r.mode==="testid"?r.value:g.testID??null,text:r.mode==="text"?r.value:g.text??null,type:g.type??null},target:{id:g.id??null,testID:g.testID??null,text:g.text??null,type:g.type??null}}:null}}),f=m.payload;(!f||typeof f.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)||(O(`${r.mode} "${r.value}"`,m),process.exit(1));let w=vo(f.cx,f.cy,m.result);w&&await q("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(I("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let i=await Ht(u,t,n),d=vo(t,n,i);d&&await q("inspect tap",d.step,d.summary),console.log(JSON.stringify(i,null,2));break}case"drag":case"swipe":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),i=Number(l[4]),d=p==="swipe"?10:12,m=p==="swipe"?8:16,f=l[5]?Number(l[5]):d,w=l[6]?Number(l[6]):m;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(f)||!Number.isFinite(w))&&(console.error(I(p,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let g=await u.send({type:"evaluate",code:`(async () => {
609
637
  const interact = window.__sootsimInteract
610
638
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
611
- const value = await interact.drag(${t}, ${n}, ${r}, ${i}, ${Math.max(1,Math.round(g))}, ${Math.max(0,Math.round(b))})
639
+ const value = await interact.drag(${t}, ${n}, ${r}, ${i}, ${Math.max(1,Math.round(f))}, ${Math.max(0,Math.round(w))})
612
640
  return { ok: !!value, value }
613
- })()`});if(y?.ok){let $=Math.max(1,Math.round(Math.max(1,g)*Math.max(0,b)));await q(`inspect ${p}`,{swipe:{start:`${t}, ${n}`,end:`${r}, ${i}`,duration:$}},`${p} ${t},${n} -> ${r},${i}`)}console.log(JSON.stringify(y,null,2));break}case"pinch":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),i=Number(l[4]),d=Number(l[5]),m=Number(l[6]),g=Number(l[7]),b=Number(l[8]),y=l[9]?Number(l[9]):12,$=l[10]?Number(l[10]):16;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(d)||!Number.isFinite(m)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(y)||!Number.isFinite($))&&(console.error(I("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let W=await u.send({type:"evaluate",code:`(async () => {
641
+ })()`});if(g?.ok){let S=Math.max(1,Math.round(Math.max(1,f)*Math.max(0,w)));await q(`inspect ${p}`,{swipe:{start:`${t}, ${n}`,end:`${r}, ${i}`,duration:S}},`${p} ${t},${n} -> ${r},${i}`)}console.log(JSON.stringify(g,null,2));break}case"pinch":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),i=Number(l[4]),d=Number(l[5]),m=Number(l[6]),f=Number(l[7]),w=Number(l[8]),g=l[9]?Number(l[9]):12,S=l[10]?Number(l[10]):16;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(d)||!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite(w)||!Number.isFinite(g)||!Number.isFinite(S))&&(console.error(I("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let W=await u.send({type:"evaluate",code:`(async () => {
614
642
  const interact = window.__sootsimInteract
615
643
  if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
616
- const value = await interact.pinch(${t}, ${n}, ${r}, ${i}, ${d}, ${m}, ${g}, ${b}, ${Math.max(1,Math.round(y))}, ${Math.max(0,Math.round($))})
644
+ const value = await interact.pinch(${t}, ${n}, ${r}, ${i}, ${d}, ${m}, ${f}, ${w}, ${Math.max(1,Math.round(g))}, ${Math.max(0,Math.round(S))})
617
645
  return { ok: !!value, value }
618
- })()`});W?.ok&&await q("inspect pinch",{pinch:{from:[t,n,r,i],to:[d,m,g,b],steps:Math.max(1,Math.round(y)),stepMs:Math.max(0,Math.round($))}},`pinch (${t},${n}) (${r},${i}) -> (${d},${m}) (${g},${b})`),console.log(JSON.stringify(W,null,2));break}case"tap-text":{let t=l[1];t||(console.error(I("tap-text","<text>")),process.exit(1));let n=Y=>{let B=e.indexOf(Y);return B>=0&&B+1<e.length?e[B+1]:null},r=Y=>e.includes(Y),i=n("--nth")??n("--index"),d=i!==null?Number(i):null;d!==null&&!Number.isFinite(d)&&(console.error(` --nth/--index requires an integer, got: ${i}`),process.exit(1));let m=n("--within"),g=n("--role"),b=r("--exact"),y=r("--first"),$=n("--min-y"),W=n("--max-y"),X=n("--min-x"),G=n("--max-x");for(let[Y,B]of[["--min-y",$],["--max-y",W],["--min-x",X],["--max-x",G]])B!==null&&!Number.isFinite(Number(B))&&(console.error(` ${Y} requires a number, got: ${B}`),process.exit(1));let z=e.indexOf("--near"),R=null;if(z>=0){let Y=Number(e[z+1]),B=Number(e[z+2]);(!Number.isFinite(Y)||!Number.isFinite(B))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),R={x:Y,y:B}}let w={exact:b,role:g,within:m,minX:X!==null?Number(X):null,maxX:G!==null?Number(G):null,minY:$!==null?Number($):null,maxY:W!==null?Number(W):null,near:R,nth:d,first:y},k=await Ut(u,t,w,{agent:me()}),T=k.payload;if(T?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),T?.ambiguous){let Y=T.candidates;console.error(` ambiguous: ${T.total} matches for "${t}"`);for(let B of Y){let Se=B.abs?`@(${Math.round(B.abs.x)},${Math.round(B.abs.y)})`:"",To=B.layout?` ${B.layout.width}x${B.layout.height}`:"",No=B.testID?` #${B.testID}`:"",Mo=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}>${Mo}${No} ${Se}${To}${Fo}`)}T.total>Y.length&&console.error(` ... and ${T.total-Y.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(k.result)||(O(`text "${t}"`,k),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 q("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||d!==null?{nth:{index:T.idx,total:T.total}}:{},...k.attempts>1?{attempts:k.attempts}:{},result:k.result},null,2));break}case"tap-best":{let t=l[1];t||(console.error(I("tap-best","<query>")),process.exit(1));let n=await Gt(u,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 i=r.node;pe(n.result)||(O(`best "${t}"`,n),process.exit(1));let d=Ze(t,{id:i.id,testID:i.testID,type:i.type,cx:r.cx,cy:r.cy},r.strategy==="testid"?"id":"text");await q("inspect tap-best",d.step,d.summary),console.log(JSON.stringify({matched:{strategy:r.strategy,nodeId:i.nodeId,id:i.id,testID:i.testID,type:i.type,text:i.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(I("tap-id","<id>")),process.exit(1));let n=await Ht(u,t,{agent:me()}),r=n.payload;(!r||typeof r.cx!="number")&&(console.error(` not found: ${t}`),await ps(u,t),process.exit(1)),pe(n.result)||(O(`id "${t}"`,n),process.exit(1));let i=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 q("inspect tap-id",i.step,i.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(I("type-into","<id> <text>")),process.exit(1));let r=JSON.stringify(t),i=await u.send({type:"evaluate",code:`(async () => {
646
+ })()`});W?.ok&&await q("inspect pinch",{pinch:{from:[t,n,r,i],to:[d,m,f,w],steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round(S))}},`pinch (${t},${n}) (${r},${i}) -> (${d},${m}) (${f},${w})`),console.log(JSON.stringify(W,null,2));break}case"tap-text":{let t=l[1];t||(console.error(I("tap-text","<text>")),process.exit(1));let n=Y=>{let B=e.indexOf(Y);return B>=0&&B+1<e.length?e[B+1]:null},r=Y=>e.includes(Y),i=n("--nth")??n("--index"),d=i!==null?Number(i):null;d!==null&&!Number.isFinite(d)&&(console.error(` --nth/--index requires an integer, got: ${i}`),process.exit(1));let m=n("--within"),f=n("--role"),w=r("--exact"),g=r("--first"),S=n("--min-y"),W=n("--max-y"),X=n("--min-x"),G=n("--max-x");for(let[Y,B]of[["--min-y",S],["--max-y",W],["--min-x",X],["--max-x",G]])B!==null&&!Number.isFinite(Number(B))&&(console.error(` ${Y} requires a number, got: ${B}`),process.exit(1));let z=e.indexOf("--near"),E=null;if(z>=0){let Y=Number(e[z+1]),B=Number(e[z+2]);(!Number.isFinite(Y)||!Number.isFinite(B))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),E={x:Y,y:B}}let $={exact:w,role:f,within:m,minX:X!==null?Number(X):null,maxX:G!==null?Number(G):null,minY:S!==null?Number(S):null,maxY:W!==null?Number(W):null,near:E,nth:d,first:g},k=await Ut(u,t,$,{agent:me()}),T=k.payload;if(T?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),T?.ambiguous){let Y=T.candidates;console.error(` ambiguous: ${T.total} matches for "${t}"`);for(let B of Y){let Se=B.abs?`@(${Math.round(B.abs.x)},${Math.round(B.abs.y)})`:"",To=B.layout?` ${B.layout.width}x${B.layout.height}`:"",No=B.testID?` #${B.testID}`:"",Mo=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}>${Mo}${No} ${Se}${To}${Fo}`)}T.total>Y.length&&console.error(` ... and ${T.total-Y.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(k.result)||(O(`text "${t}"`,k),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 q("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||d!==null?{nth:{index:T.idx,total:T.total}}:{},...k.attempts>1?{attempts:k.attempts}:{},result:k.result},null,2));break}case"tap-best":{let t=l[1];t||(console.error(I("tap-best","<query>")),process.exit(1));let n=await Gt(u,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 i=r.node;pe(n.result)||(O(`best "${t}"`,n),process.exit(1));let d=Ze(t,{id:i.id,testID:i.testID,type:i.type,cx:r.cx,cy:r.cy},r.strategy==="testid"?"id":"text");await q("inspect tap-best",d.step,d.summary),console.log(JSON.stringify({matched:{strategy:r.strategy,nodeId:i.nodeId,id:i.id,testID:i.testID,type:i.type,text:i.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(I("tap-id","<id>")),process.exit(1));let n=await Kt(u,t,{agent:me()}),r=n.payload;(!r||typeof r.cx!="number")&&(console.error(` not found: ${t}`),await ps(u,t),process.exit(1)),pe(n.result)||(O(`id "${t}"`,n),process.exit(1));let i=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 q("inspect tap-id",i.step,i.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(I("type-into","<id> <text>")),process.exit(1));let r=JSON.stringify(t),i=await u.send({type:"evaluate",code:`(async () => {
619
647
  const t = window.__sootsimTest
620
648
  if (!t) return null
621
649
  const n = await (t.findByTestId(${r}) || t.findById(${r}))
@@ -630,7 +658,7 @@ ${n}
630
658
  secureTextEntry: !!n.secureTextEntry,
631
659
  placeholder: n.placeholder || null,
632
660
  }
633
- })()`});(!i||typeof i.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),i.isTextInput||console.error(` warning: ${t} is not a text input (isTextInput: false)`);let d=await u.send({type:"tap",x:i.cx,y:i.cy,target:{id:i.id??t,testID:i.testID??t,text:null,type:i.type??null}}),m=i.secureTextEntry===!0,g=await $s(u,1e3,{targetId:t,secureTextEntry:m});g.visible||(console.error(` keyboard did not open after tapping ${t}`),process.exit(1));let b=g.focusedInput;b&&(b.testID===t||b.id===t||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(t)} but focus is on ${JSON.stringify(b.testID??b.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await u.send({type:"keyboard",action:"type",text:n});let y=m||be(g),$=y?Z:Ve(n,g),W=y&&g.focusedInput?{...g.focusedInput,secureTextEntry:!0,text:typeof g.focusedInput.text=="string"?Z:g.focusedInput.text}:g.focusedInput??null;await q("inspect type-into",{tapOn:{id:t},inputText:$},$===Z?`type-into #${t} ${Z}`:`type-into #${t} ${JSON.stringify(n)}`),console.log(JSON.stringify({target:t,isTextInput:i.isTextInput,secureTextEntry:y,keyboardOpened:g.visible??d?.keyboardOpened??!1,focusedInput:W,typed:$},null,2));break}case"type":{let t=l.slice(1).join(" ");t||(console.error(I("type","<text>")),process.exit(1));let n=await Pe(u,"type");await u.send({type:"keyboard",action:"type",text:t});let r=Ve(t,n);await q("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(I("key","<name>")),process.exit(1)),await Pe(u,"key"),await u.send({type:"keyboard",action:"press",text:t}),await q("inspect key",{pressKey:t},`key ${t}`),console.log(` pressed: ${t}`);break}case"key-sequence":{let t=l.slice(1);t.length===0&&(console.error(I("key-sequence","<key> [<key> ...]")),process.exit(1)),await Pe(u,"key-sequence");for(let n of t)await u.send({type:"keyboard",action:"press",text:n});await q("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(I("keycode","<code> [<code> ...]")),process.exit(1));let n=t.map(i=>({code:i,key:Ss(i)})),r=n.filter(i=>!i.key);r.length>0&&(console.error(` unsupported keycode(s): ${r.map(i=>i.code).join(", ")}`),process.exit(1)),await Pe(u,"keycode");for(let i of n)await u.send({type:"keyboard",action:"press",text:i.key});await q("inspect keycode",{pressKey:n.map(i=>i.key).join(" ")},`keycode ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"dispatch":{let t=l[1];t||(console.error(I("dispatch","<char>")),process.exit(1)),await u.send({type:"keyboard",action:"dispatchKey",text:t}),await q("inspect dispatch",{dispatchKey:t},`dispatch ${JSON.stringify(t)}`),console.log(` dispatched: ${t}`);break}case"dismiss":{await u.send({type:"keyboard",action:"dismiss"}),await q("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let t=Number(l[1]),n=Number(l[2]),r=we(e);if(r){let g=await Oe(u,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 i=l[3]?Number(l[3]):80;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(i))&&(console.error(I("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let d=Math.max(0,Math.round(i)),m=await u.send({type:"evaluate",code:`(async () => {
661
+ })()`});(!i||typeof i.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),i.isTextInput||console.error(` warning: ${t} is not a text input (isTextInput: false)`);let d=await u.send({type:"tap",x:i.cx,y:i.cy,target:{id:i.id??t,testID:i.testID??t,text:null,type:i.type??null}}),m=i.secureTextEntry===!0,f=await $s(u,1e3,{targetId:t,secureTextEntry:m});f.visible||(console.error(` keyboard did not open after tapping ${t}`),process.exit(1));let w=f.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 u.send({type:"keyboard",action:"type",text:n});let g=m||be(f),S=g?Z:Ve(n,f),W=g&&f.focusedInput?{...f.focusedInput,secureTextEntry:!0,text:typeof f.focusedInput.text=="string"?Z:f.focusedInput.text}:f.focusedInput??null;await q("inspect type-into",{tapOn:{id:t},inputText:S},S===Z?`type-into #${t} ${Z}`:`type-into #${t} ${JSON.stringify(n)}`),console.log(JSON.stringify({target:t,isTextInput:i.isTextInput,secureTextEntry:g,keyboardOpened:f.visible??d?.keyboardOpened??!1,focusedInput:W,typed:S},null,2));break}case"type":{let t=l.slice(1).join(" ");t||(console.error(I("type","<text>")),process.exit(1));let n=await Pe(u,"type");await u.send({type:"keyboard",action:"type",text:t});let r=Ve(t,n);await q("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(I("key","<name>")),process.exit(1)),await Pe(u,"key"),await u.send({type:"keyboard",action:"press",text:t}),await q("inspect key",{pressKey:t},`key ${t}`),console.log(` pressed: ${t}`);break}case"key-sequence":{let t=l.slice(1);t.length===0&&(console.error(I("key-sequence","<key> [<key> ...]")),process.exit(1)),await Pe(u,"key-sequence");for(let n of t)await u.send({type:"keyboard",action:"press",text:n});await q("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(I("keycode","<code> [<code> ...]")),process.exit(1));let n=t.map(i=>({code:i,key:Ss(i)})),r=n.filter(i=>!i.key);r.length>0&&(console.error(` unsupported keycode(s): ${r.map(i=>i.code).join(", ")}`),process.exit(1)),await Pe(u,"keycode");for(let i of n)await u.send({type:"keyboard",action:"press",text:i.key});await q("inspect keycode",{pressKey:n.map(i=>i.key).join(" ")},`keycode ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"dispatch":{let t=l[1];t||(console.error(I("dispatch","<char>")),process.exit(1)),await u.send({type:"keyboard",action:"dispatchKey",text:t}),await q("inspect dispatch",{dispatchKey:t},`dispatch ${JSON.stringify(t)}`),console.log(` dispatched: ${t}`);break}case"dismiss":{await u.send({type:"keyboard",action:"dismiss"}),await q("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let t=Number(l[1]),n=Number(l[2]),r=we(e);if(r){let f=await Oe(u,r);f||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=f.x,n=f.y}let i=l[3]?Number(l[3]):80;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(i))&&(console.error(I("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let d=Math.max(0,Math.round(i)),m=await u.send({type:"evaluate",code:`(async () => {
634
662
  const interact = window.__sootsimInteract
635
663
  if (interact?.doubleTap) {
636
664
  return {
@@ -653,13 +681,13 @@ ${n}
653
681
  first,
654
682
  second,
655
683
  }
656
- })()`});m?.ok&&await q("inspect double-tap",{doubleTapAtCoords:{x:t,y:n,gapMs:d}},`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=we(e),i=null;if(r){let y=await Oe(u,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,i={id:y.id??null,testID:y.testID??null,text:y.text??null,type:y.type??null}}let d=r?l[1]:l[3],m=d?Number(d):600;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(m))&&(console.error(I("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let g=Math.max(0,Math.round(m)),b=await u.send({type:"longPress",x:t,y:n,durationMs:g,target:i});b?.ok&&await q("inspect long-press",{tapAtCoords:{x:t,y:n}},`long-press @${t},${n}`),console.log(JSON.stringify(b,null,2));break}case"touch":{let t=l[1],n=Number(l[2]),r=Number(l[3]),i=l[4]?Number(l[4]):999,d=t==="down"?"touchDown":t==="move"?"touchMove":t==="up"?"touchUp":t==="cancel"?"touchCancel":null;d||(console.error(I("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),t!=="cancel"&&(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(I("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} } }));`:"",b=await u.send({type:"evaluate",code:`(async () => {
657
- ${g}
684
+ })()`});m?.ok&&await q("inspect double-tap",{doubleTapAtCoords:{x:t,y:n,gapMs:d}},`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=we(e),i=null;if(r){let g=await Oe(u,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,i={id:g.id??null,testID:g.testID??null,text:g.text??null,type:g.type??null}}let d=r?l[1]:l[3],m=d?Number(d):600;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(m))&&(console.error(I("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let f=Math.max(0,Math.round(m)),w=await u.send({type:"longPress",x:t,y:n,durationMs:f,target:i});w?.ok&&await q("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]),i=l[4]?Number(l[4]):999,d=t==="down"?"touchDown":t==="move"?"touchMove":t==="up"?"touchUp":t==="cancel"?"touchCancel":null;d||(console.error(I("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),t!=="cancel"&&(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(I("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let m=t==="down"?"tap":t==="move"?"move":null,f=m&&Number.isFinite(n)&&Number.isFinite(r)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${m}', x: ${n}, y: ${r} } }));`:"",w=await u.send({type:"evaluate",code:`(async () => {
685
+ ${f}
658
686
  const interact = window.__sootsimInteract
659
687
  if (!interact?.${d}) return { ok: false, reason: 'no interact.${d}' }
660
688
  const value = ${t==="cancel"?`await interact.${d}(${Math.max(1,Math.round(i))})`:`await interact.${d}(${n}, ${r}, ${Math.max(1,Math.round(i))})`}
661
689
  return { ok: !!value, value }
662
- })()`});b?.ok&&t!=="cancel"&&await q("inspect touch",{tapAtCoords:{x:n,y:r}},`touch ${t} @${n},${r}`),console.log(JSON.stringify(b,null,2));break}case"gesture":{let t=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],n=l[1],r=l[2]?Number(l[2]):220;(!n||!Number.isFinite(r))&&(console.error(I("gesture","<preset> [durationMs]")),console.error(` presets: ${t.join(", ")}`),process.exit(1)),t.includes(n)||(console.error(` unknown gesture preset: ${n}`),console.error(` presets: ${t.join(", ")}`),process.exit(1));let i=await u.send({type:"evaluate",code:`(async () => {
690
+ })()`});w?.ok&&t!=="cancel"&&await q("inspect touch",{tapAtCoords:{x:n,y:r}},`touch ${t} @${n},${r}`),console.log(JSON.stringify(w,null,2));break}case"gesture":{let t=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],n=l[1],r=l[2]?Number(l[2]):220;(!n||!Number.isFinite(r))&&(console.error(I("gesture","<preset> [durationMs]")),console.error(` presets: ${t.join(", ")}`),process.exit(1)),t.includes(n)||(console.error(` unknown gesture preset: ${n}`),console.error(` presets: ${t.join(", ")}`),process.exit(1));let i=await u.send({type:"evaluate",code:`(async () => {
663
691
  const spec = globalThis.__sootsimDeviceSpec || {}
664
692
  return {
665
693
  width: spec.width || window.innerWidth || 393,
@@ -667,12 +695,12 @@ ${n}
667
695
  statusBarHeight: spec.statusBarHeight || 0,
668
696
  homeIndicatorHeight: spec.homeIndicatorHeight || 0,
669
697
  }
670
- })()`}),d=Number(i?.width)||393,m=Number(i?.height)||852,g=Number(i?.statusBarHeight)||0,b=Number(i?.homeIndicatorHeight)||0,y=Math.round(d/2),$=Math.round(m/2),W=Math.max(24,g+18),X=Math.max(24,b+18),G=18,z=Math.min(220,Math.round(m*.24)),R=Math.min(180,Math.round(d*.32)),w=y,k=$,T=y,ne=$;switch(n){case"scroll-up":k=$+Math.round(z/2),ne=$-Math.round(z/2);break;case"scroll-down":k=$-Math.round(z/2),ne=$+Math.round(z/2);break;case"scroll-left":w=y+Math.round(R/2),T=y-Math.round(R/2);break;case"scroll-right":w=y-Math.round(R/2),T=y+Math.round(R/2);break;case"swipe-from-left-edge":w=G,k=$,T=Math.min(d-G,G+R);break;case"swipe-from-right-edge":w=d-G,k=$,T=Math.max(G,d-G-R);break;case"swipe-from-top-edge":w=y,k=W,ne=Math.min(m-X,W+z);break;case"swipe-from-bottom-edge":w=y,k=m-X,ne=Math.max(W,m-X-z);break}let Y=Math.max(8,Math.round(r/16)),B=Math.max(1,Math.round(r/Y)),Se=await u.send({type:"evaluate",code:`(async () => {
698
+ })()`}),d=Number(i?.width)||393,m=Number(i?.height)||852,f=Number(i?.statusBarHeight)||0,w=Number(i?.homeIndicatorHeight)||0,g=Math.round(d/2),S=Math.round(m/2),W=Math.max(24,f+18),X=Math.max(24,w+18),G=18,z=Math.min(220,Math.round(m*.24)),E=Math.min(180,Math.round(d*.32)),$=g,k=S,T=g,ne=S;switch(n){case"scroll-up":k=S+Math.round(z/2),ne=S-Math.round(z/2);break;case"scroll-down":k=S-Math.round(z/2),ne=S+Math.round(z/2);break;case"scroll-left":$=g+Math.round(E/2),T=g-Math.round(E/2);break;case"scroll-right":$=g-Math.round(E/2),T=g+Math.round(E/2);break;case"swipe-from-left-edge":$=G,k=S,T=Math.min(d-G,G+E);break;case"swipe-from-right-edge":$=d-G,k=S,T=Math.max(G,d-G-E);break;case"swipe-from-top-edge":$=g,k=W,ne=Math.min(m-X,W+z);break;case"swipe-from-bottom-edge":$=g,k=m-X,ne=Math.max(W,m-X-z);break}let Y=Math.max(8,Math.round(r/16)),B=Math.max(1,Math.round(r/Y)),Se=await u.send({type:"evaluate",code:`(async () => {
671
699
  const interact = window.__sootsimInteract
672
700
  if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
673
- const value = await interact.drag(${w}, ${k}, ${T}, ${ne}, ${Y}, ${B})
701
+ const value = await interact.drag(${$}, ${k}, ${T}, ${ne}, ${Y}, ${B})
674
702
  return { ok: !!value, value }
675
- })()`});Se?.ok&&await q("inspect gesture",{swipe:{start:`${w}, ${k}`,end:`${T}, ${ne}`,duration:Math.max(1,Math.round(r))}},`gesture ${n}`),console.log(JSON.stringify({preset:n,from:{x:w,y:k},to:{x:T,y:ne},result:Se},null,2));break}case"scroll":{let t=we(e),n=ks(e),r=t?.mode==="testid"?t.value:n==null?l[1]:null,i=t||n!=null?1:2,d=Number(l[i]),m=Number(l[i+1]);(!r&&n==null||!Number.isFinite(d)||!Number.isFinite(m))&&(console.error(I("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),process.exit(1));let g=await u.send({type:"evaluate",code:`(async () => {
703
+ })()`});Se?.ok&&await q("inspect gesture",{swipe:{start:`${$}, ${k}`,end:`${T}, ${ne}`,duration:Math.max(1,Math.round(r))}},`gesture ${n}`),console.log(JSON.stringify({preset:n,from:{x:$,y:k},to:{x:T,y:ne},result:Se},null,2));break}case"scroll":{let t=we(e),n=ks(e),r=t?.mode==="testid"?t.value:n==null?l[1]:null,i=t||n!=null?1:2,d=Number(l[i]),m=Number(l[i+1]);(!r&&n==null||!Number.isFinite(d)||!Number.isFinite(m))&&(console.error(I("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),process.exit(1));let f=await u.send({type:"evaluate",code:`(async () => {
676
704
  const t = window.__sootsimTest
677
705
  if (!t) return null
678
706
  const n = ${n!=null?`await t.inspectByNodeId(${JSON.stringify(n)})`:`await t.findByTestId(${JSON.stringify(r)})
@@ -682,7 +710,7 @@ ${n}
682
710
  cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
683
711
  cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
684
712
  }
685
- })()`}),b=await V(u,"scrollTo",n!=null?{nodeId:n}:r,d,m,!1);if(b?.ok){let y=n!=null?`node ${n}`:`#${r}`;await q("inspect scroll",{scrollTo:{...n!=null?{nodeId:n}:{id:r},x:d,y:m}},`scroll ${y} -> ${d},${m}`)}console.log(JSON.stringify({...b,...g?{at:{x:g.cx,y:g.cy}}:{}},null,2));break}case"state":{let t=l[1];if(s==="get"&&!t){let r=await V(u,"getRuntimeState"),i=await u.send({type:"evaluate",code:ke});if(r&&typeof r=="object"&&r.diagnostics&&(r.diagnostics.errors=i?.errors??0,r.diagnostics.warnings=i?.warnings??0),r&&typeof r=="object"&&r.shell==null)try{let d=await ue(u);d&&(r.shell=d)}catch{}console.log(JSON.stringify(r,null,2));break}if(!t||t==="--help"||t==="-h"){console.log(`
713
+ })()`}),w=await V(u,"scrollTo",n!=null?{nodeId:n}:r,d,m,!1);if(w?.ok){let g=n!=null?`node ${n}`:`#${r}`;await q("inspect scroll",{scrollTo:{...n!=null?{nodeId:n}:{id:r},x:d,y:m}},`scroll ${g} -> ${d},${m}`)}console.log(JSON.stringify({...w,...f?{at:{x:f.cx,y:f.cy}}:{}},null,2));break}case"state":{let t=l[1];if(s==="get"&&!t){let r=await V(u,"getRuntimeState"),i=await u.send({type:"evaluate",code:ke});if(r&&typeof r=="object"&&r.diagnostics&&(r.diagnostics.errors=i?.errors??0,r.diagnostics.warnings=i?.warnings??0),r&&typeof r=="object"&&r.shell==null)try{let d=await ue(u);d&&(r.shell=d)}catch{}console.log(JSON.stringify(r,null,2));break}if(!t||t==="--help"||t==="-h"){console.log(`
686
714
  ${h("state")} \u2014 dump raw runtime state
687
715
 
688
716
  subcommands:
@@ -764,7 +792,7 @@ ${n}
764
792
  ${h("shell")} open-card clock 800
765
793
  ${h("shell")} appearance dark
766
794
  ${h("shell")} lock
767
- `);break}let n=t==="launch"||t==="open-card"||t==="home"||t==="switcher",r=t==="launch"||t==="open-card"?l[3]:l[2],i=r?Number(r):350;n&&(!Number.isFinite(i)||i<0)&&(console.error(I("shell",t==="launch"||t==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let d=!1,m=!1,g=null,b=e.includes("--clear-state");if(t==="launch"){let y=l[2];y||(console.error(I("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),b&&await u.send({type:"evaluate",code:qe(!0)}),d=!!await ge(u,"launchApp",i,y),{settled:m,state:g}=await Ee(u,Math.round(i),$=>!!$&&$.state==="app"&&$.activeApp===y&&$.showSwitcher===!1&&$.switcherPhase==="idle"&&typeof $.launchProgress=="number"&&$.launchProgress>=.98),d&&await q("inspect shell launch",b?{launchApp:{clearState:!0}}:{launchApp:{}},b?"launch app (clear state)":"launch app")}else if(t==="home")d=!!await ge(u,"goHome",i),{settled:m,state:g}=await Ee(u,Math.round(i),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")d=!!await ge(u,"openSwitcher",i),{settled:m,state:g}=await Ee(u,Math.round(i),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 ue(u));else if(t==="open-card"){let y=l[2];y||(console.error(I("shell","open-card <appId> [settleMs]")),process.exit(1)),d=!!await ge(u,"openSwitcherCard",i,y),{settled:m,state:g}=await Ee(u,Math.round(i),$=>!!$&&$.state==="app"&&$.activeApp===y&&$.showSwitcher===!1&&$.switcherPhase==="idle"&&typeof $.zoomLevel=="number"&&$.zoomLevel>=.98&&typeof $.horizontalZoom=="number"&&$.horizontalZoom>=.98),d&&await q("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(I("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let $=await So(u,"appearance",y);if(d=!!$?.ok,g={appearance:$},d){let W=$?.applied??y;console.log(` appearance: ${W}`)}}else if(t==="lock"||t==="shake"){let y=await So(u,t);d=!!y?.ok,g={[t]:y}}else console.error(` unknown shell subcommand: ${t}`),process.exit(1);console.log(JSON.stringify({ok:d,settled:m,state:g},null,2));break}case"url":{await ao(u,{args:a});break}case"reload":{let r=!1,i=!1;try{await u.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let g=await u.send({type:"evaluate",code:`;(async () => {
795
+ `);break}let n=t==="launch"||t==="open-card"||t==="home"||t==="switcher",r=t==="launch"||t==="open-card"?l[3]:l[2],i=r?Number(r):350;n&&(!Number.isFinite(i)||i<0)&&(console.error(I("shell",t==="launch"||t==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let d=!1,m=!1,f=null,w=e.includes("--clear-state");if(t==="launch"){let g=l[2];g||(console.error(I("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),w&&await u.send({type:"evaluate",code:qe(!0)}),d=!!await ge(u,"launchApp",i,g),{settled:m,state:f}=await Re(u,Math.round(i),S=>!!S&&S.state==="app"&&S.activeApp===g&&S.showSwitcher===!1&&S.switcherPhase==="idle"&&typeof S.launchProgress=="number"&&S.launchProgress>=.98),d&&await q("inspect shell launch",w?{launchApp:{clearState:!0}}:{launchApp:{}},w?"launch app (clear state)":"launch app")}else if(t==="home")d=!!await ge(u,"goHome",i),{settled:m,state:f}=await Re(u,Math.round(i),g=>!!g&&g.state==="home"&&g.activeApp==null&&g.showSwitcher===!1&&g.switcherPhase==="idle"&&typeof g.launchProgress=="number"&&g.launchProgress>=.98);else if(t==="switcher")d=!!await ge(u,"openSwitcher",i),{settled:m,state:f}=await Re(u,Math.round(i),g=>!!g&&g.state==="app"&&g.showSwitcher===!0&&g.switcherPhase==="idle"&&typeof g.zoomLevel=="number"&&Math.abs(g.zoomLevel)<=.02&&typeof g.horizontalZoom=="number"&&Math.abs(g.horizontalZoom)<=.02),m&&(await oe(ws),f=await ue(u));else if(t==="open-card"){let g=l[2];g||(console.error(I("shell","open-card <appId> [settleMs]")),process.exit(1)),d=!!await ge(u,"openSwitcherCard",i,g),{settled:m,state:f}=await Re(u,Math.round(i),S=>!!S&&S.state==="app"&&S.activeApp===g&&S.showSwitcher===!1&&S.switcherPhase==="idle"&&typeof S.zoomLevel=="number"&&S.zoomLevel>=.98&&typeof S.horizontalZoom=="number"&&S.horizontalZoom>=.98),d&&await q("inspect shell open-card",{openSwitcherCard:{appId:g}},`open switcher card ${g}`)}else if(t==="appearance"){let g=l[2];(!g||!["light","dark","auto","toggle"].includes(g))&&(console.error(I("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let S=await So(u,"appearance",g);if(d=!!S?.ok,f={appearance:S},d){let W=S?.applied??g;console.log(` appearance: ${W}`)}}else if(t==="lock"||t==="shake"){let g=await So(u,t);d=!!g?.ok,f={[t]:g}}else console.error(` unknown shell subcommand: ${t}`),process.exit(1);console.log(JSON.stringify({ok:d,settled:m,state:f},null,2));break}case"url":{await ao(u,{args:a});break}case"reload":{let r=!1,i=!1;try{await u.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let f=await u.send({type:"evaluate",code:`;(async () => {
768
796
  // in-place guest reload is only valid while the page still runs
769
797
  // the engine build the server would serve NOW. the shell dev
770
798
  // server has no HMR client, so a long-lived sim tab otherwise
@@ -788,13 +816,13 @@ ${n}
788
816
  }
789
817
  window.location.reload()
790
818
  return { kind: 'page', engineStale }
791
- })()`});i=!!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 d=u,m=null;if(i)m=await Te(u,{timeoutMs:1e4,errorGraceMs:3e3});else{r&&await oe(300);let b=await Ft(F,M,N,{timeoutMs:3e4,simIdSource:L});b?(d=b,m=await Te(b,{timeoutMs:3e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 30000ms"),d=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(d)try{let g=await fe(d,10);if(d!==u&&d.close(),Array.isArray(g)&&g.length>0){console.log(`
792
- \u26A0 ${g.length} error(s) during mount:
793
- `);for(let b of g){let y=b.args.map($=>typeof $=="object"?JSON.stringify($):$).join(" ");if(console.log(` ${y}`),b.stack){let $=b.stack.split(`
794
- `).slice(0,2);for(let W of $)console.log(` ${W.trim()}`)}}}}catch{}m&&!m.ready&&(process.exitCode=1);break}case"storage-clear":{if(await Le(u),await u.send({type:"evaluate",code:qe(!0)})!==!0){P(a)?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 i=await Te(u,{timeoutMs:1e4,errorGraceMs:3e3});if(P(a)){D({cleared:!0,ready:i.ready,reload:i}),i.ready||(process.exitCode=1);break}if(i.ready){let d=i.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` cleared tenant storage; ready in ${i.elapsedMs}ms: ${i.nodes} nodes${d}`)}else if(i.source==="error-bail")console.log(` \u26A0 storage clear reloaded but bailed after ${i.elapsedMs}ms: ${i.errors} console error(s), ready signal never fired`);else{let d=yo(i);console.log(` \u26A0 storage clear reloaded but timed out after ${i.elapsedMs}ms \u2014 ${d} (nodes: ${i.nodes}, targets: ${i.targets}, errors: ${i.errors})`)}try{let d=await fe(u,10);if(Array.isArray(d)&&d.length>0){console.log(`
819
+ })()`});i=!!f&&f.kind==="external-app",r=!0,f&&f.engineStale&&console.log(" engine build changed since page load \u2014 full page reload")}catch{}console.log(" reloading...");let d=u,m=null;if(i)m=await Te(u,{timeoutMs:1e4,errorGraceMs:3e3});else{r&&await oe(300);let w=await Ft(F,M,N,{timeoutMs:3e4,simIdSource:L});w?(d=w,m=await Te(w,{timeoutMs:3e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 30000ms"),d=null)}if(m)if(m.ready){let f=m.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${m.elapsedMs}ms: ${m.nodes} nodes${f}`)}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 f=yo(m);console.log(` \u26A0 reload timed out after ${m.elapsedMs}ms \u2014 ${f} (nodes: ${m.nodes}, targets: ${m.targets}, errors: ${m.errors})`)}if(d)try{let f=await fe(d,10);if(d!==u&&d.close(),Array.isArray(f)&&f.length>0){console.log(`
820
+ \u26A0 ${f.length} error(s) during mount:
821
+ `);for(let w of f){let g=w.args.map(S=>typeof S=="object"?JSON.stringify(S):S).join(" ");if(console.log(` ${g}`),w.stack){let S=w.stack.split(`
822
+ `).slice(0,2);for(let W of S)console.log(` ${W.trim()}`)}}}}catch{}m&&!m.ready&&(process.exitCode=1);break}case"storage-clear":{if(await Le(u),await u.send({type:"evaluate",code:qe(!0)})!==!0){P(a)?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 i=await Te(u,{timeoutMs:1e4,errorGraceMs:3e3});if(P(a)){D({cleared:!0,ready:i.ready,reload:i}),i.ready||(process.exitCode=1);break}if(i.ready){let d=i.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` cleared tenant storage; ready in ${i.elapsedMs}ms: ${i.nodes} nodes${d}`)}else if(i.source==="error-bail")console.log(` \u26A0 storage clear reloaded but bailed after ${i.elapsedMs}ms: ${i.errors} console error(s), ready signal never fired`);else{let d=yo(i);console.log(` \u26A0 storage clear reloaded but timed out after ${i.elapsedMs}ms \u2014 ${d} (nodes: ${i.nodes}, targets: ${i.targets}, errors: ${i.errors})`)}try{let d=await fe(u,10);if(Array.isArray(d)&&d.length>0){console.log(`
795
823
  \u26A0 ${d.length} error(s) during mount:
796
- `);for(let m of d){let g=m.args.map(b=>typeof b=="object"?JSON.stringify(b):b).join(" ");if(console.log(` ${g}`),m.stack){let b=m.stack.split(`
797
- `).slice(0,2);for(let y of b)console.log(` ${y.trim()}`)}}}}catch{}i.ready||(process.exitCode=1);break}case"eval":case"js":{let t=l.slice(1).join(" ");t||(console.error(I("js","<javascript>")),console.error(""),console.error(" runs the snippet in the engine realm. SootSim is the"),console.error(" canonical state surface \u2014 reach into it directly."),console.error(""),console.error(" examples:"),console.error(` ${h("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${h("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${h("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${h("js")} SootSim.state.root.children.length`),process.exit(1));let n=t;n.startsWith("(async")||(n=`(async () => ${n})()`);let r=await u.send({type:"evaluate",code:n});console.log(JSON.stringify(r,null,2));let i=t.toLowerCase(),d=[];(i.includes("sootsim:gohome")||i.includes("gohome"))&&d.push("sootsim shell home"),(i.includes("sootsim:appswitcher")||i.includes("appswitcher"))&&d.push("sootsim shell switcher"),(i.includes("keyboard.isvisible")||i.includes("keyboard.getmode"))&&d.push("sootsim debug state keyboard"),i.includes("interact.tap")&&d.push("sootsim do tap <x> <y>"),i.includes("keyboard.type")&&d.push("sootsim do type <text>"),(i.includes("keyboard.press")||i.includes("keyboard.dispatchkey"))&&d.push("sootsim do key <name>"),i.includes("keyboard.dismiss")&&d.push("sootsim do dismiss"),i.includes("dumptree")&&d.push("sootsim get tree"),i.includes("dumpaccessibilitytree")&&d.push("sootsim get a11y"),i.includes("getnodecount")&&d.push("sootsim get count"),i.includes("findbytext")&&d.push("sootsim find <text>"),(i.includes("findbytestid")||i.includes("findbyid"))&&d.push("sootsim find --testid <id>"),i.includes("document.hidden")&&d.push("sootsim debug state keyboard (includes tab health)"),d.length>0&&Q("prefer-cli-over-eval",d);break}case"globals":{let t=await u.send({type:"evaluate",code:`(async () => {
824
+ `);for(let m of d){let f=m.args.map(w=>typeof w=="object"?JSON.stringify(w):w).join(" ");if(console.log(` ${f}`),m.stack){let w=m.stack.split(`
825
+ `).slice(0,2);for(let g of w)console.log(` ${g.trim()}`)}}}}catch{}i.ready||(process.exitCode=1);break}case"eval":case"js":{let t=l.slice(1).join(" ");if(t||(console.error(I("js","<javascript>")),console.error(""),console.error(" runs the snippet in the engine realm. SootSim is the"),console.error(" canonical state surface \u2014 reach into it directly."),console.error(""),console.error(" examples:"),console.error(` ${h("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${h("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${h("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${h("js")} SootSim.state.root.children.length`),process.exit(1)),e.includes("--tenant")){let m=l.slice(1).filter(w=>w!=="--tenant").join(" "),f=await u.send({type:"evaluate",code:`(async () => SootSim.bridges.test.evalInTenant(${JSON.stringify(m)}))()`});console.log(JSON.stringify(f,null,2));break}let n=t;n.startsWith("(async")||(n=`(async () => ${n})()`);let r=await u.send({type:"evaluate",code:n});console.log(JSON.stringify(r,null,2));let i=t.toLowerCase(),d=[];(i.includes("sootsim:gohome")||i.includes("gohome"))&&d.push("sootsim shell home"),(i.includes("sootsim:appswitcher")||i.includes("appswitcher"))&&d.push("sootsim shell switcher"),(i.includes("keyboard.isvisible")||i.includes("keyboard.getmode"))&&d.push("sootsim debug state keyboard"),i.includes("interact.tap")&&d.push("sootsim do tap <x> <y>"),i.includes("keyboard.type")&&d.push("sootsim do type <text>"),(i.includes("keyboard.press")||i.includes("keyboard.dispatchkey"))&&d.push("sootsim do key <name>"),i.includes("keyboard.dismiss")&&d.push("sootsim do dismiss"),i.includes("dumptree")&&d.push("sootsim get tree"),i.includes("dumpaccessibilitytree")&&d.push("sootsim get a11y"),i.includes("getnodecount")&&d.push("sootsim get count"),i.includes("findbytext")&&d.push("sootsim find <text>"),(i.includes("findbytestid")||i.includes("findbyid"))&&d.push("sootsim find --testid <id>"),i.includes("document.hidden")&&d.push("sootsim debug state keyboard (includes tab health)"),d.length>0&&Q("prefer-cli-over-eval",d);break}case"globals":{let t=await u.send({type:"evaluate",code:`(async () => {
798
826
  const globals = {}
799
827
 
800
828
  // test bridge (proxy in worker mode)
@@ -832,7 +860,7 @@ ${n}
832
860
 
833
861
  return globals
834
862
  })()`});console.log(` sootsim JS API:
835
- `);for(let[n,r]of Object.entries(t)){console.log(` ${n}:`);for(let i of r)console.log(` .${i}`);console.log("")}console.log(` use: ${h("js")} <expression>`),console.log(` example: ${h("js")} test.findByText("Sign in")`);break}case"describe":{await Yt({bridge:u,args:e,positional:l});break}case"perf":{f==="debug"&&!o.internalShellPerf&&(console.error(" `sootsim debug perf` was removed. use `sootsim perf shell ...`."),process.exit(1));let t=l[1];if(!t||t==="--help"||t==="-h"){console.log(`
863
+ `);for(let[n,r]of Object.entries(t)){console.log(` ${n}:`);for(let i of r)console.log(` .${i}`);console.log("")}console.log(` use: ${h("js")} <expression>`),console.log(` example: ${h("js")} test.findByText("Sign in")`);break}case"describe":{await Yt({bridge:u,args:e,positional:l});break}case"perf":{y==="debug"&&!o.internalShellPerf&&(console.error(" `sootsim debug perf` was removed. use `sootsim perf shell ...`."),process.exit(1));let t=l[1];if(!t||t==="--help"||t==="-h"){console.log(`
836
864
  ${h("perf")} \u2014 shell frame profiling (the worker that paints)
837
865
 
838
866
  records per-painted-frame timing in the shell worker \u2014 the surface that
@@ -889,28 +917,28 @@ ${n}
889
917
  await new Promise(r => setTimeout(r, 600))
890
918
  return await window.__sootsimShellPerf.stop()
891
919
  })()`});if(d?.error&&(console.error(` error: ${d.error}`),process.exit(1)),P(a)){D(d);break}Ie(` ${n} transition profiled:`),$o(d);break}default:console.error(` unknown perf subcommand: ${t}`),console.error(" valid: start, stop, transition"),/^--?reset$/.test(t)&&console.error(" note: 'perf start' already clears prior frames \u2014 no reset needed"),(t==="stats"||t==="frames"||t==="worst")&&(console.error(" note: the tenant sampler (stats/frames/worst) was removed \u2014 it hardcoded"),console.error(" layout/render/copy to zero because the shell worker owns every real paint."),console.error(" use 'perf start' / 'perf stop' (worst frames are in the stop report).")),process.exit(1)}break}case"errors":{let t=l[1];if(t==="clear"){await Le(u),P(a)?D({cleared:!0}):console.log(" error buffer cleared");break}let n=t?Number(t):20,r=await fe(u,n);if(P(a)){D(r);break}if(r.length===0){console.log(" no errors captured");break}console.log(` ${r.length} error(s):
892
- `);for(let i of r){let d=ie(i.timestamp),m=i.args.map(g=>typeof g=="object"?JSON.stringify(g):g).join(" ");if(console.log(` [${d}] ${m}`),i.stack){let g=i.stack.split(`
893
- `).slice(0,3);for(let b of g)console.log(` ${b.trim()}`)}}break}case"warnings":{let t=l[1]?Number(l[1]):20,n=await gt(u,t);if(P(a)){D(n);break}if(n.length===0){console.log(" no warnings captured");break}console.log(` ${n.length} warning(s):
920
+ `);for(let i of r){let d=ie(i.timestamp),m=i.args.map(f=>typeof f=="object"?JSON.stringify(f):f).join(" ");if(console.log(` [${d}] ${m}`),i.stack){let f=i.stack.split(`
921
+ `).slice(0,3);for(let w of f)console.log(` ${w.trim()}`)}}break}case"warnings":{let t=l[1]?Number(l[1]):20,n=await gt(u,t);if(P(a)){D(n);break}if(n.length===0){console.log(" no warnings captured");break}console.log(` ${n.length} warning(s):
894
922
  `);for(let r of n){let i=ie(r.timestamp),d=r.args.map(m=>typeof m=="object"?JSON.stringify(m):m).join(" ");console.log(` [${i}] ${d}`)}break}case"animations":{let t=await V(u,"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):
895
- `);for(let n of t){let r=String(n.kind).padEnd(6),i=`${Number(n.from).toFixed(2)}\u2192${Number(n.to).toFixed(2)}`,d=Number(n.current??0).toFixed(2),m=`${Math.round((n.progress??0)*100)}%`,g=`${Math.round(n.elapsedMs??0)}ms`,b=n.loop?" loop":"",y=n.layoutBound?" layout":"";console.log(` #${n.id} ${r} ${i.padEnd(14)} cur=${d.padEnd(7)} ${m.padStart(4)} ${g}${b}${y}`)}break}case"animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${h("animation")} <id>`),process.exit(1));let n=Number(t);Number.isFinite(n)||(console.error(` invalid id: ${t}`),process.exit(1));let r=await V(u,"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: ${h("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 V(u,"stopAnimation",n);console.log(` stopped ${r??0} animation(s)`);break}case"requests":{let t=l[1];if(t==="clear"){await ht(u),P(a)?D({cleared:!0}):console.log(" request buffer cleared");break}let n=t==="all",r=n?l[2]:t,i=r?Number(r):20,d=await yt(u,{failed:!n,limit:i});if(P(a)){D(d);break}if(d.length===0){console.log(n?" no requests captured":" no failed requests captured");break}console.log(` ${d.length} ${n?"request(s)":"failed request(s)"}:
896
- `);for(let m of d){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,i=!1,d=!1,m=1e3,g=!1,b=!1;for(let R=0;R<a.length;R++){let w=a[R];if(w==="--filter")n=a[R+1]??null,R++;else if(w==="--limit"){let k=Number(a[R+1]);Number.isFinite(k)&&(r=k),R++}else if(w==="--threshold"){let k=Number(a[R+1]);Number.isFinite(k)&&k>0&&(m=k),R++}else w==="--failed"?i=!0:w==="--slow"?d=!0:w==="--tail"||w==="-f"?g=!0:w==="--json"&&(b=!0)}if(t==="clear"){await u.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(t==="get"){let R=l[2];R||(console.error(" usage: sootsim network get <id>"),process.exit(1));let w=await u.send({type:"evaluate",code:`(() => {
923
+ `);for(let n of t){let r=String(n.kind).padEnd(6),i=`${Number(n.from).toFixed(2)}\u2192${Number(n.to).toFixed(2)}`,d=Number(n.current??0).toFixed(2),m=`${Math.round((n.progress??0)*100)}%`,f=`${Math.round(n.elapsedMs??0)}ms`,w=n.loop?" loop":"",g=n.layoutBound?" layout":"";console.log(` #${n.id} ${r} ${i.padEnd(14)} cur=${d.padEnd(7)} ${m.padStart(4)} ${f}${w}${g}`)}break}case"animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${h("animation")} <id>`),process.exit(1));let n=Number(t);Number.isFinite(n)||(console.error(` invalid id: ${t}`),process.exit(1));let r=await V(u,"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: ${h("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 V(u,"stopAnimation",n);console.log(` stopped ${r??0} animation(s)`);break}case"requests":{let t=l[1];if(t==="clear"){await ht(u),P(a)?D({cleared:!0}):console.log(" request buffer cleared");break}let n=t==="all",r=n?l[2]:t,i=r?Number(r):20,d=await yt(u,{failed:!n,limit:i});if(P(a)){D(d);break}if(d.length===0){console.log(n?" no requests captured":" no failed requests captured");break}console.log(` ${d.length} ${n?"request(s)":"failed request(s)"}:
924
+ `);for(let m of d){let f=ie(m.timestamp);console.log(` [${f}] ${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,i=!1,d=!1,m=1e3,f=!1,w=!1;for(let E=0;E<a.length;E++){let $=a[E];if($==="--filter")n=a[E+1]??null,E++;else if($==="--limit"){let k=Number(a[E+1]);Number.isFinite(k)&&(r=k),E++}else if($==="--threshold"){let k=Number(a[E+1]);Number.isFinite(k)&&k>0&&(m=k),E++}else $==="--failed"?i=!0:$==="--slow"?d=!0:$==="--tail"||$==="-f"?f=!0:$==="--json"&&(w=!0)}if(t==="clear"){await u.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 $=await u.send({type:"evaluate",code:`(() => {
897
925
  const obs = window.__sootsimObservability;
898
926
  if (!obs) return null;
899
- return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(R)}) || null;
900
- })()`});w||(console.error(` no entry with id ${R}`),process.exit(1)),b?console.log(JSON.stringify(w,null,2)):ys(w);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. ${h("network")} 100).
901
- to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let $=async()=>{let R=await u.send({type:"evaluate",code:`(() => {
927
+ return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(E)}) || null;
928
+ })()`});$||(console.error(` no entry with id ${E}`),process.exit(1)),w?console.log(JSON.stringify($,null,2)):ys($);break}let g=r??(f?200:t?Number(t):20);Number.isFinite(g)||(console.error(` invalid limit: ${t} \u2014 \`network\` takes a numeric count (e.g. ${h("network")} 100).
929
+ to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let S=async()=>{let E=await u.send({type:"evaluate",code:`(() => {
902
930
  const obs = window.__sootsimObservability;
903
931
  if (!obs) return { ok: false };
904
932
  return { ok: true, entries: obs.network.getSnapshot() };
905
- })()`});if(!R||!R.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return R.entries??[]},W=R=>{let w=R;if(i&&(w=w.filter(k=>!!k.error||k.status!=null&&k.status>=400)),d&&(w=w.filter(k=>k.durationMs!=null&&k.durationMs>=m)),n){let k=n.toLowerCase();w=w.filter(T=>(T.displayUrl||T.url).toLowerCase().includes(k))}return d&&!g&&(w=[...w].sort((k,T)=>(T.durationMs??0)-(k.durationMs??0))),w};if(!g){let R=await $(),w=W(R).slice(-y);if(b){console.log(JSON.stringify(w,null,2));break}if(w.length===0){R.length===0?console.log(" no network requests captured"):console.log(d?` no requests slower than ${m}ms (${R.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(d?` ${w.length} request(s) slower than ${m}ms (sorted by duration desc):
906
- `:` ${w.length} request(s):
907
- `);for(let k of w)ho(k);break}console.log(` tailing network (ctrl-c to stop)...
908
- `);let X=new Set,G=!0,z=()=>{G=!1};process.on("SIGINT",z);try{for(;G;){let R=await $(),w=W(R);for(let k of w)k.durationMs!=null&&(X.has(k.id)||(X.add(k.id),b?console.log(JSON.stringify(k)):ho(k)));await oe(250)}}finally{process.off("SIGINT",z)}break}case"logs":{let t=l[1],n=null,r=null,i=null,d=!1,m=!1,g=!1;for(let w=0;w<a.length;w++){let k=a[w];if(k==="--filter")n=a[w+1]??null,w++;else if(k==="--limit"){let T=Number(a[w+1]);Number.isFinite(T)&&(r=T),w++}else k==="--level"?(i=a[w+1]??null,w++):k==="--tail"||k==="-f"?d=!0:k==="--json"?m=!0:(k==="--internal"||k==="--all")&&(g=!0)}let b=i?new Set(i.split(",").map(w=>w.trim()).filter(w=>w==="log"||w==="info"||w==="warn"||w==="error"||w==="debug")):null;if(t==="clear"){await wt(u),console.log(" log buffer cleared");break}let y=!m&&process.stdout.isTTY===!0,$=r??(d?500:t?Number(t):50);Number.isFinite($)||(console.error(` invalid limit: ${t} \u2014 \`logs\` takes a numeric count (e.g. ${h("logs")} 100).
909
- to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let W=()=>bt(u),X=w=>xt(w,{level:b,filter:n,showInternal:g});if(!d){let w=await W(),k=X(w).slice(-$);if(m){console.log(JSON.stringify(k,null,2));break}if(k.length===0){console.log(w.length===0?" no logs captured":" no matching logs");break}console.log(` ${k.length} log(s):
910
- `);for(let T of k)wo(T,y);break}console.log(` tailing logs (ctrl-c to stop)...
911
- `);let G=new Set,z=!0,R=()=>{z=!1};process.on("SIGINT",R);try{for(;z;){let w=await W(),k=X(w);for(let T of k)G.has(T.id)||(G.add(T.id),m?console.log(JSON.stringify(T)):wo(T,y));await oe(250)}}finally{process.off("SIGINT",R)}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(u,p)&&await S(u),x.length>0&&ee(x),!A.has(p)&&!P(a))try{await xe(u)}catch{}}catch(x){let t=x instanceof Error?x.message:String(x);console.error(` ${p??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),i=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await Et(u,F,n[1]);else if(/^no sim connected$/.test(t))Rt(F);else if(r)if(await ds(u)){let m=p??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
933
+ })()`});if(!E||!E.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return E.entries??[]},W=E=>{let $=E;if(i&&($=$.filter(k=>!!k.error||k.status!=null&&k.status>=400)),d&&($=$.filter(k=>k.durationMs!=null&&k.durationMs>=m)),n){let k=n.toLowerCase();$=$.filter(T=>(T.displayUrl||T.url).toLowerCase().includes(k))}return d&&!f&&($=[...$].sort((k,T)=>(T.durationMs??0)-(k.durationMs??0))),$};if(!f){let E=await S(),$=W(E).slice(-g);if(w){console.log(JSON.stringify($,null,2));break}if($.length===0){E.length===0?console.log(" no network requests captured"):console.log(d?` no requests slower than ${m}ms (${E.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(d?` ${$.length} request(s) slower than ${m}ms (sorted by duration desc):
934
+ `:` ${$.length} request(s):
935
+ `);for(let k of $)ho(k);break}console.log(` tailing network (ctrl-c to stop)...
936
+ `);let X=new Set,G=!0,z=()=>{G=!1};process.on("SIGINT",z);try{for(;G;){let E=await S(),$=W(E);for(let k of $)k.durationMs!=null&&(X.has(k.id)||(X.add(k.id),w?console.log(JSON.stringify(k)):ho(k)));await oe(250)}}finally{process.off("SIGINT",z)}break}case"logs":{let t=l[1],n=null,r=null,i=null,d=!1,m=!1,f=!1;for(let $=0;$<a.length;$++){let k=a[$];if(k==="--filter")n=a[$+1]??null,$++;else if(k==="--limit"){let T=Number(a[$+1]);Number.isFinite(T)&&(r=T),$++}else k==="--level"?(i=a[$+1]??null,$++):k==="--tail"||k==="-f"?d=!0:k==="--json"?m=!0:(k==="--internal"||k==="--all")&&(f=!0)}let w=i?new Set(i.split(",").map($=>$.trim()).filter($=>$==="log"||$==="info"||$==="warn"||$==="error"||$==="debug")):null;if(t==="clear"){await wt(u),console.log(" log buffer cleared");break}let g=!m&&process.stdout.isTTY===!0,S=r??(d?500:t?Number(t):50);Number.isFinite(S)||(console.error(` invalid limit: ${t} \u2014 \`logs\` takes a numeric count (e.g. ${h("logs")} 100).
937
+ to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let W=()=>bt(u),X=$=>xt($,{level:w,filter:n,showInternal:f});if(!d){let $=await W(),k=X($).slice(-S);if(m){console.log(JSON.stringify(k,null,2));break}if(k.length===0){console.log($.length===0?" no logs captured":" no matching logs");break}console.log(` ${k.length} log(s):
938
+ `);for(let T of k)wo(T,g);break}console.log(` tailing logs (ctrl-c to stop)...
939
+ `);let G=new Set,z=!0,E=()=>{z=!1};process.on("SIGINT",E);try{for(;z;){let $=await W(),k=X($);for(let T of k)G.has(T.id)||(G.add(T.id),m?console.log(JSON.stringify(T)):wo(T,g));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(u,p)&&await v(u),x.length>0&&ee(x),!A.has(p)&&!P(a))try{await xe(u)}catch{}}catch(x){let t=x instanceof Error?x.message:String(x);console.error(` ${p??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),i=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await Rt(u,F,n[1]);else if(/^no sim connected$/.test(t))Et(F);else if(r)if(await ds(u)){let m=p??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
912
940
  the screen's node tree is large; narrow the query or raise the budget:
913
941
  sootsim ${m} --testid <id> # scope to one subtree
914
942
  sootsim find --testid <id> # targeted single-node lookup
915
943
  sootsim ${m} --timeout 60000 # raise per-command budget (ms)
916
- `)}else go();else if(i)go();else{try{await Ot(u)}catch{}try{await te({includeTail:!0})}catch{}try{await K({includeTail:!0})}catch{}}process.exit(1)}finally{u.close()}}export{qe as a,At as b,Ro as c,Ns as d,As as e,Ds as f,Bs as g,Cs as h,se as i,$o as j,Or as k};
944
+ `)}else go();else if(i)go();else{try{await Ot(u)}catch{}try{await te({includeTail:!0})}catch{}try{await H({includeTail:!0})}catch{}}process.exit(1)}finally{u.close()}}export{qe as a,At as b,Eo as c,Ns as d,As as e,Ds as f,Bs as g,Cs as h,se as i,$o as j,Or as k};