@kwonye/mcpx 0.1.97 → 0.1.99
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/dist/{cli-remv48t3.js → cli-1ewrsfj4.js} +1 -1
- package/dist/{cli-zjepj3sj.js → cli-28g7x9rn.js} +10 -1
- package/dist/{cli-gf70a85c.js → cli-7x2n23em.js} +112 -24
- package/dist/{cli-vy81xjm0.js → cli-b0xrqsjc.js} +1612 -488
- package/dist/cli-ct7asw78.js +598 -0
- package/dist/{cli-g4w6k655.js → cli-dy7x0zrg.js} +70 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +137 -25
- package/dist/{config-2s2aqkqp.js → config-yx5m60fv.js} +2 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/daemon.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +46 -20
- package/dist/core/marketplace-defaults.d.ts +4 -0
- package/dist/core/marketplace-defaults.d.ts.map +1 -0
- package/dist/core/marketplace-updater.d.ts +10 -0
- package/dist/core/marketplace-updater.d.ts.map +1 -0
- package/dist/core/marketplace.d.ts +67 -0
- package/dist/core/marketplace.d.ts.map +1 -0
- package/dist/core/paths.d.ts +3 -0
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/plugin-cache.d.ts.map +1 -1
- package/dist/core/plugin-manager.d.ts +21 -7
- package/dist/core/plugin-manager.d.ts.map +1 -1
- package/dist/core/plugin-parse.d.ts.map +1 -1
- package/dist/marketplace-pwabb3ea.js +33 -0
- package/dist/{plugin-host-d9wkemnr.js → plugin-host-9xcpnehq.js} +4 -5
- package/dist/{plugin-manager-0ygz96m9.js → plugin-manager-19q55n69.js} +6 -5
- package/dist/{registry-bnjb2345.js → registry-yvbxcaq6.js} +2 -2
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cli-tdsve98z.js +0 -1029
|
@@ -65,6 +65,15 @@ function getPluginCacheRoot() {
|
|
|
65
65
|
function getPluginDataRoot() {
|
|
66
66
|
return path.join(getDataRoot(), "mcpx", "plugins", "data");
|
|
67
67
|
}
|
|
68
|
+
function getMarketplaceCacheRoot() {
|
|
69
|
+
return path.join(getDataRoot(), "mcpx", "marketplaces", "cache");
|
|
70
|
+
}
|
|
71
|
+
function getMarketplaceUpdateStatePath() {
|
|
72
|
+
return path.join(getStateRoot(), "mcpx", "marketplaces", "update-state.json");
|
|
73
|
+
}
|
|
74
|
+
function getMarketplaceUpdateLockPath() {
|
|
75
|
+
return path.join(getStateRoot(), "mcpx", "marketplaces", ".update.lock");
|
|
76
|
+
}
|
|
68
77
|
function ensureDir(dirPath) {
|
|
69
78
|
fs.mkdirSync(dirPath, { recursive: true });
|
|
70
79
|
}
|
|
@@ -114,4 +123,4 @@ function sha256(value) {
|
|
|
114
123
|
return crypto.createHash("sha256").update(value).digest("hex");
|
|
115
124
|
}
|
|
116
125
|
|
|
117
|
-
export { homeDir, getConfigPath, getSkillsDir, getManagedIndexPath, getSecretsStorePath, getSecretsKeyPath, getPidPath, getLogPath, getGatewayTokenPath, getUpdatesDir, getStagedVersionPath, getUpdateLockPath, getPluginCacheRoot, getPluginDataRoot, ensureDir, ensureParentDir, findProjectConfigPath, readJsonFile, writeJsonAtomic, sha256 };
|
|
126
|
+
export { homeDir, getConfigPath, getSkillsDir, getManagedIndexPath, getSecretsStorePath, getSecretsKeyPath, getPidPath, getLogPath, getGatewayTokenPath, getUpdatesDir, getStagedVersionPath, getUpdateLockPath, getPluginCacheRoot, getPluginDataRoot, getMarketplaceCacheRoot, getMarketplaceUpdateStatePath, getMarketplaceUpdateLockPath, ensureDir, ensureParentDir, findProjectConfigPath, readJsonFile, writeJsonAtomic, sha256 };
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
refreshAutoUpdateMarketplaces
|
|
3
|
+
} from "./cli-ct7asw78.js";
|
|
1
4
|
import {
|
|
2
5
|
APP_VERSION,
|
|
3
6
|
getGatewayUrl,
|
|
4
7
|
persistSyncState,
|
|
5
8
|
syncAllClients
|
|
6
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-b0xrqsjc.js";
|
|
7
10
|
import {
|
|
8
11
|
loadConfig,
|
|
9
12
|
loadMergedConfig,
|
|
10
13
|
saveConfig
|
|
11
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-dy7x0zrg.js";
|
|
12
15
|
import {
|
|
13
16
|
SecretsManager,
|
|
14
17
|
UpstreamError,
|
|
15
18
|
classifyUpstreamError,
|
|
16
19
|
ensureGatewayToken
|
|
17
|
-
} from "./cli-
|
|
20
|
+
} from "./cli-1ewrsfj4.js";
|
|
18
21
|
import {
|
|
19
22
|
ensureDir,
|
|
20
23
|
ensureParentDir,
|
|
21
24
|
getLogPath,
|
|
25
|
+
getMarketplaceUpdateLockPath,
|
|
26
|
+
getMarketplaceUpdateStatePath,
|
|
22
27
|
getPidPath,
|
|
23
28
|
getStagedVersionPath,
|
|
24
29
|
getUpdateLockPath,
|
|
25
30
|
getUpdatesDir
|
|
26
|
-
} from "./cli-
|
|
31
|
+
} from "./cli-28g7x9rn.js";
|
|
27
32
|
import {
|
|
28
33
|
isServerEnabled
|
|
29
34
|
} from "./cli-s4gspqdf.js";
|
|
@@ -1001,8 +1006,89 @@ function performRollback() {
|
|
|
1001
1006
|
};
|
|
1002
1007
|
}
|
|
1003
1008
|
|
|
1004
|
-
// src/core/
|
|
1009
|
+
// src/core/marketplace-updater.ts
|
|
1005
1010
|
import fs4 from "node:fs";
|
|
1011
|
+
var MARKETPLACE_UPDATE_INTERVAL_MS = 6 * 60 * 60 * 1000;
|
|
1012
|
+
var INITIAL_DELAY_MS = 30000;
|
|
1013
|
+
var LOCK_STALE_MS = 30 * 60 * 1000;
|
|
1014
|
+
function readState() {
|
|
1015
|
+
try {
|
|
1016
|
+
return JSON.parse(fs4.readFileSync(getMarketplaceUpdateStatePath(), "utf8"));
|
|
1017
|
+
} catch {
|
|
1018
|
+
return {};
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function writeState(state) {
|
|
1022
|
+
const target = getMarketplaceUpdateStatePath();
|
|
1023
|
+
ensureParentDir(target);
|
|
1024
|
+
fs4.writeFileSync(target, JSON.stringify(state, null, 2), { mode: 384 });
|
|
1025
|
+
}
|
|
1026
|
+
function due(now = Date.now()) {
|
|
1027
|
+
const last = readState().lastRunAt;
|
|
1028
|
+
return !last || !Number.isFinite(Date.parse(last)) || now - Date.parse(last) >= MARKETPLACE_UPDATE_INTERVAL_MS;
|
|
1029
|
+
}
|
|
1030
|
+
function acquireLock2() {
|
|
1031
|
+
const target = getMarketplaceUpdateLockPath();
|
|
1032
|
+
ensureParentDir(target);
|
|
1033
|
+
try {
|
|
1034
|
+
fs4.writeFileSync(target, `${process.pid}
|
|
1035
|
+
`, { flag: "wx", mode: 384 });
|
|
1036
|
+
return true;
|
|
1037
|
+
} catch {
|
|
1038
|
+
try {
|
|
1039
|
+
if (Date.now() - fs4.statSync(target).mtimeMs > LOCK_STALE_MS) {
|
|
1040
|
+
fs4.unlinkSync(target);
|
|
1041
|
+
return acquireLock2();
|
|
1042
|
+
}
|
|
1043
|
+
} catch {
|
|
1044
|
+
return acquireLock2();
|
|
1045
|
+
}
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function releaseLock2() {
|
|
1050
|
+
try {
|
|
1051
|
+
fs4.unlinkSync(getMarketplaceUpdateLockPath());
|
|
1052
|
+
} catch {}
|
|
1053
|
+
}
|
|
1054
|
+
async function runMarketplaceAutoUpdate(options) {
|
|
1055
|
+
if (process.env.MCPX_NO_UPDATE === "1")
|
|
1056
|
+
return { checked: [], errors: [], skipped: true };
|
|
1057
|
+
if (!options?.force && !due())
|
|
1058
|
+
return { checked: [], errors: [], skipped: true };
|
|
1059
|
+
if (!acquireLock2())
|
|
1060
|
+
return { checked: [], errors: [], skipped: true };
|
|
1061
|
+
try {
|
|
1062
|
+
const result = await refreshAutoUpdateMarketplaces();
|
|
1063
|
+
writeState({ lastRunAt: new Date().toISOString() });
|
|
1064
|
+
return result;
|
|
1065
|
+
} finally {
|
|
1066
|
+
releaseLock2();
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
function startMarketplaceAutoUpdater() {
|
|
1070
|
+
if (process.env.MCPX_NO_UPDATE === "1")
|
|
1071
|
+
return () => {};
|
|
1072
|
+
let stopped = false;
|
|
1073
|
+
const run = () => {
|
|
1074
|
+
if (!stopped)
|
|
1075
|
+
runMarketplaceAutoUpdate().catch(() => {
|
|
1076
|
+
return;
|
|
1077
|
+
});
|
|
1078
|
+
};
|
|
1079
|
+
const initial = setTimeout(run, INITIAL_DELAY_MS);
|
|
1080
|
+
initial.unref?.();
|
|
1081
|
+
const interval = setInterval(run, MARKETPLACE_UPDATE_INTERVAL_MS);
|
|
1082
|
+
interval.unref?.();
|
|
1083
|
+
return () => {
|
|
1084
|
+
stopped = true;
|
|
1085
|
+
clearTimeout(initial);
|
|
1086
|
+
clearInterval(interval);
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// src/core/daemon.ts
|
|
1091
|
+
import fs5 from "node:fs";
|
|
1006
1092
|
import net from "node:net";
|
|
1007
1093
|
import { spawn as spawn2, execFileSync as execFileSync2 } from "node:child_process";
|
|
1008
1094
|
|
|
@@ -1996,10 +2082,10 @@ function createGatewayServer(options) {
|
|
|
1996
2082
|
|
|
1997
2083
|
// src/core/daemon.ts
|
|
1998
2084
|
function readPidRecordFromFile(pidPath = getPidPath()) {
|
|
1999
|
-
if (!
|
|
2085
|
+
if (!fs5.existsSync(pidPath)) {
|
|
2000
2086
|
return null;
|
|
2001
2087
|
}
|
|
2002
|
-
const raw =
|
|
2088
|
+
const raw = fs5.readFileSync(pidPath, "utf8").trim();
|
|
2003
2089
|
if (!raw) {
|
|
2004
2090
|
return null;
|
|
2005
2091
|
}
|
|
@@ -2117,7 +2203,7 @@ async function startDaemon(config, cliPath, secrets) {
|
|
|
2117
2203
|
};
|
|
2118
2204
|
}
|
|
2119
2205
|
try {
|
|
2120
|
-
|
|
2206
|
+
fs5.unlinkSync(getPidPath());
|
|
2121
2207
|
} catch {}
|
|
2122
2208
|
}
|
|
2123
2209
|
const { port, fellBackFrom } = await resolveGatewayPort(config, secrets);
|
|
@@ -2130,24 +2216,24 @@ async function startDaemon(config, cliPath, secrets) {
|
|
|
2130
2216
|
const logPath = getLogPath();
|
|
2131
2217
|
ensureParentDir(pidPath);
|
|
2132
2218
|
ensureParentDir(logPath);
|
|
2133
|
-
let logFd =
|
|
2134
|
-
const logStat =
|
|
2219
|
+
let logFd = fs5.openSync(logPath, "a", 384);
|
|
2220
|
+
const logStat = fs5.fstatSync(logFd);
|
|
2135
2221
|
if (logStat.size > 10 * 1024 * 1024) {
|
|
2136
|
-
|
|
2222
|
+
fs5.closeSync(logFd);
|
|
2137
2223
|
const log1 = `${logPath}.1`;
|
|
2138
2224
|
const log2 = `${logPath}.2`;
|
|
2139
2225
|
try {
|
|
2140
|
-
if (
|
|
2141
|
-
|
|
2226
|
+
if (fs5.existsSync(log2))
|
|
2227
|
+
fs5.unlinkSync(log2);
|
|
2142
2228
|
} catch {}
|
|
2143
2229
|
try {
|
|
2144
|
-
if (
|
|
2145
|
-
|
|
2230
|
+
if (fs5.existsSync(log1))
|
|
2231
|
+
fs5.renameSync(log1, log2);
|
|
2146
2232
|
} catch {}
|
|
2147
2233
|
try {
|
|
2148
|
-
|
|
2234
|
+
fs5.renameSync(logPath, log1);
|
|
2149
2235
|
} catch {}
|
|
2150
|
-
logFd =
|
|
2236
|
+
logFd = fs5.openSync(logPath, "a", 384);
|
|
2151
2237
|
}
|
|
2152
2238
|
const child = spawn2(process.execPath, [cliPath, "daemon", "run", "--port", String(port)], {
|
|
2153
2239
|
detached: true,
|
|
@@ -2158,7 +2244,7 @@ async function startDaemon(config, cliPath, secrets) {
|
|
|
2158
2244
|
}
|
|
2159
2245
|
});
|
|
2160
2246
|
child.unref();
|
|
2161
|
-
|
|
2247
|
+
fs5.writeFileSync(pidPath, `${child.pid}:${port}
|
|
2162
2248
|
`, { mode: 384 });
|
|
2163
2249
|
startBackgroundUpdateCheck();
|
|
2164
2250
|
await waitForGatewayReady(port, token);
|
|
@@ -2182,7 +2268,7 @@ function stopDaemon() {
|
|
|
2182
2268
|
const cmd = execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf8", timeout: 2000 }).trim();
|
|
2183
2269
|
const looksLikeMcpxDaemon = cmd.includes("daemon run") && (cmd.includes("mcpx") || cmd.includes("cli.js"));
|
|
2184
2270
|
if (!looksLikeMcpxDaemon) {
|
|
2185
|
-
|
|
2271
|
+
fs5.unlinkSync(pidPath);
|
|
2186
2272
|
return {
|
|
2187
2273
|
stopped: false,
|
|
2188
2274
|
message: `PID ${pid} is not a mcpx daemon (command: ${cmd.slice(0, 80)}). Pidfile cleaned up.`
|
|
@@ -2190,7 +2276,7 @@ function stopDaemon() {
|
|
|
2190
2276
|
}
|
|
2191
2277
|
} catch {
|
|
2192
2278
|
try {
|
|
2193
|
-
|
|
2279
|
+
fs5.unlinkSync(pidPath);
|
|
2194
2280
|
} catch {}
|
|
2195
2281
|
return {
|
|
2196
2282
|
stopped: false,
|
|
@@ -2201,7 +2287,7 @@ function stopDaemon() {
|
|
|
2201
2287
|
process.kill(pid, "SIGTERM");
|
|
2202
2288
|
} catch {}
|
|
2203
2289
|
try {
|
|
2204
|
-
|
|
2290
|
+
fs5.unlinkSync(pidPath);
|
|
2205
2291
|
} catch {}
|
|
2206
2292
|
return {
|
|
2207
2293
|
stopped: true,
|
|
@@ -2214,10 +2300,10 @@ async function restartDaemon(config, cliPath, secrets) {
|
|
|
2214
2300
|
}
|
|
2215
2301
|
function readDaemonLogs(maxLines = 200) {
|
|
2216
2302
|
const logPath = getLogPath();
|
|
2217
|
-
if (!
|
|
2303
|
+
if (!fs5.existsSync(logPath)) {
|
|
2218
2304
|
return "";
|
|
2219
2305
|
}
|
|
2220
|
-
const lines =
|
|
2306
|
+
const lines = fs5.readFileSync(logPath, "utf8").split(`
|
|
2221
2307
|
`);
|
|
2222
2308
|
return lines.slice(Math.max(lines.length - maxLines, 0)).join(`
|
|
2223
2309
|
`);
|
|
@@ -2230,7 +2316,9 @@ function runDaemonForeground(config, port, secrets) {
|
|
|
2230
2316
|
expectedToken: token,
|
|
2231
2317
|
secrets
|
|
2232
2318
|
});
|
|
2319
|
+
const stopMarketplaceUpdater = startMarketplaceAutoUpdater();
|
|
2233
2320
|
const cleanup = () => {
|
|
2321
|
+
stopMarketplaceUpdater();
|
|
2234
2322
|
server.close(() => resolve());
|
|
2235
2323
|
};
|
|
2236
2324
|
process.on("SIGINT", cleanup);
|
|
@@ -2360,4 +2448,4 @@ async function buildStatusReport(config, managedIndex, daemon = getDaemonStatus(
|
|
|
2360
2448
|
};
|
|
2361
2449
|
}
|
|
2362
2450
|
|
|
2363
|
-
export { probeHttpAuthRequirement, fetchRegistryServerDetail, selectBestPackage, extractRequiredInputs, mapRegistryToSpec, toSecretRef, secretRefName, defaultAuthSecretName, resolveAuthTarget, applyAuthReference, removeAuthReference, listAuthBindings, maybePrefixBearer, buildEnrichedPath, isOAuthReference, oauthReferenceServerName, runOAuthLogin, getOAuthAccessToken, compareVersions, checkForUpdates, getStagedUpdate, shouldUseStagedCli, clearStagedUpdate, getStagedCliPath, startBackgroundUpdateCheck, runBackgroundUpdate, performUpdate, performRollback, getDaemonStatus, startDaemon, stopDaemon, restartDaemon, readDaemonLogs, runDaemonForeground, STATUS_CLIENTS, buildStatusReport };
|
|
2451
|
+
export { probeHttpAuthRequirement, fetchRegistryServerDetail, selectBestPackage, extractRequiredInputs, mapRegistryToSpec, toSecretRef, secretRefName, defaultAuthSecretName, resolveAuthTarget, applyAuthReference, removeAuthReference, listAuthBindings, maybePrefixBearer, buildEnrichedPath, isOAuthReference, oauthReferenceServerName, runOAuthLogin, getOAuthAccessToken, compareVersions, checkForUpdates, getStagedUpdate, shouldUseStagedCli, clearStagedUpdate, getStagedCliPath, startBackgroundUpdateCheck, runBackgroundUpdate, performUpdate, performRollback, runMarketplaceAutoUpdate, startMarketplaceAutoUpdater, getDaemonStatus, startDaemon, stopDaemon, restartDaemon, readDaemonLogs, runDaemonForeground, STATUS_CLIENTS, buildStatusReport };
|