@mysten-incubation/memwal-mcp 0.0.14-dev.0 → 0.0.14-dev.10
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/README.md +238 -1
- package/dist/auth-required.d.ts +325 -0
- package/dist/auth-required.d.ts.map +1 -1
- package/dist/auth-required.js +84 -16
- package/dist/auth-required.js.map +1 -1
- package/dist/auth.d.ts +179 -18
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +458 -35
- package/dist/auth.js.map +1 -1
- package/dist/auto-save.d.ts +100 -0
- package/dist/auto-save.d.ts.map +1 -0
- package/dist/auto-save.js +290 -0
- package/dist/auto-save.js.map +1 -0
- package/dist/bridge.d.ts +14 -2
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +233 -25
- package/dist/bridge.js.map +1 -1
- package/dist/consent.d.ts +36 -0
- package/dist/consent.d.ts.map +1 -0
- package/dist/consent.js +129 -0
- package/dist/consent.js.map +1 -0
- package/dist/health-probe.d.ts +35 -0
- package/dist/health-probe.d.ts.map +1 -0
- package/dist/health-probe.js +87 -0
- package/dist/health-probe.js.map +1 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +266 -5
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +17 -18
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +84 -20
- package/dist/instructions.js.map +1 -1
- package/dist/login.d.ts +15 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +109 -9
- package/dist/login.js.map +1 -1
- package/dist/memory-policy.d.ts +38 -0
- package/dist/memory-policy.d.ts.map +1 -0
- package/dist/memory-policy.js +80 -0
- package/dist/memory-policy.js.map +1 -0
- package/dist/messages.d.ts +10 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +16 -5
- package/dist/messages.js.map +1 -1
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +15 -13
- package/dist/recovery.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,UAAU,UAAU;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB;0EACsE;IACtE,cAAc,EAAE,OAAO,CAAC;IACxB,oCAAoC;IACpC,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC;2EACuE;IACvE,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAeD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA8GpD;AAED,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CA0YhF;AAkCD;wCACwC;AACxC,wBAAgB,QAAQ,IAAI,MAAM,CAgIjC;AAGD,OAAO,EACH,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,GACnC,MAAM,WAAW,CAAC;AACnB,OAAO,EACH,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,aAAa,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
* 5. On 401 (revoked key), the bridge wipes credentials before throwing
|
|
10
10
|
* — the next process spawn will re-trigger login.
|
|
11
11
|
*/
|
|
12
|
-
import { clearCreds, clearPendingLogin, credsPath, loadCreds } from "./auth.js";
|
|
12
|
+
import { approveProjectCreds, clearCreds, clearPendingLogin, credsPath, formatProjectCredsNotice, formatProjectCredsStorageWarning, loadCreds, resolveCreds, revokeProjectCredsApproval, } from "./auth.js";
|
|
13
13
|
import { recoverPendingLogin, formatStrandedLoginNotice } from "./recovery.js";
|
|
14
14
|
import { runAuthRequiredServer } from "./auth-required.js";
|
|
15
15
|
import { notePendingLoginSuccess, runBridge } from "./bridge.js";
|
|
16
16
|
import { loginFlow } from "./login.js";
|
|
17
|
+
import { autoSaveStatus, autoSaveSummary, markConsentPending, pendingConsentNotice, publishHookState, setAutoSave, AUTO_SAVE_ENV, } from "./auto-save.js";
|
|
18
|
+
import { askAutoSaveConsent, consentOutcomeNotice } from "./consent.js";
|
|
17
19
|
import { log, note } from "./logger.js";
|
|
18
20
|
/** Per-environment URL shortcuts. `--dev`/`--staging`/`--local` set both
|
|
19
21
|
* relayer + web in one flag. Explicit `--relayer` / `--web-url` override. */
|
|
@@ -25,9 +27,16 @@ const ENV_PRESETS = {
|
|
|
25
27
|
};
|
|
26
28
|
/** Bare words that are commands rather than values. An unknown flag must not
|
|
27
29
|
* swallow one as its argument. */
|
|
28
|
-
const POSITIONALS = new Set(["login"]);
|
|
30
|
+
const POSITIONALS = new Set(["login", "approve-project", "revoke-project", "auto-save", "on", "off", "status"]);
|
|
29
31
|
export function parseArgs(argv) {
|
|
30
|
-
const out = {
|
|
32
|
+
const out = {
|
|
33
|
+
help: false,
|
|
34
|
+
logout: false,
|
|
35
|
+
forceLogin: false,
|
|
36
|
+
approveProject: false,
|
|
37
|
+
revokeProject: false,
|
|
38
|
+
unknown: [],
|
|
39
|
+
};
|
|
31
40
|
for (let i = 0; i < argv.length; i++) {
|
|
32
41
|
const a = argv[i];
|
|
33
42
|
const next = () => argv[++i];
|
|
@@ -43,6 +52,29 @@ export function parseArgs(argv) {
|
|
|
43
52
|
case "login":
|
|
44
53
|
out.forceLogin = true;
|
|
45
54
|
break;
|
|
55
|
+
case "--approve-project":
|
|
56
|
+
case "approve-project":
|
|
57
|
+
out.approveProject = true;
|
|
58
|
+
break;
|
|
59
|
+
case "--revoke-project":
|
|
60
|
+
case "revoke-project":
|
|
61
|
+
out.revokeProject = true;
|
|
62
|
+
break;
|
|
63
|
+
case "auto-save":
|
|
64
|
+
case "--auto-save": {
|
|
65
|
+
// `auto-save` on its own reports the state rather than
|
|
66
|
+
// changing it — a bare subcommand must never be read as
|
|
67
|
+
// consent to turn automatic saving on.
|
|
68
|
+
const value = argv[i + 1]?.toLowerCase();
|
|
69
|
+
if (value === "on" || value === "off" || value === "status") {
|
|
70
|
+
out.autoSave = value;
|
|
71
|
+
i++;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
out.autoSave = "status";
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
46
78
|
case "--prod":
|
|
47
79
|
case "--dev":
|
|
48
80
|
case "--staging":
|
|
@@ -125,6 +157,36 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
125
157
|
printHelp();
|
|
126
158
|
return;
|
|
127
159
|
}
|
|
160
|
+
// Republish the resolved opt-in for the plugin hooks before anything else
|
|
161
|
+
// runs. The hooks do no resolution of their own — they read this file or
|
|
162
|
+
// they fail safe to "off" (WALM-642) — so every start-up refreshes it,
|
|
163
|
+
// including the ones that return early below. Best effort by design: a
|
|
164
|
+
// read-only home must not stop the server, and a hook that finds nothing
|
|
165
|
+
// already behaves as off.
|
|
166
|
+
publishHookState();
|
|
167
|
+
// Runs before the credential paths below: reading or flipping the opt-in
|
|
168
|
+
// does not need an account, and a user deciding whether to enable
|
|
169
|
+
// automatic memory should not be pushed through a browser login first.
|
|
170
|
+
if (args.autoSave) {
|
|
171
|
+
if (args.autoSave === "status") {
|
|
172
|
+
note(autoSaveSummary());
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const enabled = args.autoSave === "on";
|
|
176
|
+
const { path } = setAutoSave(enabled);
|
|
177
|
+
note(enabled
|
|
178
|
+
? `Automatic memory is ON. The agent may now save durable facts without being asked; ` +
|
|
179
|
+
`credentials are still excluded and stripped before any write. Saved to ${path}.`
|
|
180
|
+
: `Automatic memory is OFF. Facts are saved only when you ask for them. Saved to ${path}.`);
|
|
181
|
+
const status = autoSaveStatus();
|
|
182
|
+
if (status.source === "env" && status.enabled !== enabled) {
|
|
183
|
+
// The file was written, but this process would still answer the
|
|
184
|
+
// other way — say so rather than let the setting look ignored.
|
|
185
|
+
note(`Note: ${AUTO_SAVE_ENV}=${process.env[AUTO_SAVE_ENV]} is set in this environment ` +
|
|
186
|
+
`and overrides the file. Unset it for the saved choice to take effect.`);
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
128
190
|
if (args.logout) {
|
|
129
191
|
const cleared = clearCreds();
|
|
130
192
|
// Explicit sign-out discards the write-ahead record too. Without this
|
|
@@ -148,6 +210,88 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
148
210
|
}
|
|
149
211
|
return;
|
|
150
212
|
}
|
|
213
|
+
// A project-local `.memwal/credentials.json` decides the account and the
|
|
214
|
+
// relayer every memory from that directory goes to, and it lives inside a
|
|
215
|
+
// repository — so it stays inert until the user approves it here
|
|
216
|
+
// (WALM-639). The approval is a decision about where memory goes, so it
|
|
217
|
+
// wants a real terminal for the same reason `login` does: a non-interactive
|
|
218
|
+
// spawn is a script or an MCP client, and neither of those is the user
|
|
219
|
+
// saying yes.
|
|
220
|
+
if (args.approveProject || args.revokeProject) {
|
|
221
|
+
if (!process.stdin.isTTY) {
|
|
222
|
+
log.error("creds.project_approval.requires_tty", { cwd: process.cwd() });
|
|
223
|
+
note("error: `approve-project` / `revoke-project` require an interactive terminal " +
|
|
224
|
+
"(stdin is not a TTY).");
|
|
225
|
+
note(" Run it in a terminal, from the project directory.");
|
|
226
|
+
process.exitCode = 1;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (args.revokeProject) {
|
|
230
|
+
const revoked = revokeProjectCredsApproval();
|
|
231
|
+
log.info("creds.project_approval.revoked", {
|
|
232
|
+
outcome: revoked.outcome,
|
|
233
|
+
projectPath: revoked.projectPath,
|
|
234
|
+
});
|
|
235
|
+
if (revoked.outcome === "none") {
|
|
236
|
+
note(`No approval on record for ${revoked.projectPath}.`);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
note(`Approval withdrawn for ${revoked.projectPath}.`);
|
|
240
|
+
note(`Memory from this project goes to ${credsPath()} again.`);
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const approved = approveProjectCreds();
|
|
245
|
+
log.info("creds.project_approval", {
|
|
246
|
+
outcome: approved.outcome,
|
|
247
|
+
projectPath: approved.projectPath,
|
|
248
|
+
accountId: approved.accountId,
|
|
249
|
+
relayerUrl: approved.relayerUrl,
|
|
250
|
+
});
|
|
251
|
+
switch (approved.outcome) {
|
|
252
|
+
case "overridden":
|
|
253
|
+
note(`MEMWAL_CREDS_DIR is set (${process.env.MEMWAL_CREDS_DIR}), so project ` +
|
|
254
|
+
`credentials are never used. Nothing to approve.`);
|
|
255
|
+
break;
|
|
256
|
+
case "none":
|
|
257
|
+
note(`No project credentials found at or above ${process.cwd()} ` +
|
|
258
|
+
`(.memwal/credentials.json). Nothing to approve.`);
|
|
259
|
+
break;
|
|
260
|
+
case "unreadable":
|
|
261
|
+
note(`${approved.projectPath} is not a valid Walrus Memory credentials file. ` +
|
|
262
|
+
`Nothing to approve.`);
|
|
263
|
+
process.exitCode = 1;
|
|
264
|
+
break;
|
|
265
|
+
case "already-approved":
|
|
266
|
+
note(`Already approved: ${approved.projectPath} → account ${approved.accountId} ` +
|
|
267
|
+
`on ${approved.relayerUrl}.`);
|
|
268
|
+
// Repeated on a no-op approve too: someone re-running this is
|
|
269
|
+
// checking what the state is, and "a private key gets written
|
|
270
|
+
// into your repo" is part of that state.
|
|
271
|
+
if (approved.projectPath) {
|
|
272
|
+
note(formatProjectCredsStorageWarning(approved.projectPath));
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
default:
|
|
276
|
+
if (approved.outcome === "reapproved") {
|
|
277
|
+
note(`The approved destination changed — was account ` +
|
|
278
|
+
`${approved.previousAccountId} on ${approved.previousRelayerUrl}.`);
|
|
279
|
+
}
|
|
280
|
+
note(`Approved ${approved.projectPath}.`);
|
|
281
|
+
note(`Memory written from this project now goes to account ${approved.accountId} ` +
|
|
282
|
+
`on ${approved.relayerUrl}.`);
|
|
283
|
+
note(`Recorded in ${approved.approvalsPath}. Approval is required again if the ` +
|
|
284
|
+
`account, delegate key or relayer changes.`);
|
|
285
|
+
// Approving picks the WRITE target as well as the read one, and
|
|
286
|
+
// that target is inside the repository. Saying only where memory
|
|
287
|
+
// now goes would leave the user to discover the delegate key in
|
|
288
|
+
// their working tree — at best in a diff, at worst in a push.
|
|
289
|
+
if (approved.projectPath) {
|
|
290
|
+
note(formatProjectCredsStorageWarning(approved.projectPath));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
151
295
|
// Resolve URLs: CLI > env > default.
|
|
152
296
|
const relayerUrl = args.relayerUrl ?? process.env.MEMWAL_SERVER_URL ?? "https://relayer.memory.walrus.xyz";
|
|
153
297
|
const webUrl = args.webUrl ?? process.env.MEMWAL_WEB_URL ?? "https://memory.walrus.xyz";
|
|
@@ -176,6 +320,25 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
176
320
|
// also destroyed the file `saveCreds` needs in order to notice that the new
|
|
177
321
|
// sign-in belongs to a different account (GH #628). The old file is now
|
|
178
322
|
// replaced only on success, and backed up when the account changes.
|
|
323
|
+
// Report a project-local credentials file that resolution refused to use,
|
|
324
|
+
// once, before anything else reads credentials. Staying silent would be the
|
|
325
|
+
// mirror of the silent redirect the gate exists to stop: the user put that
|
|
326
|
+
// file there expecting it to be used, and nothing else would tell them it
|
|
327
|
+
// was skipped or how to approve it (WALM-639).
|
|
328
|
+
const resolution = resolveCreds();
|
|
329
|
+
const projectNotice = formatProjectCredsNotice(resolution);
|
|
330
|
+
if (projectNotice) {
|
|
331
|
+
log.warn("creds.project_ignored", {
|
|
332
|
+
projectPath: resolution.project?.path,
|
|
333
|
+
decision: resolution.project?.decision,
|
|
334
|
+
// Destination it would have redirected to — never anything from
|
|
335
|
+
// the file's key material.
|
|
336
|
+
projectAccountId: resolution.project?.accountId,
|
|
337
|
+
projectRelayerUrl: resolution.project?.relayerUrl,
|
|
338
|
+
using: resolution.path,
|
|
339
|
+
});
|
|
340
|
+
note(projectNotice);
|
|
341
|
+
}
|
|
179
342
|
let creds = args.forceLogin ? null : loadCreds();
|
|
180
343
|
// A previous sign-in may have died after the browser registered our
|
|
181
344
|
// delegate key on-chain but before the callback saved it (WALM-332). The
|
|
@@ -189,6 +352,8 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
189
352
|
creds = recovery.credentials;
|
|
190
353
|
note(`Recovered credentials from an interrupted sign-in ` +
|
|
191
354
|
`(delegate ${recovery.credentials.delegateAddress}).`);
|
|
355
|
+
if (recovery.replacementNotice)
|
|
356
|
+
note(recovery.replacementNotice);
|
|
192
357
|
}
|
|
193
358
|
else {
|
|
194
359
|
const notice = formatStrandedLoginNotice(recovery);
|
|
@@ -239,6 +404,13 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
239
404
|
// tool from the MCP client) opens the correct dashboard. Before
|
|
240
405
|
// this fix `--dev` was silently dropped here and the flow always
|
|
241
406
|
// routed to prod (https://memory.walrus.xyz).
|
|
407
|
+
// No credentials and no terminal: a brand-new install being set up
|
|
408
|
+
// through an MCP client. Stamp it now, while we can still tell it
|
|
409
|
+
// apart from a long-standing user — otherwise a sign-in through the
|
|
410
|
+
// `memwal_login` tool would later be indistinguishable from one,
|
|
411
|
+
// and automatic saving would switch itself on with nobody having
|
|
412
|
+
// been asked (WALM-642).
|
|
413
|
+
markConsentPending();
|
|
242
414
|
const handoff = await runAuthRequiredServer({ relayerUrl, webUrl, label, namespace });
|
|
243
415
|
if (handoff) {
|
|
244
416
|
// The user completed `memwal_login` in this SAME session: the
|
|
@@ -259,14 +431,21 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
259
431
|
delegateAddress: handoff.creds.delegateAddress,
|
|
260
432
|
credentialsPath: credsPath(),
|
|
261
433
|
});
|
|
434
|
+
const pendingAfterLogin = pendingConsentNotice();
|
|
435
|
+
if (pendingAfterLogin)
|
|
436
|
+
note(pendingAfterLogin);
|
|
262
437
|
await runBridge(handoff.creds, { relayerUrl, webUrl, label, namespace }, handoff.pendingLines);
|
|
263
438
|
}
|
|
264
439
|
return;
|
|
265
440
|
}
|
|
266
441
|
// TTY = manual invocation. Block on the browser flow as before.
|
|
267
442
|
note("Walrus Memory MCP is not authorized yet — opening browser to connect your Sui wallet.");
|
|
268
|
-
creds = await loginFlow({ relayerUrl, webUrl, label });
|
|
443
|
+
creds = await loginFlow({ relayerUrl, webUrl, label, freshKey: args.forceLogin });
|
|
269
444
|
note(`Authorized as ${creds.walletAddress.slice(0, 10)}...`);
|
|
445
|
+
// Before the question is put, not after: if the user abandons the
|
|
446
|
+
// prompt, the install must still read as "never answered" rather than
|
|
447
|
+
// fall through to the pre-existing-user rule and start saving.
|
|
448
|
+
markConsentPending();
|
|
270
449
|
}
|
|
271
450
|
else {
|
|
272
451
|
log.info("creds.loaded", {
|
|
@@ -274,6 +453,10 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
274
453
|
delegateAddress: creds.delegateAddress,
|
|
275
454
|
label: creds.label,
|
|
276
455
|
relayerUrl: creds.relayerUrl,
|
|
456
|
+
// Which file won, and how. "Where is this sending my memory" is
|
|
457
|
+
// otherwise only answerable by re-deriving the resolution by hand.
|
|
458
|
+
credentialsPath: resolution.path,
|
|
459
|
+
credentialsSource: resolution.source,
|
|
277
460
|
});
|
|
278
461
|
}
|
|
279
462
|
// Manual invocation from a real terminal: print status and exit.
|
|
@@ -282,22 +465,62 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
282
465
|
// user is the one looking at stdout — there's no MCP client to bridge
|
|
283
466
|
// with, so hanging the process is the wrong default.
|
|
284
467
|
if (process.stdin.isTTY) {
|
|
468
|
+
// The one moment there is demonstrably a human here. Consent is asked
|
|
469
|
+
// on a terminal and nowhere else — never as an MCP tool, a tool
|
|
470
|
+
// description or an instruction, because a model answering this is not
|
|
471
|
+
// the user answering it (WALM-642).
|
|
472
|
+
await askForConsentIfOwed();
|
|
285
473
|
note(``);
|
|
286
474
|
if (wasLoggedIn) {
|
|
287
475
|
note(`✅ Already authorized as ${creds.walletAddress.slice(0, 10)}...${creds.walletAddress.slice(-6)}`);
|
|
288
476
|
note(` Account: ${creds.accountId}`);
|
|
289
477
|
note(` Relayer: ${creds.relayerUrl}`);
|
|
478
|
+
note(` Creds: ${resolution.path} (${resolution.source})`);
|
|
290
479
|
}
|
|
291
480
|
else {
|
|
292
481
|
note(`✅ Login complete. Credentials saved to ${credsPath()}`);
|
|
293
482
|
}
|
|
294
483
|
note(``);
|
|
484
|
+
// The one moment a human is guaranteed to be looking at this output —
|
|
485
|
+
// so it is where the automatic-save choice gets surfaced (WALM-642).
|
|
486
|
+
note(autoSaveSummary());
|
|
487
|
+
note(``);
|
|
295
488
|
note(`Next: add this package to your MCP client config (Cursor / Claude Desktop / etc).`);
|
|
296
489
|
note(`See \`memwal-mcp --help\` for ready-to-paste snippets.`);
|
|
297
490
|
return;
|
|
298
491
|
}
|
|
492
|
+
// Non-interactive from here on. Say the state once on stderr — there is no
|
|
493
|
+
// one to ask, and a prompt on this stdin would hang the server forever.
|
|
494
|
+
const pending = pendingConsentNotice();
|
|
495
|
+
if (pending)
|
|
496
|
+
note(pending);
|
|
299
497
|
await runBridge(creds, { relayerUrl, webUrl, label, namespace });
|
|
300
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Put the consent question to the user, if it is still owed one.
|
|
501
|
+
*
|
|
502
|
+
* Silent when the question has been answered, when `MEMWAL_AUTO_SAVE` has
|
|
503
|
+
* settled it, or when the input stream ends without an answer — in that last
|
|
504
|
+
* case the state stays unset and the question comes back next time, rather than
|
|
505
|
+
* a choice being recorded that nobody made. A declined answer is written once
|
|
506
|
+
* and never asked about again.
|
|
507
|
+
*/
|
|
508
|
+
async function askForConsentIfOwed() {
|
|
509
|
+
if (!autoSaveStatus().pendingConsent)
|
|
510
|
+
return;
|
|
511
|
+
const answer = await askAutoSaveConsent({
|
|
512
|
+
input: process.stdin,
|
|
513
|
+
output: process.stderr,
|
|
514
|
+
isTTY: process.stdin.isTTY === true,
|
|
515
|
+
});
|
|
516
|
+
if (answer === null) {
|
|
517
|
+
note("No answer recorded — automatic memory is unchanged and you will be " +
|
|
518
|
+
"asked again next time. Set it directly with `memwal-mcp auto-save on|off`.");
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
const { path } = setAutoSave(answer);
|
|
522
|
+
note(consentOutcomeNotice(answer, path));
|
|
523
|
+
}
|
|
301
524
|
function printHelp() {
|
|
302
525
|
process.stderr.write(helpText() + "\n");
|
|
303
526
|
}
|
|
@@ -323,6 +546,34 @@ export function helpText() {
|
|
|
323
546
|
" browser).",
|
|
324
547
|
" memwal-mcp --logout Delete saved credentials without",
|
|
325
548
|
" re-running login.",
|
|
549
|
+
" memwal-mcp approve-project Approve the project-local",
|
|
550
|
+
" .memwal/credentials.json found from",
|
|
551
|
+
" the current directory, so memory",
|
|
552
|
+
" written here goes to ITS account and",
|
|
553
|
+
" relayer. Until approved the file is",
|
|
554
|
+
" ignored and the global credentials",
|
|
555
|
+
" are used. Approval is per machine,",
|
|
556
|
+
" stored outside the repository, and",
|
|
557
|
+
" required again if the account,",
|
|
558
|
+
" delegate key or relayer changes.",
|
|
559
|
+
" memwal-mcp revoke-project Withdraw that approval.",
|
|
560
|
+
" memwal-mcp auto-save on|off Turn automatic memory on or off.",
|
|
561
|
+
" ON once you agree to it: `login` asks",
|
|
562
|
+
" in the terminal the first time, and",
|
|
563
|
+
" nothing is saved unprompted until you",
|
|
564
|
+
" answer. Saved memories are permanent",
|
|
565
|
+
" — Walrus is immutable storage — so",
|
|
566
|
+
" you can stop saving new ones but",
|
|
567
|
+
" cannot delete one already saved.",
|
|
568
|
+
" Credentials (passwords, API keys,",
|
|
569
|
+
" tokens, private keys, seed phrases,",
|
|
570
|
+
" auth headers, URLs with an embedded",
|
|
571
|
+
" user:password) are stripped before",
|
|
572
|
+
" any write either way — a safety net,",
|
|
573
|
+
" not a guarantee. Stored in",
|
|
574
|
+
" settings.json next to",
|
|
575
|
+
" credentials.json.",
|
|
576
|
+
" memwal-mcp auto-save Report the current setting.",
|
|
326
577
|
" memwal-mcp --help Show this help.",
|
|
327
578
|
"",
|
|
328
579
|
"Options:",
|
|
@@ -354,7 +605,15 @@ export function helpText() {
|
|
|
354
605
|
" MEMWAL_SERVER_URL same as --relayer",
|
|
355
606
|
" MEMWAL_WEB_URL same as --web-url",
|
|
356
607
|
" MEMWAL_CLIENT_LABEL same as --label",
|
|
608
|
+
" MEMWAL_CREDS_DIR Use this directory for credentials",
|
|
609
|
+
" and approvals, overriding both the",
|
|
610
|
+
" project-local and global files.",
|
|
611
|
+
" Must be an ABSOLUTE path outside the",
|
|
612
|
+
" project; anything else is refused.",
|
|
357
613
|
" MEMWAL_NAMESPACE same as --namespace",
|
|
614
|
+
" MEMWAL_AUTO_SAVE=1 Automatic memory for this server",
|
|
615
|
+
" only; overrides settings.json and",
|
|
616
|
+
" skips the login question. 0 = off.",
|
|
358
617
|
" MEMWAL_MCP_DEBUG=1 Verbose stderr logging.",
|
|
359
618
|
"",
|
|
360
619
|
"Minimal MCP client config (Cursor, Claude Desktop, etc.):",
|
|
@@ -397,7 +656,9 @@ export function helpText() {
|
|
|
397
656
|
return help;
|
|
398
657
|
}
|
|
399
658
|
// Re-exports — handy if someone wants to embed this in another tool.
|
|
400
|
-
export { loadCreds, saveCreds, clearCreds, credsPath } from "./auth.js";
|
|
659
|
+
export { loadCreds, saveCreds, clearCreds, credsPath, resolveCreds, approveProjectCreds, revokeProjectCredsApproval, formatProjectCredsNotice, formatProjectCredsStorageWarning, } from "./auth.js";
|
|
660
|
+
export { isAutoSaveEnabled, isConsentPending, autoSaveStatus, setAutoSave, markConsentPending, publishHookState, settingsPath, hookStatePath, } from "./auto-save.js";
|
|
661
|
+
export { askAutoSaveConsent, interpretConsentAnswer, CONSENT_PROMPT } from "./consent.js";
|
|
401
662
|
export { loginFlow } from "./login.js";
|
|
402
663
|
export { runBridge } from "./bridge.js";
|
|
403
664
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,IAA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yE;QACzE,uEAAuE;QACvE,wDAAwD;QACxD,qEAAqE;QACrE,sEAAsE;QACtE,uEAAuE;QACvE,4DAA4D;QAC5D,EAAE;QACF,2DAA2D;QAC3D,KAAK;QACL,qBAAqB;QACrB,mBAAmB;QACnB,2BAA2B;QAC3B,yDAAyD;QACzD,SAAS;QACT,OAAO;QACP,KAAK;QACL,EAAE;QACF,wDAAwD;QACxD,KAAK;QACL,qBAAqB;QACrB,mBAAmB;QACnB,2BAA2B;QAC3B,mBAAmB;QACnB,kDAAkD;QAClD,wDAAwD;QACxD,WAAW;QACX,SAAS;QACT,OAAO;QACP,KAAK;QACL,EAAE;QACF,wEAAwE;QACxE,KAAK;QACL,qBAAqB;QACrB,mBAAmB;QACnB,2BAA2B;QAC3B,mBAAmB;QACnB,kDAAkD;QAClD,iCAAiC;QACjC,WAAW;QACX,SAAS;QACT,OAAO;QACP,KAAK;QACL,EAAE;KACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,qEAAqE;AACrE,OAAO,EACH,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,GACnC,MAAM,WAAW,CAAC;AACnB,OAAO,EACH,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,aAAa,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/instructions.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Build the signed-in instruction payload for a given opt-in state.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* `initialize` itself and SUPPRESSES the relayer's reply (see
|
|
13
|
-
* `buildLocalInitializeResult` in bridge.ts). Without this, the relayer's
|
|
14
|
-
* instructions are correct but unreachable for every stdio client.
|
|
4
|
+
* Exported separately from the resolver so tests can pin both branches without
|
|
5
|
+
* touching the filesystem or the environment.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildProactiveInstructions(opts: {
|
|
8
|
+
autoSave: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
/**
|
|
11
|
+
* The payload for THIS process, resolved from the user's opt-in at call time.
|
|
15
12
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
* A function, not a const: the opt-in lives on disk and in the environment, and
|
|
14
|
+
* `initialize` can arrive after the user has flipped it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function proactiveInstructions(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Signed-in path (bridge mode) with automatic saving on. Kept as a named
|
|
19
|
+
* export because it is the text the whole proactive contract is written
|
|
20
|
+
* against; `proactiveInstructions()` is what the bridge actually serves.
|
|
21
21
|
*/
|
|
22
|
-
/** Signed-in path (bridge mode). Full proactive contract. */
|
|
23
22
|
export declare const PROACTIVE_INSTRUCTIONS: string;
|
|
24
23
|
/**
|
|
25
24
|
* Signed-out path (auth-required mode). Deliberately NOT the proactive text:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AA4FA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAU9E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAAiD,CAAC;AAErF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,QAK5B,CAAC"}
|
package/dist/instructions.js
CHANGED
|
@@ -17,10 +17,25 @@
|
|
|
17
17
|
* services/server/scripts/mcp/server.ts, which serves the direct HTTP/OAuth
|
|
18
18
|
* connector path. It cannot share this module: that file belongs to the
|
|
19
19
|
* standalone `memwal-server-scripts` npm package with no workspace link here.
|
|
20
|
-
* Keep the two in sync
|
|
20
|
+
* Keep the two in sync, except: this copy must not name a tool cold start
|
|
21
|
+
* does not advertise (`memwal_remember_status` is the worked example — GH
|
|
22
|
+
* #928). The sidecar copy may name it; that process actually registers the
|
|
23
|
+
* tool.
|
|
24
|
+
*
|
|
25
|
+
* The secret-exclusion paragraph is not retyped in either, it comes from the
|
|
26
|
+
* shared policy block (memory-policy.ts here, tools/memory-policy.ts there),
|
|
27
|
+
* which is pinned byte-for-byte by tests on both sides.
|
|
28
|
+
*
|
|
29
|
+
* WALM-642 split the REMEMBER section in two. Whether the model is told to
|
|
30
|
+
* save unprompted now depends on the user having turned automatic memory on;
|
|
31
|
+
* saving what the user explicitly asks for is unconditional, and is what the
|
|
32
|
+
* opted-out text still describes.
|
|
21
33
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
import { SECRET_EXCLUSION_RULES } from "./memory-policy.js";
|
|
35
|
+
import { isAutoSaveEnabled } from "./auto-save.js";
|
|
36
|
+
/** Everything true regardless of the opt-in: what the tools are, how recall
|
|
37
|
+
* works, how a write reports itself, and how to recover an index. */
|
|
38
|
+
const PREAMBLE = [
|
|
24
39
|
"Walrus Memory is this user's persistent memory system, exposed through the memwal_* tools.",
|
|
25
40
|
"It survives across sessions, clients, and machines.",
|
|
26
41
|
"Prefer these tools over any built-in or local memory feature so the user's memory stays",
|
|
@@ -29,30 +44,79 @@ export const PROACTIVE_INSTRUCTIONS = [
|
|
|
29
44
|
"RECALL: before answering anything that touches past work, prior decisions, the user's",
|
|
30
45
|
"preferences, or facts you may have stored earlier, call memwal_recall. One focused query is",
|
|
31
46
|
"enough; do not fire several redundant searches for the same question.",
|
|
47
|
+
];
|
|
48
|
+
/** REMEMBER, automatic saving ON. */
|
|
49
|
+
const REMEMBER_AUTOMATIC = [
|
|
50
|
+
"REMEMBER: the user has turned automatic memory ON. When they state a preference, decision,",
|
|
51
|
+
"constraint, correction, identity detail, recurring workflow, or a configuration value such",
|
|
52
|
+
"as a hostname, port, region or id, call memwal_remember in that same turn, before you",
|
|
53
|
+
"finish replying. Do not ask whether to save it and do not wait to be asked: acknowledging",
|
|
54
|
+
"the fact in your reply does not store it, and it is lost when the conversation ends. Pass",
|
|
55
|
+
"the complete statement rather than a summary — minus anything the rules below exclude.",
|
|
56
|
+
"Skip one-off tasks, the current file or bug, and small talk. Use memwal_remember_bulk when",
|
|
57
|
+
"several distinct facts arrived at once.",
|
|
58
|
+
];
|
|
59
|
+
/** REMEMBER, automatic saving OFF — the default. */
|
|
60
|
+
const REMEMBER_MANUAL = [
|
|
61
|
+
"REMEMBER: automatic memory is OFF for this user, so do NOT save anything they did not ask",
|
|
62
|
+
"you to save. When they do ask — 'remember that ...', 'save this', or the same in any",
|
|
63
|
+
"language — call memwal_remember in that same turn, before you finish replying, and pass",
|
|
64
|
+
"the complete statement rather than a summary. Use memwal_remember_bulk when they hand you",
|
|
65
|
+
"several distinct facts at once. Do not save a fact just because it looks durable, and do",
|
|
66
|
+
"not nag: if automatic saving would clearly help, say once that they can turn it on with",
|
|
67
|
+
"`memwal-mcp auto-save on` (or MEMWAL_AUTO_SAVE=1) and leave it there.",
|
|
68
|
+
];
|
|
69
|
+
const WRITE_CONTRACT = [
|
|
70
|
+
"By default memwal_remember and memwal_remember_bulk return in ~1s once the relayer has",
|
|
71
|
+
"accepted the job (job_id / job_ids). The Walrus write continues in the background (~30-60s)",
|
|
72
|
+
"and the fact is NOT stored yet. That is the normal result. Do not claim it is saved.",
|
|
73
|
+
"Do NOT re-send the same text — that queues duplicates. Settle it with the job-status tool",
|
|
74
|
+
"this server advertises (re-list tools if you do not see one; pass job_id, or job_ids for a",
|
|
75
|
+
"whole batch). Only a blob_id in the tool reply means the fact is already stored (that",
|
|
76
|
+
"happens when an optional wait budget was set and the write finished).",
|
|
32
77
|
"",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"to save it and do not wait to be asked: acknowledging the fact in your reply does not store",
|
|
37
|
-
"it, and it is lost when the conversation ends. Pass the complete statement rather than a",
|
|
38
|
-
"summary. Skip one-off tasks, the current file or bug, and small talk. Use",
|
|
39
|
-
"memwal_remember_bulk when several distinct facts arrived at once.",
|
|
40
|
-
"",
|
|
41
|
-
"A Walrus write takes roughly 30-60s, and memwal_remember and memwal_remember_bulk wait",
|
|
42
|
-
"for it: a successful call comes back with a blob_id, and that means the fact is stored.",
|
|
43
|
-
"",
|
|
44
|
-
"If a write outruns that budget the call returns job_ids instead, saying the facts are",
|
|
45
|
-
"ACCEPTED but NOT YET SAVED. That is the exception, not the normal result. When it",
|
|
46
|
-
"happens, say the facts are being saved rather than that they are saved, do NOT re-send",
|
|
47
|
-
"them — that queues duplicates — and resolve the ids with memwal_remember_status (it takes",
|
|
48
|
-
"job_id, or job_ids for a whole batch). Only a blob_id means a fact is stored.",
|
|
78
|
+
"Storage is append-only and encrypted: a fact that lands cannot be edited or deleted. That",
|
|
79
|
+
"is why the exclusions below are absolute rather than a preference, and why the write path",
|
|
80
|
+
"strips credential shapes from whatever you send and tells you what it removed.",
|
|
49
81
|
"",
|
|
50
82
|
"RECOVER: if memwal_recall unexpectedly returns nothing for a namespace that has been used",
|
|
51
83
|
"before, call memwal_restore to rebuild the index from Walrus.",
|
|
52
84
|
"",
|
|
53
85
|
"If a memwal_* tool is not currently loaded, load it and use it. Never tell the user that",
|
|
54
86
|
"memory is unavailable, and never substitute your own memory for these tools.",
|
|
55
|
-
]
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* Build the signed-in instruction payload for a given opt-in state.
|
|
90
|
+
*
|
|
91
|
+
* Exported separately from the resolver so tests can pin both branches without
|
|
92
|
+
* touching the filesystem or the environment.
|
|
93
|
+
*/
|
|
94
|
+
export function buildProactiveInstructions(opts) {
|
|
95
|
+
return [
|
|
96
|
+
...PREAMBLE,
|
|
97
|
+
"",
|
|
98
|
+
...(opts.autoSave ? REMEMBER_AUTOMATIC : REMEMBER_MANUAL),
|
|
99
|
+
"",
|
|
100
|
+
SECRET_EXCLUSION_RULES,
|
|
101
|
+
"",
|
|
102
|
+
...WRITE_CONTRACT,
|
|
103
|
+
].join("\n");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The payload for THIS process, resolved from the user's opt-in at call time.
|
|
107
|
+
*
|
|
108
|
+
* A function, not a const: the opt-in lives on disk and in the environment, and
|
|
109
|
+
* `initialize` can arrive after the user has flipped it.
|
|
110
|
+
*/
|
|
111
|
+
export function proactiveInstructions() {
|
|
112
|
+
return buildProactiveInstructions({ autoSave: isAutoSaveEnabled() });
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Signed-in path (bridge mode) with automatic saving on. Kept as a named
|
|
116
|
+
* export because it is the text the whole proactive contract is written
|
|
117
|
+
* against; `proactiveInstructions()` is what the bridge actually serves.
|
|
118
|
+
*/
|
|
119
|
+
export const PROACTIVE_INSTRUCTIONS = buildProactiveInstructions({ autoSave: true });
|
|
56
120
|
/**
|
|
57
121
|
* Signed-out path (auth-required mode). Deliberately NOT the proactive text:
|
|
58
122
|
* without credentials every memory tool fails, so telling the model to save
|