sootsim 0.1.230 → 0.1.231
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.
- package/dist-cli/bin.js +4 -4
- package/dist-cli/chunks/{agent-HKBFUUIT.js → agent-AH5KSX6R.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-MKQFZDTK.js → agent-wrapper-6KEN4XWE.js} +2 -2
- package/dist-cli/chunks/{app-fonts-AIFCR65V.js → app-fonts-6KSWFR34.js} +2 -2
- package/dist-cli/chunks/{assert-4TVYMSYB.js → assert-VK3ZNVOE.js} +2 -2
- package/dist-cli/chunks/{auth-WDTNFXFC.js → auth-K5TSJU4G.js} +2 -2
- package/dist-cli/chunks/beta-GG4SKXJH.js +2 -0
- package/dist-cli/chunks/{camera-YHQ4U4DY.js → camera-V4FPK26J.js} +2 -2
- package/dist-cli/chunks/{chunk-XS72QD5F.js → chunk-2D6RUG3E.js} +2 -2
- package/dist-cli/chunks/{chunk-OSKXFSEW.js → chunk-2WAYJJIL.js} +2 -2
- package/dist-cli/chunks/{chunk-UBMWVAU7.js → chunk-4GWETXII.js} +2 -2
- package/dist-cli/chunks/{chunk-TZBAMT3F.js → chunk-4XMWRLHS.js} +1 -1
- package/dist-cli/chunks/{chunk-OHFY7KGT.js → chunk-5GMZJIXF.js} +2 -2
- package/dist-cli/chunks/{chunk-O5Q4WUPP.js → chunk-75XS6H6B.js} +1 -1
- package/dist-cli/chunks/{chunk-FKE2NHET.js → chunk-76NRK5LH.js} +2 -2
- package/dist-cli/chunks/{chunk-4UYMLSFL.js → chunk-77PV2FU7.js} +1 -1
- package/dist-cli/chunks/{chunk-JS4CQN4E.js → chunk-7JZVKKSL.js} +2 -2
- package/dist-cli/chunks/{chunk-H6NIZEHS.js → chunk-ADT2LUD2.js} +1 -1
- package/dist-cli/chunks/{chunk-YDIPQ2J4.js → chunk-AE3BELZM.js} +1 -1
- package/dist-cli/chunks/{chunk-FFW4IVQI.js → chunk-BCUTZMYU.js} +1 -1
- package/dist-cli/chunks/{chunk-5FGADJZA.js → chunk-BUQ4OVPF.js} +1 -1
- package/dist-cli/chunks/{chunk-3SBXDOZZ.js → chunk-D3ZEKF5O.js} +2 -2
- package/dist-cli/chunks/{chunk-THJZT2N5.js → chunk-DATFU5M3.js} +1 -1
- package/dist-cli/chunks/{chunk-ROJCLUO7.js → chunk-DVQS7XW4.js} +1 -1
- package/dist-cli/chunks/{chunk-IZGUWTF7.js → chunk-EYBZL4LO.js} +2 -2
- package/dist-cli/chunks/{chunk-DUBC22VO.js → chunk-FAMEC3A3.js} +2 -2
- package/dist-cli/chunks/{chunk-LULYUY7P.js → chunk-HGP47PYK.js} +2 -2
- package/dist-cli/chunks/{chunk-DBAK72QO.js → chunk-HGXZ5LTS.js} +2 -2
- package/dist-cli/chunks/{chunk-FZFB2OZS.js → chunk-I3NLVJO7.js} +1 -1
- package/dist-cli/chunks/chunk-J3U5NHJ6.js +1 -0
- package/dist-cli/chunks/{chunk-TK7M5F6S.js → chunk-L7STWTUD.js} +1 -1
- package/dist-cli/chunks/{chunk-SIU7QATA.js → chunk-MC32IMHX.js} +1 -1
- package/dist-cli/chunks/{chunk-XEYUPFNF.js → chunk-N5J3NQIA.js} +1 -1
- package/dist-cli/chunks/{chunk-JGGADCQK.js → chunk-NNXM4S37.js} +1 -1
- package/dist-cli/chunks/{chunk-XHPPEQI4.js → chunk-NPCX4IAQ.js} +3 -3
- package/dist-cli/chunks/{chunk-62YYON2N.js → chunk-NQASQSKK.js} +1 -1
- package/dist-cli/chunks/{chunk-CMNUMJPV.js → chunk-NWTNH63K.js} +2 -2
- package/dist-cli/chunks/{chunk-HG4RA7CO.js → chunk-OE6VL4ZA.js} +2 -2
- package/dist-cli/chunks/{chunk-PL6EHWGV.js → chunk-P4X4M3ZU.js} +2 -2
- package/dist-cli/chunks/{chunk-YVEZNXNW.js → chunk-PYYTNSGW.js} +3 -3
- package/dist-cli/chunks/{chunk-TNT7TAX5.js → chunk-R6X7MBYT.js} +3 -3
- package/dist-cli/chunks/{chunk-P4KO4ECO.js → chunk-SB7INNHS.js} +3 -3
- package/dist-cli/chunks/{chunk-4QXQNNAI.js → chunk-SCVX5MDD.js} +1 -1
- package/dist-cli/chunks/{chunk-AHL4WALW.js → chunk-SHSYOZSW.js} +3 -3
- package/dist-cli/chunks/{chunk-RFMY24WX.js → chunk-TDEFREVM.js} +2 -2
- package/dist-cli/chunks/{chunk-3M3HSRK2.js → chunk-V3TEFUGE.js} +1 -1
- package/dist-cli/chunks/{chunk-FLUDPGRE.js → chunk-V7J6D2DS.js} +2 -2
- package/dist-cli/chunks/{chunk-FG52DIVI.js → chunk-VPMLXKVQ.js} +2 -2
- package/dist-cli/chunks/{chunk-EOXIIWK6.js → chunk-VRTTFRVD.js} +2 -2
- package/dist-cli/chunks/{chunk-H3MLNZHE.js → chunk-WAUO3ED2.js} +2 -2
- package/dist-cli/chunks/chunk-XE4BKSAN.js +1 -0
- package/dist-cli/chunks/{chunk-VSMUXKQV.js → chunk-YCAL6N7R.js} +2 -2
- package/dist-cli/chunks/{chunk-C3HOLPYO.js → chunk-ZVHAYHJO.js} +1 -1
- package/dist-cli/chunks/cli-version-JHTQTAP7.js +2 -0
- package/dist-cli/chunks/{compat-TZEY7RZM.js → compat-3ZU42KR4.js} +3 -3
- package/dist-cli/chunks/{config-AQ3GH3FR.js → config-2M6LE7GM.js} +2 -2
- package/dist-cli/chunks/{control-SG5Q4L64.js → control-D7OTV6TJ.js} +2 -2
- package/dist-cli/chunks/daemon-PBEEDQBA.js +2 -0
- package/dist-cli/chunks/{debug-F2IL5OBI.js → debug-JMJNOHJD.js} +3 -3
- package/dist-cli/chunks/{desktop-FLQ565RL.js → desktop-KB2WRU2C.js} +3 -3
- package/dist-cli/chunks/{detox-5TZPMZQF.js → detox-EKPVQJDG.js} +2 -2
- package/dist-cli/chunks/{device-OWNJ37V4.js → device-KWIWZRFU.js} +2 -2
- package/dist-cli/chunks/{diagnose-VLJDPUHV.js → diagnose-GAZMES24.js} +2 -2
- package/dist-cli/chunks/drivers-SQSCB6TD.js +2 -0
- package/dist-cli/chunks/{film-SSXRAQBW.js → film-BZWIEUKD.js} +3 -3
- package/dist-cli/chunks/flow-RWWESFRX.js +2 -0
- package/dist-cli/chunks/help-77N2EWKA.js +2 -0
- package/dist-cli/chunks/{hidden-runtime-alias-ATPNECCP.js → hidden-runtime-alias-Z2W6KIXU.js} +2 -2
- package/dist-cli/chunks/{home-paths-AKSJKOCX.js → home-paths-SEZOWRM2.js} +2 -2
- package/dist-cli/chunks/inspect-DFW3SSR2.js +2 -0
- package/dist-cli/chunks/install-desktop-X4PMZYLV.js +2 -0
- package/dist-cli/chunks/{login-PJOZTLK2.js → login-PSX27F6J.js} +4 -4
- package/dist-cli/chunks/{logout-T5NNOL37.js → logout-NI5E3G7P.js} +2 -2
- package/dist-cli/chunks/{maestro-S5NCE5GL.js → maestro-PPFQ5C56.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-ME5LCEQV.js → maestro-generate-6VJUC7Y2.js} +3 -3
- package/dist-cli/chunks/{mode-Q6O6NBT5.js → mode-7K2ZK3L3.js} +2 -2
- package/dist-cli/chunks/optional-demo-registry-IFCUM2NS.js +2 -0
- package/dist-cli/chunks/{perf-LV4QH54X.js → perf-RBYOKWVM.js} +2 -2
- package/dist-cli/chunks/{record-4LD5JGW7.js → record-LHANNPUS.js} +3 -3
- package/dist-cli/chunks/runtime-QX5QTV2U.js +2 -0
- package/dist-cli/chunks/{screenshot-command-RBMMMK3D.js → screenshot-command-RUDD2TRH.js} +3 -3
- package/dist-cli/chunks/{screenshots-capture-OOR7ORQZ.js → screenshots-capture-VVZYN5RO.js} +2 -2
- package/dist-cli/chunks/{serve-KX3TPFEM.js → serve-AE4VMFKM.js} +7 -7
- package/dist-cli/chunks/{setup-2WNETFVJ.js → setup-W6FVHUX5.js} +3 -3
- package/dist-cli/chunks/{skills-CBY4DMPN.js → skills-T4R4SJEB.js} +2 -2
- package/dist-cli/chunks/{storage-REOZAXUT.js → storage-63GA4N7U.js} +2 -2
- package/dist-cli/chunks/store-RRGC4ZGZ.js +2 -0
- package/dist-cli/chunks/telemetry-FABN6VZA.js +2 -0
- package/dist-cli/chunks/{timeline-MC5I4MP5.js → timeline-BA6UP4YU.js} +2 -2
- package/dist-cli/chunks/{upgrade-XUSLR5J2.js → upgrade-FF3QGMPI.js} +2 -2
- package/dist-cli/chunks/upload-GPOYAPIE.js +2 -0
- package/dist-cli/chunks/{version-XK5CBJM6.js → version-C4LNO3QB.js} +2 -2
- package/dist-cli/chunks/{web-2YGOXHIY.js → web-43QRKPAU.js} +2 -2
- package/dist-cli/chunks/{what-happened-VM2XNZBH.js → what-happened-43KTITUH.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1 -2
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +5 -6
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/scripts/dev-server-scanner.ts +1 -1
- package/src/config.ts +5 -0
- package/src/host/agent-host.ts +1 -2
- package/dist-cli/chunks/beta-P3YYMVNZ.js +0 -2
- package/dist-cli/chunks/chunk-PV37DC5L.js +0 -1
- package/dist-cli/chunks/chunk-SS4WSBTW.js +0 -1
- package/dist-cli/chunks/cli-version-OO7BXUF3.js +0 -2
- package/dist-cli/chunks/daemon-PFFOASPW.js +0 -2
- package/dist-cli/chunks/drivers-IDPIZR54.js +0 -2
- package/dist-cli/chunks/flow-ZD76KVZK.js +0 -2
- package/dist-cli/chunks/help-Y62CJ432.js +0 -2
- package/dist-cli/chunks/inspect-HIGWFAT2.js +0 -2
- package/dist-cli/chunks/install-desktop-7PUIVFVF.js +0 -2
- package/dist-cli/chunks/optional-demo-registry-EPHZ7VHD.js +0 -2
- package/dist-cli/chunks/runtime-3XWIYVBP.js +0 -2
- package/dist-cli/chunks/store-FP73G6TV.js +0 -2
- package/dist-cli/chunks/telemetry-I5DWQXU5.js +0 -2
- package/dist-cli/chunks/upload-5BLST4HU.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{b as k,d as v}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{b as k,d as v}from"./chunk-2D6RUG3E.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";import{exec as L}from"node:child_process";import{randomBytes as R}from"node:crypto";import x from"node:http";var b=process.env.SOOTSIM_AUTH_ORIGIN||"https://contrast.dev",w="http://localhost:3000";async function P(r){if(r)return r;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(`${w}/api/auth/me`)).ok)return w}catch{}return b}function A(){console.log(`
|
|
3
3
|
sootsim login \u2014 sign in so uploads can attach to your account
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -21,6 +21,6 @@ options:
|
|
|
21
21
|
<p style="color:#ccc">${r}</p>
|
|
22
22
|
</div>
|
|
23
23
|
</body>
|
|
24
|
-
</html>`}async function E(r){try{let e=await fetch(`${r.replace(/\/$/,"")}/api/dev-login`,{method:"POST"});if(e.status===403)return{ok:!1,error:"local dev-login unavailable"};if(!e.ok){let u=await e.text().catch(()=>"");return{ok:!1,error:`dev-login ${e.status}: ${u}`}}let t=await e.json();return t.token?{ok:!0,token:t.token,userId:t.user?.id,email:t.email}:{ok:!1,error:"dev-login response missing token"}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"dev-login fetch failed"}}}function G(r){try{let e=new URL(r).hostname.replace(/^\[|\]$/g,"").toLowerCase();return!!(e==="localhost"||/^127(?:\.\d{1,3}){3}$/.test(e)||e==="::1"||e==="0.0.0.0"||e.endsWith(".local")||e.endsWith(".localhost")||e==="host.containers.internal"||e==="host.docker.internal"||e==="host.orb.internal"||e==="host.lima.internal"||e==="fd07:b51a:cc66:f0::fe"||e==="192.168.5.2"||/^192\.168\.(?:64|139)\.1$/.test(e))}catch{return!1}}async function z(r){(r.includes("--help")||r.includes("-h"))&&(A(),process.exit(0));let e=[...r],t=await P(C(e,"--origin"));if(G(t)){console.log(` detected local origin (${t}) \u2014 signing in as dev user`);let o=await E(t);if(o.ok){k({token:o.token,user:o.userId?{id:o.userId,email:o.email}:null,origin:t,source:"cli"});let i=await v(t),d=i?.user?.email||o.email||i?.user?.id||o.userId,{trackCliEvent:a,flushCliTelemetry:f}=await import("./telemetry-
|
|
24
|
+
</html>`}async function E(r){try{let e=await fetch(`${r.replace(/\/$/,"")}/api/dev-login`,{method:"POST"});if(e.status===403)return{ok:!1,error:"local dev-login unavailable"};if(!e.ok){let u=await e.text().catch(()=>"");return{ok:!1,error:`dev-login ${e.status}: ${u}`}}let t=await e.json();return t.token?{ok:!0,token:t.token,userId:t.user?.id,email:t.email}:{ok:!1,error:"dev-login response missing token"}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"dev-login fetch failed"}}}function G(r){try{let e=new URL(r).hostname.replace(/^\[|\]$/g,"").toLowerCase();return!!(e==="localhost"||/^127(?:\.\d{1,3}){3}$/.test(e)||e==="::1"||e==="0.0.0.0"||e.endsWith(".local")||e.endsWith(".localhost")||e==="host.containers.internal"||e==="host.docker.internal"||e==="host.orb.internal"||e==="host.lima.internal"||e==="fd07:b51a:cc66:f0::fe"||e==="192.168.5.2"||/^192\.168\.(?:64|139)\.1$/.test(e))}catch{return!1}}async function z(r){(r.includes("--help")||r.includes("-h"))&&(A(),process.exit(0));let e=[...r],t=await P(C(e,"--origin"));if(G(t)){console.log(` detected local origin (${t}) \u2014 signing in as dev user`);let o=await E(t);if(o.ok){k({token:o.token,user:o.userId?{id:o.userId,email:o.email}:null,origin:t,source:"cli"});let i=await v(t),d=i?.user?.email||o.email||i?.user?.id||o.userId,{trackCliEvent:a,flushCliTelemetry:f}=await import("./telemetry-FABN6VZA.js");a({event:"cli_login_succeeded",identity:{userId:o.userId??i?.user?.id??null},properties:{origin:t,mode:"dev"}}),await f(),console.log(` signed in${d?` as ${d}`:""} (dev)`);return}console.log(` dev-login not available (${o.error}); falling back to browser`)}let u=R(16).toString("hex");{let{trackCliEvent:o,flushCliTelemetry:i}=await import("./telemetry-FABN6VZA.js");o({event:"cli_login_started",properties:{origin:t}}),await i()}let m=300*1e3,s=await new Promise(o=>{let i,d=!1,a=c=>{d||(d=!0,clearTimeout(i),o(c),f.close())},f=x.createServer((c,n)=>{try{let l=new URL(c.url||"/","http://127.0.0.1"),_=l.searchParams.get("state"),y=l.searchParams.get("token"),$=l.searchParams.get("email")||void 0,T=l.searchParams.get("userId")||void 0,p=l.searchParams.get("error");if(_!==u){n.statusCode=404,n.end("not found");return}if(n.setHeader("content-type","text/html; charset=utf-8"),p){n.end(g(`sign-in failed: ${p}`)),a({ok:!1,error:p});return}if(!y){n.end(g("missing token. close this tab and retry `sootsim login`.")),a({ok:!1,error:"missing token"});return}n.end(g("sign-in complete. you can return to the terminal.")),a({ok:!0,token:y,email:$,userId:T})}catch(l){n.statusCode=500,n.end(g("sign-in callback failed. retry `sootsim login`.")),a({ok:!1,error:l instanceof Error?l.message:"callback failed"})}});i=setTimeout(()=>{a({ok:!1,error:"timed out waiting for the browser sign-in (5 minutes). rerun `sootsim login` and complete the github authorize screen if it appears."})},m),f.listen(0,"127.0.0.1",()=>{let c=f.address();if(!c||typeof c=="string"){a({ok:!1,error:"failed to bind callback server"});return}let n=new URL(`${t.replace(/\/$/,"")}/auth/sootsim-cli`);n.searchParams.set("state",u),n.searchParams.set("port",String(c.port)),n.searchParams.set("contrast",t),console.log(" opening browser for sootsim login..."),console.log(" first time here? github will show an authorize screen. approve it to continue."),console.log(" waiting up to 5 minutes for the browser (ctrl+c to cancel)"),console.log(` if nothing opens, visit:
|
|
25
25
|
${n.toString()}
|
|
26
|
-
`),U(n.toString())})});if(!s.ok){let{trackCliEvent:o,flushCliTelemetry:i}=await import("./telemetry-
|
|
26
|
+
`),U(n.toString())})});if(!s.ok){let{trackCliEvent:o,flushCliTelemetry:i}=await import("./telemetry-FABN6VZA.js");o({event:"cli_login_failed",properties:{origin:t,error:s.error}}),await i(),console.error(` login failed: ${s.error}`),process.exit(1)}k({token:s.token,user:s.userId?{id:s.userId,email:s.email}:null,origin:t,source:"cli"});let h=await v(t),I=h?.user?.email||s.email||h?.user?.id||s.userId,{trackCliEvent:O,flushCliTelemetry:S}=await import("./telemetry-FABN6VZA.js");O({event:"cli_login_succeeded",identity:{userId:s.userId??h?.user?.id??null},properties:{origin:t}}),await S(),console.log(` signed in${I?` as ${I}`:""}`)}export{z as runLogin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as r,b as i}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as r,b as i}from"./chunk-VRTTFRVD.js";import{a as t,c as o}from"./chunk-2D6RUG3E.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.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.
|
|
2
|
-
import{c as M,d as E,f as O,g as L,h as R}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{c as M,d as E,f as O,g as L,h as R}from"./chunk-NPCX4IAQ.js";import"./chunk-5GMZJIXF.js";import"./chunk-N5J3NQIA.js";import{c as S}from"./chunk-R6X7MBYT.js";import{a as A,b as $,c as F}from"./chunk-HGXZ5LTS.js";import{a as x}from"./chunk-2WAYJJIL.js";import{a as T}from"./chunk-P4X4M3ZU.js";import{a as k}from"./chunk-TDEFREVM.js";import"./chunk-76NRK5LH.js";import"./chunk-PYYTNSGW.js";import"./chunk-J3U5NHJ6.js";import"./chunk-YCAL6N7R.js";import"./chunk-I3NLVJO7.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import"./chunk-4XMWRLHS.js";import"./chunk-NNXM4S37.js";import"./chunk-D3ZEKF5O.js";import"./chunk-75XS6H6B.js";import"./chunk-FAMEC3A3.js";import"./chunk-MC32IMHX.js";import"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import"./chunk-NWTNH63K.js";import"./chunk-4GWETXII.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-BCUTZMYU.js";import"./chunk-V3TEFUGE.js";import"./chunk-OE6VL4ZA.js";import"./chunk-ADT2LUD2.js";import"./chunk-DVQS7XW4.js";import*as s from"fs";import*as a from"path";var I=[".maestro","maestro"];function P(){console.log(`
|
|
3
3
|
sootsim maestro \u2014 author and run Maestro YAML flows against sootsim
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -89,7 +89,7 @@ appId: com.example.app
|
|
|
89
89
|
- inputText: "secret123"
|
|
90
90
|
- tapOn: "Sign in"
|
|
91
91
|
- assertVisible: "Welcome"
|
|
92
|
-
`,"utf8"),console.log(` + wrote ${e}`),console.log(" next: sootsim maestro test .maestro/login.yaml"),0)}async function z(o,n={}){if(o.includes("--help")||o.includes("-h"))return P(),0;if(o.includes("--list-compat"))return W(),0;let e;try{e=D(o)}catch(r){return console.error(` error: ${r.message}`),1}e=L(e);let t=process.cwd(),i=e[0];if(i==="init")return N(t);if(i==="generate"){let{runMaestroGenerate:r}=await import("./maestro-generate-
|
|
92
|
+
`,"utf8"),console.log(` + wrote ${e}`),console.log(" next: sootsim maestro test .maestro/login.yaml"),0)}async function z(o,n={}){if(o.includes("--help")||o.includes("-h"))return P(),0;if(o.includes("--list-compat"))return W(),0;let e;try{e=D(o)}catch(r){return console.error(` error: ${r.message}`),1}e=L(e);let t=process.cwd(),i=e[0];if(i==="init")return N(t);if(i==="generate"){let{runMaestroGenerate:r}=await import("./maestro-generate-6VJUC7Y2.js");return r(e.slice(1))}if(i==="start"||i==="keep"||i==="good"||i==="end"||i==="validate")return R(e);e=Y(e);let u=null,p;if(i==="test"){let r=e.slice(1).find(f=>!U(f));r?(u=a.resolve(t,r),p=e.slice(1).filter(f=>f!==r)):(u=j(t),p=e.slice(1))}else i&&!U(i)?(u=a.resolve(t,i),p=e.slice(1)):(u=j(t),p=e);if(!u)return console.error(`
|
|
93
93
|
error: no maestro flows found.
|
|
94
94
|
expected one of: ${I.map(r=>`./${r}/`).join(", ")}
|
|
95
95
|
or pass a flow explicitly: sootsim maestro test path/to/flow.yaml
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as O,c as k}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as O,c as k}from"./chunk-HGXZ5LTS.js";import{a as x}from"./chunk-2WAYJJIL.js";import{a as A}from"./chunk-P4X4M3ZU.js";import{a as v,b as T}from"./chunk-TDEFREVM.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import"./chunk-4XMWRLHS.js";import{f as y}from"./chunk-75XS6H6B.js";import{g as b,i as S}from"./chunk-FAMEC3A3.js";import"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";import{mkdtempSync as j,writeFileSync as N}from"fs";import{tmpdir as C}from"os";import{join as E}from"path";var J=process.env.SOOTSIM_TEST_MODEL||"deepseek-v4-flash",_=18e3,V=18e4;function f(e,t){let r=e.indexOf(t);return r>=0?e[r+1]:void 0}function G(e,t){for(let r of t){let o=f(e,r);if(o)return o}}var F=new Set(["--origin","--preview-origin","--public-origin","--preview-public-origin","--owner","--repo","--url","--driver","--sim","--device","--slow","--tail-wait","--remap","--replace"]);function H(e){for(let t=0;t<e.length;t++){let r=e[t];if(r){if(F.has(r)){t+=1;continue}if(!r.startsWith("-"))return{prompt:r,index:t}}}return null}function Y(e,t){return e.filter((r,o)=>o!==t)}async function K(e,t){let r=Y(e,t),o=b(r,{stripBooleanFlags:["--new","--headless","--headed","--electron","--preview-open"],stripValueFlags:[...F]}),i=S(o);try{let s=await y(i,{describe:!0,verbose:!1,filter:"",compact:!0,hideXy:!0}),a=[s.shell?`shell: ${JSON.stringify(s.shell)}`:"",s.keyboard?`keyboard: ${JSON.stringify(s.keyboard)}`:"",typeof s.nodeCount=="number"?`nodes: ${s.nodeCount}`:"",s.tree||""].filter(Boolean).join(`
|
|
3
3
|
`);return a.length>_?a.slice(0,_)+`
|
|
4
4
|
[tree truncated]`:a}finally{i.close()}}var z=`
|
|
5
5
|
You write Maestro-compatible SootSim YAML flows from a user's plain-language test goal.
|
|
@@ -30,5 +30,5 @@ ${t||"[no tree available]"}
|
|
|
30
30
|
|
|
31
31
|
Generate the shortest replayable flow that verifies the goal from this current state.
|
|
32
32
|
`.trim()}function M(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&t.type==="text"?String(t.text??""):"").join(""):""}async function X(e){let t=await fetch(`${e.origin.replace(/\/$/,"")}/api/llm`,{method:"POST",headers:{"content-type":"application/json",authorization:e.authHeader},body:JSON.stringify({modelId:J,context:{systemPrompt:z,messages:[{role:"user",content:W(e.prompt,e.describe),timestamp:Date.now()}]},options:{maxTokens:1800,temperature:.2},threadId:null}),signal:AbortSignal.timeout(V)});if(!t.ok||!t.body){let c=await t.text().catch(()=>"");throw new Error(`/api/llm ${t.status}${c?`: ${c}`:""}`)}let r=t.body.getReader(),o=new TextDecoder,i=[],s="",l="",a=c=>{let d=c.trim();if(!d)return;let n=JSON.parse(d);if(n.type==="text_delta"&&n.delta)i.push(n.delta);else if(n.type==="text_end"&&n.content)s=n.content;else if(n.type==="done")s=M(n.message?.content);else if(n.type==="error")throw new Error(n.error?.errorMessage||M(n.error?.content)||"llm error")};for(;;){let{value:c,done:d}=await r.read();if(d)break;l+=o.decode(c,{stream:!0});let n;for(;(n=l.indexOf(`
|
|
33
|
-
`))>=0;)a(l.slice(0,n)),l=l.slice(n+1)}l+=o.decode(),l.trim()&&a(l);let u=(s||i.join("")).trim();if(!u)throw new Error("llm returned an empty test flow");return u}function q(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/i),r=t?t[1]:e.slice(e.indexOf("{"),e.lastIndexOf("}")+1);return JSON.parse(r)}function P(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Q(e){let t=q(e);if(!P(t))throw new Error("llm did not return a JSON object");let r=typeof t.summary=="string"&&t.summary.trim()?t.summary.trim().slice(0,500):"SootSim generated test",o=t.steps;if(!Array.isArray(o)||o.length===0)throw new Error("llm returned no flow steps");let i=o.map((s,l)=>{if(!P(s))throw new Error(`flow step ${l+1} is not an object`);return s});return{summary:r,steps:i,yamlText:x.stringify(i)}}function Z(e,t,r,o){let i=[r,"--preview","--preview-origin",o,"--billing-kind","test_run"],s=new Set(["--public-origin","--preview-public-origin","--owner","--repo","--url","--driver","--sim","--device","--slow","--tail-wait","--remap","--replace"]),l=new Set(["--new","--headless","--headed","--electron","--preview-open","--no-shell","--shell-only"]);for(let a=0;a<e.length;a++){if(a===t)continue;let u=e[a];if(u==="--origin"||u==="--preview-origin"){a+=1;continue}if(u==="--public-origin"){let c=e[a+1];c&&i.push("--preview-public-origin",c),a+=1;continue}if(s.has(u)){let c=e[a+1];c&&i.push(u,c),a+=1;continue}l.has(u)&&i.push(u)}return i}async function ce(e){let t=H(e);if(!t)return console.error(' usage: sootsim maestro generate "test goal"'),1;let{prompt:r,index:o}=t,i=v();if(!i||i.kind==="github")return console.error(' sootsim maestro generate "<goal>" needs a login or SOOTSIM_API_KEY.'),console.error(" API keys must include preview_upload and llm scopes."),1;let s=T(i),l=await A(G(e,["--origin","--preview-origin"]));console.log(" inspecting current sim\u2026");let a=await K(e,o);console.log(" generating Maestro flow\u2026");let u=await X({prompt:r,describe:a,origin:l,authHeader:s}),c=Q(u),d=j(E(C(),"sootsim-maestro-generate-")),n=E(d,"flow.yaml");N(n,c.yamlText),console.log(` flow: ${n}`);let I=Date.now(),{runFlowPlayback:$,getLastFlowPreviewUploadResult:D,getLastFlowTraceSteps:L}=await import("./flow-
|
|
33
|
+
`))>=0;)a(l.slice(0,n)),l=l.slice(n+1)}l+=o.decode(),l.trim()&&a(l);let u=(s||i.join("")).trim();if(!u)throw new Error("llm returned an empty test flow");return u}function q(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/i),r=t?t[1]:e.slice(e.indexOf("{"),e.lastIndexOf("}")+1);return JSON.parse(r)}function P(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Q(e){let t=q(e);if(!P(t))throw new Error("llm did not return a JSON object");let r=typeof t.summary=="string"&&t.summary.trim()?t.summary.trim().slice(0,500):"SootSim generated test",o=t.steps;if(!Array.isArray(o)||o.length===0)throw new Error("llm returned no flow steps");let i=o.map((s,l)=>{if(!P(s))throw new Error(`flow step ${l+1} is not an object`);return s});return{summary:r,steps:i,yamlText:x.stringify(i)}}function Z(e,t,r,o){let i=[r,"--preview","--preview-origin",o,"--billing-kind","test_run"],s=new Set(["--public-origin","--preview-public-origin","--owner","--repo","--url","--driver","--sim","--device","--slow","--tail-wait","--remap","--replace"]),l=new Set(["--new","--headless","--headed","--electron","--preview-open","--no-shell","--shell-only"]);for(let a=0;a<e.length;a++){if(a===t)continue;let u=e[a];if(u==="--origin"||u==="--preview-origin"){a+=1;continue}if(u==="--public-origin"){let c=e[a+1];c&&i.push("--preview-public-origin",c),a+=1;continue}if(s.has(u)){let c=e[a+1];c&&i.push(u,c),a+=1;continue}l.has(u)&&i.push(u)}return i}async function ce(e){let t=H(e);if(!t)return console.error(' usage: sootsim maestro generate "test goal"'),1;let{prompt:r,index:o}=t,i=v();if(!i||i.kind==="github")return console.error(' sootsim maestro generate "<goal>" needs a login or SOOTSIM_API_KEY.'),console.error(" API keys must include preview_upload and llm scopes."),1;let s=T(i),l=await A(G(e,["--origin","--preview-origin"]));console.log(" inspecting current sim\u2026");let a=await K(e,o);console.log(" generating Maestro flow\u2026");let u=await X({prompt:r,describe:a,origin:l,authHeader:s}),c=Q(u),d=j(E(C(),"sootsim-maestro-generate-")),n=E(d,"flow.yaml");N(n,c.yamlText),console.log(` flow: ${n}`);let I=Date.now(),{runFlowPlayback:$,getLastFlowPreviewUploadResult:D,getLastFlowTraceSteps:L}=await import("./flow-RWWESFRX.js"),U=Z(e,o,n,l),w=await $(U),p=D(),h=L(),B=h.find(R=>R.status==="failure"),g=w===0?"passed":"failed",m=await k({origin:l,kind:"maestro",prompt:r,summary:c.summary,status:g,failureMessage:g==="failed"?B?.error??"flow playback failed":null,previewShareId:p?.shareId??null,owner:f(e,"--owner")??null,repo:f(e,"--repo")??null,durationMs:Date.now()-I,flowYamlSizeBytes:Buffer.byteLength(c.yamlText,"utf8"),...O(h),auth:i});return console.log(`
|
|
34
34
|
result: ${g}`),m&&console.log(` run: ${m.id}`),p?.previewUrl&&console.log(` preview: ${p.previewUrl}`),m?.traceUrl&&console.log(` replay: ${m.traceUrl}`),w}export{ce as runMaestroGenerate};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as s,b as i}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as s,b as i}from"./chunk-WAUO3ED2.js";import"./chunk-FAMEC3A3.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";async function r(e,o){(e.includes("--help")||e.includes("-h"))&&(console.log(`
|
|
3
3
|
sootsim mode screenshot \u2014 toggle the screenshot-mode chrome overlay
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{k as x}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{k as x}from"./chunk-R6X7MBYT.js";import"./chunk-2WAYJJIL.js";import"./chunk-76NRK5LH.js";import"./chunk-PYYTNSGW.js";import"./chunk-J3U5NHJ6.js";import"./chunk-YCAL6N7R.js";import"./chunk-I3NLVJO7.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import"./chunk-4XMWRLHS.js";import"./chunk-NNXM4S37.js";import"./chunk-D3ZEKF5O.js";import"./chunk-75XS6H6B.js";import{g as R,i as N,l as d,m as S}from"./chunk-FAMEC3A3.js";import"./chunk-MC32IMHX.js";import"./chunk-NWTNH63K.js";import"./chunk-4GWETXII.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-BCUTZMYU.js";import"./chunk-V3TEFUGE.js";import"./chunk-OE6VL4ZA.js";import"./chunk-ADT2LUD2.js";import"./chunk-DVQS7XW4.js";import{mkdirSync as W,writeFileSync as A}from"fs";import{dirname as J,resolve as B}from"path";import{WebSocket as E}from"ws";var C=e=>new Promise(o=>setTimeout(o,e)),v=class{ws;nextId=1;pending=new Map;listeners=new Set;ready;constructor(o){this.ws=new E(o,{maxPayload:1<<28}),this.ready=new Promise((r,t)=>{this.ws.once("open",()=>r()),this.ws.once("error",t)}),this.ws.on("message",r=>{let t=JSON.parse(r.toString());if(t.id&&this.pending.has(t.id)){let{res:n,rej:s}=this.pending.get(t.id);this.pending.delete(t.id),t.error?s(new Error(JSON.stringify(t.error))):n(t.result)}else if(t.method)for(let n of this.listeners)n(t.method,t.params)})}waitOpen(){return this.ready}on(o){this.listeners.add(o)}send(o,r={},t){let n=this.nextId++;return new Promise((s,l)=>{this.pending.set(n,{res:s,rej:l}),this.ws.send(JSON.stringify({id:n,method:o,params:r,...t?{sessionId:t}:{}}))})}close(){try{this.ws.close()}catch{}}};async function O(e,o){let r=Number(w(e,"--duration")??"5");if(!Number.isFinite(r)||r<=0)return console.error(" --duration must be a positive number (seconds)"),1;let t=Number(w(e,"--sample-interval")??"0.1"),n=Number(w(e,"--cdp-port")??process.env.SOOTSIM_CDP_PORT??"9222"),s=w(e,"--match")??"/rn/",l=w(e,"--output")??w(e,"-o"),i=B(process.cwd(),l??"/tmp/sootsim.cpuprofile"),a=[];try{a=await(await fetch(`http://localhost:${n}/json/list`)).json()}catch{return U(n),1}let f=a.find(m=>m.type==="page"&&m.url.includes(s));if(!f)return console.error(` no page target matching "${s}" on CDP :${n}`),console.error(` open targets: ${a.map(m=>m.url).join(", ")||"(none)"}`),1;let u=new v(f.webSocketDebuggerUrl);await u.waitOpen();try{let m=new Map;if(u.on((c,p)=>{c==="Target.attachedToTarget"&&p.targetInfo?.type==="worker"&&m.set(p.sessionId,p.targetInfo.url),c==="Target.detachedFromTarget"&&m.delete(p.sessionId)}),await u.send("Target.setAutoAttach",{autoAttach:!0,waitForDebuggerOnStart:!1,flatten:!0}),await C(500),m.size===0)return console.error(" no worker targets attached \u2014 is the app loaded in this tab?"),1;for(let c of m.keys())await u.send("Profiler.enable",{},c),await u.send("Profiler.setSamplingInterval",{interval:t*1e3},c),await u.send("Profiler.start",{},c);console.log(` recording ${r}s across ${m.size} worker(s) \u2014 interact now\u2026`),await C(r*1e3);let b=[];for(let[c,p]of m){let{profile:y}=await u.send("Profiler.stop",{},c);b.push({url:p,profile:y})}return b.sort((c,p)=>p.profile.samples.length-c.profile.samples.length),W(J(i),{recursive:!0}),b.forEach((c,p)=>{let y=p===0?i:i.replace(/(\.[^.]+)?$/,`.worker${p}$1`);if(A(y,JSON.stringify(c.profile)),console.log(` ${P(c.url)}: ${c.profile.samples.length} samples \u2192 ${y}`),o.verbose&&c.profile.samples.length>0)for(let $ of _(c.profile,12))console.log(` ${$.pct.toFixed(1).padStart(5)}% ${$.name} ${$.url}`)}),console.log(" open in chrome devtools \u2192 Performance \u2192 Load profile to inspect."),0}finally{u.close()}}function U(e){console.error(` perf cpu needs a CDP-enabled browser on :${e}.`),console.error(" the tenant worker can't be profiled via the JS Self-Profiler API (F28),"),console.error(" so the sim must expose Chrome remote debugging. easiest path \u2014"),console.error(" open the sim with a CDP port (it stays driveable over the bridge,"),console.error(" so you can scroll/navigate while profiling):"),console.error(""),console.error(` sootsim open <metro-port> --new --driver playwright --cdp-port ${e}`),console.error(` sootsim perf cpu --cdp-port ${e} --match <metro-port>`),console.error(""),console.error(" or launch a standalone CDP Chrome (not bridge-driveable):"),console.error(""),console.error(' "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \\'),console.error(` --remote-debugging-port=${e} --user-data-dir=/tmp/sootsim-cdp \\`),console.error(" --no-sandbox --disable-gpu-sandbox \\"),console.error(" --use-gl=angle --use-angle=metal \\"),console.error(' "http://localhost:5173/rn/<metro-port>" &'),console.error(""),console.error(" override the port with --cdp-port or $SOOTSIM_CDP_PORT.")}function P(e){return e?e.replace(/^https?:\/\/[^/]+/,"").replace(/\?.*$/,"").slice(-50):"(native)"}function _(e,o){let r=e.samples.length||1,t=new Map;for(let n of e.nodes){let s=n.callFrame,l=`${s.functionName||"(anonymous)"}@${P(s.url)}:${s.lineNumber}`,i=t.get(l)??{self:0,name:s.functionName||"(anonymous)",url:`${P(s.url)}:${s.lineNumber}`};i.self+=n.hitCount??0,t.set(l,i)}return[...t.values()].map(n=>({...n,pct:n.self/r*100})).sort((n,s)=>s.self-n.self).slice(0,o)}function w(e,o){let r=e.indexOf(o);if(!(r<0||r===e.length-1))return e[r+1]}function j(){console.log(`
|
|
3
3
|
sootsim perf react \u2014 inspect React component render cost in the tenant worker
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as P}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as P}from"./chunk-5GMZJIXF.js";import"./chunk-P4X4M3ZU.js";import{a as Z,c as ee}from"./chunk-TDEFREVM.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import{d as Y}from"./chunk-4XMWRLHS.js";import{g as b,i as v,j as Q}from"./chunk-FAMEC3A3.js";import"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import"./chunk-L7STWTUD.js";import{c as X}from"./chunk-DATFU5M3.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";import{existsSync as we,mkdirSync as E,readdirSync as he,readFileSync as be,rmSync as J,writeFileSync as N}from"fs";import{homedir as ve,tmpdir as ye}from"os";import{dirname as W,extname as oe,join as C,resolve as Se}from"path";var z=24e4,Re=9e4,$e=3e4;async function D(e,r,o,i){let t=Math.max(2e4,i+$e);try{return await e.send({type:"evaluate",code:r},{timeoutMs:t})}catch(n){let s=n instanceof Error?n.message:String(n);/^command timed out after \d+s$/.test(s)&&(console.error(` ${o} stalled \u2014 the render host did not finish within ${Math.round(t/1e3)}s; it is likely contended or wedged.
|
|
3
3
|
the capture lock auto-releases, so simply retry the recording.
|
|
4
4
|
if it persists, recover the sim with \`sootsim close --sim <id>\`.`),process.exit(1)),/render host not available|already streaming|already recording|lock already held/i.test(s)&&(console.error(` ${o} failed: ${s}
|
|
5
5
|
a prior recording was abandoned and its capture is still
|
|
6
6
|
releasing. the lock self-heals in ~${Math.round((i+2e4)/1e3)}s \u2014 retry then, or recover now with
|
|
7
|
-
\`sootsim close --sim <id>\` and reopen the sim.`),process.exit(1)),console.error(` ${o} failed: ${s}`),process.exit(1)}}var _e=new Set(["--sim","--port","-p","--mode","--duration","--fps","--format","--output","-o","--frames","--max-width","--origin","--owner","--repo"]),xe=new Set(["start","stop","cancel","status","prelude-start","upload"]);function ke(e){for(let r=0;r<e.length;r++){let o=e[r];if(o.startsWith("-")){_e.has(o)&&r++;continue}return xe.has(o)?{name:o,index:r}:null}return null}function Oe(){let e=process.env,r=(e.CONTRAST_BRANCH||e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME||"").trim(),o=(e.CONTRAST_SHA||e.GITHUB_SHA||"").trim(),i=(e.CONTRAST_PR_NUMBER||"").trim(),t=i?Number.parseInt(i,10):Number.NaN,n=(e.CONTRAST_PR_TITLE||"").trim();return{branch:r||void 0,commitSha:o||void 0,pullRequestNumber:Number.isFinite(t)&&t>0?t:void 0,pullRequestTitle:n||void 0}}function re(e){let r=l(e,"--owner")?.trim(),o=l(e,"--repo")?.trim();return(r&&!o||!r&&o)&&(console.error(" --owner and --repo must be provided together"),process.exit(1)),r&&o?{owner:r,repo:o}:null}async function qe(e,r){let o=ke(e);if(o){let d=[...e.slice(0,o.index),...e.slice(o.index+1)];if(o.name==="start"){await Ne(d,r);return}if(o.name==="prelude-start"){await Ce(d,r);return}if(o.name==="upload"){let{runUpload:y}=await import("./upload-
|
|
7
|
+
\`sootsim close --sim <id>\` and reopen the sim.`),process.exit(1)),console.error(` ${o} failed: ${s}`),process.exit(1)}}var _e=new Set(["--sim","--port","-p","--mode","--duration","--fps","--format","--output","-o","--frames","--max-width","--origin","--owner","--repo"]),xe=new Set(["start","stop","cancel","status","prelude-start","upload"]);function ke(e){for(let r=0;r<e.length;r++){let o=e[r];if(o.startsWith("-")){_e.has(o)&&r++;continue}return xe.has(o)?{name:o,index:r}:null}return null}function Oe(){let e=process.env,r=(e.CONTRAST_BRANCH||e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME||"").trim(),o=(e.CONTRAST_SHA||e.GITHUB_SHA||"").trim(),i=(e.CONTRAST_PR_NUMBER||"").trim(),t=i?Number.parseInt(i,10):Number.NaN,n=(e.CONTRAST_PR_TITLE||"").trim();return{branch:r||void 0,commitSha:o||void 0,pullRequestNumber:Number.isFinite(t)&&t>0?t:void 0,pullRequestTitle:n||void 0}}function re(e){let r=l(e,"--owner")?.trim(),o=l(e,"--repo")?.trim();return(r&&!o||!r&&o)&&(console.error(" --owner and --repo must be provided together"),process.exit(1)),r&&o?{owner:r,repo:o}:null}async function qe(e,r){let o=ke(e);if(o){let d=[...e.slice(0,o.index),...e.slice(o.index+1)];if(o.name==="start"){await Ne(d,r);return}if(o.name==="prelude-start"){await Ce(d,r);return}if(o.name==="upload"){let{runUpload:y}=await import("./upload-GPOYAPIE.js");await y(d,r);return}if(o.name==="stop"){await Pe(d,r);return}if(o.name==="cancel"){await Fe(d,r);return}await Ae(d,r);return}let i=b(e,{port:r.port,stripBooleanFlags:["--no-shell","--shell-only","--open"],stripValueFlags:["--mode","--duration","--fps","--format","--output","--frames","--max-width","--origin","--owner","--repo"]}),t=ie(l(e,"--mode")),n=e.includes("--shell-only")?"shell":e.includes("--no-shell")?"tenant":void 0,s=l(e,"--format");s&&!["webm","mp4","gif","png"].includes(s)&&(console.error(` invalid --format "${s}" \u2014 expected webm | mp4 | gif | png`),process.exit(1));let c=l(e,"--output"),a=Number(l(e,"--duration")??"10");(!Number.isFinite(a)||a<=0)&&(console.error(` invalid --duration "${l(e,"--duration")}" \u2014 expected a positive number of seconds`),process.exit(1));let m=600;a>m&&(console.error(` invalid --duration "${l(e,"--duration")}" \u2014 exceeds the ${m}s (10m) maximum`),process.exit(1));let u=Number(l(e,"--fps")??"30"),p=l(e,"--frames");if(p!==void 0){let d=Number(p);(!Number.isInteger(d)||d<=0)&&(console.error(` invalid --frames "${p}" \u2014 expected a positive integer count`),process.exit(1))}let x=e.includes("--open"),j=l(e,"--max-width")?Number(l(e,"--max-width")):void 0,g=Math.max(100,Math.round(a*1e3)),K=l(e,"--origin"),pe=re(e);if(t==="live"||t==="combined"){c&&console.log(` note: --output is ignored for --mode ${t} \u2014 the recording uploads to /preview/<id>`),n&&t==="live"&&console.log(` note: --${n==="shell"?"shell-only":"no-shell"} is ignored for --mode live \u2014 live recordings capture events only, no video`),await P("record",{originOverride:K,allowGitHubAuth:!0});let d=v({...i,commandTimeoutMs:6e4});try{await q(d),await ae(d,t),t==="combined"&&await T(d),await de(d,K,pe);let y=await ce(d,t,t==="combined"?n:void 0);y.ok||(console.error(` start failed: recording store refused to start (${t})`+(y.error?`: ${y.error}`:"")),process.exit(1)),console.log(` recording ${t} for ${a}s`),await new Promise(_=>setTimeout(_,g)),await le(d);let k=await ue(d);me(k,x,t)}finally{d.close()}return}let I=p?Number(p):null,R=Be(s,c,I);x&&console.log(" note: --open is ignored for local-file capture \u2014 it applies to --mode live/combined");let h=v({...i,commandTimeoutMs:6e4});try{if(await te(h),await T(h),R==="png"){let $=I??10,w=U(c,`sootsim-frames-${M()}`);c&&oe(c)&&console.log(` note: --frames writes multiple pngs, so --output "${c}" is a directory \u2014 frame-NNN.png files land inside it`),E(w,{recursive:!0});for(let f of he(w))/^frame-\d+\.png$/.test(f)&&J(C(w,f),{force:!0});console.log(` sampling ${$} frames over ${a}s \u2192 ${w}`);let S=await h.send({type:"evaluate",code:`window.__sootsimRecorder.startFrameCapture({ count: ${$}, durationMs: ${g}${n?`, layers: ${JSON.stringify(n)}`:""} })`});(!S.ok||!S.requestId)&&(console.error(` frame capture start failed: ${S.error??"unknown error"}`),process.exit(1)),await new Promise(f=>setTimeout(f,g));let fe=Date.now()+Math.max(5e3,g),A=null;for(;;){let f=await h.send({type:"evaluate",code:`window.__sootsimRecorder.getFrameCaptureResult(${S.requestId})`});if(f||(console.error(" frame capture result missing"),process.exit(1)),f.done){f.ok||(console.error(` frame capture failed: ${f.error??"unknown error"}`),process.exit(1)),A=f.frames??[];break}Date.now()>=fe&&(console.error(" frame capture timed out"),process.exit(1)),await new Promise(F=>setTimeout(F,100))}A.forEach((f,F)=>{let ge=`${w}/frame-${String(F+1).padStart(3,"0")}.png`;N(ge,Buffer.from(f.data,"base64"))}),console.log(` saved ${A.length} frames`);return}if(R==="gif"){let $=I??Math.max(10,Math.round(a*u/3)),w=U(c,`sootsim-${M()}.gif`);E(W(w),{recursive:!0}),console.log(` encoding gif: ${$} frames over ${a}s \u2192 ${w}`);let S=await D(h,`window.__sootsimRecorder.captureGif({ frames: ${$}, durationMs: ${g}${j?`, maxWidth: ${j}`:""}${n?`, layers: ${JSON.stringify(n)}`:""} })`,"gif encode",g);S||(console.error(" gif capture returned no frames"),process.exit(1)),N(w,Buffer.from(S.data,"base64")),console.log(` saved: ${w} (${G(S.size)})`);return}let d=U(c,`sootsim-${M()}.${R}`);E(W(d),{recursive:!0});let y={format:R,fps:u,durationMs:g};n&&(y.layers=n);let k=await D(h,`window.__sootsimRecorder.start(${JSON.stringify(y)})`,`${R} start`,g);k.ok||(console.error(` start failed: ${k.error??"unknown error"}`),/render host not available|already streaming|already recording|lock already held/i.test(k.error??"")&&console.error(" a prior recording was abandoned and its capture is still\n releasing. retry in ~20s, or recover now with\n `sootsim close --sim <id>` then reopen the sim."),process.exit(1)),console.log(` recording ${R} for ${a}s \u2192 ${d}`),await new Promise($=>setTimeout($,g));let _=await D(h,"window.__sootsimRecorder.stop()",`${R} encode/flush`,g);_.ok||(console.error(` stop failed: ${_.error??"unknown error"}`),process.exit(1)),_.size||(console.error(" recorder returned an empty blob \u2014 nothing written"),process.exit(1)),await ne(h,d),console.log(` saved: ${d} (${G(_.size)})`)}finally{h.close()}}var Ee=6e3;async function L(e,r){try{return await e.send({type:"evaluate",code:r},{timeoutMs:Ee})}catch(o){let i=o instanceof Error?o.message:String(o);throw/^command timed out after \d+s$/.test(i)&&(console.error(" sim did not respond \u2014 it is connected to the bridge but has not\n loaded an app (or its page is unresponsive). run `sootsim list`\n and target a sim with a loaded app via --sim <id>."),process.exit(1)),o}}async function te(e){await L(e,'typeof window.__sootsimRecorder !== "undefined"')||(console.error(" window.__sootsimRecorder missing \u2014 is sootsim engine running in this sim?"),process.exit(1))}async function T(e){let{hidden:r}=await Q(e);r&&(console.error(` refusing to record: the sootsim tab is hidden, so frame capture
|
|
8
8
|
would be throttled to ~1fps and produce a frozen-looking file.
|
|
9
9
|
bring the chrome window to the foreground (un-minimize / switch to
|
|
10
10
|
its tab) or run the recording in headless playwright, then retry.`),process.exit(1))}async function ne(e,r){let o=[],i=0;for(;;){let t=await e.send({type:"evaluate",code:`window.__sootsimRecorder.getBlobBase64({ offset: ${i}, chunk: 2097152 })`});if(!t)throw new Error("no blob available on recorder");if(o.push(Buffer.from(t.data,"base64")),i=t.offset,t.done)break}N(r,Buffer.concat(o))}function l(e,r){let o=e.indexOf(r);if(!(o<0||o===e.length-1))return e[o+1]}function Te(e){if(!e)return;let r=oe(e).toLowerCase().replace(/^\./,"");if(r==="webm"||r==="mp4"||r==="gif")return r;if(r==="png")return"png"}function Be(e,r,o){return e||(o!=null?"png":Te(r)??"webm")}function M(){return new Date().toISOString().replace(/[:T]/g,"-").replace(/\..+/,"")}function Me(){let e=C(ve(),".sootsim","recordings");return E(e,{recursive:!0}),e}function U(e,r){return e?Se(process.cwd(),e):C(Me(),r)}function G(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}function ie(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 H(){return C(ye(),`sootsim-recording-${X()}.json`)}function B(){let e=H();if(!we(e))return null;try{return{mode:"video",...JSON.parse(be(e,"utf8"))}}catch{return J(e,{force:!0}),null}}function Ue(e){N(H(),JSON.stringify(e,null,2))}function O(){J(H(),{force:!0})}function V(e,r){e&&r.simId&&e!==r.simId&&console.log(` note: the tracked recording session is on sim ${r.simId}, not the
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a}from"./chunk-SB7INNHS.js";import"./chunk-7JZVKKSL.js";import"./chunk-FAMEC3A3.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";export{a as runRuntime};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as re,b as ne,f as se}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as re,b as ne,f as se}from"./chunk-NPCX4IAQ.js";import"./chunk-5GMZJIXF.js";import{a as k}from"./chunk-N5J3NQIA.js";import{b as Q}from"./chunk-R6X7MBYT.js";import{a as ee}from"./chunk-2WAYJJIL.js";import"./chunk-P4X4M3ZU.js";import{a as te,b as oe}from"./chunk-TDEFREVM.js";import"./chunk-76NRK5LH.js";import"./chunk-PYYTNSGW.js";import"./chunk-J3U5NHJ6.js";import"./chunk-YCAL6N7R.js";import"./chunk-I3NLVJO7.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import"./chunk-4XMWRLHS.js";import"./chunk-NNXM4S37.js";import"./chunk-D3ZEKF5O.js";import{r as K}from"./chunk-75XS6H6B.js";import{g as A,h as X,i as R,j as J,k as Z,l as M,m as $}from"./chunk-FAMEC3A3.js";import"./chunk-MC32IMHX.js";import"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import"./chunk-NWTNH63K.js";import"./chunk-4GWETXII.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-BCUTZMYU.js";import"./chunk-V3TEFUGE.js";import"./chunk-OE6VL4ZA.js";import{a as x,b as j,c as I,d as L,e as U,f as F,g as E}from"./chunk-ADT2LUD2.js";import"./chunk-DVQS7XW4.js";import{mkdirSync as le,writeFileSync as ie}from"fs";import{dirname as ce,resolve as ue}from"path";async function de(e,t){let o=Ie(e);(o.includes("--help")||o.includes("-h"))&&(console.log(`
|
|
3
3
|
sootsim screenshot \u2014 capture the canvas as a PNG
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -150,4 +150,4 @@ examples:
|
|
|
150
150
|
await new Promise((r) => setTimeout(r, 40))
|
|
151
151
|
}
|
|
152
152
|
return false
|
|
153
|
-
})()`,{acquireLock:!0}))throw new Error("could not enable screenshot mode \u2014 is this a browser sim with the screenshot plugin? (electron has no screenshot mode)")}function wt(e){console.log(` ${e.projectName} \u2014 canvas ${e.canvas} (${e.exportSize.width}\xD7${e.exportSize.height}), device ${e.deviceModel}`);for(let t of e.slides){let o=[t.focused?"focused":t.active?"active":null,t.captured?`captured${t.captureMode==="3d"?" 3d":""}`:"no capture"].filter(Boolean).join(", "),i=t.title?`"${t.title}"`:"(no title)",r=[`bg ${t.bgTop}\u2192${t.bgBottom}`,t.titleColor?`color ${t.titleColor}`:null,t.titleSize?`size ${t.titleSize}`:null,t.titleUnderlay?`underlay ${t.titleUnderlay}`:null,t.titleShadow?`shadow ${t.titleShadow}`:null].filter(Boolean).join(", ");console.log(` ${t.index}. ${i} \u2014 ${r} [${o}]`),t.subtitle&&console.log(` ${t.subtitle}`)}}function yt(e){let t=e.match(/^data:[^;]+;base64,(.+)$/);if(!t)throw new Error("export returned an unexpected payload");return Buffer.from(t[1],"base64")}async function Fe(e,t){if(e.includes("--help")||e.includes("-h")){console.log(pt);return}let{rest:o,values:i,json:r}=ht(e),s=A(o,{port:t.port,commandTimeoutMs:45e3}),n=s.positional[0]??"list",a=ft(s.positional[1]),l=R(s),u=c=>{r?console.log(JSON.stringify(c,null,2)):wt(c)};try{switch(await gt(l),n){case"list":{u(await M(l,"SootSim.bridges.screenshotControl.getState"));break}case"set":{if(a==null)throw new Error("usage: sootsim screenshot slides set <n> --title \u2026 (see --help)");let c={};for(let d of["title","subtitle","bgTop","bgBottom","titleColor","titleSize","titleUnderlay","titleShadow"])i[d]!=null&&(c[d]=i[d]);if(Object.keys(c).length===0)throw new Error("nothing to set \u2014 pass at least one field (see --help)");u(await $(l,"SootSim.bridges.screenshotControl.setSlide",a,c));break}case"add":{u(await $(l,"SootSim.bridges.screenshotControl.addSlide"));break}case"remove":{if(a==null)throw new Error("usage: sootsim screenshot slides remove <n>");u(await $(l,"SootSim.bridges.screenshotControl.removeSlide",a));break}case"focus":{if(a==null)throw new Error("usage: sootsim screenshot slides focus <n>");u(await $(l,"SootSim.bridges.screenshotControl.focusSlide",a));break}case"overview":{u(await $(l,"SootSim.bridges.screenshotControl.overview"));break}case"capture":{let c=await $(l,"SootSim.bridges.screenshotControl.capture",...a!=null?[a]:[]);u(c);break}case"export":{let c=i.out?ut(i.out)?i.out:dt(process.cwd(),i.out):Ne(process.cwd(),"screenshots"),d=await M(l,"SootSim.bridges.screenshotControl.getState"),g=a!=null?d.slides.filter(m=>m.index===a||m.id===a):d.slides.filter(m=>m.captured);if(g.length===0)throw new Error(a!=null?`no slide ${a}`:"no captured slides to export \u2014 capture first");let h=[];for(let m of g){let p=await M(l,"SootSim.bridges.screenshotControl.exportSlide",m.index),y=Ne(c,p.name);at(ct(y),{recursive:!0}),lt(y,yt(p.dataUrl)),h.push(y),console.log(` saved: ${y} (${p.width}\xD7${p.height})`)}r&&console.log(JSON.stringify({written:h},null,2));break}default:throw new Error(`unknown subcommand "${n}" \u2014 see sootsim screenshot slides --help`)}}finally{l.close()}}var bt=new Set(["--sim","--port","-p","--output","-o","--out","--plan","--app","--device","--org","--repo","--api-origin","--branch","--platform","--slides","--shell-origin","--timeout"]),St=new Set(["capture","slides","appstore"]);function Ee(e){for(let t=0;t<e.length;t++){let o=e[t];if(o.startsWith("-")){bt.has(o)&&t++;continue}return St.has(o)?{name:o,index:t}:null}return null}function _(e,t){return[...e.slice(0,t),...e.slice(t+1)]}function xt(e){let t=[];for(let o=0;o<e.length;o++){if(e[o]==="--sim"){o++;continue}t.push(e[o])}return t}async function xo(e,t){let o=Ee(e);if(!o||o.name==="capture"){await de(o?_(e,o.index):e,t);return}if(o.name==="slides"){await Fe(_(e,o.index),t);return}let i=_(e,o.index),r=Ee(i);if(r?.name==="capture")try{let{runScreenshotsCapture:s}=await import("./screenshots-capture-
|
|
153
|
+
})()`,{acquireLock:!0}))throw new Error("could not enable screenshot mode \u2014 is this a browser sim with the screenshot plugin? (electron has no screenshot mode)")}function wt(e){console.log(` ${e.projectName} \u2014 canvas ${e.canvas} (${e.exportSize.width}\xD7${e.exportSize.height}), device ${e.deviceModel}`);for(let t of e.slides){let o=[t.focused?"focused":t.active?"active":null,t.captured?`captured${t.captureMode==="3d"?" 3d":""}`:"no capture"].filter(Boolean).join(", "),i=t.title?`"${t.title}"`:"(no title)",r=[`bg ${t.bgTop}\u2192${t.bgBottom}`,t.titleColor?`color ${t.titleColor}`:null,t.titleSize?`size ${t.titleSize}`:null,t.titleUnderlay?`underlay ${t.titleUnderlay}`:null,t.titleShadow?`shadow ${t.titleShadow}`:null].filter(Boolean).join(", ");console.log(` ${t.index}. ${i} \u2014 ${r} [${o}]`),t.subtitle&&console.log(` ${t.subtitle}`)}}function yt(e){let t=e.match(/^data:[^;]+;base64,(.+)$/);if(!t)throw new Error("export returned an unexpected payload");return Buffer.from(t[1],"base64")}async function Fe(e,t){if(e.includes("--help")||e.includes("-h")){console.log(pt);return}let{rest:o,values:i,json:r}=ht(e),s=A(o,{port:t.port,commandTimeoutMs:45e3}),n=s.positional[0]??"list",a=ft(s.positional[1]),l=R(s),u=c=>{r?console.log(JSON.stringify(c,null,2)):wt(c)};try{switch(await gt(l),n){case"list":{u(await M(l,"SootSim.bridges.screenshotControl.getState"));break}case"set":{if(a==null)throw new Error("usage: sootsim screenshot slides set <n> --title \u2026 (see --help)");let c={};for(let d of["title","subtitle","bgTop","bgBottom","titleColor","titleSize","titleUnderlay","titleShadow"])i[d]!=null&&(c[d]=i[d]);if(Object.keys(c).length===0)throw new Error("nothing to set \u2014 pass at least one field (see --help)");u(await $(l,"SootSim.bridges.screenshotControl.setSlide",a,c));break}case"add":{u(await $(l,"SootSim.bridges.screenshotControl.addSlide"));break}case"remove":{if(a==null)throw new Error("usage: sootsim screenshot slides remove <n>");u(await $(l,"SootSim.bridges.screenshotControl.removeSlide",a));break}case"focus":{if(a==null)throw new Error("usage: sootsim screenshot slides focus <n>");u(await $(l,"SootSim.bridges.screenshotControl.focusSlide",a));break}case"overview":{u(await $(l,"SootSim.bridges.screenshotControl.overview"));break}case"capture":{let c=await $(l,"SootSim.bridges.screenshotControl.capture",...a!=null?[a]:[]);u(c);break}case"export":{let c=i.out?ut(i.out)?i.out:dt(process.cwd(),i.out):Ne(process.cwd(),"screenshots"),d=await M(l,"SootSim.bridges.screenshotControl.getState"),g=a!=null?d.slides.filter(m=>m.index===a||m.id===a):d.slides.filter(m=>m.captured);if(g.length===0)throw new Error(a!=null?`no slide ${a}`:"no captured slides to export \u2014 capture first");let h=[];for(let m of g){let p=await M(l,"SootSim.bridges.screenshotControl.exportSlide",m.index),y=Ne(c,p.name);at(ct(y),{recursive:!0}),lt(y,yt(p.dataUrl)),h.push(y),console.log(` saved: ${y} (${p.width}\xD7${p.height})`)}r&&console.log(JSON.stringify({written:h},null,2));break}default:throw new Error(`unknown subcommand "${n}" \u2014 see sootsim screenshot slides --help`)}}finally{l.close()}}var bt=new Set(["--sim","--port","-p","--output","-o","--out","--plan","--app","--device","--org","--repo","--api-origin","--branch","--platform","--slides","--shell-origin","--timeout"]),St=new Set(["capture","slides","appstore"]);function Ee(e){for(let t=0;t<e.length;t++){let o=e[t];if(o.startsWith("-")){bt.has(o)&&t++;continue}return St.has(o)?{name:o,index:t}:null}return null}function _(e,t){return[...e.slice(0,t),...e.slice(t+1)]}function xt(e){let t=[];for(let o=0;o<e.length;o++){if(e[o]==="--sim"){o++;continue}t.push(e[o])}return t}async function xo(e,t){let o=Ee(e);if(!o||o.name==="capture"){await de(o?_(e,o.index):e,t);return}if(o.name==="slides"){await Fe(_(e,o.index),t);return}let i=_(e,o.index),r=Ee(i);if(r?.name==="capture")try{let{runScreenshotsCapture:s}=await import("./screenshots-capture-VVZYN5RO.js");return await s(xt(_(i,r.index)))}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ERR_MODULE_NOT_FOUND")return console.error("screenshot appstore capture is repo-only tooling \u2014 it needs the sootsim workspace (playwright is not shipped with the published CLI)."),1;throw s}return De(i,t)}export{xo as runScreenshotCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{b as M}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{b as M}from"./chunk-N5J3NQIA.js";import{a as x}from"./chunk-TDEFREVM.js";import"./chunk-2D6RUG3E.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";import{execSync as T}from"node:child_process";import{mkdirSync as D,mkdtempSync as O,rmSync as E,writeFileSync as j}from"node:fs";import{tmpdir as G}from"node:os";import{dirname as q,isAbsolute as B,join as U,resolve as L}from"node:path";import{chromium as W}from"playwright-core";var z=`
|
|
3
3
|
sootsim screenshot appstore capture \u2014 headlessly capture + upload App Store slides
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{b as le,c as H,d as de,e as F,f as ue,h as pe,i as C,j as me,k as he,l as fe,p as ge,s as v,t as Se,u as ye,v as ve,w as be}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{b as le,c as H,d as de,e as F,f as ue,h as pe,i as C,j as me,k as he,l as fe,p as ge,s as v,t as Se,u as ye,v as ve,w as be}from"./chunk-EYBZL4LO.js";import"./chunk-BUQ4OVPF.js";import{a as ce}from"./chunk-P4X4M3ZU.js";import"./chunk-TDEFREVM.js";import{h as ae}from"./chunk-7JZVKKSL.js";import{f as P,g as se}from"./chunk-PYYTNSGW.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import{d as oe}from"./chunk-4XMWRLHS.js";import"./chunk-NNXM4S37.js";import"./chunk-FAMEC3A3.js";import{a as ee,b as te}from"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import{a as re,b as ne}from"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import{E as J,G as E,H as K,I as V,J as D,L as G,M as q,O as z,Q as X,R as Y,S as Z,T as U,U as Q,y as M,z as j}from"./chunk-V3TEFUGE.js";import{a as ie}from"./chunk-NQASQSKK.js";import"./chunk-DVQS7XW4.js";import{spawn as ut}from"child_process";import I from"fs";import{createServer as pt}from"http";import S from"path";import{WebSocket as h,WebSocketServer as mt}from"ws";import Ie from"node:fs";import R from"node:path";import{spawn as Me}from"node:child_process";import De from"node:fs";import Ue from"node:os";import He from"node:path";var we=/^[A-Za-z0-9._:-]{1,160}$/;function W(o){if(!o?.startsWith("AGENTBUS_SESSION:"))return null;let e=o.slice(17).trim();return we.test(e)?e:null}function Ae(o){return we.test(o)}function Fe(o){return typeof o.text=="string"?o.text.trim():""}function We(o){let e=o?.trim();if(e)return e;let t=process.env.AGENTBUS_COMMAND?.trim();if(t)return t;let i=He.join(Ue.homedir(),".local","bin","agentbus");return De.existsSync(i)?i:"agentbus"}async function ke(o){let e=o.sessionId.trim();if(!Ae(e))throw new Error(`invalid agentbus session id: ${e||"<empty>"}`);let t=Fe(o.prompt);if(!t)throw new Error("prompt text is empty");let i=We(o.command),s=o.timeoutMs??15e3;await new Promise((n,a)=>{let r=Me(i,["send",e,t],{stdio:["ignore","ignore","pipe"],env:process.env}),c="",d=setTimeout(()=>{try{r.kill("SIGTERM")}catch{}a(new Error(`agentbus send timed out after ${Math.round(s/1e3)}s`))},s);r.stderr?.setEncoding("utf8"),r.stderr?.on("data",l=>{c.length<4e3&&(c+=String(l))}),r.on("error",l=>{clearTimeout(d),a(l)}),r.on("exit",(l,u)=>{if(clearTimeout(d),l===0){n();return}let p=c.trim();a(new Error(p||`agentbus send exited with ${u?`signal ${u}`:`code ${l??"unknown"}`}`))})})}var x=1;function $e(){return[Number(process.env.VITE_PORT_WEB||process.env.PORT||3e3),Number(process.env.VITE_PORT_ZERO||7849),Number(process.env.VITE_PORT_R2||9500)].filter(o=>Number.isFinite(o)&&o>0)}var _=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 s=t.id;try{let n=await this.dispatch(e,i,t);this.respond(e,s,n)}catch(n){n instanceof v?this.respondError(e,s,n.message,n.code):this.respondError(e,s,n instanceof Error?n.message:String(n))}return!0}async seedOnBoot(){try{await fe()}catch(e){process.stderr.write(`[sootsim-agent] seedFromDemoAppRegistry failed: ${e instanceof Error?e.message:String(e)}
|
|
3
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 F();case"agent:upsert-project":return H(i.input??{});case"agent:delete-project":return pe(String(i.projectId)),{ok:!0};case"agent:auto-attach-for-url":return this.autoAttachForUrl(i.input??{});case"agent:list-sessions":return me(i.projectId?String(i.projectId):void 0);case"agent:start-session":return this.doStartSession(i.input??{});case"agent:send-claimed-prompt":return this.sendClaimedPrompt(i);case"agent:send-prompt":{let n=String(i.sessionId),a=C(n);if(!a)throw new v("NO_SESSION",`no session: ${n}`);let r=this.normalizePromptEnvelope(i);return await ye(n,r),this.notePromptAccepted(n,r,a.status==="working")}case"agent:end-session":this.dropSessionFanout(String(i.sessionId)),await ve(String(i.sessionId));let s=C(String(i.sessionId));return s&&this.broadcastSessionStatus(s),{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 v("UNKNOWN_AGENT_MSG",`unknown agent message: ${t}`)}}async sendClaimedPrompt(e){let t=typeof e.simId=="string"?e.simId.trim():"";if(!t)throw new v("NO_SIM","agent:send-claimed-prompt requires simId");let i=this.opts.resolveCliLease?.(t)??null;if(!i||i.kind!=="cli"||i.expiresAt<=Date.now())throw new v("NO_CLAIM",`sim ${t} has no active CLI claim`);let s=W(i.cliIdentityKey);if(!s)throw new v("UNSUPPORTED_CLAIM",`sim ${t} is claimed by a CLI identity that is not promptable`);return await ke({sessionId:s,prompt:this.normalizePromptEnvelope(e)}),{ok:!0,routed:"agentbus",sessionId:s}}async doStartSession(e){if(!de(e.projectId))throw new v("NO_PROJECT",`no project: ${e.projectId}`);let i=await Se(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 s=this.opts.getExcludePorts?.()??$e(),a=(await P({excludePorts:s})).find(l=>String(l.port)===i);if(!a||!a.cwd)return{project:null};let r=F().find(l=>l.cwd===a.cwd)??null,c=Array.from(new Set([...r?.knownBundleUrls??[],a.bundleUrl,t]));return{project:H({cwd:a.cwd,name:a.projectName??R.basename(a.cwd),preferredProvider:e.provider??r?.preferredProvider,sourceRoots:r?.sourceRoots??[a.cwd],knownBundleUrls:c,framework:r?.framework??je(a.framework),bundleId:a.bundleId??r?.bundleId})}}getTranscript(e){let t=ge(e);return Ie.existsSync(t)?Ie.readFileSync(t,"utf8"):{error:"transcript not found",code:"NO_TRANSCRIPT"}}getPaths(){let e=le();return{userDataDir:e,storeFile:R.join(e,"attached-projects.json"),sessionsDir:R.join(e,"sessions"),transcriptsDir:R.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 s=this.subscriptions.get(t);if(s)return s.refCount++,{ok:!0,refCount:s.refCount};let n=be(t,a=>{let r=this.coalescePromptEcho(t,a);if(r&&(this.applySessionEvent(t,r),this.fanOutEvent(t,r)),a.type==="turn-completed"){let c=C(t);if(c)try{ue(c.projectId,{usd:a.costUsd,ts:a.ts})}catch(d){process.stderr.write(`[sootsim-agent] recordTurnTelemetry failed: ${d instanceof Error?d.message:String(d)}
|
|
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 s=Date.now(),n=this.pendingPromptEchoes.get(e)??[];n.push({sentAt:s}),this.pendingPromptEchoes.set(e,n);let a=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,a);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:s}),{ok:!0,queued:a>1,pendingTurns:a,queueDepth:Math.max(0,a-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){he(e,t);let i=C(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[s,n]of this.sessionsBySocket)if(n.has(e)&&s.readyState===
|
|
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 s=Date.now(),n=this.pendingPromptEchoes.get(e)??[];n.push({sentAt:s}),this.pendingPromptEchoes.set(e,n);let a=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,a);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:s}),{ok:!0,queued:a>1,pendingTurns:a,queueDepth:Math.max(0,a-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){he(e,t);let i=C(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[s,n]of this.sessionsBySocket)if(n.has(e)&&s.readyState===x)try{s.send(i)}catch{}}broadcastSessionStatus(e){let t=JSON.stringify({type:"agent:session-status",session:e});for(let i of this.allSockets)if(i.readyState===x)try{i.send(t)}catch{}}respond(e,t,i){if(e.readyState===x)try{e.send(JSON.stringify({id:t,result:i}))}catch{}}respondError(e,t,i,s){if(e.readyState===x)try{e.send(JSON.stringify({id:t,error:i,...s?{code:s}:{}}))}catch{}}};function je(o){return o==="expo"?"expo":o==="one"||o==="vxrn"?"one":"unknown"}import Ve from"http";import Ge from"https";var $="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",Je=[{hostSuffix:"uniswap.org",headers:{origin:"https://app.uniswap.org",referer:"https://app.uniswap.org/"},suppressBrowserUserAgent:!0}];function Ke(o){let e=o.toLowerCase();for(let t of Je)if(e===t.hostSuffix||e.endsWith(`.${t.hostSuffix}`))return t}function Ce(o){let e=Ke(o.hostname);return{"accept-encoding":"identity",...e?.suppressBrowserUserAgent?{}:{"user-agent":$},...e?.headers}}var qe=new Set(["host","origin","referer","user-agent","accept-encoding","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"]),ze={"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"},Xe=new Set(["host","origin","referer","sec-fetch-site","sec-fetch-mode","sec-fetch-dest"]);function T(o){for(let[e,t]of Object.entries(ze))o.setHeader(e,t)}function Ye(o,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 o.includes("stored-in-.env.local")?`${n} | upstream url still contains placeholder env values`:n}function Ze(o){let t=(Array.isArray(o)?o[0]:o)?.split(";",1)[0]?.trim().toLowerCase();return t?t.startsWith("text/")||t==="application/json"||t.endsWith("+json")||t==="application/x-www-form-urlencoded"||t==="application/xml"||t.endsWith("+xml")||t==="application/javascript"||t==="application/graphql":!1}function Qe(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(qe.has(i.toLowerCase())||(t[i]=Array.isArray(s)?s.join(", "):s));return Object.assign(t,e?Ce(e):{"user-agent":$}),t}function et(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(Xe.has(i.toLowerCase())||(t[i]=s));return t.host=e.host,t.origin=e.origin,t.referer=`${e.origin}/`,t}function Te(o){return o?.startsWith("/__fetch-proxy?")||o?.startsWith("/__proxy?")||!1}function Ee(o){return o?!!(o.startsWith("/__app-api?")||o.startsWith("/__app-api/")):!1}async function Pe(o,e){if(o.method==="OPTIONS"){T(e),e.writeHead(204),e.end();return}let i=new URLSearchParams((o.url||"").split("?")[1]||"").get("url");if(!i){T(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("missing url param");return}let s;try{s=new URL(i)}catch{T(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("invalid url param");return}let n=Qe(o.headers,s),a;if(o.method!=="GET"&&o.method!=="HEAD"){let l=[];for await(let u of o)l.push(Buffer.isBuffer(u)?u:Buffer.from(u));if(l.length>0){let u=Buffer.concat(l);a=Ze(o.headers["content-type"])?u.toString("utf8"):u}}let r;try{r=await fetch(s.href,{method:o.method,headers:n,body:a,redirect:"follow"})}catch(l){T(e),e.writeHead(502,{"Content-Type":"text/plain"}),e.end(`fetch proxy error: ${Ye(s.href,l)}`);return}r.headers.forEach((l,u)=>{let p=u.toLowerCase();p==="content-encoding"||p==="transfer-encoding"||p==="content-length"||p==="set-cookie"||p.startsWith("access-control-")||e.setHeader(u,l)}),T(e);let c=r.headers.getSetCookie?.()??[];c.length>0&&e.setHeader("x-sootsim-set-cookie",c.join(", ")),e.statusCode=r.status;let d=Buffer.from(await r.arrayBuffer());e.end(d)}function Re(o,e){let t=o.url||"",i="",s="";if(t.startsWith("/__app-api?")){let d=new URL(t,"http://sootsim.local");i=d.searchParams.get("path")||"",s=d.searchParams.get("origin")?.trim()||""}else if(t.startsWith("/__app-api/"))i=t.slice(10);else return!1;if(!s)return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: missing origin query param"),!0;if(o.method==="OPTIONS")return e.writeHead(204,{"Access-Control-Allow-Origin":o.headers.origin||"*","Access-Control-Allow-Methods":"GET,POST,PUT,PATCH,DELETE,OPTIONS","Access-Control-Allow-Headers":o.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,s)}catch{return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: invalid origin or path"),!0}let a=n.protocol==="https:"?Ge:Ve,r=et(o.headers,n),c=a.request({hostname:n.hostname,port:n.port||(n.protocol==="https:"?443:80),path:n.pathname+n.search,method:o.method,headers:r},d=>{let l=Object.keys(d.headers).filter(u=>{let p=u.toLowerCase();return!p.startsWith("access-control-")&&p!=="set-cookie"}).join(", ");e.writeHead(d.statusCode??502,{...d.headers,"access-control-allow-origin":o.headers.origin||"*","access-control-allow-credentials":"true","access-control-expose-headers":l}),d.pipe(e)});return c.on("error",d=>{e.statusCode=502,e.end(`app proxy error: ${d.message}`)}),o.pipe(c),!0}import{WebSocket as k,WebSocketServer as tt}from"ws";var it="/__websocket-proxy",rt=new Set(["host","connection","upgrade","transfer-encoding","content-length","sec-websocket-accept","sec-websocket-extensions","sec-websocket-key","sec-websocket-protocol","sec-websocket-version"]);function A(o,e,t){try{o.write(`HTTP/1.1 ${e} ${t}\r
|
|
5
5
|
Connection: close\r
|
|
6
6
|
Content-Type: text/plain\r
|
|
7
7
|
Content-Length: ${t.length}\r
|
|
8
8
|
\r
|
|
9
|
-
${t}`)}catch{}o.destroy()}function nt(o){let e=o.headers.origin,t=o.headers.host;if(!e||!t)return!1;try{return new URL(e).host===t}catch{return!1}}function st(o){if(!o)return{};let e=o.replace(/-/g,"+").replace(/_/g,"/"),t=e+"=".repeat((4-e.length%4)%4),i=JSON.parse(Buffer.from(t,"base64").toString("utf8"));if(!i||typeof i!="object"||Array.isArray(i))return{};let s={};for(let[n,a]of Object.entries(i))a!=null&&(rt.has(n.toLowerCase())||(s[n]=Array.isArray(a)?a.join(", "):String(a)));return s}function ot(o){let e=new URL(o.href);return e.protocol=o.protocol==="wss:"?"https:":"http:",e.origin}function at(o){let e=o.headers["sec-websocket-protocol"];return(Array.isArray(e)?e.join(","):e||"").split(",").map(i=>i.trim()).filter(Boolean)}function O(o,e,t){if(!(o.readyState===k.CLOSED||o.readyState===k.CLOSING))try{o.close(e,t)}catch{o.terminate()}}function ct(o,e){let t=!1,i=(s,n,a,r)=>{t||(t=!0,O(n,a,r.toString()),s.readyState===k.OPEN&&O(s,a,r.toString()))};o.on("message",(s,n)=>{e.readyState===k.OPEN&&e.send(s,{binary:n})}),e.on("message",(s,n)=>{o.readyState===k.OPEN&&o.send(s,{binary:n})}),o.on("close",(s,n)=>i(o,e,s,n)),e.on("close",(s,n)=>i(e,o,s,n)),o.on("error",()=>O(e,1011,"proxy client error")),e.on("error",()=>O(o,1011,"upstream websocket error"))}function lt(o,e,t){let i={...t};return Object.keys(i).some(s=>s.toLowerCase()==="origin")||(i.origin=ot(o)),new k(o.href,e,{headers:i})}function dt(o){if(!o)return!1;try{return new URL(o,"http://localhost").pathname===it}catch{return!1}}function
|
|
9
|
+
${t}`)}catch{}o.destroy()}function nt(o){let e=o.headers.origin,t=o.headers.host;if(!e||!t)return!1;try{return new URL(e).host===t}catch{return!1}}function st(o){if(!o)return{};let e=o.replace(/-/g,"+").replace(/_/g,"/"),t=e+"=".repeat((4-e.length%4)%4),i=JSON.parse(Buffer.from(t,"base64").toString("utf8"));if(!i||typeof i!="object"||Array.isArray(i))return{};let s={};for(let[n,a]of Object.entries(i))a!=null&&(rt.has(n.toLowerCase())||(s[n]=Array.isArray(a)?a.join(", "):String(a)));return s}function ot(o){let e=new URL(o.href);return e.protocol=o.protocol==="wss:"?"https:":"http:",e.origin}function at(o){let e=o.headers["sec-websocket-protocol"];return(Array.isArray(e)?e.join(","):e||"").split(",").map(i=>i.trim()).filter(Boolean)}function O(o,e,t){if(!(o.readyState===k.CLOSED||o.readyState===k.CLOSING))try{o.close(e,t)}catch{o.terminate()}}function ct(o,e){let t=!1,i=(s,n,a,r)=>{t||(t=!0,O(n,a,r.toString()),s.readyState===k.OPEN&&O(s,a,r.toString()))};o.on("message",(s,n)=>{e.readyState===k.OPEN&&e.send(s,{binary:n})}),e.on("message",(s,n)=>{o.readyState===k.OPEN&&o.send(s,{binary:n})}),o.on("close",(s,n)=>i(o,e,s,n)),e.on("close",(s,n)=>i(e,o,s,n)),o.on("error",()=>O(e,1011,"proxy client error")),e.on("error",()=>O(o,1011,"upstream websocket error"))}function lt(o,e,t){let i={...t};return Object.keys(i).some(s=>s.toLowerCase()==="origin")||(i.origin=ot(o)),new k(o.href,e,{headers:i})}function dt(o){if(!o)return!1;try{return new URL(o,"http://localhost").pathname===it}catch{return!1}}function xe(o,e,t){if(!dt(o.url))return!1;if(!nt(o))return A(e,403,"forbidden websocket proxy origin"),!0;let i,s;try{let c=new URL(o.url||"/","http://localhost"),d=c.searchParams.get("url");if(!d)return A(e,400,"missing websocket proxy url"),!0;if(i=new URL(d),i.protocol!=="ws:"&&i.protocol!=="wss:")return A(e,400,"invalid websocket proxy protocol"),!0;s=st(c.searchParams.get("headers"))}catch{return A(e,400,"invalid websocket proxy request"),!0}let n=at(o),a=lt(i,n,s),r=!1;return e.once("close",()=>{r||a.terminate()}),a.once("open",()=>{if(r)return;r=!0;let c=a.protocol;new tt({noServer:!0,clientTracking:!1,handleProtocols(l){return c||l.values().next().value||!1}}).handleUpgrade(o,e,t,l=>{ct(l,a)})}),a.once("error",()=>{r||(r=!0,A(e,502,"upstream websocket error"))}),a.once("close",()=>{r||(r=!0,A(e,502,"upstream websocket closed"))}),!0}var ht="require-corp",ft=new Set(["tap","keyboard"]),gt=2e3,St=1e3;function yt(o){return!o||typeof o.type!="string"?!1:o.acquireLock===!0?!0:o.readOnly===!0?!1:ft.has(o.type)}var _e=5e3,vt=3600*1e3,bt="SOOTSIM_RUNTIME_UPDATE_INTERVAL_MS",wt={".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 Oe(o,e,t){let i;try{let c=M();i=JSON.stringify(c)}catch{i="{}"}let s=e>0?`window.__sootsimBridgePort=${e};`:"",n=t?`window.__sootsimContrastOrigin=${JSON.stringify(t)};`:"",a=`<script>window.__sootsimSharedConfig=${i};`+s+n+`window.__sootsimCliVersion=${JSON.stringify(ie())};</script>`,r=o.toString("utf8");return r.includes("<head>")?r.replace("<head>",`<head>${a}`):r.includes("</head>")?r.replace("</head>",a+"</head>"):r.includes("</body>")?r.replace("</body>",a+"</body>"):a+r}function Le(o){typeof o=="object"&&o!==null&&"unref"in o&&o.unref()}var L=class o{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;static SIM_IDLE_REAP_TTL_MS=30*6e4;static AUTOMATION_SIM_IDLE_REAP_TTL_MS=10*6e4;static MAX_CONCURRENT_AUTOMATION_SIMS=6;static AUTOMATION_SIM_ACTIVE_GRACE_MS=6e4;preferredPort;portFallbackCount;simIdleReapTtlMs;automationSimIdleReapTtlMs;maxConcurrentAutomationSims;automationSimActiveGraceMs;shouldWriteLockfile;shouldWriteDevLockfile;getShellPort;contrastOrigin=null;effectivePort=0;startedAt=0;heartbeatTimer=null;devHeartbeatTimer=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.shouldWriteDevLockfile=e.writeDevLockfile===!0,this.getShellPort=e.getShellPort??null,this.portFallbackCount=Math.max(1,e.portFallbackCount??10),this.openUrlHandler=e.openUrl,this.agentHost=new _({getExcludePorts:e.agentScanExcludes,resolveCliLease:t=>{let i=this.sims.get(t),s=i?this.getActiveLease(i):null;return s?{kind:s.kind,cliIdentityKey:s.cliIdentityKey,expiresAt:s.expiresAt}:null}}),this.contrastOrigin=e.contrastOrigin?.replace(/\/$/,"")||null,this.simIdleReapTtlMs=e.simIdleReapTtlMs??o.SIM_IDLE_REAP_TTL_MS,this.automationSimIdleReapTtlMs=e.automationSimIdleReapTtlMs??o.AUTOMATION_SIM_IDLE_REAP_TTL_MS,this.maxConcurrentAutomationSims=e.maxConcurrentAutomationSims??o.MAX_CONCURRENT_AUTOMATION_SIMS,this.automationSimActiveGraceMs=e.automationSimActiveGraceMs??o.AUTOMATION_SIM_ACTIVE_GRACE_MS}getAgentHost(){return this.agentHost}reapIdleSimsForTest(e=Date.now()){this.reapIdleSims(e)}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)
|
|
10
10
|
`),this.afterBind(),i}catch(s){if(s?.code!=="EADDRINUSE")throw s;e?.silent||process.stderr.write(`ws bridge port ${i} already in use, trying ${i+1}
|
|
11
11
|
`)}}throw new Error(`could not bind ws bridge after ${this.portFallbackCount} attempts starting at ${this.preferredPort}`)}bindOnce(e,t){return new Promise((i,s)=>{let n=pt((c,d)=>this.handleHttpRequest(c,d)),a=!1,r=c=>{if(!a){a=!0;try{n.close()}catch{}this.httpServer=null,this.wss=null,s(c)}};n.once("error",r),n.listen(e,"127.0.0.1",()=>{a||(a=!0,n.removeListener("error",r),n.on("error",c=>{process.stderr.write(`ws bridge http error: ${String(c)}
|
|
12
|
-
`)}),this.httpServer=n,this.wss=new mt({noServer:!0}),this.wireWebSocketServer(),n.on("upgrade",(c,d,l)=>{
|
|
12
|
+
`)}),this.httpServer=n,this.wss=new mt({noServer:!0}),this.wireWebSocketServer(),n.on("upgrade",(c,d,l)=>{xe(c,d,l)||this.wss?.handleUpgrade(c,d,l,u=>{this.wss?.emit("connection",u,c)})}),i())})})}wireWebSocketServer(){this.wss&&this.wss.on("connection",(e,t)=>{let i=t.headers.origin,s=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),s==="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 a=`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,a)}e.on("message",a=>{let r;try{r=JSON.parse(a.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=D(),d=this.getActiveRuntime(),l={type:"runtime:list:ok",id:r.id,installed:c,active:d.version,activeRuntimeDir:d.runtimeDir};try{e.send(JSON.stringify(l))}catch{}return}if(r.type==="runtime:use"){let c=typeof r.version=="string"?r.version:"";if(!D().includes(c)){try{e.send(JSON.stringify({type:"runtime:use:error",id:r.id,error:`runtime ${c||"(missing)"} is not installed`}))}catch{}return}let l=this.setActiveRuntime(c);try{e.send(JSON.stringify({type:"runtime:use:ok",id:r.id,version:l.version,runtimeDir:l.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(s==="sim"&&r.type==="bridge:hello"&&n&&!n.url){let c=n.id;this.sims.delete(c),this.primarySimId===c&&(this.primarySimId=this.getOpenSim()?.id??null),n=null,s="cli",this.cliIdentityKeyBySocket.set(e,`ws-${this.nextCliFallbackId++}`),this.broadcastSimAssignments(),this.broadcastSimClientStates()}if(s==="sim"){if(n&&(n.lastSeenAt=Date.now()),r.type==="bridge:register"&&n){let l=r,u=this.tryRestoreSimId(n,l.simId);n.url=l.url,n.title=l.title,n.userAgent=l.userAgent,typeof l.kind=="string"&&l.kind.trim()&&(n.kind=l.kind.trim()),l.meta&&typeof l.meta=="object"&&(n.meta=l.meta);let p=this.primarySimId!==n.id&&this.shouldPromoteSim(n);p&&(this.primarySimId=n.id),(u||p)&&(this.broadcastSimAssignments(),this.broadcastSimClientStates());return}if(r.type==="bridge:user-focus-state"&&n){let l=r;this.updateUserFocusLease(n,l);return}if(r.type==="bridge:user-interact"&&n){this.updateUserActivity(n);return}if(r.type==="bridge:write-shared-config"){let l=r.patch&&typeof r.patch=="object"?r.patch:null;if(!l)return;let u;try{u=j(l)}catch(m){process.stderr.write(`sootsim: bridge:write-shared-config failed: ${m instanceof Error?m.message:String(m)}
|
|
13
13
|
`);return}let p=JSON.stringify({type:"bridge:shared-config-changed",config:u});for(let m of this.sims.values())if(m.ws.readyState===h.OPEN)try{m.ws.send(p)}catch{}return}if(r.type==="bridge:open-path"){let l=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;l&&this.openPathInEditor(l,u,p);return}if(r.type==="bridge:boot-clients"&&n){let l=[];for(let[p,m]of this.cliSimBySocket)m===n.id&&l.push(p);for(let p of l){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()+o.USER_BOOT_LEASE_TTL_MS},process.stderr.write(`sootsim booted ${l.length} cli client(s)${u?" (overrode prior lease)":""}; held sim for user [${n.id}]
|
|
14
14
|
`),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 d=this.cliBySentId.get(r.id);if(d&&(this.cliBySentId.delete(r.id),d.ws.readyState===h.OPEN)){let l=this.getOtherCliIdentityCount(d.ws,d.simId),u=l>0?{...r,id:d.originalId,_otherCliCount:l}:{...r,id:d.originalId};d.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[m,f]of this.cliBySentId)f.ws===e&&this.cliBySentId.delete(m);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===h.OPEN&&e.send(JSON.stringify({id:r.id,result:{cliIdentityKey:p,leaseTtlMs:o.CLI_LEASE_TTL_MS,leasing:!0}}));return}if(r.type==="bridge:list-sims"){e.readyState===h.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===h.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),m=this.tryAcquireLease(e,p,{force:r.force===!0});if(!m.granted){e.readyState===h.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${p.id} is locked by another cli`,_locked:m.lock}));return}this.setCliSimTarget(e,p.id),this.recordSimAction(p.id,m.bootedCount>0?`cli force-claimed sim (booted ${m.bootedCount})`:"cli claimed sim"),e.readyState===h.OPEN&&e.send(JSON.stringify({id:r.id,result:{simId:p.id,lockedBy:m.lease.cliIdentityKey,lockExpiresAt:m.lease.expiresAt,bootedCount:m.bootedCount}}));return}let c=await this.waitForSim(r.simId);if(yt(r)){let p=this.tryAcquireLease(e,c);if(!p.granted){e.readyState===h.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\``,_locked:p.lock}));return}}else this.ensureCliIdentityKey(e);this.setCliSimTarget(e,c.id),this.recordSimAction(c.id,this.describeForwardedCommand(r));let d=this.nextCommandId++;this.cliBySentId.set(d,{simId:c.id,ws:e,originalId:r.id});let{simId:l,...u}=r;if(c.ws.send(JSON.stringify({...u,id:d})),u.type==="close"){this.cliBySentId.delete(d),e.readyState===h.OPEN&&e.send(JSON.stringify({id:r.id,result:{requested:!0,simId:c.id}}));let p=c.ws,m=setTimeout(()=>{this.closeSimSocketFromHost(p)},gt);Le(m)}}catch(c){e.readyState===h.OPEN&&e.send(JSON.stringify({id:r.id,error:c instanceof Error?c.message:String(c)}))}})()}}),e.on("close",()=>{if(this.agentHost.unregisterSocket(e),s==="sim"&&n){this.rememberDisconnectedSim(n),this.primarySimId===n.id&&(this.primarySimId=this.getOpenSim()?.id??null);for(let[a,r]of this.pendingCommands)r.simId===n.id&&(r.reject(new Error("sim disconnected")),this.pendingCommands.delete(a));for(let[a,r]of this.cliBySentId)r.simId===n.id&&(r.ws.readyState===h.OPEN&&r.ws.send(JSON.stringify({id:r.originalId,error:"sim disconnected before responding"})),this.cliBySentId.delete(a));this.broadcastSimAssignments(),this.broadcastSimClientStates()}else if(s==="cli"){let a=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);a&&this.broadcastSimClientStates()}})})}afterBind(){if(process.stderr.write(`ws bridge listening on port ${this.port}
|
|
15
15
|
`),this.cliIdleTimer=setInterval(()=>this.sweepIdleCliClients(),3e4),this.cliIdleTimer.unref(),this.wsHeartbeatTimer=setInterval(()=>this.sweepDeadWebSockets(),o.WS_HEARTBEAT_INTERVAL_MS),this.wsHeartbeatTimer.unref(),this.shouldWriteLockfile){try{if(E(),!Z(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)}
|
|
16
|
-
`),e}this.heartbeatTimer=setInterval(()=>{try{this.writeLockfileSnapshot()}catch{}},
|
|
17
|
-
`)}this.devHeartbeatTimer=setInterval(()=>{try{this.writeDevLockfileSnapshot()}catch{}},
|
|
16
|
+
`),e}this.heartbeatTimer=setInterval(()=>{try{this.writeLockfileSnapshot()}catch{}},_e),this.heartbeatTimer.unref(),this.startRuntimeUpdater()}if(this.shouldWriteDevLockfile){try{this.writeDevLockfileSnapshot()}catch(e){process.stderr.write(`ws bridge failed to write dev bridge lockfile: ${String(e)}
|
|
17
|
+
`)}this.devHeartbeatTimer=setInterval(()=>{try{this.writeDevLockfileSnapshot()}catch{}},_e),this.devHeartbeatTimer.unref()}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}}buildDevLockfileSnapshot(){let e=this.getShellPort?.()??null;return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,...e&&e>0?{shellPort:e}:{},cwd:process.cwd(),startedAt:this.startedAt,heartbeatAt:Date.now(),source:"vite-dev"}}writeLockfileSnapshot(){X(this.buildLockfileSnapshot())}writeDevLockfileSnapshot(){Y(this.buildDevLockfileSnapshot())}refreshActiveRuntime(){this.activeRuntimeVersion=K(),this.activeRuntimeDirPath=se()??G()}runServerScan(){if(this.inflightScan)return this.inflightScan;let e=this.effectivePort>0?[this.effectivePort]:[];return this.inflightScan=P({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=s=>{e.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),e.end(JSON.stringify(s))},i=Date.now()-this.scanCacheAt;if(this.scanCache&&i<o.SCAN_FRESH_MS){t(this.scanCache);return}if(this.scanCache){t(this.scanCache),this.runServerScan().catch(()=>{});return}this.runServerScan().then(s=>t(s))}resolveRuntimeUpdateIntervalMs(){let e=Number(process.env[bt]);return Number.isFinite(e)&&e>0?Math.max(100,Math.round(e)):vt}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
|
|
18
18
|
`);let t=await ae();if(!t.updated||!t.latestVersion){e==="startup"&&process.stderr.write(`sootsim: runtime ${this.activeRuntimeVersion??"(none)"} is current
|
|
19
19
|
`);return}let i=this.activeRuntimeVersion,s=this.setActiveRuntime(t.latestVersion);process.stderr.write(`sootsim runtime updated to ${s.version} (${e})
|
|
20
20
|
`);try{J({from:i,to:s.version,at:Date.now()})}catch{}}catch(t){process.stderr.write(`sootsim runtime update failed (${e}): ${t instanceof Error?t.message:String(t)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as g,b as k}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as g,b as k}from"./chunk-77PV2FU7.js";import{b as S,c as x}from"./chunk-HGP47PYK.js";import{a as w}from"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import"./chunk-V7J6D2DS.js";import"./chunk-VPMLXKVQ.js";import"./chunk-NWTNH63K.js";import"./chunk-4GWETXII.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-BCUTZMYU.js";import{H as v,M as f,O as m,l as b}from"./chunk-V3TEFUGE.js";import"./chunk-NQASQSKK.js";import"./chunk-ZVHAYHJO.js";import"./chunk-ADT2LUD2.js";import"./chunk-DVQS7XW4.js";import{existsSync as r,mkdirSync as j,readFileSync as d,readdirSync as I,writeFileSync as D}from"fs";import{basename as p,dirname as y,join as i,relative as c,resolve as h}from"path";var T=["bun","pnpm","npm"];async function pe(n){(n.includes("--help")||n.includes("-h"))&&(console.log(`
|
|
3
3
|
sootsim setup \u2014 set up this machine for SootSim
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -94,4 +94,4 @@ module.exports = {
|
|
|
94
94
|
4. inspect and drive it:
|
|
95
95
|
sootsim describe
|
|
96
96
|
sootsim do tap-text "Sign in"
|
|
97
|
-
`)}function N(n,e){switch(n){case"bun":return`bunx ${e}`;case"pnpm":return`pnpm exec ${e}`;case"npm":return`npx ${e}`}}function ne(n,e){switch(n){case"bun":return`bun run ${e}`;case"pnpm":return`pnpm run ${e}`;case"npm":return`npm run ${e}`}}function oe(n){switch(n){case"bun":return"bun add -g sootsim";case"pnpm":return"pnpm add -g sootsim";case"npm":return"npm i -g sootsim"}}async function te(n,e){if(!e||n.dryRun)return;if(console.log(" last step:"),!process.stdin.isTTY){console.log(" run `sootsim open` after your Metro/Expo/One server is up");return}if(!await g("I'll run `sootsim open` for you now?",!0)){console.log(" later: sootsim open");return}let{runOpenCommand:o}=await import("./control-
|
|
97
|
+
`)}function N(n,e){switch(n){case"bun":return`bunx ${e}`;case"pnpm":return`pnpm exec ${e}`;case"npm":return`npx ${e}`}}function ne(n,e){switch(n){case"bun":return`bun run ${e}`;case"pnpm":return`pnpm run ${e}`;case"npm":return`npm run ${e}`}}function oe(n){switch(n){case"bun":return"bun add -g sootsim";case"pnpm":return"pnpm add -g sootsim";case"npm":return"npm i -g sootsim"}}async function te(n,e){if(!e||n.dryRun)return;if(console.log(" last step:"),!process.stdin.isTTY){console.log(" run `sootsim open` after your Metro/Expo/One server is up");return}if(!await g("I'll run `sootsim open` for you now?",!0)){console.log(" later: sootsim open");return}let{runOpenCommand:o}=await import("./control-D7OTV6TJ.js");await o([],{port:7668})}async function R(n,e,o){return o.yes?!0:process.stdin.isTTY?g(n,e):(console.log(` ${n} ${e?"[Y/n]":"[y/N]"} n (non-interactive; pass --yes to accept)`),!1)}export{J as detectConfigScaffoldExt,M as detectNodeVersionPins,W as detectPreferredPackageManager,E as readMachineSetupStatus,pe as runSetup,de as shouldRunSetupForBareCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import"./chunk-DVQS7XW4.js";import*as i from"fs";import*as I from"os";import*as a from"path";import{fileURLToPath as h}from"url";function $(){try{let t=h(import.meta.resolve("sootsim/package.json"));return a.join(a.dirname(t),"skills")}catch{let t=a.dirname(h(import.meta.url));return a.resolve(t,"../../skills")}}var d=$(),w=new Set(["all","codex","claude"]);function S(){console.log(`sootsim skill
|
|
3
3
|
|
|
4
4
|
install and inspect bundled SootSim agent skills.
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{k as f}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{k as f}from"./chunk-R6X7MBYT.js";import"./chunk-2WAYJJIL.js";import"./chunk-76NRK5LH.js";import"./chunk-PYYTNSGW.js";import"./chunk-J3U5NHJ6.js";import{a as t,b as n,c as l,d as c,e as a}from"./chunk-YCAL6N7R.js";import"./chunk-I3NLVJO7.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import"./chunk-4XMWRLHS.js";import"./chunk-NNXM4S37.js";import"./chunk-D3ZEKF5O.js";import"./chunk-75XS6H6B.js";import"./chunk-FAMEC3A3.js";import"./chunk-MC32IMHX.js";import"./chunk-NWTNH63K.js";import"./chunk-4GWETXII.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-BCUTZMYU.js";import"./chunk-V3TEFUGE.js";import"./chunk-OE6VL4ZA.js";import"./chunk-ADT2LUD2.js";import"./chunk-DVQS7XW4.js";function p(){console.log(`
|
|
3
3
|
sootsim storage profile \u2014 manage isolated storage profiles
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{g as m,i as d,l as s}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{g as m,i as d,l as s}from"./chunk-FAMEC3A3.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";import{writeFileSync as g}from"fs";function u(){console.log(`
|
|
3
3
|
sootsim timeline \u2014 control the semantic event timeline
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as d}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as d}from"./chunk-SB7INNHS.js";import{e as m}from"./chunk-7JZVKKSL.js";import"./chunk-FAMEC3A3.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import{K as a,g as r,h as l}from"./chunk-V3TEFUGE.js";import{a as c}from"./chunk-NQASQSKK.js";import"./chunk-DVQS7XW4.js";import{spawn as g}from"node:child_process";import u from"node:fs";import p from"node:os";import e from"node:path";var f="https://registry.npmjs.org/sootsim/latest";async function j(o){let n=o.indexOf("--channel"),t=n>=0&&o[n+1]?o[n+1]:void 0;console.log(`sootsim upgrade
|
|
3
3
|
`),console.log("runtime:");let i=m();i&&(console.log(` pinned to ${i} \u2014 installing the pin, not channel latest`),console.log(" (run `sootsim runtime unpin` to follow latest again)")),await d(["install",...t?["--channel",t]:[]],{}),console.log(`
|
|
4
4
|
cli:`),await $()}function h(){if(l())return{kind:"dev"};let o=process.argv[1]??"";try{o=u.realpathSync(o)}catch{}let n=e.sep;if(o.includes(`${n}_npx${n}`)||o.includes(`${n}.bunx${n}`))return{kind:"npx"};if(o.includes(`${n}.bun${n}`))return{kind:"global",command:"bun",args:["add","-g","sootsim@latest"]};if(o.includes(`${n}pnpm${n}`))return{kind:"global",command:"pnpm",args:["add","-g","sootsim@latest"]};let t=e.join(r(),"cli");if(o.startsWith(`${t}${n}`))return{kind:"global",command:"npm",args:["i","-g","--prefix",t,"sootsim@latest"]};let i=e.resolve(process.env.SOOTSIM_CLI_PREFIX||e.join(p.homedir(),".local"));return o.startsWith(`${i}${n}`)?{kind:"global",command:"npm",args:["i","-g","--prefix",i,"sootsim@latest"]}:{kind:"global",command:"npm",args:["i","-g","sootsim@latest"]}}async function $(){let o=c(),n=await k();if(!n){console.log(` v${o} \u2014 couldn't reach the npm registry, skipped`);return}if(a(n,o)<=0){console.log(` v${o} (latest)`);return}let t=h();if(console.log(` v${o} \u2192 v${n}`),t.kind==="dev"){console.log(" running from the Contrast dev checkout \u2014 pull instead of upgrading");return}if(t.kind==="npx"){console.log(" running from the npx cache \u2014 get the latest with:"),console.log(" npx sootsim@latest");return}let i=`${t.command} ${t.args.join(" ")}`;console.log(` updating global install (${i})\u2026`),await v(t.command,t.args)?console.log(` updated to v${n}`):(console.log(" update failed \u2014 run it yourself:"),console.log(` ${i}`))}function v(o,n){return new Promise(t=>{let i=g(o,n,{stdio:"inherit"});i.on("error",()=>t(!1)),i.on("exit",s=>t(s===0))})}async function k(){try{let o=await fetch(f,{headers:{accept:"application/json"},signal:AbortSignal.timeout(8e3)});if(!o.ok)return null;let n=await o.json();return typeof n.version=="string"&&n.version?n.version:null}catch{return null}}export{j as runUpgrade};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! sootsim v0.1.231 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a,b,c}from"./chunk-P4X4M3ZU.js";import"./chunk-TDEFREVM.js";import"./chunk-AE3BELZM.js";import"./chunk-SCVX5MDD.js";import"./chunk-4XMWRLHS.js";import"./chunk-FAMEC3A3.js";import"./chunk-VRTTFRVD.js";import"./chunk-2D6RUG3E.js";import"./chunk-L7STWTUD.js";import"./chunk-DATFU5M3.js";import"./chunk-V3TEFUGE.js";import"./chunk-DVQS7XW4.js";export{a as resolveDefaultUploadOrigin,b as resolvePublicPreviewOrigin,c as runUpload};
|