@signetai/connector-gemini 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
@@ -9507,6 +9507,96 @@ function up79(db) {
9507
9507
  ON transcript_capture_jobs(agent_id, session_key, created_at);
9508
9508
  `);
9509
9509
  }
9510
+ function hasColumn10(db, table, column) {
9511
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
9512
+ return rows.some((row) => row.name === column);
9513
+ }
9514
+ function up80(db) {
9515
+ if (!hasColumn10(db, "documents", "agent_id")) {
9516
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
9517
+ }
9518
+ if (!hasColumn10(db, "documents", "project")) {
9519
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
9520
+ }
9521
+ db.exec(`
9522
+ UPDATE documents
9523
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
9524
+ WHERE metadata_json IS NOT NULL
9525
+ AND json_valid(metadata_json)
9526
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
9527
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
9528
+ `);
9529
+ db.exec(`
9530
+ UPDATE documents
9531
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
9532
+ WHERE metadata_json IS NOT NULL
9533
+ AND json_valid(metadata_json)
9534
+ AND json_type(metadata_json, '$.signet.project') = 'text'
9535
+ `);
9536
+ db.exec(`
9537
+ WITH linked_scope AS (
9538
+ SELECT
9539
+ dm.document_id,
9540
+ m.agent_id,
9541
+ m.project,
9542
+ ROW_NUMBER() OVER (
9543
+ PARTITION BY dm.document_id
9544
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
9545
+ ) AS rank
9546
+ FROM document_memories dm
9547
+ JOIN memories m ON m.id = dm.memory_id
9548
+ WHERE m.agent_id IS NOT NULL
9549
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
9550
+ GROUP BY dm.document_id, m.agent_id, m.project
9551
+ )
9552
+ UPDATE documents
9553
+ SET
9554
+ agent_id = COALESCE((
9555
+ SELECT agent_id FROM linked_scope
9556
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9557
+ ), agent_id),
9558
+ project = (
9559
+ SELECT project FROM linked_scope
9560
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9561
+ )
9562
+ WHERE EXISTS (
9563
+ SELECT 1 FROM linked_scope
9564
+ WHERE linked_scope.document_id = documents.id AND rank = 1
9565
+ )
9566
+ AND NOT (
9567
+ metadata_json IS NOT NULL
9568
+ AND json_valid(metadata_json)
9569
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
9570
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
9571
+ )
9572
+ `);
9573
+ if (hasColumn10(db, "memories", "visibility") && hasColumn10(db, "memories", "type") && hasColumn10(db, "memories", "source_type")) {
9574
+ db.exec(`
9575
+ UPDATE memories
9576
+ SET visibility = 'private'
9577
+ WHERE id IN (SELECT memory_id FROM document_memories)
9578
+ AND type = 'document_chunk'
9579
+ AND source_type = 'document'
9580
+ AND (visibility IS NULL OR visibility = 'global')
9581
+ `);
9582
+ }
9583
+ 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")) {
9584
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
9585
+ db.exec(`
9586
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
9587
+ ON memories(
9588
+ content_hash,
9589
+ COALESCE(NULLIF(agent_id, ''), 'default'),
9590
+ COALESCE(project, ''),
9591
+ COALESCE(scope, '__NULL__'),
9592
+ COALESCE(visibility, 'global')
9593
+ )
9594
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
9595
+ `);
9596
+ }
9597
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
9598
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
9599
+ }
9510
9600
  var MIGRATIONS = [
9511
9601
  {
9512
9602
  version: 1,
@@ -10141,6 +10231,17 @@ var MIGRATIONS = [
10141
10231
  artifacts: {
10142
10232
  tables: ["transcript_capture_jobs"]
10143
10233
  }
10234
+ },
10235
+ {
10236
+ version: 80,
10237
+ name: "document-scope-columns",
10238
+ up: up80,
10239
+ artifacts: {
10240
+ columns: [
10241
+ { table: "documents", column: "agent_id" },
10242
+ { table: "documents", column: "project" }
10243
+ ]
10244
+ }
10144
10245
  }
10145
10246
  ];
10146
10247
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -17482,7 +17583,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
17482
17583
  return true;
17483
17584
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
17484
17585
  }
17485
- function up80(db) {
17586
+ function up81(db) {
17486
17587
  db.exec(`
17487
17588
  CREATE TABLE IF NOT EXISTS schema_migrations (
17488
17589
  version INTEGER PRIMARY KEY,
@@ -17571,12 +17672,12 @@ function up80(db) {
17571
17672
  } catch {}
17572
17673
  createMemoriesFts2(db);
17573
17674
  }
17574
- function hasColumn10(db, table, column) {
17675
+ function hasColumn11(db, table, column) {
17575
17676
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
17576
17677
  return rows.some((r) => r.name === column);
17577
17678
  }
17578
17679
  function addColumnIfMissing20(db, table, column, definition) {
17579
- if (!hasColumn10(db, table, column)) {
17680
+ if (!hasColumn11(db, table, column)) {
17580
17681
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
17581
17682
  }
17582
17683
  }
@@ -20040,11 +20141,101 @@ function up792(db) {
20040
20141
  ON transcript_capture_jobs(agent_id, session_key, created_at);
20041
20142
  `);
20042
20143
  }
20144
+ function hasColumn102(db, table, column) {
20145
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
20146
+ return rows.some((row) => row.name === column);
20147
+ }
20148
+ function up802(db) {
20149
+ if (!hasColumn102(db, "documents", "agent_id")) {
20150
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
20151
+ }
20152
+ if (!hasColumn102(db, "documents", "project")) {
20153
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
20154
+ }
20155
+ db.exec(`
20156
+ UPDATE documents
20157
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
20158
+ WHERE metadata_json IS NOT NULL
20159
+ AND json_valid(metadata_json)
20160
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
20161
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
20162
+ `);
20163
+ db.exec(`
20164
+ UPDATE documents
20165
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
20166
+ WHERE metadata_json IS NOT NULL
20167
+ AND json_valid(metadata_json)
20168
+ AND json_type(metadata_json, '$.signet.project') = 'text'
20169
+ `);
20170
+ db.exec(`
20171
+ WITH linked_scope AS (
20172
+ SELECT
20173
+ dm.document_id,
20174
+ m.agent_id,
20175
+ m.project,
20176
+ ROW_NUMBER() OVER (
20177
+ PARTITION BY dm.document_id
20178
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
20179
+ ) AS rank
20180
+ FROM document_memories dm
20181
+ JOIN memories m ON m.id = dm.memory_id
20182
+ WHERE m.agent_id IS NOT NULL
20183
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
20184
+ GROUP BY dm.document_id, m.agent_id, m.project
20185
+ )
20186
+ UPDATE documents
20187
+ SET
20188
+ agent_id = COALESCE((
20189
+ SELECT agent_id FROM linked_scope
20190
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20191
+ ), agent_id),
20192
+ project = (
20193
+ SELECT project FROM linked_scope
20194
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20195
+ )
20196
+ WHERE EXISTS (
20197
+ SELECT 1 FROM linked_scope
20198
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20199
+ )
20200
+ AND NOT (
20201
+ metadata_json IS NOT NULL
20202
+ AND json_valid(metadata_json)
20203
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
20204
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
20205
+ )
20206
+ `);
20207
+ if (hasColumn102(db, "memories", "visibility") && hasColumn102(db, "memories", "type") && hasColumn102(db, "memories", "source_type")) {
20208
+ db.exec(`
20209
+ UPDATE memories
20210
+ SET visibility = 'private'
20211
+ WHERE id IN (SELECT memory_id FROM document_memories)
20212
+ AND type = 'document_chunk'
20213
+ AND source_type = 'document'
20214
+ AND (visibility IS NULL OR visibility = 'global')
20215
+ `);
20216
+ }
20217
+ 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")) {
20218
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
20219
+ db.exec(`
20220
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
20221
+ ON memories(
20222
+ content_hash,
20223
+ COALESCE(NULLIF(agent_id, ''), 'default'),
20224
+ COALESCE(project, ''),
20225
+ COALESCE(scope, '__NULL__'),
20226
+ COALESCE(visibility, 'global')
20227
+ )
20228
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
20229
+ `);
20230
+ }
20231
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
20232
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
20233
+ }
20043
20234
  var MIGRATIONS2 = [
20044
20235
  {
20045
20236
  version: 1,
20046
20237
  name: "baseline",
20047
- up: up80,
20238
+ up: up81,
20048
20239
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
20049
20240
  },
20050
20241
  {
@@ -20674,6 +20865,17 @@ var MIGRATIONS2 = [
20674
20865
  artifacts: {
20675
20866
  tables: ["transcript_capture_jobs"]
20676
20867
  }
20868
+ },
20869
+ {
20870
+ version: 80,
20871
+ name: "document-scope-columns",
20872
+ up: up802,
20873
+ artifacts: {
20874
+ columns: [
20875
+ { table: "documents", column: "agent_id" },
20876
+ { table: "documents", column: "project" }
20877
+ ]
20878
+ }
20677
20879
  }
20678
20880
  ];
20679
20881
  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-gemini",
3
- "version": "0.144.0",
3
+ "version": "0.145.0",
4
4
  "description": "Signet connector for Gemini 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",