@mysten-incubation/memwal-mcp 0.0.14-dev.4 → 0.0.14-dev.6

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.
@@ -21,9 +21,21 @@
21
21
  * does not advertise (`memwal_remember_status` is the worked example — GH
22
22
  * #928). The sidecar copy may name it; that process actually registers the
23
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.
24
33
  */
25
- /** Signed-in path (bridge mode). Full proactive contract. */
26
- export const PROACTIVE_INSTRUCTIONS = [
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 = [
27
39
  "Walrus Memory is this user's persistent memory system, exposed through the memwal_* tools.",
28
40
  "It survives across sessions, clients, and machines.",
29
41
  "Prefer these tools over any built-in or local memory feature so the user's memory stays",
@@ -32,15 +44,29 @@ export const PROACTIVE_INSTRUCTIONS = [
32
44
  "RECALL: before answering anything that touches past work, prior decisions, the user's",
33
45
  "preferences, or facts you may have stored earlier, call memwal_recall. One focused query is",
34
46
  "enough; do not fire several redundant searches for the same question.",
35
- "",
36
- "REMEMBER: when the user states a preference, decision, constraint, correction, identity",
37
- "detail, recurring workflow, or a configuration value such as a hostname, port, region or",
38
- "id, call memwal_remember in that same turn, before you finish replying. Do not ask whether",
39
- "to save it and do not wait to be asked: acknowledging the fact in your reply does not store",
40
- "it, and it is lost when the conversation ends. Pass the complete statement rather than a",
41
- "summary. Skip one-off tasks, the current file or bug, and small talk. Use",
42
- "memwal_remember_bulk when several distinct facts arrived at once.",
43
- "",
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 = [
44
70
  "By default memwal_remember and memwal_remember_bulk return in ~1s once the relayer has",
45
71
  "accepted the job (job_id / job_ids). The Walrus write continues in the background (~30-60s)",
46
72
  "and the fact is NOT stored yet. That is the normal result. Do not claim it is saved.",
@@ -49,12 +75,48 @@ export const PROACTIVE_INSTRUCTIONS = [
49
75
  "whole batch). Only a blob_id in the tool reply means the fact is already stored (that",
50
76
  "happens when an optional wait budget was set and the write finished).",
51
77
  "",
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.",
81
+ "",
52
82
  "RECOVER: if memwal_recall unexpectedly returns nothing for a namespace that has been used",
53
83
  "before, call memwal_restore to rebuild the index from Walrus.",
54
84
  "",
55
85
  "If a memwal_* tool is not currently loaded, load it and use it. Never tell the user that",
56
86
  "memory is unavailable, and never substitute your own memory for these tools.",
57
- ].join("\n");
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 });
58
120
  /**
59
121
  * Signed-out path (auth-required mode). Deliberately NOT the proactive text:
60
122
  * without credentials every memory tool fails, so telling the model to save
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAClC,4FAA4F;IAC5F,qDAAqD;IACrD,yFAAyF;IACzF,mCAAmC;IACnC,EAAE;IACF,uFAAuF;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,yFAAyF;IACzF,uEAAuE;CAC1E,CAAC;AAEF,MAAM,cAAc,GAAG;IACnB,wFAAwF;IACxF,6FAA6F;IAC7F,sFAAsF;IACtF,2FAA2F;IAC3F,4FAA4F;IAC5F,uFAAuF;IACvF,uEAAuE;IACvE,EAAE;IACF,2FAA2F;IAC3F,2FAA2F;IAC3F,gFAAgF;IAChF,EAAE;IACF,2FAA2F;IAC3F,+DAA+D;IAC/D,EAAE;IACF,0FAA0F;IAC1F,8EAA8E;CACjF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAA2B;IAClE,OAAO;QACH,GAAG,QAAQ;QACX,EAAE;QACF,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,eAAe,CAAC;QACzD,EAAE;QACF,sBAAsB;QACtB,EAAE;QACF,GAAG,cAAc;KACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACjC,OAAO,0BAA0B,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,4FAA4F;IAC5F,gFAAgF;IAChF,gGAAgG;IAChG,wFAAwF;CAC3F,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Shared automatic-memory policy — the MCP client's copy.
3
+ *
4
+ * Consumed by `instructions.ts` (the MCP `instructions` field, which is the
5
+ * only proactive-usage channel that survives lazy tool loading) and by
6
+ * `auth-required.ts` (the cold-start / signed-out `tools/list`).
7
+ *
8
+ * WALM-642: before this module the secret rules did not exist at all, and the
9
+ * save guidance was written out three times — here, in the plugin hooks, and in
10
+ * the relayer sidecar's tool descriptions — with nothing tying them together.
11
+ * A preference stated next to a password was forwarded whole.
12
+ */
13
+ /**
14
+ * The secret-exclusion and do-not-save rules, stated verbatim by every
15
+ * automatic-save surface.
16
+ *
17
+ * These are model-facing rules, not enforcement. The programmatic backstop is
18
+ * the redactor in the relayer sidecar's write path
19
+ * (services/server/scripts/mcp/tools/redaction.ts), which runs before any text
20
+ * reaches the SDK.
21
+ */
22
+ export declare const SECRET_EXCLUSION_RULES: string;
23
+ /**
24
+ * One-line form, for surfaces with no room for the full block (a per-turn
25
+ * nudge, a tool description tail). It is a reminder of the block above, never a
26
+ * replacement for it: any surface that drives an automatic save states the full
27
+ * `SECRET_EXCLUSION_RULES`.
28
+ */
29
+ export declare const SECRET_EXCLUSION_SUMMARY: string;
30
+ /**
31
+ * Whether to save unprompted is the user's standing choice, and this is the
32
+ * sentence that says so. A direct request ("remember that ...") is never gated
33
+ * by it — the gate is only on saving something the user did not ask you to save.
34
+ */
35
+ export declare const AUTO_SAVE_OPT_IN_RULE: string;
36
+ /** Bumped whenever the text above changes, so a stale copy is identifiable. */
37
+ export declare const MEMORY_POLICY_VERSION = "2026-09-17.2";
38
+ //# sourceMappingURL=memory-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-policy.d.ts","sourceRoot":"","sources":["../src/memory-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuBH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAWxB,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAI1B,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAMvB,CAAC;AAEZ,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,iBAAiB,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Shared automatic-memory policy — the MCP client's copy.
3
+ *
4
+ * Consumed by `instructions.ts` (the MCP `instructions` field, which is the
5
+ * only proactive-usage channel that survives lazy tool loading) and by
6
+ * `auth-required.ts` (the cold-start / signed-out `tools/list`).
7
+ *
8
+ * WALM-642: before this module the secret rules did not exist at all, and the
9
+ * save guidance was written out three times — here, in the plugin hooks, and in
10
+ * the relayer sidecar's tool descriptions — with nothing tying them together.
11
+ * A preference stated next to a password was forwarded whole.
12
+ */
13
+ // ─── memwal:policy-block:start ───────────────────────────────────────────────
14
+ // WALM-642. The lines between these two markers are BYTE-IDENTICAL in three
15
+ // files that cannot import one another, because the three packages have no
16
+ // workspace link:
17
+ //
18
+ // packages/mcp/src/memory-policy.ts — MCP client: initialize
19
+ // instructions + the
20
+ // cold-start tools/list
21
+ // packages/mcp/plugin/scripts/lib/memory-policy.mjs — plugin hooks: the
22
+ // guidance injected at
23
+ // SessionStart /
24
+ // UserPromptSubmit /
25
+ // PostToolUse
26
+ // services/server/scripts/mcp/tools/memory-policy.ts — relayer sidecar: the
27
+ // live tool descriptions
28
+ //
29
+ // The duplication is deliberate and pinned: `memory-policy-sync` tests on both
30
+ // sides extract this block from each file and compare the bytes, so editing one
31
+ // copy fails the suite until the other two match. Edit the block, then copy it
32
+ // verbatim — markers included — into the other two files.
33
+ /**
34
+ * The secret-exclusion and do-not-save rules, stated verbatim by every
35
+ * automatic-save surface.
36
+ *
37
+ * These are model-facing rules, not enforcement. The programmatic backstop is
38
+ * the redactor in the relayer sidecar's write path
39
+ * (services/server/scripts/mcp/tools/redaction.ts), which runs before any text
40
+ * reaches the SDK.
41
+ */
42
+ export const SECRET_EXCLUSION_RULES = [
43
+ "NEVER save a credential, even when it sits next to something worth saving: passwords,",
44
+ "API keys, access or refresh tokens, private keys, seed or recovery phrases, authorization",
45
+ "headers, session cookies, and connection strings or URLs that embed a user:password.",
46
+ "When a message mixes a preference with a credential, save the preference alone and leave",
47
+ "the credential out; never store the line verbatim.",
48
+ "If the user says not to save something ('don't save this', 'off the record', or the same",
49
+ "in any language), do not save it, and do not save a paraphrase of it either.",
50
+ "Do not store quoted or pasted third-party material — log excerpts, code, articles, other",
51
+ "people's messages — as if it were a fact about this user. Save only what the user is",
52
+ "telling you about themselves or their work, in your own words.",
53
+ ].join(" ");
54
+ /**
55
+ * One-line form, for surfaces with no room for the full block (a per-turn
56
+ * nudge, a tool description tail). It is a reminder of the block above, never a
57
+ * replacement for it: any surface that drives an automatic save states the full
58
+ * `SECRET_EXCLUSION_RULES`.
59
+ */
60
+ export const SECRET_EXCLUSION_SUMMARY = [
61
+ "Never save passwords, keys, tokens or other credentials — not even beside a fact worth",
62
+ "saving; honour an explicit 'do not save this'; never store pasted third-party content as",
63
+ "a fact about the user.",
64
+ ].join(" ");
65
+ /**
66
+ * Whether to save unprompted is the user's standing choice, and this is the
67
+ * sentence that says so. A direct request ("remember that ...") is never gated
68
+ * by it — the gate is only on saving something the user did not ask you to save.
69
+ */
70
+ export const AUTO_SAVE_OPT_IN_RULE = [
71
+ "Whether to save things the user did not ask you to save is their standing choice, made once",
72
+ "in a terminal. When automatic memory is on, save durable facts as they state them; when it is",
73
+ "off, save only what they ask you to save in that turn. That question is put by `memwal-mcp",
74
+ "login` and set by `memwal-mcp auto-save on|off` — never ask the user to answer it in chat,",
75
+ "and never answer it on their behalf.",
76
+ ].join(" ");
77
+ /** Bumped whenever the text above changes, so a stale copy is identifiable. */
78
+ export const MEMORY_POLICY_VERSION = "2026-09-17.2";
79
+ // ─── memwal:policy-block:end ─────────────────────────────────────────────────
80
+ //# sourceMappingURL=memory-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-policy.js","sourceRoot":"","sources":["../src/memory-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,gFAAgF;AAChF,4EAA4E;AAC5E,2EAA2E;AAC3E,kBAAkB;AAClB,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,wEAAwE;AACxE,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,gFAAgF;AAChF,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,0DAA0D;AAE1D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAClC,uFAAuF;IACvF,2FAA2F;IAC3F,sFAAsF;IACtF,0FAA0F;IAC1F,oDAAoD;IACpD,0FAA0F;IAC1F,8EAA8E;IAC9E,0FAA0F;IAC1F,sFAAsF;IACtF,gEAAgE;CACnE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,wFAAwF;IACxF,0FAA0F;IAC1F,wBAAwB;CAC3B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,6FAA6F;IAC7F,+FAA+F;IAC/F,4FAA4F;IAC5F,4FAA4F;IAC5F,sCAAsC;CACzC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,+EAA+E;AAC/E,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,gFAAgF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/memwal-mcp",
3
- "version": "0.0.14-dev.4",
3
+ "version": "0.0.14-dev.6",
4
4
  "description": "Walrus Memory MCP client — single-binary stdio MCP server that bridges Cursor / Claude Desktop / Antigravity / Claude Code to the Walrus Memory relayer. Handles browser-based wallet login on first run.",
5
5
  "type": "module",
6
6
  "engines": {