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