@signetai/connector-openclaw 0.144.0 → 0.145.0

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 +206 -4
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -10640,6 +10640,96 @@ function up79(db) {
10640
10640
  ON transcript_capture_jobs(agent_id, session_key, created_at);
10641
10641
  `);
10642
10642
  }
10643
+ function hasColumn10(db, table, column) {
10644
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
10645
+ return rows.some((row) => row.name === column);
10646
+ }
10647
+ function up80(db) {
10648
+ if (!hasColumn10(db, "documents", "agent_id")) {
10649
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
10650
+ }
10651
+ if (!hasColumn10(db, "documents", "project")) {
10652
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
10653
+ }
10654
+ db.exec(`
10655
+ UPDATE documents
10656
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
10657
+ WHERE metadata_json IS NOT NULL
10658
+ AND json_valid(metadata_json)
10659
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
10660
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
10661
+ `);
10662
+ db.exec(`
10663
+ UPDATE documents
10664
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
10665
+ WHERE metadata_json IS NOT NULL
10666
+ AND json_valid(metadata_json)
10667
+ AND json_type(metadata_json, '$.signet.project') = 'text'
10668
+ `);
10669
+ db.exec(`
10670
+ WITH linked_scope AS (
10671
+ SELECT
10672
+ dm.document_id,
10673
+ m.agent_id,
10674
+ m.project,
10675
+ ROW_NUMBER() OVER (
10676
+ PARTITION BY dm.document_id
10677
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
10678
+ ) AS rank
10679
+ FROM document_memories dm
10680
+ JOIN memories m ON m.id = dm.memory_id
10681
+ WHERE m.agent_id IS NOT NULL
10682
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
10683
+ GROUP BY dm.document_id, m.agent_id, m.project
10684
+ )
10685
+ UPDATE documents
10686
+ SET
10687
+ agent_id = COALESCE((
10688
+ SELECT agent_id FROM linked_scope
10689
+ WHERE linked_scope.document_id = documents.id AND rank = 1
10690
+ ), agent_id),
10691
+ project = (
10692
+ SELECT project FROM linked_scope
10693
+ WHERE linked_scope.document_id = documents.id AND rank = 1
10694
+ )
10695
+ WHERE EXISTS (
10696
+ SELECT 1 FROM linked_scope
10697
+ WHERE linked_scope.document_id = documents.id AND rank = 1
10698
+ )
10699
+ AND NOT (
10700
+ metadata_json IS NOT NULL
10701
+ AND json_valid(metadata_json)
10702
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
10703
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
10704
+ )
10705
+ `);
10706
+ if (hasColumn10(db, "memories", "visibility") && hasColumn10(db, "memories", "type") && hasColumn10(db, "memories", "source_type")) {
10707
+ db.exec(`
10708
+ UPDATE memories
10709
+ SET visibility = 'private'
10710
+ WHERE id IN (SELECT memory_id FROM document_memories)
10711
+ AND type = 'document_chunk'
10712
+ AND source_type = 'document'
10713
+ AND (visibility IS NULL OR visibility = 'global')
10714
+ `);
10715
+ }
10716
+ 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")) {
10717
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
10718
+ db.exec(`
10719
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
10720
+ ON memories(
10721
+ content_hash,
10722
+ COALESCE(NULLIF(agent_id, ''), 'default'),
10723
+ COALESCE(project, ''),
10724
+ COALESCE(scope, '__NULL__'),
10725
+ COALESCE(visibility, 'global')
10726
+ )
10727
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
10728
+ `);
10729
+ }
10730
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
10731
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
10732
+ }
10643
10733
  var MIGRATIONS = [
10644
10734
  {
10645
10735
  version: 1,
@@ -11274,6 +11364,17 @@ var MIGRATIONS = [
11274
11364
  artifacts: {
11275
11365
  tables: ["transcript_capture_jobs"]
11276
11366
  }
11367
+ },
11368
+ {
11369
+ version: 80,
11370
+ name: "document-scope-columns",
11371
+ up: up80,
11372
+ artifacts: {
11373
+ columns: [
11374
+ { table: "documents", column: "agent_id" },
11375
+ { table: "documents", column: "project" }
11376
+ ]
11377
+ }
11277
11378
  }
11278
11379
  ];
11279
11380
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -18569,7 +18670,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
18569
18670
  return true;
18570
18671
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
18571
18672
  }
18572
- function up80(db) {
18673
+ function up81(db) {
18573
18674
  db.exec(`
18574
18675
  CREATE TABLE IF NOT EXISTS schema_migrations (
18575
18676
  version INTEGER PRIMARY KEY,
@@ -18658,12 +18759,12 @@ function up80(db) {
18658
18759
  } catch {}
18659
18760
  createMemoriesFts2(db);
18660
18761
  }
18661
- function hasColumn10(db, table, column) {
18762
+ function hasColumn11(db, table, column) {
18662
18763
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
18663
18764
  return rows.some((r) => r.name === column);
18664
18765
  }
18665
18766
  function addColumnIfMissing20(db, table, column, definition) {
18666
- if (!hasColumn10(db, table, column)) {
18767
+ if (!hasColumn11(db, table, column)) {
18667
18768
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
18668
18769
  }
18669
18770
  }
@@ -21127,11 +21228,101 @@ function up792(db) {
21127
21228
  ON transcript_capture_jobs(agent_id, session_key, created_at);
21128
21229
  `);
21129
21230
  }
21231
+ function hasColumn102(db, table, column) {
21232
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
21233
+ return rows.some((row) => row.name === column);
21234
+ }
21235
+ function up802(db) {
21236
+ if (!hasColumn102(db, "documents", "agent_id")) {
21237
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
21238
+ }
21239
+ if (!hasColumn102(db, "documents", "project")) {
21240
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
21241
+ }
21242
+ db.exec(`
21243
+ UPDATE documents
21244
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
21245
+ WHERE metadata_json IS NOT NULL
21246
+ AND json_valid(metadata_json)
21247
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
21248
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
21249
+ `);
21250
+ db.exec(`
21251
+ UPDATE documents
21252
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
21253
+ WHERE metadata_json IS NOT NULL
21254
+ AND json_valid(metadata_json)
21255
+ AND json_type(metadata_json, '$.signet.project') = 'text'
21256
+ `);
21257
+ db.exec(`
21258
+ WITH linked_scope AS (
21259
+ SELECT
21260
+ dm.document_id,
21261
+ m.agent_id,
21262
+ m.project,
21263
+ ROW_NUMBER() OVER (
21264
+ PARTITION BY dm.document_id
21265
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
21266
+ ) AS rank
21267
+ FROM document_memories dm
21268
+ JOIN memories m ON m.id = dm.memory_id
21269
+ WHERE m.agent_id IS NOT NULL
21270
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
21271
+ GROUP BY dm.document_id, m.agent_id, m.project
21272
+ )
21273
+ UPDATE documents
21274
+ SET
21275
+ agent_id = COALESCE((
21276
+ SELECT agent_id FROM linked_scope
21277
+ WHERE linked_scope.document_id = documents.id AND rank = 1
21278
+ ), agent_id),
21279
+ project = (
21280
+ SELECT project FROM linked_scope
21281
+ WHERE linked_scope.document_id = documents.id AND rank = 1
21282
+ )
21283
+ WHERE EXISTS (
21284
+ SELECT 1 FROM linked_scope
21285
+ WHERE linked_scope.document_id = documents.id AND rank = 1
21286
+ )
21287
+ AND NOT (
21288
+ metadata_json IS NOT NULL
21289
+ AND json_valid(metadata_json)
21290
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
21291
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
21292
+ )
21293
+ `);
21294
+ if (hasColumn102(db, "memories", "visibility") && hasColumn102(db, "memories", "type") && hasColumn102(db, "memories", "source_type")) {
21295
+ db.exec(`
21296
+ UPDATE memories
21297
+ SET visibility = 'private'
21298
+ WHERE id IN (SELECT memory_id FROM document_memories)
21299
+ AND type = 'document_chunk'
21300
+ AND source_type = 'document'
21301
+ AND (visibility IS NULL OR visibility = 'global')
21302
+ `);
21303
+ }
21304
+ if (hasColumn102(db, "memories", "content_hash") && hasColumn102(db, "memories", "agent_id") && hasColumn102(db, "memories", "project") && hasColumn102(db, "memories", "scope") && hasColumn102(db, "memories", "visibility") && hasColumn102(db, "memories", "is_deleted")) {
21305
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
21306
+ db.exec(`
21307
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
21308
+ ON memories(
21309
+ content_hash,
21310
+ COALESCE(NULLIF(agent_id, ''), 'default'),
21311
+ COALESCE(project, ''),
21312
+ COALESCE(scope, '__NULL__'),
21313
+ COALESCE(visibility, 'global')
21314
+ )
21315
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
21316
+ `);
21317
+ }
21318
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
21319
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
21320
+ }
21130
21321
  var MIGRATIONS2 = [
21131
21322
  {
21132
21323
  version: 1,
21133
21324
  name: "baseline",
21134
- up: up80,
21325
+ up: up81,
21135
21326
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
21136
21327
  },
21137
21328
  {
@@ -21761,6 +21952,17 @@ var MIGRATIONS2 = [
21761
21952
  artifacts: {
21762
21953
  tables: ["transcript_capture_jobs"]
21763
21954
  }
21955
+ },
21956
+ {
21957
+ version: 80,
21958
+ name: "document-scope-columns",
21959
+ up: up802,
21960
+ artifacts: {
21961
+ columns: [
21962
+ { table: "documents", column: "agent_id" },
21963
+ { table: "documents", column: "project" }
21964
+ ]
21965
+ }
21764
21966
  }
21765
21967
  ];
21766
21968
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-openclaw",
3
- "version": "0.144.0",
3
+ "version": "0.145.0",
4
4
  "description": "Signet connector for OpenClaw - configures workspace and memory hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "test": "bun test"
26
26
  },
27
27
  "dependencies": {
28
- "@signetai/connector-base": "0.144.0",
29
- "@signetai/core": "0.144.0",
28
+ "@signetai/connector-base": "0.145.0",
29
+ "@signetai/core": "0.145.0",
30
30
  "json5": "^2.2.3"
31
31
  },
32
32
  "devDependencies": {