sootsim 0.1.305 → 0.1.307
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/dist-cli/bin.js +5 -5
- package/dist-cli/chunks/{agent-OJP4VF2K.js → agent-BQ3KAQAU.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-HMVFZKH3.js → agent-wrapper-DS6FBIAI.js} +2 -2
- package/dist-cli/chunks/{app-fonts-INFYQMIN.js → app-fonts-VTLZYBCH.js} +2 -2
- package/dist-cli/chunks/{assert-YSFBCP5P.js → assert-MPQ4CDNH.js} +2 -2
- package/dist-cli/chunks/{auth-M7RKDYQV.js → auth-O3PQ5WAK.js} +2 -2
- package/dist-cli/chunks/{beta-4NRMM37T.js → beta-CHK46VAX.js} +2 -2
- package/dist-cli/chunks/{camera-MHLM35MB.js → camera-YOO6XYC5.js} +2 -2
- package/dist-cli/chunks/{chunk-6EXIYEOQ.js → chunk-2ODPPVQC.js} +2 -2
- package/dist-cli/chunks/{chunk-2UKSI3VX.js → chunk-2P5OBO7Z.js} +1 -1
- package/dist-cli/chunks/{chunk-R5TBMYGH.js → chunk-3JLFWHOZ.js} +1 -1
- package/dist-cli/chunks/{chunk-CWDEDUOZ.js → chunk-3S57XWPX.js} +1 -1
- package/dist-cli/chunks/{chunk-JKIPNRAK.js → chunk-4BZ6SM53.js} +24 -25
- package/dist-cli/chunks/{chunk-H5D6E3DR.js → chunk-4QCKHLRV.js} +2 -2
- package/dist-cli/chunks/{chunk-UUKUKTV3.js → chunk-537ULSCX.js} +11 -11
- package/dist-cli/chunks/chunk-5MN7CUQB.js +6 -0
- package/dist-cli/chunks/{chunk-XI6CPN53.js → chunk-6Q3FIZGP.js} +1 -1
- package/dist-cli/chunks/{chunk-TRV5K6D2.js → chunk-746PZ7ND.js} +1 -1
- package/dist-cli/chunks/{chunk-B65RMI7A.js → chunk-7HPBPICZ.js} +1 -1
- package/dist-cli/chunks/{chunk-2D7NF3XK.js → chunk-7T5WCLEU.js} +2 -2
- package/dist-cli/chunks/{chunk-KG2WUKD2.js → chunk-AD2J3Y5G.js} +2 -2
- package/dist-cli/chunks/chunk-BO2XSJJA.js +5 -0
- package/dist-cli/chunks/{chunk-IJ64Z77P.js → chunk-CKLXK3SU.js} +2 -2
- package/dist-cli/chunks/{chunk-DHDSGBZB.js → chunk-E2AY5MPI.js} +1 -1
- package/dist-cli/chunks/chunk-EWSHWBPU.js +4 -0
- package/dist-cli/chunks/chunk-EY5RFXHC.js +125 -0
- package/dist-cli/chunks/{chunk-6YE25EJB.js → chunk-FRTR2EUL.js} +3 -3
- package/dist-cli/chunks/{chunk-SWBTXTEO.js → chunk-IBM36KUP.js} +2 -2
- package/dist-cli/chunks/{chunk-WQYUHDBU.js → chunk-J52NXD2T.js} +2 -2
- package/dist-cli/chunks/chunk-KCRDI5B2.js +5 -0
- package/dist-cli/chunks/{chunk-JQRRJIMT.js → chunk-KPDYFXBD.js} +1 -1
- package/dist-cli/chunks/{chunk-NNR3BU5O.js → chunk-LL76B22R.js} +7 -7
- package/dist-cli/chunks/{chunk-4Q42Y64Y.js → chunk-LTS6OYSK.js} +2 -2
- package/dist-cli/chunks/{chunk-HKPJYMJC.js → chunk-NK72QUBY.js} +15 -12
- package/dist-cli/chunks/chunk-NLE5PR7V.js +15 -0
- package/dist-cli/chunks/{chunk-EWVEUNRO.js → chunk-NWOGE4YS.js} +81 -37
- package/dist-cli/chunks/{chunk-DTHOMSAA.js → chunk-OQ6KN4TP.js} +2 -2
- package/dist-cli/chunks/{chunk-W3M4676V.js → chunk-Q32TOAPX.js} +3 -3
- package/dist-cli/chunks/{chunk-54AINFEF.js → chunk-Q35WXZFI.js} +2 -2
- package/dist-cli/chunks/{chunk-BDNZULU7.js → chunk-QJ7B6FFD.js} +2 -2
- package/dist-cli/chunks/chunk-RCLJQZQR.js +4 -0
- package/dist-cli/chunks/chunk-S5QHC5LD.js +4 -0
- package/dist-cli/chunks/{chunk-VKBCGFOU.js → chunk-SKMVVRFI.js} +2 -2
- package/dist-cli/chunks/{chunk-EBCXFB3K.js → chunk-SLEKK2UU.js} +1 -1
- package/dist-cli/chunks/chunk-SZDXEZ2I.js +4 -0
- package/dist-cli/chunks/{chunk-43SNLCXR.js → chunk-SZX2PHDS.js} +1 -1
- package/dist-cli/chunks/{chunk-AJCL7DHI.js → chunk-UKKB52JO.js} +2 -2
- package/dist-cli/chunks/{chunk-R6MBDR56.js → chunk-UURKPOZU.js} +1 -1
- package/dist-cli/chunks/{chunk-3PREBGTH.js → chunk-WE6WXVYB.js} +2 -2
- package/dist-cli/chunks/{chunk-EPZG2F4I.js → chunk-WPVMW3I5.js} +1 -1
- package/dist-cli/chunks/{chunk-J653UMCU.js → chunk-WTWGQFNU.js} +2 -2
- package/dist-cli/chunks/{chunk-SLCYXISJ.js → chunk-XRUSCWIH.js} +2 -2
- package/dist-cli/chunks/{chunk-LOF3WUKB.js → chunk-XVQ2YGCI.js} +1 -1
- package/dist-cli/chunks/{chunk-HMOYEM6V.js → chunk-YIKFWG22.js} +2 -2
- package/dist-cli/chunks/{chunk-KVLXMWV5.js → chunk-YPKDDYIE.js} +2 -2
- package/dist-cli/chunks/{chunk-HHLH4TWF.js → chunk-Z772XMEF.js} +1 -1
- package/dist-cli/chunks/{chunk-KSZRLJPA.js → chunk-ZJR2AKLU.js} +2 -2
- package/dist-cli/chunks/{chunk-POIK3AHY.js → chunk-ZZBMQEEE.js} +2 -2
- package/dist-cli/chunks/{cleanup-ZJ7FQKED.js → cleanup-RT2PX5NP.js} +2 -2
- package/dist-cli/chunks/{cli-version-5LGCFOAC.js → cli-version-W3D5LXK5.js} +2 -2
- package/dist-cli/chunks/{compat-EQACACVP.js → compat-LGAXCMPJ.js} +2 -2
- package/dist-cli/chunks/{config-ADGNCDG5.js → config-3MQYRCSB.js} +2 -2
- package/dist-cli/chunks/control-MDWGTCXV.js +4 -0
- package/dist-cli/chunks/daemon-4FHSWZSV.js +4 -0
- package/dist-cli/chunks/{debug-PU73W33T.js → debug-UKOFTGI3.js} +3 -3
- package/dist-cli/chunks/desktop-N6TEZAIJ.js +31 -0
- package/dist-cli/chunks/{detox-SHVVEPPX.js → detox-T2Y4HE44.js} +2 -2
- package/dist-cli/chunks/{device-NMRUACB4.js → device-ZE2WSDJN.js} +2 -2
- package/dist-cli/chunks/{diagnose-S2AVGABT.js → diagnose-WFEFBH6U.js} +2 -2
- package/dist-cli/chunks/disk-cleanup-YXC3JGG5.js +4 -0
- package/dist-cli/chunks/drivers-62L33HHX.js +4 -0
- package/dist-cli/chunks/{film-UB7N4EKB.js → film-THTAWD5P.js} +3 -3
- package/dist-cli/chunks/flow-3HCUMLZL.js +4 -0
- package/dist-cli/chunks/help-KEXQPE2I.js +4 -0
- package/dist-cli/chunks/{hidden-runtime-alias-M44SGZLM.js → hidden-runtime-alias-SNP5LSQD.js} +2 -2
- package/dist-cli/chunks/{home-paths-ZTEBHBUO.js → home-paths-WUCC72RE.js} +2 -2
- package/dist-cli/chunks/inspect-2SR5AEEA.js +4 -0
- package/dist-cli/chunks/install-desktop-KE5ZPY6L.js +4 -0
- package/dist-cli/chunks/{login-YQ3HRPPS.js → login-ZEB4WSVZ.js} +4 -4
- package/dist-cli/chunks/{logout-XGBDWO4J.js → logout-P6PV2WRO.js} +2 -2
- package/dist-cli/chunks/{maestro-CESBE2SF.js → maestro-TUA7YURM.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-4IHISKJL.js → maestro-generate-HI4UM47Q.js} +3 -3
- package/dist-cli/chunks/{mode-BQGGZ737.js → mode-ILLUAGCG.js} +2 -2
- package/dist-cli/chunks/optional-demo-registry-R7UFXPBP.js +4 -0
- package/dist-cli/chunks/{perf-TUR22UTE.js → perf-4CE5R2TN.js} +2 -2
- package/dist-cli/chunks/{permissions-POJIVSRV.js → permissions-NQCKUHGU.js} +2 -2
- package/dist-cli/chunks/{record-Q55SGXLU.js → record-5JRY7R54.js} +3 -3
- package/dist-cli/chunks/{report-issue-LRRX7VJV.js → report-issue-PFE7RDDV.js} +2 -2
- package/dist-cli/chunks/runtime-MP2QVB2X.js +4 -0
- package/dist-cli/chunks/{screenshot-command-C7EU43J3.js → screenshot-command-R3MPUAQI.js} +3 -3
- package/dist-cli/chunks/{screenshot-layers-NYVOJYUU.js → screenshot-layers-TKLUUDFA.js} +2 -2
- package/dist-cli/chunks/{screenshots-capture-AYKJKBLR.js → screenshots-capture-6UT2EVTR.js} +2 -2
- package/dist-cli/chunks/{serve-EN3ZPJSA.js → serve-L5GFNPAX.js} +3 -3
- package/dist-cli/chunks/{setup-KKMKLJZE.js → setup-IZQ7IXYW.js} +2 -2
- package/dist-cli/chunks/{skills-DR5DG2SK.js → skills-2CY6YIL7.js} +2 -2
- package/dist-cli/chunks/{storage-GMDBVTQ5.js → storage-EPY4VXCY.js} +2 -2
- package/dist-cli/chunks/store-F5RQZH7P.js +4 -0
- package/dist-cli/chunks/telemetry-MZKLKJAS.js +4 -0
- package/dist-cli/chunks/{timeline-VY3444AZ.js → timeline-LK5IA74W.js} +2 -2
- package/dist-cli/chunks/{upgrade-EUYCW55F.js → upgrade-ZK6YJMUA.js} +2 -2
- package/dist-cli/chunks/upload-LP6UOKRF.js +4 -0
- package/dist-cli/chunks/{version-TEGM4WRU.js → version-SRC2HVYI.js} +2 -2
- package/dist-cli/chunks/{web-QF7LF4VB.js → web-SVNHYKX5.js} +2 -2
- package/dist-cli/chunks/{what-happened-HDTJGNND.js → what-happened-URW3Q7QP.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +43 -21
- 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 +8 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +51 -41
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +222 -302
- 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/jump-to-source-babel.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 +43 -13
- package/dist-lib/sdk.cjs +47 -10
- package/dist-lib/sdk.mjs +47 -10
- package/dist-lib/skills.cjs +11364 -6863
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/scripts/dev-server-scanner.ts +9 -15
- package/scripts/optional-demo-registry.ts +52 -10
- package/skills/sootsim-debug/SKILL.md +4 -5
- package/skills/sootsim-setup/SKILL.md +29 -49
- package/src/bridge-constants.ts +15 -0
- package/src/host/bridge-host.ts +0 -16
- package/src/host/open-url.ts +2 -147
- package/src/plist.ts +27 -0
- package/src/settings-bundle.ts +2 -23
- package/src/skills/builtin/maestro-test.ts +4 -1
- package/src/vite-plugin.ts +2 -1
- package/dist-cli/chunks/chunk-COD6QGS2.js +0 -125
- package/dist-cli/chunks/chunk-KVOY4Z2X.js +0 -4
- package/dist-cli/chunks/chunk-OCRL2VU4.js +0 -4
- package/dist-cli/chunks/chunk-PELXRGDN.js +0 -4
- package/dist-cli/chunks/chunk-QJUKXBH5.js +0 -15
- package/dist-cli/chunks/chunk-QVH276LI.js +0 -5
- package/dist-cli/chunks/chunk-WIRBJTTU.js +0 -7
- package/dist-cli/chunks/chunk-XWMTLVCE.js +0 -4
- package/dist-cli/chunks/chunk-ZRQFYMTL.js +0 -4
- package/dist-cli/chunks/control-Y3E5IIMO.js +0 -4
- package/dist-cli/chunks/daemon-A6CWUYMR.js +0 -4
- package/dist-cli/chunks/desktop-V675PYF4.js +0 -34
- package/dist-cli/chunks/disk-cleanup-EJEZIIT4.js +0 -4
- package/dist-cli/chunks/drivers-PM4PVYHY.js +0 -4
- package/dist-cli/chunks/flow-XJRNL25V.js +0 -4
- package/dist-cli/chunks/help-2ZJHCVUZ.js +0 -4
- package/dist-cli/chunks/inspect-L76RUF62.js +0 -4
- package/dist-cli/chunks/install-desktop-UIXKNXKF.js +0 -4
- package/dist-cli/chunks/optional-demo-registry-LWYRXVIE.js +0 -4
- package/dist-cli/chunks/runtime-NHDHZJJN.js +0 -4
- package/dist-cli/chunks/store-QZEMKQDC.js +0 -4
- package/dist-cli/chunks/telemetry-TNX72J2B.js +0 -4
- package/dist-cli/chunks/upload-D43U7RGT.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.307 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -36,15 +36,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
36
36
|
var optional_demo_registry_exports = {};
|
|
37
37
|
__export(optional_demo_registry_exports, {
|
|
38
38
|
__withOptionalDemoAppsForTests: () => __withOptionalDemoAppsForTests,
|
|
39
|
+
findInternalDemoRegistry: () => findInternalDemoRegistry,
|
|
39
40
|
loadOptionalDemoApps: () => loadOptionalDemoApps,
|
|
40
41
|
optionalDemoAppsSync: () => optionalDemoAppsSync
|
|
41
42
|
});
|
|
43
|
+
function findInternalDemoRegistry(startDir) {
|
|
44
|
+
let dir = startDir;
|
|
45
|
+
for (let step = 0; step < MAX_ANCESTOR_STEPS; step++) {
|
|
46
|
+
if ((0, import_node_path2.basename)(dir) === "node_modules") return null;
|
|
47
|
+
const candidate = (0, import_node_path2.join)(dir, REGISTRY_REPO_PATH);
|
|
48
|
+
if ((0, import_node_fs.existsSync)(candidate)) return candidate;
|
|
49
|
+
const parent = (0, import_node_path2.dirname)(dir);
|
|
50
|
+
if (parent === dir) return null;
|
|
51
|
+
dir = parent;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
42
55
|
async function loadOptionalDemoApps() {
|
|
43
56
|
if (cached) return cached;
|
|
57
|
+
const registryPath = findInternalDemoRegistry((0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)));
|
|
58
|
+
if (!registryPath) {
|
|
59
|
+
cached = [];
|
|
60
|
+
return cached;
|
|
61
|
+
}
|
|
44
62
|
try {
|
|
45
63
|
const mod = await import(
|
|
46
64
|
/* @vite-ignore */
|
|
47
|
-
|
|
65
|
+
(0, import_node_url.pathToFileURL)(registryPath).href
|
|
48
66
|
);
|
|
49
67
|
cached = Array.isArray(mod.APPS) ? mod.APPS : [];
|
|
50
68
|
} catch {
|
|
@@ -64,11 +82,15 @@ function __withOptionalDemoAppsForTests(apps) {
|
|
|
64
82
|
}
|
|
65
83
|
};
|
|
66
84
|
}
|
|
67
|
-
var
|
|
85
|
+
var import_node_fs, import_node_path2, import_node_url, REGISTRY_REPO_PATH, MAX_ANCESTOR_STEPS, cached;
|
|
68
86
|
var init_optional_demo_registry = __esm({
|
|
69
87
|
"scripts/optional-demo-registry.ts"() {
|
|
70
88
|
"use strict";
|
|
71
|
-
|
|
89
|
+
import_node_fs = require("node:fs");
|
|
90
|
+
import_node_path2 = require("node:path");
|
|
91
|
+
import_node_url = require("node:url");
|
|
92
|
+
REGISTRY_REPO_PATH = "packages/sootsim/scripts/demo-app-registry.ts";
|
|
93
|
+
MAX_ANCESTOR_STEPS = 8;
|
|
72
94
|
cached = null;
|
|
73
95
|
}
|
|
74
96
|
});
|
|
@@ -81,9 +103,9 @@ __export(bridge_host_exports, {
|
|
|
81
103
|
});
|
|
82
104
|
module.exports = __toCommonJS(bridge_host_exports);
|
|
83
105
|
var import_child_process3 = require("child_process");
|
|
84
|
-
var
|
|
106
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
85
107
|
var import_http3 = require("http");
|
|
86
|
-
var
|
|
108
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
87
109
|
var import_ws2 = require("ws");
|
|
88
110
|
|
|
89
111
|
// scripts/dev-server-scanner.ts
|
|
@@ -146,12 +168,9 @@ function normalizeNativeDevBundleUrl(bundleUrl) {
|
|
|
146
168
|
// src/settings-bundle.ts
|
|
147
169
|
var import_promises = require("node:fs/promises");
|
|
148
170
|
var import_node_path = require("node:path");
|
|
171
|
+
|
|
172
|
+
// src/plist.ts
|
|
149
173
|
var import_plist = __toESM(require("@expo/plist"), 1);
|
|
150
|
-
var MAX_PLIST_BYTES = 1048576;
|
|
151
|
-
var MAX_CHILD_DEPTH = 8;
|
|
152
|
-
var MAX_PLIST_FILES = 32;
|
|
153
|
-
var MAX_SPECIFIERS = 512;
|
|
154
|
-
var settingsBundleCache = /* @__PURE__ */ new Map();
|
|
155
174
|
function isRecord(value) {
|
|
156
175
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157
176
|
}
|
|
@@ -167,6 +186,19 @@ function resolvePlistParser(value) {
|
|
|
167
186
|
return typeof nestedParse === "function" ? (source) => Reflect.apply(nestedParse, nested, [source]) : null;
|
|
168
187
|
}
|
|
169
188
|
var parsePlist = resolvePlistParser(import_plist.default);
|
|
189
|
+
function parsePlistSource(source) {
|
|
190
|
+
return parsePlist?.(source) ?? null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/settings-bundle.ts
|
|
194
|
+
var MAX_PLIST_BYTES = 1048576;
|
|
195
|
+
var MAX_CHILD_DEPTH = 8;
|
|
196
|
+
var MAX_PLIST_FILES = 32;
|
|
197
|
+
var MAX_SPECIFIERS = 512;
|
|
198
|
+
var settingsBundleCache = /* @__PURE__ */ new Map();
|
|
199
|
+
function isRecord2(value) {
|
|
200
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
201
|
+
}
|
|
170
202
|
function optionalString(value) {
|
|
171
203
|
return typeof value === "string" ? value : void 0;
|
|
172
204
|
}
|
|
@@ -289,12 +321,11 @@ async function settingsBundleFingerprint(bundlePath) {
|
|
|
289
321
|
}
|
|
290
322
|
async function parsePlistRecord(path9) {
|
|
291
323
|
try {
|
|
292
|
-
if (!parsePlist) return null;
|
|
293
324
|
const metadata = await (0, import_promises.stat)(path9);
|
|
294
325
|
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
295
326
|
const source = await (0, import_promises.readFile)(path9, "utf8");
|
|
296
|
-
const parsed =
|
|
297
|
-
return
|
|
327
|
+
const parsed = parsePlistSource(source);
|
|
328
|
+
return isRecord2(parsed) ? parsed : null;
|
|
298
329
|
} catch {
|
|
299
330
|
return null;
|
|
300
331
|
}
|
|
@@ -330,7 +361,7 @@ function normalizeMultiValue(raw, key, title) {
|
|
|
330
361
|
};
|
|
331
362
|
}
|
|
332
363
|
async function normalizeSpecifier(raw, context) {
|
|
333
|
-
if (!
|
|
364
|
+
if (!isRecord2(raw)) return null;
|
|
334
365
|
if (context.budget.specifiers >= MAX_SPECIFIERS) return null;
|
|
335
366
|
const type = requiredString(raw.Type);
|
|
336
367
|
if (!type) return null;
|
|
@@ -479,7 +510,6 @@ async function readAppSettingsBundle(projectRoot) {
|
|
|
479
510
|
// scripts/dev-server-scanner.ts
|
|
480
511
|
init_optional_demo_registry();
|
|
481
512
|
var execP = (0, import_util.promisify)(import_child_process.exec);
|
|
482
|
-
void loadOptionalDemoApps();
|
|
483
513
|
var TIMEOUT_MS = 250;
|
|
484
514
|
var MANIFEST_TIMEOUT_MS = 1500;
|
|
485
515
|
var TCP_GATE_MS = 120;
|
|
@@ -732,6 +762,7 @@ var knownNonPatched = /* @__PURE__ */ new Set();
|
|
|
732
762
|
var knownNonExpo = /* @__PURE__ */ new Set();
|
|
733
763
|
var knownOne = /* @__PURE__ */ new Set();
|
|
734
764
|
async function probePort(port, buildIconProxyUrl) {
|
|
765
|
+
await loadOptionalDemoApps();
|
|
735
766
|
if (!await tcpPing(port)) return null;
|
|
736
767
|
const onePath = `/node_modules/one/metro-entry.bundle?platform=ios&dev=true`;
|
|
737
768
|
const [sootsimRes, statusRes, manifestRes, expoRes] = await Promise.all([
|
|
@@ -934,19 +965,19 @@ var SOOTSIM_BRIDGE_SIM_CLOSE_CODE = 4001;
|
|
|
934
965
|
var SOOTSIM_BRIDGE_SIM_CLOSE_REASON = "sootsim close";
|
|
935
966
|
|
|
936
967
|
// src/cli-version.ts
|
|
937
|
-
var
|
|
938
|
-
var
|
|
968
|
+
var import_node_fs2 = require("node:fs");
|
|
969
|
+
var import_node_url2 = require("node:url");
|
|
939
970
|
var import_meta = {};
|
|
940
971
|
var cached2 = null;
|
|
941
972
|
function getCliVersion() {
|
|
942
973
|
if (cached2 != null) return cached2;
|
|
943
974
|
const candidates = [
|
|
944
|
-
() => (0,
|
|
945
|
-
() => (0,
|
|
975
|
+
() => (0, import_node_url2.fileURLToPath)(import_meta.resolve("sootsim/package.json")),
|
|
976
|
+
() => (0, import_node_url2.fileURLToPath)(new URL("../package.json", __sootsim_import_meta_url))
|
|
946
977
|
];
|
|
947
978
|
for (const resolve of candidates) {
|
|
948
979
|
try {
|
|
949
|
-
const version = JSON.parse((0,
|
|
980
|
+
const version = JSON.parse((0, import_node_fs2.readFileSync)(resolve(), "utf8")).version;
|
|
950
981
|
if (typeof version === "string" && version) {
|
|
951
982
|
cached2 = version;
|
|
952
983
|
return cached2;
|
|
@@ -959,9 +990,9 @@ function getCliVersion() {
|
|
|
959
990
|
}
|
|
960
991
|
|
|
961
992
|
// src/home-paths.ts
|
|
962
|
-
var
|
|
993
|
+
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
963
994
|
var import_node_os = require("node:os");
|
|
964
|
-
var
|
|
995
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
965
996
|
var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
|
|
966
997
|
var ACTIVE_RUNTIME_FILE = "active";
|
|
967
998
|
var DAEMON_LOCKFILE = "daemon.json";
|
|
@@ -970,8 +1001,8 @@ var CONFIG_FILE = "config.json";
|
|
|
970
1001
|
var DAEMON_HEARTBEAT_STALE_MS = 3e4;
|
|
971
1002
|
function sootsimHomeDir() {
|
|
972
1003
|
const override = process.env[SOOTSIM_HOME_ENV];
|
|
973
|
-
if (override && override.length > 0) return
|
|
974
|
-
return
|
|
1004
|
+
if (override && override.length > 0) return import_node_path3.default.resolve(override);
|
|
1005
|
+
return import_node_path3.default.join((0, import_node_os.homedir)(), ".sootsim");
|
|
975
1006
|
}
|
|
976
1007
|
function isSootsimDevCheckout() {
|
|
977
1008
|
if (process.env.SOOTSIM_FORCE_DAEMON_INSTALL === "1") return false;
|
|
@@ -981,45 +1012,45 @@ function isSootsimDevCheckout() {
|
|
|
981
1012
|
const argv1 = process.argv[1];
|
|
982
1013
|
if (!argv1) return false;
|
|
983
1014
|
try {
|
|
984
|
-
const real =
|
|
985
|
-
return real.includes(`${
|
|
1015
|
+
const real = import_node_fs3.default.realpathSync(argv1);
|
|
1016
|
+
return real.includes(`${import_node_path3.default.sep}packages${import_node_path3.default.sep}sootsim${import_node_path3.default.sep}`);
|
|
986
1017
|
} catch {
|
|
987
1018
|
return false;
|
|
988
1019
|
}
|
|
989
1020
|
}
|
|
990
1021
|
function runtimesDir() {
|
|
991
|
-
return
|
|
1022
|
+
return import_node_path3.default.join(sootsimHomeDir(), "runtimes");
|
|
992
1023
|
}
|
|
993
1024
|
function runtimeDir(version) {
|
|
994
|
-
return
|
|
1025
|
+
return import_node_path3.default.join(runtimesDir(), version);
|
|
995
1026
|
}
|
|
996
1027
|
function activeRuntimeFile() {
|
|
997
|
-
return
|
|
1028
|
+
return import_node_path3.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
998
1029
|
}
|
|
999
1030
|
function electronDir() {
|
|
1000
|
-
return
|
|
1031
|
+
return import_node_path3.default.join(sootsimHomeDir(), "electron");
|
|
1001
1032
|
}
|
|
1002
1033
|
function electronUserDataDir() {
|
|
1003
|
-
return
|
|
1034
|
+
return import_node_path3.default.join(electronDir(), "userData");
|
|
1004
1035
|
}
|
|
1005
1036
|
function profilesDir() {
|
|
1006
|
-
return
|
|
1037
|
+
return import_node_path3.default.join(sootsimHomeDir(), "profiles");
|
|
1007
1038
|
}
|
|
1008
1039
|
function cacheDir() {
|
|
1009
|
-
return
|
|
1040
|
+
return import_node_path3.default.join(sootsimHomeDir(), "cache");
|
|
1010
1041
|
}
|
|
1011
1042
|
function daemonLockfilePath() {
|
|
1012
|
-
return
|
|
1043
|
+
return import_node_path3.default.join(sootsimHomeDir(), DAEMON_LOCKFILE);
|
|
1013
1044
|
}
|
|
1014
1045
|
function devBridgeLockfilePath() {
|
|
1015
|
-
return
|
|
1046
|
+
return import_node_path3.default.join(sootsimHomeDir(), DEV_BRIDGE_LOCKFILE);
|
|
1016
1047
|
}
|
|
1017
1048
|
function configFilePath() {
|
|
1018
|
-
return
|
|
1049
|
+
return import_node_path3.default.join(sootsimHomeDir(), CONFIG_FILE);
|
|
1019
1050
|
}
|
|
1020
1051
|
function readSharedConfig() {
|
|
1021
1052
|
try {
|
|
1022
|
-
const raw =
|
|
1053
|
+
const raw = import_node_fs3.default.readFileSync(configFilePath(), "utf8");
|
|
1023
1054
|
const parsed = JSON.parse(raw);
|
|
1024
1055
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
1025
1056
|
} catch {
|
|
@@ -1037,39 +1068,39 @@ function writeSharedConfig(patch) {
|
|
|
1037
1068
|
};
|
|
1038
1069
|
}
|
|
1039
1070
|
const tmp = `${configFilePath()}.tmp`;
|
|
1040
|
-
|
|
1071
|
+
import_node_fs3.default.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}
|
|
1041
1072
|
`, "utf8");
|
|
1042
|
-
|
|
1073
|
+
import_node_fs3.default.renameSync(tmp, configFilePath());
|
|
1043
1074
|
return next;
|
|
1044
1075
|
}
|
|
1045
1076
|
function runtimeUpgradeNoticePath() {
|
|
1046
|
-
return
|
|
1077
|
+
return import_node_path3.default.join(sootsimHomeDir(), "runtime-upgraded.json");
|
|
1047
1078
|
}
|
|
1048
1079
|
function writeRuntimeUpgradeNotice(notice) {
|
|
1049
1080
|
ensureSootsimHome();
|
|
1050
1081
|
const tmp = `${runtimeUpgradeNoticePath()}.tmp`;
|
|
1051
|
-
|
|
1082
|
+
import_node_fs3.default.writeFileSync(tmp, `${JSON.stringify(notice)}
|
|
1052
1083
|
`, "utf8");
|
|
1053
|
-
|
|
1084
|
+
import_node_fs3.default.renameSync(tmp, runtimeUpgradeNoticePath());
|
|
1054
1085
|
}
|
|
1055
1086
|
function ensureSootsimHome() {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1087
|
+
import_node_fs3.default.mkdirSync(sootsimHomeDir(), { recursive: true });
|
|
1088
|
+
import_node_fs3.default.mkdirSync(runtimesDir(), { recursive: true });
|
|
1089
|
+
import_node_fs3.default.mkdirSync(electronDir(), { recursive: true });
|
|
1090
|
+
import_node_fs3.default.mkdirSync(profilesDir(), { recursive: true });
|
|
1091
|
+
import_node_fs3.default.mkdirSync(cacheDir(), { recursive: true });
|
|
1061
1092
|
}
|
|
1062
1093
|
function readActiveRuntime() {
|
|
1063
1094
|
try {
|
|
1064
|
-
const value =
|
|
1095
|
+
const value = import_node_fs3.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
1065
1096
|
return value.length > 0 ? value : null;
|
|
1066
1097
|
} catch {
|
|
1067
1098
|
return null;
|
|
1068
1099
|
}
|
|
1069
1100
|
}
|
|
1070
1101
|
function writeActiveRuntime(version) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1102
|
+
import_node_fs3.default.mkdirSync(runtimesDir(), { recursive: true });
|
|
1103
|
+
import_node_fs3.default.writeFileSync(activeRuntimeFile(), `${version}
|
|
1073
1104
|
`, "utf8");
|
|
1074
1105
|
}
|
|
1075
1106
|
function activeRuntimeDir() {
|
|
@@ -1077,7 +1108,7 @@ function activeRuntimeDir() {
|
|
|
1077
1108
|
if (!version) return null;
|
|
1078
1109
|
const dir = runtimeDir(version);
|
|
1079
1110
|
try {
|
|
1080
|
-
if (
|
|
1111
|
+
if (import_node_fs3.default.statSync(dir).isDirectory()) return dir;
|
|
1081
1112
|
} catch {
|
|
1082
1113
|
}
|
|
1083
1114
|
return null;
|
|
@@ -1085,10 +1116,10 @@ function activeRuntimeDir() {
|
|
|
1085
1116
|
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
1086
1117
|
function readDaemonLockfile() {
|
|
1087
1118
|
try {
|
|
1088
|
-
const fd =
|
|
1119
|
+
const fd = import_node_fs3.default.openSync(daemonLockfilePath(), "r");
|
|
1089
1120
|
try {
|
|
1090
1121
|
const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
|
|
1091
|
-
const bytesRead =
|
|
1122
|
+
const bytesRead = import_node_fs3.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
|
|
1092
1123
|
const raw = buf.subarray(0, bytesRead).toString("utf8");
|
|
1093
1124
|
const parsed = JSON.parse(raw);
|
|
1094
1125
|
if (parsed && parsed.schema === 1 && typeof parsed.pid === "number" && typeof parsed.bridgePort === "number" && typeof parsed.runtimePort === "number" && typeof parsed.startedAt === "number" && typeof parsed.heartbeatAt === "number" && (parsed.servedRuntimes === void 0 || Array.isArray(parsed.servedRuntimes) && parsed.servedRuntimes.every((version) => typeof version === "string"))) {
|
|
@@ -1096,7 +1127,7 @@ function readDaemonLockfile() {
|
|
|
1096
1127
|
}
|
|
1097
1128
|
return null;
|
|
1098
1129
|
} finally {
|
|
1099
|
-
|
|
1130
|
+
import_node_fs3.default.closeSync(fd);
|
|
1100
1131
|
}
|
|
1101
1132
|
} catch {
|
|
1102
1133
|
return null;
|
|
@@ -1115,16 +1146,16 @@ function isDaemonLockfileFresh(lock, now = Date.now()) {
|
|
|
1115
1146
|
function writeDaemonLockfile(data) {
|
|
1116
1147
|
ensureSootsimHome();
|
|
1117
1148
|
const tmp = `${daemonLockfilePath()}.tmp`;
|
|
1118
|
-
|
|
1149
|
+
import_node_fs3.default.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}
|
|
1119
1150
|
`, "utf8");
|
|
1120
|
-
|
|
1151
|
+
import_node_fs3.default.renameSync(tmp, daemonLockfilePath());
|
|
1121
1152
|
}
|
|
1122
1153
|
function writeDevBridgeLockfile(data) {
|
|
1123
1154
|
ensureSootsimHome();
|
|
1124
1155
|
const tmp = `${devBridgeLockfilePath()}.tmp`;
|
|
1125
|
-
|
|
1156
|
+
import_node_fs3.default.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}
|
|
1126
1157
|
`, "utf8");
|
|
1127
|
-
|
|
1158
|
+
import_node_fs3.default.renameSync(tmp, devBridgeLockfilePath());
|
|
1128
1159
|
}
|
|
1129
1160
|
function claimDaemonLockfile(data) {
|
|
1130
1161
|
ensureSootsimHome();
|
|
@@ -1137,13 +1168,13 @@ function claimDaemonLockfile(data) {
|
|
|
1137
1168
|
}
|
|
1138
1169
|
function removeDaemonLockfile() {
|
|
1139
1170
|
try {
|
|
1140
|
-
|
|
1171
|
+
import_node_fs3.default.unlinkSync(daemonLockfilePath());
|
|
1141
1172
|
} catch {
|
|
1142
1173
|
}
|
|
1143
1174
|
}
|
|
1144
1175
|
function removeDevBridgeLockfile() {
|
|
1145
1176
|
try {
|
|
1146
|
-
|
|
1177
|
+
import_node_fs3.default.unlinkSync(devBridgeLockfilePath());
|
|
1147
1178
|
} catch {
|
|
1148
1179
|
}
|
|
1149
1180
|
}
|
|
@@ -1156,27 +1187,27 @@ var import_url = require("url");
|
|
|
1156
1187
|
// ../contrast-runtime-delivery/src/index.ts
|
|
1157
1188
|
var import_node_child_process = require("node:child_process");
|
|
1158
1189
|
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
1159
|
-
var
|
|
1190
|
+
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
1160
1191
|
var import_node_os2 = __toESM(require("node:os"), 1);
|
|
1161
|
-
var
|
|
1192
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
1162
1193
|
var import_node_stream = require("node:stream");
|
|
1163
1194
|
var import_promises3 = require("node:stream/promises");
|
|
1164
1195
|
|
|
1165
1196
|
// ../contrast-runtime-delivery/src/product.ts
|
|
1166
|
-
var
|
|
1167
|
-
var
|
|
1197
|
+
var import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
1198
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
1168
1199
|
function isValidRuntimeVersion(value) {
|
|
1169
1200
|
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
1170
1201
|
}
|
|
1171
1202
|
function listInstalledRuntimes(product) {
|
|
1172
1203
|
try {
|
|
1173
|
-
return
|
|
1204
|
+
return import_node_fs4.default.readdirSync(product.runtimesDir(), { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort(compareSemver);
|
|
1174
1205
|
} catch {
|
|
1175
1206
|
return [];
|
|
1176
1207
|
}
|
|
1177
1208
|
}
|
|
1178
1209
|
function runtimeTarballCacheName(product, version) {
|
|
1179
|
-
return
|
|
1210
|
+
return import_node_path4.default.posix.basename(product.tarballPath(version));
|
|
1180
1211
|
}
|
|
1181
1212
|
function compareSemver(a, b) {
|
|
1182
1213
|
const parse = (v) => {
|
|
@@ -1206,7 +1237,7 @@ function createRuntimeDelivery(product) {
|
|
|
1206
1237
|
function readConfig() {
|
|
1207
1238
|
try {
|
|
1208
1239
|
const parsed = JSON.parse(
|
|
1209
|
-
|
|
1240
|
+
import_node_fs5.default.readFileSync(product.configFile(), "utf8")
|
|
1210
1241
|
);
|
|
1211
1242
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
1212
1243
|
} catch {
|
|
@@ -1273,7 +1304,7 @@ function createRuntimeDelivery(product) {
|
|
|
1273
1304
|
const setActive = opts.setActive !== false;
|
|
1274
1305
|
const protectVersions = [version, ...opts.protectVersions ?? []];
|
|
1275
1306
|
pruneLocalRetention({ protectVersions });
|
|
1276
|
-
if (!opts.force &&
|
|
1307
|
+
if (!opts.force && import_node_fs5.default.existsSync(import_node_path5.default.join(destDir, product.installedMarker))) {
|
|
1277
1308
|
if (setActive) product.writeActiveRuntime(version);
|
|
1278
1309
|
pruneLocalRetention({ protectVersions });
|
|
1279
1310
|
return {
|
|
@@ -1287,18 +1318,18 @@ function createRuntimeDelivery(product) {
|
|
|
1287
1318
|
};
|
|
1288
1319
|
}
|
|
1289
1320
|
const tarUrl = entry.tarball || tarballUrl(version, cdnOrigin);
|
|
1290
|
-
const downloadDir =
|
|
1291
|
-
|
|
1321
|
+
const downloadDir = import_node_fs5.default.mkdtempSync(
|
|
1322
|
+
import_node_path5.default.join(import_node_os2.default.tmpdir(), `${product.id}-runtime-download-`)
|
|
1292
1323
|
);
|
|
1293
|
-
const runtimeArchivePath =
|
|
1324
|
+
const runtimeArchivePath = import_node_path5.default.join(
|
|
1294
1325
|
downloadDir,
|
|
1295
1326
|
runtimeTarballCacheName(product, version)
|
|
1296
1327
|
);
|
|
1297
|
-
const tmpDir =
|
|
1298
|
-
|
|
1328
|
+
const tmpDir = import_node_path5.default.join(
|
|
1329
|
+
import_node_path5.default.dirname(destDir),
|
|
1299
1330
|
`.installing-${version}-${process.pid}`
|
|
1300
1331
|
);
|
|
1301
|
-
|
|
1332
|
+
import_node_fs5.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
1302
1333
|
try {
|
|
1303
1334
|
process.stderr.write(`${product.id}: downloading runtime ${version}\u2026
|
|
1304
1335
|
`);
|
|
@@ -1311,20 +1342,20 @@ function createRuntimeDelivery(product) {
|
|
|
1311
1342
|
`sha256 mismatch for runtime ${version}: expected ${entry.sha256}, actual ${actualSha}`
|
|
1312
1343
|
);
|
|
1313
1344
|
}
|
|
1314
|
-
|
|
1345
|
+
import_node_fs5.default.mkdirSync(tmpDir, { recursive: true });
|
|
1315
1346
|
await extractTarball(runtimeArchivePath, tmpDir);
|
|
1316
|
-
if (!
|
|
1347
|
+
if (!import_node_fs5.default.existsSync(import_node_path5.default.join(tmpDir, product.installedMarker))) {
|
|
1317
1348
|
throw new Error(
|
|
1318
1349
|
`extracted tarball for runtime ${version} is missing ${product.installedMarker}`
|
|
1319
1350
|
);
|
|
1320
1351
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1352
|
+
import_node_fs5.default.rmSync(destDir, { recursive: true, force: true });
|
|
1353
|
+
import_node_fs5.default.renameSync(tmpDir, destDir);
|
|
1323
1354
|
} catch (err) {
|
|
1324
|
-
|
|
1355
|
+
import_node_fs5.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
1325
1356
|
throw err;
|
|
1326
1357
|
} finally {
|
|
1327
|
-
|
|
1358
|
+
import_node_fs5.default.rmSync(downloadDir, { recursive: true, force: true });
|
|
1328
1359
|
}
|
|
1329
1360
|
if (setActive) product.writeActiveRuntime(version);
|
|
1330
1361
|
pruneLocalRetention({ protectVersions });
|
|
@@ -1346,8 +1377,8 @@ function createRuntimeDelivery(product) {
|
|
|
1346
1377
|
const pin = resolvePin();
|
|
1347
1378
|
if (pin) {
|
|
1348
1379
|
const activeVersion2 = product.readActiveRuntime();
|
|
1349
|
-
const pinInstalled =
|
|
1350
|
-
|
|
1380
|
+
const pinInstalled = import_node_fs5.default.existsSync(
|
|
1381
|
+
import_node_path5.default.join(product.runtimeDir(pin), product.installedMarker)
|
|
1351
1382
|
);
|
|
1352
1383
|
if (activeVersion2 === pin && pinInstalled) {
|
|
1353
1384
|
return {
|
|
@@ -1396,7 +1427,7 @@ function createRuntimeDelivery(product) {
|
|
|
1396
1427
|
}
|
|
1397
1428
|
const activeVersion = product.readActiveRuntime();
|
|
1398
1429
|
const activeDir = activeVersion ? product.runtimeDir(activeVersion) : null;
|
|
1399
|
-
const activeInstalled = activeDir ?
|
|
1430
|
+
const activeInstalled = activeDir ? import_node_fs5.default.existsSync(import_node_path5.default.join(activeDir, product.installedMarker)) : false;
|
|
1400
1431
|
const shouldInstall = !activeVersion || !activeInstalled || compareSemver(latestVersion, activeVersion) > 0;
|
|
1401
1432
|
if (!shouldInstall) {
|
|
1402
1433
|
return {
|
|
@@ -1468,12 +1499,12 @@ function createRuntimeDelivery(product) {
|
|
|
1468
1499
|
let removeCacheFiles = [];
|
|
1469
1500
|
if (markerOffset >= 0) {
|
|
1470
1501
|
try {
|
|
1471
|
-
removeCacheFiles =
|
|
1502
|
+
removeCacheFiles = import_node_fs5.default.readdirSync(product.cacheDir(), { withFileTypes: true }).filter((entry) => {
|
|
1472
1503
|
if (!entry.isFile()) return false;
|
|
1473
1504
|
const complete = entry.name.startsWith(cachePrefix) && entry.name.endsWith(cacheSuffix);
|
|
1474
1505
|
const partial = entry.name.startsWith(cachePrefix) && entry.name.endsWith(`${cacheSuffix}.partial`);
|
|
1475
1506
|
return complete || partial;
|
|
1476
|
-
}).map((entry) =>
|
|
1507
|
+
}).map((entry) => import_node_path5.default.join(product.cacheDir(), entry.name)).sort();
|
|
1477
1508
|
} catch {
|
|
1478
1509
|
}
|
|
1479
1510
|
}
|
|
@@ -1488,10 +1519,10 @@ function createRuntimeDelivery(product) {
|
|
|
1488
1519
|
function pruneLocalRetention(opts = {}) {
|
|
1489
1520
|
const plan = planLocalRetention(opts);
|
|
1490
1521
|
for (const version of plan.removeVersions) {
|
|
1491
|
-
|
|
1522
|
+
import_node_fs5.default.rmSync(product.runtimeDir(version), { recursive: true, force: true });
|
|
1492
1523
|
}
|
|
1493
1524
|
for (const cacheFile of plan.removeCacheFiles) {
|
|
1494
|
-
|
|
1525
|
+
import_node_fs5.default.rmSync(cacheFile, { force: true });
|
|
1495
1526
|
}
|
|
1496
1527
|
return plan;
|
|
1497
1528
|
}
|
|
@@ -1517,17 +1548,17 @@ async function downloadToFile(url, destPath) {
|
|
|
1517
1548
|
if (!res.ok || !res.body) {
|
|
1518
1549
|
throw new Error(`download failed: ${res.status} ${res.statusText} (${url})`);
|
|
1519
1550
|
}
|
|
1520
|
-
|
|
1551
|
+
import_node_fs5.default.mkdirSync(import_node_path5.default.dirname(destPath), { recursive: true });
|
|
1521
1552
|
const tmp = `${destPath}.partial`;
|
|
1522
1553
|
try {
|
|
1523
1554
|
await (0, import_promises3.pipeline)(
|
|
1524
1555
|
import_node_stream.Readable.fromWeb(res.body),
|
|
1525
|
-
|
|
1556
|
+
import_node_fs5.default.createWriteStream(tmp)
|
|
1526
1557
|
);
|
|
1527
|
-
|
|
1558
|
+
import_node_fs5.default.renameSync(tmp, destPath);
|
|
1528
1559
|
} catch (err) {
|
|
1529
1560
|
try {
|
|
1530
|
-
|
|
1561
|
+
import_node_fs5.default.unlinkSync(tmp);
|
|
1531
1562
|
} catch {
|
|
1532
1563
|
}
|
|
1533
1564
|
throw err;
|
|
@@ -1536,7 +1567,7 @@ async function downloadToFile(url, destPath) {
|
|
|
1536
1567
|
function sha256File(filePath) {
|
|
1537
1568
|
return new Promise((resolve, reject) => {
|
|
1538
1569
|
const hash = import_node_crypto.default.createHash("sha256");
|
|
1539
|
-
const stream =
|
|
1570
|
+
const stream = import_node_fs5.default.createReadStream(filePath);
|
|
1540
1571
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
1541
1572
|
stream.on("error", reject);
|
|
1542
1573
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
@@ -1628,14 +1659,14 @@ var SOOTSIM_RUNTIME_PRODUCT = {
|
|
|
1628
1659
|
var sootsimRuntime = createRuntimeDelivery(SOOTSIM_RUNTIME_PRODUCT);
|
|
1629
1660
|
|
|
1630
1661
|
// src/host/agent-host.ts
|
|
1631
|
-
var
|
|
1632
|
-
var
|
|
1662
|
+
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
1663
|
+
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
1633
1664
|
|
|
1634
1665
|
// src/agent-sessions.ts
|
|
1635
1666
|
var import_node_child_process2 = require("node:child_process");
|
|
1636
1667
|
var import_node_crypto3 = require("node:crypto");
|
|
1637
|
-
var
|
|
1638
|
-
var
|
|
1668
|
+
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
1669
|
+
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
1639
1670
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
1640
1671
|
|
|
1641
1672
|
// src/agent-events.ts
|
|
@@ -1679,8 +1710,8 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
1679
1710
|
|
|
1680
1711
|
// src/attached-projects.ts
|
|
1681
1712
|
var import_node_crypto2 = require("node:crypto");
|
|
1682
|
-
var
|
|
1683
|
-
var
|
|
1713
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
1714
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
1684
1715
|
var overrideDir = null;
|
|
1685
1716
|
function userDataDir() {
|
|
1686
1717
|
if (overrideDir) return overrideDir;
|
|
@@ -1692,7 +1723,7 @@ function getUserDataDir() {
|
|
|
1692
1723
|
return userDataDir();
|
|
1693
1724
|
}
|
|
1694
1725
|
function storeFile() {
|
|
1695
|
-
return
|
|
1726
|
+
return import_node_path6.default.join(userDataDir(), "attached-projects.json");
|
|
1696
1727
|
}
|
|
1697
1728
|
function cloneEmpty() {
|
|
1698
1729
|
return {
|
|
@@ -1706,7 +1737,7 @@ function loadStore() {
|
|
|
1706
1737
|
const file = storeFile();
|
|
1707
1738
|
let raw;
|
|
1708
1739
|
try {
|
|
1709
|
-
raw =
|
|
1740
|
+
raw = import_node_fs6.default.readFileSync(file, "utf8");
|
|
1710
1741
|
} catch (err) {
|
|
1711
1742
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
1712
1743
|
throw err;
|
|
@@ -1723,7 +1754,7 @@ function loadStore() {
|
|
|
1723
1754
|
} catch (err) {
|
|
1724
1755
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
1725
1756
|
try {
|
|
1726
|
-
|
|
1757
|
+
import_node_fs6.default.renameSync(file, quarantine);
|
|
1727
1758
|
console.warn(
|
|
1728
1759
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
1729
1760
|
);
|
|
@@ -1734,16 +1765,16 @@ function loadStore() {
|
|
|
1734
1765
|
}
|
|
1735
1766
|
function writeStore(store) {
|
|
1736
1767
|
const file = storeFile();
|
|
1737
|
-
|
|
1768
|
+
import_node_fs6.default.mkdirSync(import_node_path6.default.dirname(file), { recursive: true });
|
|
1738
1769
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
1739
|
-
const fd =
|
|
1770
|
+
const fd = import_node_fs6.default.openSync(tmp, "w", 384);
|
|
1740
1771
|
try {
|
|
1741
|
-
|
|
1742
|
-
|
|
1772
|
+
import_node_fs6.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
1773
|
+
import_node_fs6.default.fsyncSync(fd);
|
|
1743
1774
|
} finally {
|
|
1744
|
-
|
|
1775
|
+
import_node_fs6.default.closeSync(fd);
|
|
1745
1776
|
}
|
|
1746
|
-
|
|
1777
|
+
import_node_fs6.default.renameSync(tmp, file);
|
|
1747
1778
|
}
|
|
1748
1779
|
function mutateStore(fn) {
|
|
1749
1780
|
const store = loadStore();
|
|
@@ -1752,13 +1783,13 @@ function mutateStore(fn) {
|
|
|
1752
1783
|
return store;
|
|
1753
1784
|
}
|
|
1754
1785
|
function projectIdForCwd(cwd) {
|
|
1755
|
-
return (0, import_node_crypto2.createHash)("sha256").update(
|
|
1786
|
+
return (0, import_node_crypto2.createHash)("sha256").update(import_node_path6.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
1756
1787
|
}
|
|
1757
1788
|
function newSessionId() {
|
|
1758
1789
|
return `s_${(0, import_node_crypto2.randomBytes)(10).toString("hex")}`;
|
|
1759
1790
|
}
|
|
1760
1791
|
function upsertProject(input) {
|
|
1761
|
-
const cwd =
|
|
1792
|
+
const cwd = import_node_path6.default.resolve(input.cwd);
|
|
1762
1793
|
const id = projectIdForCwd(cwd);
|
|
1763
1794
|
let result;
|
|
1764
1795
|
mutateStore((store) => {
|
|
@@ -1784,7 +1815,7 @@ function upsertProject(input) {
|
|
|
1784
1815
|
const now = Date.now();
|
|
1785
1816
|
const created = {
|
|
1786
1817
|
id,
|
|
1787
|
-
name: input.name ??
|
|
1818
|
+
name: input.name ?? import_node_path6.default.basename(cwd),
|
|
1788
1819
|
cwd,
|
|
1789
1820
|
repoRoot: input.repoRoot,
|
|
1790
1821
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -1930,8 +1961,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
1930
1961
|
if (apps.length === 0) return;
|
|
1931
1962
|
mutateStore((store) => {
|
|
1932
1963
|
for (const app of apps) {
|
|
1933
|
-
if (!
|
|
1934
|
-
const cwd =
|
|
1964
|
+
if (!import_node_fs6.default.existsSync(app.dir)) continue;
|
|
1965
|
+
const cwd = import_node_path6.default.resolve(app.dir);
|
|
1935
1966
|
const id = projectIdForCwd(cwd);
|
|
1936
1967
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
1937
1968
|
const now = Date.now();
|
|
@@ -1955,16 +1986,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
1955
1986
|
|
|
1956
1987
|
// src/agent-sessions.ts
|
|
1957
1988
|
function sessionDir(sessionId) {
|
|
1958
|
-
return
|
|
1989
|
+
return import_node_path7.default.join(getUserDataDir(), "sessions", sessionId);
|
|
1959
1990
|
}
|
|
1960
1991
|
function promptFifoPath(sessionId) {
|
|
1961
|
-
return
|
|
1992
|
+
return import_node_path7.default.join(sessionDir(sessionId), "prompt.in");
|
|
1962
1993
|
}
|
|
1963
1994
|
function eventsFifoPath(sessionId) {
|
|
1964
|
-
return
|
|
1995
|
+
return import_node_path7.default.join(sessionDir(sessionId), "events.out");
|
|
1965
1996
|
}
|
|
1966
1997
|
function transcriptPath(sessionId) {
|
|
1967
|
-
return
|
|
1998
|
+
return import_node_path7.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
1968
1999
|
}
|
|
1969
2000
|
function pidIsAlive(pid, sessionId) {
|
|
1970
2001
|
if (!pid) return false;
|
|
@@ -1974,7 +2005,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
1974
2005
|
return false;
|
|
1975
2006
|
}
|
|
1976
2007
|
if (sessionId) {
|
|
1977
|
-
if (!
|
|
2008
|
+
if (!import_node_fs7.default.existsSync(sessionDir(sessionId))) return false;
|
|
1978
2009
|
}
|
|
1979
2010
|
return true;
|
|
1980
2011
|
}
|
|
@@ -1986,11 +2017,11 @@ function resolveSootsimInvocation() {
|
|
|
1986
2017
|
const resourcesPath = process.resourcesPath;
|
|
1987
2018
|
if (resourcesPath) {
|
|
1988
2019
|
const candidates = [
|
|
1989
|
-
|
|
1990
|
-
|
|
2020
|
+
import_node_path7.default.join(resourcesPath, "bin", "sootsim"),
|
|
2021
|
+
import_node_path7.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
1991
2022
|
];
|
|
1992
2023
|
for (const c of candidates) {
|
|
1993
|
-
if (
|
|
2024
|
+
if (import_node_fs7.default.existsSync(c)) return { cmd: c, prefixArgs: [] };
|
|
1994
2025
|
}
|
|
1995
2026
|
}
|
|
1996
2027
|
}
|
|
@@ -2013,15 +2044,15 @@ function tryWorkspaceSootsim() {
|
|
|
2013
2044
|
const sootsimDir = resolveSootsimPackageDir();
|
|
2014
2045
|
if (!sootsimDir) return null;
|
|
2015
2046
|
const binaryName = `sootsim-${process.platform}-${process.arch}`;
|
|
2016
|
-
const distBinary =
|
|
2017
|
-
if (
|
|
2018
|
-
const distBin =
|
|
2019
|
-
if (
|
|
2047
|
+
const distBinary = import_node_path7.default.join(sootsimDir, "dist-bin", binaryName);
|
|
2048
|
+
if (import_node_fs7.default.existsSync(distBinary)) return { cmd: distBinary, prefixArgs: [] };
|
|
2049
|
+
const distBin = import_node_path7.default.join(sootsimDir, "dist-cli", "bin.js");
|
|
2050
|
+
if (import_node_fs7.default.existsSync(distBin)) {
|
|
2020
2051
|
try {
|
|
2021
|
-
const src =
|
|
2022
|
-
if (
|
|
2023
|
-
const srcMtime =
|
|
2024
|
-
const buildMtime =
|
|
2052
|
+
const src = import_node_path7.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
|
|
2053
|
+
if (import_node_fs7.default.existsSync(src)) {
|
|
2054
|
+
const srcMtime = import_node_fs7.default.statSync(src).mtimeMs;
|
|
2055
|
+
const buildMtime = import_node_fs7.default.statSync(distBin).mtimeMs;
|
|
2025
2056
|
if (buildMtime < srcMtime) {
|
|
2026
2057
|
console.warn(
|
|
2027
2058
|
`[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/sootsim build:cli\`.`
|
|
@@ -2040,22 +2071,22 @@ function tryWorkspaceSootsim() {
|
|
|
2040
2071
|
function resolveSootsimPackageDir() {
|
|
2041
2072
|
try {
|
|
2042
2073
|
const resolved = require.resolve("sootsim/package.json");
|
|
2043
|
-
return
|
|
2074
|
+
return import_node_path7.default.dirname(resolved);
|
|
2044
2075
|
} catch {
|
|
2045
2076
|
}
|
|
2046
2077
|
const here = fileFromImportMeta();
|
|
2047
2078
|
if (!here) return null;
|
|
2048
|
-
let cur =
|
|
2079
|
+
let cur = import_node_path7.default.dirname(here);
|
|
2049
2080
|
for (let i = 0; i < 8; i++) {
|
|
2050
|
-
const pkg =
|
|
2081
|
+
const pkg = import_node_path7.default.join(cur, "package.json");
|
|
2051
2082
|
try {
|
|
2052
|
-
if (
|
|
2053
|
-
const parsed = JSON.parse(
|
|
2083
|
+
if (import_node_fs7.default.existsSync(pkg)) {
|
|
2084
|
+
const parsed = JSON.parse(import_node_fs7.default.readFileSync(pkg, "utf8"));
|
|
2054
2085
|
if (parsed.name === "sootsim") return cur;
|
|
2055
2086
|
}
|
|
2056
2087
|
} catch {
|
|
2057
2088
|
}
|
|
2058
|
-
const parent =
|
|
2089
|
+
const parent = import_node_path7.default.dirname(cur);
|
|
2059
2090
|
if (parent === cur) break;
|
|
2060
2091
|
cur = parent;
|
|
2061
2092
|
}
|
|
@@ -2071,28 +2102,28 @@ function fileFromImportMeta() {
|
|
|
2071
2102
|
}
|
|
2072
2103
|
}
|
|
2073
2104
|
async function withStartLock(projectId, provider, fn) {
|
|
2074
|
-
const lockDir =
|
|
2075
|
-
|
|
2105
|
+
const lockDir = import_node_path7.default.join(getUserDataDir(), "locks");
|
|
2106
|
+
import_node_fs7.default.mkdirSync(lockDir, { recursive: true });
|
|
2076
2107
|
try {
|
|
2077
|
-
|
|
2108
|
+
import_node_fs7.default.chmodSync(lockDir, 448);
|
|
2078
2109
|
} catch {
|
|
2079
2110
|
}
|
|
2080
|
-
const lockPath =
|
|
2111
|
+
const lockPath = import_node_path7.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
2081
2112
|
const deadline = Date.now() + 4e3;
|
|
2082
2113
|
let fd = null;
|
|
2083
2114
|
while (fd === null) {
|
|
2084
2115
|
try {
|
|
2085
|
-
fd =
|
|
2116
|
+
fd = import_node_fs7.default.openSync(
|
|
2086
2117
|
lockPath,
|
|
2087
|
-
|
|
2118
|
+
import_node_fs7.constants.O_WRONLY | import_node_fs7.constants.O_CREAT | import_node_fs7.constants.O_EXCL,
|
|
2088
2119
|
384
|
|
2089
2120
|
);
|
|
2090
2121
|
} catch (err) {
|
|
2091
2122
|
if (err.code !== "EEXIST") throw err;
|
|
2092
2123
|
try {
|
|
2093
|
-
const stale = Number(
|
|
2124
|
+
const stale = Number(import_node_fs7.default.readFileSync(lockPath, "utf8").trim());
|
|
2094
2125
|
if (stale && !isProcessAlive(stale)) {
|
|
2095
|
-
|
|
2126
|
+
import_node_fs7.default.unlinkSync(lockPath);
|
|
2096
2127
|
continue;
|
|
2097
2128
|
}
|
|
2098
2129
|
} catch {
|
|
@@ -2106,15 +2137,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
2106
2137
|
}
|
|
2107
2138
|
}
|
|
2108
2139
|
try {
|
|
2109
|
-
|
|
2140
|
+
import_node_fs7.default.writeFileSync(fd, String(process.pid));
|
|
2110
2141
|
return await fn();
|
|
2111
2142
|
} finally {
|
|
2112
2143
|
try {
|
|
2113
|
-
|
|
2144
|
+
import_node_fs7.default.closeSync(fd);
|
|
2114
2145
|
} catch {
|
|
2115
2146
|
}
|
|
2116
2147
|
try {
|
|
2117
|
-
|
|
2148
|
+
import_node_fs7.default.unlinkSync(lockPath);
|
|
2118
2149
|
} catch {
|
|
2119
2150
|
}
|
|
2120
2151
|
}
|
|
@@ -2128,25 +2159,25 @@ function isProcessAlive(pid) {
|
|
|
2128
2159
|
}
|
|
2129
2160
|
}
|
|
2130
2161
|
function mkfifoSync(p) {
|
|
2131
|
-
const parent =
|
|
2132
|
-
|
|
2162
|
+
const parent = import_node_path7.default.dirname(p);
|
|
2163
|
+
import_node_fs7.default.mkdirSync(parent, { recursive: true });
|
|
2133
2164
|
try {
|
|
2134
|
-
|
|
2165
|
+
import_node_fs7.default.chmodSync(parent, 448);
|
|
2135
2166
|
} catch {
|
|
2136
2167
|
}
|
|
2137
|
-
if (
|
|
2168
|
+
if (import_node_fs7.default.existsSync(p)) {
|
|
2138
2169
|
try {
|
|
2139
|
-
const stat2 =
|
|
2170
|
+
const stat2 = import_node_fs7.default.statSync(p);
|
|
2140
2171
|
if (stat2.isFIFO()) {
|
|
2141
2172
|
try {
|
|
2142
|
-
|
|
2173
|
+
import_node_fs7.default.chmodSync(p, 384);
|
|
2143
2174
|
} catch {
|
|
2144
2175
|
}
|
|
2145
2176
|
return;
|
|
2146
2177
|
}
|
|
2147
|
-
|
|
2178
|
+
import_node_fs7.default.unlinkSync(p);
|
|
2148
2179
|
} catch {
|
|
2149
|
-
|
|
2180
|
+
import_node_fs7.default.unlinkSync(p);
|
|
2150
2181
|
}
|
|
2151
2182
|
}
|
|
2152
2183
|
const result = (0, import_node_child_process2.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
@@ -2193,10 +2224,10 @@ async function startSession(opts) {
|
|
|
2193
2224
|
const transcript = transcriptPath(session.id);
|
|
2194
2225
|
mkfifoSync(promptIn);
|
|
2195
2226
|
mkfifoSync(eventsOut);
|
|
2196
|
-
const transcriptDir =
|
|
2197
|
-
|
|
2227
|
+
const transcriptDir = import_node_path7.default.dirname(transcript);
|
|
2228
|
+
import_node_fs7.default.mkdirSync(transcriptDir, { recursive: true });
|
|
2198
2229
|
try {
|
|
2199
|
-
|
|
2230
|
+
import_node_fs7.default.chmodSync(transcriptDir, 448);
|
|
2200
2231
|
} catch {
|
|
2201
2232
|
}
|
|
2202
2233
|
const { cmd, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -2247,7 +2278,7 @@ async function startSession(opts) {
|
|
|
2247
2278
|
}
|
|
2248
2279
|
}
|
|
2249
2280
|
try {
|
|
2250
|
-
|
|
2281
|
+
import_node_fs7.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
2251
2282
|
} catch {
|
|
2252
2283
|
}
|
|
2253
2284
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -2275,18 +2306,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
2275
2306
|
);
|
|
2276
2307
|
}
|
|
2277
2308
|
const fifo = promptFifoPath(sessionId);
|
|
2278
|
-
if (!
|
|
2309
|
+
if (!import_node_fs7.default.existsSync(fifo)) {
|
|
2279
2310
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
2280
2311
|
}
|
|
2281
|
-
const fd =
|
|
2312
|
+
const fd = import_node_fs7.default.openSync(fifo, import_node_fs7.constants.O_WRONLY);
|
|
2282
2313
|
try {
|
|
2283
2314
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
2284
2315
|
if (!wireText) {
|
|
2285
2316
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
2286
2317
|
}
|
|
2287
|
-
|
|
2318
|
+
import_node_fs7.default.writeSync(fd, wireText + "\n");
|
|
2288
2319
|
} finally {
|
|
2289
|
-
|
|
2320
|
+
import_node_fs7.default.closeSync(fd);
|
|
2290
2321
|
}
|
|
2291
2322
|
updateSessionStatus(sessionId, {
|
|
2292
2323
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -2308,7 +2339,7 @@ async function endSession(sessionId) {
|
|
|
2308
2339
|
const base = getUserDataDir();
|
|
2309
2340
|
if (dir.startsWith(base)) {
|
|
2310
2341
|
try {
|
|
2311
|
-
|
|
2342
|
+
import_node_fs7.default.rmSync(dir, { recursive: true, force: true });
|
|
2312
2343
|
} catch {
|
|
2313
2344
|
}
|
|
2314
2345
|
}
|
|
@@ -2316,11 +2347,11 @@ async function endSession(sessionId) {
|
|
|
2316
2347
|
}
|
|
2317
2348
|
function subscribeEvents(sessionId, onEvent) {
|
|
2318
2349
|
const fifo = eventsFifoPath(sessionId);
|
|
2319
|
-
if (!
|
|
2350
|
+
if (!import_node_fs7.default.existsSync(fifo)) {
|
|
2320
2351
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
2321
2352
|
}
|
|
2322
|
-
const fd =
|
|
2323
|
-
const stream =
|
|
2353
|
+
const fd = import_node_fs7.default.openSync(fifo, import_node_fs7.constants.O_RDWR);
|
|
2354
|
+
const stream = import_node_fs7.default.createReadStream("", { fd, autoClose: true });
|
|
2324
2355
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
2325
2356
|
rl.on("line", (line) => {
|
|
2326
2357
|
const event = parseAgentEventLine(line);
|
|
@@ -2331,7 +2362,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
2331
2362
|
if (closed) return;
|
|
2332
2363
|
closed = true;
|
|
2333
2364
|
try {
|
|
2334
|
-
|
|
2365
|
+
import_node_fs7.default.writeSync(fd, "\n");
|
|
2335
2366
|
} catch {
|
|
2336
2367
|
}
|
|
2337
2368
|
try {
|
|
@@ -2345,7 +2376,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
2345
2376
|
};
|
|
2346
2377
|
}
|
|
2347
2378
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
2348
|
-
const fd =
|
|
2379
|
+
const fd = import_node_fs7.default.openSync(fifo, import_node_fs7.constants.O_RDWR | import_node_fs7.constants.O_NONBLOCK);
|
|
2349
2380
|
const buf = Buffer.alloc(8192);
|
|
2350
2381
|
let leftover = "";
|
|
2351
2382
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -2353,7 +2384,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
2353
2384
|
while (Date.now() < deadline) {
|
|
2354
2385
|
let n = 0;
|
|
2355
2386
|
try {
|
|
2356
|
-
n =
|
|
2387
|
+
n = import_node_fs7.default.readSync(fd, buf, 0, buf.length, null);
|
|
2357
2388
|
} catch (err) {
|
|
2358
2389
|
if (err.code !== "EAGAIN") throw err;
|
|
2359
2390
|
n = 0;
|
|
@@ -2373,7 +2404,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
2373
2404
|
}
|
|
2374
2405
|
return null;
|
|
2375
2406
|
} finally {
|
|
2376
|
-
|
|
2407
|
+
import_node_fs7.default.closeSync(fd);
|
|
2377
2408
|
}
|
|
2378
2409
|
}
|
|
2379
2410
|
|
|
@@ -2651,7 +2682,7 @@ var AgentHost = class {
|
|
|
2651
2682
|
);
|
|
2652
2683
|
const project = upsertProject({
|
|
2653
2684
|
cwd: match.cwd,
|
|
2654
|
-
name: match.projectName ??
|
|
2685
|
+
name: match.projectName ?? import_node_path8.default.basename(match.cwd),
|
|
2655
2686
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
2656
2687
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
2657
2688
|
knownBundleUrls,
|
|
@@ -2662,18 +2693,18 @@ var AgentHost = class {
|
|
|
2662
2693
|
}
|
|
2663
2694
|
getTranscript(sessionId) {
|
|
2664
2695
|
const p = transcriptPath(sessionId);
|
|
2665
|
-
if (!
|
|
2696
|
+
if (!import_node_fs8.default.existsSync(p)) {
|
|
2666
2697
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
2667
2698
|
}
|
|
2668
|
-
return
|
|
2699
|
+
return import_node_fs8.default.readFileSync(p, "utf8");
|
|
2669
2700
|
}
|
|
2670
2701
|
getPaths() {
|
|
2671
2702
|
const dir = getUserDataDir();
|
|
2672
2703
|
return {
|
|
2673
2704
|
userDataDir: dir,
|
|
2674
|
-
storeFile:
|
|
2675
|
-
sessionsDir:
|
|
2676
|
-
transcriptsDir:
|
|
2705
|
+
storeFile: import_node_path8.default.join(dir, "attached-projects.json"),
|
|
2706
|
+
sessionsDir: import_node_path8.default.join(dir, "sessions"),
|
|
2707
|
+
transcriptsDir: import_node_path8.default.join(dir, "transcripts")
|
|
2677
2708
|
};
|
|
2678
2709
|
}
|
|
2679
2710
|
// --- subscription management ---
|
|
@@ -3294,86 +3325,9 @@ function handleAppApiRequest(req, res) {
|
|
|
3294
3325
|
|
|
3295
3326
|
// src/host/open-url.ts
|
|
3296
3327
|
var import_child_process2 = require("child_process");
|
|
3297
|
-
var import_fs2 = require("fs");
|
|
3298
|
-
var import_os = require("os");
|
|
3299
|
-
var import_path2 = require("path");
|
|
3300
|
-
var MAC_CHROMIUM_CANDIDATES = [
|
|
3301
|
-
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
3302
|
-
"~/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
3303
|
-
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
3304
|
-
"~/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
3305
|
-
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
3306
|
-
"~/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
3307
|
-
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
3308
|
-
"~/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
3309
|
-
"/Applications/Arc.app/Contents/MacOS/Arc",
|
|
3310
|
-
"~/Applications/Arc.app/Contents/MacOS/Arc"
|
|
3311
|
-
];
|
|
3312
|
-
var LINUX_CHROMIUM_CANDIDATES = [
|
|
3313
|
-
"/usr/bin/google-chrome",
|
|
3314
|
-
"/usr/bin/chromium",
|
|
3315
|
-
"/usr/bin/chromium-browser",
|
|
3316
|
-
"/usr/bin/microsoft-edge",
|
|
3317
|
-
"/usr/bin/brave-browser",
|
|
3318
|
-
"/snap/bin/chromium"
|
|
3319
|
-
];
|
|
3320
|
-
var WINDOWS_CHROMIUM_CANDIDATES = [
|
|
3321
|
-
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
3322
|
-
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
|
|
3323
|
-
"C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe",
|
|
3324
|
-
"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
|
|
3325
|
-
"C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe",
|
|
3326
|
-
"C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
|
|
3327
|
-
];
|
|
3328
|
-
var UNIX_CHROMIUM_COMMANDS = [
|
|
3329
|
-
"google-chrome",
|
|
3330
|
-
"chromium",
|
|
3331
|
-
"chromium-browser",
|
|
3332
|
-
"microsoft-edge",
|
|
3333
|
-
"brave-browser"
|
|
3334
|
-
];
|
|
3335
|
-
var WINDOWS_CHROMIUM_COMMANDS = ["chrome", "msedge", "brave"];
|
|
3336
|
-
function expandHome(candidate) {
|
|
3337
|
-
return candidate.startsWith("~/") ? (0, import_path2.join)((0, import_os.homedir)(), candidate.slice(2)) : candidate;
|
|
3338
|
-
}
|
|
3339
|
-
function firstExisting(candidates) {
|
|
3340
|
-
for (const candidate of candidates) {
|
|
3341
|
-
const expanded = expandHome(candidate);
|
|
3342
|
-
if ((0, import_fs2.existsSync)(expanded)) return expanded;
|
|
3343
|
-
}
|
|
3344
|
-
return null;
|
|
3345
|
-
}
|
|
3346
|
-
function lookupExecutable(command, platform) {
|
|
3347
|
-
try {
|
|
3348
|
-
const tool = platform === "win32" ? "where" : "which";
|
|
3349
|
-
const out = (0, import_child_process2.execFileSync)(tool, [command], {
|
|
3350
|
-
encoding: "utf8",
|
|
3351
|
-
timeout: 1500,
|
|
3352
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
3353
|
-
}).trim();
|
|
3354
|
-
return out ? out.split(/\r?\n/)[0] : null;
|
|
3355
|
-
} catch {
|
|
3356
|
-
return null;
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
function resolveChromiumBinary(platform = process.platform) {
|
|
3360
|
-
const envCandidate = process.env.CHROME_PATH || process.env.CHROMIUM_PATH;
|
|
3361
|
-
if (envCandidate && (0, import_fs2.existsSync)(envCandidate)) return envCandidate;
|
|
3362
|
-
const direct = platform === "darwin" ? firstExisting(MAC_CHROMIUM_CANDIDATES) : platform === "win32" ? firstExisting(WINDOWS_CHROMIUM_CANDIDATES) : firstExisting(LINUX_CHROMIUM_CANDIDATES);
|
|
3363
|
-
if (direct) return direct;
|
|
3364
|
-
const commands = platform === "win32" ? WINDOWS_CHROMIUM_COMMANDS : UNIX_CHROMIUM_COMMANDS;
|
|
3365
|
-
for (const command of commands) {
|
|
3366
|
-
const found = lookupExecutable(command, platform);
|
|
3367
|
-
if (found) return found;
|
|
3368
|
-
}
|
|
3369
|
-
return null;
|
|
3370
|
-
}
|
|
3371
3328
|
function buildOpenUrlCommand(url, options = {}) {
|
|
3372
3329
|
if (!url) throw new Error("openUrl requires a url");
|
|
3373
3330
|
const platform = options.platform ?? process.platform;
|
|
3374
|
-
if (options.newWindow) {
|
|
3375
|
-
return buildChromiumUrlCommand(url, { ...options, platform, newWindow: true });
|
|
3376
|
-
}
|
|
3377
3331
|
if (platform === "darwin") {
|
|
3378
3332
|
return {
|
|
3379
3333
|
command: "open",
|
|
@@ -3394,25 +3348,6 @@ function buildOpenUrlCommand(url, options = {}) {
|
|
|
3394
3348
|
via: "system"
|
|
3395
3349
|
};
|
|
3396
3350
|
}
|
|
3397
|
-
function buildChromiumUrlCommand(url, options = {}) {
|
|
3398
|
-
if (!url) throw new Error("openUrl requires a url");
|
|
3399
|
-
const platform = options.platform ?? process.platform;
|
|
3400
|
-
const chromiumBinary = "chromiumBinary" in options ? options.chromiumBinary : resolveChromiumBinary(platform);
|
|
3401
|
-
if (!chromiumBinary) {
|
|
3402
|
-
throw new Error("browser launch requires Chrome, Chromium, Edge, Brave, or Arc");
|
|
3403
|
-
}
|
|
3404
|
-
const args = [];
|
|
3405
|
-
if (options.newWindow !== false) {
|
|
3406
|
-
args.push("--new-window");
|
|
3407
|
-
}
|
|
3408
|
-
args.push(url);
|
|
3409
|
-
return {
|
|
3410
|
-
command: chromiumBinary,
|
|
3411
|
-
args,
|
|
3412
|
-
via: "chromium",
|
|
3413
|
-
target: chromiumBinary
|
|
3414
|
-
};
|
|
3415
|
-
}
|
|
3416
3351
|
async function spawnLaunch(command, args, detached) {
|
|
3417
3352
|
return new Promise((resolve, reject) => {
|
|
3418
3353
|
const child = (0, import_child_process2.spawn)(command, args, {
|
|
@@ -4157,21 +4092,6 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4157
4092
|
}
|
|
4158
4093
|
return;
|
|
4159
4094
|
}
|
|
4160
|
-
if (msg.type === "bridge:open") {
|
|
4161
|
-
if (typeof msg.url !== "string" || !msg.url) {
|
|
4162
|
-
throw new Error("bridge:open requires a url");
|
|
4163
|
-
}
|
|
4164
|
-
await this.openUrl(msg.url, { newWindow: msg.newWindow === true });
|
|
4165
|
-
if (ws.readyState === import_ws2.WebSocket.OPEN) {
|
|
4166
|
-
ws.send(
|
|
4167
|
-
JSON.stringify({
|
|
4168
|
-
id: msg.id,
|
|
4169
|
-
result: { ok: true, url: msg.url }
|
|
4170
|
-
})
|
|
4171
|
-
);
|
|
4172
|
-
}
|
|
4173
|
-
return;
|
|
4174
|
-
}
|
|
4175
4095
|
if (msg.type === "bridge:claim") {
|
|
4176
4096
|
const targetSim2 = await this.waitForSim(msg.simId);
|
|
4177
4097
|
const outcome = this.tryAcquireLease(ws, targetSim2, {
|
|
@@ -4482,7 +4402,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4482
4402
|
}
|
|
4483
4403
|
startRuntimeUpdater() {
|
|
4484
4404
|
if (!this.shouldWriteLockfile || this.runtimeUpdateTimer) return;
|
|
4485
|
-
if (
|
|
4405
|
+
if (import_fs2.default.existsSync(import_path2.default.join(sootsimHomeDir(), "runtime-update-disabled"))) return;
|
|
4486
4406
|
if (process.env.SOOTSIM_HOME && isSootsimDevCheckout() && !readActiveRuntime()) {
|
|
4487
4407
|
return;
|
|
4488
4408
|
}
|
|
@@ -4791,34 +4711,34 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4791
4711
|
return;
|
|
4792
4712
|
}
|
|
4793
4713
|
}
|
|
4794
|
-
const resolved =
|
|
4795
|
-
const baseWithSep = baseDir.endsWith(
|
|
4714
|
+
const resolved = import_path2.default.resolve(baseDir, "." + rel);
|
|
4715
|
+
const baseWithSep = baseDir.endsWith(import_path2.default.sep) ? baseDir : baseDir + import_path2.default.sep;
|
|
4796
4716
|
if (!resolved.startsWith(baseWithSep) && resolved !== baseDir) {
|
|
4797
4717
|
res.writeHead(403);
|
|
4798
4718
|
res.end("forbidden");
|
|
4799
4719
|
return;
|
|
4800
4720
|
}
|
|
4801
|
-
|
|
4721
|
+
import_fs2.default.realpath(resolved, (realErr, realResolved) => {
|
|
4802
4722
|
const servePath = realErr ? resolved : realResolved;
|
|
4803
|
-
const servePathWithSep = servePath.endsWith(
|
|
4723
|
+
const servePathWithSep = servePath.endsWith(import_path2.default.sep) ? servePath : servePath + import_path2.default.sep;
|
|
4804
4724
|
if (!realErr) {
|
|
4805
4725
|
const realBaseWithSep = (() => {
|
|
4806
4726
|
try {
|
|
4807
|
-
const rb =
|
|
4808
|
-
return rb.endsWith(
|
|
4727
|
+
const rb = import_fs2.default.realpathSync(baseDir);
|
|
4728
|
+
return rb.endsWith(import_path2.default.sep) ? rb : rb + import_path2.default.sep;
|
|
4809
4729
|
} catch {
|
|
4810
4730
|
return baseWithSep;
|
|
4811
4731
|
}
|
|
4812
4732
|
})();
|
|
4813
|
-
if (!servePathWithSep.startsWith(realBaseWithSep) && servePath +
|
|
4733
|
+
if (!servePathWithSep.startsWith(realBaseWithSep) && servePath + import_path2.default.sep !== realBaseWithSep) {
|
|
4814
4734
|
res.writeHead(403);
|
|
4815
4735
|
res.end("forbidden");
|
|
4816
4736
|
return;
|
|
4817
4737
|
}
|
|
4818
4738
|
}
|
|
4819
|
-
|
|
4739
|
+
import_fs2.default.stat(servePath, (err, stats) => {
|
|
4820
4740
|
if (err || !stats?.isFile()) {
|
|
4821
|
-
const ext2 =
|
|
4741
|
+
const ext2 = import_path2.default.extname(rel).toLowerCase();
|
|
4822
4742
|
if (ext2 && ext2 !== ".html") {
|
|
4823
4743
|
res.writeHead(404);
|
|
4824
4744
|
res.end("not found");
|
|
@@ -4829,8 +4749,8 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4829
4749
|
res.end("not found");
|
|
4830
4750
|
return;
|
|
4831
4751
|
}
|
|
4832
|
-
const indexPath =
|
|
4833
|
-
|
|
4752
|
+
const indexPath = import_path2.default.join(baseDir, "index.html");
|
|
4753
|
+
import_fs2.default.readFile(indexPath, (err2, data) => {
|
|
4834
4754
|
if (err2) {
|
|
4835
4755
|
res.writeHead(404);
|
|
4836
4756
|
res.end("not found");
|
|
@@ -4850,7 +4770,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4850
4770
|
});
|
|
4851
4771
|
return;
|
|
4852
4772
|
}
|
|
4853
|
-
const ext =
|
|
4773
|
+
const ext = import_path2.default.extname(servePath).toLowerCase();
|
|
4854
4774
|
const contentType = HTTP_MIME_TYPES[ext] || "application/octet-stream";
|
|
4855
4775
|
res.writeHead(200, {
|
|
4856
4776
|
"Content-Type": contentType,
|
|
@@ -4861,7 +4781,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4861
4781
|
return;
|
|
4862
4782
|
}
|
|
4863
4783
|
if (ext === ".html") {
|
|
4864
|
-
|
|
4784
|
+
import_fs2.default.readFile(servePath, (readErr, data) => {
|
|
4865
4785
|
if (readErr) {
|
|
4866
4786
|
try {
|
|
4867
4787
|
res.end();
|
|
@@ -4875,7 +4795,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
4875
4795
|
});
|
|
4876
4796
|
return;
|
|
4877
4797
|
}
|
|
4878
|
-
const stream =
|
|
4798
|
+
const stream = import_fs2.default.createReadStream(servePath);
|
|
4879
4799
|
stream.pipe(res);
|
|
4880
4800
|
stream.on("error", () => {
|
|
4881
4801
|
try {
|