@yawlabs/mcp 1.1.16 → 1.1.18

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/CHANGELOG.md CHANGED
@@ -4,6 +4,49 @@ All notable changes to `@yawlabs/mcp` (formerly `@yawlabs/mcph`) are documented
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 1.1.18
8
+
9
+ **Changed -- the oam floor moves to 0.22.0, and the hostable node flags gain --title and --env-file**
10
+
11
+ `npm run verify:oam-floor` hosted a stdio `@modelcontextprotocol/server` server on oam v0.22.0 through `oam run` on 2026-11-28 -- both protocol eras, 2025-11-25 (initialize) and 2026-07-28 (server/discover), each through tools/list and tools/call -- and raised `MIN_OAM_VERSION` to it; the floor was 0.21.1. A machine whose oam is older hosts its node/npx sidecars on node instead, and logs a warning naming both versions, `oam self-update` as the fix, and that yaw-mcp needs a restart afterwards.
12
+
13
+ 0.22.0 also fixed the stale exclusion that kept three node flags off the oam allowlist: `--title=NAME`, `--env-file=PATH` and `--env-file-if-exists=PATH` take effect on oam and stay in `process.execArgv`, exactly as on node -- measured beside node 26.13.1 on oam 0.22.0, and again on oam 0.21.1, where the `=` forms already behaved this way (the exclusion dates from the 0.19.5-era measurement and had gone stale). The rewrite now carries all three onto `oam run` instead of leaving the launch on node, and the real-oam contract test exercises them. What 0.22.0 itself adds, the mirror in `OAM_SPACED_VALUE_OPTIONS` learns: `--title` accepts a spaced value there (`oam run --title T entry`), which 0.21.1 refused with a clap error. `--process-timeout=<n><ms|s|m|h>`, new in both node 26 and oam 0.22.0, stays off the allowlist: oam enforces it but leaves it out of execArgv where node reflects it, so a server forking a worker with its own execArgv would lose the deadline.
14
+
15
+ **Added -- the "Left off, and why" exclusion reasons are machine-checked on every run**
16
+
17
+ The three individually-reasoned oam exclusions (`--enable-source-maps`, `--pending-deprecation`, `--process-timeout`) now live in `OAM_NODE_FLAG_EXCLUSIONS` in `oam-spawn.ts` with the kind of claim each reason makes -- `refused-by-oam`, `execArgv-dropped`, `effect-diverges` -- and the real-oam contract test re-measures each one against the installed oam and the local node on every run: that oam refuses `--enable-source-maps` without running the entry, that node's `--pending-deprecation` emits DEP0111 for `process.binding()` where oam's does not, and that oam accepts and enforces `--process-timeout` but leaves it out of `process.execArgv` where node 26 reflects it. A floor raise that changes oam's behavior under one of these reasons now fails the suite naming the flag, instead of leaving the exclusion silently stale -- which is how the `--title` one survived three floor raises (it dated from the 0.19.5-era measurement and nothing re-read it). Two static tests pin the map's exact contents and that it never overlaps the allowlist. `--inspect*` and the "not verified" catch-all stay prose: policy cannot go stale, and the catch-all already fails safe.
18
+
19
+ ## 1.1.17
20
+
21
+ **Fixed -- the consent screen is no longer hidden behind a "package manager not installed" refusal**
22
+
23
+ `yaw-mcp add --git` resolved how to invoke the package manager (yarn/pnpm on PATH or through corepack) BEFORE showing the consent screen, so on a machine with neither yarn nor corepack a repo whose install would run a root `.yarnrc.yml` `yarnPath` (or any other package-manager config) was refused with `this repo builds with yarn, which is not installed` and the listing of what that config would run never appeared. The consent gate -- lifecycle scripts plus the repo's package-manager config files -- now runs first, so the refusal names the `yarnPath`/`.pnpmfile`/`.npmrc` code an install would load; the environment refusal follows only once the repo's scripts are allowed to run. Nothing about what is blocked changed: a refused add still builds nothing.
24
+
25
+ **Fixed -- a deny written against a flag value cannot be escaped by respelling the flag**
26
+
27
+ An unknown runner flag spelled with `=` (`bunx --unknown=hidden other`) used to drop its value from the launch identity entirely, while the space spelling (`bunx --unknown hidden other`) kept it as a weak reading a `package:` deny matches -- so rewriting the same flag with `=` hid the package. The `--long=value` form now keeps the weak reading too (runner launchers only; an attached short flag such as `docker run -eTOKEN=abc` is not read as a package, and an empty value is never one). An interpreter's value-taking flag (`node --watch-path src /x/a.js`) used to bind the flag's VALUE as the launch identity (`command:src`): two different scripts sharing one flag value were treated as the same server, and a `command:` deny on the script itself missed the launch. node's and python's value flags are now listed, so the script is the identity; an interpreter flag the table does not know is read as boolean, the first positional is the script, and the positional after it survives only as a weak reading -- so `node --inspect /opt/a.js stdio` still binds `/opt/a.js`, and a deny naming the script still matches when a value flag is missing from the table.
28
+
29
+ **Fixed -- health's policy and profile lines stop contradicting the other surfaces**
30
+
31
+ A broken policy file's message printed twice in `mcp_connect_health` -- once as `POLICY ERROR:` and again as `POLICY WARNING:`, because the config loader folds every error into the warnings list for the refusal surfaces. The refusals' `Note:` dropped the duplicate too, for the same reason. The `also blocked via identity:` line fired for any namespace the enforced profile excludes whose name is not in the raw `blocked` list, so a plain allow-list (`servers: ["ssh"]` excluding `ssh2`, no `blocked` entry anywhere) was mislabeled as an identity block; the line now names only namespaces a `blocked` entry actually reaches through a launch identity, the same helper the refusal uses.
32
+
33
+ **Changed -- the recovery confirm's empty-answer bound counts consecutive blanks**
34
+
35
+ The bound that ends a recovery-code confirmation on a closed stdin (`No group was entered -- the prompt was left empty 5 times in a row.`) counted cumulative blanks: wrong, wrong, then three bare Enters fired a "in a row" claim about answers that were not consecutive. A typed answer resets the count now, so the message means what it says; the closed-stdin case ("" forever) still terminates on the same bound.
36
+
37
+ **Changed -- the npx-under-node rewrite logs its decisions and caches its lookup**
38
+
39
+ When the `node npx-cli.js` rewrite on Windows finds no node.exe on PATH or no npx-cli.js beside it, it now logs that at debug -- naming the node binary -- instead of failing silently into the cryptic cmd.exe message, and a rewrite that applies logs the node binary and cli it chose. The no-op cases (off Windows, not an npx launch, a node-hosted broker) stay quiet, since they are every other launch. The rewrite now resolves `node.exe` itself, so a `node.cmd`/`node.bat` shim earlier on PATH can no longer reintroduce the cmd.exe detour. The node/npx-cli.js resolution is memoized for the process: the rewrite runs at the end of the launch resolver on every connect of an npx sidecar under a non-node broker (the oam->node downgrade respawn and first-attempt npx launches alike), and each one used to pay a full PATH walk plus up to three existence probes. A cached hit is re-checked on disk and resolved fresh if npx-cli.js has gone; misses are never cached, so a node installed mid-session is picked up.
40
+
41
+ **Fixed -- secrets and refusal surfaces**
42
+
43
+ - An initialize rejection with empty stderr no longer carries a credential the server echoed back into the activation error: the raw SDK message is redacted like every other pre-handshake failure. A vault secret that shares its name with an env or header key holding a different value is now redacted too, instead of one overwriting the other in the redaction map.
44
+ - A refusal for a disabled server under a broken policy file names the policy file again (the duplicate-message fix had dropped it from every refusal kind, not just the policy-invalid one).
45
+ - A config reload applies `grades.json` before installing the new server list, so a concurrent call can no longer slip a server below `YAW_MCP_MIN_COMPLIANCE` through during the grades read. Pre-warm no longer announces, warns about, or waits on a server the compliance floor refuses.
46
+ - `mcp_connect_find_tool` marks its no-servers and empty-query replies as errors; the no-argument secrets report says no servers are usable (as an error) instead of a misleading remedy.
47
+ - The bundles "enable with:" remedy lists one `yaw-mcp enable <ns>` per disabled member instead of joining them with `&&`, which Windows PowerShell 5.1 rejects.
48
+ - `secrets recover` on the last wrong recovery-code group prints the mismatch after leaving the alternate screen, so it is no longer wiped the moment it is shown. `recover --file` recognises the vault's own path regardless of case on Windows. Its `--json` `passphrase_source` now reports where the NEW passphrase came from, with `stale_env_set` saying whether the old `YAW_MCP_VAULT_PASSPHRASE` is still set.
49
+
7
50
  ## 1.1.16
8
51
 
9
52
  **Fixed -- the oam->npx downgrade respawn runs npx under node.exe on Windows**
