@anuma/sdk 1.2.2 → 1.3.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.
@@ -47,8 +47,10 @@ import { ResultCallback } from '@nozbe/watermelondb/utils/fp/Result';
47
47
  * - v33: Added embedding_model column to memory_vault so stale-model vectors are
48
48
  * detectable and re-embeddable after an embedding-model change (null = legacy
49
49
  * rows, grandfathered as compatible with the current model)
50
+ * - v35: Added conversation_memory table recording which vault memories a
51
+ * conversation drew on, so the conversation-level Memories panel survives reload
50
52
  */
51
- declare const SDK_SCHEMA_VERSION = 34;
53
+ declare const SDK_SCHEMA_VERSION = 35;
52
54
  /**
53
55
  * Combined WatermelonDB schema for all SDK storage modules.
54
56
  *
@@ -126,6 +128,7 @@ declare const sdkSchema: Readonly<{
126
128
  * - v30 → v31: Added `user_id` column to memory_entity for multi-user scoping of the W5 graph lane (with backfill from memory_vault.user_id)
127
129
  * - v31 → v32: Added `pinned_at` column to conversations for pinning chats
128
130
  * - v32 → v33: Added `embedding_model` column to memory_vault (null grandfathered as current-model-compatible)
131
+ * - v34 → v35: Added `conversation_memory` table (conversation ↔ recalled memory ids)
129
132
  */
130
133
  declare const sdkMigrations: Readonly<{
131
134
  validated: true;
@@ -245,8 +248,18 @@ interface DatabaseManagerOptions {
245
248
  * ```
246
249
  */
247
250
  declare class DatabaseManager {
248
- private database;
249
- private currentWalletAddress;
251
+ /**
252
+ * WatermelonDB instances cached by their derived `dbName` (not by raw wallet
253
+ * address). Caching per dbName makes {@link getDatabase} idempotent: a wallet
254
+ * that is requested again — including after a transient `undefined`/guest
255
+ * excursion or an address that briefly arrives in a different form during
256
+ * sign-up — reuses the SAME instance instead of being torn down and rebuilt.
257
+ * The rebuild was what left the web OPFS adapter disposed/orphaned mid-session
258
+ * (client#4821). Instances are kept for the lifetime of the manager (typically
259
+ * guest + one wallet); switching wallets keeps prior ones cached rather than
260
+ * disposing an instance the app may still hold a reference to.
261
+ */
262
+ private readonly databases;
250
263
  private migrationInProgress;
251
264
  private readonly dbNamePrefix;
252
265
  private readonly createAdapter;
@@ -261,8 +274,9 @@ declare class DatabaseManager {
261
274
  /**
262
275
  * Get or create a WatermelonDB Database instance for the given wallet.
263
276
  *
264
- * If the wallet address has changed since the last call, the previous
265
- * database instance is discarded and a new one is created.
277
+ * Instances are cached per derived dbName and reused across calls (including
278
+ * repeat/guest-interleaved requests for the same wallet); a new one is built
279
+ * only for a dbName not yet seen. See the `databases` field for why.
266
280
  *
267
281
  * @param walletAddress - The wallet address to scope the database to.
268
282
  * If undefined, uses a "guest" database.
@@ -271,7 +285,7 @@ declare class DatabaseManager {
271
285
  */
272
286
  getDatabase(walletAddress?: string): Database;
273
287
  /**
274
- * Reset the current database (useful for logout or testing).
288
+ * Reset ALL cached databases (useful for logout or testing).
275
289
  */
276
290
  resetDatabase(): Promise<void>;
277
291
  /**
@@ -47,8 +47,10 @@ import { ResultCallback } from '@nozbe/watermelondb/utils/fp/Result';
47
47
  * - v33: Added embedding_model column to memory_vault so stale-model vectors are
48
48
  * detectable and re-embeddable after an embedding-model change (null = legacy
49
49
  * rows, grandfathered as compatible with the current model)
50
+ * - v35: Added conversation_memory table recording which vault memories a
51
+ * conversation drew on, so the conversation-level Memories panel survives reload
50
52
  */
51
- declare const SDK_SCHEMA_VERSION = 34;
53
+ declare const SDK_SCHEMA_VERSION = 35;
52
54
  /**
53
55
  * Combined WatermelonDB schema for all SDK storage modules.
54
56
  *
@@ -126,6 +128,7 @@ declare const sdkSchema: Readonly<{
126
128
  * - v30 → v31: Added `user_id` column to memory_entity for multi-user scoping of the W5 graph lane (with backfill from memory_vault.user_id)
127
129
  * - v31 → v32: Added `pinned_at` column to conversations for pinning chats
128
130
  * - v32 → v33: Added `embedding_model` column to memory_vault (null grandfathered as current-model-compatible)
131
+ * - v34 → v35: Added `conversation_memory` table (conversation ↔ recalled memory ids)
129
132
  */
130
133
  declare const sdkMigrations: Readonly<{
131
134
  validated: true;
@@ -245,8 +248,18 @@ interface DatabaseManagerOptions {
245
248
  * ```
246
249
  */
247
250
  declare class DatabaseManager {
248
- private database;
249
- private currentWalletAddress;
251
+ /**
252
+ * WatermelonDB instances cached by their derived `dbName` (not by raw wallet
253
+ * address). Caching per dbName makes {@link getDatabase} idempotent: a wallet
254
+ * that is requested again — including after a transient `undefined`/guest
255
+ * excursion or an address that briefly arrives in a different form during
256
+ * sign-up — reuses the SAME instance instead of being torn down and rebuilt.
257
+ * The rebuild was what left the web OPFS adapter disposed/orphaned mid-session
258
+ * (client#4821). Instances are kept for the lifetime of the manager (typically
259
+ * guest + one wallet); switching wallets keeps prior ones cached rather than
260
+ * disposing an instance the app may still hold a reference to.
261
+ */
262
+ private readonly databases;
250
263
  private migrationInProgress;
251
264
  private readonly dbNamePrefix;
252
265
  private readonly createAdapter;
@@ -261,8 +274,9 @@ declare class DatabaseManager {
261
274
  /**
262
275
  * Get or create a WatermelonDB Database instance for the given wallet.
263
276
  *
264
- * If the wallet address has changed since the last call, the previous
265
- * database instance is discarded and a new one is created.
277
+ * Instances are cached per derived dbName and reused across calls (including
278
+ * repeat/guest-interleaved requests for the same wallet); a new one is built
279
+ * only for a dbName not yet seen. See the `databases` field for why.
266
280
  *
267
281
  * @param walletAddress - The wallet address to scope the database to.
268
282
  * If undefined, uses a "guest" database.
@@ -271,7 +285,7 @@ declare class DatabaseManager {
271
285
  */
272
286
  getDatabase(walletAddress?: string): Database;
273
287
  /**
274
- * Reset the current database (useful for logout or testing).
288
+ * Reset ALL cached databases (useful for logout or testing).
275
289
  */
276
290
  resetDatabase(): Promise<void>;
277
291
  /**