sootsim 0.1.162 → 0.1.163
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/dist-cli/bin.js +3 -3
- package/dist-cli/chunks/{agent-LO265RAL.js → agent-2UJH7NLM.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-DAWUFAQB.js → agent-wrapper-IARGRXXC.js} +2 -2
- package/dist-cli/chunks/{app-fonts-H6UHD3KO.js → app-fonts-4JHC6FEJ.js} +2 -2
- package/dist-cli/chunks/{assert-UT7AICKK.js → assert-ETPPYEZL.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-RUXZLYLL.js +2 -0
- package/dist-cli/chunks/beta-WQIEGEVM.js +2 -0
- package/dist-cli/chunks/{camera-W2LBLRBV.js → camera-MT3JIJW5.js} +2 -2
- package/dist-cli/chunks/chunk-24UV32LK.js +1 -0
- package/dist-cli/chunks/{chunk-S5K7GZCC.js → chunk-2DAZ32M2.js} +3 -3
- package/dist-cli/chunks/{chunk-FQMEXGSM.js → chunk-3PVLSJHL.js} +1 -1
- package/dist-cli/chunks/{chunk-Q4SGZDMS.js → chunk-6RY6L5JR.js} +1 -1
- package/dist-cli/chunks/{chunk-VC2QRHWO.js → chunk-76AZBX3S.js} +2 -2
- package/dist-cli/chunks/{chunk-FB2PESZ4.js → chunk-7FLA4A4M.js} +2 -2
- package/dist-cli/chunks/chunk-7QFEXS62.js +2 -0
- package/dist-cli/chunks/{chunk-F6M3RMFD.js → chunk-AEDFOOYN.js} +1 -1
- package/dist-cli/chunks/{chunk-XJ6US7DQ.js → chunk-ATMMZFJE.js} +1 -1
- package/dist-cli/chunks/{chunk-FLTCCI7Y.js → chunk-BH7P5BRG.js} +32 -16
- package/dist-cli/chunks/{chunk-CSDNVNTT.js → chunk-C4AIMLRI.js} +2 -2
- package/dist-cli/chunks/{chunk-LHQSYK3T.js → chunk-CMH5RKUR.js} +2 -2
- package/dist-cli/chunks/{chunk-52WDVJM3.js → chunk-DDAGD5DR.js} +2 -2
- package/dist-cli/chunks/{chunk-EHOM3BI7.js → chunk-EETYYBYZ.js} +1 -1
- package/dist-cli/chunks/{chunk-5ODCFRMJ.js → chunk-ERENNF6M.js} +1 -1
- package/dist-cli/chunks/{chunk-SXENHCOV.js → chunk-FLZXWNIH.js} +2 -2
- package/dist-cli/chunks/{chunk-EOEQ4HNN.js → chunk-GL7XIITU.js} +2 -2
- package/dist-cli/chunks/{chunk-YQI4W45L.js → chunk-H5PWNDJX.js} +2 -2
- package/dist-cli/chunks/{chunk-QAERV7TK.js → chunk-HHKHMWRR.js} +2 -2
- package/dist-cli/chunks/{chunk-GPCURKEG.js → chunk-HWBJB3EE.js} +2 -2
- package/dist-cli/chunks/{chunk-BIM3MQKR.js → chunk-I2BWZNCX.js} +1 -1
- package/dist-cli/chunks/{chunk-UDGOCL6E.js → chunk-K6OWYKCH.js} +1 -1
- package/dist-cli/chunks/chunk-KMLULXMX.js +1 -0
- package/dist-cli/chunks/{chunk-MQUXKFR7.js → chunk-LIFPDHVG.js} +1 -1
- package/dist-cli/chunks/{chunk-HML6NZPS.js → chunk-MFTSL5T7.js} +2 -2
- package/dist-cli/chunks/{chunk-H4USTFVM.js → chunk-N2RYSVRC.js} +2 -2
- package/dist-cli/chunks/{chunk-SMYSGUOC.js → chunk-NPS6GG4R.js} +1 -1
- package/dist-cli/chunks/{chunk-YQ7G3RJ4.js → chunk-NURFX6AZ.js} +1 -1
- package/dist-cli/chunks/{chunk-27MSLKR3.js → chunk-OJIOSOSI.js} +1 -1
- package/dist-cli/chunks/{chunk-6GHECYKR.js → chunk-OJKEKN6J.js} +1 -1
- package/dist-cli/chunks/{chunk-DR4YEAAG.js → chunk-QD3SYTZB.js} +2 -2
- package/dist-cli/chunks/{chunk-HWRWRQQM.js → chunk-RAFS3IF4.js} +1 -1
- package/dist-cli/chunks/{chunk-VGAM6F6G.js → chunk-S723QE3J.js} +1 -1
- package/dist-cli/chunks/chunk-SCIZLBBI.js +1 -0
- package/dist-cli/chunks/{chunk-MUTEYS5D.js → chunk-SLH7AMG2.js} +65 -63
- package/dist-cli/chunks/{chunk-HS6OQVDE.js → chunk-SNIJMEQV.js} +2 -2
- package/dist-cli/chunks/{chunk-XC54E57T.js → chunk-T56IURYQ.js} +1 -1
- package/dist-cli/chunks/{chunk-5JFU2WAM.js → chunk-U3JJW7K3.js} +2 -2
- package/dist-cli/chunks/{chunk-DSURWK65.js → chunk-UJWRFH4F.js} +3 -3
- package/dist-cli/chunks/{chunk-GRDHKXX4.js → chunk-VC6LECEG.js} +3 -3
- package/dist-cli/chunks/{chunk-XC6QP4VA.js → chunk-WEUFC7SG.js} +1 -1
- package/dist-cli/chunks/{chunk-OTR36LRW.js → chunk-XA54L6E7.js} +2 -2
- package/dist-cli/chunks/{chunk-NQZAX3PN.js → chunk-XEL4ZT7P.js} +2 -2
- package/dist-cli/chunks/{chunk-ZBGRSZSL.js → chunk-YDOTSYCN.js} +2 -2
- package/dist-cli/chunks/{chunk-FT4YJUPI.js → chunk-YKRDJEXB.js} +2 -2
- package/dist-cli/chunks/{chunk-CA7BU2LJ.js → chunk-Z76N3LVQ.js} +2 -2
- package/dist-cli/chunks/cli-version-JOMTNDB5.js +2 -0
- package/dist-cli/chunks/{compat-MKY2VAXV.js → compat-PVZQRLJ6.js} +3 -3
- package/dist-cli/chunks/{config-CDYR5D7R.js → config-KO3JTNDD.js} +2 -2
- package/dist-cli/chunks/{control-S3FIQDAU.js → control-KSMUT3S3.js} +2 -2
- package/dist-cli/chunks/{cpu-profile-DB37SW5C.js → cpu-profile-XAZP7XUR.js} +2 -2
- package/dist-cli/chunks/{daemon-BUONCHBV.js → daemon-4NBH5C6S.js} +2 -2
- package/dist-cli/chunks/{debug-VRS6Y7B7.js → debug-22DO3PBO.js} +3 -3
- package/dist-cli/chunks/{detox-7KEHONVO.js → detox-EBPXAOAO.js} +2 -2
- package/dist-cli/chunks/{device-SKVTABDY.js → device-JOVGQXTD.js} +2 -2
- package/dist-cli/chunks/{diagnose-EMIKFM2D.js → diagnose-LY65X3IJ.js} +2 -2
- package/dist-cli/chunks/drivers-CVMCFSMA.js +2 -0
- package/dist-cli/chunks/{electron-Q3HNB7PL.js → electron-X4EV5RDR.js} +3 -3
- package/dist-cli/chunks/flow-6XTWYTV2.js +2 -0
- package/dist-cli/chunks/help-RJKPD5OO.js +2 -0
- package/dist-cli/chunks/{hints-HZS7GAJA.js → hints-5WYSEJRG.js} +2 -2
- package/dist-cli/chunks/{home-paths-P6EXIVWD.js → home-paths-4OM2SXFV.js} +2 -2
- package/dist-cli/chunks/{inspect-MCXM5SAQ.js → inspect-FQCH4VYC.js} +3 -3
- package/dist-cli/chunks/install-36CBFFVW.js +2 -0
- package/dist-cli/chunks/{install-desktop-AFTXVHP3.js → install-desktop-ZK6OM5BF.js} +3 -3
- package/dist-cli/chunks/{keys-QDWU67OR.js → keys-YVIHIHM6.js} +2 -2
- package/dist-cli/chunks/{launch-NG26B5RZ.js → launch-SZM2GUG3.js} +3 -3
- package/dist-cli/chunks/{login-PQ7RMILY.js → login-3THHYZHX.js} +4 -4
- package/dist-cli/chunks/{logout-CKK2G7SP.js → logout-KIL255SD.js} +2 -2
- package/dist-cli/chunks/{maestro-JVEU6KHH.js → maestro-H3RCJ7LM.js} +2 -2
- package/dist-cli/chunks/optional-demo-registry-PYWPXAHB.js +2 -0
- package/dist-cli/chunks/{preview-WGYMKOE3.js → preview-FFCTIVNR.js} +2 -2
- package/dist-cli/chunks/{profile-U7Z4Q47X.js → profile-5PXB4YSX.js} +2 -2
- package/dist-cli/chunks/{react-AQ2OCEAQ.js → react-VUGPLZXV.js} +2 -2
- package/dist-cli/chunks/{record-J7HLU4JS.js → record-V65T5C5M.js} +2 -2
- package/dist-cli/chunks/runtime-A4PZC73P.js +2 -0
- package/dist-cli/chunks/{runtime-delivery-CJNUY63Q.js → runtime-delivery-AAOS2QLP.js} +2 -2
- package/dist-cli/chunks/{screenshot-OHQXY74L.js → screenshot-UMGAKH23.js} +2 -2
- package/dist-cli/chunks/{screenshot-mode-SOHMBDT5.js → screenshot-mode-D6TMSRFV.js} +2 -2
- package/dist-cli/chunks/{screenshots-Z4RQONGR.js → screenshots-FF3ZUERE.js} +2 -2
- package/dist-cli/chunks/{server-4S3UQTRL.js → server-K7XHAKC3.js} +3 -3
- package/dist-cli/chunks/setup-repo-VMRRSQNQ.js +2 -0
- package/dist-cli/chunks/{skills-7HB5S4LI.js → skills-RL3Y6UA4.js} +2 -2
- package/dist-cli/chunks/{slides-R4H4FR3H.js → slides-ZT63RJ4N.js} +2 -2
- package/dist-cli/chunks/{start-E55XI5LU.js → start-6Q4AH3SE.js} +4 -4
- package/dist-cli/chunks/store-G7ATTZYC.js +2 -0
- package/dist-cli/chunks/telemetry-2PKRXSHN.js +2 -0
- package/dist-cli/chunks/{test-NBLAG64Y.js → test-LQ6BIRWA.js} +3 -3
- package/dist-cli/chunks/{three-mode-TRW5YX7K.js → three-mode-IU2M4YBF.js} +2 -2
- package/dist-cli/chunks/{timeline-4T3GVHLC.js → timeline-HIBVAHPT.js} +2 -2
- package/dist-cli/chunks/{upgrade-O76AN43O.js → upgrade-FI4K2DGQ.js} +2 -2
- package/dist-cli/chunks/upload-H5BBABDO.js +2 -0
- package/dist-cli/chunks/{version-62GSJHBJ.js → version-CU4X5HHD.js} +2 -2
- package/dist-cli/chunks/{web-W4LJPXDZ.js → web-TNVHBB2J.js} +2 -2
- package/dist-cli/chunks/{what-happened-3ZQIL7IG.js → what-happened-B6PDCO7H.js} +2 -2
- package/dist-cli/chunks/{whoami-B7732WRQ.js → whoami-QI7BT4PM.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1 -1
- 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 +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- 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 +1 -1
- package/dist-lib/sdk.cjs +22 -6
- package/dist-lib/sdk.mjs +22 -6
- package/dist-lib/skills.cjs +22 -6
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/auto-bootstrap-I3KNM7GQ.js +0 -2
- package/dist-cli/chunks/beta-J7RAAVTX.js +0 -2
- package/dist-cli/chunks/chunk-4F2UTA6M.js +0 -1
- package/dist-cli/chunks/chunk-DWJF3EAY.js +0 -1
- package/dist-cli/chunks/chunk-IPH6PRZA.js +0 -1
- package/dist-cli/chunks/chunk-VWH4Z4IA.js +0 -2
- package/dist-cli/chunks/cli-version-YMKXVHAQ.js +0 -2
- package/dist-cli/chunks/drivers-4HCW2H2D.js +0 -2
- package/dist-cli/chunks/flow-S7Z4VO7M.js +0 -2
- package/dist-cli/chunks/help-GXUUDYEB.js +0 -2
- package/dist-cli/chunks/install-2BEUCVU6.js +0 -2
- package/dist-cli/chunks/optional-demo-registry-6EBMAPK6.js +0 -2
- package/dist-cli/chunks/runtime-E6LF6N34.js +0 -2
- package/dist-cli/chunks/setup-repo-EQOEDMLO.js +0 -2
- package/dist-cli/chunks/store-EJXO6Z7O.js +0 -2
- package/dist-cli/chunks/telemetry-SWSWXD7D.js +0 -2
- package/dist-cli/chunks/upload-YZOHYDIQ.js +0 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as d,b as g}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as d,b as g}from"./chunk-S723QE3J.js";import{a as f,c as w}from"./chunk-SNIJMEQV.js";import{a as u,b as h,c as p}from"./chunk-3PVLSJHL.js";import{c as m}from"./chunk-RAFS3IF4.js";function I(){let e=u();return e?{available:!0,reason:null,detail:e}:{available:!1,reason:"no chromium-family browser found (chrome, chromium, edge, brave, arc)"}}async function _(e){if(e.headless)return{launched:!1,message:"the chromium driver launches a visible browser window and cannot run headless \u2014 a headless `chrome --headless=new` process exits immediately and the sim never connects. for headless automation use `--driver playwright`."};let r=u();if(!r)return{launched:!1,message:"chromium not found \u2014 install chrome or run `sootsim list --drivers`"};if(!e.url)return{launched:!1,message:"chromium driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current Chrome profile"};try{let t=await p(e.url,{detached:e.detached??!0});return{launched:!0,message:`chromium launched \u2192 ${e.url}`,pid:t.pid,target:t.target??r,attachUrl:e.url}}catch(t){return{launched:!1,message:`chromium spawn failed: ${t instanceof Error?t.message:String(t)}`}}}var v={id:"chromium",name:"chromium",description:"system chrome / chromium / edge \u2014 visible window (headless: use playwright)",kind:"browser",availability:I,launch:_};function x(){let e=d();return e?{available:!0,reason:null,detail:`${e.kind} @ ${e.path}`}:{available:!1,reason:"sootsim desktop app not installed (run `sootsim install-desktop`)"}}async function M(e){let r=d();if(!r)return{launched:!1,message:"sootsim desktop app not installed"};try{let t=await g(e.url,r,{device:e.device,profileId:e.profileId,ephemeralProfile:e.ephemeralProfile});return t.launched?{launched:!0,message:e.url?`electron launched via ${t.via} \u2192 ${e.url}`:`electron launched via ${t.via}`,target:t.target,attachUrl:e.url}:{launched:!1,message:"desktop companion failed to start"}}catch(t){return{launched:!1,message:`electron launch failed: ${t instanceof Error?t.message:String(t)}`}}}var y={id:"electron",name:"electron",description:"sootsim desktop companion app (native window, menu bar)",kind:"native",availability:x,launch:M};import{spawn as C}from"child_process";import{closeSync as E,mkdtempSync as A,openSync as L,readFileSync as W}from"fs";import{createRequire as R}from"module";import{tmpdir as b}from"os";import{join as P}from"path";var N=`
|
|
3
3
|
const modulePath = process.env.SOOTSIM_PW_MODULE;
|
|
4
4
|
const url = process.env.SOOTSIM_PW_URL;
|
|
5
5
|
const headless = process.env.SOOTSIM_PW_HEADLESS === '1';
|
|
6
|
-
const
|
|
6
|
+
const callerUserDataDir = process.env.SOOTSIM_PW_USERDATADIR || '';
|
|
7
7
|
// pid of the session that launched us (its topmost non-init ancestor). when
|
|
8
8
|
// that process exits we tear Chrome down \u2014 see startOwnerWatch below. 0/unset
|
|
9
9
|
// disables the watchdog. SOOTSIM_PW_OWNER_POLL_MS is a test-only override of
|
|
@@ -16,28 +16,41 @@ const ownerPollMs = Number(process.env.SOOTSIM_PW_OWNER_POLL_MS || 5000);
|
|
|
16
16
|
const cdpPort = process.env.SOOTSIM_PW_CDP_PORT || '';
|
|
17
17
|
const closeTimeoutMs = Number(process.env.SOOTSIM_PW_CLOSE_TIMEOUT_MS || 2500);
|
|
18
18
|
const connectAckFile = process.env.SOOTSIM_PW_CONNECTED_ACK_FILE || '';
|
|
19
|
-
const { existsSync, unlinkSync } = require('fs');
|
|
19
|
+
const { existsSync, mkdtempSync, rmSync, unlinkSync } = require('fs');
|
|
20
20
|
const { execSync } = require('child_process');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
21
|
+
const { tmpdir } = require('os');
|
|
22
|
+
const { join } = require('path');
|
|
23
|
+
// chrome tree reaper \u2014 playwright's browser.close() and even SIGKILLing the
|
|
24
|
+
// root chrome process do NOT reliably take down the helper tree (gpu, renderer,
|
|
25
|
+
// network/storage utilities). they reparent to launchd/init and survive, each
|
|
26
|
+
// one busy enough to peg CPU at 100%+. close() only reaches the root.
|
|
27
|
+
//
|
|
28
|
+
// the prior approach was \`pgrep -f ms-playwright/[c]hromium\` \u2014 that filter is
|
|
29
|
+
// deliberately narrow so a system Chrome (channel:'chrome' \u2192 /Applications/
|
|
30
|
+
// Google Chrome.app/...) is never matched and never killed. but channel:'chrome'
|
|
31
|
+
// is exactly the default path, so the reaper was a no-op in the common case and
|
|
32
|
+
// every aborted/closed \`sootsim open\` leaked a renderer + gpu helper burning
|
|
33
|
+
// 100%+ CPU until manually killed (multiple incidents 2026-06).
|
|
34
|
+
//
|
|
35
|
+
// fix: identify our chrome tree by its UNIQUE user-data-dir. every helper a
|
|
36
|
+
// chrome root spawns inherits \`--user-data-dir=<dir>\` in its cmdline, so
|
|
37
|
+
// \`pgrep -f <profileDir>\` finds exactly the tree we launched and nothing else
|
|
38
|
+
// \u2014 system Chrome and bundled playwright chromium alike. as a side benefit we
|
|
39
|
+
// no longer need the launch / launchPersistentContext fork: we ALWAYS use a
|
|
40
|
+
// profile dir (mkdtemp'd if the caller didn't pass one, then removed at exit).
|
|
31
41
|
const reapEnabled = process.platform !== 'win32';
|
|
32
|
-
|
|
42
|
+
let profileDir = callerUserDataDir;
|
|
43
|
+
let ephemeralProfile = false;
|
|
44
|
+
if (!profileDir) {
|
|
45
|
+
profileDir = mkdtempSync(join(tmpdir(), 'sootsim-playwright-host-'));
|
|
46
|
+
ephemeralProfile = true;
|
|
47
|
+
}
|
|
48
|
+
const chromePidsByProfile = () => {
|
|
33
49
|
if (!reapEnabled) return [];
|
|
34
50
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// the character class keeps the pattern from matching its own literal.
|
|
39
|
-
return execSync('pgrep -f "ms-playwright/[c]hromium" || true', { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
40
|
-
.toString().split('\\n').filter(Boolean);
|
|
51
|
+
return execSync('pgrep -f ' + profileDir + ' || true', { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
52
|
+
.toString().split('\\n').filter(Boolean).map((p) => Number(p))
|
|
53
|
+
.filter((p) => p && p !== process.pid);
|
|
41
54
|
} catch { return []; }
|
|
42
55
|
};
|
|
43
56
|
const killTree = (pid) => {
|
|
@@ -49,11 +62,13 @@ const killTree = (pid) => {
|
|
|
49
62
|
for (const k of kids) killTree(Number(k));
|
|
50
63
|
try { process.kill(pid, 'SIGKILL'); } catch {}
|
|
51
64
|
};
|
|
52
|
-
const
|
|
53
|
-
const
|
|
65
|
+
const reapChrome = () => { for (const pid of chromePidsByProfile()) killTree(pid); };
|
|
66
|
+
const cleanupProfile = () => {
|
|
67
|
+
if (!ephemeralProfile) return;
|
|
68
|
+
try { rmSync(profileDir, { recursive: true, force: true }); } catch {}
|
|
69
|
+
};
|
|
54
70
|
(async () => {
|
|
55
71
|
const pw = require(modulePath);
|
|
56
|
-
let browser = null;
|
|
57
72
|
let context;
|
|
58
73
|
let keepAlive = null;
|
|
59
74
|
let connectTimer = null;
|
|
@@ -106,17 +121,12 @@ const reapChromium = () => { for (const pid of myChromiumRoots) killTree(pid); }
|
|
|
106
121
|
if (timer) clearTimeout(timer);
|
|
107
122
|
}
|
|
108
123
|
};
|
|
109
|
-
const maybeBrowser = () => {
|
|
110
|
-
if (browser) return browser;
|
|
111
|
-
if (context && typeof context.browser === 'function') {
|
|
112
|
-
try { return context.browser(); } catch {}
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
};
|
|
116
124
|
const browserProcess = () => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
if (context && typeof context.browser === 'function') {
|
|
126
|
+
try {
|
|
127
|
+
const b = context.browser();
|
|
128
|
+
if (b && typeof b.process === 'function') return b.process();
|
|
129
|
+
} catch {}
|
|
120
130
|
}
|
|
121
131
|
return null;
|
|
122
132
|
};
|
|
@@ -149,12 +159,12 @@ const reapChromium = () => { for (const pid of myChromiumRoots) killTree(pid); }
|
|
|
149
159
|
if (ownerWatch) clearInterval(ownerWatch);
|
|
150
160
|
const timeoutMs = Number.isFinite(closeTimeoutMs) && closeTimeoutMs > 0 ? closeTimeoutMs : 2500;
|
|
151
161
|
if (context) await bounded('context.close', () => context.close(), timeoutMs);
|
|
152
|
-
const b = maybeBrowser();
|
|
153
|
-
if (b) await bounded('browser.close', () => b.close(), timeoutMs);
|
|
154
162
|
await terminateBrowserProcess();
|
|
155
|
-
// close()
|
|
156
|
-
//
|
|
157
|
-
|
|
163
|
+
// close() + root-SIGKILL above handle the graceful case; the helper tree
|
|
164
|
+
// (gpu/renderer/utilities) reparents and survives every one of those, so
|
|
165
|
+
// we always sweep by our unique profile dir as the load-bearing teardown.
|
|
166
|
+
reapChrome();
|
|
167
|
+
cleanupProfile();
|
|
158
168
|
if (connectAckFile) {
|
|
159
169
|
try { unlinkSync(connectAckFile); } catch {}
|
|
160
170
|
}
|
|
@@ -163,8 +173,8 @@ const reapChromium = () => { for (const pid of myChromiumRoots) killTree(pid); }
|
|
|
163
173
|
process.once('SIGTERM', () => { void shutdown(0); });
|
|
164
174
|
process.once('SIGINT', () => { void shutdown(0); });
|
|
165
175
|
// the launch-failure path at the bottom of this script exits without going
|
|
166
|
-
// through shutdown(); the exit hook (sync
|
|
167
|
-
process.on('exit', () => {
|
|
176
|
+
// through shutdown(); the exit hook (sync sweep) still reaps the tree.
|
|
177
|
+
process.on('exit', () => { reapChrome(); cleanupProfile(); });
|
|
168
178
|
// owner-liveness watchdog \u2014 the load-bearing fix for leaked Chrome hosts.
|
|
169
179
|
// we are spawned detached + unref'd so \`sootsim open\` returns immediately,
|
|
170
180
|
// which means nothing in the OS process tree ties Chrome's lifetime to the
|
|
@@ -218,31 +228,18 @@ const reapChromium = () => { for (const pid of myChromiumRoots) killTree(pid); }
|
|
|
218
228
|
'--disable-renderer-backgrounding',
|
|
219
229
|
];
|
|
220
230
|
if (cdpPort) opts.args.push('--remote-debugging-port=' + cdpPort);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
231
|
+
// ALWAYS persistent: every chrome process inherits --user-data-dir=<dir>
|
|
232
|
+
// in its cmdline, which is how reapChrome() finds the whole tree (root +
|
|
233
|
+
// helpers) on shutdown. without a unique dir there is no way to attribute
|
|
234
|
+
// an orphaned helper back to us, which is the leak we just fixed.
|
|
235
|
+
return await pw.chromium.launchPersistentContext(profileDir, opts);
|
|
225
236
|
};
|
|
226
237
|
let launchErr = null;
|
|
227
238
|
let launchedChannel = null;
|
|
228
239
|
for (const channel of channelsToTry) {
|
|
229
240
|
try {
|
|
230
|
-
|
|
231
|
-
// host spawned is ever reaped (playwright's Browser exposes no pid, so
|
|
232
|
-
// the diff is the portable way to find our roots \u2014 same approach as
|
|
233
|
-
// scripts/lib/reap-browser.ts).
|
|
234
|
-
const pidsBefore = new Set(chromiumPids());
|
|
235
|
-
const launched = await launchWith(channel);
|
|
236
|
-
for (const p of chromiumPids()) {
|
|
237
|
-
if (!pidsBefore.has(p)) myChromiumRoots.add(Number(p));
|
|
238
|
-
}
|
|
241
|
+
context = await launchWith(channel);
|
|
239
242
|
launchedChannel = channel || 'chromium';
|
|
240
|
-
if (launched.kind === 'persistent') {
|
|
241
|
-
context = launched.value;
|
|
242
|
-
} else {
|
|
243
|
-
browser = launched.value;
|
|
244
|
-
context = await browser.newContext();
|
|
245
|
-
}
|
|
246
243
|
launchErr = null;
|
|
247
244
|
break;
|
|
248
245
|
} catch (err) {
|
|
@@ -310,12 +307,17 @@ const reapChromium = () => { for (const pid of myChromiumRoots) killTree(pid); }
|
|
|
310
307
|
process.stderr.write('[goto] ' + String((err && err.message) || err) + '\\n');
|
|
311
308
|
}
|
|
312
309
|
keepAlive = setInterval(() => {}, 1 << 30);
|
|
313
|
-
|
|
310
|
+
// browser disconnect (e.g. user killed chrome from outside) \u2192 tear down.
|
|
311
|
+
// we are persistent-only now, so .browser() is the only handle to it.
|
|
312
|
+
try {
|
|
313
|
+
const b = context.browser && context.browser();
|
|
314
|
+
if (b && typeof b.on === 'function') b.on('disconnected', () => { void shutdown(0); });
|
|
315
|
+
} catch {}
|
|
314
316
|
context.on('close', () => { void shutdown(0); });
|
|
315
317
|
page.on('close', () => { void shutdown(0); });
|
|
316
318
|
})().catch((err) => {
|
|
317
319
|
process.stderr.write(String((err && err.stack) || err) + '\\n');
|
|
318
320
|
process.exit(1);
|
|
319
321
|
});
|
|
320
|
-
`;function
|
|
321
|
-
${i}`:""}`}}return{launched:!0,message:`playwright chrome launched \u2192 ${e.url}`,pid:l.pid,target:r.spec,attachUrl:e.url,connectAckFile:n,diagnosticLogPath:t}}catch(o){return{launched:!1,message:`playwright launch failed: ${o instanceof Error?o.message:String(o)}`}}finally{E(a)}}var k={id:"playwright",name:"playwright",description:"programmatic chromium via the playwright package \u2014 headless default",kind:"automation",availability
|
|
322
|
+
`;function S(){let e=[process.cwd()+"/"];try{process.argv[1]&&e.push(process.argv[1])}catch{}for(let r of e)try{let t=R(r);for(let n of["playwright","playwright-chromium","playwright-core"])try{return{spec:n,modulePath:t.resolve(n)}}catch{}}catch{}return null}function U(){let e=S();return e?{available:!0,reason:null,detail:`resolved via ${e.spec}`}:{available:!1,reason:"playwright not installed in the current workspace"}}function $(e){return e.profileId?f(w(e.profileId).id):e.ephemeralProfile?A(P(b(),"sootsim-playwright-profile-")):""}async function F(e){let r=S();if(!r)return{launched:!1,message:"playwright not installed \u2014 run `bun add -D playwright` first"};if(!e.url)return{launched:!1,message:"playwright driver requires a target url"};let t=P(b(),`sootsim-playwright-host-${Date.now().toString(36)}-${process.pid}.log`),n=`${t}.connected`,a=L(t,"a");try{let o=m(),l=C(process.execPath,["-e",N],{detached:!0,stdio:["ignore","ignore",a],env:{...process.env,SOOTSIM_PW_MODULE:r.modulePath,SOOTSIM_PW_URL:e.url,SOOTSIM_PW_HEADLESS:e.headless??!0?"1":"0",SOOTSIM_PW_USERDATADIR:$(e),SOOTSIM_PW_CDP_PORT:e.cdpPort?String(e.cdpPort):"",SOOTSIM_PW_CONNECTED_ACK_FILE:n,SOOTSIM_PW_CONNECT_TIMEOUT_MS:String(e.connectTimeoutMs??12e4),SOOTSIM_PW_OWNER_PID:o&&o>1?String(o):""}});l.unref();let c=await new Promise(i=>{let O=setTimeout(()=>i(null),4e3);l.once("exit",T=>{clearTimeout(O),i(T??0)})});if(c!==null&&c!==0){let i=W(t,"utf8").trim();return{launched:!1,message:`playwright host exited early (code ${c}) \u2014 host log ${t}${i?`:
|
|
323
|
+
${i}`:""}`}}return{launched:!0,message:`playwright chrome launched \u2192 ${e.url}`,pid:l.pid,target:r.spec,attachUrl:e.url,connectAckFile:n,diagnosticLogPath:t}}catch(o){return{launched:!1,message:`playwright launch failed: ${o instanceof Error?o.message:String(o)}`}}finally{E(a)}}var k={id:"playwright",name:"playwright",description:"programmatic chromium via the playwright package \u2014 headless default",kind:"automation",availability:U,launch:F};function q(){return process.platform!=="darwin"&&process.platform!=="linux"&&process.platform!=="win32"?{available:!1,reason:`unsupported platform: ${process.platform}`}:{available:!0,reason:null,detail:process.platform==="darwin"?"open(1)":process.platform==="win32"?"cmd /c start":"xdg-open(1)"}}async function H(e){if(e.headless)return{launched:!1,message:"system driver does not support --headless; use chromium or playwright"};if(!e.url)return{launched:!1,message:"system driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current browser profile"};try{let r=await h(e.url,{detached:e.detached??!0,newWindow:e.newWindow});return{launched:!0,message:`${r.via} launch \u2192 ${e.url}`,pid:r.pid,target:r.target,attachUrl:e.url}}catch(r){return{launched:!1,message:`system launch failed: ${r instanceof Error?r.message:String(r)}`}}}var D={id:"system",name:"system",description:"shared browser launcher \u2014 system default or chromium window",kind:"delegate",availability:q,launch:H};var s=[v,y,k,D];function ae(){return s}function le(e){return s.find(r=>r.id===e)??null}function ce(e,r){if(e)return s.find(n=>n.id===e)??null;for(let t of r){let n=s.find(a=>a.id===t);if(n&&n.availability().available)return n}return null}function ue(){return s.map(e=>{let r=e.availability();return{id:e.id,name:e.name,kind:e.kind,description:e.description,available:r.available,reason:r.reason,detail:r.detail??null}})}export{v as a,y as b,k as c,D as d,s as e,ae as f,le as g,ce as h,ue as i};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{A as m,n as P,p as a}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{A as m,n as P,p as a}from"./chunk-ATMMZFJE.js";import l from"fs";import c from"path";var s="default",S="profiles.json",i=1;function o(e){let r=e.trim();if(!r)throw new Error("profile id is required");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(r))throw new Error("profile ids must start with a letter or number and contain only letters, numbers, dot, dash, or underscore");if(r==="."||r==="..")throw new Error(`invalid profile id: ${r}`);return r}function d(){return c.join(a(),S)}function I(e){return`sootsim-profile-${o(e)}`}function h(e){return c.join(P(),"Partitions",I(e))}function A(e){return c.join(a(),"playwright",o(e))}function u(){try{let e=JSON.parse(l.readFileSync(d(),"utf8"));if(!e||e.version!==i)return{version:i,profiles:[]};let r=Array.isArray(e.profiles)?e.profiles.filter(t=>!!t&&typeof t.id=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string").map(t=>({id:o(t.id),createdAt:t.createdAt,updatedAt:t.updatedAt})):[];return{version:i,profiles:r}}catch{return{version:i,profiles:[]}}}function x(e){return[...e].sort((r,t)=>r.id===s?-1:t.id===s?1:r.id.localeCompare(t.id))}function p(e){if(e.profiles.some(t=>t.id===s))return{...e,profiles:x(e.profiles)};let r=new Date().toISOString();return{version:i,profiles:x([{id:s,createdAt:r,updatedAt:r},...e.profiles])}}function g(e){m();let r=p(e),t=`${d()}.tmp`;return l.writeFileSync(t,`${JSON.stringify(r,null,2)}
|
|
3
3
|
`,"utf8"),l.renameSync(t,d()),r}function y(){return g(u()).profiles}function E(e){let r=o(e);return y().find(t=>t.id===r)??null}function _(e=s){let r=o(e),t=E(r);return t||D(r)}function D(e){let r=o(e),t=p(u());if(t.profiles.some(w=>w.id===r))throw new Error(`profile already exists: ${r}`);let f=new Date().toISOString(),n={id:r,createdAt:f,updatedAt:f};return g({version:i,profiles:[...t.profiles,n]}),n}function F(e){let r=o(e);if(r===s)throw new Error("the default profile cannot be deleted; clear it instead");let t=p(u()),f=t.profiles.find(n=>n.id===r);if(!f)throw new Error(`profile not found: ${r}`);return g({version:i,profiles:t.profiles.filter(n=>n.id!==r)}),v(r),f}function v(e){let r=o(e);for(let t of[h(r),A(r)])try{l.rmSync(t,{recursive:!0,force:!0})}catch{}}export{A as a,y as b,_ as c,D as d,F as e,v as f};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var d=Object.defineProperty;var e=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var f=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0})};export{e as a,f as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as t}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as t}from"./chunk-76AZBX3S.js";import{a as p,b as m,c as a}from"./chunk-6RY6L5JR.js";import{a as r}from"./chunk-7QFEXS62.js";import{a as l}from"./chunk-NURFX6AZ.js";import{a as u,d}from"./chunk-LIFPDHVG.js";import{B as i}from"./chunk-ATMMZFJE.js";function c(){let o=i();return`sootsim CLI v${l()} \xB7 runtime ${o?`v${o}`:"not installed"}`}function S(){let o=m({bridgePort:7668,defaultShellUrl:r},t()),e=`
|
|
3
3
|
${d}
|
|
4
4
|
`;console.log(`${c()}
|
|
5
5
|
${e}${o}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as u}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as u}from"./chunk-QD3SYTZB.js";import{B as g,G as l,H as m,h as p,i as h,k as w}from"./chunk-ATMMZFJE.js";import{closeSync as k,existsSync as f,openSync as P,readSync as S,statSync as b}from"fs";import{homedir as T}from"os";import{resolve as D}from"path";import{WebSocket as $}from"ws";var L=6e4;async function E(){let e=g();if(e&&f(w(e)))return;console.log(" first run \u2014 installing sootsim engine runtime (~6 MB)...");let{runRuntime:t}=await import("./runtime-A4PZC73P.js");await t(["install"],{})}function W(e,t){return B(e)??t??u()}async function x(e=u(),t=L){if(await c(e,250)||await c(e,1500))return;let n=l();if(n&&m(n)){if(n.bootstrapping===!0&&(await v(t),await c(n.bridgePort,500)))return;throw new Error(`sootsim daemon lockfile is fresh (port ${n.bridgePort}) but the bridge is not reachable. run \`sootsim daemon restart\` or \`sootsim daemon uninstall\`.`)}if(h()){let r=p()?"dev workstations":"dev checkouts";throw new Error(`sootsim bridge daemon is not running on port ${e}.
|
|
3
3
|
${r} don't run a standalone daemon \u2014 the live \`bun dev\` stack hosts the
|
|
4
4
|
bridge in-process on :${e}. start the dev stack (\`bun dev\`) so the CLI can
|
|
5
5
|
reach it, or set SOOTSIM_FORCE_DAEMON_INSTALL=1 to run \`bun sootsim server\`
|
|
6
|
-
standalone here on purpose.`)}console.log(" registering sootsim bridge daemon...");let{daemonInstall:o}=await import("./daemon-
|
|
6
|
+
standalone here on purpose.`)}console.log(" registering sootsim bridge daemon...");let{daemonInstall:o}=await import("./daemon-4NBH5C6S.js");try{await o({port:e,force:!0})}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`${s}
|
|
7
7
|
if this keeps failing, run \`sootsim daemon uninstall\` and retry, or run \`sootsim server\` in a persistent shell as a workaround.`)}console.log(" waiting for runtime to come online...");let i=process.platform==="darwin"?O():null;try{await v(t);let r=Date.now()+5e3;for(;Date.now()<r;){if(await c(e,500))return;await new Promise(s=>setTimeout(s,200))}throw new Error(`daemon registered but the bridge never bound on port ${e} \u2014 see ${d()} (mac) or \`journalctl --user -u sootsim-server\` (linux).`)}finally{i?.stop()}}async function C(e=u()){await E(),await x(e)}function B(e){for(let t=0;t<e.length;t++){let n=e[t];if((n==="--port"||n==="-p")&&e[t+1]){let o=Number(e[t+1]);return Number.isFinite(o)?o:void 0}if(n.startsWith("--port=")){let o=Number(n.slice(7));return Number.isFinite(o)?o:void 0}}}function c(e,t){return new Promise(n=>{let o=new $(`ws://127.0.0.1:${e}`,{handshakeTimeout:t}),i=!1,r=s=>{if(!i){i=!0;try{o.close()}catch{}n(s)}};o.once("open",()=>r(!0)),o.once("error",()=>r(!1)),setTimeout(()=>r(!1),t)})}async function v(e){let t=Date.now()+e,n;for(;Date.now()<t;){let o=l();if(o&&m(o)){if(o.bootstrapping!==!0)return;o.bootstrapping!==n&&(n=o.bootstrapping)}await new Promise(i=>setTimeout(i,250))}throw new Error(`daemon did not finish bootstrapping within ${Math.round(e/1e3)}s \u2014 check ${d()} (mac) or \`journalctl --user -u sootsim-server\` (linux).`)}function d(){return D(T(),"Library/Logs/sootsim/server.err.log")}function O(){let e=d(),t=0;try{f(e)&&(t=b(e).size)}catch{}let n=!1,o=()=>{if(!n){try{if(f(e)){let i=b(e).size;if(i>t){let r=Buffer.alloc(i-t),s=P(e,"r");try{S(s,r,0,r.length,t)}finally{k(s)}t=i;for(let y of r.toString("utf8").split(/\r?\n/)){let a=y.trim();a&&(a.startsWith("sootsim:")||a.startsWith("sootsim "))&&console.log(` ${a}`)}}else i<t&&(t=i)}}catch{}setTimeout(o,250)}};return o(),{stop:()=>{n=!0}}}export{E as a,W as b,x as c,C as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as Be}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as Be}from"./chunk-YKRDJEXB.js";import{a as Le}from"./chunk-GL7XIITU.js";import{a as je}from"./chunk-N2RYSVRC.js";import{a as Se,b as Ee,c as ne,d as re,e as Ie,f as ie,h as oe,i as Pe,j as Me}from"./chunk-DDAGD5DR.js";import{g as Re,n as Ne,p as Ce,t as De}from"./chunk-Z76N3LVQ.js";import{e as Oe}from"./chunk-YDOTSYCN.js";import{m as ke}from"./chunk-H5PWNDJX.js";import{m as xe,n as Te,o as $e,p as Fe}from"./chunk-BH7P5BRG.js";import{c as ee,d as te,e as ve}from"./chunk-QD3SYTZB.js";import{a as Ae}from"./chunk-WEUFC7SG.js";import{a as _e}from"./chunk-S723QE3J.js";import{d as Q,e as be}from"./chunk-RAFS3IF4.js";import{a as ge,b as Z}from"./chunk-MFTSL5T7.js";import{g as ye}from"./chunk-NPS6GG4R.js";import*as _ from"fs";import{tmpdir as He}from"os";import*as b from"path";import*as v from"fs";import*as g from"path";import{spawnSync as nt}from"child_process";import*as A from"vm";var rt=3e5,it=`
|
|
3
3
|
let input = '';
|
|
4
4
|
process.stdin.on('data', (c) => { input += c });
|
|
5
5
|
process.stdin.on('end', async () => {
|
|
@@ -455,7 +455,7 @@ flow extension:
|
|
|
455
455
|
+ completed (${E.length} steps)`),u>0&&console.log(` screenshots: ${u} \u2192 ${a}`),I&&We(I),T&&console.log(` video: ${T}`),console.log()}catch(m){if(n&&!I)try{I=await d.stopProfile()}catch{}if($&&!T)try{T=await d.stopRecording(),C=d.getLastRecordingDurationMs()}catch(u){console.warn(` recording stop failed: ${u?.message||String(u)}`)}console.error(`
|
|
456
456
|
x failed: ${m.message}
|
|
457
457
|
`),I&&(console.log(" partial profile:"),We(I)),T&&console.log(` partial video: ${T}`);try{let u=d.lastFailedStep,y=u?`step-${String(u.index+1).padStart(2,"0")}-${u.kind}`:"unstaged",V=b.join(a,y);await d.captureFailureBundle(V,{error:m,stepIndex:u?.index,stepKind:u?.kind,stepTarget:u?.target}),console.log(` failure bundle: ${V}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(u){try{let y=b.join(a,"error.png");await d.captureFailureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${u instanceof Error?u.message:String(u)})`)}await ke(k,{errorsCommand:`sootsim get errors 5${d.simId?` --sim ${d.simId}`:""}`,warningsCommand:`sootsim get warnings 5${d.simId?` --sim ${d.simId}`:""}`,requestsCommand:`sootsim get requests 5${d.simId?` --sim ${d.simId}`:""}`}),L=1}finally{k.close()}if(L===0&&w)try{let m=await wt(X??[]),u=["--origin",R,"--events",m];ae&&u.push("--public-origin",ae),T&&u.push("--video",T),T&&C&&Number.isFinite(C)&&u.push("--video-duration-ms",String(Math.round(C))),d.simId&&u.push("--sim",d.simId),qe&&u.push("--open"),le&&u.push("--owner",le),ce&&u.push("--repo",ce),console.log(`
|
|
458
|
-
preparing preview upload\u2026`);let{runUpload:y}=await import("./upload-
|
|
458
|
+
preparing preview upload\u2026`);let{runUpload:y}=await import("./upload-H5BBABDO.js");await y(u,{})}catch(m){console.error(` preview upload failed: ${m?.message||m}`),L=1}return z?(d.simId&&Y.add(d.simId),await ht(S.wsPort,S.commandTimeoutMs,[...Y])):d.simId&&d.simId!==j&&be(d.simId),await Z(),L}async function ht(i,e,t){let n=[...new Set(t.filter(Boolean))];if(n.length===0)return;let r=te(i,{commandTimeoutMs:e});try{let o=await r.listSims(),s=n.filter(l=>o.some(f=>f.id===l&&f.readyState==="open"));if(s.length===0)return;let a=await De(r,i,e,s);await Ne(o,s),a.closed.length>0&&console.log(` closed flow sim(s): ${a.closed.join(", ")}`),a.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${a.remaining.join(", ")}`)}catch(o){console.warn(` warn: failed to close flow sim(s): ${o instanceof Error?o.message:String(o)}`)}finally{r.close()}}async function wt(i){let{gzipSync:e}=await import("zlib"),t=i.map(o=>JSON.stringify(o)).join(`
|
|
459
459
|
`)+(i.length?`
|
|
460
460
|
`:""),n=e(Buffer.from(t,"utf8")),r=b.join(He(),`sootsim-events-${Date.now()}.jsonl.gz`);return _.writeFileSync(r,n),console.log(` events: ${i.length} written to ${r} (${n.length} bytes gz)`),r}async function gt(i){let e=i[0],t=n=>i.find((r,o)=>i[o-1]===n);switch(e){case"start":{let{path:n,state:r}=Ie();console.log(" flow draft started"),console.log(` session: ${n}`),console.log(` steps: ${r.steps.length}`);return}case"keep":case"good":{let n=oe();if(n.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!n.kept){console.log(" no pending action to keep");return}console.log(` kept: ${n.candidate.summary}`),console.log(` steps: ${n.stepCount}`);return}case"end":{let n=t("--output")||(i[1]&&!i[1].startsWith("-")?i[1]:void 0),r=i.includes("--validate")||i.includes("--video"),o=i.includes("--video"),s=oe();s.active&&s.kept&&console.log(` auto-kept trailing action: ${s.candidate.summary}`);let a=Pe(n||(r?bt():void 0));if(a.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!a.valid){console.error(" flow draft is not valid:");for(let l of a.issues)console.error(` - ${l}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim flow start` to reset"),process.exit(1)}if(r){let l=vt(i,a.outputPath),f=await Ke(l);if(f!==0){console.error(`
|
|
461
461
|
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=f;return}ie(),console.log(` flow draft validated (${a.stepCount} step${a.stepCount===1?"":"s"})`),a.outputPath&&console.log(` saved: ${a.outputPath}`),o&&console.log(" video: recorded during validation run");return}if(ie(),console.log(` flow draft ended (${a.stepCount} step${a.stepCount===1?"":"s"})`),a.outputPath){console.log(` saved: ${a.outputPath}`),console.log(` next: sootsim flow ${a.outputPath} --record`);return}console.log(""),process.stdout.write(a.yaml);return}case"validate":{let n=i[1];(!n||n.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let r=re(n);if(r.length>0){console.error(` x ${n} failed validation:`);for(let o of r)console.error(` - ${o}`);process.exit(1)}console.log(` + ${n} looks valid`);return}}}function yt(i){return i[0]==="--sim"&&i.length>=2?[...i.slice(2),"--sim",i[1]]:i}async function Ht(i){let e=yt(i),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await gt(e),0;let n=await Ke(e);return n!==0&&(process.exitCode=n),n}function We(i){let e=i.avgMs>0?(1e3/i.avgMs).toFixed(1):"?",t=i.sampleCount>0?(i.jankFrames/i.sampleCount*100).toFixed(1):"0";console.log(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var t="./demo-app-registry.ts",o=null;async function n(){if(o)return o;try{let r=await import(t);o=Array.isArray(r.APPS)?r.APPS:[]}catch{o=[]}return o}function e(){return o??[]}export{n as a,e as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{c as i,e as d,h as c}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{c as i,e as d,h as c}from"./chunk-QD3SYTZB.js";function g(r){let e=r[0]?.toLowerCase()??"toggle";return e!=="on"&&e!=="off"&&e!=="toggle"&&(console.error(` unknown argument: "${e}" (expected on | off | toggle)`),process.exit(1)),e}async function u(r,e,t){let l=i(r,{port:e.port}),s=g(l.positional),a=d({...l,commandTimeoutMs:5e3});try{let n=!!(await c(a,"SootSim.bridges.settings.get"))?.[t.modeKey],o=s==="on"?!0:s==="off"?!1:!n;if(n===o)return console.log(` ${t.displayName}: already ${o?"on":"off"}`),{current:n,target:o,changed:!1};if(!await a.send({type:"evaluate",acquireLock:!0,code:`(async () => {
|
|
3
3
|
const modeKey = ${JSON.stringify(t.modeKey)}
|
|
4
4
|
const target = ${JSON.stringify(o)}
|
|
5
5
|
window.dispatchEvent(new CustomEvent('sootsim:shell-command', {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as R}from"./chunk-27MSLKR3.js";import{n as D}from"./chunk-XJ6US7DQ.js";import{a as T}from"./chunk-XC54E57T.js";function Y(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function I(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return Y(r)?r:null}catch{return null}}import{randomBytes as G,createHash as q}from"node:crypto";import m from"node:fs";import h from"node:path";var N=null;function _(){if(N)return N;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||D()}function y(){return _()}function U(){return h.join(_(),"attached-projects.json")}function $(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=m.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return $();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{m.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return $()}}function X(e){let t=U();m.mkdirSync(h.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=m.openSync(r,"w",384);try{m.writeFileSync(n,JSON.stringify(e,null,2)),m.fsyncSync(n)}finally{m.closeSync(n)}m.renameSync(r,t)}function w(e){let t=S();return e(t),X(t),t}function B(e){return q("sha256").update(h.resolve(e)).digest("hex").slice(0,16)}function K(){return`s_${G(10).toString("hex")}`}function ge(e){let t=h.resolve(e.cwd),r=B(t),n;return w(o=>{let s=o.attachedProjects.find(c=>c.id===r);if(s){let c={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=c,n=c;return}let a=Date.now(),d={id:r,name:e.name??h.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:a,updatedAt:a};o.attachedProjects.push(d),n=d}),n}function F(e){return S().attachedProjects.find(t=>t.id===e)??null}function he(){return S().attachedProjects}var Q=336*60*60*1e3;function ye(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],a=o-Q,d=s.filter(c=>c.ts>=a);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Se(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function we(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function M(e){let t;return w(r=>{if(e.id){let a=r.agentSessions.find(d=>d.id===e.id);if(a){let d={...a,...e,lastSeenAt:Date.now()},c=r.agentSessions.indexOf(a);r.agentSessions[c]=d,t=d;return}}let n=r.attachedProjects.find(a=>a.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??K(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function C(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function v(e,t){w(r=>{let n=r.agentSessions.find(s=>s.id===e);if(!n)return;let o=r.agentSessions.indexOf(n);r.agentSessions[o]={...n,...t,id:n.id,projectId:n.projectId,createdAt:n.createdAt,lastSeenAt:Date.now()}})}async function ve(){if(S().attachedProjects.length>0)return;let{loadOptionalDemoApps:t}=await import("./optional-demo-registry-6EBMAPK6.js"),r=await t();r.length!==0&&w(n=>{for(let o of r){if(!m.existsSync(o.dir))continue;let s=h.resolve(o.dir),a=B(s);if(n.attachedProjects.some(c=>c.id===a))continue;let d=Date.now();n.attachedProjects.push({id:a,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as V,spawnSync as z}from"node:child_process";import{randomUUID as Z}from"node:crypto";import i,{constants as f}from"node:fs";import u from"node:path";import ee from"node:readline";function j(e){return u.join(y(),"sessions",e)}function W(e){return u.join(j(e),"prompt.in")}function J(e){return u.join(j(e),"events.out")}function te(e){return u.join(y(),"transcripts",`${e}.log`)}function O(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(j(t)))}function re(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ne();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("sootsim CLI not found. set SOOTSIM_BIN to the path of the sootsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ne(){try{let e=se();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli` (watch:cli:binary builds dist-bin/ instead).")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function se(){try{let r=T.resolve("sootsim/package.json");return u.dirname(r)}catch{}let e=oe();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name==="sootsim")return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function oe(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function ie(e,t,r){let n=u.join(y(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,a=null;for(;a===null;)try{a=i.openSync(o,f.O_WRONLY|f.O_CREAT|f.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let c=Number(i.readFileSync(o,"utf8").trim());if(c&&!ce(c)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(c=>setTimeout(c,50))}try{return i.writeFileSync(a,String(process.pid)),await r()}finally{try{i.closeSync(a)}catch{}try{i.unlinkSync(o)}catch{}}}function ce(e){try{return process.kill(e,0),!0}catch{return!1}}function L(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=z("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Te(e){let t=F(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return ie(t.id,r,async()=>{let n=C(t.id).find(p=>p.provider===r&&p.status!=="ended"&&O(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`sootsim agent end <sessionId>\`.`);let o=r==="claude"?Z():void 0,s=M({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),a=W(s.id),d=J(s.id),c=te(s.id);L(a),L(d);let g=u.dirname(c);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:H}=re(),x=[...H,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",a,"--events-out",d,"--transcript",c];e.codexBin&&x.push("--codex-bin",e.codexBin),e.claudeBin&&x.push("--claude-bin",e.claudeBin),e.freshThread&&x.push("--fresh-thread"),o&&x.push("--claude-session-uuid",o);let P=V(A,x,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:y()}});P.unref();let E=e.readyTimeoutMs??6e3,b=await ae(d,p=>p.type==="ready"||p.type==="error",E);if(!b||b.type==="error"){if(P.pid)try{process.kill(P.pid,"SIGTERM")}catch{}try{i.rmSync(j(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=b&&b.type==="error"?b.message:`no ready event within ${E}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:P.pid,status:"idle"}),{session:k(s.id),wrapperPid:P.pid}})}async function De(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!O(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=W(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,f.O_WRONLY);try{let s=R(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as R}from"./chunk-OJIOSOSI.js";import{n as D}from"./chunk-ATMMZFJE.js";import{a as T}from"./chunk-T56IURYQ.js";function Y(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function I(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return Y(r)?r:null}catch{return null}}import{randomBytes as G,createHash as q}from"node:crypto";import m from"node:fs";import h from"node:path";var N=null;function _(){if(N)return N;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||D()}function y(){return _()}function U(){return h.join(_(),"attached-projects.json")}function $(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=m.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return $();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{m.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return $()}}function X(e){let t=U();m.mkdirSync(h.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=m.openSync(r,"w",384);try{m.writeFileSync(n,JSON.stringify(e,null,2)),m.fsyncSync(n)}finally{m.closeSync(n)}m.renameSync(r,t)}function w(e){let t=S();return e(t),X(t),t}function B(e){return q("sha256").update(h.resolve(e)).digest("hex").slice(0,16)}function K(){return`s_${G(10).toString("hex")}`}function ge(e){let t=h.resolve(e.cwd),r=B(t),n;return w(o=>{let s=o.attachedProjects.find(c=>c.id===r);if(s){let c={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=c,n=c;return}let a=Date.now(),d={id:r,name:e.name??h.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:a,updatedAt:a};o.attachedProjects.push(d),n=d}),n}function F(e){return S().attachedProjects.find(t=>t.id===e)??null}function he(){return S().attachedProjects}var Q=336*60*60*1e3;function ye(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],a=o-Q,d=s.filter(c=>c.ts>=a);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Se(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function we(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function M(e){let t;return w(r=>{if(e.id){let a=r.agentSessions.find(d=>d.id===e.id);if(a){let d={...a,...e,lastSeenAt:Date.now()},c=r.agentSessions.indexOf(a);r.agentSessions[c]=d,t=d;return}}let n=r.attachedProjects.find(a=>a.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??K(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function C(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function v(e,t){w(r=>{let n=r.agentSessions.find(s=>s.id===e);if(!n)return;let o=r.agentSessions.indexOf(n);r.agentSessions[o]={...n,...t,id:n.id,projectId:n.projectId,createdAt:n.createdAt,lastSeenAt:Date.now()}})}async function ve(){if(S().attachedProjects.length>0)return;let{loadOptionalDemoApps:t}=await import("./optional-demo-registry-PYWPXAHB.js"),r=await t();r.length!==0&&w(n=>{for(let o of r){if(!m.existsSync(o.dir))continue;let s=h.resolve(o.dir),a=B(s);if(n.attachedProjects.some(c=>c.id===a))continue;let d=Date.now();n.attachedProjects.push({id:a,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as V,spawnSync as z}from"node:child_process";import{randomUUID as Z}from"node:crypto";import i,{constants as f}from"node:fs";import u from"node:path";import ee from"node:readline";function j(e){return u.join(y(),"sessions",e)}function W(e){return u.join(j(e),"prompt.in")}function J(e){return u.join(j(e),"events.out")}function te(e){return u.join(y(),"transcripts",`${e}.log`)}function O(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(j(t)))}function re(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ne();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("sootsim CLI not found. set SOOTSIM_BIN to the path of the sootsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ne(){try{let e=se();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli` (watch:cli:binary builds dist-bin/ instead).")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function se(){try{let r=T.resolve("sootsim/package.json");return u.dirname(r)}catch{}let e=oe();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name==="sootsim")return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function oe(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function ie(e,t,r){let n=u.join(y(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,a=null;for(;a===null;)try{a=i.openSync(o,f.O_WRONLY|f.O_CREAT|f.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let c=Number(i.readFileSync(o,"utf8").trim());if(c&&!ce(c)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(c=>setTimeout(c,50))}try{return i.writeFileSync(a,String(process.pid)),await r()}finally{try{i.closeSync(a)}catch{}try{i.unlinkSync(o)}catch{}}}function ce(e){try{return process.kill(e,0),!0}catch{return!1}}function L(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=z("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Te(e){let t=F(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return ie(t.id,r,async()=>{let n=C(t.id).find(p=>p.provider===r&&p.status!=="ended"&&O(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`sootsim agent end <sessionId>\`.`);let o=r==="claude"?Z():void 0,s=M({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),a=W(s.id),d=J(s.id),c=te(s.id);L(a),L(d);let g=u.dirname(c);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:H}=re(),x=[...H,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",a,"--events-out",d,"--transcript",c];e.codexBin&&x.push("--codex-bin",e.codexBin),e.claudeBin&&x.push("--claude-bin",e.claudeBin),e.freshThread&&x.push("--fresh-thread"),o&&x.push("--claude-session-uuid",o);let P=V(A,x,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:y()}});P.unref();let E=e.readyTimeoutMs??6e3,b=await ae(d,p=>p.type==="ready"||p.type==="error",E);if(!b||b.type==="error"){if(P.pid)try{process.kill(P.pid,"SIGTERM")}catch{}try{i.rmSync(j(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=b&&b.type==="error"?b.message:`no ready event within ${E}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:P.pid,status:"idle"}),{session:k(s.id),wrapperPid:P.pid}})}async function De(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!O(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=W(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,f.O_WRONLY);try{let s=R(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
|
|
3
3
|
`)}finally{i.closeSync(o)}v(e,{lastPrompt:t.displayText??t.text,status:"working"})}async function Re(e){let t=k(e);if(!t)throw new l("NO_SESSION",`no session with id=${e}`);if(O(t.wrapperPid,e))try{process.kill(t.wrapperPid,"SIGTERM")}catch{}let r=j(e),n=y();if(r.startsWith(n))try{i.rmSync(r,{recursive:!0,force:!0})}catch{}v(e,{status:"ended",wrapperPid:void 0})}function Ne(e,t){let r=J(e);if(!i.existsSync(r))throw new l("NO_FIFO",`events FIFO missing: ${r}`);let n=i.openSync(r,f.O_RDWR),o=i.createReadStream("",{fd:n,autoClose:!0}),s=ee.createInterface({input:o,crlfDelay:1/0});s.on("line",d=>{let c=I(d);c&&t(c)});let a=!1;return()=>{if(!a){a=!0;try{s.close()}catch{}try{o.destroy()}catch{}}}}async function ae(e,t,r){let n=i.openSync(e,f.O_RDWR|f.O_NONBLOCK),o=Buffer.alloc(8192),s="",a=Date.now()+r;try{for(;Date.now()<a;){let d=0;try{d=i.readSync(n,o,0,o.length,null)}catch(c){if(c.code!=="EAGAIN")throw c;d=0}if(d>0){s+=o.subarray(0,d).toString("utf8");let c;for(;(c=s.indexOf(`
|
|
4
4
|
`))>=0;){let g=s.slice(0,c);s=s.slice(c+1);let A=I(g);if(A&&t(A))return A}}else await new Promise(c=>setTimeout(c,30))}return null}finally{i.closeSync(n)}}export{I as a,y as b,ge as c,F as d,he as e,ye as f,Se as g,we as h,k as i,C as j,v as k,ve as l,j as m,W as n,J as o,te as p,O as q,re as r,l as s,Te as t,De as u,Re as v,Ne as w};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as C,b as k}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as C,b as k}from"./chunk-WEUFC7SG.js";var x="sootsimConfig";function m(e){return!!e&&Object.keys(e).length>0}function D(e){return e?m(e.modules)||m(e.turboModules)||m(e.nativeModules)||m(e.env)||m(e.network?.remap)||m(e.settings)||m(e.initialState):!1}function M(e,o){let t=new URL(e);return D(o)?t.searchParams.set(x,JSON.stringify(o)):t.searchParams.delete(x),t.toString()}import{exec as N}from"child_process";import L from"http";import O from"net";import{promisify as $}from"util";var te="/index.bundle?platform=ios&dev=true&hot=true&minify=false";function T(e){return/^https?:\/\//i.test(e)}function E(e){return e.endsWith(".bundle")}function A(e){process.env.SOOTSIM_PREVIEW_PROD_BUNDLE&&(e.searchParams.set("dev","false"),e.searchParams.set("minify","true"),e.searchParams.has("hot")&&e.searchParams.set("hot","false"))}function U(e){try{let o=T(e),t=new URL(e,"http://soot.local");return t.pathname=t.pathname.replace(/\.\.bundle$/,".bundle"),E(t.pathname)?(t.searchParams.delete("transform.bytecode"),A(t),o?t.toString():`${t.pathname}${t.search}${t.hash}`):e}catch{return e}}var v=$(N);C();var I=250,B=1500,H=120;function j(e,o=H){return new Promise(t=>{let r=new O.Socket,s=!1,i=a=>{s||(s=!0,r.destroy(),t(a))};r.setTimeout(o),r.once("connect",()=>i(!0)),r.once("timeout",()=>i(!1)),r.once("error",()=>i(!1)),r.connect(e,"localhost")})}function h(e,o,t="GET",r=I,s={}){return new Promise(i=>{let a=L.request({hostname:"localhost",port:e,path:o,method:t,timeout:r,headers:s},n=>{let u="";n.on("data",l=>u+=l.toString());let c=(()=>{let l=n.headers["content-type"];if(typeof l=="string")return l;if(Array.isArray(l))return l[0]})();n.on("end",()=>i({statusCode:n.statusCode||0,body:u,contentType:c}))});a.on("error",()=>i(null)),a.setTimeout(r,()=>{a.destroy(),i(null)}),a.end()})}var W=[8081,8082,8083,8084,8085,8086,3e3,3001,19e3].map(e=>({port:e,pid:0}));function P(e,o){return!(e<=0||e>=2e4||o.has(e)||e>=5170&&e<=5200)}async function F(e=[]){let o=new Set(e);try{let{stdout:t}=await v("lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'",{encoding:"utf8",timeout:2e3});if(t.trim()){let r=new Map;for(let s of t.trim().split(`
|
|
3
3
|
`)){let i=s.trim().split(/\s+/);if(i.length<9)continue;let a=Number(i[1]),u=i[8].match(/:(\d+)$/);if(!u)continue;let c=Number(u[1]);P(c,o)&&(r.has(c)||r.set(c,a))}if(r.size>0)return[...r.entries()].map(([s,i])=>({port:s,pid:i}))}}catch{}try{let{stdout:t}=await v(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,{encoding:"utf8",timeout:2e3});if(t.trim()){let r=new Map;for(let s of t.trim().split(`
|
|
4
4
|
`)){let i=s.match(/:(\d+)\s/),a=s.match(/pid=(\d+)/);if(!i)continue;let n=Number(i[1]),u=a?Number(a[1]):0;P(n,o)&&(r.has(n)||r.set(n,u))}if(r.size>0)return[...r.entries()].map(([s,i])=>({port:s,pid:i}))}}catch{}return W.filter(t=>P(t.port,o))}var y=new Map;async function G(e){if(e<=0)return null;let o=y.get(e);if(o)return o;try{let{stdout:t}=await v(`lsof -p ${e} -a -d cwd -Fn 2>/dev/null`,{encoding:"utf8",timeout:1500});for(let r of t.split(`
|
|
5
5
|
`))if(r.startsWith("n")&&r.length>1){let s=r.slice(1).trim();if(s)return y.set(e,s),s}}catch{}return null}function z(e,o){return{port:e,framework:o,bundleUrl:g(e,`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()}}function g(e,o){let t=k().find(s=>s.preferredPort===e),r=t?.runtimeConfig?M(o,t.runtimeConfig):o;return U(r)}function J(e){return e.includes("/node_modules/one/metro-entry.bundle")}function K(e){try{let o=JSON.parse(e);return o&&typeof o=="object"?o:null}catch{return null}}function w(e,o,t){if(!o)return e;try{let r=JSON.parse(o.body),s=r?.extra?.expoClient||r?.extra||{};s.name&&(e.projectName=s.name),s.ios?.bundleIdentifier&&(e.bundleId=s.ios.bundleIdentifier),e.framework==="metro"&&s.sdkVersion&&(e.framework="expo");let i=r?.launchAsset?.url;i&&!e.patched&&!J(e.bundleUrl)&&(e.bundleUrl=g(e.port,i));let a=s.iconUrl||s.ios?.iconUrl||s.icon||s.ios?.icon;if(a)if(e.iconPath=a,t)if(a.startsWith("http"))e.iconUrl=t(a);else{let n=a.replace(/^\.\//,"");e.iconUrl=t(`http://localhost:${e.port}/assets/${n}`)}else e.iconUrl=a.startsWith("http")?a:`http://localhost:${e.port}/assets/${a.replace(/^\.\//,"")}`}catch{}return e}var d=new Set,p=new Set,S=new Set;async function V(e,o){if(!await j(e))return null;let t="/node_modules/one/metro-entry.bundle?platform=ios&dev=true",[r,s,i,a]=await Promise.all([d.has(e)?Promise.resolve(null):h(e,"/__soot/"),h(e,"/status"),S.has(e)?Promise.resolve(null):h(e,"/","GET",B,{"expo-platform":"ios"}),p.has(e)?Promise.resolve(null):h(e,"/_expo/status")]);a&&a.statusCode===200?p.delete(e):p.has(e)||p.add(e);let n=i?K(i.body):null,u=typeof n?.launchAsset?.url=="string"?n.launchAsset.url:null,c=n?.extra?.expoClient||n?.extra||{};if(n&&(u||typeof c.name=="string")){d.add(e);let R=u||`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`,_=R.includes("/one/metro-entry.bundle")?"one":"expo";return w({port:e,framework:_,bundleUrl:g(e,R),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},i,o)}if(s&&s.body.includes("packager-status:running"))return d.add(e),w(z(e,a&&a.statusCode===200?"expo":"metro"),i,o);if(r&&r.statusCode===200&&r.body.includes("sootsim-patched"))return d.delete(e),w({port:e,framework:"one",bundleUrl:g(e,`http://localhost:${e}/__soot/bundle.js`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now(),patched:!0},i,o);if(s&&s.statusCode===200||a&&a.statusCode===200||i&&i.statusCode===200&&n!=null)return null;let f=await h(e,t,"HEAD");return f&&f.statusCode>0&&f.statusCode<400&&/application\/javascript/i.test(f.contentType||"")?(d.add(e),S.add(e),w({port:e,framework:"one",bundleUrl:g(e,`http://localhost:${e}${t}&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},i,o)):(d.add(e),null)}function q(e){let o=e.projectName?.trim().toLowerCase();return!!(o==="soot"||o==="sootsim"||e.bundleId?.trim().toLowerCase()?.startsWith("dev.soot"))}var b=new Map,Q=3e4,Y=1500;function X(e){return!e||e.framework==="metro"||e.framework==="unknown"}function Z(e){return e?g(e.port,e.bundleUrl)===e.bundleUrl:!0}function ee(e,o,t=Date.now()){if(o===0||e.pid!==o||!Z(e.result))return!1;let r=t-e.cachedAt;return!(e.result===null&&r>=Q||X(e.result)&&r>=Y)}async function de(e={}){let o=await F(e.excludePorts),t=new Set(o.map(n=>n.port));for(let n of[...b.keys()])t.has(n)||b.delete(n);for(let n of[...d])t.has(n)||d.delete(n);for(let n of[...p])t.has(n)||p.delete(n);for(let n of[...S])t.has(n)||S.delete(n);let r=[],s=[];for(let{port:n,pid:u}of o){let c=b.get(n);if(c&&ee(c,u)){c.result&&r.push(c.result);continue}c&&c.pid!==u&&(d.delete(n),p.delete(n),S.delete(n)),s.push({port:n,pid:u})}s.length>0&&(await Promise.all(s.map(u=>V(u.port,e.buildIconProxyUrl)))).forEach((u,c)=>{let{port:l,pid:f}=s[c];f!==0&&b.set(l,{pid:f,result:u,cachedAt:Date.now()}),u&&r.push(u)});let i=new Map;for(let{port:n,pid:u}of o)u>0&&i.set(n,u);await Promise.all(r.map(async n=>{let u=i.get(n.port);if(!u)return;n.pid=u;let c=await G(u);c&&(n.cwd=c)}));let a=new Set(i.values());for(let n of[...y.keys()])a.has(n)||y.delete(n);return r.filter(n=>!q(n))}export{M as a,te as b,U as c,V as d,de as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{h as u}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{h as u}from"./chunk-NPS6GG4R.js";var S=52,l=18,h=42,x=96,g=54,E=1.5,$="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",w=1;function y(e){let t=u(e),r=t.scale,o=!t.dynamicIsland&&t.homeIndicatorHeight===0&&t.cornerRadius===0,n=t.width,i=t.height,a=o?t.width+l*2:t.width+28,d=o?t.height+h+x:t.height+28,c=9.5,b=w,p=a+c*2,m=d+w*2,f=c+(o?l:14),B=o?h:14,H=o?S:t.cornerRadius+14,v=[{side:"right",top:t.hardwareButtons.lock.top,height:t.hardwareButtons.lock.height,width:t.hardwareButtons.width},{side:"left",top:t.hardwareButtons.ringToggle.top,height:t.hardwareButtons.ringToggle.height,width:t.hardwareButtons.width},{side:"left",top:t.hardwareButtons.volumeUp.top,height:t.hardwareButtons.volumeUp.height,width:t.hardwareButtons.width},{side:"left",top:t.hardwareButtons.volumeDown.top,height:t.hardwareButtons.volumeDown.height,width:t.hardwareButtons.width}];return{model:e,renderScale:r,outerWidth:Math.round(p*r),outerHeight:Math.round(m*r),logicalOuterWidth:p,logicalOuterHeight:m,logicalFrameWidth:a,logicalFrameHeight:d,logicalFrameLeft:c,logicalFrameTop:b,logicalScreenWidth:n,logicalScreenHeight:i,logicalScreenLeft:f,logicalScreenTop:B,logicalScreenRadius:o?0:t.cornerRadius,logicalFrameRadius:H,frameBackground:o?"linear-gradient(180deg, #1b1c20 0%, #0f1012 42%, #050608 100%)":"#000000",frameOutline:o?"0 0 0 1px #1f2125":"0 0 0 1px #333",metallicRingShadow:o?null:$,buttons:v,legacyHomeButton:o?{top:h+t.height+(x-g)/2,left:t.width/2-g/2+l,size:g,ring:E}:null,showHomeIndicator:t.homeIndicatorHeight>0,logicalHomeIndicatorStripHeight:t.homeIndicatorHeight}}function L(e){let t=e.side==="right",r=t?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
|
|
3
3
|
<div
|
|
4
4
|
aria-hidden="true"
|
|
5
5
|
style="
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as B,b as V,c as me,d as ue}from"./chunk-ZBGRSZSL.js";import{m as D}from"./chunk-YQI4W45L.js";import{m as ce,o as de}from"./chunk-FLTCCI7Y.js";import{a as he,b as we}from"./chunk-5ODCFRMJ.js";import{a as fe,b as G,c as ge}from"./chunk-BIM3MQKR.js";import{b as le,c as I,d as v,e as P}from"./chunk-DR4YEAAG.js";import{g as Q}from"./chunk-MUTEYS5D.js";import{a as M,b as J}from"./chunk-VGAM6F6G.js";import{c as pe}from"./chunk-HS6OQVDE.js";import{d as q}from"./chunk-FQMEXGSM.js";import{d as C,e as w,f as T}from"./chunk-HWRWRQQM.js";import{a as ae}from"./chunk-VWH4Z4IA.js";import{G as se,H as ie}from"./chunk-XJ6US7DQ.js";import Z from"node:fs";import He from"node:os";import x from"node:path";function Oe(e){return e.replace(/^\[|\]$/g,"").toLowerCase()}function L(e){let o=Oe(e);return o==="localhost"||o.endsWith(".localhost")||o==="0.0.0.0"||o==="::1"||/^127(?:\.\d{1,3}){3}$/.test(o)}function be(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function De(e,o){return e?.includes("/one/metro-entry.bundle")?"one":typeof o=="string"&&o?"expo":"unknown"}function Se(e,o,t){return`${e}//${o}:${t}`}function Be(e){if(typeof window>"u")return!1;try{let o=new URL(e);return L(o.hostname)&&L(window.location.hostname)&&o.origin!==window.location.origin}catch{return!1}}async function ye(e,o){let t={...o,cache:o?.cache??"no-store"};return Be(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,t):fetch(e,t)}function Le(e){return e==="https:"?443:80}function Ae(e){let o=e.pathname||"/";return(o==="/"||o==="")&&!e.search&&!e.hash}async function Ne(e){try{let o=await fetch("/__server-scan",{cache:"no-store"});if(!o.ok||!(o.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let t=await o.json();if(!Array.isArray(t))return null;let n=t.find(r=>!!r&&typeof r=="object"&&r.port===e&&typeof r.bundleUrl=="string");return n?{bundleUrl:n.bundleUrl,port:e,framework:typeof n.framework=="string"?n.framework:"unknown",projectName:typeof n.projectName=="string"?n.projectName:void 0}:null}catch{return null}}async function $e(e,o){let t=e.replace(/\/+$/,"");try{if(L(new URL(t).hostname)){let n=await Ne(o);if(n)return n}}catch{}try{let n=await ye(`${t}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),s=r?.extra?.expoClient||r?.extra||{},i=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(i||s.name)return{bundleUrl:me(i||`${t}${V}`),port:o,framework:De(i,s.sdkVersion),projectName:s.name}}}catch{}try{let n=await ye(`${t}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${t}${V}`,port:o,framework:"metro"}}catch{}return null}async function ve(e){return $e(Se("http:","localhost",e),e)}async function Ie(e){let o=e.trim();if(/^\d+$/.test(o)){let a=parseInt(o,10),l=await ve(a);if(l)return l;let c=3;for(let d=1;d<=c;d++){let m=await ve(a+d);if(m)return m}throw be(`localhost:${a} (also scanned +1..+${c})`)}let t=o.startsWith("http")?o:`http://${o}`,n;try{n=new URL(t)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",s=n.port?parseInt(n.port,10):Le(r),i=Se(r,n.hostname,s);if(Ae(n)){let a=await $e(i,s);if(a)return a;throw be(i)}return{bundleUrl:n.toString(),port:s,framework:"unknown"}}function xt(){console.error(" no sootsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" sootsim install-desktop"),console.error(""),console.error(" or wire sootsim into your own project so your dev server hosts the bridge:"),console.error(" sootsim setup-repo"),console.error("")}function Pe(e){let o=M();if(console.log(` note: no sootsim bridge detected on port ${e}`),o){console.log(" launch the installed companion with:"),console.log(" sootsim electron");return}console.log(""),console.log(" to get a bridge running, either:"),console.log(" sootsim install-desktop # download the electron app"),console.log(" sootsim setup-repo # wire sootsim into your own project")}function Fe(e){console.error(""),console.error(` no sim is connected to the sootsim bridge on port ${e}.`),console.error(""),console.error(" start your app dev server, then open it in sootsim:"),console.error(" npx expo start --localhost --port 8081"),console.error(" sootsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" sootsim describe")}async function kt(e,o,t){let n=[];try{n=await e.listSims()}catch{}if(console.error(""),n.length===0){Fe(o);return}console.error(` no sim with id "${t}" is connected to the bridge on port ${o}.`),console.error(""),console.error(" connected sims:");for(let r of n){let s=[r.isPrimary?"primary":null,r.readyState,r.userVisible===!1?"hidden":r.userVisible===!0?"visible":null,r.userFocused?"focused":null].filter(Boolean).join(", ");console.error(` ${r.id} (${s})`)}console.error(""),console.error(" pass a valid --sim id, or run `sootsim list` to see all sessions.")}var je=12e4,xe=500,Ke=5e3,We={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function S(e){return new Promise(o=>setTimeout(o,e))}function ke(e){let o=process.env[e]?.trim();if(!o)return null;let t=Number(o);return Number.isInteger(t)&&t>0?t:null}function ze(){let e=ke("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??ke("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??je;return{timeoutMs:e,hostTimeoutMs:e+Ke,intervalMs:xe,attempts:Math.max(1,Math.ceil(e/xe))}}function qe(e){return e==="chromium"||e==="electron"||e==="playwright"||e==="system"}function F(e){return e.trim()}function Y(e){try{let o=new URL(e),t=o.pathname.replace(/\/+$/,"")||"/";return o.searchParams.has("open")||o.searchParams.has("port")||o.searchParams.has("bundle")||o.searchParams.has("demo")||o.pathname.includes("/sootsim/index.html")||t==="/sootsim"||o.pathname==="/__soot"||o.pathname==="/__soot/"||t==="/rn"||/^\/rn\/[^/]+$/i.test(t)||/^\/app\/[^/]+$/i.test(t)||t==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(t)||/^\/__soot\/app\/[^/]+$/i.test(t)}catch{return!1}}function Ve(e){try{let o=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(o)||/^\/build\/.+/.test(o)}catch{return!1}}async function Vt(e){let o=F(e);return(await Re(o)).bundleUrl}function Ge(e){try{let o=new URL(e.startsWith("http")?e:`http://${e}`),t=o.pathname||"/";if(t!=="/"&&t!==""||o.search||o.hash||!/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(o.hostname))return null;let n=o.port?Number(o.port):o.protocol==="https:"?443:80;return Number.isFinite(n)&&n>0?n:null}catch{return null}}async function Re(e){let o=F(e),t=/^\d+$/.test(o)?Number(o):Ge(o);if(t&&t>0){let n=await ue(t);if(n)return{bundleUrl:n.bundleUrl,port:n.port,framework:n.framework,projectName:n.projectName}}return Ie(o)}function ee(e){let o=e.replace(/\/+$/,"")||"/";return o==="/__soot"||o.startsWith("/__soot/")?"/__soot":""}function Je(e,o){let t=F(e),n=new URL(o),r=ee(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(t)?n.pathname=`${r}/rn/${t}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",t)),n.toString()}function Qe(e){let o=F(e);return/^\d+$/.test(o)||/^https?:\/\//i.test(o)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(o)}async function Xe(e,o){let t=await Re(e),n=new URL(o),r=ee(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.set("bundle",t.bundleUrl),n.toString()}function Ye(e){return e.startsWith("~/")?x.join(He.homedir(),e.slice(2)):x.isAbsolute(e)?e:x.resolve(process.cwd(),e)}function Ze(e){let o={},t={};for(let r=0;r<e.length;r++){if(e[r]==="--replace"){let s=e[r+1];s||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let i=s.indexOf("=");(i<=0||i===s.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let a=s.slice(0,i).trim(),l=Ye(s.slice(i+1).trim());Z.existsSync(l)||(console.error(` sootsim open: replacement file not found: ${l}`),process.exit(1)),o[a]={file:l},r++;continue}if(e[r]==="--remap"){let s=e[r+1],i=s?s.indexOf("="):-1;(!s||i<=0||i===s.length-1)&&(console.error(" sootsim open: --remap expects <host:port>=<host:port>"),process.exit(1)),t[s.slice(0,i).trim()]=s.slice(i+1).trim(),r++;continue}}let n={};return Object.keys(o).length>0&&(n.modules=o),Object.keys(t).length>0&&(n.network={remap:t}),n.modules||n.network?n:void 0}function _e(){let e=se();return ie(e)&&e.runtimePort>0?`http://localhost:${e.runtimePort}/`:ae}async function et(e){try{let o=new URL(e),t=o.searchParams.get("bundle")||"";if(!t)return e;let n=process.env.SOOT_REPO_DIR||await G(t)||void 0,r=fe({bundleUrl:t,repoDir:n});if(r.length===0)return e;let s=await tt(r);return s.length===0?e:(o.searchParams.set("appFonts",ge(s)),o.toString())}catch{return e}}async function tt(e){let o=await Promise.all(e.map(async n=>{let r=new AbortController,s=setTimeout(()=>r.abort(),1500);try{let i=await fetch(n.url,{method:"HEAD",signal:r.signal});return i.status>=200&&i.status<400?n:null}catch{return null}finally{clearTimeout(s)}})),t=[];for(let n of o)n!==null&&t.push(n);return t}async function ot(e,o){if(!e)return new URL(o).toString();if(Y(e))return new URL(e).toString();let t=We[e.toLowerCase()];if(t){let n=new URL(o),r=ee(n.pathname);return n.pathname=`${r}${t}`,n.toString()}return Qe(e)?Xe(e,o):Je(e,o)}async function nt(e){try{let o=new URL(e),t=o.searchParams.get("bundle")||"";if(!t)return e;let n=process.env.SOOT_REPO_DIR||await G(t)||void 0,r=he({bundleUrl:t,repoDir:n});return!r||r.imageUrl&&!await rt(r.imageUrl)?e:(o.searchParams.set("appSplash",we(r)),o.toString())}catch{return e}}async function rt(e){let o=new AbortController,t=setTimeout(()=>o.abort(),1500);try{let n=await fetch(e,{method:"HEAD",signal:o.signal});return n.status>=200&&n.status<400}catch{return!1}finally{clearTimeout(t)}}async function N(e,o=_e()){let t=await ot(e,o);return nt(await et(t))}function Ce(e,o){let t=e?.url||e?.origin||o;try{let n=new URL(t);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.searchParams.delete("appFonts"),n.searchParams.delete("appSplash"),n.toString()}catch{return o}}async function st(e,o,t){let n=new URL(await N(e,o));return n.searchParams.set("inspectOpen",t),n.toString()}async function it(e,o,t,n={}){let r=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<r;a++){let l=v(e,{commandTimeoutMs:o,simId:t,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>i)return{bridge:l,count:c}}catch{}l.close(),await S(s)}return null}function at(e){if(!e)return null;try{let o=new URL(e);if(o.searchParams.has("bundle")){let t=o.searchParams.get("bundle")||"";try{let n=new URL(t),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return o.searchParams.has("port")?`connect :${o.searchParams.get("port")||""}`:o.searchParams.has("open")?`connect ${o.searchParams.get("open")||""}`:o.searchParams.has("demo")?`demo ${o.searchParams.get("demo")||"default"}`:o.pathname.includes("/sootsim/index.html")||o.pathname==="/sootsim/"||o.pathname==="/sootsim"?"embedded sootsim":null}catch{return null}}function lt(e){let o=e.indexOf(":");if(o<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let t=e.slice(0,o),n=e.slice(o+1),r=n.length>12?`${n.slice(0,8)}\u2026`:n;return t==="CLAUDE_CODE_SESSION_ID"||t==="CODEX_THREAD_ID"?`agent ${r}`:`${t} ${r}`}function ct(e,o){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as B,b as V,c as me,d as ue}from"./chunk-YDOTSYCN.js";import{m as D}from"./chunk-H5PWNDJX.js";import{m as ce,o as de}from"./chunk-BH7P5BRG.js";import{a as he,b as we}from"./chunk-ERENNF6M.js";import{a as fe,b as G,c as ge}from"./chunk-I2BWZNCX.js";import{b as le,c as I,d as v,e as P}from"./chunk-QD3SYTZB.js";import{g as Q}from"./chunk-SLH7AMG2.js";import{a as M,b as J}from"./chunk-S723QE3J.js";import{c as pe}from"./chunk-SNIJMEQV.js";import{d as q}from"./chunk-3PVLSJHL.js";import{d as C,e as w,f as T}from"./chunk-RAFS3IF4.js";import{a as ae}from"./chunk-7QFEXS62.js";import{G as se,H as ie}from"./chunk-ATMMZFJE.js";import Z from"node:fs";import He from"node:os";import x from"node:path";function Oe(e){return e.replace(/^\[|\]$/g,"").toLowerCase()}function L(e){let o=Oe(e);return o==="localhost"||o.endsWith(".localhost")||o==="0.0.0.0"||o==="::1"||/^127(?:\.\d{1,3}){3}$/.test(o)}function be(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function De(e,o){return e?.includes("/one/metro-entry.bundle")?"one":typeof o=="string"&&o?"expo":"unknown"}function Se(e,o,t){return`${e}//${o}:${t}`}function Be(e){if(typeof window>"u")return!1;try{let o=new URL(e);return L(o.hostname)&&L(window.location.hostname)&&o.origin!==window.location.origin}catch{return!1}}async function ye(e,o){let t={...o,cache:o?.cache??"no-store"};return Be(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,t):fetch(e,t)}function Le(e){return e==="https:"?443:80}function Ae(e){let o=e.pathname||"/";return(o==="/"||o==="")&&!e.search&&!e.hash}async function Ne(e){try{let o=await fetch("/__server-scan",{cache:"no-store"});if(!o.ok||!(o.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let t=await o.json();if(!Array.isArray(t))return null;let n=t.find(r=>!!r&&typeof r=="object"&&r.port===e&&typeof r.bundleUrl=="string");return n?{bundleUrl:n.bundleUrl,port:e,framework:typeof n.framework=="string"?n.framework:"unknown",projectName:typeof n.projectName=="string"?n.projectName:void 0}:null}catch{return null}}async function $e(e,o){let t=e.replace(/\/+$/,"");try{if(L(new URL(t).hostname)){let n=await Ne(o);if(n)return n}}catch{}try{let n=await ye(`${t}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),s=r?.extra?.expoClient||r?.extra||{},i=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(i||s.name)return{bundleUrl:me(i||`${t}${V}`),port:o,framework:De(i,s.sdkVersion),projectName:s.name}}}catch{}try{let n=await ye(`${t}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${t}${V}`,port:o,framework:"metro"}}catch{}return null}async function ve(e){return $e(Se("http:","localhost",e),e)}async function Ie(e){let o=e.trim();if(/^\d+$/.test(o)){let a=parseInt(o,10),l=await ve(a);if(l)return l;let c=3;for(let d=1;d<=c;d++){let m=await ve(a+d);if(m)return m}throw be(`localhost:${a} (also scanned +1..+${c})`)}let t=o.startsWith("http")?o:`http://${o}`,n;try{n=new URL(t)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",s=n.port?parseInt(n.port,10):Le(r),i=Se(r,n.hostname,s);if(Ae(n)){let a=await $e(i,s);if(a)return a;throw be(i)}return{bundleUrl:n.toString(),port:s,framework:"unknown"}}function xt(){console.error(" no sootsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" sootsim install-desktop"),console.error(""),console.error(" or wire sootsim into your own project so your dev server hosts the bridge:"),console.error(" sootsim setup-repo"),console.error("")}function Pe(e){let o=M();if(console.log(` note: no sootsim bridge detected on port ${e}`),o){console.log(" launch the installed companion with:"),console.log(" sootsim electron");return}console.log(""),console.log(" to get a bridge running, either:"),console.log(" sootsim install-desktop # download the electron app"),console.log(" sootsim setup-repo # wire sootsim into your own project")}function Fe(e){console.error(""),console.error(` no sim is connected to the sootsim bridge on port ${e}.`),console.error(""),console.error(" start your app dev server, then open it in sootsim:"),console.error(" npx expo start --localhost --port 8081"),console.error(" sootsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" sootsim describe")}async function kt(e,o,t){let n=[];try{n=await e.listSims()}catch{}if(console.error(""),n.length===0){Fe(o);return}console.error(` no sim with id "${t}" is connected to the bridge on port ${o}.`),console.error(""),console.error(" connected sims:");for(let r of n){let s=[r.isPrimary?"primary":null,r.readyState,r.userVisible===!1?"hidden":r.userVisible===!0?"visible":null,r.userFocused?"focused":null].filter(Boolean).join(", ");console.error(` ${r.id} (${s})`)}console.error(""),console.error(" pass a valid --sim id, or run `sootsim list` to see all sessions.")}var je=12e4,xe=500,Ke=5e3,We={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function S(e){return new Promise(o=>setTimeout(o,e))}function ke(e){let o=process.env[e]?.trim();if(!o)return null;let t=Number(o);return Number.isInteger(t)&&t>0?t:null}function ze(){let e=ke("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??ke("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??je;return{timeoutMs:e,hostTimeoutMs:e+Ke,intervalMs:xe,attempts:Math.max(1,Math.ceil(e/xe))}}function qe(e){return e==="chromium"||e==="electron"||e==="playwright"||e==="system"}function F(e){return e.trim()}function Y(e){try{let o=new URL(e),t=o.pathname.replace(/\/+$/,"")||"/";return o.searchParams.has("open")||o.searchParams.has("port")||o.searchParams.has("bundle")||o.searchParams.has("demo")||o.pathname.includes("/sootsim/index.html")||t==="/sootsim"||o.pathname==="/__soot"||o.pathname==="/__soot/"||t==="/rn"||/^\/rn\/[^/]+$/i.test(t)||/^\/app\/[^/]+$/i.test(t)||t==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(t)||/^\/__soot\/app\/[^/]+$/i.test(t)}catch{return!1}}function Ve(e){try{let o=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(o)||/^\/build\/.+/.test(o)}catch{return!1}}async function Vt(e){let o=F(e);return(await Re(o)).bundleUrl}function Ge(e){try{let o=new URL(e.startsWith("http")?e:`http://${e}`),t=o.pathname||"/";if(t!=="/"&&t!==""||o.search||o.hash||!/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(o.hostname))return null;let n=o.port?Number(o.port):o.protocol==="https:"?443:80;return Number.isFinite(n)&&n>0?n:null}catch{return null}}async function Re(e){let o=F(e),t=/^\d+$/.test(o)?Number(o):Ge(o);if(t&&t>0){let n=await ue(t);if(n)return{bundleUrl:n.bundleUrl,port:n.port,framework:n.framework,projectName:n.projectName}}return Ie(o)}function ee(e){let o=e.replace(/\/+$/,"")||"/";return o==="/__soot"||o.startsWith("/__soot/")?"/__soot":""}function Je(e,o){let t=F(e),n=new URL(o),r=ee(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(t)?n.pathname=`${r}/rn/${t}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",t)),n.toString()}function Qe(e){let o=F(e);return/^\d+$/.test(o)||/^https?:\/\//i.test(o)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(o)}async function Xe(e,o){let t=await Re(e),n=new URL(o),r=ee(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.set("bundle",t.bundleUrl),n.toString()}function Ye(e){return e.startsWith("~/")?x.join(He.homedir(),e.slice(2)):x.isAbsolute(e)?e:x.resolve(process.cwd(),e)}function Ze(e){let o={},t={};for(let r=0;r<e.length;r++){if(e[r]==="--replace"){let s=e[r+1];s||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let i=s.indexOf("=");(i<=0||i===s.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let a=s.slice(0,i).trim(),l=Ye(s.slice(i+1).trim());Z.existsSync(l)||(console.error(` sootsim open: replacement file not found: ${l}`),process.exit(1)),o[a]={file:l},r++;continue}if(e[r]==="--remap"){let s=e[r+1],i=s?s.indexOf("="):-1;(!s||i<=0||i===s.length-1)&&(console.error(" sootsim open: --remap expects <host:port>=<host:port>"),process.exit(1)),t[s.slice(0,i).trim()]=s.slice(i+1).trim(),r++;continue}}let n={};return Object.keys(o).length>0&&(n.modules=o),Object.keys(t).length>0&&(n.network={remap:t}),n.modules||n.network?n:void 0}function _e(){let e=se();return ie(e)&&e.runtimePort>0?`http://localhost:${e.runtimePort}/`:ae}async function et(e){try{let o=new URL(e),t=o.searchParams.get("bundle")||"";if(!t)return e;let n=process.env.SOOT_REPO_DIR||await G(t)||void 0,r=fe({bundleUrl:t,repoDir:n});if(r.length===0)return e;let s=await tt(r);return s.length===0?e:(o.searchParams.set("appFonts",ge(s)),o.toString())}catch{return e}}async function tt(e){let o=await Promise.all(e.map(async n=>{let r=new AbortController,s=setTimeout(()=>r.abort(),1500);try{let i=await fetch(n.url,{method:"HEAD",signal:r.signal});return i.status>=200&&i.status<400?n:null}catch{return null}finally{clearTimeout(s)}})),t=[];for(let n of o)n!==null&&t.push(n);return t}async function ot(e,o){if(!e)return new URL(o).toString();if(Y(e))return new URL(e).toString();let t=We[e.toLowerCase()];if(t){let n=new URL(o),r=ee(n.pathname);return n.pathname=`${r}${t}`,n.toString()}return Qe(e)?Xe(e,o):Je(e,o)}async function nt(e){try{let o=new URL(e),t=o.searchParams.get("bundle")||"";if(!t)return e;let n=process.env.SOOT_REPO_DIR||await G(t)||void 0,r=he({bundleUrl:t,repoDir:n});return!r||r.imageUrl&&!await rt(r.imageUrl)?e:(o.searchParams.set("appSplash",we(r)),o.toString())}catch{return e}}async function rt(e){let o=new AbortController,t=setTimeout(()=>o.abort(),1500);try{let n=await fetch(e,{method:"HEAD",signal:o.signal});return n.status>=200&&n.status<400}catch{return!1}finally{clearTimeout(t)}}async function N(e,o=_e()){let t=await ot(e,o);return nt(await et(t))}function Ce(e,o){let t=e?.url||e?.origin||o;try{let n=new URL(t);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.searchParams.delete("appFonts"),n.searchParams.delete("appSplash"),n.toString()}catch{return o}}async function st(e,o,t){let n=new URL(await N(e,o));return n.searchParams.set("inspectOpen",t),n.toString()}async function it(e,o,t,n={}){let r=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<r;a++){let l=v(e,{commandTimeoutMs:o,simId:t,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>i)return{bridge:l,count:c}}catch{}l.close(),await S(s)}return null}function at(e){if(!e)return null;try{let o=new URL(e);if(o.searchParams.has("bundle")){let t=o.searchParams.get("bundle")||"";try{let n=new URL(t),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return o.searchParams.has("port")?`connect :${o.searchParams.get("port")||""}`:o.searchParams.has("open")?`connect ${o.searchParams.get("open")||""}`:o.searchParams.has("demo")?`demo ${o.searchParams.get("demo")||"default"}`:o.pathname.includes("/sootsim/index.html")||o.pathname==="/sootsim/"||o.pathname==="/sootsim"?"embedded sootsim":null}catch{return null}}function lt(e){let o=e.indexOf(":");if(o<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let t=e.slice(0,o),n=e.slice(o+1),r=n.length>12?`${n.slice(0,8)}\u2026`:n;return t==="CLAUDE_CODE_SESSION_ID"||t==="CODEX_THREAD_ID"?`agent ${r}`:`${t} ${r}`}function ct(e,o){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
|
|
3
3
|
`);for(let t of e){let n=t.lockedBy&&t.lockExpiresAt?`locked by ${lt(t.lockedBy)} (${Math.max(0,Math.round((t.lockExpiresAt-Date.now())/1e3))}s)`:"",r=[t.isPrimary?"primary":"",t.id===o?"selected":"",t.readyState,t.userVisible===!1?"hidden":t.userVisible===!0?"visible":"",t.attachedCliCount&&t.attachedCliCount>0?"in use":"",t.userFocused?"focused":"",n].filter(Boolean);console.log(` ${t.id}${r.length?` [${r.join(", ")}]`:""}`);let s=at(t.url);if(s)console.log(` loaded: ${s}`);else if(t.url){let a=t.url.length>96?`${t.url.slice(0,93)}\u2026`:t.url;console.log(` url: ${a}`)}else t.origin&&console.log(` origin: ${t.origin}`);let i=dt(t);i&&console.log(` engine: ${i}`),t.title&&console.log(` title: ${t.title}`),t.visibilityState&&t.visibilityState!=="visible"&&console.log(` visibility: ${t.visibilityState}`),console.log(` connected: ${Te(Date.now()-t.connectedAt)}`),t.lastActiveAt&&t.lastActiveAt>0&&console.log(` last active: ${Te(Date.now()-t.lastActiveAt)}`)}}function dt(e){let o=e.url||e.origin||"";if(!o)return null;try{let t=new URL(o).port;return t==="5173"?"dev \u2014 local source (:5173)":t==="3000"?"soot app embedded (:3000)":`runtime \u2014 published engine (:${t||"?"})`}catch{return null}}function Te(e){let o=Math.max(0,Math.round(e/1e3));return o<60?`${o}s ago`:o<3600?`${Math.round(o/60)}m ago`:o<86400?`${Math.round(o/3600)}h ago`:`${Math.round(o/86400)}d ago`}async function A(e,o,t,n={}){let r=n.attempts??30,s=n.intervalMs??500;for(let i=0;i<r;i++){let a=v(e,{commandTimeoutMs:o});try{let c=(await a.listSims()).find(t);if(c)return c}catch{}finally{a.close()}await S(s)}return null}async function mt(e,o,t,n={}){let r=n.attempts??20,s=n.intervalMs??250;for(let i=0;i<r;i++){let a=v(e,{commandTimeoutMs:o});try{let c=(await a.listSims()).find(d=>d.id===t);if(!c||c.readyState!=="open")return!0}catch{return!0}finally{a.close()}await S(s)}return!1}function ut(e){let o=e.meta;if(!o||o.sootsimHostDriver!=="playwright")return null;let t=Number(o.sootsimHostPid);return!Number.isInteger(t)||t<=1||t===process.pid?null:t}function pt(e){if(!e.connectAckFile)return!1;try{return Z.writeFileSync(e.connectAckFile,`${JSON.stringify({connectedAt:Date.now(),pid:e.pid??null})}
|
|
4
4
|
`,{flag:"w"}),!0}catch{return!1}}function ft(e){if(e.diagnosticLogPath)try{let o=Z.readFileSync(e.diagnosticLogPath,"utf8").trim();if(!o){console.error(` ${x.basename(e.diagnosticLogPath)} was empty`);return}let t=o.length>4e3?`\u2026
|
|
5
5
|
${o.slice(-4e3)}`:o;console.error(` ${x.basename(e.diagnosticLogPath)}:`),console.error(t)}catch(o){let t=o instanceof Error?o.message:String(o);console.error(` failed to read ${x.basename(e.diagnosticLogPath)}: ${t}`)}}function Me(e){try{return process.kill(e,0),!0}catch(o){return o?.code==="EPERM"}}async function gt(e,o=2500){let t=Date.now()+o;for(;Date.now()<t;){if(!Me(e))return!0;await S(100)}return!Me(e)}async function X(e,o){let t=new Set(o),n=new Set;for(let r of e){if(!t.has(r.id))continue;let s=ut(r);s&&n.add(s)}for(let r of n){try{process.kill(r,"SIGTERM")}catch{}if(await gt(r)){console.log(` closed playwright host process ${r}`);continue}try{process.kill(r,"SIGKILL"),console.log(` force-closed playwright host process ${r}`)}catch{}}}function H(e,o){if(o){let r=o.trim(),s=e.find(i=>i.id===r);if(!s)throw new Error(`no sim connected with id ${r}`);return s}let t=e.find(r=>r.isPrimary&&r.readyState==="open");if(t)return t;let n=e.find(r=>r.readyState==="open");if(n)return n;throw new Error("no sim connected")}function R(e,o,t){console.log(` ${t==="current sim"?"loaded":"opened"}: ${e} [${t}]`),console.log(` current sim: ${o.id}`),console.log(JSON.stringify({simId:o.id,url:o.url},null,2))}async function _(e,o,t){if(t.includes("--no-describe"))return;let n=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await ht(e,o,{stableMs:150,maxMs:400});let r=v(e,{commandTimeoutMs:3e3,simId:o,cliLabel:"open --describe",simIdSource:"flag"});try{let s=null;try{s=await r.send({type:"evaluate",code:ce})}catch{}if(s&&!(s.flag===!0&&!s.loadingText&&de(s))){let d=s.loadingText?`still showing "${s.loadingText}"`:s.flag!==!0?"guest ready event has not fired":s.targets<=0?"no visible app content is inspectable yet":"app tree is still stabilizing";console.log(` app still loading: ${d} (nodes: ${s.nodes}, targets: ${s.targets})`),console.log(" before interacting, run: sootsim wait ready --max-ms 120000")}let a=`(async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import"./chunk-T56IURYQ.js";import{existsSync as x,readFileSync as j}from"fs";import{resolve as g}from"path";async function P(s){(s.includes("--help")||s.includes("-h"))&&(console.log(`
|
|
3
3
|
sootsim compat \u2014 check package compatibility
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -20,7 +20,7 @@ examples:
|
|
|
20
20
|
sootsim compat react-native-reanimated
|
|
21
21
|
sootsim compat --json
|
|
22
22
|
sootsim compat --brief
|
|
23
|
-
`),process.exit(0));let c=s.includes("--json"),e=s.includes("--brief"),l=s.indexOf("--app"),n=l!==-1&&s[l+1]?g(s[l+1]):process.cwd(),k=s.filter((o,a)=>!o.startsWith("-")&&(l===-1||a!==l+1))[0];if(c||e){let{scanDeps:o}=await import("./web-
|
|
23
|
+
`),process.exit(0));let c=s.includes("--json"),e=s.includes("--brief"),l=s.indexOf("--app"),n=l!==-1&&s[l+1]?g(s[l+1]):process.cwd(),k=s.filter((o,a)=>!o.startsWith("-")&&(l===-1||a!==l+1))[0];if(c||e){let{scanDeps:o}=await import("./web-TNVHBB2J.js"),a=g(n,"package.json");x(a)||(console.error(" no package.json found in",n),process.exit(1));let u=JSON.parse(j(a,"utf8")),r=o(u);if(c){console.log(JSON.stringify(r,null,2));return}if(r.packages.length===0){console.log(" no RN ecosystem packages detected");return}let T=Math.round(r.overallScore*100),v=r.packages.filter(i=>i.status==="full").length,$=r.packages.filter(i=>i.status==="partial"||i.status==="auto-stub").length,w=r.packages.filter(i=>i.status==="unsupported").length,p=[];v&&p.push(`${v} fully supported`),$&&p.push(`${$} partial`),w&&p.push(`${w} unsupported`),console.log(` ${p.join(", ")} \u2014 ${T}% compatible`);return}let{POLYFILL_REGISTRY:d}=await import("./web-TNVHBB2J.js");if(k){W(k,d);return}let b=g(n,"package.json");x(b)||(console.error(" no package.json found in",n),process.exit(1));let m=JSON.parse(j(b,"utf8")),S={...m.dependencies,...m.devDependencies},t={full:[],partial:[],autoStub:[],unsupported:[],justWorks:[],unknown:[]};for(let o of Object.keys(S)){let a=d[o];if(a){let u=a.stubType==="native"?"full":a.stubType==="works"?"not-relevant":a.stubType;if(a.stubType!=="native"&&a.versions?.length){let r=Math.max(...a.versions.map(y=>y.coverage||0));u=r>=.8?"full":r>=.3?"partial":"auto-stub"}switch(u){case"full":t.full.push(o);break;case"partial":t.partial.push(o);break;case"auto-stub":t.autoStub.push(o);break;case"unsupported":t.unsupported.push(o);break;case"not-relevant":t.justWorks.push(o);break;default:f(o)&&t.unknown.push(o)}}else f(o)&&t.unknown.push(o)}console.log(`
|
|
24
24
|
sootsim compatibility report
|
|
25
25
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
26
26
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import"./chunk-
|
|
1
|
+
/*! sootsim v0.1.163 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import"./chunk-T56IURYQ.js";import{existsSync as i,writeFileSync as n,readFileSync as c}from"fs";import{resolve as t}from"path";async function a(s){let e=s[0];switch((!e||s.includes("--help")||s.includes("-h"))&&(console.log(`
|
|
3
3
|
sootsim config \u2014 manage sootsim configuration
|
|
4
4
|
|
|
5
5
|
usage:
|