rnxsim 0.1.343 → 0.1.345
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -31
- package/cli/app-fonts.ts +8 -28
- package/cli/app-project.ts +12 -184
- package/cli/app-splash.ts +3 -17
- package/cli/bin.ts +15 -28
- package/cli/commands/control.ts +20 -30
- package/cli/commands/daemon.ts +19 -44
- package/cli/commands/flow.ts +0 -27
- package/cli/commands/install-desktop.ts +2 -16
- package/cli/commands/login.ts +3 -43
- package/cli/commands/logout.ts +0 -7
- package/cli/commands/serve.ts +2 -32
- package/cli/commands/setup.ts +20 -194
- package/cli/commands/telemetry.ts +7 -5
- package/cli/commands/upload.ts +1 -48
- package/cli/commands/welcome.ts +64 -0
- package/cli/outbound-endpoints.ts +586 -0
- package/cli/privacy.ts +53 -0
- package/cli/runtime-notes.ts +2 -2
- package/cli/telemetry.ts +46 -149
- package/dist-cli/bin.js +6 -6
- package/dist-cli/chunks/{agent-RFD32ACU.js → agent-52G55XTO.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-2YLW2HQK.js → agent-wrapper-BOZM43ON.js} +2 -2
- package/dist-cli/chunks/{app-fonts-6OATDF3Y.js → app-fonts-A2L6V5EZ.js} +2 -2
- package/dist-cli/chunks/{assert-PSQICFOY.js → assert-CJKIP4LN.js} +2 -2
- package/dist-cli/chunks/{auth-XWLFKZT7.js → auth-VHHN3TOB.js} +2 -2
- package/dist-cli/chunks/{beta-I6WTVM6C.js → beta-EBDIGV3E.js} +2 -2
- package/dist-cli/chunks/{camera-45HKTLWG.js → camera-5F4KKCQ3.js} +2 -2
- package/dist-cli/chunks/chunk-3DBTS4MC.js +15 -0
- package/dist-cli/chunks/chunk-3N7M5HMJ.js +6 -0
- package/dist-cli/chunks/{chunk-RWYA2USN.js → chunk-4BIPA7MD.js} +1 -1
- package/dist-cli/chunks/chunk-4OKV7T5D.js +4 -0
- package/dist-cli/chunks/{chunk-T4T6DDKM.js → chunk-4ZILDTZX.js} +2 -2
- package/dist-cli/chunks/{chunk-R7X74I3I.js → chunk-5GXRRUOA.js} +26 -26
- package/dist-cli/chunks/chunk-63ASUHOV.js +4 -0
- package/dist-cli/chunks/{chunk-DASP2EKF.js → chunk-7GO2DSYQ.js} +1 -1
- package/dist-cli/chunks/{chunk-HJXIBZ35.js → chunk-7LGINKM6.js} +2 -2
- package/dist-cli/chunks/{chunk-2IPMH24A.js → chunk-7UIIAHVU.js} +2 -2
- package/dist-cli/chunks/{chunk-ES5BHPTS.js → chunk-7V4KPZ7O.js} +2 -2
- package/dist-cli/chunks/{chunk-FCHRGEHA.js → chunk-7YMQRA6L.js} +2 -2
- package/dist-cli/chunks/{chunk-DC7TS573.js → chunk-A2Q76LJV.js} +2 -2
- package/dist-cli/chunks/{chunk-SAUCA7SN.js → chunk-BCQV63BW.js} +45 -45
- package/dist-cli/chunks/{chunk-3FYJ7U3C.js → chunk-BFTDL2GX.js} +17 -17
- package/dist-cli/chunks/chunk-BHKSCNDC.js +4 -0
- package/dist-cli/chunks/{chunk-QPTJNLPT.js → chunk-DGTV3KOW.js} +1 -1
- package/dist-cli/chunks/chunk-DHM3JDCK.js +4 -0
- package/dist-cli/chunks/{chunk-TQRVLK64.js → chunk-DPP2M4AJ.js} +1 -1
- package/dist-cli/chunks/chunk-E2RGSCHT.js +4 -0
- package/dist-cli/chunks/{chunk-TQ5OPG33.js → chunk-EPLVIDPC.js} +1 -1
- package/dist-cli/chunks/{chunk-P3IDK7FR.js → chunk-GKGXULJK.js} +2 -2
- package/dist-cli/chunks/{chunk-34KDMQ6U.js → chunk-HK7YKH6N.js} +2 -2
- package/dist-cli/chunks/{chunk-BJUNXCPO.js → chunk-HXE344V3.js} +1 -1
- package/dist-cli/chunks/{chunk-HJHFC5ZZ.js → chunk-JC33TOAF.js} +1 -1
- package/dist-cli/chunks/{chunk-G3B2RZ47.js → chunk-KA4PJNTE.js} +2 -2
- package/dist-cli/chunks/{chunk-VC4TDPJQ.js → chunk-KH777UAO.js} +3 -3
- package/dist-cli/chunks/{chunk-4PFMDBLB.js → chunk-KRZPFXVN.js} +1 -1
- package/dist-cli/chunks/{chunk-6SLM6URN.js → chunk-KZFJNDH3.js} +1 -1
- package/dist-cli/chunks/{chunk-KLMWLQAO.js → chunk-LAQGSSTT.js} +1 -1
- package/dist-cli/chunks/chunk-LRM2XCEQ.js +11 -0
- package/dist-cli/chunks/{chunk-YKKVDKLE.js → chunk-NUPRHZQW.js} +2 -2
- package/dist-cli/chunks/{chunk-AKV2DGKM.js → chunk-OPHT4DUO.js} +1 -1
- package/dist-cli/chunks/{chunk-KON6XG4Y.js → chunk-P2CGGMU2.js} +2 -2
- package/dist-cli/chunks/{chunk-5FB4EA33.js → chunk-PLB6UVVX.js} +2 -2
- package/dist-cli/chunks/{chunk-FRRHCLG2.js → chunk-PLUWN2V5.js} +1 -1
- package/dist-cli/chunks/{chunk-WDA4QR6U.js → chunk-QNBBKRCA.js} +2 -2
- package/dist-cli/chunks/{chunk-G7S6T5OX.js → chunk-QNRWPAOA.js} +2 -2
- package/dist-cli/chunks/{chunk-2EVBZ37G.js → chunk-R7ZNRGQN.js} +1 -1
- package/dist-cli/chunks/{chunk-TMJGPUWJ.js → chunk-RB4VFUNM.js} +3 -3
- package/dist-cli/chunks/chunk-RT3DXTDP.js +25 -0
- package/dist-cli/chunks/{chunk-OYLIWHDB.js → chunk-RTDHX6CW.js} +2 -2
- package/dist-cli/chunks/{chunk-YLFDA4WW.js → chunk-T7SBFG5I.js} +2 -2
- package/dist-cli/chunks/{chunk-W7EXE22C.js → chunk-TEU5NGUA.js} +2 -2
- package/dist-cli/chunks/chunk-TMRD5MHL.js +99 -0
- package/dist-cli/chunks/{chunk-SU7RE3PV.js → chunk-TOF5TA5X.js} +11 -11
- package/dist-cli/chunks/{chunk-6IVEGYWV.js → chunk-U5YHXQHH.js} +2 -2
- package/dist-cli/chunks/{chunk-BA3HRFJ5.js → chunk-UVOEHIGP.js} +1 -1
- package/dist-cli/chunks/{chunk-SW4DV2TY.js → chunk-VLBN3KRC.js} +1 -1
- package/dist-cli/chunks/{chunk-7WKV6EKX.js → chunk-WPPGU5IK.js} +2 -2
- package/dist-cli/chunks/{chunk-JOE3J46E.js → chunk-WU72KL6Z.js} +2 -2
- package/dist-cli/chunks/chunk-XJBFJGNT.js +4 -0
- package/dist-cli/chunks/{chunk-3CMKNWRL.js → chunk-XXZLK4BY.js} +1 -1
- package/dist-cli/chunks/{chunk-BKMPV6N4.js → chunk-YVSUFVVB.js} +1 -1
- package/dist-cli/chunks/{chunk-RO3WVQPB.js → chunk-ZMTZ5G5H.js} +2 -2
- package/dist-cli/chunks/{cleanup-OU4VKFC3.js → cleanup-MAVZJXVW.js} +2 -2
- package/dist-cli/chunks/cli-version-2B4KRNML.js +4 -0
- package/dist-cli/chunks/{compat-GAEKP67T.js → compat-7AURLGCS.js} +2 -2
- package/dist-cli/chunks/config-TN3Y4J5N.js +13 -0
- package/dist-cli/chunks/{control-VQJURMFD.js → control-EV2ELU5R.js} +2 -2
- package/dist-cli/chunks/daemon-KKDG5MYR.js +4 -0
- package/dist-cli/chunks/{debug-F5N2LO4T.js → debug-JICITUB6.js} +3 -3
- package/dist-cli/chunks/{desktop-I4ILT4BS.js → desktop-4F5HGLLX.js} +3 -3
- package/dist-cli/chunks/{detox-2HMPYSP4.js → detox-ZC7NHLJI.js} +2 -2
- package/dist-cli/chunks/{device-5LWLOB5R.js → device-V57GHRXX.js} +2 -2
- package/dist-cli/chunks/{diagnose-5S4IQPAP.js → diagnose-FF4IWYXC.js} +2 -2
- package/dist-cli/chunks/{disk-cleanup-CJSZVJQX.js → disk-cleanup-T277L6ZO.js} +2 -2
- package/dist-cli/chunks/drivers-LCX7S76X.js +4 -0
- package/dist-cli/chunks/{film-HCPU2TDB.js → film-G7ZAPWB7.js} +3 -3
- package/dist-cli/chunks/flow-ONZGGFGD.js +4 -0
- package/dist-cli/chunks/help-DROVDXJM.js +4 -0
- package/dist-cli/chunks/{hidden-runtime-alias-YYUEZQPR.js → hidden-runtime-alias-VSJNNSNI.js} +2 -2
- package/dist-cli/chunks/{home-paths-3FXISM5I.js → home-paths-75HP3HKA.js} +2 -2
- package/dist-cli/chunks/inspect-MDA7ESGQ.js +4 -0
- package/dist-cli/chunks/install-desktop-EIVZHIFA.js +4 -0
- package/dist-cli/chunks/login-ZSIHGHUK.js +26 -0
- package/dist-cli/chunks/logout-Q4DXMI2C.js +4 -0
- package/dist-cli/chunks/{maestro-F5KK4RC4.js → maestro-LE5LCRBL.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-6SUU3Y5I.js → maestro-generate-D3ZIJCRL.js} +3 -3
- package/dist-cli/chunks/{mode-CSWGOJLI.js → mode-BWX6MDPJ.js} +2 -2
- package/dist-cli/chunks/{optional-demo-registry-Y6VJ4SVV.js → optional-demo-registry-6CVASL3S.js} +2 -2
- package/dist-cli/chunks/{perf-NRWWAJL4.js → perf-NXQZISN6.js} +2 -2
- package/dist-cli/chunks/{permissions-OD62A3DJ.js → permissions-5PD67RRO.js} +2 -2
- package/dist-cli/chunks/privacy-H5KNRNIZ.js +4 -0
- package/dist-cli/chunks/{record-JZT2GM3G.js → record-YJF4KXMR.js} +3 -3
- package/dist-cli/chunks/{report-issue-ZWSNHOPB.js → report-issue-XOL5FQBG.js} +2 -2
- package/dist-cli/chunks/reset-5LZN5P5B.js +4 -0
- package/dist-cli/chunks/runtime-U36VWBH3.js +4 -0
- package/dist-cli/chunks/{screenshot-command-ZGJR7ICY.js → screenshot-command-VRPJXWFS.js} +3 -3
- package/dist-cli/chunks/{screenshot-layers-5AQKOJZK.js → screenshot-layers-QP4WA2F5.js} +2 -2
- package/dist-cli/chunks/{screenshots-capture-CPTWK5Y3.js → screenshots-capture-O2IBAVSP.js} +2 -2
- package/dist-cli/chunks/serve-WC6RZNJL.js +118 -0
- package/dist-cli/chunks/setup-A6BIG3KL.js +30 -0
- package/dist-cli/chunks/{skills-NVWRBMEO.js → skills-A7YC6RL5.js} +2 -2
- package/dist-cli/chunks/{state-QGLTKN6K.js → state-IJI5YROJ.js} +2 -2
- package/dist-cli/chunks/{storage-OZMEZ4AV.js → storage-Z2DBO2PQ.js} +4 -4
- package/dist-cli/chunks/store-BYTCKNIC.js +4 -0
- package/dist-cli/chunks/telemetry-JLHFMD7N.js +4 -0
- package/dist-cli/chunks/{timeline-EXLDREY3.js → timeline-N7V2M6QA.js} +2 -2
- package/dist-cli/chunks/{upgrade-4VWXQO6I.js → upgrade-P2NH3BOR.js} +2 -2
- package/dist-cli/chunks/upload-Z2WX5DCD.js +4 -0
- package/dist-cli/chunks/{version-WZM6XCD2.js → version-OUHCSCUS.js} +2 -2
- package/dist-cli/chunks/{web-ZYPEUVWL.js → web-6NRTF3UV.js} +2 -2
- package/dist-cli/chunks/welcome-6RS7PEJW.js +5 -0
- package/dist-cli/chunks/{what-happened-KF2HLWKW.js → what-happened-FUEL3BEF.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +18 -4
- package/dist-lib/home-paths.cjs +145 -11
- package/dist-lib/host/bridge-host.cjs +236 -31
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +71 -4
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +337 -37
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +484 -14
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +25 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +384 -385
- package/dist-lib/vite.cjs +193 -37
- package/package.json +2 -1
- package/scripts/dev-server-scanner.ts +12 -5
- package/skills/rnx-test/SKILL.md +4 -0
- package/src/dev-bundle-resolution.ts +13 -6
- package/src/dev-server-open.ts +197 -0
- package/src/home-paths.ts +168 -15
- package/src/host/bridge-host.ts +2 -2
- package/src/host/replacement-module-handler.ts +68 -2
- package/src/metro-plugin.ts +83 -5
- package/src/native-dev-bundle-url.ts +22 -0
- package/src/vite-plugin-one.ts +42 -28
- package/dist-cli/chunks/chunk-44LRQEU3.js +0 -4
- package/dist-cli/chunks/chunk-4RKTGL63.js +0 -9
- package/dist-cli/chunks/chunk-5SCIDXJD.js +0 -25
- package/dist-cli/chunks/chunk-CUVY4A2A.js +0 -4
- package/dist-cli/chunks/chunk-DPJGB7MP.js +0 -101
- package/dist-cli/chunks/chunk-HD6P3W5R.js +0 -4
- package/dist-cli/chunks/chunk-HFNESSHG.js +0 -15
- package/dist-cli/chunks/chunk-I7HHBFSD.js +0 -4
- package/dist-cli/chunks/chunk-LV2G34IX.js +0 -4
- package/dist-cli/chunks/cli-version-REQOM22G.js +0 -4
- package/dist-cli/chunks/config-QTFXJKD6.js +0 -13
- package/dist-cli/chunks/daemon-ETA375WE.js +0 -4
- package/dist-cli/chunks/drivers-R4YB2XAF.js +0 -4
- package/dist-cli/chunks/flow-3VQL6XZT.js +0 -4
- package/dist-cli/chunks/help-2RYCKZ2G.js +0 -4
- package/dist-cli/chunks/inspect-XDSX5D6D.js +0 -4
- package/dist-cli/chunks/install-desktop-OKVRLL35.js +0 -4
- package/dist-cli/chunks/login-4VCBPAY2.js +0 -28
- package/dist-cli/chunks/logout-WSL5JS5R.js +0 -4
- package/dist-cli/chunks/reset-3C52YQCV.js +0 -4
- package/dist-cli/chunks/runtime-4V2RBUOR.js +0 -4
- package/dist-cli/chunks/serve-ERAZQGCJ.js +0 -118
- package/dist-cli/chunks/setup-UG6PLYIL.js +0 -32
- package/dist-cli/chunks/store-VPBQKKWA.js +0 -4
- package/dist-cli/chunks/telemetry-FRW7OCYZ.js +0 -4
- package/dist-cli/chunks/upload-C6676NST.js +0 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*! rnx v0.1.345 | (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 ye,c as K,d as be,e as G,f as ve,h as we,i as _,j as Ae,k as Te,l as Ce,m as xe,q as Ee,t as C,u as ke,v as Ie,w as Re,x as Pe}from"./chunk-P2CGGMU2.js";import"./chunk-DGTV3KOW.js";import{e as Se}from"./chunk-TMRD5MHL.js";import"./chunk-7LGINKM6.js";import"./chunk-PLB6UVVX.js";import{a as me,c as he,d as D,e as fe}from"./chunk-4OKV7T5D.js";import{d as ge}from"./chunk-63ASUHOV.js";import{c as I,i as N}from"./chunk-TOF5TA5X.js";import"./chunk-R7ZNRGQN.js";import"./chunk-E2RGSCHT.js";import{c as ue,d as pe}from"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import{f as M}from"./chunk-TEU5NGUA.js";import{A as $,B as ee,G as te,I as L,J as V,K as ie,L as re,M as ne,O as se,R as oe,S as ae,T as ce,U as J,V as de,g as X,h as Z,r as Q}from"./chunk-LRM2XCEQ.js";import{a as le}from"./chunk-T7SBFG5I.js";import"./chunk-PLUWN2V5.js";import"./chunk-LAQGSSTT.js";import{spawn as _t}from"child_process";import T from"fs";import{createServer as Ot}from"http";import v from"path";import{WebSocket as S,WebSocketServer as Lt}from"ws";import Me from"node:fs";import B from"node:path";import{spawn as tt}from"node:child_process";var _e=/^[A-Za-z0-9._:-]{1,160}$/;function z(o){if(!o?.startsWith("TM_SESSION:"))return null;let e=o.slice(11).trim();return _e.test(e)?e:null}function Oe(o){return _e.test(o)}function it(o){return typeof o.text=="string"?o.text.trim():""}function rt(o){let e=o?.trim();return e||"tm"}async function Le(o){let e=o.sessionId.trim();if(!Oe(e))throw new Error(`invalid Team Machine session id: ${e||"<empty>"}`);let t=it(o.prompt);if(!t)throw new Error("prompt text is empty");let i=rt(o.command),r=o.timeoutMs??15e3;await new Promise((s,c)=>{let n=tt(i,["send",e,t],{stdio:["ignore","ignore","pipe"],env:process.env}),a="",d=setTimeout(()=>{try{n.kill("SIGTERM")}catch{}c(new Error(`tm send timed out after ${Math.round(r/1e3)}s`))},r);n.stderr?.setEncoding("utf8"),n.stderr?.on("data",l=>{a.length<4e3&&(a+=String(l))}),n.on("error",l=>{clearTimeout(d),c(l)}),n.on("exit",(l,u)=>{if(clearTimeout(d),l===0){s();return}let p=a.trim();c(new Error(p||`tm send exited with ${u?`signal ${u}`:`code ${l??"unknown"}`}`))})})}var H=1,nt=25;function st(){return[Number(process.env.VITE_PORT_WEB||process.env.PORT||3e3),Number(process.env.VITE_PORT_ZERO||7849),Number(process.env.VITE_PORT_R2||9500)].filter(o=>Number.isFinite(o)&&o>0)}var U=class{subscriptions=new Map;sessionsBySocket=new Map;allSockets=new Set;pendingPromptEchoes=new Map;pendingTurns=new Map;pendingSessionStates=new Map;pendingSessionPatches=new Map;sessionStatusPersistTimer=null;opts;constructor(e={}){this.opts=e}registerSocket(e){this.allSockets.add(e)}unregisterSocket(e){let t=this.sessionsBySocket.get(e);if(t){for(let i of t)this.decrementSubscription(i);this.sessionsBySocket.delete(e)}this.allSockets.delete(e)}async handleMessage(e,t){let i=t?.type;if(typeof i!="string"||!i.startsWith("agent:"))return!1;let r=t.id;try{let s=await this.dispatch(e,i,t);this.respond(e,r,s)}catch(s){s instanceof C?this.respondError(e,r,s.message,s.code):this.respondError(e,r,s instanceof Error?s.message:String(s))}return!0}async seedOnBoot(){try{await xe()}catch(e){process.stderr.write(`[sootsim-agent] seedFromDemoAppRegistry failed: ${e instanceof Error?e.message:String(e)}
|
|
5
|
+
`)}}close(){this.sessionStatusPersistTimer&&(clearTimeout(this.sessionStatusPersistTimer),this.sessionStatusPersistTimer=null),this.flushSessionStatuses();for(let e of this.subscriptions.values())try{e.unsubscribe()}catch{}this.subscriptions.clear(),this.sessionsBySocket.clear(),this.allSockets.clear()}async dispatch(e,t,i){switch(t){case"agent:list-projects":return G();case"agent:upsert-project":return K(i.input??{});case"agent:delete-project":return we(String(i.projectId)),{ok:!0};case"agent:auto-attach-for-url":return this.autoAttachForUrl(i.input??{});case"agent:list-sessions":return Ae(i.projectId?String(i.projectId):void 0);case"agent:start-session":return this.doStartSession(i.input??{});case"agent:send-claimed-prompt":return this.sendClaimedPrompt(i);case"agent:send-prompt":{let s=String(i.sessionId),c=_(s);if(!c)throw new C("NO_SESSION",`no session: ${s}`);let n=this.normalizePromptEnvelope(i);return await Ie(s,n),this.notePromptAccepted(s,n,c.status==="working")}case"agent:end-session":this.dropSessionFanout(String(i.sessionId)),await Re(String(i.sessionId));let r=_(String(i.sessionId));return r&&this.broadcastSessionStatus(r),{ok:!0};case"agent:get-transcript":return this.getTranscript(String(i.sessionId));case"agent:get-paths":return this.getPaths();case"agent:subscribe-events":return this.subscribeSocket(e,String(i.sessionId));case"agent:unsubscribe-events":return this.unsubscribeSocket(e,String(i.sessionId));default:throw new C("UNKNOWN_AGENT_MSG",`unknown agent message: ${t}`)}}async sendClaimedPrompt(e){let t=typeof e.simId=="string"?e.simId.trim():"";if(!t)throw new C("NO_SIM","agent:send-claimed-prompt requires simId");let i=this.opts.resolveCliLease?.(t)??null;if(!i||i.kind!=="cli"||i.expiresAt<=Date.now())throw new C("NO_CLAIM",`sim ${t} has no active CLI claim`);let r=z(i.cliIdentityKey);if(!r)throw new C("UNSUPPORTED_CLAIM",`sim ${t} is claimed by a CLI identity that is not promptable`);return await Le({sessionId:r,prompt:this.normalizePromptEnvelope(e)}),{ok:!0,routed:"team-machine",sessionId:r}}async doStartSession(e){if(!be(e.projectId))throw new C("NO_PROJECT",`no project: ${e.projectId}`);let i=await ke(e);return this.broadcastSessionStatus(i.session),i}async autoAttachForUrl(e){let t=e.bundleUrl??"",i=(()=>{try{return new URL(t).port||null}catch{return null}})();if(!i)return{project:null};let r=this.opts.getExcludePorts?.()??st(),c=(await N({excludePorts:r})).find(l=>String(l.port)===i);if(!c||!c.cwd)return{project:null};let n=G().find(l=>l.cwd===c.cwd)??null,a=Array.from(new Set([...n?.knownBundleUrls??[],c.bundleUrl,t]));return{project:K({cwd:c.cwd,name:c.projectName??B.basename(c.cwd),preferredProvider:e.provider??n?.preferredProvider,sourceRoots:n?.sourceRoots??[c.cwd],knownBundleUrls:a,framework:n?.framework??ot(c.framework),bundleId:c.bundleId??n?.bundleId})}}getTranscript(e){let t=Ee(e);return Me.existsSync(t)?Me.readFileSync(t,"utf8"):{error:"transcript not found",code:"NO_TRANSCRIPT"}}getPaths(){let e=ye();return{userDataDir:e,storeFile:B.join(e,"attached-projects.json"),sessionsDir:B.join(e,"sessions"),transcriptsDir:B.join(e,"transcripts")}}subscribeSocket(e,t){let i=this.sessionsBySocket.get(e);if(i||(i=new Set,this.sessionsBySocket.set(e,i)),i.has(t))return{ok:!0,refCount:this.subscriptions.get(t)?.refCount??1};i.add(t);let r=this.subscriptions.get(t);if(r)return r.refCount++,{ok:!0,refCount:r.refCount};let s=Pe(t,c=>{let n=this.coalescePromptEcho(t,c);if(n&&(this.applySessionEvent(t,n),this.fanOutEvent(t,n)),c.type==="turn-completed"){let a=_(t);if(a)try{ve(a.projectId,{usd:c.costUsd,ts:c.ts})}catch(d){process.stderr.write(`[sootsim-agent] recordTurnTelemetry failed: ${d instanceof Error?d.message:String(d)}
|
|
6
|
+
`)}}});return this.subscriptions.set(t,{unsubscribe:s,refCount:1}),{ok:!0,refCount:1}}unsubscribeSocket(e,t){let i=this.sessionsBySocket.get(e);return!i||!i.has(t)?{ok:!0,refCount:0}:(i.delete(t),this.decrementSubscription(t))}decrementSubscription(e){let t=this.subscriptions.get(e);if(!t)return{ok:!0,refCount:0};if(t.refCount--,t.refCount<=0){try{t.unsubscribe()}catch{}return this.subscriptions.delete(e),{ok:!0,refCount:0}}return{ok:!0,refCount:t.refCount}}dropSessionFanout(e){let t=this.subscriptions.get(e);if(t){try{t.unsubscribe()}catch{}this.subscriptions.delete(e)}for(let i of this.sessionsBySocket.values())i.delete(e);this.clearPromptTracking(e)}normalizePromptEnvelope(e){if(e?.prompt&&typeof e.prompt=="object"){let t=e.prompt;return{text:String(t.text??""),...typeof t.displayText=="string"?{displayText:t.displayText}:{},...typeof t.inspectSummary=="string"?{inspectSummary:t.inspectSummary}:{},...typeof t.inspectTrace=="string"?{inspectTrace:t.inspectTrace}:{}}}return{text:String(e?.text??""),...typeof e?.displayText=="string"?{displayText:e.displayText}:{},...typeof e?.inspectSummary=="string"?{inspectSummary:e.inspectSummary}:{},...typeof e?.inspectTrace=="string"?{inspectTrace:e.inspectTrace}:{}}}notePromptAccepted(e,t,i){let r=Date.now(),s=this.pendingPromptEchoes.get(e)??[];s.push({sentAt:r}),this.pendingPromptEchoes.set(e,s);let c=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,c);let n=t.displayText??t.text;return this.patchSession(e,{lastPrompt:n,status:"working",needsAttention:!1}),this.fanOutEvent(e,{type:"prompt-received",text:n,...t.inspectSummary?{inspectSummary:t.inspectSummary}:{},...t.inspectTrace?{inspectTrace:t.inspectTrace}:{},ts:r}),{ok:!0,queued:c>1,pendingTurns:c,queueDepth:Math.max(0,c-1)}}applySessionEvent(e,t){switch(t.type){case"prompt-received":case"turn-started":this.patchSession(e,{status:"working",needsAttention:!1});return;case"turn-completed":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"idle",needsAttention:!1,lastTurnFiles:t.filesTouched,currentlyEditing:void 0});return}case"approval-needed":this.patchSession(e,{status:"needs-attention",needsAttention:!0});return;case"error":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"needs-attention",needsAttention:i<=0,currentlyEditing:void 0});return}case"exited":this.clearPromptTracking(e),this.patchSession(e,{status:"ended",needsAttention:!1,wrapperPid:void 0,currentlyEditing:void 0});return;case"ready":case"turn-reasoning":case"turn-message":case"turn-plan":case"tool-call":case"file-edited":case"file-diff-delta":return}}patchSession(e,t){let i=this.pendingSessionStates.get(e)??_(e);if(!i)return;let r=Te(i,t);this.pendingSessionStates.set(e,r),this.pendingSessionPatches.set(e,{...this.pendingSessionPatches.get(e),...t}),this.broadcastSessionStatus(r),!this.sessionStatusPersistTimer&&(this.sessionStatusPersistTimer=setTimeout(()=>{this.sessionStatusPersistTimer=null,this.flushSessionStatuses()},nt))}flushSessionStatuses(){if(this.pendingSessionPatches.size===0)return;let e=this.pendingSessionStates,t=this.pendingSessionPatches;this.pendingSessionStates=new Map,this.pendingSessionPatches=new Map;try{Ce([...t].map(([i,r])=>({id:i,patch:r})))}catch(i){for(let[r,s]of e)this.pendingSessionStates.has(r)||this.pendingSessionStates.set(r,s);for(let[r,s]of t)this.pendingSessionPatches.set(r,{...s,...this.pendingSessionPatches.get(r)});process.stderr.write(`[sootsim-agent] session status persistence failed: ${i instanceof Error?i.message:String(i)}
|
|
7
|
+
`)}}coalescePromptEcho(e,t){if(t.type!=="prompt-received")return t;let i=this.pendingPromptEchoes.get(e);if(!i||i.length===0)return t;for(;i.length>0&&Date.now()-i[0].sentAt>15e3;)i.shift();return i.length===0?(this.pendingPromptEchoes.delete(e),t):(i.shift(),i.length===0?this.pendingPromptEchoes.delete(e):this.pendingPromptEchoes.set(e,i),null)}consumeSettledTurn(e){let t=Math.max(0,(this.pendingTurns.get(e)??1)-1);return t>0?this.pendingTurns.set(e,t):this.pendingTurns.delete(e),t}clearPromptTracking(e){this.pendingPromptEchoes.delete(e),this.pendingTurns.delete(e)}fanOutEvent(e,t){let i=JSON.stringify({type:"agent:event",sessionId:e,event:t});for(let[r,s]of this.sessionsBySocket)if(s.has(e)&&r.readyState===H)try{r.send(i)}catch{}}broadcastSessionStatus(e){let t=JSON.stringify({type:"agent:session-status",session:e});for(let i of this.allSockets)if(i.readyState===H)try{i.send(t)}catch{}}respond(e,t,i){if(e.readyState===H)try{e.send(JSON.stringify({id:t,result:i}))}catch{}}respondError(e,t,i,r){if(e.readyState===H)try{e.send(JSON.stringify({id:t,error:i,...r?{code:r}:{}}))}catch{}}};function ot(o){return o==="expo"?"expo":o==="one"||o==="vxrn"?"one":"unknown"}import De from"http";import Be from"https";import{finished as dt,pipeline as lt}from"stream/promises";var q="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",at=[{hostSuffix:"uniswap.org",headers:{origin:"https://app.uniswap.org",referer:"https://app.uniswap.org/"},suppressBrowserUserAgent:!0}];function ct(o){let e=o.toLowerCase();for(let t of at)if(e===t.hostSuffix||e.endsWith(`.${t.hostSuffix}`))return t}function Ne(o){let e=ct(o.hostname);return{"accept-encoding":"identity",...e?.suppressBrowserUserAgent?{}:{"user-agent":q},...e?.headers}}var ut=new Set(["host","origin","referer","user-agent","accept-encoding","cookie","connection","keep-alive","transfer-encoding","upgrade","content-length","sec-fetch-site","sec-fetch-mode","sec-fetch-dest","sec-ch-ua","sec-ch-ua-mobile","sec-ch-ua-platform"]),pt={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,PUT,DELETE,PATCH,OPTIONS","access-control-allow-headers":"*","access-control-expose-headers":"*","access-control-max-age":"3600"},mt=new Set(["host","origin","referer","sec-fetch-site","sec-fetch-mode","sec-fetch-dest"]);function He(o){return o.protocol!=="https:"?{}:I(o.hostname)?{rejectUnauthorized:!1}:{}}function O(o){for(let[e,t]of Object.entries(pt))o.setHeader(e,t)}function ht(o,e){let t=[],i=e;i?.code&&t.push(i.code),i?.message&&t.push(i.message),i?.cause?.code&&t.push(i.cause.code),i?.cause?.message&&t.push(i.cause.message);let s=[...new Set(t.filter(Boolean))].join(" | ")||String(e);return o.includes("stored-in-.env.local")?`${s} | upstream url still contains placeholder env values`:s}function ft(o,e){let t={};for(let[i,r]of Object.entries(o))r&&(ut.has(i.toLowerCase())||(t[i]=Array.isArray(r)?r.join(", "):r));return Object.assign(t,e?Ne(e):{"user-agent":q}),t}function gt(o,e){let t={};for(let[i,r]of Object.entries(o))r&&(mt.has(i.toLowerCase())||(t[i]=r));return t.host=e.host,t.origin=e.origin,t.referer=`${e.origin}/`,t}function Ue(o){return o?.startsWith("/__fetch-proxy?")||o?.startsWith("/__proxy?")||!1}function Fe(o){return o?!!(o.startsWith("/__app-api?")||o.startsWith("/__app-api/")):!1}async function je(o,e){if(o.method==="OPTIONS"){O(e),e.writeHead(204),e.end();return}let i=new URLSearchParams((o.url||"").split("?")[1]||"").get("url");if(!i){O(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("missing url param");return}let r;try{r=new URL(i)}catch{O(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("invalid url param");return}let s;if(o.method!=="GET"&&o.method!=="HEAD"){let a=[];for await(let d of o)a.push(Buffer.isBuffer(d)?d:Buffer.from(d));a.length>0&&(s=Buffer.concat(a))}let c=o.method||"GET",n=async(a,d,l,u)=>{let p=a.protocol==="https:"?Be:De,m=ft(o.headers,a);a.origin!==r.origin&&(delete m.authorization,delete m["proxy-authorization"]),d==="GET"||d==="HEAD"?(delete m["content-length"],delete m["content-type"]):l&&(m["content-length"]=String(l.byteLength));let f=await new Promise((w,A)=>{let y=p.request({hostname:a.hostname,port:a.port||(a.protocol==="https:"?443:80),path:a.pathname+a.search,method:d,headers:m,...He(a)},w),k=()=>y.destroy(new Error("fetch proxy client disconnected"));o.once("aborted",k),y.once("close",()=>o.off("aborted",k)),y.once("error",A),l===void 0?y.end():y.end(l)}),h=f.statusCode??502,g=f.headers.location;if(g&&(h===301||h===302||h===303||h===307||h===308)){if(u>=10)throw f.destroy(),new Error("too many redirects");let w=(h===301||h===302)&&d==="POST"||h===303&&d!=="GET"&&d!=="HEAD",A=new URL(g,a);f.resume(),await dt(f),await n(A,w?"GET":d,w?void 0:l,u+1);return}for(let[w,A]of Object.entries(f.headers)){let y=w.toLowerCase();A===void 0||y==="set-cookie"||y==="connection"||y==="keep-alive"||y==="proxy-authenticate"||y==="proxy-authorization"||y==="te"||y==="trailer"||y==="transfer-encoding"||y==="upgrade"||y.startsWith("access-control-")||e.setHeader(w,A)}O(e);let b=f.headers["set-cookie"]??[];b.length>0&&e.setHeader("x-sootsim-set-cookie",(Array.isArray(b)?b:[b]).join(", ")),e.statusCode=h,await lt(f,e)};try{await n(r,c,s,0)}catch(a){if(e.headersSent){e.destroy(a instanceof Error?a:new Error(String(a)));return}O(e),e.writeHead(502,{"Content-Type":"text/plain"}),e.end(`fetch proxy error: ${ht(r.href,a)}`)}}function We(o,e){let t=o.url||"",i="",r="";if(t.startsWith("/__app-api?")){let d=new URL(t,"http://sootsim.local");i=d.searchParams.get("path")||"",r=d.searchParams.get("origin")?.trim()||""}else if(t.startsWith("/__app-api/"))i=t.slice(10);else return!1;if(!r)return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: missing origin query param"),!0;if(o.method==="OPTIONS")return e.writeHead(204,{"Access-Control-Allow-Origin":o.headers.origin||"*","Access-Control-Allow-Methods":"GET,POST,PUT,PATCH,DELETE,OPTIONS","Access-Control-Allow-Headers":o.headers["access-control-request-headers"]||"*","Access-Control-Allow-Credentials":"true","Access-Control-Max-Age":"86400"}),e.end(),!0;let s;try{s=new URL(i,r)}catch{return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: invalid origin or path"),!0}let c=s.protocol==="https:"?Be:De,n=gt(o.headers,s),a=c.request({hostname:s.hostname,port:s.port||(s.protocol==="https:"?443:80),path:s.pathname+s.search,method:o.method,headers:n,...He(s)},d=>{let l=Object.keys(d.headers).filter(u=>{let p=u.toLowerCase();return!p.startsWith("access-control-")&&p!=="set-cookie"}).join(", ");e.writeHead(d.statusCode??502,{...d.headers,"access-control-allow-origin":o.headers.origin||"*","access-control-allow-credentials":"true","access-control-expose-headers":l}),d.pipe(e)});return a.on("error",d=>{e.statusCode=502,e.end(`app proxy error: ${d.message}`)}),o.pipe(a),!0}import $e from"node:fs/promises";import x from"node:path";import{build as St}from"esbuild";var Ve="/__sootsim-replacement-module",R="/__sootsim-replacement-runtime";function yt(o){switch(x.extname(o).toLowerCase()){case".js":return"js";case".jsx":return"jsx";case".ts":return"ts";case".tsx":return"tsx";default:return null}}function bt(o){return o?`export * from ${JSON.stringify(o)};
|
|
8
|
+
import React from ${JSON.stringify(o)};
|
|
9
|
+
export default React;
|
|
10
|
+
`:`const bridge = globalThis.__sootsim_react_bridge
|
|
11
|
+
if (!bridge) throw new Error('[rnx] replacement React bridge is not ready')
|
|
12
|
+
export default bridge.default
|
|
13
|
+
export const Activity = bridge.Activity
|
|
14
|
+
export const Children = bridge.Children
|
|
15
|
+
export const Component = bridge.Component
|
|
16
|
+
export const Fragment = bridge.Fragment
|
|
17
|
+
export const Profiler = bridge.Profiler
|
|
18
|
+
export const PureComponent = bridge.PureComponent
|
|
19
|
+
export const StrictMode = bridge.StrictMode
|
|
20
|
+
export const Suspense = bridge.Suspense
|
|
21
|
+
export const __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = bridge.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE
|
|
22
|
+
export const __COMPILER_RUNTIME = bridge.__COMPILER_RUNTIME
|
|
23
|
+
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = bridge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
24
|
+
export const act = bridge.act
|
|
25
|
+
export const cache = bridge.cache
|
|
26
|
+
export const cacheSignal = bridge.cacheSignal
|
|
27
|
+
export const captureOwnerStack = bridge.captureOwnerStack
|
|
28
|
+
export const cloneElement = bridge.cloneElement
|
|
29
|
+
export const createContext = bridge.createContext
|
|
30
|
+
export const createElement = bridge.createElement
|
|
31
|
+
export const createRef = bridge.createRef
|
|
32
|
+
export const forwardRef = bridge.forwardRef
|
|
33
|
+
export const isValidElement = bridge.isValidElement
|
|
34
|
+
export const lazy = bridge.lazy
|
|
35
|
+
export const memo = bridge.memo
|
|
36
|
+
export const startTransition = bridge.startTransition
|
|
37
|
+
export const unstable_useCacheRefresh = bridge.unstable_useCacheRefresh
|
|
38
|
+
export const use = bridge.use
|
|
39
|
+
export const useActionState = bridge.useActionState
|
|
40
|
+
export const useCallback = bridge.useCallback
|
|
41
|
+
export const useContext = bridge.useContext
|
|
42
|
+
export const useDebugValue = bridge.useDebugValue
|
|
43
|
+
export const useDeferredValue = bridge.useDeferredValue
|
|
44
|
+
export const useEffect = bridge.useEffect
|
|
45
|
+
export const useEffectEvent = bridge.useEffectEvent
|
|
46
|
+
export const useId = bridge.useId
|
|
47
|
+
export const useImperativeHandle = bridge.useImperativeHandle
|
|
48
|
+
export const useInsertionEffect = bridge.useInsertionEffect
|
|
49
|
+
export const useLayoutEffect = bridge.useLayoutEffect
|
|
50
|
+
export const useMemo = bridge.useMemo
|
|
51
|
+
export const useOptimistic = bridge.useOptimistic
|
|
52
|
+
export const useReducer = bridge.useReducer
|
|
53
|
+
export const useRef = bridge.useRef
|
|
54
|
+
export const useState = bridge.useState
|
|
55
|
+
export const useSyncExternalStore = bridge.useSyncExternalStore
|
|
56
|
+
export const useTransition = bridge.useTransition
|
|
57
|
+
export const version = bridge.version
|
|
58
|
+
`}function vt(){return`const rn = globalThis.__sootsim_components__ || {}
|
|
59
|
+
export default rn
|
|
60
|
+
export const View = rn.View
|
|
61
|
+
export const Text = rn.Text
|
|
62
|
+
export const Image = rn.Image
|
|
63
|
+
export const ScrollView = rn.ScrollView
|
|
64
|
+
export const FlatList = rn.FlatList
|
|
65
|
+
export const Pressable = rn.Pressable
|
|
66
|
+
export const TouchableOpacity = rn.TouchableOpacity
|
|
67
|
+
export const TouchableWithoutFeedback = rn.TouchableWithoutFeedback
|
|
68
|
+
export const TouchableHighlight = rn.TouchableHighlight
|
|
69
|
+
export const TextInput = rn.TextInput
|
|
70
|
+
export const ActivityIndicator = rn.ActivityIndicator
|
|
71
|
+
export const KeyboardAvoidingView = rn.KeyboardAvoidingView
|
|
72
|
+
export const Button = rn.Button
|
|
73
|
+
export const Modal = rn.Modal
|
|
74
|
+
export const Switch = rn.Switch
|
|
75
|
+
export const StyleSheet = rn.StyleSheet
|
|
76
|
+
export const Platform = rn.Platform
|
|
77
|
+
export const Keyboard = rn.Keyboard
|
|
78
|
+
export const Dimensions = rn.Dimensions
|
|
79
|
+
export const Appearance = rn.Appearance
|
|
80
|
+
`}function Y(o,e,t){let i=o.headers.origin,r;if(i)try{I(new URL(i).hostname)&&(r=i)}catch{}e.writeHead(200,{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-cache",...r?{"Access-Control-Allow-Origin":r,Vary:"Origin"}:{}}),e.end(o.method==="HEAD"?void 0:t)}function Je(o){if(!o)return!1;try{let e=new URL(o,"http://rnx.local").pathname;return e===Ve||e.startsWith(`${R}/`)}catch{return!1}}async function Ke(o,e,t={}){let i=o.url||"",r;try{r=new URL(i,"http://rnx.local")}catch{return!1}if(t.requireLoopbackOrigin){let d=o.headers.origin,l=o.socket.remoteAddress?.replace(/^::ffff:/,""),u=!!(l&&I(l));if(u&&d)try{u=I(new URL(d).hostname)}catch{u=!1}if(!u)return e.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),e.end("replacement modules are available only to loopback origins"),!0}if(r.pathname===`${R}/react`)return Y(o,e,bt(t.reactBridgeUrl)),!0;if(r.pathname===`${R}/react-native`)return Y(o,e,vt()),!0;if(r.pathname!==Ve)return!1;if(t.requestToken&&r.searchParams.get("token")!==t.requestToken)return e.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),e.end("replacement module request token is invalid"),!0;let s=r.searchParams.get("path");if(!s)return e.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),e.end("missing path param"),!0;if(!yt(s))return e.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),e.end("replacement files must be .js, .jsx, .ts, or .tsx"),!0;if(!x.isAbsolute(s))return e.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),e.end("replacement file path must be absolute"),!0;let n;if(t.projectRoot){let d=x.resolve(t.projectRoot);n=await $e.realpath(t.projectRoot);let l=x.relative(d,s);if(l.startsWith("..")||x.isAbsolute(l))return e.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),e.end("replacement file must be inside the project root"),!0}let a;try{a=await $e.realpath(s)}catch(d){let l=d instanceof Error?d.message:String(d);return e.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),e.end(`replacement file not found: ${l}`),!0}if(n){let d=x.relative(n,a);if(d.startsWith("..")||x.isAbsolute(d))return e.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),e.end("replacement file must be inside the project root"),!0}try{let l=(await St({entryPoints:[a],bundle:!0,write:!1,format:"esm",platform:"browser",target:"es2022",jsx:"transform",jsxFactory:"React.createElement",jsxFragment:"React.Fragment",tsconfigRaw:{compilerOptions:{jsx:"react"}},sourcemap:"inline",logLevel:"silent",external:["react","react-native"]})).outputFiles[0]?.text??"",u=/\bimport\s+(?:\*\s+as\s+React|React(?:\s*,|\s+from)|\{[^}]*\bdefault\s+as\s+React\b)/.test(l),m=((/\bReact\.(?:createElement|Fragment)\b/.test(l)&&!u?`import * as React from '${R}/react';
|
|
81
|
+
`:"")+l).replace(/from\s*["']react-native["']/g,`from '${R}/react-native'`).replace(/from\s*["']react["']/g,`from '${R}/react'`);Y(o,e,m)}catch(d){let l=d instanceof Error?d.message:String(d);e.writeHead(500,{"Content-Type":"text/plain; charset=utf-8"}),e.end(`replacement bundle failed: ${l}`)}return!0}import{WebSocket as E,WebSocketServer as wt}from"ws";var At="/__websocket-proxy",Tt=new Set(["host","connection","upgrade","transfer-encoding","content-length","sec-websocket-accept","sec-websocket-extensions","sec-websocket-key","sec-websocket-protocol","sec-websocket-version"]);function P(o,e,t){try{o.write(`HTTP/1.1 ${e} ${t}\r
|
|
82
|
+
Connection: close\r
|
|
83
|
+
Content-Type: text/plain\r
|
|
84
|
+
Content-Length: ${t.length}\r
|
|
85
|
+
\r
|
|
86
|
+
${t}`)}catch{}o.destroy()}function Ct(o){let e=o.headers.origin,t=o.headers.host;if(!e||!t)return!1;try{return new URL(e).host===t}catch{return!1}}function xt(o){if(!o)return{};let e=o.replace(/-/g,"+").replace(/_/g,"/"),t=e+"=".repeat((4-e.length%4)%4),i=JSON.parse(Buffer.from(t,"base64").toString("utf8"));if(!i||typeof i!="object"||Array.isArray(i))return{};let r={};for(let[s,c]of Object.entries(i))c!=null&&(Tt.has(s.toLowerCase())||(r[s]=Array.isArray(c)?c.join(", "):String(c)));return r}function Et(o){let e=new URL(o.href);return e.protocol=o.protocol==="wss:"?"https:":"http:",e.origin}function kt(o){let e=o.headers["sec-websocket-protocol"];return(Array.isArray(e)?e.join(","):e||"").split(",").map(i=>i.trim()).filter(Boolean)}function F(o,e,t){if(!(o.readyState===E.CLOSED||o.readyState===E.CLOSING))try{o.close(e,t)}catch{o.terminate()}}function It(o,e){let t=!1,i=(r,s,c,n)=>{t||(t=!0,F(s,c,n.toString()),r.readyState===E.OPEN&&F(r,c,n.toString()))};o.on("message",(r,s)=>{e.readyState===E.OPEN&&e.send(r,{binary:s})}),e.on("message",(r,s)=>{o.readyState===E.OPEN&&o.send(r,{binary:s})}),o.on("close",(r,s)=>i(o,e,r,s)),e.on("close",(r,s)=>i(e,o,r,s)),o.on("error",()=>F(e,1011,"proxy client error")),e.on("error",()=>F(o,1011,"upstream websocket error"))}function Rt(o,e,t,i){let r={...t},s=Object.keys(r).filter(c=>c.toLowerCase()==="origin");if(i&&s.length===0)r.origin=Et(o);else if(!i)for(let c of s)delete r[c];return Object.keys(r).length===0?new E(o.href,e):new E(o.href,e,{headers:r})}function Pt(o){if(!o)return!1;try{return new URL(o,"http://localhost").pathname===At}catch{return!1}}function Ge(o,e,t,i=!0){if(!Pt(o.url))return!1;if(!Ct(o))return P(e,403,"forbidden websocket proxy origin"),!0;let r,s;try{let d=new URL(o.url||"/","http://localhost"),l=d.searchParams.get("url");if(!l)return P(e,400,"missing websocket proxy url"),!0;if(r=new URL(l),r.protocol!=="ws:"&&r.protocol!=="wss:")return P(e,400,"invalid websocket proxy protocol"),!0;s=xt(d.searchParams.get("headers"))}catch{return P(e,400,"invalid websocket proxy request"),!0}let c=kt(o),n=Rt(r,c,s,i),a=!1;return e.once("close",()=>{a||n.terminate()}),n.once("open",()=>{if(a)return;a=!0;let d=n.protocol;new wt({noServer:!0,clientTracking:!1,handleProtocols(u){return d||u.values().next().value||!1}}).handleUpgrade(o,e,t,u=>{It(u,n)})}),n.once("error",()=>{a||(a=!0,P(e,502,"upstream websocket error"))}),n.once("close",()=>{a||(a=!0,P(e,502,"upstream websocket closed"))}),!0}var Mt="require-corp",Nt=new Set(["tap","keyboard","longPress","perform","reset","camera"]),Dt=2e3,Bt=1e3;function Ht(o){return!o||typeof o.type!="string"?!1:o.acquireLock===!0?!0:o.readOnly===!0?!1:Nt.has(o.type)}var ze=5e3,Ut=3600*1e3,Ft="SOOTSIM_RUNTIME_UPDATE_INTERVAL_MS",qe={".html":"text/html; charset=utf-8",".js":"application/javascript",".cjs":"application/javascript",".mjs":"application/javascript",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".wasm":"application/wasm",".ttf":"font/ttf",".otf":"font/otf",".woff":"font/woff",".woff2":"font/woff2",".map":"application/json",".txt":"text/plain; charset=utf-8",".mp4":"video/mp4",".m4v":"video/mp4",".webm":"video/webm",".mov":"video/quicktime"},Ye="/__camera-fixtures/",jt=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function Xe(o,e,t){let i;try{let a=$();i=JSON.stringify(a)}catch{i="{}"}let r=e>0?`window.__sootsimBridgePort=${e};`:"",s=t?`window.__sootsimContrastOrigin=${JSON.stringify(t)};`:"",c=`<script>window.__sootsimSharedConfig=${i};`+r+s+`window.__sootsimCliVersion=${JSON.stringify(le())};</script>`,n=o.toString("utf8");return n.includes("<head>")?n.replace("<head>",`<head>${c}`):n.includes("</head>")?n.replace("</head>",c+"</head>"):n.includes("</body>")?n.replace("</body>",c+"</body>"):c+n}function Ze(o){typeof o=="object"&&o!==null&&"unref"in o&&o.unref()}var j=class o{port;openUrlHandler;httpServer=null;wss=null;nextCommandId=1;nextSimNumber=161;sims=new Map;primarySimId=null;pendingCommands=new Map;cliBySentId=new Map;cliSimBySocket=new Map;cliLastCommandAt=new Map;cliIdentityKeyBySocket=new Map;cliLabelBySocket=new Map;restorableSims=new Map;nextCliFallbackId=1;cliIdleTimer=null;agentHost;static CLI_IDLE_TIMEOUT_MS=6e4;static CLI_LEASE_TTL_MS=6e5;static USER_ACTIVE_LEASE_TTL_MS=8e3;static USER_BOOT_LEASE_TTL_MS=6e4;static SIM_RECONNECT_TTL_MS=3e4;static SIM_IDLE_REAP_TTL_MS=30*6e4;static AUTOMATION_SIM_IDLE_REAP_TTL_MS=10*6e4;static MAX_CONCURRENT_AUTOMATION_SIMS=6;static AUTOMATION_SIM_ACTIVE_GRACE_MS=6e4;preferredPort;portFallbackCount;simIdleReapTtlMs;automationSimIdleReapTtlMs;maxConcurrentAutomationSims;automationSimActiveGraceMs;shouldWriteLockfile;shouldWriteDevLockfile;getShellPort;contrastOrigin=null;effectivePort=0;startedAt=0;heartbeatTimer=null;devHeartbeatTimer=null;wsHeartbeatTimer=null;wsIsAlive=new WeakMap;static WS_HEARTBEAT_INTERVAL_MS=3e4;runtimeUpdateTimer=null;runtimeUpdateInFlight=null;activeRuntimeVersion=null;activeRuntimeDirPath=null;scanCache=null;scanCacheAt=0;inflightScan=null;static SCAN_FRESH_MS=2e3;constructor(e={}){this.preferredPort=e.port||7668,this.port=this.preferredPort,this.shouldWriteLockfile=e.writeLockfile===!0,this.shouldWriteDevLockfile=e.writeDevLockfile===!0,this.getShellPort=e.getShellPort??null,this.portFallbackCount=Math.max(1,e.portFallbackCount??10),this.openUrlHandler=e.openUrl,this.agentHost=new U({getExcludePorts:e.agentScanExcludes,resolveCliLease:t=>{let i=this.sims.get(t),r=i?this.getActiveLease(i):null;return r?{kind:r.kind,cliIdentityKey:r.cliIdentityKey,expiresAt:r.expiresAt}:null}}),this.contrastOrigin=e.contrastOrigin?.replace(/\/$/,"")||null,this.simIdleReapTtlMs=e.simIdleReapTtlMs??o.SIM_IDLE_REAP_TTL_MS,this.automationSimIdleReapTtlMs=e.automationSimIdleReapTtlMs??o.AUTOMATION_SIM_IDLE_REAP_TTL_MS,this.maxConcurrentAutomationSims=e.maxConcurrentAutomationSims??o.MAX_CONCURRENT_AUTOMATION_SIMS,this.automationSimActiveGraceMs=e.automationSimActiveGraceMs??o.AUTOMATION_SIM_ACTIVE_GRACE_MS}getAgentHost(){return this.agentHost}reapIdleSimsForTest(e=Date.now()){this.reapIdleSims(e)}start(e){this.startAsync(e)}async startAsync(e){if(this.httpServer||this.wss)return this.effectivePort;this.refreshActiveRuntime();for(let t=0;t<this.portFallbackCount;t++){let i=this.preferredPort+t;try{return await this.bindOnce(i,e?.silent===!0),this.effectivePort=i,this.port=i,this.startedAt=Date.now(),t>0&&!e?.silent&&process.stderr.write(`ws bridge bound to port ${i} (preferred ${this.preferredPort} was taken)
|
|
87
|
+
`),this.afterBind(),i}catch(r){if(r?.code!=="EADDRINUSE")throw r;e?.silent||process.stderr.write(`ws bridge port ${i} already in use, trying ${i+1}
|
|
88
|
+
`)}}throw new Error(`could not bind ws bridge after ${this.portFallbackCount} attempts starting at ${this.preferredPort}`)}bindOnce(e,t){return new Promise((i,r)=>{let s=Ot((a,d)=>this.handleHttpRequest(a,d)),c=!1,n=a=>{if(!c){c=!0;try{s.close()}catch{}this.httpServer=null,this.wss=null,r(a)}};s.once("error",n),s.listen(e,"127.0.0.1",()=>{c||(c=!0,s.removeListener("error",n),s.on("error",a=>{process.stderr.write(`ws bridge http error: ${String(a)}
|
|
89
|
+
`)}),this.httpServer=s,this.wss=new Lt({noServer:!0}),this.wireWebSocketServer(),s.on("upgrade",(a,d,l)=>{Ge(a,d,l)||this.wss?.handleUpgrade(a,d,l,u=>{this.wss?.emit("connection",u,a)})}),i())})})}wireWebSocketServer(){this.wss&&this.wss.on("connection",(e,t)=>{let i=t.headers.origin,r=i?"sim":"cli",s=null;if(e.on("error",()=>{}),this.wsIsAlive.set(e,!0),e.on("pong",()=>{this.wsIsAlive.set(e,!0)}),this.agentHost.registerSocket(e),r==="sim")s={id:this.allocateSimId(),ws:e,origin:i,connectedAt:Date.now(),lastSeenAt:Date.now(),lastActiveAt:0,recentActions:[]},this.sims.set(s.id,s),this.writeConnectedRuntimeSnapshot(),this.shouldPromoteSim(s)&&(this.primarySimId=s.id),this.broadcastSimAssignments(),this.broadcastSimClientStates();else{let c=`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,c)}e.on("message",c=>{let n;try{n=JSON.parse(c.toString())}catch{return}if(!(!n||typeof n!="object")){if(typeof n.type=="string"&&n.type.startsWith("agent:")){this.agentHost.handleMessage(e,n);return}if(n.type==="runtime:list"){let a=M.listInstalled(),d=this.getActiveRuntime(),l={type:"runtime:list:ok",id:n.id,installed:a,active:d.version,activeRuntimeDir:d.runtimeDir};try{e.send(JSON.stringify(l))}catch{}return}if(n.type==="runtime:use"){let a=typeof n.version=="string"?n.version:"";if(!M.listInstalled().includes(a)){try{e.send(JSON.stringify({type:"runtime:use:error",id:n.id,error:`runtime ${a||"(missing)"} is not installed`}))}catch{}return}let l=this.setActiveRuntime(a);try{e.send(JSON.stringify({type:"runtime:use:ok",id:n.id,version:l.version,runtimeDir:l.runtimeDir}))}catch{}return}if(n.type==="runtime:get"){let a=this.getActiveRuntime();try{e.send(JSON.stringify({type:"runtime:get:ok",id:n.id,active:a.version,activeRuntimeDir:a.runtimeDir}))}catch{}return}if(r==="sim"&&n.type==="bridge:hello"&&s&&!s.url){let a=s.id;this.sims.delete(a),this.primarySimId===a&&(this.primarySimId=this.getOpenSim()?.id??null),s=null,r="cli",this.cliIdentityKeyBySocket.set(e,`ws-${this.nextCliFallbackId++}`),this.writeConnectedRuntimeSnapshot(),this.broadcastSimAssignments(),this.broadcastSimClientStates()}if(r==="sim"){if(s&&(s.lastSeenAt=Date.now()),n.type==="bridge:register"&&s){let l=n,u=this.tryRestoreSimId(s,l.simId);s.url=l.url,s.title=l.title,s.userAgent=l.userAgent,this.writeConnectedRuntimeSnapshot(),typeof l.kind=="string"&&l.kind.trim()&&(s.kind=l.kind.trim()),l.meta&&typeof l.meta=="object"&&(s.meta=l.meta);let p=this.primarySimId!==s.id&&this.shouldPromoteSim(s);p&&(this.primarySimId=s.id),(u||p)&&(this.broadcastSimAssignments(),this.broadcastSimClientStates());return}if(n.type==="bridge:user-focus-state"&&s){let l=n;this.updateUserFocusLease(s,l);return}if(n.type==="bridge:user-interact"&&s){this.updateUserActivity(s);return}if(n.type==="bridge:write-shared-config"){if(!n.patch||typeof n.patch!="object"||Array.isArray(n.patch))return;let l=Object.fromEntries(Object.entries(n.patch));try{this.writeAndBroadcastSharedConfig(l)}catch(u){process.stderr.write(`sootsim: bridge:write-shared-config failed: ${u instanceof Error?u.message:String(u)}
|
|
90
|
+
`);return}return}if(n.type==="bridge:open-path"){let l=typeof n.path=="string"?n.path:"",u=typeof n.line=="number"&&Number.isFinite(n.line)?n.line:void 0,p=typeof n.column=="number"&&Number.isFinite(n.column)?n.column:void 0;l&&this.openPathInEditor(l,u,p);return}if(n.type==="bridge:boot-clients"&&s){let l=[];for(let[p,m]of this.cliSimBySocket)m===s.id&&l.push(p);for(let p of l){this.cliSimBySocket.delete(p);try{p.close(1e3,"booted by sim")}catch{}}let u=!!s.cliLease;s.cliLease={kind:"user-active",cliIdentityKey:"__user-active__",cliLabel:"active user",expiresAt:Date.now()+o.USER_BOOT_LEASE_TTL_MS},process.stderr.write(`rnx booted ${l.length} cli client(s)${u?" (overrode prior lease)":""}; held sim for user [${s.id}]
|
|
91
|
+
`),this.recordSimAction(s.id,"sim booted cli clients"),this.broadcastSimClientStates();return}let a=this.pendingCommands.get(n.id);if(a){this.pendingCommands.delete(n.id),n.error?a.reject(new Error(n.error)):a.resolve(n.result);return}let d=this.cliBySentId.get(n.id);if(d&&(this.cliBySentId.delete(n.id),d.ws.readyState===S.OPEN)){let l=this.getOtherCliIdentityCount(d.ws,d.simId),u=l>0?{...n,id:d.originalId,_otherCliCount:l}:{...n,id:d.originalId};d.ws.send(JSON.stringify(u))}return}(async()=>{this.cliLastCommandAt.set(e,Date.now());try{if(n.type==="bridge:bye"){let p=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[m,f]of this.cliBySentId)f.ws===e&&this.cliBySentId.delete(m);p&&this.broadcastSimClientStates();return}if(n.type==="bridge:hello"){let p=typeof n.cliIdentityKey=="string"&&n.cliIdentityKey.trim()?n.cliIdentityKey.trim():this.cliIdentityKeyBySocket.get(e)||`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,p),typeof n.cliLabel=="string"&&n.cliLabel.trim()&&this.cliLabelBySocket.set(e,n.cliLabel.trim()),e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,result:{cliIdentityKey:p,leaseTtlMs:o.CLI_LEASE_TTL_MS,leasing:!0}}));return}if(n.type==="bridge:list-sims"){e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,result:this.listSims()}));return}if(n.type==="bridge:claim"){let p=await this.waitForSim(n.simId),m=this.tryAcquireLease(e,p,{force:n.force===!0});if(!m.granted){e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,error:`sim ${p.id} is locked by another cli`,_locked:m.lock}));return}this.setCliSimTarget(e,p.id),this.recordSimAction(p.id,m.bootedCount>0?`cli force-claimed sim (booted ${m.bootedCount})`:"cli claimed sim"),e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,result:{simId:p.id,lockedBy:m.lease.cliIdentityKey,lockExpiresAt:m.lease.expiresAt,bootedCount:m.bootedCount}}));return}let a=await this.waitForSim(n.simId);if(Ht(n)){let p=this.tryAcquireLease(e,a);if(!p.granted){e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,error:`sim ${a.id} is locked by another cli \u2014 use \`rnx claim ${a.id} --force\` or \`rnx open --new\``,_locked:p.lock}));return}}else this.ensureCliIdentityKey(e);this.setCliSimTarget(e,a.id),this.recordSimAction(a.id,this.describeForwardedCommand(n));let d=this.nextCommandId++;this.cliBySentId.set(d,{simId:a.id,ws:e,originalId:n.id});let{simId:l,...u}=n;if(a.ws.send(JSON.stringify({...u,id:d})),u.type==="close"){this.cliBySentId.delete(d),e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,result:{requested:!0,simId:a.id}}));let p=a.ws,m=setTimeout(()=>{this.closeSimSocketFromHost(p)},Dt);Ze(m)}}catch(a){e.readyState===S.OPEN&&e.send(JSON.stringify({id:n.id,error:a instanceof Error?a.message:String(a)}))}})()}}),e.on("close",()=>{if(this.agentHost.unregisterSocket(e),r==="sim"&&s){this.rememberDisconnectedSim(s),this.primarySimId===s.id&&(this.primarySimId=this.getOpenSim()?.id??null);for(let[c,n]of this.pendingCommands)n.simId===s.id&&(n.reject(new Error("sim disconnected")),this.pendingCommands.delete(c));for(let[c,n]of this.cliBySentId)n.simId===s.id&&(n.ws.readyState===S.OPEN&&n.ws.send(JSON.stringify({id:n.originalId,error:"sim disconnected before responding"})),this.cliBySentId.delete(c));this.broadcastSimAssignments(),this.broadcastSimClientStates()}else if(r==="cli"){let c=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[n,a]of this.cliBySentId)a.ws===e&&this.cliBySentId.delete(n);c&&this.broadcastSimClientStates()}})})}afterBind(){if(process.stderr.write(`ws bridge listening on port ${this.port}
|
|
92
|
+
`),this.cliIdleTimer=setInterval(()=>this.sweepIdleCliClients(),3e4),this.cliIdleTimer.unref(),this.wsHeartbeatTimer=setInterval(()=>this.sweepDeadWebSockets(),o.WS_HEARTBEAT_INTERVAL_MS),this.wsHeartbeatTimer.unref(),this.shouldWriteLockfile){try{if(L(),!ce(this.buildLockfileSnapshot()))throw new Error("another rnx daemon wrote the lockfile during startup \u2014 aborting")}catch(e){throw process.stderr.write(`ws bridge failed to claim daemon lockfile: ${String(e)}
|
|
93
|
+
`),e}this.heartbeatTimer=setInterval(()=>{try{this.writeLockfileSnapshot()}catch{}},ze),this.heartbeatTimer.unref(),this.startRuntimeUpdater()}if(this.shouldWriteDevLockfile){try{this.writeDevLockfileSnapshot()}catch(e){process.stderr.write(`ws bridge failed to write dev bridge lockfile: ${String(e)}
|
|
94
|
+
`)}this.devHeartbeatTimer=setInterval(()=>{try{this.writeDevLockfileSnapshot()}catch{}},ze),this.devHeartbeatTimer.unref()}this.agentHost.seedOnBoot()}bootstrapping=!0;connectedRuntimeVersions(){let e=new Set;for(let t of this.sims.values())try{let i=new URL(t.url||t.origin||"http://localhost"),r=D(i.hostname);r&&e.add(r)}catch{}return[...e].sort()}buildLockfileSnapshot(){return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,activeRuntimeDir:this.activeRuntimeDirPath,servedRuntimes:this.connectedRuntimeVersions(),startedAt:this.startedAt,heartbeatAt:Date.now(),bootstrapping:this.bootstrapping}}buildDevLockfileSnapshot(){let e=this.getShellPort?.()??null;return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,...e&&e>0?{shellPort:e}:{},cwd:process.cwd(),startedAt:this.startedAt,heartbeatAt:Date.now(),source:"vite-dev",servedRuntimes:this.connectedRuntimeVersions()}}writeLockfileSnapshot(){oe(this.buildLockfileSnapshot())}writeDevLockfileSnapshot(){ae(this.buildDevLockfileSnapshot())}writeConnectedRuntimeSnapshot(){if(this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}if(this.shouldWriteDevLockfile&&this.httpServer)try{this.writeDevLockfileSnapshot()}catch{}}refreshActiveRuntime(){this.activeRuntimeVersion=V(),this.activeRuntimeDirPath=me()??re()}runServerScan(){if(this.inflightScan)return this.inflightScan;let e=this.effectivePort>0?[this.effectivePort]:[];return this.inflightScan=N({excludePorts:e,buildIconProxyUrl:t=>`/__bundle-proxy?url=${encodeURIComponent(t)}`}).then(t=>(this.scanCache=t,this.scanCacheAt=Date.now(),t)).catch(t=>{let i=t instanceof Error?t.message:String(t);return console.error("[rnx] /__server-scan failed:",i),this.scanCache??[]}).finally(()=>{this.inflightScan=null}),this.inflightScan}handleCameraFixture(e,t,i){let r=(t.method||"GET").toUpperCase(),s={"Access-Control-Allow-Origin":"*","Cache-Control":"no-store"};if(r==="OPTIONS"){i.writeHead(204,{...s,"Access-Control-Allow-Methods":"GET, HEAD, OPTIONS","Access-Control-Allow-Headers":"range"}),i.end();return}if(r!=="GET"&&r!=="HEAD"){i.writeHead(405,s),i.end();return}if(!jt.test(e)){i.writeHead(400,{...s,"Content-Type":"text/plain; charset=utf-8"}),i.end("bad fixture name");return}let c=Q(),n=v.join(c,e),a;try{a=T.lstatSync(n)}catch{i.writeHead(404,{...s,"Content-Type":"text/plain; charset=utf-8"}),i.end("not found");return}if(!a.isFile()){i.writeHead(403,{...s,"Content-Type":"text/plain; charset=utf-8"}),i.end("forbidden");return}let d=qe[v.extname(n).toLowerCase()]||"application/octet-stream",l=a.size,u=/^bytes=(\d*)-(\d*)$/.exec(t.headers.range||"");if(u){let[,p,m]=u,f=p?Number(p):0,h=m?Math.min(Number(m),l-1):l-1;if(!Number.isFinite(f)||f>h||f>=l){i.writeHead(416,{...s,"Content-Range":`bytes */${l}`}),i.end();return}if(i.writeHead(206,{...s,"Content-Type":d,"Content-Range":`bytes ${f}-${h}/${l}`,"Accept-Ranges":"bytes","Content-Length":String(h-f+1)}),r==="HEAD"){i.end();return}T.createReadStream(n,{start:f,end:h}).pipe(i);return}if(i.writeHead(200,{...s,"Content-Type":d,"Accept-Ranges":"bytes","Content-Length":String(l)}),r==="HEAD"){i.end();return}T.createReadStream(n).pipe(i)}handleServerScan(e){let t=r=>{e.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),e.end(JSON.stringify(r))},i=Date.now()-this.scanCacheAt;if(this.scanCache&&i<o.SCAN_FRESH_MS){t(this.scanCache);return}if(this.scanCache){t(this.scanCache),this.runServerScan().catch(()=>{});return}this.runServerScan().then(r=>t(r))}resolveRuntimeUpdateIntervalMs(){let e=Number(process.env[Ft]);return Number.isFinite(e)&&e>0?Math.max(100,Math.round(e)):Ut}startRuntimeUpdater(){if(!this.shouldWriteLockfile||this.runtimeUpdateTimer||T.existsSync(v.join(X(),"runtime-update-disabled"))||process.env.SOOTSIM_HOME&&Z()&&!V())return;this.runRuntimeUpdate("startup");let e=this.resolveRuntimeUpdateIntervalMs();this.runtimeUpdateTimer=setInterval(()=>{this.runRuntimeUpdate("periodic")},e),this.runtimeUpdateTimer.unref()}runRuntimeUpdate(e){return this.runtimeUpdateInFlight?this.runtimeUpdateInFlight:(this.runtimeUpdateInFlight=(async()=>{try{e==="startup"&&process.stderr.write(`rnx: checking for runtime updates\u2026
|
|
95
|
+
`);let t=await M.updateToLatest({protectVersions:this.connectedRuntimeVersions()});if(!t.updated||!t.latestVersion){e==="startup"&&process.stderr.write(`rnx: runtime ${this.activeRuntimeVersion??"(none)"} is current
|
|
96
|
+
`);return}let i=this.activeRuntimeVersion,r=this.setActiveRuntime(t.latestVersion);process.stderr.write(`rnx runtime updated to ${r.version} (${e})
|
|
97
|
+
`);try{te({from:i,to:r.version,at:Date.now()})}catch{}}catch(t){process.stderr.write(`rnx runtime update failed (${e}): ${t instanceof Error?t.message:String(t)}
|
|
98
|
+
`)}finally{if(this.runtimeUpdateInFlight=null,e==="startup"&&this.bootstrapping){if(this.bootstrapping=!1,this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}process.stderr.write(`rnx: ready
|
|
99
|
+
`)}}})(),this.runtimeUpdateInFlight)}setActiveRuntime(e){if(ie(e),this.refreshActiveRuntime(),this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}let t=JSON.stringify({type:"runtime:changed",version:e,runtimeDir:this.activeRuntimeDirPath});for(let i of this.sims.values()){try{let r=new URL(i.url||i.origin||"http://localhost");if(D(r.hostname))continue}catch{}if(i.ws.readyState===S.OPEN)try{i.ws.send(t)}catch{}}return{version:e,runtimeDir:this.activeRuntimeDirPath}}getActiveRuntime(){return{version:this.activeRuntimeVersion,runtimeDir:this.activeRuntimeDirPath}}removeLockfile(){if(this.shouldWriteLockfile)try{J({pid:process.pid,startedAt:this.startedAt})}catch{}}handleHttpRequest(e,t){if(t.setHeader("Cross-Origin-Opener-Policy","same-origin"),t.setHeader("Cross-Origin-Embedder-Policy",Mt),t.setHeader("Cross-Origin-Resource-Policy","cross-origin"),t.setHeader("Document-Policy","js-profiling"),Ue(e.url)){je(e,t);return}if(Fe(e.url)&&We(e,t))return;if(Je(e.url)){Ke(e,t);return}let i=(e.method||"GET").toUpperCase(),r;try{r=new URL(e.url||"/",`http://${e.headers.host||"localhost"}`)}catch{t.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),t.end("invalid request URL or host");return}if(r.pathname==="/__sootsim/shared-config"){if(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Headers","Content-Type"),t.setHeader("Cache-Control","no-store"),i==="OPTIONS"){t.writeHead(204,{Allow:"GET, HEAD, POST, OPTIONS"}),t.end();return}if(i==="GET"||i==="HEAD"){let u="{}";try{u=JSON.stringify($())}catch{}t.writeHead(200,{"Content-Type":"application/json"}),i==="HEAD"?t.end():t.end(u);return}if(i==="POST"){(async()=>{try{let u=[],p=0;for await(let g of e){let b=Buffer.isBuffer(g)?g:Buffer.from(g);if(p+=b.byteLength,p>8*1024*1024){t.writeHead(413,{"Content-Type":"text/plain; charset=utf-8"}),t.end("shared config patch is too large");return}u.push(b)}let m=JSON.parse(Buffer.concat(u).toString("utf8"));if(!m||typeof m!="object"||Array.isArray(m))throw new Error("shared config patch must be an object");let f=Object.fromEntries(Object.entries(m)),h=this.writeAndBroadcastSharedConfig(f);t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify(h))}catch(u){t.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),t.end(`invalid shared config patch: ${u instanceof Error?u.message:String(u)}`)}})();return}t.writeHead(405,{Allow:"GET, HEAD, POST, OPTIONS"}),t.end("method not allowed");return}if(r.pathname.startsWith(Ye)){this.handleCameraFixture(r.pathname.slice(Ye.length),e,t);return}if(i!=="GET"&&i!=="HEAD"){t.writeHead(405,{Allow:"GET, HEAD"}),t.end("method not allowed");return}if(r.pathname==="/__bundle-proxy"){let u=r.searchParams.get("url");if(!u){t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: missing url query param");return}let p;try{p=new URL(u)}catch{t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: invalid url");return}let m=p.hostname;if(!(m==="localhost"||m==="127.0.0.1"||m==="::1"||m.endsWith(".localhost"))){t.writeHead(403,{"Content-Type":"text/plain"}),t.end("bundle-proxy: only loopback targets allowed");return}(async()=>{try{let h=await fetch(p.toString(),{redirect:"follow"}),g={},b=h.headers.get("content-type");if(b&&(g["Content-Type"]=b),g["Cache-Control"]="no-store",t.writeHead(h.status,g),!h.body){t.end();return}let w=h.body.getReader();for(;;){let{done:A,value:y}=await w.read();if(A)break;t.write(Buffer.from(y))}t.end()}catch(h){t.writeHead(502,{"Content-Type":"text/plain"}),t.end(`bundle-proxy: upstream fetch failed: ${h instanceof Error?h.message:String(h)}`)}})();return}if(r.pathname==="/__server-scan"){this.handleServerScan(t);return}if(r.pathname==="/healthz"){t.writeHead(200,{"Content-Type":"application/json","Cache-Control":"no-store"}),t.end(JSON.stringify({ok:!0,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,bridgeSource:this.shouldWriteDevLockfile?"vite-dev":this.shouldWriteLockfile?"daemon":"embedded",startedAt:this.startedAt,uptimeMs:this.startedAt>0?Date.now()-this.startedAt:0}));return}let s=he(r.hostname),c=D(r.hostname);s||this.refreshActiveRuntime();let n=s?fe(r.hostname):this.activeRuntimeDirPath;if(!n){t.writeHead(503,{"Content-Type":"text/plain; charset=utf-8"}),t.end(s?`rnx: runtime ${c??"(invalid version origin)"} is not installed. run \`rnx open\` from that app again.`:"rnx: no active runtime installed. run `rnx runtime install` to fetch one.");return}let a=r.pathname;if(a==="/runtime"||a==="/runtime/"?a="/":a.startsWith("/runtime/")?a=a.slice(8):a==="/sootsim"||a==="/sootsim/"?a="/":a.startsWith("/sootsim/")&&(a=a.slice(8)),(a===""||a==="/")&&(a="/index.html"),a.includes("\0")){t.writeHead(400),t.end("bad request");return}if(process.platform!=="win32"&&a.includes("\\")){t.writeHead(400),t.end("bad request");return}for(let u of a.split("/"))if(u===".."){t.writeHead(403),t.end("forbidden");return}let d=v.resolve(n,"."+a),l=n.endsWith(v.sep)?n:n+v.sep;if(!d.startsWith(l)&&d!==n){t.writeHead(403),t.end("forbidden");return}T.realpath(d,(u,p)=>{let m=u?d:p,f=m.endsWith(v.sep)?m:m+v.sep;if(!u){let h=(()=>{try{let g=T.realpathSync(n);return g.endsWith(v.sep)?g:g+v.sep}catch{return l}})();if(!f.startsWith(h)&&m+v.sep!==h){t.writeHead(403),t.end("forbidden");return}}T.stat(m,(h,g)=>{if(h||!g?.isFile()){let y=v.extname(a).toLowerCase();if(y&&y!==".html"){t.writeHead(404),t.end("not found");return}if(a.startsWith("/__")||a.startsWith("/api/")||a==="/api"){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("not found");return}let k=v.join(n,"index.html");T.readFile(k,(Qe,et)=>{if(Qe){t.writeHead(404),t.end("not found");return}if(t.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),i==="HEAD"){t.end();return}t.end(Xe(et,this.effectivePort,this.contrastOrigin))});return}let b=v.extname(m).toLowerCase(),w=qe[b]||"application/octet-stream";if(t.writeHead(200,{"Content-Type":w,"Cache-Control":"no-store"}),i==="HEAD"){t.end();return}if(b===".html"){T.readFile(m,(y,k)=>{if(y){try{t.end()}catch{}return}t.end(Xe(k,this.effectivePort,this.contrastOrigin))});return}let A=T.createReadStream(m);A.pipe(t),A.on("error",()=>{try{t.end()}catch{}})})})}sweepIdleCliClients(){let e=Date.now(),t=!1;for(let[i,r]of this.cliSimBySocket){let s=this.cliLastCommandAt.get(i)??0;if(e-s<o.CLI_IDLE_TIMEOUT_MS)continue;let c=!1;for(let n of this.cliBySentId.values())if(n.ws===i){c=!0;break}if(!c){this.cliSimBySocket.delete(i),this.cliLastCommandAt.delete(i);for(let[n,a]of this.cliBySentId)a.ws===i&&this.cliBySentId.delete(n);try{i.close(1e3,"idle timeout")}catch{}t=!0}}t&&this.broadcastSimClientStates(),this.sweepRestorableSims(e),this.reapIdleSims(e)}isAutomationSim(e){return e.meta?.sootsimHostDriver==="playwright"}automationSimOwnerAlive(e){let t=Number(e.meta?.sootsimHostPid);if(!Number.isInteger(t)||t<=1||t===process.pid)return!1;try{return process.kill(t,0),!0}catch(i){return i.code==="EPERM"}}reapIdleSims(e=Date.now()){let t=new Set(this.cliSimBySocket.values()),i=[];for(let s of this.sims.values()){if(s.id===this.primarySimId||t.has(s.id)||this.getActiveLease(s))continue;let c=Math.max(s.lastActiveAt,s.connectedAt),n=e-c,a=this.isAutomationSim(s);if(a&&this.automationSimOwnerAlive(s))continue;let d=a?this.automationSimIdleReapTtlMs:this.simIdleReapTtlMs;if(n>=d){this.closeSimSocketFromHost(s.ws);continue}a&&i.push({sim:s,idleMs:n})}let r=this.maxConcurrentAutomationSims;if(i.length>r){i.sort((s,c)=>c.idleMs-s.idleMs);for(let{sim:s,idleMs:c}of i.slice(0,i.length-r))c<this.automationSimActiveGraceMs||this.closeSimSocketFromHost(s.ws)}}sweepDeadWebSockets(){if(this.wss)for(let e of this.wss.clients){if(e.readyState!==S.OPEN)continue;if(this.wsIsAlive.get(e)===!1){try{e.terminate()}catch{}continue}this.wsIsAlive.set(e,!1);try{e.ping()}catch{try{e.terminate()}catch{}}}}closeSimSocketFromHost(e){if(e.readyState!==S.OPEN)return;try{e.close(ue,pe)}catch{try{e.terminate()}catch{}return}let t=setTimeout(()=>{if(e.readyState!==S.CLOSED)try{e.terminate()}catch{}},Bt);Ze(t)}listSims(){return Array.from(this.sims.values()).sort((e,t)=>e.id===this.primarySimId?-1:t.id===this.primarySimId?1:e.connectedAt-t.connectedAt).map(e=>this.describeSim(e))}async sendCommand(e){let t=await this.waitForSim(e.simId),i=this.nextCommandId++;return new Promise((r,s)=>{let c=setTimeout(()=>{this.pendingCommands.delete(i),this.broadcastSimClientStates(),s(new Error("command timed out after 30s"))},3e4);this.pendingCommands.set(i,{simId:t.id,resolve:d=>{clearTimeout(c),this.pendingCommands.delete(i),this.broadcastSimClientStates(),r(d)},reject:d=>{clearTimeout(c),this.pendingCommands.delete(i),this.broadcastSimClientStates(),s(d)}}),this.broadcastSimClientStates();let{simId:n,...a}=e;t.ws.send(JSON.stringify({...a,id:i}))})}async evaluate(e,t){return this.sendCommand({type:"evaluate",code:e,simId:t})}async focusSim(e){return this.sendCommand({type:"focus",simId:e})}async closeSim(e){return this.sendCommand({type:"close",simId:e})}async openPathInEditor(e,t,i){let r=t!=null?`:${t}${i!=null?`:${i}`:""}`:"",s=`${e}${r}`,c=(a,d)=>new Promise(l=>{try{let u=_t(a,d,{detached:!0,stdio:"ignore"}),p=!1;u.on("error",()=>{p||(p=!0,l(!1))}),u.on("spawn",()=>{p||(p=!0,u.unref(),l(!0))})}catch{l(!1)}}),n=process.env.REACT_EDITOR||process.env.EDITOR;if(n){let a=n.split(" ").filter(Boolean);if(a.length&&await c(a[0],[...a.slice(1),"-g",s]))return}await c("cursor",["-g",s])||await c("code",["-g",s])||await this.openUrl(e)}async openUrl(e,t={}){if(this.openUrlHandler){await this.openUrlHandler(e,t);return}await ge(e,t)}async close(){if(this.cliIdleTimer&&(clearInterval(this.cliIdleTimer),this.cliIdleTimer=null),this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.devHeartbeatTimer&&(clearInterval(this.devHeartbeatTimer),this.devHeartbeatTimer=null),this.wsHeartbeatTimer&&(clearInterval(this.wsHeartbeatTimer),this.wsHeartbeatTimer=null),this.runtimeUpdateTimer&&(clearInterval(this.runtimeUpdateTimer),this.runtimeUpdateTimer=null),this.shouldWriteLockfile)try{J({pid:process.pid,startedAt:this.startedAt})}catch{}if(this.shouldWriteDevLockfile)try{de({bridgePort:this.effectivePort,pid:process.pid,startedAt:this.startedAt})}catch{}this.effectivePort=0,this.startedAt=0,this.agentHost.close();for(let[i,r]of this.pendingCommands)r.reject(new Error("server closing")),this.pendingCommands.delete(i);for(let i of this.sims.values())i.ws.close();this.sims.clear(),this.primarySimId=null;let e=this.wss,t=this.httpServer;if(this.wss=null,this.httpServer=null,e)try{e.close()}catch{}if(t)try{t.close()}catch{}}describeSim(e){let t;try{t=e.ws.readyState}catch{t=S.CLOSED}let i=this.getActiveLease(e);return{id:e.id,origin:e.origin,url:e.url,title:e.title,userAgent:e.userAgent,connectedAt:e.connectedAt,lastSeenAt:e.lastSeenAt,lastActiveAt:e.lastActiveAt||void 0,isPrimary:e.id===this.primarySimId,readyState:t===S.OPEN?"open":t===S.CLOSING?"closing":"closed",attachedCliCount:this.getAttachedCliCount(e.id),lockedBy:i?i.cliLabel||i.cliIdentityKey:void 0,lockedByKind:i?i.kind:void 0,lockExpiresAt:i?i.expiresAt:void 0,userFocused:e.userFocused||void 0,userVisible:e.userVisible,visibilityState:e.visibilityState,documentFocused:e.documentFocused,kind:e.kind,meta:e.meta}}getActiveLease(e){let t=e.cliLease;return t?Date.now()>=t.expiresAt?(e.cliLease=void 0,null):t:null}tryAcquireLease(e,t,i={}){let r=this.cliIdentityKeyBySocket.get(e)??(()=>{let u=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,u),u})(),s=this.cliLabelBySocket.get(e),c=Date.now(),n=this.getActiveLease(t),a=n&&n.cliIdentityKey===r,d=0;if(n&&!a&&!i.force)return{granted:!1,lease:n,lock:{by:n.cliLabel||n.cliIdentityKey,expiresInMs:Math.max(0,n.expiresAt-c)},bootedCount:0};if(n&&!a&&i.force)for(let[u,p]of this.cliSimBySocket){if(p!==t.id)continue;let m=this.cliIdentityKeyBySocket.get(u);if(m&&m!==r){this.cliSimBySocket.delete(u);try{u.close(1e3,"lease claimed by another cli")}catch{}d++}}let l={kind:"cli",cliIdentityKey:r,cliLabel:s,expiresAt:c+o.CLI_LEASE_TTL_MS};return t.cliLease=l,{granted:!0,lease:l,bootedCount:d}}updateUserFocusLease(e,t){let i=t.focused===!0,r=typeof t.visible=="boolean"?t.visible:void 0,s=typeof t.visibilityState=="string"?t.visibilityState:void 0,c=typeof t.documentFocused=="boolean"?t.documentFocused:void 0;e.userFocused===i&&e.userVisible===r&&e.visibilityState===s&&e.documentFocused===c||(e.userFocused=i,e.userVisible=r,e.visibilityState=s,e.documentFocused=c,this.broadcastSimClientStates())}updateUserActivity(e){let t=this.getActiveLease(e);if(t&&t.kind==="cli")return;let r=Date.now()+o.USER_ACTIVE_LEASE_TTL_MS,s=t&&t.kind==="user-active"?Math.max(t.expiresAt,r):r;e.cliLease={kind:"user-active",cliIdentityKey:"__user-active__",cliLabel:"active user",expiresAt:s},this.broadcastSimClientStates()}ensureCliIdentityKey(e){let t=this.cliIdentityKeyBySocket.get(e);if(t)return t;let i=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,i),i}getOpenSim(e){if(e){let i=this.sims.get(e);return i?.ws.readyState===S.OPEN?i:null}let t=this.getDefaultSimCandidates();return t.find(i=>i.id===this.primarySimId)??t[0]??null}getDefaultSimCandidates(){let e=Array.from(this.sims.values()).filter(i=>i.ws.readyState===S.OPEN),t=e.filter(i=>i.url);return t.length>0?t:e}async waitForSim(e,t={}){let i=t.attempts??10,r=t.intervalMs??200;for(let c=0;c<i;c++){if(e){let n=this.getOpenSim(e);if(n)return n}else{let n=this.getDefaultSimCandidates();if(n.length>1)throw new Error(`multiple sims are connected: ${n.map(d=>d.id).join(", ")}; run \`rnx use <sim>\` or pass \`--sim <sim>\``);let a=n[0];if(a)return a}await new Promise(n=>setTimeout(n,r))}if(!e)throw new Error("no sim connected");let s=this.getDefaultSimCandidates().map(c=>c.id);throw new Error(`no sim connected with id ${e}`+(s.length>0?`; connected sims: ${s.join(", ")}`:""))}shouldPromoteSim(e){let t=this.primarySimId?this.sims.get(this.primarySimId):null;if(!e.url)return!t;let i=t?.ws.readyState===S.OPEN;if(!t||!i||!t.url)return!0;let r=e.origin?.includes(":5173"),s=t.origin?.includes(":5173");return!!r||!s}broadcastSimAssignments(){for(let e of this.sims.values())e.ws.readyState===S.OPEN&&e.ws.send(JSON.stringify({type:"bridge:welcome",simId:e.id,isPrimary:e.id===this.primarySimId}))}writeAndBroadcastSharedConfig(e){let t=ee(e),i=JSON.stringify({type:"bridge:shared-config-changed",config:t});for(let r of this.sims.values())if(r.ws.readyState===S.OPEN)try{r.ws.send(i)}catch{}return t}broadcastSimClientStates(){for(let e of this.sims.values()){if(e.ws.readyState!==S.OPEN)continue;let t=this.getActiveLease(e),i={type:"bridge:client-state",attachedCliCount:this.getAttachedCliCount(e.id),activeAgentCommandCount:this.getActiveAgentCommandCount(e.id),recentActions:e.recentActions,lockedBy:t?t.cliLabel||t.cliIdentityKey:void 0,lockedByKind:t?t.kind:void 0,lockExpiresAt:t?t.expiresAt:void 0,userFocused:e.userFocused||void 0,userVisible:e.userVisible,visibilityState:e.visibilityState,documentFocused:e.documentFocused};e.ws.send(JSON.stringify(i))}}setCliSimTarget(e,t){let i=this.cliSimBySocket.get(e);i!==t&&(this.cliSimBySocket.set(e,t),this.recordSimAction(t,i?"cli switched sims":"cli connected",!1),this.broadcastSimClientStates())}recordSimAction(e,t,i=!0){let r=t?.trim();if(!r)return;let s=this.sims.get(e);if(!s)return;let c=Date.now();s.lastActiveAt=c,s.recentActions=[{label:r,at:c},...s.recentActions.filter(n=>n.label!==r)].slice(0,4),i&&this.broadcastSimClientStates()}describeForwardedCommand(e){switch(e?.type){case"evaluate":return"evaluated page state";case"screenshot":return"captured screenshot";case"tap":return"sent tap event";case"keyboard":return e?.action==="type"?"typed text":"used keyboard";case"tree":return"dumped tree";case"focus":return"focused sim";case"close":return"requested close";default:return typeof e?.type=="string"?e.type:null}}getAttachedCliCount(e){let t=new Set;for(let[i,r]of this.cliSimBySocket){if(r!==e||i.readyState!==S.OPEN)continue;let s=this.cliIdentityKeyBySocket.get(i);t.add(s??`ws-unknown-${t.size}`)}return t.size}getOtherCliIdentityCount(e,t){let i=this.cliIdentityKeyBySocket.get(e),r=new Set;for(let[s,c]of this.cliSimBySocket){if(c!==t||s.readyState!==S.OPEN)continue;let n=this.cliIdentityKeyBySocket.get(s);n&&n===i||r.add(n??`ws-unknown-${r.size}`)}return r.size}getActiveAgentCommandCount(e){let t=0;for(let i of this.pendingCommands.values())i.simId===e&&t++;return t}allocateSimId(){for(;;){let e=this.nextSimNumber.toString(16);if(this.nextSimNumber++,!this.sims.has(e)&&!this.restorableSims.has(e))return e}}tryRestoreSimId(e,t){let i=t?.trim();if(!i||i===e.id)return!1;let r=this.sims.get(i);if(r&&r!==e&&r.ws.readyState===S.OPEN)return!1;let s=this.getRestorableSimState(i),c=e.id;this.sims.delete(c),e.id=i,s&&(e.recentActions=s.recentActions.map(n=>({...n})),e.lastActiveAt=s.lastActiveAt,e.cliLease=s.cliLease?{...s.cliLease}:void 0,this.restorableSims.delete(i)),this.sims.set(e.id,e),this.primarySimId===c&&(this.primarySimId=e.id);for(let[n,a]of this.cliSimBySocket)a===c&&this.cliSimBySocket.set(n,e.id);return!0}rememberDisconnectedSim(e){let t=this.getActiveLease(e);this.restorableSims.set(e.id,{recentActions:e.recentActions.map(i=>({...i})),lastActiveAt:e.lastActiveAt,cliLease:t&&t.kind==="cli"?{...t}:void 0,expiresAt:Date.now()+o.SIM_RECONNECT_TTL_MS}),this.sims.delete(e.id),this.writeConnectedRuntimeSnapshot()}getRestorableSimState(e){let t=this.restorableSims.get(e);return t?t.expiresAt<=Date.now()?(this.restorableSims.delete(e),null):(t.cliLease&&t.cliLease.expiresAt<=Date.now()&&(t.cliLease=void 0),t):null}sweepRestorableSims(e=Date.now()){for(let[t,i]of this.restorableSims)if(!(i.expiresAt>e)){this.restorableSims.delete(t);for(let[r,s]of this.cliSimBySocket)s===t&&this.cliSimBySocket.delete(r)}}resetServerState(){this.cliIdleTimer&&(clearInterval(this.cliIdleTimer),this.cliIdleTimer=null),this.wsHeartbeatTimer&&(clearInterval(this.wsHeartbeatTimer),this.wsHeartbeatTimer=null),this.runtimeUpdateTimer&&(clearInterval(this.runtimeUpdateTimer),this.runtimeUpdateTimer=null);let e=this.wss,t=this.httpServer;if(this.wss=null,this.httpServer=null,e)try{e.close()}catch{}if(t)try{t.close()}catch{}}};async function Di(o,e={}){(o.includes("--help")||o.includes("-h"))&&(console.log(`
|
|
100
|
+
rnx serve \u2014 run the rnx bridge in the foreground
|
|
101
|
+
|
|
102
|
+
hosts the WS bridge that CLI commands talk to. once running, any rnx
|
|
103
|
+
renderer (browser, electron, headless playwright) that connects to port 7668
|
|
104
|
+
becomes drivable from 'rnx describe', 'rnx do tap', etc.
|
|
105
|
+
|
|
106
|
+
usage:
|
|
107
|
+
rnx serve [options]
|
|
108
|
+
|
|
109
|
+
options:
|
|
110
|
+
--port <n> bridge port (defaults to ${7668})
|
|
111
|
+
--quiet suppress per-connection logging
|
|
112
|
+
|
|
113
|
+
examples:
|
|
114
|
+
rnx serve
|
|
115
|
+
rnx serve --port 7668 --quiet
|
|
116
|
+
`),process.exit(0));let t=o.indexOf("--port"),i=t>=0&&o[t+1]?Number(o[t+1]):e.port??7668;Number.isNaN(i)&&(console.error(` invalid --port value: ${o[t+1]}`),process.exit(1));let r=o.includes("--quiet")||o.includes("-q"),s=ne();s&&se(s)&&(console.error(` an rnx bridge is already running (pid ${s.pid}, port ${s.bridgePort})`),console.error(" stop it with 'rnx daemon stop' first"),process.exit(1)),L();let c=await Se(),n=new j({port:i,writeLockfile:!0,contrastOrigin:c}),a=await n.startAsync({silent:r}),d=Date.now(),l=f=>{r||process.stdout.write(`${f}
|
|
117
|
+
`)},u=new Set,p=setInterval(()=>{let f=n.listSims(),h=new Set(f.map(g=>g.id));for(let g of f)if(!u.has(g.id)){let b=g.title||g.url||g.origin||"(unknown)";l(` + ${g.id} ${b}`)}for(let g of u)h.has(g)||l(` - ${g}`);u.clear();for(let g of h)u.add(g)},500);l(`rnx bridge listening on ws://localhost:${a} (runtime http on same port)`),a!==i&&l(` (preferred port ${i} was taken \u2014 fell back to ${a})`),l(" ready for browser, electron, or headless playwright sims to connect"),l(" (ctrl-c to stop)");let m=async f=>{clearInterval(p),l(`
|
|
118
|
+
${f} received \u2014 shutting down after ${Math.round((Date.now()-d)/1e3)}s`);try{await n.close()}catch{}process.exit(0)};process.on("SIGINT",()=>m("SIGINT")),process.on("SIGTERM",()=>m("SIGTERM")),process.on("SIGHUP",()=>m("SIGHUP")),process.on("exit",()=>{try{n.removeLockfile()}catch{}}),await new Promise(()=>{})}export{Di as runServe};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*! rnx v0.1.345 | (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 N,c as I}from"./chunk-BFTDL2GX.js";import{d as D,g as A,i as E,j as M}from"./chunk-OPHT4DUO.js";import"./chunk-7YMQRA6L.js";import"./chunk-7UIIAHVU.js";import"./chunk-WU72KL6Z.js";import"./chunk-U5YHXQHH.js";import"./chunk-RB4VFUNM.js";import"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import"./chunk-VLBN3KRC.js";import{f}from"./chunk-TEU5NGUA.js";import{c as O}from"./chunk-XJBFJGNT.js";import"./chunk-DHM3JDCK.js";import{a as d}from"./chunk-3N7M5HMJ.js";import{a as $}from"./chunk-BHKSCNDC.js";import{C as w,D as k,J as P,l as x}from"./chunk-LRM2XCEQ.js";import{a as j}from"./chunk-T7SBFG5I.js";import{a as s}from"./chunk-PLUWN2V5.js";import"./chunk-XXZLK4BY.js";import"./chunk-LAQGSSTT.js";import ee from"node:fs";import q from"node:os";import F from"node:path";import{spawn as z}from"node:child_process";import u from"node:fs";import a from"node:path";function C(e){let n=a.resolve(e);for(;;){if(u.existsSync(a.join(n,"package.json")))return n;let r=a.dirname(n);if(r===n)return null;n=r}}function m(e){let n=a.resolve(e);for(;;){if(u.existsSync(a.join(n,"bun.lock"))||u.existsSync(a.join(n,"bun.lockb")))return"bun";if(u.existsSync(a.join(n,"pnpm-lock.yaml")))return"pnpm";if(u.existsSync(a.join(n,"package-lock.json")))return"npm";let r=a.dirname(n);if(r===n)return"npm";n=r}}function V(e){let n=a.resolve(e.appDir),r=G(a.join(n,"package.json")),o=`${s.commandName} open`,t=r.scripts?.[s.commandName];if(t&&t!==o)throw new Error(`package.json already defines scripts.${s.commandName} as ${JSON.stringify(t)}; resolve that conflict before setup`);let i=m(n),c=[];return r.devDependencies?.[s.packageName]!==e.cliVersion&&c.push(H(i,e.cliVersion)),t!==o&&c.push(Q(i)),{appDir:n,packageManager:i,operations:c}}async function J(e,n){for(let r of e.operations)n.dryRun||await K(r,e.appDir,n.json)}function y(e){return e.operations.map(n=>`${n.command} ${n.args.map(Z).join(" ")}`)}function G(e){let n;try{n=JSON.parse(u.readFileSync(e,"utf8"))}catch(t){let i=t instanceof Error?t.message:String(t);throw new Error(`could not read ${e}: ${i}`)}if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${e} must contain a JSON object`);let r=T(Reflect.get(n,"scripts")),o=T(Reflect.get(n,"devDependencies"));return{...r?{scripts:r}:{},...o?{devDependencies:o}:{}}}function T(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=Object.entries(e).filter(r=>typeof r[1]=="string");return Object.fromEntries(n)}function H(e,n){let r=`${s.packageName}@${n}`;switch(e){case"bun":return{command:"bun",args:["add","--dev","--exact",r],description:`install ${r} as an exact dev dependency`};case"pnpm":return{command:"pnpm",args:["add","--save-dev","--save-exact",r],description:`install ${r} as an exact dev dependency`};case"npm":return{command:"npm",args:["install","--save-dev","--save-exact",r],description:`install ${r} as an exact dev dependency`}}}function Z(e){return/^[a-zA-Z0-9_./@=-]+$/.test(e)?e:JSON.stringify(e)}function K(e,n,r){return new Promise((o,t)=>{let i=z(e.command,e.args,{cwd:n,stdio:r?["ignore",2,"inherit"]:"inherit"});i.once("error",t),i.once("exit",c=>{c===0?o():t(new Error(`${e.command} exited with code ${c??"unknown"}`))})})}function Q(e){return{command:e,args:e==="bun"?["pm","pkg","set",`scripts.${s.commandName}=${s.commandName} open`]:["pkg","set",`scripts.${s.commandName}=${s.commandName} open`],description:`add the \`${s.commandName}\` package script`}}async function Te(e){if(e.includes("--help")||e.includes("-h")){me();return}let n=ne(e);try{let r=C(n.appDir),o=N(),t=w(),i=await te(n,o),c=await oe(n,r),g=await ie(n,t),B=!1,U=await f.fetchManifest(),l=f.resolveVersion(U,{channel:"stable"}).version,S=j();if(S==="0.0.0")throw new Error("could not resolve the installed rnx CLI version");let p=null;c&&r&&(p=V({appDir:r,cliVersion:S})),ce(n),pe(n,o,i,l),ue(n,r,p),le(n,g);let v=!1;if(!n.dryRun){let b=P();v=(await f.install({version:l,channel:"stable",setActive:!0,protectVersions:b?[b]:[]})).installed}p&&await J(p,{dryRun:n.dryRun,json:n.json});let h=o.installed;i&&!o.installed&&!n.dryRun&&(await I({port:7668,force:!1}),h=!0),n.dryRun||k({productAnalytics:g,crashReports:B});let W=r?se(r):null;de(n,W);let R={runtimeVersion:l,serviceInstalled:h,repositoryPrepared:p!==null},Y=ae(l);return n.json?console.log(JSON.stringify({...R,runtimeInstalled:n.dryRun?!1:v,dryRun:n.dryRun,cache:Y,repositoryOperations:p?y(p):[]},null,2)):fe(p),R}catch(r){throw O(r),r}}function ne(e){let n=e.indexOf("--app"),r=n>=0?e[n+1]:void 0;if(n>=0&&(!r||r.startsWith("-")))throw new Error("--app requires a directory");let o=_(e,"--service","--no-service"),t=_(e,"--repo","--no-repo");return{appDir:F.resolve(r??process.cwd()),ci:e.includes("--ci")||$(),dryRun:e.includes("--dry-run"),json:e.includes("--json"),yes:e.includes("--yes")||e.includes("-y"),service:o,repository:t,productAnalytics:re(e,"--analytics")}}function _(e,n,r){if(e.includes(n)&&e.includes(r))throw new Error(`${n} and ${r} cannot be used together`);if(e.includes(n))return!0;if(e.includes(r))return!1}function re(e,n){let r=e.find(i=>i.startsWith(`${n}=`)),o=e.indexOf(n),t=r?.slice(n.length+1)??(o>=0?e[o+1]:void 0);if(t!==void 0){if(t==="on"||t==="yes"||t==="true")return!0;if(t==="off"||t==="no"||t==="false")return!1;throw new Error(`${n} must be on or off`)}}async function te(e,n){if(e.ci){if(e.service===!0)throw new Error("--ci cannot install a machine service");return!1}return n.supported?n.installed&&e.service===void 0?!0:e.service!==void 0?e.service:e.yes?!0:(L(e,"--service or --no-service"),d("Install the background service and shared managed runtime?",!0)):!1}async function oe(e,n){if(!n){if(e.repository===!0)throw new Error("--repo requires a package.json");return!1}return e.repository!==void 0?e.repository:e.yes?!0:(L(e,"--repo or --no-repo"),d(`Prepare ${n} for reproducible rnx runs?`,!0))}async function ie(e,n){return e.productAnalytics!==void 0?e.productAnalytics:n.configured?n.productAnalytics:e.yes||e.ci||!process.stdin.isTTY?!1:d("Share anonymous package incompatibilities and error classes to improve rnx?",!1)}function L(e,n){if(!(process.stdin.isTTY&&!e.ci))throw new Error(`non-interactive setup requires ${n}, or --yes to accept defaults`)}function se(e){let n=JSON.parse(ee.readFileSync(F.join(e,"package.json"),"utf8"));if(!n||typeof n!="object")throw new Error("package.json must contain an object");return D(n)}function ae(e){let n=q.platform(),r=q.arch();return{path:x(e),key:`sootsim-runtime-${n}-${r}-${e}`,inputs:{platform:n,arch:r,runtimeVersion:e}}}function ce(e){e.json||console.log(`
|
|
5
|
+
rnx setup`)}function pe(e,n,r,o){e.json||(console.log(`
|
|
6
|
+
1. machine`),console.log(` stable runtime: ${o}`),console.log(` background service: ${n.supported?r?"install":"skip":"unsupported on this platform"}`))}function ue(e,n,r){if(!e.json){if(console.log(`
|
|
7
|
+
2. repository`),!n){console.log(" no package.json found; repository preparation skipped");return}if(!r){console.log(` skipped for ${n}`);return}console.log(` package manager: ${m(n)}`);for(let o of y(r))console.log(` ${e.dryRun?"would run":"run"}: ${o}`)}}function le(e,n){e.json||(console.log(`
|
|
8
|
+
3. privacy`),console.log(` bounded diagnostics: ${n?"on":"off"}`),console.log(" package name/version/unsupported API or error class only"),console.log(" source, paths, project names, app content, identity, and command usage are never included"))}function de(e,n){if(!e.json){if(console.log(`
|
|
9
|
+
4. compatibility`),!n){console.log(" no package.json found; run `rnx compat` inside an app later");return}console.log(` ${A(n)}`);for(let r of E(n))console.log(` ${r}`);console.log(` ${M}`)}}function fe(e){if(console.log(`
|
|
10
|
+
5. ready`),e){let n=e.packageManager==="bun"?"bun run sootsim":`${e.packageManager} run rnx`;console.log(` start your app normally, then ${n} -- <port>`)}else console.log(" start your app normally, then rnx open <port>");console.log(" useful next commands: rnx describe; rnx get errors; rnx compat"),console.log(" install agent skills with `rnx skill install`, then start a new session"),console.log(" if a concrete rnx seam is missing or broken, preview `rnx report-issue` and confirm separately")}function me(){console.log(`
|
|
11
|
+
rnx setup \u2014 configure a machine and optionally prepare the current repository
|
|
12
|
+
|
|
13
|
+
usage:
|
|
14
|
+
rnx setup
|
|
15
|
+
rnx setup --yes
|
|
16
|
+
rnx setup --ci --yes --json
|
|
17
|
+
rnx setup --dry-run --yes
|
|
18
|
+
|
|
19
|
+
decisions:
|
|
20
|
+
--service | --no-service
|
|
21
|
+
--repo | --no-repo
|
|
22
|
+
--analytics on|off
|
|
23
|
+
|
|
24
|
+
automation:
|
|
25
|
+
--yes accept setup defaults; diagnostics remain off unless explicitly enabled
|
|
26
|
+
--ci never prompt or install a background service
|
|
27
|
+
--json emit runtime/cache metadata as JSON
|
|
28
|
+
--dry-run print exact repository operations without changing the machine
|
|
29
|
+
--app DIR use DIR as the repository search start
|
|
30
|
+
`)}export{Te as runSetup};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a as h}from"./chunk-
|
|
4
|
+
import{a as h}from"./chunk-PLUWN2V5.js";import"./chunk-LAQGSSTT.js";import*as l from"fs";import*as L from"os";import*as a from"path";import{fileURLToPath as x}from"url";function D(){try{let e=x(import.meta.resolve(`${h.packageName}/package.json`));return a.join(a.dirname(e),"skills")}catch{let e=a.dirname(x(import.meta.url));return a.resolve(e,"../../skills")}}var d=D(),j=new Set(["all","codex","claude"]);function S(){console.log(`rnx skill
|
|
5
5
|
|
|
6
6
|
install and inspect bundled rnx agent skills.
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{m as a}from"./chunk-
|
|
4
|
+
import{m as a}from"./chunk-ZMTZ5G5H.js";import"./chunk-4BIPA7MD.js";import{q as c,s as l}from"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import"./chunk-LRM2XCEQ.js";import"./chunk-LAQGSSTT.js";function g(t){return!!t&&typeof t=="object"&&typeof Reflect.get(t,"capturedAt")=="number"}function p(){console.log(`
|
|
5
5
|
rnx state - capture the current app state in one call
|
|
6
6
|
|
|
7
7
|
usage:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{
|
|
4
|
+
import{a as f}from"./chunk-HK7YKH6N.js";import"./chunk-ZMTZ5G5H.js";import"./chunk-4BIPA7MD.js";import"./chunk-KA4PJNTE.js";import{b as t,c as l,d as s,e as c,f as a}from"./chunk-QNRWPAOA.js";import"./chunk-KZFJNDH3.js";import"./chunk-LRM2XCEQ.js";import"./chunk-LAQGSSTT.js";function p(){console.log(`
|
|
5
5
|
rnx storage profile \u2014 manage isolated storage profiles
|
|
6
6
|
|
|
7
7
|
usage:
|
|
@@ -21,7 +21,7 @@ examples:
|
|
|
21
21
|
rnx open 8081 --profile qa --driver playwright
|
|
22
22
|
rnx storage profile clear qa
|
|
23
23
|
rnx storage profile delete qa
|
|
24
|
-
`)}async function d(r,n){if(r.includes("--help")||r.includes("-h"))return p(),0;let o=r[0]??"list";try{switch(o){case"list":{let e=
|
|
24
|
+
`)}async function d(r,n){if(r.includes("--help")||r.includes("-h"))return p(),0;let o=r[0]??"list";try{switch(o){case"list":{let e=t();for(let i of e)console.log(` ${i.id}`);return 0}case"create":{let e=r[1];if(!e)return console.error(" profile create expects <id>"),1;let i=s(e);return console.log(` created profile: ${i.id}`),0}case"ensure":{let e=r[1];if(!e)return console.error(" profile ensure expects <id>"),1;let i=l(e);return console.log(` profile: ${i.id}`),0}case"clear":{let e=r[1];return e?(l(e),a(e),console.log(` cleared profile: ${e}`),0):(console.error(" profile clear expects <id>"),1)}case"delete":{let e=r[1];if(!e)return console.error(" profile delete expects <id>"),1;let i=c(e);return console.log(` deleted profile: ${i.id}`),0}default:return console.error(` unknown profile command: ${o}`),p(),1}}catch(e){return console.error(` profile failed: ${e instanceof Error?e.message:String(e)}`),1}}var m=new Set(["--sim","--port","-p"]),g=new Set(["profile","clear"]);function x(r){for(let n=0;n<r.length;n++){let o=r[n];if(o.startsWith("-")){m.has(o)&&n++;continue}return g.has(o)?{name:o,index:n}:null}return null}function u(){console.log(`
|
|
25
25
|
rnx storage \u2014 manage sim and app storage
|
|
26
26
|
|
|
27
27
|
usage:
|
|
@@ -34,4 +34,4 @@ subcommands:
|
|
|
34
34
|
profile clear <id>
|
|
35
35
|
profile delete <id>
|
|
36
36
|
clear clear the current guest app data and relaunch it
|
|
37
|
-
`)}async function w(r,n){if(r.includes("--help")||r.includes("-h"))return u(),0;let o=x(r);return o?.name==="profile"?d([...r.slice(0,o.index),...r.slice(o.index+1)],n):o?.name==="clear"?
|
|
37
|
+
`)}async function w(r,n){if(r.includes("--help")||r.includes("-h"))return u(),0;let o=x(r);return o?.name==="profile"?d([...r.slice(0,o.index),...r.slice(o.index+1)],n):o?.name==="clear"?f([...r.slice(0,o.index),...r.slice(o.index+1)],n):(console.error(` unknown storage command: ${o?.name??"(missing)"}`),u(),1)}export{w as runStorage};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! rnx v0.1.345 | (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}from"./chunk-7V4KPZ7O.js";import"./chunk-RB4VFUNM.js";import"./chunk-LAQGSSTT.js";export{a as settingsStore};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! rnx v0.1.345 | (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,b,c,d}from"./chunk-XJBFJGNT.js";import"./chunk-DHM3JDCK.js";import"./chunk-3N7M5HMJ.js";import"./chunk-BHKSCNDC.js";import"./chunk-LRM2XCEQ.js";import"./chunk-LAQGSSTT.js";export{a as buildCliDiagnosticEvent,d as flushCliTelemetry,b as trackCliDiagnostic,c as trackCliError};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{q as m,s as d,v as i}from"./chunk-
|
|
4
|
+
import{q as m,s as d,v as i}from"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import"./chunk-LRM2XCEQ.js";import"./chunk-LAQGSSTT.js";import{writeFileSync as g}from"fs";function u(){console.log(`
|
|
5
5
|
rnx timeline \u2014 control the semantic event timeline
|
|
6
6
|
|
|
7
7
|
usage:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a as h,b as v,c as $}from"./chunk-
|
|
4
|
+
import{a as h,b as v,c as $}from"./chunk-KH777UAO.js";import{b as p}from"./chunk-RTDHX6CW.js";import"./chunk-E2RGSCHT.js";import"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import{b as g}from"./chunk-TEU5NGUA.js";import{J as a,g as m,h as u,l as d}from"./chunk-LRM2XCEQ.js";import{a as f}from"./chunk-T7SBFG5I.js";import"./chunk-PLUWN2V5.js";import"./chunk-LAQGSSTT.js";import{spawn as y}from"node:child_process";import x from"node:fs";import R from"node:os";import s from"node:path";var b="https://registry.npmjs.org/rnxsim/latest";async function W(t){let n=t.indexOf("--channel"),e=n>=0&&t[n+1]?t[n+1]:void 0;console.log(`rnx upgrade
|
|
5
5
|
`),console.log("runtime:");let o=a(),{config:l}=await p(),r=l?.runtimeVersion,c=r?x.existsSync(s.join(d(r),"index.html")):!1;r&&console.log(` project config: v${r}`);let i=(r&&c?null:await $(["install",...r?[r,"--set-active=false"]:[],...e?["--channel",e]:[]],{}))?.version??r??a();i&&console.log(r?c?` result: v${i} already installed for this project`:` result: not installed \u2192 v${i} for this project`:o&&o!==i?` result: v${o} \u2192 v${i}`:o?` result: v${i} already current`:` result: not installed \u2192 v${i}`);let k=i?await h(i):null;console.log(`
|
|
6
6
|
cli:`),await j(),i&&console.log(`
|
|
7
7
|
${v(i,k)}`)}function w(){if(u())return{kind:"dev"};let t=process.argv[1]??"";try{t=x.realpathSync(t)}catch{}let n=s.sep;if(t.includes(`${n}_npx${n}`)||t.includes(`${n}.bunx${n}`))return{kind:"npx"};if(t.includes(`${n}.bun${n}`))return{kind:"global",command:"bun",args:["add","-g","rnxsim@latest"]};if(t.includes(`${n}pnpm${n}`))return{kind:"global",command:"pnpm",args:["add","-g","rnxsim@latest"]};let e=s.join(m(),"cli");if(t.startsWith(`${e}${n}`))return{kind:"global",command:"npm",args:["i","-g","--prefix",e,"rnxsim@latest"]};let o=s.resolve(process.env.SOOTSIM_CLI_PREFIX||s.join(R.homedir(),".local"));return t.startsWith(`${o}${n}`)?{kind:"global",command:"npm",args:["i","-g","--prefix",o,"rnxsim@latest"]}:{kind:"global",command:"npm",args:["i","-g","rnxsim@latest"]}}async function j(){let t=f(),n=await C();if(!n){console.log(` v${t} \u2014 couldn't reach the npm registry, skipped`);return}if(g(n,t)<=0){console.log(` v${t} (latest)`);return}let e=w();if(console.log(` v${t} \u2192 v${n}`),e.kind==="dev"){console.log(" running from the Contrast dev checkout \u2014 pull instead of upgrading");return}if(e.kind==="npx"){console.log(" running from the npx cache \u2014 get the latest with:"),console.log(" npx rnxsim@latest");return}let o=`${e.command} ${e.args.join(" ")}`;console.log(` updating global install (${o})\u2026`),await S(e.command,e.args)?console.log(` updated to v${n}`):(console.log(" update failed \u2014 run it yourself:"),console.log(` ${o}`))}function S(t,n){return new Promise(e=>{let o=y(t,n,{stdio:"inherit"});o.on("error",()=>e(!1)),o.on("exit",l=>e(l===0))})}async function C(){try{let t=await fetch(b,{headers:{accept:"application/json"},signal:AbortSignal.timeout(8e3)});if(!t.ok)return null;let n=await t.json();return typeof n.version=="string"&&n.version?n.version:null}catch{return null}}export{W as runUpgrade};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! rnx v0.1.345 | (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 a,f as b,g as c}from"./chunk-TMRD5MHL.js";import"./chunk-7LGINKM6.js";import"./chunk-PLB6UVVX.js";import"./chunk-63ASUHOV.js";import"./chunk-TOF5TA5X.js";import"./chunk-R7ZNRGQN.js";import"./chunk-E2RGSCHT.js";import"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import"./chunk-LRM2XCEQ.js";import"./chunk-PLUWN2V5.js";import"./chunk-LAQGSSTT.js";export{a as resolveDefaultUploadOrigin,b as resolvePublicPreviewOrigin,c as runUpload};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{
|
|
4
|
+
import{a as m}from"./chunk-7UIIAHVU.js";import{b as a}from"./chunk-RTDHX6CW.js";import"./chunk-E2RGSCHT.js";import"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import{d as s,f as t}from"./chunk-TEU5NGUA.js";import{l as r}from"./chunk-LRM2XCEQ.js";import{a as l}from"./chunk-T7SBFG5I.js";import"./chunk-PLUWN2V5.js";import"./chunk-LAQGSSTT.js";import g from"node:fs";import d from"node:path";async function R($){let{IS_BETA:c,BETA_LABEL:u}=await import("./beta-EBDIGV3E.js"),f=c?` \xB7 ${u}`:"";console.log(`rnx v${l()}${f}`);let o=m(),n=t.resolveChannel();o.isDevBridge?(console.log(o.primary),o.installedRuntime&&console.log(`${o.installedRuntime} \xB7 ${n}`)):o.primary==="runtime not installed"?console.log("runtime not installed \u2014 run `rnx runtime install`"):console.log(`${o.primary} \xB7 ${n}`);let{config:e}=await a();if(e?.runtimeVersion){let p=g.existsSync(d.join(r(e.runtimeVersion),"index.html"));console.log(`project runtime v${e.runtimeVersion} \xB7 configured \xB7 ${p?"installed":"installs on open"}`)}let i=await t.checkUpToDate({channel:n});i.outdated&&i.latest&&console.log(`
|
|
5
5
|
\u2191 default runtime v${i.latest} available; run \`rnx upgrade\``),console.log(`
|
|
6
6
|
what's new: ${s}`)}export{R as runVersion};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-OPHT4DUO.js";import"./chunk-LAQGSSTT.js";export{b as COMPAT_CATEGORIES,j as COMPAT_RESULT_CAVEAT,c as POLYFILL_REGISTRY,a as UNSUPPORTABLE,f as countScanResults,i as formatDetailedScanLines,h as formatPackageStatus,g as formatScanCounts,d as scanDeps,e as scanDepsWithData};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
+
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
+
import{r as u}from"./chunk-3DBTS4MC.js";import"./chunk-4OKV7T5D.js";import"./chunk-KRZPFXVN.js";import"./chunk-63ASUHOV.js";import{i as p}from"./chunk-TOF5TA5X.js";import"./chunk-U5YHXQHH.js";import"./chunk-7V4KPZ7O.js";import"./chunk-RB4VFUNM.js";import"./chunk-R7ZNRGQN.js";import"./chunk-RTDHX6CW.js";import"./chunk-E2RGSCHT.js";import"./chunk-ZMTZ5G5H.js";import"./chunk-4BIPA7MD.js";import{r as m}from"./chunk-KA4PJNTE.js";import"./chunk-NUPRHZQW.js";import"./chunk-EPLVIDPC.js";import"./chunk-QNRWPAOA.js";import"./chunk-KZFJNDH3.js";import"./chunk-TEU5NGUA.js";import"./chunk-YVSUFVVB.js";import{a as l}from"./chunk-DHM3JDCK.js";import{b as s}from"./chunk-3N7M5HMJ.js";import"./chunk-BHKSCNDC.js";import{C as c}from"./chunk-LRM2XCEQ.js";import"./chunk-PLUWN2V5.js";import"./chunk-LAQGSSTT.js";function d(e){return`${e.projectName?.trim()||e.framework} on :${e.port}`}async function g(e){if(e.length===0)return null;let r=[...e].sort((t,n)=>t.port-n.port);if(r.length===1||!l())return r[0]??null;let o=await s("which running app should rnx open?",r.map(d));return r[o]??r[0]??null}async function S(){let e=c();console.log(`
|
|
5
|
+
welcome to rnx`),console.log(` diagnostics: ${e.configured&&e.productAnalytics?"bounded opt-in on":"off until you opt in"}`),console.log(" looking for a running React Native app\u2026");let r=await g(await p({excludePorts:[7668]}));if(!r)return console.error(" no running React Native development server found."),console.error(" start your app normally, then run `npx rnxsim` again."),1;console.log(` found ${d(r)} \xB7 opening simulator\u2026`);let o=await u([r.bundleUrl]);if(o!==void 0){let{runInspect:t}=await import("./inspect-MDA7ESGQ.js");await t(["wait","ready","--max-ms","120000"],{port:o});let n=m(o,{commandTimeoutMs:45e3});try{let i=await n.send({type:"screenshot"}),a="data:image/png;base64,";if(typeof i!="string"||!i.startsWith(a)||i.length<=a.length)throw new Error("the simulator connected but did not produce a visible app frame")}finally{n.close()}}return 0}export{S as runWelcome};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
3
|
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{D as F,E as T,G as y,R as A,S as b,T as S}from"./chunk-
|
|
4
|
+
import{D as F,E as T,G as y,R as A,S as b,T as S}from"./chunk-4BIPA7MD.js";import{e as k,q as x,s as N}from"./chunk-KA4PJNTE.js";import"./chunk-KZFJNDH3.js";import"./chunk-LRM2XCEQ.js";import"./chunk-LAQGSSTT.js";function O(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--since"&&e+1<n.length){t.push(e,e+1);let s=n[e+1].trim(),l=/^(\d+(?:\.\d+)?)(ms|s|m)?$/.exec(s);if(l){let c=Number(l[1]),u=l[2]??"ms",v=u==="s"?c*1e3:u==="m"?c*6e4:c;return{since:Date.now()-v,consumed:t}}let i=Number(s);if(Number.isFinite(i)&&i>1e12)return{since:i,consumed:t}}return{consumed:t}}function B(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--kinds"&&e+1<n.length)return t.push(e,e+1),{kinds:n[e+1].split(",").map(s=>s.trim()).filter(Boolean),consumed:t};return{consumed:t}}function D(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--limit"&&e+1<n.length){t.push(e,e+1);let s=Number(n[e+1]);if(Number.isFinite(s)&&s>0)return{limit:s,consumed:t}}return{consumed:t}}function _(n){let t=[],e={label:"initial state",events:[],startedAt:n[0]?.t??null};t.push(e);for(let s of n)if(e.events.push(s),s.kind==="screen"||s.kind==="route"){let l=s.data,i=l?.phase;if(!i||i==="enter"||i==="appear"||i==="active"){let c=l?.name||l?.activeName||l?.path||l?.pathname||s.kind;t.length===1&&e.events.length===1?e.label=`${s.kind}: ${c}`:(e={label:`${s.kind}: ${c}`,events:[],startedAt:s.t},t.push(e))}}return t}async function J(n,t){let e=x(n,{port:t.port,stripBooleanFlags:["--summary","--all","--json","--no-advance","--help","-h","--flow","--noisy"],stripValueFlags:["--since","--kinds","--limit"]});(n.includes("--help")||n.includes("-h"))&&(console.log(`
|
|
5
5
|
rnx what-happened \u2014 show recent events from the semantic timeline
|
|
6
6
|
|
|
7
7
|
usage:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/beta.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/beta.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/config.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/detox/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.345 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|