@melandlabs/memory-store 0.2.6 → 0.2.7

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.
@@ -155,8 +155,21 @@ interface UnifiedSearchDeps {
155
155
  }>>;
156
156
  }
157
157
  interface MemoryStoreConfig {
158
- /** Database handle factory. Required for any persistence. */
158
+ /**
159
+ * Database handle factory. Required for the Postgres backend
160
+ * (`OPENCONTEXT_MEMORY_STORE_BACKEND=postgres`).
161
+ */
159
162
  db?: MemoryStoreDb;
163
+ /**
164
+ * Custom SQLite database file path for the default SQLite backend.
165
+ *
166
+ * If provided, this takes precedence over the `MEMORY_STORE_DB_PATH`
167
+ * environment variable and the default `~/.opencontext/memory/store.db`.
168
+ *
169
+ * For backward compatibility with early tutorials, `db.path` is also
170
+ * honoured when `db` is supplied as `{ type, path }`.
171
+ */
172
+ dbPath?: string;
160
173
  /** Environment helpers. Defaults to a process.env-only stub if omitted. */
161
174
  env?: MemoryStoreEnv;
162
175
  /** Vector backend config. Defaults to env-based detection. */
package/dist/http.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as MemoryStoreConfig } from './config-BYfTzG3h.js';
1
+ import { M as MemoryStoreConfig } from './config-Ll6ktm4D.js';
2
2
 
