@hasna/mementos 0.14.18 → 0.14.20

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/dist/cli/index.js CHANGED
@@ -13547,6 +13547,7 @@ CREATE TABLE IF NOT EXISTS machines (
13547
13547
  name TEXT NOT NULL UNIQUE,
13548
13548
  hostname TEXT NOT NULL,
13549
13549
  platform TEXT NOT NULL DEFAULT 'unknown',
13550
+ is_primary INTEGER NOT NULL DEFAULT 0,
13550
13551
  created_at TEXT NOT NULL DEFAULT (datetime('now')),
13551
13552
  last_seen_at TEXT NOT NULL DEFAULT (datetime('now'))
13552
13553
  );
@@ -13926,33 +13927,44 @@ CREATE INDEX IF NOT EXISTS idx_memories_sequence_group ON memories(sequence_grou
13926
13927
  INSERT OR IGNORE INTO _migrations (id) VALUES (32);
13927
13928
  `,
13928
13929
  `
13929
- ALTER TABLE machines ADD COLUMN is_primary INTEGER NOT NULL DEFAULT 0;
13930
- CREATE INDEX IF NOT EXISTS idx_machines_primary ON machines(is_primary);
13931
- CREATE TRIGGER IF NOT EXISTS machines_single_primary_insert
13932
- AFTER INSERT ON machines
13933
- WHEN NEW.is_primary = 1
13934
- BEGIN
13935
- UPDATE machines
13936
- SET is_primary = 0,
13937
- last_seen_at = COALESCE(NEW.last_seen_at, datetime('now'))
13938
- WHERE id != NEW.id AND is_primary = 1;
13939
- END;
13940
- CREATE TRIGGER IF NOT EXISTS machines_single_primary_update
13941
- AFTER UPDATE OF is_primary ON machines
13942
- WHEN NEW.is_primary = 1
13943
- BEGIN
13944
- UPDATE machines
13945
- SET is_primary = 0,
13946
- last_seen_at = COALESCE(NEW.last_seen_at, datetime('now'))
13947
- WHERE id != NEW.id AND is_primary = 1;
13948
- END;
13949
- CREATE TRIGGER IF NOT EXISTS machines_prevent_delete_primary
13950
- BEFORE DELETE ON machines
13951
- WHEN OLD.is_primary = 1
13952
- BEGIN
13953
- SELECT RAISE(ABORT, 'Primary machine cannot be deleted');
13954
- END;
13955
- INSERT OR IGNORE INTO _migrations (id) VALUES (33);
13930
+ CREATE TABLE IF NOT EXISTS tasks (
13931
+ id TEXT PRIMARY KEY,
13932
+ subject TEXT NOT NULL,
13933
+ description TEXT DEFAULT '',
13934
+ status TEXT NOT NULL DEFAULT 'pending' CHECK(status IN ('pending', 'in_progress', 'completed', 'failed', 'cancelled')),
13935
+ priority TEXT NOT NULL DEFAULT 'medium' CHECK(priority IN ('critical', 'high', 'medium', 'low')),
13936
+ tags TEXT NOT NULL DEFAULT '[]',
13937
+ assigned_agent_id TEXT REFERENCES agents(id) ON DELETE SET NULL,
13938
+ project_id TEXT REFERENCES projects(id) ON DELETE SET NULL,
13939
+ session_id TEXT,
13940
+ parent_task_id TEXT REFERENCES tasks(id) ON DELETE SET NULL,
13941
+ metadata TEXT NOT NULL DEFAULT '{}',
13942
+ progress REAL NOT NULL DEFAULT 0 CHECK(progress >= 0 AND progress <= 1),
13943
+ due_at TEXT,
13944
+ started_at TEXT,
13945
+ completed_at TEXT,
13946
+ failed_at TEXT,
13947
+ error TEXT,
13948
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
13949
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
13950
+ );
13951
+ CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status);
13952
+ CREATE INDEX IF NOT EXISTS idx_tasks_priority ON tasks(priority);
13953
+ CREATE INDEX IF NOT EXISTS idx_tasks_agent ON tasks(assigned_agent_id);
13954
+ CREATE INDEX IF NOT EXISTS idx_tasks_project ON tasks(project_id);
13955
+ CREATE INDEX IF NOT EXISTS idx_tasks_session ON tasks(session_id);
13956
+ CREATE INDEX IF NOT EXISTS idx_tasks_parent ON tasks(parent_task_id);
13957
+
13958
+ CREATE TABLE IF NOT EXISTS task_comments (
13959
+ id TEXT PRIMARY KEY,
13960
+ task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
13961
+ agent_id TEXT REFERENCES agents(id) ON DELETE SET NULL,
13962
+ body TEXT NOT NULL,
13963
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
13964
+ );
13965
+ CREATE INDEX IF NOT EXISTS idx_task_comments_task ON task_comments(task_id);
13966
+ CREATE INDEX IF NOT EXISTS idx_task_comments_agent ON task_comments(agent_id);
13967
+ INSERT OR IGNORE INTO _migrations (id) VALUES (34);
13956
13968
  `
13957
13969
  ];
13958
13970
  });
@@ -14641,7 +14653,7 @@ function createMemory(input, dedupeMode = "merge", db) {
14641
14653
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'active', 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 1, ?, ?, ?, ?, ?, ?)`, [
14642
14654
  id,
14643
14655
  input.key,
14644
- input.value,
14656
+ safeValue,
14645
14657
  input.category || "knowledge",
14646
14658
  input.scope || "private",
14647
14659
  input.summary || null,
@@ -16405,6 +16417,10 @@ function buildFilterConditions(filter) {
16405
16417
  params.push(tag);
16406
16418
  }
16407
16419
  }
