sootsim 0.1.175 → 0.1.177

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 (153) hide show
  1. package/dist-cli/bin.js +3 -3
  2. package/dist-cli/chunks/{agent-A4WFJEFV.js → agent-3BCITLIZ.js} +3 -3
  3. package/dist-cli/chunks/{agent-wrapper-EOZBE6UT.js → agent-wrapper-26RIZVGD.js} +2 -2
  4. package/dist-cli/chunks/{app-fonts-H2I7IV7N.js → app-fonts-JVDHATQE.js} +2 -2
  5. package/dist-cli/chunks/{assert-36QXQUCE.js → assert-IT2OXM4Y.js} +2 -2
  6. package/dist-cli/chunks/beta-SPH73CAA.js +2 -0
  7. package/dist-cli/chunks/{camera-7HK2Y3PY.js → camera-ZYVEUCIO.js} +2 -2
  8. package/dist-cli/chunks/{chunk-2QTAUBZX.js → chunk-3L6I2M2Z.js} +3 -3
  9. package/dist-cli/chunks/chunk-4INGTBO7.js +4 -0
  10. package/dist-cli/chunks/{chunk-EEIUS5AS.js → chunk-4JESO36F.js} +4 -4
  11. package/dist-cli/chunks/{chunk-HWUFW3IP.js → chunk-4YNKFN2A.js} +2 -2
  12. package/dist-cli/chunks/{chunk-V7AGBG2P.js → chunk-52O56BTW.js} +2 -2
  13. package/dist-cli/chunks/{chunk-ZZWAHZ37.js → chunk-64QAFSY7.js} +1 -1
  14. package/dist-cli/chunks/{chunk-OMJ2DTQJ.js → chunk-65ZBQDQM.js} +2 -2
  15. package/dist-cli/chunks/{chunk-DV6SWCY7.js → chunk-A2WASN2L.js} +1 -1
  16. package/dist-cli/chunks/{chunk-H2J4Z7LY.js → chunk-A3VHHWLU.js} +2 -2
  17. package/dist-cli/chunks/{chunk-UMJDCX2P.js → chunk-AN4DM7IB.js} +2 -2
  18. package/dist-cli/chunks/{chunk-5QLWXLML.js → chunk-ATVKVVHZ.js} +2 -2
  19. package/dist-cli/chunks/chunk-B6GISAUX.js +1 -0
  20. package/dist-cli/chunks/{chunk-P2WO5LMI.js → chunk-BTTZN2SN.js} +2 -2
  21. package/dist-cli/chunks/{chunk-LYZXARZO.js → chunk-C5QOGCVN.js} +2 -2
  22. package/dist-cli/chunks/{chunk-RCPMRHTK.js → chunk-CH3MWM5W.js} +1 -1
  23. package/dist-cli/chunks/{chunk-7F2LH7U5.js → chunk-CHTYIQLE.js} +2 -2
  24. package/dist-cli/chunks/{chunk-SV3SRWN5.js → chunk-CUO7F2JE.js} +1 -1
  25. package/dist-cli/chunks/{chunk-YMBQBKKA.js → chunk-D2BBJUEY.js} +1 -1
  26. package/dist-cli/chunks/chunk-DGDBEXXQ.js +1 -0
  27. package/dist-cli/chunks/{chunk-3SUIAUIY.js → chunk-IBSEFPPL.js} +1 -1
  28. package/dist-cli/chunks/{chunk-ZPQY5DBY.js → chunk-JFLNZGDS.js} +2 -2
  29. package/dist-cli/chunks/{chunk-4UATZVHM.js → chunk-JHYLPDCC.js} +2 -2
  30. package/dist-cli/chunks/{chunk-XDDO46ZW.js → chunk-JS3NH2SJ.js} +1 -1
  31. package/dist-cli/chunks/{chunk-UXZRHPX6.js → chunk-JS7SSYDG.js} +2 -2
  32. package/dist-cli/chunks/{chunk-HWJ52K4J.js → chunk-JXO6UPGI.js} +1 -1
  33. package/dist-cli/chunks/{chunk-MLLINRL2.js → chunk-LTZPVG65.js} +1 -1
  34. package/dist-cli/chunks/{chunk-GJQGKFLY.js → chunk-NOLQYF76.js} +1 -1
  35. package/dist-cli/chunks/{chunk-2J67UJXT.js → chunk-NYGESF6F.js} +1 -1
  36. package/dist-cli/chunks/{chunk-QK76RK6J.js → chunk-NZWTC6K6.js} +1 -1
  37. package/dist-cli/chunks/{chunk-NPZPBSZD.js → chunk-PAU64XFG.js} +1 -1
  38. package/dist-cli/chunks/{chunk-IKJSGKUB.js → chunk-PL3ALTWB.js} +2 -2
  39. package/dist-cli/chunks/{chunk-ZG2A6LCL.js → chunk-QWZFOMCI.js} +2 -2
  40. package/dist-cli/chunks/{chunk-Y3OHYOFS.js → chunk-SNLUVL3H.js} +2 -2
  41. package/dist-cli/chunks/{chunk-KSF72FPP.js → chunk-SU3JJ7ER.js} +2 -2
  42. package/dist-cli/chunks/{chunk-XBK3XAKL.js → chunk-TVFHGWTW.js} +2 -2
  43. package/dist-cli/chunks/{chunk-JCQEG4R6.js → chunk-UBJQDMDG.js} +2 -2
  44. package/dist-cli/chunks/{chunk-VW643HG5.js → chunk-UJN3FMEX.js} +2 -2
  45. package/dist-cli/chunks/chunk-WKG5J4RD.js +2 -0
  46. package/dist-cli/chunks/{chunk-IISA6UXR.js → chunk-WRHJEI7Y.js} +1 -1
  47. package/dist-cli/chunks/{chunk-4UGD4KJM.js → chunk-WUEKKZ7Z.js} +2 -2
  48. package/dist-cli/chunks/{chunk-5D4PHINP.js → chunk-Y2637KG7.js} +1 -1
  49. package/dist-cli/chunks/chunk-YU6CNUJD.js +2 -0
  50. package/dist-cli/chunks/{chunk-46S56FJJ.js → chunk-YVDSGGOT.js} +1 -1
  51. package/dist-cli/chunks/{chunk-WM73SGMM.js → chunk-Z4IMGLHM.js} +2 -2
  52. package/dist-cli/chunks/{chunk-4PQ36DTJ.js → chunk-ZUTVEJVA.js} +3 -3
  53. package/dist-cli/chunks/cli-version-HENS6BZI.js +2 -0
  54. package/dist-cli/chunks/{compat-KWM6HXJD.js → compat-MNTQH57R.js} +3 -3
  55. package/dist-cli/chunks/{control-PVZRPH57.js → control-WQ7XEPCI.js} +2 -2
  56. package/dist-cli/chunks/{cpu-profile-3YLLRNVG.js → cpu-profile-P27HBXOI.js} +2 -2
  57. package/dist-cli/chunks/daemon-WUAZELEI.js +2 -0
  58. package/dist-cli/chunks/{debug-TD4EVFT7.js → debug-ES4A3SZQ.js} +3 -3
  59. package/dist-cli/chunks/{detox-S7M5WN3L.js → detox-Q36B2553.js} +2 -2
  60. package/dist-cli/chunks/{device-WR7GA4RN.js → device-NA7TB4E6.js} +2 -2
  61. package/dist-cli/chunks/{diagnose-JZMNR25X.js → diagnose-DKW5WI3X.js} +2 -2
  62. package/dist-cli/chunks/drivers-RFOOGIRC.js +2 -0
  63. package/dist-cli/chunks/{electron-V2YDDVKJ.js → electron-6C2VDAZW.js} +3 -3
  64. package/dist-cli/chunks/flow-GSHP52QS.js +2 -0
  65. package/dist-cli/chunks/help-J6PF4PZX.js +2 -0
  66. package/dist-cli/chunks/{hints-OK373YOJ.js → hints-W7ZZ6KZE.js} +2 -2
  67. package/dist-cli/chunks/{home-paths-IFY5UTLL.js → home-paths-K4347S7C.js} +2 -2
  68. package/dist-cli/chunks/{inspect-LRIJ7MQT.js → inspect-ZPHNFMEX.js} +4 -4
  69. package/dist-cli/chunks/{install-desktop-ESQL2Q2T.js → install-desktop-ZCCPJMOF.js} +3 -3
  70. package/dist-cli/chunks/{keys-IHG2YEL3.js → keys-XM67H4SM.js} +2 -2
  71. package/dist-cli/chunks/{login-CYIWYJGG.js → login-O4OGJKYL.js} +4 -4
  72. package/dist-cli/chunks/{logout-NALFLZWI.js → logout-DWCBRMLM.js} +2 -2
  73. package/dist-cli/chunks/{maestro-QKSXVPWG.js → maestro-MEWENIGQ.js} +2 -2
  74. package/dist-cli/chunks/optional-demo-registry-O3XS3WXJ.js +2 -0
  75. package/dist-cli/chunks/{preview-XCQGBN2I.js → preview-VPWG4462.js} +2 -2
  76. package/dist-cli/chunks/{profile-RDAPVU7K.js → profile-R4CSGXYJ.js} +2 -2
  77. package/dist-cli/chunks/{react-MM373YNE.js → react-5LFUOYV5.js} +2 -2
  78. package/dist-cli/chunks/{record-SQA376Z7.js → record-MHAAYOWF.js} +2 -2
  79. package/dist-cli/chunks/runtime-R2PRKIZM.js +2 -0
  80. package/dist-cli/chunks/{screenshot-FCKW6JV6.js → screenshot-XAEO7EBF.js} +2 -2
  81. package/dist-cli/chunks/{screenshot-mode-QVRUJXZ3.js → screenshot-mode-QNR5ESKN.js} +2 -2
  82. package/dist-cli/chunks/{screenshots-ITBCSBZS.js → screenshots-Z6OSENKY.js} +2 -2
  83. package/dist-cli/chunks/{screenshots-capture-H4EAYFH3.js → screenshots-capture-3DJPYJUD.js} +2 -2
  84. package/dist-cli/chunks/{serve-3GHYSGJR.js → serve-IVTQFOFI.js} +16 -16
  85. package/dist-cli/chunks/{setup-ME5SRHWD.js → setup-AMRSL4IK.js} +2 -2
  86. package/dist-cli/chunks/{skills-E5JE3SAI.js → skills-K4DG2CIH.js} +2 -2
  87. package/dist-cli/chunks/{slides-D37ML4LI.js → slides-UIH7KXFR.js} +2 -2
  88. package/dist-cli/chunks/store-2JY2VLVA.js +2 -0
  89. package/dist-cli/chunks/telemetry-KNKROOT5.js +2 -0
  90. package/dist-cli/chunks/{test-CWWQJG5K.js → test-XUJ2V5ZX.js} +3 -3
  91. package/dist-cli/chunks/{three-mode-WESGARG5.js → three-mode-P6HSLJMD.js} +2 -2
  92. package/dist-cli/chunks/{timeline-RUVZASG4.js → timeline-YSUY4PHV.js} +2 -2
  93. package/dist-cli/chunks/{upgrade-DKWD6TSY.js → upgrade-YZMDFQIH.js} +2 -2
  94. package/dist-cli/chunks/upload-TIH2LID6.js +2 -0
  95. package/dist-cli/chunks/{version-G45RLONC.js → version-5QAMZ5CK.js} +2 -2
  96. package/dist-cli/chunks/{web-X2HCJQQE.js → web-LM3JSBQF.js} +2 -2
  97. package/dist-cli/chunks/{what-happened-5DBVOXKC.js → what-happened-NYVQ7KER.js} +2 -2
  98. package/dist-cli/chunks/{whoami-ZDT3RQOC.js → whoami-AAHH72FM.js} +2 -2
  99. package/dist-lib/agent-daemon-client.cjs +10 -1
  100. package/dist-lib/agent-events.cjs +1 -1
  101. package/dist-lib/agent-sessions.cjs +1 -1
  102. package/dist-lib/attached-projects.cjs +1 -1
  103. package/dist-lib/auth/shared-session.cjs +1 -1
  104. package/dist-lib/backend-origin.cjs +1 -1
  105. package/dist-lib/beta.cjs +1 -1
  106. package/dist-lib/beta.mjs +1 -1
  107. package/dist-lib/bridge-constants.cjs +7 -1
  108. package/dist-lib/cli-constants.cjs +1 -1
  109. package/dist-lib/config.cjs +1 -1
  110. package/dist-lib/detox/index.cjs +1 -1
  111. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  112. package/dist-lib/home-paths.cjs +1 -1
  113. package/dist-lib/host/bridge-host.cjs +126 -12
  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/websocket-proxy.cjs +1 -1
  118. package/dist-lib/index.cjs +1 -1
  119. package/dist-lib/jump-to-source-babel.cjs +1 -1
  120. package/dist-lib/menu.cjs +1 -1
  121. package/dist-lib/menu.mjs +1 -1
  122. package/dist-lib/metro.cjs +1 -1
  123. package/dist-lib/profiles.cjs +1 -1
  124. package/dist-lib/render-mode.cjs +1 -1
  125. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  126. package/dist-lib/sdk.cjs +1 -1
  127. package/dist-lib/sdk.mjs +1 -1
  128. package/dist-lib/skills.cjs +237 -102
  129. package/dist-lib/vite.cjs +1 -1
  130. package/package.json +7 -1
  131. package/src/agent-daemon-client.ts +13 -0
  132. package/src/agent-identity.ts +21 -0
  133. package/src/agentbus-prompt.ts +80 -0
  134. package/src/bridge-constants.ts +9 -0
  135. package/src/host/agent-host.ts +42 -0
  136. package/src/host/bridge-host.ts +14 -1
  137. package/src/native-seam-manifest.ts +11 -0
  138. package/dist-cli/chunks/beta-7FRVMDBH.js +0 -2
  139. package/dist-cli/chunks/chunk-3G5EE3ST.js +0 -2
  140. package/dist-cli/chunks/chunk-HCKTFQLK.js +0 -2
  141. package/dist-cli/chunks/chunk-ODISDSXU.js +0 -1
  142. package/dist-cli/chunks/chunk-RAESCYIA.js +0 -4
  143. package/dist-cli/chunks/chunk-URQSBUTU.js +0 -1
  144. package/dist-cli/chunks/cli-version-HCYSKPJO.js +0 -2
  145. package/dist-cli/chunks/daemon-2DT4QAJ4.js +0 -2
  146. package/dist-cli/chunks/drivers-UMQTPEMU.js +0 -2
  147. package/dist-cli/chunks/flow-CKXTFJJ7.js +0 -2
  148. package/dist-cli/chunks/help-OEMLUQMD.js +0 -2
  149. package/dist-cli/chunks/optional-demo-registry-CIEW2ET7.js +0 -2
  150. package/dist-cli/chunks/runtime-CUNVH66R.js +0 -2
  151. package/dist-cli/chunks/store-UW5HH6DW.js +0 -2
  152. package/dist-cli/chunks/telemetry-KSBNWXNE.js +0 -2
  153. package/dist-cli/chunks/upload-LYANGCPB.js +0 -2
