@yawlabs/mcp 0.76.0 → 0.76.2
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/{auto-upgrade-UCSHJTHO.js → auto-upgrade-I7PUQHNN.js} +3 -1
- package/dist/{chunk-32TGMWW7.js → chunk-CNEMSMQD.js} +78 -18
- package/dist/{chunk-SP5LWLFP.js → chunk-EPEOXHMM.js} +28 -16
- package/dist/index.js +224 -108
- package/dist/{oam-spawn-6TZ42IGK.js → oam-spawn-VPVBHI7B.js} +1 -1
- package/package.json +1 -1
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
detectRunningInstallPrefix,
|
|
4
4
|
maybeAutoUpgrade,
|
|
5
|
+
quoteArgForDisplay,
|
|
5
6
|
quoteShellArgIfNeeded
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EPEOXHMM.js";
|
|
7
8
|
import "./chunk-C3AQHLOR.js";
|
|
8
9
|
export {
|
|
9
10
|
detectRunningInstallPrefix,
|
|
10
11
|
maybeAutoUpgrade,
|
|
12
|
+
quoteArgForDisplay,
|
|
11
13
|
quoteShellArgIfNeeded
|
|
12
14
|
};
|
|
@@ -187,17 +187,52 @@ function pathFor(client, scope, os, base) {
|
|
|
187
187
|
throw new Error(`Unhandled client: ${client}`);
|
|
188
188
|
}
|
|
189
189
|
var CMD_METACHARS = /[&|<>^()]/g;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
var HAS_CMD_METACHAR = /[&|<>^()]/;
|
|
191
|
+
var KNOWN_CMD_SHIM_LAUNCHERS = /* @__PURE__ */ new Set(["npx", "uvx", "pipx", "npm", "pnpm", "yarn", "bunx"]);
|
|
192
|
+
var KNOWN_DIRECT_BINARIES = /* @__PURE__ */ new Set([
|
|
193
|
+
"node",
|
|
194
|
+
"deno",
|
|
195
|
+
"bun",
|
|
196
|
+
"python",
|
|
197
|
+
"python3",
|
|
198
|
+
"py",
|
|
199
|
+
"ruby",
|
|
200
|
+
"php",
|
|
201
|
+
"docker",
|
|
202
|
+
"dotnet",
|
|
203
|
+
"java",
|
|
204
|
+
"go"
|
|
205
|
+
]);
|
|
206
|
+
function isCmdShimLauncher(command) {
|
|
207
|
+
const base = command.replace(/^.*[\\/]/, "").toLowerCase();
|
|
208
|
+
if (/\.(?:cmd|bat)$/.test(base)) return true;
|
|
209
|
+
if (/\.(?:exe|com)$/.test(base)) return false;
|
|
210
|
+
const stem = base.replace(/\.[^.]*$/, "");
|
|
211
|
+
if (KNOWN_CMD_SHIM_LAUNCHERS.has(stem)) return true;
|
|
212
|
+
if (KNOWN_DIRECT_BINARIES.has(stem)) return false;
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
function escapeCmdArg(arg, opts) {
|
|
216
|
+
if (arg.includes('"')) {
|
|
217
|
+
if (HAS_CMD_METACHAR.test(arg)) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Cannot safely encode an argument that contains BOTH a double-quote and a cmd.exe metacharacter (& | < > ^ ( )) for the Windows cmd /c launcher: ${arg} -- passing it through cmd.exe risks a command injection at client-spawn time. Rework the server's args to drop one of the two.`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return arg;
|
|
223
|
+
}
|
|
224
|
+
if (/[ \t]/.test(arg)) return arg;
|
|
225
|
+
const caret = opts.shim ? "^^^" : "^";
|
|
226
|
+
return arg.replace(CMD_METACHARS, (m) => caret + m);
|
|
193
227
|
}
|
|
194
228
|
function buildLaunchEntry(opts) {
|
|
195
229
|
if (opts.upstream) {
|
|
196
230
|
const { command, args, env } = opts.upstream;
|
|
197
231
|
if (opts.os === "windows") {
|
|
232
|
+
const shim = isCmdShimLauncher(command);
|
|
198
233
|
const wrapped = {
|
|
199
234
|
command: "cmd",
|
|
200
|
-
args: ["/c", escapeCmdArg(command), ...args.map(escapeCmdArg)]
|
|
235
|
+
args: ["/c", escapeCmdArg(command, { shim: false }), ...args.map((a) => escapeCmdArg(a, { shim }))]
|
|
201
236
|
};
|
|
202
237
|
if (env && Object.keys(env).length > 0) wrapped.env = { ...env };
|
|
203
238
|
return wrapped;
|
|
@@ -237,7 +272,7 @@ function resolveClaudeCodeSettingsPath(scope, opts) {
|
|
|
237
272
|
}
|
|
238
273
|
|
|
239
274
|
// src/paths.ts
|
|
240
|
-
import { access, stat } from "fs/promises";
|
|
275
|
+
import { access, realpath, stat } from "fs/promises";
|
|
241
276
|
import { homedir as homedir2 } from "os";
|
|
242
277
|
import path from "path";
|
|
243
278
|
function cacheDir() {
|
|
@@ -264,20 +299,27 @@ function userConfigDir(home = homedir2()) {
|
|
|
264
299
|
return path.join(home, CONFIG_DIRNAME);
|
|
265
300
|
}
|
|
266
301
|
function normalizeForCompare(p) {
|
|
267
|
-
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
302
|
+
return process.platform === "win32" || process.platform === "darwin" ? p.toLowerCase() : p;
|
|
303
|
+
}
|
|
304
|
+
async function realpathOrSelf(p) {
|
|
305
|
+
try {
|
|
306
|
+
return await realpath(p);
|
|
307
|
+
} catch {
|
|
308
|
+
return p;
|
|
309
|
+
}
|
|
268
310
|
}
|
|
269
311
|
function isUnderHome(dir, homeResolved) {
|
|
270
312
|
const dirKey = normalizeForCompare(dir);
|
|
271
313
|
const homeKey = normalizeForCompare(homeResolved);
|
|
272
314
|
if (dirKey === homeKey) return false;
|
|
273
|
-
const rel = path.relative(
|
|
315
|
+
const rel = path.relative(homeKey, dirKey);
|
|
274
316
|
if (rel === "" || path.isAbsolute(rel)) return false;
|
|
275
|
-
|
|
276
|
-
return relNorm !== ".." && !relNorm.startsWith(`..${path.sep}`);
|
|
317
|
+
return rel !== ".." && !rel.startsWith(`..${path.sep}`);
|
|
277
318
|
}
|
|
319
|
+
var ALLOW_UNOWNED_ENV = "YAW_MCP_ALLOW_UNOWNED_PROJECT_DIRS";
|
|
278
320
|
async function ownedByCurrentUser(candidate) {
|
|
279
321
|
const geteuid = process.geteuid;
|
|
280
|
-
if (typeof geteuid !== "function") return
|
|
322
|
+
if (typeof geteuid !== "function") return process.env[ALLOW_UNOWNED_ENV] === "1";
|
|
281
323
|
try {
|
|
282
324
|
const st = await stat(candidate);
|
|
283
325
|
return typeof st.uid === "number" && st.uid === geteuid.call(process);
|
|
@@ -287,8 +329,9 @@ async function ownedByCurrentUser(candidate) {
|
|
|
287
329
|
}
|
|
288
330
|
async function findProjectConfigDir(start, home = homedir2()) {
|
|
289
331
|
const homeFallback = home && home.length > 0 ? home : process.env.USERPROFILE || homedir2();
|
|
290
|
-
const homeResolved = path.resolve(homeFallback);
|
|
291
|
-
let dir = path.resolve(start);
|
|
332
|
+
const homeResolved = path.resolve(await realpathOrSelf(path.resolve(homeFallback)));
|
|
333
|
+
let dir = path.resolve(await realpathOrSelf(path.resolve(start)));
|
|
334
|
+
const userConfigKey = normalizeForCompare(await realpathOrSelf(path.join(homeResolved, CONFIG_DIRNAME)));
|
|
292
335
|
const boundedByHome = isUnderHome(dir, homeResolved) || normalizeForCompare(dir) === normalizeForCompare(homeResolved);
|
|
293
336
|
let prev = "";
|
|
294
337
|
while (dir !== prev) {
|
|
@@ -296,8 +339,16 @@ async function findProjectConfigDir(start, home = homedir2()) {
|
|
|
296
339
|
const candidate = path.join(dir, CONFIG_DIRNAME);
|
|
297
340
|
try {
|
|
298
341
|
await access(candidate);
|
|
299
|
-
if (
|
|
300
|
-
|
|
342
|
+
if (normalizeForCompare(await realpathOrSelf(candidate)) === userConfigKey) {
|
|
343
|
+
log("debug", "Skipping a .yaw-mcp/ that resolves to the user-global config dir", { candidate });
|
|
344
|
+
} else if (boundedByHome || await ownedByCurrentUser(candidate)) {
|
|
345
|
+
return candidate;
|
|
346
|
+
} else {
|
|
347
|
+
log("warn", "Skipping an untrusted .yaw-mcp/ dir outside $HOME", {
|
|
348
|
+
candidate,
|
|
349
|
+
hint: `owned by another user, or ownership is unverifiable on this platform (set ${ALLOW_UNOWNED_ENV}=1 to trust it)`
|
|
350
|
+
});
|
|
351
|
+
}
|
|
301
352
|
} catch {
|
|
302
353
|
}
|
|
303
354
|
prev = dir;
|
|
@@ -881,9 +932,15 @@ var REFRESH_COMMAND = {
|
|
|
881
932
|
// on a server waiting for stdin" (measured on
|
|
882
933
|
// @modelcontextprotocol/server-memory). `npm cache add` is no substitute:
|
|
883
934
|
// it only fills _cacache, never the _npx install tree this resolver reads.
|
|
884
|
-
//
|
|
885
|
-
//
|
|
886
|
-
|
|
935
|
+
// No inline `#` comment either: that is comment syntax only in sh and
|
|
936
|
+
// PowerShell -- cmd.exe hands `#` and everything after it to npx as literal
|
|
937
|
+
// argv for the spawned server, which arg-parsing servers fail on. The
|
|
938
|
+
// Ctrl-C guidance rides in REFRESH_NOTE instead, so the command itself is
|
|
939
|
+
// copy-paste safe in all three shells.
|
|
940
|
+
"npx-cache": (pkg) => `npx -y ${pkg}@latest`
|
|
941
|
+
};
|
|
942
|
+
var REFRESH_NOTE = {
|
|
943
|
+
"npx-cache": "then Ctrl-C -- the cache is refreshed before the server starts"
|
|
887
944
|
};
|
|
888
945
|
var pinnedReported = /* @__PURE__ */ new Set();
|
|
889
946
|
function resetPinnedSidecarLog() {
|
|
@@ -904,7 +961,10 @@ function notePinnedSidecar(pkg, version, source, from) {
|
|
|
904
961
|
// the command differs -- so this is what makes the advice actionable
|
|
905
962
|
// rather than something to run in whatever cwd the user happens to be.
|
|
906
963
|
from,
|
|
907
|
-
refreshWith: REFRESH_COMMAND[source](pkg)
|
|
964
|
+
refreshWith: REFRESH_COMMAND[source](pkg),
|
|
965
|
+
// Only npx-cache has one today; JSON.stringify drops the field entirely
|
|
966
|
+
// for the sources that do not, rather than printing "undefined".
|
|
967
|
+
refreshNote: REFRESH_NOTE[source]
|
|
908
968
|
}
|
|
909
969
|
);
|
|
910
970
|
}
|
|
@@ -208,7 +208,7 @@ async function fetchLatestVersion(opts = {}) {
|
|
|
208
208
|
async function oamFloorLines(probe) {
|
|
209
209
|
if (!probe && process.env.VITEST) return [];
|
|
210
210
|
try {
|
|
211
|
-
const { MIN_OAM_VERSION, probeOam } = await import("./oam-spawn-
|
|
211
|
+
const { MIN_OAM_VERSION, probeOam } = await import("./oam-spawn-VPVBHI7B.js");
|
|
212
212
|
const oam = probe ? await probe() : await probeOam();
|
|
213
213
|
if (!oam.belowMin) return [];
|
|
214
214
|
return [
|
|
@@ -224,7 +224,7 @@ async function oamFloorLines(probe) {
|
|
|
224
224
|
}
|
|
225
225
|
async function defaultRunningPrefix(argvPath) {
|
|
226
226
|
if (process.env.VITEST) return null;
|
|
227
|
-
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-
|
|
227
|
+
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-I7PUQHNN.js");
|
|
228
228
|
return detectRunningInstallPrefix2(argvPath);
|
|
229
229
|
}
|
|
230
230
|
async function defaultSpawn(cmd, args, cwd) {
|
|
@@ -271,16 +271,30 @@ async function runUpgrade(opts = {}) {
|
|
|
271
271
|
latest = null;
|
|
272
272
|
}
|
|
273
273
|
const plan = buildUpgradePlan({ current, latest, method });
|
|
274
|
+
let globalPrefixArg = null;
|
|
275
|
+
let suggestedCommand = plan.command;
|
|
276
|
+
if (method === "global-npm") {
|
|
277
|
+
const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
|
|
278
|
+
if (rawPrefix !== null) {
|
|
279
|
+
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-I7PUQHNN.js");
|
|
280
|
+
const spawnForm = quoteShellArgIfNeeded2(rawPrefix);
|
|
281
|
+
const displayForm = quoteArgForDisplay2(rawPrefix);
|
|
282
|
+
if (spawnForm !== null && displayForm !== null) {
|
|
283
|
+
globalPrefixArg = spawnForm;
|
|
284
|
+
suggestedCommand = `npm install -g --prefix ${displayForm} @yawlabs/mcp@latest`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
274
288
|
if (opts.json) {
|
|
275
|
-
print(JSON.stringify(plan, null, 2));
|
|
289
|
+
print(JSON.stringify({ ...plan, command: suggestedCommand }, null, 2));
|
|
276
290
|
return { exitCode: plan.stale && !opts.run ? 1 : 0, lines };
|
|
277
291
|
}
|
|
278
292
|
if (latest === null) {
|
|
279
293
|
print("yaw-mcp upgrade: couldn't reach the npm registry (offline? firewall?).");
|
|
280
|
-
if (
|
|
294
|
+
if (suggestedCommand) {
|
|
281
295
|
print("When you're back online, run:");
|
|
282
296
|
print("");
|
|
283
|
-
print(` ${
|
|
297
|
+
print(` ${suggestedCommand}`);
|
|
284
298
|
} else if (method === "bundled-app") {
|
|
285
299
|
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app \u2014 nothing to run.");
|
|
286
300
|
} else if (method === "binary") {
|
|
@@ -319,19 +333,11 @@ async function runUpgrade(opts = {}) {
|
|
|
319
333
|
return { exitCode: opts.run ? 2 : 1, lines };
|
|
320
334
|
}
|
|
321
335
|
const installRoot = method === "local-node-modules" ? localInstallRoot(argvPath) : null;
|
|
322
|
-
let globalPrefixArg = null;
|
|
323
|
-
if (method === "global-npm") {
|
|
324
|
-
const raw = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
|
|
325
|
-
if (raw !== null) {
|
|
326
|
-
const { quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-UCSHJTHO.js");
|
|
327
|
-
globalPrefixArg = quoteShellArgIfNeeded2(raw);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
336
|
const runSpec = method === "global-npm" ? {
|
|
331
337
|
cmd: "npm",
|
|
332
338
|
args: globalPrefixArg ? ["install", "-g", "--prefix", globalPrefixArg, "@yawlabs/mcp@latest"] : ["install", "-g", "@yawlabs/mcp@latest"]
|
|
333
339
|
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "local-node-modules" && installRoot !== null ? { cmd: "npm", args: ["install", "@yawlabs/mcp@latest"], cwd: installRoot } : null;
|
|
334
|
-
const commandLine = runSpec ? [runSpec.cmd, ...runSpec.args].join(" ") : plan.command;
|
|
340
|
+
const commandLine = method === "global-npm" ? suggestedCommand : runSpec ? [runSpec.cmd, ...runSpec.args].join(" ") : plan.command;
|
|
335
341
|
if (!opts.run) {
|
|
336
342
|
if (runSpec) {
|
|
337
343
|
print("Run `yaw-mcp upgrade --run` to upgrade in place, or run it yourself:");
|
|
@@ -373,7 +379,7 @@ async function runUpgrade(opts = {}) {
|
|
|
373
379
|
return { exitCode: 3, lines };
|
|
374
380
|
}
|
|
375
381
|
function readCurrentVersion() {
|
|
376
|
-
return true ? "0.76.
|
|
382
|
+
return true ? "0.76.2" : "dev";
|
|
377
383
|
}
|
|
378
384
|
|
|
379
385
|
// src/auto-upgrade.ts
|
|
@@ -383,6 +389,11 @@ function quoteShellArgIfNeeded(arg, platform = process.platform) {
|
|
|
383
389
|
if (!/[\s&|<>^]/.test(arg)) return arg;
|
|
384
390
|
return `"${arg}"`;
|
|
385
391
|
}
|
|
392
|
+
function quoteArgForDisplay(arg, platform = process.platform) {
|
|
393
|
+
if (platform === "win32") return quoteShellArgIfNeeded(arg, platform);
|
|
394
|
+
if (/^[A-Za-z0-9_\-./+,:@=]+$/.test(arg)) return arg;
|
|
395
|
+
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
396
|
+
}
|
|
386
397
|
function detectRunningInstallPrefix(argvPath) {
|
|
387
398
|
if (!argvPath) return null;
|
|
388
399
|
let resolved;
|
|
@@ -458,7 +469,7 @@ function defaultSpawn2(cmd, args) {
|
|
|
458
469
|
async function maybeAutoUpgrade(deps = {}) {
|
|
459
470
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
460
471
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
461
|
-
const current = deps.currentVersion ?? (true ? "0.76.
|
|
472
|
+
const current = deps.currentVersion ?? (true ? "0.76.2" : "dev");
|
|
462
473
|
if (current === "dev") return;
|
|
463
474
|
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
464
475
|
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion)();
|
|
@@ -527,6 +538,7 @@ async function maybeAutoUpgrade(deps = {}) {
|
|
|
527
538
|
|
|
528
539
|
export {
|
|
529
540
|
quoteShellArgIfNeeded,
|
|
541
|
+
quoteArgForDisplay,
|
|
530
542
|
detectRunningInstallPrefix,
|
|
531
543
|
maybeAutoUpgrade,
|
|
532
544
|
BINARY_DOWNLOAD_URL,
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
sidecarsRoot,
|
|
38
38
|
specConstraint,
|
|
39
39
|
userConfigDir
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-CNEMSMQD.js";
|
|
41
41
|
import {
|
|
42
42
|
BINARY_DOWNLOAD_URL,
|
|
43
43
|
buildUpgradePlan,
|
|
@@ -48,13 +48,16 @@ import {
|
|
|
48
48
|
parseUpgradeArgs,
|
|
49
49
|
refineInstallMethod,
|
|
50
50
|
runUpgrade
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-EPEOXHMM.js";
|
|
52
52
|
import {
|
|
53
53
|
log
|
|
54
54
|
} from "./chunk-C3AQHLOR.js";
|
|
55
55
|
|
|
56
56
|
// src/audit-cmd.ts
|
|
57
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
57
58
|
import { homedir as homedir4 } from "os";
|
|
59
|
+
import { dirname, join as join4 } from "path";
|
|
60
|
+
import { fileURLToPath } from "url";
|
|
58
61
|
|
|
59
62
|
// src/grades-cache.ts
|
|
60
63
|
import { readFile } from "fs/promises";
|
|
@@ -445,7 +448,7 @@ async function readTrustStore(home = homedir2()) {
|
|
|
445
448
|
log("warn", "Dropping trust entry with a missing or malformed sha256", { path: path6, key });
|
|
446
449
|
continue;
|
|
447
450
|
}
|
|
448
|
-
setJsonKey(entries, key, {
|
|
451
|
+
setJsonKey(entries, normalizeTrustKey(key), {
|
|
449
452
|
path: typeof v.path === "string" && v.path.length > 0 ? v.path : key,
|
|
450
453
|
sha256: v.sha256,
|
|
451
454
|
grantedAt: typeof v.grantedAt === "string" ? v.grantedAt : ""
|
|
@@ -989,15 +992,41 @@ ${AUDIT_USAGE}` };
|
|
|
989
992
|
function findServer(servers, namespace) {
|
|
990
993
|
return servers.find((s) => s.namespace === namespace);
|
|
991
994
|
}
|
|
995
|
+
async function resolveComplianceSuiteVersion(fromUrl = import.meta.url) {
|
|
996
|
+
let here;
|
|
997
|
+
try {
|
|
998
|
+
here = fileURLToPath(fromUrl);
|
|
999
|
+
} catch {
|
|
1000
|
+
return void 0;
|
|
1001
|
+
}
|
|
1002
|
+
for (let dir = dirname(here); ; dir = dirname(dir)) {
|
|
1003
|
+
const pjPath = join4(dir, "node_modules", "@yawlabs", "mcp-compliance", "package.json");
|
|
1004
|
+
let raw;
|
|
1005
|
+
try {
|
|
1006
|
+
raw = await readFile4(pjPath, "utf8");
|
|
1007
|
+
} catch {
|
|
1008
|
+
if (dirname(dir) === dir) return void 0;
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
1011
|
+
try {
|
|
1012
|
+
const parsed = JSON.parse(raw);
|
|
1013
|
+
const version = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed.version : void 0;
|
|
1014
|
+
return typeof version === "string" && version.length > 0 ? version : void 0;
|
|
1015
|
+
} catch {
|
|
1016
|
+
return void 0;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
992
1020
|
async function defaultRunner(target) {
|
|
993
|
-
const { runComplianceSuite
|
|
1021
|
+
const { runComplianceSuite } = await import("@yawlabs/mcp-compliance");
|
|
1022
|
+
const suiteVersion = await resolveComplianceSuiteVersion();
|
|
994
1023
|
const report = await runComplianceSuite({
|
|
995
1024
|
type: "stdio",
|
|
996
1025
|
command: target.command,
|
|
997
1026
|
args: target.args,
|
|
998
1027
|
env: target.env
|
|
999
1028
|
});
|
|
1000
|
-
return { grade: report.grade, score: report.score, suiteVersion:
|
|
1029
|
+
return suiteVersion ? { grade: report.grade, score: report.score, suiteVersion } : { grade: report.grade, score: report.score };
|
|
1001
1030
|
}
|
|
1002
1031
|
async function runAudit(opts = {}) {
|
|
1003
1032
|
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
@@ -1172,13 +1201,13 @@ function topPartialBundles(installedNamespaces, limit) {
|
|
|
1172
1201
|
}
|
|
1173
1202
|
|
|
1174
1203
|
// src/config-loader.ts
|
|
1175
|
-
import { readFile as
|
|
1204
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
1176
1205
|
import { homedir as homedir5 } from "os";
|
|
1177
|
-
import { join as
|
|
1206
|
+
import { join as join6, resolve as resolve3 } from "path";
|
|
1178
1207
|
|
|
1179
1208
|
// src/migrate.ts
|
|
1180
1209
|
import { mkdir as mkdir2, rename as rename2, stat as stat2 } from "fs/promises";
|
|
1181
|
-
import { dirname, join as
|
|
1210
|
+
import { dirname as dirname2, join as join5, resolve as resolve2 } from "path";
|
|
1182
1211
|
var LEGACY_GLOBAL_FILENAME = ".yaw-mcp.json";
|
|
1183
1212
|
var LEGACY_PROJECT_FILENAME = ".yaw-mcp.json";
|
|
1184
1213
|
var LEGACY_LOCAL_FILENAME = ".yaw-mcp.local.json";
|
|
@@ -1229,7 +1258,7 @@ async function migrateFile(legacy, target, scope) {
|
|
|
1229
1258
|
return;
|
|
1230
1259
|
}
|
|
1231
1260
|
try {
|
|
1232
|
-
await mkdir2(
|
|
1261
|
+
await mkdir2(dirname2(target), { recursive: true });
|
|
1233
1262
|
await rename2(legacy, target);
|
|
1234
1263
|
log("info", "yaw-mcp config: migrated legacy file into .yaw-mcp/ directory", {
|
|
1235
1264
|
scope,
|
|
@@ -1247,17 +1276,17 @@ async function migrateFile(legacy, target, scope) {
|
|
|
1247
1276
|
}
|
|
1248
1277
|
async function migrateLegacyConfigPaths(opts) {
|
|
1249
1278
|
const { cwd, home } = opts;
|
|
1250
|
-
const legacyGlobal =
|
|
1251
|
-
const newGlobal =
|
|
1279
|
+
const legacyGlobal = join5(home, LEGACY_GLOBAL_FILENAME);
|
|
1280
|
+
const newGlobal = join5(userConfigDir(home), NEW_CONFIG_FILENAME);
|
|
1252
1281
|
await migrateFile(legacyGlobal, newGlobal, "global");
|
|
1253
1282
|
const legacyProjectRoot = await findLegacyProjectRoot(cwd, home);
|
|
1254
1283
|
if (legacyProjectRoot) {
|
|
1255
|
-
const newDir =
|
|
1256
|
-
const legacyLocal =
|
|
1257
|
-
const newLocal =
|
|
1284
|
+
const newDir = join5(legacyProjectRoot, CONFIG_DIRNAME);
|
|
1285
|
+
const legacyLocal = join5(legacyProjectRoot, LEGACY_LOCAL_FILENAME);
|
|
1286
|
+
const newLocal = join5(newDir, NEW_LOCAL_FILENAME);
|
|
1258
1287
|
await migrateFile(legacyLocal, newLocal, "local");
|
|
1259
|
-
const legacyProject =
|
|
1260
|
-
const newProject =
|
|
1288
|
+
const legacyProject = join5(legacyProjectRoot, LEGACY_PROJECT_FILENAME);
|
|
1289
|
+
const newProject = join5(newDir, NEW_CONFIG_FILENAME);
|
|
1261
1290
|
await migrateFile(legacyProject, newProject, "project");
|
|
1262
1291
|
}
|
|
1263
1292
|
}
|
|
@@ -1267,11 +1296,11 @@ async function findLegacyProjectRoot(cwd, home) {
|
|
|
1267
1296
|
let prev = "";
|
|
1268
1297
|
while (dir !== prev) {
|
|
1269
1298
|
if (!isUnderHome(dir, homeResolved)) return null;
|
|
1270
|
-
const legacyProject =
|
|
1271
|
-
const legacyLocal =
|
|
1299
|
+
const legacyProject = join5(dir, LEGACY_PROJECT_FILENAME);
|
|
1300
|
+
const legacyLocal = join5(dir, LEGACY_LOCAL_FILENAME);
|
|
1272
1301
|
if (await exists(legacyProject) || await exists(legacyLocal)) return dir;
|
|
1273
1302
|
prev = dir;
|
|
1274
|
-
dir =
|
|
1303
|
+
dir = dirname2(dir);
|
|
1275
1304
|
}
|
|
1276
1305
|
return null;
|
|
1277
1306
|
}
|
|
@@ -1303,7 +1332,7 @@ function filterStringArray(raw, field, path6, warnings) {
|
|
|
1303
1332
|
async function readConfigAt(path6, scope, warnings) {
|
|
1304
1333
|
let raw;
|
|
1305
1334
|
try {
|
|
1306
|
-
raw = await
|
|
1335
|
+
raw = await readFile5(path6, "utf8");
|
|
1307
1336
|
} catch (err) {
|
|
1308
1337
|
const code = err.code;
|
|
1309
1338
|
if (code === "ENOENT" || code === "ENOTDIR") return null;
|
|
@@ -1394,9 +1423,9 @@ async function loadYawMcpConfig(opts = {}) {
|
|
|
1394
1423
|
return null;
|
|
1395
1424
|
});
|
|
1396
1425
|
const globalDir = userConfigDir(home);
|
|
1397
|
-
const localPath = projectConfigDir ?
|
|
1398
|
-
const projectPath = projectConfigDir ?
|
|
1399
|
-
const globalPath =
|
|
1426
|
+
const localPath = projectConfigDir ? join6(projectConfigDir, LOCAL_CONFIG_FILENAME) : null;
|
|
1427
|
+
const projectPath = projectConfigDir ? join6(projectConfigDir, CONFIG_FILENAME) : null;
|
|
1428
|
+
const globalPath = join6(globalDir, CONFIG_FILENAME);
|
|
1400
1429
|
const local = localPath ? await readConfigAt(localPath, "local", warnings) : null;
|
|
1401
1430
|
if (local) loadedFiles.push(local);
|
|
1402
1431
|
const normalizeDir = (d) => {
|
|
@@ -2145,9 +2174,9 @@ Target: ${url}
|
|
|
2145
2174
|
|
|
2146
2175
|
// src/doctor-cmd.ts
|
|
2147
2176
|
import { closeSync, existsSync as existsSync6, fstatSync, openSync, readFileSync as readFileSync2, readSync } from "fs";
|
|
2148
|
-
import { readFile as
|
|
2177
|
+
import { readFile as readFile10 } from "fs/promises";
|
|
2149
2178
|
import { homedir as homedir9 } from "os";
|
|
2150
|
-
import { isAbsolute, join as
|
|
2179
|
+
import { isAbsolute, join as join9 } from "path";
|
|
2151
2180
|
|
|
2152
2181
|
// src/cli-shadows.ts
|
|
2153
2182
|
var EMPTY = [];
|
|
@@ -2436,14 +2465,14 @@ function describeServerRuntime(server, configDefault, probe) {
|
|
|
2436
2465
|
}
|
|
2437
2466
|
|
|
2438
2467
|
// src/guide.ts
|
|
2439
|
-
import { readFile as
|
|
2468
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
2440
2469
|
var GUIDE_READ_TIMEOUT_MS = 1e3;
|
|
2441
2470
|
async function readGuide(path6, scope) {
|
|
2442
2471
|
let raw;
|
|
2443
2472
|
const ac = new AbortController();
|
|
2444
2473
|
const timer = setTimeout(() => ac.abort(new Error("guide read timeout")), GUIDE_READ_TIMEOUT_MS);
|
|
2445
2474
|
try {
|
|
2446
|
-
raw = await
|
|
2475
|
+
raw = await readFile6(path6, { encoding: "utf8", signal: ac.signal });
|
|
2447
2476
|
} catch (err) {
|
|
2448
2477
|
const isTimeout = err instanceof Error && err.code === "ABORT_ERR";
|
|
2449
2478
|
if (isTimeout) {
|
|
@@ -2523,7 +2552,7 @@ function renderActiveServersSection(activeServers) {
|
|
|
2523
2552
|
}
|
|
2524
2553
|
|
|
2525
2554
|
// src/persistence.ts
|
|
2526
|
-
import { readFile as
|
|
2555
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
2527
2556
|
import path2 from "path";
|
|
2528
2557
|
var STATE_SCHEMA_VERSION = 2;
|
|
2529
2558
|
var STATE_FILENAME = "state.json";
|
|
@@ -2549,7 +2578,7 @@ function emptyState() {
|
|
|
2549
2578
|
}
|
|
2550
2579
|
async function loadState(filePath = statePath()) {
|
|
2551
2580
|
try {
|
|
2552
|
-
const raw = await
|
|
2581
|
+
const raw = await readFile7(filePath, "utf8");
|
|
2553
2582
|
const parsed = JSON.parse(raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw);
|
|
2554
2583
|
if (!parsed || typeof parsed !== "object") return emptyState();
|
|
2555
2584
|
if (!isReadableStateVersion(parsed.version)) return emptyState();
|
|
@@ -2659,7 +2688,7 @@ function errorMessage(err) {
|
|
|
2659
2688
|
import { spawn as spawn2 } from "child_process";
|
|
2660
2689
|
import { existsSync as existsSync3, mkdirSync, readFileSync } from "fs";
|
|
2661
2690
|
import { homedir as homedir6 } from "os";
|
|
2662
|
-
import { join as
|
|
2691
|
+
import { join as join7 } from "path";
|
|
2663
2692
|
function collectSidecarSpecs(servers) {
|
|
2664
2693
|
const byPkg = /* @__PURE__ */ new Map();
|
|
2665
2694
|
for (const s of servers) {
|
|
@@ -2709,7 +2738,7 @@ function sidecarsManifest(specs) {
|
|
|
2709
2738
|
`;
|
|
2710
2739
|
}
|
|
2711
2740
|
function sidecarsPlatformPath(home = homedir6()) {
|
|
2712
|
-
return
|
|
2741
|
+
return join7(sidecarsRoot(home), "platform.json");
|
|
2713
2742
|
}
|
|
2714
2743
|
function installedPlatform(home = homedir6()) {
|
|
2715
2744
|
try {
|
|
@@ -2723,7 +2752,7 @@ function installedPlatform(home = homedir6()) {
|
|
|
2723
2752
|
}
|
|
2724
2753
|
}
|
|
2725
2754
|
function installedVersion(pkg, home = homedir6()) {
|
|
2726
|
-
const pj =
|
|
2755
|
+
const pj = join7(sidecarsNodeModules(home), ...pkg.split("/"), "package.json");
|
|
2727
2756
|
try {
|
|
2728
2757
|
const v = JSON.parse(readFileSync(pj, "utf8")).version;
|
|
2729
2758
|
return typeof v === "string" ? v : null;
|
|
@@ -2887,7 +2916,7 @@ async function runSidecarsInstall(opts = {}) {
|
|
|
2887
2916
|
return { exitCode: 0, installed: [], lines };
|
|
2888
2917
|
}
|
|
2889
2918
|
mkdirSync(root, { recursive: true });
|
|
2890
|
-
await atomicWriteFile(
|
|
2919
|
+
await atomicWriteFile(join7(root, "package.json"), sidecarsManifest(specs));
|
|
2891
2920
|
print(`Installing ${specs.length} server package(s) into ${root}`);
|
|
2892
2921
|
if (bundles.path !== null) {
|
|
2893
2922
|
print(` from ${bundles.path}`);
|
|
@@ -2957,9 +2986,9 @@ function hasManagedSidecars(home = homedir6()) {
|
|
|
2957
2986
|
|
|
2958
2987
|
// src/try-cmd.ts
|
|
2959
2988
|
import { existsSync as existsSync5 } from "fs";
|
|
2960
|
-
import { chmod as chmod4, mkdir as mkdir3, readdir, readFile as
|
|
2989
|
+
import { chmod as chmod4, mkdir as mkdir3, readdir, readFile as readFile9, unlink as unlink2 } from "fs/promises";
|
|
2961
2990
|
import { homedir as homedir8 } from "os";
|
|
2962
|
-
import { join as
|
|
2991
|
+
import { join as join8, resolve as resolve5 } from "path";
|
|
2963
2992
|
|
|
2964
2993
|
// src/catalog.ts
|
|
2965
2994
|
var DEFAULT_CATALOG_URL = "https://yaw.sh/data/mcp-catalog.json";
|
|
@@ -3087,7 +3116,7 @@ async function resolveCatalogSlug(slug, opts = {}) {
|
|
|
3087
3116
|
|
|
3088
3117
|
// src/install-cmd.ts
|
|
3089
3118
|
import { existsSync as existsSync4 } from "fs";
|
|
3090
|
-
import { readFile as
|
|
3119
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
3091
3120
|
import { homedir as homedir7 } from "os";
|
|
3092
3121
|
import { resolve as resolve4 } from "path";
|
|
3093
3122
|
import { createInterface } from "readline/promises";
|
|
@@ -3222,7 +3251,7 @@ ${USAGE}`);
|
|
|
3222
3251
|
if (existsSync4(resolved.absolute)) {
|
|
3223
3252
|
let raw;
|
|
3224
3253
|
try {
|
|
3225
|
-
raw = await
|
|
3254
|
+
raw = await readFile8(resolved.absolute, "utf8");
|
|
3226
3255
|
} catch (e) {
|
|
3227
3256
|
err(`yaw-mcp install: cannot read ${resolved.absolute}: ${e.message}`);
|
|
3228
3257
|
return { written: [], wouldWrite: [], messages, exitCode: 1 };
|
|
@@ -3409,7 +3438,7 @@ async function prepareClaudeCodeSettingsPatch(opts) {
|
|
|
3409
3438
|
let rawSettings = null;
|
|
3410
3439
|
if (existsSync4(path6)) {
|
|
3411
3440
|
try {
|
|
3412
|
-
const raw = await
|
|
3441
|
+
const raw = await readFile8(path6, "utf8");
|
|
3413
3442
|
if (raw.trim().length > 0) {
|
|
3414
3443
|
const parsed = parseJsonc(raw);
|
|
3415
3444
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
@@ -3923,10 +3952,10 @@ function parseDurationMs(s) {
|
|
|
3923
3952
|
return n * factor;
|
|
3924
3953
|
}
|
|
3925
3954
|
function trialsDir(home = homedir8()) {
|
|
3926
|
-
return
|
|
3955
|
+
return join8(home, CONFIG_DIRNAME, TRIALS_DIRNAME);
|
|
3927
3956
|
}
|
|
3928
3957
|
function trialMarkerPath(slug, home = homedir8()) {
|
|
3929
|
-
return
|
|
3958
|
+
return join8(trialsDir(home), `${slug}.json`);
|
|
3930
3959
|
}
|
|
3931
3960
|
function rejectUntrustedMarker(marker) {
|
|
3932
3961
|
if (!marker.entryName.startsWith(TRIAL_ENTRY_PREFIX)) {
|
|
@@ -3939,7 +3968,7 @@ function rejectUntrustedMarker(marker) {
|
|
|
3939
3968
|
}
|
|
3940
3969
|
async function readTrialMarker(markerPath) {
|
|
3941
3970
|
try {
|
|
3942
|
-
const parsed = JSON.parse(await
|
|
3971
|
+
const parsed = JSON.parse(await readFile9(markerPath, "utf8"));
|
|
3943
3972
|
if (!parsed || typeof parsed !== "object") return null;
|
|
3944
3973
|
if (typeof parsed.clientPath !== "string" || typeof parsed.entryName !== "string") return null;
|
|
3945
3974
|
if (!Array.isArray(parsed.containerPath)) return null;
|
|
@@ -3952,7 +3981,7 @@ async function peelTrialEntry(marker) {
|
|
|
3952
3981
|
if (rejectUntrustedMarker(marker) !== null) return "failed";
|
|
3953
3982
|
if (!existsSync5(marker.clientPath)) return "absent";
|
|
3954
3983
|
try {
|
|
3955
|
-
const raw = await
|
|
3984
|
+
const raw = await readFile9(marker.clientPath, "utf8");
|
|
3956
3985
|
if (raw.trim().length === 0) return "absent";
|
|
3957
3986
|
const parsed = parseJsonc(raw);
|
|
3958
3987
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return "failed";
|
|
@@ -4095,7 +4124,7 @@ async function runTry(opts) {
|
|
|
4095
4124
|
if (clientPreExisted) {
|
|
4096
4125
|
let raw;
|
|
4097
4126
|
try {
|
|
4098
|
-
raw = await
|
|
4127
|
+
raw = await readFile9(resolved.absolute, "utf8");
|
|
4099
4128
|
} catch (e) {
|
|
4100
4129
|
const code = e.code;
|
|
4101
4130
|
printErr(
|
|
@@ -4226,7 +4255,7 @@ async function runTryCleanup(opts) {
|
|
|
4226
4255
|
}
|
|
4227
4256
|
let marker;
|
|
4228
4257
|
try {
|
|
4229
|
-
const raw = await
|
|
4258
|
+
const raw = await readFile9(markerPath, "utf8");
|
|
4230
4259
|
const parsed = JSON.parse(raw);
|
|
4231
4260
|
if (!parsed || typeof parsed !== "object" || typeof parsed.entryName !== "string") {
|
|
4232
4261
|
throw new Error("marker is missing required fields");
|
|
@@ -4245,7 +4274,7 @@ async function runTryCleanup(opts) {
|
|
|
4245
4274
|
const written = [];
|
|
4246
4275
|
if (existsSync5(marker.clientPath)) {
|
|
4247
4276
|
try {
|
|
4248
|
-
const raw = await
|
|
4277
|
+
const raw = await readFile9(marker.clientPath, "utf8");
|
|
4249
4278
|
if (raw.trim().length > 0) {
|
|
4250
4279
|
const parsed = parseJsonc(raw);
|
|
4251
4280
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
@@ -4297,9 +4326,9 @@ async function scanTrials(opts = {}) {
|
|
|
4297
4326
|
}
|
|
4298
4327
|
for (const filename of entries) {
|
|
4299
4328
|
if (!filename.endsWith(".json")) continue;
|
|
4300
|
-
const path6 =
|
|
4329
|
+
const path6 = join8(dir, filename);
|
|
4301
4330
|
try {
|
|
4302
|
-
const raw = await
|
|
4331
|
+
const raw = await readFile9(path6, "utf8");
|
|
4303
4332
|
const parsed = JSON.parse(raw);
|
|
4304
4333
|
if (!parsed || typeof parsed !== "object" || typeof parsed.slug !== "string" || typeof parsed.expiresAt !== "number" || typeof parsed.clientPath !== "string" || !Array.isArray(parsed.containerPath) || typeof parsed.entryName !== "string" || // Same trust check runTryCleanup applies: the GC deletes these three
|
|
4305
4334
|
// fields' worth of state from a file named by the marker itself, so a
|
|
@@ -4333,7 +4362,7 @@ async function gcExpiredTrials(opts) {
|
|
|
4333
4362
|
for (const { marker, path: path6 } of scan.expired) {
|
|
4334
4363
|
try {
|
|
4335
4364
|
if (existsSync5(marker.clientPath)) {
|
|
4336
|
-
const raw = await
|
|
4365
|
+
const raw = await readFile9(marker.clientPath, "utf8");
|
|
4337
4366
|
if (raw.trim().length > 0) {
|
|
4338
4367
|
const parsed = parseJsonc(raw);
|
|
4339
4368
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
@@ -4590,7 +4619,7 @@ function foldBundleWarnings(warnings, probe) {
|
|
|
4590
4619
|
const prefix = `${probe.path}:`;
|
|
4591
4620
|
return warnings.filter((w) => !w.startsWith(prefix));
|
|
4592
4621
|
}
|
|
4593
|
-
var VERSION = true ? "0.76.
|
|
4622
|
+
var VERSION = true ? "0.76.2" : "dev";
|
|
4594
4623
|
async function runDoctor(opts = {}) {
|
|
4595
4624
|
if (opts.json) return runDoctorJson(opts);
|
|
4596
4625
|
const lines = [];
|
|
@@ -4634,7 +4663,7 @@ async function runDoctor(opts = {}) {
|
|
|
4634
4663
|
config.warnings = [...config.warnings, ...foldBundleWarnings(oamStatus.bundleWarnings, trustProbe)];
|
|
4635
4664
|
renderOamRuntimeSection({ status: oamStatus, print, os });
|
|
4636
4665
|
const persistenceDisabled = isPersistenceDisabled(env);
|
|
4637
|
-
const stateFilePath =
|
|
4666
|
+
const stateFilePath = join9(userConfigDir(home), STATE_FILENAME);
|
|
4638
4667
|
const statePeek = persistenceDisabled ? null : await peekStateFile(stateFilePath);
|
|
4639
4668
|
const persistedState = statePeek?.kind === "ok" ? await loadState(stateFilePath) : null;
|
|
4640
4669
|
renderStateSection({
|
|
@@ -4751,7 +4780,7 @@ async function runDoctorJson(opts) {
|
|
|
4751
4780
|
envOverrides[name] = raw === void 0 || raw === "" ? null : raw;
|
|
4752
4781
|
}
|
|
4753
4782
|
const persistDisabled = isPersistenceDisabled(env);
|
|
4754
|
-
const stateFilePath =
|
|
4783
|
+
const stateFilePath = join9(userConfigDir(home), STATE_FILENAME);
|
|
4755
4784
|
const statePeek = persistDisabled ? null : await peekStateFile(stateFilePath);
|
|
4756
4785
|
const stateUsable = statePeek !== null && (statePeek.kind === "ok" || statePeek.kind === "missing");
|
|
4757
4786
|
const persisted = stateUsable ? await loadState(stateFilePath) : null;
|
|
@@ -5080,7 +5109,7 @@ function renderStateSection(opts) {
|
|
|
5080
5109
|
async function peekStateFile(filePath) {
|
|
5081
5110
|
let raw;
|
|
5082
5111
|
try {
|
|
5083
|
-
raw = await
|
|
5112
|
+
raw = await readFile10(filePath, "utf8");
|
|
5084
5113
|
} catch (err) {
|
|
5085
5114
|
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
5086
5115
|
return { kind: "missing" };
|
|
@@ -5390,7 +5419,7 @@ async function probeClientsAsync(opts) {
|
|
|
5390
5419
|
for (const { result, read } of enumerateProbeSlots(opts)) {
|
|
5391
5420
|
if (read) {
|
|
5392
5421
|
try {
|
|
5393
|
-
Object.assign(result, classifyProbeContent(await
|
|
5422
|
+
Object.assign(result, classifyProbeContent(await readFile10(read.path, "utf8"), read.containerPath));
|
|
5394
5423
|
} catch {
|
|
5395
5424
|
Object.assign(result, MALFORMED);
|
|
5396
5425
|
}
|
|
@@ -5426,9 +5455,9 @@ function scanShellHistoryForShadows(opts) {
|
|
|
5426
5455
|
}
|
|
5427
5456
|
function shellHistorySources(opts) {
|
|
5428
5457
|
const sources = [];
|
|
5429
|
-
sources.push({ path:
|
|
5458
|
+
sources.push({ path: join9(opts.home, ".bash_history"), extractCommand: (l) => l.trim() || null });
|
|
5430
5459
|
sources.push({
|
|
5431
|
-
path:
|
|
5460
|
+
path: join9(opts.home, ".zsh_history"),
|
|
5432
5461
|
// Zsh extended-history lines look like `: 1700000000:0;npm audit`.
|
|
5433
5462
|
// Strip the metadata prefix so we get just the command.
|
|
5434
5463
|
extractCommand: (l) => {
|
|
@@ -5444,7 +5473,7 @@ function shellHistorySources(opts) {
|
|
|
5444
5473
|
const appData = opts.env.APPDATA;
|
|
5445
5474
|
if (appData) {
|
|
5446
5475
|
sources.push({
|
|
5447
|
-
path:
|
|
5476
|
+
path: join9(appData, "Microsoft", "Windows", "PowerShell", "PSReadLine", "ConsoleHost_history.txt"),
|
|
5448
5477
|
extractCommand: (l) => l.trim() || null
|
|
5449
5478
|
});
|
|
5450
5479
|
}
|
|
@@ -6032,12 +6061,12 @@ async function runFoundryExport(opts) {
|
|
|
6032
6061
|
}
|
|
6033
6062
|
|
|
6034
6063
|
// src/local-add-cmd.ts
|
|
6035
|
-
import { readFile as
|
|
6064
|
+
import { readFile as readFile12 } from "fs/promises";
|
|
6036
6065
|
import { homedir as homedir13 } from "os";
|
|
6037
6066
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
6038
6067
|
|
|
6039
6068
|
// src/trust-cmd.ts
|
|
6040
|
-
import { readFile as
|
|
6069
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
6041
6070
|
import { homedir as homedir12 } from "os";
|
|
6042
6071
|
import { isAbsolute as isAbsolute2, resolve as resolve6 } from "path";
|
|
6043
6072
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
@@ -6220,7 +6249,7 @@ async function runTrustGrant(opts) {
|
|
|
6220
6249
|
}
|
|
6221
6250
|
let confirmBytes;
|
|
6222
6251
|
try {
|
|
6223
|
-
confirmBytes = await
|
|
6252
|
+
confirmBytes = await readFile11(path6);
|
|
6224
6253
|
} catch (e) {
|
|
6225
6254
|
printErr(
|
|
6226
6255
|
`yaw-mcp trust: ${displaySafe(path6)} could not be re-read before approving (${e.message}). Nothing approved.`
|
|
@@ -6325,6 +6354,13 @@ var VALUELESS_RUNNER_FLAGS = /* @__PURE__ */ new Set([
|
|
|
6325
6354
|
"--no-install",
|
|
6326
6355
|
"--ignore-existing"
|
|
6327
6356
|
]);
|
|
6357
|
+
function stripVersionPrefixV(spec) {
|
|
6358
|
+
const start = spec.startsWith("@") ? 1 : 0;
|
|
6359
|
+
const at = spec.indexOf("@", start);
|
|
6360
|
+
if (at === -1) return spec;
|
|
6361
|
+
const suffix = spec.slice(at + 1);
|
|
6362
|
+
return /^v\d/.test(suffix) ? spec.slice(0, at + 1) + suffix.slice(1) : spec;
|
|
6363
|
+
}
|
|
6328
6364
|
function unversionedRegistrySpec(s) {
|
|
6329
6365
|
const base = (s.command ?? "").split(/[\\/]/).pop()?.replace(/\.(?:exe|cmd|bat)$/i, "") ?? "";
|
|
6330
6366
|
const runner = REGISTRY_RUNNERS.find((r) => r.cmd === base);
|
|
@@ -6346,7 +6382,7 @@ function unversionedRegistrySpec(s) {
|
|
|
6346
6382
|
if (spec === null || spec.length === 0) return null;
|
|
6347
6383
|
if (spec.includes("://") || isAbsolute2(spec) || /^\.{1,2}[\\/]/.test(spec)) return null;
|
|
6348
6384
|
if (spec.includes("==")) return null;
|
|
6349
|
-
if (specConstraint(spec).kind === "exact") return null;
|
|
6385
|
+
if (specConstraint(stripVersionPrefixV(spec)).kind === "exact") return null;
|
|
6350
6386
|
return spec;
|
|
6351
6387
|
}
|
|
6352
6388
|
function pinGaps(s) {
|
|
@@ -6434,7 +6470,7 @@ async function runTrustList(opts) {
|
|
|
6434
6470
|
}
|
|
6435
6471
|
async function classifyRecord(path6, sha256) {
|
|
6436
6472
|
try {
|
|
6437
|
-
const raw = await
|
|
6473
|
+
const raw = await readFile11(path6);
|
|
6438
6474
|
return hashTrustContent(raw) === sha256 ? "ok" : "stale (content changed)";
|
|
6439
6475
|
} catch (e) {
|
|
6440
6476
|
const code = e.code;
|
|
@@ -6731,7 +6767,7 @@ async function findRemovalTarget(candidates, home) {
|
|
|
6731
6767
|
const path6 = localBundlesPath(userConfigDir(home));
|
|
6732
6768
|
let raw;
|
|
6733
6769
|
try {
|
|
6734
|
-
raw = await
|
|
6770
|
+
raw = await readFile12(path6, "utf8");
|
|
6735
6771
|
} catch {
|
|
6736
6772
|
return null;
|
|
6737
6773
|
}
|
|
@@ -6757,7 +6793,7 @@ async function namespacesForStoredSlug(target, home) {
|
|
|
6757
6793
|
const path6 = localBundlesPath(userConfigDir(home));
|
|
6758
6794
|
let raw;
|
|
6759
6795
|
try {
|
|
6760
|
-
raw = await
|
|
6796
|
+
raw = await readFile12(path6, "utf8");
|
|
6761
6797
|
} catch {
|
|
6762
6798
|
return [];
|
|
6763
6799
|
}
|
|
@@ -6891,6 +6927,32 @@ var LIST_USAGE = `Usage: yaw-mcp list [--json]
|
|
|
6891
6927
|
\`yaw-mcp audit\` last cached for each. --json for machine output.
|
|
6892
6928
|
Env vars appear as \`envKeys\` -- key NAMES only, never the stored
|
|
6893
6929
|
values (same posture as \`add --json\`).`;
|
|
6930
|
+
async function rawEnvKeysByNamespace(path6) {
|
|
6931
|
+
const out = /* @__PURE__ */ new Map();
|
|
6932
|
+
if (!path6) return out;
|
|
6933
|
+
let raw;
|
|
6934
|
+
try {
|
|
6935
|
+
raw = await readFile12(path6, "utf8");
|
|
6936
|
+
} catch {
|
|
6937
|
+
return out;
|
|
6938
|
+
}
|
|
6939
|
+
let parsed;
|
|
6940
|
+
try {
|
|
6941
|
+
parsed = parseJsonc(raw);
|
|
6942
|
+
} catch {
|
|
6943
|
+
return out;
|
|
6944
|
+
}
|
|
6945
|
+
if (typeof parsed !== "object" || parsed === null) return out;
|
|
6946
|
+
const servers = parsed.servers;
|
|
6947
|
+
if (!Array.isArray(servers)) return out;
|
|
6948
|
+
for (const s of servers) {
|
|
6949
|
+
const e = s;
|
|
6950
|
+
if (!e || typeof e.namespace !== "string" || out.has(e.namespace)) continue;
|
|
6951
|
+
const env = e.env && typeof e.env === "object" && !Array.isArray(e.env) ? e.env : {};
|
|
6952
|
+
out.set(e.namespace, Object.keys(env));
|
|
6953
|
+
}
|
|
6954
|
+
return out;
|
|
6955
|
+
}
|
|
6894
6956
|
function parseListArgs(argv) {
|
|
6895
6957
|
const opts = {};
|
|
6896
6958
|
for (const a of argv) {
|
|
@@ -6923,8 +6985,11 @@ async function runList(opts) {
|
|
|
6923
6985
|
return cached ? { ...s, complianceGrade: cached.grade } : s;
|
|
6924
6986
|
});
|
|
6925
6987
|
if (opts.json) {
|
|
6988
|
+
const rawEnvKeys = await rawEnvKeysByNamespace(loaded.path);
|
|
6926
6989
|
const jsonServers = graded.map((s) => {
|
|
6927
6990
|
const entry = jsonEntry(s);
|
|
6991
|
+
const keys = rawEnvKeys.get(s.namespace);
|
|
6992
|
+
if (keys !== void 0 && keys.length > 0) entry.envKeys = keys;
|
|
6928
6993
|
const cached = grades[s.namespace];
|
|
6929
6994
|
if (cached) {
|
|
6930
6995
|
entry.complianceGradedAt = cached.gradedAt;
|
|
@@ -6961,9 +7026,9 @@ ${servers.length} server${servers.length === 1 ? "" : "s"} in ${loaded.path}`);
|
|
|
6961
7026
|
}
|
|
6962
7027
|
|
|
6963
7028
|
// src/reset-learning-cmd.ts
|
|
6964
|
-
import { readFile as
|
|
7029
|
+
import { readFile as readFile13, unlink as unlink3 } from "fs/promises";
|
|
6965
7030
|
import { homedir as homedir14 } from "os";
|
|
6966
|
-
import { join as
|
|
7031
|
+
import { join as join10 } from "path";
|
|
6967
7032
|
var RESET_LEARNING_USAGE = `Usage: yaw-mcp reset-learning
|
|
6968
7033
|
|
|
6969
7034
|
Delete ~/.yaw-mcp/state.json so cross-session learning starts fresh.
|
|
@@ -7009,7 +7074,7 @@ async function runResetLearning(opts = {}) {
|
|
|
7009
7074
|
writeErr(`${s}
|
|
7010
7075
|
`);
|
|
7011
7076
|
};
|
|
7012
|
-
const filePath =
|
|
7077
|
+
const filePath = join10(userConfigDir(home), STATE_FILENAME);
|
|
7013
7078
|
if (isPersistenceDisabled(env)) {
|
|
7014
7079
|
print("yaw-mcp reset-learning: persistence is disabled (YAW_MCP_DISABLE_PERSISTENCE) \u2014 nothing to clear.");
|
|
7015
7080
|
return { exitCode: 0, lines, removed: false, path: filePath };
|
|
@@ -7046,7 +7111,7 @@ async function runResetLearning(opts = {}) {
|
|
|
7046
7111
|
async function peekParsedCleanly(filePath) {
|
|
7047
7112
|
let raw;
|
|
7048
7113
|
try {
|
|
7049
|
-
raw = await
|
|
7114
|
+
raw = await readFile13(filePath, "utf8");
|
|
7050
7115
|
} catch (err) {
|
|
7051
7116
|
if (isFileNotFound2(err)) return true;
|
|
7052
7117
|
return false;
|
|
@@ -7069,13 +7134,13 @@ import { homedir as homedir17 } from "os";
|
|
|
7069
7134
|
|
|
7070
7135
|
// src/secrets-audit.ts
|
|
7071
7136
|
import { existsSync as existsSync7 } from "fs";
|
|
7072
|
-
import { appendFile as appendFile2, chmod as chmod5, readFile as
|
|
7137
|
+
import { appendFile as appendFile2, chmod as chmod5, readFile as readFile14, stat as stat4 } from "fs/promises";
|
|
7073
7138
|
import { homedir as homedir15 } from "os";
|
|
7074
|
-
import { join as
|
|
7139
|
+
import { join as join11 } from "path";
|
|
7075
7140
|
var SECRETS_AUDIT_FILENAME = "secrets-audit.log";
|
|
7076
7141
|
var AUDIT_TAIL_CAP = 5e3;
|
|
7077
7142
|
function auditLogPath(home = homedir15()) {
|
|
7078
|
-
return
|
|
7143
|
+
return join11(home, CONFIG_DIRNAME, SECRETS_AUDIT_FILENAME);
|
|
7079
7144
|
}
|
|
7080
7145
|
async function appendAuditEvent(input, home = homedir15()) {
|
|
7081
7146
|
try {
|
|
@@ -7104,7 +7169,7 @@ var MIN_AUDIT_LINE_BYTES = 64;
|
|
|
7104
7169
|
async function trimToTailCap(path6) {
|
|
7105
7170
|
const { size } = await stat4(path6);
|
|
7106
7171
|
if (size < AUDIT_TAIL_CAP * MIN_AUDIT_LINE_BYTES) return;
|
|
7107
|
-
const raw = await
|
|
7172
|
+
const raw = await readFile14(path6, "utf8");
|
|
7108
7173
|
const lines = raw.split("\n").filter((l) => l.length > 0);
|
|
7109
7174
|
if (lines.length <= AUDIT_TAIL_CAP) return;
|
|
7110
7175
|
const kept = lines.slice(lines.length - AUDIT_TAIL_CAP);
|
|
@@ -7116,7 +7181,7 @@ async function readAuditLog(filter = {}, home = homedir15()) {
|
|
|
7116
7181
|
if (!existsSync7(path6)) return [];
|
|
7117
7182
|
let raw;
|
|
7118
7183
|
try {
|
|
7119
|
-
raw = await
|
|
7184
|
+
raw = await readFile14(path6, "utf8");
|
|
7120
7185
|
} catch {
|
|
7121
7186
|
return [];
|
|
7122
7187
|
}
|
|
@@ -7144,9 +7209,9 @@ function isAuditEvent(v) {
|
|
|
7144
7209
|
|
|
7145
7210
|
// src/secrets-vault.ts
|
|
7146
7211
|
import { createHmac, randomBytes as randomBytes2, timingSafeEqual } from "crypto";
|
|
7147
|
-
import { chmod as chmod6, mkdir as mkdir5, readFile as
|
|
7212
|
+
import { chmod as chmod6, mkdir as mkdir5, readFile as readFile15 } from "fs/promises";
|
|
7148
7213
|
import { homedir as homedir16 } from "os";
|
|
7149
|
-
import { dirname as
|
|
7214
|
+
import { dirname as dirname3, join as join12 } from "path";
|
|
7150
7215
|
|
|
7151
7216
|
// src/secrets-crypto.ts
|
|
7152
7217
|
import { createCipheriv, createDecipheriv, randomBytes, scrypt as scryptCb } from "crypto";
|
|
@@ -7205,7 +7270,7 @@ var SECRETS_SCHEMA_VERSION = 1;
|
|
|
7205
7270
|
var VAULT_CHECK_PLAINTEXT = "yaw-mcp-vault-v1";
|
|
7206
7271
|
var VAULT_CHECK_CORRUPT_ERROR = 'vault verification token ("check") is corrupt -- the passphrase is correct, but the check marker does not decrypt';
|
|
7207
7272
|
function vaultPath(home = homedir16()) {
|
|
7208
|
-
return
|
|
7273
|
+
return join12(home, CONFIG_DIRNAME, SECRETS_FILENAME);
|
|
7209
7274
|
}
|
|
7210
7275
|
function emptyVault() {
|
|
7211
7276
|
return {
|
|
@@ -7217,7 +7282,7 @@ function emptyVault() {
|
|
|
7217
7282
|
async function loadVault(path6) {
|
|
7218
7283
|
let raw;
|
|
7219
7284
|
try {
|
|
7220
|
-
raw = await
|
|
7285
|
+
raw = await readFile15(path6, "utf8");
|
|
7221
7286
|
} catch (err) {
|
|
7222
7287
|
const code = err.code;
|
|
7223
7288
|
if (code === "ENOENT") return null;
|
|
@@ -7266,7 +7331,7 @@ function isEncryptedEntry(v) {
|
|
|
7266
7331
|
return typeof e.iv === "string" && typeof e.ciphertext === "string" && typeof e.authTag === "string";
|
|
7267
7332
|
}
|
|
7268
7333
|
async function saveVault(path6, vault) {
|
|
7269
|
-
const dir =
|
|
7334
|
+
const dir = dirname3(path6);
|
|
7270
7335
|
await mkdir5(dir, { recursive: true });
|
|
7271
7336
|
if (process.platform !== "win32") {
|
|
7272
7337
|
try {
|
|
@@ -8690,12 +8755,12 @@ function pushToolCall(history, record, limit = HISTORY_LIMIT) {
|
|
|
8690
8755
|
|
|
8691
8756
|
// src/install-nudge.ts
|
|
8692
8757
|
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
8693
|
-
import { dirname as
|
|
8758
|
+
import { dirname as dirname4, join as join13 } from "path";
|
|
8694
8759
|
var INSTALL_NUDGE_MIN_COUNT = 5;
|
|
8695
8760
|
var INSTALL_NUDGE_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
8696
8761
|
var INSTALL_NUDGE_STATE_FILENAME = "install-nudge-state.json";
|
|
8697
8762
|
function installNudgeStatePath(home) {
|
|
8698
|
-
return
|
|
8763
|
+
return join13(home, CONFIG_DIRNAME, INSTALL_NUDGE_STATE_FILENAME);
|
|
8699
8764
|
}
|
|
8700
8765
|
function installNudgeEnabled(env, config) {
|
|
8701
8766
|
if (env.YAW_MCP_INSTALL_NUDGE === "1") return true;
|
|
@@ -8734,7 +8799,7 @@ function recordNudge(cli, home, now = Date.now) {
|
|
|
8734
8799
|
const kept = state.nudges.filter((n) => n.cli !== cli && at - n.nudgedAt < INSTALL_NUDGE_COOLDOWN_MS);
|
|
8735
8800
|
kept.push({ cli, nudgedAt: at });
|
|
8736
8801
|
const path6 = installNudgeStatePath(home);
|
|
8737
|
-
mkdirSync3(
|
|
8802
|
+
mkdirSync3(dirname4(path6), { recursive: true });
|
|
8738
8803
|
writeFileSync2(path6, `${JSON.stringify({ nudges: kept }, null, 2)}
|
|
8739
8804
|
`, "utf8");
|
|
8740
8805
|
} catch (err) {
|
|
@@ -10429,6 +10494,7 @@ var STDERR_RING_CAP = 8 * 1024;
|
|
|
10429
10494
|
var MAX_TOOLS_PER_SERVER = 1e3;
|
|
10430
10495
|
var MAX_RESOURCES_PER_SERVER = 1e3;
|
|
10431
10496
|
var MAX_PROMPTS_PER_SERVER = 1e3;
|
|
10497
|
+
var MAX_LIST_PAGES = 50;
|
|
10432
10498
|
var ActivationError = class extends Error {
|
|
10433
10499
|
constructor(message, category, stderrTail, cause) {
|
|
10434
10500
|
super(message);
|
|
@@ -10512,7 +10578,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
|
|
|
10512
10578
|
if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
|
|
10513
10579
|
if (downstreamCaps?.roots) capabilities.roots = {};
|
|
10514
10580
|
const client = new Client(
|
|
10515
|
-
{ name: "yaw-mcp", version: true ? "0.76.
|
|
10581
|
+
{ name: "yaw-mcp", version: true ? "0.76.2" : "dev" },
|
|
10516
10582
|
{ capabilities }
|
|
10517
10583
|
);
|
|
10518
10584
|
if (bridge && capabilities.elicitation) {
|
|
@@ -10736,23 +10802,42 @@ async function disconnectFromUpstream(connection) {
|
|
|
10736
10802
|
}
|
|
10737
10803
|
log("info", "Disconnected from upstream", { namespace: connection.config.namespace });
|
|
10738
10804
|
}
|
|
10739
|
-
async function fetchAllPages(fetchPage, cap) {
|
|
10805
|
+
async function fetchAllPages(fetchPage, cap, context) {
|
|
10740
10806
|
const all = [];
|
|
10741
10807
|
let cursor;
|
|
10742
|
-
for (let page = 0; page <
|
|
10808
|
+
for (let page = 0; page < MAX_LIST_PAGES; page++) {
|
|
10743
10809
|
const { items, nextCursor } = await fetchPage(cursor);
|
|
10744
10810
|
all.push(...items);
|
|
10745
|
-
if (nextCursor === void 0 || all.length > cap)
|
|
10811
|
+
if (nextCursor === void 0 || all.length > cap) return all;
|
|
10812
|
+
if (items.length === 0) {
|
|
10813
|
+
log("warn", "Upstream returned an empty page with a cursor; stopping pagination", {
|
|
10814
|
+
namespace: context.namespace,
|
|
10815
|
+
endpoint: context.endpoint,
|
|
10816
|
+
pagesFetched: page + 1,
|
|
10817
|
+
items: all.length
|
|
10818
|
+
});
|
|
10819
|
+
return all;
|
|
10820
|
+
}
|
|
10746
10821
|
cursor = nextCursor;
|
|
10747
10822
|
}
|
|
10823
|
+
log("warn", "Upstream pagination exceeded page cap; truncating", {
|
|
10824
|
+
namespace: context.namespace,
|
|
10825
|
+
endpoint: context.endpoint,
|
|
10826
|
+
pageCap: MAX_LIST_PAGES,
|
|
10827
|
+
items: all.length
|
|
10828
|
+
});
|
|
10748
10829
|
return all;
|
|
10749
10830
|
}
|
|
10750
10831
|
async function fetchResourcesFromUpstream(client, namespace, opts = {}) {
|
|
10751
10832
|
try {
|
|
10752
|
-
const raw = await fetchAllPages(
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10833
|
+
const raw = await fetchAllPages(
|
|
10834
|
+
async (cursor) => {
|
|
10835
|
+
const result = await client.listResources(cursor === void 0 ? {} : { cursor }, { timeout: LIST_TIMEOUT });
|
|
10836
|
+
return { items: result.resources ?? [], nextCursor: result.nextCursor };
|
|
10837
|
+
},
|
|
10838
|
+
MAX_RESOURCES_PER_SERVER,
|
|
10839
|
+
{ namespace, endpoint: "resources/list" }
|
|
10840
|
+
);
|
|
10756
10841
|
if (raw.length > MAX_RESOURCES_PER_SERVER) {
|
|
10757
10842
|
log("warn", "Upstream returned more resources than cap; truncating", {
|
|
10758
10843
|
namespace,
|
|
@@ -10775,10 +10860,14 @@ async function fetchResourcesFromUpstream(client, namespace, opts = {}) {
|
|
|
10775
10860
|
}
|
|
10776
10861
|
async function fetchPromptsFromUpstream(client, namespace, opts = {}) {
|
|
10777
10862
|
try {
|
|
10778
|
-
const raw = await fetchAllPages(
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10863
|
+
const raw = await fetchAllPages(
|
|
10864
|
+
async (cursor) => {
|
|
10865
|
+
const result = await client.listPrompts(cursor === void 0 ? {} : { cursor }, { timeout: LIST_TIMEOUT });
|
|
10866
|
+
return { items: result.prompts ?? [], nextCursor: result.nextCursor };
|
|
10867
|
+
},
|
|
10868
|
+
MAX_PROMPTS_PER_SERVER,
|
|
10869
|
+
{ namespace, endpoint: "prompts/list" }
|
|
10870
|
+
);
|
|
10782
10871
|
if (raw.length > MAX_PROMPTS_PER_SERVER) {
|
|
10783
10872
|
log("warn", "Upstream returned more prompts than cap; truncating", {
|
|
10784
10873
|
namespace,
|
|
@@ -10801,10 +10890,14 @@ async function fetchPromptsFromUpstream(client, namespace, opts = {}) {
|
|
|
10801
10890
|
async function fetchToolsFromUpstream(client, namespace) {
|
|
10802
10891
|
let all;
|
|
10803
10892
|
try {
|
|
10804
|
-
all = await fetchAllPages(
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10893
|
+
all = await fetchAllPages(
|
|
10894
|
+
async (cursor) => {
|
|
10895
|
+
const result = await client.listTools(cursor === void 0 ? {} : { cursor }, { timeout: LIST_TIMEOUT });
|
|
10896
|
+
return { items: result.tools ?? [], nextCursor: result.nextCursor };
|
|
10897
|
+
},
|
|
10898
|
+
MAX_TOOLS_PER_SERVER,
|
|
10899
|
+
{ namespace, endpoint: "tools/list" }
|
|
10900
|
+
);
|
|
10808
10901
|
} catch (err) {
|
|
10809
10902
|
const message = err instanceof Error ? err.message : String(err);
|
|
10810
10903
|
throw new ActivationError(
|
|
@@ -11127,7 +11220,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
11127
11220
|
static SHUTDOWN_DRAIN_MS = 2e3;
|
|
11128
11221
|
constructor() {
|
|
11129
11222
|
this.server = new Server(
|
|
11130
|
-
{ name: "yaw-mcp", version: true ? "0.76.
|
|
11223
|
+
{ name: "yaw-mcp", version: true ? "0.76.2" : "dev" },
|
|
11131
11224
|
{
|
|
11132
11225
|
capabilities: {
|
|
11133
11226
|
tools: { listChanged: true },
|
|
@@ -11448,16 +11541,18 @@ var ConnectServer = class _ConnectServer {
|
|
|
11448
11541
|
});
|
|
11449
11542
|
await this.hydrateComplianceGrades();
|
|
11450
11543
|
await this.reconcileConfig(this.config);
|
|
11451
|
-
if (this.config?.servers.some((s) => s.command
|
|
11544
|
+
if (this.config?.servers.some((s) => s.command !== void 0 && uvLaunchKind(s.command) !== null)) {
|
|
11452
11545
|
ensureUv().catch((err) => log("warn", "uv prewarm failed", { error: err?.message }));
|
|
11453
11546
|
}
|
|
11454
11547
|
const transport = new StdioServerTransport();
|
|
11548
|
+
this.server.oninitialized = () => {
|
|
11549
|
+
this.prewarmDormantServers().catch((err) => log("warn", "Pre-warm failed", { error: err?.message }));
|
|
11550
|
+
if (isAutoLoadEnabled() && this.persistenceReady) {
|
|
11551
|
+
this.autoLoadRecurringPack().catch((err) => log("warn", "Auto-load failed", { error: err?.message }));
|
|
11552
|
+
}
|
|
11553
|
+
};
|
|
11455
11554
|
await this.server.connect(transport);
|
|
11456
|
-
this.prewarmDormantServers().catch((err) => log("warn", "Pre-warm failed", { error: err?.message }));
|
|
11457
11555
|
maybeAutoUpgrade().catch((err) => log("warn", "Auto-upgrade check failed", { error: err?.message }));
|
|
11458
|
-
if (isAutoLoadEnabled() && this.persistenceReady) {
|
|
11459
|
-
this.autoLoadRecurringPack().catch((err) => log("warn", "Auto-load failed", { error: err?.message }));
|
|
11460
|
-
}
|
|
11461
11556
|
log("info", "yaw-mcp started", {
|
|
11462
11557
|
servers: this.config?.servers.length ?? 0
|
|
11463
11558
|
});
|
|
@@ -11521,7 +11616,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
11521
11616
|
// re-learned weekly instead of only at the 30-day persistence expiry.
|
|
11522
11617
|
async prewarmDormantServers() {
|
|
11523
11618
|
const dormant = this.getProfiledActiveServers().filter(
|
|
11524
|
-
(s) => !this.hasKnownTools(s) || this.isLearnedCacheStale(s.namespace)
|
|
11619
|
+
(s) => this.connections.get(s.namespace)?.status !== "connected" && (!this.hasKnownTools(s) || this.isLearnedCacheStale(s.namespace))
|
|
11525
11620
|
);
|
|
11526
11621
|
if (dormant.length === 0) return;
|
|
11527
11622
|
log("info", "Pre-warming dormant servers", {
|
|
@@ -11542,6 +11637,10 @@ var ConnectServer = class _ConnectServer {
|
|
|
11542
11637
|
true
|
|
11543
11638
|
);
|
|
11544
11639
|
if (!result.ok) return;
|
|
11640
|
+
if (!result.isChanged) {
|
|
11641
|
+
this.prewarmNamespaces.delete(server.namespace);
|
|
11642
|
+
return;
|
|
11643
|
+
}
|
|
11545
11644
|
if (!this.prewarmNamespaces.has(server.namespace)) {
|
|
11546
11645
|
log("info", "Pre-warm skipping disconnect \u2014 namespace claimed by explicit activate", {
|
|
11547
11646
|
namespace: server.namespace
|
|
@@ -11876,7 +11975,14 @@ var ConnectServer = class _ConnectServer {
|
|
|
11876
11975
|
const topWinsDecisively = top !== void 0 && top.score >= minScore && (second === void 0 || top.score / (second.score || 1e-6) >= margin);
|
|
11877
11976
|
if (!topWinsDecisively || !top) return this.handleDiscover(context);
|
|
11878
11977
|
const existing = this.connections.get(top.namespace);
|
|
11879
|
-
if (existing && existing.status === "connected")
|
|
11978
|
+
if (existing && existing.status === "connected") {
|
|
11979
|
+
const grew = !this.sessionActivated.has(top.namespace);
|
|
11980
|
+
this.sessionActivated.add(top.namespace);
|
|
11981
|
+
if (grew) {
|
|
11982
|
+
await this.notifyAllListsChanged();
|
|
11983
|
+
}
|
|
11984
|
+
return this.buildDiscoverOutput(context, top.namespace);
|
|
11985
|
+
}
|
|
11880
11986
|
progress?.(`Auto-warming top candidate "${top.namespace}"`);
|
|
11881
11987
|
const result = await this.activateOne(top.namespace, progress);
|
|
11882
11988
|
if (result.ok) {
|
|
@@ -12395,6 +12501,7 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12395
12501
|
let anyChanged = false;
|
|
12396
12502
|
let anyError = false;
|
|
12397
12503
|
let anyCapped = false;
|
|
12504
|
+
let advertisedGrew = false;
|
|
12398
12505
|
const total = namespaces.length;
|
|
12399
12506
|
let i = 0;
|
|
12400
12507
|
for (const namespace of namespaces) {
|
|
@@ -12403,7 +12510,10 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12403
12510
|
const r = await this.activateOne(namespace, progress);
|
|
12404
12511
|
results.push(r.message);
|
|
12405
12512
|
if (r.isChanged) anyChanged = true;
|
|
12406
|
-
if (r.ok)
|
|
12513
|
+
if (r.ok) {
|
|
12514
|
+
if (!this.sessionActivated.has(namespace)) advertisedGrew = true;
|
|
12515
|
+
this.sessionActivated.add(namespace);
|
|
12516
|
+
}
|
|
12407
12517
|
if (!r.ok) {
|
|
12408
12518
|
if (r.capped) anyCapped = true;
|
|
12409
12519
|
else anyError = true;
|
|
@@ -12417,7 +12527,7 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12417
12527
|
}
|
|
12418
12528
|
if (anyChanged) {
|
|
12419
12529
|
await this.refreshRoutesAndNotify();
|
|
12420
|
-
} else if (filtersChanged) {
|
|
12530
|
+
} else if (filtersChanged || advertisedGrew) {
|
|
12421
12531
|
await this.notifyAllListsChanged();
|
|
12422
12532
|
}
|
|
12423
12533
|
return {
|
|
@@ -12545,6 +12655,7 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12545
12655
|
let anyChanged = false;
|
|
12546
12656
|
let anyError = false;
|
|
12547
12657
|
let anyCapped = false;
|
|
12658
|
+
let advertisedGrew = false;
|
|
12548
12659
|
let i = 0;
|
|
12549
12660
|
for (const winner of winners) {
|
|
12550
12661
|
i += 1;
|
|
@@ -12552,7 +12663,10 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12552
12663
|
const r = await this.activateOne(winner.namespace, progress);
|
|
12553
12664
|
results.push(`${winner.namespace} (score ${winner.score.toFixed(2)}): ${r.message}`);
|
|
12554
12665
|
if (r.isChanged) anyChanged = true;
|
|
12555
|
-
if (r.ok)
|
|
12666
|
+
if (r.ok) {
|
|
12667
|
+
if (!this.sessionActivated.has(winner.namespace)) advertisedGrew = true;
|
|
12668
|
+
this.sessionActivated.add(winner.namespace);
|
|
12669
|
+
}
|
|
12556
12670
|
if (!r.ok) {
|
|
12557
12671
|
if (r.capped) anyCapped = true;
|
|
12558
12672
|
else anyError = true;
|
|
@@ -12560,6 +12674,8 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12560
12674
|
}
|
|
12561
12675
|
if (anyChanged) {
|
|
12562
12676
|
await this.refreshRoutesAndNotify();
|
|
12677
|
+
} else if (advertisedGrew) {
|
|
12678
|
+
await this.notifyAllListsChanged();
|
|
12563
12679
|
}
|
|
12564
12680
|
const header = `Dispatched "${trimmed}" \u2014 loaded top ${winners.length} of ${ranked.length} matching server${ranked.length === 1 ? "" : "s"}.
|
|
12565
12681
|
`;
|
|
@@ -13612,7 +13728,7 @@ if (subcommand === "compliance") {
|
|
|
13612
13728
|
`);
|
|
13613
13729
|
process.exitCode = 0;
|
|
13614
13730
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
13615
|
-
process.stdout.write(`yaw-mcp ${true ? "0.76.
|
|
13731
|
+
process.stdout.write(`yaw-mcp ${true ? "0.76.2" : "dev"}
|
|
13616
13732
|
`);
|
|
13617
13733
|
process.exitCode = 0;
|
|
13618
13734
|
} else if (subcommand && !subcommand.startsWith("-")) {
|
package/package.json
CHANGED