sootsim 0.1.165 → 0.1.166

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 (161) hide show
  1. package/README.md +7 -0
  2. package/dist-cli/bin.js +3 -3
  3. package/dist-cli/chunks/{agent-2EPUTBUL.js → agent-C2HTMDLW.js} +2 -2
  4. package/dist-cli/chunks/{agent-wrapper-VMZZJY7Y.js → agent-wrapper-EE2BNDAQ.js} +2 -2
  5. package/dist-cli/chunks/{app-fonts-6L4RKPLM.js → app-fonts-5JUWVRIA.js} +2 -2
  6. package/dist-cli/chunks/{assert-7XQLVOIT.js → assert-KF2OHBES.js} +2 -2
  7. package/dist-cli/chunks/auto-bootstrap-ITBEBASC.js +2 -0
  8. package/dist-cli/chunks/beta-FUBQGOA5.js +2 -0
  9. package/dist-cli/chunks/{camera-F7ADKILD.js → camera-L2DDKMHH.js} +2 -2
  10. package/dist-cli/chunks/{chunk-ESGMJNNM.js → chunk-2TE65ODE.js} +1 -1
  11. package/dist-cli/chunks/chunk-3CTBL6ST.js +1 -0
  12. package/dist-cli/chunks/{chunk-AJD3G3DQ.js → chunk-4SYV3YPR.js} +2 -2
  13. package/dist-cli/chunks/{chunk-FXQRRTHD.js → chunk-6OOIOB2X.js} +3 -3
  14. package/dist-cli/chunks/{chunk-53AQC5XE.js → chunk-7534S5IR.js} +1 -1
  15. package/dist-cli/chunks/{chunk-HA5LR3RI.js → chunk-7RFYWPAN.js} +1 -1
  16. package/dist-cli/chunks/chunk-B47GJVB3.js +3 -0
  17. package/dist-cli/chunks/{chunk-5IXQLSHV.js → chunk-BFEM7E4T.js} +2 -2
  18. package/dist-cli/chunks/{chunk-BVMLSYUA.js → chunk-C7KANC2Z.js} +2 -2
  19. package/dist-cli/chunks/{chunk-XJQRNGCW.js → chunk-D3GGZIBS.js} +5 -4
  20. package/dist-cli/chunks/{chunk-43R7N2HR.js → chunk-EFCPQBFY.js} +1 -1
  21. package/dist-cli/chunks/{chunk-5IIMWTMI.js → chunk-F4FR47MS.js} +3 -3
  22. package/dist-cli/chunks/chunk-FEWTUTZE.js +1 -0
  23. package/dist-cli/chunks/{chunk-QQXWV7VE.js → chunk-FLDFTC6A.js} +4 -6
  24. package/dist-cli/chunks/chunk-GS6OBVQR.js +1 -0
  25. package/dist-cli/chunks/{chunk-FNUHS7EZ.js → chunk-H52Z73AU.js} +2 -2
  26. package/dist-cli/chunks/{chunk-ZUY4EZUO.js → chunk-HHMW6MXX.js} +2 -2
  27. package/dist-cli/chunks/{chunk-J7YRSCPF.js → chunk-HNZF4VNH.js} +1 -1
  28. package/dist-cli/chunks/{chunk-T3SJIJNN.js → chunk-ITF7FOSZ.js} +1 -1
  29. package/dist-cli/chunks/{chunk-X3Q65CKA.js → chunk-ITJSVY3L.js} +2 -2
  30. package/dist-cli/chunks/{chunk-DZPNBMAP.js → chunk-J7FYMPIN.js} +1 -1
  31. package/dist-cli/chunks/{chunk-MF7QK7PS.js → chunk-JXHFW3SD.js} +1 -1
  32. package/dist-cli/chunks/{chunk-IIY2O6LJ.js → chunk-KCP7TTSW.js} +2 -2
  33. package/dist-cli/chunks/chunk-LIYFRTZG.js +2 -0
  34. package/dist-cli/chunks/{chunk-L3ZBX3DX.js → chunk-LOGFVSIT.js} +1 -1
  35. package/dist-cli/chunks/{chunk-TGNYK2JI.js → chunk-LSDWJEFJ.js} +2 -2
  36. package/dist-cli/chunks/{chunk-2N5FR2CU.js → chunk-M77N57QN.js} +1 -1
  37. package/dist-cli/chunks/{chunk-KMXETT3S.js → chunk-MC5ENPQM.js} +2 -2
  38. package/dist-cli/chunks/{chunk-WJHZQUAF.js → chunk-MPJ2W2JQ.js} +1 -1
  39. package/dist-cli/chunks/{chunk-32YLDVP3.js → chunk-O3PHDVRF.js} +2 -2
  40. package/dist-cli/chunks/chunk-OIVSYUZ4.js +5 -0
  41. package/dist-cli/chunks/{chunk-HAJPACUR.js → chunk-OY57XV3X.js} +2 -2
  42. package/dist-cli/chunks/{chunk-OXGEETXY.js → chunk-OYY6EJM7.js} +2 -2
  43. package/dist-cli/chunks/chunk-QIPSGUG7.js +13 -0
  44. package/dist-cli/chunks/{chunk-YXQNPOHC.js → chunk-R3YXB2EL.js} +2 -2
  45. package/dist-cli/chunks/{chunk-6WWYHNYI.js → chunk-S2MAMEQX.js} +1 -1
  46. package/dist-cli/chunks/{chunk-XLVOIA4F.js → chunk-S4DTM5EZ.js} +23 -13
  47. package/dist-cli/chunks/chunk-SBMHSZXI.js +119 -0
  48. package/dist-cli/chunks/{chunk-EV5NG4AO.js → chunk-USUANHKD.js} +2 -2
  49. package/dist-cli/chunks/{chunk-EGBFMW45.js → chunk-V6OGDC6H.js} +1 -1
  50. package/dist-cli/chunks/{chunk-AA5UBYX7.js → chunk-VKAJ6AJC.js} +1 -1
  51. package/dist-cli/chunks/{chunk-UYFIE5X3.js → chunk-VS5TCZSA.js} +6 -6
  52. package/dist-cli/chunks/{chunk-6YEVWYSG.js → chunk-WCJQSVYO.js} +1 -1
  53. package/dist-cli/chunks/{chunk-HQZMG2HF.js → chunk-WPJGFVZ5.js} +2 -2
  54. package/dist-cli/chunks/{chunk-BZS6I346.js → chunk-Y6RN5IR4.js} +1 -1
  55. package/dist-cli/chunks/{chunk-ALSMTP6C.js → chunk-Y7PCKIZD.js} +2 -2
  56. package/dist-cli/chunks/cli-version-7JACJRBF.js +2 -0
  57. package/dist-cli/chunks/{compat-VN34CJ6G.js → compat-SSS76KYC.js} +3 -3
  58. package/dist-cli/chunks/{config-XDZODP5I.js → config-6HJMGQPE.js} +2 -2
  59. package/dist-cli/chunks/control-X3X6VYUC.js +2 -0
  60. package/dist-cli/chunks/{cpu-profile-JFAHFE6I.js → cpu-profile-UQKTGYR7.js} +2 -2
  61. package/dist-cli/chunks/daemon-XSH6YITB.js +67 -0
  62. package/dist-cli/chunks/{debug-ABBVZGOK.js → debug-UCOOENBO.js} +3 -3
  63. package/dist-cli/chunks/{detox-SIZWOR5E.js → detox-BJP2O7XH.js} +2 -2
  64. package/dist-cli/chunks/{device-RLXPXXPO.js → device-CVN2YZJF.js} +2 -2
  65. package/dist-cli/chunks/{diagnose-V73S6VLC.js → diagnose-7XEK27S3.js} +2 -2
  66. package/dist-cli/chunks/drivers-JQ5QIRRE.js +2 -0
  67. package/dist-cli/chunks/{electron-YQR52UGK.js → electron-4HYAKJ2I.js} +3 -3
  68. package/dist-cli/chunks/flow-YTT2UHCY.js +2 -0
  69. package/dist-cli/chunks/help-C4GBFKLP.js +2 -0
  70. package/dist-cli/chunks/{hints-ZL56EHFZ.js → hints-DWCFCVNT.js} +2 -2
  71. package/dist-cli/chunks/{home-paths-U4FRKF6W.js → home-paths-V6KYK6EL.js} +2 -2
  72. package/dist-cli/chunks/{inspect-LPQT5DTA.js → inspect-TCCQEJHM.js} +3 -3
  73. package/dist-cli/chunks/install-EN2VEO4H.js +2 -0
  74. package/dist-cli/chunks/{install-desktop-KEOL5MR2.js → install-desktop-2YKS5HAY.js} +3 -3
  75. package/dist-cli/chunks/{keys-7S22SCJL.js → keys-GQWGTUBQ.js} +2 -2
  76. package/dist-cli/chunks/{launch-MP6Y7PAS.js → launch-26WSX7AZ.js} +3 -3
  77. package/dist-cli/chunks/{login-7IAUA2K7.js → login-TD7H5EDV.js} +4 -4
  78. package/dist-cli/chunks/{logout-L2KZIVSL.js → logout-6ARTPVDG.js} +2 -2
  79. package/dist-cli/chunks/{maestro-UPW6VRQA.js → maestro-DPZQ34MP.js} +2 -2
  80. package/dist-cli/chunks/optional-demo-registry-J65S4L7Y.js +2 -0
  81. package/dist-cli/chunks/{preview-D4GRDZRM.js → preview-RFQX4EDS.js} +2 -2
  82. package/dist-cli/chunks/{profile-NU5AQZYQ.js → profile-RCTOBUDR.js} +2 -2
  83. package/dist-cli/chunks/{react-FMBASJYN.js → react-ECJL6YMK.js} +2 -2
  84. package/dist-cli/chunks/{record-UGXBLMIS.js → record-3UMKAJKA.js} +4 -4
  85. package/dist-cli/chunks/runtime-GPY6OO6J.js +2 -0
  86. package/dist-cli/chunks/{runtime-delivery-23LSZG33.js → runtime-delivery-F4P6KJZM.js} +2 -2
  87. package/dist-cli/chunks/{screenshot-RFDYG3WW.js → screenshot-N2UGTFR3.js} +2 -2
  88. package/dist-cli/chunks/{screenshot-mode-Y26AAZTJ.js → screenshot-mode-OAMJJM3R.js} +2 -2
  89. package/dist-cli/chunks/{screenshots-OWPSRJ5A.js → screenshots-WRE3VRYN.js} +2 -2
  90. package/dist-cli/chunks/{server-3ZCQ257D.js → server-6CLFPGMH.js} +3 -3
  91. package/dist-cli/chunks/setup-repo-2FQX6VMQ.js +2 -0
  92. package/dist-cli/chunks/{skills-BF5OYDL4.js → skills-HO4NIDC3.js} +2 -2
  93. package/dist-cli/chunks/{slides-NI6F3FRT.js → slides-PJ3DY3WK.js} +2 -2
  94. package/dist-cli/chunks/{start-PN6254AD.js → start-P2UWHC5R.js} +4 -4
  95. package/dist-cli/chunks/store-KUJUGFQQ.js +2 -0
  96. package/dist-cli/chunks/telemetry-ZD3GGZT5.js +2 -0
  97. package/dist-cli/chunks/{test-GYLIVGBO.js → test-WV2CC6VE.js} +3 -3
  98. package/dist-cli/chunks/{three-mode-BXCPBK7G.js → three-mode-BLBIUFK7.js} +2 -2
  99. package/dist-cli/chunks/{timeline-RR75CYQP.js → timeline-T7DCGGXA.js} +2 -2
  100. package/dist-cli/chunks/{upgrade-POFEYCZJ.js → upgrade-MDJCUJG3.js} +2 -2
  101. package/dist-cli/chunks/upload-DBW7W7BM.js +2 -0
  102. package/dist-cli/chunks/{version-ZIW3AABE.js → version-LPLNI3HW.js} +2 -2
  103. package/dist-cli/chunks/{web-AMUML35L.js → web-BQYICLPD.js} +2 -2
  104. package/dist-cli/chunks/{what-happened-YRVA42P7.js → what-happened-7QAYQKHI.js} +2 -2
  105. package/dist-cli/chunks/{whoami-TIO2K57H.js → whoami-3PLHCC2N.js} +2 -2
  106. package/dist-lib/agent-daemon-client.cjs +1 -1
  107. package/dist-lib/agent-events.cjs +1 -1
  108. package/dist-lib/agent-sessions.cjs +1 -1
  109. package/dist-lib/attached-projects.cjs +1 -1
  110. package/dist-lib/auth/shared-session.cjs +1 -1
  111. package/dist-lib/backend-origin.cjs +1 -1
  112. package/dist-lib/beta.cjs +1 -1
  113. package/dist-lib/beta.mjs +1 -1
  114. package/dist-lib/bridge-constants.cjs +1 -1
  115. package/dist-lib/cli-constants.cjs +1 -1
  116. package/dist-lib/config.cjs +1 -1
  117. package/dist-lib/detox/index.cjs +1 -1
  118. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  119. package/dist-lib/home-paths.cjs +1 -1
  120. package/dist-lib/host/bridge-host.cjs +1 -1
  121. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  122. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  123. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  124. package/dist-lib/host/websocket-proxy.cjs +1 -1
  125. package/dist-lib/index.cjs +1 -1
  126. package/dist-lib/menu.cjs +1 -1
  127. package/dist-lib/menu.mjs +1 -1
  128. package/dist-lib/metro.cjs +1 -1
  129. package/dist-lib/profiles.cjs +1 -1
  130. package/dist-lib/render-mode.cjs +1 -1
  131. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  132. package/dist-lib/sdk.cjs +1 -1
  133. package/dist-lib/sdk.mjs +1 -1
  134. package/dist-lib/skills.cjs +1 -1
  135. package/dist-lib/vite.cjs +1 -1
  136. package/package.json +4 -2
  137. package/scripts/preuninstall.cjs +118 -0
  138. package/src/native-dev-bundle-url.ts +22 -0
  139. package/dist-cli/chunks/auto-bootstrap-GOOU4KQE.js +0 -2
  140. package/dist-cli/chunks/beta-CRII6BIU.js +0 -2
  141. package/dist-cli/chunks/chunk-5QWSPJHN.js +0 -13
  142. package/dist-cli/chunks/chunk-HFPCHOKV.js +0 -2
  143. package/dist-cli/chunks/chunk-HKCO4GFF.js +0 -5
  144. package/dist-cli/chunks/chunk-M72THY5Y.js +0 -1
  145. package/dist-cli/chunks/chunk-O4J2RSBF.js +0 -119
  146. package/dist-cli/chunks/chunk-RAS5AWIY.js +0 -1
  147. package/dist-cli/chunks/chunk-X3TVSME2.js +0 -3
  148. package/dist-cli/chunks/chunk-YIZQFYDE.js +0 -1
  149. package/dist-cli/chunks/cli-version-EJUVAAK3.js +0 -2
  150. package/dist-cli/chunks/control-QUGPN5RE.js +0 -2
  151. package/dist-cli/chunks/daemon-TUYHAVYA.js +0 -67
  152. package/dist-cli/chunks/drivers-HBCRUONZ.js +0 -2
  153. package/dist-cli/chunks/flow-VY5435YB.js +0 -2
  154. package/dist-cli/chunks/help-GCFMWV2P.js +0 -2
  155. package/dist-cli/chunks/install-HLUFKIYY.js +0 -2
  156. package/dist-cli/chunks/optional-demo-registry-WSPMNQX5.js +0 -2
  157. package/dist-cli/chunks/runtime-QAQWW2CP.js +0 -2
  158. package/dist-cli/chunks/setup-repo-IT6HNGID.js +0 -2
  159. package/dist-cli/chunks/store-NU4G6MAF.js +0 -2
  160. package/dist-cli/chunks/telemetry-WZFPP7XR.js +0 -2
  161. package/dist-cli/chunks/upload-NHL3ZR6J.js +0 -2
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{h as w,j as u,k as m,l}from"./chunk-J7YRSCPF.js";var p="sootsim:settings",v=["errorReporting","colorScheme","a11yMode","a11yDepth","screenshotCanvas","screenshotBackground","screenshotText","screenshotPose","screenshotDynamicSize","agentProvider","onboardingComplete","betaConsentVersion","detailedTelemetry"];function S(){if(typeof window>"u")return null;let e=window.sootsimElectron;return e&&typeof e=="object"?e:null}function g(e){let t={};for(let n of v){if(!(n in e))continue;let r=e[n],o=u[n];o.validate&&!o.validate(r)||o.options&&!o.options.includes(r)||(t[n]=r)}return t}function h(e){let t={};for(let n of v)t[n]=e[n];return t}function _(){if(typeof localStorage>"u")return{};try{let e=localStorage.getItem(p);return e?g(JSON.parse(e)):{}}catch{return{}}}function V(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(p,JSON.stringify(h(e)))}catch{}}function E(){let t=S()?.sharedConfig?.settings;return!t||typeof t!="object"?{}:g(t)}function K(e){let t=S();if(t?.writeSharedConfig)try{t.writeSharedConfig({settings:h(e)})}catch{}}function k(){if(typeof window>"u")return null;let e=window.__sootsimSharedConfig;return e&&typeof e=="object"?e:null}function j(){let e=k()?.settings;return!e||typeof e!="object"?{}:g(e)}function D(e){if(!k())return;let t={settings:h(e)};try{if(globalThis.__sootsimBridgeRequest?.writeSharedConfig?.(t))return}catch{}if(!(typeof fetch>"u"))try{fetch("/__sootsim/shared-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}function b(){let e=_(),t=j(),n=E();return{...e,...t,...n}}function R(e){V(e),K(e),D(e)}function C(e){if(typeof window>"u")return()=>{};let t=i=>{if(!(i.key!==p||i.newValue==null))try{e(g(JSON.parse(i.newValue)))}catch{}};window.addEventListener("storage",t);let n=S(),r;n?.onSharedConfigChanged&&(r=n.onSharedConfigChanged(i=>{let d=i?.settings;!d||typeof d!="object"||e(g(d))}));let c=globalThis.__sootsimBridgeRequest?.subscribeSharedConfig?.(i=>{let d=i?.settings;!d||typeof d!="object"||e(g(d))});return()=>{window.removeEventListener("storage",t),r?.(),c?.()}}var M=l(),P=b();for(let e of Object.keys(m()))delete P[e];var s={...M,...P},f=[],a=null;function y(){for(let e of f)e();R(s)}C(e=>{let t={...s},n=!1;for(let[r,o]of Object.entries(e)){let c=r;t[c]!==o&&(t[c]=o,n=!0)}if(n){s=t,a=null;for(let r of f)r()}});var L={get(e){return s[e]},set(e,t){let n=u[e];n.validate&&!n.validate(t)||n.options&&!n.options.includes(t)||s[e]!==t&&(s={...s,[e]:t},e==="deviceModel"&&(a=null),y())},getAll(){return s},apply(e){let t=!1,n={...s};for(let[r,o]of Object.entries(e)){if(o===void 0)continue;let c=r,i=u[c];i&&(i.validate&&!i.validate(o)||i.options&&!i.options.includes(o)||n[c]!==o&&(n[c]=o,t=!0))}t&&(s=n,a=null,y())},reset(){s=l(),a=null,y()},subscribe(e){return f.push(e),()=>{f=f.filter(t=>t!==e)}},getDeviceSpec(){return a||(a=w(s.deviceModel)),a},getA11yMode(){return s.a11yMode},setA11yMode(e){this.set("a11yMode",e)},getInspectMode(){return s.inspectMode},setInspectMode(e){this.set("inspectMode",e)}};export{L as a};
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{h as w,j as u,k as m,l}from"./chunk-HNZF4VNH.js";var p="sootsim:settings",v=["errorReporting","colorScheme","a11yMode","a11yDepth","screenshotCanvas","screenshotBackground","screenshotText","screenshotPose","screenshotDynamicSize","agentProvider","onboardingComplete","betaConsentVersion","detailedTelemetry"];function S(){if(typeof window>"u")return null;let e=window.sootsimElectron;return e&&typeof e=="object"?e:null}function g(e){let t={};for(let n of v){if(!(n in e))continue;let r=e[n],o=u[n];o.validate&&!o.validate(r)||o.options&&!o.options.includes(r)||(t[n]=r)}return t}function h(e){let t={};for(let n of v)t[n]=e[n];return t}function _(){if(typeof localStorage>"u")return{};try{let e=localStorage.getItem(p);return e?g(JSON.parse(e)):{}}catch{return{}}}function V(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(p,JSON.stringify(h(e)))}catch{}}function E(){let t=S()?.sharedConfig?.settings;return!t||typeof t!="object"?{}:g(t)}function K(e){let t=S();if(t?.writeSharedConfig)try{t.writeSharedConfig({settings:h(e)})}catch{}}function k(){if(typeof window>"u")return null;let e=window.__sootsimSharedConfig;return e&&typeof e=="object"?e:null}function j(){let e=k()?.settings;return!e||typeof e!="object"?{}:g(e)}function D(e){if(!k())return;let t={settings:h(e)};try{if(globalThis.__sootsimBridgeRequest?.writeSharedConfig?.(t))return}catch{}if(!(typeof fetch>"u"))try{fetch("/__sootsim/shared-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}function b(){let e=_(),t=j(),n=E();return{...e,...t,...n}}function R(e){V(e),K(e),D(e)}function C(e){if(typeof window>"u")return()=>{};let t=i=>{if(!(i.key!==p||i.newValue==null))try{e(g(JSON.parse(i.newValue)))}catch{}};window.addEventListener("storage",t);let n=S(),r;n?.onSharedConfigChanged&&(r=n.onSharedConfigChanged(i=>{let d=i?.settings;!d||typeof d!="object"||e(g(d))}));let c=globalThis.__sootsimBridgeRequest?.subscribeSharedConfig?.(i=>{let d=i?.settings;!d||typeof d!="object"||e(g(d))});return()=>{window.removeEventListener("storage",t),r?.(),c?.()}}var M=l(),P=b();for(let e of Object.keys(m()))delete P[e];var s={...M,...P},f=[],a=null;function y(){for(let e of f)e();R(s)}C(e=>{let t={...s},n=!1;for(let[r,o]of Object.entries(e)){let c=r;t[c]!==o&&(t[c]=o,n=!0)}if(n){s=t,a=null;for(let r of f)r()}});var L={get(e){return s[e]},set(e,t){let n=u[e];n.validate&&!n.validate(t)||n.options&&!n.options.includes(t)||s[e]!==t&&(s={...s,[e]:t},e==="deviceModel"&&(a=null),y())},getAll(){return s},apply(e){let t=!1,n={...s};for(let[r,o]of Object.entries(e)){if(o===void 0)continue;let c=r,i=u[c];i&&(i.validate&&!i.validate(o)||i.options&&!i.options.includes(o)||n[c]!==o&&(n[c]=o,t=!0))}t&&(s=n,a=null,y())},reset(){s=l(),a=null,y()},subscribe(e){return f.push(e),()=>{f=f.filter(t=>t!==e)}},getDeviceSpec(){return a||(a=w(s.deviceModel)),a},getA11yMode(){return s.a11yMode},setA11yMode(e){this.set("a11yMode",e)},getInspectMode(){return s.inspectMode},setInspectMode(e){this.set("inspectMode",e)}};export{L as a};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  var c="sootsim-agent-prompt-v1";function r(n){return typeof n=="string"?n.trim():""}function m(n){let e=r(n.text);if(!e)return"";let t=r(n.displayText),s=r(n.inspectSummary),o=r(n.inspectTrace);return!!s||!!o||/[\r\n]/.test(e)||!!t&&t!==e?JSON.stringify({__sootsimAgentPrompt:c,text:e,displayText:t,inspectSummary:s,inspectTrace:o}):e}function u(n){let e=r(n);if(!e)return null;try{let t=JSON.parse(e);if(t.__sootsimAgentPrompt!==c)return{text:e};let s=r(typeof t.text=="string"?t.text:void 0);if(!s)return null;let o=r(typeof t.displayText=="string"?t.displayText:void 0),i=r(typeof t.inspectSummary=="string"?t.inspectSummary:void 0),p=r(typeof t.inspectTrace=="string"?t.inspectTrace:void 0);return{text:s,...o?{displayText:o}:{},...i?{inspectSummary:i}:{},...p?{inspectTrace:p}:{}}}catch{return{text:e}}}export{m as a,u as b};
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  function M(t,e){let r=["--max-ms","--maxMs","--maxms","--max_ms"];for(let n of r){let s=t.indexOf(n);if(s>=0&&t[s+1]){let o=Number(t[s+1]);if(Number.isFinite(o))return Math.max(100,o)}}return e}var w=new Set(["tap","double-tap","tap-text","tap-id","long-press","touch"]);function S(t){return typeof t=="string"&&w.has(t)}async function v(t){return await t.send({type:"evaluate",code:"window.__sootsimEngineState?.inspectActive === true"})===!0}async function H(t,e){if(!S(e))return!1;try{return await v(t)}catch{return!1}}async function C(t){let e=await t.send({type:"evaluate",code:"(async () => await window.__sootsimTest.getNodeCount())()"});return{nodes:typeof e=="number"?e:0}}async function B(t,e=5){let r=await t.send({type:"evaluate",code:`(async () => await window.__sootsimTest.dumpTree(${e}))()`});return{depth:e,tree:r}}async function W(t){let e=await t.send({type:"evaluate",code:"window.location.href"});return{url:typeof e=="string"?e:""}}async function F(t,e){let r=`(async () => {
3
3
  const t = window.__sootsimTest
4
4
  const mainShell = window.SootSim?.bridges?.mainShell
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as P,d as T,f as C}from"./chunk-ESGMJNNM.js";import{G as k,H as v}from"./chunk-EGBFMW45.js";import{WebSocket as I}from"ws";function x(){let e=k();return e&&v(e)?e.bridgePort:7668}var w=class extends Error{lock;constructor(r,i){super(r),this.name="BridgeSimLockedError",this.lock=i}};function $(e){return e==="flag"?"via --sim":e==="saved"?"saved via `sootsim use`":"primary fallback \u2014 no sim pinned"}function N(e,r={}){let i=new Set,a=r.port??x(),l=r.commandTimeoutMs??15e3,t,m="none",h=new Set(r.stripBooleanFlags??[]),b=new Set(r.stripValueFlags??[]);for(let n=0;n<e.length;n++){let d=e[n];if(d==="--port"||d==="-p"){i.add(n),n+1<e.length&&(i.add(n+1),a=Number(e[n+1])),n++;continue}if(d.startsWith("--port=")){i.add(n),a=Number(d.slice(7));continue}if(d==="--timeout"){i.add(n),n+1<e.length&&(i.add(n+1),l=Number(e[n+1])),n++;continue}if(d==="--sim"||d==="--session"||d==="--tab"){i.add(n),n+1<e.length&&(i.add(n+1),t=e[n+1]?.trim()||void 0,m="flag"),n++;continue}let s=d.startsWith("--sim=")?d.slice(6):d.startsWith("--session=")?d.slice(10):d.startsWith("--tab=")?d.slice(6):void 0;if(s!==void 0){i.add(n),t=s.trim()||void 0,m="flag";continue}if(h.has(d)){i.add(n);continue}b.has(d)&&(i.add(n),n+1<e.length&&i.add(n+1),n++)}if(!t){let n=T();n&&(t=n.trim()||void 0,m="saved")}return{positional:e.filter((n,d)=>!i.has(d)),wsPort:a,simId:t,simIdSource:m,commandTimeoutMs:l}}function E(e,r={}){let i=1,a=r.commandTimeoutMs??15e3,l=new Map,t=new I(`ws://localhost:${e}`),m=P(),h=new Promise((s,o)=>{t.on("open",()=>{try{t.send(JSON.stringify({type:"bridge:hello",id:0,cliIdentityKey:m.key,cliIdentitySource:m.source,cliLabel:r.cliLabel}))}catch{}s()}),t.on("error",c=>{let g=c.message?`: ${c.message}`:"";o(new Error(`could not connect to ws://localhost:${e}${g}`))})}),b=!1,n=!1;function d(s,o){if(n||process.env.SOOTSIM_QUIET_TARGET_NOTICE==="1"||s.startsWith("bridge:")||s==="focus"||s==="close")return;n=!0;let c=o??"primary",g=$(o?r.simIdSource:"none");process.stderr.write(` \u2192 ${c} (${g})
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as P,d as T,f as C}from"./chunk-2TE65ODE.js";import{G as k,H as v}from"./chunk-V6OGDC6H.js";import{WebSocket as I}from"ws";function x(){let e=k();return e&&v(e)?e.bridgePort:7668}var w=class extends Error{lock;constructor(r,i){super(r),this.name="BridgeSimLockedError",this.lock=i}};function $(e){return e==="flag"?"via --sim":e==="saved"?"saved via `sootsim use`":"primary fallback \u2014 no sim pinned"}function N(e,r={}){let i=new Set,a=r.port??x(),l=r.commandTimeoutMs??15e3,t,m="none",h=new Set(r.stripBooleanFlags??[]),b=new Set(r.stripValueFlags??[]);for(let n=0;n<e.length;n++){let d=e[n];if(d==="--port"||d==="-p"){i.add(n),n+1<e.length&&(i.add(n+1),a=Number(e[n+1])),n++;continue}if(d.startsWith("--port=")){i.add(n),a=Number(d.slice(7));continue}if(d==="--timeout"){i.add(n),n+1<e.length&&(i.add(n+1),l=Number(e[n+1])),n++;continue}if(d==="--sim"||d==="--session"||d==="--tab"){i.add(n),n+1<e.length&&(i.add(n+1),t=e[n+1]?.trim()||void 0,m="flag"),n++;continue}let s=d.startsWith("--sim=")?d.slice(6):d.startsWith("--session=")?d.slice(10):d.startsWith("--tab=")?d.slice(6):void 0;if(s!==void 0){i.add(n),t=s.trim()||void 0,m="flag";continue}if(h.has(d)){i.add(n);continue}b.has(d)&&(i.add(n),n+1<e.length&&i.add(n+1),n++)}if(!t){let n=T();n&&(t=n.trim()||void 0,m="saved")}return{positional:e.filter((n,d)=>!i.has(d)),wsPort:a,simId:t,simIdSource:m,commandTimeoutMs:l}}function E(e,r={}){let i=1,a=r.commandTimeoutMs??15e3,l=new Map,t=new I(`ws://localhost:${e}`),m=P(),h=new Promise((s,o)=>{t.on("open",()=>{try{t.send(JSON.stringify({type:"bridge:hello",id:0,cliIdentityKey:m.key,cliIdentitySource:m.source,cliLabel:r.cliLabel}))}catch{}s()}),t.on("error",c=>{let g=c.message?`: ${c.message}`:"";o(new Error(`could not connect to ws://localhost:${e}${g}`))})}),b=!1,n=!1;function d(s,o){if(n||process.env.SOOTSIM_QUIET_TARGET_NOTICE==="1"||s.startsWith("bridge:")||s==="focus"||s==="close")return;n=!0;let c=o??"primary",g=$(o?r.simIdSource:"none");process.stderr.write(` \u2192 ${c} (${g})
3
3
  `)}return t.on("message",s=>{let o;try{o=JSON.parse(s.toString())}catch{return}if(o.id===0)return;let c=l.get(o.id);c&&(l.delete(o.id),o._otherCliCount>0&&!b&&(b=!0,process.stderr.write(`
4
4
  \u26A0 ${o._otherCliCount} other CLI identity/identities are driving this sim
5
5
  taps, scrolls, and keyboard input from multiple agents will collide on
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ var t="http://localhost:5173/";export{t as a};
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import{execFileSync as h,spawn as g}from"child_process";import{existsSync as s,readdirSync as k}from"fs";import{dirname as m,join as l,resolve as a}from"path";import{fileURLToPath as v}from"url";var c;function p(){if(c!==void 0)return c;try{c=m(v(import.meta.resolve("sootsim-engine/package.json")))}catch{c=null}return c}var I="dev.sootsim.simulator";function x(){let n=p();if(!n)return null;let e=l(n,"dist-electron/main.cjs");if(!s(e))return null;let i=D(n);return i?{path:i,platform:process.platform,kind:"dev-electron",engineDir:n}:null}function b(){let n=p();return n?s(l(n,"src-electron/main.ts")):!1}function D(n){let e=n;for(let i=0;i<6;i++){let t=l(e,"node_modules/.bin/electron");if(s(t))return t;let r=m(e);if(r===e)break;e=r}return null}function C(){let n=p(),i=["/Applications/sootsim.app",a(process.env.HOME||"","Applications/sootsim.app"),...n?[a(n,"app/sootsim.app")]:[]].find(t=>s(t));if(i)return{path:i,platform:"darwin",kind:"mac-app"};try{let t=h("mdfind",[`kMDItemCFBundleIdentifier == "${I}"`],{encoding:"utf8",timeout:3e3}).trim();if(t)return{path:t.split(`
3
3
  `)[0],platform:"darwin",kind:"mac-app"}}catch{}return null}function f(n){if(!s(n))return null;let e=k(n).filter(i=>i.startsWith("sootsim")&&i.endsWith(".AppImage")).sort().reverse()[0];return e?l(n,e):null}function w(){let n=p(),i=[a(process.env.HOME||"","Applications/sootsim.AppImage"),a(process.env.HOME||"",".local/bin/sootsim.AppImage"),"/opt/sootsim/sootsim.AppImage","/opt/sootsim/sootsim",...n?[a(n,"app/sootsim.AppImage"),a(n,"release/linux-unpacked/sootsim")]:[]].find(r=>s(r));if(i)return{path:i,platform:"linux",kind:i.endsWith(".AppImage")?"linux-appimage":"linux-binary"};let t=n?f(a(n,"app"))||f(a(n,"release")):null;return t?{path:t,platform:"linux",kind:"linux-appimage"}:null}function A(){let n=x();if(n)return n;if(b()){let e=p(),i=l(e,"dist-electron/main.cjs");return s(i)?console.error(` no node_modules/.bin/electron found near ${e}. run \`bun install\`.`):console.error(` dist-electron/main.cjs missing in ${e}.
4
4
  run: bun run --cwd packages/sootsim-engine build:electron-main
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as p}from"./chunk-5IXQLSHV.js";import{d as c,e as l}from"./chunk-FNUHS7EZ.js";import{a}from"./chunk-ALSMTP6C.js";async function g(e,t){if(t)return t.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let i=a();return i?.origin?i.origin.replace(/\/$/,""):(await p()).replace(/\/$/,"")}async function m(e,t={}){let i=c();if(i||(process.stderr.write(`
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as p}from"./chunk-BFEM7E4T.js";import{d as c,e as l}from"./chunk-H52Z73AU.js";import{a}from"./chunk-Y7PCKIZD.js";async function g(e,t){if(t)return t.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let i=a();return i?.origin?i.origin.replace(/\/$/,""):(await p()).replace(/\/$/,"")}async function m(e,t={}){let i=c();if(i||(process.stderr.write(`
3
3
  sootsim ${e} needs auth before it can check recording access.
4
4
 
5
5
  pick one:
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  var d=Object.defineProperty;var e=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var f=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0})};export{e as a,f as b};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- var m={"--help":{type:"boolean",short:"-h"},"--version":{type:"boolean",short:"-V"},"--verbose":{type:"boolean",short:"-v"},"--port":{type:"number",short:"-p"},"--device":{type:"string",short:"-d"},"--theme":{type:"string",short:"-t"},"--headless":{type:"boolean"},"--driver":{type:"string"},"--sim":{type:"string"},"--session":{type:"string"},"--tab":{type:"string"}},c=new Set(["list","describe","find","get","do","wait","network","logs","shell"]),p=new Set(["do","get","wait","shell","debug"]),b={tap:"sootsim do tap","double-tap":"sootsim do double-tap","tap-text":"sootsim do tap-text","tap-id":"sootsim do tap-id",type:"sootsim do type","type-into":"sootsim do type-into",key:"sootsim do key",dispatch:"sootsim do dispatch",dismiss:"sootsim do dismiss",scroll:"sootsim do scroll",drag:"sootsim do drag",swipe:"sootsim do swipe",pinch:"sootsim do pinch",reload:"sootsim do reload",sleep:"sootsim do sleep",settle:"sootsim do settle",tree:"sootsim get tree",a11y:"sootsim get a11y",count:"sootsim get count",layout:"sootsim get layout",url:"sootsim get url",globals:"sootsim get globals",errors:"sootsim get errors",warnings:"sootsim get warnings",requests:"sootsim get requests",node:"sootsim get node",state:"sootsim debug state",js:"sootsim debug js",eval:"sootsim debug eval",perf:"sootsim debug perf","sample-color":"sootsim debug sample-color","find-id":"sootsim find --testid",query:"sootsim find --text|--role|--type|--pressable|--visible",capture:"sootsim screenshot"},u=new Set(["preview","test","detox","maestro","flow","record","profile","cpu-profile","react","screenshot","screenshots","screenshot-mode","slides","three-mode","3d-mode","inspect","debug","camera","timeline","what-happened","diagnose","shell","assert","device","open","list","use","focus","claim","close","config","compat","scan","electron","login","logout","whoami","install","setup-repo","install-desktop","server","daemon","runtime","upgrade","version","launch","start","skills","upload","app-fonts","keys","hints","agent-wrapper","agent",...c,...Object.keys(b)]);function h(g){let i=g.slice(2),e={command:null,commandArgs:[],globalFlags:{},help:!1,version:!1,verbose:!1},s=0;for(;s<i.length;){let o=i[s];if(o==="--"){e.commandArgs.push(...i.slice(s+1));break}let a=Object.entries(m).find(([n,t])=>n===o||t.short===o);if(a){let[n,t]=a,l=n.replace(/^--/,"");if(t.type==="boolean")e.globalFlags[l]=!0,s++;else{let r=i[s+1];if(r===void 0||r.startsWith("-")){console.error(` warning: ${o} requires a value`),s++;continue}if(t.type==="number"){let d=Number(r);if(Number.isNaN(d)){console.error(` warning: ${o} requires a number, got "${r}"`),s+=2;continue}e.globalFlags[l]=d}else e.globalFlags[l]=r;s+=2}continue}if(!e.command&&!o.startsWith("-")){let n=o.indexOf("-");if(n>0){let t=o.slice(0,n),l=o.slice(n+1);if(p.has(t)&&l.length>0){e.command=t;let r=i.slice(s+1);e.commandArgs=[l,...r[0]==="--"?r.slice(1):r];break}}if(u.has(o)){e.command=o;let t=i.slice(s+1);e.commandArgs=t[0]==="--"?t.slice(1):t;break}e.commandArgs=i.slice(s);break}e.commandArgs.push(o),s++}return e.help=!!e.globalFlags.help,e.version=!!e.globalFlags.version,e.verbose=!!e.globalFlags.verbose,e}export{c as a,b,h as c};
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ var m={"--help":{type:"boolean",short:"-h"},"--version":{type:"boolean",short:"-V"},"--verbose":{type:"boolean",short:"-v"},"--port":{type:"number",short:"-p"},"--device":{type:"string",short:"-d"},"--theme":{type:"string",short:"-t"},"--headless":{type:"boolean"},"--driver":{type:"string"},"--sim":{type:"string"},"--session":{type:"string"},"--tab":{type:"string"}},c=new Set(["list","describe","find","get","do","wait","network","logs","shell"]),p=new Set(["do","get","wait","shell","debug"]),b={tap:"sootsim do tap","double-tap":"sootsim do double-tap","tap-text":"sootsim do tap-text","tap-id":"sootsim do tap-id",type:"sootsim do type","type-into":"sootsim do type-into",key:"sootsim do key",dispatch:"sootsim do dispatch",dismiss:"sootsim do dismiss",scroll:"sootsim do scroll",drag:"sootsim do drag",swipe:"sootsim do swipe",pinch:"sootsim do pinch",reload:"sootsim do reload",sleep:"sootsim do sleep",settle:"sootsim do settle",tree:"sootsim get tree",a11y:"sootsim get a11y",count:"sootsim get count",layout:"sootsim get layout",url:"sootsim get url",globals:"sootsim get globals",errors:"sootsim get errors",warnings:"sootsim get warnings",requests:"sootsim get requests",node:"sootsim get node",state:"sootsim debug state",js:"sootsim debug js",eval:"sootsim debug eval",perf:"sootsim debug perf","sample-color":"sootsim debug sample-color","find-id":"sootsim find --testid",query:"sootsim find --text|--role|--type|--pressable|--visible",capture:"sootsim screenshot"},u=new Set(["preview","test","detox","maestro","flow","record","profile","cpu-profile","react","screenshot","screenshots","screenshot-mode","slides","three-mode","3d-mode","inspect","debug","camera","timeline","what-happened","diagnose","shell","assert","device","open","list","use","focus","claim","close","config","compat","scan","electron","login","logout","whoami","install","setup-repo","init","install-desktop","server","daemon","runtime","upgrade","version","launch","start","skills","upload","app-fonts","keys","hints","agent-wrapper","agent",...c,...Object.keys(b)]);function h(g){let i=g.slice(2),e={command:null,commandArgs:[],globalFlags:{},help:!1,version:!1,verbose:!1},s=0;for(;s<i.length;){let o=i[s];if(o==="--"){e.commandArgs.push(...i.slice(s+1));break}let a=Object.entries(m).find(([n,t])=>n===o||t.short===o);if(a){let[n,t]=a,l=n.replace(/^--/,"");if(t.type==="boolean")e.globalFlags[l]=!0,s++;else{let r=i[s+1];if(r===void 0||r.startsWith("-")){console.error(` warning: ${o} requires a value`),s++;continue}if(t.type==="number"){let d=Number(r);if(Number.isNaN(d)){console.error(` warning: ${o} requires a number, got "${r}"`),s+=2;continue}e.globalFlags[l]=d}else e.globalFlags[l]=r;s+=2}continue}if(!e.command&&!o.startsWith("-")){let n=o.indexOf("-");if(n>0){let t=o.slice(0,n),l=o.slice(n+1);if(p.has(t)&&l.length>0){e.command=t;let r=i.slice(s+1);e.commandArgs=[l,...r[0]==="--"?r.slice(1):r];break}}if(u.has(o)){e.command=o;let t=i.slice(s+1);e.commandArgs=t[0]==="--"?t.slice(1):t;break}e.commandArgs=i.slice(s);break}e.commandArgs.push(o),s++}return e.help=!!e.globalFlags.help,e.version=!!e.globalFlags.version,e.verbose=!!e.globalFlags.verbose,e}export{c as a,b,h as c};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  var t="./demo-app-registry.ts",o=null;async function n(){if(o)return o;try{let r=await import(t);o=Array.isArray(r.APPS)?r.APPS:[]}catch{o=[]}return o}function e(){return o??[]}export{n as a,e as b};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{G as P,m as v,n as A,o as h,t as I,v as N}from"./chunk-MF7QK7PS.js";import{d as y,h as B,i as E}from"./chunk-IIY2O6LJ.js";var q={timeoutMs:1800,settleMs:48,startWindowMs:64};function w(e){return new Promise(t=>setTimeout(t,e))}function U(e){return e.includes("--json")}function Y(e){process.stdout.write(`${JSON.stringify(e??null,null,2)}
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{G as P,m as v,n as A,o as h,t as I,v as N}from"./chunk-JXHFW3SD.js";import{d as y,h as B,i as E}from"./chunk-KCP7TTSW.js";var q={timeoutMs:1800,settleMs:48,startWindowMs:64};function w(e){return new Promise(t=>setTimeout(t,e))}function U(e){return e.includes("--json")}function Y(e){process.stdout.write(`${JSON.stringify(e??null,null,2)}
3
3
  `)}function V(e){process.stderr.write(`${e}
4
4
  `)}function b(e,t=Date.now()){let r=new Date(e),n=`${S(r.getHours())}:${S(r.getMinutes())}:${S(r.getSeconds())}`,s=t-e;if(s<0)return n;let o=Math.round(s/1e3);return o<60?`${n} +${o}s`:o<3600?`${n} +${Math.round(o/60)}m`:o<86400?`${n} +${Math.round(o/3600)}h`:`${n} +${Math.round(o/86400)}d`}function S(e){return e<10?`0${e}`:String(e)}async function D(e,t,...r){return B(e,`__sootsimTest.${t}`,...r)}async function k(e,t,...r){return E(e,`SootSim.bridges.mainShell.${t}`,...r)}async function z(e,t={}){try{let r=await D(e,"waitForScreenTransitions",q);if(!t.verbose||!r?.started)return;if(r.timedOut){console.log(` screen transition still active after ${r.waitedMs}ms; continuing`);return}r.waitedMs>0&&console.log(` waited ${r.waitedMs}ms for screen transition settle`)}catch{}}async function K(e,t,r,...n){let s=Date.now()+Math.max(0,r);for(;;)try{return await k(e,t,...n)}catch(o){if(!P(o)||Date.now()>=s)throw o;await w(50)}}async function Q(e,t,r,n={}){let s=n.attempts??30,o=n.intervalMs??500,l=n.minNodeCount??10;for(let a=0;a<s;a++){let u=y(e,{commandTimeoutMs:t,simId:r,simIdSource:n.simIdSource});try{let c=await u.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>l)return{bridge:u,count:c}}catch{}u.close(),await w(o)}return null}async function X(e,t,r,n={}){let s=n.timeoutMs??8e3,o=n.intervalMs??250,l=Date.now()+s;for(;Date.now()<l;){let a=y(e,{commandTimeoutMs:t,simId:r,simIdSource:n.simIdSource});try{return await a.send({type:"evaluate",code:"1"}),a}catch{a.close()}await w(o)}return null}async function Z(e,t={}){let r=t.timeoutMs??1e4,n=t.errorGraceMs??3e3,s=t.pollIntervalMs??200,o=Date.now(),l=o+r,a=-1,u=o,c=null,d=!1,m={ready:!1,source:"timeout",elapsedMs:0,nodes:0,targets:0,flag:void 0,loadingText:"",externalReady:null,externalStatus:"",externalError:"",errors:0};for(;Date.now()<l;){try{let i=await e.send({type:"evaluate",code:v}),g=Date.now()-o,f=Number(i?.nodes)||0,$=Number(i?.targets)||0,x=Number(i?.errors)||0,C=i?.flag===!0,p=i?.externalReady,T=typeof i?.loadingText=="string"?i.loadingText.trim():"",W=typeof i?.externalStatus=="string"?i.externalStatus.trim():"",M=typeof i?.externalError=="string"?i.externalError.trim():"",R=typeof i?.externalError=="string"&&M.length>0;if(c=p,d=R,f!==a&&(a=f,u=g),m={ready:!1,source:"timeout",elapsedMs:g,nodes:f,targets:$,flag:i?.flag,loadingText:T,externalReady:typeof p=="boolean"?p:null,externalStatus:W,externalError:M,errors:x},C&&p!==!1&&!R&&!T&&h({nodes:f,targets:$})&&g-u>=A)return{...m,ready:!0,source:"flag"};if(g>=n&&x>0&&!C)return{...m,ready:!1,source:"error-bail"}}catch{}await w(s)}return c!==!1&&!d&&!m.loadingText&&h(m)?{...m,ready:!0,source:"nodes-fallback"}:{...m,ready:!1,source:"timeout",elapsedMs:Date.now()-o}}function O(e){let t=e.displayUrl||e.url;return e.status!=null?`${e.method} ${t} -> ${e.status}${e.statusText?` ${e.statusText}`:""}`:e.error?`${e.method} ${t} -> ${e.error}`:`${e.method} ${t}`}async function _(e,t,...r){return e.send({type:"call",path:`__sootsimTest.${t}`,args:r})}async function F(e,t={}){let r=await e.send({type:"evaluate",code:N});if(!r||typeof r!="object")return;let n=Math.max(0,Number(r.errors)||0),s=Math.max(0,Number(r.warnings)||0);if(n===0&&s===0)return;let o=[];if(n>0&&o.push(`${n} console error${n===1?"":"s"}`),s>0&&o.push(`${s} console warning${s===1?"":"s"}`),console.log(`
5
5
  console: ${o.join(", ")}`),t.errorsCommand&&console.log(` inspect: ${t.errorsCommand}`),s>0&&t.warningsCommand&&console.log(` inspect: ${t.warningsCommand}`),!t.includeTail||n===0)return;let l=await I(e,5);if(!(!Array.isArray(l)||l.length===0)){console.log(`
@@ -0,0 +1,5 @@
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as C,b as x}from"./chunk-MPJ2W2JQ.js";var k="sootsimConfig";function m(e){return!!e&&Object.keys(e).length>0}function E(e){return e?m(e.modules)||m(e.turboModules)||m(e.nativeModules)||m(e.env)||m(e.network?.remap)||m(e.settings)||m(e.initialState):!1}function M(e,r){let o=new URL(e);return E(r)?o.searchParams.set(k,JSON.stringify(r)):o.searchParams.delete(k),o.toString()}var te="/index.bundle?platform=ios&dev=true&hot=true&minify=false";function _(e){return/^https?:\/\//i.test(e)}function D(e){return e.endsWith(".bundle")}function A(e){process.env.SOOTSIM_PREVIEW_PROD_BUNDLE&&(e.searchParams.set("dev","false"),e.searchParams.set("minify","true"),e.searchParams.has("hot")&&e.searchParams.set("hot","false"))}function U(e){try{let r=_(e),o=new URL(e,"http://soot.local");return o.pathname=o.pathname.replace(/\.\.bundle$/,".bundle"),D(o.pathname)?(o.searchParams.delete("transform.bytecode"),A(o),r?o.toString():`${o.pathname}${o.search}${o.hash}`):e}catch{return e}}function oe(e,r){try{let o=_(e),t=new URL(e,"http://soot.local");return D(t.pathname)?(t.searchParams.set("hot",r?"true":"false"),o?t.toString():`${t.pathname}${t.search}${t.hash}`):e}catch{return e}}import{exec as N}from"child_process";import L from"http";import $ from"net";import{promisify as O}from"util";var v=O(N);C();var I=250,B=1500,H=120;function j(e,r=H){return new Promise(o=>{let t=new $.Socket,s=!1,i=a=>{s||(s=!0,t.destroy(),o(a))};t.setTimeout(r),t.once("connect",()=>i(!0)),t.once("timeout",()=>i(!1)),t.once("error",()=>i(!1)),t.connect(e,"localhost")})}function h(e,r,o="GET",t=I,s={}){return new Promise(i=>{let a=L.request({hostname:"localhost",port:e,path:r,method:o,timeout:t,headers:s},n=>{let u="";n.on("data",l=>u+=l.toString());let c=(()=>{let l=n.headers["content-type"];if(typeof l=="string")return l;if(Array.isArray(l))return l[0]})();n.on("end",()=>i({statusCode:n.statusCode||0,body:u,contentType:c}))});a.on("error",()=>i(null)),a.setTimeout(t,()=>{a.destroy(),i(null)}),a.end()})}var W=[8081,8082,8083,8084,8085,8086,3e3,3001,19e3].map(e=>({port:e,pid:0}));function P(e,r){return!(e<=0||e>=2e4||r.has(e)||e>=5170&&e<=5200)}async function F(e=[]){let r=new Set(e);try{let{stdout:o}=await v("lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'",{encoding:"utf8",timeout:2e3});if(o.trim()){let t=new Map;for(let s of o.trim().split(`
3
+ `)){let i=s.trim().split(/\s+/);if(i.length<9)continue;let a=Number(i[1]),u=i[8].match(/:(\d+)$/);if(!u)continue;let c=Number(u[1]);P(c,r)&&(t.has(c)||t.set(c,a))}if(t.size>0)return[...t.entries()].map(([s,i])=>({port:s,pid:i}))}}catch{}try{let{stdout:o}=await v(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,{encoding:"utf8",timeout:2e3});if(o.trim()){let t=new Map;for(let s of o.trim().split(`
4
+ `)){let i=s.match(/:(\d+)\s/),a=s.match(/pid=(\d+)/);if(!i)continue;let n=Number(i[1]),u=a?Number(a[1]):0;P(n,r)&&(t.has(n)||t.set(n,u))}if(t.size>0)return[...t.entries()].map(([s,i])=>({port:s,pid:i}))}}catch{}return W.filter(o=>P(o.port,r))}var y=new Map;async function G(e){if(e<=0)return null;let r=y.get(e);if(r)return r;try{let{stdout:o}=await v(`lsof -p ${e} -a -d cwd -Fn 2>/dev/null`,{encoding:"utf8",timeout:1500});for(let t of o.split(`
5
+ `))if(t.startsWith("n")&&t.length>1){let s=t.slice(1).trim();if(s)return y.set(e,s),s}}catch{}return null}function z(e,r){return{port:e,framework:r,bundleUrl:g(e,`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()}}function g(e,r){let o=x().find(s=>s.preferredPort===e),t=o?.runtimeConfig?M(r,o.runtimeConfig):r;return U(t)}function J(e){return e.includes("/node_modules/one/metro-entry.bundle")}function K(e){try{let r=JSON.parse(e);return r&&typeof r=="object"?r:null}catch{return null}}function w(e,r,o){if(!r)return e;try{let t=JSON.parse(r.body),s=t?.extra?.expoClient||t?.extra||{};s.name&&(e.projectName=s.name),s.ios?.bundleIdentifier&&(e.bundleId=s.ios.bundleIdentifier),e.framework==="metro"&&s.sdkVersion&&(e.framework="expo");let i=t?.launchAsset?.url;i&&!e.patched&&!J(e.bundleUrl)&&(e.bundleUrl=g(e.port,i));let a=s.iconUrl||s.ios?.iconUrl||s.icon||s.ios?.icon;if(a)if(e.iconPath=a,o)if(a.startsWith("http"))e.iconUrl=o(a);else{let n=a.replace(/^\.\//,"");e.iconUrl=o(`http://localhost:${e.port}/assets/${n}`)}else e.iconUrl=a.startsWith("http")?a:`http://localhost:${e.port}/assets/${a.replace(/^\.\//,"")}`}catch{}return e}var d=new Set,p=new Set,S=new Set;async function V(e,r){if(!await j(e))return null;let o="/node_modules/one/metro-entry.bundle?platform=ios&dev=true",[t,s,i,a]=await Promise.all([d.has(e)?Promise.resolve(null):h(e,"/__soot/"),h(e,"/status"),S.has(e)?Promise.resolve(null):h(e,"/","GET",B,{"expo-platform":"ios"}),p.has(e)?Promise.resolve(null):h(e,"/_expo/status")]);a&&a.statusCode===200?p.delete(e):p.has(e)||p.add(e);let n=i?K(i.body):null,u=typeof n?.launchAsset?.url=="string"?n.launchAsset.url:null,c=n?.extra?.expoClient||n?.extra||{};if(n&&(u||typeof c.name=="string")){d.add(e);let R=u||`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`,T=R.includes("/one/metro-entry.bundle")?"one":"expo";return w({port:e,framework:T,bundleUrl:g(e,R),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},i,r)}if(s&&s.body.includes("packager-status:running"))return d.add(e),w(z(e,a&&a.statusCode===200?"expo":"metro"),i,r);if(t&&t.statusCode===200&&t.body.includes("sootsim-patched"))return d.delete(e),w({port:e,framework:"one",bundleUrl:g(e,`http://localhost:${e}/__soot/bundle.js`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now(),patched:!0},i,r);if(s&&s.statusCode===200||a&&a.statusCode===200||i&&i.statusCode===200&&n!=null)return null;let f=await h(e,o,"HEAD");return f&&f.statusCode>0&&f.statusCode<400&&/application\/javascript/i.test(f.contentType||"")?(d.add(e),S.add(e),w({port:e,framework:"one",bundleUrl:g(e,`http://localhost:${e}${o}&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},i,r)):(d.add(e),null)}function q(e){let r=e.projectName?.trim().toLowerCase();return!!(r==="soot"||r==="sootsim"||e.bundleId?.trim().toLowerCase()?.startsWith("dev.soot"))}var b=new Map,Q=3e4,Y=1500;function X(e){return!e||e.framework==="metro"||e.framework==="unknown"}function Z(e){return e?g(e.port,e.bundleUrl)===e.bundleUrl:!0}function ee(e,r,o=Date.now()){if(r===0||e.pid!==r||!Z(e.result))return!1;let t=o-e.cachedAt;return!(e.result===null&&t>=Q||X(e.result)&&t>=Y)}async function fe(e={}){let r=await F(e.excludePorts),o=new Set(r.map(n=>n.port));for(let n of[...b.keys()])o.has(n)||b.delete(n);for(let n of[...d])o.has(n)||d.delete(n);for(let n of[...p])o.has(n)||p.delete(n);for(let n of[...S])o.has(n)||S.delete(n);let t=[],s=[];for(let{port:n,pid:u}of r){let c=b.get(n);if(c&&ee(c,u)){c.result&&t.push(c.result);continue}c&&c.pid!==u&&(d.delete(n),p.delete(n),S.delete(n)),s.push({port:n,pid:u})}s.length>0&&(await Promise.all(s.map(u=>V(u.port,e.buildIconProxyUrl)))).forEach((u,c)=>{let{port:l,pid:f}=s[c];f!==0&&b.set(l,{pid:f,result:u,cachedAt:Date.now()}),u&&t.push(u)});let i=new Map;for(let{port:n,pid:u}of r)u>0&&i.set(n,u);await Promise.all(t.map(async n=>{let u=i.get(n.port);if(!u)return;n.pid=u;let c=await G(u);c&&(n.cwd=c)}));let a=new Set(i.values());for(let n of[...y.keys()])a.has(n)||y.delete(n);return t.filter(n=>!q(n))}export{M as a,te as b,U as c,oe as d,V as e,fe as f};
@@ -1,3 +1,3 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{A as m,n as P,p as a}from"./chunk-EGBFMW45.js";import l from"fs";import c from"path";var s="default",S="profiles.json",i=1;function o(e){let r=e.trim();if(!r)throw new Error("profile id is required");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(r))throw new Error("profile ids must start with a letter or number and contain only letters, numbers, dot, dash, or underscore");if(r==="."||r==="..")throw new Error(`invalid profile id: ${r}`);return r}function d(){return c.join(a(),S)}function I(e){return`sootsim-profile-${o(e)}`}function h(e){return c.join(P(),"Partitions",I(e))}function A(e){return c.join(a(),"playwright",o(e))}function u(){try{let e=JSON.parse(l.readFileSync(d(),"utf8"));if(!e||e.version!==i)return{version:i,profiles:[]};let r=Array.isArray(e.profiles)?e.profiles.filter(t=>!!t&&typeof t.id=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string").map(t=>({id:o(t.id),createdAt:t.createdAt,updatedAt:t.updatedAt})):[];return{version:i,profiles:r}}catch{return{version:i,profiles:[]}}}function x(e){return[...e].sort((r,t)=>r.id===s?-1:t.id===s?1:r.id.localeCompare(t.id))}function p(e){if(e.profiles.some(t=>t.id===s))return{...e,profiles:x(e.profiles)};let r=new Date().toISOString();return{version:i,profiles:x([{id:s,createdAt:r,updatedAt:r},...e.profiles])}}function g(e){m();let r=p(e),t=`${d()}.tmp`;return l.writeFileSync(t,`${JSON.stringify(r,null,2)}
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{A as m,n as P,p as a}from"./chunk-V6OGDC6H.js";import l from"fs";import c from"path";var s="default",S="profiles.json",i=1;function o(e){let r=e.trim();if(!r)throw new Error("profile id is required");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(r))throw new Error("profile ids must start with a letter or number and contain only letters, numbers, dot, dash, or underscore");if(r==="."||r==="..")throw new Error(`invalid profile id: ${r}`);return r}function d(){return c.join(a(),S)}function I(e){return`sootsim-profile-${o(e)}`}function h(e){return c.join(P(),"Partitions",I(e))}function A(e){return c.join(a(),"playwright",o(e))}function u(){try{let e=JSON.parse(l.readFileSync(d(),"utf8"));if(!e||e.version!==i)return{version:i,profiles:[]};let r=Array.isArray(e.profiles)?e.profiles.filter(t=>!!t&&typeof t.id=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string").map(t=>({id:o(t.id),createdAt:t.createdAt,updatedAt:t.updatedAt})):[];return{version:i,profiles:r}}catch{return{version:i,profiles:[]}}}function x(e){return[...e].sort((r,t)=>r.id===s?-1:t.id===s?1:r.id.localeCompare(t.id))}function p(e){if(e.profiles.some(t=>t.id===s))return{...e,profiles:x(e.profiles)};let r=new Date().toISOString();return{version:i,profiles:x([{id:s,createdAt:r,updatedAt:r},...e.profiles])}}function g(e){m();let r=p(e),t=`${d()}.tmp`;return l.writeFileSync(t,`${JSON.stringify(r,null,2)}
3
3
  `,"utf8"),l.renameSync(t,d()),r}function y(){return g(u()).profiles}function E(e){let r=o(e);return y().find(t=>t.id===r)??null}function _(e=s){let r=o(e),t=E(r);return t||D(r)}function D(e){let r=o(e),t=p(u());if(t.profiles.some(w=>w.id===r))throw new Error(`profile already exists: ${r}`);let f=new Date().toISOString(),n={id:r,createdAt:f,updatedAt:f};return g({version:i,profiles:[...t.profiles,n]}),n}function F(e){let r=o(e);if(r===s)throw new Error("the default profile cannot be deleted; clear it instead");let t=p(u()),f=t.profiles.find(n=>n.id===r);if(!f)throw new Error(`profile not found: ${r}`);return g({version:i,profiles:t.profiles.filter(n=>n.id!==r)}),v(r),f}function v(e){let r=o(e);for(let t of[h(r),A(r)])try{l.rmSync(t,{recursive:!0,force:!0})}catch{}}export{A as a,y as b,_ as c,D as d,F as e,v as f};
@@ -1,3 +1,3 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{j as n}from"./chunk-J7YRSCPF.js";var i=[];for(let[t,e]of Object.entries(n))e.cliFlag&&i.push({name:`--${e.cliFlag}`,short:e.cliFlagShort?`-${e.cliFlagShort}`:void 0,key:t,type:e.type==="enum"?"string":e.type,description:e.description,options:e.options,default:e.default});var a=i;function g(){let t=[];for(let e of a){let s=e.short?`${e.short}, ${e.name}`:` ${e.name}`,o=e.options?` [${e.options.join("|")}]`:"",r=e.default!==void 0?` (default: ${e.default})`:"";t.push(` ${s.padEnd(24)}${e.description}${o}${r}`)}return t.join(`
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{j as n}from"./chunk-HNZF4VNH.js";var i=[];for(let[t,e]of Object.entries(n))e.cliFlag&&i.push({name:`--${e.cliFlag}`,short:e.cliFlagShort?`-${e.cliFlagShort}`:void 0,key:t,type:e.type==="enum"?"string":e.type,description:e.description,options:e.options,default:e.default});var a=i;function g(){let t=[];for(let e of a){let s=e.short?`${e.short}, ${e.name}`:` ${e.name}`,o=e.options?` [${e.options.join("|")}]`:"",r=e.default!==void 0?` (default: ${e.default})`:"";t.push(` ${s.padEnd(24)}${e.description}${o}${r}`)}return t.join(`
3
3
  `)}export{g as a};
@@ -0,0 +1,13 @@
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as L,b as V,c as he,d as ge,e as we}from"./chunk-OIVSYUZ4.js";import{m as D}from"./chunk-O3PHDVRF.js";import{m as pe,o as fe}from"./chunk-JXHFW3SD.js";import{a as ve,b as $e}from"./chunk-Y6RN5IR4.js";import{a as ye,b as G,c as Se}from"./chunk-S2MAMEQX.js";import{b as ue,c as I,d as y,e as x}from"./chunk-KCP7TTSW.js";import{g as Q}from"./chunk-D3GGZIBS.js";import{a as T,b as J}from"./chunk-LOGFVSIT.js";import{c as be}from"./chunk-OY57XV3X.js";import{d as q}from"./chunk-EFCPQBFY.js";import{a as me}from"./chunk-LIYFRTZG.js";import{d as C,e as b,f as M}from"./chunk-2TE65ODE.js";import{G as ce,H as de}from"./chunk-V6OGDC6H.js";import te from"node:fs";import qe from"node:os";import k from"node:path";function Ne(e){return e.replace(/^\[|\]$/g,"").toLowerCase()}function A(e){let t=Ne(e);return t==="localhost"||t.endsWith(".localhost")||t==="0.0.0.0"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t)}function Ie(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function Fe(e,t){return e?.includes("/one/metro-entry.bundle")?"one":typeof t=="string"&&t?"expo":"unknown"}function Pe(e,t,o){return`${e}//${t}:${o}`}function He(e){if(typeof window>"u")return!1;try{let t=new URL(e);return A(t.hostname)&&A(window.location.hostname)&&t.origin!==window.location.origin}catch{return!1}}async function xe(e,t){let o={...t,cache:t?.cache??"no-store"};return He(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,o):fetch(e,o)}function je(e){return e==="https:"?443:80}function Ke(e){let t=e.pathname||"/";return(t==="/"||t==="")&&!e.search&&!e.hash}async function We(e){try{let t=await fetch("/__server-scan",{cache:"no-store"});if(!t.ok||!(t.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let o=await t.json();if(!Array.isArray(o))return null;let n=o.find(r=>!!r&&typeof r=="object"&&r.port===e&&typeof r.bundleUrl=="string");return n?{bundleUrl:n.bundleUrl,port:e,framework:typeof n.framework=="string"?n.framework:"unknown",projectName:typeof n.projectName=="string"?n.projectName:void 0}:null}catch{return null}}async function Ce(e,t){let o=e.replace(/\/+$/,"");try{if(A(new URL(o).hostname)){let n=await We(t);if(n)return n}}catch{}try{let n=await xe(`${o}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),s=r?.extra?.expoClient||r?.extra||{},i=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(i||s.name)return{bundleUrl:he(i||`${o}${V}`),port:t,framework:Fe(i,s.sdkVersion),projectName:s.name}}}catch{}try{let n=await xe(`${o}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${o}${V}`,port:t,framework:"metro"}}catch{}return null}async function ke(e){return Ce(Pe("http:","localhost",e),e)}async function Me(e){let t=e.trim();if(/^\d+$/.test(t)){let a=parseInt(t,10),l=await ke(a);if(l)return l;let c=3;for(let d=1;d<=c;d++){let m=await ke(a+d);if(m)return m}throw Ie(`localhost:${a} (also scanned +1..+${c})`)}let o=t.startsWith("http")?t:`http://${t}`,n;try{n=new URL(o)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",s=n.port?parseInt(n.port,10):je(r),i=Pe(r,n.hostname,s);if(Ke(n)){let a=await Ce(i,s);if(a)return a;throw Ie(i)}return{bundleUrl:n.toString(),port:s,framework:"unknown"}}function Rt(){console.error(" no sootsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" sootsim install-desktop"),console.error(""),console.error(" or wire sootsim into your own project so your dev server hosts the bridge:"),console.error(" sootsim setup-repo"),console.error("")}function Te(e){let t=T();if(console.log(` note: no sootsim bridge detected on port ${e}`),t){console.log(" launch the installed companion with:"),console.log(" sootsim electron");return}console.log(""),console.log(" to get a bridge running, either:"),console.log(" sootsim install-desktop # download the electron app"),console.log(" sootsim setup-repo # wire sootsim into your own project")}function ze(e){console.error(""),console.error(` no sim is connected to the sootsim bridge on port ${e}.`),console.error(""),console.error(" start your app dev server, then open it in sootsim:"),console.error(" npx expo start --localhost --port 8081"),console.error(" sootsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" sootsim describe")}async function Et(e,t,o){let n=[];try{n=await e.listSims()}catch{}if(console.error(""),n.length===0){ze(t);return}console.error(` no sim with id "${o}" is connected to the bridge on port ${t}.`),console.error(""),console.error(" connected sims:");for(let r of n){let s=[r.isPrimary?"primary":null,r.readyState,r.userVisible===!1?"hidden":r.userVisible===!0?"visible":null,r.userFocused?"focused":null].filter(Boolean).join(", ");console.error(` ${r.id} (${s})`)}console.error(""),console.error(" pass a valid --sim id, or run `sootsim list` to see all sessions.")}var Ve=12e4,Ue=500,Ge=5e3,Je={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function v(e){return new Promise(t=>setTimeout(t,e))}function Oe(e){let t=process.env[e]?.trim();if(!t)return null;let o=Number(t);return Number.isInteger(o)&&o>0?o:null}function Qe(){let e=Oe("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??Oe("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??Ve;return{timeoutMs:e,hostTimeoutMs:e+Ge,intervalMs:Ue,attempts:Math.max(1,Math.ceil(e/Ue))}}function Ye(e){return e==="chromium"||e==="electron"||e==="playwright"||e==="system"}function Xe(e,t){return e.includes("--headless")?!0:e.includes("--headed")?!1:t==="playwright"&&process.platform==="linux"&&!process.env.DISPLAY&&!process.env.WAYLAND_DISPLAY?(console.error(" no display detected \u2192 running playwright headless (override with --headed)"),!0):!1}function F(e){return e.trim()}function Z(e){try{let t=new URL(e),o=t.pathname.replace(/\/+$/,"")||"/";return t.searchParams.has("open")||t.searchParams.has("port")||t.searchParams.has("bundle")||t.searchParams.has("demo")||t.pathname.includes("/sootsim/index.html")||o==="/sootsim"||t.pathname==="/__soot"||t.pathname==="/__soot/"||o==="/rn"||/^\/rn\/[^/]+$/i.test(o)||/^\/app\/[^/]+$/i.test(o)||o==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(o)||/^\/__soot\/app\/[^/]+$/i.test(o)}catch{return!1}}function Ze(e){try{let t=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(t)||/^\/build\/.+/.test(t)}catch{return!1}}async function to(e){let t=F(e);return(await Be(t)).bundleUrl}function et(e){try{let t=new URL(e.startsWith("http")?e:`http://${e}`),o=t.pathname||"/";if(o!=="/"&&o!==""||t.search||t.hash||!/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(t.hostname))return null;let n=t.port?Number(t.port):t.protocol==="https:"?443:80;return Number.isFinite(n)&&n>0?n:null}catch{return null}}async function Be(e){let t=F(e),o=/^\d+$/.test(t)?Number(t):et(t);if(o&&o>0){let n=await we(o);if(n)return{bundleUrl:n.bundleUrl,port:n.port,framework:n.framework,projectName:n.projectName}}return Me(t)}function oe(e){let t=e.replace(/\/+$/,"")||"/";return t==="/__soot"||t.startsWith("/__soot/")?"/__soot":""}function tt(e,t){let o=F(e),n=new URL(t),r=oe(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(o)?n.pathname=`${r}/rn/${o}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",o)),n.toString()}function ot(e){let t=F(e);return/^\d+$/.test(t)||/^https?:\/\//i.test(t)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(t)}async function nt(e,t,o={}){let n=await Be(e),r=new URL(t),s=oe(r.pathname);r.pathname=`${s}/rn`,r.searchParams.delete("open"),r.searchParams.delete("port"),r.searchParams.delete("demo"),r.searchParams.delete("app");let i=o.hot===void 0?n.bundleUrl:ge(n.bundleUrl,o.hot);return r.searchParams.set("bundle",i),r.toString()}function rt(e){return e.startsWith("~/")?k.join(qe.homedir(),e.slice(2)):k.isAbsolute(e)?e:k.resolve(process.cwd(),e)}function st(e){let t={},o={};for(let r=0;r<e.length;r++){if(e[r]==="--replace"){let s=e[r+1];s||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let i=s.indexOf("=");(i<=0||i===s.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let a=s.slice(0,i).trim(),l=rt(s.slice(i+1).trim());te.existsSync(l)||(console.error(` sootsim open: replacement file not found: ${l}`),process.exit(1)),t[a]={file:l},r++;continue}if(e[r]==="--remap"){let s=e[r+1],i=s?s.indexOf("="):-1;(!s||i<=0||i===s.length-1)&&(console.error(" sootsim open: --remap expects <host:port>=<host:port>"),process.exit(1)),o[s.slice(0,i).trim()]=s.slice(i+1).trim(),r++;continue}}let n={};return Object.keys(t).length>0&&(n.modules=t),Object.keys(o).length>0&&(n.network={remap:o}),n.modules||n.network?n:void 0}function De(){let e=ce();return de(e)&&e.runtimePort>0?`http://localhost:${e.runtimePort}/`:me}async function it(e){try{let t=new URL(e),o=t.searchParams.get("bundle")||"";if(!o)return e;let n=process.env.SOOT_REPO_DIR||await G(o)||void 0,r=ye({bundleUrl:o,repoDir:n});if(r.length===0)return e;let s=await at(r);return s.length===0?e:(t.searchParams.set("appFonts",Se(s)),t.toString())}catch{return e}}async function at(e){let t=await Promise.all(e.map(async n=>{let r=new AbortController,s=setTimeout(()=>r.abort(),1500);try{let i=await fetch(n.url,{method:"HEAD",signal:r.signal});return i.status>=200&&i.status<400?n:null}catch{return null}finally{clearTimeout(s)}})),o=[];for(let n of t)n!==null&&o.push(n);return o}async function lt(e,t,o={}){if(!e)return new URL(t).toString();if(Z(e))return new URL(e).toString();let n=Je[e.toLowerCase()];if(n){let r=new URL(t),s=oe(r.pathname);return r.pathname=`${s}${n}`,r.toString()}return ot(e)?nt(e,t,o):tt(e,t)}async function ct(e){try{let t=new URL(e),o=t.searchParams.get("bundle")||"";if(!o)return e;let n=process.env.SOOT_REPO_DIR||await G(o)||void 0,r=ve({bundleUrl:o,repoDir:n});return!r||r.imageUrl&&!await dt(r.imageUrl)?e:(t.searchParams.set("appSplash",$e(r)),t.toString())}catch{return e}}async function dt(e){let t=new AbortController,o=setTimeout(()=>t.abort(),1500);try{let n=await fetch(e,{method:"HEAD",signal:t.signal});return n.status>=200&&n.status<400}catch{return!1}finally{clearTimeout(o)}}async function N(e,t=De(),o={}){let n=await lt(e,t,o);return ct(await it(n))}function Re(e,t){let o=e?.url||e?.origin||t;try{let n=new URL(o);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.searchParams.delete("appFonts"),n.searchParams.delete("appSplash"),n.toString()}catch{return t}}async function mt(e,t,o,n={}){let r=new URL(await N(e,t,n));return r.searchParams.set("inspectOpen",o),r.toString()}async function ut(e,t,o,n={}){let r=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<r;a++){let l=y(e,{commandTimeoutMs:t,simId:o,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>i)return{bridge:l,count:c}}catch{}l.close(),await v(s)}return null}function pt(e){if(!e)return null;try{let t=new URL(e);if(t.searchParams.has("bundle")){let o=t.searchParams.get("bundle")||"";try{let n=new URL(o),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return t.searchParams.has("port")?`connect :${t.searchParams.get("port")||""}`:t.searchParams.has("open")?`connect ${t.searchParams.get("open")||""}`:t.searchParams.has("demo")?`demo ${t.searchParams.get("demo")||"default"}`:t.pathname.includes("/sootsim/index.html")||t.pathname==="/sootsim/"||t.pathname==="/sootsim"?"embedded sootsim":null}catch{return null}}function ft(e){let t=e.indexOf(":");if(t<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let o=e.slice(0,t),n=e.slice(t+1),r=n.length>12?`${n.slice(0,8)}\u2026`:n;return o==="CLAUDE_CODE_SESSION_ID"||o==="CODEX_THREAD_ID"?`agent ${r}`:`${o} ${r}`}function ht(e,t){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
3
+ `);for(let o of e){let n=o.lockedBy&&o.lockExpiresAt?`locked by ${ft(o.lockedBy)} (${Math.max(0,Math.round((o.lockExpiresAt-Date.now())/1e3))}s)`:"",r=[o.isPrimary?"primary":"",o.id===t?"selected":"",o.readyState,o.userVisible===!1?"hidden":o.userVisible===!0?"visible":"",o.attachedCliCount&&o.attachedCliCount>0?"in use":"",o.userFocused?"focused":"",n].filter(Boolean);console.log(` ${o.id}${r.length?` [${r.join(", ")}]`:""}`);let s=pt(o.url);if(s)console.log(` loaded: ${s}`);else if(o.url){let a=o.url.length>96?`${o.url.slice(0,93)}\u2026`:o.url;console.log(` url: ${a}`)}else o.origin&&console.log(` origin: ${o.origin}`);let i=gt(o);i&&console.log(` engine: ${i}`),o.title&&console.log(` title: ${o.title}`),o.visibilityState&&o.visibilityState!=="visible"&&console.log(` visibility: ${o.visibilityState}`),console.log(` connected: ${Ee(Date.now()-o.connectedAt)}`),o.lastActiveAt&&o.lastActiveAt>0&&console.log(` last active: ${Ee(Date.now()-o.lastActiveAt)}`)}}function gt(e){let t=e.url||e.origin||"";if(!t)return null;try{let o=new URL(t).port;return o==="5173"?"dev \u2014 local source (:5173)":o==="3000"?"soot app embedded (:3000)":`runtime \u2014 published engine (:${o||"?"})`}catch{return null}}function Ee(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}async function Y(e,t,o,n={}){let r=n.attempts??30,s=n.intervalMs??500;for(let i=0;i<r;i++){let a=y(e,{commandTimeoutMs:t});try{let c=(await a.listSims()).find(o);if(c)return c}catch{}finally{a.close()}await v(s)}return null}async function wt(e,t,o,n,r={}){let s=r.attempts??30,i=r.intervalMs??500,a=!!n&&Number.isInteger(n)&&n>1,l=()=>a&&n!==void 0&&!ee(n);for(let c=0;c<s;c++){if(l())return{kind:"host-exit"};let d=y(e,{commandTimeoutMs:t});try{let h=(await d.listSims()).find(o);if(h)return l()?{kind:"host-exit"}:{kind:"match",sim:h}}catch{}finally{d.close()}if(l())return{kind:"host-exit"};await v(i)}return{kind:"timeout"}}async function bt(e,t,o,n={}){let r=n.attempts??20,s=n.intervalMs??250;for(let i=0;i<r;i++){let a=y(e,{commandTimeoutMs:t});try{let c=(await a.listSims()).find(d=>d.id===o);if(!c||c.readyState!=="open")return!0}catch{return!0}finally{a.close()}await v(s)}return!1}function yt(e){let t=e.meta;if(!t||t.sootsimHostDriver!=="playwright")return null;let o=Number(t.sootsimHostPid);return!Number.isInteger(o)||o<=1||o===process.pid?null:o}function St(e){if(!e.connectAckFile)return!1;try{return te.writeFileSync(e.connectAckFile,`${JSON.stringify({connectedAt:Date.now(),pid:e.pid??null})}
4
+ `,{flag:"w"}),!0}catch{return!1}}function _e(e){if(e.diagnosticLogPath)try{let t=te.readFileSync(e.diagnosticLogPath,"utf8").trim();if(!t){console.error(` ${k.basename(e.diagnosticLogPath)} was empty`);return}let o=t.length>4e3?`\u2026
5
+ ${t.slice(-4e3)}`:t;console.error(` ${k.basename(e.diagnosticLogPath)}:`),console.error(o)}catch(t){let o=t instanceof Error?t.message:String(t);console.error(` failed to read ${k.basename(e.diagnosticLogPath)}: ${o}`)}}function ee(e){try{return process.kill(e,0),!0}catch(t){return t?.code==="EPERM"}}async function vt(e,t=2500){let o=Date.now()+t;for(;Date.now()<o;){if(!ee(e))return!0;await v(100)}return!ee(e)}async function X(e,t){let o=new Set(t),n=new Set;for(let r of e){if(!o.has(r.id))continue;let s=yt(r);s&&n.add(s)}for(let r of n){try{process.kill(r,"SIGTERM")}catch{}if(await vt(r)){console.log(` closed playwright host process ${r}`);continue}try{process.kill(r,"SIGKILL"),console.log(` force-closed playwright host process ${r}`)}catch{}}}function H(e,t){if(t){let r=t.trim(),s=e.find(i=>i.id===r);if(!s)throw new Error(`no sim connected with id ${r}`);return s}let o=e.find(r=>r.isPrimary&&r.readyState==="open");if(o)return o;let n=e.find(r=>r.readyState==="open");if(n)return n;throw new Error("no sim connected")}function U(e,t,o){console.log(` ${o==="current sim"?"loaded":"opened"}: ${e} [${o}]`),console.log(` current sim: ${t.id}`),console.log(JSON.stringify({simId:t.id,url:t.url},null,2))}async function O(e,t,o){if(o.includes("--no-describe"))return;let n=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await $t(e,t,{stableMs:150,maxMs:400});let r=y(e,{commandTimeoutMs:3e3,simId:t,cliLabel:"open --describe",simIdSource:"flag"});try{let s=null;try{s=await r.send({type:"evaluate",code:pe})}catch{}if(s&&!(s.flag===!0&&!s.loadingText&&fe(s))){let d=s.loadingText?`still showing "${s.loadingText}"`:s.flag!==!0?"guest ready event has not fired":s.targets<=0?"no visible app content is inspectable yet":"app tree is still stabilizing";console.log(` app still loading: ${d} (nodes: ${s.nodes}, targets: ${s.targets})`),console.log(" before interacting, run: sootsim wait ready --max-ms 120000")}let a=`(async () => {
6
+ const t = window.__sootsimTest
7
+ const ms = window.SootSim?.bridges?.mainShell
8
+ if (!t) return null
9
+ let shell = null
10
+ try { shell = ms?.getState ? await ms.getState() : null } catch {}
11
+ const tree = await t.dumpTree(12, ${JSON.stringify({describe:!0,verbose:!1,filter:""})})
12
+ return { tree, shell }
13
+ })()`,l=await r.send({type:"evaluate",code:a});if(!l?.tree)return;if(console.log(""),l.shell?.state){let c=[`state=${l.shell.state}`,l.shell.activeApp?`app=${l.shell.activeApp}`:null].filter(Boolean);console.log(` shell: ${c.join(" ")}`)}console.log(l.tree)}finally{r.close()}}catch{}finally{n===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=n}}async function $t(e,t,o){let n=Date.now()+o.maxMs,r="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",s=y(e,{commandTimeoutMs:2e3,simId:t,simIdSource:"flag"});try{let i=-1,a=0;for(;Date.now()<n;){let l=-1;try{let c=await s.send({type:"evaluate",code:r});typeof c=="number"&&(l=c)}catch{}if(l>=0&&l===i){if(Date.now()-a>=o.stableMs)return}else i=l,a=Date.now();await v(50)}}finally{s.close()}}async function oo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs}),n=x(o);try{let r=await n.listSims();ht(r,o.simId)}finally{n.close()}}async function no(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--new","--headless","--headed","--ephemeral","--hot","--no-hmr"],stripValueFlags:["--base-url","--replace","--driver","--profile","--cdp-port"]}),n=e.find((u,p)=>e[p-1]==="--profile"),r=e.includes("--ephemeral"),s=e.find((u,p)=>e[p-1]==="--cdp-port"),i=s?Number(s):void 0;s&&(!Number.isFinite(i)||i<=0)&&(console.error(` sootsim open: --cdp-port must be a positive port number, got "${s}"`),process.exit(1)),n&&r&&(console.error(" sootsim open: --profile cannot be combined with --ephemeral"),process.exit(1));let a=n?be(n).id:void 0,l=!!a||r,c=e.includes("--new")||l,d=st(e);c&&o.simIdSource==="flag"&&(console.error(" sootsim open: --new, --profile, and --ephemeral cannot be combined with --sim"),process.exit(1));let m=o.positional[0]||"";if(Ze(m)){let u=(()=>{try{return/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(new URL(m).hostname)}catch{return!1}})();console.log(" that\u2019s a SootSim preview/build link \u2014 a full player page, not a driveable sim."),console.log(" opening it in your browser for viewing\u2026");try{await q(m,{background:!1})}catch(p){console.error(` could not launch a browser: ${p instanceof Error?p.message:String(p)}`),console.error(` open it yourself: ${m}`),process.exit(1)}console.log(u?" to drive it under the CLI, point `sootsim open` at the app\u2019s dev port instead (e.g. `sootsim open 8081`).":" the CLI can\u2019t drive a remote preview (the engine only attaches to the local bridge from localhost). to drive the app, run it locally and `sootsim open <port>`.");return}let h=e.find((u,p)=>e[p-1]==="--driver")||"",j=Xe(e,h);i&&h!=="playwright"&&(console.error(" sootsim open: --cdp-port is only honored by the playwright driver \u2014 add `--driver playwright`"),process.exit(1));let ne=e.includes("--hot"),re=e.includes("--no-hmr");ne&&re&&(console.error(" sootsim open: --hot and --no-hmr cannot be combined"),process.exit(1));let R={hot:ne?!0:re?!1:h!=="playwright"},P=e.find((u,p)=>e[p-1]==="--base-url")||De(),se=e.includes("--base-url"),ie=C();if(!h&&!c&&(o.simIdSource==="flag"||o.simIdSource==="saved"&&!!ie)){let u=x(o),p=o.simId?` --sim ${o.simId}`:"",f=!1;try{let g=null;try{let w=await u.listSims();if(o.simIdSource==="saved"?(g=w.find($=>$.id===ie&&$.readyState==="open")??null,g||M()):g=H(w,o.simId),!g)if(o.simIdSource==="saved")f=!0;else throw new Error("no sim connected");if(!f&&g){let $=se||Z(m)?P:Re(g,P),B=await N(m,L($,d),R);u.send({type:"evaluate",simId:g.id,code:`window.location.href = ${JSON.stringify(B)}`}).catch(()=>{})}}catch(w){console.error(` open failed: ${w instanceof Error?w.message:String(w)}`),await D(u,{errorsCommand:`sootsim get errors 5${p}`,warningsCommand:`sootsim get warnings 5${p}`,requestsCommand:`sootsim get requests 5${p}`}),process.exit(1)}if(!f&&g){await v(1500);let w=await ut(o.wsPort,o.commandTimeoutMs,g.id);w||(console.error(" timed out waiting for current sim to load target"),process.exit(1)),w.bridge.close(),b(g.id);let $=se||Z(m)?P:Re(g,P),B=await N(m,L($,d),R);U(B,{...g,url:B},"current sim"),await O(o.wsPort,g.id,e);return}}finally{u.close()}}let ae=L(P,d),Ae=await N(m,ae,R),le=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=await mt(m,ae,le,R),K={newWindow:!0},E=u=>u.url?.includes(`inspectOpen=${le}`)??!1;if(h){Ye(h)||(console.error(` unknown driver "${h}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let u=Q(h);u||(console.error(` unknown driver "${h}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let p=Qe(),f=await u.launch({url:S,headless:j,newWindow:K.newWindow,profileId:a,ephemeralProfile:r,cdpPort:i,connectTimeoutMs:p.hostTimeoutMs});f.launched||(console.error(` ${u.name} driver: ${f.message}`),process.exit(1));let g=await wt(o.wsPort,o.commandTimeoutMs,E,f.pid,{attempts:p.attempts,intervalMs:p.intervalMs});if(g.kind==="host-exit"&&(_e(f),console.error(` ${u.name} host crashed \u2014 sim is no longer attached`),process.exit(1)),g.kind==="timeout"){if(f.pid)try{process.kill(f.pid,"SIGTERM"),console.error(` closed ${u.name} host process ${f.pid}`)}catch{}_e(f),console.error(` timed out after ${p.timeoutMs}ms waiting for opened sim to connect`),process.exit(1)}let w=g.sim;b(w.id),St(f),U(S,w,`${u.name} driver`),await O(o.wsPort,w.id,e);return}if(l){let u=T();u||(console.error(" profiles require electron or playwright; install the desktop companion or use `--driver playwright`"),process.exit(1));try{(await J(S,u,{profileId:a,ephemeralProfile:r})).launched||(console.error(" desktop companion failed to start"),process.exit(1))}catch(f){console.error(` desktop companion failed: ${f instanceof Error?f.message:String(f)}`),process.exit(1)}let p=await Y(o.wsPort,o.commandTimeoutMs,E,{attempts:40,intervalMs:500});p||(console.error(" timed out waiting for profiled sim to connect"),process.exit(1)),b(p.id),U(S,p,"desktop companion"),await O(o.wsPort,p.id,e);return}let W=!1,z=!1;try{let u=y(o.wsPort,{commandTimeoutMs:2e3});try{await u.listSims(),W=!0}finally{u.close()}}catch{}if(W)try{let u=y(o.wsPort,{commandTimeoutMs:3e3});try{await u.openUrl(S,K),z=!0}finally{u.close()}}catch{}if(!z){let u=T();if(u)try{if((await J(S,u)).launched){let f=await Y(o.wsPort,o.commandTimeoutMs,E,{attempts:20,intervalMs:500});if(f){b(f.id),U(S,f,"desktop companion"),await O(o.wsPort,f.id,e);return}}}catch{}try{await q(S,K)}catch(p){console.error(` open failed: ${p instanceof Error?p.message:String(p)}`),Q("playwright")?.availability().available?console.error(" no system browser found \u2014 retry with `sootsim open \u2026 --driver playwright` for a headless sim."):console.error(" run `sootsim list --drivers` to see available drivers."),process.exit(1)}if(!W){console.log(` opened: ${Ae}`),Te(o.wsPort);return}}let _=await Y(o.wsPort,o.commandTimeoutMs,E,{attempts:30,intervalMs:500});_||(console.error(" timed out waiting for opened sim to connect"),process.exit(1)),b(_.id),U(S,_,z?"bridge":"direct shell open"),await O(o.wsPort,_.id,e)}async function Le(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--force"]}),n=e.includes("--force"),r=x(o),s=o.simId?` --sim ${o.simId}`:"";try{try{let i=await r.listSims(),a=H(i,o.positional[0]||o.simId);if(a.lockedBy&&a.lockExpiresAt&&a.lockExpiresAt>Date.now()){let l=Math.max(0,Math.round((a.lockExpiresAt-Date.now())/1e3));a.lockedByKind==="user-active"&&(console.error(` refused: ${a.id} is locked by the active user (${l}s) \u2014 that's a live human tab`),console.error(" run `sootsim open --new` for a fresh investigation sim"),process.exit(1)),n||(console.error(` refused: ${a.id} is leased by ${a.lockedBy} (${l}s)`),console.error(` \`sootsim use ${a.id} --force\` to take it, or \`sootsim open --new\` for a fresh sim`),process.exit(1))}await r.focusSim(a.id),b(a.id),console.log(` using: ${a.id}`)}catch(i){console.error(` use failed: ${i instanceof Error?i.message:String(i)}`),await D(r,{errorsCommand:`sootsim get errors 5${s}`,warningsCommand:`sootsim get warnings 5${s}`,requestsCommand:`sootsim get requests 5${s}`}),process.exit(1)}}finally{r.close()}}async function ro(e,t={}){await Le(e,t)}async function so(e,t={}){await Le(e,t)}async function io(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--force"]}),n=e.includes("--force"),r=x(o);try{try{let s=await r.listSims(),i=H(s,o.positional[0]||o.simId),a=n&&i.lockedBy&&i.lockedByKind!=="user-active"?i.lockedBy:null,l=await r.claim(i.id,{force:n});b(i.id);let c=Math.max(0,Math.round((l.lockExpiresAt-Date.now())/1e3)),d=l.bootedCount>0?` (booted ${l.bootedCount})`:"";console.log(` claimed: ${l.simId} [${c}s]${d}`),a&&console.log(` took over from: ${a}`)}catch(s){if(s instanceof ue){let i=Math.max(0,Math.round(s.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${s.lock.by} for ${i}s more`),console.error(" use --force to take it, or `sootsim open --new` for a fresh sim"),process.exit(1)}console.error(` claim failed: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}}finally{r.close()}}async function It(e,t,o,n){if(n.length===0)return{closed:[],remaining:[]};await Promise.all(n.map(s=>e.closeSim(s).catch(()=>{})));let r=new Set(n);for(let s=0;s<40;s++){let i=[];try{let a=y(t,{commandTimeoutMs:o});try{i=(await a.listSims()).filter(c=>r.has(c.id)&&c.readyState==="open").map(c=>c.id)}finally{a.close()}}catch{i=[]}if(i.length===0)return{closed:[...r],remaining:[]};if(s===39)return{closed:[...r].filter(a=>!i.includes(a)),remaining:i};await v(250)}return{closed:[...r],remaining:[]}}function xt(e,t){let o=e.filter(m=>m.readyState==="open"),n=o.map(m=>m.id),r=t.explicitKeepId?.trim()||"",s=t.savedKeepId?.trim()||"",i=s?o.some(m=>m.id===s):!1,a=s&&!i?s:null,l=null,c=null,d=null;if(t.closeOthers)if(r){let m=o.find(h=>h.id===r);m?l=m.id:c=r}else if(s&&i)l=s;else{let m=o.find(h=>h.isPrimary)??o[0]??null;m&&(l=m.id,s&&!i&&(d=m.id))}return{openIds:n,keepId:l,targets:c?[]:n.filter(m=>m!==l),staleSavedId:a,missingExplicitKeepId:c,fallbackKeepId:d}}async function ao(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--all","--others"]}),n=x(o),r=o.simId?` --sim ${o.simId}`:"",s=e.includes("--all"),i=e.includes("--others");if(s||i){try{let a=await n.listSims(),l=C(),c=o.positional[0]||(o.simIdSource==="flag"?o.simId:void 0),d=xt(a,{closeOthers:i,explicitKeepId:c,savedKeepId:l});if(d.staleSavedId&&M(),d.fallbackKeepId&&(b(d.fallbackKeepId),console.log(` saved sim ${d.staleSavedId} is gone \u2014 keeping primary ${d.fallbackKeepId}`)),d.missingExplicitKeepId&&(console.error(` close failed: keep sim ${d.missingExplicitKeepId} is not connected; not closing other sims`),process.exit(1)),d.targets.length===0){console.log(d.keepId?` nothing to close \u2014 only the kept sim ${d.keepId} is connected`:d.staleSavedId?` nothing to close \u2014 no sims connected (cleared stale current sim ${d.staleSavedId})`:" nothing to close \u2014 no sims connected");return}let m=await It(n,o.wsPort,o.commandTimeoutMs,d.targets);await X(a,d.targets);let h=C();h&&m.closed.includes(h)&&(d.keepId?b(d.keepId):M());let j=` closed ${m.closed.length} sim(s)${d.keepId?` (kept ${d.keepId})`:""}`;console.log(j),m.remaining.length>0&&(console.error(` close failed: still connected: ${m.remaining.join(", ")}`),process.exit(1))}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}finally{n.close()}return}try{try{let a=await n.listSims(),l=H(a,o.positional[0]||o.simId),c=a.find(m=>m.id!==l.id&&m.readyState==="open");await n.closeSim(l.id),await bt(o.wsPort,o.commandTimeoutMs,l.id)||(await X(a,[l.id]),console.error(` close failed: ${l.id} is still connected`),process.exit(1)),await X(a,[l.id]),C()===l.id&&(c?b(c.id):M()),console.log(` closed: ${l.id}`)}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),await D(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}export{Rt as a,ze as b,Et as c,Qe as d,to as e,De as f,N as g,mt as h,pt as i,ht as j,Y as k,wt as l,yt as m,St as n,X as o,oo as p,no as q,ro as r,so as s,io as t,It as u,xt as v,ao as w};
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as R}from"./chunk-DZPNBMAP.js";import{n as D}from"./chunk-EGBFMW45.js";import{a as T}from"./chunk-2N5FR2CU.js";function Y(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function I(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return Y(r)?r:null}catch{return null}}import{randomBytes as G,createHash as q}from"node:crypto";import m from"node:fs";import h from"node:path";var N=null;function _(){if(N)return N;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||D()}function y(){return _()}function U(){return h.join(_(),"attached-projects.json")}function $(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=m.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return $();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{m.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return $()}}function X(e){let t=U();m.mkdirSync(h.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=m.openSync(r,"w",384);try{m.writeFileSync(n,JSON.stringify(e,null,2)),m.fsyncSync(n)}finally{m.closeSync(n)}m.renameSync(r,t)}function w(e){let t=S();return e(t),X(t),t}function B(e){return q("sha256").update(h.resolve(e)).digest("hex").slice(0,16)}function K(){return`s_${G(10).toString("hex")}`}function ge(e){let t=h.resolve(e.cwd),r=B(t),n;return w(o=>{let s=o.attachedProjects.find(c=>c.id===r);if(s){let c={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=c,n=c;return}let a=Date.now(),d={id:r,name:e.name??h.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:a,updatedAt:a};o.attachedProjects.push(d),n=d}),n}function F(e){return S().attachedProjects.find(t=>t.id===e)??null}function he(){return S().attachedProjects}var Q=336*60*60*1e3;function ye(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],a=o-Q,d=s.filter(c=>c.ts>=a);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Se(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function we(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function M(e){let t;return w(r=>{if(e.id){let a=r.agentSessions.find(d=>d.id===e.id);if(a){let d={...a,...e,lastSeenAt:Date.now()},c=r.agentSessions.indexOf(a);r.agentSessions[c]=d,t=d;return}}let n=r.attachedProjects.find(a=>a.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??K(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function C(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function v(e,t){w(r=>{let n=r.agentSessions.find(s=>s.id===e);if(!n)return;let o=r.agentSessions.indexOf(n);r.agentSessions[o]={...n,...t,id:n.id,projectId:n.projectId,createdAt:n.createdAt,lastSeenAt:Date.now()}})}async function ve(){if(S().attachedProjects.length>0)return;let{loadOptionalDemoApps:t}=await import("./optional-demo-registry-WSPMNQX5.js"),r=await t();r.length!==0&&w(n=>{for(let o of r){if(!m.existsSync(o.dir))continue;let s=h.resolve(o.dir),a=B(s);if(n.attachedProjects.some(c=>c.id===a))continue;let d=Date.now();n.attachedProjects.push({id:a,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as V,spawnSync as z}from"node:child_process";import{randomUUID as Z}from"node:crypto";import i,{constants as f}from"node:fs";import u from"node:path";import ee from"node:readline";function j(e){return u.join(y(),"sessions",e)}function W(e){return u.join(j(e),"prompt.in")}function J(e){return u.join(j(e),"events.out")}function te(e){return u.join(y(),"transcripts",`${e}.log`)}function O(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(j(t)))}function re(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ne();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("sootsim CLI not found. set SOOTSIM_BIN to the path of the sootsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ne(){try{let e=se();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli` (watch:cli:binary builds dist-bin/ instead).")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function se(){try{let r=T.resolve("sootsim/package.json");return u.dirname(r)}catch{}let e=oe();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name==="sootsim")return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function oe(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function ie(e,t,r){let n=u.join(y(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,a=null;for(;a===null;)try{a=i.openSync(o,f.O_WRONLY|f.O_CREAT|f.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let c=Number(i.readFileSync(o,"utf8").trim());if(c&&!ce(c)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(c=>setTimeout(c,50))}try{return i.writeFileSync(a,String(process.pid)),await r()}finally{try{i.closeSync(a)}catch{}try{i.unlinkSync(o)}catch{}}}function ce(e){try{return process.kill(e,0),!0}catch{return!1}}function L(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=z("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Te(e){let t=F(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return ie(t.id,r,async()=>{let n=C(t.id).find(p=>p.provider===r&&p.status!=="ended"&&O(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`sootsim agent end <sessionId>\`.`);let o=r==="claude"?Z():void 0,s=M({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),a=W(s.id),d=J(s.id),c=te(s.id);L(a),L(d);let g=u.dirname(c);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:H}=re(),x=[...H,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",a,"--events-out",d,"--transcript",c];e.codexBin&&x.push("--codex-bin",e.codexBin),e.claudeBin&&x.push("--claude-bin",e.claudeBin),e.freshThread&&x.push("--fresh-thread"),o&&x.push("--claude-session-uuid",o);let P=V(A,x,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:y()}});P.unref();let E=e.readyTimeoutMs??6e3,b=await ae(d,p=>p.type==="ready"||p.type==="error",E);if(!b||b.type==="error"){if(P.pid)try{process.kill(P.pid,"SIGTERM")}catch{}try{i.rmSync(j(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=b&&b.type==="error"?b.message:`no ready event within ${E}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:P.pid,status:"idle"}),{session:k(s.id),wrapperPid:P.pid}})}async function De(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!O(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=W(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,f.O_WRONLY);try{let s=R(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as R}from"./chunk-J7FYMPIN.js";import{n as D}from"./chunk-V6OGDC6H.js";import{a as T}from"./chunk-M77N57QN.js";function Y(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function I(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return Y(r)?r:null}catch{return null}}import{randomBytes as G,createHash as q}from"node:crypto";import m from"node:fs";import h from"node:path";var N=null;function _(){if(N)return N;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||D()}function y(){return _()}function U(){return h.join(_(),"attached-projects.json")}function $(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=m.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return $();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{m.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return $()}}function X(e){let t=U();m.mkdirSync(h.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=m.openSync(r,"w",384);try{m.writeFileSync(n,JSON.stringify(e,null,2)),m.fsyncSync(n)}finally{m.closeSync(n)}m.renameSync(r,t)}function w(e){let t=S();return e(t),X(t),t}function B(e){return q("sha256").update(h.resolve(e)).digest("hex").slice(0,16)}function K(){return`s_${G(10).toString("hex")}`}function ge(e){let t=h.resolve(e.cwd),r=B(t),n;return w(o=>{let s=o.attachedProjects.find(c=>c.id===r);if(s){let c={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=c,n=c;return}let a=Date.now(),d={id:r,name:e.name??h.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:a,updatedAt:a};o.attachedProjects.push(d),n=d}),n}function F(e){return S().attachedProjects.find(t=>t.id===e)??null}function he(){return S().attachedProjects}var Q=336*60*60*1e3;function ye(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],a=o-Q,d=s.filter(c=>c.ts>=a);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Se(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function we(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function M(e){let t;return w(r=>{if(e.id){let a=r.agentSessions.find(d=>d.id===e.id);if(a){let d={...a,...e,lastSeenAt:Date.now()},c=r.agentSessions.indexOf(a);r.agentSessions[c]=d,t=d;return}}let n=r.attachedProjects.find(a=>a.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??K(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function C(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function v(e,t){w(r=>{let n=r.agentSessions.find(s=>s.id===e);if(!n)return;let o=r.agentSessions.indexOf(n);r.agentSessions[o]={...n,...t,id:n.id,projectId:n.projectId,createdAt:n.createdAt,lastSeenAt:Date.now()}})}async function ve(){if(S().attachedProjects.length>0)return;let{loadOptionalDemoApps:t}=await import("./optional-demo-registry-J65S4L7Y.js"),r=await t();r.length!==0&&w(n=>{for(let o of r){if(!m.existsSync(o.dir))continue;let s=h.resolve(o.dir),a=B(s);if(n.attachedProjects.some(c=>c.id===a))continue;let d=Date.now();n.attachedProjects.push({id:a,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as V,spawnSync as z}from"node:child_process";import{randomUUID as Z}from"node:crypto";import i,{constants as f}from"node:fs";import u from"node:path";import ee from"node:readline";function j(e){return u.join(y(),"sessions",e)}function W(e){return u.join(j(e),"prompt.in")}function J(e){return u.join(j(e),"events.out")}function te(e){return u.join(y(),"transcripts",`${e}.log`)}function O(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(j(t)))}function re(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ne();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("sootsim CLI not found. set SOOTSIM_BIN to the path of the sootsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ne(){try{let e=se();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli` (watch:cli:binary builds dist-bin/ instead).")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function se(){try{let r=T.resolve("sootsim/package.json");return u.dirname(r)}catch{}let e=oe();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name==="sootsim")return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function oe(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function ie(e,t,r){let n=u.join(y(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,a=null;for(;a===null;)try{a=i.openSync(o,f.O_WRONLY|f.O_CREAT|f.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let c=Number(i.readFileSync(o,"utf8").trim());if(c&&!ce(c)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(c=>setTimeout(c,50))}try{return i.writeFileSync(a,String(process.pid)),await r()}finally{try{i.closeSync(a)}catch{}try{i.unlinkSync(o)}catch{}}}function ce(e){try{return process.kill(e,0),!0}catch{return!1}}function L(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=z("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Te(e){let t=F(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return ie(t.id,r,async()=>{let n=C(t.id).find(p=>p.provider===r&&p.status!=="ended"&&O(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`sootsim agent end <sessionId>\`.`);let o=r==="claude"?Z():void 0,s=M({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),a=W(s.id),d=J(s.id),c=te(s.id);L(a),L(d);let g=u.dirname(c);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:H}=re(),x=[...H,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",a,"--events-out",d,"--transcript",c];e.codexBin&&x.push("--codex-bin",e.codexBin),e.claudeBin&&x.push("--claude-bin",e.claudeBin),e.freshThread&&x.push("--fresh-thread"),o&&x.push("--claude-session-uuid",o);let P=V(A,x,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:y()}});P.unref();let E=e.readyTimeoutMs??6e3,b=await ae(d,p=>p.type==="ready"||p.type==="error",E);if(!b||b.type==="error"){if(P.pid)try{process.kill(P.pid,"SIGTERM")}catch{}try{i.rmSync(j(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=b&&b.type==="error"?b.message:`no ready event within ${E}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:P.pid,status:"idle"}),{session:k(s.id),wrapperPid:P.pid}})}async function De(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!O(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=W(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,f.O_WRONLY);try{let s=R(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
3
3
  `)}finally{i.closeSync(o)}v(e,{lastPrompt:t.displayText??t.text,status:"working"})}async function Re(e){let t=k(e);if(!t)throw new l("NO_SESSION",`no session with id=${e}`);if(O(t.wrapperPid,e))try{process.kill(t.wrapperPid,"SIGTERM")}catch{}let r=j(e),n=y();if(r.startsWith(n))try{i.rmSync(r,{recursive:!0,force:!0})}catch{}v(e,{status:"ended",wrapperPid:void 0})}function Ne(e,t){let r=J(e);if(!i.existsSync(r))throw new l("NO_FIFO",`events FIFO missing: ${r}`);let n=i.openSync(r,f.O_RDWR),o=i.createReadStream("",{fd:n,autoClose:!0}),s=ee.createInterface({input:o,crlfDelay:1/0});s.on("line",d=>{let c=I(d);c&&t(c)});let a=!1;return()=>{if(!a){a=!0;try{s.close()}catch{}try{o.destroy()}catch{}}}}async function ae(e,t,r){let n=i.openSync(e,f.O_RDWR|f.O_NONBLOCK),o=Buffer.alloc(8192),s="",a=Date.now()+r;try{for(;Date.now()<a;){let d=0;try{d=i.readSync(n,o,0,o.length,null)}catch(c){if(c.code!=="EAGAIN")throw c;d=0}if(d>0){s+=o.subarray(0,d).toString("utf8");let c;for(;(c=s.indexOf(`
4
4
  `))>=0;){let g=s.slice(0,c);s=s.slice(c+1);let A=I(g);if(A&&t(A))return A}}else await new Promise(c=>setTimeout(c,30))}return null}finally{i.closeSync(n)}}export{I as a,y as b,ge as c,F as d,he as e,ye as f,Se as g,we as h,k as i,C as j,v as k,ve as l,j as m,W as n,J as o,te as p,O as q,re as r,l as s,Te as t,De as u,Re as v,Ne as w};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import{createHash as b}from"node:crypto";import g from"node:fs";import{createRequire as S}from"node:module";import u from"node:path";var y=/\.(ttf|otf|woff|woff2)$/i;function P(t,n,r){if(!t||typeof t!="object")return;let o=t.fonts;if(Array.isArray(o))for(let i of o)typeof i=="string"&&r.push(i);let e=t[n];if(!e||typeof e!="object")return;let s=e.fonts;if(Array.isArray(s))for(let i of s){if(typeof i=="string"){r.push(i);continue}if(!i||typeof i!="object")continue;let c=i.fontDefinitions;if(Array.isArray(c))for(let a of c){if(!a||typeof a!="object")continue;let p=a.path;typeof p=="string"&&r.push(p)}}}function m(t,n){if(!Array.isArray(t))return[];let r=[];for(let o of t){let e=Array.isArray(o)?o[0]:o;if(typeof e!="string"||!/(^|\/)expo-font$/.test(e))continue;let s=Array.isArray(o)?o[1]??{}:{};P(s,n,r)}return r}function C(t){return t.slice(t.lastIndexOf("/")+1).replace(y,"")}function h(t,n){let r=n.replace(/\/+$/,""),o=new Set,e=[];for(let s of t){let i=s.replace(/^\.\//,"").replace(/^\/+/,"");!i||o.has(i)||(o.add(i),y.test(i)&&e.push({family:C(i),url:`${r}/assets/${i}`}))}return e}var d=S(import.meta.url);function x(t){try{let n=new URL(t),r=n.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(r==="localhost"||r.endsWith(".localhost")||r==="0.0.0.0"||r==="::1"||/^127(?:\.\d{1,3}){3}$/.test(r))return n.origin}catch{}return null}var R=["app.config.js","app.config.ts","app.config.cjs","app.config.mjs","app.json"];function w(t){for(let n of R)try{if(g.statSync(u.join(t,n)).isFile())return!0}catch{}return!1}var j=new Set(["node_modules","artifacts","dist","build","out","coverage","tmp","public","ios","android","macos","windows","__fixtures__","__tests__","examples","example"]);function F(t,n){w(t)&&n.push(t);let r;try{r=g.readdirSync(t,{withFileTypes:!0})}catch{return}for(let o of r)o.isDirectory()&&(o.name.startsWith(".")||j.has(o.name)||F(u.join(t,o.name),n))}function _(t){try{return g.statSync(u.join(t,"package.json")).isFile()}catch{return!1}}function I(t){let n=x(t.bundleUrl);if(!n)return[];let r=t.repoDir||process.env.SOOT_REPO_DIR,o=r?u.resolve(r):process.cwd();if(!r&&!_(o))return[];let e=[];if(r)F(o,e),e.includes(o)||e.push(o);else{if(!w(o))return[];e.push(o)}if(e.length===0)return[];let s=(t.platform||process.env.SOOT_PLATFORM||"ios").toLowerCase(),i=null;try{let l=d.resolve("@expo/config",{paths:[...e,o]}),f=d(l);typeof f.getConfig=="function"&&(i=f.getConfig)}catch{}if(!i)return[];let c;for(let l of e)try{let f=i(l,{skipSDKVersionRequirement:!0});if(f?.exp&&typeof f.exp=="object"){let A=f.exp.plugins;if(Array.isArray(A)){c=f.exp;break}}}catch{}if(!c||typeof c!="object")return[];let a=c.plugins;if(!Array.isArray(a))return[];let p=m(a,s==="android"?"android":"ios");return h(p,n)}async function L(t,n){let r=x(t);if(!r)return null;let o=new AbortController,e=setTimeout(()=>o.abort(),n?.timeoutMs??1500);try{let s=await fetch(`${r}/`,{headers:{"expo-platform":"ios",Accept:"application/json"},signal:o.signal});if(!s.ok)return null;let c=(await s.json())?.extra?.expoClient?._internal?.projectRoot;return typeof c=="string"&&c.length>0?c:null}catch{return null}finally{clearTimeout(e)}}function M(t){return t.map(n=>`${encodeURIComponent(n.url)}::${encodeURIComponent(n.family)}`).join(",")}function k(t){let n=[];for(let r of t.split(",")){let o=r.trim();if(!o)continue;let e=o.indexOf("::"),s=e===-1?o:o.slice(0,e);try{n.push(decodeURIComponent(s))}catch{n.push(s)}}return n.filter(Boolean)}function D(t){let n=(t.split("?")[0].split(".").pop()||"").toLowerCase();return n==="ttf"?"font/ttf":n==="otf"?"font/otf":n==="woff"?"font/woff":n==="woff2"?"font/woff2":"application/octet-stream"}async function G(t,n){let r=[],o=new Set;for(let e of k(t)){let s=b("sha256").update(e).digest("hex");if(!o.has(s)){o.add(s);try{let i=await fetch(e);if(!i.ok){n?.onError?.(e,new Error(`${i.status} ${i.statusText}`));continue}let c=new Uint8Array(await i.arrayBuffer());r.push({url:e,urlhash:s,contentType:D(e),bytes:c}),n?.onStaged?.({url:e,byteLength:c.byteLength})}catch(i){n?.onError?.(e,i)}}}return r}export{I as a,L as b,M as c,G as d};
@@ -1,26 +1,36 @@
1
- /*! sootsim v0.1.165 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as P,b as S}from"./chunk-AA5UBYX7.js";import{d as v}from"./chunk-5IIMWTMI.js";import{a as j}from"./chunk-EV5NG4AO.js";import{execSync as A}from"child_process";import{existsSync as k,readFileSync as E,writeFileSync as b}from"fs";import{relative as B,resolve as g}from"path";import{existsSync as p,readFileSync as h,readdirSync as O,statSync as L}from"fs";import{basename as R,dirname as T,join as a}from"path";function D(e){let o=e;for(;;){if(p(a(o,"turbo.json"))||p(a(o,"nx.json"))||p(a(o,"lerna.json"))||p(a(o,"pnpm-workspace.yaml")))return o;let i=a(o,"package.json");if(p(i))try{if(JSON.parse(h(i,"utf8")).workspaces)return o}catch{}let r=T(o);if(r===o)break;o=r}return e}function W(e){return p(a(e,"bun.lock"))||p(a(e,"bun.lockb"))?"bun":p(a(e,"pnpm-lock.yaml"))?"pnpm":p(a(e,"yarn.lock"))?"yarn":"npm"}function J(e){if(p(a(e,"turbo.json")))return"turbo";if(p(a(e,"nx.json")))return"nx";if(p(a(e,"pnpm-workspace.yaml")))return"pnpm";let o=a(e,"package.json");if(p(o))try{if(JSON.parse(h(o,"utf8")).workspaces)return"npm-workspaces"}catch{}return"single"}function N(e){return e.one?"one":e.expo?"expo":e["react-native"]?"bare":"unknown"}function x(e){let o=a(e,"package.json");if(!p(o))return null;let i;try{i=JSON.parse(h(o,"utf8"))}catch{return null}let r={...i.dependencies,...i.devDependencies},s=N(r);return s==="unknown"?null:{dir:e,name:i.name||R(e),framework:s,hasViteConfig:p(a(e,"vite.config.ts"))||p(a(e,"vite.config.js")),hasMetroConfig:p(a(e,"metro.config.js"))||p(a(e,"metro.config.ts")),hasSootsimDependency:!!r.sootsim,devCommand:i.scripts?.dev||null}}function V(e){let o=[],i=a(e,"pnpm-workspace.yaml");if(p(i)){let t=h(i,"utf8").match(/packages:\s*\n((?:\s+-\s+.+\n?)+)/);if(t){let c=t[1].split(`
3
- `).filter(Boolean);for(let n of c){let m=n.replace(/^\s*-\s*['"]?/,"").replace(/['"]?\s*$/,"");m&&o.push(...$(e,m))}}return o}let r=a(e,"package.json");if(p(r))try{let s=JSON.parse(h(r,"utf8")),t=Array.isArray(s.workspaces)?s.workspaces:s.workspaces?.packages||[];for(let c of t)o.push(...$(e,c))}catch{}return o}function $(e,o){let i=o.replace(/\/\*\*?$/,"").replace(/\*$/,""),r=a(e,i);if(!p(r))return[];try{return O(r).map(t=>a(r,t)).filter(t=>{try{return L(t).isDirectory()&&p(a(t,"package.json"))}catch{return!1}})}catch{return[]}}function M(e){let o=J(e),i=W(e);if(o==="single"){let c=x(e);return{root:e,type:o,packageManager:i,apps:c?[c]:[]}}let r=V(e),s=[],t=x(e);t&&s.push(t);for(let c of r){if(c===e)continue;let n=x(c);n&&s.push(n)}return{root:e,type:o,packageManager:i,apps:s}}function C(e){switch(e){case"bun":return"bun add -d sootsim";case"pnpm":return"pnpm add -D sootsim";case"yarn":return"yarn add -D sootsim";case"npm":return"npm install -D sootsim"}}async function ce(e){(e.includes("--help")||e.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.166 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as P,b as S}from"./chunk-VKAJ6AJC.js";import{d as j}from"./chunk-F4FR47MS.js";import{a as v}from"./chunk-USUANHKD.js";import{execSync as A}from"child_process";import{existsSync as k,readFileSync as E,writeFileSync as b}from"fs";import{relative as B,resolve as g}from"path";import{existsSync as p,readFileSync as h,readdirSync as O,statSync as L}from"fs";import{basename as R,dirname as T,join as a}from"path";function $(e){let o=e;for(;;){if(p(a(o,"turbo.json"))||p(a(o,"nx.json"))||p(a(o,"lerna.json"))||p(a(o,"pnpm-workspace.yaml")))return o;let i=a(o,"package.json");if(p(i))try{if(JSON.parse(h(i,"utf8")).workspaces)return o}catch{}let r=T(o);if(r===o)break;o=r}return e}function W(e){return p(a(e,"bun.lock"))||p(a(e,"bun.lockb"))?"bun":p(a(e,"pnpm-lock.yaml"))?"pnpm":p(a(e,"yarn.lock"))?"yarn":"npm"}function J(e){if(p(a(e,"turbo.json")))return"turbo";if(p(a(e,"nx.json")))return"nx";if(p(a(e,"pnpm-workspace.yaml")))return"pnpm";let o=a(e,"package.json");if(p(o))try{if(JSON.parse(h(o,"utf8")).workspaces)return"npm-workspaces"}catch{}return"single"}function N(e){return e.one?"one":e.expo?"expo":e["react-native"]?"bare":"unknown"}function x(e){let o=a(e,"package.json");if(!p(o))return null;let i;try{i=JSON.parse(h(o,"utf8"))}catch{return null}let r={...i.dependencies,...i.devDependencies},s=N(r);return s==="unknown"?null:{dir:e,name:i.name||R(e),framework:s,hasViteConfig:p(a(e,"vite.config.ts"))||p(a(e,"vite.config.js")),hasMetroConfig:p(a(e,"metro.config.js"))||p(a(e,"metro.config.ts")),hasSootsimDependency:!!r.sootsim,devCommand:i.scripts?.dev||null}}function V(e){let o=[],i=a(e,"pnpm-workspace.yaml");if(p(i)){let t=h(i,"utf8").match(/packages:\s*\n((?:\s+-\s+.+\n?)+)/);if(t){let c=t[1].split(`
3
+ `).filter(Boolean);for(let n of c){let u=n.replace(/^\s*-\s*['"]?/,"").replace(/['"]?\s*$/,"");u&&o.push(...M(e,u))}}return o}let r=a(e,"package.json");if(p(r))try{let s=JSON.parse(h(r,"utf8")),t=Array.isArray(s.workspaces)?s.workspaces:s.workspaces?.packages||[];for(let c of t)o.push(...M(e,c))}catch{}return o}function M(e,o){let i=o.replace(/\/\*\*?$/,"").replace(/\*$/,""),r=a(e,i);if(!p(r))return[];try{return O(r).map(t=>a(r,t)).filter(t=>{try{return L(t).isDirectory()&&p(a(t,"package.json"))}catch{return!1}})}catch{return[]}}function D(e){let o=J(e),i=W(e);if(o==="single"){let c=x(e);return{root:e,type:o,packageManager:i,apps:c?[c]:[]}}let r=V(e),s=[],t=x(e);t&&s.push(t);for(let c of r){if(c===e)continue;let n=x(c);n&&s.push(n)}return{root:e,type:o,packageManager:i,apps:s}}function C(e){switch(e){case"bun":return"bun add -d sootsim";case"pnpm":return"pnpm add -D sootsim";case"yarn":return"yarn add -D sootsim";case"npm":return"npm install -D sootsim"}}async function ce(e){(e.includes("--help")||e.includes("-h"))&&(console.log(`
4
4
  sootsim setup-repo \u2014 set up sootsim in your project
5
+ (alias: sootsim init)
5
6
 
6
7
  detects your bundler (one, expo, metro), adds sootsim as a
7
8
  dependency, configures the bundler plugin, and adds dev scripts.
8
9
 
9
10
  usage:
10
11
  sootsim setup-repo interactive setup (current directory)
12
+ sootsim init same thing (alias)
11
13
  sootsim setup-repo --app <dir> set up the project at <dir> (default: cwd)
12
14
  sootsim setup-repo --yes skip confirmations
13
15
  sootsim setup-repo --dry-run show what would be done
14
16
 
15
17
  works with monorepos (turbo, pnpm, nx) \u2014 scans for app packages.
16
- `),process.exit(0));let o=e.includes("--yes")||e.includes("-y"),i=e.includes("--dry-run"),r=e.indexOf("--app"),s=r!==-1&&e[r+1]?g(e[r+1]):process.cwd();k(s)||(console.error(` directory not found: ${s}`),process.exit(1));let t=D(s),c=M(t);if(console.log(`
18
+ `),process.exit(0));let o=e.includes("--yes")||e.includes("-y"),i=e.includes("--dry-run"),r=e.indexOf("--app"),s=r!==-1&&e[r+1]?g(e[r+1]):process.cwd();k(s)||(console.error(` directory not found: ${s}`),process.exit(1));let t=$(s),c=D(t);if(console.log(`
17
19
  sootsim \u2014 project setup
18
- `),!i)try{await v()}catch(l){console.error(` bootstrap failed: ${l instanceof Error?l.message:String(l)}`),console.error(" continuing with project setup; rerun later if needed.")}c.apps.length===0&&(console.log(" no react native apps found in this project."),console.log(` sootsim works with one, expo, and react-native projects.
19
- `),process.exit(1));let n;if(c.type!=="single"&&c.apps.length>1){console.log(` monorepo detected (${c.type} + ${c.packageManager})
20
- `);let l=await S("which app?",c.apps.map(f=>`${(B(t,f.dir)||".").padEnd(30)} (${f.framework})`));n=c.apps[l]}else n=c.apps[0];let m=n.framework==="one"?"metro (via one)":n.framework==="expo"?"metro (via expo)":"metro";console.log(" detected:"),console.log(` framework: ${n.framework}`),console.log(` bundler: ${m}`),console.log(` package: ${n.name}`),console.log(` manager: ${c.packageManager}`),console.log();let u=[];if(!n.hasSootsimDependency){let l=C(c.packageManager);u.push({label:"add sootsim as devDependency",run:()=>{A(l,{cwd:n.dir,stdio:"pipe"})}})}n.framework==="one"&&n.hasViteConfig?u.push({label:"add sootsimPlugin() to vite.config.ts",run:()=>_(n.dir)}):(n.framework==="expo"||n.framework==="bare")&&n.hasMetroConfig?u.push({label:"add withSootsim() to metro.config.js",run:()=>G(n.dir)}):n.framework==="one"?u.push({label:"add sootsimPlugin() to vite.config.ts",run:()=>_(n.dir)}):u.push({label:"create metro.config.js with withSootsim()",run:()=>z(n.dir,n.framework)}),console.log(" will:"),u.forEach((l,f)=>console.log(` ${f+1}. ${l.label}`)),console.log(),i&&(console.log(` (dry run \u2014 no changes made)
20
+ `),!i)try{await j()}catch(l){console.error(` bootstrap failed: ${l instanceof Error?l.message:String(l)}`),console.error(" continuing with project setup; rerun later if needed.")}c.apps.length===0&&(console.log(` no react native app found here.
21
+
22
+ start one of:
23
+ bunx create-expo-app@latest my-app \u2192 expo (recommended)
24
+ bunx @react-native-community/cli init MyApp \u2192 bare react native
25
+ bunx create-one@latest my-app \u2192 one (web + native)
26
+
27
+ then:
28
+ cd my-app && sootsim open
29
+ `),process.exit(0));let n;if(c.type!=="single"&&c.apps.length>1){console.log(` monorepo detected (${c.type} + ${c.packageManager})
30
+ `);let l=await S("which app?",c.apps.map(m=>`${(B(t,m.dir)||".").padEnd(30)} (${m.framework})`));n=c.apps[l]}else n=c.apps[0];let u=n.framework==="one"?"metro (via one)":n.framework==="expo"?"metro (via expo)":"metro";console.log(" detected:"),console.log(` framework: ${n.framework}`),console.log(` bundler: ${u}`),console.log(` package: ${n.name}`),console.log(` manager: ${c.packageManager}`),console.log();let f=[];if(!n.hasSootsimDependency){let l=C(c.packageManager);f.push({label:"add sootsim as devDependency",run:()=>{A(l,{cwd:n.dir,stdio:"pipe"})}})}n.framework==="one"&&n.hasViteConfig?f.push({label:"add sootsimPlugin() to vite.config.ts",run:()=>_(n.dir)}):(n.framework==="expo"||n.framework==="bare")&&n.hasMetroConfig?f.push({label:"add withSootsim() to metro.config.js",run:()=>G(n.dir)}):n.framework==="one"?f.push({label:"add sootsimPlugin() to vite.config.ts",run:()=>_(n.dir)}):f.push({label:"create metro.config.js with withSootsim()",run:()=>z(n.dir,n.framework)}),console.log(" will:"),f.forEach((l,m)=>console.log(` ${m+1}. ${l.label}`)),console.log(),i&&(console.log(` (dry run \u2014 no changes made)
21
31
  `),process.exit(0)),o||(await P("continue?")||(console.log(`
22
32
  cancelled.
23
- `),process.exit(0)),console.log());let d=0;for(let l=0;l<u.length;l++){let f=u[l];process.stdout.write(` [${l+1}/${u.length}] ${f.label}...`);try{f.run(),console.log(" done")}catch(y){d++,console.log(` failed: ${y.message}`),(f.label.includes("vite.config")||f.label.includes("metro.config"))&&H(n)}}j({event:"cli_setup_repo",properties:{framework:n.framework,package_manager:c.packageManager,workspace_type:c.type,step_count:u.length,step_failures:d}});let w=n.framework==="expo"?"npx expo start":n.framework==="one"?`${c.packageManager} run dev`:"npx react-native start";console.log(`
33
+ `),process.exit(0)),console.log());let d=0;for(let l=0;l<f.length;l++){let m=f[l];process.stdout.write(` [${l+1}/${f.length}] ${m.label}...`);try{m.run(),console.log(" done")}catch(y){d++,console.log(` failed: ${y.message}`),(m.label.includes("vite.config")||m.label.includes("metro.config"))&&H(n)}}v({event:"cli_setup_repo",properties:{framework:n.framework,package_manager:c.packageManager,workspace_type:c.type,step_count:f.length,step_failures:d}});let w=n.framework==="expo"?"npx expo start":n.framework==="one"?`${c.packageManager} run dev`:"npx react-native start";console.log(`
24
34
  done! start your dev server:
25
35
 
26
36
  ${w}
@@ -32,13 +42,13 @@ works with monorepos (turbo, pnpm, nx) \u2014 scans for app packages.
32
42
  or attach a sim straight from the CLI:
33
43
 
34
44
  sootsim open <dev server port>
35
- `)}function _(e){let o=g(e,"vite.config.ts")||g(e,"vite.config.js"),i=g(e,"vite.config.ts"),r=g(e,"vite.config.js"),s=k(i)?i:r;if(!k(s))throw new Error(`no vite config found at ${e}`);let t=E(s,"utf8");if(t.includes("sootsimPlugin")){console.log(" (already configured)");return}let c="import { sootsimPlugin } from 'sootsim/vite'",n=/^(import\s+.+)$/gm,m=0,u;for(;(u=n.exec(t))!==null;)m=u.index+u[0].length;m>0?t=t.slice(0,m)+`
36
- `+c+t.slice(m):t=c+`
37
- `+t;let d=t.match(/plugins\s*:\s*\[/);if(d&&d.index!==void 0){let w=d.index+d[0].length,l=1,f=w;for(;f<t.length&&l>0;)t[f]==="["&&l++,t[f]==="]"&&l--,l>0&&f++;let y=t.slice(0,f),I=t.slice(f),q=t.slice(w).match(/\n(\s+)\S/)?.[1]||" ",F=t.slice(t.lastIndexOf(`
38
- `,f),f+1).match(/\n(\s*)/)?.[1]||" ";t=y.trimEnd()+`
45
+ `)}function _(e){let o=g(e,"vite.config.ts")||g(e,"vite.config.js"),i=g(e,"vite.config.ts"),r=g(e,"vite.config.js"),s=k(i)?i:r;if(!k(s))throw new Error(`no vite config found at ${e}`);let t=E(s,"utf8");if(t.includes("sootsimPlugin")){console.log(" (already configured)");return}let c="import { sootsimPlugin } from 'sootsim/vite'",n=/^(import\s+.+)$/gm,u=0,f;for(;(f=n.exec(t))!==null;)u=f.index+f[0].length;u>0?t=t.slice(0,u)+`
46
+ `+c+t.slice(u):t=c+`
47
+ `+t;let d=t.match(/plugins\s*:\s*\[/);if(d&&d.index!==void 0){let w=d.index+d[0].length,l=1,m=w;for(;m<t.length&&l>0;)t[m]==="["&&l++,t[m]==="]"&&l--,l>0&&m++;let y=t.slice(0,m),I=t.slice(m),q=t.slice(w).match(/\n(\s+)\S/)?.[1]||" ",F=t.slice(t.lastIndexOf(`
48
+ `,m),m+1).match(/\n(\s*)/)?.[1]||" ";t=y.trimEnd()+`
39
49
  `+q+`sootsimPlugin(),
40
50
  `+F+I}else throw new Error("could not find plugins array in vite config");b(s,t)}function G(e){let o=g(e,"metro.config.js"),i=g(e,"metro.config.ts"),r=k(o)?o:i;if(!k(r))throw new Error(`no metro config found at ${e}`);let s=E(r,"utf8");if(s.includes("withSootsim")){console.log(" (already configured)");return}s="const { withSootsim } = require('sootsim/metro')"+`
41
- `+s,s=s.replace(/(module\.exports\s*=\s*)([^;]+)/,(c,n,m)=>`${n}withSootsim(${m.trim()})`),b(r,s)}function z(e,o){let i=g(e,"metro.config.js"),r;o==="expo"?r=`const { getDefaultConfig } = require('expo/metro-config')
51
+ `+s,s=s.replace(/(module\.exports\s*=\s*)([^;]+)/,(c,n,u)=>`${n}withSootsim(${u.trim()})`),b(r,s)}function z(e,o){let i=g(e,"metro.config.js"),r;o==="expo"?r=`const { getDefaultConfig } = require('expo/metro-config')
42
52
  const { withSootsim } = require('sootsim/metro')
43
53
 
44
54
  const config = getDefaultConfig(__dirname)