@signetai/signet-memory-openclaw 0.143.2 → 0.144.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.
Files changed (2) hide show
  1. package/dist/index.js +101 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9508,6 +9508,96 @@ function up79(db) {
9508
9508
  ON transcript_capture_jobs(agent_id, session_key, created_at);
9509
9509
  `);
9510
9510
  }
9511
+ function hasColumn10(db, table, column) {
9512
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
9513
+ return rows.some((row) => row.name === column);
9514
+ }
9515
+ function up80(db) {
9516
+ if (!hasColumn10(db, "documents", "agent_id")) {
9517
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
9518
+ }
9519
+ if (!hasColumn10(db, "documents", "project")) {
9520
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
9521
+ }
9522
+ db.exec(`
9523
+ UPDATE documents
9524
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
9525
+ WHERE metadata_json IS NOT NULL
9526
+ AND json_valid(metadata_json)
9527
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
9528
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
9529
+ `);
9530
+ db.exec(`
9531
+ UPDATE documents
9532
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
9533
+ WHERE metadata_json IS NOT NULL
9534
+ AND json_valid(metadata_json)
9535
+ AND json_type(metadata_json, '$.signet.project') = 'text'
9536
+ `);
9537
+ db.exec(`
9538
+ WITH linked_scope AS (
9539
+ SELECT
9540
+ dm.document_id,
9541
+ m.agent_id,
9542
+ m.project,
9543
+ ROW_NUMBER() OVER (
9544
+ PARTITION BY dm.document_id
9545
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
9546
+ ) AS rank
9547
+ FROM document_memories dm
9548
+ JOIN memories m ON m.id = dm.memory_id
9549
+ WHERE m.agent_id IS NOT NULL
9550
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
9551
+ GROUP BY dm.document_id, m.agent_id, m.project
9552
+ )
9553
+ UPDATE documents
9554
+ SET
9555
+ agent_id = COALESCE((
9556
+ SELECT agent_id FROM linked_scope
9557
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9558
+ ), agent_id),
9559
+ project = (
9560
+ SELECT project FROM linked_scope
9561
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9562
+ )
9563
+ WHERE EXISTS (
9564
+ SELECT 1 FROM linked_scope
9565
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9566
+ )
9567
+ AND NOT (
9568
+ metadata_json IS NOT NULL
9569
+ AND json_valid(metadata_json)
9570
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
9571
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
9572
+ )
9573
+ `);
9574
+ if (hasColumn10(db, "memories", "visibility") && hasColumn10(db, "memories", "type") && hasColumn10(db, "memories", "source_type")) {
9575
+ db.exec(`
9576
+ UPDATE memories
9577
+ SET visibility = 'private'
9578
+ WHERE id IN (SELECT memory_id FROM document_memories)
9579
+ AND type = 'document_chunk'
9580
+ AND source_type = 'document'
9581
+ AND (visibility IS NULL OR visibility = 'global')
9582
+ `);
9583
+ }
9584
+ if (hasColumn10(db, "memories", "content_hash") && hasColumn10(db, "memories", "agent_id") && hasColumn10(db, "memories", "project") && hasColumn10(db, "memories", "scope") && hasColumn10(db, "memories", "visibility") && hasColumn10(db, "memories", "is_deleted")) {
9585
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
9586
+ db.exec(`
9587
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
9588
+ ON memories(
9589
+ content_hash,
9590
+ COALESCE(NULLIF(agent_id, ''), 'default'),
9591
+ COALESCE(project, ''),
9592
+ COALESCE(scope, '__NULL__'),
9593
+ COALESCE(visibility, 'global')
9594
+ )
9595
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
9596
+ `);
9597
+ }
9598
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
9599
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
9600
+ }
9511
9601
  var MIGRATIONS = [
9512
9602
  {
9513
9603
  version: 1,
@@ -10142,6 +10232,17 @@ var MIGRATIONS = [
10142
10232
  artifacts: {
10143
10233
  tables: ["transcript_capture_jobs"]
10144
10234
  }
10235
+ },
10236
+ {
10237
+ version: 80,
10238
+ name: "document-scope-columns",
10239
+ up: up80,
10240
+ artifacts: {
10241
+ columns: [
10242
+ { table: "documents", column: "agent_id" },
10243
+ { table: "documents", column: "project" }
10244
+ ]
10245
+ }
10145
10246
  }
10146
10247
  ];
10147
10248
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/signet-memory-openclaw",
3
- "version": "0.143.2",
3
+ "version": "0.144.1",
4
4
  "description": "Signet adapter for OpenClaw — runtime plugin for AI agent memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",