@@ -14,7 +14,7 @@ import {
14
14
  recordAttemptAt,
15
15
  runsUnderNpmConfigPrefix,
16
16
  writeCheckMemo
17
- } from "./chunk-A45PPRNA.js";
17
+ } from "./chunk-4Y3B23Z3.js";
18
18
  export {
19
19
  PREFIX_REFUSED_REASON,
20
20
  UPGRADE_LOCK_NAME,
@@ -5370,7 +5370,7 @@ function npxSpec(args) {
5370
5370
  const spec = args[idx];
5371
5371
  return spec.startsWith("-") ? null : spec;
5372
5372
  }
5373
- var MIN_OAM_VERSION = "0.21.1";
5373
+ var MIN_OAM_VERSION = "0.22.0";
5374
5374
  var OAM_INSTALL_SH = "curl -fsSL https://oamjs.org/install.sh | sh";
5375
5375
  var OAM_INSTALL_PS1 = "irm https://oamjs.org/install.ps1 | iex";
5376
5376
  function oamInstallCommand(os) {
@@ -5697,7 +5697,7 @@ async function probeOamUncached(run, generation) {
5697
5697
  // ...but updating alone changes nothing here. A non-timeout verdict
5698
5698
  // like this one is cached for the process lifetime and only cleared by
5699
5699
  // a test hook (only a timeout verdict lapses, after
5700
- // OAM_PROBE_TIMEOUT_RECHECK_MS), so every opted-in server keeps landing
5700
+ // OAM_PROBE_TIMEOUT_RECHECK_MS), so every oam-hosted (node/npx) server keeps landing
5701
5701
  // on node until the broker restarts -- and an MCP broker under a
5702
5702
  // desktop client lives for days. Without this the user runs the update,
5703
5703
  // sees no further log line, and reads a working fix as a fix that did
@@ -5795,7 +5795,20 @@ var OAM_HOSTABLE_NODE_VALUE_FLAGS = /* @__PURE__ */ new Map([
5795
5795
  ["--max-old-space-size", HEAP_MB],
5796
5796
  ["--max-http-header-size", POSITIVE_INT],
5797
5797
  ["--dns-result-order", /^(?:verbatim|ipv4first|ipv6first)$/],
5798
- ["--disable-warning", /^[A-Za-z0-9_]+$/]
5798
+ ["--disable-warning", /^[A-Za-z0-9_]+$/],
5799
+ // Excluded since the 0.19.5-era measurement, which found oam dropping
5800
+ // these from execArgv; re-measured 2026-11-28 against oam 0.22.0 beside
5801
+ // node 26.13.1, all three take effect and stay in execArgv in the = form
5802
+ // (--title=abc -> ["--title=abc"] on both; --env-file's missing file exits
5803
+ // 9 on both, -if-exists' exits 0 with a stderr notice on both). The =
5804
+ // forms already behaved this way on 0.21.1 (measured the same day) -- what
5805
+ // 0.22.0 itself adds is --title's spaced-value form, which 0.21.1 refused
5806
+ // with a clap error. The path is arbitrary (node validates it at parse
5807
+ // time), so the check is only "non-empty"; the = spelling alone is not
5808
+ // the flag.
5809
+ ["--title", /^.+$/],
5810
+ ["--env-file", /^.+$/],
5811
+ ["--env-file-if-exists", /^.+$/]
5799
5812
  ]);
5800
5813
  function scanNodeLaunchFlags(args) {
5801
5814
  const flags = [];
@@ -5841,7 +5854,8 @@ var OAM_SPACED_VALUE_OPTIONS = /* @__PURE__ */ new Set([
5841
5854
  "--disable-warning",
5842
5855
  "--redirect-warnings",
5843
5856
  "--allow-fs-read",
5844
- "--allow-fs-write"
5857
+ "--allow-fs-write",
5858
+ "--title"
5845
5859
  ]);
5846
5860
  function rewriteForOam(command, args, deps) {
5847
5861
  const bin = deps.oamBin;
@@ -5929,10 +5943,6 @@ function managedNodeBin(env = process.env, platform = process.platform, execPath
5929
5943
  }
5930
5944
  function rewriteNpmToManagedNode(command, args, deps) {
5931
5945
  if (nodeLaunchKind(command) !== "npx") return { command, args };
5932
- if (!deps.nodeBin) {
5933
- log("debug", "no node binary located for the managed sidecar spawn; staying on npx", { command });
5934
- return { command, args };
5935
- }
5936
5946
  const launch = classifyNpxLaunch(args);
5937
5947
  if (launch.kind === "no-spec") return { command, args };
5938
5948
  if (launch.kind === "flag-spec") {
@@ -5955,6 +5965,11 @@ function rewriteNpmToManagedNode(command, args, deps) {
5955
5965
  });
5956
5966
  return { command, args };
5957
5967
  }
5968
+ const nodeBin = typeof deps.nodeBin === "function" ? deps.nodeBin() : deps.nodeBin;
5969
+ if (!nodeBin) {
5970
+ log("debug", "no node binary located for the managed sidecar spawn; staying on npx", { command });
5971
+ return { command, args };
5972
+ }
5958
5973
  const { pkg, wantVersion } = launch;
5959
5974
  const entry = deps.resolveEntry(pkg, wantVersion);
5960
5975
  if (!entry) {
@@ -5970,7 +5985,7 @@ function rewriteNpmToManagedNode(command, args, deps) {
5970
5985
  }
5971
5986
  return { command, args };
5972
5987
  }
5973
- return { command: deps.nodeBin, args: [entry, ...launch.rest] };
5988
+ return { command: nodeBin, args: [entry, ...launch.rest] };
5974
5989
  }
5975
5990
  var NPX_CACHE_MARKER = `${sep}_npx${sep}`;
5976
5991
  function npxHashNodeModules(npxRoot) {
@@ -6266,7 +6281,7 @@ var managedEntryMemo = /* @__PURE__ */ new Map();
6266
6281
  function resolveManagedSpawn(command, args, fromUrl = import.meta.url, npmCache = npmCacheDir(fromUrl), managedRoot = sidecarsNodeModules(), nodeBin) {
6267
6282
  if (nodeLaunchKind(command) !== "npx") return { command, args };
6268
6283
  return rewriteNpmToManagedNode(command, args, {
6269
- nodeBin: nodeBin === void 0 ? managedNodeBin() : nodeBin,
6284
+ nodeBin: nodeBin === void 0 ? () => managedNodeBin() : nodeBin,
6270
6285
  resolveEntry: (pkg, wantVersion) => {
6271
6286
  if (wantVersion !== null) return resolveNpmEntry(pkg, fromUrl, npmCache, managedRoot, wantVersion);
6272
6287
  const memoed = managedEntryMemo.get(pkg);
@@ -6282,19 +6297,46 @@ function resolveManagedSpawn(command, args, fromUrl = import.meta.url, npmCache
6282
6297
  }
6283
6298
  });
6284
6299
  }
6300
+ var npxUnderNodeMemo = /* @__PURE__ */ new Map();
6301
+ function npxMemoKey(env) {
6302
+ const path5 = env.PATH ?? env.Path ?? env.path ?? "";
6303
+ const pathext = env.PATHEXT ?? env.PathExt ?? env.pathext ?? "";
6304
+ return JSON.stringify([path5, pathext]);
6305
+ }
6285
6306
  function npxUnderNode(command, args, opts = {}) {
6286
6307
  const platform = opts.platform ?? process.platform;
6287
6308
  if (platform !== "win32") return { command, args };
6288
- if (nodeLaunchKind(command) !== "npx") return { command, args };
6309
+ if (nodeLaunchKind(command) !== "npx" || /[\\/]/.test(command)) return { command, args };
6289
6310
  const execPath = opts.execPath ?? process.execPath;
6290
6311
  if (nodeLaunchKind(execPath) === "node") return { command, args };
6291
6312
  const env = opts.env ?? process.env;
6292
6313
  const fileExists = opts.exists ?? existsSync3;
6293
- const nodeBin = resolveBinAbsolute("node", env, platform);
6294
- if (nodeBin === null) return { command, args };
6295
- const cli = npxCliCandidates(nodeBin, platform).find((c) => fileExists(c));
6296
- if (cli === void 0) return { command, args };
6297
- return { command: nodeBin, args: [cli, ...args] };
6314
+ const defaulted = opts.platform === void 0 && opts.execPath === void 0 && opts.exists === void 0;
6315
+ const memoKey = npxMemoKey(env);
6316
+ const memoed = npxUnderNodeMemo.get(memoKey);
6317
+ if (memoed !== void 0 && !fileExists(memoed.cli)) {
6318
+ npxUnderNodeMemo.delete(memoKey);
6319
+ }
6320
+ const found = npxUnderNodeMemo.get(memoKey) ?? (() => {
6321
+ const nodeBin = resolveBinAbsolute("node.exe", env, platform);
6322
+ if (nodeBin === null) {
6323
+ log("debug", "no node.exe resolved on PATH; staying on npx", { command });
6324
+ return null;
6325
+ }
6326
+ const cli = npxCliCandidates(nodeBin, platform).find((c) => fileExists(c));
6327
+ if (cli === void 0) {
6328
+ log("debug", "no npx-cli.js beside the resolved node binary; staying on npx", { command, nodeBin });
6329
+ return null;
6330
+ }
6331
+ if (defaulted) npxUnderNodeMemo.set(memoKey, { nodeBin, cli });
6332
+ return { nodeBin, cli };
6333
+ })();
6334
+ if (found === null) return { command, args };
6335
+ log("debug", "npx launch rewritten to node + npx-cli.js (skips the cmd.exe verbatim-args detour)", {
6336
+ nodeBin: found.nodeBin,
6337
+ cli: found.cli
6338
+ });
6339
+ return { command: found.nodeBin, args: [found.cli, ...args] };
6298
6340
  }
6299
6341
  function isOamCommand(command) {
6300
6342
  const base = command.split(/[\\/]/).pop() ?? command;
@@ -6636,21 +6678,21 @@ async function oamFloorLines(probe) {
6636
6678
  }
6637
6679
  async function defaultRunningPrefix(argvPath) {
6638
6680
  if (isTestSandbox()) return null;
6639
- const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-IKD7SJNW.js");
6681
+ const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-C6AD444Q.js");
6640
6682
  return detectRunningInstallPrefix2(argvPath);
6641
6683
  }
6642
6684
  async function defaultConfirmGlobalPrefix(argvPath, prefix) {
6643
- const { defaultConfirmGlobalPrefix: confirm } = await import("./auto-upgrade-IKD7SJNW.js");
6685
+ const { defaultConfirmGlobalPrefix: confirm } = await import("./auto-upgrade-C6AD444Q.js");
6644
6686
  return confirm(argvPath, prefix);
6645
6687
  }
6646
6688
  async function defaultAcquireLock(prefixDir) {
6647
6689
  if (isTestSandbox()) return () => {
6648
6690
  };
6649
- const { acquireUpgradeLock: acquireUpgradeLock2 } = await import("./auto-upgrade-IKD7SJNW.js");
6691
+ const { acquireUpgradeLock: acquireUpgradeLock2 } = await import("./auto-upgrade-C6AD444Q.js");
6650
6692
  return acquireUpgradeLock2(prefixDir);
6651
6693
  }
6652
6694
  async function upgradeLockPath(prefixDir) {
6653
- const { UPGRADE_LOCK_NAME: UPGRADE_LOCK_NAME2 } = await import("./auto-upgrade-IKD7SJNW.js");
6695
+ const { UPGRADE_LOCK_NAME: UPGRADE_LOCK_NAME2 } = await import("./auto-upgrade-C6AD444Q.js");
6654
6696
  return join12(prefixDir, UPGRADE_LOCK_NAME2);
6655
6697
  }
6656
6698
  async function defaultSpawn(cmd, args, cwd) {
@@ -6714,12 +6756,12 @@ async function runUpgrade(opts = {}) {
6714
6756
  if (method === "global-npm") {
6715
6757
  rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
6716
6758
  if (rawPrefix !== null && !await (opts.confirmGlobalPrefix ?? defaultConfirmGlobalPrefix)(argvPath, rawPrefix)) {
6717
- const { PREFIX_REFUSED_REASON: PREFIX_REFUSED_REASON2, prefixRefusedRemedies: prefixRefusedRemedies2 } = await import("./auto-upgrade-IKD7SJNW.js");
6759
+ const { PREFIX_REFUSED_REASON: PREFIX_REFUSED_REASON2, prefixRefusedRemedies: prefixRefusedRemedies2 } = await import("./auto-upgrade-C6AD444Q.js");
6718
6760
  prefixRefusedNote = `Note: not pinning --prefix ${rawPrefix}: ${PREFIX_REFUSED_REASON2}. The command below installs into npm's own global prefix and does NOT update the copy at ${rawPrefix}. ` + prefixRefusedRemedies2(rawPrefix, opts.platform);
6719
6761
  rawPrefix = null;
6720
6762
  }
6721
6763
  if (rawPrefix !== null) {
6722
- const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-IKD7SJNW.js");
6764
+ const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-C6AD444Q.js");
6723
6765
  const spawnForm = quoteShellArgIfNeeded2(rawPrefix, opts.platform);
6724
6766
  const displayForm = quoteArgForDisplay2(rawPrefix, opts.platform);
6725
6767
  if (spawnForm !== null && displayForm !== null) {
@@ -6858,7 +6900,7 @@ async function runUpgrade(opts = {}) {
6858
6900
  return { exitCode: 3, lines };
6859
6901
  }
6860
6902
  function readCurrentVersion() {
6861
- return true ? "1.1.16" : "dev";
6903
+ return true ? "1.1.18" : "dev";
6862
6904
  }
6863
6905
 
6864
6906
  // src/auto-upgrade.ts
@@ -7175,7 +7217,7 @@ function defaultSpawn2(cmd, args, onDone = () => {
7175
7217
  }
7176
7218
  async function maybeAutoUpgrade(deps = {}) {
7177
7219
  if (isFeatureDisabled("YAW_MCP_AUTO_UPGRADE")) return;
7178
- const current = deps.currentVersion ?? (true ? "1.1.16" : "dev");
7220
+ const current = deps.currentVersion ?? (true ? "1.1.18" : "dev");
7179
7221
  if (current === "dev") return;
7180
7222
  const argvPath = deps.argvPath ?? process.argv[1];
7181
7223
  let method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync3, ["unknown", "local-node-modules"]);
@@ -45,7 +45,7 @@ import {
45
45
  stripJsoncComments,
46
46
  stripTrailingCommas,
47
47
  userConfigDir
48
- } from "./chunk-A45PPRNA.js";
48
+ } from "./chunk-4Y3B23Z3.js";
49
49
 
50
50
  // src/git-source.ts
51
51
  import { spawn as spawn3 } from "child_process";
@@ -837,7 +837,7 @@ async function loadVault(path2, opts) {
837
837
  const code = err.code;
838
838
  if (code === "ENOENT") return null;
839
839
  if (!onWarning) {
840
- log("warn", "Failed to read vault", { path: path2, error: err instanceof Error ? err.message : String(err), code });
840
+ log("warn", "Failed to read vault", { path: path2, error: errorMessage(err), code });
841
841
  }
842
842
  throw err;
843
843
  }
@@ -846,9 +846,9 @@ async function loadVault(path2, opts) {
846
846
  parsed = JSON.parse(raw);
847
847
  } catch (err) {
848
848
  if (!onWarning) {
849
- log("warn", "Vault file is not valid JSON", { path: path2, error: err instanceof Error ? err.message : String(err) });
849
+ log("warn", "Vault file is not valid JSON", { path: path2, error: errorMessage(err) });
850
850
  }
851
- throw new Error(`vault at ${path2} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
851
+ throw new Error(`vault at ${path2} is not valid JSON: ${errorMessage(err)}`);
852
852
  }
853
853
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
854
854
  throw new Error(`vault at ${path2} is corrupt: root must be a JSON object`);
@@ -1162,7 +1162,7 @@ async function unlockV3(vault, passphrase) {
1162
1162
  }
1163
1163
  function verifyV3Contents(vault, dek) {
1164
1164
  const entries = Object.entries(vault.entries);
1165
- const someEntryDecrypts = () => entries.some(([name, e]) => canDecrypt(vault, e, dek, vaultEntryAad(vault, name)));
1165
+ const someEntryDecrypts = () => anyEntryDecrypts(vault, dek);
1166
1166
  if (vault.check) {
1167
1167
  if (checkMarkerMatches(vault, dek)) return "ok";
1168
1168
  if (entries.length === 0) return "marker-corrupt";
@@ -1218,16 +1218,17 @@ function canDecrypt(vault, entry, key, aad) {
1218
1218
  return false;
1219
1219
  }
1220
1220
  }
1221
+ function anyEntryDecrypts(vault, key) {
1222
+ return Object.entries(vault.entries).some(([name, e]) => canDecrypt(vault, e, key, vaultEntryAad(vault, name)));
1223
+ }
1221
1224
  function verifyKey(vault, key) {
1222
- const entries = Object.entries(vault.entries);
1223
- const someEntryDecrypts = () => entries.some(([name, e]) => canDecrypt(vault, e, key, vaultEntryAad(vault, name)));
1224
1225
  if (vault.check) {
1225
1226
  if (checkMarkerMatches(vault, key)) return;
1226
- if (someEntryDecrypts()) throw new Error(VAULT_CHECK_CORRUPT_ERROR);
1227
+ if (anyEntryDecrypts(vault, key)) throw new Error(VAULT_CHECK_CORRUPT_ERROR);
1227
1228
  throw new Error(VAULT_WRONG_PASSPHRASE_ERROR);
1228
1229
  }
1229
- if (entries.length === 0) return;
1230
- if (someEntryDecrypts()) return;
1230
+ if (Object.keys(vault.entries).length === 0) return;
1231
+ if (anyEntryDecrypts(vault, key)) return;
1231
1232
  throw new Error(VAULT_WRONG_PASSPHRASE_ERROR);
1232
1233
  }
1233
1234
  function checkMarkerMatches(vault, key) {
@@ -1255,7 +1256,7 @@ async function checkVaultPassphrase(vault, passphrase) {
1255
1256
  (await unlock(vault, passphrase)).fill(0);
1256
1257
  return "opens";
1257
1258
  } catch (err) {
1258
- const msg = err instanceof Error ? err.message : String(err);
1259
+ const msg = errorMessage(err);
1259
1260
  if (msg === VAULT_CHECK_CORRUPT_ERROR) return "marker-corrupt";
1260
1261
  if (msg === VAULT_SLOT_DAMAGED_ERROR) return "slot-damaged";
1261
1262
  if (msg === VAULT_WRONG_PASSPHRASE_ERROR) return "wrong";
@@ -4417,7 +4418,16 @@ function localRedactionMap(configEnv, serverEnv, secretValues) {
4417
4418
  out[k] = v;
4418
4419
  }
4419
4420
  }
4420
- return { ...out, ...secretValues };
4421
+ return mergeSecretValues(out, secretValues);
4422
+ }
4423
+ function mergeSecretValues(base, secretValues) {
4424
+ const out = { ...base };
4425
+ for (const [name, value] of Object.entries(secretValues)) {
4426
+ if (typeof value !== "string") continue;
4427
+ if (!Object.hasOwn(out, name)) out[name] = value;
4428
+ else if (out[name] !== value) out[`secret:${name}`] = value;
4429
+ }
4430
+ return out;
4421
4431
  }
4422
4432
  function hasUrlPassword(value) {
4423
4433
  const { scheme, userinfo } = splitUserinfo(value.trim());
@@ -4543,12 +4553,12 @@ async function gitBuildMissing(config, home, consented) {
4543
4553
  }
4544
4554
  async function gitRepoConsented(config) {
4545
4555
  if (!config.git?.commit || gitEntryBuilt(config.namespace, config.git)) return void 0;
4546
- const { hasRepoConsent: hasRepoConsent2 } = await import("./git-source-H3L3VEQ7.js");
4556
+ const { hasRepoConsent: hasRepoConsent2 } = await import("./git-source-7SUMXT6H.js");
4547
4557
  return hasRepoConsent2(config.git.url, homedir6());
4548
4558
  }
4549
4559
  async function recordActivatedGitPin(namespace, commit) {
4550
4560
  try {
4551
- const { recordLoadedGitPin: recordLoadedGitPin2 } = await import("./git-source-H3L3VEQ7.js");
4561
+ const { recordLoadedGitPin: recordLoadedGitPin2 } = await import("./git-source-7SUMXT6H.js");
4552
4562
  await recordLoadedGitPin2(namespace, commit, { home: homedir6(), cwd: process.cwd() });
4553
4563
  } catch (e) {
4554
4564
  log("debug", "Could not record the git build an activation uses", { namespace, error: e.message });
@@ -4648,7 +4658,7 @@ async function connectToUpstream(config, onDisconnect, onListChanged, bridge, pr
4648
4658
  } catch (err) {
4649
4659
  if (!(err instanceof ActivationError)) throw err;
4650
4660
  if (attempt.oamRewriteApplied) {
4651
- log("warn", "oam-hosted server failed to boot; downgrading to node for this session", {
4661
+ log("warn", "oam-hosted server failed to boot; retrying once on node", {
4652
4662
  namespace: config.namespace,
4653
4663
  oamVersion: attempt.oamVersion,
4654
4664
  category: err.category,
@@ -4685,7 +4695,7 @@ async function connectToUpstream(config, onDisconnect, onListChanged, bridge, pr
4685
4695
  }
4686
4696
  }
4687
4697
  if (attempt.managedRewriteApplied) {
4688
- log("warn", "managed-sidecar server failed to boot; downgrading to npx for this session", {
4698
+ log("warn", "managed-sidecar server failed to boot; retrying once on npx", {
4689
4699
  namespace: config.namespace,
4690
4700
  category: err.category,
4691
4701
  error: err.message
@@ -4756,7 +4766,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
4756
4766
  if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
4757
4767
  if (downstreamCaps?.roots) capabilities.roots = {};
4758
4768
  const client = new Client(
4759
- { name: "yaw-mcp", version: true ? "1.1.16" : "dev" },
4769
+ { name: "yaw-mcp", version: true ? "1.1.18" : "dev" },
4760
4770
  { capabilities }
4761
4771
  );
4762
4772
  if (bridge && capabilities.elicitation) {
@@ -4841,7 +4851,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
4841
4851
  resolved = managed;
4842
4852
  }
4843
4853
  }
4844
- resolved = npxUnderNode(resolved.command, resolved.args);
4854
+ resolved = npxUnderNode(resolved.command, resolved.args, { env: mergeChildEnv(parentEnv, serverEnv) });
4845
4855
  } catch (err) {
4846
4856
  if (err instanceof ActivationError) throw err;
4847
4857
  const message = err instanceof Error ? err.message : String(err);
@@ -4937,7 +4947,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
4937
4947
  }
4938
4948
  throw err;
4939
4949
  }
4940
- resolvedServerEnv = { ...resolvedHeaders, ...headerSecretValues };
4950
+ resolvedServerEnv = mergeSecretValues(resolvedHeaders, headerSecretValues);
4941
4951
  requestHeaders = resolvedHeaders;
4942
4952
  }
4943
4953
  const transportOpts = requestHeaders ? { requestInit: { headers: requestHeaders } } : void 0;
@@ -5038,7 +5048,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
5038
5048
  const underlying = SPAWN_ERRNO.test(raw) ? "" : ` Underlying error: ${redactSecretsInOutput(raw, resolvedServerEnv).slice(0, 300)}`;
5039
5049
  message = `Command '${config.command}' is not on PATH or is not executable. Verify the runtime is installed (e.g. Node.js for npx, Python for uvx).${spawnedNote}${underlying}`;
5040
5050
  } else {
5041
- message = err instanceof Error ? err.message : String(err);
5051
+ message = redactSecretsInOutput(err instanceof Error ? err.message : String(err), resolvedServerEnv);
5042
5052
  }
5043
5053
  }
5044
5054
  const redactedTail = trimmedStderr ? redactSecretsInOutput(trimmedStderr, resolvedServerEnv) : void 0;
@@ -6508,10 +6518,6 @@ async function buildLocked(req, ctx, root) {
6508
6518
  const plan = detectPackageManager(installDir);
6509
6519
  if ("error" in plan) return fail(2, `${scrubRepoUrlUserinfo(req.spec.url)}: ${plan.error}`);
6510
6520
  for (const w of plan.warnings) warn(w);
6511
- const pmCmd = resolvePmCommand(plan, { env: ctx.env, platform: ctx.platform, exclude: work });
6512
- if ("error" in pmCmd) return fail(2, pmCmd.error);
6513
- const build = planBuild(plan, installDir, targetDir);
6514
- if (build && "error" in build) return fail(2, build.error);
6515
6521
  if (!hasRepoConsent(req.spec.url, ctx.home)) {
6516
6522
  const lines = consentLines(
6517
6523
  lifecycleScripts(installDir, targetDir),
@@ -6539,6 +6545,10 @@ Not a TTY, so nothing can be asked: re-run with --yes to allow this repo's scrip
6539
6545
  }
6540
6546
  await recordRepoConsent(req.spec.url, ctx.home, ctx.now?.());
6541
6547
  }
6548
+ const pmCmd = resolvePmCommand(plan, { env: ctx.env, platform: ctx.platform, exclude: work });
6549
+ if ("error" in pmCmd) return fail(2, pmCmd.error);
6550
+ const build = planBuild(plan, installDir, targetDir);
6551
+ if (build && "error" in build) return fail(2, build.error);
6542
6552
  const pmOpts = (output) => ({
6543
6553
  ...pmCmd.bin ? { bin: pmCmd.bin } : {},
6544
6554
  env: plan.env,
@@ -62,8 +62,8 @@ import {
62
62
  tryRemoveTree,
63
63
  writeAskpassHelper,
64
64
  writeGitState
65
- } from "./chunk-HR6CEGYC.js";
66
- import "./chunk-A45PPRNA.js";
65
+ } from "./chunk-S36KB7D2.js";
66
+ import "./chunk-4Y3B23Z3.js";
67
67
  export {
68
68
  GIT_CONSENT_FILENAME,
69
69
  GIT_CREDENTIALS_REFUSAL,
package/dist/index.js CHANGED
@@ -168,7 +168,7 @@ import {
168
168
  withWarnSink,
169
169
  withoutControls,
170
170
  writeGitState
171
- } from "./chunk-HR6CEGYC.js";
171
+ } from "./chunk-S36KB7D2.js";
172
172
  import {
173
173
  BINARY_RETIRED_HINT,
174
174
  CLAUDE_CODE_ALLOW_PATTERN,
@@ -295,7 +295,7 @@ import {
295
295
  userConfigDir,
296
296
  withFileLock,
297
297
  yawModeOverlay
298
- } from "./chunk-A45PPRNA.js";
298
+ } from "./chunk-4Y3B23Z3.js";
299
299
 
300
300
  // src/audit-cmd.ts
301
301
  import { homedir as homedir3 } from "os";
@@ -815,7 +815,6 @@ async function loadYawMcpConfig(opts = {}) {
815
815
  const global = await readConfigAt(globalPath, "global", warnings, policyErrors);
816
816
  if (global) loadedFiles.push(global);
817
817
  const policyWarnings = loadedFiles.flatMap((f) => f.unknownKeysWarning ? [f.unknownKeysWarning] : []);
818
- policyWarnings.push(...policyErrors.map((e) => e.message));
819
818
  return {
820
819
  servers: pickServers(loadedFiles, warnings),
821
820
  blocked: unionStringField(loadedFiles, "blocked"),
@@ -905,7 +904,7 @@ var CONTAINER_RUNNER = {
905
904
  };
906
905
  var NODE_INTERPRETER = {
907
906
  value: flags(
908
- "-r --require --import --loader --experimental-loader -C --conditions --env-file --input-type --title --preload --tsconfig --tsconfig-override"
907
+ "-r --require --import --loader --experimental-loader -C --conditions --env-file --input-type --title --preload --tsconfig --tsconfig-override --watch-path --env-file-if-exists --inspect-port --debug-port --max-old-space-size --max-semi-space-size --stack-size --openssl-config --icu-data-dir --redirect-warnings --disable-warning --unhandled-rejections --dns-result-order --diagnostic-dir --report-dir --report-directory --report-filename --report-signal --cpu-prof-dir --cpu-prof-name --heap-prof-dir --heap-prof-name --heapsnapshot-signal --secure-heap --secure-heap-min --experimental-config-file --localstorage-file --trace-event-categories --trace-event-file-pattern --use-largepages --tls-cipher-list --tls-keylog --watch-kill-signal"
909
908
  ),
910
909
  bool: flags(""),
911
910
  stop: flags("-e --eval -p --print"),
@@ -916,8 +915,8 @@ var DENO_INTERPRETER = {
916
915
  value: /* @__PURE__ */ new Set([...NODE_INTERPRETER.value, "-c", "--config", "--import-map", "--lock"])
917
916
  };
918
917
  var PYTHON_INTERPRETER = {
919
- value: flags("-W -X"),
920
- bool: flags(""),
918
+ value: flags("-W -X --check-hash-based-pycs"),
919
+ bool: flags("-b -B -d -E -i -I -O -OO -P -q -R -s -S -u -v -x"),
921
920
  target: flags("-m"),
922
921
  stop: flags("-c"),
923
922
  unknownIsBool: true
@@ -1018,16 +1017,27 @@ function parseTarget(args, table) {
1018
1017
  const value = eq === -1 ? args[i + 1] : a.slice(eq + 1);
1019
1018
  if (value) return done(value, true);
1020
1019
  }
1021
- if (eq !== -1 || table.bool.has(a)) continue;
1020
+ if (eq !== -1 || table.bool.has(a)) {
1021
+ if (eq !== -1 && !table.unknownIsBool && a.startsWith("--") && !table.value.has(name) && !table.bool.has(name)) {
1022
+ const v = a.slice(eq + 1);
1023
+ if (v) ambiguous.push(v);
1024
+ }
1025
+ continue;
1026
+ }
1022
1027
  if (table.value.has(a)) {
1023
1028
  i++;
1024
1029
  continue;
1025
1030
  }
1026
1031
  if (/^-[A-Za-z]{2,}$/.test(a) && [...a.slice(1)].every((c) => table.bool.has(`-${c}`))) continue;
1027
- if (table.unknownIsBool) continue;
1032
+ if (table.unknownIsBool) {
1033
+ const next2 = args[i + 1];
1034
+ const after = args[i + 2];
1035
+ if (next2 !== void 0 && !next2.startsWith("-") && after && !after.startsWith("-")) ambiguous.push(after);
1036
+ continue;
1037
+ }
1028
1038
  const next = args[i + 1];
1029
1039
  if (next !== void 0 && !next.startsWith("-")) {
1030
- ambiguous.push(next);
1040
+ if (next) ambiguous.push(next);
1031
1041
  i++;
1032
1042
  }
1033
1043
  }
@@ -1061,11 +1071,12 @@ function localIdentity(command, args) {
1061
1071
  if (table) {
1062
1072
  const scriptArgs = (launcher === "deno" || launcher === "bun") && args[0] === "run" ? args.slice(1) : args;
1063
1073
  const expanded = table === PYTHON_INTERPRETER ? scriptArgs.flatMap((a) => /^-[bBdEiIOPqRsSuvx]+m$/.test(a) ? [a.slice(0, -1), "-m"] : [a]) : scriptArgs;
1064
- const { target, viaFlag } = parseTarget(expanded, table);
1065
- if (!target) return identity([], [], launchers);
1066
- if (viaFlag) return identity([packageId(target)], [], launchers);
1074
+ const { target, viaFlag, ambiguous } = parseTarget(expanded, table);
1075
+ const weakReadings = ambiguous.map((v) => commandIds(v)).flatMap((c) => [c.strong, ...c.weak]);
1076
+ if (!target) return identity([], weakReadings, launchers);
1077
+ if (viaFlag) return identity([packageId(target)], weakReadings, launchers);
1067
1078
  const script = commandIds(target);
1068
- return identity([script.strong], script.weak, launchers);
1079
+ return identity([script.strong], [...script.weak, ...weakReadings], launchers);
1069
1080
  }
1070
1081
  if (SHELLS.has(launcher) || GENERIC_LAUNCHERS.has(launcher)) return identity([], [], launchers);
1071
1082
  const suffix = args.length > 0 ? `${ARGS_SEPARATOR}${JSON.stringify(args)}` : "";
@@ -1141,6 +1152,16 @@ function identityBlockOf(profile, servers, namespace) {
1141
1152
  if (!profileAllows(profile, namespace)) return null;
1142
1153
  return displayIdentity(matched);
1143
1154
  }
1155
+ function identityBlocksOf(profile, servers, namespaces) {
1156
+ const blocks = identityBlocks(profile, identify(servers));
1157
+ const out = /* @__PURE__ */ new Map();
1158
+ for (const namespace of namespaces) {
1159
+ const matched = blocks.get(namespace);
1160
+ if (!matched || !profileAllows(profile, namespace)) continue;
1161
+ out.set(namespace, displayIdentity(matched));
1162
+ }
1163
+ return out;
1164
+ }
1144
1165
  function effectiveProfile(profile, servers) {
1145
1166
  if (!profile || !profile.blocked?.length && !profile.blockedTools?.length) return profile;
1146
1167
  const identified = identify(servers);
@@ -3866,7 +3887,7 @@ async function cachedRegistryLatest(pkg, fetchLatest, opts) {
3866
3887
 
3867
3888
  // src/secrets-cmd.ts
3868
3889
  import { createHash, randomInt } from "crypto";
3869
- import { chmod, copyFile, constants as fsConstants, readFile as readFile5, unlink } from "fs/promises";
3890
+ import { chmod, copyFile, constants as fsConstants, readFile as readFile5, realpath, unlink } from "fs/promises";
3870
3891
  import { homedir as homedir6, constants as osConstants } from "os";
3871
3892
  import { resolve as resolvePath } from "path";
3872
3893
  var SECRETS_USAGE = `Usage: yaw-mcp secrets <action> [args]
@@ -4680,7 +4701,7 @@ It is not stored anywhere you can read it back, and this screen clears when you
4680
4701
 
4681
4702
  `
4682
4703
  );
4683
- for (let attempt = 0, empty = 0; attempt < RECOVERY_CONFIRM_ATTEMPTS && empty < RECOVERY_CONFIRM_MAX_EMPTY; ) {
4704
+ for (let attempt = 0, empty = 0; attempt < RECOVERY_CONFIRM_ATTEMPTS; ) {
4684
4705
  const first = randomInt(groups.length);
4685
4706
  let second = randomInt(groups.length - 1);
4686
4707
  if (second >= first) second++;
@@ -4704,6 +4725,7 @@ It is not stored anywhere you can read it back, and this screen clears when you
4704
4725
  i--;
4705
4726
  continue;
4706
4727
  }
4728
+ empty = 0;
4707
4729
  if (typed !== groups[g]) {
4708
4730
  ok = false;
4709
4731
  break;
@@ -4711,9 +4733,13 @@ It is not stored anywhere you can read it back, and this screen clears when you
4711
4733
  }
4712
4734
  if (ok) return "confirmed";
4713
4735
  attempt++;
4714
- out.write(
4715
- attempt < RECOVERY_CONFIRM_ATTEMPTS ? "That does not match the code above. Check what you wrote down and try again.\n" : "That does not match the code above.\n"
4716
- );
4736
+ if (attempt < RECOVERY_CONFIRM_ATTEMPTS) {
4737
+ out.write("That does not match the code above. Check what you wrote down and try again.\n");
4738
+ } else {
4739
+ out.write(ALT_SCREEN_OFF);
4740
+ out.write(`That does not match the code shown -- ${RECOVERY_CONFIRM_ATTEMPTS} attempts used.
4741
+ `);
4742
+ }
4717
4743
  }
4718
4744
  return "exhausted";
4719
4745
  } finally {
@@ -5397,13 +5423,13 @@ function resetVaultNudge(io, path3, json, envKeyed) {
5397
5423
  ${lines.join("\n")}
5398
5424
  `);
5399
5425
  }
5400
- function rotateVaultNudge(io, path3, json, envKeyed, warning = "vault-rotated") {
5426
+ function rotateVaultNudge(io, path3, json, envKeyed, warning = "vault-rotated", jsonFields = { passphrase_source: envKeyed ? "env" : "prompt" }) {
5401
5427
  if (json) {
5402
5428
  io.err(
5403
5429
  `${JSON.stringify({
5404
5430
  warning,
5405
5431
  path: path3,
5406
- passphrase_source: envKeyed ? "env" : "prompt",
5432
+ ...jsonFields,
5407
5433
  hint: "Update YAW_MCP_VAULT_PASSPHRASE to the new passphrase wherever it is set (this shell, a shell profile, any client config `env` block) -- the old value no longer unlocks the vault. A running yaw-mcp server keeps the passphrase it started with -- restart it (restart your MCP client). `yaw-mcp doctor` reports whether the passphrase it sees unlocks the vault."
5408
5434
  })}
5409
5435
  `
@@ -5576,6 +5602,18 @@ async function runSecretsReset(opts, io) {
5576
5602
  if (noCodeBlocker !== null) noRecoveryCodeNudge(io, json, noCodeBlocker);
5577
5603
  return { exitCode: 0 };
5578
5604
  }
5605
+ async function isSameFilePath(a, b, platform = process.platform) {
5606
+ const canonical = async (p) => {
5607
+ const resolved = resolvePath(p);
5608
+ try {
5609
+ return await realpath(resolved);
5610
+ } catch {
5611
+ return resolved;
5612
+ }
5613
+ };
5614
+ const [x, y] = await Promise.all([canonical(a), canonical(b)]);
5615
+ return platform === "win32" ? x.toLowerCase() === y.toLowerCase() : x === y;
5616
+ }
5579
5617
  async function runSecretsRecover(opts, io) {
5580
5618
  const home = opts.home ?? homedir6();
5581
5619
  const path3 = vaultPath(home);
@@ -5603,7 +5641,7 @@ async function runSecretsRecover(opts, io) {
5603
5641
  }
5604
5642
  }
5605
5643
  const source = opts.file !== void 0 ? resolvePath(opts.file) : path3;
5606
- const fromCopy = source !== resolvePath(path3);
5644
+ const fromCopy = !await isSameFilePath(source, path3);
5607
5645
  const baseline = await vaultFingerprint(path3);
5608
5646
  if (isVaultUnreadable(baseline)) return vaultUnreadableResult(io, json, "recover", path3, baseline);
5609
5647
  let sourceBaseline = baseline;
@@ -5704,10 +5742,8 @@ async function runSecretsRecover(opts, io) {
5704
5742
  if (await vaultChangedSinceLoad(path3, baseline) || fromCopy && await vaultChangedSinceLoad(source, sourceBaseline)) {
5705
5743
  return vaultChangedResult(io, json, "recover");
5706
5744
  }
5707
- const cause = await trySaveVault(path3, recovered);
5708
- if (cause !== null) {
5709
- return fail(`could not write the vault file at ${path3} (${cause}) -- nothing was saved.`);
5710
- }
5745
+ const failed = await saveVaultOrReport(path3, recovered, io, json, "recover");
5746
+ if (failed) return failed;
5711
5747
  lock();
5712
5748
  await auditVaultEvents(home, [
5713
5749
  "recovery-used",
@@ -5738,7 +5774,11 @@ async function runSecretsRecover(opts, io) {
5738
5774
  if (issuedCode !== void 0 && !fromCopy) io.out("A new recovery code replaced it.\n");
5739
5775
  }
5740
5776
  const envKeyed = (process.env.YAW_MCP_VAULT_PASSPHRASE ?? "").length > 0;
5741
- rotateVaultNudge(io, path3, json, envKeyed, "vault-recovered");
5777
+ const newFromEnv = opts.newPassphrase === void 0 && (process.env.YAW_MCP_VAULT_PASSPHRASE_NEW ?? "").length > 0;
5778
+ rotateVaultNudge(io, path3, json, envKeyed, "vault-recovered", {
5779
+ passphrase_source: newFromEnv ? "env" : "prompt",
5780
+ stale_env_set: envKeyed
5781
+ });
5742
5782
  return { exitCode: 0 };
5743
5783
  } finally {
5744
5784
  key.fill(0);
@@ -9483,7 +9523,7 @@ function foldBundleWarnings(warnings, probe) {
9483
9523
  const prefix = `${probe.path}:`;
9484
9524
  return warnings.filter((w) => !w.startsWith(prefix));
9485
9525
  }
9486
- var VERSION = true ? "1.1.16" : "dev";
9526
+ var VERSION = true ? "1.1.18" : "dev";
9487
9527
  var DOCTOR_USAGE = `Usage: yaw-mcp doctor [--json]
9488
9528
 
9489
9529
  Print a diagnostic of your yaw-mcp setup.
@@ -19642,7 +19682,7 @@ var ConnectServer = class _ConnectServer {
19642
19682
  // Per-namespace count of tool calls currently awaiting an upstream
19643
19683
  // response. Incremented immediately before routeToolCall and decremented
19644
19684
  // in a finally, so it is accurate across concurrent calls. Read by
19645
- // trackUsageAndAutoDeactivate: the idle reaper runs on OTHER calls'
19685
+ // trackUsageForNamespaces: the idle reaper runs on OTHER calls'
19646
19686
  // completions, so without this a long call to B can be killed mid-flight
19647
19687
  // by a burst of short calls to A (and then booked as B's failure).
19648
19688
  inflightCalls = /* @__PURE__ */ new Map();
@@ -19686,8 +19726,8 @@ var ConnectServer = class _ConnectServer {
19686
19726
  static DISCOVER_CACHE_TTL_MS = 3e3;
19687
19727
  // Baseline idle-call threshold lives in resolveIdleThreshold() (module
19688
19728
  // scope, re-read per call) rather than in a static initializer here: a
19689
- // static latches the env at import, which is exactly the pattern the
19690
- // isAutoActivateEnabled comment above calls out as the one to avoid.
19729
+ // static latches the env at import, which is exactly the pattern
19730
+ // resolveIdleThreshold's own comment above calls out as the one to avoid.
19691
19731
  // Concurrent-load ceiling. See server-cap.ts — checked in
19692
19732
  // runActivateOne before a new upstream is spawned so we refuse at
19693
19733
  // the door instead of over-inflating the LLM's context. Instance
@@ -19757,7 +19797,7 @@ var ConnectServer = class _ConnectServer {
19757
19797
  * initialize handshake completes; see beginSession for why it waits. */
19758
19798
  buildServer(era, supportedProtocolVersions) {
19759
19799
  const s = new Server(
19760
- { name: "yaw-mcp", version: true ? "1.1.16" : "dev" },
19800
+ { name: "yaw-mcp", version: true ? "1.1.18" : "dev" },
19761
19801
  {
19762
19802
  capabilities: {
19763
19803
  tools: { listChanged: true },
@@ -20067,7 +20107,7 @@ var ConnectServer = class _ConnectServer {
20067
20107
  await this.ready;
20068
20108
  const resourceNamespace = this.getBuiltinResourceMap().has(request.params.uri) ? void 0 : this.resourceRoutes.get(request.params.uri)?.namespace;
20069
20109
  const resourceRefusal = resourceNamespace ? this.serverPolicyRefusal(resourceNamespace) : null;
20070
- if (resourceRefusal) return { contents: [{ uri: request.params.uri, text: resourceRefusal }] };
20110
+ if (resourceRefusal) throw new ProtocolError(ProtocolErrorCode.InvalidRequest, resourceRefusal);
20071
20111
  return await routeResourceRead(
20072
20112
  request.params.uri,
20073
20113
  this.resourceRoutes,
@@ -20090,9 +20130,7 @@ var ConnectServer = class _ConnectServer {
20090
20130
  await this.ready;
20091
20131
  const promptNamespace = this.promptRoutes.get(request.params.name)?.namespace;
20092
20132
  const promptRefusal = promptNamespace ? this.serverPolicyRefusal(promptNamespace) : null;
20093
- if (promptRefusal) {
20094
- return { messages: [{ role: "user", content: { type: "text", text: promptRefusal } }] };
20095
- }
20133
+ if (promptRefusal) throw new ProtocolError(ProtocolErrorCode.InvalidRequest, promptRefusal);
20096
20134
  return await routePromptGet(
20097
20135
  request.params.name,
20098
20136
  request.params.arguments,
@@ -20116,15 +20154,7 @@ var ConnectServer = class _ConnectServer {
20116
20154
  onUpstreamListChanged = (ns) => {
20117
20155
  log("info", "Upstream list changed, rebuilding routes", { namespace: ns });
20118
20156
  const conn = this.connections.get(ns);
20119
- if (conn?.status === "connected") {
20120
- this.toolCache.set(
20121
- ns,
20122
- conn.tools.map((t) => ({ name: t.name, description: t.description }))
20123
- );
20124
- this.toolCacheLearnedAt.set(ns, Date.now());
20125
- this.stampLearnedMeta(ns, conn);
20126
- this.scheduleStateSave();
20127
- }
20157
+ if (conn?.status === "connected") this.learnToolsFrom(ns, conn);
20128
20158
  this.refreshRoutesAndNotify().catch((err) => {
20129
20159
  log("warn", "Failed to notify client of upstream list change", {
20130
20160
  namespace: ns,
@@ -20143,7 +20173,15 @@ var ConnectServer = class _ConnectServer {
20143
20173
  * snapshot, so a server the sweep has already finished drops out as soon
20144
20174
  * as its list lands. */
20145
20175
  serversPrewarmIsLearning() {
20146
- return this.getProfiledActiveServers().filter((s) => this.prewarmMustLearn(s) && !this.prewarmBackoffFor(s));
20176
+ return this.getProfiledActiveServers().filter(
20177
+ (s) => this.spawnGatePasses(s) && this.prewarmMustLearn(s) && !this.prewarmBackoffFor(s)
20178
+ );
20179
+ }
20180
+ /** Would the spawn gate let this server be launched right now? The verdict
20181
+ * alone, for the pre-warm sweep: a server it refuses (the compliance floor)
20182
+ * is never spawned by pre-warm, so it must not be counted as learning. */
20183
+ spawnGatePasses(server) {
20184
+ return spawnGateVerdict(server, this.profile, resolveMinCompliance(), this.config?.servers ?? [server]) === null;
20147
20185
  }
20148
20186
  /** Must pre-warm learn this server before its tools can be trusted -- no
20149
20187
  * list at all, or a list learned under a launch config that no longer
@@ -20172,6 +20210,20 @@ var ConnectServer = class _ConnectServer {
20172
20210
  const entry = (this.config?.servers ?? []).find((s) => s.namespace === namespace);
20173
20211
  return entry === void 0 ? void 0 : toolCacheConfigKey(entry);
20174
20212
  }
20213
+ /** Learn `conn`'s tool list as the namespace's cold cache: the list itself,
20214
+ * when it was learned, its fingerprint (stampLearnedMeta), and a debounced,
20215
+ * best-effort state save so the next session can skip the pre-warm spawn.
20216
+ * The one sequence behind both a fresh activation (runActivateOne) and an
20217
+ * upstream list_changed, so a field added here reaches both. */
20218
+ learnToolsFrom(namespace, conn) {
20219
+ this.toolCache.set(
20220
+ namespace,
20221
+ conn.tools.map((t) => ({ name: t.name, description: t.description }))
20222
+ );
20223
+ this.toolCacheLearnedAt.set(namespace, Date.now());
20224
+ this.stampLearnedMeta(namespace, conn);
20225
+ this.scheduleStateSave();
20226
+ }
20175
20227
  /** Record the fingerprint + upstream version of a list just learned from
20176
20228
  * `conn`, and clear any pre-warm failure the success supersedes. */
20177
20229
  stampLearnedMeta(namespace, conn) {
@@ -20517,10 +20569,18 @@ var ConnectServer = class _ConnectServer {
20517
20569
  // synthetic ~/.yaw-mcp without running the whole of start().
20518
20570
  async hydrateComplianceGrades(home = homedir17()) {
20519
20571
  if (!this.config) return;
20572
+ this.config.servers = await this.overlayComplianceGrades(this.config.servers, home);
20573
+ }
20574
+ /** The overlay itself, over a server list that need not be installed yet.
20575
+ * The reload path applies it to the freshly-parsed list BEFORE adoptConfig,
20576
+ * so `this.config` is never observable without it: proxied tools/call
20577
+ * requests are not serialized behind a reload, and one landing during the
20578
+ * grades.json read would otherwise gate on un-overlaid entries. */
20579
+ async overlayComplianceGrades(servers, home = homedir17()) {
20520
20580
  const grades = await readGradesCache(home).catch(() => ({}));
20521
- if (Object.keys(grades).length === 0) return;
20581
+ if (Object.keys(grades).length === 0) return servers;
20522
20582
  let applied = 0;
20523
- this.config.servers = this.config.servers.map((server) => {
20583
+ const overlaid = servers.map((server) => {
20524
20584
  if (!Object.hasOwn(grades, server.namespace)) return server;
20525
20585
  const cached = grades[server.namespace];
20526
20586
  if (!cached) return server;
@@ -20528,6 +20588,7 @@ var ConnectServer = class _ConnectServer {
20528
20588
  return { ...server, complianceGrade: cached.grade };
20529
20589
  });
20530
20590
  if (applied > 0) log("info", "Applied cached compliance grades", { graded: applied });
20591
+ return overlaid;
20531
20592
  }
20532
20593
  /** Install a freshly-loaded server list as the running config. Shared by
20533
20594
  * start() and the reload path so the namespace dedupe below cannot come to
@@ -20654,12 +20715,12 @@ var ConnectServer = class _ConnectServer {
20654
20715
  }
20655
20716
  return false;
20656
20717
  }
20718
+ const reloaded = result.config ? { ...result.config, servers: await this.overlayComplianceGrades(result.config.servers) } : result.config;
20657
20719
  const previousVersion = this.configVersion;
20658
20720
  this.configWarnings = result.warnings;
20659
- this.adoptConfig(result.config);
20721
+ this.adoptConfig(reloaded);
20660
20722
  this.bundlesLoadedFrom = result.path;
20661
20723
  this.bundlesVanishedWarned = false;
20662
- await this.hydrateComplianceGrades();
20663
20724
  const changed = this.configVersion !== previousVersion;
20664
20725
  log("info", changed ? "Reloaded bundles" : "bundles.json touched but unchanged", {
20665
20726
  path: result.path,
@@ -20878,11 +20939,16 @@ var ConnectServer = class _ConnectServer {
20878
20939
  resolvedConfig = await loadYawMcpConfig({ cwd: process.cwd() }).catch((err) => {
20879
20940
  const path3 = join12(userConfigDir(), CONFIG_FILENAME);
20880
20941
  const message = `${path3}: yaw-mcp could not load its config (${err instanceof Error ? err.message : String(err)}). No MCP server will start until this is fixed: check that the file and your project's .yaw-mcp/ directory are readable, restart your MCP client, and run \`yaw-mcp doctor\` to confirm.`;
20881
- return { projectConfigDir: null, loadedFiles: [], warnings: [message], policyErrors: [{ path: path3, message }] };
20942
+ return {
20943
+ projectConfigDir: null,
20944
+ loadedFiles: [],
20945
+ warnings: [message],
20946
+ policyErrors: [{ path: path3, message }]
20947
+ };
20882
20948
  });
20883
- for (const w of resolvedConfig?.warnings ?? []) log("warn", "Config warning", { warning: w });
20949
+ for (const w of resolvedConfig.warnings) log("warn", "Config warning", { warning: w });
20884
20950
  }
20885
- this.profile = resolvedConfig ? toProfile(resolvedConfig) : null;
20951
+ this.profile = toProfile(resolvedConfig);
20886
20952
  if (this.profile) {
20887
20953
  log("info", "Loaded profile", {
20888
20954
  path: this.profile.path,
@@ -21062,7 +21128,7 @@ var ConnectServer = class _ConnectServer {
21062
21128
  return;
21063
21129
  }
21064
21130
  const available = this.getProfiledActiveServers().filter(
21065
- (s) => this.connections.get(s.namespace)?.status !== "connected"
21131
+ (s) => this.connections.get(s.namespace)?.status !== "connected" && this.spawnGatePasses(s)
21066
21132
  );
21067
21133
  const backedOff = available.flatMap((s) => {
21068
21134
  const failure = this.prewarmBackoffFor(s);
@@ -21657,7 +21723,9 @@ var ConnectServer = class _ConnectServer {
21657
21723
  const errors = this.profile?.policyErrors;
21658
21724
  if (errors?.length) return policyErrorText(errors);
21659
21725
  if (profileAllows(this.policy(), namespace)) return null;
21660
- return `Server "${namespace}" is not allowed by the project profile at ${this.profile?.path}. Report the block to the user instead of routing around it; if it should be reachable, the profile must be edited and this MCP client restarted.`;
21726
+ const identity2 = this.profile ? identityBlockOf(this.profile, this.config?.servers ?? [], namespace) : null;
21727
+ const identityHint = identity2 ? ` (it launches ${identity2}, the same server as a "blocked" entry, so remove that entry to allow it; listing it in "servers" does not)` : "";
21728
+ return `Server "${namespace}" is not allowed by the project profile at ${this.profile?.path}${identityHint}. Report the block to the user instead of routing around it; if it should be reachable, the profile must be edited and this MCP client restarted.`;
21661
21729
  }
21662
21730
  toolRouteRefusal(wireName) {
21663
21731
  const namespace = this.toolRoutes.get(wireName)?.namespace;
@@ -21709,6 +21777,22 @@ var ConnectServer = class _ConnectServer {
21709
21777
  if (!top) return this.handleDiscover(context, focusNamespace);
21710
21778
  const existing = this.connections.get(top.namespace);
21711
21779
  if (existing && existing.status === "connected") {
21780
+ if (this.prewarmNamespaces.has(top.namespace)) {
21781
+ const capDecision = this.evaluateCapFor(top.namespace);
21782
+ if (!capDecision.allow) {
21783
+ const output2 = this.buildDiscoverOutput(context, null, focusNamespace);
21784
+ return {
21785
+ ...output2,
21786
+ content: [
21787
+ ...output2.content,
21788
+ {
21789
+ type: "text",
21790
+ text: `Could not auto-load "${top.namespace}" (top match for your query): ${capDecision.message}`
21791
+ }
21792
+ ]
21793
+ };
21794
+ }
21795
+ }
21712
21796
  this.prewarmNamespaces.delete(top.namespace);
21713
21797
  const grew = !this.sessionActivated.has(top.namespace);
21714
21798
  this.sessionActivated.add(top.namespace);
@@ -21783,6 +21867,12 @@ var ConnectServer = class _ConnectServer {
21783
21867
  "No servers are loaded, and the diagnostics above say why -- so this is NOT necessarily an empty install; servers already in bundles.json can be missing because the file could not be read. Fix it (or run `yaw-mcp doctor` for the full report); the fix is picked up on the next mcp_connect_* call, with no client restart."
21784
21868
  ].join("\n");
21785
21869
  }
21870
+ /** The answer for "getProfiledActiveServers() is empty": nothing configured
21871
+ * (emptyStateText) versus everything configured filtered out
21872
+ * (noServersEnabledText). One split for the handlers that need both. */
21873
+ noUsableServersText() {
21874
+ return (this.config?.servers.length ?? 0) === 0 ? this.emptyStateText() : this.noServersEnabledText();
21875
+ }
21786
21876
  /** Everything installed is either `"isActive": false` or kept out by the
21787
21877
  * project profile -- there is no third way past getProfiledActiveServers,
21788
21878
  * so at least one of the two lists below is non-empty.
@@ -22076,8 +22166,9 @@ Tool lists show the first ${_ConnectServer.DISCOVER_TOOL_NAME_CAP} names; call m
22076
22166
  if (!focused && inactive.length > 0) {
22077
22167
  lines.push("\nDisabled servers:");
22078
22168
  for (const server of inactive) {
22079
- lines.push(` ${server.namespace} \u2014 ${server.name} ("isActive": false in bundles.json)`);
22169
+ lines.push(` ${server.namespace} \u2014 ${server.name} ("isActive": false)`);
22080
22170
  }
22171
+ lines.push(` (set "isActive": true in ${bundlesFileHint("defines-it")} to enable one)`);
22081
22172
  }
22082
22173
  if (!focused && !listOnly) lines.push(...this.buildInstallCandidatesLines(allProfiled));
22083
22174
  const activeCount = Array.from(this.connections.values()).filter((c) => c.status === "connected").length;
@@ -22321,15 +22412,17 @@ ${activeCount} loaded in this session, ${totalTools} ${totalTools === 1 ? "tool"
22321
22412
  // configured server from a shell, with no broker in the process -- enforces
22322
22413
  // the identical policy without importing this module.
22323
22414
  //
22324
- // Four callers HERE. Two actually execute the server's configured command
22415
+ // Five callers HERE. Two actually execute the server's configured command
22325
22416
  // with its resolved env -- runActivateOne (persistent activation) and
22326
22417
  // handleReadTool (transient inspect) -- so "we disconnect afterwards" buys
22327
22418
  // read_tool no exemption. Those two used to carry line-for-line copies of
22328
22419
  // the checks, which meant a policy change had to land twice to stay
22329
- // consistent. The other two spawn nothing and only want the verdict as
22420
+ // consistent. The other three spawn nothing and only want the verdict as
22330
22421
  // text: handleSecretsReport, to say why a named server is missing from its
22331
- // report, and handleExec's pre-flight, to refuse a pipeline before step 0
22332
- // when a later step's deferred server would be refused anyway. `purpose`
22422
+ // report, handleExec's pre-flight, to refuse a pipeline before step 0
22423
+ // when a later step's deferred server would be refused anyway, and
22424
+ // buildDiscoverOutputImpl's focus miss, to say why a named server is not
22425
+ // loadable (it passes "activate", the action the reader would take). `purpose`
22333
22426
  // supplies the only words that legitimately differ: what the caller was
22334
22427
  // about to do with the server.
22335
22428
  //
@@ -22341,15 +22434,18 @@ ${activeCount} loaded in this session, ${totalTools} ${totalTools === 1 ? "tool"
22341
22434
  const refusal = spawnGateVerdict(server, this.profile, resolveMinCompliance(), this.config?.servers ?? [server]);
22342
22435
  if (!refusal) return null;
22343
22436
  const text = this.spawnGateRefusalText(refusal, purpose);
22344
- const policyWarnings = this.profile?.policyWarnings ?? [];
22345
- return policyWarnings.length > 0 ? `${text} Note: ${policyWarnings.join(" ")}` : text;
22437
+ const notes = [
22438
+ ...refusal.kind === "policy-invalid" ? [] : (this.profile?.policyErrors ?? []).map((e) => e.message),
22439
+ ...this.profile?.policyWarnings ?? []
22440
+ ];
22441
+ return notes.length > 0 ? `${text} Note: ${notes.join(" ")}` : text;
22346
22442
  }
22347
22443
  spawnGateRefusalText(refusal, purpose) {
22348
22444
  switch (refusal.kind) {
22349
22445
  case "disabled":
22350
22446
  return `"${refusal.namespace}" is installed but disabled. Set "isActive": true for it in ${bundlesFileHint("defines-it")} and try again to ${purpose} -- the edit is picked up on the next mcp_connect_* call, with no client restart.`;
22351
22447
  case "policy-invalid":
22352
- return `Cannot ${purpose} for "${refusal.namespace}". ${policyErrorText(refusal.errors)}`;
22448
+ return `"${refusal.namespace}": cannot ${purpose}. ${policyErrorText(refusal.errors)}`;
22353
22449
  case "profile":
22354
22450
  return `"${refusal.namespace}" is not allowed by the project profile at ${refusal.profilePath}${refusal.identity ? ` (it launches ${refusal.identity}, the same server as a "blocked" entry, so remove that entry to allow it; listing it in "servers" does not)` : ""}.`;
22355
22451
  case "compliance":
@@ -22552,11 +22648,7 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
22552
22648
  });
22553
22649
  }
22554
22650
  this.idleCallCounts.set(namespace, 0);
22555
- const toolMeta = connection.tools.map((t) => ({ name: t.name, description: t.description }));
22556
- this.toolCache.set(namespace, toolMeta);
22557
- this.toolCacheLearnedAt.set(namespace, Date.now());
22558
- this.stampLearnedMeta(namespace, connection);
22559
- this.scheduleStateSave();
22651
+ this.learnToolsFrom(namespace, connection);
22560
22652
  const { served, shadowed } = this.splitShadowedTools(namespace, connection.tools);
22561
22653
  const toolNames = served.map((t) => t.namespacedName).join(", ");
22562
22654
  this.activationFailures.delete(namespace);
@@ -22707,9 +22799,9 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
22707
22799
  });
22708
22800
  const entry = leg ? await this.untilPosted(leg, entryPromise) : await entryPromise;
22709
22801
  if (entry === "posted") {
22710
- const asked2 = leg?.ask;
22711
- if (asked2) {
22712
- asked2.settled = entryPromise.then(
22802
+ const pendingAsk = leg?.ask;
22803
+ if (pendingAsk) {
22804
+ pendingAsk.settled = entryPromise.then(
22713
22805
  (e) => {
22714
22806
  if (e.kind === "submitted") this.storeCredentialValues(namespace, missing, e.values);
22715
22807
  return { subject, kind: "credential", entry: e };
@@ -23177,6 +23269,8 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
23177
23269
  // or the page closed under the wait); or, from a drifted
23178
23270
  // page only, an empty submission.
23179
23271
  // unreachable -- the masked-entry page never took a passphrase.
23272
+ // unverifiable -- typed, but the vault had nothing to check it against;
23273
+ // not stored, not latched.
23180
23274
  async promptForVaultPassphrase(namespace, lastError, progress) {
23181
23275
  this.vaultPassphrasePrompts++;
23182
23276
  if (this.vaultPassphrasePrompts >= MAX_VAULT_PASSPHRASE_PROMPTS) this.vaultPassphraseElicited = true;
@@ -23357,8 +23451,7 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
23357
23451
  const ns = filterRequestedFor;
23358
23452
  const unmatched = this.unmatchedFilterNames(ns);
23359
23453
  if (unmatched.length > 0) {
23360
- const conn = this.connections.get(ns);
23361
- const offered = conn && conn.status === "connected" ? conn.tools.map((t) => t.name) : (this.cachedToolsFor(ns) ?? []).map((t) => t.name);
23454
+ const offered = this.knownToolNames(ns);
23362
23455
  const plural = unmatched.length === 1;
23363
23456
  const lead = `Note: the ${plural ? "tool" : "tools"} you asked to keep ${plural ? "does" : "do"} not exist on "${ns}": ${unmatched.join(", ")}.`;
23364
23457
  const fix = ` That server offers: ${offered.join(", ")}. Re-run mcp_connect_activate with a name from that list, or omit "tools" to advertise all of them.`;
@@ -23380,17 +23473,20 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
23380
23473
  unmatchedFilterNames(namespace) {
23381
23474
  const filter = this.toolFilters.get(namespace);
23382
23475
  if (!filter || filter.size === 0) return [];
23383
- const conn = this.connections.get(namespace);
23384
- let known;
23385
- if (conn && conn.status === "connected") {
23386
- known = conn.tools.map((t) => t.name);
23387
- } else {
23388
- known = (this.cachedToolsFor(namespace) ?? []).map((t) => t.name);
23389
- }
23476
+ const known = this.knownToolNames(namespace);
23390
23477
  if (known.length === 0) return [];
23391
23478
  const have = new Set(known);
23392
23479
  return [...filter].filter((n) => !have.has(n)).sort();
23393
23480
  }
23481
+ /** The tool names `namespace` is known to offer: the live list when
23482
+ * connected, else the cached one; [] when neither is known. The one list
23483
+ * both unmatchedFilterNames and handleActivate's "That server offers"
23484
+ * line read, so the two cannot disagree. */
23485
+ knownToolNames(namespace) {
23486
+ const conn = this.connections.get(namespace);
23487
+ if (conn && conn.status === "connected") return conn.tools.map((t) => t.name);
23488
+ return (this.cachedToolsFor(namespace) ?? []).map((t) => t.name);
23489
+ }
23394
23490
  // Background refinement of a just-recorded heuristic reward via the optional
23395
23491
  // LLM grader. Fire-and-forget: the tool result has already returned. If the
23396
23492
  // grader returns a verdict different from the heuristic, revise the credit by
@@ -23632,7 +23728,10 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
23632
23728
  // Deliberately NOT cleared here: toolCache / toolCacheLearnedAt (what the
23633
23729
  // server offers survives an unload -- that is what makes it deferred
23634
23730
  // rather than invisible), activationFailures (a health signal with its own
23635
- // TTL), and learning counters (cross-session by design).
23731
+ // TTL), learning counters (cross-session by design), and
23732
+ // lastIntentByNamespace (the reward grader's best-effort, per-namespace
23733
+ // intent; staleness across an unload is the documented limit in
23734
+ // reward-grader.ts, and a re-dispatch overwrites it).
23636
23735
  //
23637
23736
  // Takes the connection being forgotten and forgets ONLY if the map still
23638
23737
  // holds that one. Every caller has just awaited disconnectFromUpstream,
@@ -23709,6 +23808,9 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
23709
23808
  content: [{ type: "text", text: results.join("\n") }]
23710
23809
  };
23711
23810
  }
23811
+ /** Single-namespace entry point to the idle reaper (trackUsageForNamespaces,
23812
+ * which exec and observed() call directly). Kept as a named wrapper because
23813
+ * the reaper tests drive it through this name. */
23712
23814
  async trackUsageAndAutoDeactivate(calledNamespace) {
23713
23815
  await this.trackUsageForNamespaces([calledNamespace]);
23714
23816
  }
@@ -23968,6 +24070,9 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
23968
24070
  isError: true
23969
24071
  };
23970
24072
  }
24073
+ if (!serverArg && servers.length === 0) {
24074
+ return { content: [{ type: "text", text: this.noUsableServersText() }], isError: true };
24075
+ }
23971
24076
  if (rows.length === 0) {
23972
24077
  const sentence = serverArg ? `Server "${serverArg}" does not reference any \${secret:NAME} vault values.` : "No installed server references any ${secret:NAME} vault values.";
23973
24078
  return {
@@ -24021,8 +24126,14 @@ The vault at ${path3} exists but could not be read, so which referenced names it
24021
24126
  if (this.profile.blocked?.length) lines.push(` block: ${this.profile.blocked.join(", ")}`);
24022
24127
  const enforced = this.profile.policyErrors?.length ? null : this.policy();
24023
24128
  const servers = this.config?.servers ?? [];
24024
- const rawBlocked = this.profile.blocked;
24025
- const extraBlocked = enforced ? servers.filter((s) => s.isActive && !profileAllows(enforced, s.namespace)).map((s) => s.namespace).filter((ns) => !rawBlocked?.includes(ns)).sort() : [];
24129
+ const profile = this.profile;
24130
+ const extraBlocked = enforced ? [
24131
+ ...identityBlocksOf(
24132
+ profile,
24133
+ servers,
24134
+ servers.filter((s) => s.isActive && !profileAllows(enforced, s.namespace)).map((s) => s.namespace)
24135
+ ).keys()
24136
+ ].sort() : [];
24026
24137
  if (extraBlocked.length > 0) lines.push(` also blocked via identity: ${extraBlocked.join(", ")}`);
24027
24138
  if (this.profile.blockedTools?.length) lines.push(` block tools: ${this.profile.blockedTools.join(", ")}`);
24028
24139
  lines.push("");
@@ -24109,10 +24220,7 @@ Cross-session reliability (dormant, <${flakyPct}% success):`);
24109
24220
  async handleFindTool(query, limit) {
24110
24221
  const servers = this.getProfiledActiveServers();
24111
24222
  if (servers.length === 0) {
24112
- const configured = this.config?.servers.length ?? 0;
24113
- return {
24114
- content: [{ type: "text", text: configured === 0 ? this.emptyStateText() : this.noServersEnabledText() }]
24115
- };
24223
+ return { content: [{ type: "text", text: this.noUsableServersText() }], isError: true };
24116
24224
  }
24117
24225
  if (query.trim() === "") {
24118
24226
  return {
@@ -24121,7 +24229,8 @@ Cross-session reliability (dormant, <${flakyPct}% success):`);
24121
24229
  type: "text",
24122
24230
  text: 'find_tool needs a query describing what the tool should do, e.g. { "query": "create a github issue" }.'
24123
24231
  }
24124
- ]
24232
+ ],
24233
+ isError: true
24125
24234
  };
24126
24235
  }
24127
24236
  const cap = Math.max(
@@ -24339,7 +24448,10 @@ Cross-session reliability (dormant, <${flakyPct}% success):`);
24339
24448
  }
24340
24449
  if (disabled.length > 0) {
24341
24450
  lines.push(
24342
- ` disabled: ${disabled.join(", ")} (installed; enable with: yaw-mcp enable ${disabled.join(" && yaw-mcp enable ")})`
24451
+ // One command per member, comma-listed: `enable` takes a single
24452
+ // namespace, and no joiner is shell-neutral (`&&` is a parse error
24453
+ // in Windows PowerShell 5.1, `;` is not a separator in cmd.exe).
24454
+ ` disabled: ${disabled.join(", ")} (installed; enable with: ${disabled.map((ns) => `yaw-mcp enable ${ns}`).join(", ")})`
24343
24455
  );
24344
24456
  }
24345
24457
  if (blocked.length > 0) {
@@ -25713,7 +25825,7 @@ async function runShutdown(shutdown, deps) {
25713
25825
  // src/status-cmd.ts
25714
25826
  import { existsSync as existsSync8 } from "fs";
25715
25827
  import { homedir as homedir20 } from "os";
25716
- var VERSION2 = true ? "1.1.16" : "dev";
25828
+ var VERSION2 = true ? "1.1.18" : "dev";
25717
25829
  var STATUS_SCHEMA_VERSION = 1;
25718
25830
  var STATUS_USAGE = `Usage: yaw-mcp status [--json]
25719
25831
 
@@ -26656,7 +26768,7 @@ if (subcommand === "compliance") {
26656
26768
  `);
26657
26769
  process.exitCode = 0;
26658
26770
  } else if (subcommand === "--version" || subcommand === "-V") {
26659
- process.stdout.write(`yaw-mcp ${true ? "1.1.16" : "dev"}
26771
+ process.stdout.write(`yaw-mcp ${true ? "1.1.18" : "dev"}
26660
26772
  `);
26661
26773
  process.exitCode = 0;
26662
26774
  } else if (subcommand !== void 0 && !subcommand.startsWith("-")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yawlabs/mcp",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "mcpName": "io.github.YawLabs/mcp",
5
5
  "description": "MCP gateway: one local install fronts every MCP server for Claude Code, Cursor, and VS Code.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",