@yawlabs/mcp 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
unparseableConfigFix,
|
|
102
102
|
userConfigDir,
|
|
103
103
|
yawModeOverlay
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-JSNVFUDY.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.13" : "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.13" : "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.");
|
|
@@ -18077,6 +18401,10 @@ function isPrewarmEnabled() {
|
|
|
18077
18401
|
}
|
|
18078
18402
|
var exposureWarnedFor = null;
|
|
18079
18403
|
var LITE_BY_DEFAULT_CLIENTS = /* @__PURE__ */ new Set(["typed-cli"]);
|
|
18404
|
+
var NO_RELIST_CLIENTS = /* @__PURE__ */ new Set(["codex-mcp-client", "continue-client"]);
|
|
18405
|
+
function clientRelistsTools(clientInfo) {
|
|
18406
|
+
return !(clientInfo?.name !== void 0 && NO_RELIST_CLIENTS.has(clientInfo.name));
|
|
18407
|
+
}
|
|
18080
18408
|
function resolveToolExposure(clientInfo) {
|
|
18081
18409
|
const fallback = clientInfo?.name !== void 0 && LITE_BY_DEFAULT_CLIENTS.has(clientInfo.name) ? "lite" : "gateway";
|
|
18082
18410
|
const raw = process.env.YAW_MCP_TOOL_EXPOSURE?.trim().toLowerCase();
|
|
@@ -18252,6 +18580,14 @@ var ConnectServer = class _ConnectServer {
|
|
|
18252
18580
|
* would see an unchanged file and skip the reconcile that never finished,
|
|
18253
18581
|
* leaving a connection running on config the user has already replaced. */
|
|
18254
18582
|
bundlesReconcilePending = false;
|
|
18583
|
+
/** The startup pre-warm while it is still running, else null. find_tool
|
|
18584
|
+
* and exec read only LEARNED tool lists, and on a fresh install the
|
|
18585
|
+
* pre-warm is what learns them -- fire-and-forget from `oninitialized`,
|
|
18586
|
+
* so a first call can land before it: find_tool said "No configured
|
|
18587
|
+
* server has a tool matching" a configured server's tool, and exec said
|
|
18588
|
+
* "Unknown tool". Both now wait for this (bounded, STARTUP_PREWARM_WAIT_MS)
|
|
18589
|
+
* when the answer would otherwise be "nothing". */
|
|
18590
|
+
startupPrewarm = null;
|
|
18255
18591
|
toolRoutes = /* @__PURE__ */ new Map();
|
|
18256
18592
|
resourceRoutes = /* @__PURE__ */ new Map();
|
|
18257
18593
|
promptRoutes = /* @__PURE__ */ new Map();
|
|
@@ -18365,6 +18701,22 @@ var ConnectServer = class _ConnectServer {
|
|
|
18365
18701
|
// the child's own secrets. Bounds the re-ask that replaced the old
|
|
18366
18702
|
// "already elicited, never ask again" latch -- see MAX_CREDENTIAL_PROMPTS.
|
|
18367
18703
|
credentialPrompts = /* @__PURE__ */ new Map();
|
|
18704
|
+
// Latch: namespaces whose prompt has ended the asking for the session,
|
|
18705
|
+
// keyed by the REASON so a follow-up activate can surface the right
|
|
18706
|
+
// refusal. The vault uses a single boolean (`vaultPassphraseElicited`)
|
|
18707
|
+
// and the same shaped message regardless of why; here, "decline" and
|
|
18708
|
+
// "empty submission" are user decisions (return the raw spawn error,
|
|
18709
|
+
// the user knows what they did) while "no-page" / "no-browser" are
|
|
18710
|
+
// wall-shaped failures a follow-up activate would hit identically, and
|
|
18711
|
+
// the user still needs the bundles.json hint on every attempt.
|
|
18712
|
+
//
|
|
18713
|
+
// Follow-up: the vault has `clearSessionVaultPassphrase` for an external
|
|
18714
|
+
// caller (the `yaw-mcp secrets reset` CLI verb) to clear the latch
|
|
18715
|
+
// WITHOUT a process restart. There is no equivalent here today -- a
|
|
18716
|
+
// namespace that latches a no-browser stays latched until shutdown.
|
|
18717
|
+
// Not worth building until a verb that needs it (e.g. a per-server
|
|
18718
|
+
// "forget I asked") actually lands.
|
|
18719
|
+
credentialElicited = /* @__PURE__ */ new Map();
|
|
18368
18720
|
// In-flight activation promises, keyed by namespace. Dedupes
|
|
18369
18721
|
// concurrent activation attempts for the same namespace so that two
|
|
18370
18722
|
// tool calls landing on a disconnected upstream don't each spawn
|
|
@@ -18474,7 +18826,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
18474
18826
|
static SHUTDOWN_DRAIN_MS = 2e3;
|
|
18475
18827
|
constructor() {
|
|
18476
18828
|
this.server = new Server(
|
|
18477
|
-
{ name: "yaw-mcp", version: true ? "1.0.
|
|
18829
|
+
{ name: "yaw-mcp", version: true ? "1.0.13" : "dev" },
|
|
18478
18830
|
{
|
|
18479
18831
|
capabilities: {
|
|
18480
18832
|
tools: { listChanged: true },
|
|
@@ -18600,6 +18952,63 @@ var ConnectServer = class _ConnectServer {
|
|
|
18600
18952
|
});
|
|
18601
18953
|
});
|
|
18602
18954
|
};
|
|
18955
|
+
/** Wait for the startup pre-warm, if it is still running, for at most
|
|
18956
|
+
* STARTUP_PREWARM_WAIT_MS, or until `signal` aborts. Resolves either way:
|
|
18957
|
+
* past the bound the caller answers from what is known, exactly as it did
|
|
18958
|
+
* before this existed, and on an abort the caller checks the signal. */
|
|
18959
|
+
async settleStartupPrewarm(signal) {
|
|
18960
|
+
const pending2 = this.startupPrewarm;
|
|
18961
|
+
if (!pending2 || signal?.aborted) return;
|
|
18962
|
+
let timer;
|
|
18963
|
+
let onAbort;
|
|
18964
|
+
const bound = new Promise((resolve8) => {
|
|
18965
|
+
timer = setTimeout(resolve8, _ConnectServer.STARTUP_PREWARM_WAIT_MS);
|
|
18966
|
+
timer.unref?.();
|
|
18967
|
+
onAbort = () => resolve8();
|
|
18968
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
18969
|
+
});
|
|
18970
|
+
try {
|
|
18971
|
+
await Promise.race([pending2, bound]);
|
|
18972
|
+
} finally {
|
|
18973
|
+
clearTimeout(timer);
|
|
18974
|
+
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
18975
|
+
}
|
|
18976
|
+
}
|
|
18977
|
+
/** How long find_tool / exec wait on a still-running startup pre-warm.
|
|
18978
|
+
* Measured on a loaded Windows ARM64 box, a fresh install's pre-warm of
|
|
18979
|
+
* two npx/oam servers finished 4-6 s after initialize; this leaves room
|
|
18980
|
+
* for a larger bundle without holding a call anywhere near a client's
|
|
18981
|
+
* tool timeout (Codex: 300 s). Not readonly, so a test can shrink it. */
|
|
18982
|
+
static STARTUP_PREWARM_WAIT_MS = 2e4;
|
|
18983
|
+
/** The line a load reply needs for a client that never re-lists tools
|
|
18984
|
+
* (NO_RELIST_CLIENTS), or null for every other client.
|
|
18985
|
+
*
|
|
18986
|
+
* The reply above it enumerates the tools just loaded as if they were now
|
|
18987
|
+
* callable, which is true for a client that re-lists and false for this
|
|
18988
|
+
* one: its tool list is the startup one, so the model's direct call fails
|
|
18989
|
+
* inside the client. The example names a tool that is really reachable --
|
|
18990
|
+
* a served, not shadowed, tool of the first namespace that loaded -- and,
|
|
18991
|
+
* where the server has one, a tool that needs no arguments (read-only
|
|
18992
|
+
* first), so `args: {}` runs as written. When every tool needs arguments
|
|
18993
|
+
* the line says to fill them in rather than show a call that would fail. */
|
|
18994
|
+
execHintForNonRelistingClient(loaded) {
|
|
18995
|
+
if (clientRelistsTools(this.server.getClientVersion())) return null;
|
|
18996
|
+
const needsNoArgs = (t) => {
|
|
18997
|
+
const required = t.inputSchema?.required;
|
|
18998
|
+
return !Array.isArray(required) || required.length === 0;
|
|
18999
|
+
};
|
|
19000
|
+
for (const ns of loaded) {
|
|
19001
|
+
const conn = this.connections.get(ns);
|
|
19002
|
+
if (!conn) continue;
|
|
19003
|
+
const served = this.splitShadowedTools(ns, conn.tools).served;
|
|
19004
|
+
const example = served.find((t) => needsNoArgs(t) && t.annotations?.readOnlyHint === true) ?? served.find(needsNoArgs) ?? served[0];
|
|
19005
|
+
if (example === void 0) continue;
|
|
19006
|
+
const call = JSON.stringify({ steps: [{ tool: example.namespacedName, args: {} }] });
|
|
19007
|
+
const fill = needsNoArgs(example) ? "" : ` (with the tool's own arguments in "args"; mcp_connect_read_tool shows a tool's arguments)`;
|
|
19008
|
+
return `This client keeps the tool list it read at startup, so the tools just loaded are not in it and a direct call to one fails. Call them through mcp_connect_exec instead, e.g. ${call}${fill}`;
|
|
19009
|
+
}
|
|
19010
|
+
return null;
|
|
19011
|
+
}
|
|
18603
19012
|
rebuildRoutes() {
|
|
18604
19013
|
this.toolRoutes = buildToolRoutes(this.connections, this.getDeferredServers());
|
|
18605
19014
|
this.resourceRoutes = buildResourceRoutes(this.connections);
|
|
@@ -19083,12 +19492,16 @@ var ConnectServer = class _ConnectServer {
|
|
|
19083
19492
|
serverCount: this.config?.servers.length ?? 0
|
|
19084
19493
|
});
|
|
19085
19494
|
await this.hydrateComplianceGrades();
|
|
19495
|
+
this.rebuildRoutes();
|
|
19086
19496
|
if (this.getProfiledActiveServers().some((s) => s.command !== void 0 && uvLaunchKind(s.command) !== null)) {
|
|
19087
19497
|
ensureUv().catch((err) => log("warn", "uv prewarm failed", { error: err?.message }));
|
|
19088
19498
|
}
|
|
19089
19499
|
const transport = new StdioServerTransport();
|
|
19090
19500
|
this.server.oninitialized = () => {
|
|
19091
|
-
this.prewarmDormantServers().catch((err) => log("warn", "Pre-warm failed", { error: err?.message }))
|
|
19501
|
+
const prewarm = this.prewarmDormantServers().catch((err) => log("warn", "Pre-warm failed", { error: err?.message })).finally(() => {
|
|
19502
|
+
if (this.startupPrewarm === prewarm) this.startupPrewarm = null;
|
|
19503
|
+
});
|
|
19504
|
+
this.startupPrewarm = prewarm;
|
|
19092
19505
|
if (isAutoLoadEnabled()) {
|
|
19093
19506
|
if (this.persistenceReady) {
|
|
19094
19507
|
this.autoLoadRecurringPack().catch((err) => log("warn", "Auto-load failed", { error: err?.message }));
|
|
@@ -19333,7 +19746,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
19333
19746
|
if (name === META_TOOLS.findTool.name) {
|
|
19334
19747
|
const q = typeof args.query === "string" ? args.query : "";
|
|
19335
19748
|
const limit = typeof args.limit === "number" && Number.isFinite(args.limit) ? args.limit : void 0;
|
|
19336
|
-
return this.observed(this.attachGuideNudge(this.handleFindTool(q, limit)));
|
|
19749
|
+
return this.observed(this.attachGuideNudge(await this.handleFindTool(q, limit)));
|
|
19337
19750
|
}
|
|
19338
19751
|
if (name === META_TOOLS.exec.name) {
|
|
19339
19752
|
const result2 = await this.handleExec(args, extra?.signal);
|
|
@@ -19838,7 +20251,10 @@ var ConnectServer = class _ConnectServer {
|
|
|
19838
20251
|
return { content: [{ type: "text", text: this.emptyStateText() }] };
|
|
19839
20252
|
}
|
|
19840
20253
|
const allProfiled = this.getProfiledActiveServers();
|
|
19841
|
-
const
|
|
20254
|
+
const warmExecHint = warmedNamespace ? this.execHintForNonRelistingClient([warmedNamespace]) : null;
|
|
20255
|
+
const warmBanner = warmedNamespace ? `Auto-loaded "${warmedNamespace}" \u2014 top match for your query.${warmExecHint ? `
|
|
20256
|
+
${warmExecHint}` : ""}` : "";
|
|
20257
|
+
const warmPrefix = warmBanner ? `${warmBanner}
|
|
19842
20258
|
|
|
19843
20259
|
` : "";
|
|
19844
20260
|
const focusMiss = (text) => ({
|
|
@@ -19895,8 +20311,8 @@ var ConnectServer = class _ConnectServer {
|
|
|
19895
20311
|
allProfiled.length === 0 ? `${this.noServersEnabledText()}
|
|
19896
20312
|
` : context ? "Servers ranked by relevance:\n" : "Installed MCP servers:\n"
|
|
19897
20313
|
);
|
|
19898
|
-
if (
|
|
19899
|
-
lines.push(
|
|
20314
|
+
if (warmBanner) {
|
|
20315
|
+
lines.push(`${warmBanner}
|
|
19900
20316
|
`);
|
|
19901
20317
|
}
|
|
19902
20318
|
const minCompliance = resolveMinCompliance();
|
|
@@ -20556,6 +20972,18 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20556
20972
|
message: `Could not load "${namespace}": it still reports ${missing.join(", ")} missing, so the values just provided were not accepted.${retryHint}`
|
|
20557
20973
|
};
|
|
20558
20974
|
}
|
|
20975
|
+
if (this.credentialElicited.has(namespace)) {
|
|
20976
|
+
const reason = this.credentialElicited.get(namespace);
|
|
20977
|
+
log("debug", "Namespace already declined or unreachable for credential prompt; not asking again", {
|
|
20978
|
+
namespace,
|
|
20979
|
+
missing,
|
|
20980
|
+
reason
|
|
20981
|
+
});
|
|
20982
|
+
if (reason === "no-page" || reason === "no-browser") {
|
|
20983
|
+
return this.credentialUnreachableRefusal(namespace, missing, reason);
|
|
20984
|
+
}
|
|
20985
|
+
return null;
|
|
20986
|
+
}
|
|
20559
20987
|
const asked = this.credentialPrompts.get(namespace) ?? 0;
|
|
20560
20988
|
if (asked >= MAX_CREDENTIAL_PROMPTS) {
|
|
20561
20989
|
log("info", "Missing credentials persist after the prompt budget; not asking again", {
|
|
@@ -20573,43 +21001,59 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20573
21001
|
});
|
|
20574
21002
|
return null;
|
|
20575
21003
|
}
|
|
20576
|
-
const properties = {};
|
|
20577
|
-
for (const key of missing) {
|
|
20578
|
-
properties[key] = {
|
|
20579
|
-
type: "string",
|
|
20580
|
-
title: key,
|
|
20581
|
-
description: `The value for ${key} required by "${namespace}". Stored only for this yaw-mcp session.`
|
|
20582
|
-
};
|
|
20583
|
-
}
|
|
20584
21004
|
progress?.(`Asking for ${missing.length === 1 ? "credential" : "credentials"}: ${missing.join(", ")}`);
|
|
20585
21005
|
this.credentialPrompts.set(namespace, asked + 1);
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
20589
|
-
|
|
20590
|
-
|
|
20591
|
-
|
|
20592
|
-
|
|
20593
|
-
|
|
20594
|
-
|
|
20595
|
-
|
|
20596
|
-
|
|
20597
|
-
|
|
20598
|
-
|
|
20599
|
-
|
|
20600
|
-
}
|
|
21006
|
+
const isPlural = missing.length !== 1;
|
|
21007
|
+
const what = isPlural ? "them" : "it";
|
|
21008
|
+
const pronoun = isPlural ? "their" : "its";
|
|
21009
|
+
const fixHint = `Set ${what} in this server's "env" in ~/.yaw-mcp/bundles.json to skip this prompt in future sessions.`;
|
|
21010
|
+
const why = `"${namespace}" cannot start: it reports ${missing.join(", ")} missing. ${fixHint}`;
|
|
21011
|
+
const entry = await this.collectSecretOnLoopbackPage({
|
|
21012
|
+
namespace,
|
|
21013
|
+
why,
|
|
21014
|
+
secretNoun: isPlural ? `the values of ${missing.join(", ")}` : `the value of ${missing[0]}`,
|
|
21015
|
+
page: {
|
|
21016
|
+
title: `"${namespace}" needs ${isPlural ? "credentials" : "a credential"} to start`,
|
|
21017
|
+
intro: `"${namespace}" cannot start without ${missing.join(", ")} and reported ${pronoun} missing key${isPlural ? "s" : ""} on ${pronoun} own. Type ${isPlural ? "each value" : "the value"} below. yaw-mcp keeps ${what} in memory for this session only -- never written to disk, and never passed to anything other than "${namespace}". ${fixHint}`,
|
|
21018
|
+
fields: missing.map((name) => ({ name, label: name })),
|
|
21019
|
+
doneMessage: "Received. You can close this tab and return to your MCP client."
|
|
21020
|
+
},
|
|
21021
|
+
progress
|
|
21022
|
+
});
|
|
21023
|
+
if (entry.kind === "failed") {
|
|
21024
|
+
log("info", "Credential elicitation did not complete", { namespace, missing });
|
|
21025
|
+
if (this.shuttingDown) return this.shuttingDownRefusal(namespace);
|
|
21026
|
+
return null;
|
|
21027
|
+
}
|
|
21028
|
+
if (entry.kind === "declined") {
|
|
21029
|
+
log("info", "User declined credential elicitation", { namespace });
|
|
21030
|
+
if (this.shuttingDown) return this.shuttingDownRefusal(namespace);
|
|
21031
|
+
this.credentialElicited.set(namespace, "declined");
|
|
20601
21032
|
return null;
|
|
20602
21033
|
}
|
|
20603
|
-
if (
|
|
20604
|
-
log("info", "
|
|
21034
|
+
if (entry.kind === "unreachable") {
|
|
21035
|
+
log("info", "Credential masked-entry page was unreachable", {
|
|
21036
|
+
namespace,
|
|
21037
|
+
missing,
|
|
21038
|
+
reason: entry.reason
|
|
21039
|
+
});
|
|
21040
|
+
if (this.shuttingDown) return this.shuttingDownRefusal(namespace);
|
|
21041
|
+
if (entry.reason !== "expired") {
|
|
21042
|
+
this.credentialElicited.set(namespace, entry.reason);
|
|
21043
|
+
return this.credentialUnreachableRefusal(namespace, missing, entry.reason);
|
|
21044
|
+
}
|
|
20605
21045
|
return null;
|
|
20606
21046
|
}
|
|
20607
21047
|
const values = {};
|
|
20608
21048
|
for (const key of missing) {
|
|
20609
|
-
const v =
|
|
21049
|
+
const v = entry.values[key];
|
|
20610
21050
|
if (typeof v === "string" && v.length > 0) values[key] = v;
|
|
20611
21051
|
}
|
|
20612
|
-
if (Object.keys(values).length === 0)
|
|
21052
|
+
if (Object.keys(values).length === 0) {
|
|
21053
|
+
log("info", "Credential masked-entry page returned no values", { namespace, missing });
|
|
21054
|
+
this.credentialElicited.set(namespace, "empty");
|
|
21055
|
+
return null;
|
|
21056
|
+
}
|
|
20613
21057
|
this.elicitedEnv.set(namespace, { ...supplied, ...values });
|
|
20614
21058
|
progress?.("Got credentials \u2014 retrying load");
|
|
20615
21059
|
return this.runActivateOne(
|
|
@@ -20735,6 +21179,37 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20735
21179
|
message: `Could not load "${namespace}": ${what}, so your local secret vault, which its env (${lastError.refKeys.join(", ")}) references, is still locked.${retryHint}`
|
|
20736
21180
|
};
|
|
20737
21181
|
}
|
|
21182
|
+
// The result for a missing-credential prompt whose masked-entry page never
|
|
21183
|
+
// took a value. Only called for no-page and no-browser -- expired keeps
|
|
21184
|
+
// the budget and falls through to runActivateOne's give-up, since the user
|
|
21185
|
+
// may simply have been away. The shape mirrors vaultPassphraseUnreachable
|
|
21186
|
+
// so a user who saw the vault message once recognises this one: explain
|
|
21187
|
+
// what could not happen, then point at the bundles.json env path as the
|
|
21188
|
+
// long-term fix. The retry hint is the same shape for both reasons: the
|
|
21189
|
+
// latch above this branch (no-page / no-browser) means a second activate
|
|
21190
|
+
// goes straight to the give-up, so a "no further prompts" line on the
|
|
21191
|
+
// first prompt would be inaccurate.
|
|
21192
|
+
credentialUnreachableRefusal(namespace, missing, reason) {
|
|
21193
|
+
let what;
|
|
21194
|
+
switch (reason) {
|
|
21195
|
+
case "no-browser":
|
|
21196
|
+
what = "yaw-mcp could not open a browser on this machine for the page that takes the credential in a masked field";
|
|
21197
|
+
break;
|
|
21198
|
+
case "no-page":
|
|
21199
|
+
what = "yaw-mcp could not start the local page that takes the credential in a masked field";
|
|
21200
|
+
break;
|
|
21201
|
+
case "expired":
|
|
21202
|
+
throw new Error(
|
|
21203
|
+
`credentialUnreachableRefusal called with reason "expired" -- the caller should have returned null`
|
|
21204
|
+
);
|
|
21205
|
+
}
|
|
21206
|
+
const retryHint = ` Activate "${namespace}" again for a new page, or set ${missing.join(", ")} in its "env" in ~/.yaw-mcp/bundles.json to skip the prompt in future sessions.`;
|
|
21207
|
+
return {
|
|
21208
|
+
ok: false,
|
|
21209
|
+
isChanged: false,
|
|
21210
|
+
message: `Could not load "${namespace}": ${what}, so ${missing.join(", ")} is still missing.${retryHint}`
|
|
21211
|
+
};
|
|
21212
|
+
}
|
|
20738
21213
|
// Collect secret values WITHOUT them ever being typed into the client's
|
|
20739
21214
|
// own dialog. They are typed into masked fields on a one-shot page this
|
|
20740
21215
|
// process serves on 127.0.0.1 (secret-entry-page.ts, which carries the
|
|
@@ -20757,8 +21232,8 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20757
21232
|
// that is exactly the exposure this replaces.
|
|
20758
21233
|
//
|
|
20759
21234
|
// Nothing here is vault-specific. The missing-credential prompt
|
|
20760
|
-
// (maybeElicitAndRetry
|
|
20761
|
-
//
|
|
21235
|
+
// (maybeElicitAndRetry) supplies its own words and fields and goes through
|
|
21236
|
+
// the same page.
|
|
20762
21237
|
async collectSecretOnLoopbackPage(request2) {
|
|
20763
21238
|
const { namespace, why, secretNoun, progress } = request2;
|
|
20764
21239
|
const modes = getSupportedElicitationModes(this.server.getClientCapabilities()?.elicitation);
|
|
@@ -20930,6 +21405,7 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20930
21405
|
let anyCapped = false;
|
|
20931
21406
|
let advertisedGrew = false;
|
|
20932
21407
|
const total = namespaces.length;
|
|
21408
|
+
const loadedOk = [];
|
|
20933
21409
|
let i = 0;
|
|
20934
21410
|
for (const namespace of namespaces) {
|
|
20935
21411
|
i += 1;
|
|
@@ -20937,6 +21413,7 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20937
21413
|
const r = await this.activateOne(namespace, progress);
|
|
20938
21414
|
results.push(r.message);
|
|
20939
21415
|
if (r.isChanged) anyChanged = true;
|
|
21416
|
+
if (r.ok) loadedOk.push(namespace);
|
|
20940
21417
|
if (r.ok) {
|
|
20941
21418
|
if (!this.sessionActivated.has(namespace)) advertisedGrew = true;
|
|
20942
21419
|
this.sessionActivated.add(namespace);
|
|
@@ -20975,6 +21452,8 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
20975
21452
|
results.push(lead + fix);
|
|
20976
21453
|
}
|
|
20977
21454
|
}
|
|
21455
|
+
const execHint = this.execHintForNonRelistingClient(loadedOk);
|
|
21456
|
+
if (execHint) results.push(execHint);
|
|
20978
21457
|
results.push(...upstreamInstructions);
|
|
20979
21458
|
return {
|
|
20980
21459
|
content: [{ type: "text", text: results.join("\n") }],
|
|
@@ -21115,6 +21594,7 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
21115
21594
|
let anyError = false;
|
|
21116
21595
|
let anyCapped = false;
|
|
21117
21596
|
let advertisedGrew = false;
|
|
21597
|
+
const dispatchedOk = [];
|
|
21118
21598
|
let i = 0;
|
|
21119
21599
|
for (const winner of winners) {
|
|
21120
21600
|
i += 1;
|
|
@@ -21125,6 +21605,7 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
21125
21605
|
if (r.ok) {
|
|
21126
21606
|
if (!this.sessionActivated.has(winner.namespace)) advertisedGrew = true;
|
|
21127
21607
|
this.sessionActivated.add(winner.namespace);
|
|
21608
|
+
dispatchedOk.push(winner.namespace);
|
|
21128
21609
|
}
|
|
21129
21610
|
if (!r.ok) {
|
|
21130
21611
|
if (r.capped) anyCapped = true;
|
|
@@ -21136,6 +21617,8 @@ Name collision: ${subject} of "${namespace}" cannot be called. ${entries}${more}
|
|
|
21136
21617
|
} else if (advertisedGrew) {
|
|
21137
21618
|
await this.notifyAllListsChanged();
|
|
21138
21619
|
}
|
|
21620
|
+
const execHint = this.execHintForNonRelistingClient(dispatchedOk);
|
|
21621
|
+
if (execHint) results.push(execHint);
|
|
21139
21622
|
const header = `Dispatched "${trimmed}" \u2014 loaded top ${winners.length} of ${ranked.length} matching server${ranked.length === 1 ? "" : "s"}.
|
|
21140
21623
|
`;
|
|
21141
21624
|
return {
|
|
@@ -21530,7 +22013,7 @@ Cross-session reliability (dormant, <${flakyPct}% success):`);
|
|
|
21530
22013
|
* match rather than leaving the model to infer it -- a silently absent
|
|
21531
22014
|
* schema reads as "this tool takes no arguments", which is a worse answer
|
|
21532
22015
|
* than "activate it to see". */
|
|
21533
|
-
handleFindTool(query, limit) {
|
|
22016
|
+
async handleFindTool(query, limit) {
|
|
21534
22017
|
const servers = this.getProfiledActiveServers();
|
|
21535
22018
|
if (servers.length === 0) {
|
|
21536
22019
|
const configured = this.config?.servers.length ?? 0;
|
|
@@ -21552,10 +22035,17 @@ Cross-session reliability (dormant, <${flakyPct}% success):`);
|
|
|
21552
22035
|
1,
|
|
21553
22036
|
Math.min(limit ?? _ConnectServer.FIND_TOOL_DEFAULT_LIMIT, _ConnectServer.FIND_TOOL_MAX_LIMIT)
|
|
21554
22037
|
);
|
|
21555
|
-
|
|
22038
|
+
let ranked = rankTools(
|
|
21556
22039
|
query,
|
|
21557
22040
|
servers.map((s) => this.rankableFor(s))
|
|
21558
22041
|
);
|
|
22042
|
+
if (ranked.length === 0 && this.startupPrewarm) {
|
|
22043
|
+
await this.settleStartupPrewarm();
|
|
22044
|
+
ranked = rankTools(
|
|
22045
|
+
query,
|
|
22046
|
+
this.getProfiledActiveServers().map((s) => this.rankableFor(s))
|
|
22047
|
+
);
|
|
22048
|
+
}
|
|
21559
22049
|
if (ranked.length === 0) {
|
|
21560
22050
|
return {
|
|
21561
22051
|
content: [
|
|
@@ -21767,6 +22257,13 @@ To load the top pack in one step, call \`mcp_connect_activate\` with namespaces=
|
|
|
21767
22257
|
isError: true
|
|
21768
22258
|
};
|
|
21769
22259
|
}
|
|
22260
|
+
if (this.startupPrewarm && steps.some((s) => !this.toolRoutes.has(s.tool))) {
|
|
22261
|
+
await this.settleStartupPrewarm(signal);
|
|
22262
|
+
if (signal?.aborted) {
|
|
22263
|
+
return { content: [{ type: "text", text: "exec: cancelled before step 0 ran." }], isError: true };
|
|
22264
|
+
}
|
|
22265
|
+
if (steps.some((s) => !this.toolRoutes.has(s.tool))) this.rebuildRoutes();
|
|
22266
|
+
}
|
|
21770
22267
|
for (let i = 0; i < steps.length; i++) {
|
|
21771
22268
|
const step = steps[i];
|
|
21772
22269
|
const route = this.toolRoutes.get(step.tool);
|
|
@@ -21982,6 +22479,7 @@ To load the top pack in one step, call \`mcp_connect_activate\` with namespaces=
|
|
|
21982
22479
|
await Promise.allSettled(disconnects);
|
|
21983
22480
|
this.connections.clear();
|
|
21984
22481
|
this.elicitedEnv.clear();
|
|
22482
|
+
this.credentialElicited.clear();
|
|
21985
22483
|
clearSessionVaultPassphrase();
|
|
21986
22484
|
this.inflightCalls.clear();
|
|
21987
22485
|
await this.server.close();
|
|
@@ -22026,7 +22524,7 @@ function registerShutdownTriggers(shutdown, targets) {
|
|
|
22026
22524
|
// src/status-cmd.ts
|
|
22027
22525
|
import { existsSync as existsSync10 } from "fs";
|
|
22028
22526
|
import { homedir as homedir23 } from "os";
|
|
22029
|
-
var VERSION2 = true ? "1.0.
|
|
22527
|
+
var VERSION2 = true ? "1.0.13" : "dev";
|
|
22030
22528
|
var STATUS_SCHEMA_VERSION = 1;
|
|
22031
22529
|
var STATUS_USAGE = `Usage: yaw-mcp status [--json]
|
|
22032
22530
|
|
|
@@ -22504,7 +23002,7 @@ if (subcommand === "compliance") {
|
|
|
22504
23002
|
|
|
22505
23003
|
Secrets:
|
|
22506
23004
|
secrets <action> Manage the local encrypted secret vault: set,
|
|
22507
|
-
get, list, remove, lock, rotate, audit.
|
|
23005
|
+
get, list, remove, lock, rotate, reset, audit.
|
|
22508
23006
|
Reference a stored value from any server's env
|
|
22509
23007
|
as \${secret:NAME}.
|
|
22510
23008
|
|
|
@@ -22640,7 +23138,8 @@ if (subcommand === "compliance") {
|
|
|
22640
23138
|
from every child env. A client that supports
|
|
22641
23139
|
MCP elicitation prompts for it instead, for
|
|
22642
23140
|
that session only. Manage entries with
|
|
22643
|
-
\`yaw-mcp secrets
|
|
23141
|
+
\`yaw-mcp secrets\`; when it is set, \`secrets
|
|
23142
|
+
reset\` keys the fresh vault it creates under it.
|
|
22644
23143
|
YAW_MCP_VAULT_PASSPHRASE_NEW The NEW passphrase for \`yaw-mcp secrets
|
|
22645
23144
|
rotate\`, so a re-wrap can run without a TTY.
|
|
22646
23145
|
Read only by \`rotate\`; without it (and
|
|
@@ -22805,7 +23304,7 @@ if (subcommand === "compliance") {
|
|
|
22805
23304
|
`);
|
|
22806
23305
|
process.exitCode = 0;
|
|
22807
23306
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
22808
|
-
process.stdout.write(`yaw-mcp ${true ? "1.0.
|
|
23307
|
+
process.stdout.write(`yaw-mcp ${true ? "1.0.13" : "dev"}
|
|
22809
23308
|
`);
|
|
22810
23309
|
process.exitCode = 0;
|
|
22811
23310
|
} else if (subcommand !== void 0 && !subcommand.startsWith("-")) {
|