rnxsim 0.0.0 → 0.1.313
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/LICENSE +21 -0
- package/README.md +512 -0
- package/detox/colors.ts +54 -0
- package/detox/config-loader.ts +135 -0
- package/detox/element-types.ts +39 -0
- package/detox/expectations.ts +537 -0
- package/detox/gestures.ts +480 -0
- package/detox/index.ts +2118 -0
- package/detox/jest-preset.cjs +51 -0
- package/detox/jest-setup-after-env.cjs +18 -0
- package/detox/matchers.ts +30 -0
- package/detox/motion-change.cjs +109 -0
- package/detox/motion-change.d.cts +35 -0
- package/detox/navigation.ts +43 -0
- package/detox/screenshots/animated-color-test-rest-norngh.png +0 -0
- package/detox/screenshots/color-test-after-drag-norngh.png +0 -0
- package/detox/screenshots/color-test-rest-norngh.png +0 -0
- package/detox/screenshots/theme-blue-toggle.png +0 -0
- package/detox/screenshots/theme-blue.png +0 -0
- package/detox/screenshots/theme-red-toggle.png +0 -0
- package/detox/screenshots/theme-red.png +0 -0
- package/dist-cli/bin.js +15 -0
- package/dist-cli/chunks/agent-XZ2KTPCU.js +48 -0
- package/dist-cli/chunks/agent-wrapper-JJYYW2WH.js +17 -0
- package/dist-cli/chunks/app-fonts-IXRNQG6B.js +4 -0
- package/dist-cli/chunks/assert-54T5SK5F.js +49 -0
- package/dist-cli/chunks/auth-FI5UDI45.js +12 -0
- package/dist-cli/chunks/beta-JV6UKADW.js +4 -0
- package/dist-cli/chunks/camera-VL73YIKP.js +22 -0
- package/dist-cli/chunks/chunk-2D2UPBBR.js +4 -0
- package/dist-cli/chunks/chunk-2YR5BGA5.js +5 -0
- package/dist-cli/chunks/chunk-3NV2NCNX.js +4 -0
- package/dist-cli/chunks/chunk-46EUUFJ5.js +4 -0
- package/dist-cli/chunks/chunk-4NPPOV2N.js +5 -0
- package/dist-cli/chunks/chunk-5DHC6KHQ.js +7 -0
- package/dist-cli/chunks/chunk-5TEF3ET3.js +74 -0
- package/dist-cli/chunks/chunk-5TPRP5QT.js +4 -0
- package/dist-cli/chunks/chunk-5YJCOWCH.js +4 -0
- package/dist-cli/chunks/chunk-7GN3LVWB.js +4 -0
- package/dist-cli/chunks/chunk-BBULZ7CG.js +568 -0
- package/dist-cli/chunks/chunk-BTWORNNG.js +71 -0
- package/dist-cli/chunks/chunk-D4FFVGI5.js +5 -0
- package/dist-cli/chunks/chunk-DCEMHR2Y.js +4 -0
- package/dist-cli/chunks/chunk-DZS6WPUI.js +4 -0
- package/dist-cli/chunks/chunk-F5ZRSS3C.js +3 -0
- package/dist-cli/chunks/chunk-FSUYIVJ6.js +9 -0
- package/dist-cli/chunks/chunk-G2WW6L2C.js +23 -0
- package/dist-cli/chunks/chunk-GASE6UBA.js +4 -0
- package/dist-cli/chunks/chunk-GGRX24GF.js +142 -0
- package/dist-cli/chunks/chunk-HI5TFJWN.js +5 -0
- package/dist-cli/chunks/chunk-IJ5CAZZC.js +5 -0
- package/dist-cli/chunks/chunk-IJO63TDP.js +4 -0
- package/dist-cli/chunks/chunk-KTHV3RUS.js +26 -0
- package/dist-cli/chunks/chunk-LF2ZVT7O.js +6 -0
- package/dist-cli/chunks/chunk-MJRLLB4R.js +38 -0
- package/dist-cli/chunks/chunk-NFK7T35W.js +4 -0
- package/dist-cli/chunks/chunk-NMF2ZMZQ.js +15 -0
- package/dist-cli/chunks/chunk-OHAZNXLK.js +4 -0
- package/dist-cli/chunks/chunk-OVFJFXUD.js +101 -0
- package/dist-cli/chunks/chunk-OZSSI4WN.js +28 -0
- package/dist-cli/chunks/chunk-QKDWYITG.js +25 -0
- package/dist-cli/chunks/chunk-RSZWCKNT.js +30 -0
- package/dist-cli/chunks/chunk-RTN5C5RL.js +4 -0
- package/dist-cli/chunks/chunk-TIVZIMMW.js +4 -0
- package/dist-cli/chunks/chunk-TZFFR3SD.js +7 -0
- package/dist-cli/chunks/chunk-UC6U3MML.js +5 -0
- package/dist-cli/chunks/chunk-VFCMSYZK.js +6 -0
- package/dist-cli/chunks/chunk-VNQEB4L7.js +5 -0
- package/dist-cli/chunks/chunk-VZXWHRUZ.js +983 -0
- package/dist-cli/chunks/chunk-W6K4EFPH.js +107 -0
- package/dist-cli/chunks/chunk-WEXDAC74.js +4 -0
- package/dist-cli/chunks/chunk-WF3T4SVI.js +14 -0
- package/dist-cli/chunks/chunk-WINYQ44O.js +4 -0
- package/dist-cli/chunks/chunk-WMIIKMGK.js +10 -0
- package/dist-cli/chunks/chunk-WUSWBCWA.js +507 -0
- package/dist-cli/chunks/chunk-WWZIXIRD.js +4 -0
- package/dist-cli/chunks/chunk-XEVZYVIW.js +766 -0
- package/dist-cli/chunks/chunk-YDGQTMQL.js +4 -0
- package/dist-cli/chunks/chunk-YIFT42WN.js +4 -0
- package/dist-cli/chunks/chunk-ZMJD5GEC.js +125 -0
- package/dist-cli/chunks/cleanup-P27PA6JI.js +25 -0
- package/dist-cli/chunks/cli-version-WWLPBDQ7.js +4 -0
- package/dist-cli/chunks/compat-ZD65FED3.js +20 -0
- package/dist-cli/chunks/config-XMJRNM2A.js +13 -0
- package/dist-cli/chunks/control-KMIQT3QP.js +4 -0
- package/dist-cli/chunks/daemon-G2ME7NLB.js +4 -0
- package/dist-cli/chunks/debug-PT4HOP7N.js +200 -0
- package/dist-cli/chunks/desktop-S3FG72AK.js +31 -0
- package/dist-cli/chunks/detox-B3D4IFCN.js +52 -0
- package/dist-cli/chunks/device-XBNDSB2R.js +18 -0
- package/dist-cli/chunks/diagnose-HMQXJE5N.js +43 -0
- package/dist-cli/chunks/disk-cleanup-BLCZ5BSZ.js +4 -0
- package/dist-cli/chunks/drivers-LDECZGP2.js +4 -0
- package/dist-cli/chunks/film-BJGTBYZB.js +74 -0
- package/dist-cli/chunks/flow-UEQNVTU7.js +4 -0
- package/dist-cli/chunks/help-T5FYSVGB.js +4 -0
- package/dist-cli/chunks/hidden-runtime-alias-ANOYADHM.js +4 -0
- package/dist-cli/chunks/home-paths-GT3LFNOR.js +4 -0
- package/dist-cli/chunks/inspect-ZA6XF5LD.js +4 -0
- package/dist-cli/chunks/install-desktop-TIMUDHPL.js +4 -0
- package/dist-cli/chunks/login-FJ737MWG.js +28 -0
- package/dist-cli/chunks/logout-ZCNMMHMY.js +4 -0
- package/dist-cli/chunks/maestro-SZTNKLDF.js +104 -0
- package/dist-cli/chunks/maestro-generate-DCFAIZ4H.js +36 -0
- package/dist-cli/chunks/mode-GRMQCRXR.js +26 -0
- package/dist-cli/chunks/optional-demo-registry-W36EWFFB.js +4 -0
- package/dist-cli/chunks/perf-QYBAAUZG.js +48 -0
- package/dist-cli/chunks/permissions-3QCQ6VF4.js +13 -0
- package/dist-cli/chunks/record-QPPC2S4E.js +72 -0
- package/dist-cli/chunks/report-issue-7NMFP4HK.js +29 -0
- package/dist-cli/chunks/runtime-XOAXMSTU.js +4 -0
- package/dist-cli/chunks/screenshot-command-67AECJFB.js +159 -0
- package/dist-cli/chunks/screenshot-layers-ASWBYPJL.js +20 -0
- package/dist-cli/chunks/screenshots-capture-PXA3HFQK.js +42 -0
- package/dist-cli/chunks/serve-BI2NBAXG.js +44 -0
- package/dist-cli/chunks/setup-7DWPMRSB.js +32 -0
- package/dist-cli/chunks/skills-S3Y22TUA.js +50 -0
- package/dist-cli/chunks/storage-XUIMJWAJ.js +37 -0
- package/dist-cli/chunks/store-JTHEJLAZ.js +4 -0
- package/dist-cli/chunks/telemetry-ZYJGD2DB.js +4 -0
- package/dist-cli/chunks/timeline-TMPLQPSP.js +24 -0
- package/dist-cli/chunks/upgrade-7HDSIM7K.js +7 -0
- package/dist-cli/chunks/upload-GMSZPWM6.js +4 -0
- package/dist-cli/chunks/version-HOCHZ37L.js +6 -0
- package/dist-cli/chunks/web-DG3WBYD3.js +4 -0
- package/dist-cli/chunks/what-happened-XFVUTZR7.js +25 -0
- package/dist-lib/agent-daemon-client.cjs +468 -0
- package/dist-lib/agent-events.cjs +48 -0
- package/dist-lib/agent-identity.cjs +53 -0
- package/dist-lib/agent-sessions.cjs +725 -0
- package/dist-lib/attached-projects.cjs +526 -0
- package/dist-lib/auth/shared-session.cjs +195 -0
- package/dist-lib/backend-origin.cjs +70 -0
- package/dist-lib/beta.cjs +41 -0
- package/dist-lib/beta.mjs +13 -0
- package/dist-lib/bridge-constants.cjs +161 -0
- package/dist-lib/cli-constants.cjs +32 -0
- package/dist-lib/config.cjs +96 -0
- package/dist-lib/detox/index.cjs +2863 -0
- package/dist-lib/detox/jest-preset.cjs +51 -0
- package/dist-lib/dev-bundle-resolution.cjs +223 -0
- package/dist-lib/home-paths.cjs +421 -0
- package/dist-lib/host/bridge-host.cjs +5600 -0
- package/dist-lib/host/fetch-proxy-handler.cjs +373 -0
- package/dist-lib/host/fetch-proxy-overrides.cjs +63 -0
- package/dist-lib/host/fetch-proxy-overrides.mjs +37 -0
- package/dist-lib/host/websocket-proxy.cjs +214 -0
- package/dist-lib/index.cjs +513 -0
- package/dist-lib/jump-to-source-babel.cjs +93 -0
- package/dist-lib/menu.cjs +620 -0
- package/dist-lib/menu.mjs +581 -0
- package/dist-lib/metro.cjs +297 -0
- package/dist-lib/profiles.cjs +246 -0
- package/dist-lib/public-brand.cjs +39 -0
- package/dist-lib/render-mode.cjs +54 -0
- package/dist-lib/scripts/dev-server-scanner.cjs +1034 -0
- package/dist-lib/sdk.cjs +2333 -0
- package/dist-lib/sdk.mjs +2240 -0
- package/dist-lib/skills.cjs +23922 -0
- package/dist-lib/vite.cjs +358 -0
- package/package.json +189 -18
- package/scripts/dev-server-scanner.ts +941 -0
- package/scripts/optional-demo-registry.ts +113 -0
- package/scripts/postinstall.cjs +3 -0
- package/scripts/preuninstall.cjs +118 -0
- package/skills/contrast/SKILL.md +171 -0
- package/skills/rnx-debug/SKILL.md +425 -0
- package/skills/rnx-perf/SKILL.md +295 -0
- package/skills/rnx-setup/SKILL.md +160 -0
- package/skills/rnx-test/SKILL.md +292 -0
- package/skills/rnx-visual/SKILL.md +122 -0
- package/src/agent-daemon-client.ts +410 -0
- package/src/agent-events.ts +71 -0
- package/src/agent-identity.ts +23 -0
- package/src/agent-prompt.ts +71 -0
- package/src/agent-sessions.ts +573 -0
- package/src/attached-projects.ts +539 -0
- package/src/auth/shared-session.ts +204 -0
- package/src/backend-origin.ts +49 -0
- package/src/beta.ts +19 -0
- package/src/bridge-constants.ts +171 -0
- package/src/browser-cache.ts +16 -0
- package/src/cli-constants.ts +1 -0
- package/src/cli-version.ts +32 -0
- package/src/codex-client.ts +215 -0
- package/src/config.ts +134 -0
- package/src/dev-bundle-resolution.ts +236 -0
- package/src/disk-cleanup.ts +466 -0
- package/src/home-paths.ts +552 -0
- package/src/host/agent-host.ts +666 -0
- package/src/host/bridge-host.ts +2626 -0
- package/src/host/fetch-proxy-handler.ts +397 -0
- package/src/host/fetch-proxy-overrides.ts +51 -0
- package/src/host/open-url.ts +89 -0
- package/src/host/websocket-proxy.ts +210 -0
- package/src/index.ts +12 -705
- package/src/jump-to-source-babel.ts +135 -0
- package/src/menu.ts +734 -0
- package/src/metro-plugin.ts +139 -0
- package/src/native-dev-bundle-url.ts +96 -0
- package/src/native-seam-manifest.ts +341 -0
- package/src/plist.ts +27 -0
- package/src/poll-until.ts +92 -0
- package/src/profiles.ts +179 -0
- package/src/public-brand.ts +9 -0
- package/src/render-mode.ts +27 -0
- package/src/runtime-assets.ts +228 -0
- package/src/runtime-delivery.ts +54 -0
- package/src/screenshots/compose.ts +422 -0
- package/src/screenshots/frame-compose.ts +454 -0
- package/src/screenshots/orchestrate.ts +256 -0
- package/src/screenshots/org-deck.ts +91 -0
- package/src/screenshots/registry.ts +58 -0
- package/src/screenshots/schema.ts +364 -0
- package/src/sdk.ts +7 -0
- package/src/settings-bundle.ts +418 -0
- package/src/skills/builtin/a11y-review.ts +132 -0
- package/src/skills/builtin/compat-check.ts +71 -0
- package/src/skills/builtin/maestro-test.ts +121 -0
- package/src/skills/builtin/perf-profile.ts +90 -0
- package/src/skills/builtin/screenshot-all.ts +52 -0
- package/src/skills/builtin/visual-diff.ts +100 -0
- package/src/skills/registry.ts +107 -0
- package/src/skills/types.ts +41 -0
- package/src/team-machine-prompt.ts +73 -0
- package/src/vite-plugin-one.ts +190 -0
- package/src/vite-plugin.ts +1750 -0
- package/src/worklets-babel.ts +134 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{a as I,b as ue,c as je}from"./chunk-7GN3LVWB.js";import{m as A}from"./chunk-MJRLLB4R.js";import{m as _e,p as Te}from"./chunk-XEVZYVIW.js";import{b as Fe,j as ze}from"./chunk-WUSWBCWA.js";import{a as Ve,b as qe,d as Ge}from"./chunk-DCEMHR2Y.js";import{a as Ae,b as L,c as ce,d as de,e as Le,f as Ne,h as We,i as q,j as Ke}from"./chunk-WF3T4SVI.js";import{a as He}from"./chunk-G2WW6L2C.js";import{a as me}from"./chunk-YDGQTMQL.js";import{b as Oe,c as Me,d as le,f as De,g as Be,h as U,i as P,j as _}from"./chunk-KTHV3RUS.js";import{f as Ce}from"./chunk-VFCMSYZK.js";import{b as ae,d as Re}from"./chunk-2YR5BGA5.js";import{b as Ee,g as Ue,h as D,i as $,j as B}from"./chunk-4NPPOV2N.js";import{H as ie,K as se,M,O as ke,l as oe}from"./chunk-FSUYIVJ6.js";import{a as re}from"./chunk-2D2UPBBR.js";import{spawn as et,spawnSync as tt}from"node:child_process";import T from"node:fs";import Et from"node:os";import C from"node:path";import{WebSocket as pe}from"ws";function Je(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function $t(e,n){return e?.includes("/one/metro-entry.bundle")?"one":typeof n=="string"&&n?"expo":"unknown"}function Ye(e,n,t){return`${e}//${n}:${t}`}function Pt(e){if(typeof window>"u")return!1;try{let n=new URL(e);return I(n.hostname)&&I(window.location.hostname)&&n.origin!==window.location.origin}catch{return!1}}async function Qe(e,n){let t={...n,cache:n?.cache??"no-store"};return Pt(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,t):fetch(e,t)}function It(e){return e==="https:"?443:80}function kt(e){let n=e.pathname||"/";return(n==="/"||n==="")&&!e.search&&!e.hash}async function Ct(e){try{let n=await fetch("/__server-scan",{cache:"no-store"});if(!n.ok||!(n.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let t=await n.json();if(!Array.isArray(t))return null;let r=t.find(o=>!!o&&typeof o=="object"&&o.port===e&&typeof o.bundleUrl=="string");return r?{bundleUrl:de(r.bundleUrl),port:e,framework:typeof r.framework=="string"?r.framework:"unknown",projectName:typeof r.projectName=="string"?r.projectName:void 0}:null}catch{return null}}async function Ze(e,n){let t=e.replace(/\/+$/,"");try{if(I(new URL(t).hostname)){let r=await Ct(n);if(r)return r}}catch{}try{let r=await Qe(`${t}/`,{headers:{"expo-platform":"ios"}});if(r.ok){let o=await r.json(),i=o?.extra?.expoClient||o?.extra||{},s=typeof o?.launchAsset?.url=="string"?o.launchAsset.url:void 0;if(s||i.name)return{bundleUrl:de(s||`${t}${ce}`),port:n,framework:$t(s,i.sdkVersion),projectName:i.name}}}catch{}try{let r=await Qe(`${t}/status`);if(r.ok&&(await r.text()).includes("packager-status:running"))return{bundleUrl:`${t}${ce}`,port:n,framework:"metro"}}catch{}return null}async function Rt(e){return Ze(Ye("http:","localhost",e),e)}async function Xe(e){let n=e.trim();if(/^\d+$/.test(n)){let a=parseInt(n,10),l=await Rt(a);if(l)return l;throw Je(`localhost:${a}`)}let t=n.startsWith("http")?n:`http://${n}`,r;try{r=new URL(t)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let o=r.protocol||"http:",i=r.port?parseInt(r.port,10):It(o),s=Ye(o,r.hostname,i);if(kt(r)){let a=await Ze(s,i);if(a)return a;throw Je(s)}return{bundleUrl:r.toString(),port:i,framework:"unknown"}}var Ut=12e4,nt=100,_t=5e3,rt=1e4,Tt={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function y(e){return new Promise(n=>setTimeout(n,e))}function ot(e){let n=process.env[e]?.trim();if(!n)return null;let t=Number(n);return Number.isInteger(t)&&t>0?t:null}function Ot(){let e=ot("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??ot("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??Ut;return{timeoutMs:e,hostTimeoutMs:e+_t,intervalMs:nt,attempts:Math.max(1,Math.ceil(e/nt))}}function it(e){return e==="electron"||e==="playwright"}function fe(e,n){return n==="playwright"?e.meta?.sootsimHostDriver==="playwright":e.userAgent?.includes("Electron/")===!0}function Mt(e,n){return e.includes("--headless")?!0:e.includes("--headed")?!1:n==="playwright"&&process.platform==="linux"&&!process.env.DISPLAY&&!process.env.WAYLAND_DISPLAY?(console.error(" no display detected \u2192 running playwright headless (override with --headed)"),!0):!1}function J(e){return e.trim()}var mt=/^[A-Za-z][A-Za-z0-9+.-]*:/;function Dt(e){let n=e.trim();if(!n)throw new Error("expected <url-or-route>");return mt.test(n)||n.startsWith("/")?n:`/${n}`}function Bt(e){return e!==null&&typeof e=="object"}function At(e){let n=e.trim();return n?n.startsWith("/")?!0:mt.test(n)?!/^https?:\/\//i.test(n):!1:!1}async function Lt(e,n=!1){if(await z(e,250))return e;let t=se();if(st(e,n,t),t&&M(t)&&await z(t.bridgePort,500))return t.bridgePort;if(t&&M(t))throw new Error(`rnx bridge lockfile is fresh (port ${t.bridgePort}) but the bridge is not reachable. run \`rnxsim daemon restart\` or \`rnxsim daemon uninstall\`.`);await Nt();let r=Ft(["serve","--quiet","--port",String(e)]),o=null;r.once("exit",(s,a)=>{o=String(s??a??"unknown")}),r.unref();let i=Date.now()+rt;for(;Date.now()<i;){let s=se();if(st(e,n,s),s&&M(s)&&await z(s.bridgePort,250))return console.error(` started local bridge on port ${s.bridgePort}; run \`sootsim setup\` to install the background daemon`),s.bridgePort;if(await z(e,250))return console.error(` started local bridge on port ${e}; run \`sootsim setup\` to install the background daemon`),e;if(o)throw new Error(`rnx bridge exited before becoming ready (exit ${o})`);await y(150)}throw new Error(`rnx bridge did not start within ${Math.round(rt/1e3)}s`)}function st(e,n,t){if(!(!n||!t||!M(t)||t.bridgePort===e))throw new Error(`${re.commandName} open: requested bridge port ${e}, but the active daemon owns port ${t.bridgePort}. explicit --port never selects another bridge; stop that daemon or use an isolated SOOTSIM_HOME.`)}async function Nt(){let e=ie();if(e&&T.existsSync(oe(e)))return;console.error(" installing rnx engine runtime...");let{runRuntime:n}=await import("./runtime-XOAXMSTU.js");await n(["install"],{})}function Ft(e){let n=process.argv[1];return n&&T.existsSync(n)?et(process.execPath,[n,...e],{detached:!0,stdio:"ignore",env:process.env}):et(re.commandName,e,{detached:!0,stdio:"ignore",env:process.env})}function z(e,n){return new Promise(t=>{let r=new pe(`ws://127.0.0.1:${e}`,{handshakeTimeout:n}),o=!1,i=s=>{o||(o=!0,r.readyState===pe.OPEN?r.close():r.readyState===pe.CONNECTING&&r.terminate(),t(s))};r.once("open",()=>i(!0)),r.on("error",()=>i(!1)),setTimeout(()=>i(!1),n)})}function he(e){try{let n=new URL(e),t=n.pathname.replace(/\/+$/,"")||"/";return n.searchParams.has("open")||n.searchParams.has("port")||n.searchParams.has("bundle")||n.searchParams.has("demo")||n.pathname.includes("/sootsim/index.html")||t==="/sootsim"||n.pathname==="/__soot"||n.pathname==="/__soot/"||t==="/rn"||/^\/rn\/[^/]+$/i.test(t)||/^\/app\/[^/]+$/i.test(t)||t==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(t)||/^\/__soot\/app\/[^/]+$/i.test(t)}catch{return!1}}function jt(e){try{let n=new URL(e,"http://sootsim.local");if(n.origin!=="http://sootsim.local")return!1;let t=n.pathname.replace(/\/+$/,"")||"/";return t==="/rn"||/^\/rn\/[^/]+$/i.test(t)||/^\/app\/[^/]+$/i.test(t)||t==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(t)||/^\/__soot\/app\/[^/]+$/i.test(t)}catch{return!1}}function Ht(e,n){let t=new URL(e,"http://sootsim.local"),r=new URL(n),o=Q(r.pathname),i=t.pathname.startsWith("/__soot/")?t.pathname.slice(7):t.pathname;return r.pathname=`${o}${i}`,r.search=t.search,r.hash=t.hash,r.toString()}function Wt(e){try{let n=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(n)||/^\/build\/.+/.test(n)}catch{return!1}}async function Yn(e){let n=J(e);return(await be(n)).bundleUrl}function Kt(e){try{let n=new URL(e.startsWith("http")?e:`http://${e}`),t=n.pathname||"/";if(t!=="/"&&t!==""||n.search||n.hash||!I(n.hostname))return null;let r=n.port?Number(n.port):n.protocol==="https:"?443:80;return Number.isFinite(r)&&r>0?r:null}catch{return null}}async function be(e){let n=J(e),t=/^\d+$/.test(n)?Number(n):Kt(n);if(t&&t>0){let r=await Ne(t);if(r)return{bundleUrl:r.bundleUrl,port:r.port,framework:r.framework,projectName:r.projectName}}return Xe(n)}function Q(e){let n=e.replace(/\/+$/,"")||"/";return n==="/__soot"||n.startsWith("/__soot/")?"/__soot":""}function Vt(e,n){let t=J(e),r=new URL(n),o=Q(r.pathname);return r.pathname=`${o}/rn`,r.searchParams.delete("bundle"),r.searchParams.delete("demo"),r.searchParams.delete("app"),r.searchParams.delete("open"),r.searchParams.delete("port"),/^\d+$/.test(t)?r.pathname=`${o}/rn/${t}`:(r.pathname=`${o}/rn`,r.searchParams.set("open",t)),r.toString()}function pt(e){let n=J(e);return/^\d+$/.test(n)||/^https?:\/\//i.test(n)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(n)}async function qt(e,n,t={}){let r=t.resolvedBundle??await be(e),o=new URL(n),i=Q(o.pathname);o.pathname=`${i}/rn`,o.searchParams.delete("open"),o.searchParams.delete("port"),o.searchParams.delete("demo"),o.searchParams.delete("app");let s=t.hot===void 0?r.bundleUrl:Le(r.bundleUrl,t.hot);return o.searchParams.set("bundle",s),o.toString()}function zt(e){return e.startsWith("~/")?C.join(Et.homedir(),e.slice(2)):C.isAbsolute(e)?e:C.resolve(process.cwd(),e)}function Gt(e){let n={},t={};for(let o=0;o<e.length;o++){if(e[o]==="--replace"){let i=e[o+1];i||(console.error(" rnxsim open: --replace expects <module>=<file>"),process.exit(1));let s=i.indexOf("=");(s<=0||s===i.length-1)&&(console.error(" rnxsim open: --replace expects <module>=<file>"),process.exit(1));let a=i.slice(0,s).trim(),l=zt(i.slice(s+1).trim());T.existsSync(l)||(console.error(` rnxsim open: replacement file not found: ${l}`),process.exit(1)),n[a]={file:l},o++;continue}if(e[o]==="--remap"){let i=e[o+1],s=i?i.indexOf("="):-1;(!i||s<=0||s===i.length-1)&&(console.error(" rnxsim open: --remap expects <host:port>=<host:port>"),process.exit(1)),t[i.slice(0,s).trim()]=i.slice(s+1).trim(),o++;continue}}let r={};return Object.keys(n).length>0&&(r.modules=n),Object.keys(t).length>0&&(r.network={remap:t}),r.modules||r.network?r:void 0}async function Jt(e){if(e){let n=await q(e.bundleUrl);if(n)return me(n,{trustStart:!0})}return me(process.env.CONTRAST_REPO_DIR||process.cwd())}async function Qt(e){if(T.existsSync(C.join(oe(e),"index.html")))return;console.error(` installing configured engine runtime ${e}...`);let n=await Ce.install({version:e,setActive:!1,protectVersions:ke()});console.error(` installed engine runtime ${n.version}`)}function Yt(e,n){let t=n??(ue()?void 0:ie()??void 0);if(!t)return e;let r=new URL(e);if(!I(r.hostname)){if(!n)return e;throw new Error(`runtimeVersion ${t} requires a local rnx host; got ${r.origin}`)}return r.hostname=je(t),r.toString()}function ft(){return Oe().shellBaseUrl}function Zt(e){return Me(e)?.shellBaseUrl??Ee(e)??ft()}async function Xt(e,n){try{let t=new URL(e),r=t.searchParams.get("bundle")||"";if(!r)return e;let o=n?.appDir??await q(r)??void 0,i=We({bundleUrl:r,repoDir:o,exactProjectDir:!!n||!!o});if(i.length===0)return e;let s=await en(i);return s.length===0?e:(t.searchParams.set("appFonts",Ke(s)),t.toString())}catch{return e}}async function en(e){let n=await Promise.all(e.map(async r=>{let o=new AbortController,i=setTimeout(()=>o.abort(),1500);try{let s=await fetch(r.url,{method:"HEAD",signal:o.signal});return s.status>=200&&s.status<400?r:null}catch{return null}finally{clearTimeout(i)}})),t=[];for(let r of n)r!==null&&t.push(r);return t}async function tn(e,n,t={}){if(!e)return new URL(n).toString();if(he(e))return new URL(e).toString();if(jt(e))return Ht(e,n);let r=Tt[e.toLowerCase()];if(r){let o=new URL(n),i=Q(o.pathname);return o.pathname=`${i}${r}`,o.toString()}return pt(e)?qt(e,n,t):Vt(e,n)}async function nn(e,n){try{let t=new URL(e),r=t.searchParams.get("bundle")||"";if(!r)return e;let o=n?.appDir??await q(r)??void 0,i=Ve({bundleUrl:r,repoDir:o,exactProjectDir:!!n||!!o});return!i||i.imageUrl&&!await rn(i.imageUrl)?e:(t.searchParams.set("appSplash",qe(i)),t.toString())}catch{return e}}async function rn(e){let n=new AbortController,t=setTimeout(()=>n.abort(),1500);try{let r=await fetch(e,{method:"HEAD",signal:n.signal});return r.status>=200&&r.status<400}catch{return!1}finally{clearTimeout(t)}}async function G(e,n=ft(),t={}){let r=await tn(e,n,t),o=await nn(await Xt(r,t.project),t.project);if(!t.device)return o;let i=new URL(o);return i.searchParams.set("device",t.device),i.toString()}function at(e,n){let t=e?.url||e?.origin||n;try{let r=new URL(t);return r.searchParams.delete("bundle"),r.searchParams.delete("demo"),r.searchParams.delete("app"),r.searchParams.delete("open"),r.searchParams.delete("port"),r.searchParams.delete("inspectOpen"),r.searchParams.delete("appFonts"),r.searchParams.delete("appSplash"),r.toString()}catch{return n}}async function on(e,n,t,r={}){let o=new URL(await G(e,n,r));return o.searchParams.set("inspectOpen",t),o.toString()}async function sn(e,n,t,r={}){let o=r.attempts??30,i=r.intervalMs??500,s=r.minNodeCount??10;for(let a=0;a<o;a++){let l=P(e,{commandTimeoutMs:n,simId:t,simIdSource:"flag"});try{let d=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof d=="number"&&d>s)return{bridge:l,count:d}}catch{}l.close(),await y(i)}return null}function an(e){if(!e)return null;try{let n=new URL(e);if(n.searchParams.has("bundle")){let t=n.searchParams.get("bundle")||"";try{let r=new URL(t),o=r.pathname.length>36?`...${r.pathname.slice(-36)}`:r.pathname;return`bundle ${r.host}${o}`}catch{return"bundle"}}return n.searchParams.has("port")?`connect :${n.searchParams.get("port")||""}`:n.searchParams.has("open")?`connect ${n.searchParams.get("open")||""}`:n.searchParams.has("demo")?`demo ${n.searchParams.get("demo")||"default"}`:n.pathname.includes("/sootsim/index.html")||n.pathname==="/sootsim/"||n.pathname==="/sootsim"?"embedded rnx":null}catch{return null}}function ln(e){let n=e.indexOf(":");if(n<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let t=e.slice(0,n),r=e.slice(n+1),o=r.length>12?`${r.slice(0,8)}\u2026`:r;return t==="TM_SESSION"||t==="CLAUDE_CODE_SESSION_ID"||t==="CODEX_THREAD_ID"?`agent ${o}`:`${t} ${o}`}function Zn(e,n){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
|
|
5
|
+
`);for(let t of e){let r=t.lockedBy&&t.lockExpiresAt?`locked by ${ln(t.lockedBy)} (${Math.max(0,Math.round((t.lockExpiresAt-Date.now())/1e3))}s)`:"",o=[t.isPrimary?"primary":"",t.id===n?"selected":"",t.readyState,t.userVisible===!1?"hidden":t.userVisible===!0?"visible":"",t.attachedCliCount&&t.attachedCliCount>0?"in use":"",t.userFocused?"focused":"",r].filter(Boolean);console.log(` ${t.id}${o.length?` [${o.join(", ")}]`:""}`);let i=an(t.url);if(i)console.log(` loaded: ${i}`);else if(t.url){let a=t.url.length>96?`${t.url.slice(0,93)}\u2026`:t.url;console.log(` url: ${a}`)}else t.origin&&console.log(` origin: ${t.origin}`);let s=cn(t);s&&console.log(` engine: ${s}`),t.title&&console.log(` title: ${t.title}`),t.visibilityState&&t.visibilityState!=="visible"&&console.log(` visibility: ${t.visibilityState}`),console.log(` connected: ${lt(Date.now()-t.connectedAt)}`),t.lastActiveAt&&t.lastActiveAt>0&&console.log(` last active: ${lt(Date.now()-t.lastActiveAt)}`)}}function cn(e){let n=e.url||e.origin||"";if(!n)return null;try{let t=new URL(n).port;return t==="5173"?"dev \u2014 local source (:5173)":t==="3000"?"Contrast app embedded (:3000)":ue()?`dev \u2014 local build (:${t||"?"})`:`runtime \u2014 published engine (:${t||"?"})`}catch{return null}}function lt(e){let n=Math.max(0,Math.round(e/1e3));return n<60?`${n}s ago`:n<3600?`${Math.round(n/60)}m ago`:n<86400?`${Math.round(n/3600)}h ago`:`${Math.round(n/86400)}d ago`}async function Xn(e,n,t,r={}){let o=r.attempts??30,i=r.intervalMs??500;for(let s=0;s<o;s++){let a=P(e,{commandTimeoutMs:n});try{let d=(await a.listSims()).find(t);if(d)return d}catch{}finally{a.close()}await y(i)}return null}async function dn(e,n,t,r,o={}){let i=o.attempts??30,s=o.intervalMs??500,a=!!r&&Number.isInteger(r)&&r>1,l=()=>a&&r!==void 0&&!we(r);for(let d=0;d<i;d++){if(l())return{kind:"host-exit"};let c=P(e,{commandTimeoutMs:n});try{let g=(await c.listSims()).find(t);if(g)return l()?{kind:"host-exit"}:{kind:"match",sim:g}}catch{}finally{c.close()}if(l())return{kind:"host-exit"};await y(s)}return{kind:"timeout"}}async function un(e,n,t,r={}){let o=r.attempts??20,i=r.intervalMs??250;for(let s=0;s<o;s++){let a=P(e,{commandTimeoutMs:n});try{let d=(await a.listSims()).find(c=>c.id===t);if(!d||d.readyState!=="open")return!0}catch{return!0}finally{a.close()}await y(i)}return!1}function mn(e){let n=e.meta;if(!n||n.sootsimHostDriver!=="playwright")return null;let t=Number(n.sootsimHostPid);return!Number.isInteger(t)||t<=1||t===process.pid?null:t}function pn(e){if(!e.connectAckFile)return!1;try{return T.writeFileSync(e.connectAckFile,`${JSON.stringify({connectedAt:Date.now(),pid:e.pid??null})}
|
|
6
|
+
`,{flag:"w"}),!0}catch{return!1}}function ct(e){if(e.diagnosticLogPath)try{let n=T.readFileSync(e.diagnosticLogPath,"utf8").trim();if(!n){console.error(` ${C.basename(e.diagnosticLogPath)} was empty`);return}let t=n.length>4e3?`\u2026
|
|
7
|
+
${n.slice(-4e3)}`:n;console.error(` ${C.basename(e.diagnosticLogPath)}:`),console.error(t)}catch(n){let t=n instanceof Error?n.message:String(n);console.error(` failed to read ${C.basename(e.diagnosticLogPath)}: ${t}`)}}function we(e){try{return process.kill(e,0),!0}catch(n){return n?.code==="EPERM"}}async function fn(e,n=2500){let t=Date.now()+n;for(;Date.now()<t;){if(!we(e))return!0;await y(100)}return!we(e)}function gn(e){let n=tt("ps",["-o","command=","-p",String(e)],{encoding:"utf8",stdio:["ignore","pipe","pipe"]}),t=tt("ps",["eww","-o","command=","-p",String(e)],{encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(n.status!==0||t.status!==0)return!1;let r=(n.stdout||"").trimEnd(),o=(t.stdout||"").trimEnd();return(o.startsWith(r)?o.slice(r.length):o).includes("SOOTSIM_PW_URL=")}async function ge(e,n){let t=new Set(n),r=new Set;for(let o of e){if(!t.has(o.id))continue;let i=mn(o);i&&r.add(i)}for(let o of r){if(!gn(o)){console.log(` skipped pid ${o}: not a rnx playwright host (stale sim record)`);continue}try{process.kill(o,"SIGTERM")}catch{}if(await fn(o)){console.log(` closed playwright host process ${o}`);continue}try{process.kill(o,"SIGKILL"),console.log(` force-closed playwright host process ${o}`)}catch{}}}function Y(e,n){if(n){let o=n.trim(),i=e.find(s=>s.id===o);if(!i)throw new Error(`no sim connected with id ${o}`);return i}let t=e.find(o=>o.isPrimary&&o.readyState==="open");if(t)return t;let r=e.find(o=>o.readyState==="open");if(r)return r;throw new Error("no sim connected")}function dt(e,n,t){console.log(` ${t==="current sim"?"loaded":"opened"}: ${e} [${t}]`),console.log(` current sim: ${n.id}`),console.log(JSON.stringify({simId:n.id,url:n.url},null,2))}async function ut(e,n,t){if(t.includes("--no-describe"))return;let r=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await hn(e,n,{stableMs:150,maxMs:400});let o=P(e,{commandTimeoutMs:3e3,simId:n,cliLabel:"open --describe",simIdSource:"flag"});try{let i=null;try{i=await o.send({type:"evaluate",code:_e})}catch{}if(i&&!(i.flag===!0&&!i.loadingText&&Te(i))){let c=i.loadingText?`still showing "${i.loadingText}"`:i.flag!==!0?"guest ready event has not fired":i.targets<=0?"no visible app content is inspectable yet":"app tree is still stabilizing";console.log(` app still loading: ${c} (nodes: ${i.nodes}, targets: ${i.targets})`),console.log(" before interacting, run: rnxsim wait ready --max-ms 120000")}let a=`(async () => {
|
|
8
|
+
const t = window.__sootsimTest
|
|
9
|
+
const ms = window.SootSim?.bridges?.mainShell
|
|
10
|
+
if (!t) return null
|
|
11
|
+
let shell = null
|
|
12
|
+
try { shell = ms?.getState ? await ms.getState() : null } catch {}
|
|
13
|
+
const tree = await t.dumpTree(12, ${JSON.stringify({describe:!0,verbose:!1,filter:""})})
|
|
14
|
+
return { tree, shell }
|
|
15
|
+
})()`,l=await o.send({type:"evaluate",code:a});if(!l?.tree)return;if(console.log(""),l.shell?.state){let d=[`state=${l.shell.state}`,l.shell.activeApp?`app=${l.shell.activeApp}`:null].filter(Boolean);console.log(` shell: ${d.join(" ")}`)}console.log(l.tree)}finally{o.close()}}catch{}finally{r===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=r}}async function hn(e,n,t){let r=Date.now()+t.maxMs,o="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",i=P(e,{commandTimeoutMs:2e3,simId:n,simIdSource:"flag"});try{let s=-1,a=0;for(;Date.now()<r;){let l=-1;try{let d=await i.send({type:"evaluate",code:o});typeof d=="number"&&(l=d)}catch{}if(l>=0&&l===s){if(Date.now()-a>=t.stableMs)return}else s=l,a=Date.now();await y(50)}}finally{i.close()}}async function wn(e,n={}){let t=U(e,{port:n.port,commandTimeoutMs:n.timeoutMs});t.positional.length!==1&&(console.error(" rnxsim open: expected exactly one <url-or-route>"),console.error(" examples: rnxsim open /settings | rnxsim open myapp://settings"),process.exit(1));let r;try{r=Dt(t.positional[0]??"")}catch(s){console.error(` rnxsim open: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}let o=_(t),i=t.simId?` --sim ${t.simId}`:"";try{let s=await o.send({type:"call",path:"SootSim.bridges.test.openDeepLink",args:[r]});if(Bt(s)&&s.ok===!1)throw new Error(typeof s.error=="string"?s.error:"deep-link dispatch failed");console.log(` opened deep link: ${r}`)}catch(s){console.error(` link failed: ${s instanceof Error?s.message:String(s)}`),await A(o,{errorsCommand:`rnxsim get errors 5${i}`,warningsCommand:`rnxsim get warnings 5${i}`,requestsCommand:`rnxsim get requests 5${i}`}),process.exit(1)}finally{o.close()}}async function er(e,n={}){let t=U(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--new","--headless","--headed","--ephemeral","--hot","--no-hmr","--no-describe"],stripValueFlags:["--base-url","--replace","--driver","--profile","--cdp-port","--device","--viewport"]}),r=e.find((p,m)=>e[m-1]==="--profile"),o=e.includes("--ephemeral"),i=e.find((p,m)=>e[m-1]==="--cdp-port"),s=i?Number(i):void 0;i&&(!Number.isFinite(s)||s<=0)&&(console.error(` rnxsim open: --cdp-port must be a positive port number, got "${i}"`),process.exit(1)),r&&o&&(console.error(" rnxsim open: --profile cannot be combined with --ephemeral"),process.exit(1));let a=r?Fe(r).id:void 0,l=e.includes("--new")||!!a||o,d=Gt(e);l&&t.simIdSource==="flag"&&(console.error(" rnxsim open: --new, --profile, and --ephemeral cannot be combined with --sim"),process.exit(1));let c=t.positional[0]||"";if(At(c)){l&&(console.error(" rnxsim open: deep links target the current app; remove --new, --profile, or --ephemeral"),process.exit(1)),await wn(e,n);return}if(Wt(c)){let p=(()=>{try{return I(new URL(c).hostname)}catch{return!1}})();console.log(" that\u2019s an rnxsim preview/build link \u2014 a full player page, not a driveable sim."),console.log(" opening it in your browser for viewing\u2026");try{await Ge(c,{background:!1})}catch(m){console.error(` could not launch a browser: ${m instanceof Error?m.message:String(m)}`),console.error(` open it yourself: ${c}`),process.exit(1)}console.log(p?" to drive it under the CLI, point `rnxsim open` at the app\u2019s dev port instead (e.g. `rnxsim open 8081`).":" the CLI can\u2019t drive a remote preview (the engine only attaches to the local bridge from localhost). to drive the app, run it locally and `rnxsim open <port>`.");return}let u=pt(c)?await be(c):void 0,g=await Jt(u),O=await He(g),N=O?.runtimeVersion,F=Ae(O?{...O,runtimeVersion:void 0}:void 0,d);N&&await Qt(N);let Z=e.find((p,m)=>e[m-1]==="--base-url");if(Z&&!t.explicitPort){let p=le(Z);p&&(t.wsPort=p)}t.wsPort=await Lt(t.wsPort,t.explicitPort);let R=e.find((p,m)=>e[m-1]==="--driver")||"";R&&!it(R)&&(console.error(` unknown driver "${R}" \u2014 run \`rnxsim list --drivers\``),process.exit(1));let S=it(R)?R:"playwright",ht=Mt(e,S);s&&S!=="playwright"&&(console.error(" rnxsim open: --cdp-port is only honored by the playwright driver"),process.exit(1));let ve=e.includes("--hot"),ye=e.includes("--no-hmr");ve&&ye&&(console.error(" rnxsim open: --hot and --no-hmr cannot be combined"),process.exit(1));let wt=ve?!0:ye?!1:R!=="playwright",k=e.find((p,m)=>e[m-1]==="--device");k&&!(k in ae)&&(console.error(` rnxsim open: unknown device "${k}"`),console.error(` known devices: ${Re().join(", ")}`),process.exit(1));let X=k?ae[k]:void 0,j=e.find((p,m)=>e[m-1]==="--viewport"),H=j?/^(\d+)x(\d+)$/.exec(j):null;j&&!H&&(console.error(` rnxsim open: --viewport must be <width>x<height>, got "${j}"`),process.exit(1));let bt=H?{width:Number(H[1]),height:Number(H[2])}:void 0,W={hot:wt,device:k,resolvedBundle:u,project:g},vt=N?`http://localhost:${t.wsPort}/`:Z||Zt(t.wsPort),x=Yt(vt,N),Se=e.includes("--base-url");De(t.wsPort,x);let yt=D();if(!l){let p=_(t),m=t.simId?` --sim ${t.simId}`:"",ne=!1;try{let f=null,V=null;try{let h=await p.listSims();if(t.simIdSource==="saved")f=h.find(w=>w.id===yt&&w.readyState==="open"&&fe(w,S))??null,f||B();else if(t.simIdSource==="flag"&&(f=Y(h,t.simId),!fe(f,S)))throw new Error(`sim ${f.id} is not managed by the ${S} driver`);if(!f&&t.simIdSource!=="flag"){V=await G(c,L(x,F),W);let w=new URL(V);w.searchParams.delete("inspectOpen"),f=h.find(v=>{if(v.readyState!=="open"||!v.url||!fe(v,S))return!1;try{let Ie=new URL(v.url);return Ie.searchParams.delete("inspectOpen"),Ie.toString()===w.toString()}catch{return!1}})??null}if(!f)if(t.simIdSource!=="flag")ne=!0;else throw new Error("no sim connected");if(!ne&&f){let w=Se||he(c)?x:at(f,x),v=V??await G(c,L(w,F),W);p.send({type:"evaluate",simId:f.id,code:`window.location.href = ${JSON.stringify(v)}`}).catch(()=>{})}}catch(h){console.error(` open failed: ${h instanceof Error?h.message:String(h)}`),await A(p,{errorsCommand:`rnxsim get errors 5${m}`,warningsCommand:`rnxsim get warnings 5${m}`,requestsCommand:`rnxsim get requests 5${m}`}),process.exit(1)}if(!ne&&f){await y(1500);let h=await sn(t.wsPort,t.commandTimeoutMs,f.id);h||(console.error(" timed out waiting for current sim to load target"),process.exit(1)),h.bridge.close(),$(f.id);let w=Se||he(c)?x:at(f,x),v=V??await G(c,L(w,F),W);dt(v,{...f,url:v},"current sim"),await ut(t.wsPort,f.id,e);return}}finally{p.close()}}let St=L(x,F),xe=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,$e=await on(c,St,xe,W),Pe=Ue();Pe||(console.error(" could not resolve a stable owning process; refusing unsupervised sim host"),process.exit(1));let xt=p=>p.url?.includes(`inspectOpen=${xe}`)??!1,E=ze(S);E||(console.error(` unknown driver "${S}" \u2014 run \`rnxsim list --drivers\``),process.exit(1));let K=Ot(),b=await E.launch({url:$e,bridgePort:le(x)??t.wsPort,headless:ht,profileId:a,ephemeralProfile:o,cdpPort:s,device:k,ownerPid:Pe,viewport:bt??(X?{width:X.width+120,height:X.height+60}:void 0),connectTimeoutMs:K.hostTimeoutMs});b.launched||(console.error(` ${E.name} driver: ${b.message}`),process.exit(1));let ee=await dn(t.wsPort,t.commandTimeoutMs,xt,b.pid,{attempts:K.attempts,intervalMs:K.intervalMs});if(ee.kind==="host-exit"&&(ct(b),console.error(` ${E.name} host crashed \u2014 sim is no longer attached`),process.exit(1)),ee.kind==="timeout"){if(b.pid)try{process.kill(b.pid,"SIGTERM"),console.error(` closed ${E.name} host process ${b.pid}`)}catch{}ct(b),console.error(` timed out after ${K.timeoutMs}ms waiting for opened sim to connect`),process.exit(1)}let te=ee.sim;$(te.id),pn(b),dt($e,te,`${E.name} driver`),await ut(t.wsPort,te.id,e)}async function gt(e,n={}){let t=U(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--force"]}),r=e.includes("--force"),o=_(t),i=t.simId?` --sim ${t.simId}`:"";try{try{let s=await o.listSims(),a=Y(s,t.positional[0]||t.simId);if(a.lockedBy&&a.lockExpiresAt&&a.lockExpiresAt>Date.now()){let l=Math.max(0,Math.round((a.lockExpiresAt-Date.now())/1e3));a.lockedByKind==="user-active"&&(console.error(` refused: ${a.id} is locked by the active user (${l}s) \u2014 that's a live human tab`),console.error(" run `rnxsim open --new` for a fresh investigation sim"),process.exit(1)),r||(console.error(` refused: ${a.id} is leased by ${a.lockedBy} (${l}s)`),console.error(` \`sootsim use ${a.id} --force\` to take it, or \`rnxsim open --new\` for a fresh sim`),process.exit(1))}await o.focusSim(a.id),$(a.id),console.log(` using: ${a.id}`)}catch(s){console.error(` use failed: ${s instanceof Error?s.message:String(s)}`),await A(o,{errorsCommand:`rnxsim get errors 5${i}`,warningsCommand:`rnxsim get warnings 5${i}`,requestsCommand:`rnxsim get requests 5${i}`}),process.exit(1)}}finally{o.close()}}async function tr(e,n={}){await gt(e,n)}async function nr(e,n={}){await gt(e,n)}async function rr(e,n={}){let t=U(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--force"]}),r=e.includes("--force"),o=_(t);try{try{let i=await o.listSims(),s=Y(i,t.positional[0]||t.simId),a=r&&s.lockedBy&&s.lockedByKind!=="user-active"?s.lockedBy:null,l=await o.claim(s.id,{force:r});$(s.id);let d=Math.max(0,Math.round((l.lockExpiresAt-Date.now())/1e3)),c=l.bootedCount>0?` (booted ${l.bootedCount})`:"";console.log(` claimed: ${l.simId} [${d}s]${c}`),a&&console.log(` took over from: ${a}`)}catch(i){if(i instanceof Be){let s=Math.max(0,Math.round(i.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${i.lock.by} for ${s}s more`),console.error(" use --force to take it, or `rnxsim open --new` for a fresh sim"),process.exit(1)}console.error(` claim failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1)}}finally{o.close()}}async function bn(e,n,t,r){if(r.length===0)return{closed:[],remaining:[]};await Promise.all(r.map(i=>e.closeSim(i).catch(()=>{})));let o=new Set(r);for(let i=0;i<40;i++){let s=[];try{let a=P(n,{commandTimeoutMs:t});try{s=(await a.listSims()).filter(d=>o.has(d.id)&&d.readyState==="open").map(d=>d.id)}finally{a.close()}}catch{s=[]}if(s.length===0)return{closed:[...o],remaining:[]};if(i===39)return{closed:[...o].filter(a=>!s.includes(a)),remaining:s};await y(250)}return{closed:[...o],remaining:[]}}function vn(e,n){let t=e.filter(u=>u.readyState==="open"),r=t.map(u=>u.id),o=n.explicitKeepId?.trim()||"",i=n.savedKeepId?.trim()||"",s=i?t.some(u=>u.id===i):!1,a=i&&!s?i:null,l=null,d=null,c=null;if(n.closeOthers)if(o){let u=t.find(g=>g.id===o);u?l=u.id:d=o}else if(i&&s)l=i;else{let u=t.find(g=>g.isPrimary)??t[0]??null;u&&(l=u.id,i&&!s&&(c=u.id))}return{openIds:r,keepId:l,targets:d?[]:r.filter(u=>u!==l),staleSavedId:a,missingExplicitKeepId:d,fallbackKeepId:c}}async function or(e,n={}){let t=U(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--all","--others"]}),r=_(t),o=t.simId?` --sim ${t.simId}`:"",i=e.includes("--all"),s=e.includes("--others");if(i||s){try{let a=await r.listSims(),l=D(),d=t.positional[0]||(t.simIdSource==="flag"?t.simId:void 0),c=vn(a,{closeOthers:s,explicitKeepId:d,savedKeepId:l});if(c.staleSavedId&&B(),c.fallbackKeepId&&($(c.fallbackKeepId),console.log(` saved sim ${c.staleSavedId} is gone \u2014 keeping primary ${c.fallbackKeepId}`)),c.missingExplicitKeepId&&(console.error(` close failed: keep sim ${c.missingExplicitKeepId} is not connected; not closing other sims`),process.exit(1)),c.targets.length===0){console.log(c.keepId?` nothing to close \u2014 only the kept sim ${c.keepId} is connected`:c.staleSavedId?` nothing to close \u2014 no sims connected (cleared stale current sim ${c.staleSavedId})`:" nothing to close \u2014 no sims connected");return}let u=await bn(r,t.wsPort,t.commandTimeoutMs,c.targets);await ge(a,c.targets);let g=D();g&&u.closed.includes(g)&&(c.keepId?$(c.keepId):B());let O=` closed ${u.closed.length} sim(s)${c.keepId?` (kept ${c.keepId})`:""}`;console.log(O),u.remaining.length>0&&(console.error(` close failed: still connected: ${u.remaining.join(", ")}`),process.exit(1))}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}finally{r.close()}return}try{try{let a=await r.listSims(),l=Y(a,t.positional[0]||t.simId),d=a.find(u=>u.id!==l.id&&u.readyState==="open");await r.closeSim(l.id),await un(t.wsPort,t.commandTimeoutMs,l.id)||(await ge(a,[l.id]),console.error(` close failed: ${l.id} is still connected`),process.exit(1)),await ge(a,[l.id]),D()===l.id&&(d?$(d.id):B()),console.log(` closed: ${l.id}`)}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),await A(r,{errorsCommand:`rnxsim get errors 5${o}`,warningsCommand:`rnxsim get warnings 5${o}`,requestsCommand:`rnxsim get requests 5${o}`}),process.exit(1)}}finally{r.close()}}export{Ot as a,Dt as b,Lt as c,Yn as d,Yt as e,ft as f,Zt as g,G as h,on as i,an as j,Zn as k,Xn as l,dn as m,mn as n,pn as o,ge as p,wn as q,er as r,tr as s,nr as t,rr as u,bn as v,vn as w,or as x};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
function p(){console.error(" no rnxsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" rnxsim desktop install"),console.error(""),console.error(" or run setup to install the background daemon:"),console.error(" rnxsim setup"),console.error("")}function t(r){console.error(""),console.error(` no sim is connected to the rnx bridge on port ${r}.`),console.error(""),console.error(" start your app dev server, then open it in rnx:"),console.error(" npx expo start --localhost --port 8081"),console.error(" rnxsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" rnxsim describe")}async function m(r,n,s){let e=[];try{e=await r.listSims()}catch{}if(console.error(""),e.length===0){t(n);return}console.error(` no sim with id "${s}" is connected to the bridge on port ${n}.`),console.error(""),console.error(" connected sims:");for(let o of e){let i=[o.isPrimary?"primary":null,o.readyState,o.userVisible===!1?"hidden":o.userVisible===!0?"visible":null,o.userFocused?"focused":null].filter(Boolean).join(", ");console.error(` ${o.id} (${i})`)}console.error(""),console.error(" pass a valid --sim id, or run `rnxsim list` to see all sessions.")}export{p as a,t as b,m as c};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{a as K,b as V,c as Le}from"./chunk-WEXDAC74.js";import{c as Ne,d as Ce}from"./chunk-DCEMHR2Y.js";import{k as Fe}from"./chunk-WF3T4SVI.js";import{h as Pe,j as $e,l as B}from"./chunk-KTHV3RUS.js";import{c as _e,d as E}from"./chunk-IJO63TDP.js";import{a as Ue}from"./chunk-HI5TFJWN.js";import{a as Ae}from"./chunk-2D2UPBBR.js";import{createHash as vt}from"crypto";import{readFileSync as M}from"fs";import qe from"path";import{gzipSync as ge,gunzipSync as xt}from"zlib";function Oe(e){let t=(e||"").toLowerCase().split(";")[0].trim();return t?!(t.startsWith("image/")||t.startsWith("video/")||t.startsWith("audio/")||t==="font/woff2"||t==="application/font-woff2"||t==="application/zip"||t==="application/gzip"):!0}import{brotliCompressSync as ct,constants as dt}from"node:zlib";var pt=9;function ze(e){return ct(e,{params:{[dt.BROTLI_PARAM_QUALITY]:pt}})}function ce(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(new Error(`${t} timed out after ${e/1e3}s`)),e);return{signal:r.signal,cancel:()=>clearTimeout(s)}}async function ft(e){let t=ce(12e4,`PUT ${e.url}`),r;try{r=await fetch(e.url,{method:"PUT",headers:{"content-type":e.contentType},body:e.bytes,signal:t.signal})}finally{t.cancel()}if(!r.ok){let s=await r.text().catch(()=>"");throw new Error(`PUT ${e.url} failed ${r.status}: ${s.slice(0,200)}`)}}async function mt(e,t=8,r){let s=0,o=0,i=e.length;await Promise.all(Array.from({length:Math.min(t,i)},async()=>{for(;s<i;){let l=e[s++];await ft(l),o++,r?.(o,i)}}))}function gt(e,t,r,s){let o=[];o.push({url:e.bundle.putUrl,contentType:e.bundle.contentType,bytes:t});for(let i of e.files){let l=r.get(i.urlhash);l&&o.push({url:i.putUrl,contentType:i.contentType,bytes:l})}e.events&&s?.eventsBytes&&o.push({url:e.events.putUrl,contentType:e.events.contentType,bytes:s.eventsBytes}),e.timeline&&s?.timelineBytes&&o.push({url:e.timeline.putUrl,contentType:e.timeline.contentType,bytes:s.timelineBytes}),e.flowVideo&&s?.videoBytes&&o.push({url:e.flowVideo.putUrl,contentType:e.flowVideo.contentType,bytes:s.videoBytes}),e.storage&&s?.storageBytes&&o.push({url:e.storage.putUrl,contentType:e.storage.contentType,bytes:s.storageBytes}),e.failureBundle&&s?.failureBundleBytes&&o.push({url:e.failureBundle.putUrl,contentType:e.failureBundle.contentType,bytes:s.failureBundleBytes});for(let i of e.snapshots??[]){let l=s?.snapshotBytes?.get(i.id);l&&o.push({url:i.putUrl,contentType:i.contentType,bytes:l})}return o}function ht(e){return e.replace(/\/+$/,"")}var W=class extends Error{constructor(r,s,o,i=""){super(r);this.status=s;this.phase=o;this.responseText=i;this.name="PresignedUploadError"}};async function De(e){let t=ht(e.originBase),r={"content-type":"application/json"};e.authHeader&&(r.authorization=e.authHeader),e.adminBypassToken&&(r["x-contrast-admin-upload-bypass"]=e.adminBypassToken);let s=ce(3e4,"init"),o;try{o=await fetch(`${t}/api/preview/upload/init`,{method:"POST",headers:r,body:JSON.stringify(e.initBody),signal:s.signal})}finally{s.cancel()}if(!o.ok){let T=await o.text().catch(()=>"");throw new W(`init failed: ${o.status} ${T.slice(0,200)}`,o.status,"init",T)}let i=await o.json(),l=gt(i,e.bundleBytes,e.filesByHash,e.extras);await mt(l,e.concurrency??8,e.onPutProgress);let f=ce(3e4,"finalize"),c;try{c=await fetch(`${t}/api/preview/upload/finalize`,{method:"POST",headers:r,body:JSON.stringify({token:i.token}),signal:f.signal})}finally{f.cancel()}if(!c.ok){let T=await c.text().catch(()=>"");throw new W(`finalize failed: ${c.status} ${T.slice(0,200)}`,c.status,"finalize",T)}let h=await c.json();return{init:i,finalize:h}}function yt(e){return e!==null&&typeof e=="object"?e:null}function He(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function de(e){let t=yt(e);return t?t.schemaVersion===1&&He(t.t)!==void 0&&He(t.seq)!==void 0&&typeof t.context=="string"&&typeof t.kind=="string"&&"data"in t:!1}function bt(e,t){let r=[];for(let s of e.split(`
|
|
5
|
+
`)){let o=s.trim();if(o)try{let i=JSON.parse(o);t(i)&&r.push(i)}catch{}}return r}function je(e){return bt(e,de)}import{execSync as wt}from"child_process";function fe(e){try{return wt(e,{stdio:["ignore","pipe","ignore"],timeout:3e3,encoding:"utf8"}).trim()||null}catch{return null}}function pe(e){let t=e?.trim();return!t||!/^\d+$/.test(t)?null:Number(t)}function Mt(){let e=fe("git remote get-url origin");if(!e)return null;let t=e.match(/github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i);return t?{owner:t[1],repo:t[2]}:null}function me(){let e=process.env.GITHUB_ACTIONS==="true",t=process.env.CONTRAST_BRANCH?.trim()||null,r=process.env.CONTRAST_SHA?.trim()||null,s=process.env.CONTRAST_PR_TITLE?.trim()||null,o=(process.env.CONTRAST_REPO||process.env.GITHUB_REPOSITORY||"").trim(),[i,l]=o.includes("/")?o.split("/",2):[null,null];if(e){let h=process.env.GITHUB_REF?.match(/^refs\/pull\/(\d+)\//)?.[1];return{owner:i,repo:l,branch:t||process.env.GITHUB_HEAD_REF?.trim()||process.env.GITHUB_REF_NAME?.trim()||null,commitSha:r||process.env.GITHUB_SHA?.trim()||null,githubUsername:process.env.GITHUB_ACTOR?.trim()||null,pullRequestNumber:pe(process.env.CONTRAST_PR_NUMBER)??pe(h),pullRequestTitle:s,githubRunId:process.env.GITHUB_RUN_ID?.trim()||null,source:"ci"}}let f=t??fe("git rev-parse --abbrev-ref HEAD"),c=i?null:Mt();return{owner:i??c?.owner??null,repo:l??c?.repo??null,branch:f==="HEAD"?null:f,commitSha:r??fe("git rev-parse HEAD"),githubUsername:null,pullRequestNumber:pe(process.env.CONTRAST_PR_NUMBER),pullRequestTitle:s,githubRunId:null,source:"cli"}}function Qt(e){if(e.length===0)return{stepCount:null,failedStepIndex:null};let t=e.find(r=>r.status==="failure");return{stepCount:e.length,failedStepIndex:t?t.stepIndex:null}}function Xt(e){return e.auth?e.uploadedShare?!0:e.auth.kind==="github"||process.env.GITHUB_ACTIONS==="true":!1}async function Zt(e){let t=e.auth??K();if(!t)return null;let r=me(),s=e.owner??(t.kind==="github"?t.owner:null)??r.owner,o=e.repo??(t.kind==="github"?t.repo:null)??r.repo;try{let i=await fetch(`${e.origin.replace(/\/$/,"")}/api/sootsim/test-runs`,{method:"POST",headers:{"content-type":"application/json",authorization:V(t)},body:JSON.stringify({kind:e.kind,source:r.source,name:e.name??void 0,prompt:e.prompt??void 0,summary:e.summary??void 0,status:e.status,failureMessage:e.failureMessage??void 0,previewShareId:e.previewShareId??void 0,owner:s??void 0,repo:o??void 0,branch:r.branch??void 0,commitSha:r.commitSha??void 0,githubUsername:r.githubUsername??void 0,pullRequestNumber:r.pullRequestNumber??void 0,githubRunId:r.githubRunId??void 0,stepCount:e.stepCount??void 0,failedStepIndex:e.failedStepIndex??void 0,durationMs:e.durationMs??void 0,flowYamlSizeBytes:e.flowYamlSizeBytes??void 0})});if(!i.ok){let f=await i.text().catch(()=>"");return console.warn(` warn: run registration failed: /api/sootsim/test-runs ${i.status}${f?`: ${f.slice(0,200)}`:""}`),null}let l=await i.json();return l.run?.id?{id:l.run.id,previewUrl:l.run.previewUrl??null,traceUrl:l.run.traceUrl??null}:(console.warn(" warn: run registration returned no id"),null)}catch(i){return console.warn(` warn: run registration failed: ${i instanceof Error?i.message:String(i)}`),null}}function Rt(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t.message=="string"&&t.message?t.message:null}catch{return null}}function kt(e){let t=JSON.parse(M(e,"utf8"));if(!Array.isArray(t))throw new Error("snapshot manifest must be an array");let r=new Set;return t.map((s,o)=>{if(s===null||typeof s!="object")throw new Error(`snapshot manifest entry ${o} must be an object`);let i=Reflect.get(s,"id"),l=Reflect.get(s,"label"),f=Reflect.get(s,"path"),c=Reflect.get(s,"t");if(typeof i!="string"||!i||r.has(i))throw new Error(`snapshot manifest entry ${o} has an invalid or duplicate id`);if(typeof f!="string"||!f)throw new Error(`snapshot manifest entry ${o} has no PNG path`);if(typeof c!="number"||!Number.isFinite(c)||c<0)throw new Error(`snapshot manifest entry ${o} has an invalid capture time`);r.add(i);let h=M(f);return{meta:{id:i,label:typeof l=="string"&&l?l:i,kind:"interaction",t:Math.round(c),contentType:"image/png",sizeBytes:h.byteLength},bytes:h}})}var We=process.env.SOOTSIM_UPLOAD_ORIGIN||"https://contrast.dev",Ye=process.env.SOOTSIM_PREVIEW_ORIGIN||Ae.origin,ye="https://contrast.localhost:3000",Et=2e3;async function Bt(e){if(e)return e;if(process.env.SOOTSIM_UPLOAD_ORIGIN)return process.env.SOOTSIM_UPLOAD_ORIGIN;try{let t=await fetch(`${ye}/api/preview/upload/init`,{method:"OPTIONS",signal:AbortSignal.timeout(Et)});if(t.ok||t.status===204||t.status===405)return ye}catch{}return We}function C(e){return e.replace(/\/$/,"")}function It(e){try{let r=new URL(e).hostname.replace(/^\[|\]$/g,"").toLowerCase();return r==="localhost"||r.endsWith(".localhost")||r==="0.0.0.0"||r==="::1"||/^127(?:\.\d{1,3}){3}$/.test(r)}catch{return!1}}function At(e){try{let t=new URL(e).hostname.toLowerCase();return t==="contrast.dev"||t.endsWith(".contrast.dev")}catch{return!1}}function Ut(e,t){return t?C(t):process.env.SOOTSIM_PREVIEW_ORIGIN?C(process.env.SOOTSIM_PREVIEW_ORIGIN):It(e)?C(e):At(e)?C(Ye):C(e)}function _t(){console.log(`
|
|
6
|
+
rnxsim record upload \u2014 publish the current recorded bundle as a /preview/<id> link
|
|
7
|
+
|
|
8
|
+
usage:
|
|
9
|
+
rnxsim record upload [--origin <url>] [--public-origin <url>] (--events <path> | --video <path>) [--screenshot <path>] [--owner <org> --repo <repo>] [--sim <sim>] [--open] [--assets-only]
|
|
10
|
+
|
|
11
|
+
options:
|
|
12
|
+
--origin <url> upload target (default: auto)
|
|
13
|
+
prefers ${ye} when available, otherwise
|
|
14
|
+
falls back to ${We}
|
|
15
|
+
override with SOOTSIM_UPLOAD_ORIGIN env var
|
|
16
|
+
--public-origin <url>
|
|
17
|
+
public /preview link origin (default: ${Ye}
|
|
18
|
+
for prod uploads, upload origin for localhost/custom origins).
|
|
19
|
+
override with SOOTSIM_PREVIEW_ORIGIN env var
|
|
20
|
+
--events <path> path to a gzipped events .jsonl.gz file to attach
|
|
21
|
+
required unless --video is present; previews must
|
|
22
|
+
have replay or recording playback data
|
|
23
|
+
--screenshot <path>
|
|
24
|
+
path to a PNG thumbnail to attach to the share
|
|
25
|
+
--snapshot-manifest <path>
|
|
26
|
+
JSON manifest of existing interaction PNGs to attach
|
|
27
|
+
--video <path> path to a mp4/gif flow recording. embedded inline
|
|
28
|
+
in the pr sticky comment served at
|
|
29
|
+
/api/preview/flow-video?id=<share-id>
|
|
30
|
+
--video-duration-ms <ms>
|
|
31
|
+
duration hint for attached flow video
|
|
32
|
+
--timeline-events <path>
|
|
33
|
+
extra trace timeline rows, JSONL or JSONL gz
|
|
34
|
+
--trace-frame-stats <path>
|
|
35
|
+
frame stats JSON returned by the recorder bridge
|
|
36
|
+
--failure-bundle <dir>
|
|
37
|
+
per-failure debug bundle dir written by the flow runner
|
|
38
|
+
(error.json, describe.json, a11y.txt, tree.txt,
|
|
39
|
+
console.json, screenshot.png). uploaded with the share
|
|
40
|
+
so failed CI runs are debuggable from the dashboard
|
|
41
|
+
--owner <org> associate a session upload with a linked org repo
|
|
42
|
+
--repo <repo> repo name for --owner; the signed-in user must belong
|
|
43
|
+
to the local/org team that owns the link
|
|
44
|
+
--billing-kind test_run
|
|
45
|
+
meter this upload as a natural-language test run
|
|
46
|
+
--sim <sim> target a specific sim (see: rnxsim list)
|
|
47
|
+
--open open the resulting /preview/<id> url in the browser
|
|
48
|
+
--assets-only drop API/JSON/HTML records before upload; keep images,
|
|
49
|
+
fonts, css, js, and binary blobs. live-data demos hit
|
|
50
|
+
the real network at replay time instead of serving
|
|
51
|
+
recorded API snapshots
|
|
52
|
+
-h, --help
|
|
53
|
+
|
|
54
|
+
examples:
|
|
55
|
+
rnxsim record upload --events ./my-session.jsonl.gz
|
|
56
|
+
rnxsim record upload --origin https://contrast.localhost:3000 --events ./my-session.jsonl.gz --open
|
|
57
|
+
rnxsim record upload --video /tmp/sootsim-flow.mp4 --video-duration-ms 12000
|
|
58
|
+
`)}function p(e,t){let r=e.findIndex(o=>o===t);if(r<0)return;let s=e[r+1];return e.splice(r,2),s}function Ge(e,t){let r=e.findIndex(s=>s===t);return r<0?!1:(e.splice(r,1),!0)}function Je(e,t){if(!e)return;let r=Number(e);return(!Number.isFinite(r)||r<=0)&&(console.error(` invalid ${t}: ${e}`),process.exit(1)),Math.round(r)}function Ke(e){let t=(e||"").toLowerCase().split(";")[0].trim();return t?!!(t.startsWith("image/")||t.startsWith("font/")||t.startsWith("video/")||t.startsWith("audio/")||t.startsWith("model/")||t==="text/css"||t==="application/javascript"||t==="text/javascript"||t==="application/wasm"||t==="application/font-woff"||t==="application/font-woff2"||t==="application/octet-stream"):!1}async function Ve(e){let t=await fetch(e);if(!t.ok)throw new Error(`fetch ${e} -> ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}function Pt(e){return/\.bundle($|\?)/.test(e)||/\.js($|\?)/.test(e)?"application/javascript":/\.zip($|\?)/.test(e)?"application/zip":"application/javascript"}function $t(e){try{return new URL(e).searchParams.get("appFonts")||""}catch{return""}}function Ft(e){try{return new URL(e).searchParams.get("appSplash")||""}catch{return""}}function Nt(e){try{let t=new URL(e);return t.searchParams.get("lazy")==="true"?(t.searchParams.set("lazy","false"),t.toString()):e}catch{return e}}async function Ct(e,t){let s=[];for(let o=0;o<t;o+=15e5){let i=Math.min(o+15e5,t),l=await B(e,`(window.__sootsimLastTransformedBundle?.text || "").slice(${o}, ${i})`);if(typeof l!="string")return null;s.push(l)}return s.join("")}function Lt(e){return e.recordedDurationMs&&e.recordingStartedAtMs?{since:e.recordingStartedAtMs-1e4,until:e.recordingStartedAtMs+e.recordedDurationMs+5e3,limit:2e3}:{limit:2e3}}function Ot(e){let t=M(e),s=(t[0]===31&&t[1]===139?xt(t):t).toString("utf8");return je(s)}function zt(e){return JSON.parse(M(e,"utf8"))}function Dt(e){if(e===null||typeof e!="object")return[];let t=e,r=typeof t.startedAtEpochMs=="number"&&t.startedAtEpochMs>0?t.startedAtEpochMs:null;if(r===null||!Array.isArray(t.samples))return[];let s=[];for(let o of t.samples){if(!Array.isArray(o)||typeof o[0]!="number")continue;let i=l=>typeof l=="number"&&Number.isFinite(l)?Math.round(l*100)/100:0;s.push({schemaVersion:1,t:r+Math.round(o[0]),seq:s.length+1,context:"tenant",kind:"frame",data:{totalMs:i(o[1]),layoutMs:i(o[2]),renderMs:i(o[3]),copyMs:i(o[4])}})}return s}function Ht(e){if(e===null||typeof e!="object")return e;let{samples:t,...r}=e;return r}function he(e){let t=new Map;for(let r of e)t.set(r.urlhash||r.url,r);return Array.from(t.values())}async function wn(e,t){(e.includes("--help")||e.includes("-h"))&&(_t(),process.exit(0));let r=[...e],s=await Bt(p(r,"--origin")),o=Ut(s,p(r,"--public-origin")),i=p(r,"--events"),l=p(r,"--screenshot"),f=p(r,"--snapshot-manifest"),c=p(r,"--video"),h=p(r,"--timeline-events"),T=p(r,"--trace-frame-stats"),Y=p(r,"--failure-bundle"),Q=p(r,"--video-duration-ms"),be=Je(p(r,"--recorded-duration-ms"),"--recorded-duration-ms"),we=Je(p(r,"--recording-started-at-ms"),"--recording-started-at-ms"),X=p(r,"--owner"),Z=p(r,"--repo"),D=p(r,"--billing-kind"),Qe=p(r,"--run-scope"),Xe=Ge(r,"--open");(X&&!Z||!X&&Z)&&(console.error(" --owner and --repo must be provided together"),process.exit(1)),D&&D!=="test_run"&&(console.error(` invalid --billing-kind: ${D}`),process.exit(1)),!i&&!c&&(console.error(" preview uploads require playback data: pass --events or --video.\n for a normal local preview, use `rnxsim record --mode combined --open`\n or `rnxsim maestro test --preview` instead of uploading a bundle-only snapshot."),process.exit(1));let Me=Ge(r,"--assets-only"),Ze=Pe(r,{stripBooleanFlags:[],stripValueFlags:[]}),S=$e(Ze),d,Te=[],v=[],x=h?Ot(h):[],Se=T?zt(T):null;x.push(...Dt(Se));let ve=x.length,ee=null;try{if(d=await B(S,'(typeof window.__sootsimCaptureBundle === "function") ? window.__sootsimCaptureBundle() : null'),d?.bundleUrl){let u=new URL(d.bundleUrl).origin,[m,P]=await Promise.all([B(S,`(window.__sootsimPreviewRecorder?.list?.(${JSON.stringify(u)}) || [])`),B(S,`(async () => {
|
|
59
|
+
const list = window.__sootsimListWorkerFetchRecorder
|
|
60
|
+
return typeof list === 'function'
|
|
61
|
+
? await list(${JSON.stringify(u)})
|
|
62
|
+
: []
|
|
63
|
+
})()`)]);Te=he([...m,...P]).filter(g=>{try{return!new URL(g.url).pathname.startsWith("/api/")}catch{return!0}});let N=await B(S,`(async () => {
|
|
64
|
+
const rec = window.__sootsimPreviewRecorder
|
|
65
|
+
const workerList = window.__sootsimListWorkerFetchRecorder
|
|
66
|
+
return {
|
|
67
|
+
main: rec?.list ? rec.list() : [],
|
|
68
|
+
worker: typeof workerList === 'function' ? await workerList() : [],
|
|
69
|
+
}
|
|
70
|
+
})()`),z=(N?he([...N.main,...N.worker]):[]).filter(g=>{try{return new URL(g.url).origin!==u}catch{return!1}}),k=z.length>0?{count:z.length,totalBytes:z.reduce((g,le)=>g+(le.size||0),0)}:null;if(k&&k.count>0){console.log(` ${k.count} recorded cross-origin responses (${(k.totalBytes/1024).toFixed(1)} KiB)`);let g=await B(S,`(async () => {
|
|
71
|
+
const rec = window.__sootsimPreviewRecorder
|
|
72
|
+
const workerDump = window.__sootsimDumpWorkerFetchRecorder
|
|
73
|
+
const bundleUrl = ${JSON.stringify(d.bundleUrl)}
|
|
74
|
+
const keep = (r) => {
|
|
75
|
+
try {
|
|
76
|
+
const u = new URL(r.url)
|
|
77
|
+
if (u.origin !== ${JSON.stringify(u)}) return true
|
|
78
|
+
// bundle-origin api responses came from the rewritten
|
|
79
|
+
// /__app-api proxy at record time (re-keyed by the
|
|
80
|
+
// recorder's unwrap step). they need bodies attached the
|
|
81
|
+
// same way as cross-origin records \u2014 direct re-fetch from
|
|
82
|
+
// the dev server lacks the bundle's session cookies.
|
|
83
|
+
if (r.url !== bundleUrl && u.pathname.startsWith('/api/')) return true
|
|
84
|
+
return false
|
|
85
|
+
} catch { return false }
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
main: rec?.dump ? rec.dump().filter(keep) : [],
|
|
89
|
+
worker: typeof workerDump === 'function'
|
|
90
|
+
? (await workerDump()).filter(keep)
|
|
91
|
+
: [],
|
|
92
|
+
}
|
|
93
|
+
})()`);if(v=he([...g.main,...g.worker]),Me){let le=v.length;v=v.filter(ue=>Ke(ue.contentType));let lt=k.totalBytes-v.reduce((ue,ut)=>ue+(ut.size||0),0);console.log(` --assets-only: kept ${v.length}/${le} records (dropped ${(lt/1024).toFixed(1)} KiB of API responses)`)}}}d?.transformedBundle&&(ee=await Ct(S,d.transformedBundle.byteLength));let n=await B(S,`(() => {
|
|
94
|
+
const bridge = window.SootSim?.bridges?.timeline ?? window.__sootsimTimeline
|
|
95
|
+
if (!bridge || typeof bridge.recent !== 'function') return null
|
|
96
|
+
return bridge.recent(${JSON.stringify(Lt({recordedDurationMs:be,recordingStartedAtMs:we}))})
|
|
97
|
+
})()`).catch(u=>(console.warn(` warning: failed to capture trace timeline: ${u instanceof Error?u.message:String(u)}`),null)),a=Array.isArray(n?.events)?n.events:[];x=[...x,...a.filter(de)].sort((u,m)=>u.t-m.t||u.seq-m.seq)}finally{S.close()}d||(console.error(" could not read bundle snapshot \u2014 is rnx running and is the bundle loaded?"),process.exit(2)),d.bundleUrl||(console.error(` no ?bundle= URL on the current rnx tab.
|
|
98
|
+
open the app you want to share first (e.g. rnxsim open 8082), then run upload.`),process.exit(2));let y,te=!1;if(ee!==null)y=new TextEncoder().encode(ee),te=!0,console.log(` using post-transform bundle: ${(y.byteLength/1024).toFixed(1)} KiB`);else{let n=Nt(d.bundleUrl);n!==d.bundleUrl&&console.log(" forcing lazy=false for self-contained bundle"),console.log(` capturing: ${n}`),y=await Ve(n),console.log(` main bundle: ${(y.byteLength/1024).toFixed(1)} KiB`)}let H=Te.filter(n=>n.url!==d.bundleUrl);Me&&(H=H.filter(n=>Ke(n.contentType))),console.log(` fetching ${H.length} extra files\u2026`);let j=(await Promise.all(H.map(async n=>{try{let a=await Ve(n.url);return{...n,bytes:a}}catch(a){return console.error(` warning: failed to re-fetch ${n.url}: ${a instanceof Error?a.message:a}`),null}}))).filter(n=>!!n),et=j.reduce((n,a)=>n+a.bytes.byteLength,0);console.log(` ${j.length} extra files: ${(et/1024).toFixed(1)} KiB`);let I;i&&(I=M(i)),x.sort((n,a)=>n.t-a.t||n.seq-a.seq);let xe=x.map(n=>JSON.stringify(n)).join(`
|
|
99
|
+
`),ne=ge(xe?`${xe}
|
|
100
|
+
`:"");console.log(` trace timeline: ${x.length} events${ve?` (${ve} from runner sidecars)`:""}`);let b;l&&(b=M(l),console.log(` attaching screenshot: ${(b.byteLength/1024).toFixed(1)} KiB`));let L=f?kt(f):[];L.length>0&&console.log(` attaching ${L.length} interaction snapshots`);let A,U;if(Y){let n=m=>{try{return M(qe.join(Y,m),"utf8")}catch{return null}},a=m=>{let P=n(m);if(P===null)return null;try{return JSON.parse(P)}catch{return P}},u={error:a("error.json"),describe:a("describe.json"),console:a("console.json"),a11y:n("a11y.txt"),tree:n("tree.txt")};Object.values(u).some(m=>m!==null)&&(A=ge(JSON.stringify(u)),console.log(` attaching failure bundle: ${(A.byteLength/1024).toFixed(1)} KiB gz`));try{U=M(qe.join(Y,"screenshot.png"))}catch{}}let R,O,Re;if(c){if(R=M(c),O=c.endsWith(".mp4")?"video/mp4":c.endsWith(".gif")?"image/gif":void 0,O||(console.error(" preview flow videos must be mp4 or gif"),await E(),process.exit(1)),Q){let n=Number(Q);(!Number.isFinite(n)||n<=0)&&(console.error(` invalid --video-duration-ms: ${Q}`),await E(),process.exit(1)),Re=Math.round(n)}console.log(` attaching flow video: ${(R.byteLength/1024).toFixed(1)} KiB (${O})`)}let $=K(),F=Le($),_=me(),tt=Ue();_e({event:"preview_upload_started",identity:{userId:$?.kind==="session"?tt?.user?.id??null:null,repoId:F?.repoId??null,installationId:F?.installationId??null},properties:{origin:s,hasAuth:!!$,authMode:$?.kind??"none",bundleBytes:y.byteLength,isTransformed:te,extraFiles:j.length,recordedFetches:v.length,hasEvents:!!I,traceTimelineEvents:x.length,hasScreenshot:!!b,hasVideo:!!R}}),$||(console.error(" preview uploads need auth."),console.error(" set RNX_API_KEY=sk_rnx_..., run `rnxsim login`, or use the Contrast github runner."),await E(),process.exit(1));let nt=V($),rt=(()=>{try{return new URL(d.bundleUrl).origin}catch{return null}})(),q=(n,a,u,m,P,N,Ie,z)=>{let k=Oe(N),g=k?ge(n):n;return{url:a,urlhash:u,method:m,bodyHash:P,requestVaryHash:z,contentType:N,responseHeaders:Ie,bytes:g,encoding:k?"gzip":void 0}},ke=[],re=$t(d.pageHref)||"";if(re){let n=await Fe(re,{onStaged:({url:a,byteLength:u})=>console.log(` staged app font: ${a} (${(u/1024).toFixed(1)} KiB)`),onError:(a,u)=>console.error(` warning: failed to fetch app font ${a}: ${u instanceof Error?u.message:u}`)});for(let a of n)ke.push(q(Buffer.from(a.bytes),a.url,a.urlhash,"GET","-",a.contentType))}let Ee=[],se=Ft(d.pageHref)||"";if(se){let n=await Ne(se,{onStaged:({url:a,byteLength:u})=>console.log(` staged splash image: ${a} (${(u/1024).toFixed(1)} KiB)`),onError:(a,u)=>console.error(` warning: failed to fetch splash image ${a}: ${u instanceof Error?u.message:u}`)});for(let a of n)Ee.push(q(Buffer.from(a.bytes),a.url,a.urlhash,"GET","-",a.contentType))}let oe=[...j.map(n=>q(n.bytes,n.url,n.urlhash,"GET","-",n.contentType,n.responseHeaders,n.requestVaryHash)),...v.map(n=>q(Buffer.from(n.bodyBase64,"base64"),n.url,n.urlhash,n.method||"GET",n.bodyHash||"-",n.contentType,n.responseHeaders,n.requestVaryHash)),...ke,...Ee],ie=ze(y),st=vt("sha256").update(y).digest("hex");console.log(` bundle raw=${(y.byteLength/1024).toFixed(1)} KiB br=${(ie.byteLength/1024).toFixed(1)} KiB`);let ot={contentHash:st,bundleSizeBytes:y.byteLength,bundleContentType:Pt(d.bundleUrl),bundleEncoding:"br",bundleMinified:!1,bundleOrigin:rt,runtimeVersion:d.runtimeVersion??void 0,appFonts:re||void 0,appSplash:se||void 0,entry:d.entry,isTransformed:te,deviceSpec:d.deviceSpec,installationId:F?.installationId??void 0,repoId:F?.repoId,owner:X??F?.owner??_.owner??void 0,repo:Z??F?.repo??_.repo??void 0,branch:_.branch??void 0,commitSha:_.commitSha??void 0,githubUsername:_.githubUsername??void 0,pullRequestNumber:_.pullRequestNumber??void 0,pullRequestTitle:_.pullRequestTitle??void 0,billingKind:D==="test_run"?"test_run":void 0,runScope:Qe||void 0,files:oe.map(n=>({url:n.url,urlhash:n.urlhash,method:n.method,bodyHash:n.bodyHash,contentType:n.contentType,responseHeaders:n.responseHeaders,requestVaryHash:n.requestVaryHash,encoding:n.encoding,sizeBytes:n.bytes.byteLength})),events:I?{sizeBytes:I.byteLength}:void 0,timeline:{sizeBytes:ne.byteLength,encoding:"gzip"},traceFrameStats:Ht(Se),recordedDurationMs:be,recordingStartedAtMs:we,failureBundle:A?{sizeBytes:A.byteLength,encoding:"gzip"}:void 0,snapshots:(()=>{let n=[];b&&n.push({id:"landing",label:"Landing",kind:"landing",t:0,contentType:"image/png",sizeBytes:b.byteLength}),U&&n.push({id:"failure",label:"Failure",kind:"failure",contentType:"image/png",sizeBytes:U.byteLength});for(let a of L)n.push(a.meta);return n.length>0?n:void 0})(),flowVideo:R&&O?{sizeBytes:R.byteLength,contentType:O,durationMs:Re}:void 0},Be=new Map;for(let n of oe)Be.set(n.urlhash,n.bytes);let G=new Map;b&&G.set("landing",b),U&&G.set("failure",U);for(let n of L)G.set(n.meta.id,n.bytes);let it=Date.now(),w=ie.byteLength;for(let n of oe)w+=n.bytes.byteLength;I&&(w+=I.byteLength),w+=ne.byteLength,b&&(w+=b.byteLength),U&&(w+=U.byteLength);for(let n of L)w+=n.bytes.byteLength;A&&(w+=A.byteLength),R&&(w+=R.byteLength);let at=`${C(s)}/api/preview/upload/init`;console.log(` init: ${at}`);let J;try{let n=await De({originBase:s,initBody:ot,bundleBytes:ie,filesByHash:Be,extras:{eventsBytes:I,timelineBytes:ne,videoBytes:R,failureBundleBytes:A,snapshotBytes:G},authHeader:nt,concurrency:16});J=n.finalize;let a=1+n.init.files.length+(n.init.events?1:0)+(n.init.timeline?1:0)+n.init.snapshots.length+(n.init.flowVideo?1:0)+(n.init.failureBundle?1:0);console.log(` PUT ${a} objects in ${Date.now()-it}ms (${(w/1024).toFixed(1)} KiB)`)}catch(n){let a=n;a.phase==="init"&&a.status===401&&(console.error(" preview upload requires a valid login."),console.error(" run `rnxsim login` and retry."),await E(),process.exit(1)),a.status===402&&(console.error(` ${Rt(a.responseText)??"preview uploads require Personal, Team, or an active trial \u2014 upgrade from the billing dialog."}`),await E(),process.exit(1)),console.error(` ${a.message??`${a.phase??"upload"} failed: ${String(n)}`}`),await E(),process.exit(1)}let ae=`${o}${J.url}`;return console.log(`
|
|
101
|
+
stored ${J.filesStored??0} extra files`),console.log(` preview: ${ae}`),Xe&&await Ce(ae),await E(),{previewUrl:ae,shareId:J.id}}export{me as a,Qt as b,Xt as c,Zt as d,Bt as e,Ut as f,wn as g};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{e as p}from"./chunk-OVFJFXUD.js";import{a as c,b as l}from"./chunk-WEXDAC74.js";import{a}from"./chunk-HI5TFJWN.js";async function g(e,i){if(i)return i.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let r=a();return r?.origin?r.origin.replace(/\/$/,""):(await p()).replace(/\/$/,"")}async function x(e,i={}){let r=c();if(r||(process.stderr.write(`
|
|
5
|
+
rnx ${e} needs auth before it can check recording access.
|
|
6
|
+
|
|
7
|
+
pick one:
|
|
8
|
+
\u2022 run \`rnxsim login\`
|
|
9
|
+
\u2022 set RNX_API_KEY=sk_rnx_... (recommended for CI)
|
|
10
|
+
|
|
11
|
+
`),process.exit(1)),r.kind==="github"&&i.allowGitHubAuth)return;let s=await g(r,i.originOverride),n;try{n=await fetch(`${s}/api/sootsim/billing/subscription`,{headers:{authorization:l(r)}})}catch(t){process.stderr.write(`
|
|
12
|
+
rnx ${e} couldn't verify recording access.
|
|
13
|
+
${t instanceof Error?t.message:String(t)}
|
|
14
|
+
|
|
15
|
+
`),process.exit(1)}if(n.status===401&&(process.stderr.write(`
|
|
16
|
+
rnx ${e} couldn't verify recording access with the current auth against ${s}.
|
|
17
|
+
sign in again for that origin, or provide a valid RNX_API_KEY.
|
|
18
|
+
|
|
19
|
+
`),process.exit(1)),!n.ok){let t=await n.text().catch(()=>"");process.stderr.write(`
|
|
20
|
+
rnx ${e} couldn't verify recording access (${n.status}).
|
|
21
|
+
${t||"unexpected billing response"}
|
|
22
|
+
|
|
23
|
+
`),process.exit(1)}let o=await n.json();if(o.entitlements?.desktopRecording===!0)return;let u=o.plan??"free";process.stderr.write(`
|
|
24
|
+
rnx ${e} recording requires Personal, Team, or an active trial.
|
|
25
|
+
current plan: ${u}.
|
|
26
|
+
free keeps basic 3d mode; the trial unlocks the full Personal surface.
|
|
27
|
+
|
|
28
|
+
`),process.exit(1)}export{x as a};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{a as $}from"./chunk-5TPRP5QT.js";import{a as k}from"./chunk-5DHC6KHQ.js";import{spawn as v,spawnSync as m}from"child_process";import{chmodSync as S,copyFileSync as T,createWriteStream as E,existsSync as w,mkdirSync as y,rmSync as g,statSync as P,unlinkSync as D}from"fs";import{tmpdir as M}from"os";import{dirname as A,join as f,resolve as b}from"path";var h="https://contrast.dev/api/electron-release";function O(){let r=process.arch;if(process.platform==="darwin"){let t=r==="arm64"?"mac-arm64":"mac-x64",e=`sootsim-latest-${t}.dmg`;return{platform:t,filename:e,url:`${h}/${e}`,install:L}}if(process.platform==="linux"){let t=r==="arm64"?"linux-arm64":"linux-x64",e=`sootsim-latest-${t}.AppImage`;return{platform:t,filename:e,url:`${h}/${e}`,install:C}}if(process.platform==="win32"){let t="sootsim-latest-win-x64.exe";return{platform:"win-x64",filename:t,url:`${h}/${t}`,install:B}}return null}async function I({url:r,dest:t,onProgress:e}){let s=await fetch(r,{redirect:"follow"});if(!s.ok)throw new Error(`${s.status} ${s.statusText} (${r})`);let o=s.headers.get("content-length"),a=o?Number(o):null;if(!s.body)throw new Error(`empty response body (${r})`);y(A(t),{recursive:!0});let i=E(t),d=s.body.getReader(),c=0;try{for(;;){let{done:l,value:p}=await d.read();if(l)break;i.write(Buffer.from(p)),c+=p.byteLength,e?.(c,a)}}finally{await new Promise((l,p)=>{i.end(n=>n?p(n):l())})}}function _(r,t){let e=(r/1048576).toFixed(1);if(!t)return` ${e} MB`;let s=Math.min(100,Math.round(r/t*100)),o=(t/(1024*1024)).toFixed(1),a=24,i=Math.round(s/100*a);return` ${"\u2588".repeat(i)+"\u2591".repeat(a-i)} ${s}% ${e} / ${o} MB`}async function L(r){let t=m("hdiutil",["attach","-nobrowse","-readonly",r],{encoding:"utf8"});if(t.status!==0)throw new Error(`hdiutil attach failed: ${t.stderr||t.stdout}`.trim());let e=t.stdout.trim().split(`
|
|
5
|
+
`),o=e[e.length-1].split(" ").pop()?.trim();if(!o||!w(o))throw new Error(`could not determine dmg mount point (output: ${t.stdout})`);let a=f(o,"sootsim.app");if(!w(a))throw m("hdiutil",["detach","-force",o]),new Error(`sootsim.app not found inside ${o}`);let i="/Applications",d=b(process.env.HOME||"","Applications"),c=i;try{let u=f(i,`.sootsim-write-probe-${process.pid}`);m("touch",[u]),w(u)?g(u,{force:!0}):c=d}catch{c=d}c===d&&y(c,{recursive:!0});let l=f(c,"sootsim.app");w(l)&&g(l,{recursive:!0,force:!0});let p=m("cp",["-R",a,l]),n=m("hdiutil",["detach","-force",o]);if(p.status!==0)throw new Error(`copy to ${l} failed: ${p.stderr?.toString()||""}`.trim());return n.status!==0&&console.warn(` warning: failed to unmount ${o} (${n.stderr?.toString().trim()||"unknown error"})`),m("xattr",["-dr","com.apple.quarantine",l]),l}async function C(r){let t=b(process.env.HOME||"","Applications");y(t,{recursive:!0});let e=f(t,"sootsim.AppImage");return w(e)&&g(e,{force:!0}),T(r,e),D(r),S(e,493),e}async function B(r){return await new Promise((t,e)=>{let s=v("cmd",["/c","start",'""',"/wait",r],{stdio:"inherit"});s.once("error",e),s.once("exit",o=>{o===0?t():e(new Error(`installer exited with code ${o}`))})}),r}async function q(r){(r.includes("--help")||r.includes("-h"))&&(console.log(`
|
|
6
|
+
rnxsim desktop install \u2014 download and install the optional desktop GUI
|
|
7
|
+
|
|
8
|
+
the CLI + daemon are the canonical rnx surface; the GUI is optional.
|
|
9
|
+
if you just want to drive a running metro/expo dev server from the
|
|
10
|
+
terminal, you don't need this.
|
|
11
|
+
|
|
12
|
+
usage:
|
|
13
|
+
rnxsim desktop install [options]
|
|
14
|
+
|
|
15
|
+
options:
|
|
16
|
+
-y, --yes skip confirmation and install immediately
|
|
17
|
+
--force reinstall even if the companion is already present
|
|
18
|
+
|
|
19
|
+
examples:
|
|
20
|
+
rnxsim desktop install
|
|
21
|
+
rnxsim desktop install --yes
|
|
22
|
+
`),process.exit(0));let t=r.includes("--yes")||r.includes("-y")||process.env.SOOTSIM_NO_PROMPT==="1"||process.env.CI==="1"||!process.stdin.isTTY,e=r.includes("--force"),s=k();if(s&&!e){console.log(` rnxsim desktop already installed at: ${s.path}`),console.log(" pass --force to reinstall.");return}let o=O();if(o||(console.error(` no desktop build available for ${process.platform}/${process.arch}.`),console.error(" supported: darwin-arm64, darwin-x64, linux-x64, linux-arm64, win32-x64"),process.exit(1)),console.log(` platform: ${o.platform}`),console.log(` download: ${o.url}`),console.log(),!t){if(!await $("download and install now?",!0)){console.log(" cancelled.");return}console.log()}let a=f(M(),`sootsim-install-${Date.now()}`),i=f(a,o.filename),d=0;process.stdout.write(` downloading ${o.filename}...
|
|
23
|
+
`);try{await I({url:o.url,dest:i,onProgress:(n,u)=>{let x=Date.now();x-d<100&&n<(u??1/0)||(d=x,process.stdout.isTTY&&process.stdout.write(`\r\x1B[2K${_(n,u)}`))}})}catch(n){g(a,{recursive:!0,force:!0});let u=n instanceof Error?n.message:String(n);console.error(`
|
|
24
|
+
download failed: ${u}`),console.error(` the ${o.platform} desktop build may not be published yet, or your`),console.error(" network blocked the request. check your connection and try again later;"),console.error(" the CLI + daemon work without the desktop app (run: rnxsim --help)."),process.exit(1)}process.stdout.isTTY&&process.stdout.write(`
|
|
25
|
+
`);let c=P(i).size;console.log(` downloaded ${(c/(1024*1024)).toFixed(1)} MB`),console.log(),console.log(" installing...");let{trackCliEvent:l,flushCliTelemetry:p}=await import("./telemetry-ZYJGD2DB.js");try{let n=await o.install(i);l({event:"cli_install_desktop_succeeded",properties:{platform:o.platform,size_bytes:c}}),console.log(` installed: ${n}`)}catch(n){l({event:"cli_install_desktop_failed",properties:{platform:o.platform,error:n instanceof Error?n.message:String(n)}}),await p(),console.error(` install failed: ${n instanceof Error?n.message:String(n)}`),console.error(` keeping download at ${i} for manual install.`),process.exit(1)}finally{g(a,{recursive:!0,force:!0})}console.log(),console.log(" next steps:"),console.log(" rnxsim desktop launch the desktop app"),console.log(" rnxsim open <target> open a demo or bundle in it")}export{q as a};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{b as $}from"./chunk-G2WW6L2C.js";import{e as x}from"./chunk-KTHV3RUS.js";import{b as y,c as R,d as m,e as w,f as a}from"./chunk-VFCMSYZK.js";import{G as g,H as u,I as d,O as h,l as p}from"./chunk-FSUYIVJ6.js";import O from"fs";import{WebSocket as E}from"ws";function C(t){if(!t||typeof t!="object")return!1;let e=Reflect.get(t,"sections");return typeof Reflect.get(t,"title")=="string"&&Array.isArray(e)&&e.every(s=>s&&typeof s=="object"&&typeof Reflect.get(s,"title")=="string"&&Array.isArray(Reflect.get(s,"items"))&&Reflect.get(s,"items").every(n=>n&&typeof n=="object"&&typeof Reflect.get(n,"summary")=="string"&&typeof Reflect.get(n,"hash")=="string"))}async function b(t,e=fetch){try{let s=new URL(w);s.searchParams.set("version",t);let n=await e(s,{headers:{accept:"application/json"},signal:AbortSignal.timeout(5e3)});if(!n.ok)return null;let o=await n.json();if(!o||typeof o!="object")return null;let i=Reflect.get(o,"entries");return!Array.isArray(i)||!C(i[0])?null:i[0]}catch{return null}}function A(t,e){let s=[`what's new in rnx engine v${t}:`];if(!e||e.sections.length===0)s.push(" release notes are not available yet");else for(let n of e.sections){s.push(` ${n.title}:`);for(let o of n.items)s.push(` \u2022 ${o.summary}`)}return s.push(` full changelog: ${m}`),s.join(`
|
|
5
|
+
`)}async function Q(t,e={}){let[s,...n]=t;if(!s||s==="--help"||s==="-h"){S();return}switch(s){case"install":return L(n,e);case"list":case"ls":return j(n);case"use":return T(n);case"remove":case"rm":return D(n);case"which":case"active":return G();case"notes":case"changelog":return U(n);default:console.error(` unknown runtime subcommand: ${s}`),S(),process.exit(1)}}function S(){console.log(`
|
|
6
|
+
rnxsim runtime \u2014 manage engine runtimes under ~/.sootsim/runtimes/
|
|
7
|
+
|
|
8
|
+
usage:
|
|
9
|
+
rnxsim runtime install [version] install a version (default: channel latest)
|
|
10
|
+
rnxsim runtime list show installed + available versions
|
|
11
|
+
rnxsim runtime use <version> switch active runtime
|
|
12
|
+
rnxsim runtime remove <version> delete an installed runtime
|
|
13
|
+
rnxsim runtime which print active runtime version
|
|
14
|
+
rnxsim runtime notes print repo or default engine release notes
|
|
15
|
+
|
|
16
|
+
flags:
|
|
17
|
+
--channel <name> channel to resolve 'latest' from (default: stable)
|
|
18
|
+
--force reinstall even if the version is already on disk
|
|
19
|
+
--set-active=false do not switch active runtime after install
|
|
20
|
+
|
|
21
|
+
environment:
|
|
22
|
+
SOOTSIM_CDN_ORIGIN override the CDN base URL (default: ${R})
|
|
23
|
+
|
|
24
|
+
examples:
|
|
25
|
+
rnxsim runtime install
|
|
26
|
+
rnxsim runtime install 1.2.3
|
|
27
|
+
rnxsim runtime install --channel beta
|
|
28
|
+
rnxsim runtime use 1.2.3
|
|
29
|
+
rnxsim runtime notes
|
|
30
|
+
`)}async function L(t,e){let{version:s,flags:n}=F(t),o=n.channel??e.channel??"stable",i=n.force===!0,l=n.setActive!==!1;g(),console.log("rnxsim runtime install"),console.log(` cdn: ${a.resolveCdnOrigin()}`);try{let r=await a.install({version:s,channel:o,force:i,setActive:l,protectVersions:h()});return console.log(` version: ${r.version} (channel: ${r.channel})`),r.installed?console.log(` installed ${r.version}`):console.log(` already installed at ${r.runtimeDir}`),l&&await k(r.version),r}catch(r){console.error(` ${I(r)}`),process.exit(1)}}async function k(t){d(t),console.log(` active: ${t}`),await _(t)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${t})`)}async function _(t){let{isDaemonLockfileFresh:e,readDaemonLockfile:s}=await import("./home-paths-GT3LFNOR.js"),n=s();if(!e(n))return!1;let o=x();return new Promise(i=>{let l=!1,r=!1,f=N=>{l||(l=!0,i(N))},c=new E(`ws://127.0.0.1:${o}`,{handshakeTimeout:800}),v=setTimeout(()=>{try{c.close()}catch{}f(r)},1500);c.on("open",()=>{try{c.send(JSON.stringify({type:"runtime:use",version:t,id:0})),r=!0}catch{}setTimeout(()=>{try{c.close()}catch{}},100)}),c.on("close",()=>{clearTimeout(v),f(r)}),c.on("error",()=>{clearTimeout(v),f(!1)})})}async function j(t){g();let e=a.listInstalled(),s=u();if(console.log("installed:"),e.length===0)console.log(" (none)");else for(let n of e)console.log(` ${n===s?"*":" "} ${n}`);try{let n=await a.fetchManifest();console.log("available (latest per channel):");for(let[i,l]of Object.entries(n.channels))console.log(` ${i.padEnd(8)} ${l.latest}`);let o=Object.keys(n.versions).sort(y).reverse();if(o.length>1){console.log("hosted versions:");for(let i of o)console.log(` ${i}`)}}catch(n){console.log(`available: (could not fetch manifest: ${I(n)})`)}}async function T(t){let e=t[0];e||(console.error(" usage: rnxsim runtime use <version>"),process.exit(1));let s=a.listInstalled();s.includes(e)||(console.error(` version ${e} is not installed`),console.error(` installed: ${s.join(", ")||"(none)"}`),console.error(` run \`rnxsim runtime install ${e}\` first`),process.exit(1)),await k(e)}async function D(t){let e=t[0];e||(console.error(" usage: rnxsim runtime remove <version>"),process.exit(1)),u()===e&&(console.error(` cannot remove active runtime ${e}`),console.error(" switch with `rnxsim runtime use <other>` first, or install another version"),process.exit(1)),h().includes(e)&&(console.error(` cannot remove runtime ${e} while a project is using it`),process.exit(1));let n=p(e);if(!O.existsSync(n)){console.error(` ${e} is not installed`);return}O.rmSync(n,{recursive:!0,force:!0}),console.log(` removed ${e}`)}async function G(){let t=u();if(!t){console.log(" no active runtime");return}console.log(t)}async function U(t){t.length>0&&(console.error(" usage: rnxsim runtime notes"),process.exit(1));let{config:e}=await $(),s=e?.runtimeVersion??u();if(!s){console.log(" no active runtime"),console.log(` release notes: ${m}`);return}console.log(A(s,await b(s)))}function F(t){let e={},s=[];for(let n=0;n<t.length;n++){let o=t[n];if(o==="--channel"&&n+1<t.length){e.channel=t[n+1],n++;continue}if(o.startsWith("--channel=")){e.channel=o.slice(10);continue}if(o==="--force"){e.force=!0;continue}if(o==="--set-active=false"||o==="--no-set-active"){e.setActive=!1;continue}s.push(o)}return{version:s[0]??null,flags:e}}function I(t){return t instanceof Error?t.message:String(t)}export{b as a,A as b,Q as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
var a=["Cache","Code Cache","DawnCache","DawnGraphiteCache","DawnWebGPUCache","GPUCache","GrShaderCache","ShaderCache"],r=new Set(a);function s(e){return r.has(e)}export{a,s as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{H as t,L as n,N as l,j as r}from"./chunk-FSUYIVJ6.js";function m(){let e=t(),i=r()?n():null;return i&&l(i)?{primary:`engine dev source (:${i.bridgePort})`,installedRuntime:e?`installed runtime v${e}`:null,isDevBridge:!0}:{primary:e?`runtime v${e}`:"runtime not installed",installedRuntime:null,isDevBridge:!1}}export{m as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{a as N}from"./chunk-5YJCOWCH.js";import{o as R}from"./chunk-FSUYIVJ6.js";import{a as I}from"./chunk-2D2UPBBR.js";import{a as T}from"./chunk-WINYQ44O.js";function G(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function O(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return G(r)?r:null}catch{return null}}import{randomBytes as q,createHash as X}from"node:crypto";import f from"node:fs";import h from"node:path";var $=null;function B(){if($)return $;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||R()}function y(){return B()}function U(){return h.join(B(),"attached-projects.json")}function _(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=f.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return _();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{f.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return _()}}function K(e){let t=U();f.mkdirSync(h.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=f.openSync(r,"w",384);try{f.writeFileSync(n,JSON.stringify(e,null,2)),f.fsyncSync(n)}finally{f.closeSync(n)}f.renameSync(r,t)}function w(e){let t=S();return e(t),K(t),t}function F(e){return X("sha256").update(h.resolve(e)).digest("hex").slice(0,16)}function Q(){return`s_${q(10).toString("hex")}`}function Se(e){let t=h.resolve(e.cwd),r=F(t),n;return w(o=>{let s=o.attachedProjects.find(a=>a.id===r);if(s){let a={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=a,n=a;return}let c=Date.now(),d={id:r,name:e.name??h.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:c,updatedAt:c};o.attachedProjects.push(d),n=d}),n}function M(e){return S().attachedProjects.find(t=>t.id===e)??null}function we(){return S().attachedProjects}var V=336*60*60*1e3;function ve(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],c=o-V,d=s.filter(a=>a.ts>=c);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Ae(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function xe(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function C(e){let t;return w(r=>{if(e.id){let c=r.agentSessions.find(d=>d.id===e.id);if(c){let d={...c,...e,lastSeenAt:Date.now()},a=r.agentSessions.indexOf(c);r.agentSessions[a]=d,t=d;return}}let n=r.attachedProjects.find(c=>c.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??Q(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function L(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function z(e,t,r=Date.now()){return{...e,...t,id:e.id,projectId:e.projectId,createdAt:e.createdAt,lastSeenAt:r}}function Z(e){e.length!==0&&w(t=>{let r=Date.now(),n=new Map(t.agentSessions.map((o,s)=>[o.id,s]));for(let{id:o,patch:s}of e){let c=n.get(o);c!==void 0&&(t.agentSessions[c]=z(t.agentSessions[c],s,r))}})}function v(e,t){Z([{id:e,patch:t}])}async function Pe(){if(S().attachedProjects.length>0)return;let{loadOptionalDemoApps:t}=await import("./optional-demo-registry-W36EWFFB.js"),r=await t();r.length!==0&&w(n=>{for(let o of r){if(!f.existsSync(o.dir))continue;let s=h.resolve(o.dir),c=F(s);if(n.attachedProjects.some(a=>a.id===c))continue;let d=Date.now();n.attachedProjects.push({id:c,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as ee,spawnSync as te}from"node:child_process";import{randomUUID as re}from"node:crypto";import i,{constants as m}from"node:fs";import u from"node:path";import ne from"node:readline";function b(e){return u.join(y(),"sessions",e)}function J(e){return u.join(b(e),"prompt.in")}function H(e){return u.join(b(e),"events.out")}function se(e){return u.join(y(),"transcripts",`${e}.log`)}function E(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(b(t)))}function oe(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ie();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("rnxsim CLI not found. set SOOTSIM_BIN to the path of the rnxsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ie(){try{let e=ce();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[rnx] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli`.")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function ce(){try{let r=T.resolve(`${I.packageName}/package.json`);return u.dirname(r)}catch{}let e=ae();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name===I.packageName)return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function ae(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function de(e,t,r){let n=u.join(y(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,c=null;for(;c===null;)try{c=i.openSync(o,m.O_WRONLY|m.O_CREAT|m.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let a=Number(i.readFileSync(o,"utf8").trim());if(a&&!ue(a)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(a=>setTimeout(a,50))}try{return i.writeFileSync(c,String(process.pid)),await r()}finally{try{i.closeSync(c)}catch{}try{i.unlinkSync(o)}catch{}}}function ue(e){try{return process.kill(e,0),!0}catch{return!1}}function W(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=te("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function $e(e){let t=M(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return de(t.id,r,async()=>{let n=L(t.id).find(p=>p.provider===r&&p.status!=="ended"&&E(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`rnxsim agent end <sessionId>\`.`);let o=r==="claude"?re():void 0,s=C({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),c=J(s.id),d=H(s.id),a=se(s.id);W(c),W(d);let g=u.dirname(a);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:Y}=oe(),x=[...Y,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",c,"--events-out",d,"--transcript",a];e.codexBin&&x.push("--codex-bin",e.codexBin),e.claudeBin&&x.push("--claude-bin",e.claudeBin),e.freshThread&&x.push("--fresh-thread"),o&&x.push("--claude-session-uuid",o);let P=ee(A,x,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:y()}});P.unref();let D=e.readyTimeoutMs??6e3,j=await le(d,p=>p.type==="ready"||p.type==="error",D);if(!j||j.type==="error"){if(P.pid)try{process.kill(P.pid,"SIGTERM")}catch{}try{i.rmSync(b(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=j&&j.type==="error"?j.message:`no ready event within ${D}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:P.pid,status:"idle"}),{session:k(s.id),wrapperPid:P.pid}})}async function _e(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!E(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=J(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,m.O_WRONLY);try{let s=N(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
|
|
5
|
+
`)}finally{i.closeSync(o)}v(e,{lastPrompt:t.displayText??t.text,status:"working"})}async function Be(e){let t=k(e);if(!t)throw new l("NO_SESSION",`no session with id=${e}`);if(E(t.wrapperPid,e))try{process.kill(t.wrapperPid,"SIGTERM")}catch{}let r=b(e),n=y();if(r.startsWith(n))try{i.rmSync(r,{recursive:!0,force:!0})}catch{}v(e,{status:"ended",wrapperPid:void 0})}function Ue(e,t){let r=H(e);if(!i.existsSync(r))throw new l("NO_FIFO",`events FIFO missing: ${r}`);let n=i.openSync(r,m.O_RDWR),o=i.createReadStream("",{fd:n,autoClose:!0}),s=ne.createInterface({input:o,crlfDelay:1/0});s.on("line",d=>{let a=O(d);a&&t(a)});let c=!1;return()=>{if(!c){c=!0;try{i.writeSync(n,`
|
|
6
|
+
`)}catch{}try{s.close()}catch{}try{o.destroy()}catch{}}}}async function le(e,t,r){let n=i.openSync(e,m.O_RDWR|m.O_NONBLOCK),o=Buffer.alloc(8192),s="",c=Date.now()+r;try{for(;Date.now()<c;){let d=0;try{d=i.readSync(n,o,0,o.length,null)}catch(a){if(a.code!=="EAGAIN")throw a;d=0}if(d>0){s+=o.subarray(0,d).toString("utf8");let a;for(;(a=s.indexOf(`
|
|
7
|
+
`))>=0;){let g=s.slice(0,a);s=s.slice(a+1);let A=O(g);if(A&&t(A))return A}}else await new Promise(a=>setTimeout(a,30))}return null}finally{i.closeSync(n)}}export{O as a,y as b,Se as c,M as d,we as e,ve as f,Ae as g,xe as h,k as i,L as j,z as k,Z as l,Pe as m,b as n,J as o,H as p,se as q,E as r,oe as s,l as t,$e as u,_e as v,Be as w,Ue as x};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{l as n}from"./chunk-2YR5BGA5.js";var i=[];for(let[t,e]of Object.entries(n))e.cliFlag&&i.push({name:`--${e.cliFlag}`,short:e.cliFlagShort?`-${e.cliFlagShort}`:void 0,key:t,type:e.type==="enum"?"string":e.type,description:e.description,options:e.options,default:e.default});var a=i;function g(){let t=[];for(let e of a){let s=e.short?`${e.short}, ${e.name}`:` ${e.name}`,o=e.options?` [${e.options.join("|")}]`:"",r=e.default!==void 0?` (default: ${e.default})`:"";t.push(` ${s.padEnd(24)}${e.description}${o}${r}`)}return t.join(`
|
|
5
|
+
`)}export{g as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{G as F,H as j,I as H,k as N,l as U,u as _,x as E}from"./chunk-FSUYIVJ6.js";import{a as L}from"./chunk-2D2UPBBR.js";import G from"node:fs";import Z from"node:path";function A(e){return e.length<=100&&/^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(e)}function D(e){try{return G.readdirSync(e.runtimesDir(),{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name).sort(k)}catch{return[]}}function M(e,c){return Z.posix.basename(e.tarballPath(c))}function k(e,c){let l=f=>{let v=f.indexOf("-"),V=v>=0?f.slice(0,v):f,T=v>=0?f.slice(v+1):"",$=V.split(".").map(S=>Number.parseInt(S,10));return $.some(S=>!Number.isFinite(S))?[[Number.POSITIVE_INFINITY],f]:[$,T]},[m,u]=l(e),[R,x]=l(c);for(let f=0;f<Math.max(m.length,R.length);f++){let v=m[f]??0,V=R[f]??0;if(v!==V)return v-V}return u===x?0:u?x?u<x?-1:1:-1:1}import{spawn as B}from"node:child_process";import J from"node:crypto";import o from"node:fs";import Y from"node:os";import y from"node:path";import{Readable as q}from"node:stream";import{pipeline as K}from"node:stream/promises";var Q=2;function W(e){function c(){try{let n=JSON.parse(o.readFileSync(e.configFile(),"utf8"));return n&&typeof n=="object"?n:{}}catch{return{}}}function l(n){let t=c();return(n||process.env[e.env.cdnOrigin]||t.cdnOrigin||e.defaultCdnOrigin).replace(/\/+$/,"")}function m(n){let t=c();return n||process.env[e.env.channel]||t.runtimeChannel||"stable"}function u(){if(!e.env.pin)return null;let n=process.env[e.env.pin];if(n&&n.trim())return n.trim();let t=c();return typeof t.runtimeVersion=="string"&&t.runtimeVersion.trim()?t.runtimeVersion.trim():null}function R(n){let t=new URL(`${l(n)}${e.manifestPath}`);return t.searchParams.set("t",String(Date.now())),t.toString()}function x(n,t){return`${l(t)}${e.tarballPath(n)}`}async function f(n){let t=R(n),r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`manifest fetch failed: ${r.status} ${r.statusText} (${t})`);return await r.json()}function v(n,t={}){let r=m(t.channel),i=t.version||u()||n.channels[r]?.latest;if(!i)throw new Error(`no version specified and channel '${r}' has no latest entry in the manifest`);if(!A(i))throw new Error(`invalid runtime version: ${i}`);let h=n.versions[i];if(!h)throw new Error(`version ${i} not found in manifest; available: ${Object.keys(n.versions).slice(-10).join(", ")||"(none)"}`);return{version:i,channel:r,entry:h}}async function V(n={}){e.ensureHome();let t=l(n.cdnOrigin),r=await f(t),{version:i,channel:h,entry:a}=v(r,n),d=e.runtimeDir(i),g=n.setActive!==!1,O=[i,...n.protectVersions??[]];if(I({protectVersions:O}),!n.force&&o.existsSync(y.join(d,e.installedMarker)))return g&&e.writeActiveRuntime(i),I({protectVersions:O}),{version:i,channel:h,cdnOrigin:t,runtimeDir:d,installed:!1,activated:g,manifest:r};let P=a.tarball||x(i,t),b=o.mkdtempSync(y.join(Y.tmpdir(),`${e.id}-runtime-download-`)),w=y.join(b,M(e,i)),p=y.join(y.dirname(d),`.installing-${i}-${process.pid}`);o.rmSync(p,{recursive:!0,force:!0});try{process.stderr.write(`${e.id}: downloading runtime ${i}\u2026
|
|
5
|
+
`),await X(P,w),process.stderr.write(`${e.id}: extracting runtime ${i}\u2026
|
|
6
|
+
`);let s=await ee(w);if(s!==a.sha256)throw new Error(`sha256 mismatch for runtime ${i}: expected ${a.sha256}, actual ${s}`);if(o.mkdirSync(p,{recursive:!0}),await ne(w,p),!o.existsSync(y.join(p,e.installedMarker)))throw new Error(`extracted tarball for runtime ${i} is missing ${e.installedMarker}`);o.rmSync(d,{recursive:!0,force:!0}),o.renameSync(p,d)}catch(s){throw o.rmSync(p,{recursive:!0,force:!0}),s}finally{o.rmSync(b,{recursive:!0,force:!0})}return g&&e.writeActiveRuntime(i),I({protectVersions:O}),{version:i,channel:h,cdnOrigin:t,runtimeDir:d,installed:!0,activated:g,manifest:r}}async function T(n={}){e.ensureHome(),I({protectVersions:n.protectVersions});let t=l(n.cdnOrigin),r=m(n.channel),i=u();if(i){let p=e.readActiveRuntime(),s=o.existsSync(y.join(e.runtimeDir(i),e.installedMarker));if(p===i&&s)return{checked:!0,updated:!1,reason:`runtime is pinned to ${i}`,activeVersion:p,latestVersion:i};let C=await V({version:i,channel:r,cdnOrigin:t,setActive:!1,protectVersions:n.protectVersions});return{checked:!0,updated:!0,reason:`runtime is pinned to ${i}`,activeVersion:i,latestVersion:i,install:C}}let h=await f(t),a=h.channels[r]?.latest;if(!a)return{checked:!0,updated:!1,reason:`channel '${r}' has no latest runtime`,activeVersion:e.readActiveRuntime()};if(!h.versions[a])return{checked:!0,updated:!1,reason:`manifest is missing version ${a}`,activeVersion:e.readActiveRuntime(),latestVersion:a};let g=e.readActiveRuntime(),O=g?e.runtimeDir(g):null,P=O?o.existsSync(y.join(O,e.installedMarker)):!1;if(!(!g||!P||k(a,g)>0))return{checked:!0,updated:!1,reason:"active runtime is current",activeVersion:g,latestVersion:a};let w=await V({version:a,channel:r,cdnOrigin:t,setActive:!1,protectVersions:n.protectVersions});return{checked:!0,updated:!0,activeVersion:a,latestVersion:a,install:w}}async function $(n={}){let t=e.readActiveRuntime(),r=u();if(r)return{active:t,latest:r,pinned:r,outdated:t!==r};try{let i=await f(l(n.cdnOrigin)),h=m(n.channel),a=i.channels[h]?.latest??null,d=!!(a&&(!t||k(a,t)>0));return{active:t,latest:a,pinned:null,outdated:d}}catch{return{active:t,latest:null,pinned:null,outdated:!1}}}function S(n={}){e.ensureHome();let t=Math.max(1,Math.floor(n.retainVersions??Q)),r=D(e),i=new Set(r),h=e.readActiveRuntime(),a=u(),d=new Set;for(let s of[h,a,...n.protectVersions??[]])s&&i.has(s)&&d.add(s);for(let s of[...r].reverse()){if(d.size>=t)break;d.add(s)}let g="__RUNTIME_VERSION__",O=M(e,g),P=O.indexOf(g),b=O.slice(0,P),w=O.slice(P+g.length),p=[];if(P>=0)try{p=o.readdirSync(e.cacheDir(),{withFileTypes:!0}).filter(s=>{if(!s.isFile())return!1;let C=s.name.startsWith(b)&&s.name.endsWith(w),z=s.name.startsWith(b)&&s.name.endsWith(`${w}.partial`);return C||z}).map(s=>y.join(e.cacheDir(),s.name)).sort()}catch{}return{activeVersion:h,pinnedVersion:a,keepVersions:r.filter(s=>d.has(s)),removeVersions:r.filter(s=>!d.has(s)),removeCacheFiles:p}}function I(n={}){let t=S(n);for(let r of t.removeVersions)o.rmSync(e.runtimeDir(r),{recursive:!0,force:!0});for(let r of t.removeCacheFiles)o.rmSync(r,{force:!0});return t}return{product:e,resolveCdnOrigin:l,resolveChannel:m,resolvePin:u,manifestUrl:R,tarballUrl:x,fetchManifest:f,resolveVersion:v,install:V,updateToLatest:T,checkUpToDate:$,planLocalRetention:S,pruneLocalRetention:I,listInstalled:()=>D(e)}}async function X(e,c){let l=await fetch(e);if(!l.ok||!l.body)throw new Error(`download failed: ${l.status} ${l.statusText} (${e})`);o.mkdirSync(y.dirname(c),{recursive:!0});let m=`${c}.partial`;try{await K(q.fromWeb(l.body),o.createWriteStream(m)),o.renameSync(m,c)}catch(u){try{o.unlinkSync(m)}catch{}throw u}}function ee(e){return new Promise((c,l)=>{let m=J.createHash("sha256"),u=o.createReadStream(e);u.on("data",R=>m.update(R)),u.on("error",l),u.on("end",()=>c(m.digest("hex")))})}function ne(e,c){return new Promise((l,m)=>{let u=B("tar",["-xzf",e,"-C",c],{stdio:["ignore","inherit","inherit"]});u.on("error",m),u.on("exit",R=>{R===0?l():m(new Error(`tar exited with code ${R}`))})})}var te="https://contrast.dev",ye=`${L.origin}/changelog`,Ve="https://contrast.dev/api/changelog/sootsim",ie={id:"sootsim",defaultCdnOrigin:te,manifestPath:"/runtimes/manifest.json",tarballPath:e=>`/runtimes/sootsim-runtime-${e}.tar.gz`,installedMarker:"index.html",env:{cdnOrigin:"SOOTSIM_CDN_ORIGIN",channel:"SOOTSIM_RUNTIME_CHANNEL"},ensureHome:F,configFile:E,runtimesDir:N,runtimeDir:U,cacheDir:_,readActiveRuntime:j,writeActiveRuntime:H},we=W(ie);export{A as a,k as b,te as c,ye as d,Ve as e,we as f};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{f}from"./chunk-4NPPOV2N.js";import{existsSync as w,mkdirSync as g,readFileSync as h,writeFileSync as S,rmSync as F}from"fs";import{tmpdir as y}from"os";import{dirname as b,join as p}from"path";var m=new Map;function o(e,n){m.set(e,n)}var s=1;function a(){return p(y(),`sootsim-cli-hints-${f()}.json`)}function d(){return p(y(),"sootsim-cli-hints-global.json")}function u(e){if(!w(e))return{version:s,shown:{}};try{let n=JSON.parse(h(e,"utf8"));return n?.version!==s||!n?.shown?{version:s,shown:{}}:n}catch{return{version:s,shown:{}}}}function l(e,n){try{g(b(e),{recursive:!0}),S(e,JSON.stringify(n)+`
|
|
5
|
+
`)}catch{}}function v(){let e=(process.env.SOOTSIM_HINTS||"").toLowerCase();return e==="off"||e==="0"||e==="false"?"off":e==="always"||e==="verbose"?"always":"normal"}function x(e,n){let i=v();if(i==="off")return!1;if(i==="always"||n==="always")return!0;let t=Date.now();if(n==="once-per-identity"){let r=u(a());return r.shown[e]?!1:(r.shown[e]=t,l(a(),r),!0)}if(n==="once-ever"){let r=u(d());return r.shown[e]?!1:(r.shown[e]=t,l(d(),r),!0)}if(typeof n=="object"&&"cooldownMs"in n){let r=u(a()),c=r.shown[e]??0;return t-c<n.cooldownMs?!1:(r.shown[e]=t,l(a(),r),!0)}return!0}function A(e,...n){let i=m.get(e);if(!i)return process.env.SOOTSIM_HINTS_DEBUG&&console.error(` [hints] no hint registered for id "${e}"`),!1;if(!x(e,i.frequency))return!1;let t=i.render(...n);if(t==null)return!1;let r=Array.isArray(t)?t:[t];for(let c of r)console.error(` hint: ${c}`);return!0}o("app-still-loading",{frequency:{cooldownMs:6e4},render:e=>`app may still be loading (${e} nodes). run \`rnxsim wait ready\` first.`});o("wait-selector-for-missing-testid",{frequency:"once-per-identity",render:e=>`rnxsim wait selector ${e}`});o("prefer-cli-over-eval",{frequency:"once-per-identity",render:e=>e.length?["try the CLI shortcut instead:",...e.map(n=>` ${n}`)]:null});o("describe-use-filters",{frequency:"once-per-identity",render:()=>["describe output is long. narrow it with:"," rnxsim describe --only '*Bottom Sheet*'"," rnxsim describe --testid-like 'swap-*'"," rnxsim describe --subtree <testID>"]});o("describe-filter-context",{frequency:"once-per-identity",render:()=>["filtered describe is search output, not current-route proof.","run `rnxsim describe` without filters after navigation; clipped nodes are marked `(clipped:...)`."]});o("subtree-root-not-found",{frequency:"always",render:e=>`no node with testID/id "${e}" \u2014 try \`rnxsim find --testid ${e}\` to discover available ids.`});o("clean-uninstall",{frequency:"once-ever",render:()=>["to remove the background daemon and all ~/.sootsim data, run `rnxsim daemon uninstall`.","the optional desktop app and its macOS preference plist are separate from the daemon."]});export{A as a};
|