sootsim 0.1.217 → 0.1.219
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/README.md +5 -3
- package/detox/index.ts +6 -7
- package/dist-cli/bin.js +4 -4
- package/dist-cli/chunks/{agent-4FX2PQLB.js → agent-ZV6ME4EG.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-KIQTUCYG.js → agent-wrapper-EGFEAPFH.js} +2 -2
- package/dist-cli/chunks/{app-fonts-7XJS63Y2.js → app-fonts-ZWVEYPCN.js} +2 -2
- package/dist-cli/chunks/{assert-VQMDKAVI.js → assert-SC3W6UNR.js} +2 -2
- package/dist-cli/chunks/{auth-6JIMQLVG.js → auth-7OTPNXUI.js} +2 -2
- package/dist-cli/chunks/beta-QPKHTN3A.js +2 -0
- package/dist-cli/chunks/{camera-BCXQMAB3.js → camera-RQGNYESB.js} +2 -2
- package/dist-cli/chunks/{chunk-SBLVM6KT.js → chunk-2CCJGEVS.js} +2 -2
- package/dist-cli/chunks/{chunk-5WGUBDNY.js → chunk-2DOBRWPU.js} +3 -3
- package/dist-cli/chunks/{chunk-P2FPQYLI.js → chunk-2U4CK5R5.js} +2 -2
- package/dist-cli/chunks/{chunk-Z6H5YGVP.js → chunk-3B5UXJ3Y.js} +1 -1
- package/dist-cli/chunks/{chunk-II5GPTCI.js → chunk-3GQ2VZT3.js} +2 -2
- package/dist-cli/chunks/{chunk-IRCQILE3.js → chunk-3PMTZACY.js} +2 -2
- package/dist-cli/chunks/{chunk-5PMHRL26.js → chunk-3QEIIJ4U.js} +2 -2
- package/dist-cli/chunks/{chunk-XGOENFDF.js → chunk-4KBHOKFR.js} +4 -4
- package/dist-cli/chunks/{chunk-KDMMOZWO.js → chunk-7EMJ67H5.js} +9 -9
- package/dist-cli/chunks/{chunk-CGQGD4YT.js → chunk-7RSH52LR.js} +1 -1
- package/dist-cli/chunks/{chunk-PH6F62XI.js → chunk-7VZLWO2D.js} +2 -2
- package/dist-cli/chunks/{chunk-C3L2JWQF.js → chunk-AWM244TZ.js} +3 -3
- package/dist-cli/chunks/{chunk-43HOXICB.js → chunk-BTLNZG23.js} +1 -1
- package/dist-cli/chunks/{chunk-DPR6E3DA.js → chunk-C5LRFEF4.js} +1 -1
- package/dist-cli/chunks/{chunk-KPQIXJ6P.js → chunk-EMWJQRT7.js} +2 -2
- package/dist-cli/chunks/{chunk-PNN5RIHU.js → chunk-FGIGSM4Z.js} +2 -2
- package/dist-cli/chunks/{chunk-72ACLZTK.js → chunk-FJPEIFZW.js} +1 -1
- package/dist-cli/chunks/{chunk-5LY3QGYK.js → chunk-G26OO66G.js} +1 -1
- package/dist-cli/chunks/{chunk-VFM2GCJK.js → chunk-GXIL7GMS.js} +1 -1
- package/dist-cli/chunks/{chunk-PNEWTGQD.js → chunk-I6SPORCZ.js} +1 -1
- package/dist-cli/chunks/{chunk-YIEZXEFD.js → chunk-ITYDRFAM.js} +3 -3
- package/dist-cli/chunks/chunk-J3WU2XCQ.js +1 -0
- package/dist-cli/chunks/{chunk-ZP7IKLL5.js → chunk-JEMQ2DRI.js} +2 -2
- package/dist-cli/chunks/{chunk-5MRHVSLH.js → chunk-JT5JOWHK.js} +1 -1
- package/dist-cli/chunks/{chunk-WOVVMHGW.js → chunk-JVJNG6BQ.js} +2 -2
- package/dist-cli/chunks/{chunk-DLGYFFRD.js → chunk-JYU7BIGJ.js} +2 -2
- package/dist-cli/chunks/{chunk-V33VVORZ.js → chunk-KLTHI6RE.js} +2 -2
- package/dist-cli/chunks/{chunk-WSHEWWAP.js → chunk-LNNBPSAL.js} +2 -2
- package/dist-cli/chunks/{chunk-2QZEYMIG.js → chunk-LUWFFYQL.js} +2 -2
- package/dist-cli/chunks/chunk-NVDHSK33.js +119 -0
- package/dist-cli/chunks/{chunk-HKQG2TQP.js → chunk-PMERG7PS.js} +1 -1
- package/dist-cli/chunks/{chunk-2MCDMCYQ.js → chunk-PYIMY6VO.js} +1 -1
- package/dist-cli/chunks/{chunk-F3OVNA6L.js → chunk-QH5KCAPX.js} +1 -1
- package/dist-cli/chunks/{chunk-JVV5UWFI.js → chunk-RCHJJ5GW.js} +1 -1
- package/dist-cli/chunks/{chunk-EDF3RMTS.js → chunk-UEA4JYEY.js} +2 -2
- package/dist-cli/chunks/{chunk-FHZ72TK4.js → chunk-V4VPUZVL.js} +91 -14
- package/dist-cli/chunks/{chunk-OKKXVF4E.js → chunk-WTWTKL3R.js} +6 -6
- package/dist-cli/chunks/chunk-Y6Y7QQLA.js +1 -0
- package/dist-cli/chunks/{chunk-FS73CB2S.js → chunk-Y7GPDSA2.js} +1 -1
- package/dist-cli/chunks/{chunk-Z5DRCU5R.js → chunk-ZGTMYSKV.js} +2 -2
- package/dist-cli/chunks/{chunk-5HXI2BXE.js → chunk-ZHMKPUDR.js} +2 -2
- package/dist-cli/chunks/{chunk-XNLHQI4J.js → chunk-ZNDD2KOF.js} +1 -1
- package/dist-cli/chunks/{chunk-7GGP6CHB.js → chunk-ZXFWW4MR.js} +1 -1
- package/dist-cli/chunks/cli-version-ZUBCW7QA.js +2 -0
- package/dist-cli/chunks/{compat-VMLCACM3.js → compat-WICAPL25.js} +3 -3
- package/dist-cli/chunks/{config-PTMQDYOZ.js → config-MGQCNMDQ.js} +2 -2
- package/dist-cli/chunks/{control-SHITPCIX.js → control-GW7OQZ2R.js} +2 -2
- package/dist-cli/chunks/daemon-2A2YTRXY.js +2 -0
- package/dist-cli/chunks/{debug-MJEQ2R54.js → debug-54HQV7MN.js} +3 -3
- package/dist-cli/chunks/{desktop-Z4LOP37S.js → desktop-5FWYDFK2.js} +3 -3
- package/dist-cli/chunks/{detox-VGPLTJYZ.js → detox-75KJXI7K.js} +2 -2
- package/dist-cli/chunks/{device-H5CH3XAB.js → device-VRR2CFKN.js} +2 -2
- package/dist-cli/chunks/{diagnose-AIQGCXUP.js → diagnose-DS623ULB.js} +2 -2
- package/dist-cli/chunks/drivers-6QFTJGK6.js +2 -0
- package/dist-cli/chunks/{film-P66JPUHW.js → film-6I22LQ4E.js} +3 -3
- package/dist-cli/chunks/flow-4RXVOUUF.js +2 -0
- package/dist-cli/chunks/help-IXPZBF5H.js +2 -0
- package/dist-cli/chunks/{home-paths-WMQMWUNA.js → home-paths-D7QIYKT2.js} +2 -2
- package/dist-cli/chunks/inspect-SU5K5IER.js +2 -0
- package/dist-cli/chunks/install-desktop-PN4SCIMA.js +2 -0
- package/dist-cli/chunks/{login-IAHY7E6Y.js → login-ETKHVL7Z.js} +4 -4
- package/dist-cli/chunks/{logout-2YEUFJAD.js → logout-FLW7LPE3.js} +2 -2
- package/dist-cli/chunks/{maestro-BSD43NA3.js → maestro-D3MAAOMX.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-QU74GL7P.js → maestro-generate-73HS4LME.js} +3 -3
- package/dist-cli/chunks/{mode-UMJMUA3Y.js → mode-SOXJRJIN.js} +2 -2
- package/dist-cli/chunks/optional-demo-registry-N2J3NEGC.js +2 -0
- package/dist-cli/chunks/{perf-XMNXZFDY.js → perf-YAKR4GMN.js} +2 -2
- package/dist-cli/chunks/{record-UCDYKK5M.js → record-HWKSSN3E.js} +3 -3
- package/dist-cli/chunks/runtime-ZUWXQ46T.js +2 -0
- package/dist-cli/chunks/screenshot-command-UNDC4C2R.js +151 -0
- package/dist-cli/chunks/screenshots-capture-QZSUIT4R.js +41 -0
- package/dist-cli/chunks/{serve-L4XOZE3V.js → serve-D66T2PP3.js} +2 -2
- package/dist-cli/chunks/{setup-O3TUZ5JW.js → setup-FML4JBOA.js} +9 -9
- package/dist-cli/chunks/{skills-P4KO6RFE.js → skills-O2KIPSJ6.js} +2 -2
- package/dist-cli/chunks/{storage-RTPEVRAI.js → storage-T7MGNCI7.js} +2 -2
- package/dist-cli/chunks/store-WTRJT3P5.js +2 -0
- package/dist-cli/chunks/telemetry-7HV5GWEK.js +2 -0
- package/dist-cli/chunks/{timeline-64CDTB5K.js → timeline-OQEJCRNZ.js} +2 -2
- package/dist-cli/chunks/upgrade-TL36WOFS.js +4 -0
- package/dist-cli/chunks/upload-7CIEKZM6.js +2 -0
- package/dist-cli/chunks/{version-A5YSPPCX.js → version-XG3TA6TB.js} +2 -2
- package/dist-cli/chunks/web-LVUK3CHP.js +2 -0
- package/dist-cli/chunks/{what-happened-Y3MVLKPF.js → what-happened-SASUKQEF.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 +53 -7
- 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 -1
- 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 +176 -30
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/skills/builtin/a11y-review.ts +4 -1
- package/src/skills/builtin/perf-profile.ts +4 -1
- package/src/skills/builtin/screenshot-all.ts +4 -1
- package/src/skills/builtin/visual-diff.ts +4 -1
- package/dist-cli/chunks/beta-N2ZUIDGA.js +0 -2
- package/dist-cli/chunks/chunk-GLAMORG7.js +0 -1
- package/dist-cli/chunks/chunk-IQUBZ6UH.js +0 -119
- package/dist-cli/chunks/chunk-S3NTQ523.js +0 -1
- package/dist-cli/chunks/cli-version-57GES5K7.js +0 -2
- package/dist-cli/chunks/daemon-KHJZASBC.js +0 -2
- package/dist-cli/chunks/drivers-LRTSTFSZ.js +0 -2
- package/dist-cli/chunks/flow-JETK5JHP.js +0 -2
- package/dist-cli/chunks/help-XX557QGO.js +0 -2
- package/dist-cli/chunks/inspect-JTBKTX2E.js +0 -2
- package/dist-cli/chunks/install-desktop-OFWYZIJ2.js +0 -2
- package/dist-cli/chunks/optional-demo-registry-MS2YBMHN.js +0 -2
- package/dist-cli/chunks/runtime-VNQTSGVX.js +0 -2
- package/dist-cli/chunks/screenshot-command-UZOLNSJN.js +0 -151
- package/dist-cli/chunks/screenshots-capture-NOWHE4AB.js +0 -41
- package/dist-cli/chunks/store-P23ZWVHH.js +0 -2
- package/dist-cli/chunks/telemetry-UFGF53JT.js +0 -2
- package/dist-cli/chunks/upgrade-OLGZ7K6Y.js +0 -4
- package/dist-cli/chunks/upload-GQYWQIIG.js +0 -2
- package/dist-cli/chunks/web-U6OTYNPM.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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{b as k,d as v}from"./chunk-3PMTZACY.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.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://sootbean.com",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:"dev-login disabled (not in dev mode)"};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:"dev-login disabled (not in dev mode)"};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-7HV5GWEK.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-7HV5GWEK.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("sootbean",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-7HV5GWEK.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-7HV5GWEK.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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as r,b as i}from"./chunk-ZHMKPUDR.js";import{a as t,c as o}from"./chunk-3PMTZACY.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.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.219 | (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-AWM244TZ.js";import{c as S}from"./chunk-4KBHOKFR.js";import{a as A,b as $,c as F}from"./chunk-JYU7BIGJ.js";import{a as x}from"./chunk-3GQ2VZT3.js";import"./chunk-EMWJQRT7.js";import{a as T}from"./chunk-2U4CK5R5.js";import{a as k}from"./chunk-LUWFFYQL.js";import"./chunk-LNNBPSAL.js";import"./chunk-JVJNG6BQ.js";import"./chunk-J3WU2XCQ.js";import"./chunk-3B5UXJ3Y.js";import"./chunk-ZXFWW4MR.js";import"./chunk-PMERG7PS.js";import"./chunk-ZGTMYSKV.js";import"./chunk-Y7GPDSA2.js";import"./chunk-2CCJGEVS.js";import"./chunk-V4VPUZVL.js";import"./chunk-ZNDD2KOF.js";import"./chunk-JT5JOWHK.js";import"./chunk-G26OO66G.js";import"./chunk-JEMQ2DRI.js";import"./chunk-ZHMKPUDR.js";import"./chunk-3PMTZACY.js";import"./chunk-NVDHSK33.js";import"./chunk-FGIGSM4Z.js";import"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import"./chunk-QH5KCAPX.js";import"./chunk-PYIMY6VO.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-73HS4LME.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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as O,c as k}from"./chunk-JYU7BIGJ.js";import{a as x}from"./chunk-3GQ2VZT3.js";import{a as A}from"./chunk-2U4CK5R5.js";import{a as v,b as T}from"./chunk-LUWFFYQL.js";import"./chunk-3B5UXJ3Y.js";import"./chunk-ZXFWW4MR.js";import{f as y}from"./chunk-Y7GPDSA2.js";import{g as b,i as S}from"./chunk-2CCJGEVS.js";import"./chunk-JT5JOWHK.js";import"./chunk-ZHMKPUDR.js";import"./chunk-3PMTZACY.js";import"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.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-4RXVOUUF.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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as s,b as i}from"./chunk-7EMJ67H5.js";import"./chunk-2CCJGEVS.js";import"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{k as x}from"./chunk-4KBHOKFR.js";import"./chunk-3GQ2VZT3.js";import"./chunk-LNNBPSAL.js";import"./chunk-JVJNG6BQ.js";import"./chunk-J3WU2XCQ.js";import"./chunk-3B5UXJ3Y.js";import"./chunk-ZXFWW4MR.js";import"./chunk-PMERG7PS.js";import"./chunk-ZGTMYSKV.js";import"./chunk-Y7GPDSA2.js";import{g as R,i as N,l as d,m as S}from"./chunk-2CCJGEVS.js";import"./chunk-V4VPUZVL.js";import"./chunk-ZNDD2KOF.js";import"./chunk-JT5JOWHK.js";import"./chunk-G26OO66G.js";import"./chunk-JEMQ2DRI.js";import"./chunk-NVDHSK33.js";import"./chunk-FGIGSM4Z.js";import"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import"./chunk-QH5KCAPX.js";import"./chunk-PYIMY6VO.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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as P}from"./chunk-EMWJQRT7.js";import"./chunk-2U4CK5R5.js";import{a as Z,c as ee}from"./chunk-LUWFFYQL.js";import"./chunk-3B5UXJ3Y.js";import"./chunk-ZXFWW4MR.js";import{g as b,i as v,j as Q}from"./chunk-2CCJGEVS.js";import{d as Y}from"./chunk-JT5JOWHK.js";import"./chunk-ZHMKPUDR.js";import"./chunk-3PMTZACY.js";import"./chunk-I6SPORCZ.js";import{b as X}from"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.js";import{existsSync as we,mkdirSync as E,readdirSync as he,readFileSync as be,rmSync as J,writeFileSync as I}from"fs";import{homedir as ve,tmpdir as ye}from"os";import{dirname as W,extname as oe,join as N,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 Oe(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 ke(){let e=process.env,r=(e.SOOT_BRANCH||e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME||"").trim(),o=(e.SOOT_SHA||e.GITHUB_SHA||"").trim(),i=(e.SOOT_PR_NUMBER||"").trim(),t=i?Number.parseInt(i,10):Number.NaN,n=(e.SOOT_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=Oe(e);if(o){let d=[...e.slice(0,o.index),...e.slice(o.index+1)];if(o.name==="start"){await Ie(d,r);return}if(o.name==="prelude-start"){await Ne(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 Oe(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 ke(){let e=process.env,r=(e.SOOT_BRANCH||e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME||"").trim(),o=(e.SOOT_SHA||e.GITHUB_SHA||"").trim(),i=(e.SOOT_PR_NUMBER||"").trim(),t=i?Number.parseInt(i,10):Number.NaN,n=(e.SOOT_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=Oe(e);if(o){let d=[...e.slice(0,o.index),...e.slice(o.index+1)];if(o.name==="start"){await Ie(d,r);return}if(o.name==="prelude-start"){await Ne(d,r);return}if(o.name==="upload"){let{runUpload:y}=await import("./upload-7CIEKZM6.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 B(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 O=await ue(d);me(O,x,t)}finally{d.close()}return}let C=p?Number(p):null,R=Te(s,c,C);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 B(h),R==="png"){let $=C??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(N(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`;I(ge,Buffer.from(f.data,"base64"))}),console.log(` saved ${A.length} frames`);return}if(R==="gif"){let $=C??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)),I(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 O=await D(h,`window.__sootsimRecorder.start(${JSON.stringify(y)})`,`${R} start`,g);O.ok||(console.error(` start failed: ${O.error??"unknown error"}`),/render host not available|already streaming|already recording|lock already held/i.test(O.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 B(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}I(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 Be(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 Te(e,r,o){return e||(o!=null?"png":Be(r)??"webm")}function M(){return new Date().toISOString().replace(/[:T]/g,"-").replace(/\..+/,"")}function Me(){let e=N(ve(),".sootsim","recordings");return E(e,{recursive:!0}),e}function U(e,r){return e?Se(process.cwd(),e):N(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 N(ye(),`sootsim-recording-${X()}.json`)}function T(){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){I(H(),JSON.stringify(e,null,2))}function k(){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.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a}from"./chunk-2DOBRWPU.js";import"./chunk-KLTHI6RE.js";import"./chunk-2CCJGEVS.js";import"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.js";export{a as runRuntime};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/*! sootsim v0.1.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as oe,b as re,f as ne}from"./chunk-AWM244TZ.js";import{b as Z}from"./chunk-4KBHOKFR.js";import{a as Q}from"./chunk-3GQ2VZT3.js";import"./chunk-EMWJQRT7.js";import"./chunk-2U4CK5R5.js";import{a as ee,b as te}from"./chunk-LUWFFYQL.js";import"./chunk-LNNBPSAL.js";import"./chunk-JVJNG6BQ.js";import"./chunk-J3WU2XCQ.js";import"./chunk-3B5UXJ3Y.js";import"./chunk-ZXFWW4MR.js";import"./chunk-PMERG7PS.js";import"./chunk-ZGTMYSKV.js";import{r as V}from"./chunk-Y7GPDSA2.js";import{g as E,h as K,i as A,j as X,k as J,l as C,m as $}from"./chunk-2CCJGEVS.js";import"./chunk-V4VPUZVL.js";import"./chunk-ZNDD2KOF.js";import"./chunk-JT5JOWHK.js";import"./chunk-G26OO66G.js";import"./chunk-JEMQ2DRI.js";import"./chunk-ZHMKPUDR.js";import"./chunk-3PMTZACY.js";import"./chunk-NVDHSK33.js";import"./chunk-FGIGSM4Z.js";import"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.js";import"./chunk-BTLNZG23.js";import{a as x,b as _,c as j,d as I,e as L,f as N,g as F}from"./chunk-QH5KCAPX.js";import"./chunk-PYIMY6VO.js";import{mkdirSync as ae,writeFileSync as se}from"fs";import{dirname as ce,resolve as le}from"path";async function ue(e,t){let o=Ie(e);(o.includes("--help")||o.includes("-h"))&&(console.log(`
|
|
3
|
+
sootsim screenshot \u2014 capture the canvas as a PNG
|
|
4
|
+
|
|
5
|
+
usage:
|
|
6
|
+
sootsim screenshot [output] [options]
|
|
7
|
+
sootsim screenshot [options] --output <path>
|
|
8
|
+
|
|
9
|
+
options:
|
|
10
|
+
--output <path> output file path (default: /tmp/sootsim-inspect.png)
|
|
11
|
+
first positional arg works too: \`screenshot /tmp/x.png\`
|
|
12
|
+
--with-frame wrap the captured screen in a tight device frame
|
|
13
|
+
--no-frame capture the raw screen bitmap (default)
|
|
14
|
+
--no-shell tenant-only capture (no status bar, keyboard, toasts,
|
|
15
|
+
notification center, or other shell overlays). use for
|
|
16
|
+
clean app screenshots when a shell surface is in the way.
|
|
17
|
+
--shell-only capture only the shell chrome, no tenant content
|
|
18
|
+
--area x,y,w,h crop to a logical sootsim rect
|
|
19
|
+
--id <testID> crop to a node's bounding box
|
|
20
|
+
--text <text> crop to a node found by text content
|
|
21
|
+
--gallery crawl and capture multiple screens as HTML gallery
|
|
22
|
+
--themes capture light and dark variants
|
|
23
|
+
|
|
24
|
+
examples:
|
|
25
|
+
sootsim screenshot
|
|
26
|
+
sootsim screenshot --no-shell --output app.png
|
|
27
|
+
sootsim screenshot --with-frame --output framed.png
|
|
28
|
+
sootsim screenshot --area 0,200,393,400 --output hero.png
|
|
29
|
+
sootsim screenshot --id loginButton --output button.png
|
|
30
|
+
`),process.exit(0));let i=Le(o);if(i.length>0){for(let{flag:p,suggestion:g}of i)console.error(g?` unknown flag: ${p} (did you mean ${g}?)`:` unknown flag: ${p}`);console.error(" run `sootsim screenshot --help` for the list of supported flags"),process.exit(1)}let r=o.includes("--gallery"),s=o.includes("--themes"),n=Te(o),a=ze(o);if(r||s)return n&&(console.error(" --with-frame is not supported with --gallery / --themes"),process.exit(1)),ie(o,t);n&&o.some(p=>p==="--area"||p==="--id"||p==="--text")&&(console.error(" --with-frame only supports full-screen capture for now"),console.error(" remove --area / --id / --text, or capture raw and compose later"),process.exit(1));let c=E(o,{port:t.port,stripBooleanFlags:["--with-frame","--no-frame","--no-shell","--shell-only"],stripValueFlags:["--output","--area","--id","--text"]}),l=pe(o),u=await Be(o);if(await Ae(c.wsPort)){try{await Re(c,l,u,n,a)}catch(p){console.error(` screenshot failed: ${p instanceof Error?p.message:String(p)}`),process.exit(1)}return}n&&(console.error(" --with-frame requires a running sootsim bridge"),console.error(" open the app in a live sim first, then rerun the command"),process.exit(1)),u&&(console.error(" --area / --id / --text require a running sootsim bridge"),console.error(" start one with `sootsim serve`, `sootsim desktop`, or your project dev server"),process.exit(1)),await ie(o,t)}async function Ae(e){let t=K(e,{commandTimeoutMs:1e3});try{return await t.listSims(),!0}catch{return!1}finally{t.close()}}async function Be(e){let t=e.find((r,s)=>e[s-1]==="--area");if(t){let r=t.split(",").map(l=>Number(l.trim()));if(r.length!==4||r.some(l=>!Number.isFinite(l)))throw new Error(`--area expects x,y,w,h (got "${t}")`);let[s,n,a,c]=r;return{x:s,y:n,w:a,h:c}}let o=e.find((r,s)=>e[s-1]==="--id"),i=e.find((r,s)=>e[s-1]==="--text");return o||i?{__matcher:{id:o,text:i}}:null}async function Re(e,t,o,i,r){let s=A({...e,commandTimeoutMs:45e3});try{(await X(s)).hidden&&process.stderr.write(` \u26A0 screenshot will capture the LAST PAINTED canvas \u2014 likely stale.
|
|
31
|
+
navigation/\`shell\` commands sent before this screenshot may not
|
|
32
|
+
have repainted yet. focus the tab manually or \`sootsim --sim <id>\`
|
|
33
|
+
to target a visible sim before capturing.
|
|
34
|
+
|
|
35
|
+
`);let a=Number(process.env.SOOT_SCREENSHOT_READY_MAX_MS)||9e4,c=await V(s,a);if(!c.ready)throw new Error(`app not ready to capture after ${Math.round(c.elapsedMs/1e3)}s`+(c.loadingText?` (still showing "${c.loadingText}")`:"")+"; refusing to capture the boot/loading card. retry once the app paints.");let l=o,u=o?.__matcher;if(u){let v=await s.send({type:"evaluate",code:Z(u)});if(!v)throw new Error(u.id?`no node with id "${u.id}"`:`no node matching text "${u.text}"`);l=v}let d=l?{x:l.x,y:l.y,w:l.w,h:l.h}:void 0,p={type:"screenshot"};r&&(p.layers=r),d&&(p.crop=d);let g=await s.send(p);if(typeof g!="string"||g.length<="data:image/png;base64,".length)throw new Error("screenshot capture returned no image data \u2014 the sim is connected but not painting; check `sootsim get errors`");let m=g.replace(/^data:image\/png;base64,/,"");d&&console.log(` area: x=${d.x} y=${d.y} w=${d.w} h=${d.h}`),r&&console.log(` layers: ${r}`);let w=le(process.cwd(),t||"/tmp/sootsim-inspect.png");ae(ce(w),{recursive:!0});let b=Buffer.from(m,"base64");if(i){let v=await Oe(s);if(!v)throw new Error("could not read current device model from the target sim");let Ee=await oe(b,v);se(w,Ee),console.log(` frame: ${v}`)}else se(w,b);console.log(` saved: ${w}`)}finally{s.close()}}async function Oe(e){let t=await C(e,"SootSim.bridges.settings.get")??{deviceModel:null},o=typeof t.deviceModel=="string"?t.deviceModel:null;return!o||!(o in F)?null:o}function Te(e){let t=!1;for(let o of e)o==="--with-frame"&&(t=!0),o==="--no-frame"&&(t=!1);return t}function ze(e){if(e.includes("--shell-only"))return"shell";if(e.includes("--no-shell"))return"tenant"}var _e=new Set(["--help","-h","--verbose","-v","--with-frame","--no-frame","--no-shell","--shell-only","--gallery","--themes"]),de=new Set(["--output","--area","--id","--text","--url","--port","--timeout","--sim"]),je={"--rect":"--area","--crop":"--area","--region":"--area","--bounds":"--area","--box":"--area","--xywh":"--area","--out":"--output","-o":"--output","--file":"--output","--path":"--output","--testid":"--id","--test-id":"--id","--test_id":"--id"};function Ie(e){let t=[],o={"-o":"--output","--out":"--output","--file":"--output","--path":"--output","--testid":"--id","--test-id":"--id","--test_id":"--id","--rect":"--area","--crop":"--area","--region":"--area","--bounds":"--area","--box":"--area","--xywh":"--area"};for(let i of e){let r=o[i];t.push(r??i)}return t}function Le(e){let t=[];for(let o=0;o<e.length;o++){let i=e[o];if(i.startsWith("-")){if(de.has(i)){o++;continue}_e.has(i)||t.push({flag:i,suggestion:je[i]})}}return t}function pe(e){let t=e.find((o,i)=>e[i-1]==="--output");if(t)return t;for(let o=0;o<e.length;o++){let i=e[o];if(i.startsWith("-")){de.has(i)&&o++;continue}return i}}async function ie(e,t){let o=pe(e)||"sootsim-screenshot.png",i=e.includes("--gallery"),r=e.find((a,c)=>e[c-1]==="--url")||`http://localhost:${t.port||5173}`,{chromium:s}=await import("playwright"),n=await s.launch({channel:"chrome",headless:!0});try{if(i)console.log(" capturing gallery..."),console.log(" (gallery mode not yet implemented)");else{let a=await n.newPage({viewport:{width:500,height:900}});await a.goto(r,{waitUntil:"networkidle"}),await a.waitForTimeout(2e3);let c=le(process.cwd(),o);ae(ce(c),{recursive:!0}),await a.screenshot({path:c}),console.log(` saved: ${c}`),await a.close()}}catch(a){console.error(` screenshot failed: ${a.message}`),process.exitCode=1}finally{await n.close()}}import{mkdirSync as q,readFileSync as Qe,writeFileSync as ve}from"fs";import{tmpdir as Zt}from"os";import O from"path";import{mkdirSync as he,readFileSync as Ue,writeFileSync as fe}from"fs";import U from"path";function me(e){return e.replace(/\\/g,"/").replace(/\.png$/i,"").trim().split("/").filter(Boolean).join("--").replace(/[^A-Za-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"slide"}function H(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function He(e){let t=e.trim();return/^#[0-9a-f]{3}$/i.test(t)?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function B(e,t){let o=He(e),i=Math.max(0,Math.min(1,t)),r=o.match(/^#([0-9a-f]{6})$/i);if(r){let s=r[1],n=Number.parseInt(s.slice(0,2),16),a=Number.parseInt(s.slice(2,4),16),c=Number.parseInt(s.slice(4,6),16);return`rgba(${n}, ${a}, ${c}, ${i})`}return o.startsWith("rgb(")?o.replace(/^rgb\((.+)\)$/i,`rgba($1, ${i})`):o}function Ye(e){if(e.type==="solid")return e.color||"#000000";let t=e.direction??180,o=e.stops?.map(i=>`${i.color} ${i.offset}%`).join(", ")||"#000000 0%, #111111 100%";return`linear-gradient(${t}deg, ${o})`}function Ge(e){let t=e.glow;return t?`radial-gradient(circle at 50% 24%, ${B(t,.46)} 0%, ${B(t,.2)} 24%, rgba(0,0,0,0) 62%)`:"none"}function Y(e){switch(e){case"tilted-left":return"perspective(2400px) rotateY(10deg) rotateZ(-2deg)";case"tilted-right":return"perspective(2400px) rotateY(-10deg) rotateZ(2deg)";case"cut-bottom":return"translateY(10%) scale(1.08)";case"cut-top":return"translateY(-16%) scale(1.08)";case"straight":default:return"none"}}function ge(...e){let t=e.map(o=>o.trim()).filter(o=>o.length>0&&o!=="none");return t.length>0?t.join(" "):"none"}function G(e){let t=B(e.color,e.opacity),o=B(e.color,e.opacity*.52);return`drop-shadow(0 34px ${e.spread}px ${o}) drop-shadow(0 0 ${e.blur}px ${t})`}function W(e,t){return!t.glow||e.color&&e.color!==x.color?e:{...e,color:t.glow}}function We(e,t){if(e==="editorial-left"){let r=Math.round(t.height*.056),s=Math.round(t.height*.022);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.12)}px`,`left:${Math.round(t.width*.085)}px`,`width:${Math.round(t.width*.42)}px`,"text-align:left","z-index:3"].join(";"),titleStyle:`font-size:${r}px;line-height:0.92;`,subStyle:`font-size:${s}px;line-height:1.36;max-width:${Math.round(t.width*.36)}px;`,eyebrowStyle:"align-items:flex-start;",deviceStyle:(n,a,c)=>{let l=Math.round(t.width*.68*(a.scale??n.scale)),u=Math.round(t.height*(.03+n.offsetY+(a.offsetY??0))),d=a.pose||n.pose||"tilted-right",p=W(n.shadow,c);return["position:absolute",`top:${Math.round(t.height*.18)+u}px`,`left:${Math.round(t.width*.56)}px`,`width:${l}px`,"transform-origin:center center",`transform:${Y(d)}`,`filter:${G(p)}`,"z-index:2"].join(";")}}}if(e==="minimal-bottom"){let r=Math.round(t.height*.041),s=Math.round(t.height*.019);return{copyStyle:["position:absolute",`left:${Math.round(t.width*.12)}px`,`right:${Math.round(t.width*.12)}px`,`bottom:${Math.round(t.height*.085)}px`,"text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${r}px;line-height:0.96;`,subStyle:`font-size:${s}px;line-height:1.34;max-width:${Math.round(t.width*.56)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(n,a,c)=>{let l=Math.round(t.width*.84*(a.scale??n.scale)),u=Math.round(t.height*(n.offsetY+(a.offsetY??0))),d=a.pose||n.pose,p=W(n.shadow,c);return["position:absolute",`top:${Math.round(t.height*.075)+u}px`,"left:50%",`width:${l}px`,"transform-origin:center center",`transform:${ge("translateX(-50%)",Y(d))}`,`filter:${G(p)}`,"z-index:2"].join(";")}}}let o=Math.round(t.height*.04),i=Math.round(t.height*.019);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.084)}px`,"left:50%",`width:${Math.round(t.width*.88)}px`,"transform:translateX(-50%)","text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${o}px;line-height:0.92;`,subStyle:`font-size:${i}px;line-height:1.34;max-width:${Math.round(t.width*.6)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(r,s,n)=>{let a=Math.round(t.width*.64*(s.scale??r.scale)),c=Math.round(t.height*(r.offsetY+(s.offsetY??0))),l=s.pose||r.pose,u=W(r.shadow,n);return["position:absolute",`top:${Math.round(t.height*.28)+c}px`,"left:50%",`width:${a}px`,"transform-origin:center top",`transform:${ge("translateX(-50%)",Y(l))}`,`filter:${G(u)}`,"z-index:2"].join(";")}}}function qe({canvas:e,compose:t,slide:o,imageDataUrl:i}){let r=o.background??t.background,s=We(t.text.preset,e),n=t.text.preset!=="none"&&!!(o.eyebrow||o.headline||o.subheadline),a=s.deviceStyle(t.frame,o,r),c=o.headline?`<div style="font-weight:780;white-space:pre-line;text-wrap:balance;${s.titleStyle}">${H(o.headline)}</div>`:"",l=o.subheadline?`<div style="margin-top:${Math.round(e.height*.018)}px;color:${t.text.subColor};white-space:pre-line;text-wrap:balance;${s.subStyle}">${H(o.subheadline)}</div>`:"",u=o.eyebrow?`<div style="display:flex;${s.eyebrowStyle}margin-bottom:${Math.round(e.height*.016)}px;"><div style="font-size:${Math.round(e.height*.014)}px;font-weight:700;letter-spacing:0.18em;text-transform:uppercase;color:${t.text.eyebrowColor};">${H(o.eyebrow)}</div></div>`:"";return`<!doctype html>
|
|
36
|
+
<html>
|
|
37
|
+
<head>
|
|
38
|
+
<meta charset="utf-8" />
|
|
39
|
+
<style>
|
|
40
|
+
html, body {
|
|
41
|
+
margin: 0;
|
|
42
|
+
width: ${e.width}px;
|
|
43
|
+
height: ${e.height}px;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
background: transparent;
|
|
46
|
+
}
|
|
47
|
+
body {
|
|
48
|
+
font-family: "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
|
|
49
|
+
}
|
|
50
|
+
#canvas {
|
|
51
|
+
position: relative;
|
|
52
|
+
width: ${e.width}px;
|
|
53
|
+
height: ${e.height}px;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
background: ${Ye(r)};
|
|
56
|
+
color: ${t.text.color};
|
|
57
|
+
isolation: isolate;
|
|
58
|
+
}
|
|
59
|
+
#glow {
|
|
60
|
+
position: absolute;
|
|
61
|
+
inset: 0;
|
|
62
|
+
background: ${Ge(r)};
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
#copy {
|
|
66
|
+
${s.copyStyle};
|
|
67
|
+
}
|
|
68
|
+
#device {
|
|
69
|
+
${a};
|
|
70
|
+
}
|
|
71
|
+
#device img {
|
|
72
|
+
display: block;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: auto;
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<div id="canvas">
|
|
80
|
+
<div id="glow"></div>
|
|
81
|
+
${n?`<div id="copy">${u}${c}${l}</div>`:""}
|
|
82
|
+
<div id="device"><img src="${i}" alt="" /></div>
|
|
83
|
+
</div>
|
|
84
|
+
</body>
|
|
85
|
+
</html>`}async function we(e,t,o){let i=[],r=o??await(async()=>{let{chromium:n}=await import("playwright");return n.launch({headless:!0})})();try{let n=await r.newContext({viewport:{width:1280,height:720}});try{for(let a of t){let l=`data:image/png;base64,${Ue(a.imagePath).toString("base64")}`;for(let u of e.canvases){let d=await n.newPage();try{await d.setViewportSize({width:u.width,height:u.height}),await d.setContent(qe({canvas:u,compose:e,slide:a.slide,imageDataUrl:l}),{waitUntil:"load"}),await d.waitForTimeout(20);let p=U.join(e.outDir,u.name,e.locale);he(p,{recursive:!0});let g=U.join(p,`${a.slide.assetKey}.png`),f=await d.screenshot({type:"png",clip:{x:0,y:0,width:u.width,height:u.height}});fe(g,f),i.push({slideId:a.slide.id,canvas:u.name,locale:e.locale,outputPath:g,sourcePath:a.imagePath})}finally{await d.close()}}}}finally{await n.close()}}finally{!o&&typeof r.close=="function"&&await r.close()}he(e.outDir,{recursive:!0});let s=U.join(e.outDir,"manifest.json");return fe(s,JSON.stringify({generatedAt:new Date().toISOString(),locale:e.locale,outputs:i},null,2)),{manifestPath:s,outputs:i.map(n=>n.outputPath),entries:i}}function M(e){return typeof e=="string"&&e.length>0?e:void 0}async function ye(e){let o=`${e.origin.replace(/\/$/,"")}/api/sootsim/screenshot-decks?org=${encodeURIComponent(e.org)}&repo=${encodeURIComponent(e.repo)}`,i=await fetch(o,{headers:{Authorization:e.authHeader}});if(!i.ok){let a=await i.text().catch(()=>"");throw new Error(`org deck fetch failed (${i.status} ${i.statusText}) for ${e.org}/${e.repo}${a?` \u2014 ${a.slice(0,200)}`:""}`)}let s=(await i.json()).decks?.[0];if(!s||!s.config||typeof s.config!="object")return null;let n=s.config.frames;return Array.isArray(n)?n.map(a=>{let c=a??{};return{title:M(c.title),subtitle:M(c.subtitle),bgTop:M(c.bgTop),bgBottom:M(c.bgBottom),titleColor:M(c.titleColor)}}):null}function be(e,t){e.compose.slides.forEach((o,i)=>{let r=t[i];if(r&&(r.title!=null&&(o.headline=r.title),r.subtitle!=null&&(o.subheadline=r.subtitle),r.bgTop&&r.bgBottom)){let s={type:"gradient",direction:180,stops:[{offset:0,color:j(r.bgTop)},{offset:1,color:j(r.bgBottom)}]};o.background=s}})}import{readFileSync as Ve}from"fs";import P from"path";function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function R(e,t){if(!h(e))throw new Error(`${t} must be an object`);return e}function y(e,t=""){return typeof e=="string"?e:t}function S(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Se(e,t){return typeof e=="boolean"?e:t}function k(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function xe(e,t){return typeof e!="string"||e.trim().length===0?t:Object.prototype.hasOwnProperty.call(F,e)?e:null}function Pe(e,t){if(typeof e=="string"){let r=N(e);if(!r)throw new Error(`unknown background preset: ${e}`);return r}if(!h(e))return L(t);let o=e.type==="solid"||e.type==="gradient"?e.type:t.type;if(o==="solid")return{type:o,color:y(e.color,t.color??"#000000"),glow:S(e.glow)??t.glow};let i=Array.isArray(e.stops)?e.stops.map(r=>{if(!h(r))return null;let s=k(r.offset,Number.NaN),n=S(r.color);return!Number.isFinite(s)||!n?null:{offset:s,color:n}}).filter(r=>!!r):t.stops?.map(r=>({...r}))??[];return{type:o,direction:k(e.direction,t.direction??180),glow:S(e.glow)??t.glow,stops:i.length>0?i:t.stops?.map(r=>({...r}))??[]}}function Ke(e){let o=(Array.isArray(e)?e:["iphone-6-9"]).map(i=>{if(typeof i!="string")throw new Error("compose.canvases entries must be strings");let r=I(i);if(!r)throw new Error(`unknown canvas preset: ${i}`);return r});if(o.length===0)throw new Error("compose.canvases must include at least one preset");return o}function Xe(e){switch(e){case"editorial-left":case"minimal-bottom":case"none":case"bold-top":return e;default:return"bold-top"}}function Je(e){switch(e){case"plan":case"flow":case"auto":return e;default:return"auto"}}function $e(e){switch(e){case"straight":case"tilted-left":case"tilted-right":case"cut-bottom":case"cut-top":return e;default:return}}function D(e,t){return P.isAbsolute(t)?t:P.resolve(e,t)}function Ze(e,t){if(!Array.isArray(e)||e.length===0)throw new Error("compose.slides must be a non-empty array");return e.map((o,i)=>{let r=R(o,`compose.slides[${i}]`),s=S(r.screenshot);if(!s)throw new Error(`compose.slides[${i}].screenshot is required`);let n=S(r.id),a=me(n||s);return{id:n||a,assetKey:a,screenshot:s,headline:y(r.headline),subheadline:y(r.subheadline),eyebrow:y(r.eyebrow),pose:$e(r.pose),scale:typeof r.scale=="number"&&Number.isFinite(r.scale)?r.scale:void 0,offsetY:typeof r.offsetY=="number"&&Number.isFinite(r.offsetY)?r.offsetY:void 0,background:r.theme||r.background?Pe(r.theme??r.background,t):void 0}})}function ke(e){let t=P.resolve(e),o=P.dirname(t),i=Q.parse(Ve(t,"utf8")),r=R(i,"screenshots plan"),s=R(r.capture??{},"capture"),n=R(r.compose??{},"compose"),a=typeof r.app=="number"?String(r.app):S(r.app),c=xe(r.device,null),l=D(o,y(s.out,P.join(".sootsim","screenshots","capture"))),u=S(s.from),d=S(s.flow);if(!u&&!d)throw new Error("capture.flow or capture.from is required");let p=s.mode==="raw"||s.mode==="framed"||s.mode==="raw+framed"?s.mode:"raw+framed",g=Je(s.pathMode),f=Pe(n.background??"cyan",N("cyan")),m={show:Se(n.frame&&h(n.frame)?n.frame.show:void 0,!0),style:xe(n.frame&&h(n.frame)?n.frame.style:null,null)||c||_,pose:$e(n.frame&&h(n.frame)?n.frame.pose:void 0)||"straight",scale:k(n.frame&&h(n.frame)?n.frame.scale:void 0,1),offsetY:k(n.frame&&h(n.frame)?n.frame.offsetY:void 0,0),shadow:{color:y(n.frame&&h(n.frame)&&h(n.frame.shadow)?n.frame.shadow.color:void 0,x.color),blur:k(n.frame&&h(n.frame)&&h(n.frame.shadow)?n.frame.shadow.blur:void 0,x.blur),spread:k(n.frame&&h(n.frame)&&h(n.frame.shadow)?n.frame.shadow.spread:void 0,x.spread),opacity:k(n.frame&&h(n.frame)&&h(n.frame.shadow)?n.frame.shadow.opacity:void 0,x.opacity)}};return{planPath:t,planDir:o,appTarget:a,deviceModel:c,capture:{flowPath:d?D(o,d):null,fromDir:u?D(o,u):null,outDir:l,rawDir:u?D(o,u):P.join(l,"raw"),framedDir:P.join(l,"framed"),mode:p,pathMode:g,simId:S(s.sim),openInNewSim:Se(s.new,!1)},compose:{outDir:D(o,y(n.out,P.join(".sootsim","screenshots","exports"))),locale:y(n.locale,"en"),canvases:Ke(n.canvases),frame:m,background:f,text:{preset:Xe(n.text&&h(n.text)?n.text.preset:void 0),color:y(n.text&&h(n.text)?n.text.color:void 0,"#ffffff"),subColor:y(n.text&&h(n.text)?n.text.subColor:void 0,"rgba(232,240,247,0.86)"),eyebrowColor:y(n.text&&h(n.text)?n.text.eyebrowColor:void 0,"rgba(229,242,255,0.72)")},slides:Ze(n.slides,f)}}}function et(e){return e.capture.pathMode==="plan"||e.capture.pathMode==="flow"?e.capture.pathMode:e.capture.fromDir?"flow":"plan"}function tt(e,t){if(!e.capture.flowPath)throw new Error("capture flow path is required to build flow args");let o=[e.capture.flowPath],i=et(e);o.push("--screenshots",e.capture.rawDir),i==="flow"&&o.push("--screenshot-paths","flow");let r=t.appTarget??e.appTarget,s=t.deviceModel??e.deviceModel,n=t.simId??e.capture.simId;return r&&o.push("--url",r),s&&o.push("--device",s),n&&o.push("--sim",n),e.capture.openInNewSim&&o.push("--new"),o}function T(e,t){return O.isAbsolute(t)?t:O.join(e.capture.rawDir,t)}function ot(e){return O.join(e.capture.outDir,"manifest.json")}async function rt(e,t){if(!e.capture.flowPath)return;q(e.capture.rawDir,{recursive:!0});let o=tt(e,t),i=await ne(o);if(i!==0)throw new Error(`flow capture failed with exit code ${i}`)}async function nt(e,t){let o=new Map;q(e.capture.framedDir,{recursive:!0});let i=t??await(async()=>{let{chromium:r}=await import("playwright");return r.launch({headless:!0})})();try{let r=await re(i);try{for(let s of e.compose.slides){let n=T(e,s.screenshot),a=Qe(n),c=await r.compose(a,e.compose.frame.style),l=O.join(e.capture.framedDir,`${s.assetKey}.png`);ve(l,c),o.set(s.id,l)}}finally{await r.close()}}finally{!t&&typeof i.close=="function"&&await i.close()}return o}function st(e,t,o){let i=[],r=[];q(e.capture.outDir,{recursive:!0});let s=ot(e),n=e.compose.slides.map(a=>{let c=T(e,a.screenshot),l=t.get(a.id)??null;return i.push(c),l&&r.push(l),{id:a.id,screenshot:a.screenshot,rawPath:c,framedPath:l}});return ve(s,JSON.stringify({generatedAt:new Date().toISOString(),deviceModel:o,mode:e.capture.mode,rawDir:e.capture.rawDir,framedDir:e.capture.framedDir,slides:n},null,2)),{manifestPath:s,rawDir:e.capture.rawDir,framedDir:e.capture.framedDir,rawFiles:i,framedFiles:r}}function it(e,t){return e.compose.slides.map(o=>({slide:o,imagePath:e.compose.frame.show===!0?t.get(o.id)??T(e,o.screenshot):T(e,o.screenshot)}))}async function Ce(e,t={}){let o=ke(e);t.orgDeckFrames&&t.orgDeckFrames.length>0&&be(o,t.orgDeckFrames);let i=t.deviceModel??o.deviceModel;t.composeOnly||await rt(o,t);let r=o.capture.mode!=="raw"||!t.captureOnly&&o.compose.frame.show===!0,n=r||!t.captureOnly?await(async()=>{let{chromium:a}=await import("playwright");return a.launch({headless:!0})})():null;try{let a=r?await nt(o,n??void 0):new Map,c=st(o,a,i);if(t.captureOnly)return{plan:o,capture:c,compose:null};let l=it(o,a),u=await we(o.compose,l,n??void 0);return{plan:o,capture:c,compose:u}}finally{n&&typeof n.close=="function"&&await n.close()}}async function Me(e,t={}){if(e.includes("--help")||e.includes("-h"))return console.log(`
|
|
86
|
+
sootsim screenshot appstore \u2014 capture and compose app-store screenshot sets
|
|
87
|
+
|
|
88
|
+
usage:
|
|
89
|
+
sootsim screenshot appstore --plan <plan.yaml> [options]
|
|
90
|
+
|
|
91
|
+
options:
|
|
92
|
+
--plan <path> screenshot plan yaml
|
|
93
|
+
--sim <id> reuse a live sim for capture
|
|
94
|
+
--app <target> override plan app target (port, url, or shell url)
|
|
95
|
+
--device <model> override plan capture device for this run
|
|
96
|
+
--org <slug> overlay copy/colors from a team's org screenshot deck
|
|
97
|
+
--repo <name> repo for --org (both required to pull the org deck)
|
|
98
|
+
--api-origin <url> sootbean origin to fetch the deck from (default: the
|
|
99
|
+
signed-in session origin, else https://sootbean.com)
|
|
100
|
+
--capture-only stop after raw/framed intermediates
|
|
101
|
+
--compose-only skip flow capture, reuse existing raw screenshots
|
|
102
|
+
|
|
103
|
+
examples:
|
|
104
|
+
sootsim screenshot appstore --plan app-store.yaml
|
|
105
|
+
sootsim screenshot appstore --plan app-store.yaml --sim a9
|
|
106
|
+
sootsim screenshot appstore --plan app-store.yaml --org acme --repo mobile
|
|
107
|
+
`),0;let o=m=>e.find((w,b)=>e[b-1]===m),i=new Set(["--plan","--sim","--app","--device","--org","--repo","--api-origin"]),r=e.filter((m,w)=>{if(m.startsWith("-"))return!1;let b=e[w-1];return!b||!i.has(b)}),s=o("--plan")||r[0];if(!s)return console.error(" error: screenshots plan path is required (`--plan <path>`)."),1;let n=o("--sim")?.trim()||null,a=o("--app")?.trim()||null,c=o("--device")?.trim()||null,l=o("--org")?.trim()||null,u=o("--repo")?.trim()||null,d=o("--api-origin")?.trim()||null,p=e.includes("--capture-only"),g=e.includes("--compose-only"),f=null;if(l||u){if(!l||!u)return console.error(" error: --org and --repo must be passed together."),1;let m=ee();if(!m)return console.error(" error: --org/--repo needs auth \u2014 run `sootsim login` or set SOOTSIM_API_KEY."),1;let w=d||(m.kind==="session"?m.origin:"https://sootbean.com");try{f=await ye({org:l,repo:u,origin:w,authHeader:te(m)})}catch(b){return console.error(` ${b.message}`),1}!f||f.length===0?console.log(` note: no org deck for ${l}/${u} \u2014 composing with the plan's copy/colors.`):console.log(` org deck: ${f.length} slide(s) from ${l}/${u}`)}try{let m=await Ce(s,{simId:n,appTarget:a,deviceModel:c,captureOnly:p,composeOnly:g,orgDeckFrames:f});return console.log(` capture manifest: ${m.capture.manifestPath}`),m.compose?(console.log(` compose manifest: ${m.compose.manifestPath}`),console.log(` exports: ${m.compose.outputs.length}`)):console.log(" compose skipped"),0}catch(m){return console.error(` screenshots failed: ${m.message}`),1}}import{mkdirSync as at,writeFileSync as ct}from"node:fs";import{dirname as lt,isAbsolute as ut,join as De,resolve as dt}from"node:path";var pt=`
|
|
108
|
+
sootsim screenshot slides \u2014 compose App Store screenshots in the live sim
|
|
109
|
+
|
|
110
|
+
usage:
|
|
111
|
+
sootsim screenshot slides list slides (alias: slides list)
|
|
112
|
+
sootsim screenshot slides set <n> [fields] patch a slide's copy/colors
|
|
113
|
+
sootsim screenshot slides add append a blank slide (focuses it)
|
|
114
|
+
sootsim screenshot slides remove <n> delete a slide
|
|
115
|
+
sootsim screenshot slides focus <n> open a slide (device flips into it)
|
|
116
|
+
sootsim screenshot slides overview back to the gallery
|
|
117
|
+
sootsim screenshot slides capture [<n>] capture the live frame into a slide
|
|
118
|
+
sootsim screenshot slides export [<n>] [--out <dir>]
|
|
119
|
+
write composed App-Store PNG(s)
|
|
120
|
+
|
|
121
|
+
set fields:
|
|
122
|
+
--title <text> headline
|
|
123
|
+
--subtitle <text> subheadline
|
|
124
|
+
--bg-top <color> gradient top (white gray slate black cyan blue
|
|
125
|
+
--bg-bottom <color> gradient bottom teal green lime gold orange coral
|
|
126
|
+
--title-color <color> copy color override, or "auto" red berry magenta
|
|
127
|
+
--title-size <s> sm | md | lg | none gray-light
|
|
128
|
+
--underlay <s> black | white | none gray-dark \u2026)
|
|
129
|
+
--shadow <s> light | medium | strong | none
|
|
130
|
+
|
|
131
|
+
notes:
|
|
132
|
+
slides are addressed by 1-based index. screenshot mode is auto-enabled.
|
|
133
|
+
capture shoots whatever the sim currently shows \u2014 navigate the app first
|
|
134
|
+
(sootsim do tap-id \u2026), then capture.
|
|
135
|
+
|
|
136
|
+
examples:
|
|
137
|
+
sootsim screenshot slides set 1 --title "The ultimate MMA community." --bg-top cyan --bg-bottom black
|
|
138
|
+
sootsim screenshot slides capture 1
|
|
139
|
+
sootsim screenshot slides export --out ./exports
|
|
140
|
+
`,mt={"--title":"title","--subtitle":"subtitle","--bg-top":"bgTop","--bg-bottom":"bgBottom","--title-color":"titleColor","--title-size":"titleSize","--underlay":"titleUnderlay","--shadow":"titleShadow","--out":"out"};function ht(e){let t=[],o={},i=!1;for(let r=0;r<e.length;r+=1){let s=e[r];if(s==="--json"){i=!0;continue}let n=s.indexOf("="),a=n>0?s.slice(0,n):s,c=mt[a];if(c){n>0?o[c]=s.slice(n+1):(o[c]=e[r+1]??"",r+=1);continue}t.push(s)}return{rest:t,values:o,json:i}}function ft(e){if(!e)return;let t=Number(e);return Number.isInteger(t)&&t>0?t:e}async function gt(e){if(!await J(e,`(async () => {
|
|
141
|
+
if (window.SootSim?.bridges?.settings?.get?.()?.screenshotMode) return true
|
|
142
|
+
window.dispatchEvent(new CustomEvent('sootsim:shell-command', {
|
|
143
|
+
detail: { type: 'fire-action', id: 'toggle-screenshot-mode' },
|
|
144
|
+
}))
|
|
145
|
+
const deadline = Date.now() + 2000
|
|
146
|
+
while (Date.now() < deadline) {
|
|
147
|
+
if (window.SootSim?.bridges?.settings?.get?.()?.screenshotMode) return true
|
|
148
|
+
await new Promise((r) => setTimeout(r, 40))
|
|
149
|
+
}
|
|
150
|
+
return false
|
|
151
|
+
})()`,{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 Ne(e,t){if(e.includes("--help")||e.includes("-h")){console.log(pt);return}let{rest:o,values:i,json:r}=ht(e),s=E(o,{port:t.port,commandTimeoutMs:45e3}),n=s.positional[0]??"list",a=ft(s.positional[1]),c=A(s),l=u=>{r?console.log(JSON.stringify(u,null,2)):wt(u)};try{switch(await gt(c),n){case"list":{l(await C(c,"SootSim.bridges.screenshotControl.getState"));break}case"set":{if(a==null)throw new Error("usage: sootsim screenshot slides set <n> --title \u2026 (see --help)");let u={};for(let d of["title","subtitle","bgTop","bgBottom","titleColor","titleSize","titleUnderlay","titleShadow"])i[d]!=null&&(u[d]=i[d]);if(Object.keys(u).length===0)throw new Error("nothing to set \u2014 pass at least one field (see --help)");l(await $(c,"SootSim.bridges.screenshotControl.setSlide",a,u));break}case"add":{l(await $(c,"SootSim.bridges.screenshotControl.addSlide"));break}case"remove":{if(a==null)throw new Error("usage: sootsim screenshot slides remove <n>");l(await $(c,"SootSim.bridges.screenshotControl.removeSlide",a));break}case"focus":{if(a==null)throw new Error("usage: sootsim screenshot slides focus <n>");l(await $(c,"SootSim.bridges.screenshotControl.focusSlide",a));break}case"overview":{l(await $(c,"SootSim.bridges.screenshotControl.overview"));break}case"capture":{let u=await $(c,"SootSim.bridges.screenshotControl.capture",...a!=null?[a]:[]);l(u);break}case"export":{let u=i.out?ut(i.out)?i.out:dt(process.cwd(),i.out):De(process.cwd(),"screenshots"),d=await C(c,"SootSim.bridges.screenshotControl.getState"),p=a!=null?d.slides.filter(f=>f.index===a||f.id===a):d.slides.filter(f=>f.captured);if(p.length===0)throw new Error(a!=null?`no slide ${a}`:"no captured slides to export \u2014 capture first");let g=[];for(let f of p){let m=await C(c,"SootSim.bridges.screenshotControl.exportSlide",f.index),w=De(u,m.name);at(lt(w),{recursive:!0}),ct(w,yt(m.dataUrl)),g.push(w),console.log(` saved: ${w} (${m.width}\xD7${m.height})`)}r&&console.log(JSON.stringify({written:g},null,2));break}default:throw new Error(`unknown subcommand "${n}" \u2014 see sootsim screenshot slides --help`)}}finally{c.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 Fe(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 z(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 yo(e,t){let o=Fe(e);if(!o||o.name==="capture"){await ue(o?z(e,o.index):e,t);return}if(o.name==="slides"){await Ne(z(e,o.index),t);return}let i=z(e,o.index),r=Fe(i);if(r?.name==="capture")try{let{runScreenshotsCapture:s}=await import("./screenshots-capture-QZSUIT4R.js");return await s(xt(z(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 Me(i,t)}export{yo as runScreenshotCommand};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*! sootsim v0.1.219 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as T}from"./chunk-LUWFFYQL.js";import"./chunk-3PMTZACY.js";import"./chunk-BTLNZG23.js";import"./chunk-PYIMY6VO.js";import{execSync as B}from"node:child_process";import{mkdirSync as L,mkdtempSync as q,rmSync as W,writeFileSync as z}from"node:fs";import{tmpdir as H}from"node:os";import{dirname as J,isAbsolute as K,join as U,resolve as V}from"node:path";import{chromium as Y}from"playwright-core";import{execSync as O}from"node:child_process";function N(r){let e=r;if(e&&typeof e.process=="function")try{let o=e.process();if(o&&typeof o.pid=="number"&&o.pid>0)return o.pid}catch{}if(e&&typeof e.browser=="function")try{let o=e.browser();if(o)return N(o)}catch{}return null}function x(r){let e=[];try{e=O(`pgrep -P ${r} || true`).toString().split(`
|
|
3
|
+
`).filter(Boolean)}catch{}for(let o of e)x(Number(o));try{process.kill(r,"SIGKILL")}catch{}}var $=new Set,A=!1;function j(){if(A)return;A=!0;let r=()=>{for(let e of $)x(e)};process.on("SIGTERM",()=>{r(),process.exit(0)}),process.on("SIGINT",()=>{r(),process.exit(0)}),process.on("exit",r)}async function M(r){let e=await r(),o=N(e),n=new Set;o!=null&&(n.add(o),$.add(o),j());let i=e;return typeof i.on=="function"&&i.on("disconnected",()=>{for(let c of n)$.delete(c)}),{browser:e,reapNow:()=>{for(let c of n)x(c),$.delete(c);n.clear()}}}var _=`
|
|
4
|
+
sootsim screenshot appstore capture \u2014 headlessly capture + upload App Store slides
|
|
5
|
+
|
|
6
|
+
usage:
|
|
7
|
+
sootsim screenshot appstore capture --org <org> --repo <repo> [options]
|
|
8
|
+
|
|
9
|
+
what it does:
|
|
10
|
+
boots the org-mode build shell in headless GPU Chrome (authed via your
|
|
11
|
+
\`sootsim login\` session), captures each slide through the live screenshot
|
|
12
|
+
composer so every slide gets editable layers (captureRef + cleanRef +
|
|
13
|
+
screenRef), and lets the shell auto-upload them to your org deck.
|
|
14
|
+
|
|
15
|
+
options:
|
|
16
|
+
--org <org> github org slug (required)
|
|
17
|
+
--repo <repo> repo name (required)
|
|
18
|
+
--branch <branch> build branch to boot (default: main)
|
|
19
|
+
--platform <p> ios | android (default: ios)
|
|
20
|
+
--slides <list> 1-based indices to capture, e.g. 1,3,5 (default: all)
|
|
21
|
+
--dry-run capture + report refs, do NOT upload (PUTs aborted)
|
|
22
|
+
--force allow overwriting a NON-EMPTY existing deck
|
|
23
|
+
--out <dir> also write composed App-Store PNGs locally
|
|
24
|
+
--shell-origin <url> origin serving /build (default: your session origin)
|
|
25
|
+
--api-origin <url> origin for deck/capture APIs (default: session origin)
|
|
26
|
+
--timeout <ms> per-step bridge timeout (default: 45000)
|
|
27
|
+
--json machine-readable summary
|
|
28
|
+
|
|
29
|
+
examples:
|
|
30
|
+
sootsim screenshot appstore capture --org acme --repo my-app --dry-run
|
|
31
|
+
sootsim screenshot appstore capture --org acme --repo my-app --branch main --force
|
|
32
|
+
`;function Q(r){let e=a=>{let c=r.indexOf(a);return c>=0?r[c+1]:void 0},o=a=>r.includes(a),n=e("--slides"),i=n?n.split(",").map(a=>Number(a.trim())).filter(a=>Number.isInteger(a)&&a>0):null;return{org:e("--org")??"",repo:e("--repo")??"",branch:e("--branch")??"main",platform:e("--platform")??"ios",slides:i&&i.length?i:null,dryRun:o("--dry-run"),force:o("--force"),out:e("--out")??null,shellOrigin:e("--shell-origin")??null,apiOrigin:e("--api-origin")??null,timeoutMs:Number(e("--timeout")??"45000")||45e3,json:o("--json")}}function X(){let r=T();if(r&&r.kind==="session")return{token:r.token,origin:r.origin};process.stderr.write(`
|
|
33
|
+
sootsim screenshot appstore capture needs a logged-in session.
|
|
34
|
+
run \`sootsim login\` first (the captured slides upload to that account).
|
|
35
|
+
|
|
36
|
+
`),process.exit(1)}function Z(r){let e=r.replace(/^\[|\]$/g,"").toLowerCase();return e==="localhost"||e.endsWith(".localhost")||e==="::1"||/^127(?:\.\d{1,3}){3}$/.test(e)}function ee(r){let e=new URL(r);if(Z(e.hostname)){let n=(Number(e.port)||3e3)-3e3;if(n>=0&&n<=1e3)return e.port=String(5173+n),e.origin}return e.hostname==="sootbean.com"||e.hostname.endsWith(".sootbean.com")?"https://sootsim.com":r}function re(){try{return Number(B("sysctl -n vm.loadavg").toString().trim().split(/\s+/)[1])||0}catch{return 0}}async function oe(r,e,o,n){let i=await fetch(`${r}/api/sootsim/screenshot-decks?org=${encodeURIComponent(o)}&repo=${encodeURIComponent(n)}`,{headers:{authorization:`Bearer ${e}`}});if(!i.ok)return[];let a=await i.json().catch(()=>null),c=[];for(let g of a?.decks??[])Array.isArray(g.config?.frames)&&c.push(...g.config.frames);return c}async function te(r,e,o,n){let i=await fetch(`${r}/api/sootsim/screenshot-capture?ref=${encodeURIComponent(n)}&org=${encodeURIComponent(o)}`,{headers:{authorization:`Bearer ${e}`}});return i.ok?`data:image/png;base64,${Buffer.from(await i.arrayBuffer()).toString("base64")}`:null}async function ne(r,e){let o=Date.now()+e;for(;Date.now()<o;){for(let n of r.frames())if(await n.evaluate(()=>!!globalThis.SootSim?.bridges?.screenshotControl).catch(()=>!1))return n;await r.waitForTimeout(250)}throw new Error("screenshot bridge never appeared \u2014 the build shell did not boot screenshot mode (check --branch/--platform has a ready build, and you are logged in)")}async function D(r){return r.evaluate(async()=>{let o=globalThis.SootSim?.bridges?.screenshotControl;if(!o)throw new Error("screenshotControl missing");return o.getState()})}async function se(r){await r.evaluate(async()=>{let e=globalThis.SootSim?.bridges?.settings,o=Date.now()+3e3;for(;Date.now()<o;){if(e?.get?.()?.screenshotMode)return;await new Promise(n=>setTimeout(n,50))}e&&!e.get().screenshotMode&&(e.set("screenshotMode",!0),e.get().showFrame||e.set("showFrame",!0))})}async function ie(r,e,o,n){await r.evaluate(async([i,a,c])=>{let g=globalThis.SootSim,h=g?.bridges?.screenshotControl;if(!h)throw new Error("screenshotControl missing");let w=b=>new Promise(d=>setTimeout(d,b));if(a){h.focusSlide(i);let b=Date.now()+3e4,d=g?.bridges?.threeMode;for(;Date.now()<b&&(d=g?.bridges?.threeMode,!(d?.setScreenImage&&d?.captureStage&&d?.getState?.()?.ready));)await w(150);await w(1e3);let l=a;d?.configure?.({colorway:l.colorway,background:l.background,...l.customGradient?{customGradient:l.customGradient}:{},setting:l.setting,focus:l.focus,environment:l.environmentActive?{pins:l.environmentPins??{},effects:l.environmentEffects??{}}:!1,pose:{phonePosition:l.phonePosition,phoneRotation:l.phoneRotation,cameraPosition:l.cameraPosition,target:l.target}}),await w(900),c&&d?.setScreenImage&&(d.setScreenImage(c),await w(1200))}await h.capture(i)},[e,o,n])}async function be(r){if(r.includes("--help")||r.includes("-h"))return console.log(_),0;let e=Q(r);if(!e.org||!e.repo)return process.stderr.write(` --org and --repo are required (see --help)
|
|
37
|
+
`),1;let{token:o,origin:n}=X(),i=(e.apiOrigin??n).replace(/\/$/,""),a=(e.shellOrigin??ee(i)).replace(/\/$/,""),c=await oe(i,o,e.org,e.repo);if(!e.dryRun&&!e.force&&c.length>0)return process.stderr.write(` refusing to overwrite the existing ${e.org}/${e.repo} deck (${c.length} slide(s)). re-run with --force to replace it, or --dry-run to preview.
|
|
38
|
+
`),1;let g=re(),h=Number(B("sysctl -n hw.ncpu").toString().trim())||8;if(g>h)return process.stderr.write(` load average ${g.toFixed(1)} exceeds ${h} cores \u2014 tear down other work first.
|
|
39
|
+
`),1;let w=`${a}/build/${encodeURIComponent(e.org)}/${encodeURIComponent(e.repo)}/${encodeURIComponent(e.branch)}?platform=${encodeURIComponent(e.platform)}&ssMode=1`,b=q(U(H(),"sootsim-capture-")),{browser:d,reapNow:l}=await M(()=>Y.launchPersistentContext(b,{headless:!0,channel:"chrome",viewport:{width:393,height:852},deviceScaleFactor:3,args:["--enable-unsafe-webgpu","--enable-features=Vulkan,WebGPU","--hide-scrollbars"]}));await d.addInitScript(s=>{try{localStorage.setItem("sootsim.session.token",s)}catch{}},o);let y=[],m=d.pages()[0]??await d.newPage();e.dryRun?await m.route(/\/api\/sootsim\/screenshot-(decks|capture)/,s=>s.request().method()==="PUT"?s.abort():s.continue()):m.on("response",s=>{let p=s.url();s.request().method()==="PUT"&&(p.includes("/api/sootsim/screenshot-decks")?y.push({kind:"deck",status:s.status()}):p.includes("/api/sootsim/screenshot-capture")&&y.push({kind:"capture",status:s.status()}))});let R=[];m.on("pageerror",s=>R.push(s.message));let E=m.waitForResponse(s=>s.url().includes("/api/sootsim/screenshot-decks")&&s.request().method()==="GET",{timeout:e.timeoutMs}).catch(()=>null);try{await m.goto(w,{waitUntil:"domcontentloaded",timeout:e.timeoutMs});let s=await ne(m,e.timeoutMs);await se(s),await E,await m.waitForTimeout(800);let p=await D(s);if(p.slides.length===0)return process.stderr.write(` the deck has no slides to capture \u2014 add slides in the composer first.
|
|
40
|
+
`),1;let v=e.slides?p.slides.filter(t=>e.slides.includes(t.index)):p.slides;console.log(` ${p.projectName} on ${p.deviceModel} \u2014 capturing ${v.length}/${p.slides.length} slide(s)${e.dryRun?" (dry-run, no upload)":""}`);for(let t of v)try{let u=c[t.index-1],f=u?.threeScene??null,C=f&&u?.screenRef?await te(i,o,e.org,u.screenRef):null;await ie(s,t.index,f,C),console.log(` \u2713 slide ${t.index} "${t.title.slice(0,40)}"`)}catch(u){console.log(` \u2717 slide ${t.index} "${t.title.slice(0,40)}" \u2014 ${u.message}`)}e.dryRun||await m.waitForTimeout(2500);let S=(await D(s)).slides.filter(t=>v.some(u=>u.id===t.id)),P=[];if(e.out){let t=K(e.out)?e.out:V(process.cwd(),e.out);for(let u of S){if(!u.captureRef)continue;let f=await s.evaluate(async k=>{let F=globalThis.SootSim?.bridges?.screenshotControl;if(!F)throw new Error("screenshotControl missing");return F.exportSlide(k)},u.index),C=f.dataUrl.match(/^data:[^;]+;base64,(.+)$/);if(C){let k=U(t,f.name);L(J(k),{recursive:!0}),z(k,Buffer.from(C[1],"base64")),P.push(k)}}}let I=S.filter(t=>t.captureRef&&t.cleanRef),G={org:e.org,repo:e.repo,branch:e.branch,dryRun:e.dryRun,slides:S.map(t=>({index:t.index,title:t.title,captureRef:!!t.captureRef,cleanRef:!!t.cleanRef,screenRef:!!t.screenRef,captureMode:t.captureMode})),editableCount:I.length,uploads:e.dryRun?"skipped (dry-run)":y,written:P,pageErrors:R.slice(0,5)};if(e.json)console.log(JSON.stringify(G,null,2));else{console.log(`
|
|
41
|
+
${I.length}/${S.length} slide(s) now have editable layers (captureRef + cleanRef)`);let t=S.filter(u=>u.captureRef&&!u.cleanRef);if(t.length&&console.log(` \u26A0 ${t.length} slide(s) baked a flat capture only (no cleanRef) \u2014 typically 3d slides whose scene didn't restore for a re-bake.`),!e.dryRun){let u=y.filter(f=>f.status>=200&&f.status<300).length;console.log(` uploads: ${u}/${y.length} PUT(s) succeeded`)}P.length&&console.log(` wrote ${P.length} local PNG(s) to ${e.out}`),R.length&&console.log(` \u26A0 ${R.length} page error(s) during capture`)}return 0}finally{await d.close().catch(()=>{}),l(),W(b,{recursive:!0,force:!0})}}export{be as runScreenshotsCapture};
|
|
@@ -1,5 +1,5 @@
|
|
|
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.219 | (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-3QEIIJ4U.js";import"./chunk-RCHJJ5GW.js";import{a as ce}from"./chunk-2U4CK5R5.js";import"./chunk-LUWFFYQL.js";import{h as ae}from"./chunk-KLTHI6RE.js";import{f as P,g as se}from"./chunk-JVJNG6BQ.js";import"./chunk-3B5UXJ3Y.js";import"./chunk-ZXFWW4MR.js";import"./chunk-PMERG7PS.js";import"./chunk-2CCJGEVS.js";import{d as oe}from"./chunk-JT5JOWHK.js";import{a as ee,b as te}from"./chunk-ZHMKPUDR.js";import"./chunk-3PMTZACY.js";import{a as re,b as ne}from"./chunk-I6SPORCZ.js";import"./chunk-C5LRFEF4.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-BTLNZG23.js";import{a as ie}from"./chunk-7RSH52LR.js";import"./chunk-PYIMY6VO.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 _=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_POSTGRES||7432),Number(process.env.VITE_PORT_R2||9500)].filter(o=>Number.isFinite(o)&&o>0)}var x=class{subscriptions=new Map;sessionsBySocket=new Map;allSockets=new Set;pendingPromptEchoes=new Map;pendingTurns=new Map;opts;constructor(e={}){this.opts=e}registerSocket(e){this.allSockets.add(e)}unregisterSocket(e){let t=this.sessionsBySocket.get(e);if(t){for(let i of t)this.decrementSubscription(i);this.sessionsBySocket.delete(e)}this.allSockets.delete(e)}async handleMessage(e,t){let i=t?.type;if(typeof i!="string"||!i.startsWith("agent:"))return!1;let 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
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===_)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===_)try{i.send(t)}catch{}}respond(e,t,i){if(e.readyState===_)try{e.send(JSON.stringify({id:t,result:i}))}catch{}}respondError(e,t,i,s){if(e.readyState===_)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
|