16420
+ if (filter.namespace) {
16421
+ conditions.push("m.namespace = ?");
16422
+ params.push(filter.namespace);
16423
+ }
16408
16424
  return { conditions, params };
16409
16425
  }
16410
16426
  function searchWithFts5(d, query, queryLower, filter, graphBoostedIds) {
@@ -21087,8 +21103,12 @@ function parseMachine(row) {
21087
21103
  is_primary: Boolean(row.is_primary)
21088
21104
  };
21089
21105
  }
21106
+ function normalizeHostname(host) {
21107
+ return host.replace(/\.(local|lan|home|internal)$/i, "");
21108
+ }
21090
21109
  function registerMachine(name, db = getDatabase()) {
21091
- const host = hostname2();
21110
+ const rawHost = hostname2();
21111
+ const host = normalizeHostname(rawHost);
21092
21112
  const plat = platform2();
21093
21113
  const machineName = name?.trim() || host;
21094
21114
  const existing = parseMachine(db.query("SELECT * FROM machines WHERE hostname = ?").get(host));
@@ -21126,7 +21146,7 @@ function touchMachine(id, db = getDatabase()) {
21126
21146
  db.run("UPDATE machines SET last_seen_at = ? WHERE id = ?", [now(), id]);
21127
21147
  }
21128
21148
  function getCurrentMachineId(db = getDatabase()) {
21129
- const host = hostname2();
21149
+ const host = normalizeHostname(hostname2());
21130
21150
  const m = db.query("SELECT id FROM machines WHERE hostname = ?").get(host);
21131
21151
  if (m) {
21132
21152
  touchMachine(m.id, db);
@@ -21877,30 +21897,42 @@ function registerBulkCommand(program2) {
21877
21897
  }
21878
21898
 
21879
21899
  // src/cli/commands/memory-cmd-remove.ts
21900
+ init_database();
21901
+ init_memories();
21902
+ init_helpers();
21880
21903
  import chalk10 from "chalk";
21881
21904
  function registerRemoveCommand(program2) {
21882
- program2.command("remove <nameOrId>").description("Remove/delete a memory by name or ID (alias for memory delete)").option("--agent <id>", "Agent ID").action((nameOrId, opts) => {
21905
+ program2.command("remove <nameOrId>").description("Remove/delete a memory by name or ID (alias for memory forget)").option("--agent <id>", "Agent ID").option("-s, --scope <scope>", "Filter by scope (when looking up by key)").action((nameOrId, opts) => {
21883
21906
  const globalOpts = program2.opts();
21884
21907
  const agentId = opts.agent || globalOpts.agent;
21885
- const { deleteMemory: _deleteMemory, getMemoryByKey: _getMemoryByKey, resolvePartialMemoryId } = (init_memories(), __toCommonJS(exports_memories));
21886
- let id = null;
21887
- try {
21888
- id = resolvePartialMemoryId?.(nameOrId) || null;
21889
- } catch {}
21908
+ const db = getDatabase();
21909
+ let id = resolvePartialId(db, "memories", nameOrId);
21890
21910
  if (!id) {
21891
- const mem = _getMemoryByKey?.(nameOrId, agentId);
21911
+ const mem = getMemoryByKey(nameOrId, opts.scope, agentId);
21892
21912
  if (mem)
21893
21913
  id = mem.id;
21894
21914
  }
21895
21915
  if (!id) {
21896
- console.error(chalk10.red(`Memory not found: ${nameOrId}`));
21916
+ if (globalOpts.json) {
21917
+ outputJson({ error: `Memory not found: ${nameOrId}` });
21918
+ } else {
21919
+ console.error(chalk10.red(`Memory not found: ${nameOrId}`));
21920
+ }
21897
21921
  process.exit(1);
21898
21922
  }
21899
- const deleted = _deleteMemory(id);
21923
+ const deleted = deleteMemory(id);
21900
21924
  if (deleted) {
21901
- console.log(chalk10.green(`\u2713 Memory ${id.slice(0, 8)} removed`));
21925
+ if (globalOpts.json) {
21926
+ outputJson({ deleted: id });
21927
+ } else {
21928
+ console.log(chalk10.green(`Memory ${id.slice(0, 8)} removed`));
21929
+ }
21902
21930
  } else {
21903
- console.error(chalk10.red(`Memory not found: ${nameOrId}`));
21931
+ if (globalOpts.json) {
21932
+ outputJson({ error: `Memory not found: ${nameOrId}` });
21933
+ } else {
21934
+ console.error(chalk10.red(`Memory not found: ${nameOrId}`));
21935
+ }
21904
21936
  process.exit(1);
21905
21937
  }
21906
21938
  });