3
3
  /**
4
4
  * @melandlabs/memory-store/http — HTTP server entry.
package/dist/http.js CHANGED
@@ -183,16 +183,17 @@ __export(sqlite_raw_message_store_exports, {
183
183
  lexicalSearchRawMessages: () => lexicalSearchRawMessages,
184
184
  resolveSQLiteRawMessageDbPath: () => resolveSQLiteRawMessageDbPath
185
185
  });
186
- function resolveSQLiteRawMessageDbPath() {
186
+ function resolveSQLiteRawMessageDbPath(dbPath) {
187
+ if (dbPath && dbPath.length > 0) return dbPath;
187
188
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
188
189
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
189
190
  }
190
191
  function isSQLiteRawMessageStorageAvailable(_env) {
191
192
  return true;
192
193
  }
193
- async function getSQLiteRawMessageManager(_env) {
194
+ async function getSQLiteRawMessageManager(options = {}) {
194
195
  if (!manager) {
195
- const dbPath = resolveSQLiteRawMessageDbPath();
196
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
196
197
  mkdirSync(dirname(dbPath), { recursive: true });
197
198
  manager = new SQLiteRawMessageManager({
198
199
  dbPath,
@@ -265,33 +266,43 @@ function createRawMessageStore(options = {}) {
265
266
  }
266
267
  return pg;
267
268
  }
268
- return await getSQLiteRawMessageManager();
269
+ return await getSQLiteRawMessageManager({
270
+ dbPath: options.dbPath
271
+ });
269
272
  },
270
273
  async close() {
271
274
  await closeSQLiteRawMessageManager();
272
275
  }
273
276
  };
274
277
  }
278
+ function resolveDbPath(config) {
279
+ if (!config) return void 0;
280
+ if (config.dbPath) return config.dbPath;
281
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
282
+ return config.db.path;
283
+ }
284
+ return void 0;
285
+ }
275
286
  function configureRawMessageStore(config) {
276
287
  moduleConfig = config;
277
- moduleStore = createRawMessageStore({ env: config.env });
288
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
278
289
  return moduleStore;
279
290
  }
280
291
  function getRawMessageStorageBackend() {
281
292
  if (!moduleStore) {
282
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
293
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
283
294
  }
284
295
  return moduleStore.getBackend();
285
296
  }
286
297
  function isRawMessageStorageAvailable() {
287
298
  if (!moduleStore) {
288
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
299
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
289
300
  }
290
301
  return moduleStore.isAvailable();
291
302
  }
292
303
  async function getRawMessageManager() {
293
304
  if (!moduleStore) {
294
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
305
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
295
306
  }
296
307
  return moduleStore.getManager();
297
308
  }
@@ -620,7 +631,8 @@ function createUnifiedSearch(deps = {}) {
620
631
  const results = await manager2.searchMessagesSemantically({
621
632
  userId: input.userId,
622
633
  queryEmbedding,
623
- limit
634
+ limit,
635
+ threshold
624
636
  });
625
637
  semantic = results.map((r) => ({
626
638
  type: "memory",
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MemoryStoreConfig } from './config-BYfTzG3h.js';
2
- export { E as EmbedQueryFn, a as MemoryStoreDb, b as MemoryStoreEnv, U as UnifiedSearchInsightsResult, c as UnifiedSearchKnowledgeResult, V as VectorBackend } from './config-BYfTzG3h.js';
1
+ import { M as MemoryStoreConfig } from './config-Ll6ktm4D.js';
2
+ export { E as EmbedQueryFn, a as MemoryStoreDb, b as MemoryStoreEnv, U as UnifiedSearchInsightsResult, c as UnifiedSearchKnowledgeResult, V as VectorBackend } from './config-Ll6ktm4D.js';
3
3
  import { UnifiedSearch } from './search/unified-search.js';
4
4
  export { UnifiedMemorySearchInput, UnifiedMemorySearchOutput, UnifiedMemorySearchResult, UnifiedMemorySearchSource, UnifiedMemorySearchWarning, clampUnifiedMemorySearchLimit, clampUnifiedMemorySearchThreshold, createUnifiedSearch, isRawMemorySemanticResult, mergeUnifiedMemorySearchResults, normalizeUnifiedMemorySearchSources, toKnowledgeResult, toMemoryResult } from './search/unified-search.js';
5
5
  import { RawMessageStore, getRawMessageManager } from './storage/raw-message-store.js';
package/dist/index.js CHANGED
@@ -114,16 +114,17 @@ __export(sqlite_raw_message_store_exports, {
114
114
  lexicalSearchRawMessages: () => lexicalSearchRawMessages,
115
115
  resolveSQLiteRawMessageDbPath: () => resolveSQLiteRawMessageDbPath
116
116
  });
117
- function resolveSQLiteRawMessageDbPath() {
117
+ function resolveSQLiteRawMessageDbPath(dbPath) {
118
+ if (dbPath && dbPath.length > 0) return dbPath;
118
119
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
119
120
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
120
121
  }
121
122
  function isSQLiteRawMessageStorageAvailable(_env) {
122
123
  return true;
123
124
  }
124
- async function getSQLiteRawMessageManager(_env) {
125
+ async function getSQLiteRawMessageManager(options = {}) {
125
126
  if (!manager) {
126
- const dbPath = resolveSQLiteRawMessageDbPath();
127
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
127
128
  mkdirSync(dirname(dbPath), { recursive: true });
128
129
  manager = new SQLiteRawMessageManager({
129
130
  dbPath,
@@ -196,33 +197,43 @@ function createRawMessageStore(options = {}) {
196
197
  }
197
198
  return pg;
198
199
  }
199
- return await getSQLiteRawMessageManager();
200
+ return await getSQLiteRawMessageManager({
201
+ dbPath: options.dbPath
202
+ });
200
203
  },
201
204
  async close() {
202
205
  await closeSQLiteRawMessageManager();
203
206
  }
204
207
  };
205
208
  }
209
+ function resolveDbPath(config) {
210
+ if (!config) return void 0;
211
+ if (config.dbPath) return config.dbPath;
212
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
213
+ return config.db.path;
214
+ }
215
+ return void 0;
216
+ }
206
217
  function configureRawMessageStore(config) {
207
218
  moduleConfig = config;
208
- moduleStore = createRawMessageStore({ env: config.env });
219
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
209
220
  return moduleStore;
210
221
  }
211
222
  function getRawMessageStorageBackend() {
212
223
  if (!moduleStore) {
213
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
224
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
214
225
  }
215
226
  return moduleStore.getBackend();
216
227
  }
217
228
  function isRawMessageStorageAvailable() {
218
229
  if (!moduleStore) {
219
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
230
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
220
231
  }
221
232
  return moduleStore.isAvailable();
222
233
  }
223
234
  async function getRawMessageManager() {
224
235
  if (!moduleStore) {
225
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
236
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
226
237
  }
227
238
  return moduleStore.getManager();
228
239
  }
@@ -551,7 +562,8 @@ function createUnifiedSearch(deps = {}) {
551
562
  const results = await manager2.searchMessagesSemantically({
552
563
  userId: input.userId,
553
564
  queryEmbedding,
554
- limit
565
+ limit,
566
+ threshold
555
567
  });
556
568
  semantic = results.map((r) => ({
557
569
  type: "memory",
@@ -651,7 +663,8 @@ init_raw_message_store();
651
663
  init_raw_message_store();
652
664
  init_postgres_raw_message_factory();
653
665
  async function createMemoryStore(config = {}) {
654
- const raw = createRawMessageStore({ env: config.env });
666
+ const dbPath = config.dbPath ?? (config.db && "path" in config.db ? config.db.path : void 0);
667
+ const raw = createRawMessageStore({ env: config.env, dbPath });
655
668
  const search = createUnifiedSearch(config.unified);
656
669
  configureRawMessageStore(config);
657
670
  return {
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { M as MemoryStoreConfig } from './config-BYfTzG3h.js';
2
+ import { M as MemoryStoreConfig } from './config-Ll6ktm4D.js';
3
3
 
4
4
  /**
5
5
  * @melandlabs/memory-store/mcp — MCP server entry.
package/dist/mcp.js CHANGED
@@ -184,16 +184,17 @@ __export(sqlite_raw_message_store_exports, {
184
184
  lexicalSearchRawMessages: () => lexicalSearchRawMessages,
185
185
  resolveSQLiteRawMessageDbPath: () => resolveSQLiteRawMessageDbPath
186
186
  });
187
- function resolveSQLiteRawMessageDbPath() {
187
+ function resolveSQLiteRawMessageDbPath(dbPath) {
188
+ if (dbPath && dbPath.length > 0) return dbPath;
188
189
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
189
190
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
190
191
  }
191
192
  function isSQLiteRawMessageStorageAvailable(_env) {
192
193
  return true;
193
194
  }
194
- async function getSQLiteRawMessageManager(_env) {
195
+ async function getSQLiteRawMessageManager(options = {}) {
195
196
  if (!manager) {
196
- const dbPath = resolveSQLiteRawMessageDbPath();
197
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
197
198
  mkdirSync(dirname(dbPath), { recursive: true });
198
199
  manager = new SQLiteRawMessageManager({
199
200
  dbPath,
@@ -266,33 +267,43 @@ function createRawMessageStore(options = {}) {
266
267
  }
267
268
  return pg;
268
269
  }
269
- return await getSQLiteRawMessageManager();
270
+ return await getSQLiteRawMessageManager({
271
+ dbPath: options.dbPath
272
+ });
270
273
  },
271
274
  async close() {
272
275
  await closeSQLiteRawMessageManager();
273
276
  }
274
277
  };
275
278
  }
279
+ function resolveDbPath(config) {
280
+ if (!config) return void 0;
281
+ if (config.dbPath) return config.dbPath;
282
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
283
+ return config.db.path;
284
+ }
285
+ return void 0;
286
+ }
276
287
  function configureRawMessageStore(config) {
277
288
  moduleConfig = config;
278
- moduleStore = createRawMessageStore({ env: config.env });
289
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
279
290
  return moduleStore;
280
291
  }
281
292
  function getRawMessageStorageBackend() {
282
293
  if (!moduleStore) {
283
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
294
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
284
295
  }
285
296
  return moduleStore.getBackend();
286
297
  }
287
298
  function isRawMessageStorageAvailable() {
288
299
  if (!moduleStore) {
289
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
300
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
290
301
  }
291
302
  return moduleStore.isAvailable();
292
303
  }
293
304
  async function getRawMessageManager() {
294
305
  if (!moduleStore) {
295
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
306
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
296
307
  }
297
308
  return moduleStore.getManager();
298
309
  }
@@ -621,7 +632,8 @@ function createUnifiedSearch(deps = {}) {
621
632
  const results = await manager2.searchMessagesSemantically({
622
633
  userId: input.userId,
623
634
  queryEmbedding,
624
- limit
635
+ limit,
636
+ threshold
625
637
  });
626
638
  semantic = results.map((r) => ({
627
639
  type: "memory",
@@ -1,4 +1,4 @@
1
- import { d as UnifiedSearchDeps } from '../config-BYfTzG3h.js';
1
+ import { d as UnifiedSearchDeps } from '../config-Ll6ktm4D.js';
2
2
 
3
3
  /**
4
4
  * Pure helpers used by the unified memory search pipeline.
@@ -108,16 +108,17 @@ __export(sqlite_raw_message_store_exports, {
108
108
  lexicalSearchRawMessages: () => lexicalSearchRawMessages,
109
109
  resolveSQLiteRawMessageDbPath: () => resolveSQLiteRawMessageDbPath
110
110
  });
111
- function resolveSQLiteRawMessageDbPath() {
111
+ function resolveSQLiteRawMessageDbPath(dbPath) {
112
+ if (dbPath && dbPath.length > 0) return dbPath;
112
113
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
113
114
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
114
115
  }
115
116
  function isSQLiteRawMessageStorageAvailable(_env) {
116
117
  return true;
117
118
  }
118
- async function getSQLiteRawMessageManager(_env) {
119
+ async function getSQLiteRawMessageManager(options = {}) {
119
120
  if (!manager) {
120
- const dbPath = resolveSQLiteRawMessageDbPath();
121
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
121
122
  mkdirSync(dirname(dbPath), { recursive: true });
122
123
  manager = new SQLiteRawMessageManager({
123
124
  dbPath,
@@ -190,33 +191,43 @@ function createRawMessageStore(options = {}) {
190
191
  }
191
192
  return pg;
192
193
  }
193
- return await getSQLiteRawMessageManager();
194
+ return await getSQLiteRawMessageManager({
195
+ dbPath: options.dbPath
196
+ });
194
197
  },
195
198
  async close() {
196
199
  await closeSQLiteRawMessageManager();
197
200
  }
198
201
  };
199
202
  }
203
+ function resolveDbPath(config) {
204
+ if (!config) return void 0;
205
+ if (config.dbPath) return config.dbPath;
206
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
207
+ return config.db.path;
208
+ }
209
+ return void 0;
210
+ }
200
211
  function configureRawMessageStore(config) {
201
212
  moduleConfig = config;
202
- moduleStore = createRawMessageStore({ env: config.env });
213
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
203
214
  return moduleStore;
204
215
  }
205
216
  function getRawMessageStorageBackend() {
206
217
  if (!moduleStore) {
207
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
218
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
208
219
  }
209
220
  return moduleStore.getBackend();
210
221
  }
211
222
  function isRawMessageStorageAvailable() {
212
223
  if (!moduleStore) {
213
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
224
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
214
225
  }
215
226
  return moduleStore.isAvailable();
216
227
  }
217
228
  async function getRawMessageManager() {
218
229
  if (!moduleStore) {
219
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
230
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
220
231
  }
221
232
  return moduleStore.getManager();
222
233
  }
@@ -545,7 +556,8 @@ function createUnifiedSearch(deps = {}) {
545
556
  const results = await manager2.searchMessagesSemantically({
546
557
  userId: input.userId,
547
558
  queryEmbedding,
548
- limit
559
+ limit,
560
+ threshold
549
561
  });
550
562
  semantic = results.map((r) => ({
551
563
  type: "memory",
@@ -184,16 +184,17 @@ __export(sqlite_raw_message_store_exports, {
184
184
  lexicalSearchRawMessages: () => lexicalSearchRawMessages,
185
185
  resolveSQLiteRawMessageDbPath: () => resolveSQLiteRawMessageDbPath
186
186
  });
187
- function resolveSQLiteRawMessageDbPath() {
187
+ function resolveSQLiteRawMessageDbPath(dbPath) {
188
+ if (dbPath && dbPath.length > 0) return dbPath;
188
189
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
189
190
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
190
191
  }
191
192
  function isSQLiteRawMessageStorageAvailable(_env) {
192
193
  return true;
193
194
  }
194
- async function getSQLiteRawMessageManager(_env) {
195
+ async function getSQLiteRawMessageManager(options = {}) {
195
196
  if (!manager) {
196
- const dbPath = resolveSQLiteRawMessageDbPath();
197
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
197
198
  mkdirSync(dirname(dbPath), { recursive: true });
198
199
  manager = new SQLiteRawMessageManager({
199
200
  dbPath,
@@ -266,33 +267,43 @@ function createRawMessageStore(options = {}) {
266
267
  }
267
268
  return pg;
268
269
  }
269
- return await getSQLiteRawMessageManager();
270
+ return await getSQLiteRawMessageManager({
271
+ dbPath: options.dbPath
272
+ });
270
273
  },
271
274
  async close() {
272
275
  await closeSQLiteRawMessageManager();
273
276
  }
274
277
  };
275
278
  }
279
+ function resolveDbPath(config) {
280
+ if (!config) return void 0;
281
+ if (config.dbPath) return config.dbPath;
282
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
283
+ return config.db.path;
284
+ }
285
+ return void 0;
286
+ }
276
287
  function configureRawMessageStore(config) {
277
288
  moduleConfig = config;
278
- moduleStore = createRawMessageStore({ env: config.env });
289
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
279
290
  return moduleStore;
280
291
  }
281
292
  function getRawMessageStorageBackend() {
282
293
  if (!moduleStore) {
283
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
294
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
284
295
  }
285
296
  return moduleStore.getBackend();
286
297
  }
287
298
  function isRawMessageStorageAvailable() {
288
299
  if (!moduleStore) {
289
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
300
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
290
301
  }
291
302
  return moduleStore.isAvailable();
292
303
  }
293
304
  async function getRawMessageManager() {
294
305
  if (!moduleStore) {
295
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
306
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
296
307
  }
297
308
  return moduleStore.getManager();
298
309
  }
@@ -621,7 +632,8 @@ function createUnifiedSearch(deps = {}) {
621
632
  const results = await manager2.searchMessagesSemantically({
622
633
  userId: input.userId,
623
634
  queryEmbedding,
624
- limit
635
+ limit,
636
+ threshold
625
637
  });
626
638
  semantic = results.map((r) => ({
627
639
  type: "memory",
@@ -185,16 +185,17 @@ __export(sqlite_raw_message_store_exports, {
185
185
  lexicalSearchRawMessages: () => lexicalSearchRawMessages,
186
186
  resolveSQLiteRawMessageDbPath: () => resolveSQLiteRawMessageDbPath
187
187
  });
188
- function resolveSQLiteRawMessageDbPath() {
188
+ function resolveSQLiteRawMessageDbPath(dbPath) {
189
+ if (dbPath && dbPath.length > 0) return dbPath;
189
190
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
190
191
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
191
192
  }
192
193
  function isSQLiteRawMessageStorageAvailable(_env) {
193
194
  return true;
194
195
  }
195
- async function getSQLiteRawMessageManager(_env) {
196
+ async function getSQLiteRawMessageManager(options = {}) {
196
197
  if (!manager) {
197
- const dbPath = resolveSQLiteRawMessageDbPath();
198
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
198
199
  mkdirSync(dirname(dbPath), { recursive: true });
199
200
  manager = new SQLiteRawMessageManager({
200
201
  dbPath,
@@ -267,33 +268,43 @@ function createRawMessageStore(options = {}) {
267
268
  }
268
269
  return pg;
269
270
  }
270
- return await getSQLiteRawMessageManager();
271
+ return await getSQLiteRawMessageManager({
272
+ dbPath: options.dbPath
273
+ });
271
274
  },
272
275
  async close() {
273
276
  await closeSQLiteRawMessageManager();
274
277
  }
275
278
  };
276
279
  }
280
+ function resolveDbPath(config) {
281
+ if (!config) return void 0;
282
+ if (config.dbPath) return config.dbPath;
283
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
284
+ return config.db.path;
285
+ }
286
+ return void 0;
287
+ }
277
288
  function configureRawMessageStore(config) {
278
289
  moduleConfig = config;
279
- moduleStore = createRawMessageStore({ env: config.env });
290
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
280
291
  return moduleStore;
281
292
  }
282
293
  function getRawMessageStorageBackend() {
283
294
  if (!moduleStore) {
284
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
295
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
285
296
  }
286
297
  return moduleStore.getBackend();
287
298
  }
288
299
  function isRawMessageStorageAvailable() {
289
300
  if (!moduleStore) {
290
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
301
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
291
302
  }
292
303
  return moduleStore.isAvailable();
293
304
  }
294
305
  async function getRawMessageManager() {
295
306
  if (!moduleStore) {
296
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
307
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
297
308
  }
298
309
  return moduleStore.getManager();
299
310
  }
@@ -622,7 +633,8 @@ function createUnifiedSearch(deps = {}) {
622
633
  const results = await manager2.searchMessagesSemantically({
623
634
  userId: input.userId,
624
635
  queryEmbedding,
625
- limit
636
+ limit,
637
+ threshold
626
638
  });
627
639
  semantic = results.map((r) => ({
628
640
  type: "memory",
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as UnifiedSearchDeps } from '../config-BYfTzG3h.js';
2
+ import { d as UnifiedSearchDeps } from '../config-Ll6ktm4D.js';
3
3
 
4
4
  /**
5
5
  * Shared argv parsing + `unified.*` wiring for the memory-store CLI bins.
@@ -35,13 +35,14 @@ function isRawMessageChromaEnabled() {
35
35
  // src/storage/sqlite-raw-message-store.ts
36
36
  var manager = null;
37
37
  var DEFAULT_SQLITE_PATH = join(homedir(), ".opencontext", "memory", "store.db");
38
- function resolveSQLiteRawMessageDbPath() {
38
+ function resolveSQLiteRawMessageDbPath(dbPath) {
39
+ if (dbPath && dbPath.length > 0) return dbPath;
39
40
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
40
41
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
41
42
  }
42
- async function getSQLiteRawMessageManager(_env) {
43
+ async function getSQLiteRawMessageManager(options = {}) {
43
44
  if (!manager) {
44
- const dbPath = resolveSQLiteRawMessageDbPath();
45
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
45
46
  mkdirSync(dirname(dbPath), { recursive: true });
46
47
  manager = new SQLiteRawMessageManager({
47
48
  dbPath,
@@ -87,7 +88,9 @@ function createRawMessageStore(options = {}) {
87
88
  }
88
89
  return pg;
89
90
  }
90
- return await getSQLiteRawMessageManager();
91
+ return await getSQLiteRawMessageManager({
92
+ dbPath: options.dbPath
93
+ });
91
94
  },
92
95
  async close() {
93
96
  await closeSQLiteRawMessageManager();
@@ -1,4 +1,4 @@
1
- import { b as MemoryStoreEnv } from '../config-BYfTzG3h.js';
1
+ import { b as MemoryStoreEnv } from '../config-Ll6ktm4D.js';
2
2
 
3
3
  /**
4
4
  * Lazy registration slot for the host's Postgres-backed raw message
@@ -1,5 +1,5 @@
1
1
  import { RawMessageStorageManager } from '@melandlabs/indexeddb/storage';
2
- import { b as MemoryStoreEnv, M as MemoryStoreConfig } from '../config-BYfTzG3h.js';
2
+ import { b as MemoryStoreEnv, M as MemoryStoreConfig } from '../config-Ll6ktm4D.js';
3
3
 
4
4
  /**
5
5
  * Top-level raw-message store facade.
@@ -45,6 +45,8 @@ type RawMessageStorageManagerWithSearch = RawMessageStorageManager & {
45
45
  };
46
46
  interface CreateRawMessageStoreOptions {
47
47
  env?: MemoryStoreEnv;
48
+ /** Custom SQLite DB file path. Only used by the SQLite backend. */
49
+ dbPath?: string;
48
50
  }
