rnxsim 0.1.376 → 0.1.378

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +28 -25
  2. package/cli/app-config.ts +9 -12
  3. package/cli/app-fonts.ts +3 -3
  4. package/cli/app-project.ts +8 -8
  5. package/cli/auth.ts +7 -9
  6. package/cli/bin.ts +16 -31
  7. package/cli/bridge-flow-runner.ts +3 -3
  8. package/cli/browser-backend.ts +44 -0
  9. package/cli/command-contract.ts +221 -0
  10. package/cli/command-registry.ts +291 -0
  11. package/cli/commands/agent-wrapper.ts +2 -2
  12. package/cli/commands/app-fonts.ts +2 -2
  13. package/cli/commands/assert.ts +3 -3
  14. package/cli/commands/auth.ts +1 -1
  15. package/cli/commands/box/cloud-box.ts +1 -1
  16. package/cli/commands/box/plane-share.ts +2 -2
  17. package/cli/commands/box.ts +4 -6
  18. package/cli/commands/compat.ts +1 -1
  19. package/cli/commands/config.ts +2 -2
  20. package/cli/commands/control.ts +29 -29
  21. package/cli/commands/cpu-profile.ts +7 -7
  22. package/cli/commands/daemon-mac-app.ts +7 -7
  23. package/cli/commands/daemon.ts +10 -10
  24. package/cli/commands/debug.ts +11 -11
  25. package/cli/commands/detox.ts +13 -13
  26. package/cli/commands/diagnose.ts +6 -6
  27. package/cli/commands/do-chain.ts +1 -2
  28. package/cli/commands/electron.ts +1 -3
  29. package/cli/commands/film.ts +3 -3
  30. package/cli/commands/flow.ts +43 -43
  31. package/cli/commands/inspect/count.ts +1 -1
  32. package/cli/commands/inspect/describe.ts +1 -1
  33. package/cli/commands/inspect/env.ts +2 -2
  34. package/cli/commands/inspect/get-layout.ts +1 -1
  35. package/cli/commands/inspect/keyboard.ts +1 -1
  36. package/cli/commands/inspect/list.ts +1 -1
  37. package/cli/commands/inspect/memory.ts +1 -1
  38. package/cli/commands/inspect/resolve-target.ts +1 -1
  39. package/cli/commands/inspect/screens.ts +1 -1
  40. package/cli/commands/inspect/tree.ts +1 -1
  41. package/cli/commands/inspect/url.ts +1 -1
  42. package/cli/commands/inspect/wait-event.ts +5 -5
  43. package/cli/commands/inspect.ts +34 -34
  44. package/cli/commands/install-desktop.ts +3 -3
  45. package/cli/commands/login.ts +6 -6
  46. package/cli/commands/maestro-generate.ts +5 -5
  47. package/cli/commands/maestro.ts +5 -5
  48. package/cli/commands/profile.ts +1 -1
  49. package/cli/commands/record.ts +9 -9
  50. package/cli/commands/runtime.ts +18 -18
  51. package/cli/commands/screenshot-command.ts +1 -1
  52. package/cli/commands/screenshot-layers.ts +5 -5
  53. package/cli/commands/screenshot-mode.ts +1 -1
  54. package/cli/commands/screenshot.ts +8 -8
  55. package/cli/commands/screenshots-capture.ts +5 -5
  56. package/cli/commands/serve.ts +3 -3
  57. package/cli/commands/setup.ts +20 -12
  58. package/cli/commands/skills.ts +5 -5
  59. package/cli/commands/slides.ts +1 -1
  60. package/cli/commands/telemetry.ts +1 -1
  61. package/cli/commands/three-mode.ts +1 -1
  62. package/cli/commands/timeline.ts +8 -8
  63. package/cli/commands/upgrade.ts +116 -131
  64. package/cli/commands/upload.ts +12 -12
  65. package/cli/commands/version.ts +7 -7
  66. package/cli/commands/what-happened.ts +9 -9
  67. package/cli/current-sim.ts +3 -3
  68. package/cli/desktop-companion.ts +1 -1
  69. package/cli/drivers/playwright.ts +9 -9
  70. package/cli/drivers/registry.ts +1 -1
  71. package/cli/drivers/types.ts +1 -1
  72. package/cli/flow-file.ts +2 -2
  73. package/cli/flow-session.ts +1 -1
  74. package/cli/help-core.ts +136 -0
  75. package/cli/help.ts +17 -53
  76. package/cli/hints.ts +5 -5
  77. package/cli/inspect-notice-state.ts +1 -1
  78. package/cli/maestro-js.ts +1 -1
  79. package/cli/outbound-endpoints.ts +23 -5
  80. package/cli/parse-args.ts +19 -66
  81. package/cli/recording-access.ts +1 -1
  82. package/cli/registry.ts +1 -0
  83. package/cli/run-registry.ts +1 -1
  84. package/cli/run-rnx-core.ts +148 -0
  85. package/cli/run-rnx.ts +6 -9
  86. package/cli/runtime-notes.ts +3 -3
  87. package/cli/standalone.ts +4 -0
  88. package/cli/ws-bridge.ts +8 -8
  89. package/detox/config-loader.ts +2 -2
  90. package/detox/index.ts +8 -8
  91. package/detox/jest-preset.cjs +1 -1
  92. package/detox/navigation.ts +2 -2
  93. package/dist-lib/agent-daemon-client.cjs +5 -5
  94. package/dist-lib/agent-events.cjs +1 -1
  95. package/dist-lib/agent-identity.cjs +2 -2
  96. package/dist-lib/agent-sessions.cjs +10 -10
  97. package/dist-lib/attached-projects.cjs +6 -6
  98. package/dist-lib/auth/shared-session.cjs +6 -6
  99. package/dist-lib/backend-origin.cjs +1 -1
  100. package/dist-lib/beta.cjs +1 -1
  101. package/dist-lib/beta.mjs +1 -1
  102. package/dist-lib/bridge-constants.cjs +1 -1
  103. package/dist-lib/bridge-contract-input.cjs +1 -1
  104. package/dist-lib/bridge-contract-input.mjs +1 -1
  105. package/dist-lib/bridge-contract.cjs +1 -1
  106. package/dist-lib/bridge-contract.mjs +1 -1
  107. package/dist-lib/cli-constants.cjs +1 -1
  108. package/dist-lib/config.cjs +25 -25
  109. package/dist-lib/detox/index.cjs +73 -31
  110. package/dist-lib/detox/jest-preset.cjs +1 -1
  111. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  112. package/dist-lib/home-paths.cjs +29 -29
  113. package/dist-lib/host/bridge-host.cjs +128 -49
  114. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  115. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  116. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  117. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  118. package/dist-lib/host/websocket-proxy.cjs +1 -1
  119. package/dist-lib/index.cjs +14 -14
  120. package/dist-lib/jump-to-source-babel.cjs +1 -1
  121. package/dist-lib/menu.cjs +1 -1
  122. package/dist-lib/menu.mjs +1 -1
  123. package/dist-lib/metro-production-bundle.cjs +1 -1
  124. package/dist-lib/metro-production-bundle.mjs +1 -1
  125. package/dist-lib/metro.cjs +8 -8
  126. package/dist-lib/profiles.cjs +12 -12
  127. package/dist-lib/public-brand.cjs +1 -1
  128. package/dist-lib/react-native-host-modules.cjs +1 -1
  129. package/dist-lib/react-native-host-modules.mjs +1 -1
  130. package/dist-lib/render-mode.cjs +1 -1
  131. package/dist-lib/scripts/dev-server-scanner.cjs +8 -8
  132. package/dist-lib/sdk.cjs +1 -1
  133. package/dist-lib/sdk.mjs +1 -1
  134. package/dist-lib/skills.cjs +329 -160
  135. package/dist-lib/vite.cjs +9 -9
  136. package/package.json +4 -11
  137. package/scripts/dev-server-scanner.ts +2 -2
  138. package/scripts/optional-demo-registry.ts +1 -1
  139. package/skills/contrast/SKILL.md +3 -3
  140. package/skills/rnx-debug/SKILL.md +1 -1
  141. package/skills/rnx-test/SKILL.md +2 -2
  142. package/src/agent-identity.ts +1 -1
  143. package/src/agent-sessions.ts +7 -5
  144. package/src/cli-version.ts +12 -4
  145. package/src/config.ts +26 -28
  146. package/src/disk-cleanup.ts +11 -11
  147. package/src/home-paths.ts +28 -28
  148. package/src/host/bridge-host.ts +16 -16
  149. package/src/metro-plugin.ts +2 -2
  150. package/src/profiles.ts +2 -2
  151. package/src/runtime-assets.ts +7 -7
  152. package/src/runtime-delivery.ts +13 -13
  153. package/src/screenshots/orchestrate.ts +1 -1
  154. package/src/screenshots/schema.ts +2 -2
  155. package/src/skills/builtin/a11y-review.ts +2 -2
  156. package/src/skills/builtin/compat-check.ts +2 -2
  157. package/src/skills/builtin/maestro-test.ts +2 -2
  158. package/src/skills/builtin/perf-profile.ts +2 -2
  159. package/src/skills/builtin/screenshot-all.ts +2 -2
  160. package/src/skills/builtin/visual-diff.ts +2 -2
  161. package/src/skills/registry.ts +8 -8
  162. package/src/skills/types.ts +1 -1
  163. package/src/vite-plugin-one.ts +3 -3
  164. package/src/vite-plugin.ts +15 -2
  165. package/dist-cli/bin.js +0 -15
  166. package/dist-cli/chunks/agent-H42FCKFF.js +0 -48
  167. package/dist-cli/chunks/agent-wrapper-BBZKTZS6.js +0 -17
  168. package/dist-cli/chunks/app-fonts-43VXIKF4.js +0 -4
  169. package/dist-cli/chunks/assert-IXOLVO5Z.js +0 -49
  170. package/dist-cli/chunks/auth-KFMFB6FU.js +0 -12
  171. package/dist-cli/chunks/beta-5AO3SJB7.js +0 -4
  172. package/dist-cli/chunks/box-ZHM66L6K.js +0 -1730
  173. package/dist-cli/chunks/camera-FNJVFCDQ.js +0 -33
  174. package/dist-cli/chunks/chunk-37MCSPTE.js +0 -71
  175. package/dist-cli/chunks/chunk-3PEMSUAQ.js +0 -30
  176. package/dist-cli/chunks/chunk-4TQ5HOK3.js +0 -7
  177. package/dist-cli/chunks/chunk-5YZYDEMI.js +0 -4
  178. package/dist-cli/chunks/chunk-6CV3R3XD.js +0 -15
  179. package/dist-cli/chunks/chunk-7LGK5XU6.js +0 -4
  180. package/dist-cli/chunks/chunk-7R2TK2NY.js +0 -4
  181. package/dist-cli/chunks/chunk-7VZZQQEE.js +0 -497
  182. package/dist-cli/chunks/chunk-AFOVILIL.js +0 -130
  183. package/dist-cli/chunks/chunk-BEU7CD7E.js +0 -9
  184. package/dist-cli/chunks/chunk-CE4JQJ6Y.js +0 -6
  185. package/dist-cli/chunks/chunk-CIE6CZXL.js +0 -142
  186. package/dist-cli/chunks/chunk-CSJ7L7ZL.js +0 -312
  187. package/dist-cli/chunks/chunk-CWCQP53A.js +0 -27
  188. package/dist-cli/chunks/chunk-DCS5FK5N.js +0 -7
  189. package/dist-cli/chunks/chunk-DEV3E3MV.js +0 -4
  190. package/dist-cli/chunks/chunk-DGJMIVZM.js +0 -5
  191. package/dist-cli/chunks/chunk-DGX3MN65.js +0 -5
  192. package/dist-cli/chunks/chunk-DNPQMTW5.js +0 -4
  193. package/dist-cli/chunks/chunk-DOVBJBVD.js +0 -5
  194. package/dist-cli/chunks/chunk-DPBJ3S3J.js +0 -3
  195. package/dist-cli/chunks/chunk-FVZBGPCU.js +0 -4
  196. package/dist-cli/chunks/chunk-GDKMOIUT.js +0 -4
  197. package/dist-cli/chunks/chunk-GIF2NJCS.js +0 -32
  198. package/dist-cli/chunks/chunk-GZE57ORL.js +0 -4
  199. package/dist-cli/chunks/chunk-H3U56DKI.js +0 -24
  200. package/dist-cli/chunks/chunk-HZLOYAPH.js +0 -4
  201. package/dist-cli/chunks/chunk-J2IKAEU2.js +0 -4
  202. package/dist-cli/chunks/chunk-JXAXYK7W.js +0 -11
  203. package/dist-cli/chunks/chunk-KJE2O2GK.js +0 -4
  204. package/dist-cli/chunks/chunk-KMNVDZZI.js +0 -423
  205. package/dist-cli/chunks/chunk-LC3QRIRB.js +0 -10
  206. package/dist-cli/chunks/chunk-LGFTAQYC.js +0 -4
  207. package/dist-cli/chunks/chunk-LQMUA5IY.js +0 -4
  208. package/dist-cli/chunks/chunk-MFIQTWC5.js +0 -4
  209. package/dist-cli/chunks/chunk-MGALNF2F.js +0 -7
  210. package/dist-cli/chunks/chunk-MLBZZHOY.js +0 -4
  211. package/dist-cli/chunks/chunk-NNRF7GIB.js +0 -107
  212. package/dist-cli/chunks/chunk-NORLYTTO.js +0 -7
  213. package/dist-cli/chunks/chunk-P6KVGV3H.js +0 -14
  214. package/dist-cli/chunks/chunk-PAJTUK33.js +0 -4
  215. package/dist-cli/chunks/chunk-QELIC5XP.js +0 -4
  216. package/dist-cli/chunks/chunk-QRDF33WD.js +0 -11
  217. package/dist-cli/chunks/chunk-R76BA7C7.js +0 -535
  218. package/dist-cli/chunks/chunk-RVEB4CZ2.js +0 -4
  219. package/dist-cli/chunks/chunk-SK4M7NXT.js +0 -5
  220. package/dist-cli/chunks/chunk-SKMG5DD7.js +0 -5
  221. package/dist-cli/chunks/chunk-TEESPOYR.js +0 -4
  222. package/dist-cli/chunks/chunk-TH2UFGVP.js +0 -4
  223. package/dist-cli/chunks/chunk-TLP3T3VO.js +0 -4
  224. package/dist-cli/chunks/chunk-TZUABDIJ.js +0 -38
  225. package/dist-cli/chunks/chunk-UB2W6OQM.js +0 -99
  226. package/dist-cli/chunks/chunk-UYVXALPB.js +0 -506
  227. package/dist-cli/chunks/chunk-VQDYFFIG.js +0 -5
  228. package/dist-cli/chunks/chunk-VWCNJPCJ.js +0 -5
  229. package/dist-cli/chunks/chunk-VZIK4WIS.js +0 -74
  230. package/dist-cli/chunks/chunk-W3FNXAQP.js +0 -4
  231. package/dist-cli/chunks/chunk-XCDNVNP3.js +0 -4
  232. package/dist-cli/chunks/chunk-XSVILA4Z.js +0 -4
  233. package/dist-cli/chunks/chunk-XUTJ7ZWD.js +0 -4
  234. package/dist-cli/chunks/chunk-YTXY3MHW.js +0 -4
  235. package/dist-cli/chunks/chunk-ZF7PVX44.js +0 -28
  236. package/dist-cli/chunks/chunk-ZSSG7OR7.js +0 -4
  237. package/dist-cli/chunks/cleanup-MLOK2OZA.js +0 -25
  238. package/dist-cli/chunks/cli-version-OBNR366V.js +0 -4
  239. package/dist-cli/chunks/compat-SHMFSKU7.js +0 -23
  240. package/dist-cli/chunks/config-TPEAEUJ2.js +0 -13
  241. package/dist-cli/chunks/connect-3LEXWTE5.js +0 -4
  242. package/dist-cli/chunks/control-Z3FWA6BO.js +0 -4
  243. package/dist-cli/chunks/daemon-RSVYSC65.js +0 -4
  244. package/dist-cli/chunks/debug-GUVAK2KR.js +0 -200
  245. package/dist-cli/chunks/desktop-OOP2PTKP.js +0 -31
  246. package/dist-cli/chunks/detox-C2ILVBEC.js +0 -52
  247. package/dist-cli/chunks/device-NXIQQJWR.js +0 -18
  248. package/dist-cli/chunks/diagnose-2JBGYE5L.js +0 -43
  249. package/dist-cli/chunks/disk-cleanup-VURWJYQV.js +0 -4
  250. package/dist-cli/chunks/do-chain-DJ4UQC7A.js +0 -5
  251. package/dist-cli/chunks/drivers-JMA2OIKU.js +0 -4
  252. package/dist-cli/chunks/env-KTNPKEZR.js +0 -4
  253. package/dist-cli/chunks/film-DCPS7EID.js +0 -74
  254. package/dist-cli/chunks/flow-4DZ7B2OA.js +0 -4
  255. package/dist-cli/chunks/help-34CJMQY2.js +0 -4
  256. package/dist-cli/chunks/hidden-runtime-alias-HHT2C7WE.js +0 -4
  257. package/dist-cli/chunks/home-paths-KTPGCPMS.js +0 -4
  258. package/dist-cli/chunks/inspect-JF5WYJRD.js +0 -4
  259. package/dist-cli/chunks/install-desktop-ZIC4CDXI.js +0 -4
  260. package/dist-cli/chunks/login-TTJAOI2Q.js +0 -26
  261. package/dist-cli/chunks/logout-ERAQ6SKW.js +0 -4
  262. package/dist-cli/chunks/maestro-W46QCF77.js +0 -108
  263. package/dist-cli/chunks/maestro-generate-VBLM3MTU.js +0 -36
  264. package/dist-cli/chunks/mode-ZEDZK7R7.js +0 -26
  265. package/dist-cli/chunks/optional-demo-registry-ZUTPSVYQ.js +0 -4
  266. package/dist-cli/chunks/perf-YVT2WXT4.js +0 -48
  267. package/dist-cli/chunks/permissions-L7VVDHFP.js +0 -13
  268. package/dist-cli/chunks/platform-7TJOU2FB.js +0 -6
  269. package/dist-cli/chunks/privacy-57UOTB5J.js +0 -4
  270. package/dist-cli/chunks/record-VXG37P7U.js +0 -72
  271. package/dist-cli/chunks/report-issue-WNNOBZHC.js +0 -29
  272. package/dist-cli/chunks/reset-H5NBFE5U.js +0 -4
  273. package/dist-cli/chunks/resolve-target-57TK5WLE.js +0 -4
  274. package/dist-cli/chunks/runtime-QU2NIF2K.js +0 -4
  275. package/dist-cli/chunks/screenshot-command-AN56TTG7.js +0 -159
  276. package/dist-cli/chunks/screenshot-layers-3W5R7DB2.js +0 -20
  277. package/dist-cli/chunks/screenshots-capture-6AWJY7XZ.js +0 -42
  278. package/dist-cli/chunks/serve-GLYO5Q7J.js +0 -56
  279. package/dist-cli/chunks/setup-UA2HLD7S.js +0 -4
  280. package/dist-cli/chunks/sim-client-5C2RDQQO.js +0 -4
  281. package/dist-cli/chunks/skills-EYXWBRNQ.js +0 -50
  282. package/dist-cli/chunks/state-REJ7W6K3.js +0 -14
  283. package/dist-cli/chunks/storage-CFMDHI3V.js +0 -37
  284. package/dist-cli/chunks/store-XMCUA45G.js +0 -4
  285. package/dist-cli/chunks/telemetry-FBL3NAKB.js +0 -4
  286. package/dist-cli/chunks/timeline-HMCHN5FO.js +0 -24
  287. package/dist-cli/chunks/upgrade-2QSPAA3P.js +0 -7
  288. package/dist-cli/chunks/upload-DUQBKZYV.js +0 -4
  289. package/dist-cli/chunks/version-IOA6QFGB.js +0 -6
  290. package/dist-cli/chunks/web-NCGUYVCJ.js +0 -4
  291. package/dist-cli/chunks/welcome-QYGSQCWQ.js +0 -5
  292. package/dist-cli/chunks/what-happened-YTOUK4LO.js +0 -25
  293. package/dist-cli/chunks/ws-bridge-OF4OZARG.js +0 -4
  294. package/scripts/postinstall.cjs +0 -3
  295. package/scripts/preuninstall.cjs +0 -118
