@yawlabs/mcp 1.0.11 → 1.0.12
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
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@yawlabs/mcp` (formerly `@yawlabs/mcph`) are documented here. This project uses [semantic versioning](https://semver.org) and a script-gated release flow: `./release.sh <version>` runs lint + typecheck + tests + build, bumps, tags, publishes to npm, and publishes `server.json` to the MCP registry.
|
|
4
4
|
|
|
5
|
+
## 1.0.12 -- `yaw-mcp secrets reset` is the way out of a forgotten vault passphrase, and `doctor` says whether the passphrase it sees unlocks the vault
|
|
6
|
+
|
|
7
|
+
Published 2026-09-23, two days after 1.0.11. Three entries below: the new `secrets reset` verb (#167), which moves the vault aside, lists its entry names and starts a new one under a new passphrase, and refuses when the passphrase it is given already opens the vault; the SECRET VAULT passphrase line in `doctor` gains its unlocks / does-not-unlock / marker-corrupt states; and under `--json` the two stderr warnings that were still prose become JSON lines.
|
|
8
|
+
|
|
9
|
+
**Added -- `yaw-mcp secrets reset`: the way out of a forgotten vault passphrase**
|
|
10
|
+
|
|
11
|
+
The vault at `~/.yaw-mcp/secrets.json` holds AES-GCM ciphertexts under a key derived from the passphrase alone (scrypt, `src/secrets-crypto.ts`); there is no server, no recovery key and no email, so a forgotten passphrase means the secrets are gone -- by design. What was not by design is that nothing said so and nothing led back to a working vault: every `secrets set` answered `wrong passphrase for this vault (decryption failed)` and exited 1, nothing pointed at the way out, and the only recovery was knowing to delete the file by hand and re-enter every secret from memory, without a list of what was in it (#167).
|
|
12
|
+
|
|
13
|
+
`yaw-mcp secrets reset` is that way back. It prints the entry names the vault holds (plaintext keys, so no passphrase is needed -- they are the list to re-enter), asks for the word `RESET` on a TTY (any case; a reflexive `y` is a no) or takes `--force` from a script, and without `--force` refuses with exit 2 when stdin or stdout is not a TTY, the way `remove` does. It moves the old file aside as `secrets.json.reset-<timestamp>` next to the vault (the ISO instant with its colons replaced by dashes, since `:` is illegal in a Windows file name; `-2`, `-3` follow if the name is taken) so a passphrase remembered later still opens it, and writes an empty vault under a new passphrase -- confirmed twice on the TTY under rotate's `New vault passphrase` labels, never the bare `Vault passphrase` an unlock prompt shows, or `YAW_MCP_VAULT_PASSPHRASE` when it is set. The new vault carries its verification marker from the start, so the passphrase chosen at reset is the one every later command verifies against; an empty vault without the marker would have accepted anything and let the next `set` establish a different one. It refuses, with the vault untouched, when the passphrase it is given already opens the vault -- whether that came from the env var (refused before RESET is asked for) or was typed from memory at the new-passphrase prompt -- because moving a working vault aside for an empty one under the same passphrase is pure loss; `rotate` and `remove` are what that user wants. When the passphrase is right and only the vault's check marker is damaged -- the state every command refuses with `verification token ("check") is corrupt` -- it refuses the same way and prints the hand-fix (delete the `check` key; the next `set` re-stamps it) rather than pointing at a `rotate` that refuses that vault too. A vault the other commands refuse as corrupt can be reset too: the names are read leniently, and when they cannot be read the output says so instead of listing nothing.
|
|
14
|
+
|
|
15
|
+
The old vault is copied aside and the new one written over it through the same atomic write every other action uses, so the vault path is never absent, a failed write leaves the old vault exactly as it was (the copy is removed, or named if it cannot be), and a symlinked vault is written through as `set` writes it rather than severed. The changed-on-disk guard the other mutating actions run before their save runs here too, after the prompts. Afterwards a running yaw-mcp server keeps the passphrase it started with and needs a restart (or its in-session prompt answered with the new one), and a `YAW_MCP_VAULT_PASSPHRASE` in a client config's `env` block still holds the old value; the command says both on stderr, as one `{"warning":"vault-reset"}` line under `--json`. `--json` reports `{ ok, path, moved_to, entries, unreadable }`, with `entries` null and `unreadable` the reason when the names could not be read. `secrets --help` and the README gain a "Forgot the passphrase?" paragraph, shell completion offers the action, and the wrong-passphrase error and the corrupt-entry hint now name `secrets reset` as the way to start over.
|
|
16
|
+
|
|
17
|
+
**Added -- `doctor` says whether the passphrase it can see unlocks the vault**
|
|
18
|
+
|
|
19
|
+
The SECRET VAULT section reported the passphrase as set or not set, so a stale or mistyped `YAW_MCP_VAULT_PASSPHRASE` -- the state the broker refuses a spawn over with "does not unlock the vault" -- read as healthy there. The line now has four states: set and unlocks the vault; set but does NOT unlock it, with the pointer at the client config's `env` block (doctor sees this shell's, which can differ) and at `secrets reset` if the passphrase is forgotten; set and right, but the vault's check marker is corrupt, so nothing opens until the `check` key is deleted by hand and the next `set` re-stamps it (never a pointer at `reset` for a vault that needs one key removed); and set but unverifiable (no readable vault, or one with no marker and no entries, which accepts any passphrase). It costs one scrypt derivation when a passphrase is set and the derived key is dropped at once; the section stays informational and the exit code does not move. `--json` gains `vault.passphraseUnlocks` (`true`, `false` or `null`) and `vault.checkMarkerCorrupt`. doctor and `reset` share one three-valued check for "is this the vault's passphrase" (`checkVaultPassphrase` in `secrets-vault.ts`: opens, marker-corrupt, wrong) and one wording of the marker hand-fix, rather than each carrying a copy of "unlock, but read the damaged-marker error as a right passphrase".
|
|
20
|
+
|
|
21
|
+
**Fixed -- under `--json`, the short-passphrase warning and the fresh-vault nudge are JSON lines**
|
|
22
|
+
|
|
23
|
+
`secrets --help` promised that stderr under `--json` is one JSON object per line, and the schema-behind notice kept it. Two lines did not: the "shorter than 12 characters" warning and the guidance printed when `set` creates the vault were prose, and the first fires at the passphrase step -- ahead of a `{"ok":false}` envelope from the changed-on-disk re-check or a failed write -- so a wrapper parsing stderr broke on a warning rather than on anything the command did. They are `{"warning":"short-passphrase",...}` and `{"warning":"vault-created",...}` lines under `--json` now, prose otherwise, and the help text lists what the warning lines cover.
|
|
24
|
+
|
|
5
25
|
## 1.0.11 -- the oam floor moves to 0.16.4, the vault passphrase is never typed into a visible field, and one slow `oam --version` no longer parks every sidecar on node
|
|
6
26
|
|
|
7
27
|
Published 2026-09-21, the day after 1.0.10, alongside oam 0.16.4. Eleven entries below: the floor moves to 0.16.4 -- the first move made by `npm run verify:oam-floor`, which now is the one thing that raises it, in place of `release.sh` mirroring whatever oam last published; the startup heal gains its off switch and reads every client config `doctor` does (the npx-cache pre-warm it replaced never ran and is removed); the in-session vault prompt moves onto a masked page served on 127.0.0.1 and the CLI refuses to prompt where echo cannot be turned off; a timed-out oam probe is retried once, the heap-cap hint stops naming a default it cannot know, and the below-floor advice says to restart a running broker. This file and the README also catch up with 1.0.3 through 1.0.10, whose headings were written here, late.
|
package/README.md
CHANGED
|
@@ -359,7 +359,7 @@ Headers are resolved through the same fail-closed path: a missing or malformed r
|
|
|
359
359
|
2. **An in-session prompt.** If your client supports MCP [elicitation](https://modelcontextprotocol.io/specification/server/elicitation), a locked vault asks for the passphrase and retries the server. The passphrase is never typed into your client's dialog: it goes into a masked field on a one-shot page yaw-mcp serves on `127.0.0.1`. A client with URL-mode elicitation opens that page from its own prompt. A client with form mode only (Claude Code, for one) asks whether to open it, and on yes yaw-mcp opens it in your default browser; with no browser to open (no graphical session), the call fails and names the env var instead. The page takes one submission and expires after 3 minutes. A mistyped passphrase gets one more try per session; a decline stops the asking. It's held in memory for that session only -- never written to disk, and never handed to the server being started.
|
|
360
360
|
3. **The CLI prompt**, for `yaw-mcp secrets` runs: no-echo on a real TTY. If the terminal will not switch echo off, the prompt refuses rather than show what you type. Note that Git Bash/MSYS can't offer one (Node sees pipes, not a TTY) -- use PowerShell, `winpty`, or the env var there.
|
|
361
361
|
|
|
362
|
-
`yaw-mcp doctor` has a **SECRET VAULT** section showing what's stored, which servers reference it, and whether
|
|
362
|
+
`yaw-mcp doctor` has a **SECRET VAULT** section showing what's stored, which servers reference it, and whether the passphrase it can see is set and unlocks the vault -- start there when a server won't load. It reports names and a yes/no, never a value.
|
|
363
363
|
|
|
364
364
|
```bash
|
|
365
365
|
yaw-mcp secrets set <name> # store a value (no-echo prompt, or --value/--stdin)
|
|
@@ -368,11 +368,14 @@ yaw-mcp secrets list # show entry NAMES only (values stay encrypted)
|
|
|
368
368
|
yaw-mcp secrets remove <name> # delete an entry
|
|
369
369
|
yaw-mcp secrets lock # forget this process's cached passphrase -- effectively a no-op from the CLI; cannot reach a running server or change the vault
|
|
370
370
|
yaw-mcp secrets rotate # re-encrypt the whole vault under a NEW passphrase
|
|
371
|
+
yaw-mcp secrets reset # forgot the passphrase? move the vault aside, list its entry names, start a new one
|
|
371
372
|
yaw-mcp secrets audit [--secret NAME] [--server NS] [--json] # who consumed which secret, when
|
|
372
373
|
```
|
|
373
374
|
|
|
374
375
|
The passphrase derives the key via scrypt and is cached in memory for one process; the on-disk file holds only ciphertext (AES-256-GCM, per-entry IV + tag, one vault salt). `rotate` decrypts every entry first and aborts untouched if any fails -- and it re-wraps the **encryption**, not the underlying tokens (a leaked token is still leaked; rotate it at its source). `audit` reads an append-only `0600` NDJSON log of secret NAME + namespace + timestamp -- never a value -- and writes fail-open so a broken log never blocks a spawn.
|
|
375
376
|
|
|
377
|
+
**Forgot the passphrase?** There is no recovery: the file holds only ciphertext under a key derived from the passphrase, and nothing else -- no server, no recovery key -- can open it. `yaw-mcp secrets reset` is the way back to a working vault. It prints the entry names the vault holds (plaintext keys, so no passphrase is needed) so you know what to set again, asks you to type `RESET` (or takes `--force` from a script; without it, no TTY means a refusal), moves the old file aside as `secrets.json.reset-<timestamp>` next to the vault -- it still opens under the old passphrase, should that turn up -- and creates an empty vault under a new passphrase, confirmed twice on a TTY or taken from `YAW_MCP_VAULT_PASSPHRASE` when it is set. It refuses when the passphrase it is given already opens the vault: that is `rotate`, not a reset. Afterwards, a yaw-mcp server that is already running keeps the passphrase it started with and needs a restart, and a `YAW_MCP_VAULT_PASSPHRASE` in a client config's `env` block still holds the old value. `yaw-mcp doctor` says whether the passphrase it can see unlocks the vault.
|
|
378
|
+
|
|
376
379
|
**Threat model.** The vault protects the on-disk file against offline brute-force after exfiltration (stolen laptop, leaked backup): useless without the passphrase, tamper-evident via GCM. It does **not** defend against a process running as you while the passphrase is cached, a keylogger, or a value already leaked at its source.
|
|
377
380
|
|
|
378
381
|
## Runtime detection & `uv` bootstrap
|
|
@@ -406,7 +409,7 @@ Common ones (run `yaw-mcp --help` for the full list):
|
|
|
406
409
|
|----------|-------------|
|
|
407
410
|
| `YAW_MCP_SERVER_CAP` | Max concurrently active servers. Default `6`; `0` disables the cap. Counts servers that are loaded and advertising tools, not upstream processes: startup pre-warm briefly spawns servers it never advertises (see `YAW_MCP_PREWARM`), so on a first session the live child count can exceed this by up to the pre-warm batch size of three, each extra child closing as soon as its tool list is read. |
|
|
408
411
|
| `YAW_MCP_MIN_COMPLIANCE` | Minimum grade (`A`-`F`) an installed server must report before `activate` loads it. |
|
|
409
|
-
| `YAW_MCP_VAULT_PASSPHRASE` | Passphrase for the local secret vault. Required for spawn-time `${secret:NAME}` substitution -- set it in yaw-mcp's own env, not the upstream server's. Clients supporting elicitation prompt for it instead. |
|
|
412
|
+
| `YAW_MCP_VAULT_PASSPHRASE` | Passphrase for the local secret vault. Required for spawn-time `${secret:NAME}` substitution -- set it in yaw-mcp's own env, not the upstream server's. Clients supporting elicitation prompt for it instead. When set, `yaw-mcp secrets reset` keys the fresh vault it creates under it. |
|
|
410
413
|
| `YAW_MCP_TRUST_PROJECT` | `1` skips the consent check on a project-local `.yaw-mcp/bundles.json` and loads it unconditionally. CI/automation only -- it lets any repo you run yaw-mcp inside spawn commands as you. Default: the file must be approved with `yaw-mcp trust`. |
|
|
411
414
|
| `YAW_MCP_AUTO_ACTIVATE` | `0` disables discover auto-loading a clearly-winning server. Default on. |
|
|
412
415
|
| `YAW_MCP_AUTO_UPGRADE` | `0` disables the background self-upgrade check at startup. Default on. |
|
|
@@ -4557,7 +4557,7 @@ async function oamFloorLines(probe) {
|
|
|
4557
4557
|
}
|
|
4558
4558
|
async function defaultRunningPrefix(argvPath) {
|
|
4559
4559
|
if (process.env.VITEST) return null;
|
|
4560
|
-
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-
|
|
4560
|
+
const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-XYB4P44U.js");
|
|
4561
4561
|
return detectRunningInstallPrefix2(argvPath);
|
|
4562
4562
|
}
|
|
4563
4563
|
async function defaultSpawn(cmd, args, cwd) {
|
|
@@ -4618,7 +4618,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4618
4618
|
if (method === "global-npm") {
|
|
4619
4619
|
const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
|
|
4620
4620
|
if (rawPrefix !== null) {
|
|
4621
|
-
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-
|
|
4621
|
+
const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-XYB4P44U.js");
|
|
4622
4622
|
const spawnForm = quoteShellArgIfNeeded2(rawPrefix, opts.platform);
|
|
4623
4623
|
const displayForm = quoteArgForDisplay2(rawPrefix, opts.platform);
|
|
4624
4624
|
if (spawnForm !== null && displayForm !== null) {
|
|
@@ -4735,7 +4735,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4735
4735
|
return { exitCode: 3, lines };
|
|
4736
4736
|
}
|
|
4737
4737
|
function readCurrentVersion() {
|
|
4738
|
-
return true ? "1.0.
|
|
4738
|
+
return true ? "1.0.12" : "dev";
|
|
4739
4739
|
}
|
|
4740
4740
|
|
|
4741
4741
|
// src/auto-upgrade.ts
|
|
@@ -5016,7 +5016,7 @@ function defaultSpawn2(cmd, args, onDone = () => {
|
|
|
5016
5016
|
}
|
|
5017
5017
|
async function maybeAutoUpgrade(deps = {}) {
|
|
5018
5018
|
if (isFeatureDisabled("YAW_MCP_AUTO_UPGRADE")) return;
|
|
5019
|
-
const current = deps.currentVersion ?? (true ? "1.0.
|
|
5019
|
+
const current = deps.currentVersion ?? (true ? "1.0.12" : "dev");
|
|
5020
5020
|
if (current === "dev") return;
|
|
5021
5021
|
const argvPath = deps.argvPath ?? process.argv[1];
|
|
5022
5022
|
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync3, ["unknown", "local-node-modules"]);
|
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
unparseableConfigFix,
|
|
102
102
|
userConfigDir,
|
|
103
103
|
yawModeOverlay
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-HRHGAT5G.js";
|
|
105
105
|
|
|
106
106
|
// src/audit-cmd.ts
|
|
107
107
|
import { homedir as homedir6 } from "os";
|
|
@@ -1688,6 +1688,7 @@ var LEGACY_SCHEMA_VERSION = 1;
|
|
|
1688
1688
|
var VAULT_CHECK_AAD = "yaw-mcp:vault-check";
|
|
1689
1689
|
var VAULT_CHECK_PLAINTEXT = "yaw-mcp-vault-v1";
|
|
1690
1690
|
var VAULT_CHECK_CORRUPT_ERROR = 'vault verification token ("check") is corrupt -- the passphrase is correct, but the check marker does not decrypt';
|
|
1691
|
+
var VAULT_WRONG_PASSPHRASE_ERROR = "wrong passphrase for this vault (decryption failed)";
|
|
1691
1692
|
function vaultPath(home = homedir4()) {
|
|
1692
1693
|
return join5(home, CONFIG_DIRNAME, SECRETS_FILENAME);
|
|
1693
1694
|
}
|
|
@@ -1848,11 +1849,11 @@ function verifyKey(vault, key) {
|
|
|
1848
1849
|
if (vault.check) {
|
|
1849
1850
|
if (checkMarkerMatches(vault, key)) return;
|
|
1850
1851
|
if (someEntryDecrypts()) throw new Error(VAULT_CHECK_CORRUPT_ERROR);
|
|
1851
|
-
throw new Error(
|
|
1852
|
+
throw new Error(VAULT_WRONG_PASSPHRASE_ERROR);
|
|
1852
1853
|
}
|
|
1853
1854
|
if (entries.length === 0) return;
|
|
1854
1855
|
if (someEntryDecrypts()) return;
|
|
1855
|
-
throw new Error(
|
|
1856
|
+
throw new Error(VAULT_WRONG_PASSPHRASE_ERROR);
|
|
1856
1857
|
}
|
|
1857
1858
|
function checkMarkerMatches(vault, key) {
|
|
1858
1859
|
if (!vault.check) return false;
|
|
@@ -1866,6 +1867,30 @@ function ensureCheck(vault, key) {
|
|
|
1866
1867
|
if (vault.check) return vault;
|
|
1867
1868
|
return { ...vault, check: encryptEntry(VAULT_CHECK_PLAINTEXT, key, VAULT_CHECK_AAD) };
|
|
1868
1869
|
}
|
|
1870
|
+
function vaultVerifiesPassphrases(vault) {
|
|
1871
|
+
return vault.check !== void 0 || Object.keys(vault.entries).length > 0;
|
|
1872
|
+
}
|
|
1873
|
+
async function checkVaultPassphrase(vault, passphrase) {
|
|
1874
|
+
if (passphrase.length === 0) return "wrong";
|
|
1875
|
+
try {
|
|
1876
|
+
(await unlock(vault, passphrase)).fill(0);
|
|
1877
|
+
return "opens";
|
|
1878
|
+
} catch (err) {
|
|
1879
|
+
return (err instanceof Error ? err.message : String(err)) === VAULT_CHECK_CORRUPT_ERROR ? "marker-corrupt" : "wrong";
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
function vaultCheckCorruptHint(path5) {
|
|
1883
|
+
return `Your entries are intact: delete the "check" key from ${path5} by hand and re-run -- the next \`yaw-mcp secrets set\` re-stamps it.`;
|
|
1884
|
+
}
|
|
1885
|
+
async function createEmptyVault(passphrase) {
|
|
1886
|
+
const vault = emptyVault();
|
|
1887
|
+
const key = await deriveKey(passphrase, Buffer.from(vault.salt, "base64"), DEFAULT_KDF);
|
|
1888
|
+
try {
|
|
1889
|
+
return ensureCheck(vault, key);
|
|
1890
|
+
} finally {
|
|
1891
|
+
key.fill(0);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1869
1894
|
async function rotateVault(vault, oldKey, newPassphrase) {
|
|
1870
1895
|
if (vault.check && !checkMarkerMatches(vault, oldKey)) {
|
|
1871
1896
|
throw new Error("rotate aborted: current passphrase is wrong (vault check failed to decrypt)");
|
|
@@ -3205,7 +3230,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
|
|
|
3205
3230
|
if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
|
|
3206
3231
|
if (downstreamCaps?.roots) capabilities.roots = {};
|
|
3207
3232
|
const client = new Client(
|
|
3208
|
-
{ name: "yaw-mcp", version: true ? "1.0.
|
|
3233
|
+
{ name: "yaw-mcp", version: true ? "1.0.12" : "dev" },
|
|
3209
3234
|
{ capabilities }
|
|
3210
3235
|
);
|
|
3211
3236
|
if (bridge && capabilities.elicitation) {
|
|
@@ -4787,7 +4812,7 @@ import { basename as basename2, isAbsolute, join as join9, resolve as resolve4 }
|
|
|
4787
4812
|
|
|
4788
4813
|
// src/secrets-cmd.ts
|
|
4789
4814
|
import { createHash as createHash4 } from "crypto";
|
|
4790
|
-
import { readFile as readFile8 } from "fs/promises";
|
|
4815
|
+
import { chmod as chmod5, copyFile, constants as fsConstants, readFile as readFile8, unlink } from "fs/promises";
|
|
4791
4816
|
import { homedir as homedir8 } from "os";
|
|
4792
4817
|
var SECRETS_USAGE = `Usage: yaw-mcp secrets <action> [args]
|
|
4793
4818
|
|
|
@@ -4832,6 +4857,19 @@ Actions:
|
|
|
4832
4857
|
entry name. (Every other command leaves the
|
|
4833
4858
|
file's schema as it found it, and says so on
|
|
4834
4859
|
stderr when it is behind.)
|
|
4860
|
+
reset Start the vault over when its passphrase is
|
|
4861
|
+
forgotten. Moves the existing file aside as
|
|
4862
|
+
secrets.json.reset-<timestamp>, next to it (it
|
|
4863
|
+
still opens under the old passphrase, should that
|
|
4864
|
+
turn up), prints the entry names it held (plaintext
|
|
4865
|
+
keys, so no passphrase is needed) so you know what
|
|
4866
|
+
to set again, and creates an empty vault under a
|
|
4867
|
+
NEW passphrase -- confirmed twice on a TTY, or
|
|
4868
|
+
YAW_MCP_VAULT_PASSPHRASE when it is set. Asks you
|
|
4869
|
+
to type RESET first, and refuses without --force
|
|
4870
|
+
when there is no TTY to ask on. Refuses when the
|
|
4871
|
+
passphrase it is given already opens the vault:
|
|
4872
|
+
that is \`rotate\`, not a reset.
|
|
4835
4873
|
audit [--secret NAME] [--server NS]
|
|
4836
4874
|
Show the local secret-resolution audit trail
|
|
4837
4875
|
(~/.yaw-mcp/secrets-audit.log): which secret
|
|
@@ -4846,8 +4884,9 @@ Actions:
|
|
|
4846
4884
|
Flags:
|
|
4847
4885
|
--json Machine-readable output (where applicable). stdout
|
|
4848
4886
|
carries the result envelope; stderr carries one
|
|
4849
|
-
JSON object per line: {"warning":...} lines
|
|
4850
|
-
|
|
4887
|
+
JSON object per line: {"warning":...} lines (a
|
|
4888
|
+
schema-behind file, a short passphrase, a vault
|
|
4889
|
+
just created or reset) and, on failure, the
|
|
4851
4890
|
{"ok":false,"error":...} envelope last. Key on
|
|
4852
4891
|
"warning" vs "ok", never on line position.
|
|
4853
4892
|
--value <v> Inline secret value (set only). The value sits in
|
|
@@ -4861,10 +4900,10 @@ Flags:
|
|
|
4861
4900
|
scripting-safe alternative to --value: the value
|
|
4862
4901
|
never appears in argv.
|
|
4863
4902
|
--force Skip the destructive-action confirmation
|
|
4864
|
-
(remove, and a set that overwrites an
|
|
4865
|
-
name). Required for remove
|
|
4866
|
-
is not a TTY (both ends are
|
|
4867
|
-
skips the passphrase.
|
|
4903
|
+
(remove, reset, and a set that overwrites an
|
|
4904
|
+
existing name). Required for remove and reset
|
|
4905
|
+
when stdin or stdout is not a TTY (both ends are
|
|
4906
|
+
needed to ask). NEVER skips the passphrase.
|
|
4868
4907
|
--secret <name> (audit only) Filter to one secret name.
|
|
4869
4908
|
--server <ns> (audit only) Filter to one server namespace.
|
|
4870
4909
|
|
|
@@ -4874,7 +4913,15 @@ Passphrase:
|
|
|
4874
4913
|
scrypt and is cached in memory for the lifetime of this yaw-mcp
|
|
4875
4914
|
process; the on-disk vault only ever holds ciphertext. For rotate, the
|
|
4876
4915
|
NEW passphrase comes from YAW_MCP_VAULT_PASSPHRASE_NEW (or a TTY
|
|
4877
|
-
confirm-twice prompt)
|
|
4916
|
+
confirm-twice prompt).
|
|
4917
|
+
|
|
4918
|
+
Forgot the passphrase?
|
|
4919
|
+
There is no recovery: the file holds only ciphertext under a key derived
|
|
4920
|
+
from the passphrase, and nothing else -- no server, no recovery key -- can
|
|
4921
|
+
open it. \`yaw-mcp secrets reset\` is the way back to a working vault: it
|
|
4922
|
+
moves the old file aside (kept, in case the passphrase turns up), lists
|
|
4923
|
+
the entry names you have to set again, and starts an empty vault under a
|
|
4924
|
+
new passphrase.`;
|
|
4878
4925
|
function parseSecretsArgs(argv) {
|
|
4879
4926
|
const opts = {};
|
|
4880
4927
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -4922,7 +4969,7 @@ ${SECRETS_USAGE}` };
|
|
|
4922
4969
|
${SECRETS_USAGE}` };
|
|
4923
4970
|
}
|
|
4924
4971
|
if (!opts.action) {
|
|
4925
|
-
if (a !== "set" && a !== "get" && a !== "list" && a !== "remove" && a !== "lock" && a !== "rotate" && a !== "audit") {
|
|
4972
|
+
if (a !== "set" && a !== "get" && a !== "list" && a !== "remove" && a !== "lock" && a !== "rotate" && a !== "reset" && a !== "audit") {
|
|
4926
4973
|
return { ok: false, error: `yaw-mcp secrets: unknown action "${a}"
|
|
4927
4974
|
|
|
4928
4975
|
${SECRETS_USAGE}` };
|
|
@@ -4991,7 +5038,7 @@ async function safeLoadVault(path5, io, json, action) {
|
|
|
4991
5038
|
} catch (err) {
|
|
4992
5039
|
const raw = err instanceof Error ? err.message : String(err);
|
|
4993
5040
|
const name = err instanceof VaultEntryCorruptError ? err.entryName : void 0;
|
|
4994
|
-
const msg = name ? `secret entry ${name} is corrupt, and every secrets command fails until it is gone. Delete the "${name}" key from ${path5} by hand (or
|
|
5041
|
+
const msg = name ? `secret entry ${name} is corrupt, and every secrets command fails until it is gone. Delete the "${name}" key from ${path5} by hand (or run \`yaw-mcp secrets reset\` to start the vault over -- it keeps the old file), then re-add it with \`yaw-mcp secrets set ${name}\`.` : raw;
|
|
4995
5042
|
if (json) io.err(`${JSON.stringify({ ok: false, error: msg })}
|
|
4996
5043
|
`);
|
|
4997
5044
|
else io.err(`yaw-mcp secrets${action ? ` ${action}` : ""}: ${msg}
|
|
@@ -5024,20 +5071,24 @@ function vaultUnreadableResult(io, json, action, path5, fp) {
|
|
|
5024
5071
|
`);
|
|
5025
5072
|
return { exitCode: 1 };
|
|
5026
5073
|
}
|
|
5027
|
-
async function
|
|
5074
|
+
async function trySaveVault(path5, vault) {
|
|
5028
5075
|
try {
|
|
5029
5076
|
await saveVault(path5, vault);
|
|
5030
5077
|
return null;
|
|
5031
5078
|
} catch (err) {
|
|
5032
5079
|
const e = err;
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5080
|
+
return e.code ?? (err instanceof Error ? err.message : String(err));
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
async function saveVaultOrReport(path5, vault, io, json, action) {
|
|
5084
|
+
const cause = await trySaveVault(path5, vault);
|
|
5085
|
+
if (cause === null) return null;
|
|
5086
|
+
const msg = `could not write the vault file at ${path5} (${cause}) -- nothing was saved.`;
|
|
5087
|
+
if (json) io.err(`${JSON.stringify({ ok: false, error: msg })}
|
|
5036
5088
|
`);
|
|
5037
|
-
|
|
5089
|
+
else io.err(`yaw-mcp secrets${action ? ` ${action}` : ""}: ${msg}
|
|
5038
5090
|
`);
|
|
5039
|
-
|
|
5040
|
-
}
|
|
5091
|
+
return { exitCode: 1 };
|
|
5041
5092
|
}
|
|
5042
5093
|
function vaultChangedResult(io, json, action) {
|
|
5043
5094
|
const msg = "the vault changed on disk while this command was waiting for input -- nothing was written. Re-run to work from the current vault.";
|
|
@@ -5049,8 +5100,13 @@ function vaultChangedResult(io, json, action) {
|
|
|
5049
5100
|
}
|
|
5050
5101
|
function unlockErrorMessage(err, path5) {
|
|
5051
5102
|
const msg = err instanceof Error ? err.message : String(err);
|
|
5052
|
-
if (msg
|
|
5053
|
-
|
|
5103
|
+
if (msg === VAULT_CHECK_CORRUPT_ERROR) {
|
|
5104
|
+
return `${msg}. ${vaultCheckCorruptHint(path5)}`;
|
|
5105
|
+
}
|
|
5106
|
+
if (msg === VAULT_WRONG_PASSPHRASE_ERROR) {
|
|
5107
|
+
return `${msg}. If it is forgotten, \`yaw-mcp secrets reset\` moves this vault aside and starts a new one (the old file is kept).`;
|
|
5108
|
+
}
|
|
5109
|
+
return msg;
|
|
5054
5110
|
}
|
|
5055
5111
|
var CANCELLED = /* @__PURE__ */ Symbol("yaw-mcp:passphrase-cancelled");
|
|
5056
5112
|
function cancelledResult(io, json) {
|
|
@@ -5100,15 +5156,39 @@ async function promptYesNo(opts, question) {
|
|
|
5100
5156
|
const a = answer.trim().toLowerCase();
|
|
5101
5157
|
return a === "y" || a === "yes";
|
|
5102
5158
|
}
|
|
5103
|
-
function warnIfShortPassphrase(io, passphrase, subject, hint) {
|
|
5159
|
+
function warnIfShortPassphrase(io, json, passphrase, subject, hint) {
|
|
5104
5160
|
if (passphrase.length >= MIN_PASSPHRASE_WARN_LEN) return;
|
|
5161
|
+
if (json) {
|
|
5162
|
+
io.err(
|
|
5163
|
+
`${JSON.stringify({
|
|
5164
|
+
warning: "short-passphrase",
|
|
5165
|
+
subject,
|
|
5166
|
+
min_length: MIN_PASSPHRASE_WARN_LEN,
|
|
5167
|
+
...hint ? { hint } : {}
|
|
5168
|
+
})}
|
|
5169
|
+
`
|
|
5170
|
+
);
|
|
5171
|
+
return;
|
|
5172
|
+
}
|
|
5105
5173
|
io.err(
|
|
5106
5174
|
`yaw-mcp secrets: warning -- ${subject} is shorter than ${MIN_PASSPHRASE_WARN_LEN} characters; consider a longer passphrase.${hint ? ` ${hint}` : ""}
|
|
5107
5175
|
`
|
|
5108
5176
|
);
|
|
5109
5177
|
}
|
|
5110
|
-
function freshVaultNudge(io, path5) {
|
|
5178
|
+
function freshVaultNudge(io, path5, json) {
|
|
5111
5179
|
const envSet = (process.env.YAW_MCP_VAULT_PASSPHRASE ?? "").length > 0;
|
|
5180
|
+
if (json) {
|
|
5181
|
+
io.err(
|
|
5182
|
+
`${JSON.stringify({
|
|
5183
|
+
warning: "vault-created",
|
|
5184
|
+
path: path5,
|
|
5185
|
+
env_set_here: envSet,
|
|
5186
|
+
hint: envSet ? "YAW_MCP_VAULT_PASSPHRASE is set in this shell; the yaw-mcp your MCP client launches has its own environment -- set it there too. `yaw-mcp doctor` reports whether it is set." : "set YAW_MCP_VAULT_PASSPHRASE in the environment your MCP client launches yaw-mcp from; without it a server referencing ${secret:...} asks in-session or fails to start. `yaw-mcp doctor` reports whether it is set."
|
|
5187
|
+
})}
|
|
5188
|
+
`
|
|
5189
|
+
);
|
|
5190
|
+
return;
|
|
5191
|
+
}
|
|
5112
5192
|
const lines = envSet ? [
|
|
5113
5193
|
" YAW_MCP_VAULT_PASSPHRASE is set in THIS shell, but ${secret:NAME} refs are resolved",
|
|
5114
5194
|
" by the yaw-mcp your MCP client launches, which has its own environment -- set it",
|
|
@@ -5144,40 +5224,54 @@ function schemaBehindNotice(io, vault, path5, json) {
|
|
|
5144
5224
|
`
|
|
5145
5225
|
);
|
|
5146
5226
|
}
|
|
5147
|
-
|
|
5227
|
+
var CREATE_VAULT_LABELS = {
|
|
5228
|
+
first: "Vault passphrase: ",
|
|
5229
|
+
confirm: "Confirm passphrase: ",
|
|
5230
|
+
subject: "the passphrase you chose"
|
|
5231
|
+
};
|
|
5232
|
+
var NEW_PASSPHRASE_LABELS = {
|
|
5233
|
+
first: "New vault passphrase: ",
|
|
5234
|
+
confirm: "Confirm new passphrase: ",
|
|
5235
|
+
subject: "the new passphrase"
|
|
5236
|
+
};
|
|
5237
|
+
async function promptPassphraseTwice(opts, io, labels) {
|
|
5238
|
+
const stdin = opts.io?.stdin ?? process.stdin;
|
|
5239
|
+
const stdout = opts.io?.stdout ?? process.stdout;
|
|
5240
|
+
for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
|
|
5241
|
+
const first = await readLineFromTTY(stdin, stdout, labels.first);
|
|
5242
|
+
if (first === CANCELLED || first === NO_ECHO) return first;
|
|
5243
|
+
if (first.length === 0) {
|
|
5244
|
+
stdout.write("Passphrase cannot be empty.\n");
|
|
5245
|
+
continue;
|
|
5246
|
+
}
|
|
5247
|
+
const second = await readLineFromTTY(stdin, stdout, labels.confirm);
|
|
5248
|
+
if (second === CANCELLED || second === NO_ECHO) return second;
|
|
5249
|
+
if (first === second) {
|
|
5250
|
+
warnIfShortPassphrase(io, opts.json, first, labels.subject);
|
|
5251
|
+
return first;
|
|
5252
|
+
}
|
|
5253
|
+
stdout.write("Passphrases did not match. Try again.\n");
|
|
5254
|
+
}
|
|
5255
|
+
return null;
|
|
5256
|
+
}
|
|
5257
|
+
async function resolvePassphrase(opts, io, confirm = false, labels = CREATE_VAULT_LABELS) {
|
|
5148
5258
|
if (opts.passphrase !== void 0) return opts.passphrase.length > 0 ? opts.passphrase : null;
|
|
5149
5259
|
const fromEnv = process.env.YAW_MCP_VAULT_PASSPHRASE;
|
|
5150
5260
|
if (typeof fromEnv === "string" && fromEnv.length > 0) {
|
|
5151
|
-
warnIfShortPassphrase(io, fromEnv, "YAW_MCP_VAULT_PASSPHRASE");
|
|
5261
|
+
warnIfShortPassphrase(io, opts.json, fromEnv, "YAW_MCP_VAULT_PASSPHRASE");
|
|
5152
5262
|
return fromEnv;
|
|
5153
5263
|
}
|
|
5154
5264
|
const stdin = opts.io?.stdin ?? process.stdin;
|
|
5155
5265
|
const stdout = opts.io?.stdout ?? process.stdout;
|
|
5156
5266
|
if (!isInteractiveTTY(opts)) return null;
|
|
5157
|
-
if (confirm)
|
|
5158
|
-
for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
|
|
5159
|
-
const first = await readLineFromTTY(stdin, stdout, "Vault passphrase: ");
|
|
5160
|
-
if (first === CANCELLED || first === NO_ECHO) return first;
|
|
5161
|
-
if (first.length === 0) {
|
|
5162
|
-
stdout.write("Passphrase cannot be empty.\n");
|
|
5163
|
-
continue;
|
|
5164
|
-
}
|
|
5165
|
-
const second = await readLineFromTTY(stdin, stdout, "Confirm passphrase: ");
|
|
5166
|
-
if (second === CANCELLED || second === NO_ECHO) return second;
|
|
5167
|
-
if (first === second) {
|
|
5168
|
-
warnIfShortPassphrase(io, first, "the passphrase you chose");
|
|
5169
|
-
return first;
|
|
5170
|
-
}
|
|
5171
|
-
stdout.write("Passphrases did not match. Try again.\n");
|
|
5172
|
-
}
|
|
5173
|
-
return null;
|
|
5174
|
-
}
|
|
5267
|
+
if (confirm) return promptPassphraseTwice(opts, io, labels);
|
|
5175
5268
|
for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
|
|
5176
5269
|
const entered = await readLineFromTTY(stdin, stdout);
|
|
5177
5270
|
if (entered === CANCELLED || entered === NO_ECHO) return entered;
|
|
5178
5271
|
if (entered.length > 0) {
|
|
5179
5272
|
warnIfShortPassphrase(
|
|
5180
5273
|
io,
|
|
5274
|
+
opts.json,
|
|
5181
5275
|
entered,
|
|
5182
5276
|
"the passphrase you entered",
|
|
5183
5277
|
"If it unlocks this vault, re-key it with `yaw-mcp secrets rotate`."
|
|
@@ -5192,28 +5286,11 @@ async function resolveNewPassphrase(opts, io) {
|
|
|
5192
5286
|
if (opts.newPassphrase !== void 0) return opts.newPassphrase.length > 0 ? opts.newPassphrase : null;
|
|
5193
5287
|
const fromEnv = process.env.YAW_MCP_VAULT_PASSPHRASE_NEW;
|
|
5194
5288
|
if (typeof fromEnv === "string" && fromEnv.length > 0) {
|
|
5195
|
-
warnIfShortPassphrase(io, fromEnv, "the new passphrase");
|
|
5289
|
+
warnIfShortPassphrase(io, opts.json, fromEnv, "the new passphrase");
|
|
5196
5290
|
return fromEnv;
|
|
5197
5291
|
}
|
|
5198
|
-
const stdin = opts.io?.stdin ?? process.stdin;
|
|
5199
|
-
const stdout = opts.io?.stdout ?? process.stdout;
|
|
5200
5292
|
if (!isInteractiveTTY(opts)) return null;
|
|
5201
|
-
|
|
5202
|
-
const first = await readLineFromTTY(stdin, stdout, "New vault passphrase: ");
|
|
5203
|
-
if (first === CANCELLED || first === NO_ECHO) return first;
|
|
5204
|
-
if (first.length === 0) {
|
|
5205
|
-
stdout.write("Passphrase cannot be empty.\n");
|
|
5206
|
-
continue;
|
|
5207
|
-
}
|
|
5208
|
-
const second = await readLineFromTTY(stdin, stdout, "Confirm new passphrase: ");
|
|
5209
|
-
if (second === CANCELLED || second === NO_ECHO) return second;
|
|
5210
|
-
if (first === second) {
|
|
5211
|
-
warnIfShortPassphrase(io, first, "the new passphrase");
|
|
5212
|
-
return first;
|
|
5213
|
-
}
|
|
5214
|
-
stdout.write("Passphrases did not match. Try again.\n");
|
|
5215
|
-
}
|
|
5216
|
-
return null;
|
|
5293
|
+
return promptPassphraseTwice(opts, io, NEW_PASSPHRASE_LABELS);
|
|
5217
5294
|
}
|
|
5218
5295
|
var MAX_PASSPHRASE_PROMPTS = 3;
|
|
5219
5296
|
var MIN_PASSPHRASE_WARN_LEN = 12;
|
|
@@ -5351,6 +5428,9 @@ async function runSecrets(opts, io = {
|
|
|
5351
5428
|
if (opts.action === "rotate") {
|
|
5352
5429
|
return await runSecretsRotate(opts, io);
|
|
5353
5430
|
}
|
|
5431
|
+
if (opts.action === "reset") {
|
|
5432
|
+
return await runSecretsReset(opts, io);
|
|
5433
|
+
}
|
|
5354
5434
|
if (opts.action === "audit") {
|
|
5355
5435
|
return await runSecretsAudit(opts, io);
|
|
5356
5436
|
}
|
|
@@ -5499,7 +5579,7 @@ async function runSecrets(opts, io = {
|
|
|
5499
5579
|
`);
|
|
5500
5580
|
else io.out(`${isFresh ? "Created vault and " : ""}Stored secret "${name}".
|
|
5501
5581
|
`);
|
|
5502
|
-
if (isFresh) freshVaultNudge(io, path5);
|
|
5582
|
+
if (isFresh) freshVaultNudge(io, path5, opts.json);
|
|
5503
5583
|
return { exitCode: 0 };
|
|
5504
5584
|
}
|
|
5505
5585
|
if (opts.action === "get") {
|
|
@@ -5647,6 +5727,221 @@ async function runSecretsRotate(opts, io) {
|
|
|
5647
5727
|
}
|
|
5648
5728
|
return { exitCode: 0 };
|
|
5649
5729
|
}
|
|
5730
|
+
function resetBackupPath(path5, at, attempt = 1) {
|
|
5731
|
+
return `${path5}.reset-${at.toISOString().replace(/:/g, "-")}${attempt > 1 ? `-${attempt}` : ""}`;
|
|
5732
|
+
}
|
|
5733
|
+
async function readVaultEntryNames(path5) {
|
|
5734
|
+
let raw;
|
|
5735
|
+
try {
|
|
5736
|
+
raw = await readFile8(path5, "utf8");
|
|
5737
|
+
} catch (err) {
|
|
5738
|
+
const e = err;
|
|
5739
|
+
return { unreadable: e.code ?? (err instanceof Error ? err.message : String(err)) };
|
|
5740
|
+
}
|
|
5741
|
+
let parsed;
|
|
5742
|
+
try {
|
|
5743
|
+
parsed = JSON.parse(raw);
|
|
5744
|
+
} catch (err) {
|
|
5745
|
+
return { unreadable: `not valid JSON: ${err instanceof Error ? err.message : String(err)}` };
|
|
5746
|
+
}
|
|
5747
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5748
|
+
return { unreadable: "root is not a JSON object" };
|
|
5749
|
+
}
|
|
5750
|
+
const entries = parsed.entries;
|
|
5751
|
+
if (!entries || typeof entries !== "object" || Array.isArray(entries)) {
|
|
5752
|
+
return { unreadable: '"entries" is missing or not an object' };
|
|
5753
|
+
}
|
|
5754
|
+
return { names: Object.keys(entries).sort() };
|
|
5755
|
+
}
|
|
5756
|
+
async function copyVaultAside(path5, at) {
|
|
5757
|
+
for (let attempt = 1; ; attempt++) {
|
|
5758
|
+
const target = resetBackupPath(path5, at, attempt);
|
|
5759
|
+
try {
|
|
5760
|
+
await copyFile(path5, target, fsConstants.COPYFILE_EXCL);
|
|
5761
|
+
} catch (err) {
|
|
5762
|
+
if (err.code === "EEXIST" && attempt < 100) continue;
|
|
5763
|
+
throw err;
|
|
5764
|
+
}
|
|
5765
|
+
if (process.platform !== "win32") await chmod5(target, 384).catch(() => void 0);
|
|
5766
|
+
return target;
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
var RESET_ALTERNATIVES = "To change the passphrase of a vault that opens, use `yaw-mcp secrets rotate`; to drop an entry from it, `yaw-mcp secrets remove <name>`.";
|
|
5770
|
+
function alreadyOpensMessage(verdict, subject, path5) {
|
|
5771
|
+
if (verdict === "marker-corrupt") {
|
|
5772
|
+
return `${subject} is this vault's passphrase; it is the check marker in ${path5} that is corrupt -- nothing to reset, and the vault was not touched. ${vaultCheckCorruptHint(path5)}`;
|
|
5773
|
+
}
|
|
5774
|
+
return `${subject} already opens the vault at ${path5} -- nothing to reset, and the vault was not touched. ${RESET_ALTERNATIVES}`;
|
|
5775
|
+
}
|
|
5776
|
+
function resetPreamble(path5, backup, names, envKeyed) {
|
|
5777
|
+
const lines = [];
|
|
5778
|
+
if ("names" in names) {
|
|
5779
|
+
const n = names.names.length;
|
|
5780
|
+
lines.push(
|
|
5781
|
+
n === 0 ? `The vault at ${path5} has no entries.` : `The vault at ${path5} holds ${n} ${n === 1 ? "entry" : "entries"}: ${names.names.join(", ")}`
|
|
5782
|
+
);
|
|
5783
|
+
} else {
|
|
5784
|
+
lines.push(`The vault at ${path5} could not be read (${names.unreadable}).`);
|
|
5785
|
+
}
|
|
5786
|
+
lines.push(`It will be moved to ${backup} -- it still opens under its old passphrase, should that turn up --`);
|
|
5787
|
+
lines.push("and an empty vault will be started in its place. Every entry has to be set again.");
|
|
5788
|
+
lines.push(
|
|
5789
|
+
envKeyed ? "The new vault will be keyed under the passphrase in YAW_MCP_VAULT_PASSPHRASE (set in this shell)." : "You will be asked to choose the new vault's passphrase next."
|
|
5790
|
+
);
|
|
5791
|
+
return `${lines.join("\n")}
|
|
5792
|
+
`;
|
|
5793
|
+
}
|
|
5794
|
+
function resetVaultNudge(io, path5, json, envKeyed) {
|
|
5795
|
+
if (json) {
|
|
5796
|
+
io.err(
|
|
5797
|
+
`${JSON.stringify({
|
|
5798
|
+
warning: "vault-reset",
|
|
5799
|
+
path: path5,
|
|
5800
|
+
passphrase_source: envKeyed ? "env" : "prompt",
|
|
5801
|
+
hint: "A running yaw-mcp server keeps the passphrase it started with -- restart it (restart your MCP client) to use the new vault, and update YAW_MCP_VAULT_PASSPHRASE in any client config `env` block that carries the old value. `yaw-mcp doctor` reports whether the passphrase it sees unlocks the vault."
|
|
5802
|
+
})}
|
|
5803
|
+
`
|
|
5804
|
+
);
|
|
5805
|
+
return;
|
|
5806
|
+
}
|
|
5807
|
+
const lines = [
|
|
5808
|
+
" A yaw-mcp server that is already running keeps the passphrase it started with and will not",
|
|
5809
|
+
" open the new vault with it: restart it (restart your MCP client), or answer its in-session",
|
|
5810
|
+
" prompt with the new passphrase if it offers one.",
|
|
5811
|
+
envKeyed ? " The new vault is keyed under YAW_MCP_VAULT_PASSPHRASE as set in THIS shell; a client config" : " A YAW_MCP_VAULT_PASSPHRASE in the `env` block of a client config still holds the OLD",
|
|
5812
|
+
envKeyed ? " whose `env` block carries a different value still holds the OLD passphrase -- update it." : " passphrase -- update it to the new one.",
|
|
5813
|
+
" `yaw-mcp doctor` reports whether the passphrase it can see unlocks the vault."
|
|
5814
|
+
];
|
|
5815
|
+
io.err(`yaw-mcp secrets: the vault at ${path5} was reset.
|
|
5816
|
+
${lines.join("\n")}
|
|
5817
|
+
`);
|
|
5818
|
+
}
|
|
5819
|
+
async function runSecretsReset(opts, io) {
|
|
5820
|
+
const home = opts.home ?? homedir8();
|
|
5821
|
+
const path5 = vaultPath(home);
|
|
5822
|
+
const json = opts.json;
|
|
5823
|
+
const fail = (msg, exitCode = 1) => {
|
|
5824
|
+
if (json) io.err(`${JSON.stringify({ ok: false, error: msg })}
|
|
5825
|
+
`);
|
|
5826
|
+
else io.err(`yaw-mcp secrets reset: ${msg}
|
|
5827
|
+
`);
|
|
5828
|
+
return { exitCode };
|
|
5829
|
+
};
|
|
5830
|
+
const baseline = await vaultFingerprint(path5);
|
|
5831
|
+
if (isVaultUnreadable(baseline)) return vaultUnreadableResult(io, json, "reset", path5, baseline);
|
|
5832
|
+
if (baseline === null) {
|
|
5833
|
+
return fail(`No vault at ${path5} to reset. Run \`yaw-mcp secrets set <name>\` to create one.`);
|
|
5834
|
+
}
|
|
5835
|
+
const names = await readVaultEntryNames(path5);
|
|
5836
|
+
let vault = null;
|
|
5837
|
+
if ("names" in names) {
|
|
5838
|
+
try {
|
|
5839
|
+
vault = await loadVault(path5);
|
|
5840
|
+
} catch {
|
|
5841
|
+
vault = null;
|
|
5842
|
+
}
|
|
5843
|
+
}
|
|
5844
|
+
const guardable = vault !== null && vaultVerifiesPassphrases(vault);
|
|
5845
|
+
const scripted = opts.passphrase ?? process.env.YAW_MCP_VAULT_PASSPHRASE ?? "";
|
|
5846
|
+
if (guardable && vault !== null && scripted.length > 0) {
|
|
5847
|
+
const verdict = await checkVaultPassphrase(vault, scripted);
|
|
5848
|
+
lock();
|
|
5849
|
+
if (verdict !== "wrong") return fail(alreadyOpensMessage(verdict, "YAW_MCP_VAULT_PASSPHRASE", path5));
|
|
5850
|
+
}
|
|
5851
|
+
const at = /* @__PURE__ */ new Date();
|
|
5852
|
+
const envKeyed = opts.passphrase === void 0 && (process.env.YAW_MCP_VAULT_PASSPHRASE ?? "").length > 0;
|
|
5853
|
+
if (!opts.force) {
|
|
5854
|
+
if (isInteractiveTTY(opts)) {
|
|
5855
|
+
const stdin = opts.io?.stdin ?? process.stdin;
|
|
5856
|
+
const stdout = opts.io?.stdout ?? process.stdout;
|
|
5857
|
+
stdout.write(resetPreamble(path5, resetBackupPath(path5, at), names, envKeyed));
|
|
5858
|
+
const answer = await readLineFromTTY(stdin, stdout, "Type RESET to continue: ", true);
|
|
5859
|
+
if (answer === CANCELLED) return cancelledResult(io, json);
|
|
5860
|
+
if (answer.trim().toLowerCase() !== "reset") return abortedResult(io, json, "reset");
|
|
5861
|
+
} else {
|
|
5862
|
+
const msg = `refusing to reset the vault without confirmation and ${nonTTYEnds(opts)}.`;
|
|
5863
|
+
const hint = "Re-run with --force to reset it. The old vault is moved aside, not deleted, and every entry has to be set again.";
|
|
5864
|
+
if (json) io.err(`${JSON.stringify({ ok: false, error: `${msg} ${hint}` })}
|
|
5865
|
+
`);
|
|
5866
|
+
else io.err(`yaw-mcp secrets reset: ${msg}
|
|
5867
|
+
${hint}
|
|
5868
|
+
`);
|
|
5869
|
+
return { exitCode: 2 };
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5872
|
+
const passphrase = await resolvePassphrase(opts, io, true, NEW_PASSPHRASE_LABELS);
|
|
5873
|
+
if (passphrase === CANCELLED) return cancelledResult(io, json);
|
|
5874
|
+
if (passphrase === NO_ECHO) {
|
|
5875
|
+
return fail(noEchoRefusal("New passphrase required.", "Set YAW_MCP_VAULT_PASSPHRASE instead."));
|
|
5876
|
+
}
|
|
5877
|
+
if (passphrase === null) {
|
|
5878
|
+
return fail(
|
|
5879
|
+
promptUnavailableMessage(opts, "New passphrase required (and must be confirmed).", "YAW_MCP_VAULT_PASSPHRASE")
|
|
5880
|
+
);
|
|
5881
|
+
}
|
|
5882
|
+
if (guardable && vault !== null && scripted.length === 0) {
|
|
5883
|
+
const verdict = await checkVaultPassphrase(vault, passphrase);
|
|
5884
|
+
lock();
|
|
5885
|
+
if (verdict !== "wrong") return fail(alreadyOpensMessage(verdict, "that passphrase", path5));
|
|
5886
|
+
}
|
|
5887
|
+
let fresh;
|
|
5888
|
+
try {
|
|
5889
|
+
fresh = await createEmptyVault(passphrase);
|
|
5890
|
+
} catch (err) {
|
|
5891
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5892
|
+
return fail(`could not derive the new vault's key (${msg}) -- nothing was changed.`);
|
|
5893
|
+
}
|
|
5894
|
+
if (await vaultChangedSinceLoad(path5, baseline)) return vaultChangedResult(io, json, "reset");
|
|
5895
|
+
let movedTo;
|
|
5896
|
+
try {
|
|
5897
|
+
movedTo = await copyVaultAside(path5, at);
|
|
5898
|
+
} catch (err) {
|
|
5899
|
+
const e = err;
|
|
5900
|
+
const cause2 = e.code ?? (err instanceof Error ? err.message : String(err));
|
|
5901
|
+
return fail(`could not copy the vault aside next to ${path5} (${cause2}) -- nothing was changed.`);
|
|
5902
|
+
}
|
|
5903
|
+
const cause = await trySaveVault(path5, fresh);
|
|
5904
|
+
if (cause !== null) {
|
|
5905
|
+
const stray = await unlink(movedTo).then(
|
|
5906
|
+
() => "",
|
|
5907
|
+
() => ` A copy of it was left at ${movedTo}.`
|
|
5908
|
+
);
|
|
5909
|
+
return fail(`could not write the new vault at ${path5} (${cause}) -- the old vault is untouched.${stray}`);
|
|
5910
|
+
}
|
|
5911
|
+
if (json) {
|
|
5912
|
+
io.out(
|
|
5913
|
+
`${JSON.stringify({
|
|
5914
|
+
ok: true,
|
|
5915
|
+
path: path5,
|
|
5916
|
+
moved_to: movedTo,
|
|
5917
|
+
entries: "names" in names ? names.names : null,
|
|
5918
|
+
unreadable: "unreadable" in names ? names.unreadable : null
|
|
5919
|
+
})}
|
|
5920
|
+
`
|
|
5921
|
+
);
|
|
5922
|
+
} else {
|
|
5923
|
+
io.out(`Moved the old vault to ${movedTo}. It still opens under its old passphrase, should that turn up.
|
|
5924
|
+
`);
|
|
5925
|
+
io.out(
|
|
5926
|
+
`Created an empty vault at ${path5} under ${envKeyed ? "the passphrase in YAW_MCP_VAULT_PASSPHRASE" : "the new passphrase"}.
|
|
5927
|
+
`
|
|
5928
|
+
);
|
|
5929
|
+
if ("names" in names) {
|
|
5930
|
+
const n = names.names.length;
|
|
5931
|
+
if (n === 0) io.out("The old vault held no entries.\n");
|
|
5932
|
+
else {
|
|
5933
|
+
io.out(`Entries to set again (${n}): ${names.names.join(", ")}
|
|
5934
|
+
`);
|
|
5935
|
+
io.out(" yaw-mcp secrets set <name> for each\n");
|
|
5936
|
+
}
|
|
5937
|
+
} else {
|
|
5938
|
+
io.out(`Could not read the old vault's entry names (${names.unreadable}); the file is kept at ${movedTo}.
|
|
5939
|
+
`);
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
resetVaultNudge(io, path5, json, envKeyed);
|
|
5943
|
+
return { exitCode: 0 };
|
|
5944
|
+
}
|
|
5650
5945
|
async function runSecretsAudit(opts, io) {
|
|
5651
5946
|
const home = opts.home ?? homedir8();
|
|
5652
5947
|
let events;
|
|
@@ -6708,7 +7003,7 @@ var SUBCOMMAND_SPEC = [
|
|
|
6708
7003
|
{
|
|
6709
7004
|
name: "secrets",
|
|
6710
7005
|
description: "Manage stored secrets",
|
|
6711
|
-
positional: [["set", "get", "list", "remove", "lock", "rotate", "audit"], ["<name>"]],
|
|
7006
|
+
positional: [["set", "get", "list", "remove", "lock", "rotate", "reset", "audit"], ["<name>"]],
|
|
6712
7007
|
flags: ["--value", "--stdin", "--force", "--secret", "--server", "--json", "--help"]
|
|
6713
7008
|
},
|
|
6714
7009
|
// Other.
|
|
@@ -8084,7 +8379,7 @@ async function maybeRefreshSidecars(deps = {}) {
|
|
|
8084
8379
|
// src/try-cmd.ts
|
|
8085
8380
|
import { createHash as createHash5 } from "crypto";
|
|
8086
8381
|
import { existsSync as existsSync5 } from "fs";
|
|
8087
|
-
import { chmod as
|
|
8382
|
+
import { chmod as chmod6, mkdir as mkdir4, readdir, readFile as readFile12, unlink as unlink2 } from "fs/promises";
|
|
8088
8383
|
import { homedir as homedir14 } from "os";
|
|
8089
8384
|
import { join as join13, resolve as resolve6 } from "path";
|
|
8090
8385
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
@@ -10636,7 +10931,7 @@ async function runTry(opts) {
|
|
|
10636
10931
|
written.push(resolved.absolute);
|
|
10637
10932
|
if (tightenPerms) {
|
|
10638
10933
|
try {
|
|
10639
|
-
await
|
|
10934
|
+
await chmod6(resolved.absolute, 384);
|
|
10640
10935
|
} catch {
|
|
10641
10936
|
}
|
|
10642
10937
|
}
|
|
@@ -10645,7 +10940,7 @@ async function runTry(opts) {
|
|
|
10645
10940
|
if (previousRead !== null && (!peelsPrevious || previousPeelFailedWhileTrusted)) {
|
|
10646
10941
|
await atomicWriteFile(trialMarkerPath(slug, home), previousRead.raw).catch(() => void 0);
|
|
10647
10942
|
} else {
|
|
10648
|
-
await
|
|
10943
|
+
await unlink2(trialMarkerPath(slug, home)).catch(() => void 0);
|
|
10649
10944
|
}
|
|
10650
10945
|
return { exitCode: 1, written: [] };
|
|
10651
10946
|
}
|
|
@@ -10777,7 +11072,7 @@ async function runTryCleanup(opts) {
|
|
|
10777
11072
|
);
|
|
10778
11073
|
}
|
|
10779
11074
|
try {
|
|
10780
|
-
await
|
|
11075
|
+
await unlink2(markerPath);
|
|
10781
11076
|
} catch (e) {
|
|
10782
11077
|
printErr(`yaw-mcp try-cleanup: couldn't delete marker ${markerPath} (${e.message}).`);
|
|
10783
11078
|
return { exitCode: 1, written: [] };
|
|
@@ -10856,7 +11151,7 @@ async function gcExpiredTrials(opts) {
|
|
|
10856
11151
|
stage = "replaced";
|
|
10857
11152
|
let markerRemoved = true;
|
|
10858
11153
|
try {
|
|
10859
|
-
await
|
|
11154
|
+
await unlink2(path5);
|
|
10860
11155
|
} catch {
|
|
10861
11156
|
markerRemoved = false;
|
|
10862
11157
|
}
|
|
@@ -10876,7 +11171,7 @@ async function gcExpiredTrials(opts) {
|
|
|
10876
11171
|
throw new Error(`${marker.clientPath} is not a JSON object`);
|
|
10877
11172
|
}
|
|
10878
11173
|
stage = "unlink";
|
|
10879
|
-
await
|
|
11174
|
+
await unlink2(path5);
|
|
10880
11175
|
cleared++;
|
|
10881
11176
|
} catch (e) {
|
|
10882
11177
|
const error = e.message;
|
|
@@ -11141,7 +11436,7 @@ function foldBundleWarnings(warnings, probe) {
|
|
|
11141
11436
|
const prefix = `${probe.path}:`;
|
|
11142
11437
|
return warnings.filter((w) => !w.startsWith(prefix));
|
|
11143
11438
|
}
|
|
11144
|
-
var VERSION = true ? "1.0.
|
|
11439
|
+
var VERSION = true ? "1.0.12" : "dev";
|
|
11145
11440
|
var DOCTOR_USAGE = `Usage: yaw-mcp doctor [--json]
|
|
11146
11441
|
|
|
11147
11442
|
Print a diagnostic of your yaw-mcp setup.
|
|
@@ -11624,15 +11919,25 @@ async function collectVaultStatus(opts) {
|
|
|
11624
11919
|
let entries = exists2 ? null : [];
|
|
11625
11920
|
let unreadable = null;
|
|
11626
11921
|
let schemaVersion = null;
|
|
11922
|
+
let vault = null;
|
|
11627
11923
|
if (exists2) {
|
|
11628
11924
|
try {
|
|
11629
|
-
|
|
11925
|
+
vault = await loadVault(path5);
|
|
11630
11926
|
entries = vault ? listKeys(vault) : [];
|
|
11631
11927
|
schemaVersion = vault ? vault.version : null;
|
|
11632
11928
|
} catch (err) {
|
|
11633
11929
|
unreadable = err instanceof Error ? err.message : String(err);
|
|
11634
11930
|
}
|
|
11635
11931
|
}
|
|
11932
|
+
const passphrase = opts.env.YAW_MCP_VAULT_PASSPHRASE ?? "";
|
|
11933
|
+
let passphraseUnlocks = null;
|
|
11934
|
+
let checkMarkerCorrupt = false;
|
|
11935
|
+
if (passphrase !== "" && vault !== null && vaultVerifiesPassphrases(vault)) {
|
|
11936
|
+
const verdict = await checkVaultPassphrase(vault, passphrase);
|
|
11937
|
+
lock();
|
|
11938
|
+
passphraseUnlocks = verdict === "opens";
|
|
11939
|
+
checkMarkerCorrupt = verdict === "marker-corrupt";
|
|
11940
|
+
}
|
|
11636
11941
|
const refs = [];
|
|
11637
11942
|
const malformed = [];
|
|
11638
11943
|
for (const s of opts.servers) {
|
|
@@ -11651,7 +11956,9 @@ async function collectVaultStatus(opts) {
|
|
|
11651
11956
|
entries,
|
|
11652
11957
|
unreadable,
|
|
11653
11958
|
schemaVersion,
|
|
11654
|
-
passphraseSet:
|
|
11959
|
+
passphraseSet: passphrase !== "",
|
|
11960
|
+
passphraseUnlocks,
|
|
11961
|
+
checkMarkerCorrupt,
|
|
11655
11962
|
refs,
|
|
11656
11963
|
malformed,
|
|
11657
11964
|
missing
|
|
@@ -11676,7 +11983,24 @@ function renderVaultSection(opts) {
|
|
|
11676
11983
|
print(` schema: v${status.schemaVersion}`);
|
|
11677
11984
|
}
|
|
11678
11985
|
}
|
|
11679
|
-
|
|
11986
|
+
if (!status.passphraseSet) {
|
|
11987
|
+
print(" passphrase: not set in this environment");
|
|
11988
|
+
} else if (status.passphraseUnlocks === true) {
|
|
11989
|
+
print(" passphrase: set in this environment, and it unlocks the vault");
|
|
11990
|
+
} else if (status.checkMarkerCorrupt) {
|
|
11991
|
+
print(" passphrase: set in this environment, and it is the vault's -- but the vault's check");
|
|
11992
|
+
print(" marker is corrupt, so nothing opens until it is repaired.");
|
|
11993
|
+
print(` ${vaultCheckCorruptHint(status.path)}`);
|
|
11994
|
+
} else if (status.passphraseUnlocks === false) {
|
|
11995
|
+
print(" passphrase: set in this environment, but it does NOT unlock the vault");
|
|
11996
|
+
print(" a server whose env references the vault fails to start or connect with it.");
|
|
11997
|
+
print(" Check the value in the `env` block of your client config (doctor sees THIS");
|
|
11998
|
+
print(" shell's, which can differ). If the passphrase is forgotten,");
|
|
11999
|
+
print(" `yaw-mcp secrets reset` moves the vault aside, lists its entry names, and");
|
|
12000
|
+
print(" starts a new one under a passphrase you choose.");
|
|
12001
|
+
} else {
|
|
12002
|
+
print(" passphrase: set in this environment");
|
|
12003
|
+
}
|
|
11680
12004
|
if (status.refs.length === 0) {
|
|
11681
12005
|
print(" refs: no server references ${secret:NAME} on the channel it uses (env local, headers remote)");
|
|
11682
12006
|
} else {
|
|
@@ -15327,7 +15651,7 @@ async function runEnableDisable(opts) {
|
|
|
15327
15651
|
|
|
15328
15652
|
// src/reset-learning-cmd.ts
|
|
15329
15653
|
import { existsSync as existsSync8 } from "fs";
|
|
15330
|
-
import { unlink as
|
|
15654
|
+
import { unlink as unlink3 } from "fs/promises";
|
|
15331
15655
|
import { homedir as homedir21 } from "os";
|
|
15332
15656
|
import { createInterface as createInterface6 } from "readline/promises";
|
|
15333
15657
|
var RESET_LEARNING_USAGE = `Usage: yaw-mcp reset-learning
|
|
@@ -15441,7 +15765,7 @@ async function runResetLearning(opts = {}) {
|
|
|
15441
15765
|
}
|
|
15442
15766
|
}
|
|
15443
15767
|
try {
|
|
15444
|
-
await
|
|
15768
|
+
await unlink3(filePath);
|
|
15445
15769
|
} catch (err) {
|
|
15446
15770
|
if (isFileNotFound(err)) {
|
|
15447
15771
|
print("yaw-mcp reset-learning: no persisted state to reset.");
|
|
@@ -18474,7 +18798,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
18474
18798
|
static SHUTDOWN_DRAIN_MS = 2e3;
|
|
18475
18799
|
constructor() {
|
|
18476
18800
|
this.server = new Server(
|
|
18477
|
-
{ name: "yaw-mcp", version: true ? "1.0.
|
|
18801
|
+
{ name: "yaw-mcp", version: true ? "1.0.12" : "dev" },
|
|
18478
18802
|
{
|
|
18479
18803
|
capabilities: {
|
|
18480
18804
|
tools: { listChanged: true },
|
|
@@ -22026,7 +22350,7 @@ function registerShutdownTriggers(shutdown, targets) {
|
|
|
22026
22350
|
// src/status-cmd.ts
|
|
22027
22351
|
import { existsSync as existsSync10 } from "fs";
|
|
22028
22352
|
import { homedir as homedir23 } from "os";
|
|
22029
|
-
var VERSION2 = true ? "1.0.
|
|
22353
|
+
var VERSION2 = true ? "1.0.12" : "dev";
|
|
22030
22354
|
var STATUS_SCHEMA_VERSION = 1;
|
|
22031
22355
|
var STATUS_USAGE = `Usage: yaw-mcp status [--json]
|
|
22032
22356
|
|
|
@@ -22504,7 +22828,7 @@ if (subcommand === "compliance") {
|
|
|
22504
22828
|
|
|
22505
22829
|
Secrets:
|
|
22506
22830
|
secrets <action> Manage the local encrypted secret vault: set,
|
|
22507
|
-
get, list, remove, lock, rotate, audit.
|
|
22831
|
+
get, list, remove, lock, rotate, reset, audit.
|
|
22508
22832
|
Reference a stored value from any server's env
|
|
22509
22833
|
as \${secret:NAME}.
|
|
22510
22834
|
|
|
@@ -22640,7 +22964,8 @@ if (subcommand === "compliance") {
|
|
|
22640
22964
|
from every child env. A client that supports
|
|
22641
22965
|
MCP elicitation prompts for it instead, for
|
|
22642
22966
|
that session only. Manage entries with
|
|
22643
|
-
\`yaw-mcp secrets
|
|
22967
|
+
\`yaw-mcp secrets\`; when it is set, \`secrets
|
|
22968
|
+
reset\` keys the fresh vault it creates under it.
|
|
22644
22969
|
YAW_MCP_VAULT_PASSPHRASE_NEW The NEW passphrase for \`yaw-mcp secrets
|
|
22645
22970
|
rotate\`, so a re-wrap can run without a TTY.
|
|
22646
22971
|
Read only by \`rotate\`; without it (and
|
|
@@ -22805,7 +23130,7 @@ if (subcommand === "compliance") {
|
|
|
22805
23130
|
`);
|
|
22806
23131
|
process.exitCode = 0;
|
|
22807
23132
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
22808
|
-
process.stdout.write(`yaw-mcp ${true ? "1.0.
|
|
23133
|
+
process.stdout.write(`yaw-mcp ${true ? "1.0.12" : "dev"}
|
|
22809
23134
|
`);
|
|
22810
23135
|
process.exitCode = 0;
|
|
22811
23136
|
} 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.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"mcpName": "io.github.YawLabs/mcp",
|
|
5
5
|
"description": "MCP gateway and orchestrator: one local install fronts every MCP server for Claude Code, Cursor, and VS Code, loading tools on demand.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|