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.
- package/README.md +13 -4
- package/dist-cli/bin.js +5 -5
- package/dist-cli/chunks/{agent-GDFF6G7N.js → agent-3F4K6MQK.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-ZUKQUOD2.js → agent-wrapper-5LLVCQRZ.js} +2 -2
- package/dist-cli/chunks/app-fonts-LPTY7A5G.js +4 -0
- package/dist-cli/chunks/{assert-GXOGZUKO.js → assert-R2ZUXEMS.js} +2 -2
- package/dist-cli/chunks/{auth-P7FAKLHQ.js → auth-CA62Q6IS.js} +2 -2
- package/dist-cli/chunks/{beta-RXT5RU3A.js → beta-4AXSOQLU.js} +2 -2
- package/dist-cli/chunks/{camera-RNVAC4IO.js → camera-Y4RBIONE.js} +2 -2
- package/dist-cli/chunks/{chunk-OYYQQBKP.js → chunk-222Y7NQA.js} +1 -1
- package/dist-cli/chunks/chunk-2LQOLMRK.js +4 -0
- package/dist-cli/chunks/{chunk-AFLGWOX3.js → chunk-2XUKWIAL.js} +1 -1
- package/dist-cli/chunks/{chunk-DI55E6CS.js → chunk-3PAZJSIG.js} +2 -2
- package/dist-cli/chunks/{chunk-2M7OZ6Y4.js → chunk-4MDLYOEI.js} +2 -2
- package/dist-cli/chunks/{chunk-EXTV6NWM.js → chunk-4NFGOGB7.js} +2 -2
- package/dist-cli/chunks/chunk-54TQ3ZGI.js +30 -0
- package/dist-cli/chunks/chunk-5FNPAMP4.js +125 -0
- package/dist-cli/chunks/{chunk-4Z4URZOG.js → chunk-6C24WCDK.js} +2 -2
- package/dist-cli/chunks/{chunk-KWIURH7N.js → chunk-74FOMZP7.js} +2 -2
- package/dist-cli/chunks/{chunk-JUOQ4ZPA.js → chunk-7GQWF7HE.js} +1 -1
- package/dist-cli/chunks/{chunk-BXO2PTNM.js → chunk-7V3JNANH.js} +4 -4
- package/dist-cli/chunks/{chunk-DUHBRW7J.js → chunk-7YQXQSG7.js} +1 -1
- package/dist-cli/chunks/{chunk-FSRRJGYC.js → chunk-AUBP44CY.js} +2 -2
- package/dist-cli/chunks/chunk-B2FB6IYX.js +4 -0
- package/dist-cli/chunks/{chunk-FNCSUHUR.js → chunk-B2LDO55K.js} +1 -1
- package/dist-cli/chunks/{chunk-K53YCAQM.js → chunk-BVWIR4CD.js} +1 -1
- package/dist-cli/chunks/{chunk-RWUNC66S.js → chunk-C462URRQ.js} +2 -2
- package/dist-cli/chunks/chunk-CAAADPRH.js +10 -0
- package/dist-cli/chunks/{chunk-VXGCZUX4.js → chunk-CDCVWGNU.js} +3 -3
- package/dist-cli/chunks/{chunk-WYRLRNIP.js → chunk-CS23DQB2.js} +2 -2
- package/dist-cli/chunks/chunk-DUYKBCM7.js +4 -0
- package/dist-cli/chunks/chunk-EISE56VD.js +6 -0
- package/dist-cli/chunks/{chunk-VVVORIQI.js → chunk-EJ6BAJKX.js} +1 -1
- package/dist-cli/chunks/chunk-F2MS365Z.js +4 -0
- package/dist-cli/chunks/{chunk-AMKQUZA2.js → chunk-FROCFR77.js} +1 -1
- package/dist-cli/chunks/{chunk-I233T2T4.js → chunk-FUPQIX4U.js} +2 -2
- package/dist-cli/chunks/{chunk-V2MYTL4C.js → chunk-G2SO5FPN.js} +2 -2
- package/dist-cli/chunks/chunk-GG5PWLGC.js +4 -0
- package/dist-cli/chunks/chunk-GG6XOQ5P.js +15 -0
- package/dist-cli/chunks/chunk-HSGS2U7P.js +6 -0
- package/dist-cli/chunks/{chunk-PZTKQG6H.js → chunk-IR3DUBRF.js} +5 -5
- package/dist-cli/chunks/chunk-LHUY46GE.js +4 -0
- package/dist-cli/chunks/{chunk-N4MT5KEB.js → chunk-MDBR4XTV.js} +3 -3
- package/dist-cli/chunks/{chunk-SLMUW2WU.js → chunk-MQ6QX46T.js} +2 -2
- package/dist-cli/chunks/chunk-N3FZRJT7.js +4 -0
- package/dist-cli/chunks/{chunk-ISJ4ACWL.js → chunk-NEARYPSC.js} +11 -11
- package/dist-cli/chunks/chunk-P7HBJBHH.js +4 -0
- package/dist-cli/chunks/{chunk-24BJFJFB.js → chunk-PEUWZRXA.js} +5 -5
- package/dist-cli/chunks/{chunk-PSOUSJSZ.js → chunk-QIDFGREY.js} +1 -1
- package/dist-cli/chunks/{chunk-ZUX5PIGI.js → chunk-R65XMN4D.js} +1 -1
- package/dist-cli/chunks/{chunk-AO65WEF7.js → chunk-S5Z4HKWX.js} +1 -1
- package/dist-cli/chunks/chunk-SUJSGGSS.js +23 -0
- package/dist-cli/chunks/{chunk-O6I5ZGMY.js → chunk-TIOPG6QZ.js} +1 -1
- package/dist-cli/chunks/chunk-WJVBD2UL.js +9 -0
- package/dist-cli/chunks/{chunk-D2R7PDN5.js → chunk-X7B5KJ6N.js} +1 -1
- package/dist-cli/chunks/{chunk-7HVMAGDK.js → chunk-XMVVZCIM.js} +2 -2
- package/dist-cli/chunks/chunk-ZIBKGZJD.js +4 -0
- package/dist-cli/chunks/chunk-ZPBIHFQW.js +12 -0
- package/dist-cli/chunks/cleanup-4RSKYPQ7.js +25 -0
- package/dist-cli/chunks/{cli-version-2JGMYL4O.js → cli-version-VZFF7GGM.js} +2 -2
- package/dist-cli/chunks/compat-FABLN4UI.js +20 -0
- package/dist-cli/chunks/config-74J37LKC.js +13 -0
- package/dist-cli/chunks/control-VBK32Y7F.js +4 -0
- package/dist-cli/chunks/daemon-VFO7LRR4.js +4 -0
- package/dist-cli/chunks/{debug-XUGWZLIW.js → debug-AOYA2CLR.js} +3 -3
- package/dist-cli/chunks/{desktop-IO5HPX5Z.js → desktop-G7XWDCTM.js} +3 -3
- package/dist-cli/chunks/{detox-E42OEJJZ.js → detox-QXJ3L2ZI.js} +2 -2
- package/dist-cli/chunks/{device-XA67L2EB.js → device-NZZ5ZT3Q.js} +2 -2
- package/dist-cli/chunks/{diagnose-36FD6ECF.js → diagnose-5CAEJ42M.js} +2 -2
- package/dist-cli/chunks/disk-cleanup-GZSUZJ6Y.js +4 -0
- package/dist-cli/chunks/drivers-OLJCUSPO.js +4 -0
- package/dist-cli/chunks/{film-XARTGFIZ.js → film-C25VRUNC.js} +3 -3
- package/dist-cli/chunks/flow-IW3WUF5D.js +4 -0
- package/dist-cli/chunks/help-GEVJF2DA.js +4 -0
- package/dist-cli/chunks/{hidden-runtime-alias-T4ZALBE2.js → hidden-runtime-alias-NSLIK6XT.js} +2 -2
- package/dist-cli/chunks/home-paths-OC6JZXIM.js +4 -0
- package/dist-cli/chunks/inspect-KXJNI7CU.js +4 -0
- package/dist-cli/chunks/install-desktop-IYWPRFPB.js +4 -0
- package/dist-cli/chunks/{login-GF6WVVER.js → login-LB4TMM4T.js} +4 -4
- package/dist-cli/chunks/{logout-6F6UKUNI.js → logout-33IOBD4X.js} +2 -2
- package/dist-cli/chunks/{maestro-FMPKHEMX.js → maestro-EEVXX536.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-QGPGNXI6.js → maestro-generate-ICPWVXGA.js} +3 -3
- package/dist-cli/chunks/{mode-JSNMAHDZ.js → mode-6IXOZDK3.js} +2 -2
- package/dist-cli/chunks/{optional-demo-registry-K4VERLJV.js → optional-demo-registry-KBMC7SNI.js} +2 -2
- package/dist-cli/chunks/{perf-PO7ARUTG.js → perf-CTTJSAIJ.js} +2 -2
- package/dist-cli/chunks/{permissions-XI2QUAEZ.js → permissions-BFQS4DIY.js} +2 -2
- package/dist-cli/chunks/{record-4CJCJAFD.js → record-MJR5ELHE.js} +3 -3
- package/dist-cli/chunks/report-issue-FMJRNDKH.js +29 -0
- package/dist-cli/chunks/runtime-PV4HH2OB.js +4 -0
- package/dist-cli/chunks/{screenshot-command-NDVULWMZ.js → screenshot-command-MGNASAXR.js} +3 -3
- package/dist-cli/chunks/{screenshots-capture-Q7UTXF3V.js → screenshots-capture-N6PANAVT.js} +2 -2
- package/dist-cli/chunks/serve-RS6TIO7U.js +44 -0
- package/dist-cli/chunks/setup-MFYGYR2F.js +32 -0
- package/dist-cli/chunks/{skills-NFG6VAO5.js → skills-TD35LDKK.js} +2 -2
- package/dist-cli/chunks/{storage-POWCOUCQ.js → storage-VCFXDJNO.js} +2 -2
- package/dist-cli/chunks/store-VNSTKYBQ.js +4 -0
- package/dist-cli/chunks/telemetry-GPNHSYFF.js +4 -0
- package/dist-cli/chunks/{timeline-MNHZCVAL.js → timeline-UJCZAWJV.js} +2 -2
- package/dist-cli/chunks/upgrade-S24NH4YG.js +7 -0
- package/dist-cli/chunks/upload-CCKAO2M5.js +4 -0
- package/dist-cli/chunks/version-IVPWT2ZQ.js +6 -0
- package/dist-cli/chunks/web-6BMWAWJL.js +4 -0
- package/dist-cli/chunks/{what-happened-H74HHGRK.js → what-happened-HRHB6ETL.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +2 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +4 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +3 -2
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +41 -14
- package/dist-lib/host/bridge-host.cjs +216 -84
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +5 -2
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +2 -3
- package/dist-lib/menu.mjs +2 -3
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +373 -159
- package/dist-lib/vite.cjs +3 -2
- package/package.json +2 -1
- package/scripts/postinstall.cjs +2 -78
- package/skills/contrast/SKILL.md +3 -2
- package/skills/sootsim-setup/SKILL.md +25 -0
- package/src/bridge-constants.ts +1 -0
- package/src/config.ts +4 -0
- package/src/disk-cleanup.ts +5 -26
- package/src/home-paths.ts +58 -23
- package/src/host/bridge-host.ts +152 -57
- package/src/index.ts +4 -1
- package/src/menu.ts +0 -1
- package/src/runtime-assets.ts +35 -0
- package/src/runtime-delivery.ts +5 -8
- package/src/skills/builtin/compat-check.ts +32 -65
- package/dist-cli/chunks/app-fonts-IMYBO6AQ.js +0 -4
- package/dist-cli/chunks/chunk-37ZXWXM3.js +0 -4
- package/dist-cli/chunks/chunk-3F2GAJ4Z.js +0 -6
- package/dist-cli/chunks/chunk-5S3GPTX7.js +0 -6
- package/dist-cli/chunks/chunk-6YN3IAWJ.js +0 -4
- package/dist-cli/chunks/chunk-7Q77LTPT.js +0 -15
- package/dist-cli/chunks/chunk-BBVBMGTT.js +0 -31
- package/dist-cli/chunks/chunk-CTMPC5DN.js +0 -6
- package/dist-cli/chunks/chunk-JFWEDISV.js +0 -120
- package/dist-cli/chunks/chunk-JGGXQHXH.js +0 -10
- package/dist-cli/chunks/chunk-OKSGM6IG.js +0 -4
- package/dist-cli/chunks/chunk-SPQKJDIK.js +0 -4
- package/dist-cli/chunks/chunk-W44PDEQH.js +0 -4
- package/dist-cli/chunks/chunk-WQL3BLFD.js +0 -9
- package/dist-cli/chunks/chunk-XYFP466E.js +0 -12
- package/dist-cli/chunks/chunk-ZFMJFX27.js +0 -4
- package/dist-cli/chunks/cleanup-74SKOD2P.js +0 -25
- package/dist-cli/chunks/compat-ME6HXEEU.js +0 -35
- package/dist-cli/chunks/config-PM67EWT3.js +0 -13
- package/dist-cli/chunks/control-HV7GZXAH.js +0 -4
- package/dist-cli/chunks/daemon-LKRHF5OK.js +0 -4
- package/dist-cli/chunks/disk-cleanup-DDCFGFWK.js +0 -4
- package/dist-cli/chunks/drivers-C2SH3DWS.js +0 -4
- package/dist-cli/chunks/flow-E64G5LF3.js +0 -4
- package/dist-cli/chunks/help-4ZSRG4F4.js +0 -4
- package/dist-cli/chunks/home-paths-5L7N2FLS.js +0 -4
- package/dist-cli/chunks/inspect-U2SV25ER.js +0 -4
- package/dist-cli/chunks/install-desktop-LTGVT7ID.js +0 -4
- package/dist-cli/chunks/runtime-SN2RWDES.js +0 -4
- package/dist-cli/chunks/serve-UEUIBHCK.js +0 -44
- package/dist-cli/chunks/setup-ZEEWYK4B.js +0 -99
- package/dist-cli/chunks/store-BJK7V7FL.js +0 -4
- package/dist-cli/chunks/telemetry-EJP5EW7K.js +0 -4
- package/dist-cli/chunks/upgrade-X57SIG7L.js +0 -6
- package/dist-cli/chunks/upload-JABM3ITZ.js +0 -4
- package/dist-cli/chunks/version-V4IKIDX7.js +0 -6
- package/dist-cli/chunks/web-F5CLF34I.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q,u as r,v as s,w as t,x as u}from"./chunk-7Q77LTPT.js";import"./chunk-XYFP466E.js";import"./chunk-ZUX5PIGI.js";import"./chunk-RWUNC66S.js";import"./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-AO65WEF7.js";import"./chunk-DI55E6CS.js";import"./chunk-VXGCZUX4.js";import"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{f as buildOpenUrl,e as buildShellUrl,s as closeSimsBulk,b as normalizeDeepLinkTarget,t as planBulkCloseTargets,k as playwrightHostPidForSim,h as printConnectedSims,c as resolveBundleTarget,d as resolveDefaultShellBaseUrl,a as resolveDriverConnectWaitOptions,r as runClaimCommand,u as runCloseCommand,q as runFocusCommand,n as runLinkCommand,o as runOpenCommand,p as runUseCommand,l as signalDriverLaunchConnected,g as summarizeSimUrl,m as terminatePlaywrightHostsForSims,i as waitForSimMatch,j as waitForSimMatchOrHostExit};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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}from"./chunk-EXTV6NWM.js";import"./chunk-ZFMJFX27.js";import"./chunk-SLMUW2WU.js";import"./chunk-JGGXQHXH.js";import"./chunk-I233T2T4.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-PSOUSJSZ.js";import"./chunk-DUHBRW7J.js";import"./chunk-D2R7PDN5.js";export{c as daemonInstall,b as getDaemonServiceStatus,a as runDaemon,e as teardownDaemonService,d as teardownLegacyMacDaemonArtifacts,f as teardownSootsimHome};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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}from"./chunk-5S3GPTX7.js";import"./chunk-CTMPC5DN.js";import"./chunk-AO65WEF7.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{e as applyAutomaticSootsimCleanup,d as applySootsimCleanup,b as formatSootsimBytes,a as isAutomaticSootsimCleanupComplete,c as planSootsimCleanup};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import"./chunk-OYYQQBKP.js";import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"./chunk-KWIURH7N.js";import"./chunk-AMKQUZA2.js";import"./chunk-VVVORIQI.js";import"./chunk-AO65WEF7.js";import"./chunk-JUOQ4ZPA.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{e as ALL_DRIVERS,i as buildDriverListRows,a as chromiumDriver,b as electronDriver,f as getAllDrivers,g as getDriver,c as playwrightDriver,h as resolveDriver,d as systemDriver};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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,d,e,f,g,h}from"./chunk-ISJ4ACWL.js";import"./chunk-7HVMAGDK.js";import"./chunk-K53YCAQM.js";import{c as a,d as b}from"./chunk-24BJFJFB.js";import"./chunk-WYRLRNIP.js";import"./chunk-BXO2PTNM.js";import"./chunk-FSRRJGYC.js";import"./chunk-7Q77LTPT.js";import"./chunk-XYFP466E.js";import"./chunk-ZUX5PIGI.js";import"./chunk-RWUNC66S.js";import"./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-ZFMJFX27.js";import"./chunk-SLMUW2WU.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";export{e as discoverSootsimUrl,c as getLastFlowPreviewUploadResult,d as getLastFlowTraceSteps,g as hoistLeadingSimFlag,a as parseFlowFile,f as runFlowPlayback,h as runMaestroAuthoring,b as validateFlowFile};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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}from"./chunk-JGGXQHXH.js";import"./chunk-I233T2T4.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-PSOUSJSZ.js";import"./chunk-DUHBRW7J.js";import"./chunk-D2R7PDN5.js";export{c as printCommandHelp,b as printGroupHelp,a as printHelp};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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,K,L,M,N,O,P,Q,R,S,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{b as ACTIVE_RUNTIME_FILE,e as CONFIG_FILE,f as DAEMON_HEARTBEAT_STALE_MS,c as DAEMON_LOCKFILE,d as DEV_BRIDGE_LOCKFILE,a as SOOTSIM_HOME_ENV,J as activeRuntimeDir,m as activeRuntimeFile,u as cacheDir,Q as claimDaemonLockfile,x as configFilePath,F as consumeRuntimeUpgradeNotice,s as daemonAppBundlePath,r as daemonAppDir,t as daemonAppLauncherPath,v as daemonLockfilePath,w as devBridgeLockfilePath,n as electronDir,o as electronUserDataDir,p as electronVersionDir,G as ensureSootsimHome,M as isDaemonLockfileFresh,N as isDevBridgeLockfileFresh,i as isDevWorkstation,h as isSootsimDevCheckout,q as profilesDir,H as readActiveRuntime,K as readDaemonLockfile,L as readDevBridgeLockfile,B as readOrCreateAnonymousId,y as readSharedConfig,A as readTelemetryEnabled,R as removeDaemonLockfile,S as removeDevBridgeLockfile,l as runtimeDir,D as runtimeUpgradeNoticePath,k as runtimesDir,j as shouldSkipPersistentDaemon,g as sootsimHomeDir,I as writeActiveRuntime,O as writeDaemonLockfile,P as writeDevBridgeLockfile,E as writeRuntimeUpgradeNotice,z as writeSharedConfig,C as writeTelemetryEnabled};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{j as a,k as b}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"./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";export{a as printShellPerfReport,b as runInspect};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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-N4MT5KEB.js";import"./chunk-AMKQUZA2.js";import"./chunk-3F2GAJ4Z.js";import"./chunk-D2R7PDN5.js";export{a as runInstallDesktop};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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-BBVBMGTT.js";import"./chunk-PZTKQG6H.js";import"./chunk-CTMPC5DN.js";import"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{a as runRuntime};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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 me,c as j,d as he,e as J,f as fe,h as ge,i as E,j as Se,k as ye,l as ve,m as be,q as we,t as k,u as Ae,v as ke,w as Te,x as Ce}from"./chunk-2M7OZ6Y4.js";import"./chunk-O6I5ZGMY.js";import{e as pe}from"./chunk-BXO2PTNM.js";import"./chunk-FSRRJGYC.js";import{f as x,g as de,h as le}from"./chunk-XYFP466E.js";import"./chunk-6YN3IAWJ.js";import"./chunk-37ZXWXM3.js";import{d as ue}from"./chunk-VVVORIQI.js";import"./chunk-FNCSUHUR.js";import"./chunk-PZTKQG6H.js";import{a as U,b as V,c as ne,d as se}from"./chunk-ZFMJFX27.js";import"./chunk-SLMUW2WU.js";import{d as O}from"./chunk-CTMPC5DN.js";import{a as ae,b as ce}from"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import{E as z,G as _,H as W,I as X,J as Y,K as Z,M as Q,O as ee,P as te,Q as ie,R as $,S as re,h as G,y as F,z as q}from"./chunk-WQL3BLFD.js";import{a as oe}from"./chunk-PSOUSJSZ.js";import"./chunk-D2R7PDN5.js";import{spawn as pt}from"child_process";import I from"fs";import{createServer as mt}from"http";import w from"path";import{WebSocket as f,WebSocketServer as ht}from"ws";import Ee from"node:fs";import L from"node:path";import{spawn as Fe}from"node:child_process";function We(o){return typeof o.text=="string"?o.text.trim():""}function $e(o){let e=o?.trim();return e||"tm"}async function Ie(o){let e=o.sessionId.trim();if(!V(e))throw new Error(`invalid Team Machine session id: ${e||"<empty>"}`);let t=We(o.prompt);if(!t)throw new Error("prompt text is empty");let i=$e(o.command),s=o.timeoutMs??15e3;await new Promise((n,a)=>{let r=Fe(i,["send",e,t],{stdio:["ignore","ignore","pipe"],env:process.env}),c="",d=setTimeout(()=>{try{r.kill("SIGTERM")}catch{}a(new Error(`tm send timed out after ${Math.round(s/1e3)}s`))},s);r.stderr?.setEncoding("utf8"),r.stderr?.on("data",l=>{c.length<4e3&&(c+=String(l))}),r.on("error",l=>{clearTimeout(d),a(l)}),r.on("exit",(l,u)=>{if(clearTimeout(d),l===0){n();return}let m=c.trim();a(new Error(m||`tm send exited with ${u?`signal ${u}`:`code ${l??"unknown"}`}`))})})}var M=1,je=25;function Je(){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 B=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 be()}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 J();case"agent:upsert-project":return j(i.input??{});case"agent:delete-project":return ge(String(i.projectId)),{ok:!0};case"agent:auto-attach-for-url":return this.autoAttachForUrl(i.input??{});case"agent:list-sessions":return Se(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),a=E(n);if(!a)throw new k("NO_SESSION",`no session: ${n}`);let r=this.normalizePromptEnvelope(i);return await ke(n,r),this.notePromptAccepted(n,r,a.status==="working")}case"agent:end-session":this.dropSessionFanout(String(i.sessionId)),await Te(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=U(i.cliIdentityKey);if(!s)throw new k("UNSUPPORTED_CLAIM",`sim ${t} is claimed by a CLI identity that is not promptable`);return await Ie({sessionId:s,prompt:this.normalizePromptEnvelope(e)}),{ok:!0,routed:"team-machine",sessionId:s}}async doStartSession(e){if(!he(e.projectId))throw new k("NO_PROJECT",`no project: ${e.projectId}`);let i=await Ae(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?.()??Je(),a=(await x({excludePorts:s})).find(l=>String(l.port)===i);if(!a||!a.cwd)return{project:null};let r=J().find(l=>l.cwd===a.cwd)??null,c=Array.from(new Set([...r?.knownBundleUrls??[],a.bundleUrl,t]));return{project:j({cwd:a.cwd,name:a.projectName??L.basename(a.cwd),preferredProvider:e.provider??r?.preferredProvider,sourceRoots:r?.sourceRoots??[a.cwd],knownBundleUrls:c,framework:r?.framework??Ke(a.framework),bundleId:a.bundleId??r?.bundleId})}}getTranscript(e){let t=we(e);return Ee.existsSync(t)?Ee.readFileSync(t,"utf8"):{error:"transcript not found",code:"NO_TRANSCRIPT"}}getPaths(){let e=me();return{userDataDir:e,storeFile:L.join(e,"attached-projects.json"),sessionsDir:L.join(e,"sessions"),transcriptsDir:L.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=Ce(t,a=>{let r=this.coalescePromptEcho(t,a);if(r&&(this.applySessionEvent(t,r),this.fanOutEvent(t,r)),a.type==="turn-completed"){let c=E(t);if(c)try{fe(c.projectId,{usd:a.costUsd,ts:a.ts})}catch(d){process.stderr.write(`[sootsim-agent] recordTurnTelemetry failed: ${d instanceof Error?d.message:String(d)}
|
|
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 a=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,a);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:a>1,pendingTurns:a,queueDepth:Math.max(0,a-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=ye(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()},je))}flushSessionStatuses(){if(this.pendingSessionPatches.size===0)return;let e=this.pendingSessionStates,t=this.pendingSessionPatches;this.pendingSessionStates=new Map,this.pendingSessionPatches=new Map;try{ve([...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 Ke(o){return o==="expo"?"expo":o==="one"||o==="vxrn"?"one":"unknown"}import Re from"http";import _e from"https";import{finished as qe,pipeline as ze}from"stream/promises";var K="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",Ve=[{hostSuffix:"uniswap.org",headers:{origin:"https://app.uniswap.org",referer:"https://app.uniswap.org/"},suppressBrowserUserAgent:!0}];function Ge(o){let e=o.toLowerCase();for(let t of Ve)if(e===t.hostSuffix||e.endsWith(`.${t.hostSuffix}`))return t}function Pe(o){let e=Ge(o.hostname);return{"accept-encoding":"identity",...e?.suppressBrowserUserAgent?{}:{"user-agent":K},...e?.headers}}var Xe=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"]),Ye={"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"},Ze=new Set(["host","origin","referer","sec-fetch-site","sec-fetch-mode","sec-fetch-dest"]);function Oe(o){return o.protocol!=="https:"?{}:de(o.hostname)?{rejectUnauthorized:!1}:{}}function P(o){for(let[e,t]of Object.entries(Ye))o.setHeader(e,t)}function Qe(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 et(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(Xe.has(i.toLowerCase())||(t[i]=Array.isArray(s)?s.join(", "):s));return Object.assign(t,e?Pe(e):{"user-agent":K}),t}function tt(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(Ze.has(i.toLowerCase())||(t[i]=s));return t.host=e.host,t.origin=e.origin,t.referer=`${e.origin}/`,t}function xe(o){return o?.startsWith("/__fetch-proxy?")||o?.startsWith("/__proxy?")||!1}function Le(o){return o?!!(o.startsWith("/__app-api?")||o.startsWith("/__app-api/")):!1}async function Me(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 c=[];for await(let d of o)c.push(Buffer.isBuffer(d)?d:Buffer.from(d));c.length>0&&(n=Buffer.concat(c))}let a=o.method||"GET",r=async(c,d,l,u)=>{let m=c.protocol==="https:"?_e:Re,p=et(o.headers,c);c.origin!==s.origin&&(delete p.authorization,delete p["proxy-authorization"]),d==="GET"||d==="HEAD"?(delete p["content-length"],delete p["content-type"]):l&&(p["content-length"]=String(l.byteLength));let h=await new Promise((v,A)=>{let y=m.request({hostname:c.hostname,port:c.port||(c.protocol==="https:"?443:80),path:c.pathname+c.search,method:d,headers:p,...Oe(c)},v),R=()=>y.destroy(new Error("fetch proxy client disconnected"));o.once("aborted",R),y.once("close",()=>o.off("aborted",R)),y.once("error",A),l===void 0?y.end():y.end(l)}),S=h.statusCode??502,g=h.headers.location;if(g&&(S===301||S===302||S===303||S===307||S===308)){if(u>=10)throw h.destroy(),new Error("too many redirects");let v=(S===301||S===302)&&d==="POST"||S===303&&d!=="GET"&&d!=="HEAD",A=new URL(g,c);h.resume(),await qe(h),await r(A,v?"GET":d,v?void 0:l,u+1);return}for(let[v,A]of Object.entries(h.headers)){let y=v.toLowerCase();A===void 0||y==="set-cookie"||y==="connection"||y==="keep-alive"||y==="proxy-authenticate"||y==="proxy-authorization"||y==="te"||y==="trailer"||y==="transfer-encoding"||y==="upgrade"||y.startsWith("access-control-")||e.setHeader(v,A)}P(e);let b=h.headers["set-cookie"]??[];b.length>0&&e.setHeader("x-sootsim-set-cookie",(Array.isArray(b)?b:[b]).join(", ")),e.statusCode=S,await ze(h,e)};try{await r(s,a,n,0)}catch(c){if(e.headersSent){e.destroy(c instanceof Error?c:new Error(String(c)));return}P(e),e.writeHead(502,{"Content-Type":"text/plain"}),e.end(`fetch proxy error: ${Qe(s.href,c)}`)}}function Be(o,e){let t=o.url||"",i="",s="";if(t.startsWith("/__app-api?")){let d=new URL(t,"http://sootsim.local");i=d.searchParams.get("path")||"",s=d.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 a=n.protocol==="https:"?_e:Re,r=tt(o.headers,n),c=a.request({hostname:n.hostname,port:n.port||(n.protocol==="https:"?443:80),path:n.pathname+n.search,method:o.method,headers:r,...Oe(n)},d=>{let l=Object.keys(d.headers).filter(u=>{let m=u.toLowerCase();return!m.startsWith("access-control-")&&m!=="set-cookie"}).join(", ");e.writeHead(d.statusCode??502,{...d.headers,"access-control-allow-origin":o.headers.origin||"*","access-control-allow-credentials":"true","access-control-expose-headers":l}),d.pipe(e)});return c.on("error",d=>{e.statusCode=502,e.end(`app proxy error: ${d.message}`)}),o.pipe(c),!0}import{WebSocket as T,WebSocketServer as it}from"ws";var rt="/__websocket-proxy",nt=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 C(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 st(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 ot(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,a]of Object.entries(i))a!=null&&(nt.has(n.toLowerCase())||(s[n]=Array.isArray(a)?a.join(", "):String(a)));return s}function at(o){let e=new URL(o.href);return e.protocol=o.protocol==="wss:"?"https:":"http:",e.origin}function ct(o){let e=o.headers["sec-websocket-protocol"];return(Array.isArray(e)?e.join(","):e||"").split(",").map(i=>i.trim()).filter(Boolean)}function D(o,e,t){if(!(o.readyState===T.CLOSED||o.readyState===T.CLOSING))try{o.close(e,t)}catch{o.terminate()}}function dt(o,e){let t=!1,i=(s,n,a,r)=>{t||(t=!0,D(n,a,r.toString()),s.readyState===T.OPEN&&D(s,a,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",()=>D(e,1011,"proxy client error")),e.on("error",()=>D(o,1011,"upstream websocket error"))}function lt(o,e,t,i){let s={...t},n=Object.keys(s).filter(a=>a.toLowerCase()==="origin");if(i&&n.length===0)s.origin=at(o);else if(!i)for(let a of n)delete s[a];return Object.keys(s).length===0?new T(o.href,e):new T(o.href,e,{headers:s})}function ut(o){if(!o)return!1;try{return new URL(o,"http://localhost").pathname===rt}catch{return!1}}function De(o,e,t,i=!0){if(!ut(o.url))return!1;if(!st(o))return C(e,403,"forbidden websocket proxy origin"),!0;let s,n;try{let d=new URL(o.url||"/","http://localhost"),l=d.searchParams.get("url");if(!l)return C(e,400,"missing websocket proxy url"),!0;if(s=new URL(l),s.protocol!=="ws:"&&s.protocol!=="wss:")return C(e,400,"invalid websocket proxy protocol"),!0;n=ot(d.searchParams.get("headers"))}catch{return C(e,400,"invalid websocket proxy request"),!0}let a=ct(o),r=lt(s,a,n,i),c=!1;return e.once("close",()=>{c||r.terminate()}),r.once("open",()=>{if(c)return;c=!0;let d=r.protocol;new it({noServer:!0,clientTracking:!1,handleProtocols(u){return d||u.values().next().value||!1}}).handleUpgrade(o,e,t,u=>{dt(u,r)})}),r.once("error",()=>{c||(c=!0,C(e,502,"upstream websocket error"))}),r.once("close",()=>{c||(c=!0,C(e,502,"upstream websocket closed"))}),!0}var ft="require-corp",gt=new Set(["tap","keyboard"]),St=2e3,yt=1e3;function vt(o){return!o||typeof o.type!="string"?!1:o.acquireLock===!0?!0:o.readOnly===!0?!1:gt.has(o.type)}var Ne=5e3,bt=3600*1e3,wt="SOOTSIM_RUNTIME_UPDATE_INTERVAL_MS",At={".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 He(o,e,t){let i;try{let c=F();i=JSON.stringify(c)}catch{i="{}"}let s=e>0?`window.__sootsimBridgePort=${e};`:"",n=t?`window.__sootsimContrastOrigin=${JSON.stringify(t)};`:"",a=`<script>window.__sootsimSharedConfig=${i};`+s+n+`window.__sootsimCliVersion=${JSON.stringify(oe())};</script>`,r=o.toString("utf8");return r.includes("<head>")?r.replace("<head>",`<head>${a}`):r.includes("</head>")?r.replace("</head>",a+"</head>"):r.includes("</body>")?r.replace("</body>",a+"</body>"):a+r}function Ue(o){typeof o=="object"&&o!==null&&"unref"in o&&o.unref()}var N=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 B({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=mt((c,d)=>this.handleHttpRequest(c,d)),a=!1,r=c=>{if(!a){a=!0;try{n.close()}catch{}this.httpServer=null,this.wss=null,s(c)}};n.once("error",r),n.listen(e,"127.0.0.1",()=>{a||(a=!0,n.removeListener("error",r),n.on("error",c=>{process.stderr.write(`ws bridge http error: ${String(c)}
|
|
15
|
-
`)}),this.httpServer=n,this.wss=new ht({noServer:!0}),this.wireWebSocketServer(),n.on("upgrade",(c,d,l)=>{De(c,d,l)||this.wss?.handleUpgrade(c,d,l,u=>{this.wss?.emit("connection",u,c)})}),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.shouldPromoteSim(n)&&(this.primarySimId=n.id),this.broadcastSimAssignments(),this.broadcastSimClientStates();else{let a=`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,a)}e.on("message",a=>{let r;try{r=JSON.parse(a.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 c=O.listInstalled(),d=this.getActiveRuntime(),l={type:"runtime:list:ok",id:r.id,installed:c,active:d.version,activeRuntimeDir:d.runtimeDir};try{e.send(JSON.stringify(l))}catch{}return}if(r.type==="runtime:use"){let c=typeof r.version=="string"?r.version:"";if(!O.listInstalled().includes(c)){try{e.send(JSON.stringify({type:"runtime:use:error",id:r.id,error:`runtime ${c||"(missing)"} is not installed`}))}catch{}return}let l=this.setActiveRuntime(c);try{e.send(JSON.stringify({type:"runtime:use:ok",id:r.id,version:l.version,runtimeDir:l.runtimeDir}))}catch{}return}if(r.type==="runtime:get"){let c=this.getActiveRuntime();try{e.send(JSON.stringify({type:"runtime:get:ok",id:r.id,active:c.version,activeRuntimeDir:c.runtimeDir}))}catch{}return}if(s==="sim"&&r.type==="bridge:hello"&&n&&!n.url){let c=n.id;this.sims.delete(c),this.primarySimId===c&&(this.primarySimId=this.getOpenSim()?.id??null),n=null,s="cli",this.cliIdentityKeyBySocket.set(e,`ws-${this.nextCliFallbackId++}`),this.broadcastSimAssignments(),this.broadcastSimClientStates()}if(s==="sim"){if(n&&(n.lastSeenAt=Date.now()),r.type==="bridge:register"&&n){let l=r,u=this.tryRestoreSimId(n,l.simId);n.url=l.url,n.title=l.title,n.userAgent=l.userAgent,typeof l.kind=="string"&&l.kind.trim()&&(n.kind=l.kind.trim()),l.meta&&typeof l.meta=="object"&&(n.meta=l.meta);let m=this.primarySimId!==n.id&&this.shouldPromoteSim(n);m&&(this.primarySimId=n.id),(u||m)&&(this.broadcastSimAssignments(),this.broadcastSimClientStates());return}if(r.type==="bridge:user-focus-state"&&n){let l=r;this.updateUserFocusLease(n,l);return}if(r.type==="bridge:user-interact"&&n){this.updateUserActivity(n);return}if(r.type==="bridge:write-shared-config"){let l=r.patch&&typeof r.patch=="object"?r.patch:null;if(!l)return;let u;try{u=q(l)}catch(p){process.stderr.write(`sootsim: bridge:write-shared-config failed: ${p instanceof Error?p.message:String(p)}
|
|
16
|
-
`);return}let m=JSON.stringify({type:"bridge:shared-config-changed",config:u});for(let p of this.sims.values())if(p.ws.readyState===f.OPEN)try{p.ws.send(m)}catch{}return}if(r.type==="bridge:open-path"){let l=typeof r.path=="string"?r.path:"",u=typeof r.line=="number"&&Number.isFinite(r.line)?r.line:void 0,m=typeof r.column=="number"&&Number.isFinite(r.column)?r.column:void 0;l&&this.openPathInEditor(l,u,m);return}if(r.type==="bridge:boot-clients"&&n){let l=[];for(let[m,p]of this.cliSimBySocket)p===n.id&&l.push(m);for(let m of l){this.cliSimBySocket.delete(m);try{m.close(1e3,"booted by sim")}catch{}}let u=!!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 ${l.length} cli client(s)${u?" (overrode prior lease)":""}; held sim for user [${n.id}]
|
|
17
|
-
`),this.recordSimAction(n.id,"sim booted cli clients"),this.broadcastSimClientStates();return}let c=this.pendingCommands.get(r.id);if(c){this.pendingCommands.delete(r.id),r.error?c.reject(new Error(r.error)):c.resolve(r.result);return}let d=this.cliBySentId.get(r.id);if(d&&(this.cliBySentId.delete(r.id),d.ws.readyState===f.OPEN)){let l=this.getOtherCliIdentityCount(d.ws,d.simId),u=l>0?{...r,id:d.originalId,_otherCliCount:l}:{...r,id:d.originalId};d.ws.send(JSON.stringify(u))}return}(async()=>{this.cliLastCommandAt.set(e,Date.now());try{if(r.type==="bridge:bye"){let m=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[p,h]of this.cliBySentId)h.ws===e&&this.cliBySentId.delete(p);m&&this.broadcastSimClientStates();return}if(r.type==="bridge:hello"){let m=typeof r.cliIdentityKey=="string"&&r.cliIdentityKey.trim()?r.cliIdentityKey.trim():this.cliIdentityKeyBySocket.get(e)||`ws-${this.nextCliFallbackId++}`;this.cliIdentityKeyBySocket.set(e,m),typeof r.cliLabel=="string"&&r.cliLabel.trim()&&this.cliLabelBySocket.set(e,r.cliLabel.trim()),e.readyState===f.OPEN&&e.send(JSON.stringify({id:r.id,result:{cliIdentityKey:m,leaseTtlMs:o.CLI_LEASE_TTL_MS,leasing:!0}}));return}if(r.type==="bridge:list-sims"){e.readyState===f.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===f.OPEN&&e.send(JSON.stringify({id:r.id,result:{ok:!0,url:r.url}}));return}if(r.type==="bridge:claim"){let m=await this.waitForSim(r.simId),p=this.tryAcquireLease(e,m,{force:r.force===!0});if(!p.granted){e.readyState===f.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${m.id} is locked by another cli`,_locked:p.lock}));return}this.setCliSimTarget(e,m.id),this.recordSimAction(m.id,p.bootedCount>0?`cli force-claimed sim (booted ${p.bootedCount})`:"cli claimed sim"),e.readyState===f.OPEN&&e.send(JSON.stringify({id:r.id,result:{simId:m.id,lockedBy:p.lease.cliIdentityKey,lockExpiresAt:p.lease.expiresAt,bootedCount:p.bootedCount}}));return}let c=await this.waitForSim(r.simId);if(vt(r)){let m=this.tryAcquireLease(e,c);if(!m.granted){e.readyState===f.OPEN&&e.send(JSON.stringify({id:r.id,error:`sim ${c.id} is locked by another cli \u2014 use \`sootsim claim ${c.id} --force\` or \`sootsim open --new\``,_locked:m.lock}));return}}else this.ensureCliIdentityKey(e);this.setCliSimTarget(e,c.id),this.recordSimAction(c.id,this.describeForwardedCommand(r));let d=this.nextCommandId++;this.cliBySentId.set(d,{simId:c.id,ws:e,originalId:r.id});let{simId:l,...u}=r;if(c.ws.send(JSON.stringify({...u,id:d})),u.type==="close"){this.cliBySentId.delete(d),e.readyState===f.OPEN&&e.send(JSON.stringify({id:r.id,result:{requested:!0,simId:c.id}}));let m=c.ws,p=setTimeout(()=>{this.closeSimSocketFromHost(m)},St);Ue(p)}}catch(c){e.readyState===f.OPEN&&e.send(JSON.stringify({id:r.id,error:c instanceof Error?c.message:String(c)}))}})()}}),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[a,r]of this.pendingCommands)r.simId===n.id&&(r.reject(new Error("sim disconnected")),this.pendingCommands.delete(a));for(let[a,r]of this.cliBySentId)r.simId===n.id&&(r.ws.readyState===f.OPEN&&r.ws.send(JSON.stringify({id:r.originalId,error:"sim disconnected before responding"})),this.cliBySentId.delete(a));this.broadcastSimAssignments(),this.broadcastSimClientStates()}else if(s==="cli"){let a=this.cliSimBySocket.delete(e);this.cliLastCommandAt.delete(e),this.cliIdentityKeyBySocket.delete(e),this.cliLabelBySocket.delete(e);for(let[r,c]of this.cliBySentId)c.ws===e&&this.cliBySentId.delete(r);a&&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(_(),!ie(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{}},Ne),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{}},Ne),this.devHeartbeatTimer.unref()}this.agentHost.seedOnBoot()}bootstrapping=!0;buildLockfileSnapshot(){return{schema:1,pid:process.pid,platform:process.platform,bridgePort:this.effectivePort,runtimePort:this.effectivePort,activeRuntime:this.activeRuntimeVersion,activeRuntimeDir:this.activeRuntimeDirPath,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"}}writeLockfileSnapshot(){ee(this.buildLockfileSnapshot())}writeDevLockfileSnapshot(){te(this.buildDevLockfileSnapshot())}refreshActiveRuntime(){this.activeRuntimeVersion=W(),this.activeRuntimeDirPath=le()??Y()}runServerScan(){if(this.inflightScan)return this.inflightScan;let e=this.effectivePort>0?[this.effectivePort]:[];return this.inflightScan=x({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[wt]);return Number.isFinite(e)&&e>0?Math.max(100,Math.round(e)):bt}startRuntimeUpdater(){if(!this.shouldWriteLockfile||this.runtimeUpdateTimer||process.env.SOOTSIM_HOME&&G()&&!W())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 O.updateToLatest();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{z({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(X(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())if(i.ws.readyState===f.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",ft),t.setHeader("Cross-Origin-Resource-Policy","cross-origin"),t.setHeader("Document-Policy","js-profiling"),xe(e.url)){Me(e,t);return}if(Le(e.url)&&Be(e,t))return;let i=(e.method||"GET").toUpperCase();if(i!=="GET"&&i!=="HEAD"){t.writeHead(405,{Allow:"GET, HEAD"}),t.end("method not allowed");return}let s=new URL(e.url||"/","http://localhost");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 l;try{l=new URL(d)}catch{t.writeHead(400,{"Content-Type":"text/plain"}),t.end("bundle-proxy: invalid url");return}let u=l.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 p=await fetch(l.toString(),{redirect:"follow"}),h={},S=p.headers.get("content-type");if(S&&(h["Content-Type"]=S),h["Cache-Control"]="no-store",t.writeHead(p.status,h),!p.body){t.end();return}let g=p.body.getReader();for(;;){let{done:b,value:v}=await g.read();if(b)break;t.write(Buffer.from(v))}t.end()}catch(p){t.writeHead(502,{"Content-Type":"text/plain"}),t.end(`bundle-proxy: upstream fetch failed: ${p instanceof Error?p.message:String(p)}`)}})();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}if(s.pathname==="/__sootsim/shared-config"){if(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Cache-Control","no-store"),i==="GET"||i==="HEAD"){let d="{}";try{d=JSON.stringify(F())}catch{}t.writeHead(200,{"Content-Type":"application/json"}),i==="HEAD"?t.end():t.end(d);return}t.writeHead(405,{Allow:"GET, HEAD"}),t.end("method not allowed (use the bridge over WS for writes)");return}this.refreshActiveRuntime();let n=this.activeRuntimeDirPath;if(!n){t.writeHead(503,{"Content-Type":"text/plain; charset=utf-8"}),t.end("sootsim: no active runtime installed. run `sootsim runtime install` to fetch one.");return}let a=s.pathname;if(a==="/runtime"||a==="/runtime/"?a="/":a.startsWith("/runtime/")?a=a.slice(8):a==="/sootsim"||a==="/sootsim/"?a="/":a.startsWith("/sootsim/")&&(a=a.slice(8)),(a===""||a==="/")&&(a="/index.html"),a.includes("\0")){t.writeHead(400),t.end("bad request");return}if(process.platform!=="win32"&&a.includes("\\")){t.writeHead(400),t.end("bad request");return}for(let d of a.split("/"))if(d===".."){t.writeHead(403),t.end("forbidden");return}let r=w.resolve(n,"."+a),c=n.endsWith(w.sep)?n:n+w.sep;if(!r.startsWith(c)&&r!==n){t.writeHead(403),t.end("forbidden");return}I.realpath(r,(d,l)=>{let u=d?r:l,m=u.endsWith(w.sep)?u:u+w.sep;if(!d){let p=(()=>{try{let h=I.realpathSync(n);return h.endsWith(w.sep)?h:h+w.sep}catch{return c}})();if(!m.startsWith(p)&&u+w.sep!==p){t.writeHead(403),t.end("forbidden");return}}I.stat(u,(p,h)=>{if(p||!h?.isFile()){let v=w.extname(a).toLowerCase();if(v&&v!==".html"){t.writeHead(404),t.end("not found");return}if(a.startsWith("/__")||a.startsWith("/api/")||a==="/api"){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("not found");return}let A=w.join(n,"index.html");I.readFile(A,(y,R)=>{if(y){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(He(R,this.effectivePort,this.contrastOrigin))});return}let S=w.extname(u).toLowerCase(),g=At[S]||"application/octet-stream";if(t.writeHead(200,{"Content-Type":g,"Cache-Control":"no-store"}),i==="HEAD"){t.end();return}if(S===".html"){I.readFile(u,(v,A)=>{if(v){try{t.end()}catch{}return}t.end(He(A,this.effectivePort,this.contrastOrigin))});return}let b=I.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 a=!1;for(let r of this.cliBySentId.values())if(r.ws===i){a=!0;break}if(!a){this.cliSimBySocket.delete(i),this.cliLastCommandAt.delete(i);for(let[r,c]of this.cliBySentId)c.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 a=Math.max(n.lastActiveAt,n.connectedAt),r=e-a,c=this.isAutomationSim(n);if(c&&this.automationSimOwnerAlive(n))continue;let d=c?this.automationSimIdleReapTtlMs:this.simIdleReapTtlMs;if(r>=d){this.closeSimSocketFromHost(n.ws);continue}c&&i.push({sim:n,idleMs:r})}let s=this.maxConcurrentAutomationSims;if(i.length>s){i.sort((n,a)=>a.idleMs-n.idleMs);for(let{sim:n,idleMs:a}of i.slice(0,i.length-s))a<this.automationSimActiveGraceMs||this.closeSimSocketFromHost(n.ws)}}sweepDeadWebSockets(){if(this.wss)for(let e of this.wss.clients){if(e.readyState!==f.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!==f.OPEN)return;try{e.close(ae,ce)}catch{try{e.terminate()}catch{}return}let t=setTimeout(()=>{if(e.readyState!==f.CLOSED)try{e.terminate()}catch{}},yt);Ue(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 a=setTimeout(()=>{this.pendingCommands.delete(i),this.broadcastSimClientStates(),n(new Error("command timed out after 30s"))},3e4);this.pendingCommands.set(i,{simId:t.id,resolve:d=>{clearTimeout(a),this.pendingCommands.delete(i),this.broadcastSimClientStates(),s(d)},reject:d=>{clearTimeout(a),this.pendingCommands.delete(i),this.broadcastSimClientStates(),n(d)}}),this.broadcastSimClientStates();let{simId:r,...c}=e;t.ws.send(JSON.stringify({...c,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}`,a=(c,d)=>new Promise(l=>{try{let u=pt(c,d,{detached:!0,stdio:"ignore"}),m=!1;u.on("error",()=>{m||(m=!0,l(!1))}),u.on("spawn",()=>{m||(m=!0,u.unref(),l(!0))})}catch{l(!1)}}),r=process.env.REACT_EDITOR||process.env.EDITOR;if(r){let c=r.split(" ").filter(Boolean);if(c.length&&await a(c[0],[...c.slice(1),"-g",n]))return}await a("cursor",["-g",n])||await a("code",["-g",n])||await this.openUrl(e)}async openUrl(e,t={}){if(this.openUrlHandler){await this.openUrlHandler(e,t);return}await ue(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{re()}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=f.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===f.OPEN?"open":t===f.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 u=`ws-${this.nextCliFallbackId++}`;return this.cliIdentityKeyBySocket.set(e,u),u})(),n=this.cliLabelBySocket.get(e),a=Date.now(),r=this.getActiveLease(t),c=r&&r.cliIdentityKey===s,d=0;if(r&&!c&&!i.force)return{granted:!1,lease:r,lock:{by:r.cliLabel||r.cliIdentityKey,expiresInMs:Math.max(0,r.expiresAt-a)},bootedCount:0};if(r&&!c&&i.force)for(let[u,m]of this.cliSimBySocket){if(m!==t.id)continue;let p=this.cliIdentityKeyBySocket.get(u);if(p&&p!==s){this.cliSimBySocket.delete(u);try{u.close(1e3,"lease claimed by another cli")}catch{}d++}}let l={kind:"cli",cliIdentityKey:s,cliLabel:n,expiresAt:a+o.CLI_LEASE_TTL_MS};return t.cliLease=l,{granted:!0,lease:l,bootedCount:d}}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,a=typeof t.documentFocused=="boolean"?t.documentFocused:void 0;e.userFocused===i&&e.userVisible===s&&e.visibilityState===n&&e.documentFocused===a||(e.userFocused=i,e.userVisible=s,e.visibilityState=n,e.documentFocused=a,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===f.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===f.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 a=0;a<i;a++){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(d=>d.id).join(", ")}; run \`sootsim use <sim>\` or pass \`--sim <sim>\``);let c=r[0];if(c)return c}await new Promise(r=>setTimeout(r,s))}if(!e)throw new Error("no sim connected");let n=this.getDefaultSimCandidates().map(a=>a.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===f.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===f.OPEN&&e.ws.send(JSON.stringify({type:"bridge:welcome",simId:e.id,isPrimary:e.id===this.primarySimId}))}broadcastSimClientStates(){for(let e of this.sims.values()){if(e.ws.readyState!==f.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 a=Date.now();n.lastActiveAt=a,n.recentActions=[{label:s,at:a},...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!==f.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,a]of this.cliSimBySocket){if(a!==t||n.readyState!==f.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===f.OPEN)return!1;let n=this.getRestorableSimState(i),a=e.id;this.sims.delete(a),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===a&&(this.primarySimId=e.id);for(let[r,c]of this.cliSimBySocket)c===a&&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)}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 kt(){return!!((process.env.XPC_SERVICE_NAME||"").includes("dev.sootsim.daemon")||process.env.INVOCATION_ID)}async function pi(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=Z();n&&Q(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)),_();let a=await pe(),r=new N({port:i,writeLockfile:!0,contrastOrigin:a}),c=await r.startAsync({silent:s}),d=Date.now(),l=h=>{s||process.stdout.write(`${h}
|
|
43
|
-
`)},u=new Set,m=setInterval(()=>{let h=r.listSims(),S=new Set(h.map(g=>g.id));for(let g of h)if(!u.has(g.id)){let b=g.title||g.url||g.origin||"(unknown)";l(` + ${g.id} ${b}`)}for(let g of u)S.has(g)||l(` - ${g}`);u.clear();for(let g of S)u.add(g)},500);ne({event:"daemon_heartbeat",properties:{bridge_port:c,under_daemon:kt(),platform:process.platform,subsource:"daemon"}}),se(),l(`sootsim bridge listening on ws://localhost:${c} (runtime http on same port)`),c!==i&&l(` (preferred port ${i} was taken \u2014 fell back to ${c})`),l(" ready for browser, electron, or headless playwright sims to connect"),l(" (ctrl-c to stop)");let p=async h=>{clearInterval(m),l(`
|
|
44
|
-
${h} received \u2014 shutting down after ${Math.round((Date.now()-d)/1e3)}s`);try{await r.close()}catch{}process.exit(0)};process.on("SIGINT",()=>p("SIGINT")),process.on("SIGTERM",()=>p("SIGTERM")),process.on("SIGHUP",()=>p("SIGHUP")),process.on("exit",()=>{try{r.removeLockfile()}catch{}}),await new Promise(()=>{})}export{pi as runServe};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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 g,b as k}from"./chunk-3F2GAJ4Z.js";import{b as S,c as x}from"./chunk-EXTV6NWM.js";import{c as w}from"./chunk-ZFMJFX27.js";import"./chunk-SLMUW2WU.js";import"./chunk-JGGXQHXH.js";import"./chunk-I233T2T4.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{H as v,K as f,M as m,l as b}from"./chunk-WQL3BLFD.js";import"./chunk-PSOUSJSZ.js";import"./chunk-DUHBRW7J.js";import"./chunk-D2R7PDN5.js";import{existsSync as r,mkdirSync as j,readFileSync as d,readdirSync as I,writeFileSync as D}from"fs";import{basename as p,dirname as y,join as i,relative as c,resolve as h}from"path";var T=["bun","pnpm","npm"];async function pe(n){(n.includes("--help")||n.includes("-h"))&&(console.log(`
|
|
5
|
-
sootsim setup \u2014 set up this machine for SootSim
|
|
6
|
-
|
|
7
|
-
usage:
|
|
8
|
-
sootsim setup
|
|
9
|
-
sootsim setup --app <dir>
|
|
10
|
-
sootsim setup --yes
|
|
11
|
-
sootsim setup --dry-run
|
|
12
|
-
|
|
13
|
-
what it checks:
|
|
14
|
-
1. preferred package manager for app commands (bun, pnpm, or npm)
|
|
15
|
-
2. repo-pinned Node versions (mise, nvm, .node-version, package engines)
|
|
16
|
-
3. background daemon; recommended because it keeps CLI commands fast
|
|
17
|
-
4. app config scaffold; emits sootsim.config.js for plain JS apps or
|
|
18
|
-
sootsim.config.ts for TypeScript apps when the file is missing
|
|
19
|
-
|
|
20
|
-
SootSim does not need to be installed in each app, and it does not need an iOS
|
|
21
|
-
native build. Start Metro/Expo/One the way you already do, then run
|
|
22
|
-
\`sootsim open\`.
|
|
23
|
-
|
|
24
|
-
If you do not have the CLI installed yet, bootstrap with:
|
|
25
|
-
\`curl -fsSL https://sootsim.com/install.sh | sh\`
|
|
26
|
-
`),process.exit(0));let e=_(n);r(e.appDir)||(console.error(` directory not found: ${e.appDir}`),process.exit(1)),L(e);let o=await V(e),t=await F(e);q(e.appDir);let s=await Z(e);return ee(o),w({event:"cli_setup_guided",properties:{package_manager:o,config_created_now:t,daemon_installed_now:s,node_pin_count:M(e.appDir).length,from_welcome:e.fromWelcome}}),await te(e,s),{daemonInstalledNow:s}}function E(){let n=S(),e=f(),o=v();return{daemonSupported:n.supported,daemonInstalled:n.installed,daemonRunning:!!(e&&m(e)),runtimeInstalled:!!(o&&r(b(o)))}}function de(n=E()){return!n.daemonInstalled}function _(n){let e=n.indexOf("--app");return{dryRun:n.includes("--dry-run"),yes:n.includes("--yes")||n.includes("-y"),fromWelcome:n.includes("--from-welcome"),appDir:e!==-1&&n[e+1]?h(n[e+1]):process.cwd()}}function L(n){let e=n.fromWelcome?"welcome to sootsim":"sootsim setup";console.log(`
|
|
27
|
-
${e}
|
|
28
|
-
|
|
29
|
-
Recommended install path:
|
|
30
|
-
curl -fsSL https://sootsim.com/install.sh | sh
|
|
31
|
-
|
|
32
|
-
Or install the CLI manually, then run \`sootsim setup\`:
|
|
33
|
-
bun add -g sootsim
|
|
34
|
-
pnpm add -g sootsim
|
|
35
|
-
npm i -g sootsim
|
|
36
|
-
|
|
37
|
-
If this app needs a config scaffold, setup will write \`sootsim.config.js\`
|
|
38
|
-
for plain JS apps or \`sootsim.config.ts\` for TypeScript apps.
|
|
39
|
-
|
|
40
|
-
No per-app install is needed. Do not add SootSim to every package.json just
|
|
41
|
-
to open a simulator.
|
|
42
|
-
|
|
43
|
-
No iOS native build is needed. Run Metro, Expo, or One normally; SootSim
|
|
44
|
-
loads that dev server directly.
|
|
45
|
-
`)}async function V(n){let e=W(n.appDir),o=A(e);if(console.log(" package manager:"),n.yes)return console.log(` ${e} (detected)`),e;let t=await k("preferred package manager for app commands?",o.map(a=>a===e?`${a} (detected)`:a)),s=o[t]??e;return console.log(` using ${s} for examples only; SootSim stays outside the app`),s}function W(n){let e=h(n);for(;;){if(r(i(e,"bun.lock"))||r(i(e,"bun.lockb")))return"bun";if(r(i(e,"pnpm-lock.yaml")))return"pnpm";if(r(i(e,"package-lock.json")))return"npm";let o=y(e);if(o===e)return"npm";e=o}}function A(n){return[n,...T.filter(e=>e!==n)]}async function F(n){let e=B(n.appDir);if(e)return console.log(`
|
|
46
|
-
config:`),console.log(` already present: ${c(process.cwd(),e)||e}`),!1;let o=J(n.appDir),t=i(n.appDir,`sootsim.config.${o}`);return console.log(`
|
|
47
|
-
config:`),console.log(` recommended scaffold: ${c(process.cwd(),t)||t}`),console.log(` emits ${o==="ts"?"TypeScript":"plain JS"} so blank Expo apps do not need extra TypeScript dependencies.`),n.dryRun?(console.log(" would create the config scaffold"),!1):await R("create the config scaffold?",!0,n)?(K(t,o),console.log(` created ${c(process.cwd(),t)||t}`),!0):!1}function B(n){for(let e of["ts","js"]){let o=i(n,`sootsim.config.${e}`);if(r(o))return o}return null}function J(n){return G(n)?"ts":"js"}function G(n){let e=Y(n);if(e&&U(e))return!0;for(let o of["tsconfig.json","tsconfig.app.json","tsconfig.node.json","app.config.ts","app.config.tsx","metro.config.ts","metro.config.tsx","vite.config.ts","vite.config.tsx","babel.config.ts","expo-env.d.ts","index.ts","index.tsx","App.ts","App.tsx"])if(r(i(n,o)))return!0;for(let o of["app","src","pages"])if(C(i(n,o)))return!0;return!1}function Y(n){let e=i(n,"package.json");if(!r(e))return null;try{let o=JSON.parse(d(e,"utf8"));return o&&typeof o=="object"?o:null}catch{return null}}function U(n){return[l(n,"dependencies"),l(n,"devDependencies"),l(n,"peerDependencies")].some(o=>!!(u(o,"typescript")||u(o,"@types/react")||u(o,"@types/react-native")))}function C(n){if(!r(n))return!1;try{for(let e of I(n,{withFileTypes:!0})){let o=i(n,e.name);if(e.isDirectory()){if(e.name==="node_modules"||e.name.startsWith("."))continue;if(C(o))return!0;continue}if(e.isFile()&&(e.name.endsWith(".ts")||e.name.endsWith(".tsx")))return!0}}catch{return!1}return!1}function K(n,e){let o=e==="ts"?`import { defineConfig } from 'sootsim/config'
|
|
48
|
-
|
|
49
|
-
export default defineConfig({
|
|
50
|
-
// module resolution overrides
|
|
51
|
-
modules: {},
|
|
52
|
-
|
|
53
|
-
// environment variables
|
|
54
|
-
env: {},
|
|
55
|
-
|
|
56
|
-
// simulator settings
|
|
57
|
-
settings: {},
|
|
58
|
-
|
|
59
|
-
// initial app state
|
|
60
|
-
initialState: {},
|
|
61
|
-
})
|
|
62
|
-
`:`/** @type {import('sootsim/config').SootSimConfig} */
|
|
63
|
-
module.exports = {
|
|
64
|
-
// module resolution overrides
|
|
65
|
-
modules: {},
|
|
66
|
-
|
|
67
|
-
// environment variables
|
|
68
|
-
env: {},
|
|
69
|
-
|
|
70
|
-
// simulator settings
|
|
71
|
-
settings: {},
|
|
72
|
-
|
|
73
|
-
// initial app state
|
|
74
|
-
initialState: {},
|
|
75
|
-
}
|
|
76
|
-
`;j(y(n),{recursive:!0}),D(n,o)}function q(n){let e=M(n);if(console.log(`
|
|
77
|
-
node versions:`),e.length===0)console.log(` no mise/nvm/package Node pin detected near ${c(process.cwd(),n)||"."}`);else for(let o of e)console.log(` ${o.source}: ${o.value}`);console.log(" SootSim sidesteps per-repo Node installs: it is not added to this app.\n Your repo's Node pin only needs to run Metro/Expo/One; `sootsim open` attaches to the running server."),e.length>0&&X(process.execPath)&&console.log(` daemon note: setup is currently running on ${process.execPath}.
|
|
78
|
-
The daemon records that Node executable so launchd/systemd can start without shell init.
|
|
79
|
-
If this is a throwaway project-specific Node, rerun \`sootsim setup\` from your normal user Node shell.`)}function M(n){let e=[],o=new Set,t=h(n);for(;;){P(e,o,i(t,".nvmrc")),P(e,o,i(t,".node-version")),z(e,o,i(t,".tool-versions")),$(e,o,i(t,"mise.toml")),$(e,o,i(t,".mise.toml")),H(e,o,i(t,"package.json"));let s=y(t);if(s===t)break;t=s}return e}function P(n,e,o){if(!r(o)||e.has(o))return;e.add(o);let t=Q(o);t&&n.push({source:c(process.cwd(),o)||p(o),value:t})}function z(n,e,o){if(!r(o)||e.has(o))return;e.add(o);let t=d(o,"utf8");for(let s of t.split(`
|
|
80
|
-
`)){let a=s.trim().match(/^(nodejs|node)\s+(.+)$/);a&&n.push({source:`${c(process.cwd(),o)||p(o)}:${a[1]}`,value:a[2].trim()})}}function $(n,e,o){if(!r(o)||e.has(o))return;e.add(o);let s=d(o,"utf8").match(/^\s*(node|nodejs)\s*=\s*["']?([^"'\n#]+)["']?/m);s&&n.push({source:`${c(process.cwd(),o)||p(o)}:${s[1]}`,value:s[2].trim()})}function H(n,e,o){if(!(!r(o)||e.has(o))){e.add(o);try{let t=JSON.parse(d(o,"utf8")),s=u(l(t,"engines"),"node");s&&n.push({source:`${c(process.cwd(),o)||p(o)}:engines.node`,value:s});let a=u(l(t,"volta"),"node");a&&n.push({source:`${c(process.cwd(),o)||p(o)}:volta.node`,value:a})}catch{}}}function l(n,e){if(!n||typeof n!="object")return null;let o=Object.getOwnPropertyDescriptor(n,e)?.value;return o&&typeof o=="object"?o:null}function u(n,e){let o=n?.[e];return typeof o=="string"&&o.trim()?o.trim():null}function Q(n){return d(n,"utf8").split(`
|
|
81
|
-
`).map(o=>o.trim()).find(o=>o&&!o.startsWith("#"))??null}function X(n){let e=n.toLowerCase();return e.includes("/.nvm/")||e.includes("/mise/")||e.includes("/fnm/")||e.includes("/volta/")||e.includes("/asdf/")}async function Z(n){let e=S(),o=f(),t=!!(o&&m(o));return console.log(`
|
|
82
|
-
daemon:`),e.supported?e.installed?(console.log(` installed${t&&o?`, running on port ${o.bridgePort}`:""}`),!1):(console.log(" not installed"),console.log(` recommended: installs a background bridge so every CLI command is much faster.
|
|
83
|
-
Without it, commands may need to spin up a local server before they can talk to the sim.`),n.dryRun?(console.log(" would install the background daemon"),!1):await R("install the background daemon?",!0,n)?(await x({port:7668,force:!1}),!0):!1):(console.log(` unavailable on ${process.platform}`),console.log(" `sootsim open` can still start a local bridge when needed"),!1)}function ee(n){console.log(`
|
|
84
|
-
basic usage:
|
|
85
|
-
1. start your app dev server normally:
|
|
86
|
-
${N(n,"expo start --port 8081")}
|
|
87
|
-
${N(n,"react-native start --port 8081")}
|
|
88
|
-
${ne(n,"dev")}
|
|
89
|
-
|
|
90
|
-
2. install and use the global CLI:
|
|
91
|
-
${oe(n)}
|
|
92
|
-
|
|
93
|
-
3. open it in SootSim:
|
|
94
|
-
sootsim open 8081
|
|
95
|
-
|
|
96
|
-
4. inspect and drive it:
|
|
97
|
-
sootsim describe
|
|
98
|
-
sootsim do tap-text "Sign in"
|
|
99
|
-
`)}function N(n,e){switch(n){case"bun":return`bunx ${e}`;case"pnpm":return`pnpm exec ${e}`;case"npm":return`npx ${e}`}}function ne(n,e){switch(n){case"bun":return`bun run ${e}`;case"pnpm":return`pnpm run ${e}`;case"npm":return`npm run ${e}`}}function oe(n){switch(n){case"bun":return"bun add -g sootsim";case"pnpm":return"pnpm add -g sootsim";case"npm":return"npm i -g sootsim"}}async function te(n,e){if(!e||n.dryRun)return;if(console.log(" last step:"),!process.stdin.isTTY){console.log(" run `sootsim open` after your Metro/Expo/One server is up");return}if(!await g("I'll run `sootsim open` for you now?",!0)){console.log(" later: sootsim open");return}let{runOpenCommand:o}=await import("./control-HV7GZXAH.js");await o([],{port:7668})}async function R(n,e,o){return o.yes?!0:process.stdin.isTTY?g(n,e):(console.log(` ${n} ${e?"[Y/n]":"[y/N]"} n (non-interactive; pass --yes to accept)`),!1)}export{J as detectConfigScaffoldExt,M as detectNodeVersionPins,W as detectPreferredPackageManager,E as readMachineSetupStatus,pe as runSetup,de as shouldRunSetupForBareCommand};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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-W44PDEQH.js";import"./chunk-VXGCZUX4.js";import"./chunk-D2R7PDN5.js";export{a as settingsStore};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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-ZFMJFX27.js";import"./chunk-SLMUW2WU.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{b as flushCliTelemetry,a as trackCliEvent};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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 d}from"./chunk-BBVBMGTT.js";import"./chunk-PZTKQG6H.js";import{a,d as c}from"./chunk-CTMPC5DN.js";import"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import{g as r,h as l}from"./chunk-WQL3BLFD.js";import{a as m}from"./chunk-PSOUSJSZ.js";import"./chunk-D2R7PDN5.js";import{spawn as g}from"node:child_process";import u from"node:fs";import p from"node:os";import e from"node:path";var f="https://registry.npmjs.org/sootsim/latest";async function R(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 i=c.resolvePin();i&&(console.log(` pinned to ${i} \u2014 installing the pin, not channel latest`),console.log(" (run `sootsim runtime unpin` to follow latest again)")),await d(["install",...t?["--channel",t]:[]],{}),console.log(`
|
|
6
|
-
cli:`),await $()}function h(){if(l())return{kind:"dev"};let o=process.argv[1]??"";try{o=u.realpathSync(o)}catch{}let n=e.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=e.join(r(),"cli");if(o.startsWith(`${t}${n}`))return{kind:"global",command:"npm",args:["i","-g","--prefix",t,"sootsim@latest"]};let i=e.resolve(process.env.SOOTSIM_CLI_PREFIX||e.join(p.homedir(),".local"));return o.startsWith(`${i}${n}`)?{kind:"global",command:"npm",args:["i","-g","--prefix",i,"sootsim@latest"]}:{kind:"global",command:"npm",args:["i","-g","sootsim@latest"]}}async function $(){let o=m(),n=await k();if(!n){console.log(` v${o} \u2014 couldn't reach the npm registry, skipped`);return}if(a(n,o)<=0){console.log(` v${o} (latest)`);return}let t=h();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 i=`${t.command} ${t.args.join(" ")}`;console.log(` updating global install (${i})\u2026`),await v(t.command,t.args)?console.log(` updated to v${n}`):(console.log(" update failed \u2014 run it yourself:"),console.log(` ${i}`))}function v(o,n){return new Promise(t=>{let i=g(o,n,{stdio:"inherit"});i.on("error",()=>t(!1)),i.on("exit",s=>t(s===0))})}async function k(){try{let o=await fetch(f,{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{R as runUpgrade};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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-BXO2PTNM.js";import"./chunk-FSRRJGYC.js";import"./chunk-6YN3IAWJ.js";import"./chunk-37ZXWXM3.js";import"./chunk-VVVORIQI.js";import"./chunk-PZTKQG6H.js";import"./chunk-ZFMJFX27.js";import"./chunk-SLMUW2WU.js";import"./chunk-OKSGM6IG.js";import"./chunk-JUOQ4ZPA.js";import"./chunk-WQL3BLFD.js";import"./chunk-D2R7PDN5.js";export{a as resolveDefaultUploadOrigin,b as resolvePublicPreviewOrigin,c as runUpload};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.294 | (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 i,d as t}from"./chunk-CTMPC5DN.js";import{a as l}from"./chunk-I233T2T4.js";import"./chunk-WQL3BLFD.js";import{a as s}from"./chunk-PSOUSJSZ.js";import"./chunk-D2R7PDN5.js";async function d(c){let{IS_BETA:r,BETA_LABEL:m}=await import("./beta-RXT5RU3A.js"),a=r?` \xB7 ${m}`:"";console.log(`sootsim v${s()}${a}`);let o=l(),e=t.resolveChannel();o.isDevBridge?(console.log(o.primary),o.installedRuntime&&console.log(`${o.installedRuntime} \xB7 ${e}`)):o.primary==="runtime not installed"?console.log("runtime not installed \u2014 run `sootsim runtime install`"):console.log(`${o.primary} \xB7 ${e}`);let n=await t.checkUpToDate({channel:e});n.pinned&&console.log(` runtime pinned to v${n.pinned} (\`sootsim runtime unpin\` to follow latest)`),n.outdated&&n.latest&&console.log(`
|
|
5
|
-
\u2191 runtime v${n.latest} available \u2014 run \`sootsim upgrade\``),console.log(`
|
|
6
|
-
what's new: ${i}`)}export{d as runVersion};
|