49
51
  interface RawMessageStore {
50
52
  getManager(): Promise<RawMessageStorageManagerWithSearch>;
@@ -34,13 +34,14 @@ function isRawMessageChromaEnabled() {
34
34
  // src/storage/sqlite-raw-message-store.ts
35
35
  var manager = null;
36
36
  var DEFAULT_SQLITE_PATH = join(homedir(), ".opencontext", "memory", "store.db");
37
- function resolveSQLiteRawMessageDbPath() {
37
+ function resolveSQLiteRawMessageDbPath(dbPath) {
38
+ if (dbPath && dbPath.length > 0) return dbPath;
38
39
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
39
40
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
40
41
  }
41
- async function getSQLiteRawMessageManager(_env) {
42
+ async function getSQLiteRawMessageManager(options = {}) {
42
43
  if (!manager) {
43
- const dbPath = resolveSQLiteRawMessageDbPath();
44
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
44
45
  mkdirSync(dirname(dbPath), { recursive: true });
45
46
  manager = new SQLiteRawMessageManager({
46
47
  dbPath,
@@ -86,7 +87,9 @@ function createRawMessageStore(options = {}) {
86
87
  }
87
88
  return pg;
88
89
  }
89
- return await getSQLiteRawMessageManager();
90
+ return await getSQLiteRawMessageManager({
91
+ dbPath: options.dbPath
92
+ });
90
93
  },
91
94
  async close() {
92
95
  await closeSQLiteRawMessageManager();
@@ -95,26 +98,34 @@ function createRawMessageStore(options = {}) {
95
98
  }
96
99
  var moduleStore = null;
97
100
  var moduleConfig = null;
101
+ function resolveDbPath(config) {
102
+ if (!config) return void 0;
103
+ if (config.dbPath) return config.dbPath;
104
+ if (config.db && typeof config.db === "object" && "path" in config.db) {
105
+ return config.db.path;
106
+ }
107
+ return void 0;
108
+ }
98
109
  function configureRawMessageStore(config) {
99
110
  moduleConfig = config;
100
- moduleStore = createRawMessageStore({ env: config.env });
111
+ moduleStore = createRawMessageStore({ env: config.env, dbPath: resolveDbPath(config) });
101
112
  return moduleStore;
102
113
  }
103
114
  function getRawMessageStorageBackend() {
104
115
  if (!moduleStore) {
105
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
116
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
106
117
  }
107
118
  return moduleStore.getBackend();
108
119
  }
109
120
  function isRawMessageStorageAvailable() {
110
121
  if (!moduleStore) {
111
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
122
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
112
123
  }
113
124
  return moduleStore.isAvailable();
114
125
  }
115
126
  async function getRawMessageManager() {
116
127
  if (!moduleStore) {
117
- moduleStore = createRawMessageStore({ env: moduleConfig?.env });
128
+ moduleStore = createRawMessageStore({ env: moduleConfig?.env, dbPath: resolveDbPath(moduleConfig) });
118
129
  }
119
130
  return moduleStore.getManager();
120
131
  }
@@ -1,5 +1,5 @@
1
1
  import { SQLiteRawMessageManager } from '@melandlabs/sqlite';
2
- import { b as MemoryStoreEnv } from '../config-BYfTzG3h.js';
2
+ import { b as MemoryStoreEnv } from '../config-Ll6ktm4D.js';
3
3
 
4
4
  /**
5
5
  * SQLite-backed raw message store.
@@ -18,13 +18,16 @@ import { b as MemoryStoreEnv } from '../config-BYfTzG3h.js';
18
18
  * Resolve the SQLite DB file path from env vars. Exposed so other storage
19
19
  * layers (vector index) can stay in sync with the same default.
20
20
  */
21
- declare function resolveSQLiteRawMessageDbPath(): string;
21
+ declare function resolveSQLiteRawMessageDbPath(dbPath?: string): string;
22
22
  /**
23
23
  * Local SQLite is the default. Every host (Tauri, server, CLI, tests) can
24
24
  * open the manager; the only failure mode is filesystem write permission.
25
25
  */
26
26
  declare function isSQLiteRawMessageStorageAvailable(_env?: MemoryStoreEnv): boolean;
27
- declare function getSQLiteRawMessageManager(_env?: MemoryStoreEnv): Promise<SQLiteRawMessageManager>;
27
+ declare function getSQLiteRawMessageManager(options?: {
28
+ env?: MemoryStoreEnv;
29
+ dbPath?: string;
30
+ }): Promise<SQLiteRawMessageManager>;
28
31
  declare function closeSQLiteRawMessageManager(): Promise<void>;
29
32
  /**
30
33
  * Test-only: reset the singleton. Used by vitest between test cases.
@@ -27,16 +27,17 @@ function isRawMessageChromaEnabled() {
27
27
  // src/storage/sqlite-raw-message-store.ts
28
28
  var manager = null;
29
29
  var DEFAULT_SQLITE_PATH = join(homedir(), ".opencontext", "memory", "store.db");
30
- function resolveSQLiteRawMessageDbPath() {
30
+ function resolveSQLiteRawMessageDbPath(dbPath) {
31
+ if (dbPath && dbPath.length > 0) return dbPath;
31
32
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
32
33
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
33
34
  }
34
35
  function isSQLiteRawMessageStorageAvailable(_env) {
35
36
  return true;
36
37
  }
37
- async function getSQLiteRawMessageManager(_env) {
38
+ async function getSQLiteRawMessageManager(options = {}) {
38
39
  if (!manager) {
39
- const dbPath = resolveSQLiteRawMessageDbPath();
40
+ const dbPath = resolveSQLiteRawMessageDbPath(options.dbPath);
40
41
  mkdirSync(dirname(dbPath), { recursive: true });
41
42
  manager = new SQLiteRawMessageManager({
42
43
  dbPath,
@@ -1,5 +1,5 @@
1
1
  import { VectorSearchResult } from '@melandlabs/rag/vector-service';
2
- import { b as MemoryStoreEnv } from '../config-BYfTzG3h.js';
2
+ import { b as MemoryStoreEnv } from '../config-Ll6ktm4D.js';
3
3
 
4
4
  /**
5
5
  * SQLite-vec-backed raw-message + insight vector index.
@@ -9,7 +9,7 @@ import '@melandlabs/rag';
9
9
 
10
10
  // src/storage/sqlite-raw-message-store.ts
11
11
  var DEFAULT_SQLITE_PATH = join(homedir(), ".opencontext", "memory", "store.db");
12
- function resolveSQLiteRawMessageDbPath() {
12
+ function resolveSQLiteRawMessageDbPath(dbPath) {
13
13
  const fromEnv = process.env.MEMORY_STORE_DB_PATH?.trim();
14
14
  return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_SQLITE_PATH;
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melandlabs/memory-store",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -60,14 +60,14 @@
60
60
  "@modelcontextprotocol/sdk": "^1.25.3",
61
61
  "hono": "^4.6.14",
62
62
  "zod": "^4.3.6",
63
- "@melandlabs/shared": "0.2.0",
64
- "@melandlabs/sqlite": "0.2.0",
65
- "@melandlabs/ai": "0.2.0",
66
- "@melandlabs/rag": "0.2.0"
63
+ "@melandlabs/ai": "0.2.1",
64
+ "@melandlabs/sqlite": "0.2.1",
65
+ "@melandlabs/shared": "0.2.1",
66
+ "@melandlabs/rag": "0.2.1"
67
67
  },
68
68
  "peerDependencies": {
69
- "@melandlabs/ai-rag": "0.2.2",
70
- "@melandlabs/indexeddb": "0.2.0"
69
+ "@melandlabs/ai-rag": "0.2.3",
70
+ "@melandlabs/indexeddb": "0.2.1"
71
71
  },
72
72
  "peerDependenciesMeta": {
73
73
  "@melandlabs/ai-rag": {
@@ -80,8 +80,8 @@
80
80
  "devDependencies": {
81
81
  "@types/node": "^22.13.10",
82
82
  "typescript": "^5.6.3",
83
- "@melandlabs/ai-rag": "0.2.2",
84
- "@melandlabs/config": "0.2.0"
83
+ "@melandlabs/config": "0.2.1",
84
+ "@melandlabs/ai-rag": "0.2.3"
85
85
  },
86
86
  "scripts": {
87
87
  "build": "tsup",