@@ -1,107 +0,0 @@
1
- /*! rnx v0.1.376 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import { createRequire as __sootsimCreateRequire } from 'node:module'
3
- var require = __sootsimCreateRequire(import.meta.url)
4
- import{t as j,v as A,y as U,z as v}from"./chunk-CWCQP53A.js";import{c as P}from"./chunk-TH2UFGVP.js";import{createHash as Q}from"node:crypto";import{mkdirSync as W,readFileSync as q,readdirSync as X,unlinkSync as Z,writeFileSync as V}from"node:fs";import{dirname as G,extname as ee,resolve as B}from"node:path";function Y(t){let e=t[0]?.toLowerCase()??"toggle";return e!=="on"&&e!=="off"&&e!=="toggle"&&(console.error(` unknown argument: "${e}" (expected on | off | toggle)`),P(1)),e}async function L(t,e,n){let o=j(t,{port:e.port}),i=Y(o.positional),u=A({...o,commandTimeoutMs:5e3});try{let a=!!(await U(u,"SootSim.bridges.settings.get"))?.[n.modeKey],m=i==="on"?!0:i==="off"?!1:!a;if(a===m)return console.log(` ${n.displayName}: already ${m?"on":"off"}`),{current:a,target:m,changed:!1};if(!await u.send({type:"evaluate",acquireLock:!0,code:`(async () => {
5
- const modeKey = ${JSON.stringify(n.modeKey)}
6
- const target = ${JSON.stringify(m)}
7
- window.dispatchEvent(new CustomEvent('sootsim:shell-command', {
8
- detail: { type: 'fire-action', id: ${JSON.stringify(n.actionId)} },
9
- }))
10
- const deadline = Date.now() + 1200
11
- while (Date.now() < deadline) {
12
- if (Boolean(window.SootSim?.bridges?.settings?.get?.()?.[modeKey]) === target) {
13
- return true
14
- }
15
- await new Promise((resolve) => setTimeout(resolve, 40))
16
- }
17
- return false
18
- })()`}))throw new Error(`${n.displayName} did not change to ${m?"on":"off"}; the live shell may not support this mode`);return console.log(` ${n.displayName}: ${a?"on":"off"} -> ${m?"on":"off"}`),{current:a,target:m,changed:!0}}finally{u.close()}}var J=12e3,te=6e5,ne=new Set(["load","seek","play","pause","render","measure"]);async function ve(t,e){(t.includes("--help")||t.includes("-h"))&&(console.log(`
19
- rnx mode three \u2014 toggle the 3d device stage
20
-
21
- usage:
22
- rnx mode three [on|off|toggle]
23
- rnx mode three configure [options]
24
- rnx mode three load <timeline.json>
25
- rnx mode three seek <time-ms>
26
- rnx mode three play|pause
27
- rnx mode three render <timeline.json> --output <dir> [options]
28
- rnx mode three measure <timeline.json> [options]
29
-
30
- arguments:
31
- on enable 3d mode
32
- off disable 3d mode
33
- toggle flip the current state (default)
34
-
35
- configure options:
36
- --device <id> set the phone body: iphone-17-air | iphone-17-pro |
37
- pixel-10 (a film authors its own via initial.device)
38
- --background <id> set the 3d background
39
- --gradient <stops> custom gradient bg: comma-separated css hex stops,
40
- e.g. "#0a0e1a,#16243f,#05080f" (overrides --background;
41
- evenly spaced, or use "color@offset" for explicit %)
42
- --gradient-angle <deg> custom gradient angle (default 180 = top\u2192bottom)
43
- --colorway <id> set the phone colorway
44
- --script <id> apply a camera preset pose
45
- --progress <0..1> script progress to sample (default: 1)
46
- --animate run the script instead of sampling one frame
47
- --slow run the script slowly when --animate is set
48
- --environment on|off enable or disable environment objects
49
- --env-shape <id> orb | pill | diamond | pane
50
- --env-spread <id> tight | medium | wide
51
- --env-size <id> small | medium | large
52
- --env-color <id> peach | gold | mint | sky | violet
53
- --env-glow on|off enable or disable environment glow
54
- --env-plastic on|off enable or disable environment plastic material
55
- --setting <id> none | room | white-backdrop
56
- --focus on|off enable or disable Focus depth of field
57
- --focus-amount <id> subtle | medium | strong | intense | extreme
58
- --focus-range <id> tight | balanced | wide
59
- --reset-pose return to the default hero pose before other changes
60
-
61
- render options:
62
- --output <dir> write frame-%05d.png + timeline-render.json
63
- --fps <number> frames per second (default: 30)
64
- --width <px> exact output width (default: 1920)
65
- --height <px> exact output height (default: 1080)
66
- --from <ms> first timeline time (default: 0)
67
- --to <ms> exclusive end time (default: timeline duration)
68
- --overwrite replace this command's existing frames in the dir
69
-
70
- measure options (projected bounds only \u2014 no pixels rendered):
71
- --fps <number> sample rate (default: 30)
72
- --width <px> output width the bounds project into (default: 1920)
73
- --height <px> output height the bounds project into (default: 1080)
74
- --from <ms> first timeline time (default: 0)
75
- --to <ms> exclusive end time (default: timeline duration)
76
- --count <n> sample n frames from --from at the --fps spacing
77
- --at <ms[,ms...]> sample exact timeline times (overrides from/to/count)
78
- --output <file.json> write the measurement JSON here instead of stdout
79
-
80
- examples:
81
- rnx mode three
82
- rnx mode three on
83
- rnx mode three configure --script hero-arc --background gradient-tide
84
- rnx mode three configure --environment on --env-shape pane --setting room
85
- rnx mode three render ./cinematic.json --output ./frames --fps 30
86
- rnx mode three measure ./cinematic.json --width 450 --height 900 --at 0,1200
87
- rnx mode three off
88
- `),P(0));let n=se(t);if(n){await ue(n,t,e);return}if(oe(t)){await re(t,e);return}(await L(t,e,{modeKey:"threeMode",displayName:"three-mode",actionId:"toggle-three-mode"})).target&&await ie(t,e)}function oe(t){return t[0]==="configure"||t.some(e=>["--device","--background","--gradient","--gradient-angle","--colorway","--script","--progress","--animate","--slow","--environment","--env-shape","--env-spread","--env-size","--env-color","--env-glow","--env-plastic","--setting","--focus","--focus-amount","--focus-range","--reset-pose"].includes(e))}async function re(t,e){let n=j(t,{port:e.port,stripBooleanFlags:["--animate","--slow","--reset-pose"],stripValueFlags:["--device","--background","--gradient","--gradient-angle","--colorway","--script","--progress","--environment","--env-shape","--env-spread","--env-size","--env-color","--env-glow","--env-plastic","--setting","--focus","--focus-amount","--focus-range"]}),o=me(t),i=A({...n,commandTimeoutMs:J+1e3});try{await K(i);let u=await v(i,"SootSim.bridges.threeMode.configure",o);console.log(` three-mode: configured (${ce(u)})`)}finally{i.close()}}async function ie(t,e){let n=j(t,{port:e.port}),o=A({...n,commandTimeoutMs:J+1e3});try{await K(o)}finally{o.close()}}async function K(t){let e=await t.send({type:"evaluate",code:`(async () => {
89
- const deadline = Date.now() + ${J}
90
- while (Date.now() < deadline) {
91
- const settings = window.SootSim?.bridges?.settings?.get?.()
92
- if (settings && settings.threeMode !== true) {
93
- return { ready: false, disabled: true }
94
- }
95
- const bridge = window.SootSim?.bridges?.threeMode
96
- const state = typeof bridge?.getState === 'function' ? bridge.getState() : null
97
- if (state?.ready === true) return state
98
- await new Promise((resolve) => setTimeout(resolve, 50))
99
- }
100
- const bridge = window.SootSim?.bridges?.threeMode
101
- const state = typeof bridge?.getState === 'function' ? bridge.getState() : null
102
- return state || { ready: false }
103
- })()`});if(e?.ready===!0)return e;throw e?.disabled?new Error("3d mode is off; run `rnx mode three on` before configure"):new Error("3d mode runtime did not become ready")}function se(t){for(let e=0;e<t.length;e+=1){let n=t[e];if(n==="--sim"||n==="--port"||n==="-p"){e+=1;continue}if(!n.startsWith("-"))return ne.has(n)?n:null}return null}function _(t,e){let n=t.indexOf(e);return n>=0?t[n+1]:void 0}function y(t,e,n,o=0){let i=_(t,e);if(i===void 0)return n;let u=Number.parseFloat(i);if(!Number.isFinite(u)||u<o)throw new Error(`${e} expects a number greater than or equal to ${o}`);return u}function H(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ae(t,e){let n=ee(t).toLowerCase();return e==="recording"?n===".mp4"||n===".m4v"?"video/mp4":"video/webm":n===".jpg"||n===".jpeg"?"image/jpeg":n===".webp"?"image/webp":"image/png"}function z(t,e){if(Array.isArray(t))return t.map(o=>z(o,e));if(!H(t))return t;let n={};for(let[o,i]of Object.entries(t))n[o]=z(i,e);if((n.type==="recording"||n.type==="screenshot"||n.kind==="screen")&&typeof n.src=="string"&&!/^(?:blob:|data:|https?:)/i.test(n.src)){let o=B(e,n.src),i=q(o);n.src=`data:${ae(o,n.type==="recording"?"recording":"screenshot")};base64,${i.toString("base64")}`}return n}function de(t){let e=B(t),n=JSON.parse(q(e,"utf8"));return{absolutePath:e,timeline:z(n,G(e))}}async function le(t){await v(t,"SootSim.bridges.settings.set","threeMode",!0),await K(t)}async function ue(t,e,n){let o=j(e,{port:n.port,commandTimeoutMs:te,stripBooleanFlags:["--overwrite"],stripValueFlags:["--output","--fps","--width","--height","--from","--to","--count","--at"]}),i=A(o);try{if(await le(i),t==="seek"){let r=o.positional[1],l=r===void 0?Number.NaN:Number.parseFloat(r);if(!Number.isFinite(l))throw new Error("three-mode seek expects time in ms");let f=await v(i,"SootSim.bridges.threeMode.seek",l);console.log(` three-mode: ${Math.round(f.timeMs)}ms / ${Math.round(f.durationMs)}ms (${f.shotId??"no shot"})`);return}if(t==="play"||t==="pause"){let r=await v(i,`SootSim.bridges.threeMode.${t}`),l=H(r.timeline)?r.timeline:{};console.log(` three-mode: ${t} (${Math.round(Number(l.timeMs??0))}ms)`);return}let u=o.positional[1];if(!u)throw new Error(`three-mode ${t} expects a timeline JSON path`);let T=de(u),a=await v(i,"SootSim.bridges.threeMode.loadTimeline",T.timeline);if(t==="load"){console.log(` three-mode: loaded ${T.absolutePath} (${Math.round(a.durationMs)}ms)`);return}if(t==="measure"){let r=y(e,"--fps",30,.001),l=Math.round(y(e,"--width",1920,1)),f=Math.round(y(e,"--height",1080,1)),h=_(e,"--at"),$;if(h!==void 0){let c=h.split(",").map(w=>{let S=Number.parseFloat(w);if(!Number.isFinite(S)||S<0)throw new Error(`--at expects comma-separated times in ms, got "${w}"`);return Math.min(S,a.durationMs)}),M=[];for(let w of c){let S=await v(i,"SootSim.bridges.threeMode.measure",{fps:r,width:l,height:f,from:w,count:1});M.push({...S.frames[0],index:M.length})}$={fps:r,from:c[0],to:c[c.length-1],width:l,height:f,frames:M}}else{let c=y(e,"--from",0,0),M=_(e,"--count"),w={fps:r,width:l,height:f,from:c};if(M===void 0){let S=y(e,"--to",a.durationMs,0);if(S<=c||S>a.durationMs)throw new Error(`--to must be greater than --from and at most ${a.durationMs}`);w.to=S}else w.count=Math.round(y(e,"--count",1,1));$=await v(i,"SootSim.bridges.threeMode.measure",w)}let b=`${JSON.stringify($,null,2)}
104
- `,I=_(e,"--output");if(I){let c=B(I);W(G(c),{recursive:!0}),V(c,b),process.stderr.write(` three-mode: measured ${$.frames.length} frames \u2192 ${c}
105
- `)}else process.stdout.write(b);return}let m=_(e,"--output");if(!m)throw new Error("three-mode render requires --output <dir>");let g=B(m),E=y(e,"--fps",30,.001),R=Math.round(y(e,"--width",1920,1)),k=Math.round(y(e,"--height",1080,1)),F=y(e,"--from",0,0),x=y(e,"--to",a.durationMs,0);if(x<=F||x>a.durationMs)throw new Error(`--to must be greater than --from and at most ${a.durationMs}`);let N=1e3/E,s=Math.ceil((x-F)/N);W(g,{recursive:!0});let p=X(g).filter(r=>/^frame-\d{5}\.png$/.test(r)||r==="timeline-render.json");if(p.length>0&&!e.includes("--overwrite"))throw new Error(`${g} already has timeline frames; pass --overwrite to replace them`);for(let r of p)Z(B(g,r));let d=[],O=4;for(let r=0;r<s;r+=O){let l=Math.min(O,s-r),f=F+r*N,h=Math.min(x,f+l*N),$=await v(i,"SootSim.bridges.threeMode.renderFrames",{fps:E,from:f,to:h,width:R,height:k,count:l});if($.frames.length!==l)throw new Error(`3d renderer returned ${$.frames.length} frames for a ${l}-frame batch`);for(let b of $.frames){let I=r+b.index,c=`frame-${String(I).padStart(5,"0")}.png`,M=b.dataUrl.indexOf(",");if(M<0||!b.dataUrl.slice(0,M).includes("image/png;base64"))throw new Error(`3d renderer returned a non-PNG frame at ${b.timeMs}ms`);let w=Buffer.from(b.dataUrl.slice(M+1),"base64");V(B(g,c),w),d.push({file:c,timeMs:b.timeMs,sha256:Q("sha256").update(w).digest("hex"),alpha:b.alpha,phoneCollision:b.phoneCollision})}process.stderr.write(`\r three-mode: rendered ${Math.min(r+l,s)}/${s}`)}process.stderr.write(`
106
- `);let C={version:2,timeline:T.absolutePath,fps:E,from:F,to:x,width:R,height:k,frameCount:s,transparent:d.every(r=>r.alpha.transparentPixels>0),frames:d};V(B(g,"timeline-render.json"),`${JSON.stringify(C,null,2)}
107
- `),console.log(` three-mode: wrote ${s} deterministic RGBA frames to ${g}`)}finally{i.close()}}function me(t){let e=s=>t.find((p,d)=>t[d-1]===s),n={},o=e("--device");if(o){if(o!=="iphone-17-air"&&o!=="iphone-17-pro"&&o!=="pixel-10")throw new Error(`--device expects iphone-17-air, iphone-17-pro, or pixel-10, got "${o}"`);n.device=o}let i=e("--colorway");i&&(n.colorway=i);let u=e("--background");u&&(n.background=u);let T=e("--gradient");if(T){let s=T.split(",").map(C=>C.trim()).filter(Boolean),p=s.map((C,r)=>{let[l,f]=C.split("@"),h=f!==void 0?Number.parseFloat(f):s.length>1?r/(s.length-1):0;return h>1&&(h=h/100),Number.isFinite(h)||(h=s.length>1?r/(s.length-1):0),{color:l.trim(),offset:h}}),d=e("--gradient-angle"),O=d===void 0?void 0:Number.parseFloat(d);if(d!==void 0&&!Number.isFinite(O))throw new Error(`--gradient-angle expects a number, got "${d}"`);n.customGradient={stops:p,...O!==void 0?{angleDeg:O}:{}}}let a=e("--setting");if(a){if(a!=="none"&&a!=="room"&&a!=="white-backdrop")throw new Error(`--setting expects none, room, or white-backdrop, got "${a}"`);n.setting=a}let m={},g=D(e("--focus"),"--focus");g!==void 0&&(m.enabled=g);for(let[s,p]of[["--focus-amount","amount"],["--focus-range","range"]]){let d=e(s);d&&(m[p]=d)}Object.keys(m).length>0&&(n.focus=m),t.includes("--reset-pose")&&(n.resetPose=!0);let E=D(e("--environment"),"--environment"),R={},k={};for(let[s,p]of[["--env-shape","shape"],["--env-spread","spread"],["--env-size","size"],["--env-color","color"]]){let d=e(s);d&&(R[p]=d)}let F=D(e("--env-glow"),"--env-glow");F!==void 0&&(k.glow=F);let x=D(e("--env-plastic"),"--env-plastic");x!==void 0&&(k.plastic=x),(E!==void 0||Object.keys(R).length>0||Object.keys(k).length>0)&&(n.environment=E===!1?!1:{pins:R,effects:k});let N=e("--script");if(N){let s=e("--progress"),p=s===void 0?1:Number.parseFloat(s);if(!Number.isFinite(p))throw new Error(`--progress expects a number from 0 to 1, got "${s}"`);n.script={id:N,progress:p,animate:t.includes("--animate"),slow:t.includes("--slow")}}return n}function D(t,e){if(t===void 0)return;let n=t.toLowerCase();if(["on","true","yes","1"].includes(n))return!0;if(["off","false","no","0"].includes(n))return!1;throw new Error(`${e} expects on or off, got "${t}"`)}function ce(t){return[`ready=${!!t.ready}`,`background=${String(t.background??"unknown")}`,`colorway=${String(t.colorway??"unknown")}`,`environment=${t.environmentActive?"on":"off"}`,`setting=${String(t.setting??"none")}`,`focus=${t.focus&&typeof t.focus=="object"&&t.focus.enabled?"on":"off"}`].join(", ")}export{L as a,ve as b,K as c,me as d};
@@ -1,7 +0,0 @@
1
- /*! rnx v0.1.376 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import { createRequire as __sootsimCreateRequire } from 'node:module'
3
- var require = __sootsimCreateRequire(import.meta.url)
4
- import{a as N}from"./chunk-XCDNVNP3.js";import{o as R}from"./chunk-QRDF33WD.js";import{a as I}from"./chunk-5YZYDEMI.js";import{a as T}from"./chunk-ZSSG7OR7.js";function G(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function O(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return G(r)?r:null}catch{return null}}import{randomBytes as q,createHash as X}from"node:crypto";import f from"node:fs";import h from"node:path";var $=null;function B(){if($)return $;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||R()}function y(){return B()}function U(){return h.join(B(),"attached-projects.json")}function _(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=f.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return _();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{f.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return _()}}function K(e){let t=U();f.mkdirSync(h.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=f.openSync(r,"w",384);try{f.writeFileSync(n,JSON.stringify(e,null,2)),f.fsyncSync(n)}finally{f.closeSync(n)}f.renameSync(r,t)}function w(e){let t=S();return e(t),K(t),t}function F(e){return X("sha256").update(h.resolve(e)).digest("hex").slice(0,16)}function Q(){return`s_${q(10).toString("hex")}`}function Se(e){let t=h.resolve(e.cwd),r=F(t),n;return w(o=>{let s=o.attachedProjects.find(a=>a.id===r);if(s){let a={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=a,n=a;return}let c=Date.now(),d={id:r,name:e.name??h.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:c,updatedAt:c};o.attachedProjects.push(d),n=d}),n}function M(e){return S().attachedProjects.find(t=>t.id===e)??null}function we(){return S().attachedProjects}var V=336*60*60*1e3;function ve(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],c=o-V,d=s.filter(a=>a.ts>=c);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Ae(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function xe(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function C(e){let t;return w(r=>{if(e.id){let c=r.agentSessions.find(d=>d.id===e.id);if(c){let d={...c,...e,lastSeenAt:Date.now()},a=r.agentSessions.indexOf(c);r.agentSessions[a]=d,t=d;return}}let n=r.attachedProjects.find(c=>c.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??Q(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function L(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function z(e,t,r=Date.now()){return{...e,...t,id:e.id,projectId:e.projectId,createdAt:e.createdAt,lastSeenAt:r}}function Z(e){e.length!==0&&w(t=>{let r=Date.now(),n=new Map(t.agentSessions.map((o,s)=>[o.id,s]));for(let{id:o,patch:s}of e){let c=n.get(o);c!==void 0&&(t.agentSessions[c]=z(t.agentSessions[c],s,r))}})}function v(e,t){Z([{id:e,patch:t}])}async function Pe(){if(S().attachedProjects.length>0)return;let{loadOptionalDemoApps:t}=await import("./optional-demo-registry-ZUTPSVYQ.js"),r=await t();r.length!==0&&w(n=>{for(let o of r){if(!f.existsSync(o.dir))continue;let s=h.resolve(o.dir),c=F(s);if(n.attachedProjects.some(a=>a.id===c))continue;let d=Date.now();n.attachedProjects.push({id:c,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as ee,spawnSync as te}from"node:child_process";import{randomUUID as re}from"node:crypto";import i,{constants as m}from"node:fs";import u from"node:path";import ne from"node:readline";function b(e){return u.join(y(),"sessions",e)}function J(e){return u.join(b(e),"prompt.in")}function H(e){return u.join(b(e),"events.out")}function se(e){return u.join(y(),"transcripts",`${e}.log`)}function E(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(b(t)))}function oe(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ie();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("rnx CLI not found. set SOOTSIM_BIN to the path of the rnx binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ie(){try{let e=ce();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[rnx] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli`.")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function ce(){try{let r=T.resolve(`${I.packageName}/package.json`);return u.dirname(r)}catch{}let e=ae();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name===I.packageName)return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function ae(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function de(e,t,r){let n=u.join(y(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,c=null;for(;c===null;)try{c=i.openSync(o,m.O_WRONLY|m.O_CREAT|m.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let a=Number(i.readFileSync(o,"utf8").trim());if(a&&!ue(a)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(a=>setTimeout(a,50))}try{return i.writeFileSync(c,String(process.pid)),await r()}finally{try{i.closeSync(c)}catch{}try{i.unlinkSync(o)}catch{}}}function ue(e){try{return process.kill(e,0),!0}catch{return!1}}function W(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=te("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function $e(e){let t=M(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return de(t.id,r,async()=>{let n=L(t.id).find(p=>p.provider===r&&p.status!=="ended"&&E(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`rnx agent end <sessionId>\`.`);let o=r==="claude"?re():void 0,s=C({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),c=J(s.id),d=H(s.id),a=se(s.id);W(c),W(d);let g=u.dirname(a);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:Y}=oe(),x=[...Y,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",c,"--events-out",d,"--transcript",a];e.codexBin&&x.push("--codex-bin",e.codexBin),e.claudeBin&&x.push("--claude-bin",e.claudeBin),e.freshThread&&x.push("--fresh-thread"),o&&x.push("--claude-session-uuid",o);let P=ee(A,x,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:y()}});P.unref();let D=e.readyTimeoutMs??6e3,j=await le(d,p=>p.type==="ready"||p.type==="error",D);if(!j||j.type==="error"){if(P.pid)try{process.kill(P.pid,"SIGTERM")}catch{}try{i.rmSync(b(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=j&&j.type==="error"?j.message:`no ready event within ${D}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:P.pid,status:"idle"}),{session:k(s.id),wrapperPid:P.pid}})}async function _e(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!E(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=J(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,m.O_WRONLY);try{let s=N(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
5
- `)}finally{i.closeSync(o)}v(e,{lastPrompt:t.displayText??t.text,status:"working"})}async function Be(e){let t=k(e);if(!t)throw new l("NO_SESSION",`no session with id=${e}`);if(E(t.wrapperPid,e))try{process.kill(t.wrapperPid,"SIGTERM")}catch{}let r=b(e),n=y();if(r.startsWith(n))try{i.rmSync(r,{recursive:!0,force:!0})}catch{}v(e,{status:"ended",wrapperPid:void 0})}function Ue(e,t){let r=H(e);if(!i.existsSync(r))throw new l("NO_FIFO",`events FIFO missing: ${r}`);let n=i.openSync(r,m.O_RDWR),o=i.createReadStream("",{fd:n,autoClose:!0}),s=ne.createInterface({input:o,crlfDelay:1/0});s.on("line",d=>{let a=O(d);a&&t(a)});let c=!1;return()=>{if(!c){c=!0;try{i.writeSync(n,`
6
- `)}catch{}try{s.close()}catch{}try{o.destroy()}catch{}}}}async function le(e,t,r){let n=i.openSync(e,m.O_RDWR|m.O_NONBLOCK),o=Buffer.alloc(8192),s="",c=Date.now()+r;try{for(;Date.now()<c;){let d=0;try{d=i.readSync(n,o,0,o.length,null)}catch(a){if(a.code!=="EAGAIN")throw a;d=0}if(d>0){s+=o.subarray(0,d).toString("utf8");let a;for(;(a=s.indexOf(`
7
- `))>=0;){let g=s.slice(0,a);s=s.slice(a+1);let A=O(g);if(A&&t(A))return A}}else await new Promise(a=>setTimeout(a,30))}return null}finally{i.closeSync(n)}}export{O as a,y as b,Se as c,M as d,we as e,ve as f,Ae as g,xe as h,k as i,L as j,z as k,Z as l,Pe as m,b as n,J as o,H as p,se as q,E as r,oe as s,l as t,$e as u,_e as v,Be as w,Ue as x};