sootsim 0.1.294 → 0.1.296

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 (186) hide show
  1. package/README.md +13 -4
  2. package/dist-cli/bin.js +5 -5
  3. package/dist-cli/chunks/{agent-GDFF6G7N.js → agent-3F4K6MQK.js} +2 -2
  4. package/dist-cli/chunks/{agent-wrapper-ZUKQUOD2.js → agent-wrapper-5LLVCQRZ.js} +2 -2
  5. package/dist-cli/chunks/app-fonts-LPTY7A5G.js +4 -0
  6. package/dist-cli/chunks/{assert-GXOGZUKO.js → assert-R2ZUXEMS.js} +2 -2
  7. package/dist-cli/chunks/{auth-P7FAKLHQ.js → auth-CA62Q6IS.js} +2 -2
  8. package/dist-cli/chunks/{beta-RXT5RU3A.js → beta-4AXSOQLU.js} +2 -2
  9. package/dist-cli/chunks/{camera-RNVAC4IO.js → camera-Y4RBIONE.js} +2 -2
  10. package/dist-cli/chunks/{chunk-OYYQQBKP.js → chunk-222Y7NQA.js} +1 -1
  11. package/dist-cli/chunks/chunk-2LQOLMRK.js +4 -0
  12. package/dist-cli/chunks/{chunk-AFLGWOX3.js → chunk-2XUKWIAL.js} +1 -1
  13. package/dist-cli/chunks/{chunk-DI55E6CS.js → chunk-3PAZJSIG.js} +2 -2
  14. package/dist-cli/chunks/{chunk-2M7OZ6Y4.js → chunk-4MDLYOEI.js} +2 -2
  15. package/dist-cli/chunks/{chunk-EXTV6NWM.js → chunk-4NFGOGB7.js} +2 -2
  16. package/dist-cli/chunks/chunk-54TQ3ZGI.js +30 -0
  17. package/dist-cli/chunks/chunk-5FNPAMP4.js +125 -0
  18. package/dist-cli/chunks/{chunk-4Z4URZOG.js → chunk-6C24WCDK.js} +2 -2
  19. package/dist-cli/chunks/{chunk-KWIURH7N.js → chunk-74FOMZP7.js} +2 -2
  20. package/dist-cli/chunks/{chunk-JUOQ4ZPA.js → chunk-7GQWF7HE.js} +1 -1
  21. package/dist-cli/chunks/{chunk-BXO2PTNM.js → chunk-7V3JNANH.js} +4 -4
  22. package/dist-cli/chunks/{chunk-DUHBRW7J.js → chunk-7YQXQSG7.js} +1 -1
  23. package/dist-cli/chunks/{chunk-FSRRJGYC.js → chunk-AUBP44CY.js} +2 -2
  24. package/dist-cli/chunks/chunk-B2FB6IYX.js +4 -0
  25. package/dist-cli/chunks/{chunk-FNCSUHUR.js → chunk-B2LDO55K.js} +1 -1
  26. package/dist-cli/chunks/{chunk-K53YCAQM.js → chunk-BVWIR4CD.js} +1 -1
  27. package/dist-cli/chunks/{chunk-RWUNC66S.js → chunk-C462URRQ.js} +2 -2
  28. package/dist-cli/chunks/chunk-CAAADPRH.js +10 -0
  29. package/dist-cli/chunks/{chunk-VXGCZUX4.js → chunk-CDCVWGNU.js} +3 -3
  30. package/dist-cli/chunks/{chunk-WYRLRNIP.js → chunk-CS23DQB2.js} +2 -2
  31. package/dist-cli/chunks/chunk-DUYKBCM7.js +4 -0
  32. package/dist-cli/chunks/chunk-EISE56VD.js +6 -0
  33. package/dist-cli/chunks/{chunk-VVVORIQI.js → chunk-EJ6BAJKX.js} +1 -1
  34. package/dist-cli/chunks/chunk-F2MS365Z.js +4 -0
  35. package/dist-cli/chunks/{chunk-AMKQUZA2.js → chunk-FROCFR77.js} +1 -1
  36. package/dist-cli/chunks/{chunk-I233T2T4.js → chunk-FUPQIX4U.js} +2 -2
  37. package/dist-cli/chunks/{chunk-V2MYTL4C.js → chunk-G2SO5FPN.js} +2 -2
  38. package/dist-cli/chunks/chunk-GG5PWLGC.js +4 -0
  39. package/dist-cli/chunks/chunk-GG6XOQ5P.js +15 -0
  40. package/dist-cli/chunks/chunk-HSGS2U7P.js +6 -0
  41. package/dist-cli/chunks/{chunk-PZTKQG6H.js → chunk-IR3DUBRF.js} +5 -5
  42. package/dist-cli/chunks/chunk-LHUY46GE.js +4 -0
  43. package/dist-cli/chunks/{chunk-N4MT5KEB.js → chunk-MDBR4XTV.js} +3 -3
  44. package/dist-cli/chunks/{chunk-SLMUW2WU.js → chunk-MQ6QX46T.js} +2 -2
  45. package/dist-cli/chunks/chunk-N3FZRJT7.js +4 -0
  46. package/dist-cli/chunks/{chunk-ISJ4ACWL.js → chunk-NEARYPSC.js} +11 -11
  47. package/dist-cli/chunks/chunk-P7HBJBHH.js +4 -0
  48. package/dist-cli/chunks/{chunk-24BJFJFB.js → chunk-PEUWZRXA.js} +5 -5
  49. package/dist-cli/chunks/{chunk-PSOUSJSZ.js → chunk-QIDFGREY.js} +1 -1
  50. package/dist-cli/chunks/{chunk-ZUX5PIGI.js → chunk-R65XMN4D.js} +1 -1
  51. package/dist-cli/chunks/{chunk-AO65WEF7.js → chunk-S5Z4HKWX.js} +1 -1
  52. package/dist-cli/chunks/chunk-SUJSGGSS.js +23 -0
  53. package/dist-cli/chunks/{chunk-O6I5ZGMY.js → chunk-TIOPG6QZ.js} +1 -1
  54. package/dist-cli/chunks/chunk-WJVBD2UL.js +9 -0
  55. package/dist-cli/chunks/{chunk-D2R7PDN5.js → chunk-X7B5KJ6N.js} +1 -1
  56. package/dist-cli/chunks/{chunk-7HVMAGDK.js → chunk-XMVVZCIM.js} +2 -2
  57. package/dist-cli/chunks/chunk-ZIBKGZJD.js +4 -0
  58. package/dist-cli/chunks/chunk-ZPBIHFQW.js +12 -0
  59. package/dist-cli/chunks/cleanup-4RSKYPQ7.js +25 -0
  60. package/dist-cli/chunks/{cli-version-2JGMYL4O.js → cli-version-VZFF7GGM.js} +2 -2
  61. package/dist-cli/chunks/compat-FABLN4UI.js +20 -0
  62. package/dist-cli/chunks/config-74J37LKC.js +13 -0
  63. package/dist-cli/chunks/control-VBK32Y7F.js +4 -0
  64. package/dist-cli/chunks/daemon-VFO7LRR4.js +4 -0
  65. package/dist-cli/chunks/{debug-XUGWZLIW.js → debug-AOYA2CLR.js} +3 -3
  66. package/dist-cli/chunks/{desktop-IO5HPX5Z.js → desktop-G7XWDCTM.js} +3 -3
  67. package/dist-cli/chunks/{detox-E42OEJJZ.js → detox-QXJ3L2ZI.js} +2 -2
  68. package/dist-cli/chunks/{device-XA67L2EB.js → device-NZZ5ZT3Q.js} +2 -2
  69. package/dist-cli/chunks/{diagnose-36FD6ECF.js → diagnose-5CAEJ42M.js} +2 -2
  70. package/dist-cli/chunks/disk-cleanup-GZSUZJ6Y.js +4 -0
  71. package/dist-cli/chunks/drivers-OLJCUSPO.js +4 -0
  72. package/dist-cli/chunks/{film-XARTGFIZ.js → film-C25VRUNC.js} +3 -3
  73. package/dist-cli/chunks/flow-IW3WUF5D.js +4 -0
  74. package/dist-cli/chunks/help-GEVJF2DA.js +4 -0
  75. package/dist-cli/chunks/{hidden-runtime-alias-T4ZALBE2.js → hidden-runtime-alias-NSLIK6XT.js} +2 -2
  76. package/dist-cli/chunks/home-paths-OC6JZXIM.js +4 -0
  77. package/dist-cli/chunks/inspect-KXJNI7CU.js +4 -0
  78. package/dist-cli/chunks/install-desktop-IYWPRFPB.js +4 -0
  79. package/dist-cli/chunks/{login-GF6WVVER.js → login-LB4TMM4T.js} +4 -4
  80. package/dist-cli/chunks/{logout-6F6UKUNI.js → logout-33IOBD4X.js} +2 -2
  81. package/dist-cli/chunks/{maestro-FMPKHEMX.js → maestro-EEVXX536.js} +3 -3
  82. package/dist-cli/chunks/{maestro-generate-QGPGNXI6.js → maestro-generate-ICPWVXGA.js} +3 -3
  83. package/dist-cli/chunks/{mode-JSNMAHDZ.js → mode-6IXOZDK3.js} +2 -2
  84. package/dist-cli/chunks/{optional-demo-registry-K4VERLJV.js → optional-demo-registry-KBMC7SNI.js} +2 -2
  85. package/dist-cli/chunks/{perf-PO7ARUTG.js → perf-CTTJSAIJ.js} +2 -2
  86. package/dist-cli/chunks/{permissions-XI2QUAEZ.js → permissions-BFQS4DIY.js} +2 -2
  87. package/dist-cli/chunks/{record-4CJCJAFD.js → record-MJR5ELHE.js} +3 -3
  88. package/dist-cli/chunks/report-issue-FMJRNDKH.js +29 -0
  89. package/dist-cli/chunks/runtime-PV4HH2OB.js +4 -0
  90. package/dist-cli/chunks/{screenshot-command-NDVULWMZ.js → screenshot-command-MGNASAXR.js} +3 -3
  91. package/dist-cli/chunks/{screenshots-capture-Q7UTXF3V.js → screenshots-capture-N6PANAVT.js} +2 -2
  92. package/dist-cli/chunks/serve-RS6TIO7U.js +44 -0
  93. package/dist-cli/chunks/setup-MFYGYR2F.js +32 -0
  94. package/dist-cli/chunks/{skills-NFG6VAO5.js → skills-TD35LDKK.js} +2 -2
  95. package/dist-cli/chunks/{storage-POWCOUCQ.js → storage-VCFXDJNO.js} +2 -2
  96. package/dist-cli/chunks/store-VNSTKYBQ.js +4 -0
  97. package/dist-cli/chunks/telemetry-GPNHSYFF.js +4 -0
  98. package/dist-cli/chunks/{timeline-MNHZCVAL.js → timeline-UJCZAWJV.js} +2 -2
  99. package/dist-cli/chunks/upgrade-S24NH4YG.js +7 -0
  100. package/dist-cli/chunks/upload-CCKAO2M5.js +4 -0
  101. package/dist-cli/chunks/version-IVPWT2ZQ.js +6 -0
  102. package/dist-cli/chunks/web-6BMWAWJL.js +4 -0
  103. package/dist-cli/chunks/{what-happened-H74HHGRK.js → what-happened-HRHB6ETL.js} +2 -2
  104. package/dist-lib/agent-daemon-client.cjs +2 -1
  105. package/dist-lib/agent-events.cjs +1 -1
  106. package/dist-lib/agent-identity.cjs +1 -1
  107. package/dist-lib/agent-sessions.cjs +1 -1
  108. package/dist-lib/attached-projects.cjs +1 -1
  109. package/dist-lib/auth/shared-session.cjs +1 -1
  110. package/dist-lib/backend-origin.cjs +1 -1
  111. package/dist-lib/beta.cjs +1 -1
  112. package/dist-lib/beta.mjs +1 -1
  113. package/dist-lib/bridge-constants.cjs +4 -1
  114. package/dist-lib/cli-constants.cjs +1 -1
  115. package/dist-lib/config.cjs +3 -2
  116. package/dist-lib/detox/index.cjs +1 -1
  117. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  118. package/dist-lib/home-paths.cjs +41 -14
  119. package/dist-lib/host/bridge-host.cjs +216 -84
  120. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  121. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  122. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  123. package/dist-lib/host/websocket-proxy.cjs +1 -1
  124. package/dist-lib/index.cjs +5 -2
  125. package/dist-lib/jump-to-source-babel.cjs +1 -1
  126. package/dist-lib/menu.cjs +2 -3
  127. package/dist-lib/menu.mjs +2 -3
  128. package/dist-lib/metro.cjs +1 -1
  129. package/dist-lib/profiles.cjs +1 -1
  130. package/dist-lib/render-mode.cjs +1 -1
  131. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  132. package/dist-lib/sdk.cjs +1 -1
  133. package/dist-lib/sdk.mjs +1 -1
  134. package/dist-lib/skills.cjs +373 -159
  135. package/dist-lib/vite.cjs +3 -2
  136. package/package.json +2 -1
  137. package/scripts/postinstall.cjs +2 -78
  138. package/skills/contrast/SKILL.md +3 -2
  139. package/skills/sootsim-setup/SKILL.md +25 -0
  140. package/src/bridge-constants.ts +1 -0
  141. package/src/config.ts +4 -0
  142. package/src/disk-cleanup.ts +5 -26
  143. package/src/home-paths.ts +58 -23
  144. package/src/host/bridge-host.ts +152 -57
  145. package/src/index.ts +4 -1
  146. package/src/menu.ts +0 -1
  147. package/src/runtime-assets.ts +35 -0
  148. package/src/runtime-delivery.ts +5 -8
  149. package/src/skills/builtin/compat-check.ts +32 -65
  150. package/dist-cli/chunks/app-fonts-IMYBO6AQ.js +0 -4
  151. package/dist-cli/chunks/chunk-37ZXWXM3.js +0 -4
  152. package/dist-cli/chunks/chunk-3F2GAJ4Z.js +0 -6
  153. package/dist-cli/chunks/chunk-5S3GPTX7.js +0 -6
  154. package/dist-cli/chunks/chunk-6YN3IAWJ.js +0 -4
  155. package/dist-cli/chunks/chunk-7Q77LTPT.js +0 -15
  156. package/dist-cli/chunks/chunk-BBVBMGTT.js +0 -31
  157. package/dist-cli/chunks/chunk-CTMPC5DN.js +0 -6
  158. package/dist-cli/chunks/chunk-JFWEDISV.js +0 -120
  159. package/dist-cli/chunks/chunk-JGGXQHXH.js +0 -10
  160. package/dist-cli/chunks/chunk-OKSGM6IG.js +0 -4
  161. package/dist-cli/chunks/chunk-SPQKJDIK.js +0 -4
  162. package/dist-cli/chunks/chunk-W44PDEQH.js +0 -4
  163. package/dist-cli/chunks/chunk-WQL3BLFD.js +0 -9
  164. package/dist-cli/chunks/chunk-XYFP466E.js +0 -12
  165. package/dist-cli/chunks/chunk-ZFMJFX27.js +0 -4
  166. package/dist-cli/chunks/cleanup-74SKOD2P.js +0 -25
  167. package/dist-cli/chunks/compat-ME6HXEEU.js +0 -35
  168. package/dist-cli/chunks/config-PM67EWT3.js +0 -13
  169. package/dist-cli/chunks/control-HV7GZXAH.js +0 -4
  170. package/dist-cli/chunks/daemon-LKRHF5OK.js +0 -4
  171. package/dist-cli/chunks/disk-cleanup-DDCFGFWK.js +0 -4
  172. package/dist-cli/chunks/drivers-C2SH3DWS.js +0 -4
  173. package/dist-cli/chunks/flow-E64G5LF3.js +0 -4
  174. package/dist-cli/chunks/help-4ZSRG4F4.js +0 -4
  175. package/dist-cli/chunks/home-paths-5L7N2FLS.js +0 -4
  176. package/dist-cli/chunks/inspect-U2SV25ER.js +0 -4
  177. package/dist-cli/chunks/install-desktop-LTGVT7ID.js +0 -4
  178. package/dist-cli/chunks/runtime-SN2RWDES.js +0 -4
  179. package/dist-cli/chunks/serve-UEUIBHCK.js +0 -44
  180. package/dist-cli/chunks/setup-ZEEWYK4B.js +0 -99
  181. package/dist-cli/chunks/store-BJK7V7FL.js +0 -4
  182. package/dist-cli/chunks/telemetry-EJP5EW7K.js +0 -4
  183. package/dist-cli/chunks/upgrade-X57SIG7L.js +0 -6
  184. package/dist-cli/chunks/upload-JABM3ITZ.js +0 -4
  185. package/dist-cli/chunks/version-V4IKIDX7.js +0 -6
  186. package/dist-cli/chunks/web-F5CLF34I.js +0 -4