package/dist-cli/bin.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
3
- import{a as u,b as d,c as g}from"./chunks/chunk-GJQGKFLY.js";import"./chunks/chunk-ZZWAHZ37.js";function f(a){let e=a instanceof Error?a.message:String(a);(/^command timed out after \d+s$/.test(e)||e.startsWith("sim disconnected:")||e.startsWith("bridge never reconnected")||e.startsWith("no sim connected with id ")||e.startsWith("could not connect to ws://")||e.startsWith("sootsim bridge daemon is not running")||e.startsWith("sootsim bridge lockfile is fresh")||e.startsWith("sootsim bridge exited before becoming ready")||e.startsWith("background daemon setup is unavailable")||e.startsWith("sootsim bridge did not start within"))&&!process.env.SOOTSIM_VERBOSE&&(process.stderr.write(` ${e}
2
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
3
+ import{a as u,b as d,c as g}from"./chunks/chunk-NOLQYF76.js";import"./chunks/chunk-64QAFSY7.js";function f(a){let e=a instanceof Error?a.message:String(a);(/^command timed out after \d+s$/.test(e)||e.startsWith("sim disconnected:")||e.startsWith("bridge never reconnected")||e.startsWith("no sim connected with id ")||e.startsWith("could not connect to ws://")||e.startsWith("sootsim bridge daemon is not running")||e.startsWith("sootsim bridge lockfile is fresh")||e.startsWith("sootsim bridge exited before becoming ready")||e.startsWith("background daemon setup is unavailable")||e.startsWith("sootsim bridge did not start within"))&&!process.env.SOOTSIM_VERBOSE&&(process.stderr.write(` ${e}
4
4
  `),process.exit(1)),a instanceof Error&&a.stack?process.stderr.write(`${a.stack}
5
5
  `):process.stderr.write(`${e}
6
6
  `),process.exit(1)}process.on("unhandledRejection",f);process.on("uncaughtException",f);var A=typeof __SOOTSIM_STANDALONE__<"u"&&__SOOTSIM_STANDALONE__,k=new Set(["preview","electron","install-desktop"]);function v(a){!A||!k.has(a)||(process.stderr.write(` sootsim ${a} isn't available in the standalone binary \u2014
7
7
  it needs vite / electron / playwright from a project's node_modules.
8
8
  install the npm package and run via bun or node instead:
9
9
  npm i -g sootsim && sootsim ${a}
10
- `),process.exit(1))}var t=g(process.argv);{let{trackCliEvent:a}=await import("./chunks/telemetry-KSBNWXNE.js");a({event:"cli_command_invoked",properties:{command:t.command||(t.version?"version":t.help?"help":"none"),arg_count:t.commandArgs.length,platform:process.platform,arch:process.arch,node_version:process.versions.node}})}async function c(a){let{flushCliTelemetry:e}=await import("./chunks/telemetry-KSBNWXNE.js");await e(),process.exit(a)}if(t.version){let{getCliVersion:a}=await import("./chunks/cli-version-HCYSKPJO.js"),{IS_BETA:e,BETA_LABEL:i}=await import("./chunks/beta-7FRVMDBH.js"),m=e?` \xB7 ${i}`:"";console.log(`sootsim v${a()}${m}`);let{readActiveRuntime:h}=await import("./chunks/home-paths-IFY5UTLL.js"),w=h();console.log(w?`runtime v${w}`:"runtime not installed"),await c(0)}if(t.help&&!t.command){let{printHelp:a}=await import("./chunks/help-OEMLUQMD.js");a(),await c(0)}var o=t.globalFlags.port,s=t.verbose,p=t.globalFlags.device,l=t.globalFlags.theme,S=t.globalFlags.driver,E=t.globalFlags.headless===!0,b=t.globalFlags.sim??t.globalFlags.session??t.globalFlags.tab,n=b?["--sim",b,...t.commandArgs]:t.commandArgs;if(p||l){let{settingsStore:a}=await import("./chunks/store-UW5HH6DW.js"),e={};p&&(e.deviceModel=p),l&&(e.colorScheme=l),a.apply(e)}if(!t.command&&t.commandArgs.length===0){let{printHelp:a}=await import("./chunks/help-OEMLUQMD.js");a(),await c(0)}var r=t.command??"";if(!r){if(t.commandArgs.length>0){let e=t.commandArgs.find(i=>!i.startsWith("-"))??t.commandArgs[0];console.error(` unknown command: ${e}`),console.error(" run `sootsim --help` to see the full surface."),await c(1)}let{printHelp:a}=await import("./chunks/help-OEMLUQMD.js");a(),await c(0)}if(r in d){let a=d[r],e=t.commandArgs.length>0?` ${t.commandArgs.join(" ")}`:"";console.error(` \`sootsim ${r}\` was removed. use \`${a}\` instead.`),e&&console.error(` \u2192 ${a}${e}`),console.error(" run `sootsim --help` to see the new verb groups."),await c(1)}if(t.help||t.commandArgs.includes("--help")||t.commandArgs.includes("-h")){if(r==="skill"){let{runSkill:i}=await import("./chunks/skills-E5JE3SAI.js");await i(t.commandArgs),await c(0)}let a=r==="do"||r==="get"||r==="debug"||r==="shell"||r==="wait",e=t.commandArgs.find(i=>!i.startsWith("-"));if(r!=="shell")if(a&&!e){let{printGroupHelp:i}=await import("./chunks/help-OEMLUQMD.js");i(r)&&await c(0)}else{let{printCommandHelp:i}=await import("./chunks/help-OEMLUQMD.js");i(a&&e?e:r,{prefer:a&&e?"verb":"command",group:a&&e?r:void 0}),await c(0)}}v(r);if(u.has(r)){let{runInspect:a}=await import("./chunks/inspect-LRIJ7MQT.js");await a([r,...n],{port:o,verbose:s})}else switch(r){case"assert":{let{runAssert:a}=await import("./chunks/assert-36QXQUCE.js");await a(t.commandArgs);break}case"flow":{let{runFlow:a}=await import("./chunks/flow-CKXTFJJ7.js"),e=await a(n);process.exit(typeof e=="number"?e:0)}case"test":{let{runTest:a}=await import("./chunks/test-CWWQJG5K.js");await a(t.commandArgs,{port:o,verbose:s});break}case"detox":{let{runDetox:a}=await import("./chunks/detox-S7M5WN3L.js");await a(t.commandArgs,{port:o,verbose:s});break}case"maestro":{let{runMaestro:a}=await import("./chunks/maestro-QKSXVPWG.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"preview":{let{runPreview:a}=await import("./chunks/preview-XCQGBN2I.js");await a(t.commandArgs,{port:o,verbose:s});break}case"record":{let{runRecord:a}=await import("./chunks/record-SQA376Z7.js");await a(n,{port:o,verbose:s});break}case"profile":{let{runProfile:a}=await import("./chunks/profile-RDAPVU7K.js"),e=await a(t.commandArgs,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"cpu-profile":{let{runCpuProfile:a}=await import("./chunks/cpu-profile-3YLLRNVG.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"react":{let{runReact:a}=await import("./chunks/react-MM373YNE.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"screenshot":{let{runScreenshot:a}=await import("./chunks/screenshot-FCKW6JV6.js");await a(n,{port:o,verbose:s});break}case"screenshots":{if(t.commandArgs[0]==="capture"){let{runScreenshotsCapture:i}=await import("./chunks/screenshots-capture-H4EAYFH3.js"),m=await i(t.commandArgs.slice(1));process.exit(typeof m=="number"?m:0)}let{runScreenshots:a}=await import("./chunks/screenshots-ITBCSBZS.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"screenshot-mode":{let{runScreenshotMode:a}=await import("./chunks/screenshot-mode-QVRUJXZ3.js");await a(t.commandArgs,{port:o,verbose:s});break}case"slides":{let{runSlides:a}=await import("./chunks/slides-D37ML4LI.js");await a(n,{port:o,verbose:s});break}case"three-mode":case"3d-mode":{let{runThreeMode:a}=await import("./chunks/three-mode-WESGARG5.js");await a(t.commandArgs,{port:o,verbose:s});break}case"inspect":{let{runInspect:a}=await import("./chunks/inspect-LRIJ7MQT.js");await a(n,{port:o,verbose:s});break}case"debug":{let{runDebug:a}=await import("./chunks/debug-TD4EVFT7.js");await a(n,{port:o,verbose:s});break}case"camera":{let{runCamera:a}=await import("./chunks/camera-7HK2Y3PY.js");await a(n,{port:o});break}case"timeline":{let{runTimeline:a}=await import("./chunks/timeline-RUVZASG4.js");await a(n,{port:o,verbose:s});break}case"what-happened":{let{runWhatHappened:a}=await import("./chunks/what-happened-5DBVOXKC.js");await a(n,{port:o,verbose:s});break}case"diagnose":{let{runDiagnose:a}=await import("./chunks/diagnose-JZMNR25X.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"open":{let{runOpenCommand:a}=await import("./chunks/control-PVZRPH57.js");await a(n,{port:o});break}case"use":case"focus":{let{runUseCommand:a}=await import("./chunks/control-PVZRPH57.js");await a(n,{port:o});break}case"claim":{let{runClaimCommand:a}=await import("./chunks/control-PVZRPH57.js");await a(n,{port:o});break}case"close":{let{runCloseCommand:a}=await import("./chunks/control-PVZRPH57.js");await a(n,{port:o});break}case"device":{let{runDeviceCommand:a}=await import("./chunks/device-WR7GA4RN.js");await a(n,{port:o});break}case"scan":case"compat":{let{runCompat:a}=await import("./chunks/compat-KWM6HXJD.js");await a(t.commandArgs);break}case"electron":{let{runElectron:a}=await import("./chunks/electron-V2YDDVKJ.js");await a(t.commandArgs,{port:o,device:p,driver:S});break}case"login":{let{runLogin:a}=await import("./chunks/login-CYIWYJGG.js");await a(t.commandArgs);break}case"logout":{let{runLogout:a}=await import("./chunks/logout-NALFLZWI.js");await a();break}case"whoami":{let{runWhoami:a}=await import("./chunks/whoami-ZDT3RQOC.js");await a();break}case"keys":{let{runKeys:a}=await import("./chunks/keys-IHG2YEL3.js");await a(t.commandArgs);break}case"setup":{let{runSetup:a}=await import("./chunks/setup-ME5SRHWD.js");await a(t.commandArgs);break}case"install-desktop":{let{runInstallDesktop:a}=await import("./chunks/install-desktop-ESQL2Q2T.js");await a(t.commandArgs);break}case"serve":{let{runServe:a}=await import("./chunks/serve-3GHYSGJR.js");await a(t.commandArgs,{port:o});break}case"daemon":{let{runDaemon:a}=await import("./chunks/daemon-2DT4QAJ4.js");await a(t.commandArgs,{port:o});break}case"runtime":{let{runRuntime:a}=await import("./chunks/runtime-CUNVH66R.js");await a(t.commandArgs);break}case"upgrade":{let{runUpgrade:a}=await import("./chunks/upgrade-DKWD6TSY.js");await a(t.commandArgs);break}case"version":{let{runVersion:a}=await import("./chunks/version-G45RLONC.js");await a(t.commandArgs);break}case"agent":{let{runAgentCommand:a}=await import("./chunks/agent-A4WFJEFV.js"),e=await a(t.commandArgs);process.exit(e)}case"agent-wrapper":{let{runAgentWrapper:a}=await import("./chunks/agent-wrapper-EOZBE6UT.js"),e=await a(t.commandArgs);process.exit(e)}case"skill":{let{runSkill:a}=await import("./chunks/skills-E5JE3SAI.js");await a(t.commandArgs);break}case"upload":{let{runUpload:a}=await import("./chunks/upload-LYANGCPB.js");await a(t.commandArgs,{port:o,verbose:s});break}case"app-fonts":{let{runAppFonts:a}=await import("./chunks/app-fonts-H2I7IV7N.js");await a(t.commandArgs);break}case"hints":{let{runHints:a}=await import("./chunks/hints-OK373YOJ.js");a(t.commandArgs);break}default:console.error(` unknown command: ${r}`),console.error(" run `sootsim --help` to see the full surface."),process.exit(1)}
10
+ `),process.exit(1))}var t=g(process.argv);{let{trackCliEvent:a}=await import("./chunks/telemetry-KNKROOT5.js");a({event:"cli_command_invoked",properties:{command:t.command||(t.version?"version":t.help?"help":"none"),arg_count:t.commandArgs.length,platform:process.platform,arch:process.arch,node_version:process.versions.node}})}async function c(a){let{flushCliTelemetry:e}=await import("./chunks/telemetry-KNKROOT5.js");await e(),process.exit(a)}if(t.version){let{getCliVersion:a}=await import("./chunks/cli-version-HENS6BZI.js"),{IS_BETA:e,BETA_LABEL:i}=await import("./chunks/beta-SPH73CAA.js"),m=e?` \xB7 ${i}`:"";console.log(`sootsim v${a()}${m}`);let{readActiveRuntime:h}=await import("./chunks/home-paths-K4347S7C.js"),w=h();console.log(w?`runtime v${w}`:"runtime not installed"),await c(0)}if(t.help&&!t.command){let{printHelp:a}=await import("./chunks/help-J6PF4PZX.js");a(),await c(0)}var o=t.globalFlags.port,s=t.verbose,p=t.globalFlags.device,l=t.globalFlags.theme,S=t.globalFlags.driver,E=t.globalFlags.headless===!0,b=t.globalFlags.sim??t.globalFlags.session??t.globalFlags.tab,n=b?["--sim",b,...t.commandArgs]:t.commandArgs;if(p||l){let{settingsStore:a}=await import("./chunks/store-2JY2VLVA.js"),e={};p&&(e.deviceModel=p),l&&(e.colorScheme=l),a.apply(e)}if(!t.command&&t.commandArgs.length===0){let{printHelp:a}=await import("./chunks/help-J6PF4PZX.js");a(),await c(0)}var r=t.command??"";if(!r){if(t.commandArgs.length>0){let e=t.commandArgs.find(i=>!i.startsWith("-"))??t.commandArgs[0];console.error(` unknown command: ${e}`),console.error(" run `sootsim --help` to see the full surface."),await c(1)}let{printHelp:a}=await import("./chunks/help-J6PF4PZX.js");a(),await c(0)}if(r in d){let a=d[r],e=t.commandArgs.length>0?` ${t.commandArgs.join(" ")}`:"";console.error(` \`sootsim ${r}\` was removed. use \`${a}\` instead.`),e&&console.error(` \u2192 ${a}${e}`),console.error(" run `sootsim --help` to see the new verb groups."),await c(1)}if(t.help||t.commandArgs.includes("--help")||t.commandArgs.includes("-h")){if(r==="skill"){let{runSkill:i}=await import("./chunks/skills-K4DG2CIH.js");await i(t.commandArgs),await c(0)}let a=r==="do"||r==="get"||r==="debug"||r==="shell"||r==="wait",e=t.commandArgs.find(i=>!i.startsWith("-"));if(r!=="shell")if(a&&!e){let{printGroupHelp:i}=await import("./chunks/help-J6PF4PZX.js");i(r)&&await c(0)}else{let{printCommandHelp:i}=await import("./chunks/help-J6PF4PZX.js");i(a&&e?e:r,{prefer:a&&e?"verb":"command",group:a&&e?r:void 0}),await c(0)}}v(r);if(u.has(r)){let{runInspect:a}=await import("./chunks/inspect-ZPHNFMEX.js");await a([r,...n],{port:o,verbose:s})}else switch(r){case"assert":{let{runAssert:a}=await import("./chunks/assert-IT2OXM4Y.js");await a(t.commandArgs);break}case"flow":{let{runFlow:a}=await import("./chunks/flow-GSHP52QS.js"),e=await a(n);process.exit(typeof e=="number"?e:0)}case"test":{let{runTest:a}=await import("./chunks/test-XUJ2V5ZX.js");await a(t.commandArgs,{port:o,verbose:s});break}case"detox":{let{runDetox:a}=await import("./chunks/detox-Q36B2553.js");await a(t.commandArgs,{port:o,verbose:s});break}case"maestro":{let{runMaestro:a}=await import("./chunks/maestro-MEWENIGQ.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"preview":{let{runPreview:a}=await import("./chunks/preview-VPWG4462.js");await a(t.commandArgs,{port:o,verbose:s});break}case"record":{let{runRecord:a}=await import("./chunks/record-MHAAYOWF.js");await a(n,{port:o,verbose:s});break}case"profile":{let{runProfile:a}=await import("./chunks/profile-R4CSGXYJ.js"),e=await a(t.commandArgs,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"cpu-profile":{let{runCpuProfile:a}=await import("./chunks/cpu-profile-P27HBXOI.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"react":{let{runReact:a}=await import("./chunks/react-5LFUOYV5.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"screenshot":{let{runScreenshot:a}=await import("./chunks/screenshot-XAEO7EBF.js");await a(n,{port:o,verbose:s});break}case"screenshots":{if(t.commandArgs[0]==="capture"){let{runScreenshotsCapture:i}=await import("./chunks/screenshots-capture-3DJPYJUD.js"),m=await i(t.commandArgs.slice(1));process.exit(typeof m=="number"?m:0)}let{runScreenshots:a}=await import("./chunks/screenshots-Z6OSENKY.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"screenshot-mode":{let{runScreenshotMode:a}=await import("./chunks/screenshot-mode-QNR5ESKN.js");await a(t.commandArgs,{port:o,verbose:s});break}case"slides":{let{runSlides:a}=await import("./chunks/slides-UIH7KXFR.js");await a(n,{port:o,verbose:s});break}case"three-mode":case"3d-mode":{let{runThreeMode:a}=await import("./chunks/three-mode-P6HSLJMD.js");await a(t.commandArgs,{port:o,verbose:s});break}case"inspect":{let{runInspect:a}=await import("./chunks/inspect-ZPHNFMEX.js");await a(n,{port:o,verbose:s});break}case"debug":{let{runDebug:a}=await import("./chunks/debug-ES4A3SZQ.js");await a(n,{port:o,verbose:s});break}case"camera":{let{runCamera:a}=await import("./chunks/camera-ZYVEUCIO.js");await a(n,{port:o});break}case"timeline":{let{runTimeline:a}=await import("./chunks/timeline-YSUY4PHV.js");await a(n,{port:o,verbose:s});break}case"what-happened":{let{runWhatHappened:a}=await import("./chunks/what-happened-NYVQ7KER.js");await a(n,{port:o,verbose:s});break}case"diagnose":{let{runDiagnose:a}=await import("./chunks/diagnose-DKW5WI3X.js"),e=await a(n,{port:o,verbose:s});process.exit(typeof e=="number"?e:0)}case"open":{let{runOpenCommand:a}=await import("./chunks/control-WQ7XEPCI.js");await a(n,{port:o});break}case"use":case"focus":{let{runUseCommand:a}=await import("./chunks/control-WQ7XEPCI.js");await a(n,{port:o});break}case"claim":{let{runClaimCommand:a}=await import("./chunks/control-WQ7XEPCI.js");await a(n,{port:o});break}case"close":{let{runCloseCommand:a}=await import("./chunks/control-WQ7XEPCI.js");await a(n,{port:o});break}case"device":{let{runDeviceCommand:a}=await import("./chunks/device-NA7TB4E6.js");await a(n,{port:o});break}case"scan":case"compat":{let{runCompat:a}=await import("./chunks/compat-MNTQH57R.js");await a(t.commandArgs);break}case"electron":{let{runElectron:a}=await import("./chunks/electron-6C2VDAZW.js");await a(t.commandArgs,{port:o,device:p,driver:S});break}case"login":{let{runLogin:a}=await import("./chunks/login-O4OGJKYL.js");await a(t.commandArgs);break}case"logout":{let{runLogout:a}=await import("./chunks/logout-DWCBRMLM.js");await a();break}case"whoami":{let{runWhoami:a}=await import("./chunks/whoami-AAHH72FM.js");await a();break}case"keys":{let{runKeys:a}=await import("./chunks/keys-XM67H4SM.js");await a(t.commandArgs);break}case"setup":{let{runSetup:a}=await import("./chunks/setup-AMRSL4IK.js");await a(t.commandArgs);break}case"install-desktop":{let{runInstallDesktop:a}=await import("./chunks/install-desktop-ZCCPJMOF.js");await a(t.commandArgs);break}case"serve":{let{runServe:a}=await import("./chunks/serve-IVTQFOFI.js");await a(t.commandArgs,{port:o});break}case"daemon":{let{runDaemon:a}=await import("./chunks/daemon-WUAZELEI.js");await a(t.commandArgs,{port:o});break}case"runtime":{let{runRuntime:a}=await import("./chunks/runtime-R2PRKIZM.js");await a(t.commandArgs);break}case"upgrade":{let{runUpgrade:a}=await import("./chunks/upgrade-YZMDFQIH.js");await a(t.commandArgs);break}case"version":{let{runVersion:a}=await import("./chunks/version-5QAMZ5CK.js");await a(t.commandArgs);break}case"agent":{let{runAgentCommand:a}=await import("./chunks/agent-3BCITLIZ.js"),e=await a(t.commandArgs);process.exit(e)}case"agent-wrapper":{let{runAgentWrapper:a}=await import("./chunks/agent-wrapper-26RIZVGD.js"),e=await a(t.commandArgs);process.exit(e)}case"skill":{let{runSkill:a}=await import("./chunks/skills-K4DG2CIH.js");await a(t.commandArgs);break}case"upload":{let{runUpload:a}=await import("./chunks/upload-TIH2LID6.js");await a(t.commandArgs,{port:o,verbose:s});break}case"app-fonts":{let{runAppFonts:a}=await import("./chunks/app-fonts-JVDHATQE.js");await a(t.commandArgs);break}case"hints":{let{runHints:a}=await import("./chunks/hints-W7ZZ6KZE.js");a(t.commandArgs);break}default:console.error(` unknown command: ${r}`),console.error(" run `sootsim --help` to see the full surface."),process.exit(1)}
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as b,b as E,c as A,d as l,e as S,g as j,h as T,j as I,m as D,n as k,o as x,p as g,q as O,r as R}from"./chunk-IKJSGKUB.js";import"./chunk-IISA6UXR.js";import{c as $}from"./chunk-5QLWXLML.js";import"./chunk-HWUFW3IP.js";import"./chunk-DV6SWCY7.js";import"./chunk-UMJDCX2P.js";import"./chunk-7F2LH7U5.js";import"./chunk-3G5EE3ST.js";import"./chunk-HCKTFQLK.js";import"./chunk-RAESCYIA.js";import{j as y}from"./chunk-3SUIAUIY.js";import"./chunk-SV3SRWN5.js";import"./chunk-XDDO46ZW.js";import"./chunk-QK76RK6J.js";import"./chunk-ZZWAHZ37.js";import w from"node:fs";import d from"node:path";import{spawn as _}from"node:child_process";import F from"node:net";import{WebSocket as C}from"ws";var c=class extends Error{code;constructor(e,t){super(e),this.name="AgentDaemonError",this.code=t}},f=class{ws;port;commandTimeoutMs;ready;closed=!1;nextId=1;pending=new Map;eventListeners=new Set;statusListeners=new Set;disconnectListeners=new Set;constructor(e={}){this.port=e.port??7668,this.commandTimeoutMs=e.commandTimeoutMs??15e3,this.ws=new C(`ws://localhost:${this.port}`),this.ready=new Promise((t,r)=>{let s=()=>{this.ws.off("error",o),t()},o=i=>{this.ws.off("open",s),r(new c(`could not connect to sootsim daemon on port ${this.port}: ${i.message}`,"NO_DAEMON"))};this.ws.once("open",s),this.ws.once("error",o)}),this.ws.on("message",t=>this.handleMessage(t)),this.ws.on("close",()=>this.handleClose()),this.ws.on("error",()=>{})}async waitReady(){return this.ready}async listProjects(){return this.send("agent:list-projects")}async upsertProject(e){return this.send("agent:upsert-project",{input:e})}async deleteProject(e){return this.send("agent:delete-project",{projectId:e})}async autoAttachForUrl(e){return this.send("agent:auto-attach-for-url",{input:e})}async listSessions(e){return this.send("agent:list-sessions",{projectId:e})}async startSession(e){return this.send("agent:start-session",{input:e})}async sendPrompt(e,t){return this.send("agent:send-prompt",{sessionId:e,prompt:t})}async endSession(e){return this.send("agent:end-session",{sessionId:e})}async getTranscript(e){return this.send("agent:get-transcript",{sessionId:e})}async getPaths(){return this.send("agent:get-paths")}async subscribeEvents(e){return this.send("agent:subscribe-events",{sessionId:e})}async unsubscribeEvents(e){return this.send("agent:unsubscribe-events",{sessionId:e})}onAgentEvent(e){return this.eventListeners.add(e),()=>this.eventListeners.delete(e)}onSessionStatusChange(e){return this.statusListeners.add(e),()=>this.statusListeners.delete(e)}onDisconnect(e){return this.disconnectListeners.add(e),()=>this.disconnectListeners.delete(e)}close(){if(!this.closed){this.closed=!0;try{this.ws.close()}catch{}}}async send(e,t={}){if(await this.ready,this.closed||this.ws.readyState!==C.OPEN)throw new c("daemon connection is closed","NO_DAEMON");let r=this.nextId++;return new Promise((s,o)=>{let i=setTimeout(()=>{this.pending.delete(r),o(new c(`${e} timed out after ${Math.round(this.commandTimeoutMs/1e3)}s`,"TIMEOUT"))},this.commandTimeoutMs);this.pending.set(r,{resolve:s,reject:o,timer:i});try{this.ws.send(JSON.stringify({id:r,type:e,...t}))}catch(a){clearTimeout(i),this.pending.delete(r),o(a instanceof Error?a:new Error(String(a)))}})}handleMessage(e){let t;try{t=JSON.parse(String(e))}catch{return}if(!t||typeof t!="object")return;if(t.type==="agent:event"){for(let s of this.eventListeners)try{s({sessionId:t.sessionId,event:t.event})}catch{}return}if(t.type==="agent:session-status"){for(let s of this.statusListeners)try{s(t.session)}catch{}return}if(typeof t.id!="number")return;let r=this.pending.get(t.id);r&&(this.pending.delete(t.id),clearTimeout(r.timer),t.error?r.reject(new c(t.error,t.code)):r.resolve(t.result))}handleClose(){if(!this.closed){this.closed=!0;for(let[,e]of this.pending)clearTimeout(e.timer),e.reject(new c("daemon disconnected","DISCONNECT"));this.pending.clear();for(let e of this.disconnectListeners)try{e()}catch{}}}};function M(n=7668,e=400){return new Promise(t=>{let r=new F.Socket,s=!1,o=i=>{s||(s=!0,r.destroy(),t(i))};r.setTimeout(e),r.once("connect",()=>o(!0)),r.once("timeout",()=>o(!1)),r.once("error",()=>o(!1)),r.connect(n,"127.0.0.1")})}async function B(n={}){let e=n.port??7668;if(await M(e))return{alreadyRunning:!0};if(y())throw new c(`no sootsim bridge on port ${e}. run \`sootsim setup\` to install the background daemon, or \`sootsim serve\` in another shell.`,"DEV_HOST_REFUSED");let{cmd:t,prefixArgs:r}=R(),s=[...r,"serve","--quiet"];e!==7668&&s.push("--port",String(e));let o=_(t,s,{detached:!0,stdio:"ignore",env:process.env,cwd:process.cwd()});o.unref();let i=Date.now()+(n.startupTimeoutMs??5e3);for(;Date.now()<i;){if(await M(e))return{alreadyRunning:!1,pid:o.pid};await new Promise(a=>setTimeout(a,100))}throw new c(`spawned sootsim daemon on port ${e} but it did not come up in time. run \`sootsim serve\` manually to diagnose.`,"SPAWN_TIMEOUT")}async function h(n={}){await B({port:n.port,startupTimeoutMs:n.startupTimeoutMs});let e=new f(n);try{await e.waitReady()}catch(t){throw e.close(),t}return e}async function ge(n){let[e,...t]=n;try{switch(e){case void 0:case"--help":case"-h":case"help":return L(),0;case"attach":return await W(t);case"projects":return await J();case"project":return await V(t);case"sessions":return await H(t);case"start":return await G(t);case"prompt":return await q(t);case"watch":return await K(t);case"transcript":return await z(t);case"end":return await Q(t);case"paths":return await Y();default:return process.stderr.write(`unknown agent subcommand: ${e}
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as b,b as E,c as A,d as l,e as S,g as j,h as T,j as I,m as k,n as D,o as x,p as g,q as O,r as C}from"./chunk-PL3ALTWB.js";import"./chunk-WRHJEI7Y.js";import{c as $}from"./chunk-ATVKVVHZ.js";import"./chunk-4YNKFN2A.js";import"./chunk-A2WASN2L.js";import"./chunk-AN4DM7IB.js";import"./chunk-CHTYIQLE.js";import"./chunk-YU6CNUJD.js";import"./chunk-WKG5J4RD.js";import"./chunk-4INGTBO7.js";import{j as y}from"./chunk-IBSEFPPL.js";import"./chunk-CUO7F2JE.js";import"./chunk-JS3NH2SJ.js";import"./chunk-NZWTC6K6.js";import"./chunk-64QAFSY7.js";import w from"node:fs";import d from"node:path";import{spawn as _}from"node:child_process";import F from"node:net";import{WebSocket as R}from"ws";var c=class extends Error{code;constructor(e,t){super(e),this.name="AgentDaemonError",this.code=t}},f=class{ws;port;commandTimeoutMs;ready;closed=!1;nextId=1;pending=new Map;eventListeners=new Set;statusListeners=new Set;disconnectListeners=new Set;constructor(e={}){this.port=e.port??7668,this.commandTimeoutMs=e.commandTimeoutMs??15e3,this.ws=new R(`ws://localhost:${this.port}`),this.ready=new Promise((t,r)=>{let s=()=>{this.ws.off("error",o),t()},o=i=>{this.ws.off("open",s),r(new c(`could not connect to sootsim daemon on port ${this.port}: ${i.message}`,"NO_DAEMON"))};this.ws.once("open",s),this.ws.once("error",o)}),this.ws.on("message",t=>this.handleMessage(t)),this.ws.on("close",()=>this.handleClose()),this.ws.on("error",()=>{})}async waitReady(){return this.ready}async listProjects(){return this.send("agent:list-projects")}async upsertProject(e){return this.send("agent:upsert-project",{input:e})}async deleteProject(e){return this.send("agent:delete-project",{projectId:e})}async autoAttachForUrl(e){return this.send("agent:auto-attach-for-url",{input:e})}async listSessions(e){return this.send("agent:list-sessions",{projectId:e})}async startSession(e){return this.send("agent:start-session",{input:e})}async sendPrompt(e,t){return this.send("agent:send-prompt",{sessionId:e,prompt:t})}async sendClaimedPrompt(e,t){return this.send("agent:send-claimed-prompt",{simId:e,prompt:t})}async endSession(e){return this.send("agent:end-session",{sessionId:e})}async getTranscript(e){return this.send("agent:get-transcript",{sessionId:e})}async getPaths(){return this.send("agent:get-paths")}async subscribeEvents(e){return this.send("agent:subscribe-events",{sessionId:e})}async unsubscribeEvents(e){return this.send("agent:unsubscribe-events",{sessionId:e})}onAgentEvent(e){return this.eventListeners.add(e),()=>this.eventListeners.delete(e)}onSessionStatusChange(e){return this.statusListeners.add(e),()=>this.statusListeners.delete(e)}onDisconnect(e){return this.disconnectListeners.add(e),()=>this.disconnectListeners.delete(e)}close(){if(!this.closed){this.closed=!0;try{this.ws.close()}catch{}}}async send(e,t={}){if(await this.ready,this.closed||this.ws.readyState!==R.OPEN)throw new c("daemon connection is closed","NO_DAEMON");let r=this.nextId++;return new Promise((s,o)=>{let i=setTimeout(()=>{this.pending.delete(r),o(new c(`${e} timed out after ${Math.round(this.commandTimeoutMs/1e3)}s`,"TIMEOUT"))},this.commandTimeoutMs);this.pending.set(r,{resolve:s,reject:o,timer:i});try{this.ws.send(JSON.stringify({id:r,type:e,...t}))}catch(a){clearTimeout(i),this.pending.delete(r),o(a instanceof Error?a:new Error(String(a)))}})}handleMessage(e){let t;try{t=JSON.parse(String(e))}catch{return}if(!t||typeof t!="object")return;if(t.type==="agent:event"){for(let s of this.eventListeners)try{s({sessionId:t.sessionId,event:t.event})}catch{}return}if(t.type==="agent:session-status"){for(let s of this.statusListeners)try{s(t.session)}catch{}return}if(typeof t.id!="number")return;let r=this.pending.get(t.id);r&&(this.pending.delete(t.id),clearTimeout(r.timer),t.error?r.reject(new c(t.error,t.code)):r.resolve(t.result))}handleClose(){if(!this.closed){this.closed=!0;for(let[,e]of this.pending)clearTimeout(e.timer),e.reject(new c("daemon disconnected","DISCONNECT"));this.pending.clear();for(let e of this.disconnectListeners)try{e()}catch{}}}};function M(n=7668,e=400){return new Promise(t=>{let r=new F.Socket,s=!1,o=i=>{s||(s=!0,r.destroy(),t(i))};r.setTimeout(e),r.once("connect",()=>o(!0)),r.once("timeout",()=>o(!1)),r.once("error",()=>o(!1)),r.connect(n,"127.0.0.1")})}async function B(n={}){let e=n.port??7668;if(await M(e))return{alreadyRunning:!0};if(y())throw new c(`no sootsim bridge on port ${e}. run \`sootsim setup\` to install the background daemon, or \`sootsim serve\` in another shell.`,"DEV_HOST_REFUSED");let{cmd:t,prefixArgs:r}=C(),s=[...r,"serve","--quiet"];e!==7668&&s.push("--port",String(e));let o=_(t,s,{detached:!0,stdio:"ignore",env:process.env,cwd:process.cwd()});o.unref();let i=Date.now()+(n.startupTimeoutMs??5e3);for(;Date.now()<i;){if(await M(e))return{alreadyRunning:!1,pid:o.pid};await new Promise(a=>setTimeout(a,100))}throw new c(`spawned sootsim daemon on port ${e} but it did not come up in time. run \`sootsim serve\` manually to diagnose.`,"SPAWN_TIMEOUT")}async function h(n={}){await B({port:n.port,startupTimeoutMs:n.startupTimeoutMs});let e=new f(n);try{await e.waitReady()}catch(t){throw e.close(),t}return e}async function ge(n){let[e,...t]=n;try{switch(e){case void 0:case"--help":case"-h":case"help":return L(),0;case"attach":return await W(t);case"projects":return await J();case"project":return await V(t);case"sessions":return await H(t);case"start":return await G(t);case"prompt":return await q(t);case"watch":return await K(t);case"transcript":return await z(t);case"end":return await Q(t);case"paths":return await Y();default:return process.stderr.write(`unknown agent subcommand: ${e}
3
3
  `),L(),2}}catch(r){if(r instanceof c)return process.stderr.write(`${r.message}
4
4
  `),1;throw r}}async function v(n){let e=await h({clientLabel:"sootsim-agent-cli"});try{return await n(e)}finally{e.close()}}function L(){$("agent")}function P(n,e){let t={},r=[];for(let s=0;s<n.length;s++){let o=n[s],i=e[o];i==="value"?(t[o]=n[s+1]??"",s++):i==="bool"?t[o]=!0:r.push(o)}return{flags:t,positional:r}}function U(n,e="codex"){return n==="codex"||n==="claude"?n:e}async function W(n){let{flags:e,positional:t}=P(n,{"--name":"value","--provider":"value"}),r=t[0];if(!r)return process.stderr.write(`usage: sootsim agent attach <dir> [--name X] [--provider codex|claude]
5
5
  `),2;let s=d.resolve(r);if(!w.existsSync(s))return process.stderr.write(`directory does not exist: ${s}
@@ -43,4 +43,4 @@ state: ${d.join(n,"attached-projects.json")}
43
43
  sessions: ${d.join(n,"sessions")}
44
44
  transcripts: ${d.join(n,"transcripts")}
45
45
  locks: ${d.join(n,"locks")}
46
- `),0}function p(n,e){return n.length<=e?n:n.slice(0,e-1)+"\u2026"}function N(n){return n.length>14?`${n.slice(0,14)}\u2026`:n}function Z(n){return new Date(n).toISOString().replace("T"," ").slice(0,19)}var fe={sessionDir:D,promptFifoPath:k,eventsFifoPath:x,transcriptPath:g,parseAgentEventLine:b};export{fe as __internals,ge as runAgentCommand};
46
+ `),0}function p(n,e){return n.length<=e?n:n.slice(0,e-1)+"\u2026"}function N(n){return n.length>14?`${n.slice(0,14)}\u2026`:n}function Z(n){return new Date(n).toISOString().replace("T"," ").slice(0,19)}var fe={sessionDir:k,promptFifoPath:D,eventsFifoPath:x,transcriptPath:g,parseAgentEventLine:b};export{fe as __internals,ge as runAgentCommand};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{b as M}from"./chunk-IISA6UXR.js";import"./chunk-ZZWAHZ37.js";import{execFile as G,spawn as q}from"node:child_process";import{randomUUID as X}from"node:crypto";import{constants as R,createReadStream as Y,createWriteStream as j,existsSync as I,openSync as J}from"node:fs";import V from"node:fs/promises";import z from"node:path";import K from"node:readline";import{promisify as Q}from"node:util";import{spawn as H}from"node:child_process";import L from"node:readline";var b=class extends Error{code;data;constructor(t,r,m){super(t),this.name="CodexRpcError",this.code=r,this.data=m}};function W(d){let t=H(d.bin,["app-server"],{cwd:d.cwd,env:{...process.env,...d.env},stdio:["pipe","pipe","pipe"]}),r=new Map,m=new Map,u=1,g=!1,a=new Promise(s=>{t.on("exit",(i,e)=>{g=!0;let p=new Error(`codex app-server exited (code=${i}, signal=${e??""})`);for(let{reject:f}of r.values())f(p);r.clear(),s({code:i,signal:e})})});L.createInterface({input:t.stdout,crlfDelay:1/0}).on("line",s=>{let i=s.trim();if(!i)return;let e;try{e=JSON.parse(i)}catch{return}if(e.id!=null&&(e.result!==void 0||e.error!==void 0)){let p=typeof e.id=="string"?Number(e.id):e.id,f=p!=null?r.get(p):void 0;if(!f)return;r.delete(p),e.error?f.reject(new b(e.error.message,e.error.code,e.error.data)):f.resolve(e.result);return}if(e.method){let p=m.get(e.method);if(!p)return;for(let f of p)try{f(e.params)}catch(l){console.error(`[codex-client] handler for "${e.method}" threw:`,l instanceof Error?l.stack??l.message:l)}}}),t.stderr.setEncoding("utf8"),t.stderr.on("data",s=>{let i=m.get("__stderr__");if(i)for(let e of i)try{e({text:s})}catch{}});function n(s){if(!g)try{t.stdin.write(JSON.stringify(s)+`
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{b as M}from"./chunk-WRHJEI7Y.js";import"./chunk-64QAFSY7.js";import{execFile as G,spawn as q}from"node:child_process";import{randomUUID as X}from"node:crypto";import{constants as R,createReadStream as Y,createWriteStream as j,existsSync as I,openSync as J}from"node:fs";import V from"node:fs/promises";import z from"node:path";import K from"node:readline";import{promisify as Q}from"node:util";import{spawn as H}from"node:child_process";import L from"node:readline";var b=class extends Error{code;data;constructor(t,r,m){super(t),this.name="CodexRpcError",this.code=r,this.data=m}};function W(d){let t=H(d.bin,["app-server"],{cwd:d.cwd,env:{...process.env,...d.env},stdio:["pipe","pipe","pipe"]}),r=new Map,m=new Map,u=1,g=!1,a=new Promise(s=>{t.on("exit",(i,e)=>{g=!0;let p=new Error(`codex app-server exited (code=${i}, signal=${e??""})`);for(let{reject:f}of r.values())f(p);r.clear(),s({code:i,signal:e})})});L.createInterface({input:t.stdout,crlfDelay:1/0}).on("line",s=>{let i=s.trim();if(!i)return;let e;try{e=JSON.parse(i)}catch{return}if(e.id!=null&&(e.result!==void 0||e.error!==void 0)){let p=typeof e.id=="string"?Number(e.id):e.id,f=p!=null?r.get(p):void 0;if(!f)return;r.delete(p),e.error?f.reject(new b(e.error.message,e.error.code,e.error.data)):f.resolve(e.result);return}if(e.method){let p=m.get(e.method);if(!p)return;for(let f of p)try{f(e.params)}catch(l){console.error(`[codex-client] handler for "${e.method}" threw:`,l instanceof Error?l.stack??l.message:l)}}}),t.stderr.setEncoding("utf8"),t.stderr.on("data",s=>{let i=m.get("__stderr__");if(i)for(let e of i)try{e({text:s})}catch{}});function n(s){if(!g)try{t.stdin.write(JSON.stringify(s)+`
3
3
  `)}catch{}}return{exited:a,on(s,i){let e=m.get(s);return e||(e=new Set,m.set(s,e)),e.add(i),()=>{e?.delete(i)}},request(s,i){if(g)return Promise.reject(new Error(`codex app-server closed; cannot call ${s}`));let e=u++;return new Promise((p,f)=>{r.set(e,{resolve:l=>p(l),reject:f,method:s}),n({jsonrpc:"2.0",id:e,method:s,params:i})})},notify(s,i){n({jsonrpc:"2.0",method:s,params:i})},async shutdown(s=1500){if(g)return;try{t.stdin.end()}catch{}let i=setTimeout(()=>{if(!g)try{t.kill("SIGTERM")}catch{}},s);try{await a}finally{clearTimeout(i)}},kill(s="SIGTERM"){if(!g)try{t.kill(s)}catch{}}}}var O="never",F="danger-full-access",Z={type:"dangerFullAccess"},D="fast",ee="medium",te=Q(G);async function ne(d,t){let r=t||d;if(r.includes("/")||r.includes("\\"))return I(r)?{ok:!0,path:r}:{ok:!1,message:`agent binary not found at path: ${r}`};try{let{stdout:m}=await te("which",[r],{timeout:1500}),u=m.trim();return u?{ok:!0,path:u}:{ok:!1,message:`${r} not found on PATH`}}catch{return{ok:!1,message:`${r} not found on PATH. install the ${d} CLI and retry, or pass --${d}-bin /path/to/${d} to agent start.`}}}function re(d){let t={"--session-id":"sessionId","--project-id":"projectId","--provider":"provider","--cwd":"cwd","--prompt-in":"promptIn","--events-out":"eventsOut","--transcript":"transcript","--codex-bin":"codexBin","--claude-bin":"claudeBin","--claude-session-uuid":"claudeSessionUuid"},r={};for(let m=0;m<d.length;m++){let u=d[m];if(u==="--fresh-thread"){r.freshThread=!0;continue}let g=t[u];g&&(r[g]=d[m+1],m++)}return r}async function Ie(d){let t=re(d);if(!t.sessionId||!t.projectId||!t.provider||!t.cwd||!t.promptIn||!t.eventsOut)return process.stderr.write(`usage: sootsim agent-wrapper --session-id <id> --project-id <id>
4
4
  --provider codex|claude --cwd <path>
5
5
  --prompt-in <fifo> --events-out <fifo>
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{d as p}from"./chunk-RCPMRHTK.js";import"./chunk-ZZWAHZ37.js";import{existsSync as h,mkdirSync as d,readFileSync as y,writeFileSync as g}from"node:fs";import{join as m}from"node:path";import{gzipSync as w}from"node:zlib";function f(t,e){let o=t.indexOf(`--${e}`);if(o!==-1&&o+1<t.length)return t[o+1];let i=t.find(r=>r.startsWith(`--${e}=`));return i?i.slice(e.length+3):void 0}async function S(t){let e=f(t,"wire")||"",o=f(t,"out-dir"),i=f(t,"manifest");if((!o||!i)&&(console.error(" usage: sootsim app-fonts stage --wire <wire> --out-dir <dir> --manifest <path>"),process.exit(1)),!e.trim()){console.log("no app fonts declared \u2014 nothing to stage");return}d(o,{recursive:!0});let r=await p(e,{onStaged:({url:n,byteLength:s})=>console.log(` staged app font: ${n} (${(s/1024).toFixed(1)} KiB)`),onError:(n,s)=>console.error(` warning: failed to fetch app font ${n}: ${s instanceof Error?s.message:s}`)}),a=[];for(let n of r){let s=w(n.bytes);g(m(o,n.urlhash),s),a.push({url:n.url,urlhash:n.urlhash,contentType:n.contentType,encoding:"gzip",sizeBytes:s.length,rawBytes:n.bytes.byteLength})}let c=[];if(h(i))try{let n=JSON.parse(y(i,"utf8"));Array.isArray(n)&&(c=n)}catch{}let u=new Set(c.map(n=>n.urlhash)),l=[...c,...a.filter(n=>!u.has(n.urlhash))];g(i,JSON.stringify(l)),console.log(`staged ${a.length} app font(s); manifest now has ${l.length} file(s)`)}async function E(t){let e=t[0];if(e==="stage"){await S(t.slice(1));return}console.error(` unknown app-fonts subcommand: ${e??"(none)"}`),console.error(" available: stage"),process.exit(1)}export{E as runAppFonts};
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{d as p}from"./chunk-CH3MWM5W.js";import"./chunk-64QAFSY7.js";import{existsSync as h,mkdirSync as d,readFileSync as y,writeFileSync as g}from"node:fs";import{join as m}from"node:path";import{gzipSync as w}from"node:zlib";function f(t,e){let o=t.indexOf(`--${e}`);if(o!==-1&&o+1<t.length)return t[o+1];let i=t.find(r=>r.startsWith(`--${e}=`));return i?i.slice(e.length+3):void 0}async function S(t){let e=f(t,"wire")||"",o=f(t,"out-dir"),i=f(t,"manifest");if((!o||!i)&&(console.error(" usage: sootsim app-fonts stage --wire <wire> --out-dir <dir> --manifest <path>"),process.exit(1)),!e.trim()){console.log("no app fonts declared \u2014 nothing to stage");return}d(o,{recursive:!0});let r=await p(e,{onStaged:({url:n,byteLength:s})=>console.log(` staged app font: ${n} (${(s/1024).toFixed(1)} KiB)`),onError:(n,s)=>console.error(` warning: failed to fetch app font ${n}: ${s instanceof Error?s.message:s}`)}),a=[];for(let n of r){let s=w(n.bytes);g(m(o,n.urlhash),s),a.push({url:n.url,urlhash:n.urlhash,contentType:n.contentType,encoding:"gzip",sizeBytes:s.length,rawBytes:n.bytes.byteLength})}let c=[];if(h(i))try{let n=JSON.parse(y(i,"utf8"));Array.isArray(n)&&(c=n)}catch{}let u=new Set(c.map(n=>n.urlhash)),l=[...c,...a.filter(n=>!u.has(n.urlhash))];g(i,JSON.stringify(l)),console.log(`staged ${a.length} app font(s); manifest now has ${l.length} file(s)`)}async function E(t){let e=t[0];if(e==="stage"){await S(t.slice(1));return}console.error(` unknown app-fonts subcommand: ${e??"(none)"}`),console.error(" available: stage"),process.exit(1)}export{E as runAppFonts};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-ZZWAHZ37.js";import{spawn as x}from"child_process";var w=new Set(["describe","find","list","network","logs","count","tree","url","a11y","node","layout","keyboard","errors","warnings","requests","animations","animation","state","sample-color"]),S=new Set(["--exists","--empty","--negate","--quiet","--allow-timeout","!"]),q=new Set(["--count","--count-at-least","--count-at-most","--contains","--not-contains","--matches","--not-matches","--equals","--jq","--has-path","--within"]),P=new Set(["--path-equals"]);function j(s){let r=[],u=[],n=0,e=!1,t=!1,i=!1;for(let o=0;o<s.length;o++){let a=s[o];if(a==="--within"){let c=Number(s[o+1]);if(!Number.isFinite(c)||c<0)return{error:`--within requires a non-negative number, got: ${s[o+1]}`};n=c,o++;continue}if(a==="--negate"||a==="!"){e=!0;continue}if(a==="--quiet"){t=!0;continue}if(a==="--allow-timeout"){i=!0;continue}if(S.has(a)){u.push({kind:a,args:[]});continue}if(q.has(a)){let c=s[o+1];if(c==null)return{error:`${a} requires a value`};u.push({kind:a,args:[c]}),o++;continue}if(P.has(a)){let c=s[o+1],f=s[o+2];if(c==null||f==null)return{error:`${a} requires <path> <value>`};u.push({kind:a,args:[c,f]}),o+=2;continue}r.push(a)}return r.length===0?{error:"assert requires a verb (e.g. find, describe, get errors)"}:{verbArgs:r,predicates:u,withinMs:n,negate:e,quiet:t,allowTimeout:i}}function N(s){return s[0]==="get"||s[0]==="debug"?w.has(s[1])?s[1]:null:s[0]==="do"||s[0]==="wait"?null:w.has(s[0])?s[0]:null}async function R(s){let u=[process.argv[1],...s,"--json"];return new Promise(n=>{let e=x(process.execPath,u,{stdio:["ignore","pipe","pipe"],env:process.env}),t="",i="";e.stdout.on("data",o=>t+=o.toString()),e.stderr.on("data",o=>i+=o.toString()),e.on("error",o=>{n({ok:!1,payload:null,reason:`spawn failed: ${o.message}`})}),e.on("close",o=>{if(o!==0){let a=i.trim().split(`
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-64QAFSY7.js";import{spawn as x}from"child_process";var w=new Set(["describe","find","list","network","logs","count","tree","url","a11y","node","layout","keyboard","errors","warnings","requests","animations","animation","state","sample-color"]),S=new Set(["--exists","--empty","--negate","--quiet","--allow-timeout","!"]),q=new Set(["--count","--count-at-least","--count-at-most","--contains","--not-contains","--matches","--not-matches","--equals","--jq","--has-path","--within"]),P=new Set(["--path-equals"]);function j(s){let r=[],u=[],n=0,e=!1,t=!1,i=!1;for(let o=0;o<s.length;o++){let a=s[o];if(a==="--within"){let c=Number(s[o+1]);if(!Number.isFinite(c)||c<0)return{error:`--within requires a non-negative number, got: ${s[o+1]}`};n=c,o++;continue}if(a==="--negate"||a==="!"){e=!0;continue}if(a==="--quiet"){t=!0;continue}if(a==="--allow-timeout"){i=!0;continue}if(S.has(a)){u.push({kind:a,args:[]});continue}if(q.has(a)){let c=s[o+1];if(c==null)return{error:`${a} requires a value`};u.push({kind:a,args:[c]}),o++;continue}if(P.has(a)){let c=s[o+1],f=s[o+2];if(c==null||f==null)return{error:`${a} requires <path> <value>`};u.push({kind:a,args:[c,f]}),o+=2;continue}r.push(a)}return r.length===0?{error:"assert requires a verb (e.g. find, describe, get errors)"}:{verbArgs:r,predicates:u,withinMs:n,negate:e,quiet:t,allowTimeout:i}}function N(s){return s[0]==="get"||s[0]==="debug"?w.has(s[1])?s[1]:null:s[0]==="do"||s[0]==="wait"?null:w.has(s[0])?s[0]:null}async function R(s){let u=[process.argv[1],...s,"--json"];return new Promise(n=>{let e=x(process.execPath,u,{stdio:["ignore","pipe","pipe"],env:process.env}),t="",i="";e.stdout.on("data",o=>t+=o.toString()),e.stderr.on("data",o=>i+=o.toString()),e.on("error",o=>{n({ok:!1,payload:null,reason:`spawn failed: ${o.message}`})}),e.on("close",o=>{if(o!==0){let a=i.trim().split(`
3
3
  `).slice(-2).join(" | ").slice(0,200);n({ok:!1,payload:null,reason:`verb exited ${o}${a?`: ${a}`:""}`});return}if(!t.trim()){n({ok:!1,payload:null,reason:"verb produced no output"});return}try{let a=JSON.parse(t);n({ok:!0,payload:a})}catch{n({ok:!1,payload:null,reason:`verb output was not valid json: ${t.slice(0,120)}`})}})})}function y(s,r){let u=r.split(".").filter(e=>e.length>0),n=s;for(let e of u){if(n==null)return{found:!1};if(Array.isArray(n)){let t=Number(e);if(!Number.isInteger(t)||t<0||t>=n.length)return{found:!1};n=n[t];continue}if(typeof n=="object"){let t=n;if(!(e in t))return{found:!1};n=t[e];continue}return{found:!1}}return{found:!0,value:n}}function d(s){return Array.isArray(s)?s.length:s&&typeof s=="object"?Object.keys(s).length:null}async function A(s,r){let{kind:u,args:n}=s;switch(u){case"--exists":return r==null?{ok:!1,reason:"payload is null"}:d(r)===0?{ok:!1,reason:"payload is empty"}:{ok:!0,reason:"exists"};case"--empty":{if(r==null)return{ok:!0,reason:"payload is null"};let e=d(r);return e===0?{ok:!0,reason:"payload is empty"}:{ok:!1,reason:`payload has ${e} item(s)`}}case"--count":{let e=Number(n[0]),t=d(r);return t==null?{ok:!1,reason:`payload not countable (${typeof r})`}:{ok:t===e,reason:`count=${t}, want=${e}`}}case"--count-at-least":{let e=Number(n[0]),t=d(r);return t==null?{ok:!1,reason:"payload not countable"}:{ok:t>=e,reason:`count=${t}, want>=${e}`}}case"--count-at-most":{let e=Number(n[0]),t=d(r);return t==null?{ok:!1,reason:"payload not countable"}:{ok:t<=e,reason:`count=${t}, want<=${e}`}}case"--contains":{let e=n[0],t=JSON.stringify(r);return{ok:t.includes(e),reason:t.includes(e)?`contains "${e}"`:`missing "${e}"`}}case"--not-contains":{let e=n[0],t=JSON.stringify(r);return{ok:!t.includes(e),reason:t.includes(e)?`unexpected "${e}"`:`not contains "${e}"`}}case"--matches":{let e=new RegExp(n[0]),t=JSON.stringify(r),i=e.test(t);return{ok:i,reason:i?`matches /${n[0]}/`:`no match for /${n[0]}/`}}case"--not-matches":{let e=new RegExp(n[0]),t=JSON.stringify(r),i=!e.test(t);return{ok:i,reason:i?`not matches /${n[0]}/`:`unexpected /${n[0]}/`}}case"--equals":{let e=n[0],t=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"?String(r):JSON.stringify(r);return{ok:t===e,reason:`got=${JSON.stringify(t)}, want=${JSON.stringify(e)}`}}case"--has-path":{let e=y(r,n[0]);return{ok:e.found,reason:e.found?`path ${n[0]} present`:`path ${n[0]} missing`}}case"--path-equals":{let[e,t]=n,i=y(r,e);if(!i.found)return{ok:!1,reason:`path ${e} missing`};let o=typeof i.value=="string"||typeof i.value=="number"||typeof i.value=="boolean"?String(i.value):JSON.stringify(i.value);return{ok:o===t,reason:`${e}=${o}, want=${t}`}}case"--jq":{let e=n[0];try{let i=(await O(e,r)).trim();return{ok:i.length>0&&i!=="null"&&i!=="false"&&i!=='""',reason:`jq: ${i.slice(0,120)}`}}catch(t){throw new Error(`jq evaluation failed: ${t.message}`)}}default:return{ok:!1,reason:`unknown predicate ${u}`}}}function O(s,r){return new Promise((u,n)=>{let e=x("jq",[s],{stdio:["pipe","pipe","pipe"]}),t="",i="";e.stdout.on("data",o=>t+=o.toString()),e.stderr.on("data",o=>i+=o.toString()),e.on("error",n),e.on("close",o=>{if(o!==0){n(new Error(i.trim()||`jq exited ${o}`));return}u(t)}),e.stdin.end(JSON.stringify(r))})}async function T(s){(s[0]==="--help"||s[0]==="-h"||s.length===0)&&(J(),process.exit(s.length===0?2:0));let r=j(s);"error"in r&&(process.stderr.write(` assert: ${r.error}
4
4
  `),process.exit(2));let{verbArgs:u,predicates:n,withinMs:e,negate:t,quiet:i,allowTimeout:o}=r;N(u)||(process.stderr.write(` assert: unknown or non-read verb: ${u.join(" ")}
5
5
  supported: ${Array.from(w).sort().join(", ")}
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a,b,c,d}from"./chunk-JS3NH2SJ.js";import"./chunk-64QAFSY7.js";export{d as BETA_ASK_HEADLINE,b as BETA_LABEL,c as BETA_TAGLINE,a as IS_BETA};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{m as f}from"./chunk-H2J4Z7LY.js";import"./chunk-YMBQBKKA.js";import{c as m,e as l,g as p}from"./chunk-OMJ2DTQJ.js";import"./chunk-HCKTFQLK.js";import"./chunk-RAESCYIA.js";import"./chunk-3SUIAUIY.js";import"./chunk-ZZWAHZ37.js";function d(){console.log(`
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{m as f}from"./chunk-A3VHHWLU.js";import"./chunk-D2BBJUEY.js";import{c as m,e as l,g as p}from"./chunk-65ZBQDQM.js";import"./chunk-WKG5J4RD.js";import"./chunk-4INGTBO7.js";import"./chunk-IBSEFPPL.js";import"./chunk-64QAFSY7.js";function d(){console.log(`
3
3
  sootsim camera \u2014 drive the sim camera
4
4
 
5
5
  usage:
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as p,b as $,c as w,e as y,f as R}from"./chunk-ZG2A6LCL.js";import{a as d}from"./chunk-OMJ2DTQJ.js";import{C as m,D as a,E as h,F as f,l as v}from"./chunk-3SUIAUIY.js";import b from"fs";import{WebSocket as A}from"ws";async function P(n,e={}){let[o,...t]=n;if(!o||o==="--help"||o==="-h"){O();return}switch(o){case"install":return D(t,e);case"list":case"ls":return N(t);case"use":return T(t);case"remove":case"rm":return L(t);case"which":case"active":return _();case"notes":case"changelog":return C(t);default:console.error(` unknown runtime subcommand: ${o}`),O(),process.exit(1)}}function O(){console.log(`
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as p,b as $,c as w,e as y,f as R}from"./chunk-QWZFOMCI.js";import{a as d}from"./chunk-65ZBQDQM.js";import{C as m,D as a,E as h,F as f,l as v}from"./chunk-IBSEFPPL.js";import b from"fs";import{WebSocket as A}from"ws";async function P(n,e={}){let[o,...t]=n;if(!o||o==="--help"||o==="-h"){O();return}switch(o){case"install":return D(t,e);case"list":case"ls":return N(t);case"use":return T(t);case"remove":case"rm":return L(t);case"which":case"active":return _();case"notes":case"changelog":return C(t);default:console.error(` unknown runtime subcommand: ${o}`),O(),process.exit(1)}}function O(){console.log(`
3
3
  sootsim runtime \u2014 manage engine runtimes under ~/.sootsim/runtimes/
4
4
 
5
5
  usage:
@@ -24,4 +24,4 @@ examples:
24
24
  sootsim runtime install --channel beta
25
25
  sootsim runtime use 1.2.3
26
26
  sootsim runtime notes
27
- `)}async function D(n,e){let{version:o,flags:t}=E(n),s=t.channel??e.channel??"stable",l=t.force===!0,c=t.setActive!==!1;m(),console.log("sootsim runtime install"),console.log(` cdn: ${w()}`);try{let i=await R({version:o,channel:s,force:l,setActive:c});console.log(` version: ${i.version} (channel: ${i.channel})`),i.installed?console.log(` installed ${i.version}`):console.log(` already installed at ${i.runtimeDir}`),c&&await I(i.version)}catch(i){console.error(` ${k(i)}`),process.exit(1)}}async function I(n){h(n),console.log(` active: ${n}`),await S(n)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${n})`)}async function S(n){let{isDaemonLockfileFresh:e,readDaemonLockfile:o}=await import("./home-paths-IFY5UTLL.js"),t=o();if(!e(t))return!1;let s=d();return new Promise(l=>{let c=!1,i=!1,u=x=>{c||(c=!0,l(x))},r=new A(`ws://127.0.0.1:${s}`,{handshakeTimeout:800}),g=setTimeout(()=>{try{r.close()}catch{}u(i)},1500);r.on("open",()=>{try{r.send(JSON.stringify({type:"runtime:use",version:n,id:0})),i=!0}catch{}setTimeout(()=>{try{r.close()}catch{}},100)}),r.on("close",()=>{clearTimeout(g),u(i)}),r.on("error",()=>{clearTimeout(g),u(!1)})})}async function N(n){m();let e=f(),o=a();if(console.log("installed:"),e.length===0)console.log(" (none)");else for(let t of e)console.log(` ${t===o?"*":" "} ${t}`);try{let t=await y();console.log("available (latest per channel):");for(let[s,l]of Object.entries(t.channels))console.log(` ${s.padEnd(8)} ${l.latest}`)}catch(t){console.log(`available: (could not fetch manifest: ${k(t)})`)}}async function T(n){let e=n[0];e||(console.error(" usage: sootsim runtime use <version>"),process.exit(1));let o=f();o.includes(e)||(console.error(` version ${e} is not installed`),console.error(` installed: ${o.join(", ")||"(none)"}`),console.error(` run \`sootsim runtime install ${e}\` first`),process.exit(1)),await I(e)}async function L(n){let e=n[0];e||(console.error(" usage: sootsim runtime remove <version>"),process.exit(1)),a()===e&&(console.error(` cannot remove active runtime ${e}`),console.error(" switch with `sootsim runtime use <other>` first, or install another version"),process.exit(1));let t=v(e);if(!b.existsSync(t)){console.error(` ${e} is not installed`);return}b.rmSync(t,{recursive:!0,force:!0}),console.log(` removed ${e}`)}async function _(){let n=a();if(!n){console.log(" no active runtime");return}console.log(n)}async function C(n){n.length>0&&(console.error(" usage: sootsim runtime notes"),process.exit(1));let e=a();e&&console.log(` active runtime: v${e}`),console.log(` release notes: ${$}`)}function E(n){let e={},o=[];for(let t=0;t<n.length;t++){let s=n[t];if(s==="--channel"&&t+1<n.length){e.channel=n[t+1],t++;continue}if(s.startsWith("--channel=")){e.channel=s.slice(10);continue}if(s==="--force"){e.force=!0;continue}if(s==="--set-active=false"||s==="--no-set-active"){e.setActive=!1;continue}o.push(s)}return{version:o[0]??null,flags:e}}function k(n){return n instanceof Error?n.message:String(n)}export{P as a};
27
+ `)}async function D(n,e){let{version:o,flags:t}=E(n),s=t.channel??e.channel??"stable",l=t.force===!0,c=t.setActive!==!1;m(),console.log("sootsim runtime install"),console.log(` cdn: ${w()}`);try{let i=await R({version:o,channel:s,force:l,setActive:c});console.log(` version: ${i.version} (channel: ${i.channel})`),i.installed?console.log(` installed ${i.version}`):console.log(` already installed at ${i.runtimeDir}`),c&&await I(i.version)}catch(i){console.error(` ${k(i)}`),process.exit(1)}}async function I(n){h(n),console.log(` active: ${n}`),await S(n)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${n})`)}async function S(n){let{isDaemonLockfileFresh:e,readDaemonLockfile:o}=await import("./home-paths-K4347S7C.js"),t=o();if(!e(t))return!1;let s=d();return new Promise(l=>{let c=!1,i=!1,u=x=>{c||(c=!0,l(x))},r=new A(`ws://127.0.0.1:${s}`,{handshakeTimeout:800}),g=setTimeout(()=>{try{r.close()}catch{}u(i)},1500);r.on("open",()=>{try{r.send(JSON.stringify({type:"runtime:use",version:n,id:0})),i=!0}catch{}setTimeout(()=>{try{r.close()}catch{}},100)}),r.on("close",()=>{clearTimeout(g),u(i)}),r.on("error",()=>{clearTimeout(g),u(!1)})})}async function N(n){m();let e=f(),o=a();if(console.log("installed:"),e.length===0)console.log(" (none)");else for(let t of e)console.log(` ${t===o?"*":" "} ${t}`);try{let t=await y();console.log("available (latest per channel):");for(let[s,l]of Object.entries(t.channels))console.log(` ${s.padEnd(8)} ${l.latest}`)}catch(t){console.log(`available: (could not fetch manifest: ${k(t)})`)}}async function T(n){let e=n[0];e||(console.error(" usage: sootsim runtime use <version>"),process.exit(1));let o=f();o.includes(e)||(console.error(` version ${e} is not installed`),console.error(` installed: ${o.join(", ")||"(none)"}`),console.error(` run \`sootsim runtime install ${e}\` first`),process.exit(1)),await I(e)}async function L(n){let e=n[0];e||(console.error(" usage: sootsim runtime remove <version>"),process.exit(1)),a()===e&&(console.error(` cannot remove active runtime ${e}`),console.error(" switch with `sootsim runtime use <other>` first, or install another version"),process.exit(1));let t=v(e);if(!b.existsSync(t)){console.error(` ${e} is not installed`);return}b.rmSync(t,{recursive:!0,force:!0}),console.log(` removed ${e}`)}async function _(){let n=a();if(!n){console.log(" no active runtime");return}console.log(n)}async function C(n){n.length>0&&(console.error(" usage: sootsim runtime notes"),process.exit(1));let e=a();e&&console.log(` active runtime: v${e}`),console.log(` release notes: ${$}`)}function E(n){let e={},o=[];for(let t=0;t<n.length;t++){let s=n[t];if(s==="--channel"&&t+1<n.length){e.channel=n[t+1],t++;continue}if(s.startsWith("--channel=")){e.channel=s.slice(10);continue}if(s==="--force"){e.force=!0;continue}if(s==="--set-active=false"||s==="--no-set-active"){e.setActive=!1;continue}o.push(s)}return{version:o[0]??null,flags:e}}function k(n){return n instanceof Error?n.message:String(n)}export{P as a};
@@ -0,0 +1,4 @@
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{existsSync as D,mkdirSync as O,readFileSync as g,rmSync as s,writeFileSync as P}from"fs";import{tmpdir as R}from"os";import{dirname as A,join as x,resolve as v}from"path";import{execFileSync as I}from"child_process";import{readFileSync as S}from"fs";import{createRequire as _}from"module";var o=null;function u(r){o||(o=N());try{return o(r)}catch{return null}}function N(){let r=Number(process.env.PPID);if(Number.isFinite(r)&&r>1&&r!==process.ppid)return()=>r;if(process.platform==="linux")return b();if(process.platform==="darwin"){let n=T();return n||C()}return()=>null}function b(){return r=>{try{let n=S(`/proc/${r}/stat`,"utf8"),t=n.lastIndexOf(")");if(t<0)return null;let i=n.slice(t+1).trim().split(/\s+/),e=Number(i[1]);return Number.isFinite(e)&&e>0?e:null}catch{return null}}}var y=3,d=216,E=16;function T(){if(!process.versions?.bun)return null;try{let r=_(import.meta.url),{dlopen:n,FFIType:t}=r("bun:ffi"),i=n("/usr/lib/libproc.dylib",{proc_pidinfo:{args:[t.i32,t.i32,t.u64,t.ptr,t.i32],returns:t.i32}}),e=Buffer.alloc(d);return a=>{if(Number(i.symbols.proc_pidinfo(a,y,0n,e,d))<=0)return null;let p=e.readUInt32LE(E);return p>0?p:null}}catch{return null}}function C(){return r=>{try{let t=I("lsof",["-R","-p",String(r),"-d","cwd","-a"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(`
3
+ `)[1];if(!t)return null;let i=t.trim().split(/\s+/),e=Number(i[2]);return Number.isFinite(e)&&e>1?e:null}catch{return null}}}var c=1,f="SOOTSIM_CLI_CURRENT_SIM_PATH",F=["SOOTSIM_CLI_IDENTITY","AGENTBUS_SESSION","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","TERM_SESSION_ID","ITERM_SESSION_ID","TMUX_PANE","STY","KITTY_WINDOW_ID","WEZTERM_PANE","ALACRITTY_WINDOW_ID","WINDOWID","VSCODE_INJECTION"];function m(r,n=20){let t=u(r);if(!t||t<=1)return null;for(let i=0;i<n;i++){let e=u(t);if(!e||e<=1)return t;t=e}return t}function k(){for(let n of F){let t=process.env[n];if(t&&t.trim())return{key:`${n}:${t.trim()}`,source:n,stable:!0}}let r=m(process.ppid);return r&&r>1?{key:`gppid-${r}`,source:"grand-ppid",stable:!0}:{key:`pid-${process.ppid}`,source:"ppid",stable:!1}}function L(){return k().key}function J(){return m(process.ppid)}function l(){if(process.env[f])return v(process.env[f]);let r=L();return x(R(),`sootsim-current-sim-${r}.json`)}function h(){let r=l();if(!D(r))return null;try{let n=JSON.parse(g(r,"utf8"));return n.version!==c||typeof n.simId!="string"||!n.simId.trim()||typeof n.updatedAt!="string"?(s(r,{force:!0}),null):{version:c,simId:n.simId.trim(),updatedAt:n.updatedAt}}catch{return s(r,{force:!0}),null}}function j(){return h()?.simId||null}function K(r){let n=r.trim();if(!n)return;let t=l();O(A(t),{recursive:!0}),P(t,JSON.stringify({version:c,simId:n,updatedAt:new Date().toISOString()},null,2)+`
4
+ `)}function X(){s(l(),{force:!0})}export{k as a,L as b,J as c,j as d,K as e,X as f};
@@ -1,8 +1,8 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as F,b as Q,c as Y,d as ye,e as Se}from"./chunk-KSF72FPP.js";import{m as N}from"./chunk-H2J4Z7LY.js";import{m as ge,o as we}from"./chunk-YMBQBKKA.js";import{g as te}from"./chunk-4UATZVHM.js";import{a as U,b as Z}from"./chunk-NPZPBSZD.js";import{c as ve}from"./chunk-VW643HG5.js";import{a as xe,b as ke}from"./chunk-2J67UJXT.js";import{a as $e,b as X,c as Ie}from"./chunk-RCPMRHTK.js";import{b as be,c as I,d as y,e as x}from"./chunk-OMJ2DTQJ.js";import{d as ee}from"./chunk-HWJ52K4J.js";import{a as he}from"./chunk-3G5EE3ST.js";import{d as M,e as b,f as T}from"./chunk-RAESCYIA.js";import{D as fe,I as A,K as C,l as pe}from"./chunk-3SUIAUIY.js";import{spawn as Oe}from"node:child_process";import R from"node:fs";import Ye from"node:os";import k from"node:path";import{WebSocket as Xe}from"ws";function We(e){return e.replace(/^\[|\]$/g,"").toLowerCase()}function H(e){let t=We(e);return t==="localhost"||t.endsWith(".localhost")||t==="0.0.0.0"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t)}function Pe(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function je(e,t){return e?.includes("/one/metro-entry.bundle")?"one":typeof t=="string"&&t?"expo":"unknown"}function Me(e,t,o){return`${e}//${t}:${o}`}function ze(e){if(typeof window>"u")return!1;try{let t=new URL(e);return H(t.hostname)&&H(window.location.hostname)&&t.origin!==window.location.origin}catch{return!1}}async function Ce(e,t){let o={...t,cache:t?.cache??"no-store"};return ze(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,o):fetch(e,o)}function qe(e){return e==="https:"?443:80}function Ve(e){let t=e.pathname||"/";return(t==="/"||t==="")&&!e.search&&!e.hash}async function Ge(e){try{let t=await fetch("/__server-scan",{cache:"no-store"});if(!t.ok||!(t.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let o=await t.json();if(!Array.isArray(o))return null;let n=o.find(r=>!!r&&typeof r=="object"&&r.port===e&&typeof r.bundleUrl=="string");return n?{bundleUrl:Y(n.bundleUrl),port:e,framework:typeof n.framework=="string"?n.framework:"unknown",projectName:typeof n.projectName=="string"?n.projectName:void 0}:null}catch{return null}}async function Te(e,t){let o=e.replace(/\/+$/,"");try{if(H(new URL(o).hostname)){let n=await Ge(t);if(n)return n}}catch{}try{let n=await Ce(`${o}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),s=r?.extra?.expoClient||r?.extra||{},i=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(i||s.name)return{bundleUrl:Y(i||`${o}${Q}`),port:t,framework:je(i,s.sdkVersion),projectName:s.name}}}catch{}try{let n=await Ce(`${o}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${o}${Q}`,port:t,framework:"metro"}}catch{}return null}async function Je(e){return Te(Me("http:","localhost",e),e)}async function Ue(e){let t=e.trim();if(/^\d+$/.test(t)){let a=parseInt(t,10),l=await Je(a);if(l)return l;throw Pe(`localhost:${a}`)}let o=t.startsWith("http")?t:`http://${t}`,n;try{n=new URL(o)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",s=n.port?parseInt(n.port,10):qe(r),i=Me(r,n.hostname,s);if(Ve(n)){let a=await Te(i,s);if(a)return a;throw Pe(i)}return{bundleUrl:n.toString(),port:s,framework:"unknown"}}function Ht(){console.error(" no sootsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" sootsim install-desktop"),console.error(""),console.error(" or run setup to install the background daemon:"),console.error(" sootsim setup"),console.error("")}function Ee(e){let t=U();if(console.log(` note: no sootsim bridge detected on port ${e}`),t){console.log(" launch the installed companion with:"),console.log(" sootsim electron");return}console.log(""),console.log(" run `sootsim setup` to install the background daemon,"),console.log(" or run `sootsim serve` in another shell for a foreground bridge.")}function Qe(e){console.error(""),console.error(` no sim is connected to the sootsim bridge on port ${e}.`),console.error(""),console.error(" start your app dev server, then open it in sootsim:"),console.error(" npx expo start --localhost --port 8081"),console.error(" sootsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" sootsim describe")}async function Kt(e,t,o){let n=[];try{n=await e.listSims()}catch{}if(console.error(""),n.length===0){Qe(t);return}console.error(` no sim with id "${o}" is connected to the bridge on port ${t}.`),console.error(""),console.error(" connected sims:");for(let r of n){let s=[r.isPrimary?"primary":null,r.readyState,r.userVisible===!1?"hidden":r.userVisible===!0?"visible":null,r.userFocused?"focused":null].filter(Boolean).join(", ");console.error(` ${r.id} (${s})`)}console.error(""),console.error(" pass a valid --sim id, or run `sootsim list` to see all sessions.")}var Ze=12e4,Re=500,et=5e3,_e=1e4,tt={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function v(e){return new Promise(t=>setTimeout(t,e))}function Be(e){let t=process.env[e]?.trim();if(!t)return null;let o=Number(t);return Number.isInteger(o)&&o>0?o:null}function ot(){let e=Be("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??Be("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??Ze;return{timeoutMs:e,hostTimeoutMs:e+et,intervalMs:Re,attempts:Math.max(1,Math.ceil(e/Re))}}function nt(e){return e==="chromium"||e==="electron"||e==="playwright"||e==="system"}function rt(e,t){return e.includes("--headless")?!0:e.includes("--headed")?!1:t==="playwright"&&process.platform==="linux"&&!process.env.DISPLAY&&!process.env.WAYLAND_DISPLAY?(console.error(" no display detected \u2192 running playwright headless (override with --headed)"),!0):!1}function j(e){return e.trim()}async function st(e){if(await K(e,250))return e;let t=A();if(t&&C(t)&&await K(t.bridgePort,500))return t.bridgePort;if(t&&C(t))throw new Error(`sootsim bridge lockfile is fresh (port ${t.bridgePort}) but the bridge is not reachable. run \`sootsim daemon restart\` or \`sootsim daemon uninstall\`.`);await it();let o=at(["serve","--quiet","--port",String(e)]),n=null;o.once("exit",(s,i)=>{n=String(s??i??"unknown")}),o.unref();let r=Date.now()+_e;for(;Date.now()<r;){let s=A();if(s&&C(s)&&await K(s.bridgePort,250))return console.error(` started local bridge on port ${s.bridgePort}; run \`sootsim setup\` to install the background daemon`),s.bridgePort;if(await K(e,250))return console.error(` started local bridge on port ${e}; run \`sootsim setup\` to install the background daemon`),e;if(n)throw new Error(`sootsim bridge exited before becoming ready (exit ${n})`);await v(150)}throw new Error(`sootsim bridge did not start within ${Math.round(_e/1e3)}s`)}async function it(){let e=fe();if(e&&R.existsSync(pe(e)))return;console.error(" installing sootsim engine runtime...");let{runRuntime:t}=await import("./runtime-CUNVH66R.js");await t(["install"],{})}function at(e){let t=process.argv[1];return t&&R.existsSync(t)?Oe(process.execPath,[t,...e],{detached:!0,stdio:"ignore",env:process.env}):Oe("sootsim",e,{detached:!0,stdio:"ignore",env:process.env})}function K(e,t){return new Promise(o=>{let n=new Xe(`ws://127.0.0.1:${e}`,{handshakeTimeout:t}),r=!1,s=i=>{if(!r){r=!0;try{n.close()}catch{}o(i)}};n.once("open",()=>s(!0)),n.once("error",()=>s(!1)),setTimeout(()=>s(!1),t)})}function re(e){try{let t=new URL(e),o=t.pathname.replace(/\/+$/,"")||"/";return t.searchParams.has("open")||t.searchParams.has("port")||t.searchParams.has("bundle")||t.searchParams.has("demo")||t.pathname.includes("/sootsim/index.html")||o==="/sootsim"||t.pathname==="/__soot"||t.pathname==="/__soot/"||o==="/rn"||/^\/rn\/[^/]+$/i.test(o)||/^\/app\/[^/]+$/i.test(o)||o==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(o)||/^\/__soot\/app\/[^/]+$/i.test(o)}catch{return!1}}function lt(e){try{let t=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(t)||/^\/build\/.+/.test(t)}catch{return!1}}async function po(e){let t=j(e);return(await Ne(t)).bundleUrl}function ct(e){try{let t=new URL(e.startsWith("http")?e:`http://${e}`),o=t.pathname||"/";if(o!=="/"&&o!==""||t.search||t.hash||!/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(t.hostname))return null;let n=t.port?Number(t.port):t.protocol==="https:"?443:80;return Number.isFinite(n)&&n>0?n:null}catch{return null}}async function Ne(e){let t=j(e),o=/^\d+$/.test(t)?Number(t):ct(t);if(o&&o>0){let n=await Se(o);if(n)return{bundleUrl:n.bundleUrl,port:n.port,framework:n.framework,projectName:n.projectName}}return Ue(t)}function ie(e){let t=e.replace(/\/+$/,"")||"/";return t==="/__soot"||t.startsWith("/__soot/")?"/__soot":""}function dt(e,t){let o=j(e),n=new URL(t),r=ie(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(o)?n.pathname=`${r}/rn/${o}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",o)),n.toString()}function mt(e){let t=j(e);return/^\d+$/.test(t)||/^https?:\/\//i.test(t)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(t)}async function ut(e,t,o={}){let n=await Ne(e),r=new URL(t),s=ie(r.pathname);r.pathname=`${s}/rn`,r.searchParams.delete("open"),r.searchParams.delete("port"),r.searchParams.delete("demo"),r.searchParams.delete("app");let i=o.hot===void 0?n.bundleUrl:ye(n.bundleUrl,o.hot);return r.searchParams.set("bundle",i),r.toString()}function pt(e){return e.startsWith("~/")?k.join(Ye.homedir(),e.slice(2)):k.isAbsolute(e)?e:k.resolve(process.cwd(),e)}function ft(e){let t={},o={};for(let r=0;r<e.length;r++){if(e[r]==="--replace"){let s=e[r+1];s||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let i=s.indexOf("=");(i<=0||i===s.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let a=s.slice(0,i).trim(),l=pt(s.slice(i+1).trim());R.existsSync(l)||(console.error(` sootsim open: replacement file not found: ${l}`),process.exit(1)),t[a]={file:l},r++;continue}if(e[r]==="--remap"){let s=e[r+1],i=s?s.indexOf("="):-1;(!s||i<=0||i===s.length-1)&&(console.error(" sootsim open: --remap expects <host:port>=<host:port>"),process.exit(1)),o[s.slice(0,i).trim()]=s.slice(i+1).trim(),r++;continue}}let n={};return Object.keys(t).length>0&&(n.modules=t),Object.keys(o).length>0&&(n.network={remap:o}),n.modules||n.network?n:void 0}function Fe(){let e=A();return C(e)&&e.runtimePort>0?`http://localhost:${e.runtimePort}/`:he}async function ht(e){try{let t=new URL(e),o=t.searchParams.get("bundle")||"";if(!o)return e;let n=process.env.SOOT_REPO_DIR||await X(o)||void 0,r=$e({bundleUrl:o,repoDir:n});if(r.length===0)return e;let s=await gt(r);return s.length===0?e:(t.searchParams.set("appFonts",Ie(s)),t.toString())}catch{return e}}async function gt(e){let t=await Promise.all(e.map(async n=>{let r=new AbortController,s=setTimeout(()=>r.abort(),1500);try{let i=await fetch(n.url,{method:"HEAD",signal:r.signal});return i.status>=200&&i.status<400?n:null}catch{return null}finally{clearTimeout(s)}})),o=[];for(let n of t)n!==null&&o.push(n);return o}async function wt(e,t,o={}){if(!e)return new URL(t).toString();if(re(e))return new URL(e).toString();let n=tt[e.toLowerCase()];if(n){let r=new URL(t),s=ie(r.pathname);return r.pathname=`${s}${n}`,r.toString()}return mt(e)?ut(e,t,o):dt(e,t)}async function bt(e){try{let t=new URL(e),o=t.searchParams.get("bundle")||"";if(!o)return e;let n=process.env.SOOT_REPO_DIR||await X(o)||void 0,r=xe({bundleUrl:o,repoDir:n});return!r||r.imageUrl&&!await yt(r.imageUrl)?e:(t.searchParams.set("appSplash",ke(r)),t.toString())}catch{return e}}async function yt(e){let t=new AbortController,o=setTimeout(()=>t.abort(),1500);try{let n=await fetch(e,{method:"HEAD",signal:t.signal});return n.status>=200&&n.status<400}catch{return!1}finally{clearTimeout(o)}}async function W(e,t=Fe(),o={}){let n=await wt(e,t,o);return bt(await ht(n))}function De(e,t){let o=e?.url||e?.origin||t;try{let n=new URL(o);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.searchParams.delete("appFonts"),n.searchParams.delete("appSplash"),n.toString()}catch{return t}}async function St(e,t,o,n={}){let r=new URL(await W(e,t,n));return r.searchParams.set("inspectOpen",o),r.toString()}async function vt(e,t,o,n={}){let r=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<r;a++){let l=y(e,{commandTimeoutMs:t,simId:o,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>i)return{bridge:l,count:c}}catch{}l.close(),await v(s)}return null}function $t(e){if(!e)return null;try{let t=new URL(e);if(t.searchParams.has("bundle")){let o=t.searchParams.get("bundle")||"";try{let n=new URL(o),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return t.searchParams.has("port")?`connect :${t.searchParams.get("port")||""}`:t.searchParams.has("open")?`connect ${t.searchParams.get("open")||""}`:t.searchParams.has("demo")?`demo ${t.searchParams.get("demo")||"default"}`:t.pathname.includes("/sootsim/index.html")||t.pathname==="/sootsim/"||t.pathname==="/sootsim"?"embedded sootsim":null}catch{return null}}function It(e){let t=e.indexOf(":");if(t<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let o=e.slice(0,t),n=e.slice(t+1),r=n.length>12?`${n.slice(0,8)}\u2026`:n;return o==="CLAUDE_CODE_SESSION_ID"||o==="CODEX_THREAD_ID"?`agent ${r}`:`${o} ${r}`}function xt(e,t){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as F,b as Q,c as Y,d as ye,e as Se}from"./chunk-SU3JJ7ER.js";import{m as N}from"./chunk-A3VHHWLU.js";import{m as ge,o as we}from"./chunk-D2BBJUEY.js";import{g as te}from"./chunk-JHYLPDCC.js";import{a as E,b as Z}from"./chunk-PAU64XFG.js";import{c as ve}from"./chunk-UJN3FMEX.js";import{a as xe,b as ke}from"./chunk-NYGESF6F.js";import{a as $e,b as X,c as Ie}from"./chunk-CH3MWM5W.js";import{b as be,c as I,d as y,e as x}from"./chunk-65ZBQDQM.js";import{d as ee}from"./chunk-JXO6UPGI.js";import{a as he}from"./chunk-YU6CNUJD.js";import{d as M,e as b,f as T}from"./chunk-4INGTBO7.js";import{D as fe,I as A,K as C,l as pe}from"./chunk-IBSEFPPL.js";import{spawn as Oe}from"node:child_process";import R from"node:fs";import Ye from"node:os";import k from"node:path";import{WebSocket as Xe}from"ws";function We(e){return e.replace(/^\[|\]$/g,"").toLowerCase()}function H(e){let t=We(e);return t==="localhost"||t.endsWith(".localhost")||t==="0.0.0.0"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t)}function Pe(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function je(e,t){return e?.includes("/one/metro-entry.bundle")?"one":typeof t=="string"&&t?"expo":"unknown"}function Me(e,t,o){return`${e}//${t}:${o}`}function ze(e){if(typeof window>"u")return!1;try{let t=new URL(e);return H(t.hostname)&&H(window.location.hostname)&&t.origin!==window.location.origin}catch{return!1}}async function Ce(e,t){let o={...t,cache:t?.cache??"no-store"};return ze(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,o):fetch(e,o)}function qe(e){return e==="https:"?443:80}function Ge(e){let t=e.pathname||"/";return(t==="/"||t==="")&&!e.search&&!e.hash}async function Ve(e){try{let t=await fetch("/__server-scan",{cache:"no-store"});if(!t.ok||!(t.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let o=await t.json();if(!Array.isArray(o))return null;let n=o.find(r=>!!r&&typeof r=="object"&&r.port===e&&typeof r.bundleUrl=="string");return n?{bundleUrl:Y(n.bundleUrl),port:e,framework:typeof n.framework=="string"?n.framework:"unknown",projectName:typeof n.projectName=="string"?n.projectName:void 0}:null}catch{return null}}async function Te(e,t){let o=e.replace(/\/+$/,"");try{if(H(new URL(o).hostname)){let n=await Ve(t);if(n)return n}}catch{}try{let n=await Ce(`${o}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),s=r?.extra?.expoClient||r?.extra||{},i=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(i||s.name)return{bundleUrl:Y(i||`${o}${Q}`),port:t,framework:je(i,s.sdkVersion),projectName:s.name}}}catch{}try{let n=await Ce(`${o}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${o}${Q}`,port:t,framework:"metro"}}catch{}return null}async function Je(e){return Te(Me("http:","localhost",e),e)}async function Ee(e){let t=e.trim();if(/^\d+$/.test(t)){let a=parseInt(t,10),l=await Je(a);if(l)return l;throw Pe(`localhost:${a}`)}let o=t.startsWith("http")?t:`http://${t}`,n;try{n=new URL(o)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",s=n.port?parseInt(n.port,10):qe(r),i=Me(r,n.hostname,s);if(Ge(n)){let a=await Te(i,s);if(a)return a;throw Pe(i)}return{bundleUrl:n.toString(),port:s,framework:"unknown"}}function Ht(){console.error(" no sootsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" sootsim install-desktop"),console.error(""),console.error(" or run setup to install the background daemon:"),console.error(" sootsim setup"),console.error("")}function Ue(e){let t=E();if(console.log(` note: no sootsim bridge detected on port ${e}`),t){console.log(" launch the installed companion with:"),console.log(" sootsim electron");return}console.log(""),console.log(" run `sootsim setup` to install the background daemon,"),console.log(" or run `sootsim serve` in another shell for a foreground bridge.")}function Qe(e){console.error(""),console.error(` no sim is connected to the sootsim bridge on port ${e}.`),console.error(""),console.error(" start your app dev server, then open it in sootsim:"),console.error(" npx expo start --localhost --port 8081"),console.error(" sootsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" sootsim describe")}async function Kt(e,t,o){let n=[];try{n=await e.listSims()}catch{}if(console.error(""),n.length===0){Qe(t);return}console.error(` no sim with id "${o}" is connected to the bridge on port ${t}.`),console.error(""),console.error(" connected sims:");for(let r of n){let s=[r.isPrimary?"primary":null,r.readyState,r.userVisible===!1?"hidden":r.userVisible===!0?"visible":null,r.userFocused?"focused":null].filter(Boolean).join(", ");console.error(` ${r.id} (${s})`)}console.error(""),console.error(" pass a valid --sim id, or run `sootsim list` to see all sessions.")}var Ze=12e4,Re=500,et=5e3,_e=1e4,tt={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function v(e){return new Promise(t=>setTimeout(t,e))}function Be(e){let t=process.env[e]?.trim();if(!t)return null;let o=Number(t);return Number.isInteger(o)&&o>0?o:null}function ot(){let e=Be("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??Be("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??Ze;return{timeoutMs:e,hostTimeoutMs:e+et,intervalMs:Re,attempts:Math.max(1,Math.ceil(e/Re))}}function nt(e){return e==="chromium"||e==="electron"||e==="playwright"||e==="system"}function rt(e,t){return e.includes("--headless")?!0:e.includes("--headed")?!1:t==="playwright"&&process.platform==="linux"&&!process.env.DISPLAY&&!process.env.WAYLAND_DISPLAY?(console.error(" no display detected \u2192 running playwright headless (override with --headed)"),!0):!1}function j(e){return e.trim()}async function st(e){if(await K(e,250))return e;let t=A();if(t&&C(t)&&await K(t.bridgePort,500))return t.bridgePort;if(t&&C(t))throw new Error(`sootsim bridge lockfile is fresh (port ${t.bridgePort}) but the bridge is not reachable. run \`sootsim daemon restart\` or \`sootsim daemon uninstall\`.`);await it();let o=at(["serve","--quiet","--port",String(e)]),n=null;o.once("exit",(s,i)=>{n=String(s??i??"unknown")}),o.unref();let r=Date.now()+_e;for(;Date.now()<r;){let s=A();if(s&&C(s)&&await K(s.bridgePort,250))return console.error(` started local bridge on port ${s.bridgePort}; run \`sootsim setup\` to install the background daemon`),s.bridgePort;if(await K(e,250))return console.error(` started local bridge on port ${e}; run \`sootsim setup\` to install the background daemon`),e;if(n)throw new Error(`sootsim bridge exited before becoming ready (exit ${n})`);await v(150)}throw new Error(`sootsim bridge did not start within ${Math.round(_e/1e3)}s`)}async function it(){let e=fe();if(e&&R.existsSync(pe(e)))return;console.error(" installing sootsim engine runtime...");let{runRuntime:t}=await import("./runtime-R2PRKIZM.js");await t(["install"],{})}function at(e){let t=process.argv[1];return t&&R.existsSync(t)?Oe(process.execPath,[t,...e],{detached:!0,stdio:"ignore",env:process.env}):Oe("sootsim",e,{detached:!0,stdio:"ignore",env:process.env})}function K(e,t){return new Promise(o=>{let n=new Xe(`ws://127.0.0.1:${e}`,{handshakeTimeout:t}),r=!1,s=i=>{if(!r){r=!0;try{n.close()}catch{}o(i)}};n.once("open",()=>s(!0)),n.once("error",()=>s(!1)),setTimeout(()=>s(!1),t)})}function re(e){try{let t=new URL(e),o=t.pathname.replace(/\/+$/,"")||"/";return t.searchParams.has("open")||t.searchParams.has("port")||t.searchParams.has("bundle")||t.searchParams.has("demo")||t.pathname.includes("/sootsim/index.html")||o==="/sootsim"||t.pathname==="/__soot"||t.pathname==="/__soot/"||o==="/rn"||/^\/rn\/[^/]+$/i.test(o)||/^\/app\/[^/]+$/i.test(o)||o==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(o)||/^\/__soot\/app\/[^/]+$/i.test(o)}catch{return!1}}function lt(e){try{let t=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(t)||/^\/build\/.+/.test(t)}catch{return!1}}async function po(e){let t=j(e);return(await Ne(t)).bundleUrl}function ct(e){try{let t=new URL(e.startsWith("http")?e:`http://${e}`),o=t.pathname||"/";if(o!=="/"&&o!==""||t.search||t.hash||!/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(t.hostname))return null;let n=t.port?Number(t.port):t.protocol==="https:"?443:80;return Number.isFinite(n)&&n>0?n:null}catch{return null}}async function Ne(e){let t=j(e),o=/^\d+$/.test(t)?Number(t):ct(t);if(o&&o>0){let n=await Se(o);if(n)return{bundleUrl:n.bundleUrl,port:n.port,framework:n.framework,projectName:n.projectName}}return Ee(t)}function ie(e){let t=e.replace(/\/+$/,"")||"/";return t==="/__soot"||t.startsWith("/__soot/")?"/__soot":""}function dt(e,t){let o=j(e),n=new URL(t),r=ie(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(o)?n.pathname=`${r}/rn/${o}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",o)),n.toString()}function mt(e){let t=j(e);return/^\d+$/.test(t)||/^https?:\/\//i.test(t)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(t)}async function ut(e,t,o={}){let n=await Ne(e),r=new URL(t),s=ie(r.pathname);r.pathname=`${s}/rn`,r.searchParams.delete("open"),r.searchParams.delete("port"),r.searchParams.delete("demo"),r.searchParams.delete("app");let i=o.hot===void 0?n.bundleUrl:ye(n.bundleUrl,o.hot);return r.searchParams.set("bundle",i),r.toString()}function pt(e){return e.startsWith("~/")?k.join(Ye.homedir(),e.slice(2)):k.isAbsolute(e)?e:k.resolve(process.cwd(),e)}function ft(e){let t={},o={};for(let r=0;r<e.length;r++){if(e[r]==="--replace"){let s=e[r+1];s||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let i=s.indexOf("=");(i<=0||i===s.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let a=s.slice(0,i).trim(),l=pt(s.slice(i+1).trim());R.existsSync(l)||(console.error(` sootsim open: replacement file not found: ${l}`),process.exit(1)),t[a]={file:l},r++;continue}if(e[r]==="--remap"){let s=e[r+1],i=s?s.indexOf("="):-1;(!s||i<=0||i===s.length-1)&&(console.error(" sootsim open: --remap expects <host:port>=<host:port>"),process.exit(1)),o[s.slice(0,i).trim()]=s.slice(i+1).trim(),r++;continue}}let n={};return Object.keys(t).length>0&&(n.modules=t),Object.keys(o).length>0&&(n.network={remap:o}),n.modules||n.network?n:void 0}function Fe(){let e=A();return C(e)&&e.runtimePort>0?`http://localhost:${e.runtimePort}/`:he}async function ht(e){try{let t=new URL(e),o=t.searchParams.get("bundle")||"";if(!o)return e;let n=process.env.SOOT_REPO_DIR||await X(o)||void 0,r=$e({bundleUrl:o,repoDir:n});if(r.length===0)return e;let s=await gt(r);return s.length===0?e:(t.searchParams.set("appFonts",Ie(s)),t.toString())}catch{return e}}async function gt(e){let t=await Promise.all(e.map(async n=>{let r=new AbortController,s=setTimeout(()=>r.abort(),1500);try{let i=await fetch(n.url,{method:"HEAD",signal:r.signal});return i.status>=200&&i.status<400?n:null}catch{return null}finally{clearTimeout(s)}})),o=[];for(let n of t)n!==null&&o.push(n);return o}async function wt(e,t,o={}){if(!e)return new URL(t).toString();if(re(e))return new URL(e).toString();let n=tt[e.toLowerCase()];if(n){let r=new URL(t),s=ie(r.pathname);return r.pathname=`${s}${n}`,r.toString()}return mt(e)?ut(e,t,o):dt(e,t)}async function bt(e){try{let t=new URL(e),o=t.searchParams.get("bundle")||"";if(!o)return e;let n=process.env.SOOT_REPO_DIR||await X(o)||void 0,r=xe({bundleUrl:o,repoDir:n});return!r||r.imageUrl&&!await yt(r.imageUrl)?e:(t.searchParams.set("appSplash",ke(r)),t.toString())}catch{return e}}async function yt(e){let t=new AbortController,o=setTimeout(()=>t.abort(),1500);try{let n=await fetch(e,{method:"HEAD",signal:t.signal});return n.status>=200&&n.status<400}catch{return!1}finally{clearTimeout(o)}}async function W(e,t=Fe(),o={}){let n=await wt(e,t,o);return bt(await ht(n))}function De(e,t){let o=e?.url||e?.origin||t;try{let n=new URL(o);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.searchParams.delete("appFonts"),n.searchParams.delete("appSplash"),n.toString()}catch{return t}}async function St(e,t,o,n={}){let r=new URL(await W(e,t,n));return r.searchParams.set("inspectOpen",o),r.toString()}async function vt(e,t,o,n={}){let r=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<r;a++){let l=y(e,{commandTimeoutMs:t,simId:o,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>i)return{bridge:l,count:c}}catch{}l.close(),await v(s)}return null}function $t(e){if(!e)return null;try{let t=new URL(e);if(t.searchParams.has("bundle")){let o=t.searchParams.get("bundle")||"";try{let n=new URL(o),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return t.searchParams.has("port")?`connect :${t.searchParams.get("port")||""}`:t.searchParams.has("open")?`connect ${t.searchParams.get("open")||""}`:t.searchParams.has("demo")?`demo ${t.searchParams.get("demo")||"default"}`:t.pathname.includes("/sootsim/index.html")||t.pathname==="/sootsim/"||t.pathname==="/sootsim"?"embedded sootsim":null}catch{return null}}function It(e){let t=e.indexOf(":");if(t<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let o=e.slice(0,t),n=e.slice(t+1),r=n.length>12?`${n.slice(0,8)}\u2026`:n;return o==="AGENTBUS_SESSION"||o==="CLAUDE_CODE_SESSION_ID"||o==="CODEX_THREAD_ID"?`agent ${r}`:`${o} ${r}`}function xt(e,t){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
3
3
  `);for(let o of e){let n=o.lockedBy&&o.lockExpiresAt?`locked by ${It(o.lockedBy)} (${Math.max(0,Math.round((o.lockExpiresAt-Date.now())/1e3))}s)`:"",r=[o.isPrimary?"primary":"",o.id===t?"selected":"",o.readyState,o.userVisible===!1?"hidden":o.userVisible===!0?"visible":"",o.attachedCliCount&&o.attachedCliCount>0?"in use":"",o.userFocused?"focused":"",n].filter(Boolean);console.log(` ${o.id}${r.length?` [${r.join(", ")}]`:""}`);let s=$t(o.url);if(s)console.log(` loaded: ${s}`);else if(o.url){let a=o.url.length>96?`${o.url.slice(0,93)}\u2026`:o.url;console.log(` url: ${a}`)}else o.origin&&console.log(` origin: ${o.origin}`);let i=kt(o);i&&console.log(` engine: ${i}`),o.title&&console.log(` title: ${o.title}`),o.visibilityState&&o.visibilityState!=="visible"&&console.log(` visibility: ${o.visibilityState}`),console.log(` connected: ${Le(Date.now()-o.connectedAt)}`),o.lastActiveAt&&o.lastActiveAt>0&&console.log(` last active: ${Le(Date.now()-o.lastActiveAt)}`)}}function kt(e){let t=e.url||e.origin||"";if(!t)return null;try{let o=new URL(t).port;return o==="5173"?"dev \u2014 local source (:5173)":o==="3000"?"soot app embedded (:3000)":`runtime \u2014 published engine (:${o||"?"})`}catch{return null}}function Le(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}async function oe(e,t,o,n={}){let r=n.attempts??30,s=n.intervalMs??500;for(let i=0;i<r;i++){let a=y(e,{commandTimeoutMs:t});try{let c=(await a.listSims()).find(o);if(c)return c}catch{}finally{a.close()}await v(s)}return null}async function Pt(e,t,o,n,r={}){let s=r.attempts??30,i=r.intervalMs??500,a=!!n&&Number.isInteger(n)&&n>1,l=()=>a&&n!==void 0&&!se(n);for(let c=0;c<s;c++){if(l())return{kind:"host-exit"};let d=y(e,{commandTimeoutMs:t});try{let h=(await d.listSims()).find(o);if(h)return l()?{kind:"host-exit"}:{kind:"match",sim:h}}catch{}finally{d.close()}if(l())return{kind:"host-exit"};await v(i)}return{kind:"timeout"}}async function Ct(e,t,o,n={}){let r=n.attempts??20,s=n.intervalMs??250;for(let i=0;i<r;i++){let a=y(e,{commandTimeoutMs:t});try{let c=(await a.listSims()).find(d=>d.id===o);if(!c||c.readyState!=="open")return!0}catch{return!0}finally{a.close()}await v(s)}return!1}function Mt(e){let t=e.meta;if(!t||t.sootsimHostDriver!=="playwright")return null;let o=Number(t.sootsimHostPid);return!Number.isInteger(o)||o<=1||o===process.pid?null:o}function Tt(e){if(!e.connectAckFile)return!1;try{return R.writeFileSync(e.connectAckFile,`${JSON.stringify({connectedAt:Date.now(),pid:e.pid??null})}
4
4
  `,{flag:"w"}),!0}catch{return!1}}function Ae(e){if(e.diagnosticLogPath)try{let t=R.readFileSync(e.diagnosticLogPath,"utf8").trim();if(!t){console.error(` ${k.basename(e.diagnosticLogPath)} was empty`);return}let o=t.length>4e3?`\u2026
5
- ${t.slice(-4e3)}`:t;console.error(` ${k.basename(e.diagnosticLogPath)}:`),console.error(o)}catch(t){let o=t instanceof Error?t.message:String(t);console.error(` failed to read ${k.basename(e.diagnosticLogPath)}: ${o}`)}}function se(e){try{return process.kill(e,0),!0}catch(t){return t?.code==="EPERM"}}async function Ut(e,t=2500){let o=Date.now()+t;for(;Date.now()<o;){if(!se(e))return!0;await v(100)}return!se(e)}async function ne(e,t){let o=new Set(t),n=new Set;for(let r of e){if(!o.has(r.id))continue;let s=Mt(r);s&&n.add(s)}for(let r of n){try{process.kill(r,"SIGTERM")}catch{}if(await Ut(r)){console.log(` closed playwright host process ${r}`);continue}try{process.kill(r,"SIGKILL"),console.log(` force-closed playwright host process ${r}`)}catch{}}}function z(e,t){if(t){let r=t.trim(),s=e.find(i=>i.id===r);if(!s)throw new Error(`no sim connected with id ${r}`);return s}let o=e.find(r=>r.isPrimary&&r.readyState==="open");if(o)return o;let n=e.find(r=>r.readyState==="open");if(n)return n;throw new Error("no sim connected")}function E(e,t,o){console.log(` ${o==="current sim"?"loaded":"opened"}: ${e} [${o}]`),console.log(` current sim: ${t.id}`),console.log(JSON.stringify({simId:t.id,url:t.url},null,2))}async function O(e,t,o){if(o.includes("--no-describe"))return;let n=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await Et(e,t,{stableMs:150,maxMs:400});let r=y(e,{commandTimeoutMs:3e3,simId:t,cliLabel:"open --describe",simIdSource:"flag"});try{let s=null;try{s=await r.send({type:"evaluate",code:ge})}catch{}if(s&&!(s.flag===!0&&!s.loadingText&&we(s))){let d=s.loadingText?`still showing "${s.loadingText}"`:s.flag!==!0?"guest ready event has not fired":s.targets<=0?"no visible app content is inspectable yet":"app tree is still stabilizing";console.log(` app still loading: ${d} (nodes: ${s.nodes}, targets: ${s.targets})`),console.log(" before interacting, run: sootsim wait ready --max-ms 120000")}let a=`(async () => {
5
+ ${t.slice(-4e3)}`:t;console.error(` ${k.basename(e.diagnosticLogPath)}:`),console.error(o)}catch(t){let o=t instanceof Error?t.message:String(t);console.error(` failed to read ${k.basename(e.diagnosticLogPath)}: ${o}`)}}function se(e){try{return process.kill(e,0),!0}catch(t){return t?.code==="EPERM"}}async function Et(e,t=2500){let o=Date.now()+t;for(;Date.now()<o;){if(!se(e))return!0;await v(100)}return!se(e)}async function ne(e,t){let o=new Set(t),n=new Set;for(let r of e){if(!o.has(r.id))continue;let s=Mt(r);s&&n.add(s)}for(let r of n){try{process.kill(r,"SIGTERM")}catch{}if(await Et(r)){console.log(` closed playwright host process ${r}`);continue}try{process.kill(r,"SIGKILL"),console.log(` force-closed playwright host process ${r}`)}catch{}}}function z(e,t){if(t){let r=t.trim(),s=e.find(i=>i.id===r);if(!s)throw new Error(`no sim connected with id ${r}`);return s}let o=e.find(r=>r.isPrimary&&r.readyState==="open");if(o)return o;let n=e.find(r=>r.readyState==="open");if(n)return n;throw new Error("no sim connected")}function U(e,t,o){console.log(` ${o==="current sim"?"loaded":"opened"}: ${e} [${o}]`),console.log(` current sim: ${t.id}`),console.log(JSON.stringify({simId:t.id,url:t.url},null,2))}async function O(e,t,o){if(o.includes("--no-describe"))return;let n=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await Ut(e,t,{stableMs:150,maxMs:400});let r=y(e,{commandTimeoutMs:3e3,simId:t,cliLabel:"open --describe",simIdSource:"flag"});try{let s=null;try{s=await r.send({type:"evaluate",code:ge})}catch{}if(s&&!(s.flag===!0&&!s.loadingText&&we(s))){let d=s.loadingText?`still showing "${s.loadingText}"`:s.flag!==!0?"guest ready event has not fired":s.targets<=0?"no visible app content is inspectable yet":"app tree is still stabilizing";console.log(` app still loading: ${d} (nodes: ${s.nodes}, targets: ${s.targets})`),console.log(" before interacting, run: sootsim wait ready --max-ms 120000")}let a=`(async () => {
6
6
  const t = window.__sootsimTest
7
7
  const ms = window.SootSim?.bridges?.mainShell
8
8
  if (!t) return null
@@ -10,4 +10,4 @@ ${t.slice(-4e3)}`:t;console.error(` ${k.basename(e.diagnosticLogPath)}:`),conso
10
10
  try { shell = ms?.getState ? await ms.getState() : null } catch {}
11
11
  const tree = await t.dumpTree(12, ${JSON.stringify({describe:!0,verbose:!1,filter:""})})
12
12
  return { tree, shell }
13
- })()`,l=await r.send({type:"evaluate",code:a});if(!l?.tree)return;if(console.log(""),l.shell?.state){let c=[`state=${l.shell.state}`,l.shell.activeApp?`app=${l.shell.activeApp}`:null].filter(Boolean);console.log(` shell: ${c.join(" ")}`)}console.log(l.tree)}finally{r.close()}}catch{}finally{n===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=n}}async function Et(e,t,o){let n=Date.now()+o.maxMs,r="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",s=y(e,{commandTimeoutMs:2e3,simId:t,simIdSource:"flag"});try{let i=-1,a=0;for(;Date.now()<n;){let l=-1;try{let c=await s.send({type:"evaluate",code:r});typeof c=="number"&&(l=c)}catch{}if(l>=0&&l===i){if(Date.now()-a>=o.stableMs)return}else i=l,a=Date.now();await v(50)}}finally{s.close()}}async function fo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs}),n=x(o);try{let r=await n.listSims();xt(r,o.simId)}finally{n.close()}}async function ho(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--new","--headless","--headed","--ephemeral","--hot","--no-hmr"],stripValueFlags:["--base-url","--replace","--driver","--profile","--cdp-port"]}),n=e.find((u,p)=>e[p-1]==="--profile"),r=e.includes("--ephemeral"),s=e.find((u,p)=>e[p-1]==="--cdp-port"),i=s?Number(s):void 0;s&&(!Number.isFinite(i)||i<=0)&&(console.error(` sootsim open: --cdp-port must be a positive port number, got "${s}"`),process.exit(1)),n&&r&&(console.error(" sootsim open: --profile cannot be combined with --ephemeral"),process.exit(1));let a=n?ve(n).id:void 0,l=!!a||r,c=e.includes("--new")||l,d=ft(e);c&&o.simIdSource==="flag"&&(console.error(" sootsim open: --new, --profile, and --ephemeral cannot be combined with --sim"),process.exit(1));let m=o.positional[0]||"";if(lt(m)){let u=(()=>{try{return/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(new URL(m).hostname)}catch{return!1}})();console.log(" that\u2019s a SootSim preview/build link \u2014 a full player page, not a driveable sim."),console.log(" opening it in your browser for viewing\u2026");try{await ee(m,{background:!1})}catch(p){console.error(` could not launch a browser: ${p instanceof Error?p.message:String(p)}`),console.error(` open it yourself: ${m}`),process.exit(1)}console.log(u?" to drive it under the CLI, point `sootsim open` at the app\u2019s dev port instead (e.g. `sootsim open 8081`).":" the CLI can\u2019t drive a remote preview (the engine only attaches to the local bridge from localhost). to drive the app, run it locally and `sootsim open <port>`.");return}o.wsPort=await st(o.wsPort);let h=e.find((u,p)=>e[p-1]==="--driver")||"",q=rt(e,h);i&&h!=="playwright"&&(console.error(" sootsim open: --cdp-port is only honored by the playwright driver \u2014 add `--driver playwright`"),process.exit(1));let ae=e.includes("--hot"),le=e.includes("--no-hmr");ae&&le&&(console.error(" sootsim open: --hot and --no-hmr cannot be combined"),process.exit(1));let _={hot:ae?!0:le?!1:h!=="playwright"},P=e.find((u,p)=>e[p-1]==="--base-url")||Fe(),ce=e.includes("--base-url"),de=M();if(!h&&!c&&(o.simIdSource==="flag"||o.simIdSource==="saved"&&!!de)){let u=x(o),p=o.simId?` --sim ${o.simId}`:"",f=!1;try{let g=null;try{let w=await u.listSims();if(o.simIdSource==="saved"?(g=w.find($=>$.id===de&&$.readyState==="open")??null,g||T()):g=z(w,o.simId),!g)if(o.simIdSource==="saved")f=!0;else throw new Error("no sim connected");if(!f&&g){let $=ce||re(m)?P:De(g,P),L=await W(m,F($,d),_);u.send({type:"evaluate",simId:g.id,code:`window.location.href = ${JSON.stringify(L)}`}).catch(()=>{})}}catch(w){console.error(` open failed: ${w instanceof Error?w.message:String(w)}`),await N(u,{errorsCommand:`sootsim get errors 5${p}`,warningsCommand:`sootsim get warnings 5${p}`,requestsCommand:`sootsim get requests 5${p}`}),process.exit(1)}if(!f&&g){await v(1500);let w=await vt(o.wsPort,o.commandTimeoutMs,g.id);w||(console.error(" timed out waiting for current sim to load target"),process.exit(1)),w.bridge.close(),b(g.id);let $=ce||re(m)?P:De(g,P),L=await W(m,F($,d),_);E(L,{...g,url:L},"current sim"),await O(o.wsPort,g.id,e);return}}finally{u.close()}}let me=F(P,d),Ke=await W(m,me,_),ue=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=await St(m,me,ue,_),V={newWindow:!0},B=u=>u.url?.includes(`inspectOpen=${ue}`)??!1;if(h){nt(h)||(console.error(` unknown driver "${h}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let u=te(h);u||(console.error(` unknown driver "${h}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let p=ot(),f=await u.launch({url:S,headless:q,newWindow:V.newWindow,profileId:a,ephemeralProfile:r,cdpPort:i,connectTimeoutMs:p.hostTimeoutMs});f.launched||(console.error(` ${u.name} driver: ${f.message}`),process.exit(1));let g=await Pt(o.wsPort,o.commandTimeoutMs,B,f.pid,{attempts:p.attempts,intervalMs:p.intervalMs});if(g.kind==="host-exit"&&(Ae(f),console.error(` ${u.name} host crashed \u2014 sim is no longer attached`),process.exit(1)),g.kind==="timeout"){if(f.pid)try{process.kill(f.pid,"SIGTERM"),console.error(` closed ${u.name} host process ${f.pid}`)}catch{}Ae(f),console.error(` timed out after ${p.timeoutMs}ms waiting for opened sim to connect`),process.exit(1)}let w=g.sim;b(w.id),Tt(f),E(S,w,`${u.name} driver`),await O(o.wsPort,w.id,e);return}if(l){let u=U();u||(console.error(" profiles require electron or playwright; install the desktop companion or use `--driver playwright`"),process.exit(1));try{(await Z(S,u,{profileId:a,ephemeralProfile:r})).launched||(console.error(" desktop companion failed to start"),process.exit(1))}catch(f){console.error(` desktop companion failed: ${f instanceof Error?f.message:String(f)}`),process.exit(1)}let p=await oe(o.wsPort,o.commandTimeoutMs,B,{attempts:40,intervalMs:500});p||(console.error(" timed out waiting for profiled sim to connect"),process.exit(1)),b(p.id),E(S,p,"desktop companion"),await O(o.wsPort,p.id,e);return}let G=!1,J=!1;try{let u=y(o.wsPort,{commandTimeoutMs:2e3});try{await u.listSims(),G=!0}finally{u.close()}}catch{}if(G)try{let u=y(o.wsPort,{commandTimeoutMs:3e3});try{await u.openUrl(S,V),J=!0}finally{u.close()}}catch{}if(!J){let u=U();if(u)try{if((await Z(S,u)).launched){let f=await oe(o.wsPort,o.commandTimeoutMs,B,{attempts:20,intervalMs:500});if(f){b(f.id),E(S,f,"desktop companion"),await O(o.wsPort,f.id,e);return}}}catch{}try{await ee(S,V)}catch(p){console.error(` open failed: ${p instanceof Error?p.message:String(p)}`),te("playwright")?.availability().available?console.error(" no system browser found \u2014 retry with `sootsim open \u2026 --driver playwright` for a headless sim."):console.error(" run `sootsim list --drivers` to see available drivers."),process.exit(1)}if(!G){console.log(` opened: ${Ke}`),Ee(o.wsPort);return}}let D=await oe(o.wsPort,o.commandTimeoutMs,B,{attempts:30,intervalMs:500});D||(console.error(" timed out waiting for opened sim to connect"),process.exit(1)),b(D.id),E(S,D,J?"bridge":"direct shell open"),await O(o.wsPort,D.id,e)}async function He(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--force"]}),n=e.includes("--force"),r=x(o),s=o.simId?` --sim ${o.simId}`:"";try{try{let i=await r.listSims(),a=z(i,o.positional[0]||o.simId);if(a.lockedBy&&a.lockExpiresAt&&a.lockExpiresAt>Date.now()){let l=Math.max(0,Math.round((a.lockExpiresAt-Date.now())/1e3));a.lockedByKind==="user-active"&&(console.error(` refused: ${a.id} is locked by the active user (${l}s) \u2014 that's a live human tab`),console.error(" run `sootsim open --new` for a fresh investigation sim"),process.exit(1)),n||(console.error(` refused: ${a.id} is leased by ${a.lockedBy} (${l}s)`),console.error(` \`sootsim use ${a.id} --force\` to take it, or \`sootsim open --new\` for a fresh sim`),process.exit(1))}await r.focusSim(a.id),b(a.id),console.log(` using: ${a.id}`)}catch(i){console.error(` use failed: ${i instanceof Error?i.message:String(i)}`),await N(r,{errorsCommand:`sootsim get errors 5${s}`,warningsCommand:`sootsim get warnings 5${s}`,requestsCommand:`sootsim get requests 5${s}`}),process.exit(1)}}finally{r.close()}}async function go(e,t={}){await He(e,t)}async function wo(e,t={}){await He(e,t)}async function bo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--force"]}),n=e.includes("--force"),r=x(o);try{try{let s=await r.listSims(),i=z(s,o.positional[0]||o.simId),a=n&&i.lockedBy&&i.lockedByKind!=="user-active"?i.lockedBy:null,l=await r.claim(i.id,{force:n});b(i.id);let c=Math.max(0,Math.round((l.lockExpiresAt-Date.now())/1e3)),d=l.bootedCount>0?` (booted ${l.bootedCount})`:"";console.log(` claimed: ${l.simId} [${c}s]${d}`),a&&console.log(` took over from: ${a}`)}catch(s){if(s instanceof be){let i=Math.max(0,Math.round(s.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${s.lock.by} for ${i}s more`),console.error(" use --force to take it, or `sootsim open --new` for a fresh sim"),process.exit(1)}console.error(` claim failed: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}}finally{r.close()}}async function Ot(e,t,o,n){if(n.length===0)return{closed:[],remaining:[]};await Promise.all(n.map(s=>e.closeSim(s).catch(()=>{})));let r=new Set(n);for(let s=0;s<40;s++){let i=[];try{let a=y(t,{commandTimeoutMs:o});try{i=(await a.listSims()).filter(c=>r.has(c.id)&&c.readyState==="open").map(c=>c.id)}finally{a.close()}}catch{i=[]}if(i.length===0)return{closed:[...r],remaining:[]};if(s===39)return{closed:[...r].filter(a=>!i.includes(a)),remaining:i};await v(250)}return{closed:[...r],remaining:[]}}function Rt(e,t){let o=e.filter(m=>m.readyState==="open"),n=o.map(m=>m.id),r=t.explicitKeepId?.trim()||"",s=t.savedKeepId?.trim()||"",i=s?o.some(m=>m.id===s):!1,a=s&&!i?s:null,l=null,c=null,d=null;if(t.closeOthers)if(r){let m=o.find(h=>h.id===r);m?l=m.id:c=r}else if(s&&i)l=s;else{let m=o.find(h=>h.isPrimary)??o[0]??null;m&&(l=m.id,s&&!i&&(d=m.id))}return{openIds:n,keepId:l,targets:c?[]:n.filter(m=>m!==l),staleSavedId:a,missingExplicitKeepId:c,fallbackKeepId:d}}async function yo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--all","--others"]}),n=x(o),r=o.simId?` --sim ${o.simId}`:"",s=e.includes("--all"),i=e.includes("--others");if(s||i){try{let a=await n.listSims(),l=M(),c=o.positional[0]||(o.simIdSource==="flag"?o.simId:void 0),d=Rt(a,{closeOthers:i,explicitKeepId:c,savedKeepId:l});if(d.staleSavedId&&T(),d.fallbackKeepId&&(b(d.fallbackKeepId),console.log(` saved sim ${d.staleSavedId} is gone \u2014 keeping primary ${d.fallbackKeepId}`)),d.missingExplicitKeepId&&(console.error(` close failed: keep sim ${d.missingExplicitKeepId} is not connected; not closing other sims`),process.exit(1)),d.targets.length===0){console.log(d.keepId?` nothing to close \u2014 only the kept sim ${d.keepId} is connected`:d.staleSavedId?` nothing to close \u2014 no sims connected (cleared stale current sim ${d.staleSavedId})`:" nothing to close \u2014 no sims connected");return}let m=await Ot(n,o.wsPort,o.commandTimeoutMs,d.targets);await ne(a,d.targets);let h=M();h&&m.closed.includes(h)&&(d.keepId?b(d.keepId):T());let q=` closed ${m.closed.length} sim(s)${d.keepId?` (kept ${d.keepId})`:""}`;console.log(q),m.remaining.length>0&&(console.error(` close failed: still connected: ${m.remaining.join(", ")}`),process.exit(1))}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}finally{n.close()}return}try{try{let a=await n.listSims(),l=z(a,o.positional[0]||o.simId),c=a.find(m=>m.id!==l.id&&m.readyState==="open");await n.closeSim(l.id),await Ct(o.wsPort,o.commandTimeoutMs,l.id)||(await ne(a,[l.id]),console.error(` close failed: ${l.id} is still connected`),process.exit(1)),await ne(a,[l.id]),M()===l.id&&(c?b(c.id):T()),console.log(` closed: ${l.id}`)}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),await N(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}export{Ht as a,Qe as b,Kt as c,ot as d,po as e,Fe as f,W as g,St as h,$t as i,xt as j,oe as k,Pt as l,Mt as m,Tt as n,ne as o,fo as p,ho as q,go as r,wo as s,bo as t,Ot as u,Rt as v,yo as w};
13
+ })()`,l=await r.send({type:"evaluate",code:a});if(!l?.tree)return;if(console.log(""),l.shell?.state){let c=[`state=${l.shell.state}`,l.shell.activeApp?`app=${l.shell.activeApp}`:null].filter(Boolean);console.log(` shell: ${c.join(" ")}`)}console.log(l.tree)}finally{r.close()}}catch{}finally{n===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=n}}async function Ut(e,t,o){let n=Date.now()+o.maxMs,r="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",s=y(e,{commandTimeoutMs:2e3,simId:t,simIdSource:"flag"});try{let i=-1,a=0;for(;Date.now()<n;){let l=-1;try{let c=await s.send({type:"evaluate",code:r});typeof c=="number"&&(l=c)}catch{}if(l>=0&&l===i){if(Date.now()-a>=o.stableMs)return}else i=l,a=Date.now();await v(50)}}finally{s.close()}}async function fo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs}),n=x(o);try{let r=await n.listSims();xt(r,o.simId)}finally{n.close()}}async function ho(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--new","--headless","--headed","--ephemeral","--hot","--no-hmr"],stripValueFlags:["--base-url","--replace","--driver","--profile","--cdp-port"]}),n=e.find((u,p)=>e[p-1]==="--profile"),r=e.includes("--ephemeral"),s=e.find((u,p)=>e[p-1]==="--cdp-port"),i=s?Number(s):void 0;s&&(!Number.isFinite(i)||i<=0)&&(console.error(` sootsim open: --cdp-port must be a positive port number, got "${s}"`),process.exit(1)),n&&r&&(console.error(" sootsim open: --profile cannot be combined with --ephemeral"),process.exit(1));let a=n?ve(n).id:void 0,l=!!a||r,c=e.includes("--new")||l,d=ft(e);c&&o.simIdSource==="flag"&&(console.error(" sootsim open: --new, --profile, and --ephemeral cannot be combined with --sim"),process.exit(1));let m=o.positional[0]||"";if(lt(m)){let u=(()=>{try{return/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(new URL(m).hostname)}catch{return!1}})();console.log(" that\u2019s a SootSim preview/build link \u2014 a full player page, not a driveable sim."),console.log(" opening it in your browser for viewing\u2026");try{await ee(m,{background:!1})}catch(p){console.error(` could not launch a browser: ${p instanceof Error?p.message:String(p)}`),console.error(` open it yourself: ${m}`),process.exit(1)}console.log(u?" to drive it under the CLI, point `sootsim open` at the app\u2019s dev port instead (e.g. `sootsim open 8081`).":" the CLI can\u2019t drive a remote preview (the engine only attaches to the local bridge from localhost). to drive the app, run it locally and `sootsim open <port>`.");return}o.wsPort=await st(o.wsPort);let h=e.find((u,p)=>e[p-1]==="--driver")||"",q=rt(e,h);i&&h!=="playwright"&&(console.error(" sootsim open: --cdp-port is only honored by the playwright driver \u2014 add `--driver playwright`"),process.exit(1));let ae=e.includes("--hot"),le=e.includes("--no-hmr");ae&&le&&(console.error(" sootsim open: --hot and --no-hmr cannot be combined"),process.exit(1));let _={hot:ae?!0:le?!1:h!=="playwright"},P=e.find((u,p)=>e[p-1]==="--base-url")||Fe(),ce=e.includes("--base-url"),de=M();if(!h&&!c&&(o.simIdSource==="flag"||o.simIdSource==="saved"&&!!de)){let u=x(o),p=o.simId?` --sim ${o.simId}`:"",f=!1;try{let g=null;try{let w=await u.listSims();if(o.simIdSource==="saved"?(g=w.find($=>$.id===de&&$.readyState==="open")??null,g||T()):g=z(w,o.simId),!g)if(o.simIdSource==="saved")f=!0;else throw new Error("no sim connected");if(!f&&g){let $=ce||re(m)?P:De(g,P),L=await W(m,F($,d),_);u.send({type:"evaluate",simId:g.id,code:`window.location.href = ${JSON.stringify(L)}`}).catch(()=>{})}}catch(w){console.error(` open failed: ${w instanceof Error?w.message:String(w)}`),await N(u,{errorsCommand:`sootsim get errors 5${p}`,warningsCommand:`sootsim get warnings 5${p}`,requestsCommand:`sootsim get requests 5${p}`}),process.exit(1)}if(!f&&g){await v(1500);let w=await vt(o.wsPort,o.commandTimeoutMs,g.id);w||(console.error(" timed out waiting for current sim to load target"),process.exit(1)),w.bridge.close(),b(g.id);let $=ce||re(m)?P:De(g,P),L=await W(m,F($,d),_);U(L,{...g,url:L},"current sim"),await O(o.wsPort,g.id,e);return}}finally{u.close()}}let me=F(P,d),Ke=await W(m,me,_),ue=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=await St(m,me,ue,_),G={newWindow:!0},B=u=>u.url?.includes(`inspectOpen=${ue}`)??!1;if(h){nt(h)||(console.error(` unknown driver "${h}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let u=te(h);u||(console.error(` unknown driver "${h}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let p=ot(),f=await u.launch({url:S,headless:q,newWindow:G.newWindow,profileId:a,ephemeralProfile:r,cdpPort:i,connectTimeoutMs:p.hostTimeoutMs});f.launched||(console.error(` ${u.name} driver: ${f.message}`),process.exit(1));let g=await Pt(o.wsPort,o.commandTimeoutMs,B,f.pid,{attempts:p.attempts,intervalMs:p.intervalMs});if(g.kind==="host-exit"&&(Ae(f),console.error(` ${u.name} host crashed \u2014 sim is no longer attached`),process.exit(1)),g.kind==="timeout"){if(f.pid)try{process.kill(f.pid,"SIGTERM"),console.error(` closed ${u.name} host process ${f.pid}`)}catch{}Ae(f),console.error(` timed out after ${p.timeoutMs}ms waiting for opened sim to connect`),process.exit(1)}let w=g.sim;b(w.id),Tt(f),U(S,w,`${u.name} driver`),await O(o.wsPort,w.id,e);return}if(l){let u=E();u||(console.error(" profiles require electron or playwright; install the desktop companion or use `--driver playwright`"),process.exit(1));try{(await Z(S,u,{profileId:a,ephemeralProfile:r})).launched||(console.error(" desktop companion failed to start"),process.exit(1))}catch(f){console.error(` desktop companion failed: ${f instanceof Error?f.message:String(f)}`),process.exit(1)}let p=await oe(o.wsPort,o.commandTimeoutMs,B,{attempts:40,intervalMs:500});p||(console.error(" timed out waiting for profiled sim to connect"),process.exit(1)),b(p.id),U(S,p,"desktop companion"),await O(o.wsPort,p.id,e);return}let V=!1,J=!1;try{let u=y(o.wsPort,{commandTimeoutMs:2e3});try{await u.listSims(),V=!0}finally{u.close()}}catch{}if(V)try{let u=y(o.wsPort,{commandTimeoutMs:3e3});try{await u.openUrl(S,G),J=!0}finally{u.close()}}catch{}if(!J){let u=E();if(u)try{if((await Z(S,u)).launched){let f=await oe(o.wsPort,o.commandTimeoutMs,B,{attempts:20,intervalMs:500});if(f){b(f.id),U(S,f,"desktop companion"),await O(o.wsPort,f.id,e);return}}}catch{}try{await ee(S,G)}catch(p){console.error(` open failed: ${p instanceof Error?p.message:String(p)}`),te("playwright")?.availability().available?console.error(" no system browser found \u2014 retry with `sootsim open \u2026 --driver playwright` for a headless sim."):console.error(" run `sootsim list --drivers` to see available drivers."),process.exit(1)}if(!V){console.log(` opened: ${Ke}`),Ue(o.wsPort);return}}let D=await oe(o.wsPort,o.commandTimeoutMs,B,{attempts:30,intervalMs:500});D||(console.error(" timed out waiting for opened sim to connect"),process.exit(1)),b(D.id),U(S,D,J?"bridge":"direct shell open"),await O(o.wsPort,D.id,e)}async function He(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--force"]}),n=e.includes("--force"),r=x(o),s=o.simId?` --sim ${o.simId}`:"";try{try{let i=await r.listSims(),a=z(i,o.positional[0]||o.simId);if(a.lockedBy&&a.lockExpiresAt&&a.lockExpiresAt>Date.now()){let l=Math.max(0,Math.round((a.lockExpiresAt-Date.now())/1e3));a.lockedByKind==="user-active"&&(console.error(` refused: ${a.id} is locked by the active user (${l}s) \u2014 that's a live human tab`),console.error(" run `sootsim open --new` for a fresh investigation sim"),process.exit(1)),n||(console.error(` refused: ${a.id} is leased by ${a.lockedBy} (${l}s)`),console.error(` \`sootsim use ${a.id} --force\` to take it, or \`sootsim open --new\` for a fresh sim`),process.exit(1))}await r.focusSim(a.id),b(a.id),console.log(` using: ${a.id}`)}catch(i){console.error(` use failed: ${i instanceof Error?i.message:String(i)}`),await N(r,{errorsCommand:`sootsim get errors 5${s}`,warningsCommand:`sootsim get warnings 5${s}`,requestsCommand:`sootsim get requests 5${s}`}),process.exit(1)}}finally{r.close()}}async function go(e,t={}){await He(e,t)}async function wo(e,t={}){await He(e,t)}async function bo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--force"]}),n=e.includes("--force"),r=x(o);try{try{let s=await r.listSims(),i=z(s,o.positional[0]||o.simId),a=n&&i.lockedBy&&i.lockedByKind!=="user-active"?i.lockedBy:null,l=await r.claim(i.id,{force:n});b(i.id);let c=Math.max(0,Math.round((l.lockExpiresAt-Date.now())/1e3)),d=l.bootedCount>0?` (booted ${l.bootedCount})`:"";console.log(` claimed: ${l.simId} [${c}s]${d}`),a&&console.log(` took over from: ${a}`)}catch(s){if(s instanceof be){let i=Math.max(0,Math.round(s.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${s.lock.by} for ${i}s more`),console.error(" use --force to take it, or `sootsim open --new` for a fresh sim"),process.exit(1)}console.error(` claim failed: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}}finally{r.close()}}async function Ot(e,t,o,n){if(n.length===0)return{closed:[],remaining:[]};await Promise.all(n.map(s=>e.closeSim(s).catch(()=>{})));let r=new Set(n);for(let s=0;s<40;s++){let i=[];try{let a=y(t,{commandTimeoutMs:o});try{i=(await a.listSims()).filter(c=>r.has(c.id)&&c.readyState==="open").map(c=>c.id)}finally{a.close()}}catch{i=[]}if(i.length===0)return{closed:[...r],remaining:[]};if(s===39)return{closed:[...r].filter(a=>!i.includes(a)),remaining:i};await v(250)}return{closed:[...r],remaining:[]}}function Rt(e,t){let o=e.filter(m=>m.readyState==="open"),n=o.map(m=>m.id),r=t.explicitKeepId?.trim()||"",s=t.savedKeepId?.trim()||"",i=s?o.some(m=>m.id===s):!1,a=s&&!i?s:null,l=null,c=null,d=null;if(t.closeOthers)if(r){let m=o.find(h=>h.id===r);m?l=m.id:c=r}else if(s&&i)l=s;else{let m=o.find(h=>h.isPrimary)??o[0]??null;m&&(l=m.id,s&&!i&&(d=m.id))}return{openIds:n,keepId:l,targets:c?[]:n.filter(m=>m!==l),staleSavedId:a,missingExplicitKeepId:c,fallbackKeepId:d}}async function yo(e,t={}){let o=I(e,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--all","--others"]}),n=x(o),r=o.simId?` --sim ${o.simId}`:"",s=e.includes("--all"),i=e.includes("--others");if(s||i){try{let a=await n.listSims(),l=M(),c=o.positional[0]||(o.simIdSource==="flag"?o.simId:void 0),d=Rt(a,{closeOthers:i,explicitKeepId:c,savedKeepId:l});if(d.staleSavedId&&T(),d.fallbackKeepId&&(b(d.fallbackKeepId),console.log(` saved sim ${d.staleSavedId} is gone \u2014 keeping primary ${d.fallbackKeepId}`)),d.missingExplicitKeepId&&(console.error(` close failed: keep sim ${d.missingExplicitKeepId} is not connected; not closing other sims`),process.exit(1)),d.targets.length===0){console.log(d.keepId?` nothing to close \u2014 only the kept sim ${d.keepId} is connected`:d.staleSavedId?` nothing to close \u2014 no sims connected (cleared stale current sim ${d.staleSavedId})`:" nothing to close \u2014 no sims connected");return}let m=await Ot(n,o.wsPort,o.commandTimeoutMs,d.targets);await ne(a,d.targets);let h=M();h&&m.closed.includes(h)&&(d.keepId?b(d.keepId):T());let q=` closed ${m.closed.length} sim(s)${d.keepId?` (kept ${d.keepId})`:""}`;console.log(q),m.remaining.length>0&&(console.error(` close failed: still connected: ${m.remaining.join(", ")}`),process.exit(1))}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}finally{n.close()}return}try{try{let a=await n.listSims(),l=z(a,o.positional[0]||o.simId),c=a.find(m=>m.id!==l.id&&m.readyState==="open");await n.closeSim(l.id),await Ct(o.wsPort,o.commandTimeoutMs,l.id)||(await ne(a,[l.id]),console.error(` close failed: ${l.id} is still connected`),process.exit(1)),await ne(a,[l.id]),M()===l.id&&(c?b(c.id):T()),console.log(` closed: ${l.id}`)}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),await N(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}export{Ht as a,Qe as b,Kt as c,ot as d,po as e,Fe as f,W as g,St as h,$t as i,xt as j,oe as k,Pt as l,Mt as m,Tt as n,ne as o,fo as p,ho as q,go as r,wo as s,bo as t,Ot as u,Rt as v,yo as w};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{D as t,J as n,L as l,j as r}from"./chunk-3SUIAUIY.js";function m(){let e=t(),i=r()?n():null;return i&&l(i)?{primary:`engine dev source (:${i.bridgePort})`,installedRuntime:e?`installed runtime v${e}`:null,isDevBridge:!0}:{primary:e?`runtime v${e}`:"runtime not installed",installedRuntime:null,isDevBridge:!1}}export{m as a};
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{D as t,J as n,L as l,j as r}from"./chunk-IBSEFPPL.js";function m(){let e=t(),i=r()?n():null;return i&&l(i)?{primary:`engine dev source (:${i.bridgePort})`,installedRuntime:e?`installed runtime v${e}`:null,isDevBridge:!0}:{primary:e?`runtime v${e}`:"runtime not installed",installedRuntime:null,isDevBridge:!1}}export{m as a};
@@ -1,3 +1,3 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as s}from"./chunk-JCQEG4R6.js";import{o}from"./chunk-3SUIAUIY.js";import{chmodSync as p,existsSync as d,mkdirSync as g,readFileSync as I,rmSync as f,writeFileSync as _}from"node:fs";import{dirname as y,join as h,resolve as k}from"node:path";function i(){return h(o(),"credentials.json")}function S(){let n=i();if(!d(n))return null;try{let t=JSON.parse(I(n,"utf8"));return t.version!==1||typeof t.apiKey!="string"||!t.apiKey.startsWith("sk_sootsim_")?null:t.apiKey}catch{return null}}function w(n){if(!n.startsWith("sk_sootsim_"))throw new Error("api key must start with sk_sootsim_");let t=i();g(y(k(t)),{recursive:!0}),_(t,JSON.stringify({version:1,apiKey:n,savedAt:new Date().toISOString()},null,2)+`
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as s}from"./chunk-UBJQDMDG.js";import{o}from"./chunk-IBSEFPPL.js";import{chmodSync as p,existsSync as d,mkdirSync as g,readFileSync as I,rmSync as f,writeFileSync as _}from"node:fs";import{dirname as y,join as h,resolve as k}from"node:path";function i(){return h(o(),"credentials.json")}function S(){let n=i();if(!d(n))return null;try{let t=JSON.parse(I(n,"utf8"));return t.version!==1||typeof t.apiKey!="string"||!t.apiKey.startsWith("sk_sootsim_")?null:t.apiKey}catch{return null}}function w(n){if(!n.startsWith("sk_sootsim_"))throw new Error("api key must start with sk_sootsim_");let t=i();g(y(k(t)),{recursive:!0}),_(t,JSON.stringify({version:1,apiKey:n,savedAt:new Date().toISOString()},null,2)+`
3
3
  `);try{p(t,384)}catch{}}function E(){f(i(),{force:!0})}var m=["ghs_","ghp_","gho_","ghu_","github_pat_"];function O(n){return!!(n&&n.length>=20&&m.some(t=>n.startsWith(t)))}function A(){let n=process.env.SOOT_INSTALLATION_TOKEN?.trim(),t=process.env.GITHUB_TOKEN?.trim(),r=n||t;if(!O(r))return null;let e=(process.env.SOOT_REPO||process.env.GITHUB_REPOSITORY||"").trim();if(!e)return null;let[l,u]=e.includes("/")?e.split("/",2):[null,null],c=(process.env.SOOT_REPO_ID||process.env.GITHUB_REPOSITORY_ID||"").trim(),a=(process.env.SOOT_INSTALLATION_ID||process.env.GITHUB_APP_INSTALLATION_ID||"").trim();return{kind:"github",token:r,repoId:e,repositoryId:c||null,owner:l||null,repo:u||null,installationId:a||null,source:n?"soot-runner":"github-actions"}}function x(){let n=process.env.SOOTSIM_API_KEY?.trim();if(n&&n.startsWith("sk_sootsim_"))return{kind:"api-key",secret:n,source:"env"};let t=A();if(t)return t;let r=S();if(r)return{kind:"api-key",secret:r,source:"file"};let e=s();return e?.token?{kind:"session",token:e.token,origin:e.origin}:null}function H(n){return n.kind==="api-key"?`Bearer ${n.secret}`:`Bearer ${n.token}`}function N(n){return!n||n.kind!=="github"?null:{repoId:n.repoId,owner:n.owner??void 0,repo:n.repo??void 0,installationId:n.installationId}}export{S as a,w as b,E as c,x as d,H as e,N as f};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  var d=Object.defineProperty;var e=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var f=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0})};export{e as a,f as b};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.175 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as A,d as W,f as x}from"./chunk-RAESCYIA.js";import{I as v,J as P,K as T,L as C,j as k}from"./chunk-3SUIAUIY.js";import{WebSocket as I}from"ws";function E(){if(k()){let n=P();if(n&&C(n))return n.bridgePort}let e=v();return e&&T(e)?e.bridgePort:7668}var w=class extends Error{lock;constructor(n,i){super(n),this.name="BridgeSimLockedError",this.lock=i}};function L(e){return e==="flag"?"via --sim":e==="saved"?"saved via `sootsim use`":"primary fallback \u2014 no sim pinned"}function V(e,n={}){let i=new Set,a=n.port??E(),l=n.commandTimeoutMs??15e3,r,m="none",h=new Set(n.stripBooleanFlags??[]),b=new Set(n.stripValueFlags??[]);for(let t=0;t<e.length;t++){let d=e[t];if(d==="--port"||d==="-p"){i.add(t),t+1<e.length&&(i.add(t+1),a=Number(e[t+1])),t++;continue}if(d.startsWith("--port=")){i.add(t),a=Number(d.slice(7));continue}if(d==="--timeout"){i.add(t),t+1<e.length&&(i.add(t+1),l=Number(e[t+1])),t++;continue}if(d==="--sim"||d==="--session"||d==="--tab"){i.add(t),t+1<e.length&&(i.add(t+1),r=e[t+1]?.trim()||void 0,m="flag"),t++;continue}let s=d.startsWith("--sim=")?d.slice(6):d.startsWith("--session=")?d.slice(10):d.startsWith("--tab=")?d.slice(6):void 0;if(s!==void 0){i.add(t),r=s.trim()||void 0,m="flag";continue}if(h.has(d)){i.add(t);continue}b.has(d)&&(i.add(t),t+1<e.length&&i.add(t+1),t++)}if(!r){let t=W();t&&(r=t.trim()||void 0,m="saved")}return{positional:e.filter((t,d)=>!i.has(d)),wsPort:a,simId:r,simIdSource:m,commandTimeoutMs:l}}function M(e,n={}){let i=1,a=n.commandTimeoutMs??15e3,l=new Map,r=new I(`ws://localhost:${e}`),m=A(),h=new Promise((s,o)=>{r.on("open",()=>{try{r.send(JSON.stringify({type:"bridge:hello",id:0,cliIdentityKey:m.key,cliIdentitySource:m.source,cliLabel:n.cliLabel}))}catch{}s()}),r.on("error",c=>{let g=c.message?`: ${c.message}`:"";o(new Error(`could not connect to ws://localhost:${e}${g}`))})}),b=!1,t=!1;function d(s,o){if(t||process.env.SOOTSIM_QUIET_TARGET_NOTICE==="1"||s.startsWith("bridge:")||s==="focus"||s==="close")return;t=!0;let c=o??"primary",g=L(o?n.simIdSource:"none");process.stderr.write(` \u2192 ${c} (${g})
1
+ /*! sootsim v0.1.177 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as A,d as W,f as x}from"./chunk-4INGTBO7.js";import{I as v,J as P,K as T,L as C,j as k}from"./chunk-IBSEFPPL.js";import{WebSocket as I}from"ws";function E(){if(k()){let n=P();if(n&&C(n))return n.bridgePort}let e=v();return e&&T(e)?e.bridgePort:7668}var w=class extends Error{lock;constructor(n,i){super(n),this.name="BridgeSimLockedError",this.lock=i}};function L(e){return e==="flag"?"via --sim":e==="saved"?"saved via `sootsim use`":"primary fallback \u2014 no sim pinned"}function V(e,n={}){let i=new Set,a=n.port??E(),l=n.commandTimeoutMs??15e3,r,m="none",h=new Set(n.stripBooleanFlags??[]),b=new Set(n.stripValueFlags??[]);for(let t=0;t<e.length;t++){let d=e[t];if(d==="--port"||d==="-p"){i.add(t),t+1<e.length&&(i.add(t+1),a=Number(e[t+1])),t++;continue}if(d.startsWith("--port=")){i.add(t),a=Number(d.slice(7));continue}if(d==="--timeout"){i.add(t),t+1<e.length&&(i.add(t+1),l=Number(e[t+1])),t++;continue}if(d==="--sim"||d==="--session"||d==="--tab"){i.add(t),t+1<e.length&&(i.add(t+1),r=e[t+1]?.trim()||void 0,m="flag"),t++;continue}let s=d.startsWith("--sim=")?d.slice(6):d.startsWith("--session=")?d.slice(10):d.startsWith("--tab=")?d.slice(6):void 0;if(s!==void 0){i.add(t),r=s.trim()||void 0,m="flag";continue}if(h.has(d)){i.add(t);continue}b.has(d)&&(i.add(t),t+1<e.length&&i.add(t+1),t++)}if(!r){let t=W();t&&(r=t.trim()||void 0,m="saved")}return{positional:e.filter((t,d)=>!i.has(d)),wsPort:a,simId:r,simIdSource:m,commandTimeoutMs:l}}function M(e,n={}){let i=1,a=n.commandTimeoutMs??15e3,l=new Map,r=new I(`ws://localhost:${e}`),m=A(),h=new Promise((s,o)=>{r.on("open",()=>{try{r.send(JSON.stringify({type:"bridge:hello",id:0,cliIdentityKey:m.key,cliIdentitySource:m.source,cliLabel:n.cliLabel}))}catch{}s()}),r.on("error",c=>{let g=c.message?`: ${c.message}`:"";o(new Error(`could not connect to ws://localhost:${e}${g}`))})}),b=!1,t=!1;function d(s,o){if(t||process.env.SOOTSIM_QUIET_TARGET_NOTICE==="1"||s.startsWith("bridge:")||s==="focus"||s==="close")return;t=!0;let c=o??"primary",g=L(o?n.simIdSource:"none");process.stderr.write(` \u2192 ${c} (${g})
3
3
  `)}return r.on("message",s=>{let o;try{o=JSON.parse(s.toString())}catch{return}if(o.id===0)return;let c=l.get(o.id);c&&(l.delete(o.id),o._otherCliCount>0&&!b&&(b=!0,process.stderr.write(`
4
4
  \u26A0 ${o._otherCliCount} other CLI identity/identities are driving this sim
5
5
  taps, scrolls, and keyboard input from multiple agents will collide on