@yawlabs/mcp 0.79.2 → 0.80.0
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 +14 -5
- package/dist/auto-upgrade-OHFS4H24.js +23 -0
- package/dist/{chunk-ODSIFM3N.js → chunk-EXO2NR5I.js} +304 -131
- package/dist/index.js +4932 -4167
- package/package.json +1 -1
- package/dist/auto-upgrade-W6LVJ7XD.js +0 -15
|
@@ -2,18 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
// src/auto-upgrade.ts
|
|
4
4
|
import { spawn as spawn3 } from "child_process";
|
|
5
|
+
import { createHash } from "crypto";
|
|
5
6
|
import {
|
|
6
7
|
closeSync,
|
|
7
8
|
openSync,
|
|
8
|
-
readFileSync as
|
|
9
|
+
readFileSync as readFileSync3,
|
|
9
10
|
realpathSync as realpathSync2,
|
|
11
|
+
renameSync,
|
|
10
12
|
statSync as statSync2,
|
|
11
13
|
unlinkSync,
|
|
12
14
|
writeFileSync,
|
|
13
15
|
writeSync
|
|
14
16
|
} from "fs";
|
|
15
17
|
import { tmpdir } from "os";
|
|
16
|
-
import { dirname as dirname2, join as
|
|
18
|
+
import { dirname as dirname2, join as join4, sep as sep2 } from "path";
|
|
19
|
+
|
|
20
|
+
// src/internal-secret-env.ts
|
|
21
|
+
var INTERNAL_SECRET_ENV_KEYS = /* @__PURE__ */ new Set([
|
|
22
|
+
"YAW_MCP_TOKEN",
|
|
23
|
+
"YAW_MCP_VAULT_PASSPHRASE",
|
|
24
|
+
"YAW_MCP_VAULT_PASSPHRASE_NEW"
|
|
25
|
+
]);
|
|
26
|
+
function scrubInternalSecretsFromProcessEnv() {
|
|
27
|
+
for (const key of Object.keys(process.env)) {
|
|
28
|
+
if (INTERNAL_SECRET_ENV_KEYS.has(key.toUpperCase())) delete process.env[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function stripInternalSecretsFromEnv(env) {
|
|
32
|
+
const out = {};
|
|
33
|
+
for (const [key, value] of Object.entries(env)) {
|
|
34
|
+
if (INTERNAL_SECRET_ENV_KEYS.has(key.toUpperCase())) continue;
|
|
35
|
+
out[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
17
39
|
|
|
18
40
|
// src/logger.ts
|
|
19
41
|
var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
@@ -48,7 +70,8 @@ function log(level, msg, data) {
|
|
|
48
70
|
|
|
49
71
|
// src/upgrade-cmd.ts
|
|
50
72
|
import { spawn as spawn2 } from "child_process";
|
|
51
|
-
import { realpathSync } from "fs";
|
|
73
|
+
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
74
|
+
import { join as join3 } from "path";
|
|
52
75
|
|
|
53
76
|
// src/oam-spawn.ts
|
|
54
77
|
import { spawn } from "child_process";
|
|
@@ -93,7 +116,10 @@ var INSTALL_TARGETS = [
|
|
|
93
116
|
label: "Claude Desktop",
|
|
94
117
|
jsonShape: "mcpServers",
|
|
95
118
|
availableOn: ["macos", "windows"],
|
|
96
|
-
|
|
119
|
+
// ASCII `--`, not an em-dash: install prints this verbatim (`Note: ...`),
|
|
120
|
+
// and Claude Desktop is a Windows client -- on a console whose codepage is
|
|
121
|
+
// not UTF-8 the em-dash rendered as mojibake in the line the user reads.
|
|
122
|
+
notes: "Claude Desktop reads one file per OS -- no project scope. Restart the app after editing.",
|
|
97
123
|
scopes: [
|
|
98
124
|
{
|
|
99
125
|
scope: "user",
|
|
@@ -250,6 +276,7 @@ var KNOWN_DIRECT_BINARIES = /* @__PURE__ */ new Set([
|
|
|
250
276
|
"python",
|
|
251
277
|
"python3",
|
|
252
278
|
"py",
|
|
279
|
+
"uv",
|
|
253
280
|
"uvx",
|
|
254
281
|
"pipx",
|
|
255
282
|
"ruby",
|
|
@@ -379,17 +406,12 @@ function isUnderHome(dir, homeResolved) {
|
|
|
379
406
|
}
|
|
380
407
|
var ALLOW_UNOWNED_ENV = "YAW_MCP_ALLOW_UNOWNED_PROJECT_DIRS";
|
|
381
408
|
var warnedUntrustedDirs = /* @__PURE__ */ new Set();
|
|
382
|
-
|
|
409
|
+
function ownedByCurrentUser(st, env) {
|
|
383
410
|
const geteuid = process.geteuid;
|
|
384
|
-
if (typeof geteuid !== "function") return
|
|
385
|
-
|
|
386
|
-
const st = await stat(candidate);
|
|
387
|
-
return typeof st.uid === "number" && st.uid === geteuid.call(process);
|
|
388
|
-
} catch {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
411
|
+
if (typeof geteuid !== "function") return env[ALLOW_UNOWNED_ENV] === "1";
|
|
412
|
+
return typeof st.uid === "number" && st.uid === geteuid.call(process);
|
|
391
413
|
}
|
|
392
|
-
async function findProjectConfigDir(start, home = homedir2()) {
|
|
414
|
+
async function findProjectConfigDir(start, home = homedir2(), env = process.env) {
|
|
393
415
|
const homeFallback = home && home.length > 0 ? home : homedir2();
|
|
394
416
|
const homeResolved = path.resolve(await realpathOrSelf(path.resolve(homeFallback)));
|
|
395
417
|
let dir = path.resolve(await realpathOrSelf(path.resolve(start)));
|
|
@@ -405,7 +427,7 @@ async function findProjectConfigDir(start, home = homedir2()) {
|
|
|
405
427
|
log("debug", "Skipping a .yaw-mcp that exists but is not a directory", { candidate });
|
|
406
428
|
} else if (normalizeForCompare(await realpathOrSelf(candidate)) === userConfigKey) {
|
|
407
429
|
log("debug", "Skipping a .yaw-mcp/ that resolves to the user-global config dir", { candidate });
|
|
408
|
-
} else if (boundedByHome ||
|
|
430
|
+
} else if (boundedByHome || ownedByCurrentUser(st, env)) {
|
|
409
431
|
return candidate;
|
|
410
432
|
} else {
|
|
411
433
|
if (!warnedUntrustedDirs.has(candidate)) {
|
|
@@ -449,7 +471,10 @@ function specConstraint(spec) {
|
|
|
449
471
|
}
|
|
450
472
|
function isRegistrySpec(spec) {
|
|
451
473
|
if (spec.includes(":") || /^[./~\\]/.test(spec)) return false;
|
|
452
|
-
|
|
474
|
+
const m = /^(?:@([^/]+)\/)?([^./_][^/]*)$/.exec(packageName(spec));
|
|
475
|
+
if (!m) return false;
|
|
476
|
+
const [, scope, name] = m;
|
|
477
|
+
return (scope === void 0 || encodeURIComponent(scope) === scope) && encodeURIComponent(name) === name;
|
|
453
478
|
}
|
|
454
479
|
function npxSpecIndex(args) {
|
|
455
480
|
return args.findIndex((a) => a !== "-y" && a !== "--yes");
|
|
@@ -624,7 +649,11 @@ function spawnVersionProbe(bin) {
|
|
|
624
649
|
try {
|
|
625
650
|
child = spawn(bin, ["--version"], {
|
|
626
651
|
stdio: ["ignore", "pipe", "ignore"],
|
|
627
|
-
windowsHide: process.platform === "win32"
|
|
652
|
+
windowsHide: process.platform === "win32",
|
|
653
|
+
// oam is a binary yaw-mcp did not write; README promises the vault
|
|
654
|
+
// passphrase is stripped from every child yaw-mcp starts, and this
|
|
655
|
+
// probe was one of two spawns that still inherited process.env whole.
|
|
656
|
+
env: stripInternalSecretsFromEnv(process.env)
|
|
628
657
|
});
|
|
629
658
|
} catch (err) {
|
|
630
659
|
reject(err);
|
|
@@ -786,7 +815,7 @@ function rewriteForOam(command, args, deps) {
|
|
|
786
815
|
if (spec.startsWith("-")) {
|
|
787
816
|
log("debug", "npx launch carries flags yaw-mcp does not parse; staying on npx instead of oam", {
|
|
788
817
|
flag: spec,
|
|
789
|
-
args
|
|
818
|
+
argc: args.length
|
|
790
819
|
});
|
|
791
820
|
return { command, args };
|
|
792
821
|
}
|
|
@@ -821,6 +850,13 @@ function rewriteForOam(command, args, deps) {
|
|
|
821
850
|
return { command, args };
|
|
822
851
|
}
|
|
823
852
|
var NPX_CACHE_MARKER = `${sep}_npx${sep}`;
|
|
853
|
+
function npxHashNodeModules(npxRoot) {
|
|
854
|
+
try {
|
|
855
|
+
return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join2(npxRoot, e.name, "node_modules"));
|
|
856
|
+
} catch {
|
|
857
|
+
return [];
|
|
858
|
+
}
|
|
859
|
+
}
|
|
824
860
|
function npxCacheNodeModules(fromUrl = import.meta.url) {
|
|
825
861
|
let here;
|
|
826
862
|
try {
|
|
@@ -831,11 +867,7 @@ function npxCacheNodeModules(fromUrl = import.meta.url) {
|
|
|
831
867
|
const idx = here.indexOf(NPX_CACHE_MARKER);
|
|
832
868
|
if (idx === -1) return [];
|
|
833
869
|
const npxRoot = here.slice(0, idx + NPX_CACHE_MARKER.length - sep.length);
|
|
834
|
-
|
|
835
|
-
return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join2(npxRoot, e.name, "node_modules"));
|
|
836
|
-
} catch {
|
|
837
|
-
return [];
|
|
838
|
-
}
|
|
870
|
+
return npxHashNodeModules(npxRoot);
|
|
839
871
|
}
|
|
840
872
|
function npmrcValue(raw) {
|
|
841
873
|
const v = raw.trim();
|
|
@@ -879,12 +911,19 @@ function npmrcCache(file) {
|
|
|
879
911
|
for (const line of text.split(/\r?\n/)) {
|
|
880
912
|
const m = /^\s*cache\s*=(.*)$/.exec(line);
|
|
881
913
|
if (!m) continue;
|
|
882
|
-
const value = npmrcValue(m[1]);
|
|
914
|
+
const value = expandNpmrcEnv(npmrcValue(m[1]));
|
|
883
915
|
if (!value) continue;
|
|
884
916
|
last = value.startsWith("~/") ? join2(homedir3(), value.slice(2)) : value;
|
|
885
917
|
}
|
|
886
918
|
return last;
|
|
887
919
|
}
|
|
920
|
+
function expandNpmrcEnv(value, env = process.env) {
|
|
921
|
+
return value.replace(/(\\*)\$\{([^${}]+)\}/g, (orig, esc, name) => {
|
|
922
|
+
if (esc.length % 2 === 1) return orig.slice((esc.length + 1) / 2);
|
|
923
|
+
const val = env[name];
|
|
924
|
+
return esc.slice(esc.length / 2) + (val === void 0 ? `\${${name}}` : val);
|
|
925
|
+
});
|
|
926
|
+
}
|
|
888
927
|
var npmCacheDirCache = /* @__PURE__ */ new Map();
|
|
889
928
|
function npmCacheDir(fromUrl = import.meta.url) {
|
|
890
929
|
const cached = npmCacheDirCache.get(fromUrl);
|
|
@@ -924,12 +963,7 @@ function resolveNpmCacheDir(fromUrl) {
|
|
|
924
963
|
}
|
|
925
964
|
function npmCacheNpxNodeModules(cacheDir2) {
|
|
926
965
|
if (!cacheDir2) return [];
|
|
927
|
-
|
|
928
|
-
try {
|
|
929
|
-
return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join2(npxRoot, e.name, "node_modules"));
|
|
930
|
-
} catch {
|
|
931
|
-
return [];
|
|
932
|
-
}
|
|
966
|
+
return npxHashNodeModules(join2(cacheDir2, "_npx"));
|
|
933
967
|
}
|
|
934
968
|
function ownNodeModules(fromUrl = import.meta.url) {
|
|
935
969
|
let here;
|
|
@@ -946,21 +980,25 @@ function ownNodeModules(fromUrl = import.meta.url) {
|
|
|
946
980
|
function packageEntry(pkgDir, pkg) {
|
|
947
981
|
const pjPath = join2(pkgDir, "package.json");
|
|
948
982
|
if (!existsSync(pjPath)) return null;
|
|
949
|
-
let
|
|
983
|
+
let parsed;
|
|
950
984
|
try {
|
|
951
|
-
|
|
985
|
+
parsed = JSON.parse(readFileSync(pjPath, "utf8"));
|
|
952
986
|
} catch {
|
|
953
987
|
return null;
|
|
954
988
|
}
|
|
989
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
990
|
+
const j = parsed;
|
|
955
991
|
let rel;
|
|
956
992
|
if (typeof j.bin === "string") {
|
|
957
993
|
rel = j.bin;
|
|
958
994
|
} else if (j.bin && typeof j.bin === "object") {
|
|
995
|
+
const bins = j.bin;
|
|
996
|
+
const own = (key) => typeof key === "string" && Object.hasOwn(bins, key) ? bins[key] : void 0;
|
|
959
997
|
const unscoped = pkg.slice(pkg.lastIndexOf("/") + 1);
|
|
960
|
-
rel =
|
|
998
|
+
rel = own(unscoped) ?? own(j.name) ?? Object.values(bins)[0];
|
|
961
999
|
}
|
|
962
1000
|
if (!rel && typeof j.main === "string") rel = j.main;
|
|
963
|
-
if (
|
|
1001
|
+
if (typeof rel !== "string" || rel.length === 0) return null;
|
|
964
1002
|
const entry = isAbsolute2(rel) ? rel : join2(pkgDir, rel);
|
|
965
1003
|
if (!existsSync(entry)) return null;
|
|
966
1004
|
return {
|
|
@@ -1120,7 +1158,6 @@ function isOamLaunch(command, args = []) {
|
|
|
1120
1158
|
}
|
|
1121
1159
|
|
|
1122
1160
|
// src/upgrade-cmd.ts
|
|
1123
|
-
var BINARY_RETIRED_HINT = "the standalone-binary track was retired in 0.70.3. Install from npm instead -- `npm install -g @yawlabs/mcp@latest` -- then delete this executable.";
|
|
1124
1161
|
var POSIX_GLOBAL_LIB_PREFIX = /^(?:[A-Za-z]:)?(?:\/usr(?:\/local)?|\/opt\/[^/]+)\/lib\/node_modules\/@yawlabs\/mcp\//;
|
|
1125
1162
|
var MANAGED_NODE_LIB_PREFIX = /\/(?:\.nvm\/versions\/node\/[^/]+|\.volta\/tools\/image\/node\/[^/]+|\.asdf\/installs\/nodejs\/[^/]+|(?:\.local\/share\/)?\.?fnm\/node-versions\/[^/]+\/installation|\.nodenv\/versions\/[^/]+|\.nvs\/[^/]+\/[^/]+\/[^/]+|n\/versions\/node\/[^/]+|\.local)\/lib\/node_modules\/@yawlabs\/mcp\//;
|
|
1126
1163
|
var UPGRADE_USAGE = `Usage: yaw-mcp upgrade [--run] [--json]
|
|
@@ -1151,10 +1188,10 @@ ${UPGRADE_USAGE}` };
|
|
|
1151
1188
|
}
|
|
1152
1189
|
return { ok: true, options: opts };
|
|
1153
1190
|
}
|
|
1154
|
-
function detectInstallMethod(argvPath, realpath2 = realpathSync) {
|
|
1191
|
+
function detectInstallMethod(argvPath, realpath2 = realpathSync, resolveWhen = ["unknown"]) {
|
|
1155
1192
|
if (!argvPath) return "unknown";
|
|
1156
1193
|
const literal = classifyEntrypoint(argvPath);
|
|
1157
|
-
if (literal
|
|
1194
|
+
if (!resolveWhen.includes(literal)) return literal;
|
|
1158
1195
|
let resolved;
|
|
1159
1196
|
try {
|
|
1160
1197
|
resolved = realpath2(argvPath);
|
|
@@ -1183,6 +1220,30 @@ function localInstallRoot(argvPath) {
|
|
|
1183
1220
|
const idx = argvPath.replace(/\\/g, "/").indexOf("/node_modules/");
|
|
1184
1221
|
return idx > 0 ? argvPath.slice(0, idx) : null;
|
|
1185
1222
|
}
|
|
1223
|
+
function runningPackageDir(argvPath, realpath2 = realpathSync) {
|
|
1224
|
+
if (!argvPath) return null;
|
|
1225
|
+
const literal = packageDirOf(argvPath);
|
|
1226
|
+
if (literal !== null) return literal;
|
|
1227
|
+
try {
|
|
1228
|
+
return packageDirOf(realpath2(argvPath));
|
|
1229
|
+
} catch {
|
|
1230
|
+
return null;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
function packageDirOf(p) {
|
|
1234
|
+
const marker = "/node_modules/@yawlabs/mcp/";
|
|
1235
|
+
const idx = p.replace(/\\/g, "/").lastIndexOf(marker);
|
|
1236
|
+
return idx === -1 ? null : p.slice(0, idx + marker.length - 1);
|
|
1237
|
+
}
|
|
1238
|
+
function defaultInstalledVersion(pkgDir) {
|
|
1239
|
+
if (process.env.VITEST) return null;
|
|
1240
|
+
try {
|
|
1241
|
+
const parsed = JSON.parse(readFileSync2(join3(pkgDir, "package.json"), "utf8"));
|
|
1242
|
+
return typeof parsed.version === "string" ? parsed.version : null;
|
|
1243
|
+
} catch {
|
|
1244
|
+
return null;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1186
1247
|
function killProcessTree(child, platform = process.platform, spawnImpl = spawn2) {
|
|
1187
1248
|
if (platform === "win32" && child.pid !== void 0) {
|
|
1188
1249
|
try {
|
|
@@ -1193,12 +1254,16 @@ function killProcessTree(child, platform = process.platform, spawnImpl = spawn2)
|
|
|
1193
1254
|
}
|
|
1194
1255
|
child.kill();
|
|
1195
1256
|
}
|
|
1196
|
-
async function npmGlobalPrefix() {
|
|
1197
|
-
if (process.env.VITEST) return null;
|
|
1257
|
+
async function npmGlobalPrefix(spawnImpl) {
|
|
1258
|
+
if (process.env.VITEST && !spawnImpl) return null;
|
|
1259
|
+
const spawnFn = spawnImpl ?? spawn2;
|
|
1198
1260
|
return new Promise((resolve2) => {
|
|
1199
|
-
const child =
|
|
1261
|
+
const child = spawnFn("npm", ["prefix", "-g"], {
|
|
1200
1262
|
shell: process.platform === "win32",
|
|
1201
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
1263
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
1264
|
+
// Even a read-only `npm prefix -g` is an npm invocation: yaw-mcp's own
|
|
1265
|
+
// secrets do not ride into it. See internal-secret-env.ts.
|
|
1266
|
+
env: stripInternalSecretsFromEnv(process.env)
|
|
1202
1267
|
});
|
|
1203
1268
|
let out = "";
|
|
1204
1269
|
const timer = setTimeout(() => {
|
|
@@ -1239,38 +1304,58 @@ async function refineInstallMethod(method, argvPath, npmPrefix = npmGlobalPrefix
|
|
|
1239
1304
|
}
|
|
1240
1305
|
return method;
|
|
1241
1306
|
}
|
|
1307
|
+
var UPGRADE_PACKAGE_SPEC = "@yawlabs/mcp@latest";
|
|
1308
|
+
var UPGRADE_COMMANDS = {
|
|
1309
|
+
"global-npm": { cmd: "npm", args: ["install", "-g", UPGRADE_PACKAGE_SPEC] },
|
|
1310
|
+
"pnpm-global": { cmd: "pnpm", args: ["add", "-g", UPGRADE_PACKAGE_SPEC] },
|
|
1311
|
+
"bun-global": { cmd: "bun", args: ["add", "-g", UPGRADE_PACKAGE_SPEC] },
|
|
1312
|
+
"local-node-modules": { cmd: "npm", args: ["install", UPGRADE_PACKAGE_SPEC] },
|
|
1313
|
+
npx: null,
|
|
1314
|
+
"bundled-app": null,
|
|
1315
|
+
"dev-checkout": null,
|
|
1316
|
+
binary: null,
|
|
1317
|
+
unknown: null
|
|
1318
|
+
};
|
|
1319
|
+
var GLOBAL_UPGRADE_METHODS = ["global-npm", "pnpm-global", "bun-global"];
|
|
1320
|
+
function upgradeSpawnSpec(method, prefixArg = null) {
|
|
1321
|
+
const base = UPGRADE_COMMANDS[method];
|
|
1322
|
+
if (base === null) return null;
|
|
1323
|
+
const args = [...base.args];
|
|
1324
|
+
if (method === "global-npm" && prefixArg !== null) args.splice(args.length - 1, 0, "--prefix", prefixArg);
|
|
1325
|
+
return { cmd: base.cmd, args };
|
|
1326
|
+
}
|
|
1327
|
+
function upgradeCommandLine(method) {
|
|
1328
|
+
const spec = upgradeSpawnSpec(method);
|
|
1329
|
+
return spec === null ? null : [spec.cmd, ...spec.args].join(" ");
|
|
1330
|
+
}
|
|
1331
|
+
var BINARY_RETIRED_HINT = `the standalone-binary track was retired in 0.70.3. Install from npm instead -- \`${upgradeCommandLine("global-npm")}\` -- then delete this executable.`;
|
|
1332
|
+
function globalUpgradeCommandLineForTool(tool) {
|
|
1333
|
+
const method = GLOBAL_UPGRADE_METHODS.find((m) => UPGRADE_COMMANDS[m]?.cmd === tool);
|
|
1334
|
+
return method === void 0 ? null : upgradeCommandLine(method);
|
|
1335
|
+
}
|
|
1242
1336
|
function buildUpgradePlan(input) {
|
|
1243
1337
|
const { current, latest, method } = input;
|
|
1244
1338
|
const stripV = (s) => s.startsWith("v") ? s.slice(1) : s;
|
|
1245
1339
|
const stale = latest !== null && current !== "dev" && compareVersions(stripV(current), stripV(latest)) < 0;
|
|
1246
1340
|
let command;
|
|
1247
1341
|
switch (method) {
|
|
1248
|
-
case "global-npm":
|
|
1249
|
-
command = "npm install -g @yawlabs/mcp@latest";
|
|
1250
|
-
break;
|
|
1251
|
-
case "pnpm-global":
|
|
1252
|
-
command = "pnpm add -g @yawlabs/mcp@latest";
|
|
1253
|
-
break;
|
|
1254
|
-
case "bun-global":
|
|
1255
|
-
command = "bun add -g @yawlabs/mcp@latest";
|
|
1256
|
-
break;
|
|
1257
1342
|
case "npx":
|
|
1258
1343
|
command = null;
|
|
1259
1344
|
break;
|
|
1260
1345
|
case "bundled-app":
|
|
1261
1346
|
command = null;
|
|
1262
1347
|
break;
|
|
1263
|
-
case "
|
|
1264
|
-
command =
|
|
1348
|
+
case "binary":
|
|
1349
|
+
command = null;
|
|
1265
1350
|
break;
|
|
1266
1351
|
case "dev-checkout":
|
|
1267
1352
|
command = "git pull && npm run build";
|
|
1268
1353
|
break;
|
|
1269
|
-
case "
|
|
1270
|
-
command =
|
|
1354
|
+
case "unknown":
|
|
1355
|
+
command = upgradeCommandLine("global-npm");
|
|
1271
1356
|
break;
|
|
1272
1357
|
default:
|
|
1273
|
-
command =
|
|
1358
|
+
command = upgradeCommandLine(method);
|
|
1274
1359
|
break;
|
|
1275
1360
|
}
|
|
1276
1361
|
return { current, latest, stale, method, command };
|
|
@@ -1328,12 +1413,21 @@ async function oamFloorLines(probe) {
|
|
|
1328
1413
|
}
|
|
1329
1414
|
async function defaultRunningPrefix(argvPath) {
|
|
1330
1415
|
if (process.env.VITEST) return null;
|
|
1331
|
-
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-
|
|
1416
|
+
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-OHFS4H24.js");
|
|
1332
1417
|
return detectRunningInstallPrefix2(argvPath);
|
|
1333
1418
|
}
|
|
1334
1419
|
async function defaultSpawn(cmd, args, cwd) {
|
|
1335
1420
|
return new Promise((resolve2) => {
|
|
1336
|
-
const child = spawn2(cmd, args, {
|
|
1421
|
+
const child = spawn2(cmd, args, {
|
|
1422
|
+
stdio: "inherit",
|
|
1423
|
+
shell: process.platform === "win32",
|
|
1424
|
+
cwd,
|
|
1425
|
+
// yaw-mcp's own secrets stay out of the install: npm runs every
|
|
1426
|
+
// dependency's pre/postinstall with this env, and a passphrase parked
|
|
1427
|
+
// in yaw-mcp's env block (where README says to put it) must not reach
|
|
1428
|
+
// them. See internal-secret-env.ts.
|
|
1429
|
+
env: stripInternalSecretsFromEnv(process.env)
|
|
1430
|
+
});
|
|
1337
1431
|
child.on("close", (code) => resolve2(typeof code === "number" ? code : 1));
|
|
1338
1432
|
child.on("error", () => resolve2(1));
|
|
1339
1433
|
});
|
|
@@ -1380,12 +1474,13 @@ async function runUpgrade(opts = {}) {
|
|
|
1380
1474
|
if (method === "global-npm") {
|
|
1381
1475
|
const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
|
|
1382
1476
|
if (rawPrefix !== null) {
|
|
1383
|
-
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-
|
|
1477
|
+
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-OHFS4H24.js");
|
|
1384
1478
|
const spawnForm = quoteShellArgIfNeeded2(rawPrefix, opts.platform);
|
|
1385
1479
|
const displayForm = quoteArgForDisplay2(rawPrefix, opts.platform);
|
|
1386
1480
|
if (spawnForm !== null && displayForm !== null) {
|
|
1387
1481
|
globalPrefixArg = spawnForm;
|
|
1388
|
-
|
|
1482
|
+
const spec2 = upgradeSpawnSpec("global-npm", displayForm);
|
|
1483
|
+
suggestedCommand = spec2 === null ? null : [spec2.cmd, ...spec2.args].join(" ");
|
|
1389
1484
|
}
|
|
1390
1485
|
}
|
|
1391
1486
|
}
|
|
@@ -1404,11 +1499,11 @@ async function runUpgrade(opts = {}) {
|
|
|
1404
1499
|
}
|
|
1405
1500
|
print(` ${suggestedCommand}`);
|
|
1406
1501
|
} else if (method === "bundled-app") {
|
|
1407
|
-
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app
|
|
1502
|
+
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app -- nothing to run.");
|
|
1408
1503
|
} else if (method === "binary") {
|
|
1409
1504
|
print(`yaw-mcp is a standalone binary; ${BINARY_RETIRED_HINT}`);
|
|
1410
1505
|
} else {
|
|
1411
|
-
print("Your install uses `npx -y`
|
|
1506
|
+
print("Your install uses `npx -y` -- just restart the MCP client when you're back online.");
|
|
1412
1507
|
}
|
|
1413
1508
|
for (const line of await oamFloorLines(opts.oamProbe)) print(line);
|
|
1414
1509
|
return { exitCode: 0, lines };
|
|
@@ -1424,33 +1519,22 @@ async function runUpgrade(opts = {}) {
|
|
|
1424
1519
|
}
|
|
1425
1520
|
print("");
|
|
1426
1521
|
if (method === "npx") {
|
|
1427
|
-
print("Your install uses `npx -y`
|
|
1522
|
+
print("Your install uses `npx -y` -- restart the MCP client and it will fetch the new version.");
|
|
1428
1523
|
return { exitCode: 0, lines };
|
|
1429
1524
|
}
|
|
1430
1525
|
if (method === "bundled-app") {
|
|
1431
|
-
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app
|
|
1526
|
+
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app --");
|
|
1432
1527
|
print("there is nothing to run here. Update Yaw Terminal to get the new version.");
|
|
1433
1528
|
return { exitCode: 0, lines };
|
|
1434
1529
|
}
|
|
1435
1530
|
if (method === "binary") {
|
|
1436
1531
|
const emit = opts.run ? printErr : print;
|
|
1437
|
-
emit("yaw-mcp is running as a standalone binary
|
|
1532
|
+
emit("yaw-mcp is running as a standalone binary -- manual upgrade required.");
|
|
1438
1533
|
emit(`There's no package manager to upgrade it, and \`--run\` can't automate this: ${BINARY_RETIRED_HINT}`);
|
|
1439
1534
|
return { exitCode: opts.run ? 2 : 1, lines };
|
|
1440
1535
|
}
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
args: globalPrefixArg ? ["install", "-g", "--prefix", globalPrefixArg, "@yawlabs/mcp@latest"] : ["install", "-g", "@yawlabs/mcp@latest"]
|
|
1444
|
-
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : (
|
|
1445
|
-
// The `installRoot !== null` arm is defensive-dead, kept only so a
|
|
1446
|
-
// future localInstallRoot change cannot produce `cwd: undefined`
|
|
1447
|
-
// and silently install into the process cwd: localInstallRoot
|
|
1448
|
-
// returns null exactly when `/node_modules/` sits at index 0, i.e.
|
|
1449
|
-
// a node_modules directory at the filesystem root, which no real
|
|
1450
|
-
// classification produces (detectInstallMethod only labels a path
|
|
1451
|
-
// local-node-modules when there is a tree above it).
|
|
1452
|
-
method === "local-node-modules" && installRoot !== null ? { cmd: "npm", args: ["install", "@yawlabs/mcp@latest"], cwd: installRoot } : null
|
|
1453
|
-
);
|
|
1536
|
+
const spec = upgradeSpawnSpec(method, globalPrefixArg);
|
|
1537
|
+
const runSpec = spec === null ? null : method === "local-node-modules" ? installRoot !== null ? { ...spec, cwd: installRoot } : null : spec;
|
|
1454
1538
|
const commandLine = method === "global-npm" ? suggestedCommand : runSpec ? [runSpec.cmd, ...runSpec.args].join(" ") : plan.command;
|
|
1455
1539
|
if (!opts.run) {
|
|
1456
1540
|
if (runSpec) {
|
|
@@ -1485,6 +1569,17 @@ async function runUpgrade(opts = {}) {
|
|
|
1485
1569
|
if (code === 0) {
|
|
1486
1570
|
print("");
|
|
1487
1571
|
print(`OK: Upgraded @yawlabs/mcp to ${latest}`);
|
|
1572
|
+
const pkgDir = runningPackageDir(argvPath);
|
|
1573
|
+
const running = pkgDir === null ? null : await (opts.installedVersion ?? defaultInstalledVersion)(pkgDir);
|
|
1574
|
+
const bare = (s) => s.startsWith("v") ? s.slice(1) : s;
|
|
1575
|
+
if (running !== null && compareVersions(bare(running), bare(latest)) < 0) {
|
|
1576
|
+
printErr("");
|
|
1577
|
+
printErr(`WARNING: the copy this command ran from still reports ${running}, not ${latest}:`);
|
|
1578
|
+
printErr(` ${pkgDir}`);
|
|
1579
|
+
printErr(
|
|
1580
|
+
"The install landed in a different tree, so your MCP client keeps spawning the old version until that tree is upgraded too (for a copy nested under another package's node_modules, upgrade the package that pins it)."
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1488
1583
|
return { exitCode: 0, lines };
|
|
1489
1584
|
}
|
|
1490
1585
|
printErr(`yaw-mcp upgrade: ${runSpec.cmd} exited ${code}. Try running the command yourself:`);
|
|
@@ -1496,7 +1591,7 @@ async function runUpgrade(opts = {}) {
|
|
|
1496
1591
|
return { exitCode: 3, lines };
|
|
1497
1592
|
}
|
|
1498
1593
|
function readCurrentVersion() {
|
|
1499
|
-
return true ? "0.
|
|
1594
|
+
return true ? "0.80.0" : "dev";
|
|
1500
1595
|
}
|
|
1501
1596
|
|
|
1502
1597
|
// src/auto-upgrade.ts
|
|
@@ -1530,19 +1625,34 @@ async function compareWithNpmPrefix(detected, probe = npmGlobalPrefix) {
|
|
|
1530
1625
|
const npmPrefix = await probe();
|
|
1531
1626
|
if (!npmPrefix?.trim()) return;
|
|
1532
1627
|
if (comparablePath(npmPrefix.trim()) === comparablePath(detected)) return;
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
Installing into the running prefix so the upgrade lands in the same tree the client spawned from.
|
|
1538
|
-
`
|
|
1628
|
+
log(
|
|
1629
|
+
"warn",
|
|
1630
|
+
"yaw-mcp self-upgrade: running prefix differs from `npm prefix -g`; installing into the running prefix so the upgrade lands in the tree the client spawned from",
|
|
1631
|
+
{ running: detected, npmPrefix }
|
|
1539
1632
|
);
|
|
1540
1633
|
}
|
|
1541
1634
|
var UPGRADE_LOCK_NAME = ".yaw-mcp-upgrade.lock";
|
|
1542
1635
|
var UPGRADE_LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
1543
1636
|
var UPGRADE_LOCK_FUTURE_SKEW_MS = 5 * 1e3;
|
|
1544
|
-
function
|
|
1545
|
-
|
|
1637
|
+
function lockHolderAlive(lockPath) {
|
|
1638
|
+
let pid;
|
|
1639
|
+
try {
|
|
1640
|
+
pid = Number.parseInt(readFileSync3(lockPath, "utf8").trim(), 10);
|
|
1641
|
+
} catch {
|
|
1642
|
+
return true;
|
|
1643
|
+
}
|
|
1644
|
+
if (!Number.isInteger(pid) || pid <= 0) return true;
|
|
1645
|
+
if (pid === process.pid) return true;
|
|
1646
|
+
try {
|
|
1647
|
+
process.kill(pid, 0);
|
|
1648
|
+
return true;
|
|
1649
|
+
} catch (err) {
|
|
1650
|
+
return err.code !== "ESRCH";
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
function acquireUpgradeLock(dir, lockName = UPGRADE_LOCK_NAME, opts = {}) {
|
|
1654
|
+
const lockPath = join4(dir, lockName);
|
|
1655
|
+
const holderAlive = (path2) => opts.probeHolder ? lockHolderAlive(path2) : true;
|
|
1546
1656
|
const mine = String(process.pid);
|
|
1547
1657
|
const take = () => {
|
|
1548
1658
|
try {
|
|
@@ -1558,7 +1668,7 @@ function acquireUpgradeLock(dir, lockName = UPGRADE_LOCK_NAME) {
|
|
|
1558
1668
|
if (released) return;
|
|
1559
1669
|
released = true;
|
|
1560
1670
|
try {
|
|
1561
|
-
if (
|
|
1671
|
+
if (readFileSync3(lockPath, "utf8").trim() !== mine) return;
|
|
1562
1672
|
unlinkSync(lockPath);
|
|
1563
1673
|
} catch {
|
|
1564
1674
|
}
|
|
@@ -1571,17 +1681,47 @@ function acquireUpgradeLock(dir, lockName = UPGRADE_LOCK_NAME) {
|
|
|
1571
1681
|
};
|
|
1572
1682
|
const first = take();
|
|
1573
1683
|
if (first !== void 0) return first;
|
|
1684
|
+
const isLive = (ageMs2) => ageMs2 > -UPGRADE_LOCK_FUTURE_SKEW_MS && ageMs2 < UPGRADE_LOCK_STALE_MS;
|
|
1574
1685
|
let ageMs;
|
|
1575
1686
|
try {
|
|
1576
1687
|
ageMs = Date.now() - statSync2(lockPath).mtimeMs;
|
|
1577
1688
|
} catch {
|
|
1578
1689
|
ageMs = UPGRADE_LOCK_STALE_MS;
|
|
1579
1690
|
}
|
|
1580
|
-
if (ageMs
|
|
1691
|
+
if (isLive(ageMs) && holderAlive(lockPath)) return null;
|
|
1692
|
+
const stolenPath = `${lockPath}.stale-${process.pid}`;
|
|
1581
1693
|
try {
|
|
1582
|
-
|
|
1694
|
+
renameSync(lockPath, stolenPath);
|
|
1583
1695
|
} catch (err) {
|
|
1584
1696
|
if (err.code !== "ENOENT") return null;
|
|
1697
|
+
const retry = take();
|
|
1698
|
+
return retry === void 0 ? null : retry;
|
|
1699
|
+
}
|
|
1700
|
+
let stoleLive = false;
|
|
1701
|
+
try {
|
|
1702
|
+
stoleLive = isLive(Date.now() - statSync2(stolenPath).mtimeMs) && holderAlive(stolenPath);
|
|
1703
|
+
} catch {
|
|
1704
|
+
}
|
|
1705
|
+
if (stoleLive) {
|
|
1706
|
+
try {
|
|
1707
|
+
const holder = readFileSync3(stolenPath, "utf8");
|
|
1708
|
+
const fd = openSync(lockPath, "wx");
|
|
1709
|
+
try {
|
|
1710
|
+
writeSync(fd, holder);
|
|
1711
|
+
} finally {
|
|
1712
|
+
closeSync(fd);
|
|
1713
|
+
}
|
|
1714
|
+
} catch {
|
|
1715
|
+
}
|
|
1716
|
+
try {
|
|
1717
|
+
unlinkSync(stolenPath);
|
|
1718
|
+
} catch {
|
|
1719
|
+
}
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
try {
|
|
1723
|
+
unlinkSync(stolenPath);
|
|
1724
|
+
} catch {
|
|
1585
1725
|
}
|
|
1586
1726
|
const second = take();
|
|
1587
1727
|
return second === void 0 ? null : second;
|
|
@@ -1593,51 +1733,76 @@ function defaultAcquireLock(dir, lockName) {
|
|
|
1593
1733
|
}
|
|
1594
1734
|
var UPGRADE_CHECK_INTERVAL_MS = 60 * 60 * 1e3;
|
|
1595
1735
|
var UPGRADE_ATTEMPT_COOLDOWN_MS = 6 * 60 * 60 * 1e3;
|
|
1596
|
-
function
|
|
1736
|
+
function readMemo(path2) {
|
|
1597
1737
|
let parsed;
|
|
1598
1738
|
try {
|
|
1599
|
-
parsed = JSON.parse(
|
|
1739
|
+
parsed = JSON.parse(readFileSync3(path2, "utf8"));
|
|
1600
1740
|
} catch {
|
|
1601
1741
|
return null;
|
|
1602
1742
|
}
|
|
1603
1743
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
1604
1744
|
const memo = parsed;
|
|
1605
1745
|
if (typeof memo.at !== "number") return null;
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
return age < -UPGRADE_LOCK_FUTURE_SKEW_MS ? null : age;
|
|
1746
|
+
const ageMs = Date.now() - memo.at;
|
|
1747
|
+
return ageMs < -UPGRADE_LOCK_FUTURE_SKEW_MS ? null : { ageMs, memo };
|
|
1609
1748
|
}
|
|
1610
|
-
function writeMemo(path2,
|
|
1611
|
-
const memo = version === null ? { at: Date.now() } : { at: Date.now(), version };
|
|
1749
|
+
function writeMemo(path2, fields) {
|
|
1612
1750
|
try {
|
|
1613
|
-
writeFileSync(path2, `${JSON.stringify(
|
|
1751
|
+
writeFileSync(path2, `${JSON.stringify({ at: Date.now(), ...fields })}
|
|
1614
1752
|
`);
|
|
1615
1753
|
} catch {
|
|
1616
1754
|
}
|
|
1617
1755
|
}
|
|
1618
1756
|
function checkMemoPath() {
|
|
1619
|
-
return
|
|
1757
|
+
return join4(tmpdir(), `.yaw-mcp-upgrade-check-${process.getuid?.() ?? "win"}.json`);
|
|
1758
|
+
}
|
|
1759
|
+
function readCheckMemo(path2) {
|
|
1760
|
+
const read = readMemo(path2);
|
|
1761
|
+
if (read === null || read.ageMs >= UPGRADE_CHECK_INTERVAL_MS) return null;
|
|
1762
|
+
const latest = read.memo.latest;
|
|
1763
|
+
if (latest !== null && typeof latest !== "string") return null;
|
|
1764
|
+
return { latest };
|
|
1765
|
+
}
|
|
1766
|
+
function writeCheckMemo(path2, latest) {
|
|
1767
|
+
writeMemo(path2, { latest });
|
|
1620
1768
|
}
|
|
1621
1769
|
function attemptMemoPath(dir, lockName) {
|
|
1622
|
-
return
|
|
1770
|
+
return join4(dir, `${lockName}.attempt`);
|
|
1771
|
+
}
|
|
1772
|
+
function attemptMemoFallbackPath(dir, lockName, fallbackDir) {
|
|
1773
|
+
const scope = createHash("sha256").update(`${dir}\0${lockName}`).digest("hex").slice(0, 16);
|
|
1774
|
+
return join4(fallbackDir, `.yaw-mcp-upgrade-attempt-${process.getuid?.() ?? "win"}-${scope}.json`);
|
|
1623
1775
|
}
|
|
1624
1776
|
function defaultCheckedRecently() {
|
|
1625
|
-
if (process.env.VITEST) return
|
|
1626
|
-
|
|
1627
|
-
return age !== null && age < UPGRADE_CHECK_INTERVAL_MS;
|
|
1777
|
+
if (process.env.VITEST) return null;
|
|
1778
|
+
return readCheckMemo(checkMemoPath());
|
|
1628
1779
|
}
|
|
1629
|
-
function defaultRecordCheck() {
|
|
1780
|
+
function defaultRecordCheck(latest) {
|
|
1630
1781
|
if (process.env.VITEST) return;
|
|
1631
|
-
|
|
1782
|
+
writeCheckMemo(checkMemoPath(), latest);
|
|
1632
1783
|
}
|
|
1633
1784
|
function defaultAttemptedRecently(dir, lockName, version) {
|
|
1634
1785
|
if (process.env.VITEST) return false;
|
|
1635
|
-
|
|
1636
|
-
return age !== null && age < UPGRADE_ATTEMPT_COOLDOWN_MS;
|
|
1786
|
+
return attemptedRecentlyAt(dir, lockName, version);
|
|
1637
1787
|
}
|
|
1638
1788
|
function defaultRecordAttempt(dir, lockName, version) {
|
|
1639
1789
|
if (process.env.VITEST) return;
|
|
1640
|
-
|
|
1790
|
+
recordAttemptAt(dir, lockName, version);
|
|
1791
|
+
}
|
|
1792
|
+
function attemptedRecentlyAt(dir, lockName, version, fallbackDir = tmpdir()) {
|
|
1793
|
+
const recent = (read) => read !== null && read.memo.version === version && read.ageMs < UPGRADE_ATTEMPT_COOLDOWN_MS;
|
|
1794
|
+
if (recent(readMemo(attemptMemoPath(dir, lockName)))) return true;
|
|
1795
|
+
return recent(readMemo(attemptMemoFallbackPath(dir, lockName, fallbackDir)));
|
|
1796
|
+
}
|
|
1797
|
+
function recordAttemptAt(dir, lockName, version, fallbackDir = tmpdir()) {
|
|
1798
|
+
const primary = attemptMemoPath(dir, lockName);
|
|
1799
|
+
try {
|
|
1800
|
+
writeFileSync(primary, `${JSON.stringify({ at: Date.now(), version })}
|
|
1801
|
+
`);
|
|
1802
|
+
return;
|
|
1803
|
+
} catch {
|
|
1804
|
+
}
|
|
1805
|
+
writeMemo(attemptMemoFallbackPath(dir, lockName, fallbackDir), { version });
|
|
1641
1806
|
}
|
|
1642
1807
|
function defaultSpawn2(cmd, args, onDone = () => {
|
|
1643
1808
|
}) {
|
|
@@ -1648,9 +1813,17 @@ function defaultSpawn2(cmd, args, onDone = () => {
|
|
|
1648
1813
|
released = true;
|
|
1649
1814
|
onDone();
|
|
1650
1815
|
};
|
|
1651
|
-
const correctiveCmd = cmd
|
|
1816
|
+
const correctiveCmd = globalUpgradeCommandLineForTool(cmd);
|
|
1652
1817
|
const child = spawn3(cmd, args, {
|
|
1653
1818
|
stdio: "ignore",
|
|
1819
|
+
// yaw-mcp's own secrets stay out of the install. npm runs every
|
|
1820
|
+
// dependency's pre/postinstall with this env, and README tells the user to
|
|
1821
|
+
// put YAW_MCP_VAULT_PASSPHRASE in yaw-mcp's env block precisely because
|
|
1822
|
+
// "yaw-mcp strips its own secrets from every child env" -- a promise the
|
|
1823
|
+
// upstream spawn kept and this one, spawning with the full inherited
|
|
1824
|
+
// process.env, silently did not: a compromised transitive dependency's
|
|
1825
|
+
// install script plus ~/.yaw-mcp/secrets.json was the whole vault.
|
|
1826
|
+
env: stripInternalSecretsFromEnv(process.env),
|
|
1654
1827
|
// Not detached, so the install shares yaw-mcp's process group and an MCP
|
|
1655
1828
|
// client that tears down the whole tree takes it with it. Two things this
|
|
1656
1829
|
// does NOT buy (the file header lists both as known gaps): on POSIX a
|
|
@@ -1668,9 +1841,10 @@ function defaultSpawn2(cmd, args, onDone = () => {
|
|
|
1668
1841
|
log("info", "yaw-mcp self-upgrade complete; the next client restart will run the new version");
|
|
1669
1842
|
} else {
|
|
1670
1843
|
const hint = cmd === "npm" ? " (often EACCES on a sudo-installed global -- run with the right permissions)" : "";
|
|
1844
|
+
const manual = correctiveCmd === null ? "Set" : `Run \`${correctiveCmd}\` manually, or set`;
|
|
1671
1845
|
log(
|
|
1672
1846
|
"warn",
|
|
1673
|
-
`yaw-mcp self-upgrade: ${cmd} exited non-zero${hint}.
|
|
1847
|
+
`yaw-mcp self-upgrade: ${cmd} exited non-zero${hint}. ${manual} YAW_MCP_AUTO_UPGRADE=0 to silence this.`,
|
|
1674
1848
|
{ code }
|
|
1675
1849
|
);
|
|
1676
1850
|
}
|
|
@@ -1681,36 +1855,27 @@ function defaultSpawn2(cmd, args, onDone = () => {
|
|
|
1681
1855
|
log("warn", `yaw-mcp self-upgrade: ${cmd} spawn failed`, { error: err?.message });
|
|
1682
1856
|
});
|
|
1683
1857
|
}
|
|
1684
|
-
function classifyInstallMethod(argvPath) {
|
|
1685
|
-
const literal = detectInstallMethod(argvPath);
|
|
1686
|
-
if (argvPath === void 0 || literal !== "unknown" && literal !== "local-node-modules") return literal;
|
|
1687
|
-
let resolved;
|
|
1688
|
-
try {
|
|
1689
|
-
resolved = realpathSync2(argvPath);
|
|
1690
|
-
} catch {
|
|
1691
|
-
return literal;
|
|
1692
|
-
}
|
|
1693
|
-
return resolved === argvPath ? literal : detectInstallMethod(resolved);
|
|
1694
|
-
}
|
|
1695
1858
|
async function maybeAutoUpgrade(deps = {}) {
|
|
1696
1859
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
1697
1860
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
1698
|
-
const current = deps.currentVersion ?? (true ? "0.
|
|
1861
|
+
const current = deps.currentVersion ?? (true ? "0.80.0" : "dev");
|
|
1699
1862
|
if (current === "dev") return;
|
|
1700
1863
|
const argvPath = deps.argvPath ?? process.argv[1];
|
|
1701
|
-
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" :
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
(
|
|
1864
|
+
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync2, ["unknown", "local-node-modules"]);
|
|
1865
|
+
const cached = (deps.checkedRecentlyImpl ?? defaultCheckedRecently)();
|
|
1866
|
+
let latest;
|
|
1867
|
+
if (cached !== null) {
|
|
1868
|
+
latest = cached.latest;
|
|
1869
|
+
} else {
|
|
1870
|
+
latest = await (deps.fetchLatestImpl ?? fetchLatestVersion)();
|
|
1871
|
+
(deps.recordCheckImpl ?? defaultRecordCheck)(latest);
|
|
1872
|
+
}
|
|
1705
1873
|
if (latest === null) return;
|
|
1706
1874
|
const plan = buildUpgradePlan({ current, latest, method });
|
|
1707
1875
|
if (!plan.stale) return;
|
|
1708
1876
|
const rawPrefix = method === "global-npm" ? detectRunningInstallPrefix(argvPath) : null;
|
|
1709
1877
|
const quotedPrefix = rawPrefix === null ? null : quoteShellArgIfNeeded(rawPrefix);
|
|
1710
|
-
const globalSpec = method
|
|
1711
|
-
cmd: "npm",
|
|
1712
|
-
args: quotedPrefix ? ["install", "-g", "--prefix", quotedPrefix, "@yawlabs/mcp@latest"] : ["install", "-g", "@yawlabs/mcp@latest"]
|
|
1713
|
-
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : null;
|
|
1878
|
+
const globalSpec = GLOBAL_UPGRADE_METHODS.includes(method) ? upgradeSpawnSpec(method, quotedPrefix) : null;
|
|
1714
1879
|
if (globalSpec) {
|
|
1715
1880
|
const lockDir = rawPrefix ?? tmpdir();
|
|
1716
1881
|
const lockName = rawPrefix === null ? `.yaw-mcp-upgrade-${globalSpec.cmd}-${process.getuid?.() ?? "win"}.lock` : UPGRADE_LOCK_NAME;
|
|
@@ -1744,7 +1909,8 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
1744
1909
|
prefix: quotedPrefix === null ? void 0 : rawPrefix ?? void 0
|
|
1745
1910
|
});
|
|
1746
1911
|
if (method === "global-npm" && rawPrefix !== null && quotedPrefix !== null) {
|
|
1747
|
-
|
|
1912
|
+
compareWithNpmPrefix(rawPrefix, deps.npmPrefixImpl).catch(() => {
|
|
1913
|
+
});
|
|
1748
1914
|
}
|
|
1749
1915
|
(deps.recordAttemptImpl ?? defaultRecordAttempt)(lockDir, lockName, latest);
|
|
1750
1916
|
try {
|
|
@@ -1799,12 +1965,16 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
1799
1965
|
}
|
|
1800
1966
|
|
|
1801
1967
|
export {
|
|
1968
|
+
INTERNAL_SECRET_ENV_KEYS,
|
|
1969
|
+
scrubInternalSecretsFromProcessEnv,
|
|
1970
|
+
stripInternalSecretsFromEnv,
|
|
1802
1971
|
log,
|
|
1803
1972
|
cacheDir,
|
|
1804
1973
|
CONFIG_DIRNAME,
|
|
1805
1974
|
sidecarsRoot,
|
|
1806
1975
|
sidecarsNodeModules,
|
|
1807
1976
|
userConfigDir,
|
|
1977
|
+
normalizeForCompare,
|
|
1808
1978
|
realpathOrSelf,
|
|
1809
1979
|
isUnderHome,
|
|
1810
1980
|
ALLOW_UNOWNED_ENV,
|
|
@@ -1817,7 +1987,6 @@ export {
|
|
|
1817
1987
|
buildLaunchEntry,
|
|
1818
1988
|
isProjectLocalEntry,
|
|
1819
1989
|
ENTRY_NAME,
|
|
1820
|
-
LEGACY_ENTRY_NAMES,
|
|
1821
1990
|
findLegacyEntry,
|
|
1822
1991
|
CLAUDE_CODE_ALLOW_PATTERN,
|
|
1823
1992
|
resolveClaudeCodeSettingsPath,
|
|
@@ -1840,10 +2009,10 @@ export {
|
|
|
1840
2009
|
resolveOamSpawn,
|
|
1841
2010
|
isOamCommand,
|
|
1842
2011
|
isOamLaunch,
|
|
1843
|
-
BINARY_RETIRED_HINT,
|
|
1844
2012
|
parseUpgradeArgs,
|
|
1845
2013
|
detectInstallMethod,
|
|
1846
2014
|
refineInstallMethod,
|
|
2015
|
+
BINARY_RETIRED_HINT,
|
|
1847
2016
|
buildUpgradePlan,
|
|
1848
2017
|
fetchLatestVersion,
|
|
1849
2018
|
detectSea,
|
|
@@ -1852,5 +2021,9 @@ export {
|
|
|
1852
2021
|
quoteArgForDisplay,
|
|
1853
2022
|
detectRunningInstallPrefix,
|
|
1854
2023
|
acquireUpgradeLock,
|
|
2024
|
+
readCheckMemo,
|
|
2025
|
+
writeCheckMemo,
|
|
2026
|
+
attemptedRecentlyAt,
|
|
2027
|
+
recordAttemptAt,
|
|
1855
2028
|
maybeAutoUpgrade
|
|
1856
2029
|
};
|