@@ -0,0 +1,44 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{b as ge,c as J,d as Se,e as K,f as ye,h as ve,i as E,j as be,k as we,l as Ae,m as ke,q as Te,t as k,u as Ce,v as Ie,w as Ee,x as Pe}from"./chunk-4MDLYOEI.js";import"./chunk-TIOPG6QZ.js";import{e as fe}from"./chunk-7V3JNANH.js";import"./chunk-AUBP44CY.js";import{g as _,h as ue,i as pe,k as L,l as me}from"./chunk-ZPBIHFQW.js";import"./chunk-GG5PWLGC.js";import"./chunk-F2MS365Z.js";import{d as he}from"./chunk-EJ6BAJKX.js";import"./chunk-B2LDO55K.js";import"./chunk-ZIBKGZJD.js";import"./chunk-IR3DUBRF.js";import{a as F,b as G,c as oe,d as ae}from"./chunk-LHUY46GE.js";import"./chunk-MQ6QX46T.js";import{f as x}from"./chunk-EISE56VD.js";import{b as de,c as le}from"./chunk-2LQOLMRK.js";import"./chunk-7GQWF7HE.js";import{E as Y,G as O,H as j,I as Z,J as Q,K as ee,M as te,P as ie,Q as re,R as ne,S as $,T as se,g as q,h as z,y as W,z as X}from"./chunk-WJVBD2UL.js";import{a as ce}from"./chunk-QIDFGREY.js";import"./chunk-X7B5KJ6N.js";import{spawn as gt}from"child_process";import C from"fs";import{createServer as St}from"http";import w from"path";import{WebSocket as g,WebSocketServer as yt}from"ws";import Oe from"node:fs";import B from"node:path";import{spawn as Je}from"node:child_process";function Ke(o){return typeof o.text=="string"?o.text.trim():""}function Ve(o){let e=o?.trim();return e||"tm"}async function Re(o){let e=o.sessionId.trim();if(!G(e))throw new Error(`invalid Team Machine session id: ${e||"<empty>"}`);let t=Ke(o.prompt);if(!t)throw new Error("prompt text is empty");let i=Ve(o.command),s=o.timeoutMs??15e3;await new Promise((n,c)=>{let r=Je(i,["send",e,t],{stdio:["ignore","ignore","pipe"],env:process.env}),a="",l=setTimeout(()=>{try{r.kill("SIGTERM")}catch{}c(new Error(`tm send timed out after ${Math.round(s/1e3)}s`))},s);r.stderr?.setEncoding("utf8"),r.stderr?.on("data",d=>{a.length<4e3&&(a+=String(d))}),r.on("error",d=>{clearTimeout(l),c(d)}),r.on("exit",(d,p)=>{if(clearTimeout(l),d===0){n();return}let u=a.trim();c(new Error(u||`tm send exited with ${p?`signal ${p}`:`code ${d??"unknown"}`}`))})})}var M=1,Ge=25;function qe(){return[Number(process.env.VITE_PORT_WEB||process.env.PORT||3e3),Number(process.env.VITE_PORT_ZERO||7849),Number(process.env.VITE_PORT_R2||9500)].filter(o=>Number.isFinite(o)&&o>0)}var D=class{subscriptions=new Map;sessionsBySocket=new Map;allSockets=new Set;pendingPromptEchoes=new Map;pendingTurns=new Map;pendingSessionStates=new Map;pendingSessionPatches=new Map;sessionStatusPersistTimer=null;opts;constructor(e={}){this.opts=e}registerSocket(e){this.allSockets.add(e)}unregisterSocket(e){let t=this.sessionsBySocket.get(e);if(t){for(let i of t)this.decrementSubscription(i);this.sessionsBySocket.delete(e)}this.allSockets.delete(e)}async handleMessage(e,t){let i=t?.type;if(typeof i!="string"||!i.startsWith("agent:"))return!1;let s=t.id;try{let n=await this.dispatch(e,i,t);this.respond(e,s,n)}catch(n){n instanceof k?this.respondError(e,s,n.message,n.code):this.respondError(e,s,n instanceof Error?n.message:String(n))}return!0}async seedOnBoot(){try{await ke()}catch(e){process.stderr.write(`[sootsim-agent] seedFromDemoAppRegistry failed: ${e instanceof Error?e.message:String(e)}
5
+ `)}}close(){this.sessionStatusPersistTimer&&(clearTimeout(this.sessionStatusPersistTimer),this.sessionStatusPersistTimer=null),this.flushSessionStatuses();for(let e of this.subscriptions.values())try{e.unsubscribe()}catch{}this.subscriptions.clear(),this.sessionsBySocket.clear(),this.allSockets.clear()}async dispatch(e,t,i){switch(t){case"agent:list-projects":return K();case"agent:upsert-project":return J(i.input??{});case"agent:delete-project":return ve(String(i.projectId)),{ok:!0};case"agent:auto-attach-for-url":return this.autoAttachForUrl(i.input??{});case"agent:list-sessions":return be(i.projectId?String(i.projectId):void 0);case"agent:start-session":return this.doStartSession(i.input??{});case"agent:send-claimed-prompt":return this.sendClaimedPrompt(i);case"agent:send-prompt":{let n=String(i.sessionId),c=E(n);if(!c)throw new k("NO_SESSION",`no session: ${n}`);let r=this.normalizePromptEnvelope(i);return await Ie(n,r),this.notePromptAccepted(n,r,c.status==="working")}case"agent:end-session":this.dropSessionFanout(String(i.sessionId)),await Ee(String(i.sessionId));let s=E(String(i.sessionId));return s&&this.broadcastSessionStatus(s),{ok:!0};case"agent:get-transcript":return this.getTranscript(String(i.sessionId));case"agent:get-paths":return this.getPaths();case"agent:subscribe-events":return this.subscribeSocket(e,String(i.sessionId));case"agent:unsubscribe-events":return this.unsubscribeSocket(e,String(i.sessionId));default:throw new k("UNKNOWN_AGENT_MSG",`unknown agent message: ${t}`)}}async sendClaimedPrompt(e){let t=typeof e.simId=="string"?e.simId.trim():"";if(!t)throw new k("NO_SIM","agent:send-claimed-prompt requires simId");let i=this.opts.resolveCliLease?.(t)??null;if(!i||i.kind!=="cli"||i.expiresAt<=Date.now())throw new k("NO_CLAIM",`sim ${t} has no active CLI claim`);let s=F(i.cliIdentityKey);if(!s)throw new k("UNSUPPORTED_CLAIM",`sim ${t} is claimed by a CLI identity that is not promptable`);return await Re({sessionId:s,prompt:this.normalizePromptEnvelope(e)}),{ok:!0,routed:"team-machine",sessionId:s}}async doStartSession(e){if(!Se(e.projectId))throw new k("NO_PROJECT",`no project: ${e.projectId}`);let i=await Ce(e);return this.broadcastSessionStatus(i.session),i}async autoAttachForUrl(e){let t=e.bundleUrl??"",i=(()=>{try{return new URL(t).port||null}catch{return null}})();if(!i)return{project:null};let s=this.opts.getExcludePorts?.()??qe(),c=(await _({excludePorts:s})).find(d=>String(d.port)===i);if(!c||!c.cwd)return{project:null};let r=K().find(d=>d.cwd===c.cwd)??null,a=Array.from(new Set([...r?.knownBundleUrls??[],c.bundleUrl,t]));return{project:J({cwd:c.cwd,name:c.projectName??B.basename(c.cwd),preferredProvider:e.provider??r?.preferredProvider,sourceRoots:r?.sourceRoots??[c.cwd],knownBundleUrls:a,framework:r?.framework??ze(c.framework),bundleId:c.bundleId??r?.bundleId})}}getTranscript(e){let t=Te(e);return Oe.existsSync(t)?Oe.readFileSync(t,"utf8"):{error:"transcript not found",code:"NO_TRANSCRIPT"}}getPaths(){let e=ge();return{userDataDir:e,storeFile:B.join(e,"attached-projects.json"),sessionsDir:B.join(e,"sessions"),transcriptsDir:B.join(e,"transcripts")}}subscribeSocket(e,t){let i=this.sessionsBySocket.get(e);if(i||(i=new Set,this.sessionsBySocket.set(e,i)),i.has(t))return{ok:!0,refCount:this.subscriptions.get(t)?.refCount??1};i.add(t);let s=this.subscriptions.get(t);if(s)return s.refCount++,{ok:!0,refCount:s.refCount};let n=Pe(t,c=>{let r=this.coalescePromptEcho(t,c);if(r&&(this.applySessionEvent(t,r),this.fanOutEvent(t,r)),c.type==="turn-completed"){let a=E(t);if(a)try{ye(a.projectId,{usd:c.costUsd,ts:c.ts})}catch(l){process.stderr.write(`[sootsim-agent] recordTurnTelemetry failed: ${l instanceof Error?l.message:String(l)}
6
+ `)}}});return this.subscriptions.set(t,{unsubscribe:n,refCount:1}),{ok:!0,refCount:1}}unsubscribeSocket(e,t){let i=this.sessionsBySocket.get(e);return!i||!i.has(t)?{ok:!0,refCount:0}:(i.delete(t),this.decrementSubscription(t))}decrementSubscription(e){let t=this.subscriptions.get(e);if(!t)return{ok:!0,refCount:0};if(t.refCount--,t.refCount<=0){try{t.unsubscribe()}catch{}return this.subscriptions.delete(e),{ok:!0,refCount:0}}return{ok:!0,refCount:t.refCount}}dropSessionFanout(e){let t=this.subscriptions.get(e);if(t){try{t.unsubscribe()}catch{}this.subscriptions.delete(e)}for(let i of this.sessionsBySocket.values())i.delete(e);this.clearPromptTracking(e)}normalizePromptEnvelope(e){if(e?.prompt&&typeof e.prompt=="object"){let t=e.prompt;return{text:String(t.text??""),...typeof t.displayText=="string"?{displayText:t.displayText}:{},...typeof t.inspectSummary=="string"?{inspectSummary:t.inspectSummary}:{},...typeof t.inspectTrace=="string"?{inspectTrace:t.inspectTrace}:{}}}return{text:String(e?.text??""),...typeof e?.displayText=="string"?{displayText:e.displayText}:{},...typeof e?.inspectSummary=="string"?{inspectSummary:e.inspectSummary}:{},...typeof e?.inspectTrace=="string"?{inspectTrace:e.inspectTrace}:{}}}notePromptAccepted(e,t,i){let s=Date.now(),n=this.pendingPromptEchoes.get(e)??[];n.push({sentAt:s}),this.pendingPromptEchoes.set(e,n);let c=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,c);let r=t.displayText??t.text;return this.patchSession(e,{lastPrompt:r,status:"working",needsAttention:!1}),this.fanOutEvent(e,{type:"prompt-received",text:r,...t.inspectSummary?{inspectSummary:t.inspectSummary}:{},...t.inspectTrace?{inspectTrace:t.inspectTrace}:{},ts:s}),{ok:!0,queued:c>1,pendingTurns:c,queueDepth:Math.max(0,c-1)}}applySessionEvent(e,t){switch(t.type){case"prompt-received":case"turn-started":this.patchSession(e,{status:"working",needsAttention:!1});return;case"turn-completed":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"idle",needsAttention:!1,lastTurnFiles:t.filesTouched,currentlyEditing:void 0});return}case"approval-needed":this.patchSession(e,{status:"needs-attention",needsAttention:!0});return;case"error":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"needs-attention",needsAttention:i<=0,currentlyEditing:void 0});return}case"exited":this.clearPromptTracking(e),this.patchSession(e,{status:"ended",needsAttention:!1,wrapperPid:void 0,currentlyEditing:void 0});return;case"ready":case"turn-reasoning":case"turn-message":case"turn-plan":case"tool-call":case"file-edited":case"file-diff-delta":return}}patchSession(e,t){let i=this.pendingSessionStates.get(e)??E(e);if(!i)return;let s=we(i,t);this.pendingSessionStates.set(e,s),this.pendingSessionPatches.set(e,{...this.pendingSessionPatches.get(e),...t}),this.broadcastSessionStatus(s),!this.sessionStatusPersistTimer&&(this.sessionStatusPersistTimer=setTimeout(()=>{this.sessionStatusPersistTimer=null,this.flushSessionStatuses()},Ge))}flushSessionStatuses(){if(this.pendingSessionPatches.size===0)return;let e=this.pendingSessionStates,t=this.pendingSessionPatches;this.pendingSessionStates=new Map,this.pendingSessionPatches=new Map;try{Ae([...t].map(([i,s])=>({id:i,patch:s})))}catch(i){for(let[s,n]of e)this.pendingSessionStates.has(s)||this.pendingSessionStates.set(s,n);for(let[s,n]of t)this.pendingSessionPatches.set(s,{...n,...this.pendingSessionPatches.get(s)});process.stderr.write(`[sootsim-agent] session status persistence failed: ${i instanceof Error?i.message:String(i)}
7
+ `)}}coalescePromptEcho(e,t){if(t.type!=="prompt-received")return t;let i=this.pendingPromptEchoes.get(e);if(!i||i.length===0)return t;for(;i.length>0&&Date.now()-i[0].sentAt>15e3;)i.shift();return i.length===0?(this.pendingPromptEchoes.delete(e),t):(i.shift(),i.length===0?this.pendingPromptEchoes.delete(e):this.pendingPromptEchoes.set(e,i),null)}consumeSettledTurn(e){let t=Math.max(0,(this.pendingTurns.get(e)??1)-1);return t>0?this.pendingTurns.set(e,t):this.pendingTurns.delete(e),t}clearPromptTracking(e){this.pendingPromptEchoes.delete(e),this.pendingTurns.delete(e)}fanOutEvent(e,t){let i=JSON.stringify({type:"agent:event",sessionId:e,event:t});for(let[s,n]of this.sessionsBySocket)if(n.has(e)&&s.readyState===M)try{s.send(i)}catch{}}broadcastSessionStatus(e){let t=JSON.stringify({type:"agent:session-status",session:e});for(let i of this.allSockets)if(i.readyState===M)try{i.send(t)}catch{}}respond(e,t,i){if(e.readyState===M)try{e.send(JSON.stringify({id:t,result:i}))}catch{}}respondError(e,t,i,s){if(e.readyState===M)try{e.send(JSON.stringify({id:t,error:i,...s?{code:s}:{}}))}catch{}}};function ze(o){return o==="expo"?"expo":o==="one"||o==="vxrn"?"one":"unknown"}import _e from"http";import Le from"https";import{finished as Ze,pipeline as Qe}from"stream/promises";var V="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",Xe=[{hostSuffix:"uniswap.org",headers:{origin:"https://app.uniswap.org",referer:"https://app.uniswap.org/"},suppressBrowserUserAgent:!0}];function Ye(o){let e=o.toLowerCase();for(let t of Xe)if(e===t.hostSuffix||e.endsWith(`.${t.hostSuffix}`))return t}function xe(o){let e=Ye(o.hostname);return{"accept-encoding":"identity",...e?.suppressBrowserUserAgent?{}:{"user-agent":V},...e?.headers}}var et=new Set(["host","origin","referer","user-agent","accept-encoding","cookie","connection","keep-alive","transfer-encoding","upgrade","content-length","sec-fetch-site","sec-fetch-mode","sec-fetch-dest","sec-ch-ua","sec-ch-ua-mobile","sec-ch-ua-platform"]),tt={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,PUT,DELETE,PATCH,OPTIONS","access-control-allow-headers":"*","access-control-expose-headers":"*","access-control-max-age":"3600"},it=new Set(["host","origin","referer","sec-fetch-site","sec-fetch-mode","sec-fetch-dest"]);function Be(o){return o.protocol!=="https:"?{}:ue(o.hostname)?{rejectUnauthorized:!1}:{}}function P(o){for(let[e,t]of Object.entries(tt))o.setHeader(e,t)}function rt(o,e){let t=[],i=e;i?.code&&t.push(i.code),i?.message&&t.push(i.message),i?.cause?.code&&t.push(i.cause.code),i?.cause?.message&&t.push(i.cause.message);let n=[...new Set(t.filter(Boolean))].join(" | ")||String(e);return o.includes("stored-in-.env.local")?`${n} | upstream url still contains placeholder env values`:n}function nt(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(et.has(i.toLowerCase())||(t[i]=Array.isArray(s)?s.join(", "):s));return Object.assign(t,e?xe(e):{"user-agent":V}),t}function st(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(it.has(i.toLowerCase())||(t[i]=s));return t.host=e.host,t.origin=e.origin,t.referer=`${e.origin}/`,t}function Me(o){return o?.startsWith("/__fetch-proxy?")||o?.startsWith("/__proxy?")||!1}function De(o){return o?!!(o.startsWith("/__app-api?")||o.startsWith("/__app-api/")):!1}async function Ne(o,e){if(o.method==="OPTIONS"){P(e),e.writeHead(204),e.end();return}let i=new URLSearchParams((o.url||"").split("?")[1]||"").get("url");if(!i){P(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("missing url param");return}let s;try{s=new URL(i)}catch{P(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("invalid url param");return}let n;if(o.method!=="GET"&&o.method!=="HEAD"){let a=[];for await(let l of o)a.push(Buffer.isBuffer(l)?l:Buffer.from(l));a.length>0&&(n=Buffer.concat(a))}let c=o.method||"GET",r=async(a,l,d,p)=>{let u=a.protocol==="https:"?Le:_e,h=nt(o.headers,a);a.origin!==s.origin&&(delete h.authorization,delete h["proxy-authorization"]),l==="GET"||l==="HEAD"?(delete h["content-length"],delete h["content-type"]):d&&(h["content-length"]=String(d.byteLength));let m=await new Promise((b,v)=>{let y=u.request({hostname:a.hostname,port:a.port||(a.protocol==="https:"?443:80),path:a.pathname+a.search,method:l,headers:h,...Be(a)},b),R=()=>y.destroy(new Error("fetch proxy client disconnected"));o.once("aborted",R),y.once("close",()=>o.off("aborted",R)),y.once("error",v),d===void 0?y.end():y.end(d)}),f=m.statusCode??502,S=m.headers.location;if(S&&(f===301||f===302||f===303||f===307||f===308)){if(p>=10)throw m.destroy(),new Error("too many redirects");let b=(f===301||f===302)&&l==="POST"||f===303&&l!=="GET"&&l!=="HEAD",v=new URL(S,a);m.resume(),await Ze(m),await r(v,b?"GET":l,b?void 0:d,p+1);return}for(let[b,v]of Object.entries(m.headers)){let y=b.toLowerCase();v===void 0||y==="set-cookie"||y==="connection"||y==="keep-alive"||y==="proxy-authenticate"||y==="proxy-authorization"||y==="te"||y==="trailer"||y==="transfer-encoding"||y==="upgrade"||y.startsWith("access-control-")||e.setHeader(b,v)}P(e);let A=m.headers["set-cookie"]??[];A.length>0&&e.setHeader("x-sootsim-set-cookie",(Array.isArray(A)?A:[A]).join(", ")),e.statusCode=f,await Qe(m,e)};try{await r(s,c,n,0)}catch(a){if(e.headersSent){e.destroy(a instanceof Error?a:new Error(String(a)));return}P(e),e.writeHead(502,{"Content-Type":"text/plain"}),e.end(`fetch proxy error: ${rt(s.href,a)}`)}}function He(o,e){let t=o.url||"",i="",s="";if(t.startsWith("/__app-api?")){let l=new URL(t,"http://sootsim.local");i=l.searchParams.get("path")||"",s=l.searchParams.get("origin")?.trim()||""}else if(t.startsWith("/__app-api/"))i=t.slice(10);else return!1;if(!s)return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: missing origin query param"),!0;if(o.method==="OPTIONS")return e.writeHead(204,{"Access-Control-Allow-Origin":o.headers.origin||"*","Access-Control-Allow-Methods":"GET,POST,PUT,PATCH,DELETE,OPTIONS","Access-Control-Allow-Headers":o.headers["access-control-request-headers"]||"*","Access-Control-Allow-Credentials":"true","Access-Control-Max-Age":"86400"}),e.end(),!0;let n;try{n=new URL(i,s)}catch{return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: invalid origin or path"),!0}let c=n.protocol==="https:"?Le:_e,r=st(o.headers,n),a=c.request({hostname:n.hostname,port:n.port||(n.protocol==="https:"?443:80),path:n.pathname+n.search,method:o.method,headers:r,...Be(n)},l=>{let d=Object.keys(l.headers).filter(p=>{let u=p.toLowerCase();return!u.startsWith("access-control-")&&u!=="set-cookie"}).join(", ");e.writeHead(l.statusCode??502,{...l.headers,"access-control-allow-origin":o.headers.origin||"*","access-control-allow-credentials":"true","access-control-expose-headers":d}),l.pipe(e)});return a.on("error",l=>{e.statusCode=502,e.end(`app proxy error: ${l.message}`)}),o.pipe(a),!0}import{WebSocket as T,WebSocketServer as ot}from"ws";var at="/__websocket-proxy",ct=new Set(["host","connection","upgrade","transfer-encoding","content-length","sec-websocket-accept","sec-websocket-extensions","sec-websocket-key","sec-websocket-protocol","sec-websocket-version"]);function I(o,e,t){try{o.write(`HTTP/1.1 ${e} ${t}\r
8
+ Connection: close\r
9
+ Content-Type: text/plain\r
10
+ Content-Length: ${t.length}\r
11
+ \r
12
+ ${t}`)}catch{}o.destroy()}function dt(o){let e=o.headers.origin,t=o.headers.host;if(!e||!t)return!1;try{return new URL(e).host===t}catch{return!1}}function lt(o){if(!o)return{};let e=o.replace(/-/g,"+").replace(/_/g,"/"),t=e+"=".repeat((4-e.length%4)%4),i=JSON.parse(Buffer.from(t,"base64").toString("utf8"));if(!i||typeof i!="object"||Array.isArray(i))return{};let s={};for(let[n,c]of Object.entries(i))c!=null&&(ct.has(n.toLowerCase())||(s[n]=Array.isArray(c)?c.join(", "):String(c)));return s}function ut(o){let e=new URL(o.href);return e.protocol=o.protocol==="wss:"?"https:":"http:",e.origin}function pt(o){let e=o.headers["sec-websocket-protocol"];return(Array.isArray(e)?e.join(","):e||"").split(",").map(i=>i.trim()).filter(Boolean)}function N(o,e,t){if(!(o.readyState===T.CLOSED||o.readyState===T.CLOSING))try{o.close(e,t)}catch{o.terminate()}}function mt(o,e){let t=!1,i=(s,n,c,r)=>{t||(t=!0,N(n,c,r.toString()),s.readyState===T.OPEN&&N(s,c,r.toString()))};o.on("message",(s,n)=>{e.readyState===T.OPEN&&e.send(s,{binary:n})}),e.on("message",(s,n)=>{o.readyState===T.OPEN&&o.send(s,{binary:n})}),o.on("close",(s,n)=>i(o,e,s,n)),e.on("close",(s,n)=>i(e,o,s,n)),o.on("error",()=>N(e,1011,"proxy client error")),e.on("error",()=>N(o,1011,"upstream websocket error"))}function ht(o,e,t,i){let s={...t},n=Object.keys(s).filter(c=>c.toLowerCase()==="origin");if(i&&n.length===0)s.origin=ut(o);else if(!i)for(let c of n)delete s[c];return Object.keys(s).length===0?new T(o.href,e):new T(o.href,e,{headers:s})}function ft(o){if(!o)return!1;try{return new URL(o,"http://localhost").pathname===at}catch{return!1}}function Ue(o,e,t,i=!0){if(!ft(o.url))return!1;if(!dt(o))return I(e,403,"forbidden websocket proxy origin"),!0;let s,n;try{let l=new URL(o.url||"/","http://localhost"),d=l.searchParams.get("url");if(!d)return I(e,400,"missing websocket proxy url"),!0;if(s=new URL(d),s.protocol!=="ws:"&&s.protocol!=="wss:")return I(e,400,"invalid websocket proxy protocol"),!0;n=lt(l.searchParams.get("headers"))}catch{return I(e,400,"invalid websocket proxy request"),!0}let c=pt(o),r=ht(s,c,n,i),a=!1;return e.once("close",()=>{a||r.terminate()}),r.once("open",()=>{if(a)return;a=!0;let l=r.protocol;new ot({noServer:!0,clientTracking:!1,handleProtocols(p){return l||p.values().next().value||!1}}).handleUpgrade(o,e,t,p=>{mt(p,r)})}),r.once("error",()=>{a||(a=!0,I(e,502,"upstream websocket error"))}),r.once("close",()=>{a||(a=!0,I(e,502,"upstream websocket closed"))}),!0}var vt="require-corp",bt=new Set(["tap","keyboard"]),wt=2e3,At=1e3;function kt(o){return!o||typeof o.type!="string"?!1:o.acquireLock===!0?!0:o.readOnly===!0?!1:bt.has(o.type)}var Fe=5e3,Tt=3600*1e3,Ct="SOOTSIM_RUNTIME_UPDATE_INTERVAL_MS",It={".html":"text/html; charset=utf-8",".js":"application/javascript",".cjs":"application/javascript",".mjs":"application/javascript",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".wasm":"application/wasm",".ttf":"font/ttf",".otf":"font/otf",".woff":"font/woff",".woff2":"font/woff2",".map":"application/json",".txt":"text/plain; charset=utf-8"};function We(o,e,t){let i;try{let a=W();i=JSON.stringify(a)}catch{i="{}"}let s=e>0?`window.__sootsimBridgePort=${e};`:"",n=t?`window.__sootsimContrastOrigin=${JSON.stringify(t)};`:"",c=`<script>window.__sootsimSharedConfig=${i};`+s+n+`window.__sootsimCliVersion=${JSON.stringify(ce())};</script>`,r=o.toString("utf8");return r.includes("<head>")?r.replace("<head>",`<head>${c}`):r.includes("</head>")?r.replace("</head>",c+"</head>"):r.includes("</body>")?r.replace("</body>",c+"</body>"):c+r}function je(o){typeof o=="object"&&o!==null&&"unref"in o&&o.unref()}var H=class o{port;openUrlHandler;httpServer=null;wss=null;nextCommandId=1;nextSimNumber=161;sims=new Map;primarySimId=null;pendingCommands=new Map;cliBySentId=new Map;cliSimBySocket=new Map;cliLastCommandAt=new Map;cliIdentityKeyBySocket=new Map;cliLabelBySocket=new Map;restorableSims=new Map;nextCliFallbackId=1;cliIdleTimer=null;agentHost;static CLI_IDLE_TIMEOUT_MS=6e4;static CLI_LEASE_TTL_MS=6e5;static USER_ACTIVE_LEASE_TTL_MS=8e3;static USER_BOOT_LEASE_TTL_MS=6e4;static SIM_RECONNECT_TTL_MS=3e4;static SIM_IDLE_REAP_TTL_MS=30*6e4;static AUTOMATION_SIM_IDLE_REAP_TTL_MS=10*6e4;static MAX_CONCURRENT_AUTOMATION_SIMS=6;static AUTOMATION_SIM_ACTIVE_GRACE_MS=6e4;preferredPort;portFallbackCount;simIdleReapTtlMs;automationSimIdleReapTtlMs;maxConcurrentAutomationSims;automationSimActiveGraceMs;shouldWriteLockfile;shouldWriteDevLockfile;getShellPort;contrastOrigin=null;effectivePort=0;startedAt=0;heartbeatTimer=null;devHeartbeatTimer=null;wsHeartbeatTimer=null;wsIsAlive=new WeakMap;static WS_HEARTBEAT_INTERVAL_MS=3e4;runtimeUpdateTimer=null;runtimeUpdateInFlight=null;activeRuntimeVersion=null;activeRuntimeDirPath=null;scanCache=null;scanCacheAt=0;inflightScan=null;static SCAN_FRESH_MS=2e3;constructor(e={}){this.preferredPort=e.port||7668,this.port=this.preferredPort,this.shouldWriteLockfile=e.writeLockfile===!0,this.shouldWriteDevLockfile=e.writeDevLockfile===!0,this.getShellPort=e.getShellPort??null,this.portFallbackCount=Math.max(1,e.portFallbackCount??10),this.openUrlHandler=e.openUrl,this.agentHost=new D({getExcludePorts:e.agentScanExcludes,resolveCliLease:t=>{let i=this.sims.get(t),s=i?this.getActiveLease(i):null;return s?{kind:s.kind,cliIdentityKey:s.cliIdentityKey,expiresAt:s.expiresAt}:null}}),this.contrastOrigin=e.contrastOrigin?.replace(/\/$/,"")||null,this.simIdleReapTtlMs=e.simIdleReapTtlMs??o.SIM_IDLE_REAP_TTL_MS,this.automationSimIdleReapTtlMs=e.automationSimIdleReapTtlMs??o.AUTOMATION_SIM_IDLE_REAP_TTL_MS,this.maxConcurrentAutomationSims=e.maxConcurrentAutomationSims??o.MAX_CONCURRENT_AUTOMATION_SIMS,this.automationSimActiveGraceMs=e.automationSimActiveGraceMs??o.AUTOMATION_SIM_ACTIVE_GRACE_MS}getAgentHost(){return this.agentHost}reapIdleSimsForTest(e=Date.now()){this.reapIdleSims(e)}start(e){this.startAsync(e)}async startAsync(e){if(this.httpServer||this.wss)return this.effectivePort;this.refreshActiveRuntime();for(let t=0;t<this.portFallbackCount;t++){let i=this.preferredPort+t;try{return await this.bindOnce(i,e?.silent===!0),this.effectivePort=i,this.port=i,this.startedAt=Date.now(),t>0&&!e?.silent&&process.stderr.write(`ws bridge bound to port ${i} (preferred ${this.preferredPort} was taken)
13
+ `),this.afterBind(),i}catch(s){if(s?.code!=="EADDRINUSE")throw s;e?.silent||process.stderr.write(`ws bridge port ${i} already in use, trying ${i+1}
14
+ `)}}throw new Error(`could not bind ws bridge after ${this.portFallbackCount} attempts starting at ${this.preferredPort}`)}bindOnce(e,t){return new Promise((i,s)=>{let n=St((a,l)=>this.handleHttpRequest(a,l)),c=!1,r=a=>{if(!c){c=!0;try{n.close()}catch{}this.httpServer=null,this.wss=null,s(a)}};n.once("error",r),n.listen(e,"127.0.0.1",()=>{c||(c=!0,n.removeListener("error",r),n.on("error",a=>{process.stderr.write(`ws bridge http error: ${String(a)}
15
+ `)}),this.httpServer=n,this.wss=new yt({noServer:!0}),this.wireWebSocketServer(),n.on("upgrade",(a,l,d)=>{Ue(a,l,d)||this.wss?.handleUpgrade(a,l,d,p=>{this.wss?.emit("connection",p,a)})}),i())})})}wireWebSocketServer(){this.wss&&this.wss.on("connection",(e,t)=>{let i=t.headers.origin,s=i?"sim":"cli",n=null;if(e.on("error",()=>{}),this.wsIsAlive.set(e,!0),e.on("pong",()=>{this.wsIsAlive.set(e,!0)}),this.agentHost.registerSocket(e),s==="sim")n={id:this.allocateSimId(),ws:e,origin:i,connectedAt:Date.now(),lastSeenAt:Date.now(),lastActiveAt:0,recentActions:[]},this.sims.set(n.id,n),this.writeConnectedRuntimeSnapshot(),this.shouldPromoteSim(n)&&(this.primarySimId=n.id),this.broadcastSimAssignments(),this.broadcastSimClientStates();else{let c=`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,c)}e.on("message",c=>{let r;try{r=JSON.parse(c.toString())}catch{return}if(!(!r||typeof r!="object")){if(typeof r.type=="string"&&r.type.startsWith("agent:")){this.agentHost.handleMessage(e,r);return}if(r.type==="runtime:list"){let a=x.listInstalled(),l=this.getActiveRuntime(),d={type:"runtime:list:ok",id:r.id,installed:a,active:l.version,activeRuntimeDir:l.runtimeDir};try{e.send(JSON.stringify(d))}catch{}return}if(r.type==="runtime:use"){let a=typeof r.version=="string"?r.version:"";if(!x.listInstalled().includes(a)){try{e.send(JSON.stringify({type:"runtime:use:error",id:r.id,error:`runtime ${a||"(missing)"} is not installed`}))}catch{}return}let d=this.setActiveRuntime(a);try{e.send(JSON.stringify({type:"runtime:use:ok",id:r.id,version:d.version,runtimeDir:d.runtimeDir}))}catch{}return}if(r.type==="runtime:get"){let a=this.getActiveRuntime();try{e.send(JSON.stringify({type:"runtime:get:ok",id:r.id,active:a.version,activeRuntimeDir:a.runtimeDir}))}catch{}return}if(s==="sim"&&r.type==="bridge:hello"&&n&&!n.url){let a=n.id;this.sims.delete(a),this.primarySimId===a&&(this.primarySimId=this.getOpenSim()?.id??null),n=null,s="cli",this.cliIdentityKeyBySocket.set(e,`ws-${this.nextCliFallbackId++}`),this.writeConnectedRuntimeSnapshot(),this.broadcastSimAssignments(),this.broadcastSimClientStates()}if(s==="sim"){if(n&&(n.lastSeenAt=Date.now()),r.type==="bridge:register"&&n){let d=r,p=this.tryRestoreSimId(n,d.simId);n.url=d.url,n.title=d.title,n.userAgent=d.userAgent,this.writeConnectedRuntimeSnapshot(),typeof d.kind=="string"&&d.kind.trim()&&(n.kind=d.kind.trim()),d.meta&&typeof d.meta=="object"&&(n.meta=d.meta);let u=this.primarySimId!==n.id&&this.shouldPromoteSim(n);u&&(this.primarySimId=n.id),(p||u)&&(this.broadcastSimAssignments(),this.broadcastSimClientStates());return}if(r.type==="bridge:user-focus-state"&&n){let d=r;this.updateUserFocusLease(n,d);return}if(r.type==="bridge:user-interact"&&n){this.updateUserActivity(n);return}if(r.type==="bridge:write-shared-config"){if(!r.patch||typeof r.patch!="object"||Array.isArray(r.patch))return;let d=Object.fromEntries(Object.entries(r.patch));try{this.writeAndBroadcastSharedConfig(d)}catch(p){process.stderr.write(`sootsim: bridge:write-shared-config failed: ${p instanceof Error?p.message:String(p)}
16
+ `);return}return}if(r.type==="bridge:open-path"){let d=typeof r.path=="string"?r.path:"",p=typeof r.line=="number"&&Number.isFinite(r.line)?r.line:void 0,u=typeof r.column=="number"&&Number.isFinite(r.column)?r.column:void 0;d&&this.openPathInEditor(d,p,u);return}if(r.type==="bridge:boot-clients"&&n){let d=[];for(let[u,h]of this.cliSimBySocket)h===n.id&&d.push(u);for(let u of d){this.cliSimBySocket.delete(u);try{u.close(1e3,"booted by sim")}catch{}}let p=!!n.cliLease;n.cliLease={kind:"user-active",cliIdentityKey:"__user-active__",cliLabel:"active user",expiresAt:Date.now()+o.USER_BOOT_LEASE_TTL_MS},process.stderr.write(`sootsim booted ${d.length} cli client(s)${p?" (overrode prior lease)":""}; held sim for user [${n.id}]
17
+ `),this.recordSimAction(n.id,"sim booted cli clients"),this.broadcastSimClientStates();return}let a=this.pendingCommands.get(r.id);if(a){this.pendingCommands.delete(r.id),r.error?a.reject(new Error(r.error)):a.resolve(r.result);return}let l=this.cliBySentId.get(r.id);if(l&&(this.cliBySentId.delete(r.id),l.ws.readyState===g.OPEN)){let d=this.getOtherCliIdentityCount(l.ws,l.simId),p=d>0?{...r,id:l.originalId,_otherCliCount:d}:{...r,id:l.originalId};l.ws.send(JSON.stringify(p))}return}(async()=>{this.cliLastCommandAt.set(e,Date.now());try{if(r.type==="bridge:bye"){let u=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[h,m]of this.cliBySentId)m.ws===e&&this.cliBySentId.delete(h);u&&this.broadcastSimClientStates();return}if(r.type==="bridge:hello"){let u=typeof r.cliIdentityKey=="string"&&r.cliIdentityKey.trim()?r.cliIdentityKey.trim():this.cliIdentityKeyBySocket.get(e)||`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,u),typeof r.cliLabel=="string"&&r.cliLabel.trim()&&this.cliLabelBySocket.set(e,r.cliLabel.trim()),e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,result:{cliIdentityKey:u,leaseTtlMs:o.CLI_LEASE_TTL_MS,leasing:!0}}));return}if(r.type==="bridge:list-sims"){e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,result:this.listSims()}));return}if(r.type==="bridge:open"){if(typeof r.url!="string"||!r.url)throw new Error("bridge:open requires a url");await this.openUrl(r.url,{newWindow:r.newWindow===!0}),e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,result:{ok:!0,url:r.url}}));return}if(r.type==="bridge:claim"){let u=await this.waitForSim(r.simId),h=this.tryAcquireLease(e,u,{force:r.force===!0});if(!h.granted){e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${u.id} is locked by another cli`,_locked:h.lock}));return}this.setCliSimTarget(e,u.id),this.recordSimAction(u.id,h.bootedCount>0?`cli force-claimed sim (booted ${h.bootedCount})`:"cli claimed sim"),e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,result:{simId:u.id,lockedBy:h.lease.cliIdentityKey,lockExpiresAt:h.lease.expiresAt,bootedCount:h.bootedCount}}));return}let a=await this.waitForSim(r.simId);if(kt(r)){let u=this.tryAcquireLease(e,a);if(!u.granted){e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${a.id} is locked by another cli \u2014 use \`sootsim claim ${a.id} --force\` or \`sootsim open --new\``,_locked:u.lock}));return}}else this.ensureCliIdentityKey(e);this.setCliSimTarget(e,a.id),this.recordSimAction(a.id,this.describeForwardedCommand(r));let l=this.nextCommandId++;this.cliBySentId.set(l,{simId:a.id,ws:e,originalId:r.id});let{simId:d,...p}=r;if(a.ws.send(JSON.stringify({...p,id:l})),p.type==="close"){this.cliBySentId.delete(l),e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,result:{requested:!0,simId:a.id}}));let u=a.ws,h=setTimeout(()=>{this.closeSimSocketFromHost(u)},wt);je(h)}}catch(a){e.readyState===g.OPEN&&e.send(JSON.stringify({id:r.id,error:a instanceof Error?a.message:String(a)}))}})()}}),e.on("close",()=>{if(this.agentHost.unregisterSocket(e),s==="sim"&&n){this.rememberDisconnectedSim(n),this.primarySimId===n.id&&(this.primarySimId=this.getOpenSim()?.id??null);for(let[c,r]of this.pendingCommands)r.simId===n.id&&(r.reject(new Error("sim disconnected")),this.pendingCommands.delete(c));for(let[c,r]of this.cliBySentId)r.simId===n.id&&(r.ws.readyState===g.OPEN&&r.ws.send(JSON.stringify({id:r.originalId,error:"sim disconnected before responding"})),this.cliBySentId.delete(c));this.broadcastSimAssignments(),this.broadcastSimClientStates()}else if(s==="cli"){let c=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[r,a]of this.cliBySentId)a.ws===e&&this.cliBySentId.delete(r);c&&this.broadcastSimClientStates()}})})}afterBind(){if(process.stderr.write(`ws bridge listening on port ${this.port}
18
+ `),this.cliIdleTimer=setInterval(()=>this.sweepIdleCliClients(),3e4),this.cliIdleTimer.unref(),this.wsHeartbeatTimer=setInterval(()=>this.sweepDeadWebSockets(),o.WS_HEARTBEAT_INTERVAL_MS),this.wsHeartbeatTimer.unref(),this.shouldWriteLockfile){try{if(O(),!ne(this.buildLockfileSnapshot()))throw new Error("another sootsim daemon wrote the lockfile during startup \u2014 aborting")}catch(e){throw process.stderr.write(`ws bridge failed to claim daemon lockfile: ${String(e)}
19
+ `),e}this.heartbeatTimer=setInterval(()=>{try{this.writeLockfileSnapshot()}catch{}},Fe),this.heartbeatTimer.unref(),this.startRuntimeUpdater()}if(this.shouldWriteDevLockfile){try{this.writeDevLockfileSnapshot()}catch(e){process.stderr.write(`ws bridge failed to write dev bridge lockfile: ${String(e)}
20
+ `)}this.devHeartbeatTimer=setInterval(()=>{try{this.writeDevLockfileSnapshot()}catch{}},Fe),this.devHeartbeatTimer.unref()}this.agentHost.seedOnBoot()}bootstrapping=!0;connectedRuntimeVersions(){let e=new Set;for(let t of this.sims.values())try{let i=new URL(t.url||t.origin||"http://localhost"),s=L(i.hostname);s&&e.add(s)}catch{}return[...e].sort()}buildLockfileSnapshot(){return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,activeRuntimeDir:this.activeRuntimeDirPath,servedRuntimes:this.connectedRuntimeVersions(),startedAt:this.startedAt,heartbeatAt:Date.now(),bootstrapping:this.bootstrapping}}buildDevLockfileSnapshot(){let e=this.getShellPort?.()??null;return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,...e&&e>0?{shellPort:e}:{},cwd:process.cwd(),startedAt:this.startedAt,heartbeatAt:Date.now(),source:"vite-dev",servedRuntimes:this.connectedRuntimeVersions()}}writeLockfileSnapshot(){ie(this.buildLockfileSnapshot())}writeDevLockfileSnapshot(){re(this.buildDevLockfileSnapshot())}writeConnectedRuntimeSnapshot(){if(this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}if(this.shouldWriteDevLockfile&&this.httpServer)try{this.writeDevLockfileSnapshot()}catch{}}refreshActiveRuntime(){this.activeRuntimeVersion=j(),this.activeRuntimeDirPath=pe()??Q()}runServerScan(){if(this.inflightScan)return this.inflightScan;let e=this.effectivePort>0?[this.effectivePort]:[];return this.inflightScan=_({excludePorts:e,buildIconProxyUrl:t=>`/__bundle-proxy?url=${encodeURIComponent(t)}`}).then(t=>(this.scanCache=t,this.scanCacheAt=Date.now(),t)).catch(t=>{let i=t instanceof Error?t.message:String(t);return console.error("[sootsim] /__server-scan failed:",i),this.scanCache??[]}).finally(()=>{this.inflightScan=null}),this.inflightScan}handleServerScan(e){let t=s=>{e.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),e.end(JSON.stringify(s))},i=Date.now()-this.scanCacheAt;if(this.scanCache&&i<o.SCAN_FRESH_MS){t(this.scanCache);return}if(this.scanCache){t(this.scanCache),this.runServerScan().catch(()=>{});return}this.runServerScan().then(s=>t(s))}resolveRuntimeUpdateIntervalMs(){let e=Number(process.env[Ct]);return Number.isFinite(e)&&e>0?Math.max(100,Math.round(e)):Tt}startRuntimeUpdater(){if(!this.shouldWriteLockfile||this.runtimeUpdateTimer||C.existsSync(w.join(q(),"runtime-update-disabled"))||process.env.SOOTSIM_HOME&&z()&&!j())return;this.runRuntimeUpdate("startup");let e=this.resolveRuntimeUpdateIntervalMs();this.runtimeUpdateTimer=setInterval(()=>{this.runRuntimeUpdate("periodic")},e),this.runtimeUpdateTimer.unref()}runRuntimeUpdate(e){return this.runtimeUpdateInFlight?this.runtimeUpdateInFlight:(this.runtimeUpdateInFlight=(async()=>{try{e==="startup"&&process.stderr.write(`sootsim: checking for runtime updates\u2026
21
+ `);let t=await x.updateToLatest({protectVersions:this.connectedRuntimeVersions()});if(!t.updated||!t.latestVersion){e==="startup"&&process.stderr.write(`sootsim: runtime ${this.activeRuntimeVersion??"(none)"} is current
22
+ `);return}let i=this.activeRuntimeVersion,s=this.setActiveRuntime(t.latestVersion);process.stderr.write(`sootsim runtime updated to ${s.version} (${e})
23
+ `);try{Y({from:i,to:s.version,at:Date.now()})}catch{}}catch(t){process.stderr.write(`sootsim runtime update failed (${e}): ${t instanceof Error?t.message:String(t)}
24
+ `)}finally{if(this.runtimeUpdateInFlight=null,e==="startup"&&this.bootstrapping){if(this.bootstrapping=!1,this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}process.stderr.write(`sootsim: ready
25
+ `)}}})(),this.runtimeUpdateInFlight)}setActiveRuntime(e){if(Z(e),this.refreshActiveRuntime(),this.shouldWriteLockfile&&this.httpServer)try{this.writeLockfileSnapshot()}catch{}let t=JSON.stringify({type:"runtime:changed",version:e,runtimeDir:this.activeRuntimeDirPath});for(let i of this.sims.values()){try{let s=new URL(i.url||i.origin||"http://localhost");if(L(s.hostname))continue}catch{}if(i.ws.readyState===g.OPEN)try{i.ws.send(t)}catch{}}return{version:e,runtimeDir:this.activeRuntimeDirPath}}getActiveRuntime(){return{version:this.activeRuntimeVersion,runtimeDir:this.activeRuntimeDirPath}}removeLockfile(){if(this.shouldWriteLockfile)try{$()}catch{}}handleHttpRequest(e,t){if(t.setHeader("Cross-Origin-Opener-Policy","same-origin"),t.setHeader("Cross-Origin-Embedder-Policy",vt),t.setHeader("Cross-Origin-Resource-Policy","cross-origin"),t.setHeader("Document-Policy","js-profiling"),Me(e.url)){Ne(e,t);return}if(De(e.url)&&He(e,t))return;let i=(e.method||"GET").toUpperCase(),s;try{s=new URL(e.url||"/",`http://${e.headers.host||"localhost"}`)}catch{t.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),t.end("invalid request URL or host");return}if(s.pathname==="/__sootsim/shared-config"){if(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Headers","Content-Type"),t.setHeader("Cache-Control","no-store"),i==="OPTIONS"){t.writeHead(204,{Allow:"GET, HEAD, POST, OPTIONS"}),t.end();return}if(i==="GET"||i==="HEAD"){let d="{}";try{d=JSON.stringify(W())}catch{}t.writeHead(200,{"Content-Type":"application/json"}),i==="HEAD"?t.end():t.end(d);return}if(i==="POST"){(async()=>{try{let d=[],p=0;for await(let f of e){let S=Buffer.isBuffer(f)?f:Buffer.from(f);if(p+=S.byteLength,p>8*1024*1024){t.writeHead(413,{"Content-Type":"text/plain; charset=utf-8"}),t.end("shared config patch is too large");return}d.push(S)}let u=JSON.parse(Buffer.concat(d).toString("utf8"));if(!u||typeof u!="object"||Array.isArray(u))throw new Error("shared config patch must be an object");let h=Object.fromEntries(Object.entries(u)),m=this.writeAndBroadcastSharedConfig(h);t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify(m))}catch(d){t.writeHead(400,{"Content-Type":"text/plain; charset=utf-8"}),t.end(`invalid shared config patch: ${d instanceof Error?d.message:String(d)}`)}})();return}t.writeHead(405,{Allow:"GET, HEAD, POST, OPTIONS"}),t.end("method not allowed");return}if(i!=="GET"&&i!=="HEAD"){t.writeHead(405,{Allow:"GET, HEAD"}),t.end("method not allowed");return}if(s.pathname==="/__bundle-proxy"){let d=s.searchParams.get("url");if(!d){t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: missing url query param");return}let p;try{p=new URL(d)}catch{t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: invalid url");return}let u=p.hostname;if(!(u==="localhost"||u==="127.0.0.1"||u==="::1"||u.endsWith(".localhost"))){t.writeHead(403,{"Content-Type":"text/plain"}),t.end("bundle-proxy: only loopback targets allowed");return}(async()=>{try{let m=await fetch(p.toString(),{redirect:"follow"}),f={},S=m.headers.get("content-type");if(S&&(f["Content-Type"]=S),f["Cache-Control"]="no-store",t.writeHead(m.status,f),!m.body){t.end();return}let A=m.body.getReader();for(;;){let{done:b,value:v}=await A.read();if(b)break;t.write(Buffer.from(v))}t.end()}catch(m){t.writeHead(502,{"Content-Type":"text/plain"}),t.end(`bundle-proxy: upstream fetch failed: ${m instanceof Error?m.message:String(m)}`)}})();return}if(s.pathname==="/__server-scan"){this.handleServerScan(t);return}if(s.pathname==="/healthz"){t.writeHead(200,{"Content-Type":"application/json","Cache-Control":"no-store"}),t.end(JSON.stringify({ok:!0,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,bridgeSource:this.shouldWriteDevLockfile?"vite-dev":this.shouldWriteLockfile?"daemon":"embedded",startedAt:this.startedAt,uptimeMs:this.startedAt>0?Date.now()-this.startedAt:0}));return}let n=L(s.hostname);n||this.refreshActiveRuntime();let c=n?me(n):this.activeRuntimeDirPath;if(!c){t.writeHead(503,{"Content-Type":"text/plain; charset=utf-8"}),t.end(n?`sootsim: runtime ${n} is not installed. run \`sootsim open\` from that app again.`:"sootsim: no active runtime installed. run `sootsim runtime install` to fetch one.");return}let r=s.pathname;if(r==="/runtime"||r==="/runtime/"?r="/":r.startsWith("/runtime/")?r=r.slice(8):r==="/sootsim"||r==="/sootsim/"?r="/":r.startsWith("/sootsim/")&&(r=r.slice(8)),(r===""||r==="/")&&(r="/index.html"),r.includes("\0")){t.writeHead(400),t.end("bad request");return}if(process.platform!=="win32"&&r.includes("\\")){t.writeHead(400),t.end("bad request");return}for(let d of r.split("/"))if(d===".."){t.writeHead(403),t.end("forbidden");return}let a=w.resolve(c,"."+r),l=c.endsWith(w.sep)?c:c+w.sep;if(!a.startsWith(l)&&a!==c){t.writeHead(403),t.end("forbidden");return}C.realpath(a,(d,p)=>{let u=d?a:p,h=u.endsWith(w.sep)?u:u+w.sep;if(!d){let m=(()=>{try{let f=C.realpathSync(c);return f.endsWith(w.sep)?f:f+w.sep}catch{return l}})();if(!h.startsWith(m)&&u+w.sep!==m){t.writeHead(403),t.end("forbidden");return}}C.stat(u,(m,f)=>{if(m||!f?.isFile()){let v=w.extname(r).toLowerCase();if(v&&v!==".html"){t.writeHead(404),t.end("not found");return}if(r.startsWith("/__")||r.startsWith("/api/")||r==="/api"){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("not found");return}let y=w.join(c,"index.html");C.readFile(y,(R,$e)=>{if(R){t.writeHead(404),t.end("not found");return}if(t.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),i==="HEAD"){t.end();return}t.end(We($e,this.effectivePort,this.contrastOrigin))});return}let S=w.extname(u).toLowerCase(),A=It[S]||"application/octet-stream";if(t.writeHead(200,{"Content-Type":A,"Cache-Control":"no-store"}),i==="HEAD"){t.end();return}if(S===".html"){C.readFile(u,(v,y)=>{if(v){try{t.end()}catch{}return}t.end(We(y,this.effectivePort,this.contrastOrigin))});return}let b=C.createReadStream(u);b.pipe(t),b.on("error",()=>{try{t.end()}catch{}})})})}sweepIdleCliClients(){let e=Date.now(),t=!1;for(let[i,s]of this.cliSimBySocket){let n=this.cliLastCommandAt.get(i)??0;if(e-n<o.CLI_IDLE_TIMEOUT_MS)continue;let c=!1;for(let r of this.cliBySentId.values())if(r.ws===i){c=!0;break}if(!c){this.cliSimBySocket.delete(i),this.cliLastCommandAt.delete(i);for(let[r,a]of this.cliBySentId)a.ws===i&&this.cliBySentId.delete(r);try{i.close(1e3,"idle timeout")}catch{}t=!0}}t&&this.broadcastSimClientStates(),this.sweepRestorableSims(e),this.reapIdleSims(e)}isAutomationSim(e){return e.meta?.sootsimHostDriver==="playwright"}automationSimOwnerAlive(e){let t=Number(e.meta?.sootsimHostPid);if(!Number.isInteger(t)||t<=1||t===process.pid)return!1;try{return process.kill(t,0),!0}catch(i){return i.code==="EPERM"}}reapIdleSims(e=Date.now()){let t=new Set(this.cliSimBySocket.values()),i=[];for(let n of this.sims.values()){if(n.id===this.primarySimId||t.has(n.id)||this.getActiveLease(n))continue;let c=Math.max(n.lastActiveAt,n.connectedAt),r=e-c,a=this.isAutomationSim(n);if(a&&this.automationSimOwnerAlive(n))continue;let l=a?this.automationSimIdleReapTtlMs:this.simIdleReapTtlMs;if(r>=l){this.closeSimSocketFromHost(n.ws);continue}a&&i.push({sim:n,idleMs:r})}let s=this.maxConcurrentAutomationSims;if(i.length>s){i.sort((n,c)=>c.idleMs-n.idleMs);for(let{sim:n,idleMs:c}of i.slice(0,i.length-s))c<this.automationSimActiveGraceMs||this.closeSimSocketFromHost(n.ws)}}sweepDeadWebSockets(){if(this.wss)for(let e of this.wss.clients){if(e.readyState!==g.OPEN)continue;if(this.wsIsAlive.get(e)===!1){try{e.terminate()}catch{}continue}this.wsIsAlive.set(e,!1);try{e.ping()}catch{try{e.terminate()}catch{}}}}closeSimSocketFromHost(e){if(e.readyState!==g.OPEN)return;try{e.close(de,le)}catch{try{e.terminate()}catch{}return}let t=setTimeout(()=>{if(e.readyState!==g.CLOSED)try{e.terminate()}catch{}},At);je(t)}listSims(){return Array.from(this.sims.values()).sort((e,t)=>e.id===this.primarySimId?-1:t.id===this.primarySimId?1:e.connectedAt-t.connectedAt).map(e=>this.describeSim(e))}async sendCommand(e){let t=await this.waitForSim(e.simId),i=this.nextCommandId++;return new Promise((s,n)=>{let c=setTimeout(()=>{this.pendingCommands.delete(i),this.broadcastSimClientStates(),n(new Error("command timed out after 30s"))},3e4);this.pendingCommands.set(i,{simId:t.id,resolve:l=>{clearTimeout(c),this.pendingCommands.delete(i),this.broadcastSimClientStates(),s(l)},reject:l=>{clearTimeout(c),this.pendingCommands.delete(i),this.broadcastSimClientStates(),n(l)}}),this.broadcastSimClientStates();let{simId:r,...a}=e;t.ws.send(JSON.stringify({...a,id:i}))})}async evaluate(e,t){return this.sendCommand({type:"evaluate",code:e,simId:t})}async focusSim(e){return this.sendCommand({type:"focus",simId:e})}async closeSim(e){return this.sendCommand({type:"close",simId:e})}async openPathInEditor(e,t,i){let s=t!=null?`:${t}${i!=null?`:${i}`:""}`:"",n=`${e}${s}`,c=(a,l)=>new Promise(d=>{try{let p=gt(a,l,{detached:!0,stdio:"ignore"}),u=!1;p.on("error",()=>{u||(u=!0,d(!1))}),p.on("spawn",()=>{u||(u=!0,p.unref(),d(!0))})}catch{d(!1)}}),r=process.env.REACT_EDITOR||process.env.EDITOR;if(r){let a=r.split(" ").filter(Boolean);if(a.length&&await c(a[0],[...a.slice(1),"-g",n]))return}await c("cursor",["-g",n])||await c("code",["-g",n])||await this.openUrl(e)}async openUrl(e,t={}){if(this.openUrlHandler){await this.openUrlHandler(e,t);return}await he(e,t)}async close(){if(this.cliIdleTimer&&(clearInterval(this.cliIdleTimer),this.cliIdleTimer=null),this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.devHeartbeatTimer&&(clearInterval(this.devHeartbeatTimer),this.devHeartbeatTimer=null),this.wsHeartbeatTimer&&(clearInterval(this.wsHeartbeatTimer),this.wsHeartbeatTimer=null),this.runtimeUpdateTimer&&(clearInterval(this.runtimeUpdateTimer),this.runtimeUpdateTimer=null),this.shouldWriteLockfile)try{$()}catch{}if(this.shouldWriteDevLockfile)try{se()}catch{}this.effectivePort=0,this.startedAt=0,this.agentHost.close();for(let[i,s]of this.pendingCommands)s.reject(new Error("server closing")),this.pendingCommands.delete(i);for(let i of this.sims.values())i.ws.close();this.sims.clear(),this.primarySimId=null;let e=this.wss,t=this.httpServer;if(this.wss=null,this.httpServer=null,e)try{e.close()}catch{}if(t)try{t.close()}catch{}}describeSim(e){let t;try{t=e.ws.readyState}catch{t=g.CLOSED}let i=this.getActiveLease(e);return{id:e.id,origin:e.origin,url:e.url,title:e.title,userAgent:e.userAgent,connectedAt:e.connectedAt,lastSeenAt:e.lastSeenAt,lastActiveAt:e.lastActiveAt||void 0,isPrimary:e.id===this.primarySimId,readyState:t===g.OPEN?"open":t===g.CLOSING?"closing":"closed",attachedCliCount:this.getAttachedCliCount(e.id),lockedBy:i?i.cliLabel||i.cliIdentityKey:void 0,lockedByKind:i?i.kind:void 0,lockExpiresAt:i?i.expiresAt:void 0,userFocused:e.userFocused||void 0,userVisible:e.userVisible,visibilityState:e.visibilityState,documentFocused:e.documentFocused,kind:e.kind,meta:e.meta}}getActiveLease(e){let t=e.cliLease;return t?Date.now()>=t.expiresAt?(e.cliLease=void 0,null):t:null}tryAcquireLease(e,t,i={}){let s=this.cliIdentityKeyBySocket.get(e)??(()=>{let p=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,p),p})(),n=this.cliLabelBySocket.get(e),c=Date.now(),r=this.getActiveLease(t),a=r&&r.cliIdentityKey===s,l=0;if(r&&!a&&!i.force)return{granted:!1,lease:r,lock:{by:r.cliLabel||r.cliIdentityKey,expiresInMs:Math.max(0,r.expiresAt-c)},bootedCount:0};if(r&&!a&&i.force)for(let[p,u]of this.cliSimBySocket){if(u!==t.id)continue;let h=this.cliIdentityKeyBySocket.get(p);if(h&&h!==s){this.cliSimBySocket.delete(p);try{p.close(1e3,"lease claimed by another cli")}catch{}l++}}let d={kind:"cli",cliIdentityKey:s,cliLabel:n,expiresAt:c+o.CLI_LEASE_TTL_MS};return t.cliLease=d,{granted:!0,lease:d,bootedCount:l}}updateUserFocusLease(e,t){let i=t.focused===!0,s=typeof t.visible=="boolean"?t.visible:void 0,n=typeof t.visibilityState=="string"?t.visibilityState:void 0,c=typeof t.documentFocused=="boolean"?t.documentFocused:void 0;e.userFocused===i&&e.userVisible===s&&e.visibilityState===n&&e.documentFocused===c||(e.userFocused=i,e.userVisible=s,e.visibilityState=n,e.documentFocused=c,this.broadcastSimClientStates())}updateUserActivity(e){let t=this.getActiveLease(e);if(t&&t.kind==="cli")return;let s=Date.now()+o.USER_ACTIVE_LEASE_TTL_MS,n=t&&t.kind==="user-active"?Math.max(t.expiresAt,s):s;e.cliLease={kind:"user-active",cliIdentityKey:"__user-active__",cliLabel:"active user",expiresAt:n},this.broadcastSimClientStates()}ensureCliIdentityKey(e){let t=this.cliIdentityKeyBySocket.get(e);if(t)return t;let i=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,i),i}getOpenSim(e){if(e){let i=this.sims.get(e);return i?.ws.readyState===g.OPEN?i:null}let t=this.getDefaultSimCandidates();return t.find(i=>i.id===this.primarySimId)??t[0]??null}getDefaultSimCandidates(){let e=Array.from(this.sims.values()).filter(i=>i.ws.readyState===g.OPEN),t=e.filter(i=>i.url);return t.length>0?t:e}async waitForSim(e,t={}){let i=t.attempts??10,s=t.intervalMs??200;for(let c=0;c<i;c++){if(e){let r=this.getOpenSim(e);if(r)return r}else{let r=this.getDefaultSimCandidates();if(r.length>1)throw new Error(`multiple sims are connected: ${r.map(l=>l.id).join(", ")}; run \`sootsim use <sim>\` or pass \`--sim <sim>\``);let a=r[0];if(a)return a}await new Promise(r=>setTimeout(r,s))}if(!e)throw new Error("no sim connected");let n=this.getDefaultSimCandidates().map(c=>c.id);throw new Error(`no sim connected with id ${e}`+(n.length>0?`; connected sims: ${n.join(", ")}`:""))}shouldPromoteSim(e){let t=this.primarySimId?this.sims.get(this.primarySimId):null;if(!e.url)return!t;let i=t?.ws.readyState===g.OPEN;if(!t||!i||!t.url)return!0;let s=e.origin?.includes(":5173"),n=t.origin?.includes(":5173");return!!s||!n}broadcastSimAssignments(){for(let e of this.sims.values())e.ws.readyState===g.OPEN&&e.ws.send(JSON.stringify({type:"bridge:welcome",simId:e.id,isPrimary:e.id===this.primarySimId}))}writeAndBroadcastSharedConfig(e){let t=X(e),i=JSON.stringify({type:"bridge:shared-config-changed",config:t});for(let s of this.sims.values())if(s.ws.readyState===g.OPEN)try{s.ws.send(i)}catch{}return t}broadcastSimClientStates(){for(let e of this.sims.values()){if(e.ws.readyState!==g.OPEN)continue;let t=this.getActiveLease(e),i={type:"bridge:client-state",attachedCliCount:this.getAttachedCliCount(e.id),activeAgentCommandCount:this.getActiveAgentCommandCount(e.id),recentActions:e.recentActions,lockedBy:t?t.cliLabel||t.cliIdentityKey:void 0,lockedByKind:t?t.kind:void 0,lockExpiresAt:t?t.expiresAt:void 0,userFocused:e.userFocused||void 0,userVisible:e.userVisible,visibilityState:e.visibilityState,documentFocused:e.documentFocused};e.ws.send(JSON.stringify(i))}}setCliSimTarget(e,t){let i=this.cliSimBySocket.get(e);i!==t&&(this.cliSimBySocket.set(e,t),this.recordSimAction(t,i?"cli switched sims":"cli connected",!1),this.broadcastSimClientStates())}recordSimAction(e,t,i=!0){let s=t?.trim();if(!s)return;let n=this.sims.get(e);if(!n)return;let c=Date.now();n.lastActiveAt=c,n.recentActions=[{label:s,at:c},...n.recentActions.filter(r=>r.label!==s)].slice(0,4),i&&this.broadcastSimClientStates()}describeForwardedCommand(e){switch(e?.type){case"evaluate":return"evaluated page state";case"screenshot":return"captured screenshot";case"tap":return"sent tap event";case"keyboard":return e?.action==="type"?"typed text":"used keyboard";case"tree":return"dumped tree";case"focus":return"focused sim";case"close":return"requested close";default:return typeof e?.type=="string"?e.type:null}}getAttachedCliCount(e){let t=new Set;for(let[i,s]of this.cliSimBySocket){if(s!==e||i.readyState!==g.OPEN)continue;let n=this.cliIdentityKeyBySocket.get(i);t.add(n??`ws-unknown-${t.size}`)}return t.size}getOtherCliIdentityCount(e,t){let i=this.cliIdentityKeyBySocket.get(e),s=new Set;for(let[n,c]of this.cliSimBySocket){if(c!==t||n.readyState!==g.OPEN)continue;let r=this.cliIdentityKeyBySocket.get(n);r&&r===i||s.add(r??`ws-unknown-${s.size}`)}return s.size}getActiveAgentCommandCount(e){let t=0;for(let i of this.pendingCommands.values())i.simId===e&&t++;return t}allocateSimId(){for(;;){let e=this.nextSimNumber.toString(16);if(this.nextSimNumber++,!this.sims.has(e)&&!this.restorableSims.has(e))return e}}tryRestoreSimId(e,t){let i=t?.trim();if(!i||i===e.id)return!1;let s=this.sims.get(i);if(s&&s!==e&&s.ws.readyState===g.OPEN)return!1;let n=this.getRestorableSimState(i),c=e.id;this.sims.delete(c),e.id=i,n&&(e.recentActions=n.recentActions.map(r=>({...r})),e.lastActiveAt=n.lastActiveAt,e.cliLease=n.cliLease?{...n.cliLease}:void 0,this.restorableSims.delete(i)),this.sims.set(e.id,e),this.primarySimId===c&&(this.primarySimId=e.id);for(let[r,a]of this.cliSimBySocket)a===c&&this.cliSimBySocket.set(r,e.id);return!0}rememberDisconnectedSim(e){let t=this.getActiveLease(e);this.restorableSims.set(e.id,{recentActions:e.recentActions.map(i=>({...i})),lastActiveAt:e.lastActiveAt,cliLease:t&&t.kind==="cli"?{...t}:void 0,expiresAt:Date.now()+o.SIM_RECONNECT_TTL_MS}),this.sims.delete(e.id),this.writeConnectedRuntimeSnapshot()}getRestorableSimState(e){let t=this.restorableSims.get(e);return t?t.expiresAt<=Date.now()?(this.restorableSims.delete(e),null):(t.cliLease&&t.cliLease.expiresAt<=Date.now()&&(t.cliLease=void 0),t):null}sweepRestorableSims(e=Date.now()){for(let[t,i]of this.restorableSims)if(!(i.expiresAt>e)){this.restorableSims.delete(t);for(let[s,n]of this.cliSimBySocket)n===t&&this.cliSimBySocket.delete(s)}}resetServerState(){this.cliIdleTimer&&(clearInterval(this.cliIdleTimer),this.cliIdleTimer=null),this.wsHeartbeatTimer&&(clearInterval(this.wsHeartbeatTimer),this.wsHeartbeatTimer=null),this.runtimeUpdateTimer&&(clearInterval(this.runtimeUpdateTimer),this.runtimeUpdateTimer=null);let e=this.wss,t=this.httpServer;if(this.wss=null,this.httpServer=null,e)try{e.close()}catch{}if(t)try{t.close()}catch{}}};function Et(){return!!((process.env.XPC_SERVICE_NAME||"").includes("dev.sootsim.daemon")||process.env.INVOCATION_ID)}async function gi(o,e={}){(o.includes("--help")||o.includes("-h"))&&(console.log(`
26
+ sootsim serve \u2014 run the sootsim bridge in the foreground
27
+
28
+ hosts the WS bridge that CLI commands talk to. once running, any sootsim
29
+ renderer (browser, electron, headless playwright) that connects to port 7668
30
+ becomes drivable from 'sootsim describe', 'sootsim do tap', etc.
31
+
32
+ usage:
33
+ sootsim serve [options]
34
+
35
+ options:
36
+ --port <n> bridge port (defaults to ${7668})
37
+ --quiet suppress per-connection logging
38
+
39
+ examples:
40
+ sootsim serve
41
+ sootsim serve --port 7668 --quiet
42
+ `),process.exit(0));let t=o.indexOf("--port"),i=t>=0&&o[t+1]?Number(o[t+1]):e.port??7668;Number.isNaN(i)&&(console.error(` invalid --port value: ${o[t+1]}`),process.exit(1));let s=o.includes("--quiet")||o.includes("-q"),n=ee();n&&te(n)&&(console.error(` a sootsim bridge is already running (pid ${n.pid}, port ${n.bridgePort})`),console.error(" stop it with 'sootsim daemon stop' first"),process.exit(1)),O();let c=await fe(),r=new H({port:i,writeLockfile:!0,contrastOrigin:c}),a=await r.startAsync({silent:s}),l=Date.now(),d=m=>{s||process.stdout.write(`${m}
43
+ `)},p=new Set,u=setInterval(()=>{let m=r.listSims(),f=new Set(m.map(S=>S.id));for(let S of m)if(!p.has(S.id)){let A=S.title||S.url||S.origin||"(unknown)";d(` + ${S.id} ${A}`)}for(let S of p)f.has(S)||d(` - ${S}`);p.clear();for(let S of f)p.add(S)},500);oe({event:"daemon_heartbeat",properties:{bridge_port:a,under_daemon:Et(),platform:process.platform,subsource:"daemon"}}),ae(),d(`sootsim bridge listening on ws://localhost:${a} (runtime http on same port)`),a!==i&&d(` (preferred port ${i} was taken \u2014 fell back to ${a})`),d(" ready for browser, electron, or headless playwright sims to connect"),d(" (ctrl-c to stop)");let h=async m=>{clearInterval(u),d(`
44
+ ${m} received \u2014 shutting down after ${Math.round((Date.now()-l)/1e3)}s`);try{await r.close()}catch{}process.exit(0)};process.on("SIGINT",()=>h("SIGINT")),process.on("SIGTERM",()=>h("SIGTERM")),process.on("SIGHUP",()=>h("SIGHUP")),process.on("exit",()=>{try{r.removeLockfile()}catch{}}),await new Promise(()=>{})}export{gi as runServe};
@@ -0,0 +1,32 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{a as l}from"./chunk-N3FZRJT7.js";import{d as V,f as q,g as J,i as N,j as F}from"./chunk-P7HBJBHH.js";import{b as k,c as L}from"./chunk-4NFGOGB7.js";import{c as w}from"./chunk-LHUY46GE.js";import"./chunk-MQ6QX46T.js";import{f as m}from"./chunk-EISE56VD.js";import"./chunk-CAAADPRH.js";import"./chunk-FUPQIX4U.js";import"./chunk-6C24WCDK.js";import"./chunk-3PAZJSIG.js";import"./chunk-CDCVWGNU.js";import"./chunk-2LQOLMRK.js";import"./chunk-7GQWF7HE.js";import"./chunk-5FNPAMP4.js";import{A as v,B as E,H as R,K as C,M as I,l as b}from"./chunk-WJVBD2UL.js";import{a as T}from"./chunk-QIDFGREY.js";import"./chunk-7YQXQSG7.js";import"./chunk-X7B5KJ6N.js";import P from"node:fs";import U from"node:os";import $ from"node:path";import{spawn as ne}from"node:child_process";import u from"node:fs";import s from"node:path";function B(e){let n=s.resolve(e);for(;;){if(u.existsSync(s.join(n,"package.json")))return n;let o=s.dirname(n);if(o===n)return null;n=o}}function j(e){let n=s.resolve(e);for(;;){if(u.existsSync(s.join(n,"bun.lock"))||u.existsSync(s.join(n,"bun.lockb")))return"bun";if(u.existsSync(s.join(n,"pnpm-lock.yaml")))return"pnpm";if(u.existsSync(s.join(n,"package-lock.json")))return"npm";let o=s.dirname(n);if(o===n)return"npm";n=o}}function Y(e){let n=s.resolve(e.appDir),o=oe(s.join(n,"package.json")),t=o.scripts?.sootsim;if(t&&t!=="sootsim open")throw new Error(`package.json already defines scripts.sootsim as ${JSON.stringify(t)}; resolve that conflict before setup`);let r=j(n),i=[];return o.devDependencies?.sootsim!==e.cliVersion&&i.push(te(r,e.cliVersion)),t!=="sootsim open"&&i.push(se(r)),{appDir:n,packageManager:r,operations:i}}async function H(e,n){for(let o of e.operations)n.dryRun||await ie(o,e.appDir,n.json)}function O(e){return e.operations.map(n=>`${n.command} ${n.args.map(re).join(" ")}`)}function oe(e){let n;try{n=JSON.parse(u.readFileSync(e,"utf8"))}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(`could not read ${e}: ${i}`)}if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${e} must contain a JSON object`);let o=W(Reflect.get(n,"scripts")),t=W(Reflect.get(n,"devDependencies"));return{...o?{scripts:o}:{},...t?{devDependencies:t}:{}}}function W(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=Object.entries(e).filter(o=>typeof o[1]=="string");return Object.fromEntries(n)}function te(e,n){let o=`sootsim@${n}`;switch(e){case"bun":return{command:"bun",args:["add","--dev","--exact",o],description:`install ${o} as an exact dev dependency`};case"pnpm":return{command:"pnpm",args:["add","--save-dev","--save-exact",o],description:`install ${o} as an exact dev dependency`};case"npm":return{command:"npm",args:["install","--save-dev","--save-exact",o],description:`install ${o} as an exact dev dependency`}}}function re(e){return/^[a-zA-Z0-9_./@=-]+$/.test(e)?e:JSON.stringify(e)}function ie(e,n,o){return new Promise((t,r)=>{let i=ne(e.command,e.args,{cwd:n,stdio:o?["ignore",2,"inherit"]:"inherit"});i.once("error",r),i.once("exit",c=>{c===0?t():r(new Error(`${e.command} exited with code ${c??"unknown"}`))})})}function se(e){return{command:e,args:e==="bun"?["pm","pkg","set","scripts.sootsim=sootsim open"]:["pkg","set","scripts.sootsim=sootsim open"],description:"add the `sootsim` package script"}}async function We(e){if(e.includes("--help")||e.includes("-h")){je();return}let n=pe(e),o="decisions";try{let t=B(n.appDir),r=k(),i=v(),c=await ue(n,r),Q=await le(n,t),y=await Z(n,"productAnalytics",i.productAnalytics,i.configured),g=await Z(n,"crashReports",i.crashReports,i.configured),X=await m.fetchManifest(),d=m.resolveVersion(X,{channel:"stable"}).version,D=T();if(D==="0.0.0")throw new Error("could not resolve the installed SootSim CLI version");let a=null;Q&&t&&(a=Y({appDir:t,cliVersion:D})),Se(n),he(n,r,c,d),be(n,t,a),ve(n,y,g),o="runtime";let A=!1;if(!n.dryRun){let _=R();A=(await m.install({version:d,channel:"stable",setActive:!0,protectVersions:_?[_]:[]})).installed}o="repository",a&&await H(a,{dryRun:n.dryRun,json:n.json}),o="service";let S=r.installed;c&&!r.installed&&!n.dryRun&&(await L({port:7668,force:!1}),S=!0),o="privacy",n.dryRun||E({productAnalytics:y,crashReports:g}),o="compatibility";let p=t?fe(t):null,h=await de(n,p);h&&p&&t&&!n.dryRun&&await me(t,p),Re(n,p,h);let M={runtimeVersion:d,serviceInstalled:S,repositoryPrepared:a!==null,compatibilityShared:h&&!n.dryRun},ee=ge(d);n.json?console.log(JSON.stringify({...M,runtimeInstalled:n.dryRun?!1:A,dryRun:n.dryRun,cache:ee,repositoryOperations:a?O(a):[]},null,2)):we(a);let f=p?q(p):null;return w({event:"cli_setup_completed",properties:{service_installed:S,repository_prepared:a!==null,product_analytics:y,crash_reports:g,compat_supported:f?.supported??0,compat_partial:f?.partial??0,compat_unsupported:f?.unsupported??0,compat_not_yet_verified:f?.notYetVerified??0,from_welcome:n.fromWelcome,ci:n.ci,dry_run:n.dryRun}}),M}catch(t){let r=ke(t);throw w({event:"cli_setup_failed",properties:{stage:o,message:r}}),t}}function ce(){let e=k(),n=C(),o=R();return{daemonSupported:e.supported,daemonInstalled:e.installed,daemonRunning:!!(n&&I(n)),runtimeInstalled:!!(o&&P.existsSync(b(o))),privacyConfigured:v().configured}}function Be(e=ce()){return!e.runtimeInstalled||!e.privacyConfigured}function pe(e){let n=e.indexOf("--app"),o=n>=0?e[n+1]:void 0;if(n>=0&&(!o||o.startsWith("-")))throw new Error("--app requires a directory");let t=z(e,"--service","--no-service"),r=z(e,"--repo","--no-repo");return{appDir:$.resolve(o??process.cwd()),ci:e.includes("--ci"),dryRun:e.includes("--dry-run"),fromWelcome:e.includes("--from-welcome"),json:e.includes("--json"),yes:e.includes("--yes")||e.includes("-y"),service:t,repository:r,productAnalytics:G(e,"--analytics"),crashReports:G(e,"--crash-reports"),shareCompatibility:e.includes("--share-compat")}}function z(e,n,o){if(e.includes(n)&&e.includes(o))throw new Error(`${n} and ${o} cannot be used together`);if(e.includes(n))return!0;if(e.includes(o))return!1}function G(e,n){let o=e.find(i=>i.startsWith(`${n}=`)),t=e.indexOf(n),r=o?.slice(n.length+1)??(t>=0?e[t+1]:void 0);if(r!==void 0){if(r==="on"||r==="yes"||r==="true")return!0;if(r==="off"||r==="no"||r==="false")return!1;throw new Error(`${n} must be on or off`)}}async function ue(e,n){if(e.ci){if(e.service===!0)throw new Error("--ci cannot install a machine service");return!1}return n.supported?n.installed&&e.service===void 0?!0:e.service!==void 0?e.service:e.yes?!0:(x(e,"--service or --no-service"),l("Install the background service and shared managed runtime?",!0)):!1}async function le(e,n){if(!n){if(e.repository===!0)throw new Error("--repo requires a package.json");return!1}return e.repository!==void 0?e.repository:e.yes?!0:(x(e,"--repo or --no-repo"),l(`Prepare ${n} for reproducible SootSim runs?`,!0))}async function Z(e,n,o,t){let r=n==="productAnalytics"?e.productAnalytics:e.crashReports;return r!==void 0?r:t?o:e.yes?!0:(x(e,n==="productAnalytics"?"--analytics on|off":"--crash-reports on|off"),l(n==="productAnalytics"?"Share bounded product analytics?":"Send bounded crash reports?",!0))}async function de(e,n){return n?e.shareCompatibility?!0:e.yes||!process.stdin.isTTY?!1:l("Share dependency names, requested versions, framework, and this compatibility result?",!1):!1}function x(e,n){if(!(process.stdin.isTTY&&!e.ci))throw new Error(`non-interactive setup requires ${n}, or --yes to accept defaults`)}function fe(e){let n=JSON.parse(P.readFileSync($.join(e,"package.json"),"utf8"));if(!n||typeof n!="object")throw new Error("package.json must contain an object");return V(n)}async function me(e,n){let o=JSON.parse(P.readFileSync($.join(e,"package.json"),"utf8"));if(!o||typeof o!="object")throw new Error("package.json must be an object");let t=await fetch("https://contrast.dev/api/scan",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(ye(o,n)),signal:AbortSignal.timeout(1e4)});if(!t.ok)throw new Error(`compatibility sharing failed with HTTP ${t.status}`)}function ye(e,n){return{dependencies:K(Reflect.get(e,"dependencies")),devDependencies:K(Reflect.get(e,"devDependencies")),framework:n.framework,result:{framework:n.framework,rnVersion:n.rnVersion,packages:n.packages.slice(0,200)},source:"desktop",shared:!0}}function K(e){if(!e||typeof e!="object")return{};let n={};for(let[o,t]of Object.entries(e).slice(0,200))typeof t=="string"&&(n[o.slice(0,160)]=t.slice(0,80));return n}function ge(e){let n=U.platform(),o=U.arch();return{path:b(e),key:`sootsim-runtime-${n}-${o}-${e}`,inputs:{platform:n,arch:o,runtimeVersion:e}}}function Se(e){e.json||console.log(`
5
+ ${e.fromWelcome?"welcome to sootsim":"sootsim setup"}`)}function he(e,n,o,t){e.json||(console.log(`
6
+ 1. machine`),console.log(` stable runtime: ${t}`),console.log(` background service: ${n.supported?o?"install":"skip":"unsupported on this platform"}`))}function be(e,n,o){if(!e.json){if(console.log(`
7
+ 2. repository`),!n){console.log(" no package.json found; repository preparation skipped");return}if(!o){console.log(` skipped for ${n}`);return}console.log(` package manager: ${j(n)}`);for(let t of O(o))console.log(` ${e.dryRun?"would run":"run"}: ${t}`)}}function ve(e,n,o){e.json||(console.log(`
8
+ 3. privacy`),console.log(` product analytics: ${n?"on":"off"}`),console.log(" command, feature, version, platform, and bounded performance events"),console.log(` crash reports: ${o?"on":"off"}`),console.log(" error type, message, stack, runtime version, platform, and bounded dependency summary"),console.log(" source files, environment values, terminal output, app data, screenshots, and recordings are not included"))}function Re(e,n,o){if(!e.json){if(console.log(`
9
+ 4. compatibility`),!n){console.log(" no package.json found; run `sootsim compat` inside an app later");return}console.log(` ${J(n)}`);for(let t of N(n))console.log(` ${t}`);console.log(` ${F}`),console.log(` dependency sharing: ${o?"yes":"no"}`)}}function we(e){if(console.log(`
10
+ 5. ready`),e){let n=e.packageManager==="bun"?"bun run sootsim":`${e.packageManager} run sootsim`;console.log(` start your app normally, then ${n} -- <port>`)}else console.log(" start your app normally, then sootsim open <port>");console.log(" useful next commands: sootsim describe; sootsim get errors; sootsim compat"),console.log(" install agent skills with `sootsim skill install`, then start a new session"),console.log(" if a concrete SootSim seam is missing or broken, preview `sootsim report-issue` and confirm separately")}function ke(e){return(e instanceof Error?e.message:String(e)).replace(/(?:\/?[\w.-]+)+/g,"<path>").slice(0,240)}function je(){console.log(`
11
+ sootsim setup \u2014 configure a machine and optionally prepare the current repository
12
+
13
+ usage:
14
+ sootsim setup
15
+ sootsim setup --yes
16
+ sootsim setup --ci --yes --json
17
+ sootsim setup --dry-run --yes
18
+
19
+ decisions:
20
+ --service | --no-service
21
+ --repo | --no-repo
22
+ --analytics on|off
23
+ --crash-reports on|off
24
+ --share-compat
25
+
26
+ automation:
27
+ --yes accept defaults; compatibility sharing still defaults off
28
+ --ci never prompt or install a background service
29
+ --json emit runtime/cache metadata as JSON
30
+ --dry-run print exact repository operations without changing the machine
31
+ --app DIR use DIR as the repository search start
32
+ `)}export{ye as buildCompatibilitySharePayload,ce as readMachineSetupStatus,We as runSetup,Be as shouldRunSetupForBareCommand};
@@ -1,7 +1,7 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import { createRequire as __sootsimCreateRequire } from 'node:module'
3
3
  var require = __sootsimCreateRequire(import.meta.url)
