sootsim 0.1.40 → 0.1.41

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 (145) hide show
  1. package/README.md +15 -15
  2. package/dist-cli/bin.js +3 -3
  3. package/dist-cli/chunks/{agent-3F5PO4NL.js → agent-7BJ2ZP22.js} +2 -2
  4. package/dist-cli/chunks/{agent-wrapper-LVUUZRWL.js → agent-wrapper-OXBYRJVT.js} +2 -2
  5. package/dist-cli/chunks/{assert-4WMVS3WU.js → assert-NZTYFTTT.js} +2 -2
  6. package/dist-cli/chunks/auto-bootstrap-4KQT4TCR.js +2 -0
  7. package/dist-cli/chunks/beta-3S56PNSS.js +2 -0
  8. package/dist-cli/chunks/{chunk-DSTHAISO.js → chunk-2T6UOHPO.js} +1 -1
  9. package/dist-cli/chunks/chunk-334L67M2.js +2 -0
  10. package/dist-cli/chunks/{chunk-Y5CFIRLN.js → chunk-33R6QMNO.js} +1 -1
  11. package/dist-cli/chunks/{chunk-WPS3TIOB.js → chunk-4UA6P3T2.js} +1 -1
  12. package/dist-cli/chunks/{chunk-WQXG4I5N.js → chunk-5JOYGXCS.js} +2 -2
  13. package/dist-cli/chunks/{chunk-PNGBWMQH.js → chunk-6PLNIOJP.js} +2 -2
  14. package/dist-cli/chunks/{chunk-WZE6T3GT.js → chunk-7YZJHZ7X.js} +1 -1
  15. package/dist-cli/chunks/{chunk-QUULF2II.js → chunk-ANDSHXLU.js} +2 -2
  16. package/dist-cli/chunks/chunk-AOYBIMKL.js +4 -0
  17. package/dist-cli/chunks/chunk-ASSV2FFC.js +1 -0
  18. package/dist-cli/chunks/chunk-BR6QRN7U.js +11 -0
  19. package/dist-cli/chunks/{chunk-EOWN4ZFJ.js → chunk-C4AMFYK3.js} +2 -2
  20. package/dist-cli/chunks/{chunk-BZED27B2.js → chunk-ECIRRKKE.js} +2 -2
  21. package/dist-cli/chunks/{chunk-LCES5ZJI.js → chunk-FZB4W23Y.js} +2 -2
  22. package/dist-cli/chunks/{chunk-PKB6IEGM.js → chunk-G2QUPNHI.js} +2 -2
  23. package/dist-cli/chunks/{chunk-FNIL6BYS.js → chunk-GB3G5LVB.js} +1 -1
  24. package/dist-cli/chunks/{chunk-KGVH3YAG.js → chunk-GI7FXE7J.js} +2 -2
  25. package/dist-cli/chunks/{chunk-6XI4VHIL.js → chunk-GOFKXREQ.js} +2 -2
  26. package/dist-cli/chunks/{chunk-YJMXGTP4.js → chunk-HAVQS3PI.js} +1 -1
  27. package/dist-cli/chunks/{chunk-6X5NQJT7.js → chunk-HZVPHAJX.js} +20 -20
  28. package/dist-cli/chunks/{chunk-5IAIIX7B.js → chunk-I5Y4IECP.js} +3 -3
  29. package/dist-cli/chunks/{chunk-MLCBIX7O.js → chunk-IF33CQL4.js} +2 -2
  30. package/dist-cli/chunks/chunk-IP2MARRU.js +27 -0
  31. package/dist-cli/chunks/{chunk-YKEBL6GE.js → chunk-J3JJRXIP.js} +1 -1
  32. package/dist-cli/chunks/{chunk-OV5TY7M3.js → chunk-LMNB7NYI.js} +2 -2
  33. package/dist-cli/chunks/{chunk-CCZHRBXJ.js → chunk-LX6KS6TL.js} +1 -1
  34. package/dist-cli/chunks/{chunk-KVOMVYG6.js → chunk-MBGNDWGV.js} +2 -2
  35. package/dist-cli/chunks/{chunk-DEBXVPIE.js → chunk-N7DDNZTO.js} +1 -1
  36. package/dist-cli/chunks/chunk-NZ5O2OEL.js +56 -0
  37. package/dist-cli/chunks/{chunk-4L45Q3YX.js → chunk-OJFHAMXD.js} +2 -2
  38. package/dist-cli/chunks/{chunk-W2XRHDQQ.js → chunk-OPDPXAYA.js} +2 -2
  39. package/dist-cli/chunks/{chunk-U3JD6X75.js → chunk-OXTFYLZJ.js} +2 -2
  40. package/dist-cli/chunks/{chunk-TK2IPNHL.js → chunk-Q6DGMQ2V.js} +2 -2
  41. package/dist-cli/chunks/{chunk-553OZX4H.js → chunk-S3SQITOO.js} +2 -2
  42. package/dist-cli/chunks/{chunk-QMBYRPRK.js → chunk-SHHUVGL2.js} +1 -1
  43. package/dist-cli/chunks/{chunk-Y66CDFAT.js → chunk-SWHWVYZS.js} +1 -1
  44. package/dist-cli/chunks/{chunk-5GK4YX7O.js → chunk-TBIGAH3T.js} +1 -1
  45. package/dist-cli/chunks/chunk-UNJTJDZZ.js +62 -0
  46. package/dist-cli/chunks/chunk-WN6YFWS5.js +117 -0
  47. package/dist-cli/chunks/{chunk-Z3I2I4IO.js → chunk-WZDE344I.js} +3 -3
  48. package/dist-cli/chunks/{chunk-LXR5EI74.js → chunk-Y2YNXUBT.js} +2 -2
  49. package/dist-cli/chunks/chunk-YFX2XIR4.js +1 -0
  50. package/dist-cli/chunks/chunk-YKFRPIVC.js +1 -0
  51. package/dist-cli/chunks/chunk-ZPURE62G.js +1 -0
  52. package/dist-cli/chunks/{compat-NBFWHK5S.js → compat-BA6HDW3Q.js} +5 -5
  53. package/dist-cli/chunks/{config-JEDQ3NHA.js → config-QQ63IS5P.js} +2 -2
  54. package/dist-cli/chunks/control-GNJNC524.js +2 -0
  55. package/dist-cli/chunks/cpu-profile-3DDV2SYN.js +2 -0
  56. package/dist-cli/chunks/{daemon-HOL7J3BI.js → daemon-RYSVONEV.js} +2 -2
  57. package/dist-cli/chunks/{debug-LNVMIWD6.js → debug-YXE4XZLP.js} +3 -3
  58. package/dist-cli/chunks/demo-app-registry-3VFEW4NV.js +2 -0
  59. package/dist-cli/chunks/{detox-EEZPH3DZ.js → detox-2UI3EAXA.js} +2 -2
  60. package/dist-cli/chunks/{device-GVLYQI7X.js → device-UGDJBZKD.js} +2 -2
  61. package/dist-cli/chunks/diagnose-IRDRYKYZ.js +41 -0
  62. package/dist-cli/chunks/drivers-EAONIWG3.js +2 -0
  63. package/dist-cli/chunks/{electron-UDV6K3IH.js → electron-ZCYWIZAE.js} +3 -3
  64. package/dist-cli/chunks/flow-ECSMFTKS.js +2 -0
  65. package/dist-cli/chunks/{hints-46PJLATZ.js → hints-OWOBCWJH.js} +2 -2
  66. package/dist-cli/chunks/{home-paths-XD7AOYU7.js → home-paths-5QMCFTBP.js} +2 -2
  67. package/dist-cli/chunks/{inspect-EDIKZ6O2.js → inspect-K4VXPM5J.js} +94 -92
  68. package/dist-cli/chunks/install-YFE7C2NU.js +2 -0
  69. package/dist-cli/chunks/{install-desktop-CX6ATQTR.js → install-desktop-U3723T63.js} +3 -3
  70. package/dist-cli/chunks/{keys-CXQIYEVW.js → keys-IFVXJ7C2.js} +2 -2
  71. package/dist-cli/chunks/{launch-DCFRKVD3.js → launch-NDGFTRZ5.js} +3 -3
  72. package/dist-cli/chunks/{login-HCIZL5GT.js → login-KEU6RAV3.js} +4 -4
  73. package/dist-cli/chunks/{logout-7X2YHJY3.js → logout-KNFLP5OQ.js} +2 -2
  74. package/dist-cli/chunks/{maestro-TY622MIW.js → maestro-GBUBLS6L.js} +2 -2
  75. package/dist-cli/chunks/{preview-DYI6ESOK.js → preview-7OKMPPMN.js} +2 -2
  76. package/dist-cli/chunks/{profile-7SXJEJTG.js → profile-CHKDPGJF.js} +2 -2
  77. package/dist-cli/chunks/{react-VGSDY766.js → react-GYI5VITJ.js} +2 -2
  78. package/dist-cli/chunks/record-DQR2TEIF.js +45 -0
  79. package/dist-cli/chunks/runtime-XXNKSGFE.js +2 -0
  80. package/dist-cli/chunks/{runtime-delivery-PWLODFCY.js → runtime-delivery-JCAY2QVQ.js} +2 -2
  81. package/dist-cli/chunks/{screenshot-PTKY4UU4.js → screenshot-3T6MNPH7.js} +2 -2
  82. package/dist-cli/chunks/{screenshot-mode-HSV7VY4G.js → screenshot-mode-BUGXY7SQ.js} +2 -2
  83. package/dist-cli/chunks/{screenshots-VY7VAGSV.js → screenshots-EMTXGI2Q.js} +2 -2
  84. package/dist-cli/chunks/server-46H2M4TF.js +35 -0
  85. package/dist-cli/chunks/setup-repo-P4LCPAF6.js +2 -0
  86. package/dist-cli/chunks/{skills-KEPQLCMR.js → skills-2RP2CFPD.js} +2 -2
  87. package/dist-cli/chunks/{start-5CJTBNRM.js → start-QFREXALP.js} +4 -4
  88. package/dist-cli/chunks/store-GH77HGEB.js +2 -0
  89. package/dist-cli/chunks/telemetry-WC5J4TE5.js +2 -0
  90. package/dist-cli/chunks/{test-REKHGKFE.js → test-LI4PGGTE.js} +3 -3
  91. package/dist-cli/chunks/{three-mode-FZYHB4ZQ.js → three-mode-PKINB46T.js} +2 -2
  92. package/dist-cli/chunks/{timeline-CWZAY52K.js → timeline-5AREJDL5.js} +2 -2
  93. package/dist-cli/chunks/{upgrade-AIUJEF5F.js → upgrade-W2AGIOSC.js} +2 -2
  94. package/dist-cli/chunks/upload-RLS6KTG6.js +2 -0
  95. package/dist-cli/chunks/web-JM6WDSZQ.js +2 -0
  96. package/dist-cli/chunks/{what-happened-JSQQVQGE.js → what-happened-SVCASJKT.js} +2 -2
  97. package/dist-cli/chunks/whoami-5NJ6IPLT.js +2 -0
  98. package/dist-lib/agent-daemon-client.cjs +1 -1
  99. package/dist-lib/agent-events.cjs +1 -1
  100. package/dist-lib/agent-sessions.cjs +1 -1
  101. package/dist-lib/attached-projects.cjs +1 -1
  102. package/dist-lib/auth/shared-session.cjs +1 -1
  103. package/dist-lib/backend-origin.cjs +1 -1
  104. package/dist-lib/bridge-constants.cjs +1 -1
  105. package/dist-lib/cli-constants.cjs +1 -1
  106. package/dist-lib/config.cjs +1 -1
  107. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  108. package/dist-lib/home-paths.cjs +1 -1
  109. package/dist-lib/host/bridge-host.cjs +14 -8
  110. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  111. package/dist-lib/index.cjs +1 -1
  112. package/dist-lib/metro.cjs +1 -1
  113. package/dist-lib/profiles.cjs +1 -1
  114. package/dist-lib/render-mode.cjs +1 -1
  115. package/dist-lib/vite-base.cjs +14 -8
  116. package/dist-lib/vite.cjs +1 -1
  117. package/package.json +1 -1
  118. package/dist-cli/chunks/auto-bootstrap-Q4A3PTF5.js +0 -2
  119. package/dist-cli/chunks/beta-CLLKUB5X.js +0 -2
  120. package/dist-cli/chunks/chunk-4IAKB3C4.js +0 -117
  121. package/dist-cli/chunks/chunk-CAJ247SC.js +0 -2
  122. package/dist-cli/chunks/chunk-D2ZMP7G4.js +0 -61
  123. package/dist-cli/chunks/chunk-D4Z7MWQY.js +0 -11
  124. package/dist-cli/chunks/chunk-DHJIXXWG.js +0 -27
  125. package/dist-cli/chunks/chunk-DPZDTJVQ.js +0 -1
  126. package/dist-cli/chunks/chunk-FFR7EA4U.js +0 -1
  127. package/dist-cli/chunks/chunk-I7KXFJDK.js +0 -1
  128. package/dist-cli/chunks/chunk-J6BPROH4.js +0 -4
  129. package/dist-cli/chunks/chunk-S4PJMUC7.js +0 -2
  130. package/dist-cli/chunks/chunk-XWXFUFB2.js +0 -1
  131. package/dist-cli/chunks/control-IMWZVYC3.js +0 -2
  132. package/dist-cli/chunks/cpu-profile-MQPUSRHG.js +0 -22
  133. package/dist-cli/chunks/demo-app-registry-4RFMJ4FM.js +0 -2
  134. package/dist-cli/chunks/diagnose-JQ7DPTSL.js +0 -41
  135. package/dist-cli/chunks/drivers-JUW6JBWH.js +0 -2
  136. package/dist-cli/chunks/flow-JOW23WNH.js +0 -2
  137. package/dist-cli/chunks/install-CCC3IF5S.js +0 -2
  138. package/dist-cli/chunks/record-7JX2SMVP.js +0 -37
  139. package/dist-cli/chunks/runtime-FTOQD7QK.js +0 -2
  140. package/dist-cli/chunks/server-EDB3EK4K.js +0 -35
  141. package/dist-cli/chunks/setup-repo-S2GFZR7F.js +0 -2
  142. package/dist-cli/chunks/store-SCRULNVS.js +0 -2
  143. package/dist-cli/chunks/telemetry-RC3OT67I.js +0 -2
  144. package/dist-cli/chunks/upload-UDA5ITTE.js +0 -2
  145. package/dist-cli/chunks/whoami-5WUUPIRN.js +0 -2
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as o}from"./chunk-UNJTJDZZ.js";import"./chunk-AOYBIMKL.js";import"./chunk-WZDE344I.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";async function t(n){console.error(" note: `sootsim install` is now `sootsim setup-repo`. forwarding\u2026\n"),await o(n)}export{t as runInstall};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as b}from"./chunk-J6BPROH4.js";import{a as x}from"./chunk-WZE6T3GT.js";import"./chunk-DEBXVPIE.js";import{spawn as k,spawnSync as u}from"child_process";import{chmodSync as S,createWriteStream as E,existsSync as w,mkdirSync as y,renameSync as T,rmSync as g,statSync as P}from"fs";import{tmpdir as D}from"os";import{dirname as M,join as f,resolve as v}from"path";var h="https://sootbean.com/api/electron-release";function A(){let r=process.arch;if(process.platform==="darwin"){let o=r==="arm64"?"mac-arm64":"mac-x64",n=`sootsim-latest-${o}.dmg`;return{platform:o,filename:n,url:`${h}/${n}`,install:_}}if(process.platform==="linux"){let o="sootsim-latest-linux-x64.AppImage";return{platform:"linux-x64",filename:o,url:`${h}/${o}`,install:L}}if(process.platform==="win32"){let o="sootsim-latest-win-x64.exe";return{platform:"win-x64",filename:o,url:`${h}/${o}`,install:C}}return null}async function O({url:r,dest:o,onProgress:n}){let s=await fetch(r,{redirect:"follow"});if(!s.ok)throw new Error(`download failed: ${s.status} ${s.statusText} (${r})`);let t=s.headers.get("content-length"),a=t?Number(t):null;if(!s.body)throw new Error("download failed: empty response body");y(M(o),{recursive:!0});let i=E(o),d=s.body.getReader(),c=0;try{for(;;){let{done:l,value:p}=await d.read();if(l)break;i.write(Buffer.from(p)),c+=p.byteLength,n?.(c,a)}}finally{await new Promise((l,p)=>{i.end(e=>e?p(e):l())})}}function I(r,o){let n=(r/1048576).toFixed(1);if(!o)return` ${n} MB`;let s=Math.min(100,Math.round(r/o*100)),t=(o/(1024*1024)).toFixed(1),a=24,i=Math.round(s/100*a);return` ${"\u2588".repeat(i)+"\u2591".repeat(a-i)} ${s}% ${n} / ${t} MB`}async function _(r){let o=u("hdiutil",["attach","-nobrowse","-readonly",r],{encoding:"utf8"});if(o.status!==0)throw new Error(`hdiutil attach failed: ${o.stderr||o.stdout}`.trim());let n=o.stdout.trim().split(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as b}from"./chunk-AOYBIMKL.js";import{a as x}from"./chunk-7YZJHZ7X.js";import"./chunk-N7DDNZTO.js";import{spawn as k,spawnSync as u}from"child_process";import{chmodSync as S,createWriteStream as E,existsSync as w,mkdirSync as y,renameSync as T,rmSync as g,statSync as P}from"fs";import{tmpdir as D}from"os";import{dirname as M,join as f,resolve as v}from"path";var h="https://sootbean.com/api/electron-release";function A(){let r=process.arch;if(process.platform==="darwin"){let o=r==="arm64"?"mac-arm64":"mac-x64",n=`sootsim-latest-${o}.dmg`;return{platform:o,filename:n,url:`${h}/${n}`,install:_}}if(process.platform==="linux"){let o="sootsim-latest-linux-x64.AppImage";return{platform:"linux-x64",filename:o,url:`${h}/${o}`,install:L}}if(process.platform==="win32"){let o="sootsim-latest-win-x64.exe";return{platform:"win-x64",filename:o,url:`${h}/${o}`,install:C}}return null}async function O({url:r,dest:o,onProgress:n}){let s=await fetch(r,{redirect:"follow"});if(!s.ok)throw new Error(`download failed: ${s.status} ${s.statusText} (${r})`);let t=s.headers.get("content-length"),a=t?Number(t):null;if(!s.body)throw new Error("download failed: empty response body");y(M(o),{recursive:!0});let i=E(o),d=s.body.getReader(),c=0;try{for(;;){let{done:l,value:p}=await d.read();if(l)break;i.write(Buffer.from(p)),c+=p.byteLength,n?.(c,a)}}finally{await new Promise((l,p)=>{i.end(e=>e?p(e):l())})}}function I(r,o){let n=(r/1048576).toFixed(1);if(!o)return` ${n} MB`;let s=Math.min(100,Math.round(r/o*100)),t=(o/(1024*1024)).toFixed(1),a=24,i=Math.round(s/100*a);return` ${"\u2588".repeat(i)+"\u2591".repeat(a-i)} ${s}% ${n} / ${t} MB`}async function _(r){let o=u("hdiutil",["attach","-nobrowse","-readonly",r],{encoding:"utf8"});if(o.status!==0)throw new Error(`hdiutil attach failed: ${o.stderr||o.stdout}`.trim());let n=o.stdout.trim().split(`
3
3
  `),t=n[n.length-1].split(" ").pop()?.trim();if(!t||!w(t))throw new Error(`could not determine dmg mount point (output: ${o.stdout})`);let a=f(t,"sootsim.app");if(!w(a))throw u("hdiutil",["detach","-force",t]),new Error(`sootsim.app not found inside ${t}`);let i="/Applications",d=v(process.env.HOME||"","Applications"),c=i;try{let m=f(i,`.sootsim-write-probe-${process.pid}`);u("touch",[m]),w(m)?g(m,{force:!0}):c=d}catch{c=d}c===d&&y(c,{recursive:!0});let l=f(c,"sootsim.app");w(l)&&g(l,{recursive:!0,force:!0});let p=u("cp",["-R",a,l]),e=u("hdiutil",["detach","-force",t]);if(p.status!==0)throw new Error(`copy to ${l} failed: ${p.stderr?.toString()||""}`.trim());return e.status!==0&&console.warn(` warning: failed to unmount ${t} (${e.stderr?.toString().trim()||"unknown error"})`),u("xattr",["-dr","com.apple.quarantine",l]),l}async function L(r){let o=v(process.env.HOME||"","Applications");y(o,{recursive:!0});let n=f(o,"sootsim.AppImage");return w(n)&&g(n,{force:!0}),T(r,n),S(n,493),n}async function C(r){return await new Promise((o,n)=>{let s=k("cmd",["/c","start",'""',"/wait",r],{stdio:"inherit"});s.once("error",n),s.once("exit",t=>{t===0?o():n(new Error(`installer exited with code ${t}`))})}),r}async function Y(r){(r.includes("--help")||r.includes("-h"))&&(console.log(`
4
4
  sootsim install-desktop \u2014 download and install the optional desktop GUI
5
5
 
@@ -20,4 +20,4 @@ examples:
20
20
  `),process.exit(0));let o=r.includes("--yes")||r.includes("-y")||process.env.SOOTSIM_NO_PROMPT==="1"||process.env.CI==="1"||!process.stdin.isTTY,n=r.includes("--force"),s=x();if(s&&!n){console.log(` sootsim desktop already installed at: ${s.path}`),console.log(" pass --force to reinstall.");return}let t=A();if(t||(console.error(` no desktop build available for ${process.platform}/${process.arch}.`),console.error(" supported: darwin-arm64, darwin-x64, linux-x64, win32-x64"),process.exit(1)),console.log(` platform: ${t.platform}`),console.log(` download: ${t.url}`),console.log(),!o){if(!await b("download and install now?",!0)){console.log(" cancelled.");return}console.log()}let a=f(D(),`sootsim-install-${Date.now()}`),i=f(a,t.filename),d=0;process.stdout.write(` downloading ${t.filename}...
21
21
  `);try{await O({url:t.url,dest:i,onProgress:(e,m)=>{let $=Date.now();$-d<100&&e<(m??1/0)||(d=$,process.stdout.isTTY&&process.stdout.write(`\r\x1B[2K${I(e,m)}`))}})}catch(e){g(a,{recursive:!0,force:!0}),console.error(`
22
22
  download failed: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}process.stdout.isTTY&&process.stdout.write(`
23
- `);let c=P(i).size;console.log(` downloaded ${(c/(1024*1024)).toFixed(1)} MB`),console.log(),console.log(" installing...");let{trackCliEvent:l,flushCliTelemetry:p}=await import("./telemetry-RC3OT67I.js");try{let e=await t.install(i);l({event:"cli_install_desktop_succeeded",properties:{platform:t.platform,size_bytes:c}}),console.log(` installed: ${e}`)}catch(e){l({event:"cli_install_desktop_failed",properties:{platform:t.platform,error:e instanceof Error?e.message:String(e)}}),await p(),console.error(` install failed: ${e instanceof Error?e.message:String(e)}`),console.error(` keeping download at ${i} for manual install.`),process.exit(1)}finally{g(a,{recursive:!0,force:!0})}console.log(),console.log(" next steps:"),console.log(" sootsim electron launch the desktop app"),console.log(" sootsim open <target> open a demo or bundle in it")}export{Y as runInstallDesktop};
23
+ `);let c=P(i).size;console.log(` downloaded ${(c/(1024*1024)).toFixed(1)} MB`),console.log(),console.log(" installing...");let{trackCliEvent:l,flushCliTelemetry:p}=await import("./telemetry-WC5J4TE5.js");try{let e=await t.install(i);l({event:"cli_install_desktop_succeeded",properties:{platform:t.platform,size_bytes:c}}),console.log(` installed: ${e}`)}catch(e){l({event:"cli_install_desktop_failed",properties:{platform:t.platform,error:e instanceof Error?e.message:String(e)}}),await p(),console.error(` install failed: ${e instanceof Error?e.message:String(e)}`),console.error(` keeping download at ${i} for manual install.`),process.exit(1)}finally{g(a,{recursive:!0,force:!0})}console.log(),console.log(" next steps:"),console.log(" sootsim electron launch the desktop app"),console.log(" sootsim open <target> open a demo or bundle in it")}export{Y as runInstallDesktop};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as l,b as d,c as k,d as y,e as g}from"./chunk-QUULF2II.js";import{d as c}from"./chunk-553OZX4H.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";async function a(){let s=await c();return s?.token||(process.stderr.write(" sootsim keys ... needs you to be signed in.\n run `sootsim login` first.\n"),process.exit(1)),{origin:s.origin,token:s.token}}function f(s){if(!s)return"never";try{return new Date(s).toLocaleString()}catch{return s}}async function h(s){let i=s[0];if(!i||i==="--help"||i==="-h"){u();return}if(i==="list"){let{origin:o,token:e}=await a(),n=await fetch(`${o.replace(/\/$/,"")}/api/sootsim/billing/keys`,{headers:{authorization:`Bearer ${e}`}});n.ok||(console.error(` keys list failed (${n.status})`),process.exit(1));let{keys:r}=await n.json();if(r.length===0){console.log(" no keys. create one with `sootsim keys create <label>`.");return}for(let t of r)console.log(` ${t.keyPrefix}\u2026 ${t.label.padEnd(24)} scopes=${t.scopes.join(",")} last=${f(t.lastUsedAt)} id=${t.id}`);return}if(i==="create"){let o=s[1]?.trim();o||(console.error(" usage: sootsim keys create <label>"),process.exit(1));let{origin:e,token:n}=await a(),r=await fetch(`${e.replace(/\/$/,"")}/api/sootsim/billing/keys`,{method:"POST",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({label:o})});r.ok||(console.error(` keys create failed (${r.status}): ${await r.text()}`),process.exit(1));let t=await r.json();console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as l,b as d,c as k,d as y,e as g}from"./chunk-ANDSHXLU.js";import{d as c}from"./chunk-S3SQITOO.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";async function a(){let s=await c();return s?.token||(process.stderr.write(" sootsim keys ... needs you to be signed in.\n run `sootsim login` first.\n"),process.exit(1)),{origin:s.origin,token:s.token}}function f(s){if(!s)return"never";try{return new Date(s).toLocaleString()}catch{return s}}async function h(s){let i=s[0];if(!i||i==="--help"||i==="-h"){u();return}if(i==="list"){let{origin:o,token:e}=await a(),n=await fetch(`${o.replace(/\/$/,"")}/api/sootsim/billing/keys`,{headers:{authorization:`Bearer ${e}`}});n.ok||(console.error(` keys list failed (${n.status})`),process.exit(1));let{keys:r}=await n.json();if(r.length===0){console.log(" no keys. create one with `sootsim keys create <label>`.");return}for(let t of r)console.log(` ${t.keyPrefix}\u2026 ${t.label.padEnd(24)} scopes=${t.scopes.join(",")} last=${f(t.lastUsedAt)} id=${t.id}`);return}if(i==="create"){let o=s[1]?.trim();o||(console.error(" usage: sootsim keys create <label>"),process.exit(1));let{origin:e,token:n}=await a(),r=await fetch(`${e.replace(/\/$/,"")}/api/sootsim/billing/keys`,{method:"POST",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({label:o})});r.ok||(console.error(` keys create failed (${r.status}): ${await r.text()}`),process.exit(1));let t=await r.json();console.log(`
3
3
  created: ${t.record.label} (${t.record.keyPrefix}\u2026)`),console.log(` scopes: ${t.record.scopes.join(",")}`),console.log(`
4
4
  secret: ${t.secret}
5
5
  `),console.log(` copy this now \u2014 we can't show it again.
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-DPZDTJVQ.js";import{b as m}from"./chunk-CAJ247SC.js";import{a as u}from"./chunk-WZE6T3GT.js";import"./chunk-TK2IPNHL.js";import"./chunk-I7KXFJDK.js";import"./chunk-EOWN4ZFJ.js";import{D as c,E as r,F as l,y as s,z as a}from"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";import{spawn as p}from"child_process";import{existsSync as h}from"fs";async function I(n){if(n.includes("--help")||n.includes("-h")){console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-YFX2XIR4.js";import{b as m}from"./chunk-NZ5O2OEL.js";import{a as u}from"./chunk-7YZJHZ7X.js";import"./chunk-Q6DGMQ2V.js";import"./chunk-YKFRPIVC.js";import"./chunk-C4AMFYK3.js";import{D as c,E as r,F as l,y as s,z as a}from"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{spawn as p}from"child_process";import{existsSync as h}from"fs";async function I(n){if(n.includes("--help")||n.includes("-h")){console.log(`
3
3
  sootsim launch \u2014 one-shot: install runtime if needed, start daemon, open app
4
4
 
5
5
  usage:
@@ -13,4 +13,4 @@ options:
13
13
  examples:
14
14
  sootsim launch
15
15
  sootsim launch --version 1.2.3
16
- `);return}let e=n.includes("--no-runtime-install"),i=n.indexOf("--channel"),t=i>=0&&n[i+1]?n[i+1]:"stable",o=n.indexOf("--version"),f=o>=0&&n[o+1]?n[o+1]:void 0;s(),await v({skipAutoInstall:e,channel:t,explicitVersion:f}),await d(),await x()}async function v(n){let e=a(),i=c();if(e&&i)return;n.skipAutoInstall&&(console.error(" no sootsim runtime installed. run `sootsim runtime install` first, or drop --no-runtime-install."),process.exit(1)),console.log("sootsim: first run \u2014 installing runtime");let{runRuntime:t}=await import("./runtime-FTOQD7QK.js"),o=[];n.explicitVersion&&o.push(n.explicitVersion),n.channel!=="stable"&&o.push("--channel",n.channel),await t(["install",...o],{channel:n.channel})}async function d(){let n=r();if(l(n))return;console.log("sootsim: starting daemon");let e=w();p(e,["server","--quiet"],{detached:!0,stdio:"ignore",env:process.env}).unref();let t=Date.now()+8e3;for(;Date.now()<t;){let o=r();if(l(o))return;await g(150)}console.error(" daemon didn't become ready within 8s \u2014 check ~/.sootsim/ or run `sootsim server` in a terminal to see errors"),process.exit(1)}async function x(){u()||(console.error(" no sootsim desktop companion installed. run `sootsim install-desktop` to download electron + the shell."),process.exit(1));let e=await m.launch({});e.launched||(console.error(` ${e.message}`),process.exit(1)),console.log(` ${e.message}`)}function w(){let n=process.argv[1];return n&&h(n)?n:"sootsim"}function g(n){return new Promise(e=>setTimeout(e,n))}async function R(){s(),await d()}export{R as ensureDaemonRunning,I as runLaunch};
16
+ `);return}let e=n.includes("--no-runtime-install"),i=n.indexOf("--channel"),t=i>=0&&n[i+1]?n[i+1]:"stable",o=n.indexOf("--version"),f=o>=0&&n[o+1]?n[o+1]:void 0;s(),await v({skipAutoInstall:e,channel:t,explicitVersion:f}),await d(),await x()}async function v(n){let e=a(),i=c();if(e&&i)return;n.skipAutoInstall&&(console.error(" no sootsim runtime installed. run `sootsim runtime install` first, or drop --no-runtime-install."),process.exit(1)),console.log("sootsim: first run \u2014 installing runtime");let{runRuntime:t}=await import("./runtime-XXNKSGFE.js"),o=[];n.explicitVersion&&o.push(n.explicitVersion),n.channel!=="stable"&&o.push("--channel",n.channel),await t(["install",...o],{channel:n.channel})}async function d(){let n=r();if(l(n))return;console.log("sootsim: starting daemon");let e=w();p(e,["server","--quiet"],{detached:!0,stdio:"ignore",env:process.env}).unref();let t=Date.now()+8e3;for(;Date.now()<t;){let o=r();if(l(o))return;await g(150)}console.error(" daemon didn't become ready within 8s \u2014 check ~/.sootsim/ or run `sootsim server` in a terminal to see errors"),process.exit(1)}async function x(){u()||(console.error(" no sootsim desktop companion installed. run `sootsim install-desktop` to download electron + the shell."),process.exit(1));let e=await m.launch({});e.launched||(console.error(` ${e.message}`),process.exit(1)),console.log(` ${e.message}`)}function w(){let n=process.argv[1];return n&&h(n)?n:"sootsim"}function g(n){return new Promise(e=>setTimeout(e,n))}async function R(){s(),await d()}export{R as ensureDaemonRunning,I as runLaunch};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{b as f,d as m}from"./chunk-553OZX4H.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";import{exec as S}from"node:child_process";import{randomBytes as $}from"node:crypto";import _ from"node:http";var I=process.env.SOOTSIM_AUTH_ORIGIN||"https://sootbean.com",h="http://localhost:3000";async function x(t){if(t)return t;if(process.env.SOOTSIM_AUTH_ORIGIN)return process.env.SOOTSIM_AUTH_ORIGIN;if(process.env.SOOTSIM_UPLOAD_ORIGIN)return process.env.SOOTSIM_UPLOAD_ORIGIN;try{if((await fetch(`${h}/api/auth/me`)).ok)return h}catch{}return I}function R(){console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{b as f,d as m}from"./chunk-S3SQITOO.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{exec as S}from"node:child_process";import{randomBytes as $}from"node:crypto";import _ from"node:http";var I=process.env.SOOTSIM_AUTH_ORIGIN||"https://sootbean.com",h="http://localhost:3000";async function x(t){if(t)return t;if(process.env.SOOTSIM_AUTH_ORIGIN)return process.env.SOOTSIM_AUTH_ORIGIN;if(process.env.SOOTSIM_UPLOAD_ORIGIN)return process.env.SOOTSIM_UPLOAD_ORIGIN;try{if((await fetch(`${h}/api/auth/me`)).ok)return h}catch{}return I}function R(){console.log(`
3
3
  sootsim login \u2014 sign in so desktop uploads can attach to your account
4
4
 
5
5
  usage:
@@ -21,6 +21,6 @@ options:
21
21
  <p style="color:#ccc">${t}</p>
22
22
  </div>
23
23
  </body>
24
- </html>`}async function P(t){try{let o=await fetch(`${t.replace(/\/$/,"")}/api/dev-login`,{method:"POST"});if(o.status===403)return{ok:!1,error:"dev-login disabled (not in dev mode)"};if(!o.ok){let c=await o.text().catch(()=>"");return{ok:!1,error:`dev-login ${o.status}: ${c}`}}let e=await o.json();return e.token?{ok:!0,token:e.token,userId:e.user?.id,email:e.email}:{ok:!1,error:"dev-login response missing token"}}catch(o){return{ok:!1,error:o instanceof Error?o.message:"dev-login fetch failed"}}}function A(t){try{let o=new URL(t).hostname;return o==="localhost"||o==="127.0.0.1"||o.endsWith(".local")}catch{return!1}}async function G(t){(t.includes("--help")||t.includes("-h"))&&(R(),process.exit(0));let o=[...t],e=await x(T(o,"--origin"));if(A(e)){console.log(` detected local origin (${e}) \u2014 signing in as dev user`);let r=await P(e);if(r.ok){f({token:r.token,user:r.userId?{id:r.userId,email:r.email}:null,origin:e,source:"cli"});let s=await m(e),l=s?.user?.email||r.email||s?.user?.id||r.userId,{trackCliEvent:n,flushCliTelemetry:a}=await import("./telemetry-RC3OT67I.js");n({event:"cli_login_succeeded",identity:{userId:r.userId??s?.user?.id??null},properties:{origin:e,mode:"dev"}}),await a(),console.log(` signed in${l?` as ${l}`:""} (dev)`);return}console.log(` dev-login not available (${r.error}); falling back to browser`)}let c=$(16).toString("hex"),i=await new Promise(r=>{let s=_.createServer((l,n)=>{try{let a=new URL(l.url||"/","http://127.0.0.1"),w=a.searchParams.get("state"),k=a.searchParams.get("token"),b=a.searchParams.get("email")||void 0,O=a.searchParams.get("userId")||void 0,g=a.searchParams.get("error");if(n.setHeader("content-type","text/html; charset=utf-8"),g){n.end(u(`sign-in failed: ${g}`)),r({ok:!1,error:g}),s.close();return}if(w!==c){n.end(u("state mismatch. close this tab and retry `sootsim login`.")),r({ok:!1,error:"state mismatch"}),s.close();return}if(!k){n.end(u("missing token. close this tab and retry `sootsim login`.")),r({ok:!1,error:"missing token"}),s.close();return}n.end(u("sign-in complete. you can return to the terminal.")),r({ok:!0,token:k,email:b,userId:O}),s.close()}catch(a){n.statusCode=500,n.end(u("sign-in callback failed. retry `sootsim login`.")),r({ok:!1,error:a instanceof Error?a.message:"callback failed"}),s.close()}});s.listen(0,"127.0.0.1",()=>{let l=s.address();if(!l||typeof l=="string"){r({ok:!1,error:"failed to bind callback server"}),s.close();return}let n=new URL(`${e.replace(/\/$/,"")}/auth/sootsim-cli`);n.searchParams.set("state",c),n.searchParams.set("port",String(l.port)),n.searchParams.set("sootbean",e),console.log(" opening browser for sootsim login..."),console.log(` waiting for callback on 127.0.0.1:${l.port}`),console.log(` if nothing opens, visit:
24
+ </html>`}async function P(t){try{let o=await fetch(`${t.replace(/\/$/,"")}/api/dev-login`,{method:"POST"});if(o.status===403)return{ok:!1,error:"dev-login disabled (not in dev mode)"};if(!o.ok){let c=await o.text().catch(()=>"");return{ok:!1,error:`dev-login ${o.status}: ${c}`}}let e=await o.json();return e.token?{ok:!0,token:e.token,userId:e.user?.id,email:e.email}:{ok:!1,error:"dev-login response missing token"}}catch(o){return{ok:!1,error:o instanceof Error?o.message:"dev-login fetch failed"}}}function A(t){try{let o=new URL(t).hostname;return o==="localhost"||o==="127.0.0.1"||o.endsWith(".local")}catch{return!1}}async function G(t){(t.includes("--help")||t.includes("-h"))&&(R(),process.exit(0));let o=[...t],e=await x(T(o,"--origin"));if(A(e)){console.log(` detected local origin (${e}) \u2014 signing in as dev user`);let r=await P(e);if(r.ok){f({token:r.token,user:r.userId?{id:r.userId,email:r.email}:null,origin:e,source:"cli"});let s=await m(e),l=s?.user?.email||r.email||s?.user?.id||r.userId,{trackCliEvent:n,flushCliTelemetry:a}=await import("./telemetry-WC5J4TE5.js");n({event:"cli_login_succeeded",identity:{userId:r.userId??s?.user?.id??null},properties:{origin:e,mode:"dev"}}),await a(),console.log(` signed in${l?` as ${l}`:""} (dev)`);return}console.log(` dev-login not available (${r.error}); falling back to browser`)}let c=$(16).toString("hex"),i=await new Promise(r=>{let s=_.createServer((l,n)=>{try{let a=new URL(l.url||"/","http://127.0.0.1"),w=a.searchParams.get("state"),k=a.searchParams.get("token"),b=a.searchParams.get("email")||void 0,O=a.searchParams.get("userId")||void 0,g=a.searchParams.get("error");if(n.setHeader("content-type","text/html; charset=utf-8"),g){n.end(u(`sign-in failed: ${g}`)),r({ok:!1,error:g}),s.close();return}if(w!==c){n.end(u("state mismatch. close this tab and retry `sootsim login`.")),r({ok:!1,error:"state mismatch"}),s.close();return}if(!k){n.end(u("missing token. close this tab and retry `sootsim login`.")),r({ok:!1,error:"missing token"}),s.close();return}n.end(u("sign-in complete. you can return to the terminal.")),r({ok:!0,token:k,email:b,userId:O}),s.close()}catch(a){n.statusCode=500,n.end(u("sign-in callback failed. retry `sootsim login`.")),r({ok:!1,error:a instanceof Error?a.message:"callback failed"}),s.close()}});s.listen(0,"127.0.0.1",()=>{let l=s.address();if(!l||typeof l=="string"){r({ok:!1,error:"failed to bind callback server"}),s.close();return}let n=new URL(`${e.replace(/\/$/,"")}/auth/sootsim-cli`);n.searchParams.set("state",c),n.searchParams.set("port",String(l.port)),n.searchParams.set("sootbean",e),console.log(" opening browser for sootsim login..."),console.log(` waiting for callback on 127.0.0.1:${l.port}`),console.log(` if nothing opens, visit:
25
25
  ${n.toString()}
26
- `),L(n.toString())})});if(!i.ok){let{trackCliEvent:r,flushCliTelemetry:s}=await import("./telemetry-RC3OT67I.js");r({event:"cli_login_failed",properties:{origin:e,error:i.error}}),await s(),console.error(` login failed: ${i.error}`),process.exit(1)}f({token:i.token,user:i.userId?{id:i.userId,email:i.email}:null,origin:e,source:"cli"});let d=await m(e),p=d?.user?.email||i.email||d?.user?.id||i.userId,{trackCliEvent:y,flushCliTelemetry:v}=await import("./telemetry-RC3OT67I.js");y({event:"cli_login_succeeded",identity:{userId:i.userId??d?.user?.id??null},properties:{origin:e}}),await v(),console.log(` signed in${p?` as ${p}`:""}`)}export{G as runLogin};
26
+ `),L(n.toString())})});if(!i.ok){let{trackCliEvent:r,flushCliTelemetry:s}=await import("./telemetry-WC5J4TE5.js");r({event:"cli_login_failed",properties:{origin:e,error:i.error}}),await s(),console.error(` login failed: ${i.error}`),process.exit(1)}f({token:i.token,user:i.userId?{id:i.userId,email:i.email}:null,origin:e,source:"cli"});let d=await m(e),p=d?.user?.email||i.email||d?.user?.id||i.userId,{trackCliEvent:y,flushCliTelemetry:v}=await import("./telemetry-WC5J4TE5.js");y({event:"cli_login_succeeded",identity:{userId:i.userId??d?.user?.id??null},properties:{origin:e}}),await v(),console.log(` signed in${p?` as ${p}`:""}`)}export{G as runLogin};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as r,b as i}from"./chunk-W2XRHDQQ.js";import{a as t,c as o}from"./chunk-553OZX4H.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";async function s(){let e=t();if(!e?.token){console.log(" not signed in");return}try{await fetch(`${e.origin.replace(/\/$/,"")}/api/auth/sign-out`,{method:"POST",headers:{authorization:`Bearer ${e.token}`}})}catch{}o(),r({event:"cli_logout",identity:{userId:e.user?.id??null},properties:{origin:e.origin}}),await i(),console.log(" signed out")}export{s as runLogout};
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as r,b as i}from"./chunk-OPDPXAYA.js";import{a as t,c as o}from"./chunk-S3SQITOO.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";async function s(){let e=t();if(!e?.token){console.log(" not signed in");return}try{await fetch(`${e.origin.replace(/\/$/,"")}/api/auth/sign-out`,{method:"POST",headers:{authorization:`Bearer ${e.token}`}})}catch{}o(),r({event:"cli_logout",identity:{userId:e.user?.id??null},properties:{origin:e.origin}}),await i(),console.log(" signed out")}export{s as runLogout};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{c as h}from"./chunk-6X5NQJT7.js";import"./chunk-4L45Q3YX.js";import"./chunk-6XI4VHIL.js";import"./chunk-FFR7EA4U.js";import"./chunk-DHJIXXWG.js";import"./chunk-KGVH3YAG.js";import"./chunk-D4Z7MWQY.js";import"./chunk-CCZHRBXJ.js";import"./chunk-QMBYRPRK.js";import"./chunk-CAJ247SC.js";import"./chunk-WZE6T3GT.js";import"./chunk-TK2IPNHL.js";import"./chunk-LCES5ZJI.js";import"./chunk-LXR5EI74.js";import"./chunk-QUULF2II.js";import"./chunk-I7KXFJDK.js";import"./chunk-EOWN4ZFJ.js";import"./chunk-WQXG4I5N.js";import"./chunk-S4PJMUC7.js";import"./chunk-PKB6IEGM.js";import"./chunk-Y5CFIRLN.js";import"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-W2XRHDQQ.js";import"./chunk-553OZX4H.js";import"./chunk-XWXFUFB2.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";import*as i from"fs";import*as l from"path";var y=[".maestro","maestro"];function b(){console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{c as h}from"./chunk-HZVPHAJX.js";import"./chunk-OJFHAMXD.js";import"./chunk-GOFKXREQ.js";import"./chunk-ZPURE62G.js";import"./chunk-IP2MARRU.js";import"./chunk-GI7FXE7J.js";import"./chunk-BR6QRN7U.js";import"./chunk-LX6KS6TL.js";import"./chunk-SHHUVGL2.js";import"./chunk-NZ5O2OEL.js";import"./chunk-7YZJHZ7X.js";import"./chunk-Q6DGMQ2V.js";import"./chunk-FZB4W23Y.js";import"./chunk-Y2YNXUBT.js";import"./chunk-ANDSHXLU.js";import"./chunk-YKFRPIVC.js";import"./chunk-C4AMFYK3.js";import"./chunk-5JOYGXCS.js";import"./chunk-334L67M2.js";import"./chunk-G2QUPNHI.js";import"./chunk-33R6QMNO.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import*as i from"fs";import*as l from"path";var y=[".maestro","maestro"];function b(){console.log(`
3
3
  sootsim maestro \u2014 run maestro YAML flows against sootsim (drop-in)
4
4
 
5
5
  usage:
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-DEBXVPIE.js";import{resolve as c,dirname as m}from"path";import{fileURLToPath as a}from"url";var t=m(a(import.meta.resolve("sootsim-engine/package.json")));async function g(o,r){(o.includes("--help")||o.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-N7DDNZTO.js";import{resolve as c,dirname as m}from"path";import{fileURLToPath as a}from"url";var t=m(a(import.meta.resolve("sootsim-engine/package.json")));async function g(o,r){(o.includes("--help")||o.includes("-h"))&&(console.log(`
3
3
  sootsim preview \u2014 production-like preview
4
4
 
5
5
  usage:
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{b as s,c as i,d as t,e as n,f as c}from"./chunk-TK2IPNHL.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";function f(){console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{b as s,c as i,d as t,e as n,f as c}from"./chunk-Q6DGMQ2V.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";function f(){console.log(`
3
3
  sootsim profile \u2014 manage isolated storage profiles
4
4
 
5
5
  usage:
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{c as w,e as b,h as m,i as f}from"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-XWXFUFB2.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";function h(){console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{c as w,e as b,h as m,i as f}from"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";function h(){console.log(`
3
3
  sootsim react \u2014 inspect React component render cost in the tenant worker
4
4
 
5
5
  usage:
@@ -0,0 +1,45 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as P}from"./chunk-IP2MARRU.js";import"./chunk-Y2YNXUBT.js";import{d as D}from"./chunk-ANDSHXLU.js";import"./chunk-YKFRPIVC.js";import{d as C}from"./chunk-C4AMFYK3.js";import{c as R,e as h}from"./chunk-6PLNIOJP.js";import{b as W}from"./chunk-SWHWVYZS.js";import"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{existsSync as te,mkdirSync as O,readFileSync as re,rmSync as J,writeFileSync as U}from"fs";import{tmpdir as ne}from"os";import{dirname as T,extname as ie,join as se,resolve as _}from"path";var L=6e4;async function Se(e,o){if((e.includes("--help")||e.includes("-h"))&&(console.log(`
3
+ sootsim record \u2014 capture the running sim
4
+
5
+ usage:
6
+ sootsim record [options] one-shot capture (duration-bounded)
7
+ sootsim record start [options] begin stateful recording
8
+ sootsim record stop [--output <path>] finalize stateful recording
9
+
10
+ options:
11
+ --mode <kind> video | live | combined (default: video)
12
+ video \u2014 local webm/mp4 file
13
+ live \u2014 pointer events only, uploads /preview/<id>
14
+ combined \u2014 events + video, uploads /preview/<id>
15
+ --duration <sec> recording duration (default: 10, atomic mode only)
16
+ --fps <n> frame rate for video/gif (default: 30)
17
+ --format <fmt> webm | mp4 | gif | png (video mode; inferred from --output ext)
18
+ --output <path> output file (video/gif) or directory (png frames)
19
+ --frames <n> sample N png frames evenly across --duration
20
+ --max-width <px> downscale gif frames to this width
21
+ --no-shell exclude the simulated iOS chrome (status bar, keyboard,
22
+ toasts) \u2014 records the tenant surfaces only
23
+ --shell-only record only the shell chrome
24
+ --open open the preview URL in the browser after stop (live/combined)
25
+ --sim <sim> target a specific sim
26
+ --origin <url> billing/upload origin for live/combined (default: auto \u2014
27
+ probes a local :3000 stack, else https://sootbean.com;
28
+ also honors SOOTSIM_UPLOAD_ORIGIN)
29
+
30
+ examples:
31
+ sootsim record # webm, 10s, ./sootsim-<ts>.webm
32
+ sootsim record --format mp4 --duration 5
33
+ sootsim record --output demo.gif --duration 3
34
+ sootsim record --frames 10 --output ./frames/
35
+ sootsim record --mode combined --duration 8 --open
36
+ sootsim record start --format mp4 # start video; interact freely
37
+ sootsim record start --mode combined # start preview-share recording
38
+ sootsim record stop --output flow.mp4 # finalize video
39
+ sootsim record stop --open # finalize live/combined + open URL
40
+ `),process.exit(0)),e[0]==="start"){await le(e.slice(1),o);return}if(e[0]==="stop"){await pe(e.slice(1),o);return}if(e[0]==="cancel"){await me(e.slice(1),o);return}if(e[0]==="status"){ue();return}let t=R(e,{port:o.port,stripBooleanFlags:["--no-shell","--shell-only","--open"],stripValueFlags:["--mode","--duration","--fps","--format","--output","--frames","--max-width","--origin"]}),r=V(a(e,"--mode")),n=e.includes("--shell-only")?"shell":e.includes("--no-shell")?"tenant":void 0,c=a(e,"--format"),i=a(e,"--output"),s=Number(a(e,"--duration")??"10");(!Number.isFinite(s)||s<=0)&&(console.error(` invalid --duration "${a(e,"--duration")}" \u2014 expected a positive number of seconds`),process.exit(1));let u=Number(a(e,"--fps")??"30"),d=a(e,"--frames"),w=e.includes("--open"),$=a(e,"--max-width")?Number(a(e,"--max-width")):void 0,v=Math.max(100,Math.round(s*1e3)),Z=a(e,"--origin");if(r==="live"||r==="combined"){await P("record",{originOverride:Z});let l=h({...t,commandTimeoutMs:6e4});try{await G(l),await K(l),await H(l,r)||(console.error(` start failed: recording store refused to start (${r})`),process.exit(1)),console.log(` recording ${r} for ${s}s`),await new Promise(y=>setTimeout(y,v)),await Q(l);let k=await X(l);Y(k,w)}finally{l.close()}return}let I=d?Number(d):null,S=de(c,i,I),p=h({...t,commandTimeoutMs:6e4});try{if(await j(p),S==="png"){let b=I??10,f=_(process.cwd(),i??`./sootsim-frames-${B()}`);O(f,{recursive:!0}),console.log(` sampling ${b} frames over ${s}s \u2192 ${f}`);let g=await p.send({type:"evaluate",code:`window.__sootsimRecorder.startFrameCapture({ count: ${b}, durationMs: ${v} })`});(!g.ok||!g.requestId)&&(console.error(` frame capture start failed: ${g.error??"unknown error"}`),process.exit(1)),await new Promise(m=>setTimeout(m,v));let ee=Date.now()+Math.max(5e3,v),A=null;for(;;){let m=await p.send({type:"evaluate",code:`window.__sootsimRecorder.getFrameCaptureResult(${g.requestId})`});if(m||(console.error(" frame capture result missing"),process.exit(1)),m.done){m.ok||(console.error(` frame capture failed: ${m.error??"unknown error"}`),process.exit(1)),A=m.frames??[];break}Date.now()>=ee&&(console.error(" frame capture timed out"),process.exit(1)),await new Promise(E=>setTimeout(E,100))}A.forEach((m,E)=>{let oe=`${f}/frame-${String(E+1).padStart(3,"0")}.png`;U(oe,Buffer.from(m.data,"base64"))}),console.log(` saved ${A.length} frames`);return}if(S==="gif"){let b=I??Math.max(10,Math.round(s*u/3)),f=_(process.cwd(),i??`./sootsim-${B()}.gif`);O(T(f),{recursive:!0}),console.log(` encoding gif: ${b} frames over ${s}s \u2192 ${f}`);let g=await p.send({type:"evaluate",code:`window.__sootsimRecorder.captureGif({ frames: ${b}, durationMs: ${v}${$?`, maxWidth: ${$}`:""} })`});g||(console.error(" gif capture returned no frames"),process.exit(1)),U(f,Buffer.from(g.data,"base64")),console.log(` saved: ${f} (${z(g.size)})`);return}let l=_(process.cwd(),i??`./sootsim-${B()}.${S}`);O(T(l),{recursive:!0});let M={format:S,fps:u};n&&(M.layers=n);let k=await p.send({type:"evaluate",code:`window.__sootsimRecorder.start(${JSON.stringify(M)})`});k.ok||(console.error(` start failed: ${k.error??"unknown error"}`),process.exit(1)),console.log(` recording ${S} for ${s}s \u2192 ${l}`),await new Promise(b=>setTimeout(b,v));let y=await p.send({type:"evaluate",code:"window.__sootsimRecorder.stop()"});y.ok||(console.error(` stop failed: ${y.error??"unknown error"}`),process.exit(1)),y.size||(console.error(" recorder returned an empty blob \u2014 nothing written"),process.exit(1)),await q(p,l),console.log(` saved: ${l} (${z(y.size)})`)}finally{p.close()}}async function j(e){if(!await e.send({type:"evaluate",code:'typeof window.__sootsimRecorder !== "undefined"'}))throw new Error("window.__sootsimRecorder missing \u2014 is sootsim engine running in this sim?")}async function q(e,o){let t=[],r=0;for(;;){let n=await e.send({type:"evaluate",code:`window.__sootsimRecorder.getBlobBase64({ offset: ${r}, chunk: 2097152 })`});if(!n)throw new Error("no blob available on recorder");if(t.push(Buffer.from(n.data,"base64")),r=n.offset,n.done)break}U(o,Buffer.concat(t))}function a(e,o){let t=e.indexOf(o);if(!(t<0||t===e.length-1))return e[t+1]}function ae(e){if(!e)return;let o=ie(e).toLowerCase().replace(/^\./,"");if(o==="webm"||o==="mp4"||o==="gif")return o;if(o==="png")return"png"}function de(e,o,t){return e||(t!=null?"png":ae(o)??"webm")}function B(){return new Date().toISOString().replace(/[:T]/g,"-").replace(/\..+/,"")}function z(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}function V(e){if(!e)return"video";if(e==="video"||e==="live"||e==="combined")return e;console.error(` invalid --mode "${e}" \u2014 expected video | live | combined`),process.exit(1)}function N(){return se(ne(),`sootsim-recording-${W()}.json`)}function F(){let e=N();if(!te(e))return null;try{return{mode:"video",...JSON.parse(re(e,"utf8"))}}catch{return J(e,{force:!0}),null}}function ce(e){U(N(),JSON.stringify(e,null,2))}function x(){J(N(),{force:!0})}async function le(e,o){let t=F();t&&(console.error(` recording already in progress (started ${t.startedAt}, sim ${t.simId??"?"}). run \`sootsim record stop\` first, or \`sootsim record cancel\` to discard.`),process.exit(1));let r=R(e,{port:o.port,stripBooleanFlags:["--no-shell","--shell-only"],stripValueFlags:["--mode","--fps","--format","--max-width","--origin"]}),n=V(a(e,"--mode")),c=e.includes("--shell-only")?"shell":e.includes("--no-shell")?"tenant":void 0,i=a(e,"--format"),s=i==="mp4"?"mp4":"webm";i&&s!==i&&(console.error(` record start only supports webm or mp4 (got: ${i}). for gif/png use atomic mode: sootsim record --format ${i} --duration <s>`),process.exit(1));let u=Number(a(e,"--fps")??"30"),d=h({...r,commandTimeoutMs:15e3});try{if(n==="live"||n==="combined")await P("record",{originOverride:a(e,"--origin")}),await G(d),await K(d),await H(d,n)||(console.error(` start failed: recording store refused to start (${n})`),process.exit(1));else{await j(d);let w={format:s,fps:u};c&&(w.layers=c);let $=await d.send({type:"evaluate",code:`window.__sootsimRecorder.start(${JSON.stringify(w)})`});$.ok||(console.error(` start failed: ${$.error??"unknown error"}`),process.exit(1))}ce({simId:r.simId??null,mode:n,format:s,fps:u,layers:c,startedAt:new Date().toISOString()}),console.log(n==="video"?` recording ${s} @ ${u}fps${c?` (${c})`:""} \u2014 run \`sootsim record stop --output <path>\` when done`:` recording ${n} \u2014 run \`sootsim record stop\` when done (add --open to launch the preview URL)`)}finally{d.close()}}function ue(){let e=F();if(!e){console.log(" no recording in progress");return}e.mode==="video"?console.log(` recording ${e.mode} (${e.format} @ ${e.fps}fps) on sim ${e.simId??"?"} since ${e.startedAt}`):console.log(` recording ${e.mode} on sim ${e.simId??"?"} since ${e.startedAt}`)}async function me(e,o){let t=F();if(!t){console.log(" no recording in progress");return}let r=R(e,{port:o.port}),n=r.simId??t.simId??void 0,c=h({...r,simId:n,commandTimeoutMs:15e3});try{t.mode==="live"||t.mode==="combined"?await c.send({type:"evaluate",code:"void window.SootSim?.bridges?.cancelRecording?.()"}):await c.send({type:"evaluate",code:"window.__sootsimRecorder.stop()"})}catch{}finally{x(),c.close()}console.log(" recording cancelled")}async function pe(e,o){let t=F();t||(console.error(" no recording in progress. start one with `sootsim record start`."),process.exit(1));let r=R(e,{port:o.port,stripBooleanFlags:["--open"],stripValueFlags:["--output"]}),n=r.simId??t.simId??void 0,c=e.includes("--open"),i=h({...r,simId:n,commandTimeoutMs:6e4});try{if(t.mode==="live"||t.mode==="combined"){await Q(i);let w=await X(i);x(),Y(w,c);return}let s=a(e,"--output"),u=_(process.cwd(),s??`./sootsim-${B()}.${t.format}`);O(T(u),{recursive:!0});let d=await i.send({type:"evaluate",code:"window.__sootsimRecorder.stop()"});d.ok||(console.error(` stop failed: ${d.error??"unknown error"}`),x(),process.exit(1)),d.size||(console.error(" recorder returned an empty blob \u2014 nothing written"),x(),process.exit(1)),await q(i,u),x(),console.log(` saved: ${u} (${z(d.size)})`)}finally{i.close()}}async function G(e){if(!await e.send({type:"evaluate",code:'typeof window.SootSim?.bridges?.startRecording === "function" && typeof window.SootSim?.bridges?.stopRecording === "function"'}))throw new Error("SootSim.bridges.startRecording missing \u2014 is sootsim engine running in this sim?")}async function K(e){let o=D();if(!o)return;let t=o.kind==="api-key"?o.secret:o.token;if(!await e.send({type:"evaluate",code:`(() => {
41
+ const set = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.setSession
42
+ if (typeof set !== 'function') return false
43
+ set({ token: ${JSON.stringify(t)}, user: null })
44
+ return true
45
+ })()`}))throw new Error("SootSim.bridges.setSession missing \u2014 the running sootsim engine is too old to accept CLI-injected auth for preview recording. update sootsim.")}async function H(e,o){return await e.send({type:"evaluate",code:`window.SootSim.bridges.startRecording(${JSON.stringify(o)})`})===!0}async function Q(e){await e.send({type:"evaluate",code:"void window.SootSim.bridges.stopRecording()"})}async function X(e){let o=Date.now()+L;for(;Date.now()<o;){let t=await e.send({type:"evaluate",code:"(() => { const s = window.SootSim?.bridges?.getRecordingState?.(); return s ? { state: s.state, lastUpload: s.lastUpload, uploadError: s.uploadError } : null })()"});if(t&&t.state==="idle"){if(t.uploadError)return{uploadError:t.uploadError};if(t.lastUpload?.previewUrl)return{previewUrl:t.lastUpload.previewUrl}}await new Promise(r=>setTimeout(r,300))}return{uploadError:`upload did not settle within ${L/1e3}s`}}function Y(e,o){e.uploadError&&(console.error(` upload failed: ${e.uploadError}`),process.exit(1)),e.previewUrl||(console.error(" upload returned no preview URL"),process.exit(1)),console.log(` preview: ${e.previewUrl}`),o&&C(e.previewUrl)}export{ae as extToFormat,de as resolveFormat,Se as runRecord,a as valueOf};
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a}from"./chunk-I5Y4IECP.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-OXTFYLZJ.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";export{a as runRuntime};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-U3JD6X75.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";export{a as DEFAULT_RUNTIME_CDN_ORIGIN,b as RUNTIME_CDN_ORIGIN_ENV,c as RUNTIME_CHANNEL_ENV,l as checkRuntimeUpToDate,h as fetchRuntimeManifest,j as installRuntime,d as resolveRuntimeCdnOrigin,e as resolveRuntimeChannel,i as resolveRuntimeVersion,f as runtimeManifestUrl,g as runtimeTarballUrl,k as updateRuntimeToLatest};
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-OXTFYLZJ.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";export{a as DEFAULT_RUNTIME_CDN_ORIGIN,b as RUNTIME_CDN_ORIGIN_ENV,c as RUNTIME_CHANNEL_ENV,l as checkRuntimeUpToDate,h as fetchRuntimeManifest,j as installRuntime,d as resolveRuntimeCdnOrigin,e as resolveRuntimeChannel,i as resolveRuntimeVersion,f as runtimeManifestUrl,g as runtimeTarballUrl,k as updateRuntimeToLatest};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as v}from"./chunk-6XI4VHIL.js";import"./chunk-FFR7EA4U.js";import{a as x}from"./chunk-WPS3TIOB.js";import"./chunk-WQXG4I5N.js";import"./chunk-PKB6IEGM.js";import{f as m}from"./chunk-Y5CFIRLN.js";import{c as h,d as g,e as w,h as y}from"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-XWXFUFB2.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";import{mkdirSync as R,writeFileSync as S}from"fs";import{dirname as _,resolve as B}from"path";async function W(e,o){(e.includes("--help")||e.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as v}from"./chunk-GOFKXREQ.js";import"./chunk-ZPURE62G.js";import{a as x}from"./chunk-4UA6P3T2.js";import"./chunk-5JOYGXCS.js";import"./chunk-G2QUPNHI.js";import{f as m}from"./chunk-33R6QMNO.js";import{c as h,d as g,e as w,h as y}from"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{mkdirSync as R,writeFileSync as S}from"fs";import{dirname as _,resolve as B}from"path";async function W(e,o){(e.includes("--help")||e.includes("-h"))&&(console.log(`
3
3
  sootsim screenshot \u2014 capture the canvas as a PNG
4
4
 
5
5
  usage:
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as o}from"./chunk-BZED27B2.js";import"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-XWXFUFB2.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";async function n(e,s){(e.includes("--help")||e.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as o}from"./chunk-ECIRRKKE.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";async function n(e,s){(e.includes("--help")||e.includes("-h"))&&(console.log(`
3
3
  sootsim screenshot-mode \u2014 toggle the screenshot-mode chrome overlay
4
4
 
5
5
  usage:
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{c as Y}from"./chunk-6X5NQJT7.js";import"./chunk-4L45Q3YX.js";import{b as j}from"./chunk-6XI4VHIL.js";import"./chunk-FFR7EA4U.js";import"./chunk-DHJIXXWG.js";import{b as O}from"./chunk-KGVH3YAG.js";import"./chunk-D4Z7MWQY.js";import"./chunk-CCZHRBXJ.js";import"./chunk-QMBYRPRK.js";import"./chunk-CAJ247SC.js";import"./chunk-WZE6T3GT.js";import"./chunk-TK2IPNHL.js";import"./chunk-LCES5ZJI.js";import"./chunk-LXR5EI74.js";import"./chunk-QUULF2II.js";import"./chunk-I7KXFJDK.js";import"./chunk-EOWN4ZFJ.js";import"./chunk-WQXG4I5N.js";import"./chunk-S4PJMUC7.js";import"./chunk-PKB6IEGM.js";import{a as w,b as D,c as k,d as z,e as x,f as T}from"./chunk-Y5CFIRLN.js";import"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-W2XRHDQQ.js";import"./chunk-553OZX4H.js";import"./chunk-XWXFUFB2.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";import{mkdirSync as B,readFileSync as pe,writeFileSync as G}from"fs";import{tmpdir as je}from"os";import C from"path";import{mkdirSync as I,readFileSync as Q,writeFileSync as H}from"fs";import F from"path";function _(e){return e.replace(/\\/g,"/").replace(/\.png$/i,"").trim().split("/").filter(Boolean).join("--").replace(/[^A-Za-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"slide"}function v(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function ee(e){let t=e.trim();return/^#[0-9a-f]{3}$/i.test(t)?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function M(e,t){let o=ee(e),i=Math.max(0,Math.min(1,t)),n=o.match(/^#([0-9a-f]{6})$/i);if(n){let s=n[1],r=Number.parseInt(s.slice(0,2),16),a=Number.parseInt(s.slice(2,4),16),u=Number.parseInt(s.slice(4,6),16);return`rgba(${r}, ${a}, ${u}, ${i})`}return o.startsWith("rgb(")?o.replace(/^rgb\((.+)\)$/i,`rgba($1, ${i})`):o}function te(e){if(e.type==="solid")return e.color||"#000000";let t=e.direction??180,o=e.stops?.map(i=>`${i.color} ${i.offset}%`).join(", ")||"#000000 0%, #111111 100%";return`linear-gradient(${t}deg, ${o})`}function re(e){let t=e.glow;return t?`radial-gradient(circle at 50% 24%, ${M(t,.46)} 0%, ${M(t,.2)} 24%, rgba(0,0,0,0) 62%)`:"none"}function A(e){switch(e){case"tilted-left":return"perspective(2400px) rotateY(10deg) rotateZ(-2deg)";case"tilted-right":return"perspective(2400px) rotateY(-10deg) rotateZ(2deg)";case"cut-bottom":return"translateY(10%) scale(1.08)";case"cut-top":return"translateY(-16%) scale(1.08)";default:return"none"}}function L(...e){let t=e.map(o=>o.trim()).filter(o=>o.length>0&&o!=="none");return t.length>0?t.join(" "):"none"}function E(e){let t=M(e.color,e.opacity),o=M(e.color,e.opacity*.52);return`drop-shadow(0 34px ${e.spread}px ${o}) drop-shadow(0 0 ${e.blur}px ${t})`}function R(e,t){return!t.glow||e.color&&e.color!==w.color?e:{...e,color:t.glow}}function oe(e,t){if(e==="editorial-left"){let n=Math.round(t.height*.056),s=Math.round(t.height*.022);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.12)}px`,`left:${Math.round(t.width*.085)}px`,`width:${Math.round(t.width*.42)}px`,"text-align:left","z-index:3"].join(";"),titleStyle:`font-size:${n}px;line-height:0.92;`,subStyle:`font-size:${s}px;line-height:1.36;max-width:${Math.round(t.width*.36)}px;`,eyebrowStyle:"align-items:flex-start;",deviceStyle:(r,a,u)=>{let p=Math.round(t.width*.68*(a.scale??r.scale)),l=Math.round(t.height*(.03+r.offsetY+(a.offsetY??0))),c=a.pose||r.pose||"tilted-right",m=R(r.shadow,u);return["position:absolute",`top:${Math.round(t.height*.18)+l}px`,`left:${Math.round(t.width*.56)}px`,`width:${p}px`,"transform-origin:center center",`transform:${A(c)}`,`filter:${E(m)}`,"z-index:2"].join(";")}}}if(e==="minimal-bottom"){let n=Math.round(t.height*.041),s=Math.round(t.height*.019);return{copyStyle:["position:absolute",`left:${Math.round(t.width*.12)}px`,`right:${Math.round(t.width*.12)}px`,`bottom:${Math.round(t.height*.085)}px`,"text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${n}px;line-height:0.96;`,subStyle:`font-size:${s}px;line-height:1.34;max-width:${Math.round(t.width*.56)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(r,a,u)=>{let p=Math.round(t.width*.84*(a.scale??r.scale)),l=Math.round(t.height*(r.offsetY+(a.offsetY??0))),c=a.pose||r.pose,m=R(r.shadow,u);return["position:absolute",`top:${Math.round(t.height*.075)+l}px`,"left:50%",`width:${p}px`,"transform-origin:center center",`transform:${L("translateX(-50%)",A(c))}`,`filter:${E(m)}`,"z-index:2"].join(";")}}}let o=Math.round(t.height*.04),i=Math.round(t.height*.019);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.084)}px`,"left:50%",`width:${Math.round(t.width*.88)}px`,"transform:translateX(-50%)","text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${o}px;line-height:0.92;`,subStyle:`font-size:${i}px;line-height:1.34;max-width:${Math.round(t.width*.6)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(n,s,r)=>{let a=t.name==="ipad-13"?.54:.64,u=Math.round(t.width*a*(s.scale??n.scale)),p=Math.round(t.height*(n.offsetY+(s.offsetY??0))),l=s.pose||n.pose,c=R(n.shadow,r);return["position:absolute",`top:${Math.round(t.height*(t.name==="ipad-13"?.25:.28))+p}px`,"left:50%",`width:${u}px`,"transform-origin:center top",`transform:${L("translateX(-50%)",A(l))}`,`filter:${E(c)}`,"z-index:2"].join(";")}}}function ne({canvas:e,compose:t,slide:o,imageDataUrl:i}){let n=o.background??t.background,s=oe(t.text.preset,e),r=t.text.preset!=="none"&&!!(o.eyebrow||o.headline||o.subheadline),a=s.deviceStyle(t.frame,o,n),u=o.headline?`<div style="font-weight:780;white-space:pre-line;text-wrap:balance;${s.titleStyle}">${v(o.headline)}</div>`:"",p=o.subheadline?`<div style="margin-top:${Math.round(e.height*.018)}px;color:${t.text.subColor};white-space:pre-line;text-wrap:balance;${s.subStyle}">${v(o.subheadline)}</div>`:"",l=o.eyebrow?`<div style="display:flex;${s.eyebrowStyle}margin-bottom:${Math.round(e.height*.016)}px;"><div style="font-size:${Math.round(e.height*.014)}px;font-weight:700;letter-spacing:0.18em;text-transform:uppercase;color:${t.text.eyebrowColor};">${v(o.eyebrow)}</div></div>`:"";return`<!doctype html>
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{c as Y}from"./chunk-HZVPHAJX.js";import"./chunk-OJFHAMXD.js";import{b as j}from"./chunk-GOFKXREQ.js";import"./chunk-ZPURE62G.js";import"./chunk-IP2MARRU.js";import{b as O}from"./chunk-GI7FXE7J.js";import"./chunk-BR6QRN7U.js";import"./chunk-LX6KS6TL.js";import"./chunk-SHHUVGL2.js";import"./chunk-NZ5O2OEL.js";import"./chunk-7YZJHZ7X.js";import"./chunk-Q6DGMQ2V.js";import"./chunk-FZB4W23Y.js";import"./chunk-Y2YNXUBT.js";import"./chunk-ANDSHXLU.js";import"./chunk-YKFRPIVC.js";import"./chunk-C4AMFYK3.js";import"./chunk-5JOYGXCS.js";import"./chunk-334L67M2.js";import"./chunk-G2QUPNHI.js";import{a as w,b as D,c as k,d as z,e as x,f as T}from"./chunk-33R6QMNO.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{mkdirSync as B,readFileSync as pe,writeFileSync as G}from"fs";import{tmpdir as je}from"os";import C from"path";import{mkdirSync as I,readFileSync as Q,writeFileSync as H}from"fs";import F from"path";function _(e){return e.replace(/\\/g,"/").replace(/\.png$/i,"").trim().split("/").filter(Boolean).join("--").replace(/[^A-Za-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"slide"}function v(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function ee(e){let t=e.trim();return/^#[0-9a-f]{3}$/i.test(t)?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function M(e,t){let o=ee(e),i=Math.max(0,Math.min(1,t)),n=o.match(/^#([0-9a-f]{6})$/i);if(n){let s=n[1],r=Number.parseInt(s.slice(0,2),16),a=Number.parseInt(s.slice(2,4),16),u=Number.parseInt(s.slice(4,6),16);return`rgba(${r}, ${a}, ${u}, ${i})`}return o.startsWith("rgb(")?o.replace(/^rgb\((.+)\)$/i,`rgba($1, ${i})`):o}function te(e){if(e.type==="solid")return e.color||"#000000";let t=e.direction??180,o=e.stops?.map(i=>`${i.color} ${i.offset}%`).join(", ")||"#000000 0%, #111111 100%";return`linear-gradient(${t}deg, ${o})`}function re(e){let t=e.glow;return t?`radial-gradient(circle at 50% 24%, ${M(t,.46)} 0%, ${M(t,.2)} 24%, rgba(0,0,0,0) 62%)`:"none"}function A(e){switch(e){case"tilted-left":return"perspective(2400px) rotateY(10deg) rotateZ(-2deg)";case"tilted-right":return"perspective(2400px) rotateY(-10deg) rotateZ(2deg)";case"cut-bottom":return"translateY(10%) scale(1.08)";case"cut-top":return"translateY(-16%) scale(1.08)";default:return"none"}}function L(...e){let t=e.map(o=>o.trim()).filter(o=>o.length>0&&o!=="none");return t.length>0?t.join(" "):"none"}function E(e){let t=M(e.color,e.opacity),o=M(e.color,e.opacity*.52);return`drop-shadow(0 34px ${e.spread}px ${o}) drop-shadow(0 0 ${e.blur}px ${t})`}function R(e,t){return!t.glow||e.color&&e.color!==w.color?e:{...e,color:t.glow}}function oe(e,t){if(e==="editorial-left"){let n=Math.round(t.height*.056),s=Math.round(t.height*.022);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.12)}px`,`left:${Math.round(t.width*.085)}px`,`width:${Math.round(t.width*.42)}px`,"text-align:left","z-index:3"].join(";"),titleStyle:`font-size:${n}px;line-height:0.92;`,subStyle:`font-size:${s}px;line-height:1.36;max-width:${Math.round(t.width*.36)}px;`,eyebrowStyle:"align-items:flex-start;",deviceStyle:(r,a,u)=>{let p=Math.round(t.width*.68*(a.scale??r.scale)),l=Math.round(t.height*(.03+r.offsetY+(a.offsetY??0))),c=a.pose||r.pose||"tilted-right",m=R(r.shadow,u);return["position:absolute",`top:${Math.round(t.height*.18)+l}px`,`left:${Math.round(t.width*.56)}px`,`width:${p}px`,"transform-origin:center center",`transform:${A(c)}`,`filter:${E(m)}`,"z-index:2"].join(";")}}}if(e==="minimal-bottom"){let n=Math.round(t.height*.041),s=Math.round(t.height*.019);return{copyStyle:["position:absolute",`left:${Math.round(t.width*.12)}px`,`right:${Math.round(t.width*.12)}px`,`bottom:${Math.round(t.height*.085)}px`,"text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${n}px;line-height:0.96;`,subStyle:`font-size:${s}px;line-height:1.34;max-width:${Math.round(t.width*.56)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(r,a,u)=>{let p=Math.round(t.width*.84*(a.scale??r.scale)),l=Math.round(t.height*(r.offsetY+(a.offsetY??0))),c=a.pose||r.pose,m=R(r.shadow,u);return["position:absolute",`top:${Math.round(t.height*.075)+l}px`,"left:50%",`width:${p}px`,"transform-origin:center center",`transform:${L("translateX(-50%)",A(c))}`,`filter:${E(m)}`,"z-index:2"].join(";")}}}let o=Math.round(t.height*.04),i=Math.round(t.height*.019);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.084)}px`,"left:50%",`width:${Math.round(t.width*.88)}px`,"transform:translateX(-50%)","text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${o}px;line-height:0.92;`,subStyle:`font-size:${i}px;line-height:1.34;max-width:${Math.round(t.width*.6)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(n,s,r)=>{let a=t.name==="ipad-13"?.54:.64,u=Math.round(t.width*a*(s.scale??n.scale)),p=Math.round(t.height*(n.offsetY+(s.offsetY??0))),l=s.pose||n.pose,c=R(n.shadow,r);return["position:absolute",`top:${Math.round(t.height*(t.name==="ipad-13"?.25:.28))+p}px`,"left:50%",`width:${u}px`,"transform-origin:center top",`transform:${L("translateX(-50%)",A(l))}`,`filter:${E(c)}`,"z-index:2"].join(";")}}}function ne({canvas:e,compose:t,slide:o,imageDataUrl:i}){let n=o.background??t.background,s=oe(t.text.preset,e),r=t.text.preset!=="none"&&!!(o.eyebrow||o.headline||o.subheadline),a=s.deviceStyle(t.frame,o,n),u=o.headline?`<div style="font-weight:780;white-space:pre-line;text-wrap:balance;${s.titleStyle}">${v(o.headline)}</div>`:"",p=o.subheadline?`<div style="margin-top:${Math.round(e.height*.018)}px;color:${t.text.subColor};white-space:pre-line;text-wrap:balance;${s.subStyle}">${v(o.subheadline)}</div>`:"",l=o.eyebrow?`<div style="display:flex;${s.eyebrowStyle}margin-bottom:${Math.round(e.height*.016)}px;"><div style="font-size:${Math.round(e.height*.014)}px;font-weight:700;letter-spacing:0.18em;text-transform:uppercase;color:${t.text.eyebrowColor};">${v(o.eyebrow)}</div></div>`:"";return`<!doctype html>
3
3
  <html>
4
4
  <head>
5
5
  <meta charset="utf-8" />
@@ -0,0 +1,35 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{b as Z,c as D,d as Q,e as H,f as ee,h as te,i as A,j as ie,k as re,l as ne,p as se,s as k,t as oe,u as ae,v as ce,w as de}from"./chunk-LMNB7NYI.js";import"./chunk-2T6UOHPO.js";import{a as E}from"./chunk-OJFHAMXD.js";import"./chunk-LX6KS6TL.js";import"./chunk-FZB4W23Y.js";import{a as X}from"./chunk-Y2YNXUBT.js";import"./chunk-ANDSHXLU.js";import"./chunk-YKFRPIVC.js";import{d as z}from"./chunk-C4AMFYK3.js";import{a as U}from"./chunk-HAVQS3PI.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import{k as Y}from"./chunk-OXTFYLZJ.js";import{a as G,b as q}from"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-ASSV2FFC.js";import{A as F,B as L,D as j,E as $,F as J,G as K,H as V,I as N,u as B,v as M,y as T,z as W}from"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{spawn as Ie}from"child_process";import w from"fs";import{createServer as Pe}from"http";import S from"path";import{WebSocket as m,WebSocketServer as xe}from"ws";import le from"node:fs";import I from"node:path";var P=1;function ye(){return[Number(process.env.VITE_PORT_WEB||process.env.PORT||3e3),Number(process.env.VITE_PORT_ZERO||7849),Number(process.env.VITE_PORT_POSTGRES||7432),Number(process.env.VITE_PORT_R2||9500)].filter(a=>Number.isFinite(a)&&a>0)}var x=class{subscriptions=new Map;sessionsBySocket=new Map;allSockets=new Set;pendingPromptEchoes=new Map;pendingTurns=new Map;opts;constructor(e={}){this.opts=e}registerSocket(e){this.allSockets.add(e)}unregisterSocket(e){let t=this.sessionsBySocket.get(e);if(t){for(let i of t)this.decrementSubscription(i);this.sessionsBySocket.delete(e)}this.allSockets.delete(e)}async handleMessage(e,t){let i=t?.type;if(typeof i!="string"||!i.startsWith("agent:"))return!1;let o=t.id;try{let n=await this.dispatch(e,i,t);this.respond(e,o,n)}catch(n){n instanceof k?this.respondError(e,o,n.message,n.code):this.respondError(e,o,n instanceof Error?n.message:String(n))}return!0}async seedOnBoot(){try{await ne()}catch(e){process.stderr.write(`[sootsim-agent] seedFromDemoAppRegistry failed: ${e instanceof Error?e.message:String(e)}
3
+ `)}}close(){for(let e of this.subscriptions.values())try{e.unsubscribe()}catch{}this.subscriptions.clear(),this.sessionsBySocket.clear(),this.allSockets.clear()}async dispatch(e,t,i){switch(t){case"agent:list-projects":return H();case"agent:upsert-project":return D(i.input??{});case"agent:delete-project":return te(String(i.projectId)),{ok:!0};case"agent:auto-attach-for-url":return this.autoAttachForUrl(i.input??{});case"agent:list-sessions":return ie(i.projectId?String(i.projectId):void 0);case"agent:start-session":return this.doStartSession(i.input??{});case"agent:send-prompt":{let n=String(i.sessionId),s=A(n);if(!s)throw new k("NO_SESSION",`no session: ${n}`);let r=this.normalizePromptEnvelope(i);return await ae(n,r),this.notePromptAccepted(n,r,s.status==="working")}case"agent:end-session":this.dropSessionFanout(String(i.sessionId)),await ce(String(i.sessionId));let o=A(String(i.sessionId));return o&&this.broadcastSessionStatus(o),{ok:!0};case"agent:get-transcript":return this.getTranscript(String(i.sessionId));case"agent:get-paths":return this.getPaths();case"agent:subscribe-events":return this.subscribeSocket(e,String(i.sessionId));case"agent:unsubscribe-events":return this.unsubscribeSocket(e,String(i.sessionId));default:throw new k("UNKNOWN_AGENT_MSG",`unknown agent message: ${t}`)}}async doStartSession(e){if(!Q(e.projectId))throw new k("NO_PROJECT",`no project: ${e.projectId}`);let i=await oe(e);return this.broadcastSessionStatus(i.session),i}async autoAttachForUrl(e){let t=e.bundleUrl??"",i=(()=>{try{return new URL(t).port||null}catch{return null}})();if(!i)return{project:null};let o=this.opts.getExcludePorts?.()??ye(),s=(await E({excludePorts:o})).find(d=>String(d.port)===i);if(!s||!s.cwd)return{project:null};let r=H().find(d=>d.cwd===s.cwd)??null,c=Array.from(new Set([...r?.knownBundleUrls??[],s.bundleUrl,t]));return{project:D({cwd:s.cwd,name:s.projectName??I.basename(s.cwd),preferredProvider:e.provider??r?.preferredProvider,sourceRoots:r?.sourceRoots??[s.cwd],knownBundleUrls:c,framework:r?.framework??ve(s.framework),bundleId:s.bundleId??r?.bundleId})}}getTranscript(e){let t=se(e);return le.existsSync(t)?le.readFileSync(t,"utf8"):{error:"transcript not found",code:"NO_TRANSCRIPT"}}getPaths(){let e=Z();return{userDataDir:e,storeFile:I.join(e,"attached-projects.json"),sessionsDir:I.join(e,"sessions"),transcriptsDir:I.join(e,"transcripts")}}subscribeSocket(e,t){let i=this.sessionsBySocket.get(e);if(i||(i=new Set,this.sessionsBySocket.set(e,i)),i.has(t))return{ok:!0,refCount:this.subscriptions.get(t)?.refCount??1};i.add(t);let o=this.subscriptions.get(t);if(o)return o.refCount++,{ok:!0,refCount:o.refCount};let n=de(t,s=>{let r=this.coalescePromptEcho(t,s);if(r&&(this.applySessionEvent(t,r),this.fanOutEvent(t,r)),s.type==="turn-completed"){let c=A(t);if(c)try{ee(c.projectId,{usd:s.costUsd,ts:s.ts})}catch(l){process.stderr.write(`[sootsim-agent] recordTurnTelemetry failed: ${l instanceof Error?l.message:String(l)}
4
+ `)}}});return this.subscriptions.set(t,{unsubscribe:n,refCount:1}),{ok:!0,refCount:1}}unsubscribeSocket(e,t){let i=this.sessionsBySocket.get(e);return!i||!i.has(t)?{ok:!0,refCount:0}:(i.delete(t),this.decrementSubscription(t))}decrementSubscription(e){let t=this.subscriptions.get(e);if(!t)return{ok:!0,refCount:0};if(t.refCount--,t.refCount<=0){try{t.unsubscribe()}catch{}return this.subscriptions.delete(e),{ok:!0,refCount:0}}return{ok:!0,refCount:t.refCount}}dropSessionFanout(e){let t=this.subscriptions.get(e);if(t){try{t.unsubscribe()}catch{}this.subscriptions.delete(e)}for(let i of this.sessionsBySocket.values())i.delete(e);this.clearPromptTracking(e)}normalizePromptEnvelope(e){if(e?.prompt&&typeof e.prompt=="object"){let t=e.prompt;return{text:String(t.text??""),...typeof t.displayText=="string"?{displayText:t.displayText}:{},...typeof t.inspectSummary=="string"?{inspectSummary:t.inspectSummary}:{},...typeof t.inspectTrace=="string"?{inspectTrace:t.inspectTrace}:{}}}return{text:String(e?.text??""),...typeof e?.displayText=="string"?{displayText:e.displayText}:{},...typeof e?.inspectSummary=="string"?{inspectSummary:e.inspectSummary}:{},...typeof e?.inspectTrace=="string"?{inspectTrace:e.inspectTrace}:{}}}notePromptAccepted(e,t,i){let o=Date.now(),n=this.pendingPromptEchoes.get(e)??[];n.push({sentAt:o}),this.pendingPromptEchoes.set(e,n);let s=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,s);let r=t.displayText??t.text;return this.patchSession(e,{lastPrompt:r,status:"working",needsAttention:!1}),this.fanOutEvent(e,{type:"prompt-received",text:r,...t.inspectSummary?{inspectSummary:t.inspectSummary}:{},...t.inspectTrace?{inspectTrace:t.inspectTrace}:{},ts:o}),{ok:!0,queued:s>1,pendingTurns:s,queueDepth:Math.max(0,s-1)}}applySessionEvent(e,t){switch(t.type){case"prompt-received":case"turn-started":this.patchSession(e,{status:"working",needsAttention:!1});return;case"turn-completed":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"idle",needsAttention:!1,lastTurnFiles:t.filesTouched,currentlyEditing:void 0});return}case"approval-needed":this.patchSession(e,{status:"needs-attention",needsAttention:!0});return;case"error":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"needs-attention",needsAttention:i<=0,currentlyEditing:void 0});return}case"exited":this.clearPromptTracking(e),this.patchSession(e,{status:"ended",needsAttention:!1,wrapperPid:void 0,currentlyEditing:void 0});return;case"ready":case"turn-reasoning":case"turn-message":case"turn-plan":case"tool-call":case"file-edited":case"file-diff-delta":return}}patchSession(e,t){re(e,t);let i=A(e);i&&this.broadcastSessionStatus(i)}coalescePromptEcho(e,t){if(t.type!=="prompt-received")return t;let i=this.pendingPromptEchoes.get(e);if(!i||i.length===0)return t;for(;i.length>0&&Date.now()-i[0].sentAt>15e3;)i.shift();return i.length===0?(this.pendingPromptEchoes.delete(e),t):(i.shift(),i.length===0?this.pendingPromptEchoes.delete(e):this.pendingPromptEchoes.set(e,i),null)}consumeSettledTurn(e){let t=Math.max(0,(this.pendingTurns.get(e)??1)-1);return t>0?this.pendingTurns.set(e,t):this.pendingTurns.delete(e),t}clearPromptTracking(e){this.pendingPromptEchoes.delete(e),this.pendingTurns.delete(e)}fanOutEvent(e,t){let i=JSON.stringify({type:"agent:event",sessionId:e,event:t});for(let[o,n]of this.sessionsBySocket)if(n.has(e)&&o.readyState===P)try{o.send(i)}catch{}}broadcastSessionStatus(e){let t=JSON.stringify({type:"agent:session-status",session:e});for(let i of this.allSockets)if(i.readyState===P)try{i.send(t)}catch{}}respond(e,t,i){if(e.readyState===P)try{e.send(JSON.stringify({id:t,result:i}))}catch{}}respondError(e,t,i,o){if(e.readyState===P)try{e.send(JSON.stringify({id:t,error:i,...o?{code:o}:{}}))}catch{}}};function ve(a){return a==="expo"?"expo":a==="one"||a==="vxrn"?"one":"unknown"}import be from"http";import we from"https";var Ae="sootsim",ke=new Set(["host","origin","referer","user-agent","cookie","connection","keep-alive","transfer-encoding","upgrade","content-length","sec-fetch-site","sec-fetch-mode","sec-fetch-dest","sec-ch-ua","sec-ch-ua-mobile","sec-ch-ua-platform"]),Ce={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,PUT,DELETE,PATCH,OPTIONS","access-control-allow-headers":"*","access-control-expose-headers":"*","access-control-max-age":"3600"};function C(a){for(let[e,t]of Object.entries(Ce))a.setHeader(e,t)}function Te(a,e){let t=[],i=e;i?.code&&t.push(i.code),i?.message&&t.push(i.message),i?.cause?.code&&t.push(i.cause.code),i?.cause?.message&&t.push(i.cause.message);let n=[...new Set(t.filter(Boolean))].join(" | ")||String(e);return a.includes("stored-in-.env.local")?`${n} | upstream url still contains placeholder env values`:n}function Ee(a){let e={};for(let[t,i]of Object.entries(a))i&&(ke.has(t.toLowerCase())||(e[t]=Array.isArray(i)?i.join(", "):i));return e["user-agent"]=Ae,e}function ue(a){return a?.startsWith("/__fetch-proxy?")||a?.startsWith("/__proxy?")||!1}function pe(a){return a?!!(a.startsWith("/__app-api?")||a.startsWith("/__app-api/")):!1}async function he(a,e){if(a.method==="OPTIONS"){C(e),e.writeHead(204),e.end();return}let i=new URLSearchParams((a.url||"").split("?")[1]||"").get("url");if(!i){C(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("missing url param");return}let o;try{o=new URL(i)}catch{C(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("invalid url param");return}let n=Ee(a.headers),s;if(a.method!=="GET"&&a.method!=="HEAD"){let d=[];for await(let u of a)d.push(Buffer.isBuffer(u)?u:Buffer.from(u));d.length>0&&(s=Buffer.concat(d))}let r;try{r=await fetch(o.href,{method:a.method,headers:n,body:s,redirect:"follow"})}catch(d){C(e),e.writeHead(502,{"Content-Type":"text/plain"}),e.end(`fetch proxy error: ${Te(o.href,d)}`);return}r.headers.forEach((d,u)=>{let p=u.toLowerCase();p==="content-encoding"||p==="transfer-encoding"||p==="content-length"||p==="set-cookie"||p.startsWith("access-control-")||e.setHeader(u,d)}),C(e);let c=r.headers.getSetCookie?.()??[];c.length>0&&e.setHeader("x-sootsim-set-cookie",c.join(", ")),e.statusCode=r.status;let l=Buffer.from(await r.arrayBuffer());e.end(l)}function me(a,e){let t=a.url||"",i="",o="";if(t.startsWith("/__app-api?")){let l=new URL(t,"http://sootsim.local");i=l.searchParams.get("path")||"",o=l.searchParams.get("origin")?.trim()||""}else if(t.startsWith("/__app-api/"))i=t.slice(10);else return!1;if(!o)return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: missing origin query param"),!0;if(a.method==="OPTIONS")return e.writeHead(204,{"Access-Control-Allow-Origin":a.headers.origin||"*","Access-Control-Allow-Methods":"GET,POST,PUT,PATCH,DELETE,OPTIONS","Access-Control-Allow-Headers":a.headers["access-control-request-headers"]||"*","Access-Control-Allow-Credentials":"true","Access-Control-Max-Age":"86400"}),e.end(),!0;let n;try{n=new URL(i,o)}catch{return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: invalid origin or path"),!0}let s=n.protocol==="https:"?we:be,r={...a.headers};delete r.host,r.host=n.host;let c=s.request({hostname:n.hostname,port:n.port||(n.protocol==="https:"?443:80),path:n.pathname+n.search,method:a.method,headers:r},l=>{let d=Object.keys(l.headers).filter(u=>{let p=u.toLowerCase();return!p.startsWith("access-control-")&&p!=="set-cookie"}).join(", ");e.writeHead(l.statusCode??502,{...l.headers,"access-control-allow-origin":a.headers.origin||"*","access-control-allow-credentials":"true","access-control-expose-headers":d}),l.pipe(e)});return c.on("error",l=>{e.statusCode=502,e.end(`app proxy error: ${l.message}`)}),a.pipe(c),!0}var Oe=new Set(["tap","keyboard","close"]);function Re(a){return!a||typeof a.type!="string"?!1:a.acquireLock===!0?!0:a.readOnly===!0?!1:Oe.has(a.type)}var _e=5e3,Be=3600*1e3,Le="SOOTSIM_RUNTIME_UPDATE_INTERVAL_MS",Ne={".html":"text/html; charset=utf-8",".js":"application/javascript",".cjs":"application/javascript",".mjs":"application/javascript",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".wasm":"application/wasm",".ttf":"font/ttf",".otf":"font/otf",".woff":"font/woff",".woff2":"font/woff2",".map":"application/json",".txt":"text/plain; charset=utf-8"};function fe(a,e,t){let i;try{let c=B();i=JSON.stringify(c)}catch{i="{}"}let o=e>0?`window.__sootsimBridgePort=${e};`:"",n=t?`window.__sootsimSootbeanOrigin=${JSON.stringify(t)};`:"",s=`<script>window.__sootsimSharedConfig=${i};`+o+n+`window.__sootsimCliVersion=${JSON.stringify(U())};</script>`,r=a.toString("utf8");return r.includes("</head>")?r.replace("</head>",s+"</head>"):r.includes("</body>")?r.replace("</body>",s+"</body>"):s+r}var O=class a{port;openUrlHandler;httpServer=null;wss=null;nextCommandId=1;nextSimNumber=161;sims=new Map;primarySimId=null;pendingCommands=new Map;cliBySentId=new Map;cliSimBySocket=new Map;cliLastCommandAt=new Map;cliIdentityKeyBySocket=new Map;cliLabelBySocket=new Map;restorableSims=new Map;nextCliFallbackId=1;cliIdleTimer=null;agentHost;static CLI_IDLE_TIMEOUT_MS=6e4;static CLI_LEASE_TTL_MS=6e5;static USER_ACTIVE_LEASE_TTL_MS=8e3;static USER_BOOT_LEASE_TTL_MS=6e4;static SIM_RECONNECT_TTL_MS=3e4;preferredPort;portFallbackCount;shouldWriteLockfile;sootbeanOrigin=null;effectivePort=0;startedAt=0;heartbeatTimer=null;wsHeartbeatTimer=null;wsIsAlive=new WeakMap;static WS_HEARTBEAT_INTERVAL_MS=3e4;runtimeUpdateTimer=null;runtimeUpdateInFlight=null;activeRuntimeVersion=null;activeRuntimeDirPath=null;scanCache=null;scanCacheAt=0;inflightScan=null;static SCAN_FRESH_MS=2e3;constructor(e={}){this.preferredPort=e.port||7668,this.port=this.preferredPort,this.shouldWriteLockfile=e.writeLockfile===!0,this.portFallbackCount=Math.max(1,e.portFallbackCount??10),this.openUrlHandler=e.openUrl,this.agentHost=new x({getExcludePorts:e.agentScanExcludes}),this.sootbeanOrigin=e.sootbeanOrigin?.replace(/\/$/,"")||null}getAgentHost(){return this.agentHost}start(e){this.startAsync(e)}async startAsync(e){if(this.httpServer||this.wss)return this.effectivePort;this.refreshActiveRuntime();for(let t=0;t<this.portFallbackCount;t++){let i=this.preferredPort+t;try{return await this.bindOnce(i,e?.silent===!0),this.effectivePort=i,this.port=i,this.startedAt=Date.now(),t>0&&!e?.silent&&process.stderr.write(`ws bridge bound to port ${i} (preferred ${this.preferredPort} was taken)
5
+ `),this.afterBind(),i}catch(o){if(o?.code!=="EADDRINUSE")throw o;e?.silent||process.stderr.write(`ws bridge port ${i} already in use, trying ${i+1}
6
+ `)}}throw new Error(`could not bind ws bridge after ${this.portFallbackCount} attempts starting at ${this.preferredPort}`)}bindOnce(e,t){return new Promise((i,o)=>{let n=Pe((c,l)=>this.handleHttpRequest(c,l)),s=!1,r=c=>{if(!s){s=!0;try{n.close()}catch{}this.httpServer=null,this.wss=null,o(c)}};n.once("error",r),n.listen(e,"127.0.0.1",()=>{s||(s=!0,n.removeListener("error",r),n.on("error",c=>{process.stderr.write(`ws bridge http error: ${String(c)}
7
+ `)}),this.httpServer=n,this.wss=new xe({server:n}),this.wireWebSocketServer(),i())})})}wireWebSocketServer(){this.wss&&this.wss.on("connection",(e,t)=>{let i=t.headers.origin,o=i?"sim":"cli",n=null;if(e.on("error",()=>{}),this.wsIsAlive.set(e,!0),e.on("pong",()=>{this.wsIsAlive.set(e,!0)}),this.agentHost.registerSocket(e),o==="sim")n={id:this.allocateSimId(),ws:e,origin:i,connectedAt:Date.now(),lastSeenAt:Date.now(),lastActiveAt:0,recentActions:[]},this.sims.set(n.id,n),this.shouldPromoteSim(n)&&(this.primarySimId=n.id),this.broadcastSimAssignments(),this.broadcastSimClientStates();else{let s=`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,s)}e.on("message",s=>{let r;try{r=JSON.parse(s.toString())}catch{return}if(!(!r||typeof r!="object")){if(typeof r.type=="string"&&r.type.startsWith("agent:")){this.agentHost.handleMessage(e,r);return}if(r.type==="runtime:list"){let c=L(),l=this.getActiveRuntime(),d={type:"runtime:list:ok",id:r.id,installed:c,active:l.version,activeRuntimeDir:l.runtimeDir};try{e.send(JSON.stringify(d))}catch{}return}if(r.type==="runtime:use"){let c=typeof r.version=="string"?r.version:"";if(!L().includes(c)){try{e.send(JSON.stringify({type:"runtime:use:error",id:r.id,error:`runtime ${c||"(missing)"} is not installed`}))}catch{}return}let d=this.setActiveRuntime(c);try{e.send(JSON.stringify({type:"runtime:use:ok",id:r.id,version:d.version,runtimeDir:d.runtimeDir}))}catch{}return}if(r.type==="runtime:get"){let c=this.getActiveRuntime();try{e.send(JSON.stringify({type:"runtime:get:ok",id:r.id,active:c.version,activeRuntimeDir:c.runtimeDir}))}catch{}return}if(o==="sim"){if(n&&(n.lastSeenAt=Date.now()),r.type==="bridge:register"&&n){let d=r,u=this.tryRestoreSimId(n,d.simId);n.url=d.url,n.title=d.title,n.userAgent=d.userAgent,typeof d.kind=="string"&&d.kind.trim()&&(n.kind=d.kind.trim()),d.meta&&typeof d.meta=="object"&&(n.meta=d.meta),u&&(this.broadcastSimAssignments(),this.broadcastSimClientStates());return}if(r.type==="bridge:user-focus-state"&&n){let d=r;this.updateUserFocusLease(n,d.focused===!0);return}if(r.type==="bridge:user-interact"&&n){this.updateUserActivity(n);return}if(r.type==="bridge:write-shared-config"){let d=r.patch&&typeof r.patch=="object"?r.patch:null;if(!d)return;let u;try{u=M(d)}catch(h){process.stderr.write(`sootsim: bridge:write-shared-config failed: ${h instanceof Error?h.message:String(h)}
8
+ `);return}let p=JSON.stringify({type:"bridge:shared-config-changed",config:u});for(let h of this.sims.values())if(h.ws.readyState===m.OPEN)try{h.ws.send(p)}catch{}return}if(r.type==="bridge:open-path"){let d=typeof r.path=="string"?r.path:"",u=typeof r.line=="number"&&Number.isFinite(r.line)?r.line:void 0,p=typeof r.column=="number"&&Number.isFinite(r.column)?r.column:void 0;d&&this.openPathInEditor(d,u,p);return}if(r.type==="bridge:boot-clients"&&n){let d=[];for(let[p,h]of this.cliSimBySocket)h===n.id&&d.push(p);for(let p of d){this.cliSimBySocket.delete(p);try{p.close(1e3,"booted by sim")}catch{}}let u=!!n.cliLease;n.cliLease={kind:"user-active",cliIdentityKey:"__user-active__",cliLabel:"active user",expiresAt:Date.now()+a.USER_BOOT_LEASE_TTL_MS},process.stderr.write(`sootsim booted ${d.length} cli client(s)${u?" (overrode prior lease)":""}; held sim for user [${n.id}]
9
+ `),this.recordSimAction(n.id,"sim booted cli clients"),this.broadcastSimClientStates();return}let c=this.pendingCommands.get(r.id);if(c){this.pendingCommands.delete(r.id),r.error?c.reject(new Error(r.error)):c.resolve(r.result);return}let l=this.cliBySentId.get(r.id);if(l&&(this.cliBySentId.delete(r.id),l.ws.readyState===m.OPEN)){let d=this.getOtherCliIdentityCount(l.ws,l.simId),u=d>0?{...r,id:l.originalId,i:d}:{...r,id:l.originalId};l.ws.send(JSON.stringify(u))}return}(async()=>{this.cliLastCommandAt.set(e,Date.now());try{if(r.type==="bridge:bye"){let p=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[h,f]of this.cliBySentId)f.ws===e&&this.cliBySentId.delete(h);p&&this.broadcastSimClientStates();return}if(r.type==="bridge:hello"){let p=typeof r.cliIdentityKey=="string"&&r.cliIdentityKey.trim()?r.cliIdentityKey.trim():this.cliIdentityKeyBySocket.get(e)||`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,p),typeof r.cliLabel=="string"&&r.cliLabel.trim()&&this.cliLabelBySocket.set(e,r.cliLabel.trim()),e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,result:{cliIdentityKey:p,leaseTtlMs:a.CLI_LEASE_TTL_MS,leasing:!0}}));return}if(r.type==="bridge:list-sims"){e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,result:this.listSims()}));return}if(r.type==="bridge:open"){if(typeof r.url!="string"||!r.url)throw new Error("bridge:open requires a url");await this.openUrl(r.url,{newWindow:r.newWindow===!0}),e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,result:{ok:!0,url:r.url}}));return}if(r.type==="bridge:claim"){let p=await this.waitForSim(r.simId),h=this.tryAcquireLease(e,p,{force:r.force===!0});if(!h.granted){e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${p.id} is locked by another cli`,o:h.lock}));return}this.setCliSimTarget(e,p.id),this.recordSimAction(p.id,h.bootedCount>0?`cli force-claimed sim (booted ${h.bootedCount})`:"cli claimed sim"),e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,result:{simId:p.id,lockedBy:h.lease.cliIdentityKey,lockExpiresAt:h.lease.expiresAt,bootedCount:h.bootedCount}}));return}let c=await this.waitForSim(r.simId);if(Re(r)){let p=this.tryAcquireLease(e,c);if(!p.granted){e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${c.id} is locked by another cli \u2014 use \`sootsim claim ${c.id} --force\` or \`sootsim open --new\``,o:p.lock}));return}}else this.ensureCliIdentityKey(e);this.setCliSimTarget(e,c.id),this.recordSimAction(c.id,this.describeForwardedCommand(r));let l=this.nextCommandId++;this.cliBySentId.set(l,{simId:c.id,ws:e,originalId:r.id});let{simId:d,...u}=r;c.ws.send(JSON.stringify({...u,id:l}))}catch(c){e.readyState===m.OPEN&&e.send(JSON.stringify({id:r.id,error:c instanceof Error?c.message:String(c)}))}})()}}),e.on("close",()=>{if(this.agentHost.unregisterSocket(e),o==="sim"&&n){this.rememberDisconnectedSim(n),this.primarySimId===n.id&&(this.primarySimId=this.getOpenSim()?.id??null);for(let[s,r]of this.pendingCommands)r.simId===n.id&&(r.reject(new Error("sim disconnected")),this.pendingCommands.delete(s));for(let[s,r]of this.cliBySentId)r.simId===n.id&&(r.ws.readyState===m.OPEN&&r.ws.send(JSON.stringify({id:r.originalId,error:"sim disconnected before responding"})),this.cliBySentId.delete(s));this.broadcastSimAssignments(),this.broadcastSimClientStates()}else if(o==="cli"){let s=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[r,c]of this.cliBySentId)c.ws===e&&this.cliBySentId.delete(r);s&&this.broadcastSimClientStates()}})})}afterBind(){if(process.stderr.write(`ws bridge listening on port ${this.port}
10
+ `),this.cliIdleTimer=setInterval(()=>this.sweepIdleCliClients(),3e4),this.cliIdleTimer.unref(),this.wsHeartbeatTimer=setInterval(()=>this.sweepDeadWebSockets(),a.WS_HEARTBEAT_INTERVAL_MS),this.wsHeartbeatTimer.unref(),this.shouldWriteLockfile){try{if(T(),!V(this.buildLockfileSnapshot()))throw new Error("another sootsim daemon wrote the lockfile during startup \u2014 aborting")}catch(e){throw process.stderr.write(`ws bridge failed to claim daemon lockfile: ${String(e)}
11
+ `),e}this.heartbeatTimer=setInterval(()=>{try{this.writeLockfileSnapshot()}catch{}},_e),this.heartbeatTimer.unref(),this.startRuntimeUpdater()}this.agentHost.seedOnBoot()}bootstrapping=!0;buildLockfileSnapshot(){return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,activeRuntimeDir:this.activeRuntimeDirPath,startedAt:this.startedAt,heartbeatAt:Date.now(),bootstrapping:this.bootstrapping}}writeLockfileSnapshot(){K(this.buildLockfileSnapshot())}refreshActiveRuntime(){this.activeRuntimeVersion=W(),this.activeRuntimeDirPath=j()}runServerScan(){if(this.inflightScan)return this.inflightScan;let e=this.effectivePort>0?[this.effectivePort]:[];return this.inflightScan=E({excludePorts:e,buildIconProxyUrl:t=>`/__bundle-proxy?url=${encodeURIComponent(t)}`}).then(t=>(this.scanCache=t,this.scanCacheAt=Date.now(),t)).catch(t=>{let i=t instanceof Error?t.message:String(t);return console.error("[sootsim] /__server-scan failed:",i),this.scanCache??[]}).finally(()=>{this.inflightScan=null}),this.inflightScan}handleServerScan(e){let t=o=>{e.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),e.end(JSON.stringify(o))},i=Date.now()-this.scanCacheAt;if(this.scanCache&&i<a.SCAN_FRESH_MS){t(this.scanCache);return}if(this.scanCache){t(this.scanCache),this.runServerScan().catch(()=>{});return}this.runServerScan().then(o=>t(o))}resolveRuntimeUpdateIntervalMs(){let e=Number(process.env[Le]);return Number.isFinite(e)&&e>0?Math.max(100,Math.round(e)):Be}startRuntimeUpdater(){if(!this.shouldWriteLockfile||this.runtimeUpdateTimer)return;this.runRuntimeUpdate("startup");let e=this.resolveRuntimeUpdateIntervalMs();this.runtimeUpdateTimer=setInterval(()=>{this.runRuntimeUpdate("periodic")},e),this.runtimeUpdateTimer.unref()}runRuntimeUpdate(e){return this.runtimeUpdateInFlight?this.runtimeUpdateInFlight:(this.runtimeUpdateInFlight=(async()=>{try{e==="startup"&&process.stderr.write(`sootsim: checking for runtime updates\u2026
12
+ `);let t=await Y();if(!t.updated||!t.latestVersion){e==="startup"&&process.stderr.write(`sootsim: runtime ${this.activeRuntimeVersion??"(none)"} is current
13
+ `);return}let i=this.setActiveRuntime(t.latestVersion);process.stderr.write(`sootsim runtime updated to ${i.version} (${e})
14
+ `)}catch(t){process.stderr.write(`sootsim runtime update failed (${e}): ${t instanceof Error?t.message:String(t)}
15
+ `)}finally{if(this.runtimeUpdateInFlight=null,e==="startup"&&this.bootstrapping){if(this.bootstrapping=!1,this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}process.stderr.write(`sootsim: ready
16
+ `)}}})(),this.runtimeUpdateInFlight)}setActiveRuntime(e){if(F(e),this.refreshActiveRuntime(),this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}let t=JSON.stringify({type:"runtime:changed",version:e,runtimeDir:this.activeRuntimeDirPath});for(let i of this.sims.values())if(i.ws.readyState===m.OPEN)try{i.ws.send(t)}catch{}return{version:e,runtimeDir:this.activeRuntimeDirPath}}getActiveRuntime(){return{version:this.activeRuntimeVersion,runtimeDir:this.activeRuntimeDirPath}}removeLockfile(){if(this.shouldWriteLockfile)try{N()}catch{}}handleHttpRequest(e,t){if(t.setHeader("Cross-Origin-Opener-Policy","same-origin"),t.setHeader("Cross-Origin-Embedder-Policy","credentialless"),t.setHeader("Cross-Origin-Resource-Policy","cross-origin"),t.setHeader("Document-Policy","js-profiling"),ue(e.url)){he(e,t);return}if(pe(e.url)&&me(e,t))return;let i=(e.method||"GET").toUpperCase();if(i!=="GET"&&i!=="HEAD"){t.writeHead(405,{Allow:"GET, HEAD"}),t.end("method not allowed");return}let o=new URL(e.url||"/","http://localhost");if(o.pathname==="/__bundle-proxy"){let l=o.searchParams.get("url");if(!l){t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: missing url query param");return}let d;try{d=new URL(l)}catch{t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: invalid url");return}let u=d.hostname;if(!(u==="localhost"||u==="127.0.0.1"||u==="::1"||u.endsWith(".localhost"))){t.writeHead(403,{"Content-Type":"text/plain"}),t.end("bundle-proxy: only loopback targets allowed");return}(async()=>{try{let h=await fetch(d.toString(),{redirect:"follow"}),f={},y=h.headers.get("content-type");if(y&&(f["Content-Type"]=y),f["Cache-Control"]="no-store",t.writeHead(h.status,f),!h.body){t.end();return}let g=h.body.getReader();for(;;){let{done:v,value:b}=await g.read();if(v)break;t.write(Buffer.from(b))}t.end()}catch(h){t.writeHead(502,{"Content-Type":"text/plain"}),t.end(`bundle-proxy: upstream fetch failed: ${h instanceof Error?h.message:String(h)}`)}})();return}if(o.pathname==="/__server-scan"){this.handleServerScan(t);return}if(o.pathname==="/healthz"){t.writeHead(200,{"Content-Type":"application/json","Cache-Control":"no-store"}),t.end(JSON.stringify({ok:!0,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,startedAt:this.startedAt,uptimeMs:this.startedAt>0?Date.now()-this.startedAt:0}));return}if(o.pathname==="/__sootsim/shared-config"){if(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Cache-Control","no-store"),i==="GET"||i==="HEAD"){let l="{}";try{l=JSON.stringify(B())}catch{}t.writeHead(200,{"Content-Type":"application/json"}),i==="HEAD"?t.end():t.end(l);return}t.writeHead(405,{Allow:"GET, HEAD"}),t.end("method not allowed (use the bridge over WS for writes)");return}this.refreshActiveRuntime();let n=this.activeRuntimeDirPath;if(!n){t.writeHead(503,{"Content-Type":"text/plain; charset=utf-8"}),t.end("sootsim: no active runtime installed. run `sootsim runtime install` to fetch one.");return}let s=o.pathname;if(s==="/runtime"||s==="/runtime/"?s="/":s.startsWith("/runtime/")&&(s=s.slice(8)),(s===""||s==="/")&&(s="/index.html"),s.includes("\0")){t.writeHead(400),t.end("bad request");return}if(process.platform!=="win32"&&s.includes("\\")){t.writeHead(400),t.end("bad request");return}for(let l of s.split("/"))if(l===".."){t.writeHead(403),t.end("forbidden");return}let r=S.resolve(n,"."+s),c=n.endsWith(S.sep)?n:n+S.sep;if(!r.startsWith(c)&&r!==n){t.writeHead(403),t.end("forbidden");return}w.realpath(r,(l,d)=>{let u=l?r:d,p=u.endsWith(S.sep)?u:u+S.sep;if(!l){let h=(()=>{try{let f=w.realpathSync(n);return f.endsWith(S.sep)?f:f+S.sep}catch{return c}})();if(!p.startsWith(h)&&u+S.sep!==h){t.writeHead(403),t.end("forbidden");return}}w.stat(u,(h,f)=>{if(h||!f?.isFile()){let b=S.extname(s).toLowerCase();if(b&&b!==".html"){t.writeHead(404),t.end("not found");return}if(s.startsWith("/__")||s.startsWith("/api/")||s==="/api"){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("not found");return}let _=S.join(n,"index.html");w.readFile(_,(ge,Se)=>{if(ge){t.writeHead(404),t.end("not found");return}if(t.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),i==="HEAD"){t.end();return}t.end(fe(Se,this.effectivePort,this.sootbeanOrigin))});return}let y=S.extname(u).toLowerCase(),g=Ne[y]||"application/octet-stream";if(t.writeHead(200,{"Content-Type":g,"Cache-Control":"no-store"}),i==="HEAD"){t.end();return}if(y===".html"){w.readFile(u,(b,_)=>{if(b){try{t.end()}catch{}return}t.end(fe(_,this.effectivePort,this.sootbeanOrigin))});return}let v=w.createReadStream(u);v.pipe(t),v.on("error",()=>{try{t.end()}catch{}})})})}sweepIdleCliClients(){let e=Date.now(),t=!1;for(let[i,o]of this.cliSimBySocket){let n=this.cliLastCommandAt.get(i)??0;if(!(e-n<a.CLI_IDLE_TIMEOUT_MS)){this.cliSimBySocket.delete(i),this.cliLastCommandAt.delete(i);for(let[s,r]of this.cliBySentId)r.ws===i&&this.cliBySentId.delete(s);try{i.close(1e3,"idle timeout")}catch{}t=!0}}t&&this.broadcastSimClientStates(),this.sweepRestorableSims(e)}sweepDeadWebSockets(){if(this.wss)for(let e of this.wss.clients){if(e.readyState!==m.OPEN)continue;if(this.wsIsAlive.get(e)===!1){try{e.terminate()}catch{}continue}this.wsIsAlive.set(e,!1);try{e.ping()}catch{try{e.terminate()}catch{}}}}listSims(){return Array.from(this.sims.values()).sort((e,t)=>e.id===this.primarySimId?-1:t.id===this.primarySimId?1:e.connectedAt-t.connectedAt).map(e=>this.describeSim(e))}async sendCommand(e){let t=await this.waitForSim(e.simId),i=this.nextCommandId++;return new Promise((o,n)=>{let s=setTimeout(()=>{this.pendingCommands.delete(i),this.broadcastSimClientStates(),n(new Error("command timed out after 30s"))},3e4);this.pendingCommands.set(i,{simId:t.id,resolve:l=>{clearTimeout(s),this.pendingCommands.delete(i),this.broadcastSimClientStates(),o(l)},reject:l=>{clearTimeout(s),this.pendingCommands.delete(i),this.broadcastSimClientStates(),n(l)}}),this.broadcastSimClientStates();let{simId:r,...c}=e;t.ws.send(JSON.stringify({...c,id:i}))})}async evaluate(e,t){return this.sendCommand({type:"evaluate",code:e,simId:t})}async focusSim(e){return this.sendCommand({type:"focus",simId:e})}async closeSim(e){return this.sendCommand({type:"close",simId:e})}async openPathInEditor(e,t,i){let o=t!=null?`:${t}${i!=null?`:${i}`:""}`:"",n=`${e}${o}`,s=(c,l)=>new Promise(d=>{try{let u=Ie(c,l,{detached:!0,stdio:"ignore"}),p=!1;u.on("error",()=>{p||(p=!0,d(!1))}),u.on("spawn",()=>{p||(p=!0,u.unref(),d(!0))})}catch{d(!1)}}),r=process.env.REACT_EDITOR||process.env.EDITOR;if(r){let c=r.split(" ").filter(Boolean);if(c.length&&await s(c[0],[...c.slice(1),"-g",n]))return}await s("cursor",["-g",n])||await s("code",["-g",n])||await this.openUrl(e)}async openUrl(e,t={}){if(this.openUrlHandler){await this.openUrlHandler(e,t);return}await z(e,t)}async close(){if(this.cliIdleTimer&&(clearInterval(this.cliIdleTimer),this.cliIdleTimer=null),this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.wsHeartbeatTimer&&(clearInterval(this.wsHeartbeatTimer),this.wsHeartbeatTimer=null),this.runtimeUpdateTimer&&(clearInterval(this.runtimeUpdateTimer),this.runtimeUpdateTimer=null),this.shouldWriteLockfile)try{N()}catch{}this.effectivePort=0,this.startedAt=0,this.agentHost.close();for(let[i,o]of this.pendingCommands)o.reject(new Error("server closing")),this.pendingCommands.delete(i);for(let i of this.sims.values())i.ws.close();this.sims.clear(),this.primarySimId=null;let e=this.wss,t=this.httpServer;if(this.wss=null,this.httpServer=null,e)try{e.close()}catch{}if(t)try{t.close()}catch{}}describeSim(e){let t;try{t=e.ws.readyState}catch{t=m.CLOSED}let i=this.getActiveLease(e);return{id:e.id,origin:e.origin,url:e.url,title:e.title,userAgent:e.userAgent,connectedAt:e.connectedAt,lastSeenAt:e.lastSeenAt,lastActiveAt:e.lastActiveAt||void 0,isPrimary:e.id===this.primarySimId,readyState:t===m.OPEN?"open":t===m.CLOSING?"closing":"closed",attachedCliCount:this.getAttachedCliCount(e.id),lockedBy:i?i.cliLabel||i.cliIdentityKey:void 0,lockedByKind:i?i.kind:void 0,lockExpiresAt:i?i.expiresAt:void 0,userFocused:e.userFocused||void 0,kind:e.kind,meta:e.meta}}getActiveLease(e){let t=e.cliLease;return t?Date.now()>=t.expiresAt?(e.cliLease=void 0,null):t:null}tryAcquireLease(e,t,i={}){let o=this.cliIdentityKeyBySocket.get(e)??(()=>{let u=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,u),u})(),n=this.cliLabelBySocket.get(e),s=Date.now(),r=this.getActiveLease(t),c=r&&r.cliIdentityKey===o,l=0;if(r&&!c&&!i.force)return{granted:!1,lease:r,lock:{by:r.cliLabel||r.cliIdentityKey,expiresInMs:Math.max(0,r.expiresAt-s)},bootedCount:0};if(r&&!c&&i.force)for(let[u,p]of this.cliSimBySocket){if(p!==t.id)continue;let h=this.cliIdentityKeyBySocket.get(u);if(h&&h!==o){this.cliSimBySocket.delete(u);try{u.close(1e3,"lease claimed by another cli")}catch{}l++}}let d={kind:"cli",cliIdentityKey:o,cliLabel:n,expiresAt:s+a.CLI_LEASE_TTL_MS};return t.cliLease=d,{granted:!0,lease:d,bootedCount:l}}updateUserFocusLease(e,t){let i=t;e.userFocused!==i&&(e.userFocused=i,this.broadcastSimClientStates())}updateUserActivity(e){let t=this.getActiveLease(e);if(t&&t.kind==="cli")return;let o=Date.now()+a.USER_ACTIVE_LEASE_TTL_MS,n=t&&t.kind==="user-active"?Math.max(t.expiresAt,o):o;e.cliLease={kind:"user-active",cliIdentityKey:"__user-active__",cliLabel:"active user",expiresAt:n},this.broadcastSimClientStates()}ensureCliIdentityKey(e){let t=this.cliIdentityKeyBySocket.get(e);if(t)return t;let i=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,i),i}getOpenSim(e){if(e){let i=this.sims.get(e);return i?.ws.readyState===m.OPEN?i:null}let t=this.primarySimId!=null?this.sims.get(this.primarySimId):null;if(t?.ws.readyState===m.OPEN)return t;for(let i of this.sims.values())if(i.ws.readyState===m.OPEN)return i;return null}async waitForSim(e,t={}){let i=t.attempts??10,o=t.intervalMs??200;for(let n=0;n<i;n++){let s=this.getOpenSim(e);if(s)return s;await new Promise(r=>setTimeout(r,o))}throw new Error(e?`no sim connected with id ${e}`:"no sim connected")}shouldPromoteSim(e){let t=this.primarySimId?this.sims.get(this.primarySimId):null,i=e.origin?.includes(":5173"),o=t?.origin?.includes(":5173");return!t||t.ws.readyState!==m.OPEN||!!i||!o}broadcastSimAssignments(){for(let e of this.sims.values())e.ws.readyState===m.OPEN&&e.ws.send(JSON.stringify({type:"bridge:welcome",simId:e.id,isPrimary:e.id===this.primarySimId}))}broadcastSimClientStates(){for(let e of this.sims.values()){if(e.ws.readyState!==m.OPEN)continue;let t=this.getActiveLease(e),i={type:"bridge:client-state",attachedCliCount:this.getAttachedCliCount(e.id),activeAgentCommandCount:this.getActiveAgentCommandCount(e.id),recentActions:e.recentActions,lockedBy:t?t.cliLabel||t.cliIdentityKey:void 0,lockedByKind:t?t.kind:void 0,lockExpiresAt:t?t.expiresAt:void 0,userFocused:e.userFocused||void 0};e.ws.send(JSON.stringify(i))}}setCliSimTarget(e,t){let i=this.cliSimBySocket.get(e);i!==t&&(this.cliSimBySocket.set(e,t),this.recordSimAction(t,i?"cli switched sims":"cli connected",!1),this.broadcastSimClientStates())}recordSimAction(e,t,i=!0){let o=t?.trim();if(!o)return;let n=this.sims.get(e);if(!n)return;let s=Date.now();n.lastActiveAt=s,n.recentActions=[{label:o,at:s},...n.recentActions.filter(r=>r.label!==o)].slice(0,4),i&&this.broadcastSimClientStates()}describeForwardedCommand(e){switch(e?.type){case"evaluate":return"evaluated page state";case"screenshot":return"captured screenshot";case"tap":return"sent tap event";case"keyboard":return e?.action==="type"?"typed text":"used keyboard";case"tree":return"dumped tree";case"focus":return"focused sim";case"close":return"requested close";default:return typeof e?.type=="string"?e.type:null}}getAttachedCliCount(e){let t=new Set;for(let[i,o]of this.cliSimBySocket){if(o!==e||i.readyState!==m.OPEN)continue;let n=this.cliIdentityKeyBySocket.get(i);t.add(n??`ws-unknown-${t.size}`)}return t.size}getOtherCliIdentityCount(e,t){let i=this.cliIdentityKeyBySocket.get(e),o=new Set;for(let[n,s]of this.cliSimBySocket){if(s!==t||n.readyState!==m.OPEN)continue;let r=this.cliIdentityKeyBySocket.get(n);r&&r===i||o.add(r??`ws-unknown-${o.size}`)}return o.size}getActiveAgentCommandCount(e){let t=0;for(let i of this.pendingCommands.values())i.simId===e&&t++;return t}allocateSimId(){for(;;){let e=this.nextSimNumber.toString(16);if(this.nextSimNumber++,!this.sims.has(e)&&!this.restorableSims.has(e))return e}}tryRestoreSimId(e,t){let i=t?.trim();if(!i||i===e.id)return!1;let o=this.sims.get(i);if(o&&o!==e&&o.ws.readyState===m.OPEN)return!1;let n=this.getRestorableSimState(i),s=e.id;this.sims.delete(s),e.id=i,n&&(e.recentActions=n.recentActions.map(r=>({...r})),e.lastActiveAt=n.lastActiveAt,e.cliLease=n.cliLease?{...n.cliLease}:void 0,this.restorableSims.delete(i)),this.sims.set(e.id,e),this.primarySimId===s&&(this.primarySimId=e.id);for(let[r,c]of this.cliSimBySocket)c===s&&this.cliSimBySocket.set(r,e.id);return!0}rememberDisconnectedSim(e){let t=this.getActiveLease(e);this.restorableSims.set(e.id,{recentActions:e.recentActions.map(i=>({...i})),lastActiveAt:e.lastActiveAt,cliLease:t&&t.kind==="cli"?{...t}:void 0,expiresAt:Date.now()+a.SIM_RECONNECT_TTL_MS}),this.sims.delete(e.id)}getRestorableSimState(e){let t=this.restorableSims.get(e);return t?t.expiresAt<=Date.now()?(this.restorableSims.delete(e),null):(t.cliLease&&t.cliLease.expiresAt<=Date.now()&&(t.cliLease=void 0),t):null}sweepRestorableSims(e=Date.now()){for(let[t,i]of this.restorableSims)if(!(i.expiresAt>e)){this.restorableSims.delete(t);for(let[o,n]of this.cliSimBySocket)n===t&&this.cliSimBySocket.delete(o)}}resetServerState(){this.cliIdleTimer&&(clearInterval(this.cliIdleTimer),this.cliIdleTimer=null),this.wsHeartbeatTimer&&(clearInterval(this.wsHeartbeatTimer),this.wsHeartbeatTimer=null),this.runtimeUpdateTimer&&(clearInterval(this.runtimeUpdateTimer),this.runtimeUpdateTimer=null);let e=this.wss,t=this.httpServer;if(this.wss=null,this.httpServer=null,e)try{e.close()}catch{}if(t)try{t.close()}catch{}}};function De(){let a=process.env.XPC_SERVICE_NAME||"";return!!(a.includes("dev.sootsim.daemon")||a.includes("dev.sootsim.server")||process.env.INVOCATION_ID)}async function ut(a,e={}){(a.includes("--help")||a.includes("-h"))&&(console.log(`
17
+ sootsim server \u2014 run the sootsim bridge daemon in the foreground
18
+
19
+ hosts the WS bridge that CLI commands talk to. once running, any sootsim
20
+ renderer (browser, electron, headless playwright) that connects to port 7668
21
+ becomes drivable from 'sootsim describe', 'sootsim tap', etc.
22
+
23
+ usage:
24
+ sootsim server [options]
25
+
26
+ options:
27
+ --port <n> bridge port (defaults to ${7668})
28
+ --quiet suppress per-connection logging
29
+
30
+ examples:
31
+ sootsim server
32
+ sootsim server --port 7668 --quiet
33
+ `),process.exit(0));let t=a.indexOf("--port"),i=t>=0&&a[t+1]?Number(a[t+1]):e.port??7668;Number.isNaN(i)&&(console.error(` invalid --port value: ${a[t+1]}`),process.exit(1));let o=a.includes("--quiet")||a.includes("-q"),n=$();n&&J(n)&&(console.error(` a sootsim daemon is already running (pid ${n.pid}, port ${n.bridgePort})`),console.error(" stop it with 'sootsim daemon stop' first"),process.exit(1)),T();let s=await X(),r=new O({port:i,writeLockfile:!0,sootbeanOrigin:s}),c=await r.startAsync({silent:o}),l=Date.now(),d=f=>{o||process.stdout.write(`${f}
34
+ `)},u=new Set,p=setInterval(()=>{let f=r.listSims(),y=new Set(f.map(g=>g.id));for(let g of f)if(!u.has(g.id)){let v=g.title||g.url||g.origin||"(unknown)";d(` + ${g.id} ${v}`)}for(let g of u)y.has(g)||d(` - ${g}`);u.clear();for(let g of y)u.add(g)},500);G({event:"daemon_heartbeat",properties:{bridge_port:c,under_daemon:De(),platform:process.platform,subsource:"daemon"}}),q(),d(`sootsim bridge listening on ws://localhost:${c} (runtime http on same port)`),c!==i&&d(` (preferred port ${i} was taken \u2014 fell back to ${c})`),d(" ready for browser, electron, or headless playwright sims to connect"),d(" (ctrl-c to stop)");let h=async f=>{clearInterval(p),d(`
35
+ ${f} received \u2014 shutting down after ${Math.round((Date.now()-l)/1e3)}s`);try{await r.close()}catch{}process.exit(0)};process.on("SIGINT",()=>h("SIGINT")),process.on("SIGTERM",()=>h("SIGTERM")),process.on("SIGHUP",()=>h("SIGHUP")),process.on("exit",()=>{try{r.removeLockfile()}catch{}}),await new Promise(()=>{})}export{ut as runServer};
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a}from"./chunk-UNJTJDZZ.js";import"./chunk-AOYBIMKL.js";import"./chunk-WZDE344I.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";export{a as runSetupRepo};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-DEBXVPIE.js";import*as l from"fs";import*as i from"path";import{fileURLToPath as f}from"url";function g(){try{let s=f(import.meta.resolve("sootsim/package.json"));return i.join(i.dirname(s),"skills")}catch{let s=i.dirname(f(import.meta.url));return i.resolve(s,"../../skills")}}var m=g();function d(s){let n=s.match(/^---\n([\s\S]*?)\n---/);if(!n)return null;let e=n[1],o=e.match(/^name:\s*(.+)$/m),r=e.match(/^description:\s*(.+)$/m);return o?{name:o[1].trim(),description:r?.[1]?.trim()||""}:null}function p(){if(!l.existsSync(m))return[];let s=l.readdirSync(m).filter(e=>e.endsWith(".md")),n=[];for(let e of s){let o=l.readFileSync(i.join(m,e),"utf8"),r=d(o);r&&n.push({...r,filename:e})}return n}function u(s,n){let e=i.join(m,s.filename),o=i.join(n,s.filename);l.copyFileSync(e,o),console.log(` copied ${s.name} \u2192 ${o}`)}async function h(s){if(s.includes("--list")||s.includes("-l")||s.length===0){let t=p();if(t.length===0){console.log(" no skills found");return}console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-N7DDNZTO.js";import*as l from"fs";import*as i from"path";import{fileURLToPath as f}from"url";function g(){try{let s=f(import.meta.resolve("sootsim/package.json"));return i.join(i.dirname(s),"skills")}catch{let s=i.dirname(f(import.meta.url));return i.resolve(s,"../../skills")}}var m=g();function d(s){let n=s.match(/^---\n([\s\S]*?)\n---/);if(!n)return null;let e=n[1],o=e.match(/^name:\s*(.+)$/m),r=e.match(/^description:\s*(.+)$/m);return o?{name:o[1].trim(),description:r?.[1]?.trim()||""}:null}function p(){if(!l.existsSync(m))return[];let s=l.readdirSync(m).filter(e=>e.endsWith(".md")),n=[];for(let e of s){let o=l.readFileSync(i.join(m,e),"utf8"),r=d(o);r&&n.push({...r,filename:e})}return n}function u(s,n){let e=i.join(m,s.filename),o=i.join(n,s.filename);l.copyFileSync(e,o),console.log(` copied ${s.name} \u2192 ${o}`)}async function h(s){if(s.includes("--list")||s.includes("-l")||s.length===0){let t=p();if(t.length===0){console.log(" no skills found");return}console.log(`
3
3
  available skills:
4
4
  `);for(let c of t)console.log(` ${c.name}`),console.log(` ${c.description}
5
5
  `);console.log(" usage: sootsim skills <target-dir> [skill-name...]"),console.log(" example: sootsim skills ./my-project"),console.log(` example: sootsim skills ./my-project debug perf
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{d as _}from"./chunk-EOWN4ZFJ.js";import"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-XWXFUFB2.js";import{E as b,F as v,i as D,y as O,z as x}from"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";import{spawn as N}from"child_process";import{existsSync as F}from"fs";import{WebSocket as B}from"ws";var T=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];var A={reset:"\x1B[0m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",bold:"\x1B[1m"};function k(){return process.stderr.isTTY===!0}function u(t,e){return k()?`${A[t]}${e}${A.reset}`:e}function L(t,e){switch(t){case"pending":return u("dim","\xB7");case"running":return u("cyan",e);case"done":return u("green","\u2713");case"fail":return u("red","\u2717");case"skip":return u("yellow","\u25CB")}}var E=class{constructor(e,s){this.stepper=e;this.data=s}start(e){this.data.state="running",e!==void 0&&(this.data.detail=e),this.stepper.render()}update(e){this.data.detail=e,this.stepper.render()}done(e){this.data.state="done",e!==void 0&&(this.data.detail=e),this.stepper.render()}fail(e){this.data.state="fail",e!==void 0&&(this.data.detail=e),this.stepper.render()}skip(e){this.data.state="skip",e!==void 0&&(this.data.detail=e),this.stepper.render()}},S=class{steps=[];bannerText="";frame=0;timer=null;lastLineCount=0;paused=!1;finished=!1;banner(e){this.bannerText=e}add(e){let s={label:e,state:"pending"};return this.steps.push(s),new E(this,s)}render(){this.paused||this.finished||(this.startSpinner(),this.draw())}pause(){this.paused||(this.paused=!0,this.stopSpinner(),this.eraseRendered(),this.lastLineCount=0)}resume(){this.paused&&(this.paused=!1,this.draw(),this.startSpinner())}finish(){this.finished||(this.finished=!0,this.stopSpinner(),this.draw())}startSpinner(){this.timer||!k()||this.steps.some(e=>e.state==="running")&&(this.timer=setInterval(()=>{this.frame=(this.frame+1)%T.length,this.draw()},80),this.timer?.unref?.())}stopSpinner(){this.timer&&(clearInterval(this.timer),this.timer=null)}draw(){if(!k()){this.drawForwardOnly();return}this.eraseRendered();let e=[];this.bannerText&&(e.push(u("bold",this.bannerText)),e.push(""));let s=T[this.frame],r=Math.max(...this.steps.map(i=>i.label.length),0);for(let i of this.steps){let n=L(i.state,s),c=i.label.padEnd(r),y=i.detail?` ${u("dim",i.detail)}`:"";e.push(` ${n} ${c}${y}`)}process.stderr.write(e.join(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{d as _}from"./chunk-C4AMFYK3.js";import"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-ASSV2FFC.js";import{E as b,F as v,i as D,y as O,z as x}from"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{spawn as N}from"child_process";import{existsSync as F}from"fs";import{WebSocket as B}from"ws";var T=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];var A={reset:"\x1B[0m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",bold:"\x1B[1m"};function k(){return process.stderr.isTTY===!0}function u(t,e){return k()?`${A[t]}${e}${A.reset}`:e}function L(t,e){switch(t){case"pending":return u("dim","\xB7");case"running":return u("cyan",e);case"done":return u("green","\u2713");case"fail":return u("red","\u2717");case"skip":return u("yellow","\u25CB")}}var E=class{constructor(e,s){this.stepper=e;this.data=s}start(e){this.data.state="running",e!==void 0&&(this.data.detail=e),this.stepper.render()}update(e){this.data.detail=e,this.stepper.render()}done(e){this.data.state="done",e!==void 0&&(this.data.detail=e),this.stepper.render()}fail(e){this.data.state="fail",e!==void 0&&(this.data.detail=e),this.stepper.render()}skip(e){this.data.state="skip",e!==void 0&&(this.data.detail=e),this.stepper.render()}},S=class{steps=[];bannerText="";frame=0;timer=null;lastLineCount=0;paused=!1;finished=!1;banner(e){this.bannerText=e}add(e){let s={label:e,state:"pending"};return this.steps.push(s),new E(this,s)}render(){this.paused||this.finished||(this.startSpinner(),this.draw())}pause(){this.paused||(this.paused=!0,this.stopSpinner(),this.eraseRendered(),this.lastLineCount=0)}resume(){this.paused&&(this.paused=!1,this.draw(),this.startSpinner())}finish(){this.finished||(this.finished=!0,this.stopSpinner(),this.draw())}startSpinner(){this.timer||!k()||this.steps.some(e=>e.state==="running")&&(this.timer=setInterval(()=>{this.frame=(this.frame+1)%T.length,this.draw()},80),this.timer?.unref?.())}stopSpinner(){this.timer&&(clearInterval(this.timer),this.timer=null)}draw(){if(!k()){this.drawForwardOnly();return}this.eraseRendered();let e=[];this.bannerText&&(e.push(u("bold",this.bannerText)),e.push(""));let s=T[this.frame],r=Math.max(...this.steps.map(i=>i.label.length),0);for(let i of this.steps){let n=L(i.state,s),c=i.label.padEnd(r),y=i.detail?` ${u("dim",i.detail)}`:"";e.push(` ${n} ${c}${y}`)}process.stderr.write(e.join(`
3
3
  `)+`
4
4
  `),this.lastLineCount=e.length,this.steps.some(i=>i.state==="running")||this.stopSpinner()}bannerPrinted=!1;lastEmitted=new Map;drawForwardOnly(){this.bannerText&&!this.bannerPrinted&&(process.stderr.write(this.bannerText+`
5
5
 
@@ -18,6 +18,6 @@ usage:
18
18
  options:
19
19
  --port <n> bridge port (default: ${7668})
20
20
  --no-open don't open the browser at the end
21
- `);return}O();let s=t.indexOf("--port"),r=s>=0&&t[s+1]?Number(t[s+1]):e.port??7668;Number.isNaN(r)&&(console.error(` invalid --port value: ${t[s+1]}`),process.exit(1));let i=t.includes("--no-open"),n=new S,{IS_BETA:c,BETA_TAGLINE:y}=await import("./beta-CLLKUB5X.js");n.banner(c?`sootsim \u2014 ${y}`:"sootsim \u2014 starting up");let m=n.add("runtime"),d=n.add("server"),$=n.add("ready"),f=n.add("open");n.render();let g=null;try{m.start("checking\u2026");let a=x();if(a&&F(D(a))){g=a;let l=await q();m.done(l?`v${a} \u2014 v${l} available, run \`sootsim upgrade\``:`v${a}`)}else{m.start("downloading engine (~6 MB)\u2026");let{runRuntime:l}=await import("./runtime-FTOQD7QK.js");n.pause(),await l(["install"],{}),n.resume(),g=x(),m.done(g?`v${g}`:"installed")}}catch(a){m.fail(h(a)),n.finish(),process.exit(1)}let o=r,p="standalone";try{d.start("checking\u2026");let a=b();if(v(a)&&await P(a.bridgePort,800))o=a.bridgePort,p="daemon-existing",d.done(`already running (port ${o})`);else if(process.platform==="darwin"||process.platform==="linux"){d.start("registering background daemon\u2026");try{let{daemonInstall:l}=await import("./daemon-HOL7J3BI.js");n.pause(),await l({port:r,force:!0}),n.resume();let R=b();o=v(R)?R.bridgePort:r,p="daemon-installed",d.done(`daemon registered (port ${o})`)}catch(l){n.resume(),d.start("daemon unavailable, starting standalone server\u2026"),o=await C(r),p="standalone",d.done(`standalone (port ${o}) \u2014 ${h(l)}`)}}else d.start("starting standalone server\u2026"),o=await C(r),p="standalone",d.done(`standalone (port ${o})`)}catch(a){d.fail(h(a)),n.finish(),process.exit(1)}try{if($.start("waiting for bridge\u2026"),!await V(o,U))throw new Error(`bridge never came online on port ${o}`);$.done(`ws://localhost:${o}`)}catch(a){$.fail(h(a)),n.finish(),process.exit(1)}let w=`http://localhost:${o}/`;if(i){f.skip(w),n.finish();return}try{f.start("launching browser\u2026"),await _(w),f.done(w)}catch(a){f.skip(`${w} (open it manually \u2014 ${h(a)})`)}n.finish(),p==="standalone"?(console.log(`
21
+ `);return}O();let s=t.indexOf("--port"),r=s>=0&&t[s+1]?Number(t[s+1]):e.port??7668;Number.isNaN(r)&&(console.error(` invalid --port value: ${t[s+1]}`),process.exit(1));let i=t.includes("--no-open"),n=new S,{IS_BETA:c,BETA_TAGLINE:y}=await import("./beta-3S56PNSS.js");n.banner(c?`sootsim \u2014 ${y}`:"sootsim \u2014 starting up");let m=n.add("runtime"),d=n.add("server"),$=n.add("ready"),f=n.add("open");n.render();let g=null;try{m.start("checking\u2026");let a=x();if(a&&F(D(a))){g=a;let l=await q();m.done(l?`v${a} \u2014 v${l} available, run \`sootsim upgrade\``:`v${a}`)}else{m.start("downloading engine (~6 MB)\u2026");let{runRuntime:l}=await import("./runtime-XXNKSGFE.js");n.pause(),await l(["install"],{}),n.resume(),g=x(),m.done(g?`v${g}`:"installed")}}catch(a){m.fail(h(a)),n.finish(),process.exit(1)}let o=r,p="standalone";try{d.start("checking\u2026");let a=b();if(v(a)&&await P(a.bridgePort,800))o=a.bridgePort,p="daemon-existing",d.done(`already running (port ${o})`);else if(process.platform==="darwin"||process.platform==="linux"){d.start("registering background daemon\u2026");try{let{daemonInstall:l}=await import("./daemon-RYSVONEV.js");n.pause(),await l({port:r,force:!0}),n.resume();let R=b();o=v(R)?R.bridgePort:r,p="daemon-installed",d.done(`daemon registered (port ${o})`)}catch(l){n.resume(),d.start("daemon unavailable, starting standalone server\u2026"),o=await C(r),p="standalone",d.done(`standalone (port ${o}) \u2014 ${h(l)}`)}}else d.start("starting standalone server\u2026"),o=await C(r),p="standalone",d.done(`standalone (port ${o})`)}catch(a){d.fail(h(a)),n.finish(),process.exit(1)}try{if($.start("waiting for bridge\u2026"),!await V(o,U))throw new Error(`bridge never came online on port ${o}`);$.done(`ws://localhost:${o}`)}catch(a){$.fail(h(a)),n.finish(),process.exit(1)}let w=`http://localhost:${o}/`;if(i){f.skip(w),n.finish();return}try{f.start("launching browser\u2026"),await _(w),f.done(w)}catch(a){f.skip(`${w} (open it manually \u2014 ${h(a)})`)}n.finish(),p==="standalone"?(console.log(`
22
22
  running in standalone mode. sootsim will exit when this process does.
23
- press ctrl-c to stop.`),await new Promise(()=>{})):p==="daemon-installed"&&console.log("\n installed as a background daemon \u2014 it'll restart on login.\n manage it with `sootsim daemon status / restart / uninstall`.")}function P(t,e){return new Promise(s=>{let r=new B(`ws://127.0.0.1:${t}`,{handshakeTimeout:e}),i=!1,n=c=>{if(!i){i=!0;try{r.close()}catch{}s(c)}};r.once("open",()=>n(!0)),r.once("error",()=>n(!1)),setTimeout(()=>n(!1),e)})}async function V(t,e){let s=Date.now()+e;for(;Date.now()<s;){if(await P(t,500))return!0;await new Promise(r=>setTimeout(r,200))}return!1}async function C(t){let e=W();N(e,["server","--quiet","--port",String(t)],{detached:!0,stdio:"ignore",env:process.env}).unref();let r=Date.now()+I;for(;Date.now()<r;){let i=b();if(v(i))return i.bridgePort;await new Promise(n=>setTimeout(n,150))}if(await P(t,800))return t;throw new Error(`standalone server didn't come online within ${Math.round(I/1e3)}s`)}function W(){let t=process.argv[1];return t&&F(t)?t:"sootsim"}function h(t){return t instanceof Error?t.message:String(t)}async function q(){try{let{checkRuntimeUpToDate:t}=await import("./runtime-delivery-PWLODFCY.js"),e,s=await Promise.race([t(),new Promise(r=>{e=setTimeout(()=>r(null),2500)})]);return e&&clearTimeout(e),s&&s.outdated?s.latest:null}catch{return null}}export{ee as runStart};
23
+ press ctrl-c to stop.`),await new Promise(()=>{})):p==="daemon-installed"&&console.log("\n installed as a background daemon \u2014 it'll restart on login.\n manage it with `sootsim daemon status / restart / uninstall`.")}function P(t,e){return new Promise(s=>{let r=new B(`ws://127.0.0.1:${t}`,{handshakeTimeout:e}),i=!1,n=c=>{if(!i){i=!0;try{r.close()}catch{}s(c)}};r.once("open",()=>n(!0)),r.once("error",()=>n(!1)),setTimeout(()=>n(!1),e)})}async function V(t,e){let s=Date.now()+e;for(;Date.now()<s;){if(await P(t,500))return!0;await new Promise(r=>setTimeout(r,200))}return!1}async function C(t){let e=W();N(e,["server","--quiet","--port",String(t)],{detached:!0,stdio:"ignore",env:process.env}).unref();let r=Date.now()+I;for(;Date.now()<r;){let i=b();if(v(i))return i.bridgePort;await new Promise(n=>setTimeout(n,150))}if(await P(t,800))return t;throw new Error(`standalone server didn't come online within ${Math.round(I/1e3)}s`)}function W(){let t=process.argv[1];return t&&F(t)?t:"sootsim"}function h(t){return t instanceof Error?t.message:String(t)}async function q(){try{let{checkRuntimeUpToDate:t}=await import("./runtime-delivery-JCAY2QVQ.js"),e,s=await Promise.race([t(),new Promise(r=>{e=setTimeout(()=>r(null),2500)})]);return e&&clearTimeout(e),s&&s.outdated?s.latest:null}catch{return null}}export{ee as runStart};
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a}from"./chunk-G2QUPNHI.js";import"./chunk-33R6QMNO.js";import"./chunk-N7DDNZTO.js";export{a as settingsStore};
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a,b}from"./chunk-OPDPXAYA.js";import"./chunk-S3SQITOO.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";export{b as flushCliTelemetry,a as trackCliEvent};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-DEBXVPIE.js";import{spawn as m}from"child_process";import{existsSync as h,readdirSync as w}from"fs";import{resolve as u,dirname as x}from"path";import{fileURLToPath as y}from"url";var d=x(y(import.meta.resolve("sootsim-engine/package.json")));async function v(t,r){let l=t.includes("--flows"),f=t.includes("--detox"),c=t.includes("--parallel"),i=t.includes("--watch"),a=t.find((e,o)=>t[o-1]==="--reporter")||"console";if((t.includes("--help")||t.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-N7DDNZTO.js";import{spawn as m}from"child_process";import{existsSync as h,readdirSync as w}from"fs";import{resolve as u,dirname as x}from"path";import{fileURLToPath as y}from"url";var d=x(y(import.meta.resolve("sootsim-engine/package.json")));async function v(t,r){let l=t.includes("--flows"),f=t.includes("--detox"),c=t.includes("--parallel"),i=t.includes("--watch"),a=t.find((e,o)=>t[o-1]==="--reporter")||"console";if((t.includes("--help")||t.includes("-h"))&&(console.log(`
3
3
  sootsim test \u2014 run tests against sootsim
4
4
 
5
5
  usage:
@@ -26,6 +26,6 @@ examples:
26
26
  notes:
27
27
  playwright is best for smoke and package-local debugging
28
28
  --detox is the preferred parity lane for behavior that should match real RN
29
- `),process.exit(0)),l)await b(t,r,c,a);else if(f){let{runDetox:e}=await import("./detox-EEZPH3DZ.js");await e(t.filter(o=>o!=="--detox"),r)}else await g(t,r)}async function g(t,r){let l=["playwright","test"],f=t.find((e,o)=>t[o-1]==="-t")||t.find((e,o)=>t[o-1]==="--testNamePattern")||t.find((e,o)=>t[o-1]==="--grep");f&&l.push("-g",f),t.includes("--watch")&&l.push("--ui");let c=new Set(["--flows","--detox","--parallel","--watch","--reporter","-t","--testNamePattern","--grep"]);for(let e=0;e<t.length;e++){if(c.has(t[e])){(t[e]==="-t"||t[e]==="--testNamePattern"||t[e]==="--grep"||t[e]==="--reporter")&&e++;continue}l.push(t[e])}console.log(` running: npx ${l.join(" ")}`);let i=m("npx",l,{cwd:d,stdio:"inherit",env:{...process.env}}),a=await new Promise(e=>{i.on("exit",o=>e(o||0))});process.exit(a)}async function b(t,r,l,f){let c=["flows","test/flows","e2e/flows",".maestro","maestro"],i=[];for(let o of c){let s=u(d,o);if(h(s)){let p=w(s).filter(n=>n.endsWith(".yaml")||n.endsWith(".yml"));for(let n of p)i.push(u(s,n))}}for(let o of c){let s=u(process.cwd(),o);if(!s.startsWith(d)&&h(s)){let p=w(s).filter(n=>n.endsWith(".yaml")||n.endsWith(".yml"));for(let n of p)i.push(u(s,n))}}i.length===0&&(console.log(" no flow files found in flows/, test/flows/, or e2e/flows/"),process.exit(0)),console.log(` found ${i.length} flow(s)`);let a=0,e=0;for(let o of i)try{let{runFlowPlayback:s}=await import("./flow-JOW23WNH.js"),p=r.port?`http://localhost:${r.port}`:"http://localhost:5173";if(await s([o,"--url",p,"--new"])!==0){e++;continue}a++}catch{e++}console.log(`
29
+ `),process.exit(0)),l)await b(t,r,c,a);else if(f){let{runDetox:e}=await import("./detox-2UI3EAXA.js");await e(t.filter(o=>o!=="--detox"),r)}else await g(t,r)}async function g(t,r){let l=["playwright","test"],f=t.find((e,o)=>t[o-1]==="-t")||t.find((e,o)=>t[o-1]==="--testNamePattern")||t.find((e,o)=>t[o-1]==="--grep");f&&l.push("-g",f),t.includes("--watch")&&l.push("--ui");let c=new Set(["--flows","--detox","--parallel","--watch","--reporter","-t","--testNamePattern","--grep"]);for(let e=0;e<t.length;e++){if(c.has(t[e])){(t[e]==="-t"||t[e]==="--testNamePattern"||t[e]==="--grep"||t[e]==="--reporter")&&e++;continue}l.push(t[e])}console.log(` running: npx ${l.join(" ")}`);let i=m("npx",l,{cwd:d,stdio:"inherit",env:{...process.env}}),a=await new Promise(e=>{i.on("exit",o=>e(o||0))});process.exit(a)}async function b(t,r,l,f){let c=["flows","test/flows","e2e/flows",".maestro","maestro"],i=[];for(let o of c){let s=u(d,o);if(h(s)){let p=w(s).filter(n=>n.endsWith(".yaml")||n.endsWith(".yml"));for(let n of p)i.push(u(s,n))}}for(let o of c){let s=u(process.cwd(),o);if(!s.startsWith(d)&&h(s)){let p=w(s).filter(n=>n.endsWith(".yaml")||n.endsWith(".yml"));for(let n of p)i.push(u(s,n))}}i.length===0&&(console.log(" no flow files found in flows/, test/flows/, or e2e/flows/"),process.exit(0)),console.log(` found ${i.length} flow(s)`);let a=0,e=0;for(let o of i)try{let{runFlowPlayback:s}=await import("./flow-ECSMFTKS.js"),p=r.port?`http://localhost:${r.port}`:"http://localhost:5173";if(await s([o,"--url",p,"--new"])!==0){e++;continue}a++}catch{e++}console.log(`
30
30
  results: ${a} passed, ${e} failed (${i.length} total)
31
31
  `),process.exit(e>0?1:0)}export{v as runTest};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.40 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as k}from"./chunk-BZED27B2.js";import{c as b,e as v,i as w}from"./chunk-PNGBWMQH.js";import"./chunk-Y66CDFAT.js";import"./chunk-XWXFUFB2.js";import"./chunk-YKEBL6GE.js";import"./chunk-DEBXVPIE.js";async function z(e,o){if((e.includes("--help")||e.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as k}from"./chunk-ECIRRKKE.js";import{c as b,e as v,i as w}from"./chunk-6PLNIOJP.js";import"./chunk-SWHWVYZS.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";async function z(e,o){if((e.includes("--help")||e.includes("-h"))&&(console.log(`
3
3
  sootsim three-mode \u2014 toggle the 3d device stage
4
4
 
5
5
  usage: