@signetai/connector-claude-code 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
@@ -9495,6 +9495,96 @@ function up79(db) {
9495
9495
  ON transcript_capture_jobs(agent_id, session_key, created_at);
9496
9496
  `);
9497
9497
  }
9498
+ function hasColumn10(db, table, column) {
9499
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
9500
+ return rows.some((row) => row.name === column);
9501
+ }
9502
+ function up80(db) {
9503
+ if (!hasColumn10(db, "documents", "agent_id")) {
9504
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
9505
+ }
9506
+ if (!hasColumn10(db, "documents", "project")) {
9507
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
9508
+ }
9509
+ db.exec(`
9510
+ UPDATE documents
9511
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
9512
+ WHERE metadata_json IS NOT NULL
9513
+ AND json_valid(metadata_json)
9514
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
9515
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
9516
+ `);
9517
+ db.exec(`
9518
+ UPDATE documents
9519
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
9520
+ WHERE metadata_json IS NOT NULL
9521
+ AND json_valid(metadata_json)
9522
+ AND json_type(metadata_json, '$.signet.project') = 'text'
9523
+ `);
9524
+ db.exec(`
9525
+ WITH linked_scope AS (
9526
+ SELECT
9527
+ dm.document_id,
9528
+ m.agent_id,
9529
+ m.project,
9530
+ ROW_NUMBER() OVER (
9531
+ PARTITION BY dm.document_id
9532
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
9533
+ ) AS rank
9534
+ FROM document_memories dm
9535
+ JOIN memories m ON m.id = dm.memory_id
9536
+ WHERE m.agent_id IS NOT NULL
9537
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
9538
+ GROUP BY dm.document_id, m.agent_id, m.project
9539
+ )
9540
+ UPDATE documents
9541
+ SET
9542
+ agent_id = COALESCE((
9543
+ SELECT agent_id FROM linked_scope
9544
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9545
+ ), agent_id),
9546
+ project = (
9547
+ SELECT project FROM linked_scope
9548
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9549
+ )
9550
+ WHERE EXISTS (
9551
+ SELECT 1 FROM linked_scope
9552
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9553
+ )
9554
+ AND NOT (
9555
+ metadata_json IS NOT NULL
9556
+ AND json_valid(metadata_json)
9557
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
9558
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
9559
+ )
9560
+ `);
9561
+ if (hasColumn10(db, "memories", "visibility") && hasColumn10(db, "memories", "type") && hasColumn10(db, "memories", "source_type")) {
9562
+ db.exec(`
9563
+ UPDATE memories
9564
+ SET visibility = 'private'
9565
+ WHERE id IN (SELECT memory_id FROM document_memories)
9566
+ AND type = 'document_chunk'
9567
+ AND source_type = 'document'
9568
+ AND (visibility IS NULL OR visibility = 'global')
9569
+ `);
9570
+ }
9571
+ 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")) {
9572
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
9573
+ db.exec(`
9574
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
9575
+ ON memories(
9576
+ content_hash,
9577
+ COALESCE(NULLIF(agent_id, ''), 'default'),
9578
+ COALESCE(project, ''),
9579
+ COALESCE(scope, '__NULL__'),
9580
+ COALESCE(visibility, 'global')
9581
+ )
9582
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
9583
+ `);
9584
+ }
9585
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
9586
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
9587
+ }
9498
9588
  var MIGRATIONS = [
9499
9589
  {
9500
9590
  version: 1,
@@ -10129,6 +10219,17 @@ var MIGRATIONS = [
10129
10219
  artifacts: {
10130
10220
  tables: ["transcript_capture_jobs"]
10131
10221
  }
10222
+ },
10223
+ {
10224
+ version: 80,
10225
+ name: "document-scope-columns",
10226
+ up: up80,
10227
+ artifacts: {
10228
+ columns: [
10229
+ { table: "documents", column: "agent_id" },
10230
+ { table: "documents", column: "project" }
10231
+ ]
10232
+ }
10132
10233
  }
10133
10234
  ];
10134
10235
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -17429,7 +17530,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
17429
17530
  return true;
17430
17531
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
17431
17532
  }
17432
- function up80(db) {
17533
+ function up81(db) {
17433
17534
  db.exec(`
17434
17535
  CREATE TABLE IF NOT EXISTS schema_migrations (
17435
17536
  version INTEGER PRIMARY KEY,
@@ -17518,12 +17619,12 @@ function up80(db) {
17518
17619
  } catch {}
17519
17620
  createMemoriesFts2(db);
17520
17621
  }
17521
- function hasColumn10(db, table, column) {
17622
+ function hasColumn11(db, table, column) {
17522
17623
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
17523
17624
  return rows.some((r) => r.name === column);
17524
17625
  }
17525
17626
  function addColumnIfMissing20(db, table, column, definition) {
17526
- if (!hasColumn10(db, table, column)) {
17627
+ if (!hasColumn11(db, table, column)) {
17527
17628
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
17528
17629
  }
17529
17630
  }
@@ -19987,11 +20088,101 @@ function up792(db) {
19987
20088
  ON transcript_capture_jobs(agent_id, session_key, created_at);
19988
20089
  `);
19989
20090
  }
20091
+ function hasColumn102(db, table, column) {
20092
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
20093
+ return rows.some((row) => row.name === column);
20094
+ }
20095
+ function up802(db) {
20096
+ if (!hasColumn102(db, "documents", "agent_id")) {
20097
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
20098
+ }
20099
+ if (!hasColumn102(db, "documents", "project")) {
20100
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
20101
+ }
20102
+ db.exec(`
20103
+ UPDATE documents
20104
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
20105
+ WHERE metadata_json IS NOT NULL
20106
+ AND json_valid(metadata_json)
20107
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
20108
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
20109
+ `);
20110
+ db.exec(`
20111
+ UPDATE documents
20112
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
20113
+ WHERE metadata_json IS NOT NULL
20114
+ AND json_valid(metadata_json)
20115
+ AND json_type(metadata_json, '$.signet.project') = 'text'
20116
+ `);
20117
+ db.exec(`
20118
+ WITH linked_scope AS (
20119
+ SELECT
20120
+ dm.document_id,
20121
+ m.agent_id,
20122
+ m.project,
20123
+ ROW_NUMBER() OVER (
20124
+ PARTITION BY dm.document_id
20125
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
20126
+ ) AS rank
20127
+ FROM document_memories dm
20128
+ JOIN memories m ON m.id = dm.memory_id
20129
+ WHERE m.agent_id IS NOT NULL
20130
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
20131
+ GROUP BY dm.document_id, m.agent_id, m.project
20132
+ )
20133
+ UPDATE documents
20134
+ SET
20135
+ agent_id = COALESCE((
20136
+ SELECT agent_id FROM linked_scope
20137
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20138
+ ), agent_id),
20139
+ project = (
20140
+ SELECT project FROM linked_scope
20141
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20142
+ )
20143
+ WHERE EXISTS (
20144
+ SELECT 1 FROM linked_scope
20145
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20146
+ )
20147
+ AND NOT (
20148
+ metadata_json IS NOT NULL
20149
+ AND json_valid(metadata_json)
20150
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
20151
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
20152
+ )
20153
+ `);
20154
+ if (hasColumn102(db, "memories", "visibility") && hasColumn102(db, "memories", "type") && hasColumn102(db, "memories", "source_type")) {
20155
+ db.exec(`
20156
+ UPDATE memories
20157
+ SET visibility = 'private'
20158
+ WHERE id IN (SELECT memory_id FROM document_memories)
20159
+ AND type = 'document_chunk'
20160
+ AND source_type = 'document'
20161
+ AND (visibility IS NULL OR visibility = 'global')
20162
+ `);
20163
+ }
20164
+ 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")) {
20165
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
20166
+ db.exec(`
20167
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
20168
+ ON memories(
20169
+ content_hash,
20170
+ COALESCE(NULLIF(agent_id, ''), 'default'),
20171
+ COALESCE(project, ''),
20172
+ COALESCE(scope, '__NULL__'),
20173
+ COALESCE(visibility, 'global')
20174
+ )
20175
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
20176
+ `);
20177
+ }
20178
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
20179
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
20180
+ }
19990
20181
  var MIGRATIONS2 = [
19991
20182
  {
19992
20183
  version: 1,
19993
20184
  name: "baseline",
19994
- up: up80,
20185
+ up: up81,
19995
20186
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
19996
20187
  },
19997
20188
  {
@@ -20621,6 +20812,17 @@ var MIGRATIONS2 = [
20621
20812
  artifacts: {
20622
20813
  tables: ["transcript_capture_jobs"]
20623
20814
  }
20815
+ },
20816
+ {
20817
+ version: 80,
20818
+ name: "document-scope-columns",
20819
+ up: up802,
20820
+ artifacts: {
20821
+ columns: [
20822
+ { table: "documents", column: "agent_id" },
20823
+ { table: "documents", column: "project" }
20824
+ ]
20825
+ }
20624
20826
  }
20625
20827
  ];
20626
20828
  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-claude-code",
3
- "version": "0.144.0",
3
+ "version": "0.145.0",
4
4
  "description": "Signet connector for Claude Code (Anthropic CLI)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "typecheck": "tsc --noEmit"
25
25
  },
26
26
  "dependencies": {
27
- "@signetai/connector-base": "0.144.0",
28
- "@signetai/core": "0.144.0"
27
+ "@signetai/connector-base": "0.145.0",
28
+ "@signetai/core": "0.145.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.0.0",