@mysten-incubation/memwal 0.0.7 → 0.1.0-dev.1

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/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute
108
+ must include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -6,7 +6,7 @@ Walrus Memory SDK for storing encrypted AI memories on Walrus and retrieving the
6
6
 
7
7
  ## Documentation
8
8
 
9
- For full documentation, visit [docs.memwal.ai](https://docs.memwal.ai).
9
+ For full documentation, visit [memory.walrus.xyz](https://memory.walrus.xyz).
10
10
 
11
11
  ## Install
12
12
 
@@ -20,6 +20,18 @@ Peer dependencies (install as needed):
20
20
  pnpm add @mysten/sui @mysten/seal @mysten/walrus ai zod
21
21
  ```
22
22
 
23
+ ### Version compatibility
24
+
25
+ `@mysten/seal` and `@mysten/walrus` must both resolve to versions that accept the same `@mysten/sui` major. Known-good matrix:
26
+
27
+ | Package | Version |
28
+ | --- | --- |
29
+ | `@mysten/sui` | `^2.16.2` |
30
+ | `@mysten/seal` | `^1.1.3` |
31
+ | `@mysten/walrus` | `^1.1.7` |
32
+
33
+ `@mysten/walrus@0.x` bundles `@mysten/sui@1.x` and cannot coexist with `@mysten/seal@1.x`, which requires `@mysten/sui@^2.x`. If `npm install` fails with `ERESOLVE` mentioning `@mysten/sui@^1.x`, upgrade `@mysten/walrus` to `^1.1.7`, refresh your lockfile, and run `npm why @mysten/sui` to find any remaining dependency that pins sui v1.
34
+
23
35
  ## Quick Start
24
36
 
25
37
  ```ts
@@ -28,7 +40,7 @@ import { MemWal } from "@mysten-incubation/memwal";
28
40
  const memwal = MemWal.create({
29
41
  key: process.env.MEMWAL_PRIVATE_KEY!,
30
42
  accountId: process.env.MEMWAL_ACCOUNT_ID!,
31
- serverUrl: process.env.MEMWAL_SERVER_URL ?? "https://relayer.memwal.ai",
43
+ serverUrl: process.env.MEMWAL_SERVER_URL ?? "https://relayer.memory.walrus.xyz",
32
44
  namespace: "demo",
33
45
  });
34
46
 
package/dist/account.d.ts CHANGED
@@ -21,6 +21,7 @@
21
21
  * // Add the delegate key
22
22
  * await addDelegateKey({
23
23
  * packageId: "0x...",
24
+ * registryId: "0x...",
24
25
  * accountId: account.accountId,
25
26
  * publicKey: delegate.publicKey,
26
27
  * label: "My Laptop",
@@ -44,7 +45,8 @@ export declare function createAccount(opts: CreateAccountOpts): Promise<CreateAc
44
45
  /**
45
46
  * Add a delegate key to a MemWalAccount.
46
47
  *
47
- * Calls `{packageId}::account::add_delegate_key(account, public_key, sui_address, label, clock)`.
48
+ * Calls `{packageId}::account::add_delegate_key(account, registry, public_key, label, clock)`.
49
+ * The contract derives the Sui address from the Ed25519 public key on-chain.
48
50
  * Only the account owner can add delegate keys.
49
51
  *
50
52
  * @param opts.publicKey - Ed25519 public key (32 bytes Uint8Array or hex string)
@@ -55,9 +57,12 @@ export declare function addDelegateKey(opts: AddDelegateKeyOpts): Promise<AddDel
55
57
  /**
56
58
  * Remove a delegate key from a MemWalAccount.
57
59
  *
58
- * Calls `{packageId}::account::remove_delegate_key(account, public_key)`.
60
+ * Calls `{packageId}::account::remove_delegate_key(account, registry, public_key)`.
59
61
  * Only the account owner can remove delegate keys.
60
62
  *
63
+ * Forward-only: this stops the key from reading memories saved *after* removal,
64
+ * but memories already saved stay readable by it until re-encrypted.
65
+ *
61
66
  * @param opts.publicKey - Ed25519 public key to remove (32 bytes Uint8Array or hex string)
62
67
  */
63
68
  export declare function removeDelegateKey(opts: RemoveDelegateKeyOpts): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAER,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,YAAY,CAAC;AA4GpB;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAC/B,IAAI,EAAE,iBAAiB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA4C9B;AAMD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAChC,IAAI,EAAE,kBAAkB,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAyC/B;AAMD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACnC,IAAI,EAAE,qBAAqB,GAC5B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAwB7B;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC,CAqBD"}
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAER,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,YAAY,CAAC;AAmIpB;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAC/B,IAAI,EAAE,iBAAiB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA2D9B;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAChC,IAAI,EAAE,kBAAkB,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAyC/B;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACnC,IAAI,EAAE,qBAAqB,GAC5B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAyB7B;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC,CAqBD"}
package/dist/account.js CHANGED
@@ -21,6 +21,7 @@
21
21
  * // Add the delegate key
22
22
  * await addDelegateKey({
23
23
  * packageId: "0x...",
24
+ * registryId: "0x...",
24
25
  * accountId: account.accountId,
25
26
  * publicKey: delegate.publicKey,
26
27
  * label: "My Laptop",
@@ -36,6 +37,9 @@ import { bytesToHex, hexToBytes } from "./utils.js";
36
37
  // SUI Clock object (shared, always 0x6)
37
38
  // ============================================================
38
39
  const SUI_CLOCK = "0x0000000000000000000000000000000000000000000000000000000000000006";
40
+ function transactionData(result) {
41
+ return result?.Transaction ?? result?.FailedTransaction ?? result;
42
+ }
39
43
  async function buildTxContext(opts) {
40
44
  if (!opts.suiPrivateKey && !opts.walletSigner) {
41
45
  throw new Error("Provide either suiPrivateKey or walletSigner");
@@ -83,26 +87,43 @@ async function buildTxContext(opts) {
83
87
  };
84
88
  }
85
89
  async function signAndExecute(ctx, tx) {
90
+ let executionResult;
86
91
  if ("signAndExecuteTransaction" in ctx.signer && typeof ctx.signer.signAndExecuteTransaction === "function" && "address" in ctx.signer) {
87
92
  // WalletSigner mode
88
- const result = await ctx.signer.signAndExecuteTransaction({ transaction: tx });
89
- // Wait for transaction to be confirmed
90
- const txResult = await ctx.suiClient.waitForTransaction({
91
- digest: result.digest,
92
- options: { showEffects: true, showObjectChanges: true },
93
+ executionResult = await ctx.signer.signAndExecuteTransaction({ transaction: tx });
94
+ }
95
+ else {
96
+ // Keypair mode
97
+ executionResult = await ctx.suiClient.signAndExecuteTransaction({
98
+ signer: ctx.signer,
99
+ transaction: tx,
93
100
  });
94
- return { digest: result.digest, effects: txResult };
95
101
  }
96
- // Keypair mode
97
- const result = await ctx.suiClient.signAndExecuteTransaction({
98
- signer: ctx.signer,
99
- transaction: tx,
100
- });
102
+ const digest = transactionData(executionResult)?.digest;
103
+ if (typeof digest !== "string" || !digest) {
104
+ throw new Error("Transaction submission returned no digest");
105
+ }
106
+ // Execution can return a digest even when the Move transaction aborts.
107
+ // Send both option dialects: legacy JSON-RPC ignores `include`, while the
108
+ // v2 clients ignore `options`. Both clients can wait by digest.
101
109
  const txResult = await ctx.suiClient.waitForTransaction({
102
- digest: result.digest,
110
+ digest,
111
+ include: { effects: true, objectTypes: true },
103
112
  options: { showEffects: true, showObjectChanges: true },
104
113
  });
105
- return { digest: result.digest, effects: txResult };
114
+ const txData = transactionData(txResult);
115
+ const status = txData?.status ?? txData?.effects?.status;
116
+ const success = status?.success === true ||
117
+ (status?.success === undefined && status?.status === "success");
118
+ if (!success) {
119
+ const detail = typeof status?.error === "string"
120
+ ? status.error
121
+ : status?.error
122
+ ? JSON.stringify(status.error)
123
+ : "missing execution status";
124
+ throw new Error(`Transaction ${digest} failed: ${detail}`);
125
+ }
126
+ return { digest, effects: txResult };
106
127
  }
107
128
  // ============================================================
108
129
  // createAccount
@@ -129,7 +150,8 @@ export async function createAccount(opts) {
129
150
  const { digest, effects } = await signAndExecute(ctx, tx);
130
151
  // Extract the created Walrus Memory account object ID from object changes
131
152
  let accountId = "";
132
- const objectChanges = effects?.objectChanges ?? [];
153
+ const txData = transactionData(effects);
154
+ const objectChanges = txData?.objectChanges ?? [];
133
155
  for (const change of objectChanges) {
134
156
  if (change.type === "created" &&
135
157
  change.objectType?.includes("::account::MemWalAccount")) {
@@ -137,9 +159,20 @@ export async function createAccount(opts) {
137
159
  break;
138
160
  }
139
161
  }
162
+ if (!accountId) {
163
+ const objectTypes = txData?.objectTypes ?? {};
164
+ const changedObjects = txData?.effects?.changedObjects ?? [];
165
+ for (const change of changedObjects) {
166
+ if (change.idOperation === "Created" &&
167
+ objectTypes[change.objectId]?.includes("::account::MemWalAccount")) {
168
+ accountId = change.objectId;
169
+ break;
170
+ }
171
+ }
172
+ }
140
173
  if (!accountId) {
141
174
  // Fallback: try to find from effects
142
- const created = effects?.effects?.created ?? [];
175
+ const created = txData?.effects?.created ?? [];
143
176
  for (const obj of created) {
144
177
  if (obj.owner?.Shared !== undefined) {
145
178
  accountId = obj.reference?.objectId ?? "";
@@ -159,7 +192,8 @@ export async function createAccount(opts) {
159
192
  /**
160
193
  * Add a delegate key to a MemWalAccount.
161
194
  *
162
- * Calls `{packageId}::account::add_delegate_key(account, public_key, sui_address, label, clock)`.
195
+ * Calls `{packageId}::account::add_delegate_key(account, registry, public_key, label, clock)`.
196
+ * The contract derives the Sui address from the Ed25519 public key on-chain.
163
197
  * Only the account owner can add delegate keys.
164
198
  *
165
199
  * @param opts.publicKey - Ed25519 public key (32 bytes Uint8Array or hex string)
@@ -188,8 +222,8 @@ export async function addDelegateKey(opts) {
188
222
  target: `${opts.packageId}::account::add_delegate_key`,
189
223
  arguments: [
190
224
  tx.object(opts.accountId),
225
+ tx.object(opts.registryId),
191
226
  tx.pure("vector<u8>", Array.from(pkBytes)),
192
- tx.pure("address", suiAddress),
193
227
  tx.pure("string", opts.label),
194
228
  tx.object(SUI_CLOCK),
195
229
  ],
@@ -207,9 +241,12 @@ export async function addDelegateKey(opts) {
207
241
  /**
208
242
  * Remove a delegate key from a MemWalAccount.
209
243
  *
210
- * Calls `{packageId}::account::remove_delegate_key(account, public_key)`.
244
+ * Calls `{packageId}::account::remove_delegate_key(account, registry, public_key)`.
211
245
  * Only the account owner can remove delegate keys.
212
246
  *
247
+ * Forward-only: this stops the key from reading memories saved *after* removal,
248
+ * but memories already saved stay readable by it until re-encrypted.
249
+ *
213
250
  * @param opts.publicKey - Ed25519 public key to remove (32 bytes Uint8Array or hex string)
214
251
  */
215
252
  export async function removeDelegateKey(opts) {
@@ -226,6 +263,7 @@ export async function removeDelegateKey(opts) {
226
263
  target: `${opts.packageId}::account::remove_delegate_key`,
227
264
  arguments: [
228
265
  tx.object(opts.accountId),
266
+ tx.object(opts.registryId),
229
267
  tx.pure("vector<u8>", Array.from(pkBytes)),
230
268
  ],
231
269
  });
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAUH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,+DAA+D;AAC/D,wCAAwC;AACxC,+DAA+D;AAC/D,MAAM,SAAS,GAAG,oEAAoE,CAAC;AAavF,KAAK,UAAU,cAAc,CAAC,IAK7B;IACG,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,GAAG,M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AE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAE9D,qBAAqB;IACrB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,sBAAsB;IACvC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACxB,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEnD,OAAO;QACH,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC;QACvC,SAAS;QACT,UAAU;KACb,CAAC;AACN,CAAC"}
@@ -44,12 +44,13 @@ export interface WithMemWalOptions extends MemWalConfig {
44
44
  * BEFORE each LLM call:
45
45
  * - Uses the last user message as a search query
46
46
  * - Recalls relevant memories (server: search → download → decrypt)
47
- * - Injects relevant memories into the system prompt
47
+ * - Injects relevant memories as nonce-delimited, untrusted user data
48
48
  *
49
49
  * AFTER each LLM call:
50
50
  * - Analyzes and saves important facts (server: LLM extract → embed → encrypt → Walrus → store)
51
51
  * - Fire-and-forget — does not block the response
52
52
  */
53
53
  export declare function withMemWal(model: AnyLanguageModel, options: WithMemWalOptions): any;
54
+ export declare function injectMemoryContext(prompt: unknown, memoryContext: string): unknown;
54
55
  export {};
55
56
  //# sourceMappingURL=middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/ai/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAM9D;;;;;GAKG;AAEH,KAAK,gBAAgB,GAAG,GAAG,CAAC;AAE5B,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACnD,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,iBAAiB,OAmF7B"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/ai/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAU9D;;;;;GAKG;AAEH,KAAK,gBAAgB,GAAG,GAAG,CAAC;AAE5B,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACnD,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,iBAAiB,OAoG7B;AA0BD,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,OAAO,EACf,aAAa,EAAE,MAAM,GACtB,OAAO,CAuCT"}
@@ -22,6 +22,7 @@
22
22
  */
23
23
  import { wrapLanguageModel } from "ai";
24
24
  import { MemWal } from "../memwal.js";
25
+ import { formatUntrustedMemories, UNTRUSTED_MEMORY_SYSTEM_INSTRUCTION, } from "./untrusted-memory.js";
25
26
  // ============================================================
26
27
  // Middleware
27
28
  // ============================================================
@@ -31,7 +32,7 @@ import { MemWal } from "../memwal.js";
31
32
  * BEFORE each LLM call:
32
33
  * - Uses the last user message as a search query
33
34
  * - Recalls relevant memories (server: search → download → decrypt)
34
- * - Injects relevant memories into the system prompt
35
+ * - Injects relevant memories as nonce-delimited, untrusted user data
35
36
  *
36
37
  * AFTER each LLM call:
37
38
  * - Analyzes and saves important facts (server: LLM extract → embed → encrypt → Walrus → store)
@@ -46,7 +47,18 @@ export function withMemWal(model, options) {
46
47
  const log = debug
47
48
  ? (...args) => console.warn("[Walrus Memory]", ...args)
48
49
  : () => { };
49
- return wrapLanguageModel({
50
+ // Fire-and-forget auto-save writes are tracked here so short-lived
51
+ // callers (CLI scripts, serverless handlers) can await them via
52
+ // flush() before the process exits, instead of losing them silently.
53
+ const pendingSaves = new Set();
54
+ function saveInBackground(userMessage) {
55
+ const savePromise = memwal
56
+ .analyze(userMessage)
57
+ .catch((err) => log("Auto-save failed:", err));
58
+ pendingSaves.add(savePromise);
59
+ savePromise.finally(() => pendingSaves.delete(savePromise));
60
+ }
61
+ const wrapped = wrapLanguageModel({
50
62
  model,
51
63
  middleware: {
52
64
  specificationVersion: 'v3', // Required by ai SDK v6+; ignored by v4/v5
@@ -63,7 +75,7 @@ export function withMemWal(model, options) {
63
75
  const relevant = recallResult.results.filter((m) => (1 - m.distance) >= minRelevance);
64
76
  if (relevant.length === 0)
65
77
  return params;
66
- const memoryContext = formatMemories(relevant);
78
+ const memoryContext = formatUntrustedMemories(relevant);
67
79
  const enrichedPrompt = injectMemoryContext(params.prompt, memoryContext);
68
80
  log(`🔍 Found ${relevant.length} relevant memories`);
69
81
  return { ...params, prompt: enrichedPrompt };
@@ -81,7 +93,7 @@ export function withMemWal(model, options) {
81
93
  if (autoSave) {
82
94
  const userMessage = findLastUserMessage(params.prompt);
83
95
  if (userMessage) {
84
- memwal.analyze(userMessage).catch((err) => log("Auto-save failed:", err));
96
+ saveInBackground(userMessage);
85
97
  }
86
98
  }
87
99
  return result;
@@ -92,13 +104,19 @@ export function withMemWal(model, options) {
92
104
  if (autoSave) {
93
105
  const userMessage = findLastUserMessage(params.prompt);
94
106
  if (userMessage) {
95
- memwal.analyze(userMessage).catch((err) => log("Auto-save failed:", err));
107
+ saveInBackground(userMessage);
96
108
  }
97
109
  }
98
110
  return result;
99
111
  },
100
112
  },
101
113
  });
114
+ // Lets short-lived callers await outstanding auto-save writes before
115
+ // exiting, e.g. `await model.flush()` right before `process.exit()`.
116
+ wrapped.flush = async () => {
117
+ await Promise.allSettled([...pendingSaves]);
118
+ };
119
+ return wrapped;
102
120
  }
103
121
  // ============================================================
104
122
  // Helpers
@@ -121,25 +139,34 @@ function findLastUserMessage(prompt) {
121
139
  }
122
140
  return null;
123
141
  }
124
- function formatMemories(memories) {
125
- const lines = memories.map((m) => `- ${m.text} (relevance: ${(1 - m.distance).toFixed(2)})`);
126
- return `[Memory Context] The following are known facts about this user from their personal memory store. Use these facts to answer the user's question:\n${lines.join("\n")}`;
127
- }
128
- function injectMemoryContext(prompt, memoryContext) {
142
+ export function injectMemoryContext(prompt, memoryContext) {
129
143
  if (!Array.isArray(prompt))
130
144
  return prompt;
131
- // Insert memory as a separate system message right before the last user message
132
- // This ensures the LLM sees it prominently, not buried in a long system prompt
145
+ // Keep the fixed trust policy in a system message, but recalled bytes only
146
+ // in a separate user message. No memory-controlled text receives system
147
+ // priority.
133
148
  const lastUserIndex = prompt.reduce((idx, m, i) => (m.role === "user" ? i : idx), -1);
134
149
  if (lastUserIndex > 0) {
135
150
  const result = [...prompt];
136
151
  result.splice(lastUserIndex, 0, {
137
152
  role: "system",
138
- content: memoryContext,
153
+ content: UNTRUSTED_MEMORY_SYSTEM_INSTRUCTION,
154
+ }, {
155
+ role: "user",
156
+ content: [{ type: "text", text: memoryContext }],
139
157
  });
140
158
  return result;
141
159
  }
142
- // Fallback: prepend as system message
143
- return [{ role: "system", content: memoryContext }, ...prompt];
160
+ return [
161
+ {
162
+ role: "system",
163
+ content: UNTRUSTED_MEMORY_SYSTEM_INSTRUCTION,
164
+ },
165
+ {
166
+ role: "user",
167
+ content: [{ type: "text", text: memoryContext }],
168
+ },
169
+ ...prompt,
170
+ ];
144
171
  }
145
172
  //# sourceMappingURL=middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/ai/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA2BtC,+DAA+D;AAC/D,aAAa;AACb,+DAA+D;AAE/D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CACtB,KAAuB,EACvB,OAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;IAC1C,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IAErC,MAAM,GAAG,GAAG,KAAK;QACb,CAAC,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC;QAClE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAEhB,OAAQ,iBAAyB,CAAC;QAC9B,KAAK;QACL,UAAU,EAAE;YACR,oBAAoB,EAAE,IAAI,EAAE,2CAA2C;YACvE,+DAA+D;YAC/D,+CAA+C;YAC/C,+DAA+D;YAC/D,eAAe,EAAE,KAAK,EAAE,EAAE,MAAM,EAAO,EAAE,EAAE;gBACvC,IAAI,CAAC;oBACD,MAAM,eAAe,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC3D,I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,CAAC,EACD;YACI,IAAI,EAAE,QAAiB;YACvB,OAAO,EAAE,mCAAmC;SAC/C,EACD;YACI,IAAI,EAAE,MAAe;YACrB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;SAC5D,CACJ,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,OAAO;QACH;YACI,IAAI,EAAE,QAAiB;YACvB,OAAO,EAAE,mCAAmC;SAC/C;QACD;YACI,IAAI,EAAE,MAAe;YACrB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;SAC5D;QACD,GAAG,MAAM;KACZ,CAAC;AACN,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { RecallMemory } from "../types.js";
2
+ export declare const UNTRUSTED_MEMORY_SYSTEM_INSTRUCTION: string;
3
+ /**
4
+ * Serialize recalled text as untrusted data behind a fresh, unpredictable
5
+ * request boundary. JSON encoding prevents memory-controlled newlines from
6
+ * changing the surrounding record structure. The nonce is generated only
7
+ * after recall, so stored content cannot pre-forge the closing delimiter.
8
+ */
9
+ export declare function formatUntrustedMemories(memories: RecallMemory[], nonce?: string): string;
10
+ //# sourceMappingURL=untrusted-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"untrusted-memory.d.ts","sourceRoot":"","sources":["../../src/ai/untrusted-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,mCAAmC,QAKC,CAAC;AAQlD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,YAAY,EAAE,EACxB,KAAK,SAAwB,GAC9B,MAAM,CAoBR"}