@vheins/local-memory-mcp 0.7.2 → 0.7.4

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.
@@ -1899,7 +1899,6 @@ function resolveDbPath() {
1899
1899
  return standardPath;
1900
1900
  }
1901
1901
  var DB_PATH = resolveDbPath();
1902
- var dbPathInstance = "";
1903
1902
  var sqlJsReady = null;
1904
1903
  var sqlJsModule = null;
1905
1904
  async function getSqlJs() {
@@ -1934,9 +1933,12 @@ var SQLiteStore = class _SQLiteStore {
1934
1933
  system;
1935
1934
  summaries;
1936
1935
  _ready;
1936
+ lastLoadedAt = 0;
1937
+ saveDbPtr;
1938
+ dbPathInstance;
1937
1939
  constructor(dbPath) {
1938
1940
  const finalPath = dbPath ?? DB_PATH;
1939
- dbPathInstance = finalPath;
1941
+ this.dbPathInstance = finalPath;
1940
1942
  warmUpSqlJs();
1941
1943
  this.db = {};
1942
1944
  this.memories = {};
@@ -1963,23 +1965,58 @@ var SQLiteStore = class _SQLiteStore {
1963
1965
  db = new SQL.Database();
1964
1966
  }
1965
1967
  }
1966
- const saveDb = createSaveFunction(db, finalPath);
1968
+ this.saveDbPtr = createSaveFunction(db, finalPath);
1969
+ const wrappedSaveDb = () => {
1970
+ if (this.saveDbPtr) {
1971
+ this.saveDbPtr();
1972
+ this.lastLoadedAt = Date.now();
1973
+ }
1974
+ };
1967
1975
  db.run("PRAGMA journal_mode = WAL");
1968
1976
  db.run("PRAGMA synchronous = NORMAL");
1969
1977
  db.run("PRAGMA busy_timeout = 5000");
1970
- const migrator = new MigrationManager(db, saveDb);
1978
+ const migrator = new MigrationManager(db, wrappedSaveDb);
1971
1979
  migrator.migrate();
1972
1980
  migrator.addMemoryCodeColumn();
1973
1981
  Object.assign(this, {
1974
1982
  db,
1975
- memories: new MemoryEntity(db, saveDb),
1976
- tasks: new TaskEntity(db, saveDb),
1977
- actions: new ActionEntity(db, saveDb),
1978
- system: new SystemEntity(db, saveDb),
1979
- summaries: new SummaryEntity(db, saveDb)
1983
+ memories: new MemoryEntity(db, wrappedSaveDb),
1984
+ tasks: new TaskEntity(db, wrappedSaveDb),
1985
+ actions: new ActionEntity(db, wrappedSaveDb),
1986
+ system: new SystemEntity(db, wrappedSaveDb),
1987
+ summaries: new SummaryEntity(db, wrappedSaveDb)
1980
1988
  });
1989
+ this.lastLoadedAt = Date.now();
1981
1990
  if (finalPath !== ":memory:") {
1982
- saveDb();
1991
+ wrappedSaveDb();
1992
+ }
1993
+ }
1994
+ async refresh(force = false) {
1995
+ const path5 = this.getDbPath();
1996
+ if (path5 === ":memory:") return;
1997
+ try {
1998
+ const stats = fs2.statSync(path5);
1999
+ const mtime = stats.mtimeMs;
2000
+ if (force || mtime > this.lastLoadedAt) {
2001
+ const SQL = await getSqlJs();
2002
+ const fileBuffer = fs2.readFileSync(path5);
2003
+ const newDb = new SQL.Database(fileBuffer);
2004
+ const wrappedSaveDb = () => {
2005
+ if (this.saveDbPtr) {
2006
+ this.saveDbPtr();
2007
+ this.lastLoadedAt = Date.now();
2008
+ }
2009
+ };
2010
+ this.db = newDb;
2011
+ this.memories = new MemoryEntity(newDb, wrappedSaveDb);
2012
+ this.tasks = new TaskEntity(newDb, wrappedSaveDb);
2013
+ this.actions = new ActionEntity(newDb, wrappedSaveDb);
2014
+ this.system = new SystemEntity(newDb, wrappedSaveDb);
2015
+ this.summaries = new SummaryEntity(newDb, wrappedSaveDb);
2016
+ this.lastLoadedAt = Date.now();
2017
+ }
2018
+ } catch (e) {
2019
+ console.error("Failed to refresh database from disk:", e);
1983
2020
  }
1984
2021
  }
1985
2022
  async ready() {
@@ -1991,7 +2028,7 @@ var SQLiteStore = class _SQLiteStore {
1991
2028
  return store;
1992
2029
  }
1993
2030
  getDbPath() {
1994
- return dbPathInstance;
2031
+ return this.dbPathInstance;
1995
2032
  }
1996
2033
  close() {
1997
2034
  if (this.db && this.db.close) {
@@ -2133,7 +2170,8 @@ var MemoryStoreSchema = z.object({
2133
2170
  supersedes: z.string().uuid().optional(),
2134
2171
  tags: z.array(z.string()).optional(),
2135
2172
  metadata: z.record(z.string(), z.any()).optional(),
2136
- is_global: z.boolean().default(false)
2173
+ is_global: z.boolean().default(false),
2174
+ structured: z.boolean().default(false)
2137
2175
  });
2138
2176
  var MemoryUpdateSchema = z.object({
2139
2177
  id: z.string().uuid(),
@@ -2148,7 +2186,8 @@ var MemoryUpdateSchema = z.object({
2148
2186
  tags: z.array(z.string()).optional(),
2149
2187
  metadata: z.record(z.string(), z.any()).optional(),
2150
2188
  is_global: z.boolean().optional(),
2151
- completed_at: z.string().optional()
2189
+ completed_at: z.string().optional(),
2190
+ structured: z.boolean().default(false)
2152
2191
  }).refine(
2153
2192
  (data) => data.type !== void 0 || data.content !== void 0 || data.title !== void 0 || data.importance !== void 0 || data.status !== void 0 || data.supersedes !== void 0 || data.tags !== void 0 || data.metadata !== void 0 || data.is_global !== void 0 || data.agent !== void 0 || data.role !== void 0 || data.completed_at !== void 0,
2154
2193
  { message: "At least one field must be provided for update" }
@@ -2171,7 +2210,8 @@ var MemorySearchSchema = z.object({
2171
2210
  var MemoryAcknowledgeSchema = z.object({
2172
2211
  memory_id: z.string().uuid(),
2173
2212
  status: z.enum(["used", "irrelevant", "contradictory"]),
2174
- application_context: z.string().min(10).optional()
2213
+ application_context: z.string().min(10).optional(),
2214
+ structured: z.boolean().default(false)
2175
2215
  });
2176
2216
  var MemoryRecapSchema = z.object({
2177
2217
  repo: z.string().min(1).transform(normalizeRepo),
@@ -2182,13 +2222,15 @@ var MemoryRecapSchema = z.object({
2182
2222
  var MemoryDeleteSchema = z.object({
2183
2223
  repo: z.string().min(1).transform(normalizeRepo).optional(),
2184
2224
  id: z.string().uuid().optional(),
2185
- ids: z.array(z.string().uuid()).min(1).optional()
2225
+ ids: z.array(z.string().uuid()).min(1).optional(),
2226
+ structured: z.boolean().default(false)
2186
2227
  }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
2187
2228
  message: "Either 'id' or 'ids' must be provided for deletion"
2188
2229
  });
2189
2230
  var MemorySummarizeSchema = z.object({
2190
2231
  repo: z.string().min(1).transform(normalizeRepo),
2191
- signals: z.array(z.string().max(200)).min(1)
2232
+ signals: z.array(z.string().max(200)).min(1),
2233
+ structured: z.boolean().default(false)
2192
2234
  });
2193
2235
  var MemorySynthesizeSchema = z.object({
2194
2236
  repo: z.string().min(1).transform(normalizeRepo).optional(),
@@ -2198,7 +2240,8 @@ var MemorySynthesizeSchema = z.object({
2198
2240
  include_tasks: z.boolean().default(true),
2199
2241
  use_tools: z.boolean().default(true),
2200
2242
  max_iterations: z.number().int().min(1).max(5).default(3),
2201
- max_tokens: z.number().int().min(128).max(4e3).default(1200)
2243
+ max_tokens: z.number().int().min(128).max(4e3).default(1200),
2244
+ structured: z.boolean().default(false)
2202
2245
  });
2203
2246
  var TaskStatusSchema = z.enum(["backlog", "pending", "in_progress", "completed", "canceled", "blocked"]);
2204
2247
  var TaskPrioritySchema = z.number().min(1).max(5);
@@ -2236,7 +2279,8 @@ var TaskCreateSchema = z.object({
2236
2279
  depends_on: z.string().uuid().optional(),
2237
2280
  est_tokens: z.number().int().min(0).optional(),
2238
2281
  // Allow bulk tasks
2239
- tasks: z.array(SingleTaskCreateSchema).min(1).optional()
2282
+ tasks: z.array(SingleTaskCreateSchema).min(1).optional(),
2283
+ structured: z.boolean().default(false)
2240
2284
  }).refine(
2241
2285
  (data) => {
2242
2286
  if (data.tasks) return true;
@@ -2245,7 +2289,8 @@ var TaskCreateSchema = z.object({
2245
2289
  { message: "Either 'tasks' array or single task fields (task_code, phase, title, description) must be provided" }
2246
2290
  );
2247
2291
  var TaskCreateInteractiveSchema = SingleTaskCreateSchema.partial().extend({
2248
- repo: z.string().min(1).transform(normalizeRepo).optional()
2292
+ repo: z.string().min(1).transform(normalizeRepo).optional(),
2293
+ structured: z.boolean().default(false)
2249
2294
  });
2250
2295
  var TaskUpdateSchema = z.object({
2251
2296
  repo: z.string().min(1).transform(normalizeRepo),
@@ -2267,7 +2312,8 @@ var TaskUpdateSchema = z.object({
2267
2312
  parent_id: z.string().uuid().optional(),
2268
2313
  depends_on: z.string().uuid().optional(),
2269
2314
  est_tokens: z.number().int().min(0).optional(),
2270
- force: z.boolean().optional()
2315
+ force: z.boolean().optional(),
2316
+ structured: z.boolean().default(false)
2271
2317
  }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
2272
2318
  message: "Either 'id' or 'ids' must be provided for update"
2273
2319
  }).refine((data) => Object.keys(data).length > 2, {
@@ -2293,13 +2339,15 @@ var TaskSearchSchema = z.object({
2293
2339
  var TaskDeleteSchema = z.object({
2294
2340
  repo: z.string().min(1).transform(normalizeRepo),
2295
2341
  id: z.string().uuid().optional(),
2296
- ids: z.array(z.string().uuid()).min(1).optional()
2342
+ ids: z.array(z.string().uuid()).min(1).optional(),
2343
+ structured: z.boolean().default(false)
2297
2344
  }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
2298
2345
  message: "Either 'id' or 'ids' must be provided for deletion"
2299
2346
  });
2300
2347
  var MemoryDetailSchema = z.object({
2301
2348
  id: z.string().uuid().optional(),
2302
- code: z.string().max(20).optional()
2349
+ code: z.string().max(20).optional(),
2350
+ structured: z.boolean().default(false)
2303
2351
  }).refine((data) => data.id !== void 0 || data.code !== void 0, {
2304
2352
  message: "Either id or code must be provided"
2305
2353
  });
@@ -2341,7 +2389,8 @@ var TOOL_DEFINITIONS = [
2341
2389
  description: "Allow the sampled model to call local memory/task tools during synthesis when the client supports sampling.tools."
2342
2390
  },
2343
2391
  max_iterations: { type: "number", minimum: 1, maximum: 5, default: 3 },
2344
- max_tokens: { type: "number", minimum: 128, maximum: 4e3, default: 1200 }
2392
+ max_tokens: { type: "number", minimum: 128, maximum: 4e3, default: 1200 },
2393
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON results." }
2345
2394
  },
2346
2395
  required: ["objective"]
2347
2396
  },
@@ -2384,7 +2433,8 @@ var TOOL_DEFINITIONS = [
2384
2433
  priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
2385
2434
  agent: { type: "string" },
2386
2435
  role: { type: "string" },
2387
- doc_path: { type: "string" }
2436
+ doc_path: { type: "string" },
2437
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
2388
2438
  }
2389
2439
  },
2390
2440
  outputSchema: {
@@ -2407,7 +2457,8 @@ var TOOL_DEFINITIONS = [
2407
2457
  inputSchema: {
2408
2458
  type: "object",
2409
2459
  properties: {
2410
- id: { type: "string", format: "uuid", description: "Memory entry ID" }
2460
+ id: { type: "string", format: "uuid", description: "Memory entry ID" },
2461
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON details." }
2411
2462
  },
2412
2463
  required: ["id"]
2413
2464
  }
@@ -2511,7 +2562,8 @@ var TOOL_DEFINITIONS = [
2511
2562
  description: "If true, this memory is shared across all repositories"
2512
2563
  },
2513
2564
  ttlDays: { type: "number", minimum: 1 },
2514
- supersedes: { type: "string", format: "uuid" }
2565
+ supersedes: { type: "string", format: "uuid" },
2566
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the stored memory." }
2515
2567
  },
2516
2568
  required: ["type", "title", "content", "importance", "scope", "agent", "model"]
2517
2569
  },
@@ -2544,7 +2596,8 @@ var TOOL_DEFINITIONS = [
2544
2596
  properties: {
2545
2597
  memory_id: { type: "string", format: "uuid" },
2546
2598
  status: { type: "string", enum: ["used", "irrelevant", "contradictory"] },
2547
- application_context: { type: "string", minLength: 10 }
2599
+ application_context: { type: "string", minLength: 10 },
2600
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
2548
2601
  },
2549
2602
  required: ["memory_id", "status"]
2550
2603
  },
@@ -2595,7 +2648,8 @@ var TOOL_DEFINITIONS = [
2595
2648
  tags: { type: "array", items: { type: "string" } },
2596
2649
  metadata: { type: "object" },
2597
2650
  is_global: { type: "boolean" },
2598
- completed_at: { type: "string" }
2651
+ completed_at: { type: "string" },
2652
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the updated memory." }
2599
2653
  },
2600
2654
  required: ["id"]
2601
2655
  },
@@ -2719,7 +2773,8 @@ var TOOL_DEFINITIONS = [
2719
2773
  items: { type: "string", maxLength: 200 },
2720
2774
  minItems: 1,
2721
2775
  description: "High-level signals to include in summary"
2722
- }
2776
+ },
2777
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the summary." }
2723
2778
  },
2724
2779
  required: ["repo", "signals"]
2725
2780
  },
@@ -2754,7 +2809,8 @@ var TOOL_DEFINITIONS = [
2754
2809
  items: { type: "string", format: "uuid" },
2755
2810
  minItems: 1,
2756
2811
  description: "Array of memory IDs to delete"
2757
- }
2812
+ },
2813
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
2758
2814
  }
2759
2815
  },
2760
2816
  outputSchema: {
@@ -2902,7 +2958,8 @@ var TOOL_DEFINITIONS = [
2902
2958
  required: ["task_code", "phase", "title", "description"]
2903
2959
  },
2904
2960
  description: "Array of tasks for bulk creation"
2905
- }
2961
+ },
2962
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
2906
2963
  },
2907
2964
  required: ["repo"]
2908
2965
  },
@@ -2968,7 +3025,8 @@ var TOOL_DEFINITIONS = [
2968
3025
  force: {
2969
3026
  type: "boolean",
2970
3027
  description: "If true, bypasses status transition validation (e.g. pending -> completed)."
2971
- }
3028
+ },
3029
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
2972
3030
  },
2973
3031
  required: ["repo"]
2974
3032
  },
@@ -3005,7 +3063,8 @@ var TOOL_DEFINITIONS = [
3005
3063
  properties: {
3006
3064
  repo: { type: "string", description: "Repository name" },
3007
3065
  id: { type: "string", format: "uuid", description: "Task ID (for single deletion)" },
3008
- ids: { type: "array", items: { type: "string", format: "uuid" }, description: "Task IDs (for bulk deletion)" }
3066
+ ids: { type: "array", items: { type: "string", format: "uuid" }, description: "Task IDs (for bulk deletion)" },
3067
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3009
3068
  },
3010
3069
  required: ["repo"]
3011
3070
  },