@signetai/connector-codex 0.146.4 → 0.147.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.
- package/dist/index.js +595 -27
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9622,6 +9622,251 @@ function up82(db) {
|
|
|
9622
9622
|
`);
|
|
9623
9623
|
db.exec("CREATE INDEX IF NOT EXISTS idx_skill_inv_harness ON skill_invocations(harness, created_at)");
|
|
9624
9624
|
}
|
|
9625
|
+
var DEPENDENCY_TYPES = new Set([
|
|
9626
|
+
"uses",
|
|
9627
|
+
"requires",
|
|
9628
|
+
"owned_by",
|
|
9629
|
+
"owns",
|
|
9630
|
+
"blocks",
|
|
9631
|
+
"informs",
|
|
9632
|
+
"maintains",
|
|
9633
|
+
"implements",
|
|
9634
|
+
"built",
|
|
9635
|
+
"depends_on",
|
|
9636
|
+
"related_to",
|
|
9637
|
+
"learned_from",
|
|
9638
|
+
"teaches",
|
|
9639
|
+
"knows",
|
|
9640
|
+
"assumes",
|
|
9641
|
+
"supports_claim",
|
|
9642
|
+
"authored_by",
|
|
9643
|
+
"links_to",
|
|
9644
|
+
"contains",
|
|
9645
|
+
"contains_note",
|
|
9646
|
+
"contradicts",
|
|
9647
|
+
"supersedes",
|
|
9648
|
+
"part_of",
|
|
9649
|
+
"produced_artifact",
|
|
9650
|
+
"precedes",
|
|
9651
|
+
"follows",
|
|
9652
|
+
"triggers",
|
|
9653
|
+
"may_execute",
|
|
9654
|
+
"requires_approval_from",
|
|
9655
|
+
"impacts",
|
|
9656
|
+
"produces",
|
|
9657
|
+
"consumes"
|
|
9658
|
+
]);
|
|
9659
|
+
function sqlStringList(values) {
|
|
9660
|
+
return [...values].map((value) => `'${value}'`).join(", ");
|
|
9661
|
+
}
|
|
9662
|
+
function hasTable3(db, table) {
|
|
9663
|
+
return Boolean(db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table));
|
|
9664
|
+
}
|
|
9665
|
+
function hasColumn12(db, table, column) {
|
|
9666
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
9667
|
+
return rows.some((row) => row.name === column);
|
|
9668
|
+
}
|
|
9669
|
+
function addColumnIfMissing20(db, table, column, definition) {
|
|
9670
|
+
if (!hasColumn12(db, table, column))
|
|
9671
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
9672
|
+
}
|
|
9673
|
+
function documentScopeColumnsPreservingExisting(db) {
|
|
9674
|
+
const preserveAgentId = hasColumn12(db, "documents", "agent_id");
|
|
9675
|
+
const preserveProject = hasColumn12(db, "documents", "project");
|
|
9676
|
+
if (preserveAgentId) {
|
|
9677
|
+
db.exec(`
|
|
9678
|
+
CREATE TEMP TABLE __signet_doc_agent_guard AS
|
|
9679
|
+
SELECT id, agent_id FROM documents
|
|
9680
|
+
WHERE NULLIF(TRIM(agent_id), '') IS NOT NULL
|
|
9681
|
+
AND NULLIF(TRIM(agent_id), '') <> 'default'
|
|
9682
|
+
`);
|
|
9683
|
+
}
|
|
9684
|
+
if (preserveProject) {
|
|
9685
|
+
db.exec(`
|
|
9686
|
+
CREATE TEMP TABLE __signet_doc_project_guard AS
|
|
9687
|
+
SELECT id, project FROM documents
|
|
9688
|
+
WHERE NULLIF(TRIM(project), '') IS NOT NULL
|
|
9689
|
+
`);
|
|
9690
|
+
}
|
|
9691
|
+
try {
|
|
9692
|
+
up80(db);
|
|
9693
|
+
if (preserveAgentId) {
|
|
9694
|
+
db.exec(`
|
|
9695
|
+
UPDATE documents
|
|
9696
|
+
SET agent_id = (SELECT agent_id FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
9697
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
9698
|
+
`);
|
|
9699
|
+
}
|
|
9700
|
+
if (preserveProject) {
|
|
9701
|
+
db.exec(`
|
|
9702
|
+
UPDATE documents
|
|
9703
|
+
SET project = (SELECT project FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
9704
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
9705
|
+
`);
|
|
9706
|
+
}
|
|
9707
|
+
} finally {
|
|
9708
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_agent_guard");
|
|
9709
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_project_guard");
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
function up83(db) {
|
|
9713
|
+
up79(db);
|
|
9714
|
+
if (hasTable3(db, "documents")) {
|
|
9715
|
+
documentScopeColumnsPreservingExisting(db);
|
|
9716
|
+
}
|
|
9717
|
+
up81(db);
|
|
9718
|
+
addColumnIfMissing20(db, "memories", "superseded_by", "TEXT");
|
|
9719
|
+
addColumnIfMissing20(db, "memories", "superseded_at", "TEXT");
|
|
9720
|
+
addColumnIfMissing20(db, "memories", "superseded_reason", "TEXT");
|
|
9721
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_superseded_by ON memories(superseded_by)");
|
|
9722
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_active_supersession ON memories(is_deleted, superseded_by)");
|
|
9723
|
+
if (!hasTable3(db, "relations") || !hasTable3(db, "entity_dependencies"))
|
|
9724
|
+
return;
|
|
9725
|
+
addColumnIfMissing20(db, "entity_dependencies", "confidence", "REAL");
|
|
9726
|
+
addColumnIfMissing20(db, "entity_dependencies", "reason", "TEXT");
|
|
9727
|
+
addColumnIfMissing20(db, "entity_dependencies", "source_id", "TEXT");
|
|
9728
|
+
addColumnIfMissing20(db, "entity_dependencies", "source_kind", "TEXT");
|
|
9729
|
+
addColumnIfMissing20(db, "entity_dependencies", "proposal_evidence", "TEXT NOT NULL DEFAULT '[]'");
|
|
9730
|
+
addColumnIfMissing20(db, "entity_dependencies", "status", "TEXT NOT NULL DEFAULT 'active'");
|
|
9731
|
+
const relationConfidence = hasColumn12(db, "relations", "confidence") ? "r.confidence" : "NULL";
|
|
9732
|
+
const relationUpdatedAt = hasColumn12(db, "relations", "updated_at") ? "r.updated_at" : "r.created_at";
|
|
9733
|
+
const sourceAgentId = hasColumn12(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(src.agent_id), ''), 'default')" : "'default'";
|
|
9734
|
+
const targetAgentId = hasColumn12(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(dst.agent_id), ''), 'default')" : "'default'";
|
|
9735
|
+
db.exec(`
|
|
9736
|
+
INSERT OR IGNORE INTO entity_dependencies (
|
|
9737
|
+
id,
|
|
9738
|
+
source_entity_id,
|
|
9739
|
+
target_entity_id,
|
|
9740
|
+
agent_id,
|
|
9741
|
+
dependency_type,
|
|
9742
|
+
strength,
|
|
9743
|
+
confidence,
|
|
9744
|
+
reason,
|
|
9745
|
+
created_at,
|
|
9746
|
+
updated_at,
|
|
9747
|
+
source_id,
|
|
9748
|
+
source_kind,
|
|
9749
|
+
proposal_evidence,
|
|
9750
|
+
status
|
|
9751
|
+
)
|
|
9752
|
+
SELECT
|
|
9753
|
+
'relation:' || r.id,
|
|
9754
|
+
r.source_entity_id,
|
|
9755
|
+
r.target_entity_id,
|
|
9756
|
+
COALESCE(${sourceAgentId}, ${targetAgentId}, 'default'),
|
|
9757
|
+
CASE WHEN r.relation_type IN (${sqlStringList(DEPENDENCY_TYPES)}) THEN r.relation_type ELSE 'related_to' END,
|
|
9758
|
+
MAX(0.1, MIN(1.0, COALESCE(r.strength, 0.5))),
|
|
9759
|
+
MAX(0.1, MIN(1.0, COALESCE(${relationConfidence}, 0.7))),
|
|
9760
|
+
'legacy relation backfill: ' || r.relation_type,
|
|
9761
|
+
COALESCE(r.created_at, datetime('now')),
|
|
9762
|
+
COALESCE(${relationUpdatedAt}, r.created_at, datetime('now')),
|
|
9763
|
+
r.id,
|
|
9764
|
+
'relation',
|
|
9765
|
+
'[]',
|
|
9766
|
+
'active'
|
|
9767
|
+
FROM relations r
|
|
9768
|
+
JOIN entities src ON src.id = r.source_entity_id
|
|
9769
|
+
JOIN entities dst ON dst.id = r.target_entity_id
|
|
9770
|
+
WHERE r.source_entity_id <> r.target_entity_id
|
|
9771
|
+
AND ${sourceAgentId} = ${targetAgentId}
|
|
9772
|
+
`);
|
|
9773
|
+
}
|
|
9774
|
+
function up84(db) {
|
|
9775
|
+
db.exec(`
|
|
9776
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
|
|
9777
|
+
path TEXT PRIMARY KEY,
|
|
9778
|
+
mtime_ms INTEGER NOT NULL,
|
|
9779
|
+
ctime_ms INTEGER NOT NULL,
|
|
9780
|
+
size INTEGER NOT NULL,
|
|
9781
|
+
content_hash TEXT NOT NULL,
|
|
9782
|
+
importer_version INTEGER NOT NULL,
|
|
9783
|
+
chunk_count INTEGER NOT NULL DEFAULT 0,
|
|
9784
|
+
last_imported_at TEXT NOT NULL,
|
|
9785
|
+
last_seen_at TEXT NOT NULL,
|
|
9786
|
+
status TEXT NOT NULL DEFAULT 'imported',
|
|
9787
|
+
error TEXT
|
|
9788
|
+
);
|
|
9789
|
+
|
|
9790
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_chunks (
|
|
9791
|
+
file_path TEXT NOT NULL,
|
|
9792
|
+
chunk_hash TEXT NOT NULL,
|
|
9793
|
+
chunk_index INTEGER NOT NULL,
|
|
9794
|
+
memory_id TEXT,
|
|
9795
|
+
source_id TEXT,
|
|
9796
|
+
created_at TEXT NOT NULL,
|
|
9797
|
+
PRIMARY KEY (file_path, chunk_hash)
|
|
9798
|
+
);
|
|
9799
|
+
|
|
9800
|
+
CREATE INDEX IF NOT EXISTS idx_legacy_markdown_chunks_memory_id
|
|
9801
|
+
ON legacy_markdown_chunks(memory_id);
|
|
9802
|
+
`);
|
|
9803
|
+
}
|
|
9804
|
+
function up85(db) {
|
|
9805
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
|
|
9806
|
+
const tableNames = new Set(tables.map((r) => String(r.name)));
|
|
9807
|
+
if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
|
|
9808
|
+
return;
|
|
9809
|
+
const relCols = db.prepare("PRAGMA table_info(relations)").all();
|
|
9810
|
+
const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
|
|
9811
|
+
const rel = new Set(relCols.map((c) => String(c.name)));
|
|
9812
|
+
const dep = new Set(depCols.map((c) => String(c.name)));
|
|
9813
|
+
if (!rel.has("source_entity_id") || !rel.has("relation_type"))
|
|
9814
|
+
return;
|
|
9815
|
+
if (!dep.has("source_entity_id") || !dep.has("dependency_type") || !dep.has("agent_id"))
|
|
9816
|
+
return;
|
|
9817
|
+
const hasRelConfidence = rel.has("confidence");
|
|
9818
|
+
const hasRelUpdated = rel.has("updated_at");
|
|
9819
|
+
const hasDepConfidence = dep.has("confidence");
|
|
9820
|
+
const hasDepReason = dep.has("reason");
|
|
9821
|
+
const hasDepStatus = dep.has("status");
|
|
9822
|
+
const selectParts = ["id", "source_entity_id", "target_entity_id"];
|
|
9823
|
+
const colParts = ["id", "source_entity_id", "target_entity_id"];
|
|
9824
|
+
selectParts.push("relation_type");
|
|
9825
|
+
colParts.push("dependency_type");
|
|
9826
|
+
selectParts.push("strength", "created_at");
|
|
9827
|
+
colParts.push("strength", "created_at");
|
|
9828
|
+
selectParts.push("'default'");
|
|
9829
|
+
colParts.push("agent_id");
|
|
9830
|
+
selectParts.push("NULL");
|
|
9831
|
+
colParts.push("aspect_id");
|
|
9832
|
+
if (hasRelConfidence && hasDepConfidence) {
|
|
9833
|
+
selectParts.push("confidence");
|
|
9834
|
+
colParts.push("confidence");
|
|
9835
|
+
}
|
|
9836
|
+
if (hasDepReason) {
|
|
9837
|
+
selectParts.push("'extracted'");
|
|
9838
|
+
colParts.push("reason");
|
|
9839
|
+
}
|
|
9840
|
+
if (hasDepStatus) {
|
|
9841
|
+
selectParts.push("'active'");
|
|
9842
|
+
colParts.push("status");
|
|
9843
|
+
}
|
|
9844
|
+
if (hasRelUpdated && dep.has("updated_at")) {
|
|
9845
|
+
selectParts.push("updated_at");
|
|
9846
|
+
colParts.push("updated_at");
|
|
9847
|
+
}
|
|
9848
|
+
const selectClause = selectParts.join(", ");
|
|
9849
|
+
const colsClause = colParts.join(", ");
|
|
9850
|
+
db.exec(`INSERT OR IGNORE INTO entity_dependencies (${colsClause})
|
|
9851
|
+
SELECT ${selectClause}
|
|
9852
|
+
FROM relations
|
|
9853
|
+
WHERE source_entity_id IS NOT NULL
|
|
9854
|
+
AND target_entity_id IS NOT NULL
|
|
9855
|
+
AND relation_type IS NOT NULL`);
|
|
9856
|
+
}
|
|
9857
|
+
function addColumnIfMissing21(db, table, column, definition) {
|
|
9858
|
+
const cols = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
9859
|
+
if (cols.some((col) => col.name === column))
|
|
9860
|
+
return;
|
|
9861
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
9862
|
+
}
|
|
9863
|
+
function up86(db) {
|
|
9864
|
+
addColumnIfMissing21(db, "summary_jobs", "content_hash", "TEXT");
|
|
9865
|
+
db.exec(`
|
|
9866
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
|
|
9867
|
+
ON summary_jobs(agent_id, session_key, content_hash)
|
|
9868
|
+
`);
|
|
9869
|
+
}
|
|
9625
9870
|
var MIGRATIONS = [
|
|
9626
9871
|
{
|
|
9627
9872
|
version: 1,
|
|
@@ -10286,6 +10531,45 @@ var MIGRATIONS = [
|
|
|
10286
10531
|
{ table: "skill_invocations", column: "tool_use_id" }
|
|
10287
10532
|
]
|
|
10288
10533
|
}
|
|
10534
|
+
},
|
|
10535
|
+
{
|
|
10536
|
+
version: 83,
|
|
10537
|
+
name: "memory-lifecycle-repair",
|
|
10538
|
+
up: up83,
|
|
10539
|
+
artifacts: {
|
|
10540
|
+
tables: ["transcript_capture_jobs", "aggregate_evidence_sources", "entity_dependencies"],
|
|
10541
|
+
columns: [
|
|
10542
|
+
{ table: "documents", column: "agent_id" },
|
|
10543
|
+
{ table: "documents", column: "project" },
|
|
10544
|
+
{ table: "memories", column: "superseded_by" },
|
|
10545
|
+
{ table: "memories", column: "superseded_at" },
|
|
10546
|
+
{ table: "memories", column: "superseded_reason" }
|
|
10547
|
+
]
|
|
10548
|
+
}
|
|
10549
|
+
},
|
|
10550
|
+
{
|
|
10551
|
+
version: 84,
|
|
10552
|
+
name: "legacy-markdown-import-state",
|
|
10553
|
+
up: up84,
|
|
10554
|
+
artifacts: {
|
|
10555
|
+
tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
|
|
10556
|
+
}
|
|
10557
|
+
},
|
|
10558
|
+
{
|
|
10559
|
+
version: 85,
|
|
10560
|
+
name: "backfill-relations-to-dependencies",
|
|
10561
|
+
up: up85,
|
|
10562
|
+
artifacts: {
|
|
10563
|
+
tables: ["entity_dependencies"]
|
|
10564
|
+
}
|
|
10565
|
+
},
|
|
10566
|
+
{
|
|
10567
|
+
version: 86,
|
|
10568
|
+
name: "summary-jobs-content-hash",
|
|
10569
|
+
up: up86,
|
|
10570
|
+
artifacts: {
|
|
10571
|
+
columns: [{ table: "summary_jobs", column: "content_hash" }]
|
|
10572
|
+
}
|
|
10289
10573
|
}
|
|
10290
10574
|
];
|
|
10291
10575
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -17636,7 +17920,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
17636
17920
|
return true;
|
|
17637
17921
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
17638
17922
|
}
|
|
17639
|
-
function
|
|
17923
|
+
function up87(db) {
|
|
17640
17924
|
db.exec(`
|
|
17641
17925
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
17642
17926
|
version INTEGER PRIMARY KEY,
|
|
@@ -17725,31 +18009,31 @@ function up83(db) {
|
|
|
17725
18009
|
} catch {}
|
|
17726
18010
|
createMemoriesFts2(db);
|
|
17727
18011
|
}
|
|
17728
|
-
function
|
|
18012
|
+
function hasColumn13(db, table, column) {
|
|
17729
18013
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
17730
18014
|
return rows.some((r) => r.name === column);
|
|
17731
18015
|
}
|
|
17732
|
-
function
|
|
17733
|
-
if (!
|
|
18016
|
+
function addColumnIfMissing22(db, table, column, definition) {
|
|
18017
|
+
if (!hasColumn13(db, table, column)) {
|
|
17734
18018
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
17735
18019
|
}
|
|
17736
18020
|
}
|
|
17737
18021
|
function up210(db) {
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
18022
|
+
addColumnIfMissing22(db, "memories", "content_hash", "TEXT");
|
|
18023
|
+
addColumnIfMissing22(db, "memories", "normalized_content", "TEXT");
|
|
18024
|
+
addColumnIfMissing22(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
18025
|
+
addColumnIfMissing22(db, "memories", "deleted_at", "TEXT");
|
|
18026
|
+
addColumnIfMissing22(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
18027
|
+
addColumnIfMissing22(db, "memories", "embedding_model", "TEXT");
|
|
18028
|
+
addColumnIfMissing22(db, "memories", "extraction_model", "TEXT");
|
|
18029
|
+
addColumnIfMissing22(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
18030
|
+
addColumnIfMissing22(db, "memories", "who", "TEXT");
|
|
18031
|
+
addColumnIfMissing22(db, "memories", "why", "TEXT");
|
|
18032
|
+
addColumnIfMissing22(db, "memories", "project", "TEXT");
|
|
18033
|
+
addColumnIfMissing22(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
18034
|
+
addColumnIfMissing22(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
18035
|
+
addColumnIfMissing22(db, "memories", "last_accessed", "TEXT");
|
|
18036
|
+
addColumnIfMissing22(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
17753
18037
|
db.exec(`
|
|
17754
18038
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
17755
18039
|
id TEXT PRIMARY KEY,
|
|
@@ -17845,7 +18129,7 @@ function up210(db) {
|
|
|
17845
18129
|
ON memory_entity_mentions(entity_id);
|
|
17846
18130
|
`);
|
|
17847
18131
|
}
|
|
17848
|
-
function
|
|
18132
|
+
function addColumnIfMissing23(db, table, column, definition) {
|
|
17849
18133
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
17850
18134
|
if (rows.some((r) => r.name === column))
|
|
17851
18135
|
return false;
|
|
@@ -17853,8 +18137,8 @@ function addColumnIfMissing22(db, table, column, definition) {
|
|
|
17853
18137
|
return true;
|
|
17854
18138
|
}
|
|
17855
18139
|
function up310(db) {
|
|
17856
|
-
|
|
17857
|
-
|
|
18140
|
+
addColumnIfMissing23(db, "memories", "why", "TEXT");
|
|
18141
|
+
addColumnIfMissing23(db, "memories", "project", "TEXT");
|
|
17858
18142
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
17859
18143
|
db.exec(`
|
|
17860
18144
|
UPDATE memories
|
|
@@ -18011,7 +18295,7 @@ function up710(db) {
|
|
|
18011
18295
|
db.exec("ALTER TABLE memory_jobs ADD COLUMN document_id TEXT");
|
|
18012
18296
|
}
|
|
18013
18297
|
}
|
|
18014
|
-
function
|
|
18298
|
+
function up88(db) {
|
|
18015
18299
|
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='embeddings'").all();
|
|
18016
18300
|
if (tables.length === 0)
|
|
18017
18301
|
return;
|
|
@@ -19280,7 +19564,7 @@ function up492(db) {
|
|
|
19280
19564
|
);
|
|
19281
19565
|
`);
|
|
19282
19566
|
}
|
|
19283
|
-
function
|
|
19567
|
+
function hasTable4(db, name) {
|
|
19284
19568
|
return db.prepare(`SELECT name
|
|
19285
19569
|
FROM sqlite_master
|
|
19286
19570
|
WHERE type = 'table' AND name = ?
|
|
@@ -19310,7 +19594,7 @@ function up502(db) {
|
|
|
19310
19594
|
CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
|
|
19311
19595
|
ON entity_dependency_history(created_at DESC);
|
|
19312
19596
|
`);
|
|
19313
|
-
if (!
|
|
19597
|
+
if (!hasTable4(db, "entity_dependencies"))
|
|
19314
19598
|
return;
|
|
19315
19599
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
|
|
19316
19600
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
|
|
@@ -20320,11 +20604,256 @@ function up822(db) {
|
|
|
20320
20604
|
`);
|
|
20321
20605
|
db.exec("CREATE INDEX IF NOT EXISTS idx_skill_inv_harness ON skill_invocations(harness, created_at)");
|
|
20322
20606
|
}
|
|
20607
|
+
var DEPENDENCY_TYPES2 = new Set([
|
|
20608
|
+
"uses",
|
|
20609
|
+
"requires",
|
|
20610
|
+
"owned_by",
|
|
20611
|
+
"owns",
|
|
20612
|
+
"blocks",
|
|
20613
|
+
"informs",
|
|
20614
|
+
"maintains",
|
|
20615
|
+
"implements",
|
|
20616
|
+
"built",
|
|
20617
|
+
"depends_on",
|
|
20618
|
+
"related_to",
|
|
20619
|
+
"learned_from",
|
|
20620
|
+
"teaches",
|
|
20621
|
+
"knows",
|
|
20622
|
+
"assumes",
|
|
20623
|
+
"supports_claim",
|
|
20624
|
+
"authored_by",
|
|
20625
|
+
"links_to",
|
|
20626
|
+
"contains",
|
|
20627
|
+
"contains_note",
|
|
20628
|
+
"contradicts",
|
|
20629
|
+
"supersedes",
|
|
20630
|
+
"part_of",
|
|
20631
|
+
"produced_artifact",
|
|
20632
|
+
"precedes",
|
|
20633
|
+
"follows",
|
|
20634
|
+
"triggers",
|
|
20635
|
+
"may_execute",
|
|
20636
|
+
"requires_approval_from",
|
|
20637
|
+
"impacts",
|
|
20638
|
+
"produces",
|
|
20639
|
+
"consumes"
|
|
20640
|
+
]);
|
|
20641
|
+
function sqlStringList2(values) {
|
|
20642
|
+
return [...values].map((value) => `'${value}'`).join(", ");
|
|
20643
|
+
}
|
|
20644
|
+
function hasTable32(db, table) {
|
|
20645
|
+
return Boolean(db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table));
|
|
20646
|
+
}
|
|
20647
|
+
function hasColumn122(db, table, column) {
|
|
20648
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
20649
|
+
return rows.some((row) => row.name === column);
|
|
20650
|
+
}
|
|
20651
|
+
function addColumnIfMissing202(db, table, column, definition) {
|
|
20652
|
+
if (!hasColumn122(db, table, column))
|
|
20653
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
20654
|
+
}
|
|
20655
|
+
function documentScopeColumnsPreservingExisting2(db) {
|
|
20656
|
+
const preserveAgentId = hasColumn122(db, "documents", "agent_id");
|
|
20657
|
+
const preserveProject = hasColumn122(db, "documents", "project");
|
|
20658
|
+
if (preserveAgentId) {
|
|
20659
|
+
db.exec(`
|
|
20660
|
+
CREATE TEMP TABLE __signet_doc_agent_guard AS
|
|
20661
|
+
SELECT id, agent_id FROM documents
|
|
20662
|
+
WHERE NULLIF(TRIM(agent_id), '') IS NOT NULL
|
|
20663
|
+
AND NULLIF(TRIM(agent_id), '') <> 'default'
|
|
20664
|
+
`);
|
|
20665
|
+
}
|
|
20666
|
+
if (preserveProject) {
|
|
20667
|
+
db.exec(`
|
|
20668
|
+
CREATE TEMP TABLE __signet_doc_project_guard AS
|
|
20669
|
+
SELECT id, project FROM documents
|
|
20670
|
+
WHERE NULLIF(TRIM(project), '') IS NOT NULL
|
|
20671
|
+
`);
|
|
20672
|
+
}
|
|
20673
|
+
try {
|
|
20674
|
+
up802(db);
|
|
20675
|
+
if (preserveAgentId) {
|
|
20676
|
+
db.exec(`
|
|
20677
|
+
UPDATE documents
|
|
20678
|
+
SET agent_id = (SELECT agent_id FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
20679
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
20680
|
+
`);
|
|
20681
|
+
}
|
|
20682
|
+
if (preserveProject) {
|
|
20683
|
+
db.exec(`
|
|
20684
|
+
UPDATE documents
|
|
20685
|
+
SET project = (SELECT project FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
20686
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
20687
|
+
`);
|
|
20688
|
+
}
|
|
20689
|
+
} finally {
|
|
20690
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_agent_guard");
|
|
20691
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_project_guard");
|
|
20692
|
+
}
|
|
20693
|
+
}
|
|
20694
|
+
function up832(db) {
|
|
20695
|
+
up792(db);
|
|
20696
|
+
if (hasTable32(db, "documents")) {
|
|
20697
|
+
documentScopeColumnsPreservingExisting2(db);
|
|
20698
|
+
}
|
|
20699
|
+
up812(db);
|
|
20700
|
+
addColumnIfMissing202(db, "memories", "superseded_by", "TEXT");
|
|
20701
|
+
addColumnIfMissing202(db, "memories", "superseded_at", "TEXT");
|
|
20702
|
+
addColumnIfMissing202(db, "memories", "superseded_reason", "TEXT");
|
|
20703
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_superseded_by ON memories(superseded_by)");
|
|
20704
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_active_supersession ON memories(is_deleted, superseded_by)");
|
|
20705
|
+
if (!hasTable32(db, "relations") || !hasTable32(db, "entity_dependencies"))
|
|
20706
|
+
return;
|
|
20707
|
+
addColumnIfMissing202(db, "entity_dependencies", "confidence", "REAL");
|
|
20708
|
+
addColumnIfMissing202(db, "entity_dependencies", "reason", "TEXT");
|
|
20709
|
+
addColumnIfMissing202(db, "entity_dependencies", "source_id", "TEXT");
|
|
20710
|
+
addColumnIfMissing202(db, "entity_dependencies", "source_kind", "TEXT");
|
|
20711
|
+
addColumnIfMissing202(db, "entity_dependencies", "proposal_evidence", "TEXT NOT NULL DEFAULT '[]'");
|
|
20712
|
+
addColumnIfMissing202(db, "entity_dependencies", "status", "TEXT NOT NULL DEFAULT 'active'");
|
|
20713
|
+
const relationConfidence = hasColumn122(db, "relations", "confidence") ? "r.confidence" : "NULL";
|
|
20714
|
+
const relationUpdatedAt = hasColumn122(db, "relations", "updated_at") ? "r.updated_at" : "r.created_at";
|
|
20715
|
+
const sourceAgentId = hasColumn122(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(src.agent_id), ''), 'default')" : "'default'";
|
|
20716
|
+
const targetAgentId = hasColumn122(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(dst.agent_id), ''), 'default')" : "'default'";
|
|
20717
|
+
db.exec(`
|
|
20718
|
+
INSERT OR IGNORE INTO entity_dependencies (
|
|
20719
|
+
id,
|
|
20720
|
+
source_entity_id,
|
|
20721
|
+
target_entity_id,
|
|
20722
|
+
agent_id,
|
|
20723
|
+
dependency_type,
|
|
20724
|
+
strength,
|
|
20725
|
+
confidence,
|
|
20726
|
+
reason,
|
|
20727
|
+
created_at,
|
|
20728
|
+
updated_at,
|
|
20729
|
+
source_id,
|
|
20730
|
+
source_kind,
|
|
20731
|
+
proposal_evidence,
|
|
20732
|
+
status
|
|
20733
|
+
)
|
|
20734
|
+
SELECT
|
|
20735
|
+
'relation:' || r.id,
|
|
20736
|
+
r.source_entity_id,
|
|
20737
|
+
r.target_entity_id,
|
|
20738
|
+
COALESCE(${sourceAgentId}, ${targetAgentId}, 'default'),
|
|
20739
|
+
CASE WHEN r.relation_type IN (${sqlStringList2(DEPENDENCY_TYPES2)}) THEN r.relation_type ELSE 'related_to' END,
|
|
20740
|
+
MAX(0.1, MIN(1.0, COALESCE(r.strength, 0.5))),
|
|
20741
|
+
MAX(0.1, MIN(1.0, COALESCE(${relationConfidence}, 0.7))),
|
|
20742
|
+
'legacy relation backfill: ' || r.relation_type,
|
|
20743
|
+
COALESCE(r.created_at, datetime('now')),
|
|
20744
|
+
COALESCE(${relationUpdatedAt}, r.created_at, datetime('now')),
|
|
20745
|
+
r.id,
|
|
20746
|
+
'relation',
|
|
20747
|
+
'[]',
|
|
20748
|
+
'active'
|
|
20749
|
+
FROM relations r
|
|
20750
|
+
JOIN entities src ON src.id = r.source_entity_id
|
|
20751
|
+
JOIN entities dst ON dst.id = r.target_entity_id
|
|
20752
|
+
WHERE r.source_entity_id <> r.target_entity_id
|
|
20753
|
+
AND ${sourceAgentId} = ${targetAgentId}
|
|
20754
|
+
`);
|
|
20755
|
+
}
|
|
20756
|
+
function up842(db) {
|
|
20757
|
+
db.exec(`
|
|
20758
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
|
|
20759
|
+
path TEXT PRIMARY KEY,
|
|
20760
|
+
mtime_ms INTEGER NOT NULL,
|
|
20761
|
+
ctime_ms INTEGER NOT NULL,
|
|
20762
|
+
size INTEGER NOT NULL,
|
|
20763
|
+
content_hash TEXT NOT NULL,
|
|
20764
|
+
importer_version INTEGER NOT NULL,
|
|
20765
|
+
chunk_count INTEGER NOT NULL DEFAULT 0,
|
|
20766
|
+
last_imported_at TEXT NOT NULL,
|
|
20767
|
+
last_seen_at TEXT NOT NULL,
|
|
20768
|
+
status TEXT NOT NULL DEFAULT 'imported',
|
|
20769
|
+
error TEXT
|
|
20770
|
+
);
|
|
20771
|
+
|
|
20772
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_chunks (
|
|
20773
|
+
file_path TEXT NOT NULL,
|
|
20774
|
+
chunk_hash TEXT NOT NULL,
|
|
20775
|
+
chunk_index INTEGER NOT NULL,
|
|
20776
|
+
memory_id TEXT,
|
|
20777
|
+
source_id TEXT,
|
|
20778
|
+
created_at TEXT NOT NULL,
|
|
20779
|
+
PRIMARY KEY (file_path, chunk_hash)
|
|
20780
|
+
);
|
|
20781
|
+
|
|
20782
|
+
CREATE INDEX IF NOT EXISTS idx_legacy_markdown_chunks_memory_id
|
|
20783
|
+
ON legacy_markdown_chunks(memory_id);
|
|
20784
|
+
`);
|
|
20785
|
+
}
|
|
20786
|
+
function up852(db) {
|
|
20787
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
|
|
20788
|
+
const tableNames = new Set(tables.map((r) => String(r.name)));
|
|
20789
|
+
if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
|
|
20790
|
+
return;
|
|
20791
|
+
const relCols = db.prepare("PRAGMA table_info(relations)").all();
|
|
20792
|
+
const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
|
|
20793
|
+
const rel = new Set(relCols.map((c) => String(c.name)));
|
|
20794
|
+
const dep = new Set(depCols.map((c) => String(c.name)));
|
|
20795
|
+
if (!rel.has("source_entity_id") || !rel.has("relation_type"))
|
|
20796
|
+
return;
|
|
20797
|
+
if (!dep.has("source_entity_id") || !dep.has("dependency_type") || !dep.has("agent_id"))
|
|
20798
|
+
return;
|
|
20799
|
+
const hasRelConfidence = rel.has("confidence");
|
|
20800
|
+
const hasRelUpdated = rel.has("updated_at");
|
|
20801
|
+
const hasDepConfidence = dep.has("confidence");
|
|
20802
|
+
const hasDepReason = dep.has("reason");
|
|
20803
|
+
const hasDepStatus = dep.has("status");
|
|
20804
|
+
const selectParts = ["id", "source_entity_id", "target_entity_id"];
|
|
20805
|
+
const colParts = ["id", "source_entity_id", "target_entity_id"];
|
|
20806
|
+
selectParts.push("relation_type");
|
|
20807
|
+
colParts.push("dependency_type");
|
|
20808
|
+
selectParts.push("strength", "created_at");
|
|
20809
|
+
colParts.push("strength", "created_at");
|
|
20810
|
+
selectParts.push("'default'");
|
|
20811
|
+
colParts.push("agent_id");
|
|
20812
|
+
selectParts.push("NULL");
|
|
20813
|
+
colParts.push("aspect_id");
|
|
20814
|
+
if (hasRelConfidence && hasDepConfidence) {
|
|
20815
|
+
selectParts.push("confidence");
|
|
20816
|
+
colParts.push("confidence");
|
|
20817
|
+
}
|
|
20818
|
+
if (hasDepReason) {
|
|
20819
|
+
selectParts.push("'extracted'");
|
|
20820
|
+
colParts.push("reason");
|
|
20821
|
+
}
|
|
20822
|
+
if (hasDepStatus) {
|
|
20823
|
+
selectParts.push("'active'");
|
|
20824
|
+
colParts.push("status");
|
|
20825
|
+
}
|
|
20826
|
+
if (hasRelUpdated && dep.has("updated_at")) {
|
|
20827
|
+
selectParts.push("updated_at");
|
|
20828
|
+
colParts.push("updated_at");
|
|
20829
|
+
}
|
|
20830
|
+
const selectClause = selectParts.join(", ");
|
|
20831
|
+
const colsClause = colParts.join(", ");
|
|
20832
|
+
db.exec(`INSERT OR IGNORE INTO entity_dependencies (${colsClause})
|
|
20833
|
+
SELECT ${selectClause}
|
|
20834
|
+
FROM relations
|
|
20835
|
+
WHERE source_entity_id IS NOT NULL
|
|
20836
|
+
AND target_entity_id IS NOT NULL
|
|
20837
|
+
AND relation_type IS NOT NULL`);
|
|
20838
|
+
}
|
|
20839
|
+
function addColumnIfMissing212(db, table, column, definition) {
|
|
20840
|
+
const cols = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
20841
|
+
if (cols.some((col) => col.name === column))
|
|
20842
|
+
return;
|
|
20843
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
20844
|
+
}
|
|
20845
|
+
function up862(db) {
|
|
20846
|
+
addColumnIfMissing212(db, "summary_jobs", "content_hash", "TEXT");
|
|
20847
|
+
db.exec(`
|
|
20848
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
|
|
20849
|
+
ON summary_jobs(agent_id, session_key, content_hash)
|
|
20850
|
+
`);
|
|
20851
|
+
}
|
|
20323
20852
|
var MIGRATIONS2 = [
|
|
20324
20853
|
{
|
|
20325
20854
|
version: 1,
|
|
20326
20855
|
name: "baseline",
|
|
20327
|
-
up:
|
|
20856
|
+
up: up87,
|
|
20328
20857
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
20329
20858
|
},
|
|
20330
20859
|
{
|
|
@@ -20373,7 +20902,7 @@ var MIGRATIONS2 = [
|
|
|
20373
20902
|
{
|
|
20374
20903
|
version: 8,
|
|
20375
20904
|
name: "embeddings-unique-hash",
|
|
20376
|
-
up:
|
|
20905
|
+
up: up88
|
|
20377
20906
|
},
|
|
20378
20907
|
{
|
|
20379
20908
|
version: 9,
|
|
@@ -20984,6 +21513,45 @@ var MIGRATIONS2 = [
|
|
|
20984
21513
|
{ table: "skill_invocations", column: "tool_use_id" }
|
|
20985
21514
|
]
|
|
20986
21515
|
}
|
|
21516
|
+
},
|
|
21517
|
+
{
|
|
21518
|
+
version: 83,
|
|
21519
|
+
name: "memory-lifecycle-repair",
|
|
21520
|
+
up: up832,
|
|
21521
|
+
artifacts: {
|
|
21522
|
+
tables: ["transcript_capture_jobs", "aggregate_evidence_sources", "entity_dependencies"],
|
|
21523
|
+
columns: [
|
|
21524
|
+
{ table: "documents", column: "agent_id" },
|
|
21525
|
+
{ table: "documents", column: "project" },
|
|
21526
|
+
{ table: "memories", column: "superseded_by" },
|
|
21527
|
+
{ table: "memories", column: "superseded_at" },
|
|
21528
|
+
{ table: "memories", column: "superseded_reason" }
|
|
21529
|
+
]
|
|
21530
|
+
}
|
|
21531
|
+
},
|
|
21532
|
+
{
|
|
21533
|
+
version: 84,
|
|
21534
|
+
name: "legacy-markdown-import-state",
|
|
21535
|
+
up: up842,
|
|
21536
|
+
artifacts: {
|
|
21537
|
+
tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
|
|
21538
|
+
}
|
|
21539
|
+
},
|
|
21540
|
+
{
|
|
21541
|
+
version: 85,
|
|
21542
|
+
name: "backfill-relations-to-dependencies",
|
|
21543
|
+
up: up852,
|
|
21544
|
+
artifacts: {
|
|
21545
|
+
tables: ["entity_dependencies"]
|
|
21546
|
+
}
|
|
21547
|
+
},
|
|
21548
|
+
{
|
|
21549
|
+
version: 86,
|
|
21550
|
+
name: "summary-jobs-content-hash",
|
|
21551
|
+
up: up862,
|
|
21552
|
+
artifacts: {
|
|
21553
|
+
columns: [{ table: "summary_jobs", column: "content_hash" }]
|
|
21554
|
+
}
|
|
20987
21555
|
}
|
|
20988
21556
|
];
|
|
20989
21557
|
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.
|
|
3
|
+
"version": "0.147.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.
|
|
28
|
-
"@signetai/core": "0.
|
|
27
|
+
"@signetai/connector-base": "0.147.0",
|
|
28
|
+
"@signetai/core": "0.147.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|