rnxsim 0.0.0 → 0.1.313
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/LICENSE +21 -0
- package/README.md +512 -0
- package/detox/colors.ts +54 -0
- package/detox/config-loader.ts +135 -0
- package/detox/element-types.ts +39 -0
- package/detox/expectations.ts +537 -0
- package/detox/gestures.ts +480 -0
- package/detox/index.ts +2118 -0
- package/detox/jest-preset.cjs +51 -0
- package/detox/jest-setup-after-env.cjs +18 -0
- package/detox/matchers.ts +30 -0
- package/detox/motion-change.cjs +109 -0
- package/detox/motion-change.d.cts +35 -0
- package/detox/navigation.ts +43 -0
- package/detox/screenshots/animated-color-test-rest-norngh.png +0 -0
- package/detox/screenshots/color-test-after-drag-norngh.png +0 -0
- package/detox/screenshots/color-test-rest-norngh.png +0 -0
- package/detox/screenshots/theme-blue-toggle.png +0 -0
- package/detox/screenshots/theme-blue.png +0 -0
- package/detox/screenshots/theme-red-toggle.png +0 -0
- package/detox/screenshots/theme-red.png +0 -0
- package/dist-cli/bin.js +15 -0
- package/dist-cli/chunks/agent-XZ2KTPCU.js +48 -0
- package/dist-cli/chunks/agent-wrapper-JJYYW2WH.js +17 -0
- package/dist-cli/chunks/app-fonts-IXRNQG6B.js +4 -0
- package/dist-cli/chunks/assert-54T5SK5F.js +49 -0
- package/dist-cli/chunks/auth-FI5UDI45.js +12 -0
- package/dist-cli/chunks/beta-JV6UKADW.js +4 -0
- package/dist-cli/chunks/camera-VL73YIKP.js +22 -0
- package/dist-cli/chunks/chunk-2D2UPBBR.js +4 -0
- package/dist-cli/chunks/chunk-2YR5BGA5.js +5 -0
- package/dist-cli/chunks/chunk-3NV2NCNX.js +4 -0
- package/dist-cli/chunks/chunk-46EUUFJ5.js +4 -0
- package/dist-cli/chunks/chunk-4NPPOV2N.js +5 -0
- package/dist-cli/chunks/chunk-5DHC6KHQ.js +7 -0
- package/dist-cli/chunks/chunk-5TEF3ET3.js +74 -0
- package/dist-cli/chunks/chunk-5TPRP5QT.js +4 -0
- package/dist-cli/chunks/chunk-5YJCOWCH.js +4 -0
- package/dist-cli/chunks/chunk-7GN3LVWB.js +4 -0
- package/dist-cli/chunks/chunk-BBULZ7CG.js +568 -0
- package/dist-cli/chunks/chunk-BTWORNNG.js +71 -0
- package/dist-cli/chunks/chunk-D4FFVGI5.js +5 -0
- package/dist-cli/chunks/chunk-DCEMHR2Y.js +4 -0
- package/dist-cli/chunks/chunk-DZS6WPUI.js +4 -0
- package/dist-cli/chunks/chunk-F5ZRSS3C.js +3 -0
- package/dist-cli/chunks/chunk-FSUYIVJ6.js +9 -0
- package/dist-cli/chunks/chunk-G2WW6L2C.js +23 -0
- package/dist-cli/chunks/chunk-GASE6UBA.js +4 -0
- package/dist-cli/chunks/chunk-GGRX24GF.js +142 -0
- package/dist-cli/chunks/chunk-HI5TFJWN.js +5 -0
- package/dist-cli/chunks/chunk-IJ5CAZZC.js +5 -0
- package/dist-cli/chunks/chunk-IJO63TDP.js +4 -0
- package/dist-cli/chunks/chunk-KTHV3RUS.js +26 -0
- package/dist-cli/chunks/chunk-LF2ZVT7O.js +6 -0
- package/dist-cli/chunks/chunk-MJRLLB4R.js +38 -0
- package/dist-cli/chunks/chunk-NFK7T35W.js +4 -0
- package/dist-cli/chunks/chunk-NMF2ZMZQ.js +15 -0
- package/dist-cli/chunks/chunk-OHAZNXLK.js +4 -0
- package/dist-cli/chunks/chunk-OVFJFXUD.js +101 -0
- package/dist-cli/chunks/chunk-OZSSI4WN.js +28 -0
- package/dist-cli/chunks/chunk-QKDWYITG.js +25 -0
- package/dist-cli/chunks/chunk-RSZWCKNT.js +30 -0
- package/dist-cli/chunks/chunk-RTN5C5RL.js +4 -0
- package/dist-cli/chunks/chunk-TIVZIMMW.js +4 -0
- package/dist-cli/chunks/chunk-TZFFR3SD.js +7 -0
- package/dist-cli/chunks/chunk-UC6U3MML.js +5 -0
- package/dist-cli/chunks/chunk-VFCMSYZK.js +6 -0
- package/dist-cli/chunks/chunk-VNQEB4L7.js +5 -0
- package/dist-cli/chunks/chunk-VZXWHRUZ.js +983 -0
- package/dist-cli/chunks/chunk-W6K4EFPH.js +107 -0
- package/dist-cli/chunks/chunk-WEXDAC74.js +4 -0
- package/dist-cli/chunks/chunk-WF3T4SVI.js +14 -0
- package/dist-cli/chunks/chunk-WINYQ44O.js +4 -0
- package/dist-cli/chunks/chunk-WMIIKMGK.js +10 -0
- package/dist-cli/chunks/chunk-WUSWBCWA.js +507 -0
- package/dist-cli/chunks/chunk-WWZIXIRD.js +4 -0
- package/dist-cli/chunks/chunk-XEVZYVIW.js +766 -0
- package/dist-cli/chunks/chunk-YDGQTMQL.js +4 -0
- package/dist-cli/chunks/chunk-YIFT42WN.js +4 -0
- package/dist-cli/chunks/chunk-ZMJD5GEC.js +125 -0
- package/dist-cli/chunks/cleanup-P27PA6JI.js +25 -0
- package/dist-cli/chunks/cli-version-WWLPBDQ7.js +4 -0
- package/dist-cli/chunks/compat-ZD65FED3.js +20 -0
- package/dist-cli/chunks/config-XMJRNM2A.js +13 -0
- package/dist-cli/chunks/control-KMIQT3QP.js +4 -0
- package/dist-cli/chunks/daemon-G2ME7NLB.js +4 -0
- package/dist-cli/chunks/debug-PT4HOP7N.js +200 -0
- package/dist-cli/chunks/desktop-S3FG72AK.js +31 -0
- package/dist-cli/chunks/detox-B3D4IFCN.js +52 -0
- package/dist-cli/chunks/device-XBNDSB2R.js +18 -0
- package/dist-cli/chunks/diagnose-HMQXJE5N.js +43 -0
- package/dist-cli/chunks/disk-cleanup-BLCZ5BSZ.js +4 -0
- package/dist-cli/chunks/drivers-LDECZGP2.js +4 -0
- package/dist-cli/chunks/film-BJGTBYZB.js +74 -0
- package/dist-cli/chunks/flow-UEQNVTU7.js +4 -0
- package/dist-cli/chunks/help-T5FYSVGB.js +4 -0
- package/dist-cli/chunks/hidden-runtime-alias-ANOYADHM.js +4 -0
- package/dist-cli/chunks/home-paths-GT3LFNOR.js +4 -0
- package/dist-cli/chunks/inspect-ZA6XF5LD.js +4 -0
- package/dist-cli/chunks/install-desktop-TIMUDHPL.js +4 -0
- package/dist-cli/chunks/login-FJ737MWG.js +28 -0
- package/dist-cli/chunks/logout-ZCNMMHMY.js +4 -0
- package/dist-cli/chunks/maestro-SZTNKLDF.js +104 -0
- package/dist-cli/chunks/maestro-generate-DCFAIZ4H.js +36 -0
- package/dist-cli/chunks/mode-GRMQCRXR.js +26 -0
- package/dist-cli/chunks/optional-demo-registry-W36EWFFB.js +4 -0
- package/dist-cli/chunks/perf-QYBAAUZG.js +48 -0
- package/dist-cli/chunks/permissions-3QCQ6VF4.js +13 -0
- package/dist-cli/chunks/record-QPPC2S4E.js +72 -0
- package/dist-cli/chunks/report-issue-7NMFP4HK.js +29 -0
- package/dist-cli/chunks/runtime-XOAXMSTU.js +4 -0
- package/dist-cli/chunks/screenshot-command-67AECJFB.js +159 -0
- package/dist-cli/chunks/screenshot-layers-ASWBYPJL.js +20 -0
- package/dist-cli/chunks/screenshots-capture-PXA3HFQK.js +42 -0
- package/dist-cli/chunks/serve-BI2NBAXG.js +44 -0
- package/dist-cli/chunks/setup-7DWPMRSB.js +32 -0
- package/dist-cli/chunks/skills-S3Y22TUA.js +50 -0
- package/dist-cli/chunks/storage-XUIMJWAJ.js +37 -0
- package/dist-cli/chunks/store-JTHEJLAZ.js +4 -0
- package/dist-cli/chunks/telemetry-ZYJGD2DB.js +4 -0
- package/dist-cli/chunks/timeline-TMPLQPSP.js +24 -0
- package/dist-cli/chunks/upgrade-7HDSIM7K.js +7 -0
- package/dist-cli/chunks/upload-GMSZPWM6.js +4 -0
- package/dist-cli/chunks/version-HOCHZ37L.js +6 -0
- package/dist-cli/chunks/web-DG3WBYD3.js +4 -0
- package/dist-cli/chunks/what-happened-XFVUTZR7.js +25 -0
- package/dist-lib/agent-daemon-client.cjs +468 -0
- package/dist-lib/agent-events.cjs +48 -0
- package/dist-lib/agent-identity.cjs +53 -0
- package/dist-lib/agent-sessions.cjs +725 -0
- package/dist-lib/attached-projects.cjs +526 -0
- package/dist-lib/auth/shared-session.cjs +195 -0
- package/dist-lib/backend-origin.cjs +70 -0
- package/dist-lib/beta.cjs +41 -0
- package/dist-lib/beta.mjs +13 -0
- package/dist-lib/bridge-constants.cjs +161 -0
- package/dist-lib/cli-constants.cjs +32 -0
- package/dist-lib/config.cjs +96 -0
- package/dist-lib/detox/index.cjs +2863 -0
- package/dist-lib/detox/jest-preset.cjs +51 -0
- package/dist-lib/dev-bundle-resolution.cjs +223 -0
- package/dist-lib/home-paths.cjs +421 -0
- package/dist-lib/host/bridge-host.cjs +5600 -0
- package/dist-lib/host/fetch-proxy-handler.cjs +373 -0
- package/dist-lib/host/fetch-proxy-overrides.cjs +63 -0
- package/dist-lib/host/fetch-proxy-overrides.mjs +37 -0
- package/dist-lib/host/websocket-proxy.cjs +214 -0
- package/dist-lib/index.cjs +513 -0
- package/dist-lib/jump-to-source-babel.cjs +93 -0
- package/dist-lib/menu.cjs +620 -0
- package/dist-lib/menu.mjs +581 -0
- package/dist-lib/metro.cjs +297 -0
- package/dist-lib/profiles.cjs +246 -0
- package/dist-lib/public-brand.cjs +39 -0
- package/dist-lib/render-mode.cjs +54 -0
- package/dist-lib/scripts/dev-server-scanner.cjs +1034 -0
- package/dist-lib/sdk.cjs +2333 -0
- package/dist-lib/sdk.mjs +2240 -0
- package/dist-lib/skills.cjs +23922 -0
- package/dist-lib/vite.cjs +358 -0
- package/package.json +189 -18
- package/scripts/dev-server-scanner.ts +941 -0
- package/scripts/optional-demo-registry.ts +113 -0
- package/scripts/postinstall.cjs +3 -0
- package/scripts/preuninstall.cjs +118 -0
- package/skills/contrast/SKILL.md +171 -0
- package/skills/rnx-debug/SKILL.md +425 -0
- package/skills/rnx-perf/SKILL.md +295 -0
- package/skills/rnx-setup/SKILL.md +160 -0
- package/skills/rnx-test/SKILL.md +292 -0
- package/skills/rnx-visual/SKILL.md +122 -0
- package/src/agent-daemon-client.ts +410 -0
- package/src/agent-events.ts +71 -0
- package/src/agent-identity.ts +23 -0
- package/src/agent-prompt.ts +71 -0
- package/src/agent-sessions.ts +573 -0
- package/src/attached-projects.ts +539 -0
- package/src/auth/shared-session.ts +204 -0
- package/src/backend-origin.ts +49 -0
- package/src/beta.ts +19 -0
- package/src/bridge-constants.ts +171 -0
- package/src/browser-cache.ts +16 -0
- package/src/cli-constants.ts +1 -0
- package/src/cli-version.ts +32 -0
- package/src/codex-client.ts +215 -0
- package/src/config.ts +134 -0
- package/src/dev-bundle-resolution.ts +236 -0
- package/src/disk-cleanup.ts +466 -0
- package/src/home-paths.ts +552 -0
- package/src/host/agent-host.ts +666 -0
- package/src/host/bridge-host.ts +2626 -0
- package/src/host/fetch-proxy-handler.ts +397 -0
- package/src/host/fetch-proxy-overrides.ts +51 -0
- package/src/host/open-url.ts +89 -0
- package/src/host/websocket-proxy.ts +210 -0
- package/src/index.ts +12 -705
- package/src/jump-to-source-babel.ts +135 -0
- package/src/menu.ts +734 -0
- package/src/metro-plugin.ts +139 -0
- package/src/native-dev-bundle-url.ts +96 -0
- package/src/native-seam-manifest.ts +341 -0
- package/src/plist.ts +27 -0
- package/src/poll-until.ts +92 -0
- package/src/profiles.ts +179 -0
- package/src/public-brand.ts +9 -0
- package/src/render-mode.ts +27 -0
- package/src/runtime-assets.ts +228 -0
- package/src/runtime-delivery.ts +54 -0
- package/src/screenshots/compose.ts +422 -0
- package/src/screenshots/frame-compose.ts +454 -0
- package/src/screenshots/orchestrate.ts +256 -0
- package/src/screenshots/org-deck.ts +91 -0
- package/src/screenshots/registry.ts +58 -0
- package/src/screenshots/schema.ts +364 -0
- package/src/sdk.ts +7 -0
- package/src/settings-bundle.ts +418 -0
- package/src/skills/builtin/a11y-review.ts +132 -0
- package/src/skills/builtin/compat-check.ts +71 -0
- package/src/skills/builtin/maestro-test.ts +121 -0
- package/src/skills/builtin/perf-profile.ts +90 -0
- package/src/skills/builtin/screenshot-all.ts +52 -0
- package/src/skills/builtin/visual-diff.ts +100 -0
- package/src/skills/registry.ts +107 -0
- package/src/skills/types.ts +41 -0
- package/src/team-machine-prompt.ts +73 -0
- package/src/vite-plugin-one.ts +190 -0
- package/src/vite-plugin.ts +1750 -0
- package/src/worklets-babel.ts +134 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
|
+
"use strict";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __esm = (fn, res) => function __init() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
+
|
|
35
|
+
// scripts/optional-demo-registry.ts
|
|
36
|
+
var optional_demo_registry_exports = {};
|
|
37
|
+
__export(optional_demo_registry_exports, {
|
|
38
|
+
__withOptionalDemoAppsForTests: () => __withOptionalDemoAppsForTests,
|
|
39
|
+
findInternalDemoRegistry: () => findInternalDemoRegistry,
|
|
40
|
+
loadOptionalDemoApps: () => loadOptionalDemoApps,
|
|
41
|
+
optionalDemoAppsSync: () => optionalDemoAppsSync
|
|
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
|
+
}
|
|
55
|
+
async function loadOptionalDemoApps() {
|
|
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
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const mod = await import(
|
|
64
|
+
/* @vite-ignore */
|
|
65
|
+
(0, import_node_url.pathToFileURL)(registryPath).href
|
|
66
|
+
);
|
|
67
|
+
cached = Array.isArray(mod.APPS) ? mod.APPS : [];
|
|
68
|
+
} catch {
|
|
69
|
+
cached = [];
|
|
70
|
+
}
|
|
71
|
+
return cached;
|
|
72
|
+
}
|
|
73
|
+
function optionalDemoAppsSync() {
|
|
74
|
+
return cached ?? [];
|
|
75
|
+
}
|
|
76
|
+
function __withOptionalDemoAppsForTests(apps) {
|
|
77
|
+
const previous = cached;
|
|
78
|
+
cached = apps;
|
|
79
|
+
return {
|
|
80
|
+
restore: () => {
|
|
81
|
+
cached = previous;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
var import_node_fs, import_node_path2, import_node_url, REGISTRY_REPO_PATH, MAX_ANCESTOR_STEPS, cached;
|
|
86
|
+
var init_optional_demo_registry = __esm({
|
|
87
|
+
"scripts/optional-demo-registry.ts"() {
|
|
88
|
+
"use strict";
|
|
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;
|
|
94
|
+
cached = null;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// src/attached-projects.ts
|
|
99
|
+
var attached_projects_exports = {};
|
|
100
|
+
__export(attached_projects_exports, {
|
|
101
|
+
__setUserDataDirForTests: () => __setUserDataDirForTests,
|
|
102
|
+
applySessionStatusPatch: () => applySessionStatusPatch,
|
|
103
|
+
costThisWeek: () => costThisWeek,
|
|
104
|
+
deletePreviewAttachment: () => deletePreviewAttachment,
|
|
105
|
+
deleteProject: () => deleteProject,
|
|
106
|
+
deleteSession: () => deleteSession,
|
|
107
|
+
findProjectByBundleUrl: () => findProjectByBundleUrl,
|
|
108
|
+
findProjectByCwd: () => findProjectByCwd,
|
|
109
|
+
findProjectById: () => findProjectById,
|
|
110
|
+
findSessionById: () => findSessionById,
|
|
111
|
+
getUserDataDir: () => getUserDataDir,
|
|
112
|
+
listPreviewAttachments: () => listPreviewAttachments,
|
|
113
|
+
listProjects: () => listProjects,
|
|
114
|
+
listSessions: () => listSessions,
|
|
115
|
+
loadStore: () => loadStore,
|
|
116
|
+
mutateStore: () => mutateStore,
|
|
117
|
+
projectIdForCwd: () => projectIdForCwd,
|
|
118
|
+
recordTurnTelemetry: () => recordTurnTelemetry,
|
|
119
|
+
seedFromDemoAppRegistry: () => seedFromDemoAppRegistry,
|
|
120
|
+
setUserDataDir: () => setUserDataDir,
|
|
121
|
+
updateSessionStatus: () => updateSessionStatus,
|
|
122
|
+
updateSessionStatuses: () => updateSessionStatuses,
|
|
123
|
+
upsertPreviewAttachment: () => upsertPreviewAttachment,
|
|
124
|
+
upsertProject: () => upsertProject,
|
|
125
|
+
upsertSession: () => upsertSession
|
|
126
|
+
});
|
|
127
|
+
module.exports = __toCommonJS(attached_projects_exports);
|
|
128
|
+
var import_node_crypto = require("node:crypto");
|
|
129
|
+
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
130
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
131
|
+
|
|
132
|
+
// src/home-paths.ts
|
|
133
|
+
var import_node_os = require("node:os");
|
|
134
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
135
|
+
var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
|
|
136
|
+
function sootsimHomeDir() {
|
|
137
|
+
const override = process.env[SOOTSIM_HOME_ENV];
|
|
138
|
+
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
139
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".sootsim");
|
|
140
|
+
}
|
|
141
|
+
function electronDir() {
|
|
142
|
+
return import_node_path.default.join(sootsimHomeDir(), "electron");
|
|
143
|
+
}
|
|
144
|
+
function electronUserDataDir() {
|
|
145
|
+
return import_node_path.default.join(electronDir(), "userData");
|
|
146
|
+
}
|
|
147
|
+
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
148
|
+
|
|
149
|
+
// src/attached-projects.ts
|
|
150
|
+
var overrideDir = null;
|
|
151
|
+
function setUserDataDir(dir) {
|
|
152
|
+
overrideDir = dir;
|
|
153
|
+
}
|
|
154
|
+
var __setUserDataDirForTests = setUserDataDir;
|
|
155
|
+
function userDataDir() {
|
|
156
|
+
if (overrideDir) return overrideDir;
|
|
157
|
+
const fromEnv = process.env.SOOTSIM_USER_DATA_DIR;
|
|
158
|
+
if (fromEnv) return fromEnv;
|
|
159
|
+
return electronUserDataDir();
|
|
160
|
+
}
|
|
161
|
+
function getUserDataDir() {
|
|
162
|
+
return userDataDir();
|
|
163
|
+
}
|
|
164
|
+
function storeFile() {
|
|
165
|
+
return import_node_path3.default.join(userDataDir(), "attached-projects.json");
|
|
166
|
+
}
|
|
167
|
+
function cloneEmpty() {
|
|
168
|
+
return {
|
|
169
|
+
version: 1,
|
|
170
|
+
attachedProjects: [],
|
|
171
|
+
previewAttachments: [],
|
|
172
|
+
agentSessions: []
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function loadStore() {
|
|
176
|
+
const file = storeFile();
|
|
177
|
+
let raw;
|
|
178
|
+
try {
|
|
179
|
+
raw = import_node_fs2.default.readFileSync(file, "utf8");
|
|
180
|
+
} catch (err) {
|
|
181
|
+
if (err.code === "ENOENT") return cloneEmpty();
|
|
182
|
+
throw err;
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const parsed = JSON.parse(raw);
|
|
186
|
+
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
187
|
+
return {
|
|
188
|
+
version: 1,
|
|
189
|
+
attachedProjects: Array.isArray(parsed.attachedProjects) ? parsed.attachedProjects : [],
|
|
190
|
+
previewAttachments: Array.isArray(parsed.previewAttachments) ? parsed.previewAttachments : [],
|
|
191
|
+
agentSessions: Array.isArray(parsed.agentSessions) ? parsed.agentSessions : []
|
|
192
|
+
};
|
|
193
|
+
} catch (err) {
|
|
194
|
+
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
195
|
+
try {
|
|
196
|
+
import_node_fs2.default.renameSync(file, quarantine);
|
|
197
|
+
console.warn(
|
|
198
|
+
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
199
|
+
);
|
|
200
|
+
} catch {
|
|
201
|
+
}
|
|
202
|
+
return cloneEmpty();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function writeStore(store) {
|
|
206
|
+
const file = storeFile();
|
|
207
|
+
import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(file), { recursive: true });
|
|
208
|
+
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
209
|
+
const fd = import_node_fs2.default.openSync(tmp, "w", 384);
|
|
210
|
+
try {
|
|
211
|
+
import_node_fs2.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
212
|
+
import_node_fs2.default.fsyncSync(fd);
|
|
213
|
+
} finally {
|
|
214
|
+
import_node_fs2.default.closeSync(fd);
|
|
215
|
+
}
|
|
216
|
+
import_node_fs2.default.renameSync(tmp, file);
|
|
217
|
+
}
|
|
218
|
+
function mutateStore(fn) {
|
|
219
|
+
const store = loadStore();
|
|
220
|
+
fn(store);
|
|
221
|
+
writeStore(store);
|
|
222
|
+
return store;
|
|
223
|
+
}
|
|
224
|
+
function projectIdForCwd(cwd) {
|
|
225
|
+
return (0, import_node_crypto.createHash)("sha256").update(import_node_path3.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
226
|
+
}
|
|
227
|
+
function newSessionId() {
|
|
228
|
+
return `s_${(0, import_node_crypto.randomBytes)(10).toString("hex")}`;
|
|
229
|
+
}
|
|
230
|
+
function newPreviewId() {
|
|
231
|
+
return `pa_${(0, import_node_crypto.randomBytes)(10).toString("hex")}`;
|
|
232
|
+
}
|
|
233
|
+
function upsertProject(input) {
|
|
234
|
+
const cwd = import_node_path3.default.resolve(input.cwd);
|
|
235
|
+
const id = projectIdForCwd(cwd);
|
|
236
|
+
let result;
|
|
237
|
+
mutateStore((store) => {
|
|
238
|
+
const existing = store.attachedProjects.find((p) => p.id === id);
|
|
239
|
+
if (existing) {
|
|
240
|
+
const merged = {
|
|
241
|
+
...existing,
|
|
242
|
+
...input,
|
|
243
|
+
id,
|
|
244
|
+
cwd,
|
|
245
|
+
sourceRoots: input.sourceRoots ?? existing.sourceRoots,
|
|
246
|
+
knownBundleUrls: input.knownBundleUrls ?? existing.knownBundleUrls,
|
|
247
|
+
pinnedSourceResolutions: input.pinnedSourceResolutions ?? existing.pinnedSourceResolutions,
|
|
248
|
+
telemetry: input.telemetry ?? existing.telemetry,
|
|
249
|
+
updatedAt: Date.now(),
|
|
250
|
+
createdAt: existing.createdAt
|
|
251
|
+
};
|
|
252
|
+
const idx = store.attachedProjects.indexOf(existing);
|
|
253
|
+
store.attachedProjects[idx] = merged;
|
|
254
|
+
result = merged;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const now = Date.now();
|
|
258
|
+
const created = {
|
|
259
|
+
id,
|
|
260
|
+
name: input.name ?? import_node_path3.default.basename(cwd),
|
|
261
|
+
cwd,
|
|
262
|
+
repoRoot: input.repoRoot,
|
|
263
|
+
sourceRoots: input.sourceRoots ?? [cwd],
|
|
264
|
+
framework: input.framework ?? "unknown",
|
|
265
|
+
bundleId: input.bundleId,
|
|
266
|
+
knownBundleUrls: input.knownBundleUrls ?? [],
|
|
267
|
+
preferredProvider: input.preferredProvider ?? "codex",
|
|
268
|
+
preferredTransport: input.preferredTransport ?? "tmux",
|
|
269
|
+
editorOpenCommand: input.editorOpenCommand,
|
|
270
|
+
moshiWebhookToken: input.moshiWebhookToken,
|
|
271
|
+
pinnedSourceResolutions: input.pinnedSourceResolutions ?? {},
|
|
272
|
+
isolateDiscovery: input.isolateDiscovery,
|
|
273
|
+
git: input.git,
|
|
274
|
+
telemetry: input.telemetry ?? { lastOpened: 0, runsCompleted: 0 },
|
|
275
|
+
createdAt: now,
|
|
276
|
+
updatedAt: now
|
|
277
|
+
};
|
|
278
|
+
store.attachedProjects.push(created);
|
|
279
|
+
result = created;
|
|
280
|
+
});
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
function findProjectById(id) {
|
|
284
|
+
return loadStore().attachedProjects.find((p) => p.id === id) ?? null;
|
|
285
|
+
}
|
|
286
|
+
function findProjectByCwd(cwd) {
|
|
287
|
+
const resolved = import_node_path3.default.resolve(cwd);
|
|
288
|
+
return loadStore().attachedProjects.find((p) => p.cwd === resolved) ?? null;
|
|
289
|
+
}
|
|
290
|
+
function findProjectByBundleUrl(bundleUrl) {
|
|
291
|
+
const store = loadStore();
|
|
292
|
+
const exact = store.attachedProjects.find((p) => p.knownBundleUrls.includes(bundleUrl));
|
|
293
|
+
if (exact) return exact;
|
|
294
|
+
const base = stripQuery(bundleUrl);
|
|
295
|
+
return store.attachedProjects.find(
|
|
296
|
+
(p) => p.knownBundleUrls.some((u) => stripQuery(u) === base)
|
|
297
|
+
) ?? null;
|
|
298
|
+
}
|
|
299
|
+
function stripQuery(url) {
|
|
300
|
+
const q = url.indexOf("?");
|
|
301
|
+
return q >= 0 ? url.slice(0, q) : url;
|
|
302
|
+
}
|
|
303
|
+
function listProjects() {
|
|
304
|
+
return loadStore().attachedProjects;
|
|
305
|
+
}
|
|
306
|
+
var COST_HISTORY_MAX_AGE_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
307
|
+
function recordTurnTelemetry(projectId, input = {}) {
|
|
308
|
+
mutateStore((store) => {
|
|
309
|
+
const project = store.attachedProjects.find((p) => p.id === projectId);
|
|
310
|
+
if (!project) return;
|
|
311
|
+
const ts = input.ts ?? Date.now();
|
|
312
|
+
project.telemetry.runsCompleted = (project.telemetry.runsCompleted ?? 0) + 1;
|
|
313
|
+
if (typeof input.usd === "number" && Number.isFinite(input.usd) && input.usd >= 0) {
|
|
314
|
+
const history = project.telemetry.costHistory ?? [];
|
|
315
|
+
const cutoff = ts - COST_HISTORY_MAX_AGE_MS;
|
|
316
|
+
const trimmed = history.filter((e) => e.ts >= cutoff);
|
|
317
|
+
trimmed.push({ ts, usd: input.usd });
|
|
318
|
+
project.telemetry.costHistory = trimmed;
|
|
319
|
+
}
|
|
320
|
+
project.updatedAt = ts;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function costThisWeek(project, now = Date.now()) {
|
|
324
|
+
const cutoff = now - 7 * 24 * 60 * 60 * 1e3;
|
|
325
|
+
const history = project.telemetry.costHistory ?? [];
|
|
326
|
+
let total = 0;
|
|
327
|
+
for (const e of history) {
|
|
328
|
+
if (e.ts >= cutoff) total += e.usd;
|
|
329
|
+
}
|
|
330
|
+
return total;
|
|
331
|
+
}
|
|
332
|
+
function deleteProject(id) {
|
|
333
|
+
mutateStore((store) => {
|
|
334
|
+
store.attachedProjects = store.attachedProjects.filter((p) => p.id !== id);
|
|
335
|
+
store.agentSessions = store.agentSessions.filter((s) => s.projectId !== id);
|
|
336
|
+
store.previewAttachments = store.previewAttachments.filter(
|
|
337
|
+
(pa) => pa.projectId !== id
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function upsertSession(input) {
|
|
342
|
+
let result;
|
|
343
|
+
mutateStore((store) => {
|
|
344
|
+
if (input.id) {
|
|
345
|
+
const existing = store.agentSessions.find((s) => s.id === input.id);
|
|
346
|
+
if (existing) {
|
|
347
|
+
const merged = {
|
|
348
|
+
...existing,
|
|
349
|
+
...input,
|
|
350
|
+
lastSeenAt: Date.now()
|
|
351
|
+
};
|
|
352
|
+
const idx = store.agentSessions.indexOf(existing);
|
|
353
|
+
store.agentSessions[idx] = merged;
|
|
354
|
+
result = merged;
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const project = store.attachedProjects.find((p) => p.id === input.projectId);
|
|
359
|
+
if (!project) {
|
|
360
|
+
throw new Error(`upsertSession: no AttachedProject with id=${input.projectId}`);
|
|
361
|
+
}
|
|
362
|
+
const now = Date.now();
|
|
363
|
+
const created = {
|
|
364
|
+
id: input.id ?? newSessionId(),
|
|
365
|
+
projectId: input.projectId,
|
|
366
|
+
provider: input.provider,
|
|
367
|
+
transport: input.transport ?? project.preferredTransport,
|
|
368
|
+
cwd: input.cwd ?? project.cwd,
|
|
369
|
+
claudeSessionUuid: input.claudeSessionUuid,
|
|
370
|
+
tmuxSessionName: input.tmuxSessionName,
|
|
371
|
+
wrapperPid: input.wrapperPid,
|
|
372
|
+
status: input.status ?? "idle",
|
|
373
|
+
needsAttention: input.needsAttention ?? false,
|
|
374
|
+
lastPrompt: input.lastPrompt,
|
|
375
|
+
lastSummary: input.lastSummary,
|
|
376
|
+
lastTurnFiles: input.lastTurnFiles,
|
|
377
|
+
currentlyEditing: input.currentlyEditing,
|
|
378
|
+
lastSeenAt: now,
|
|
379
|
+
createdAt: now
|
|
380
|
+
};
|
|
381
|
+
store.agentSessions.push(created);
|
|
382
|
+
result = created;
|
|
383
|
+
});
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
function findSessionById(id) {
|
|
387
|
+
return loadStore().agentSessions.find((s) => s.id === id) ?? null;
|
|
388
|
+
}
|
|
389
|
+
function listSessions(projectId) {
|
|
390
|
+
const all = loadStore().agentSessions;
|
|
391
|
+
return projectId ? all.filter((s) => s.projectId === projectId) : all;
|
|
392
|
+
}
|
|
393
|
+
function applySessionStatusPatch(existing, patch, now = Date.now()) {
|
|
394
|
+
return {
|
|
395
|
+
...existing,
|
|
396
|
+
...patch,
|
|
397
|
+
id: existing.id,
|
|
398
|
+
projectId: existing.projectId,
|
|
399
|
+
createdAt: existing.createdAt,
|
|
400
|
+
lastSeenAt: now
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function updateSessionStatuses(updates) {
|
|
404
|
+
if (updates.length === 0) return;
|
|
405
|
+
mutateStore((store) => {
|
|
406
|
+
const now = Date.now();
|
|
407
|
+
const indexById = new Map(
|
|
408
|
+
store.agentSessions.map((session, index) => [session.id, index])
|
|
409
|
+
);
|
|
410
|
+
for (const { id, patch } of updates) {
|
|
411
|
+
const idx = indexById.get(id);
|
|
412
|
+
if (idx === void 0) continue;
|
|
413
|
+
store.agentSessions[idx] = applySessionStatusPatch(
|
|
414
|
+
store.agentSessions[idx],
|
|
415
|
+
patch,
|
|
416
|
+
now
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function updateSessionStatus(id, patch) {
|
|
422
|
+
updateSessionStatuses([{ id, patch }]);
|
|
423
|
+
}
|
|
424
|
+
function deleteSession(id) {
|
|
425
|
+
mutateStore((store) => {
|
|
426
|
+
store.agentSessions = store.agentSessions.filter((s) => s.id !== id);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function upsertPreviewAttachment(input) {
|
|
430
|
+
let result;
|
|
431
|
+
mutateStore((store) => {
|
|
432
|
+
const existing = store.previewAttachments.find(
|
|
433
|
+
(pa) => pa.bundleUrl === input.bundleUrl && pa.simId === input.simId
|
|
434
|
+
);
|
|
435
|
+
if (existing) {
|
|
436
|
+
const merged = {
|
|
437
|
+
...existing,
|
|
438
|
+
...input,
|
|
439
|
+
lastSeenAt: Date.now()
|
|
440
|
+
};
|
|
441
|
+
const idx = store.previewAttachments.indexOf(existing);
|
|
442
|
+
store.previewAttachments[idx] = merged;
|
|
443
|
+
result = merged;
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const created = {
|
|
447
|
+
id: input.id ?? newPreviewId(),
|
|
448
|
+
projectId: input.projectId ?? null,
|
|
449
|
+
bundleUrl: input.bundleUrl,
|
|
450
|
+
simId: input.simId,
|
|
451
|
+
deviceModel: input.deviceModel ?? "unknown",
|
|
452
|
+
status: input.status ?? "connecting",
|
|
453
|
+
lastSeenAt: Date.now()
|
|
454
|
+
};
|
|
455
|
+
store.previewAttachments.push(created);
|
|
456
|
+
result = created;
|
|
457
|
+
});
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
460
|
+
function listPreviewAttachments(projectId) {
|
|
461
|
+
const all = loadStore().previewAttachments;
|
|
462
|
+
return projectId ? all.filter((pa) => pa.projectId === projectId) : all;
|
|
463
|
+
}
|
|
464
|
+
function deletePreviewAttachment(id) {
|
|
465
|
+
mutateStore((store) => {
|
|
466
|
+
store.previewAttachments = store.previewAttachments.filter((pa) => pa.id !== id);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
async function seedFromDemoAppRegistry() {
|
|
470
|
+
const existing = loadStore().attachedProjects;
|
|
471
|
+
if (existing.length > 0) return;
|
|
472
|
+
const { loadOptionalDemoApps: loadOptionalDemoApps2 } = await Promise.resolve().then(() => (init_optional_demo_registry(), optional_demo_registry_exports));
|
|
473
|
+
const apps = await loadOptionalDemoApps2();
|
|
474
|
+
if (apps.length === 0) return;
|
|
475
|
+
mutateStore((store) => {
|
|
476
|
+
for (const app of apps) {
|
|
477
|
+
if (!import_node_fs2.default.existsSync(app.dir)) continue;
|
|
478
|
+
const cwd = import_node_path3.default.resolve(app.dir);
|
|
479
|
+
const id = projectIdForCwd(cwd);
|
|
480
|
+
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
481
|
+
const now = Date.now();
|
|
482
|
+
store.attachedProjects.push({
|
|
483
|
+
id,
|
|
484
|
+
name: app.label,
|
|
485
|
+
cwd,
|
|
486
|
+
sourceRoots: [cwd],
|
|
487
|
+
framework: app.framework,
|
|
488
|
+
knownBundleUrls: [`http://localhost:${app.preferredPort}/index.bundle`],
|
|
489
|
+
preferredProvider: "codex",
|
|
490
|
+
preferredTransport: "tmux",
|
|
491
|
+
pinnedSourceResolutions: {},
|
|
492
|
+
telemetry: { lastOpened: 0, runsCompleted: 0 },
|
|
493
|
+
createdAt: now,
|
|
494
|
+
updatedAt: now
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
500
|
+
0 && (module.exports = {
|
|
501
|
+
__setUserDataDirForTests,
|
|
502
|
+
applySessionStatusPatch,
|
|
503
|
+
costThisWeek,
|
|
504
|
+
deletePreviewAttachment,
|
|
505
|
+
deleteProject,
|
|
506
|
+
deleteSession,
|
|
507
|
+
findProjectByBundleUrl,
|
|
508
|
+
findProjectByCwd,
|
|
509
|
+
findProjectById,
|
|
510
|
+
findSessionById,
|
|
511
|
+
getUserDataDir,
|
|
512
|
+
listPreviewAttachments,
|
|
513
|
+
listProjects,
|
|
514
|
+
listSessions,
|
|
515
|
+
loadStore,
|
|
516
|
+
mutateStore,
|
|
517
|
+
projectIdForCwd,
|
|
518
|
+
recordTurnTelemetry,
|
|
519
|
+
seedFromDemoAppRegistry,
|
|
520
|
+
setUserDataDir,
|
|
521
|
+
updateSessionStatus,
|
|
522
|
+
updateSessionStatuses,
|
|
523
|
+
upsertPreviewAttachment,
|
|
524
|
+
upsertProject,
|
|
525
|
+
upsertSession
|
|
526
|
+
});
|