4
- import"./chunk-D2R7PDN5.js";import*as i from"fs";import*as I from"os";import*as a from"path";import{fileURLToPath as h}from"url";function $(){try{let t=h(import.meta.resolve("sootsim/package.json"));return a.join(a.dirname(t),"skills")}catch{let t=a.dirname(h(import.meta.url));return a.resolve(t,"../../skills")}}var d=$(),w=new Set(["all","codex","claude"]);function S(){console.log(`sootsim skill
4
+ import"./chunk-X7B5KJ6N.js";import*as i from"fs";import*as I from"os";import*as a from"path";import{fileURLToPath as h}from"url";function $(){try{let t=h(import.meta.resolve("sootsim/package.json"));return a.join(a.dirname(t),"skills")}catch{let t=a.dirname(h(import.meta.url));return a.resolve(t,"../../skills")}}var d=$(),w=new Set(["all","codex","claude"]);function S(){console.log(`sootsim skill
5
5
 
6
6
  install and inspect bundled SootSim agent skills.
7
7
 
@@ -1,7 +1,7 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import { createRequire as __sootsimCreateRequire } from 'node:module'
3
3
  var require = __sootsimCreateRequire(import.meta.url)
4
- import{k as f}from"./chunk-24BJFJFB.js";import"./chunk-WYRLRNIP.js";import"./chunk-7Q77LTPT.js";import"./chunk-XYFP466E.js";import"./chunk-ZUX5PIGI.js";import"./chunk-RWUNC66S.js";import{a as t,b as n,c as l,d as c,e as a}from"./chunk-KWIURH7N.js";import"./chunk-AMKQUZA2.js";import"./chunk-AFLGWOX3.js";import"./chunk-6YN3IAWJ.js";import"./chunk-37ZXWXM3.js";import"./chunk-VVVORIQI.js";import"./chunk-W44PDEQH.js";import"./chunk-FNCSUHUR.js";import"./chunk-PZTKQG6H.js";import"./chunk-SPQKJDIK.js";import"./chunk-AO65WEF7.js";import"./chunk-4Z4URZOG.js";import"./chunk-DI55E6CS.js";import"./chunk-VXGCZUX4.js";import"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import"./chunk-JFWEDISV.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";function p(){console.log(`
4
+ import{k as f}from"./chunk-PEUWZRXA.js";import"./chunk-CS23DQB2.js";import"./chunk-GG6XOQ5P.js";import"./chunk-ZPBIHFQW.js";import"./chunk-R65XMN4D.js";import"./chunk-C462URRQ.js";import"./chunk-2XUKWIAL.js";import{a as t,b as n,c as l,d as c,e as a}from"./chunk-74FOMZP7.js";import"./chunk-FROCFR77.js";import"./chunk-GG5PWLGC.js";import"./chunk-F2MS365Z.js";import"./chunk-EJ6BAJKX.js";import"./chunk-B2FB6IYX.js";import"./chunk-B2LDO55K.js";import"./chunk-SUJSGGSS.js";import"./chunk-ZIBKGZJD.js";import"./chunk-IR3DUBRF.js";import"./chunk-DUYKBCM7.js";import"./chunk-S5Z4HKWX.js";import"./chunk-EISE56VD.js";import"./chunk-6C24WCDK.js";import"./chunk-3PAZJSIG.js";import"./chunk-CDCVWGNU.js";import"./chunk-2LQOLMRK.js";import"./chunk-7GQWF7HE.js";import"./chunk-5FNPAMP4.js";import"./chunk-WJVBD2UL.js";import"./chunk-X7B5KJ6N.js";function p(){console.log(`
5
5
  sootsim storage profile \u2014 manage isolated storage profiles
6
6
 
7
7
  usage:
@@ -0,0 +1,4 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{a}from"./chunk-B2FB6IYX.js";import"./chunk-CDCVWGNU.js";import"./chunk-X7B5KJ6N.js";export{a as settingsStore};
@@ -0,0 +1,4 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{c as a,d as b}from"./chunk-LHUY46GE.js";import"./chunk-MQ6QX46T.js";import"./chunk-WJVBD2UL.js";import"./chunk-X7B5KJ6N.js";export{b as flushCliTelemetry,a as trackCliEvent};
@@ -1,7 +1,7 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import { createRequire as __sootsimCreateRequire } from 'node:module'
3
3
  var require = __sootsimCreateRequire(import.meta.url)
4
- import{g as m,i as d,l as s}from"./chunk-PZTKQG6H.js";import"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";import{writeFileSync as g}from"fs";function u(){console.log(`
4
+ import{h as m,j as d,m as s}from"./chunk-IR3DUBRF.js";import"./chunk-2LQOLMRK.js";import"./chunk-7GQWF7HE.js";import"./chunk-WJVBD2UL.js";import"./chunk-X7B5KJ6N.js";import{writeFileSync as g}from"fs";function u(){console.log(`
5
5
  sootsim timeline \u2014 control the semantic event timeline
6
6
 
7
7
  usage:
@@ -0,0 +1,7 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{a as h,b as v,c as $}from"./chunk-54TQ3ZGI.js";import{b as p}from"./chunk-SUJSGGSS.js";import"./chunk-ZIBKGZJD.js";import"./chunk-IR3DUBRF.js";import{b as g}from"./chunk-EISE56VD.js";import"./chunk-2LQOLMRK.js";import"./chunk-7GQWF7HE.js";import{H as a,g as m,h as u,l as d}from"./chunk-WJVBD2UL.js";import{a as f}from"./chunk-QIDFGREY.js";import"./chunk-X7B5KJ6N.js";import{spawn as y}from"node:child_process";import k from"node:fs";import R from"node:os";import r from"node:path";var b="https://registry.npmjs.org/sootsim/latest";async function W(o){let n=o.indexOf("--channel"),t=n>=0&&o[n+1]?o[n+1]:void 0;console.log(`sootsim upgrade
5
+ `),console.log("runtime:");let e=a(),{config:l}=await p(),s=l?.runtimeVersion,c=s?k.existsSync(r.join(d(s),"index.html")):!1;s&&console.log(` project config: v${s}`);let i=(s&&c?null:await $(["install",...s?[s,"--set-active=false"]:[],...t?["--channel",t]:[]],{}))?.version??s??a();i&&console.log(s?c?` result: v${i} already installed for this project`:` result: not installed \u2192 v${i} for this project`:e&&e!==i?` result: v${e} \u2192 v${i}`:e?` result: v${i} already current`:` result: not installed \u2192 v${i}`);let x=i?await h(i):null;console.log(`
6
+ cli:`),await j(),i&&console.log(`
7
+ ${v(i,x)}`)}function w(){if(u())return{kind:"dev"};let o=process.argv[1]??"";try{o=k.realpathSync(o)}catch{}let n=r.sep;if(o.includes(`${n}_npx${n}`)||o.includes(`${n}.bunx${n}`))return{kind:"npx"};if(o.includes(`${n}.bun${n}`))return{kind:"global",command:"bun",args:["add","-g","sootsim@latest"]};if(o.includes(`${n}pnpm${n}`))return{kind:"global",command:"pnpm",args:["add","-g","sootsim@latest"]};let t=r.join(m(),"cli");if(o.startsWith(`${t}${n}`))return{kind:"global",command:"npm",args:["i","-g","--prefix",t,"sootsim@latest"]};let e=r.resolve(process.env.SOOTSIM_CLI_PREFIX||r.join(R.homedir(),".local"));return o.startsWith(`${e}${n}`)?{kind:"global",command:"npm",args:["i","-g","--prefix",e,"sootsim@latest"]}:{kind:"global",command:"npm",args:["i","-g","sootsim@latest"]}}async function j(){let o=f(),n=await C();if(!n){console.log(` v${o} \u2014 couldn't reach the npm registry, skipped`);return}if(g(n,o)<=0){console.log(` v${o} (latest)`);return}let t=w();if(console.log(` v${o} \u2192 v${n}`),t.kind==="dev"){console.log(" running from the Contrast dev checkout \u2014 pull instead of upgrading");return}if(t.kind==="npx"){console.log(" running from the npx cache \u2014 get the latest with:"),console.log(" npx sootsim@latest");return}let e=`${t.command} ${t.args.join(" ")}`;console.log(` updating global install (${e})\u2026`),await S(t.command,t.args)?console.log(` updated to v${n}`):(console.log(" update failed \u2014 run it yourself:"),console.log(` ${e}`))}function S(o,n){return new Promise(t=>{let e=y(o,n,{stdio:"inherit"});e.on("error",()=>t(!1)),e.on("exit",l=>t(l===0))})}async function C(){try{let o=await fetch(b,{headers:{accept:"application/json"},signal:AbortSignal.timeout(8e3)});if(!o.ok)return null;let n=await o.json();return typeof n.version=="string"&&n.version?n.version:null}catch{return null}}export{W as runUpgrade};
@@ -0,0 +1,4 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{e as a,f as b,g as c}from"./chunk-7V3JNANH.js";import"./chunk-AUBP44CY.js";import"./chunk-GG5PWLGC.js";import"./chunk-F2MS365Z.js";import"./chunk-EJ6BAJKX.js";import"./chunk-ZIBKGZJD.js";import"./chunk-IR3DUBRF.js";import"./chunk-LHUY46GE.js";import"./chunk-MQ6QX46T.js";import"./chunk-2LQOLMRK.js";import"./chunk-7GQWF7HE.js";import"./chunk-WJVBD2UL.js";import"./chunk-X7B5KJ6N.js";export{a as resolveDefaultUploadOrigin,b as resolvePublicPreviewOrigin,c as runUpload};
@@ -0,0 +1,6 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{b as a}from"./chunk-SUJSGGSS.js";import"./chunk-ZIBKGZJD.js";import{d as r,f as e}from"./chunk-EISE56VD.js";import{a as m}from"./chunk-FUPQIX4U.js";import{l as s}from"./chunk-WJVBD2UL.js";import{a as l}from"./chunk-QIDFGREY.js";import"./chunk-X7B5KJ6N.js";import g from"node:fs";import d from"node:path";async function V($){let{IS_BETA:c,BETA_LABEL:u}=await import("./beta-4AXSOQLU.js"),f=c?` \xB7 ${u}`:"";console.log(`sootsim v${l()}${f}`);let o=m(),i=e.resolveChannel();o.isDevBridge?(console.log(o.primary),o.installedRuntime&&console.log(`${o.installedRuntime} \xB7 ${i}`)):o.primary==="runtime not installed"?console.log("runtime not installed \u2014 run `sootsim runtime install`"):console.log(`${o.primary} \xB7 ${i}`);let{config:n}=await a();if(n?.runtimeVersion){let p=g.existsSync(d.join(s(n.runtimeVersion),"index.html"));console.log(`project runtime v${n.runtimeVersion} \xB7 configured \xB7 ${p?"installed":"installs on open"}`)}let t=await e.checkUpToDate({channel:i});t.outdated&&t.latest&&console.log(`
5
+ \u2191 default runtime v${t.latest} available; run \`sootsim upgrade\``),console.log(`
6
+ what's new: ${r}`)}export{V as runVersion};
@@ -0,0 +1,4 @@
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import { createRequire as __sootsimCreateRequire } from 'node:module'
3
+ var require = __sootsimCreateRequire(import.meta.url)
4
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-P7HBJBHH.js";import"./chunk-X7B5KJ6N.js";export{b as COMPAT_CATEGORIES,j as COMPAT_RESULT_CAVEAT,c as POLYFILL_REGISTRY,a as UNSUPPORTABLE,f as countScanResults,i as formatDetailedScanLines,h as formatPackageStatus,g as formatScanCounts,d as scanDeps,e as scanDepsWithData};
@@ -1,7 +1,7 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import { createRequire as __sootsimCreateRequire } from 'node:module'
3
3
  var require = __sootsimCreateRequire(import.meta.url)
4
- import{D as N,E as F,G as y,R as T,S as b,T as S}from"./chunk-AFLGWOX3.js";import{g as A,i as _}from"./chunk-PZTKQG6H.js";import"./chunk-OKSGM6IG.js";import{c as k}from"./chunk-JUOQ4ZPA.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";function O(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--since"&&e+1<n.length){t.push(e,e+1);let s=n[e+1].trim(),l=/^(\d+(?:\.\d+)?)(ms|s|m)?$/.exec(s);if(l){let r=Number(l[1]),u=l[2]??"ms",v=u==="s"?r*1e3:u==="m"?r*6e4:r;return{since:Date.now()-v,consumed:t}}let i=Number(s);if(Number.isFinite(i)&&i>1e12)return{since:i,consumed:t}}return{consumed:t}}function B(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--kinds"&&e+1<n.length)return t.push(e,e+1),{kinds:n[e+1].split(",").map(s=>s.trim()).filter(Boolean),consumed:t};return{consumed:t}}function D(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--limit"&&e+1<n.length){t.push(e,e+1);let s=Number(n[e+1]);if(Number.isFinite(s)&&s>0)return{limit:s,consumed:t}}return{consumed:t}}function x(n){let t=[],e={label:"initial state",events:[],startedAt:n[0]?.t??null};t.push(e);for(let s of n)if(e.events.push(s),s.kind==="screen"||s.kind==="route"){let l=s.data,i=l?.phase;if(!i||i==="enter"||i==="appear"||i==="active"){let r=l?.name||l?.activeName||l?.path||l?.pathname||s.kind;t.length===1&&e.events.length===1?e.label=`${s.kind}: ${r}`:(e={label:`${s.kind}: ${r}`,events:[],startedAt:s.t},t.push(e))}}return t}async function J(n,t){let e=A(n,{port:t.port,stripBooleanFlags:["--summary","--all","--json","--no-advance","--help","-h","--flow","--noisy"],stripValueFlags:["--since","--kinds","--limit"]});(n.includes("--help")||n.includes("-h"))&&(console.log(`
4
+ import{D as N,E as F,G as y,R as T,S as b,T as S}from"./chunk-2XUKWIAL.js";import{h as A,j as _}from"./chunk-IR3DUBRF.js";import"./chunk-2LQOLMRK.js";import{c as k}from"./chunk-7GQWF7HE.js";import"./chunk-WJVBD2UL.js";import"./chunk-X7B5KJ6N.js";function O(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--since"&&e+1<n.length){t.push(e,e+1);let s=n[e+1].trim(),l=/^(\d+(?:\.\d+)?)(ms|s|m)?$/.exec(s);if(l){let r=Number(l[1]),u=l[2]??"ms",v=u==="s"?r*1e3:u==="m"?r*6e4:r;return{since:Date.now()-v,consumed:t}}let i=Number(s);if(Number.isFinite(i)&&i>1e12)return{since:i,consumed:t}}return{consumed:t}}function B(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--kinds"&&e+1<n.length)return t.push(e,e+1),{kinds:n[e+1].split(",").map(s=>s.trim()).filter(Boolean),consumed:t};return{consumed:t}}function D(n){let t=[];for(let e=0;e<n.length;e++)if(n[e]==="--limit"&&e+1<n.length){t.push(e,e+1);let s=Number(n[e+1]);if(Number.isFinite(s)&&s>0)return{limit:s,consumed:t}}return{consumed:t}}function x(n){let t=[],e={label:"initial state",events:[],startedAt:n[0]?.t??null};t.push(e);for(let s of n)if(e.events.push(s),s.kind==="screen"||s.kind==="route"){let l=s.data,i=l?.phase;if(!i||i==="enter"||i==="appear"||i==="active"){let r=l?.name||l?.activeName||l?.path||l?.pathname||s.kind;t.length===1&&e.events.length===1?e.label=`${s.kind}: ${r}`:(e={label:`${s.kind}: ${r}`,events:[],startedAt:s.t},t.push(e))}}return t}async function J(n,t){let e=A(n,{port:t.port,stripBooleanFlags:["--summary","--all","--json","--no-advance","--help","-h","--flow","--noisy"],stripValueFlags:["--since","--kinds","--limit"]});(n.includes("--help")||n.includes("-h"))&&(console.log(`
5
5
  sootsim what-happened \u2014 show recent events from the semantic timeline
6
6
 
7
7
  usage:
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -172,6 +172,7 @@ function fileFromImportMeta() {
172
172
 
173
173
  // src/bridge-constants.ts
174
174
  var DEFAULT_SOOTSIM_BRIDGE_PORT = 7668;
175
+ var DEFAULT_SOOTSIM_BRIDGE_URL = `http://localhost:${DEFAULT_SOOTSIM_BRIDGE_PORT}/`;
175
176
 
176
177
  // src/agent-daemon-client.ts
177
178
  var AgentDaemonError = class extends Error {
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
package/dist-lib/beta.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
package/dist-lib/beta.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/beta.ts
4
4
  var IS_BETA = true;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -23,6 +23,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
23
23
  var bridge_constants_exports = {};
24
24
  __export(bridge_constants_exports, {
25
25
  DEFAULT_SOOTSIM_BRIDGE_PORT: () => DEFAULT_SOOTSIM_BRIDGE_PORT,
26
+ DEFAULT_SOOTSIM_BRIDGE_URL: () => DEFAULT_SOOTSIM_BRIDGE_URL,
26
27
  SOOTSIM_BRIDGE_SIM_CLOSE_CODE: () => SOOTSIM_BRIDGE_SIM_CLOSE_CODE,
27
28
  SOOTSIM_BRIDGE_SIM_CLOSE_REASON: () => SOOTSIM_BRIDGE_SIM_CLOSE_REASON,
28
29
  resolveSootsimBridgePort: () => resolveSootsimBridgePort,
@@ -33,6 +34,7 @@ __export(bridge_constants_exports, {
33
34
  });
34
35
  module.exports = __toCommonJS(bridge_constants_exports);
35
36
  var DEFAULT_SOOTSIM_BRIDGE_PORT = 7668;
37
+ var DEFAULT_SOOTSIM_BRIDGE_URL = `http://localhost:${DEFAULT_SOOTSIM_BRIDGE_PORT}/`;
36
38
  function parsePort(value) {
37
39
  if (typeof value === "number") {
38
40
  return Number.isInteger(value) && value > 0 ? value : null;
@@ -136,6 +138,7 @@ var SOOTSIM_BRIDGE_SIM_CLOSE_REASON = "sootsim close";
136
138
  // Annotate the CommonJS export names for ESM import in node:
137
139
  0 && (module.exports = {
138
140
  DEFAULT_SOOTSIM_BRIDGE_PORT,
141
+ DEFAULT_SOOTSIM_BRIDGE_URL,
139
142
  SOOTSIM_BRIDGE_SIM_CLOSE_CODE,
140
143
  SOOTSIM_BRIDGE_SIM_CLOSE_REASON,
141
144
  resolveSootsimBridgePort,
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -39,13 +39,14 @@ function hasOwnKeys(value) {
39
39
  }
40
40
  function hasSootSimConfig(config) {
41
41
  if (!config) return false;
42
- return hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialState);
42
+ return typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialState);
43
43
  }
44
44
  function mergeSootSimConfig(base, override) {
45
45
  if (!hasSootSimConfig(base) && !hasSootSimConfig(override)) return void 0;
46
46
  if (!hasSootSimConfig(base)) return override ? { ...override } : void 0;
47
47
  if (!hasSootSimConfig(override)) return base ? { ...base } : void 0;
48
48
  return {
49
+ runtimeVersion: override.runtimeVersion ?? base.runtimeVersion,
49
50
  modules: { ...base.modules || {}, ...override.modules || {} },
50
51
  turboModules: { ...base.turboModules || {}, ...override.turboModules || {} },
51
52
  nativeModules: {
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.296 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;