@signetai/connector-forge 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;
@@ -17485,7 +17586,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
17485
17586
  return true;
17486
17587
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
17487
17588
  }
17488
- function up80(db) {
17589
+ function up81(db) {
17489
17590
  db.exec(`
17490
17591
  CREATE TABLE IF NOT EXISTS schema_migrations (
17491
17592
  version INTEGER PRIMARY KEY,
@@ -17574,12 +17675,12 @@ function up80(db) {
17574
17675
  } catch {}
17575
17676
  createMemoriesFts2(db);
17576
17677
  }
17577
- function hasColumn10(db, table, column) {
17678
+ function hasColumn11(db, table, column) {
17578
17679
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
17579
17680
  return rows.some((r) => r.name === column);
17580
17681
  }
17581
17682
  function addColumnIfMissing20(db, table, column, definition) {
17582
- if (!hasColumn10(db, table, column)) {
17683
+ if (!hasColumn11(db, table, column)) {
17583
17684
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
17584
17685
  }
17585
17686
  }
@@ -20043,11 +20144,101 @@ function up792(db) {
20043
20144
  ON transcript_capture_jobs(agent_id, session_key, created_at);
20044
20145
  `);
20045
20146
  }
20147
+ function hasColumn102(db, table, column) {
20148
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
20149
+ return rows.some((row) => row.name === column);
20150
+ }
20151
+ function up802(db) {
20152
+ if (!hasColumn102(db, "documents", "agent_id")) {
20153
+ db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
20154
+ }
20155
+ if (!hasColumn102(db, "documents", "project")) {
20156
+ db.exec("ALTER TABLE documents ADD COLUMN project TEXT");
20157
+ }
20158
+ db.exec(`
20159
+ UPDATE documents
20160
+ SET agent_id = NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '')
20161
+ WHERE metadata_json IS NOT NULL
20162
+ AND json_valid(metadata_json)
20163
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
20164
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
20165
+ `);
20166
+ db.exec(`
20167
+ UPDATE documents
20168
+ SET project = NULLIF(TRIM(json_extract(metadata_json, '$.signet.project')), '')
20169
+ WHERE metadata_json IS NOT NULL
20170
+ AND json_valid(metadata_json)
20171
+ AND json_type(metadata_json, '$.signet.project') = 'text'
20172
+ `);
20173
+ db.exec(`
20174
+ WITH linked_scope AS (
20175
+ SELECT
20176
+ dm.document_id,
20177
+ m.agent_id,
20178
+ m.project,
20179
+ ROW_NUMBER() OVER (
20180
+ PARTITION BY dm.document_id
20181
+ ORDER BY COUNT(*) DESC, m.agent_id, COALESCE(m.project, '')
20182
+ ) AS rank
20183
+ FROM document_memories dm
20184
+ JOIN memories m ON m.id = dm.memory_id
20185
+ WHERE m.agent_id IS NOT NULL
20186
+ AND NULLIF(TRIM(m.agent_id), '') IS NOT NULL
20187
+ GROUP BY dm.document_id, m.agent_id, m.project
20188
+ )
20189
+ UPDATE documents
20190
+ SET
20191
+ agent_id = COALESCE((
20192
+ SELECT agent_id FROM linked_scope
20193
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20194
+ ), agent_id),
20195
+ project = (
20196
+ SELECT project FROM linked_scope
20197
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20198
+ )
20199
+ WHERE EXISTS (
20200
+ SELECT 1 FROM linked_scope
20201
+ WHERE linked_scope.document_id = documents.id AND rank = 1
20202
+ )
20203
+ AND NOT (
20204
+ metadata_json IS NOT NULL
20205
+ AND json_valid(metadata_json)
20206
+ AND json_type(metadata_json, '$.signet.agentId') = 'text'
20207
+ AND NULLIF(TRIM(json_extract(metadata_json, '$.signet.agentId')), '') IS NOT NULL
20208
+ )
20209
+ `);
20210
+ if (hasColumn102(db, "memories", "visibility") && hasColumn102(db, "memories", "type") && hasColumn102(db, "memories", "source_type")) {
20211
+ db.exec(`
20212
+ UPDATE memories
20213
+ SET visibility = 'private'
20214
+ WHERE id IN (SELECT memory_id FROM document_memories)
20215
+ AND type = 'document_chunk'
20216
+ AND source_type = 'document'
20217
+ AND (visibility IS NULL OR visibility = 'global')
20218
+ `);
20219
+ }
20220
+ 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")) {
20221
+ db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
20222
+ db.exec(`
20223
+ CREATE UNIQUE INDEX idx_memories_content_hash_unique
20224
+ ON memories(
20225
+ content_hash,
20226
+ COALESCE(NULLIF(agent_id, ''), 'default'),
20227
+ COALESCE(project, ''),
20228
+ COALESCE(scope, '__NULL__'),
20229
+ COALESCE(visibility, 'global')
20230
+ )
20231
+ WHERE content_hash IS NOT NULL AND is_deleted = 0
20232
+ `);
20233
+ }
20234
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
20235
+ db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
20236
+ }
20046
20237
  var MIGRATIONS2 = [
20047
20238
  {
20048
20239
  version: 1,
20049
20240
  name: "baseline",
20050
- up: up80,
20241
+ up: up81,
20051
20242
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
20052
20243
  },
20053
20244
  {
@@ -20677,6 +20868,17 @@ var MIGRATIONS2 = [
20677
20868
  artifacts: {
20678
20869
  tables: ["transcript_capture_jobs"]
20679
20870
  }
20871
+ },
20872
+ {
20873
+ version: 80,
20874
+ name: "document-scope-columns",
20875
+ up: up802,
20876
+ artifacts: {
20877
+ columns: [
20878
+ { table: "documents", column: "agent_id" },
20879
+ { table: "documents", column: "project" }
20880
+ ]
20881
+ }
20680
20882
  }
20681
20883
  ];
20682
20884
  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-forge",
3
- "version": "0.144.0",
3
+ "version": "0.145.0",
4
4
  "description": "Signet connector for ForgeCode - installs MCP, identity, and skills integration",
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",