cozo-memory 1.2.11 → 1.2.13

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +35 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -473,7 +473,7 @@ Built with:
473
473
 
474
474
  Research foundations:
475
475
  - GraphRAG-R1 (Yu et al., WWW 2026) - conceptual inspiration for adaptive retrieval
476
- - HopRAG (ACL 2025)
477
- - T-GRAG (Li et al., 2025)
476
+ - HopRAG (ACL 2025) - conceptual inspiration for multi-hop reasoning
477
+ - T-GRAG (Li et al., 2025) - conceptual inspiration for temporal conflict resolution
478
478
  - FEEG Framework (Samuel et al., 2026) - conceptual inspiration for query intent classification
479
- - Allan-Poe (arXiv:2511.00855)
479
+ - Allan-Poe (arXiv:2511.00855) - conceptual inspiration for dynamic fusion
package/dist/index.js CHANGED
@@ -3415,7 +3415,11 @@ Format MUST start with "ExecutiveSummary: " followed by the consolidated content
3415
3415
  const incTl = args.include_timeline === true;
3416
3416
  const entRes = await this.db.run(`?[name, type, metadata, ts] := *entity{id: $id, name, type, metadata, created_at, @ "NOW"}, ts = to_int(created_at)`, { id: args.entity_id });
3417
3417
  if (entRes.rows.length === 0)
3418
- return { error: "Entity not found" };
3418
+ return {
3419
+ error: "Entity not found",
3420
+ entity_id: args.entity_id,
3421
+ hint: "Make sure you are passing an entity ID (not an observation ID or relation ID). Use 'list_entities' or 'search' to find valid entity IDs.",
3422
+ };
3419
3423
  const e = entRes.rows[0];
3420
3424
  const metadata = (e[2] || {});
3421
3425
  const created_at_us = e[3];
@@ -3562,12 +3566,13 @@ Format MUST start with "ExecutiveSummary: " followed by the consolidated content
3562
3566
  targetIds = [...new Set(targetIds)];
3563
3567
  let deleted_observations = 0;
3564
3568
  let deleted_relations = 0;
3565
- const deleted_entities = [];
3569
+ const deleted = [];
3570
+ const not_found = [];
3566
3571
  const errors = [];
3567
3572
  for (const id of targetIds) {
3568
3573
  const exists = await this.db.run('?[name] := *entity{id: $id, name, @ "NOW"}', { id });
3569
3574
  if (exists.rows.length === 0) {
3570
- errors.push({ id, error: "Entity not found" });
3575
+ not_found.push(id);
3571
3576
  continue;
3572
3577
  }
3573
3578
  if (dryRun) {
@@ -3576,26 +3581,28 @@ Format MUST start with "ExecutiveSummary: " followed by the consolidated content
3576
3581
  const relInC = await this.db.run('?[count(f)] := *relationship{from_id: f, to_id: $id, @ "NOW"}', { id });
3577
3582
  deleted_observations += Number(obsC.rows[0]?.[0] || 0);
3578
3583
  deleted_relations += Number(relOutC.rows[0]?.[0] || 0) + Number(relInC.rows[0]?.[0] || 0);
3579
- deleted_entities.push(id);
3584
+ deleted.push(id);
3580
3585
  }
3581
3586
  else {
3582
3587
  const res = await this.deleteEntity({ entity_id: id });
3583
3588
  if (res.error) {
3584
- errors.push({ id, error: res.message || res.error });
3589
+ errors.push(`${id}: ${res.message || res.error}`);
3585
3590
  continue;
3586
3591
  }
3587
3592
  deleted_observations += Number(res.deleted?.observations || 0);
3588
3593
  deleted_relations += Number(res.deleted?.outgoing_relations || 0) + Number(res.deleted?.incoming_relations || 0);
3589
- deleted_entities.push(id);
3594
+ deleted.push(id);
3590
3595
  }
3591
3596
  }
3592
3597
  return {
3593
3598
  status: dryRun ? "dry_run" : "deleted",
3594
- deleted_count: deleted_entities.length,
3595
- deleted_entities,
3599
+ deleted_count: deleted.length,
3600
+ deleted,
3601
+ not_found,
3602
+ errors,
3603
+ deleted_entities: deleted,
3596
3604
  deleted_observations,
3597
3605
  deleted_relations,
3598
- ...(errors.length ? { errors } : {}),
3599
3606
  };
3600
3607
  }
3601
3608
  catch (error) {
@@ -4093,6 +4100,22 @@ Format MUST start with "ExecutiveSummary: " followed by the consolidated content
4093
4100
  continue_on_error: zod_1.z.boolean().optional().describe("For batch: continue after failures (non-transactional)"),
4094
4101
  transactional: zod_1.z.boolean().optional().describe("For batch: all-or-nothing (default true)"),
4095
4102
  });
4103
+ // Normalizes common parameter aliases that LLMs frequently send so they
4104
+ // pass discriminatedUnion validation (which doesn't support z.preprocess).
4105
+ const normalizeAliases = (args) => {
4106
+ if (!args || typeof args !== "object")
4107
+ return args;
4108
+ const a = { ...args };
4109
+ if (a.action === "create_entity" && a.entity_type && !a.type)
4110
+ a.type = a.entity_type;
4111
+ if (a.action === "update_entity" && a.entity_id && !a.id)
4112
+ a.id = a.entity_id;
4113
+ if (a.action === "stop_session" && a.session_id && !a.id)
4114
+ a.id = a.session_id;
4115
+ if (a.action === "stop_task" && a.task_id && !a.id)
4116
+ a.id = a.task_id;
4117
+ return a;
4118
+ };
4096
4119
  this.mcp.addTool({
4097
4120
  name: "mutate_memory",
4098
4121
  description: `Write access to memory. Select operation via 'action'.
@@ -4109,8 +4132,10 @@ Note: Inference rules must return exactly 5 columns: [from_id, to_id, relation_t
4109
4132
  execute: async (args) => {
4110
4133
  await this.initPromise;
4111
4134
  console.error(`[mutate_memory] Call with:`, JSON.stringify(args, null, 2));
4135
+ // Normalize common parameter aliases that LLMs frequently send before validation.
4136
+ const normalizedArgs = normalizeAliases(args);
4112
4137
  // Zod discriminatedUnion is strict. We try to parse it more flexibly.
4113
- const parsed = MutateMemorySchema.safeParse(args);
4138
+ const parsed = MutateMemorySchema.safeParse(normalizedArgs);
4114
4139
  if (!parsed.success) {
4115
4140
  console.error(`[mutate_memory] Validation error:`, JSON.stringify(parsed.error.issues, null, 2));
4116
4141
  return JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozo-memory",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
4
4
  "mcpName": "io.github.tobs-code/cozo-memory",
5
5
  "description": "Local-first persistent memory system for AI agents with hybrid search, graph reasoning, and MCP integration",
6
6
  "main": "dist/index.js",