@yawlabs/mcp 0.67.1 → 0.70.1
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/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
findProjectConfigDir,
|
|
10
10
|
getResource,
|
|
11
11
|
getSession,
|
|
12
|
+
getSessionWithCookie,
|
|
12
13
|
guidePath,
|
|
13
14
|
listAnalyticsEvents,
|
|
14
15
|
log,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
signIn,
|
|
18
19
|
signOut,
|
|
19
20
|
userConfigDir
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-L5AGSAQ5.js";
|
|
21
22
|
|
|
22
23
|
// src/audit-cmd.ts
|
|
23
24
|
import { homedir as homedir3 } from "os";
|
|
@@ -298,9 +299,17 @@ async function readBundlesAt(path5, warnings) {
|
|
|
298
299
|
warnings.push(`${path5}: 'servers' must be an array -- file ignored`);
|
|
299
300
|
return { exists: true, file: null };
|
|
300
301
|
}
|
|
302
|
+
let defaultRuntime2;
|
|
303
|
+
if (obj.defaultRuntime === "oam" || obj.defaultRuntime === "node") {
|
|
304
|
+
defaultRuntime2 = obj.defaultRuntime;
|
|
305
|
+
} else if (obj.defaultRuntime !== void 0) {
|
|
306
|
+
warnings.push(
|
|
307
|
+
`${path5}: ignoring invalid 'defaultRuntime' ${JSON.stringify(obj.defaultRuntime)} (expected "oam" or "node")`
|
|
308
|
+
);
|
|
309
|
+
}
|
|
301
310
|
return {
|
|
302
311
|
exists: true,
|
|
303
|
-
file: { version, servers: rawServers }
|
|
312
|
+
file: { version, servers: rawServers, defaultRuntime: defaultRuntime2 }
|
|
304
313
|
};
|
|
305
314
|
}
|
|
306
315
|
function hashContent(servers) {
|
|
@@ -334,13 +343,25 @@ async function loadLocalBundles(opts = {}) {
|
|
|
334
343
|
const validated = validateEntry2(raw, warnings);
|
|
335
344
|
if (validated) servers.push(validated);
|
|
336
345
|
}
|
|
346
|
+
let defaultRuntime2 = file.defaultRuntime;
|
|
347
|
+
let defaultRuntimePath = defaultRuntime2 !== void 0 ? sourcePath ?? void 0 : void 0;
|
|
348
|
+
if (defaultRuntime2 === void 0 && sourcePath === projectPath && projectPath !== null) {
|
|
349
|
+
const scratch = [];
|
|
350
|
+
const globalResult = await readBundlesAt(globalPath, scratch);
|
|
351
|
+
if (globalResult.file?.defaultRuntime !== void 0) {
|
|
352
|
+
defaultRuntime2 = globalResult.file.defaultRuntime;
|
|
353
|
+
defaultRuntimePath = globalPath;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
337
356
|
return {
|
|
338
357
|
config: {
|
|
339
358
|
servers,
|
|
340
359
|
configVersion: hashContent(servers)
|
|
341
360
|
},
|
|
342
361
|
path: sourcePath,
|
|
343
|
-
warnings
|
|
362
|
+
warnings,
|
|
363
|
+
defaultRuntime: defaultRuntime2,
|
|
364
|
+
defaultRuntimePath
|
|
344
365
|
};
|
|
345
366
|
}
|
|
346
367
|
var bundleWriteChain = Promise.resolve();
|
|
@@ -367,7 +388,14 @@ async function readRawUserBundles(home) {
|
|
|
367
388
|
const detail = warnings.length > 0 ? ` (${warningText})` : "";
|
|
368
389
|
throw new Error(`${path5} could not be parsed -- fix the JSON${detail} before adding servers.`);
|
|
369
390
|
}
|
|
370
|
-
|
|
391
|
+
for (const w of warnings) {
|
|
392
|
+
log("warn", "bundles.json warning (write path)", { warning: w });
|
|
393
|
+
}
|
|
394
|
+
return {
|
|
395
|
+
version: r.file.version ?? CURRENT_BUNDLES_SCHEMA_VERSION,
|
|
396
|
+
servers: r.file.servers,
|
|
397
|
+
...r.file.defaultRuntime !== void 0 ? { defaultRuntime: r.file.defaultRuntime } : {}
|
|
398
|
+
};
|
|
371
399
|
}
|
|
372
400
|
function upsertUserBundle(entry, opts = {}) {
|
|
373
401
|
const result = bundleWriteChain.then(() => doUpsertUserBundle(entry, opts));
|
|
@@ -612,8 +640,8 @@ var CURATED_BUNDLES = [
|
|
|
612
640
|
{
|
|
613
641
|
id: "data-ops",
|
|
614
642
|
name: "Data Ops",
|
|
615
|
-
description: "Postgres +
|
|
616
|
-
namespaces: ["postgres", "
|
|
643
|
+
description: "Postgres + AWS + Snowflake for pipeline debugging",
|
|
644
|
+
namespaces: ["postgres", "aws", "snowflake"],
|
|
617
645
|
category: "data"
|
|
618
646
|
},
|
|
619
647
|
{
|
|
@@ -1331,6 +1359,11 @@ var SUBCOMMAND_SPEC = [
|
|
|
1331
1359
|
flags: ["--dry-run", "--json", "--help"]
|
|
1332
1360
|
},
|
|
1333
1361
|
{ name: "stats", description: "Show usage statistics", flags: ["--limit", "--days", "--json", "--help"] },
|
|
1362
|
+
{
|
|
1363
|
+
name: "token",
|
|
1364
|
+
description: "Print the account session token for a trusted local app",
|
|
1365
|
+
flags: ["--json", "--help"]
|
|
1366
|
+
},
|
|
1334
1367
|
{
|
|
1335
1368
|
name: "secrets",
|
|
1336
1369
|
description: "Manage stored secrets",
|
|
@@ -1720,10 +1753,10 @@ Publish failed: ${message}
|
|
|
1720
1753
|
}
|
|
1721
1754
|
|
|
1722
1755
|
// src/doctor-cmd.ts
|
|
1723
|
-
import { existsSync as
|
|
1756
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2, statSync } from "fs";
|
|
1724
1757
|
import { readFile as readFile7, stat as stat3 } from "fs/promises";
|
|
1725
1758
|
import { homedir as homedir8 } from "os";
|
|
1726
|
-
import { join as
|
|
1759
|
+
import { join as join9 } from "path";
|
|
1727
1760
|
|
|
1728
1761
|
// src/analytics.ts
|
|
1729
1762
|
import { request as request3 } from "undici";
|
|
@@ -2091,9 +2124,211 @@ function formatShadowLine(server) {
|
|
|
2091
2124
|
return `prefer over local CLI: ${parts.join(", ")}`;
|
|
2092
2125
|
}
|
|
2093
2126
|
|
|
2127
|
+
// src/oam-spawn.ts
|
|
2128
|
+
import { execFileSync } from "child_process";
|
|
2129
|
+
import { existsSync as existsSync2, readdirSync, readFileSync } from "fs";
|
|
2130
|
+
import { isAbsolute, join as join5, sep } from "path";
|
|
2131
|
+
import { fileURLToPath } from "url";
|
|
2132
|
+
function packageName(spec) {
|
|
2133
|
+
const start = spec.startsWith("@") ? 1 : 0;
|
|
2134
|
+
const at = spec.indexOf("@", start);
|
|
2135
|
+
return at === -1 ? spec : spec.slice(0, at);
|
|
2136
|
+
}
|
|
2137
|
+
var MIN_OAM_VERSION = "0.6.0";
|
|
2138
|
+
var oamProbeCache;
|
|
2139
|
+
function parseOamVersion(out) {
|
|
2140
|
+
const m = /(\d+\.\d+\.\d+)/.exec(out);
|
|
2141
|
+
return m ? m[1] : null;
|
|
2142
|
+
}
|
|
2143
|
+
function compareVersions(a, b) {
|
|
2144
|
+
const parse = (s) => {
|
|
2145
|
+
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(s);
|
|
2146
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
2147
|
+
};
|
|
2148
|
+
const pa = parse(a);
|
|
2149
|
+
const pb = parse(b);
|
|
2150
|
+
if (!pa || !pb) return 0;
|
|
2151
|
+
for (let i = 0; i < 3; i++) {
|
|
2152
|
+
if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1;
|
|
2153
|
+
}
|
|
2154
|
+
return 0;
|
|
2155
|
+
}
|
|
2156
|
+
function winNormalize(p, platform = process.platform) {
|
|
2157
|
+
return platform === "win32" ? p.replace(/\//g, "\\") : p;
|
|
2158
|
+
}
|
|
2159
|
+
function probeOam(run = (bin) => execFileSync(bin, ["--version"], { stdio: ["ignore", "pipe", "ignore"], encoding: "utf8" })) {
|
|
2160
|
+
if (oamProbeCache !== void 0) return oamProbeCache;
|
|
2161
|
+
const bin = winNormalize(process.env.OAM_BIN || (process.platform === "win32" ? "oam.exe" : "oam"));
|
|
2162
|
+
try {
|
|
2163
|
+
const version = parseOamVersion(run(bin));
|
|
2164
|
+
if (version !== null && compareVersions(version, MIN_OAM_VERSION) < 0) {
|
|
2165
|
+
log("warn", "oam is installed but below the minimum supported version; falling back to node", {
|
|
2166
|
+
oamVersion: version,
|
|
2167
|
+
minVersion: MIN_OAM_VERSION
|
|
2168
|
+
});
|
|
2169
|
+
oamProbeCache = { bin: null, version, belowMin: true };
|
|
2170
|
+
} else {
|
|
2171
|
+
oamProbeCache = { bin, version, belowMin: false };
|
|
2172
|
+
}
|
|
2173
|
+
} catch {
|
|
2174
|
+
oamProbeCache = { bin: null, version: null, belowMin: false };
|
|
2175
|
+
}
|
|
2176
|
+
return oamProbeCache;
|
|
2177
|
+
}
|
|
2178
|
+
function oamBin() {
|
|
2179
|
+
return probeOam().bin;
|
|
2180
|
+
}
|
|
2181
|
+
function rewriteForOam(command, args, deps) {
|
|
2182
|
+
const bin = deps.oamBin;
|
|
2183
|
+
if (!bin) return { command, args };
|
|
2184
|
+
const toOam = (entry, rest) => ({
|
|
2185
|
+
command: bin,
|
|
2186
|
+
args: rest.length > 0 ? ["run", entry, "--", ...rest] : ["run", entry]
|
|
2187
|
+
});
|
|
2188
|
+
if (command === "node") {
|
|
2189
|
+
const [entry, ...rest] = args;
|
|
2190
|
+
if (!entry) return { command, args };
|
|
2191
|
+
return toOam(entry, rest);
|
|
2192
|
+
}
|
|
2193
|
+
if (command === "npx") {
|
|
2194
|
+
const positional = args.filter((a) => a !== "-y" && a !== "--yes");
|
|
2195
|
+
const [spec, ...rest] = positional;
|
|
2196
|
+
if (!spec) return { command, args };
|
|
2197
|
+
const entry = deps.resolveEntry(packageName(spec));
|
|
2198
|
+
if (!entry) return { command, args };
|
|
2199
|
+
return toOam(entry, rest);
|
|
2200
|
+
}
|
|
2201
|
+
return { command, args };
|
|
2202
|
+
}
|
|
2203
|
+
function npxCacheNodeModules(fromUrl = import.meta.url) {
|
|
2204
|
+
let here;
|
|
2205
|
+
try {
|
|
2206
|
+
here = fileURLToPath(fromUrl);
|
|
2207
|
+
} catch {
|
|
2208
|
+
return [];
|
|
2209
|
+
}
|
|
2210
|
+
const marker = `${sep}_npx${sep}`;
|
|
2211
|
+
const idx = here.indexOf(marker);
|
|
2212
|
+
if (idx === -1) return [];
|
|
2213
|
+
const npxRoot = here.slice(0, idx + marker.length - sep.length);
|
|
2214
|
+
try {
|
|
2215
|
+
return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join5(npxRoot, e.name, "node_modules"));
|
|
2216
|
+
} catch {
|
|
2217
|
+
return [];
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
function ownNodeModules(fromUrl = import.meta.url) {
|
|
2221
|
+
let here;
|
|
2222
|
+
try {
|
|
2223
|
+
here = fileURLToPath(fromUrl);
|
|
2224
|
+
} catch {
|
|
2225
|
+
return [];
|
|
2226
|
+
}
|
|
2227
|
+
const seg = `${sep}node_modules${sep}`;
|
|
2228
|
+
const idx = here.lastIndexOf(seg);
|
|
2229
|
+
if (idx === -1) return [];
|
|
2230
|
+
return [here.slice(0, idx + seg.length - sep.length)];
|
|
2231
|
+
}
|
|
2232
|
+
function packageEntry(pkgDir, pkg) {
|
|
2233
|
+
const pjPath = join5(pkgDir, "package.json");
|
|
2234
|
+
if (!existsSync2(pjPath)) return null;
|
|
2235
|
+
let j;
|
|
2236
|
+
try {
|
|
2237
|
+
j = JSON.parse(readFileSync(pjPath, "utf8"));
|
|
2238
|
+
} catch {
|
|
2239
|
+
return null;
|
|
2240
|
+
}
|
|
2241
|
+
let rel;
|
|
2242
|
+
if (typeof j.bin === "string") {
|
|
2243
|
+
rel = j.bin;
|
|
2244
|
+
} else if (j.bin && typeof j.bin === "object") {
|
|
2245
|
+
const unscoped = pkg.slice(pkg.lastIndexOf("/") + 1);
|
|
2246
|
+
rel = j.bin[unscoped] ?? (j.name ? j.bin[j.name] : void 0) ?? Object.values(j.bin)[0];
|
|
2247
|
+
}
|
|
2248
|
+
if (!rel && typeof j.main === "string") rel = j.main;
|
|
2249
|
+
if (!rel) return null;
|
|
2250
|
+
return isAbsolute(rel) ? rel : join5(pkgDir, rel);
|
|
2251
|
+
}
|
|
2252
|
+
function resolveNpmEntry(pkg, fromUrl = import.meta.url) {
|
|
2253
|
+
const parts = pkg.split("/");
|
|
2254
|
+
for (const nodeModules of [...ownNodeModules(fromUrl), ...npxCacheNodeModules(fromUrl)]) {
|
|
2255
|
+
const entry = packageEntry(join5(nodeModules, ...parts), pkg);
|
|
2256
|
+
if (entry) return entry;
|
|
2257
|
+
}
|
|
2258
|
+
return null;
|
|
2259
|
+
}
|
|
2260
|
+
function resolveOamSpawn(command, args) {
|
|
2261
|
+
return rewriteForOam(command, args, {
|
|
2262
|
+
oamBin: oamBin(),
|
|
2263
|
+
resolveEntry: (pkg) => resolveNpmEntry(pkg)
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
// src/default-runtime.ts
|
|
2268
|
+
var bundlesDefaultCache;
|
|
2269
|
+
var warnedInvalidEnv = false;
|
|
2270
|
+
async function describeDefaultRuntime(opts = {}) {
|
|
2271
|
+
const env = opts.env ?? process.env;
|
|
2272
|
+
const raw = env.YAW_MCP_DEFAULT_RUNTIME;
|
|
2273
|
+
if (raw === "oam" || raw === "node") return { runtime: raw, source: "env", path: null };
|
|
2274
|
+
if (raw !== void 0 && raw !== "" && !warnedInvalidEnv) {
|
|
2275
|
+
warnedInvalidEnv = true;
|
|
2276
|
+
log("warn", 'Ignoring invalid YAW_MCP_DEFAULT_RUNTIME (expected "oam" or "node")', { value: raw });
|
|
2277
|
+
}
|
|
2278
|
+
const bundles = await loadLocalBundles({ cwd: opts.cwd, home: opts.home }).catch(() => ({
|
|
2279
|
+
defaultRuntime: void 0,
|
|
2280
|
+
defaultRuntimePath: void 0
|
|
2281
|
+
}));
|
|
2282
|
+
return bundles.defaultRuntime !== void 0 ? { runtime: bundles.defaultRuntime, source: "bundles", path: bundles.defaultRuntimePath ?? null } : { runtime: null, source: null, path: null };
|
|
2283
|
+
}
|
|
2284
|
+
async function defaultRuntime() {
|
|
2285
|
+
const raw = process.env.YAW_MCP_DEFAULT_RUNTIME;
|
|
2286
|
+
if (raw === "oam" || raw === "node") return raw;
|
|
2287
|
+
if (raw !== void 0 && raw !== "" && !warnedInvalidEnv) {
|
|
2288
|
+
warnedInvalidEnv = true;
|
|
2289
|
+
log("warn", 'Ignoring invalid YAW_MCP_DEFAULT_RUNTIME (expected "oam" or "node")', { value: raw });
|
|
2290
|
+
}
|
|
2291
|
+
if (bundlesDefaultCache === void 0) {
|
|
2292
|
+
const bundles = await loadLocalBundles({ cwd: process.cwd() }).catch(() => ({ defaultRuntime: void 0 }));
|
|
2293
|
+
bundlesDefaultCache = bundles.defaultRuntime ?? null;
|
|
2294
|
+
}
|
|
2295
|
+
return bundlesDefaultCache;
|
|
2296
|
+
}
|
|
2297
|
+
function describeServerRuntime(server, configDefault, probe2) {
|
|
2298
|
+
if (server.type !== "local") {
|
|
2299
|
+
return { runtime: null, code: "remote", reason: "remote server (no local spawn)" };
|
|
2300
|
+
}
|
|
2301
|
+
if (server.runtime === "node") {
|
|
2302
|
+
return { runtime: "node", code: "per-server-node", reason: 'per-server runtime:"node"' };
|
|
2303
|
+
}
|
|
2304
|
+
const wantsOam = server.runtime === "oam" || server.runtime === void 0 && configDefault === "oam";
|
|
2305
|
+
if (!wantsOam) {
|
|
2306
|
+
return { runtime: "node", code: "default-node", reason: "default (no oam opt-in)" };
|
|
2307
|
+
}
|
|
2308
|
+
const via = server.runtime === "oam" ? 'per-server runtime:"oam"' : 'default runtime "oam"';
|
|
2309
|
+
if (server.command !== "node" && server.command !== "npx") {
|
|
2310
|
+
return { runtime: "node", code: "not-node-command", reason: `${via}, but command is not node/npx` };
|
|
2311
|
+
}
|
|
2312
|
+
if (probe2.belowMin) {
|
|
2313
|
+
return {
|
|
2314
|
+
runtime: "node",
|
|
2315
|
+
code: "oam-below-min",
|
|
2316
|
+
reason: `${via}, but oam ${probe2.version} is below min ${MIN_OAM_VERSION}`
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
if (probe2.bin === null) {
|
|
2320
|
+
return { runtime: "node", code: "oam-not-installed", reason: `${via}, but oam is not installed` };
|
|
2321
|
+
}
|
|
2322
|
+
return {
|
|
2323
|
+
runtime: "oam",
|
|
2324
|
+
code: server.runtime === "oam" ? "per-server-oam" : "default-oam",
|
|
2325
|
+
reason: via
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2094
2329
|
// src/install-targets.ts
|
|
2095
2330
|
import { homedir as homedir5 } from "os";
|
|
2096
|
-
import { isAbsolute, join as
|
|
2331
|
+
import { isAbsolute as isAbsolute2, join as join6, resolve as resolve3 } from "path";
|
|
2097
2332
|
var CURRENT_OS = process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : "linux";
|
|
2098
2333
|
var INSTALL_TARGETS = [
|
|
2099
2334
|
{
|
|
@@ -2175,7 +2410,7 @@ var INSTALL_TARGETS = [
|
|
|
2175
2410
|
];
|
|
2176
2411
|
function resolveInstallPath(opts) {
|
|
2177
2412
|
const home = opts.home ?? homedir5();
|
|
2178
|
-
const appData = opts.appData ?? process.env.APPDATA ??
|
|
2413
|
+
const appData = opts.appData ?? process.env.APPDATA ?? join6(home, "AppData", "Roaming");
|
|
2179
2414
|
const { clientId, scope, os, projectDir, claudeConfigDir } = opts;
|
|
2180
2415
|
const target = INSTALL_TARGETS.find((t) => t.clientId === clientId);
|
|
2181
2416
|
if (!target) throw new Error(`Unknown client: ${clientId}`);
|
|
@@ -2187,7 +2422,7 @@ function resolveInstallPath(opts) {
|
|
|
2187
2422
|
if (scopeSpec.requiresProjectDir && !projectDir) {
|
|
2188
2423
|
throw new Error(`Scope ${scope} for ${clientId} requires a project directory`);
|
|
2189
2424
|
}
|
|
2190
|
-
const absoluteProjectDir = projectDir && !
|
|
2425
|
+
const absoluteProjectDir = projectDir && !isAbsolute2(projectDir) ? resolve3(projectDir) : projectDir;
|
|
2191
2426
|
const p = pathFor(clientId, scope, os, {
|
|
2192
2427
|
home,
|
|
2193
2428
|
appData,
|
|
@@ -2203,25 +2438,25 @@ function pathFor(client, scope, os, base) {
|
|
|
2203
2438
|
if (client === "claude-code") {
|
|
2204
2439
|
if (scope === "user") {
|
|
2205
2440
|
if (claudeConfigDir) {
|
|
2206
|
-
const absolute =
|
|
2441
|
+
const absolute = join6(claudeConfigDir, ".claude.json");
|
|
2207
2442
|
return { absolute, display: absolute, containerPath: ["mcpServers"] };
|
|
2208
2443
|
}
|
|
2209
2444
|
const display = os === "windows" ? "%USERPROFILE%\\.claude.json" : "~/.claude.json";
|
|
2210
|
-
return { absolute:
|
|
2445
|
+
return { absolute: join6(home, ".claude.json"), display, containerPath: ["mcpServers"] };
|
|
2211
2446
|
}
|
|
2212
2447
|
if (scope === "project") {
|
|
2213
2448
|
return {
|
|
2214
|
-
absolute:
|
|
2449
|
+
absolute: join6(projectDir, ".mcp.json"),
|
|
2215
2450
|
display: joinPath("<project folder>", ".mcp.json"),
|
|
2216
2451
|
containerPath: ["mcpServers"]
|
|
2217
2452
|
};
|
|
2218
2453
|
}
|
|
2219
2454
|
if (claudeConfigDir) {
|
|
2220
|
-
const absolute =
|
|
2455
|
+
const absolute = join6(claudeConfigDir, ".claude.json");
|
|
2221
2456
|
return { absolute, display: absolute, containerPath: ["projects", projectDir, "mcpServers"] };
|
|
2222
2457
|
}
|
|
2223
2458
|
return {
|
|
2224
|
-
absolute:
|
|
2459
|
+
absolute: join6(home, ".claude.json"),
|
|
2225
2460
|
display: os === "windows" ? "%USERPROFILE%\\.claude.json" : "~/.claude.json",
|
|
2226
2461
|
containerPath: ["projects", projectDir, "mcpServers"]
|
|
2227
2462
|
};
|
|
@@ -2229,14 +2464,14 @@ function pathFor(client, scope, os, base) {
|
|
|
2229
2464
|
if (client === "claude-desktop") {
|
|
2230
2465
|
if (os === "macos") {
|
|
2231
2466
|
return {
|
|
2232
|
-
absolute:
|
|
2467
|
+
absolute: join6(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"),
|
|
2233
2468
|
display: "~/Library/Application Support/Claude/claude_desktop_config.json",
|
|
2234
2469
|
containerPath: ["mcpServers"]
|
|
2235
2470
|
};
|
|
2236
2471
|
}
|
|
2237
2472
|
if (os === "windows") {
|
|
2238
2473
|
return {
|
|
2239
|
-
absolute:
|
|
2474
|
+
absolute: join6(appData, "Claude", "claude_desktop_config.json"),
|
|
2240
2475
|
display: "%APPDATA%\\Claude\\claude_desktop_config.json",
|
|
2241
2476
|
containerPath: ["mcpServers"]
|
|
2242
2477
|
};
|
|
@@ -2246,17 +2481,17 @@ function pathFor(client, scope, os, base) {
|
|
|
2246
2481
|
if (client === "cursor") {
|
|
2247
2482
|
if (scope === "user") {
|
|
2248
2483
|
const display = os === "windows" ? "%USERPROFILE%\\.cursor\\mcp.json" : "~/.cursor/mcp.json";
|
|
2249
|
-
return { absolute:
|
|
2484
|
+
return { absolute: join6(home, ".cursor", "mcp.json"), display, containerPath: ["mcpServers"] };
|
|
2250
2485
|
}
|
|
2251
2486
|
return {
|
|
2252
|
-
absolute:
|
|
2487
|
+
absolute: join6(projectDir, ".cursor", "mcp.json"),
|
|
2253
2488
|
display: joinPath("<project folder>", ".cursor", "mcp.json"),
|
|
2254
2489
|
containerPath: ["mcpServers"]
|
|
2255
2490
|
};
|
|
2256
2491
|
}
|
|
2257
2492
|
if (client === "vscode") {
|
|
2258
2493
|
return {
|
|
2259
|
-
absolute:
|
|
2494
|
+
absolute: join6(projectDir, ".vscode", "mcp.json"),
|
|
2260
2495
|
display: joinPath("<project folder>", ".vscode", "mcp.json"),
|
|
2261
2496
|
containerPath: ["servers"]
|
|
2262
2497
|
};
|
|
@@ -2289,9 +2524,9 @@ var CLAUDE_CODE_ALLOW_PATTERN = "mcp__mcp__*";
|
|
|
2289
2524
|
function resolveClaudeCodeSettingsPath(scope, opts) {
|
|
2290
2525
|
const { home, projectDir, claudeConfigDir } = opts;
|
|
2291
2526
|
const cfgDir = claudeConfigDir && claudeConfigDir.length > 0 ? claudeConfigDir : null;
|
|
2292
|
-
if (scope === "user") return cfgDir ?
|
|
2293
|
-
if (scope === "project" && projectDir) return
|
|
2294
|
-
if (scope === "local" && projectDir) return
|
|
2527
|
+
if (scope === "user") return cfgDir ? join6(cfgDir, "settings.json") : join6(home, ".claude", "settings.json");
|
|
2528
|
+
if (scope === "project" && projectDir) return join6(projectDir, ".claude", "settings.json");
|
|
2529
|
+
if (scope === "local" && projectDir) return join6(projectDir, ".claude", "settings.local.json");
|
|
2295
2530
|
return null;
|
|
2296
2531
|
}
|
|
2297
2532
|
|
|
@@ -2424,10 +2659,10 @@ async function reportTools(serverId, tools) {
|
|
|
2424
2659
|
|
|
2425
2660
|
// src/try-cmd.ts
|
|
2426
2661
|
import { createHash as createHash2 } from "crypto";
|
|
2427
|
-
import { existsSync as
|
|
2662
|
+
import { existsSync as existsSync4 } from "fs";
|
|
2428
2663
|
import { chmod as chmod3, mkdir as mkdir2, readdir, readFile as readFile6, unlink } from "fs/promises";
|
|
2429
2664
|
import { homedir as homedir7, hostname, userInfo } from "os";
|
|
2430
|
-
import { join as
|
|
2665
|
+
import { join as join8, resolve as resolve5 } from "path";
|
|
2431
2666
|
import { request as request5 } from "undici";
|
|
2432
2667
|
|
|
2433
2668
|
// src/catalog.ts
|
|
@@ -2529,10 +2764,10 @@ async function resolveCatalogSlug(slug, opts = {}) {
|
|
|
2529
2764
|
}
|
|
2530
2765
|
|
|
2531
2766
|
// src/install-cmd.ts
|
|
2532
|
-
import { existsSync as
|
|
2767
|
+
import { existsSync as existsSync3 } from "fs";
|
|
2533
2768
|
import { chmod as chmod2, readFile as readFile5 } from "fs/promises";
|
|
2534
2769
|
import { homedir as homedir6 } from "os";
|
|
2535
|
-
import { join as
|
|
2770
|
+
import { join as join7, resolve as resolve4 } from "path";
|
|
2536
2771
|
import { createInterface } from "readline/promises";
|
|
2537
2772
|
import { Writable } from "stream";
|
|
2538
2773
|
var USAGE = "Usage: yaw-mcp install <claude-code|claude-desktop|cursor|vscode> [--scope user|project|local]\n [--token <mcp_pat_\u2026>] [--project-dir <path>] [--os macos|linux|windows]\n [--force | --skip] [--dry-run] [--no-yaw-mcp-config]\n yaw-mcp install --list (detect clients; no writes)\n yaw-mcp install --all [--token <mcp_pat_\u2026>] (install into every detected client)\n\n Note: --token puts the PAT on the command line, where it is visible in shell\n history and the process table (ps/Task Manager) -- avoid it on shared machines.\n Prefer seeding ~/.yaw-mcp/config.json once (install reads the token from there),\n or set the token via your account before installing.";
|
|
@@ -2610,7 +2845,7 @@ ${USAGE}`);
|
|
|
2610
2845
|
}
|
|
2611
2846
|
if (!token5) {
|
|
2612
2847
|
log2(
|
|
2613
|
-
"yaw-mcp install: no token resolved -- configuring for local mode
|
|
2848
|
+
"yaw-mcp install: no token resolved -- configuring for local mode.\n Add servers by editing ~/.yaw-mcp/bundles.json, or re-run with --token mcp_pat_... to use a Yaw MCP account."
|
|
2614
2849
|
);
|
|
2615
2850
|
}
|
|
2616
2851
|
const newEntry = buildLaunchEntry({ os });
|
|
@@ -2618,7 +2853,7 @@ ${USAGE}`);
|
|
|
2618
2853
|
let existing = {};
|
|
2619
2854
|
let existingHasEntry = false;
|
|
2620
2855
|
let legacyEntry = null;
|
|
2621
|
-
if (
|
|
2856
|
+
if (existsSync3(resolved.absolute)) {
|
|
2622
2857
|
let raw;
|
|
2623
2858
|
try {
|
|
2624
2859
|
raw = await readFile5(resolved.absolute, "utf8");
|
|
@@ -2679,7 +2914,7 @@ ${USAGE}`);
|
|
|
2679
2914
|
`;
|
|
2680
2915
|
const writeYawMcpConfig = !opts.skipYawMcpConfig && token5 !== null;
|
|
2681
2916
|
const home = opts.home ?? homedir6();
|
|
2682
|
-
const yawMcpConfigPath =
|
|
2917
|
+
const yawMcpConfigPath = join7(home, CONFIG_DIRNAME, CONFIG_FILENAME);
|
|
2683
2918
|
const yawMcpConfigComposed = writeYawMcpConfig ? await composeYawMcpConfig(yawMcpConfigPath, token5) : { json: "" };
|
|
2684
2919
|
if ("backupPath" in yawMcpConfigComposed && yawMcpConfigComposed.backupPath) {
|
|
2685
2920
|
const reason = yawMcpConfigComposed.backupReason;
|
|
@@ -2780,7 +3015,7 @@ async function prepareClaudeCodeSettingsPatch(opts) {
|
|
|
2780
3015
|
});
|
|
2781
3016
|
if (!path5) return null;
|
|
2782
3017
|
let existing = {};
|
|
2783
|
-
if (
|
|
3018
|
+
if (existsSync3(path5)) {
|
|
2784
3019
|
try {
|
|
2785
3020
|
const raw = await readFile5(path5, "utf8");
|
|
2786
3021
|
if (raw.trim().length > 0) {
|
|
@@ -2879,7 +3114,7 @@ async function composeYawMcpConfig(path5, token5) {
|
|
|
2879
3114
|
let existing = {};
|
|
2880
3115
|
let backupPath;
|
|
2881
3116
|
let backupReason;
|
|
2882
|
-
if (
|
|
3117
|
+
if (existsSync3(path5)) {
|
|
2883
3118
|
let raw = "";
|
|
2884
3119
|
try {
|
|
2885
3120
|
raw = await readFile5(path5, "utf8");
|
|
@@ -3284,13 +3519,13 @@ function parseDurationMs(s) {
|
|
|
3284
3519
|
return n * factor;
|
|
3285
3520
|
}
|
|
3286
3521
|
function trialsDir(home = homedir7()) {
|
|
3287
|
-
return
|
|
3522
|
+
return join8(home, CONFIG_DIRNAME, TRIALS_DIRNAME);
|
|
3288
3523
|
}
|
|
3289
3524
|
function trialMarkerPath(slug, home = homedir7()) {
|
|
3290
|
-
return
|
|
3525
|
+
return join8(trialsDir(home), `${slug}.json`);
|
|
3291
3526
|
}
|
|
3292
3527
|
function anonIdPath(home = homedir7()) {
|
|
3293
|
-
return
|
|
3528
|
+
return join8(trialsDir(home), ANON_FILENAME);
|
|
3294
3529
|
}
|
|
3295
3530
|
function computeAnonId() {
|
|
3296
3531
|
const h = createHash2("sha256");
|
|
@@ -3303,7 +3538,7 @@ function computeAnonId() {
|
|
|
3303
3538
|
}
|
|
3304
3539
|
async function loadOrCreateAnonId(home = homedir7()) {
|
|
3305
3540
|
const path5 = anonIdPath(home);
|
|
3306
|
-
if (
|
|
3541
|
+
if (existsSync4(path5)) {
|
|
3307
3542
|
try {
|
|
3308
3543
|
const raw = (await readFile6(path5, "utf8")).trim();
|
|
3309
3544
|
if (/^[0-9a-f]{16}$/.test(raw)) return raw;
|
|
@@ -3455,7 +3690,7 @@ async function runTry(opts) {
|
|
|
3455
3690
|
entryName,
|
|
3456
3691
|
createdAt: now
|
|
3457
3692
|
};
|
|
3458
|
-
const clientPreExisted =
|
|
3693
|
+
const clientPreExisted = existsSync4(resolved.absolute);
|
|
3459
3694
|
let rawClient = null;
|
|
3460
3695
|
if (clientPreExisted) {
|
|
3461
3696
|
try {
|
|
@@ -3559,7 +3794,7 @@ async function runTryCleanup(opts) {
|
|
|
3559
3794
|
const home = opts.home ?? homedir7();
|
|
3560
3795
|
const baseUrl = opts.baseUrl ?? env.YAW_MCP_BASE_URL ?? DEFAULT_BASE_URL;
|
|
3561
3796
|
const markerPath = trialMarkerPath(slug, home);
|
|
3562
|
-
if (!
|
|
3797
|
+
if (!existsSync4(markerPath)) {
|
|
3563
3798
|
print(`yaw-mcp try-cleanup: no trial marker for "${slug}" (nothing to do).`);
|
|
3564
3799
|
return { exitCode: 0, written: [] };
|
|
3565
3800
|
}
|
|
@@ -3576,7 +3811,7 @@ async function runTryCleanup(opts) {
|
|
|
3576
3811
|
return { exitCode: 1, written: [] };
|
|
3577
3812
|
}
|
|
3578
3813
|
const written = [];
|
|
3579
|
-
if (
|
|
3814
|
+
if (existsSync4(marker.clientPath)) {
|
|
3580
3815
|
try {
|
|
3581
3816
|
const raw = await readFile6(marker.clientPath, "utf8");
|
|
3582
3817
|
if (raw.trim().length > 0) {
|
|
@@ -3622,7 +3857,7 @@ async function scanTrials(opts = {}) {
|
|
|
3622
3857
|
const now = opts.now ? opts.now() : Date.now();
|
|
3623
3858
|
const dir = trialsDir(home);
|
|
3624
3859
|
const result = { live: [], expired: [], malformed: [] };
|
|
3625
|
-
if (!
|
|
3860
|
+
if (!existsSync4(dir)) return result;
|
|
3626
3861
|
let entries;
|
|
3627
3862
|
try {
|
|
3628
3863
|
entries = await readdir(dir);
|
|
@@ -3631,7 +3866,7 @@ async function scanTrials(opts = {}) {
|
|
|
3631
3866
|
}
|
|
3632
3867
|
for (const filename of entries) {
|
|
3633
3868
|
if (!filename.endsWith(".json")) continue;
|
|
3634
|
-
const path5 =
|
|
3869
|
+
const path5 = join8(dir, filename);
|
|
3635
3870
|
try {
|
|
3636
3871
|
const raw = await readFile6(path5, "utf8");
|
|
3637
3872
|
const parsed = JSON.parse(raw);
|
|
@@ -3662,7 +3897,7 @@ async function gcExpiredTrials(opts) {
|
|
|
3662
3897
|
let failed = 0;
|
|
3663
3898
|
for (const { marker } of scan.expired) {
|
|
3664
3899
|
try {
|
|
3665
|
-
if (
|
|
3900
|
+
if (existsSync4(marker.clientPath)) {
|
|
3666
3901
|
const raw = await readFile6(marker.clientPath, "utf8");
|
|
3667
3902
|
if (raw.trim().length > 0) {
|
|
3668
3903
|
const parsed = parseJsonc(raw);
|
|
@@ -4006,7 +4241,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4006
4241
|
return { exitCode: 3, lines };
|
|
4007
4242
|
}
|
|
4008
4243
|
function readCurrentVersion() {
|
|
4009
|
-
return true ? "0.
|
|
4244
|
+
return true ? "0.70.1" : "dev";
|
|
4010
4245
|
}
|
|
4011
4246
|
|
|
4012
4247
|
// src/usage-hints.ts
|
|
@@ -4068,7 +4303,7 @@ function selectFlakyNamespaces(entries, limit) {
|
|
|
4068
4303
|
}
|
|
4069
4304
|
|
|
4070
4305
|
// src/doctor-cmd.ts
|
|
4071
|
-
var VERSION = true ? "0.
|
|
4306
|
+
var VERSION = true ? "0.70.1" : "dev";
|
|
4072
4307
|
function isPersistenceDisabled(env) {
|
|
4073
4308
|
const raw = env.YAW_MCP_DISABLE_PERSISTENCE;
|
|
4074
4309
|
return raw !== void 0 && raw !== "" && (raw === "1" || raw.toLowerCase() === "true");
|
|
@@ -4109,8 +4344,10 @@ async function runDoctor(opts = {}) {
|
|
|
4109
4344
|
print(` source: ${config.apiBaseSource}`);
|
|
4110
4345
|
print("");
|
|
4111
4346
|
renderEnvSection({ env, print });
|
|
4347
|
+
const oamStatus = await collectOamRuntimeStatus({ env, cwd, home, probeFn: opts.oamProbe ?? probeOam });
|
|
4348
|
+
renderOamRuntimeSection({ status: oamStatus, print });
|
|
4112
4349
|
const persistenceDisabled = isPersistenceDisabled(env);
|
|
4113
|
-
const stateFilePath =
|
|
4350
|
+
const stateFilePath = join9(userConfigDir(home), STATE_FILENAME);
|
|
4114
4351
|
const statePeek = persistenceDisabled ? null : await peekStateFile(stateFilePath);
|
|
4115
4352
|
const persistedState = statePeek?.kind === "ok" ? await loadState(stateFilePath) : null;
|
|
4116
4353
|
renderStateSection({
|
|
@@ -4188,7 +4425,7 @@ async function runDoctor(opts = {}) {
|
|
|
4188
4425
|
}
|
|
4189
4426
|
if (config.token === null) {
|
|
4190
4427
|
print("DIAGNOSIS");
|
|
4191
|
-
print(" Local mode
|
|
4428
|
+
print(" Local mode -- fully functional, no account needed. yaw-mcp serves");
|
|
4192
4429
|
print(" whatever servers are configured locally in ~/.yaw-mcp/bundles.json.");
|
|
4193
4430
|
} else if (config.warnings.length > 0) {
|
|
4194
4431
|
exitCode = 2;
|
|
@@ -4219,7 +4456,8 @@ async function runDoctorJson(opts) {
|
|
|
4219
4456
|
"YAW_MCP_MIN_COMPLIANCE",
|
|
4220
4457
|
"YAW_MCP_AUTO_LOAD",
|
|
4221
4458
|
"YAW_MCP_AUTO_ACTIVATE",
|
|
4222
|
-
"YAW_MCP_PRUNE_RESPONSES"
|
|
4459
|
+
"YAW_MCP_PRUNE_RESPONSES",
|
|
4460
|
+
"YAW_MCP_DEFAULT_RUNTIME"
|
|
4223
4461
|
];
|
|
4224
4462
|
const envOverrides = {};
|
|
4225
4463
|
for (const name of envVarNames) {
|
|
@@ -4227,7 +4465,7 @@ async function runDoctorJson(opts) {
|
|
|
4227
4465
|
envOverrides[name] = raw === void 0 || raw === "" ? null : raw;
|
|
4228
4466
|
}
|
|
4229
4467
|
const persistDisabled = isPersistenceDisabled(env);
|
|
4230
|
-
const stateFilePath =
|
|
4468
|
+
const stateFilePath = join9(userConfigDir(home), STATE_FILENAME);
|
|
4231
4469
|
const persisted = persistDisabled ? null : await loadState(stateFilePath);
|
|
4232
4470
|
const state = persistDisabled || !persisted ? { disabled: true, path: null, savedAt: null, learningEntries: null, packHistoryEntries: null } : (() => {
|
|
4233
4471
|
const fresh = persisted.savedAt === 0;
|
|
@@ -4247,7 +4485,10 @@ async function runDoctorJson(opts) {
|
|
|
4247
4485
|
reliability.push({
|
|
4248
4486
|
namespace,
|
|
4249
4487
|
dispatched: usage.dispatched,
|
|
4250
|
-
succeeded
|
|
4488
|
+
// `succeeded` is a graded-reward SUM (learning.ts), so adding [0,1]
|
|
4489
|
+
// rewards can leave IEEE-754 noise (e.g. 48.00000000000001). Round for
|
|
4490
|
+
// a clean diagnostic; successRate stays computed from the raw value.
|
|
4491
|
+
succeeded: Math.round(usage.succeeded * 1e3) / 1e3,
|
|
4251
4492
|
successRate: usage.succeeded / usage.dispatched,
|
|
4252
4493
|
lastUsedAt: new Date(usage.lastUsedAt).toISOString()
|
|
4253
4494
|
});
|
|
@@ -4270,6 +4511,21 @@ async function runDoctorJson(opts) {
|
|
|
4270
4511
|
})),
|
|
4271
4512
|
malformed: trialScan.malformed
|
|
4272
4513
|
};
|
|
4514
|
+
const oamStatus = await collectOamRuntimeStatus({ env, cwd, home, probeFn: opts.oamProbe ?? probeOam });
|
|
4515
|
+
const oamRuntime = {
|
|
4516
|
+
binary: oamStatus.probe.bin,
|
|
4517
|
+
version: oamStatus.probe.version,
|
|
4518
|
+
belowMin: oamStatus.probe.belowMin,
|
|
4519
|
+
minVersion: MIN_OAM_VERSION,
|
|
4520
|
+
defaultRuntime: oamStatus.dflt.runtime,
|
|
4521
|
+
defaultRuntimeSource: oamStatus.dflt.source,
|
|
4522
|
+
defaultRuntimePath: oamStatus.dflt.path,
|
|
4523
|
+
servers: oamStatus.servers.map((s) => ({
|
|
4524
|
+
namespace: s.namespace,
|
|
4525
|
+
runtime: s.info.runtime,
|
|
4526
|
+
reason: s.info.reason
|
|
4527
|
+
}))
|
|
4528
|
+
};
|
|
4273
4529
|
const analyticsFailure = getLastAnalyticsFailure();
|
|
4274
4530
|
const reportFailure = getLastReportFailure();
|
|
4275
4531
|
const backgroundPosters = {
|
|
@@ -4292,7 +4548,7 @@ async function runDoctorJson(opts) {
|
|
|
4292
4548
|
`);
|
|
4293
4549
|
}
|
|
4294
4550
|
if (config.token === null) {
|
|
4295
|
-
summary = "Local mode
|
|
4551
|
+
summary = "Local mode -- fully functional, no account needed.";
|
|
4296
4552
|
} else if (config.warnings.length > 0) {
|
|
4297
4553
|
exitCode = 2;
|
|
4298
4554
|
summary = "Token present, but warnings need attention.";
|
|
@@ -4319,6 +4575,7 @@ async function runDoctorJson(opts) {
|
|
|
4319
4575
|
shellShadows,
|
|
4320
4576
|
trials,
|
|
4321
4577
|
backgroundPosters,
|
|
4578
|
+
oamRuntime,
|
|
4322
4579
|
upgrade: { current: effectiveVersion, latest, stale },
|
|
4323
4580
|
diagnosis: { exitCode, summary }
|
|
4324
4581
|
};
|
|
@@ -4336,7 +4593,8 @@ function renderEnvSection(opts) {
|
|
|
4336
4593
|
{ name: "YAW_MCP_MIN_COMPLIANCE", defaultHint: "filter inactive" },
|
|
4337
4594
|
{ name: "YAW_MCP_AUTO_LOAD", defaultHint: "auto-load inactive" },
|
|
4338
4595
|
{ name: "YAW_MCP_AUTO_ACTIVATE", defaultHint: "default on" },
|
|
4339
|
-
{ name: "YAW_MCP_PRUNE_RESPONSES", defaultHint: "pruning active" }
|
|
4596
|
+
{ name: "YAW_MCP_PRUNE_RESPONSES", defaultHint: "pruning active" },
|
|
4597
|
+
{ name: "YAW_MCP_DEFAULT_RUNTIME", defaultHint: "per-server opt-in only" }
|
|
4340
4598
|
];
|
|
4341
4599
|
const widest = vars.reduce((m, v) => Math.max(m, v.name.length), 0);
|
|
4342
4600
|
print("ENVIRONMENT (behavior overrides)");
|
|
@@ -4347,6 +4605,38 @@ function renderEnvSection(opts) {
|
|
|
4347
4605
|
}
|
|
4348
4606
|
print("");
|
|
4349
4607
|
}
|
|
4608
|
+
async function collectOamRuntimeStatus(opts) {
|
|
4609
|
+
const probe2 = opts.probeFn();
|
|
4610
|
+
const dflt = await describeDefaultRuntime({ env: opts.env, cwd: opts.cwd, home: opts.home });
|
|
4611
|
+
const bundles = await loadLocalBundles({ cwd: opts.cwd, home: opts.home }).catch(() => null);
|
|
4612
|
+
const servers = (bundles?.config?.servers ?? []).map((s) => ({
|
|
4613
|
+
namespace: s.namespace,
|
|
4614
|
+
info: describeServerRuntime(s, dflt.runtime, probe2)
|
|
4615
|
+
}));
|
|
4616
|
+
return { probe: probe2, dflt, servers };
|
|
4617
|
+
}
|
|
4618
|
+
function renderOamRuntimeSection(opts) {
|
|
4619
|
+
const { status, print } = opts;
|
|
4620
|
+
const { probe: probe2, dflt, servers } = status;
|
|
4621
|
+
print("OAM RUNTIME");
|
|
4622
|
+
if (probe2.belowMin) {
|
|
4623
|
+
print(` binary: installed (v${probe2.version}) \u2014 below min ${MIN_OAM_VERSION}; IGNORED, servers run on node`);
|
|
4624
|
+
} else if (probe2.bin === null) {
|
|
4625
|
+
print(" binary: not installed \u2014 node/npx spawns are used directly");
|
|
4626
|
+
} else {
|
|
4627
|
+
print(` binary: ${probe2.bin} (v${probe2.version ?? "unknown"}, min ${MIN_OAM_VERSION})`);
|
|
4628
|
+
}
|
|
4629
|
+
const dfltLabel = dflt.runtime !== null ? `${dflt.runtime} (${dflt.source === "env" ? "env YAW_MCP_DEFAULT_RUNTIME" : `bundles.json defaultRuntime @ ${dflt.path}`})` : '(not set \u2014 per-server runtime:"oam" opt-in only)';
|
|
4630
|
+
print(` default runtime: ${dfltLabel}`);
|
|
4631
|
+
if (servers.length > 0) {
|
|
4632
|
+
print(" servers (local bundles.json):");
|
|
4633
|
+
const widest = servers.reduce((m, s) => Math.max(m, s.namespace.length), 0);
|
|
4634
|
+
for (const s of servers) {
|
|
4635
|
+
print(` ${s.namespace.padEnd(widest)} ${(s.info.runtime ?? "-").padEnd(4)} ${s.info.reason}`);
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
print("");
|
|
4639
|
+
}
|
|
4350
4640
|
function renderStateSection(opts) {
|
|
4351
4641
|
const { filePath, disabled, persisted, peek, print } = opts;
|
|
4352
4642
|
print("STATE");
|
|
@@ -4519,7 +4809,7 @@ function probeClients(opts) {
|
|
|
4519
4809
|
} catch {
|
|
4520
4810
|
continue;
|
|
4521
4811
|
}
|
|
4522
|
-
const exists3 =
|
|
4812
|
+
const exists3 = existsSync5(resolved.absolute);
|
|
4523
4813
|
let classified = {
|
|
4524
4814
|
hasMcpEntry: false,
|
|
4525
4815
|
hasLegacyEntry: false,
|
|
@@ -4529,7 +4819,7 @@ function probeClients(opts) {
|
|
|
4529
4819
|
if (exists3) {
|
|
4530
4820
|
try {
|
|
4531
4821
|
statSync(resolved.absolute);
|
|
4532
|
-
const raw =
|
|
4822
|
+
const raw = readFileSync2(resolved.absolute, "utf8");
|
|
4533
4823
|
classified = classifyProbeContent(raw, resolved.containerPath);
|
|
4534
4824
|
} catch {
|
|
4535
4825
|
classified = { hasMcpEntry: false, hasLegacyEntry: false, legacyEntryName: null, malformed: true };
|
|
@@ -4612,7 +4902,7 @@ async function probeClientsAsync(opts) {
|
|
|
4612
4902
|
} catch {
|
|
4613
4903
|
continue;
|
|
4614
4904
|
}
|
|
4615
|
-
const exists3 =
|
|
4905
|
+
const exists3 = existsSync5(resolved.absolute);
|
|
4616
4906
|
let classified = {
|
|
4617
4907
|
hasMcpEntry: false,
|
|
4618
4908
|
hasLegacyEntry: false,
|
|
@@ -4689,9 +4979,9 @@ function scanShellHistoryForShadows(opts) {
|
|
|
4689
4979
|
}
|
|
4690
4980
|
function shellHistorySources(opts) {
|
|
4691
4981
|
const sources = [];
|
|
4692
|
-
sources.push({ path:
|
|
4982
|
+
sources.push({ path: join9(opts.home, ".bash_history"), extractCommand: (l) => l.trim() || null });
|
|
4693
4983
|
sources.push({
|
|
4694
|
-
path:
|
|
4984
|
+
path: join9(opts.home, ".zsh_history"),
|
|
4695
4985
|
// Zsh extended-history lines look like `: 1700000000:0;npm audit`.
|
|
4696
4986
|
// Strip the metadata prefix so we get just the command.
|
|
4697
4987
|
extractCommand: (l) => {
|
|
@@ -4707,7 +4997,7 @@ function shellHistorySources(opts) {
|
|
|
4707
4997
|
const appData = opts.env.APPDATA;
|
|
4708
4998
|
if (appData) {
|
|
4709
4999
|
sources.push({
|
|
4710
|
-
path:
|
|
5000
|
+
path: join9(appData, "Microsoft", "Windows", "PowerShell", "PSReadLine", "ConsoleHost_history.txt"),
|
|
4711
5001
|
extractCommand: (l) => l.trim() || null
|
|
4712
5002
|
});
|
|
4713
5003
|
}
|
|
@@ -4715,7 +5005,7 @@ function shellHistorySources(opts) {
|
|
|
4715
5005
|
}
|
|
4716
5006
|
function readTailLines(path5, n) {
|
|
4717
5007
|
try {
|
|
4718
|
-
const raw =
|
|
5008
|
+
const raw = readFileSync2(path5, "utf8");
|
|
4719
5009
|
const all = raw.split(/\r?\n/);
|
|
4720
5010
|
return all.length <= n ? all : all.slice(all.length - n);
|
|
4721
5011
|
} catch {
|
|
@@ -4761,7 +5051,7 @@ function compareSemver(a, b) {
|
|
|
4761
5051
|
}
|
|
4762
5052
|
|
|
4763
5053
|
// src/foundry-cmd.ts
|
|
4764
|
-
import { mkdirSync, readFileSync as
|
|
5054
|
+
import { mkdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
4765
5055
|
import { homedir as homedir10 } from "os";
|
|
4766
5056
|
import path3 from "path";
|
|
4767
5057
|
|
|
@@ -4958,7 +5248,7 @@ async function appendFoundryTrace(trace, home = homedir9()) {
|
|
|
4958
5248
|
}
|
|
4959
5249
|
|
|
4960
5250
|
// src/foundry-corpus.ts
|
|
4961
|
-
import { readFileSync as
|
|
5251
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
4962
5252
|
var FOUNDRY_CORPUS_VERSION = 1;
|
|
4963
5253
|
var DEFAULT_CORPUS_CAP = 500;
|
|
4964
5254
|
function parseTraceLines(text) {
|
|
@@ -5121,7 +5411,7 @@ async function runFoundryExport(opts) {
|
|
|
5121
5411
|
const harvestPath = path3.join(userConfigDir(home), FOUNDRY_FILENAME);
|
|
5122
5412
|
const blob = opts.readTraces ? opts.readTraces() : (() => {
|
|
5123
5413
|
try {
|
|
5124
|
-
return
|
|
5414
|
+
return readFileSync4(harvestPath, "utf8");
|
|
5125
5415
|
} catch {
|
|
5126
5416
|
return null;
|
|
5127
5417
|
}
|
|
@@ -5591,7 +5881,7 @@ async function runLogout(opts = {}, io = {
|
|
|
5591
5881
|
// src/reset-learning-cmd.ts
|
|
5592
5882
|
import { readFile as readFile8, unlink as unlink2 } from "fs/promises";
|
|
5593
5883
|
import { homedir as homedir12 } from "os";
|
|
5594
|
-
import { join as
|
|
5884
|
+
import { join as join10 } from "path";
|
|
5595
5885
|
var RESET_LEARNING_USAGE = `Usage: yaw-mcp reset-learning
|
|
5596
5886
|
|
|
5597
5887
|
Delete ~/.yaw-mcp/state.json so cross-session learning starts fresh.
|
|
@@ -5627,7 +5917,7 @@ async function runResetLearning(opts = {}) {
|
|
|
5627
5917
|
writeErr(`${s}
|
|
5628
5918
|
`);
|
|
5629
5919
|
};
|
|
5630
|
-
const filePath =
|
|
5920
|
+
const filePath = join10(userConfigDir(home), STATE_FILENAME);
|
|
5631
5921
|
const raw = env.YAW_MCP_DISABLE_PERSISTENCE;
|
|
5632
5922
|
const disabled = raw !== void 0 && raw !== "" && (raw === "1" || raw.toLowerCase() === "true");
|
|
5633
5923
|
if (disabled) {
|
|
@@ -5682,18 +5972,18 @@ function isFileNotFound2(err) {
|
|
|
5682
5972
|
}
|
|
5683
5973
|
|
|
5684
5974
|
// src/secrets-cmd.ts
|
|
5685
|
-
import { existsSync as
|
|
5975
|
+
import { existsSync as existsSync7 } from "fs";
|
|
5686
5976
|
import { homedir as homedir15 } from "os";
|
|
5687
5977
|
|
|
5688
5978
|
// src/secrets-audit.ts
|
|
5689
|
-
import { existsSync as
|
|
5979
|
+
import { existsSync as existsSync6 } from "fs";
|
|
5690
5980
|
import { appendFile as appendFile2, chmod as chmod4, readFile as readFile9, writeFile } from "fs/promises";
|
|
5691
5981
|
import { homedir as homedir13 } from "os";
|
|
5692
|
-
import { join as
|
|
5982
|
+
import { join as join11 } from "path";
|
|
5693
5983
|
var SECRETS_AUDIT_FILENAME = "secrets-audit.log";
|
|
5694
5984
|
var AUDIT_TAIL_CAP = 5e3;
|
|
5695
5985
|
function auditLogPath(home = homedir13()) {
|
|
5696
|
-
return
|
|
5986
|
+
return join11(home, CONFIG_DIRNAME, SECRETS_AUDIT_FILENAME);
|
|
5697
5987
|
}
|
|
5698
5988
|
async function appendAuditEvent(input, home = homedir13()) {
|
|
5699
5989
|
try {
|
|
@@ -5706,7 +5996,7 @@ async function appendAuditEvent(input, home = homedir13()) {
|
|
|
5706
5996
|
const path5 = auditLogPath(home);
|
|
5707
5997
|
const line = `${JSON.stringify(event)}
|
|
5708
5998
|
`;
|
|
5709
|
-
if (!
|
|
5999
|
+
if (!existsSync6(path5)) {
|
|
5710
6000
|
await atomicWriteFile(path5, line);
|
|
5711
6001
|
} else {
|
|
5712
6002
|
await appendFile2(path5, line, "utf8");
|
|
@@ -5728,7 +6018,7 @@ async function trimToTailCap(path5) {
|
|
|
5728
6018
|
}
|
|
5729
6019
|
async function readAuditLog(filter = {}, home = homedir13()) {
|
|
5730
6020
|
const path5 = auditLogPath(home);
|
|
5731
|
-
if (!
|
|
6021
|
+
if (!existsSync6(path5)) return [];
|
|
5732
6022
|
let raw;
|
|
5733
6023
|
try {
|
|
5734
6024
|
raw = await readFile9(path5, "utf8");
|
|
@@ -5760,7 +6050,7 @@ function isAuditEvent(v) {
|
|
|
5760
6050
|
// src/secrets-vault.ts
|
|
5761
6051
|
import { chmod as chmod5, mkdir as mkdir4, readFile as readFile10 } from "fs/promises";
|
|
5762
6052
|
import { homedir as homedir14 } from "os";
|
|
5763
|
-
import { dirname as dirname2, join as
|
|
6053
|
+
import { dirname as dirname2, join as join12 } from "path";
|
|
5764
6054
|
|
|
5765
6055
|
// src/secrets-crypto.ts
|
|
5766
6056
|
import { createCipheriv, createDecipheriv, randomBytes, scrypt as scryptCb } from "crypto";
|
|
@@ -5820,7 +6110,7 @@ var SECRETS_FILENAME = "secrets.json";
|
|
|
5820
6110
|
var SECRETS_SCHEMA_VERSION = 1;
|
|
5821
6111
|
var VAULT_CHECK_PLAINTEXT = "yaw-mcp-vault-v1";
|
|
5822
6112
|
function vaultPath(home = homedir14()) {
|
|
5823
|
-
return
|
|
6113
|
+
return join12(home, CONFIG_DIRNAME, SECRETS_FILENAME);
|
|
5824
6114
|
}
|
|
5825
6115
|
function emptyVault() {
|
|
5826
6116
|
return {
|
|
@@ -6333,7 +6623,7 @@ async function runSecrets(opts, io = {
|
|
|
6333
6623
|
if (!loaded.ok) return loaded.result;
|
|
6334
6624
|
const vault2 = loaded.vault;
|
|
6335
6625
|
const keys = vault2 ? listKeys(vault2) : [];
|
|
6336
|
-
if (opts.json) io.out(`${JSON.stringify({ ok: true, vault:
|
|
6626
|
+
if (opts.json) io.out(`${JSON.stringify({ ok: true, vault: existsSync7(path5), keys }, null, 2)}
|
|
6337
6627
|
`);
|
|
6338
6628
|
else if (!vault2) io.out(`No vault at ${path5}. Run \`yaw-mcp secrets set <name>\` to create one.
|
|
6339
6629
|
`);
|
|
@@ -6364,7 +6654,7 @@ async function runSecrets(opts, io = {
|
|
|
6364
6654
|
const loadedForMutate = await safeLoadVault(path5, io, opts.json, opts.action ?? "");
|
|
6365
6655
|
if (!loadedForMutate.ok) return loadedForMutate.result;
|
|
6366
6656
|
let vault = loadedForMutate.vault ?? newVault();
|
|
6367
|
-
const isFresh = !
|
|
6657
|
+
const isFresh = !existsSync7(path5);
|
|
6368
6658
|
const passphrase = await resolvePassphrase(opts);
|
|
6369
6659
|
if (passphrase === null) {
|
|
6370
6660
|
const msg = "Passphrase required. Set YAW_MCP_VAULT_PASSPHRASE or run from a TTY so we can prompt.";
|
|
@@ -6777,7 +7067,7 @@ import { request as request10 } from "undici";
|
|
|
6777
7067
|
// src/auto-upgrade.ts
|
|
6778
7068
|
import { spawn as spawn3 } from "child_process";
|
|
6779
7069
|
import { realpathSync as realpathSync2 } from "fs";
|
|
6780
|
-
import { dirname as dirname3, sep } from "path";
|
|
7070
|
+
import { dirname as dirname3, sep as sep2 } from "path";
|
|
6781
7071
|
function detectRunningInstallPrefix(argvPath) {
|
|
6782
7072
|
if (!argvPath) return null;
|
|
6783
7073
|
let resolved;
|
|
@@ -6790,10 +7080,10 @@ function detectRunningInstallPrefix(argvPath) {
|
|
|
6790
7080
|
let prev = "";
|
|
6791
7081
|
let safety = 24;
|
|
6792
7082
|
while (dir !== prev && safety-- > 0) {
|
|
6793
|
-
const idx = dir.lastIndexOf(`${
|
|
7083
|
+
const idx = dir.lastIndexOf(`${sep2}node_modules${sep2}`);
|
|
6794
7084
|
if (idx !== -1) {
|
|
6795
7085
|
const candidate = dir.slice(0, idx);
|
|
6796
|
-
if (candidate.endsWith(`${
|
|
7086
|
+
if (candidate.endsWith(`${sep2}lib`)) return candidate.slice(0, -`${sep2}lib`.length);
|
|
6797
7087
|
return candidate;
|
|
6798
7088
|
}
|
|
6799
7089
|
prev = dir;
|
|
@@ -6876,7 +7166,7 @@ function defaultSpawn2(cmd, args) {
|
|
|
6876
7166
|
async function maybeAutoUpgrade(deps = {}) {
|
|
6877
7167
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
6878
7168
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
6879
|
-
const current = deps.currentVersion ?? (true ? "0.
|
|
7169
|
+
const current = deps.currentVersion ?? (true ? "0.70.1" : "dev");
|
|
6880
7170
|
if (current === "dev") return;
|
|
6881
7171
|
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
6882
7172
|
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion2)();
|
|
@@ -7610,13 +7900,13 @@ function pushToolCall(history, record, limit = HISTORY_LIMIT) {
|
|
|
7610
7900
|
}
|
|
7611
7901
|
|
|
7612
7902
|
// src/install-nudge.ts
|
|
7613
|
-
import { existsSync as
|
|
7614
|
-
import { dirname as dirname4, join as
|
|
7903
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
7904
|
+
import { dirname as dirname4, join as join13 } from "path";
|
|
7615
7905
|
var INSTALL_NUDGE_MIN_COUNT = 5;
|
|
7616
7906
|
var INSTALL_NUDGE_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
7617
7907
|
var INSTALL_NUDGE_STATE_FILENAME = "install-nudge-state.json";
|
|
7618
7908
|
function installNudgeStatePath(home) {
|
|
7619
|
-
return
|
|
7909
|
+
return join13(home, CONFIG_DIRNAME, INSTALL_NUDGE_STATE_FILENAME);
|
|
7620
7910
|
}
|
|
7621
7911
|
function installNudgeEnabled(env, config) {
|
|
7622
7912
|
if (env.YAW_MCP_INSTALL_NUDGE === "1") return true;
|
|
@@ -7625,9 +7915,9 @@ function installNudgeEnabled(env, config) {
|
|
|
7625
7915
|
}
|
|
7626
7916
|
function readState(home) {
|
|
7627
7917
|
const path5 = installNudgeStatePath(home);
|
|
7628
|
-
if (!
|
|
7918
|
+
if (!existsSync8(path5)) return { nudges: [] };
|
|
7629
7919
|
try {
|
|
7630
|
-
const parsed = JSON.parse(
|
|
7920
|
+
const parsed = JSON.parse(readFileSync5(path5, "utf8"));
|
|
7631
7921
|
if (!parsed || typeof parsed !== "object") return { nudges: [] };
|
|
7632
7922
|
const raw = parsed.nudges;
|
|
7633
7923
|
if (!Array.isArray(raw)) return { nudges: [] };
|
|
@@ -8887,7 +9177,7 @@ async function callLegacyRerank(payload) {
|
|
|
8887
9177
|
}
|
|
8888
9178
|
}
|
|
8889
9179
|
async function readTeamCookie() {
|
|
8890
|
-
const teamSync = await import("./team-sync-
|
|
9180
|
+
const teamSync = await import("./team-sync-7QRMSGUD.js");
|
|
8891
9181
|
return teamSync.getCachedCookie();
|
|
8892
9182
|
}
|
|
8893
9183
|
|
|
@@ -9429,117 +9719,6 @@ import {
|
|
|
9429
9719
|
ToolListChangedNotificationSchema
|
|
9430
9720
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9431
9721
|
|
|
9432
|
-
// src/oam-spawn.ts
|
|
9433
|
-
import { execFileSync } from "child_process";
|
|
9434
|
-
import { existsSync as existsSync8, readdirSync, readFileSync as readFileSync5 } from "fs";
|
|
9435
|
-
import { isAbsolute as isAbsolute2, join as join13, sep as sep2 } from "path";
|
|
9436
|
-
import { fileURLToPath } from "url";
|
|
9437
|
-
function packageName(spec) {
|
|
9438
|
-
const start = spec.startsWith("@") ? 1 : 0;
|
|
9439
|
-
const at = spec.indexOf("@", start);
|
|
9440
|
-
return at === -1 ? spec : spec.slice(0, at);
|
|
9441
|
-
}
|
|
9442
|
-
var oamBinCache;
|
|
9443
|
-
function winNormalize(p, platform = process.platform) {
|
|
9444
|
-
return platform === "win32" ? p.replace(/\//g, "\\") : p;
|
|
9445
|
-
}
|
|
9446
|
-
function oamBin() {
|
|
9447
|
-
if (oamBinCache !== void 0) return oamBinCache;
|
|
9448
|
-
const bin = winNormalize(process.env.OAM_BIN || (process.platform === "win32" ? "oam.exe" : "oam"));
|
|
9449
|
-
try {
|
|
9450
|
-
execFileSync(bin, ["--version"], { stdio: "ignore" });
|
|
9451
|
-
oamBinCache = bin;
|
|
9452
|
-
} catch {
|
|
9453
|
-
oamBinCache = null;
|
|
9454
|
-
}
|
|
9455
|
-
return oamBinCache;
|
|
9456
|
-
}
|
|
9457
|
-
function rewriteForOam(command, args, deps) {
|
|
9458
|
-
const bin = deps.oamBin;
|
|
9459
|
-
if (!bin) return { command, args };
|
|
9460
|
-
const toOam = (entry, rest) => ({
|
|
9461
|
-
command: bin,
|
|
9462
|
-
args: rest.length > 0 ? ["run", entry, "--", ...rest] : ["run", entry]
|
|
9463
|
-
});
|
|
9464
|
-
if (command === "node") {
|
|
9465
|
-
const [entry, ...rest] = args;
|
|
9466
|
-
if (!entry) return { command, args };
|
|
9467
|
-
return toOam(entry, rest);
|
|
9468
|
-
}
|
|
9469
|
-
if (command === "npx") {
|
|
9470
|
-
const positional = args.filter((a) => a !== "-y" && a !== "--yes");
|
|
9471
|
-
const [spec, ...rest] = positional;
|
|
9472
|
-
if (!spec) return { command, args };
|
|
9473
|
-
const entry = deps.resolveEntry(packageName(spec));
|
|
9474
|
-
if (!entry) return { command, args };
|
|
9475
|
-
return toOam(entry, rest);
|
|
9476
|
-
}
|
|
9477
|
-
return { command, args };
|
|
9478
|
-
}
|
|
9479
|
-
function npxCacheNodeModules(fromUrl = import.meta.url) {
|
|
9480
|
-
let here;
|
|
9481
|
-
try {
|
|
9482
|
-
here = fileURLToPath(fromUrl);
|
|
9483
|
-
} catch {
|
|
9484
|
-
return [];
|
|
9485
|
-
}
|
|
9486
|
-
const marker = `${sep2}_npx${sep2}`;
|
|
9487
|
-
const idx = here.indexOf(marker);
|
|
9488
|
-
if (idx === -1) return [];
|
|
9489
|
-
const npxRoot = here.slice(0, idx + marker.length - sep2.length);
|
|
9490
|
-
try {
|
|
9491
|
-
return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join13(npxRoot, e.name, "node_modules"));
|
|
9492
|
-
} catch {
|
|
9493
|
-
return [];
|
|
9494
|
-
}
|
|
9495
|
-
}
|
|
9496
|
-
function ownNodeModules(fromUrl = import.meta.url) {
|
|
9497
|
-
let here;
|
|
9498
|
-
try {
|
|
9499
|
-
here = fileURLToPath(fromUrl);
|
|
9500
|
-
} catch {
|
|
9501
|
-
return [];
|
|
9502
|
-
}
|
|
9503
|
-
const seg = `${sep2}node_modules${sep2}`;
|
|
9504
|
-
const idx = here.lastIndexOf(seg);
|
|
9505
|
-
if (idx === -1) return [];
|
|
9506
|
-
return [here.slice(0, idx + seg.length - sep2.length)];
|
|
9507
|
-
}
|
|
9508
|
-
function packageEntry(pkgDir, pkg) {
|
|
9509
|
-
const pjPath = join13(pkgDir, "package.json");
|
|
9510
|
-
if (!existsSync8(pjPath)) return null;
|
|
9511
|
-
let j;
|
|
9512
|
-
try {
|
|
9513
|
-
j = JSON.parse(readFileSync5(pjPath, "utf8"));
|
|
9514
|
-
} catch {
|
|
9515
|
-
return null;
|
|
9516
|
-
}
|
|
9517
|
-
let rel;
|
|
9518
|
-
if (typeof j.bin === "string") {
|
|
9519
|
-
rel = j.bin;
|
|
9520
|
-
} else if (j.bin && typeof j.bin === "object") {
|
|
9521
|
-
const unscoped = pkg.slice(pkg.lastIndexOf("/") + 1);
|
|
9522
|
-
rel = j.bin[unscoped] ?? (j.name ? j.bin[j.name] : void 0) ?? Object.values(j.bin)[0];
|
|
9523
|
-
}
|
|
9524
|
-
if (!rel && typeof j.main === "string") rel = j.main;
|
|
9525
|
-
if (!rel) return null;
|
|
9526
|
-
return isAbsolute2(rel) ? rel : join13(pkgDir, rel);
|
|
9527
|
-
}
|
|
9528
|
-
function resolveNpmEntry(pkg, fromUrl = import.meta.url) {
|
|
9529
|
-
const parts = pkg.split("/");
|
|
9530
|
-
for (const nodeModules of [...ownNodeModules(fromUrl), ...npxCacheNodeModules(fromUrl)]) {
|
|
9531
|
-
const entry = packageEntry(join13(nodeModules, ...parts), pkg);
|
|
9532
|
-
if (entry) return entry;
|
|
9533
|
-
}
|
|
9534
|
-
return null;
|
|
9535
|
-
}
|
|
9536
|
-
function resolveOamSpawn(command, args) {
|
|
9537
|
-
return rewriteForOam(command, args, {
|
|
9538
|
-
oamBin: oamBin(),
|
|
9539
|
-
resolveEntry: (pkg) => resolveNpmEntry(pkg)
|
|
9540
|
-
});
|
|
9541
|
-
}
|
|
9542
|
-
|
|
9543
9722
|
// src/uv-bootstrap.ts
|
|
9544
9723
|
import { spawn as spawn5 } from "child_process";
|
|
9545
9724
|
import { createHash as createHash3 } from "crypto";
|
|
@@ -9877,9 +10056,26 @@ function categorizeSpawnError(err) {
|
|
|
9877
10056
|
if (/EACCES|permission denied/i.test(msg)) return "spawn_failure";
|
|
9878
10057
|
return "unknown";
|
|
9879
10058
|
}
|
|
10059
|
+
var oamDowngradedNamespaces = /* @__PURE__ */ new Set();
|
|
9880
10060
|
async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
10061
|
+
const attempt = { oamRewritten: false, oamVersion: null };
|
|
10062
|
+
try {
|
|
10063
|
+
return await connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, false);
|
|
10064
|
+
} catch (err) {
|
|
10065
|
+
if (!attempt.oamRewritten || !(err instanceof ActivationError)) throw err;
|
|
10066
|
+
oamDowngradedNamespaces.add(config.namespace);
|
|
10067
|
+
log("warn", "oam-hosted server failed to boot; downgrading to node for this session", {
|
|
10068
|
+
namespace: config.namespace,
|
|
10069
|
+
oamVersion: attempt.oamVersion,
|
|
10070
|
+
category: err.category,
|
|
10071
|
+
error: err.message
|
|
10072
|
+
});
|
|
10073
|
+
return await connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, true);
|
|
10074
|
+
}
|
|
10075
|
+
}
|
|
10076
|
+
async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, disableOamRewrite) {
|
|
9881
10077
|
const client = new Client(
|
|
9882
|
-
{ name: "yaw-mcp", version: true ? "0.
|
|
10078
|
+
{ name: "yaw-mcp", version: true ? "0.70.1" : "dev" },
|
|
9883
10079
|
{ capabilities: {} }
|
|
9884
10080
|
);
|
|
9885
10081
|
let transport;
|
|
@@ -9895,8 +10091,14 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
|
9895
10091
|
...parentEnv
|
|
9896
10092
|
} = process.env;
|
|
9897
10093
|
let resolved = await resolveUvSpawn(config.command, config.args ?? []);
|
|
9898
|
-
|
|
9899
|
-
|
|
10094
|
+
const effectiveRuntime = config.runtime ?? await defaultRuntime();
|
|
10095
|
+
if (effectiveRuntime === "oam" && !disableOamRewrite && !oamDowngradedNamespaces.has(config.namespace)) {
|
|
10096
|
+
const rewritten = resolveOamSpawn(resolved.command, resolved.args);
|
|
10097
|
+
if (rewritten.command !== resolved.command) {
|
|
10098
|
+
attempt.oamRewritten = true;
|
|
10099
|
+
attempt.oamVersion = probeOam().version;
|
|
10100
|
+
resolved = rewritten;
|
|
10101
|
+
}
|
|
9900
10102
|
}
|
|
9901
10103
|
const serverEnv = await resolveServerEnv(config.env ?? {}, config.namespace);
|
|
9902
10104
|
resolvedServerEnv = serverEnv;
|
|
@@ -9969,7 +10171,13 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
|
9969
10171
|
const redactedTail = trimmedStderr ? redactSecretsInOutput(trimmedStderr, resolvedServerEnv) : void 0;
|
|
9970
10172
|
throw new ActivationError(message, category, redactedTail, err);
|
|
9971
10173
|
}
|
|
9972
|
-
|
|
10174
|
+
const runtimeFields = attempt.oamRewritten ? disableOamRewrite ? { runtime: "node", downgradedFromOam: true } : { runtime: "oam", oamVersion: attempt.oamVersion } : {};
|
|
10175
|
+
log("info", "Connected to upstream", {
|
|
10176
|
+
name: config.name,
|
|
10177
|
+
namespace: config.namespace,
|
|
10178
|
+
type: config.type,
|
|
10179
|
+
...runtimeFields
|
|
10180
|
+
});
|
|
9973
10181
|
try {
|
|
9974
10182
|
const connection = { status: "disconnected" };
|
|
9975
10183
|
client.onclose = () => {
|
|
@@ -10214,7 +10422,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
10214
10422
|
this.apiUrl = apiUrl5;
|
|
10215
10423
|
this.token = token5;
|
|
10216
10424
|
this.server = new Server(
|
|
10217
|
-
{ name: "yaw-mcp", version: true ? "0.
|
|
10425
|
+
{ name: "yaw-mcp", version: true ? "0.70.1" : "dev" },
|
|
10218
10426
|
{
|
|
10219
10427
|
capabilities: {
|
|
10220
10428
|
tools: { listChanged: true },
|
|
@@ -12775,9 +12983,18 @@ async function runServersCommand(opts = {}) {
|
|
|
12775
12983
|
return cached ? { ...s, complianceGrade: cached.grade } : s;
|
|
12776
12984
|
})
|
|
12777
12985
|
};
|
|
12986
|
+
const probe2 = (opts.oamProbe ?? probeOam)();
|
|
12987
|
+
const dflt = await describeDefaultRuntime({ env: opts.env, cwd: opts.cwd, home: opts.home });
|
|
12988
|
+
const runtimes = new Map(
|
|
12989
|
+
merged.servers.map((s) => [s, describeServerRuntime(s, dflt.runtime, probe2)])
|
|
12990
|
+
);
|
|
12778
12991
|
if (opts.json) {
|
|
12779
12992
|
const payload = {
|
|
12780
12993
|
...merged,
|
|
12994
|
+
servers: merged.servers.map((s) => {
|
|
12995
|
+
const v = runtimes.get(s);
|
|
12996
|
+
return { ...s, effectiveRuntime: v?.runtime ?? null, effectiveRuntimeReason: v?.reason ?? "" };
|
|
12997
|
+
}),
|
|
12781
12998
|
filter: opts.filter ?? null,
|
|
12782
12999
|
filterMatched: opts.filter !== void 0 ? merged.servers.length > 0 : null
|
|
12783
13000
|
};
|
|
@@ -12788,10 +13005,23 @@ async function runServersCommand(opts = {}) {
|
|
|
12788
13005
|
print(`No servers match "${opts.filter}". Run \`yaw-mcp servers\` to see the full list.`);
|
|
12789
13006
|
return { exitCode: 0, lines };
|
|
12790
13007
|
}
|
|
12791
|
-
renderTable(merged, print);
|
|
13008
|
+
renderTable(merged, runtimes, print);
|
|
12792
13009
|
return { exitCode: 0, lines };
|
|
12793
13010
|
}
|
|
12794
|
-
function
|
|
13011
|
+
function runtimeCell(v) {
|
|
13012
|
+
if (!v || v.runtime === null) return "-";
|
|
13013
|
+
switch (v.code) {
|
|
13014
|
+
case "oam-not-installed":
|
|
13015
|
+
return "node (no oam)";
|
|
13016
|
+
case "oam-below-min":
|
|
13017
|
+
return "node (oam too old)";
|
|
13018
|
+
case "not-node-command":
|
|
13019
|
+
return "node (not node-based)";
|
|
13020
|
+
default:
|
|
13021
|
+
return v.runtime;
|
|
13022
|
+
}
|
|
13023
|
+
}
|
|
13024
|
+
function renderTable(cfg, runtimes, print) {
|
|
12795
13025
|
const servers = cfg.servers;
|
|
12796
13026
|
if (servers.length === 0) {
|
|
12797
13027
|
print("No servers configured yet. Visit https://yaw.sh/mcp to add one.");
|
|
@@ -12808,6 +13038,7 @@ function renderTable(cfg, print) {
|
|
|
12808
13038
|
name: s.name,
|
|
12809
13039
|
type: s.type,
|
|
12810
13040
|
status: s.isActive ? "enabled" : "disabled",
|
|
13041
|
+
runtime: runtimeCell(runtimes.get(s)),
|
|
12811
13042
|
grade: s.complianceGrade ?? "-",
|
|
12812
13043
|
tools: s.toolCache ? String(s.toolCache.length) : "?"
|
|
12813
13044
|
}));
|
|
@@ -12816,14 +13047,15 @@ function renderTable(cfg, print) {
|
|
|
12816
13047
|
name: Math.max("NAME".length, ...rows.map((r) => r.name.length)),
|
|
12817
13048
|
type: Math.max("TYPE".length, ...rows.map((r) => r.type.length)),
|
|
12818
13049
|
status: Math.max("STATUS".length, ...rows.map((r) => r.status.length)),
|
|
13050
|
+
runtime: Math.max("RUNTIME".length, ...rows.map((r) => r.runtime.length)),
|
|
12819
13051
|
grade: Math.max("GRADE".length, ...rows.map((r) => r.grade.length)),
|
|
12820
13052
|
tools: Math.max("TOOLS".length, ...rows.map((r) => r.tools.length))
|
|
12821
13053
|
};
|
|
12822
|
-
const header = ` ${"NAMESPACE".padEnd(widths.namespace)} ${"NAME".padEnd(widths.name)} ${"TYPE".padEnd(widths.type)} ${"STATUS".padEnd(widths.status)} ${"GRADE".padEnd(widths.grade)} ${"TOOLS".padStart(widths.tools)}`;
|
|
13054
|
+
const header = ` ${"NAMESPACE".padEnd(widths.namespace)} ${"NAME".padEnd(widths.name)} ${"TYPE".padEnd(widths.type)} ${"STATUS".padEnd(widths.status)} ${"RUNTIME".padEnd(widths.runtime)} ${"GRADE".padEnd(widths.grade)} ${"TOOLS".padStart(widths.tools)}`;
|
|
12823
13055
|
print(header);
|
|
12824
13056
|
const sorted = [...rows].sort((a, b) => a.namespace.localeCompare(b.namespace));
|
|
12825
13057
|
for (const r of sorted) {
|
|
12826
|
-
const line = ` ${r.namespace.padEnd(widths.namespace)} ${r.name.padEnd(widths.name)} ${r.type.padEnd(widths.type)} ${r.status.padEnd(widths.status)} ${r.grade.padEnd(widths.grade)} ${r.tools.padStart(widths.tools)}`;
|
|
13058
|
+
const line = ` ${r.namespace.padEnd(widths.namespace)} ${r.name.padEnd(widths.name)} ${r.type.padEnd(widths.type)} ${r.status.padEnd(widths.status)} ${r.runtime.padEnd(widths.runtime)} ${r.grade.padEnd(widths.grade)} ${r.tools.padStart(widths.tools)}`;
|
|
12827
13059
|
print(line);
|
|
12828
13060
|
}
|
|
12829
13061
|
}
|
|
@@ -13198,6 +13430,7 @@ var KNOWN_SUBCOMMANDS = [
|
|
|
13198
13430
|
"logout",
|
|
13199
13431
|
"sync",
|
|
13200
13432
|
"stats",
|
|
13433
|
+
"token",
|
|
13201
13434
|
"secrets",
|
|
13202
13435
|
"set-active",
|
|
13203
13436
|
"help",
|
|
@@ -13507,6 +13740,58 @@ function handleSyncError(err, opts, io) {
|
|
|
13507
13740
|
return { exitCode: 1 };
|
|
13508
13741
|
}
|
|
13509
13742
|
|
|
13743
|
+
// src/token-cmd.ts
|
|
13744
|
+
var TOKEN_USAGE = `Usage: yaw-mcp token [--json]
|
|
13745
|
+
|
|
13746
|
+
Print this machine's Yaw Team session token, for a trusted local app to
|
|
13747
|
+
present to a Yaw endpoint (e.g. Vew Meetings). Requires a prior
|
|
13748
|
+
\`yaw-mcp login\`.
|
|
13749
|
+
|
|
13750
|
+
--json Emit machine-readable JSON: { ok, token, email, exp }.
|
|
13751
|
+
|
|
13752
|
+
The token is a BEARER credential -- treat stdout as sensitive. Makes no
|
|
13753
|
+
network call; exits 1 if not signed in (or the session has expired).`;
|
|
13754
|
+
function parseTokenArgs(argv) {
|
|
13755
|
+
const opts = {};
|
|
13756
|
+
for (let i = 0; i < argv.length; i++) {
|
|
13757
|
+
const a = argv[i];
|
|
13758
|
+
if (a === "--json") {
|
|
13759
|
+
opts.json = true;
|
|
13760
|
+
} else if (a === "--help" || a === "-h") {
|
|
13761
|
+
return { ok: false, error: TOKEN_USAGE, help: true };
|
|
13762
|
+
} else {
|
|
13763
|
+
return { ok: false, error: `yaw-mcp token: unknown argument "${a}"
|
|
13764
|
+
|
|
13765
|
+
${TOKEN_USAGE}` };
|
|
13766
|
+
}
|
|
13767
|
+
}
|
|
13768
|
+
return { ok: true, options: opts };
|
|
13769
|
+
}
|
|
13770
|
+
async function runTokenCmd(opts, io = {
|
|
13771
|
+
out: (s) => process.stdout.write(s),
|
|
13772
|
+
err: (s) => process.stderr.write(s)
|
|
13773
|
+
}) {
|
|
13774
|
+
const found = await getSessionWithCookie({ home: opts.home, filePath: opts.filePath });
|
|
13775
|
+
if (!found) {
|
|
13776
|
+
if (opts.json) {
|
|
13777
|
+
io.err(`${JSON.stringify({ ok: false, error: "Not signed in." })}
|
|
13778
|
+
`);
|
|
13779
|
+
} else {
|
|
13780
|
+
io.err("yaw-mcp token: not signed in -- run `yaw-mcp login --key <license-key>` first.\n");
|
|
13781
|
+
}
|
|
13782
|
+
return { exitCode: 1 };
|
|
13783
|
+
}
|
|
13784
|
+
const { cookie, session } = found;
|
|
13785
|
+
if (opts.json) {
|
|
13786
|
+
io.out(`${JSON.stringify({ ok: true, token: cookie, email: session.email, exp: session.exp }, null, 2)}
|
|
13787
|
+
`);
|
|
13788
|
+
} else {
|
|
13789
|
+
io.out(`${cookie}
|
|
13790
|
+
`);
|
|
13791
|
+
}
|
|
13792
|
+
return { exitCode: 0 };
|
|
13793
|
+
}
|
|
13794
|
+
|
|
13510
13795
|
// src/index.ts
|
|
13511
13796
|
function dispatch(cmd, p) {
|
|
13512
13797
|
p.then((r) => {
|
|
@@ -13734,6 +14019,19 @@ if (subcommand === "compliance") {
|
|
|
13734
14019
|
process.exit(2);
|
|
13735
14020
|
}
|
|
13736
14021
|
dispatch("logout", runLogout(parsed.options));
|
|
14022
|
+
} else if (subcommand === "token") {
|
|
14023
|
+
const parsed = parseTokenArgs(process.argv.slice(3));
|
|
14024
|
+
if (!parsed.ok) {
|
|
14025
|
+
if (parsed.help) {
|
|
14026
|
+
process.stdout.write(`${parsed.error}
|
|
14027
|
+
`);
|
|
14028
|
+
process.exit(0);
|
|
14029
|
+
}
|
|
14030
|
+
process.stderr.write(`${parsed.error}
|
|
14031
|
+
`);
|
|
14032
|
+
process.exit(2);
|
|
14033
|
+
}
|
|
14034
|
+
dispatch("token", runTokenCmd(parsed.options));
|
|
13737
14035
|
} else if (subcommand === "sync") {
|
|
13738
14036
|
const parsed = parseSyncArgs(process.argv.slice(3));
|
|
13739
14037
|
if (!parsed.ok) {
|
|
@@ -13846,6 +14144,8 @@ if (subcommand === "compliance") {
|
|
|
13846
14144
|
remove, lock, push, pull.
|
|
13847
14145
|
stats Show your account usage statistics
|
|
13848
14146
|
(--limit, --days, --json).
|
|
14147
|
+
token Print this machine's session token for a trusted
|
|
14148
|
+
local app (e.g. Vew Meetings). --json for fields.
|
|
13849
14149
|
|
|
13850
14150
|
Other:
|
|
13851
14151
|
compliance <target> Run the 88-test compliance suite against an MCP
|
|
@@ -13880,6 +14180,12 @@ if (subcommand === "compliance") {
|
|
|
13880
14180
|
stale global-npm installs are upgraded in the
|
|
13881
14181
|
background).
|
|
13882
14182
|
YAW_MCP_PRUNE_RESPONSES Set to \`0\` to disable response pruning.
|
|
14183
|
+
YAW_MCP_DEFAULT_RUNTIME Default runtime for local node/npx servers
|
|
14184
|
+
(\`oam\` or \`node\`). Servers without a per-
|
|
14185
|
+
server \`runtime\` use this; per-server
|
|
14186
|
+
\`"runtime": "node"\` opts out. Same knob as
|
|
14187
|
+
bundles.json top-level \`defaultRuntime\`
|
|
14188
|
+
(env wins). Unset = node (today's default).
|
|
13883
14189
|
YAW_MCP_DISABLE_PERSISTENCE Disable cross-session learning state.
|
|
13884
14190
|
YAW_MCP_CATALOG_URL Override the catalog \`add\`/\`try\` resolve slugs
|
|
13885
14191
|
against (default https://yaw.sh/data/mcp-catalog.json).
|
|
@@ -13902,7 +14208,7 @@ if (subcommand === "compliance") {
|
|
|
13902
14208
|
`);
|
|
13903
14209
|
process.exit(0);
|
|
13904
14210
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
13905
|
-
process.stdout.write(`yaw-mcp ${true ? "0.
|
|
14211
|
+
process.stdout.write(`yaw-mcp ${true ? "0.70.1" : "dev"}
|
|
13906
14212
|
`);
|
|
13907
14213
|
process.exit(0);
|
|
13908
14214
|
} else if (subcommand && !subcommand.startsWith("-")) {
|