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