@signetai/connector-hermes-agent 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
|
@@ -9623,6 +9623,251 @@ function up82(db) {
|
|
|
9623
9623
|
`);
|
|
9624
9624
|
db.exec("CREATE INDEX IF NOT EXISTS idx_skill_inv_harness ON skill_invocations(harness, created_at)");
|
|
9625
9625
|
}
|
|
9626
|
+
var DEPENDENCY_TYPES = new Set([
|
|
9627
|
+
"uses",
|
|
9628
|
+
"requires",
|
|
9629
|
+
"owned_by",
|
|
9630
|
+
"owns",
|
|
9631
|
+
"blocks",
|
|
9632
|
+
"informs",
|
|
9633
|
+
"maintains",
|
|
9634
|
+
"implements",
|
|
9635
|
+
"built",
|
|
9636
|
+
"depends_on",
|
|
9637
|
+
"related_to",
|
|
9638
|
+
"learned_from",
|
|
9639
|
+
"teaches",
|
|
9640
|
+
"knows",
|
|
9641
|
+
"assumes",
|
|
9642
|
+
"supports_claim",
|
|
9643
|
+
"authored_by",
|
|
9644
|
+
"links_to",
|
|
9645
|
+
"contains",
|
|
9646
|
+
"contains_note",
|
|
9647
|
+
"contradicts",
|
|
9648
|
+
"supersedes",
|
|
9649
|
+
"part_of",
|
|
9650
|
+
"produced_artifact",
|
|
9651
|
+
"precedes",
|
|
9652
|
+
"follows",
|
|
9653
|
+
"triggers",
|
|
9654
|
+
"may_execute",
|
|
9655
|
+
"requires_approval_from",
|
|
9656
|
+
"impacts",
|
|
9657
|
+
"produces",
|
|
9658
|
+
"consumes"
|
|
9659
|
+
]);
|
|
9660
|
+
function sqlStringList(values) {
|
|
9661
|
+
return [...values].map((value) => `'${value}'`).join(", ");
|
|
9662
|
+
}
|
|
9663
|
+
function hasTable3(db, table) {
|
|
9664
|
+
return Boolean(db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table));
|
|
9665
|
+
}
|
|
9666
|
+
function hasColumn12(db, table, column) {
|
|
9667
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
9668
|
+
return rows.some((row) => row.name === column);
|
|
9669
|
+
}
|
|
9670
|
+
function addColumnIfMissing20(db, table, column, definition) {
|
|
9671
|
+
if (!hasColumn12(db, table, column))
|
|
9672
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
9673
|
+
}
|
|
9674
|
+
function documentScopeColumnsPreservingExisting(db) {
|
|
9675
|
+
const preserveAgentId = hasColumn12(db, "documents", "agent_id");
|
|
9676
|
+
const preserveProject = hasColumn12(db, "documents", "project");
|
|
9677
|
+
if (preserveAgentId) {
|
|
9678
|
+
db.exec(`
|
|
9679
|
+
CREATE TEMP TABLE __signet_doc_agent_guard AS
|
|
9680
|
+
SELECT id, agent_id FROM documents
|
|
9681
|
+
WHERE NULLIF(TRIM(agent_id), '') IS NOT NULL
|
|
9682
|
+
AND NULLIF(TRIM(agent_id), '') <> 'default'
|
|
9683
|
+
`);
|
|
9684
|
+
}
|
|
9685
|
+
if (preserveProject) {
|
|
9686
|
+
db.exec(`
|
|
9687
|
+
CREATE TEMP TABLE __signet_doc_project_guard AS
|
|
9688
|
+
SELECT id, project FROM documents
|
|
9689
|
+
WHERE NULLIF(TRIM(project), '') IS NOT NULL
|
|
9690
|
+
`);
|
|
9691
|
+
}
|
|
9692
|
+
try {
|
|
9693
|
+
up80(db);
|
|
9694
|
+
if (preserveAgentId) {
|
|
9695
|
+
db.exec(`
|
|
9696
|
+
UPDATE documents
|
|
9697
|
+
SET agent_id = (SELECT agent_id FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
9698
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
9699
|
+
`);
|
|
9700
|
+
}
|
|
9701
|
+
if (preserveProject) {
|
|
9702
|
+
db.exec(`
|
|
9703
|
+
UPDATE documents
|
|
9704
|
+
SET project = (SELECT project FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
9705
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
9706
|
+
`);
|
|
9707
|
+
}
|
|
9708
|
+
} finally {
|
|
9709
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_agent_guard");
|
|
9710
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_project_guard");
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9713
|
+
function up83(db) {
|
|
9714
|
+
up79(db);
|
|
9715
|
+
if (hasTable3(db, "documents")) {
|
|
9716
|
+
documentScopeColumnsPreservingExisting(db);
|
|
9717
|
+
}
|
|
9718
|
+
up81(db);
|
|
9719
|
+
addColumnIfMissing20(db, "memories", "superseded_by", "TEXT");
|
|
9720
|
+
addColumnIfMissing20(db, "memories", "superseded_at", "TEXT");
|
|
9721
|
+
addColumnIfMissing20(db, "memories", "superseded_reason", "TEXT");
|
|
9722
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_superseded_by ON memories(superseded_by)");
|
|
9723
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_active_supersession ON memories(is_deleted, superseded_by)");
|
|
9724
|
+
if (!hasTable3(db, "relations") || !hasTable3(db, "entity_dependencies"))
|
|
9725
|
+
return;
|
|
9726
|
+
addColumnIfMissing20(db, "entity_dependencies", "confidence", "REAL");
|
|
9727
|
+
addColumnIfMissing20(db, "entity_dependencies", "reason", "TEXT");
|
|
9728
|
+
addColumnIfMissing20(db, "entity_dependencies", "source_id", "TEXT");
|
|
9729
|
+
addColumnIfMissing20(db, "entity_dependencies", "source_kind", "TEXT");
|
|
9730
|
+
addColumnIfMissing20(db, "entity_dependencies", "proposal_evidence", "TEXT NOT NULL DEFAULT '[]'");
|
|
9731
|
+
addColumnIfMissing20(db, "entity_dependencies", "status", "TEXT NOT NULL DEFAULT 'active'");
|
|
9732
|
+
const relationConfidence = hasColumn12(db, "relations", "confidence") ? "r.confidence" : "NULL";
|
|
9733
|
+
const relationUpdatedAt = hasColumn12(db, "relations", "updated_at") ? "r.updated_at" : "r.created_at";
|
|
9734
|
+
const sourceAgentId = hasColumn12(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(src.agent_id), ''), 'default')" : "'default'";
|
|
9735
|
+
const targetAgentId = hasColumn12(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(dst.agent_id), ''), 'default')" : "'default'";
|
|
9736
|
+
db.exec(`
|
|
9737
|
+
INSERT OR IGNORE INTO entity_dependencies (
|
|
9738
|
+
id,
|
|
9739
|
+
source_entity_id,
|
|
9740
|
+
target_entity_id,
|
|
9741
|
+
agent_id,
|
|
9742
|
+
dependency_type,
|
|
9743
|
+
strength,
|
|
9744
|
+
confidence,
|
|
9745
|
+
reason,
|
|
9746
|
+
created_at,
|
|
9747
|
+
updated_at,
|
|
9748
|
+
source_id,
|
|
9749
|
+
source_kind,
|
|
9750
|
+
proposal_evidence,
|
|
9751
|
+
status
|
|
9752
|
+
)
|
|
9753
|
+
SELECT
|
|
9754
|
+
'relation:' || r.id,
|
|
9755
|
+
r.source_entity_id,
|
|
9756
|
+
r.target_entity_id,
|
|
9757
|
+
COALESCE(${sourceAgentId}, ${targetAgentId}, 'default'),
|
|
9758
|
+
CASE WHEN r.relation_type IN (${sqlStringList(DEPENDENCY_TYPES)}) THEN r.relation_type ELSE 'related_to' END,
|
|
9759
|
+
MAX(0.1, MIN(1.0, COALESCE(r.strength, 0.5))),
|
|
9760
|
+
MAX(0.1, MIN(1.0, COALESCE(${relationConfidence}, 0.7))),
|
|
9761
|
+
'legacy relation backfill: ' || r.relation_type,
|
|
9762
|
+
COALESCE(r.created_at, datetime('now')),
|
|
9763
|
+
COALESCE(${relationUpdatedAt}, r.created_at, datetime('now')),
|
|
9764
|
+
r.id,
|
|
9765
|
+
'relation',
|
|
9766
|
+
'[]',
|
|
9767
|
+
'active'
|
|
9768
|
+
FROM relations r
|
|
9769
|
+
JOIN entities src ON src.id = r.source_entity_id
|
|
9770
|
+
JOIN entities dst ON dst.id = r.target_entity_id
|
|
9771
|
+
WHERE r.source_entity_id <> r.target_entity_id
|
|
9772
|
+
AND ${sourceAgentId} = ${targetAgentId}
|
|
9773
|
+
`);
|
|
9774
|
+
}
|
|
9775
|
+
function up84(db) {
|
|
9776
|
+
db.exec(`
|
|
9777
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
|
|
9778
|
+
path TEXT PRIMARY KEY,
|
|
9779
|
+
mtime_ms INTEGER NOT NULL,
|
|
9780
|
+
ctime_ms INTEGER NOT NULL,
|
|
9781
|
+
size INTEGER NOT NULL,
|
|
9782
|
+
content_hash TEXT NOT NULL,
|
|
9783
|
+
importer_version INTEGER NOT NULL,
|
|
9784
|
+
chunk_count INTEGER NOT NULL DEFAULT 0,
|
|
9785
|
+
last_imported_at TEXT NOT NULL,
|
|
9786
|
+
last_seen_at TEXT NOT NULL,
|
|
9787
|
+
status TEXT NOT NULL DEFAULT 'imported',
|
|
9788
|
+
error TEXT
|
|
9789
|
+
);
|
|
9790
|
+
|
|
9791
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_chunks (
|
|
9792
|
+
file_path TEXT NOT NULL,
|
|
9793
|
+
chunk_hash TEXT NOT NULL,
|
|
9794
|
+
chunk_index INTEGER NOT NULL,
|
|
9795
|
+
memory_id TEXT,
|
|
9796
|
+
source_id TEXT,
|
|
9797
|
+
created_at TEXT NOT NULL,
|
|
9798
|
+
PRIMARY KEY (file_path, chunk_hash)
|
|
9799
|
+
);
|
|
9800
|
+
|
|
9801
|
+
CREATE INDEX IF NOT EXISTS idx_legacy_markdown_chunks_memory_id
|
|
9802
|
+
ON legacy_markdown_chunks(memory_id);
|
|
9803
|
+
`);
|
|
9804
|
+
}
|
|
9805
|
+
function up85(db) {
|
|
9806
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
|
|
9807
|
+
const tableNames = new Set(tables.map((r) => String(r.name)));
|
|
9808
|
+
if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
|
|
9809
|
+
return;
|
|
9810
|
+
const relCols = db.prepare("PRAGMA table_info(relations)").all();
|
|
9811
|
+
const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
|
|
9812
|
+
const rel = new Set(relCols.map((c) => String(c.name)));
|
|
9813
|
+
const dep = new Set(depCols.map((c) => String(c.name)));
|
|
9814
|
+
if (!rel.has("source_entity_id") || !rel.has("relation_type"))
|
|
9815
|
+
return;
|
|
9816
|
+
if (!dep.has("source_entity_id") || !dep.has("dependency_type") || !dep.has("agent_id"))
|
|
9817
|
+
return;
|
|
9818
|
+
const hasRelConfidence = rel.has("confidence");
|
|
9819
|
+
const hasRelUpdated = rel.has("updated_at");
|
|
9820
|
+
const hasDepConfidence = dep.has("confidence");
|
|
9821
|
+
const hasDepReason = dep.has("reason");
|
|
9822
|
+
const hasDepStatus = dep.has("status");
|
|
9823
|
+
const selectParts = ["id", "source_entity_id", "target_entity_id"];
|
|
9824
|
+
const colParts = ["id", "source_entity_id", "target_entity_id"];
|
|
9825
|
+
selectParts.push("relation_type");
|
|
9826
|
+
colParts.push("dependency_type");
|
|
9827
|
+
selectParts.push("strength", "created_at");
|
|
9828
|
+
colParts.push("strength", "created_at");
|
|
9829
|
+
selectParts.push("'default'");
|
|
9830
|
+
colParts.push("agent_id");
|
|
9831
|
+
selectParts.push("NULL");
|
|
9832
|
+
colParts.push("aspect_id");
|
|
9833
|
+
if (hasRelConfidence && hasDepConfidence) {
|
|
9834
|
+
selectParts.push("confidence");
|
|
9835
|
+
colParts.push("confidence");
|
|
9836
|
+
}
|
|
9837
|
+
if (hasDepReason) {
|
|
9838
|
+
selectParts.push("'extracted'");
|
|
9839
|
+
colParts.push("reason");
|
|
9840
|
+
}
|
|
9841
|
+
if (hasDepStatus) {
|
|
9842
|
+
selectParts.push("'active'");
|
|
9843
|
+
colParts.push("status");
|
|
9844
|
+
}
|
|
9845
|
+
if (hasRelUpdated && dep.has("updated_at")) {
|
|
9846
|
+
selectParts.push("updated_at");
|
|
9847
|
+
colParts.push("updated_at");
|
|
9848
|
+
}
|
|
9849
|
+
const selectClause = selectParts.join(", ");
|
|
9850
|
+
const colsClause = colParts.join(", ");
|
|
9851
|
+
db.exec(`INSERT OR IGNORE INTO entity_dependencies (${colsClause})
|
|
9852
|
+
SELECT ${selectClause}
|
|
9853
|
+
FROM relations
|
|
9854
|
+
WHERE source_entity_id IS NOT NULL
|
|
9855
|
+
AND target_entity_id IS NOT NULL
|
|
9856
|
+
AND relation_type IS NOT NULL`);
|
|
9857
|
+
}
|
|
9858
|
+
function addColumnIfMissing21(db, table, column, definition) {
|
|
9859
|
+
const cols = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
9860
|
+
if (cols.some((col) => col.name === column))
|
|
9861
|
+
return;
|
|
9862
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
9863
|
+
}
|
|
9864
|
+
function up86(db) {
|
|
9865
|
+
addColumnIfMissing21(db, "summary_jobs", "content_hash", "TEXT");
|
|
9866
|
+
db.exec(`
|
|
9867
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
|
|
9868
|
+
ON summary_jobs(agent_id, session_key, content_hash)
|
|
9869
|
+
`);
|
|
9870
|
+
}
|
|
9626
9871
|
var MIGRATIONS = [
|
|
9627
9872
|
{
|
|
9628
9873
|
version: 1,
|
|
@@ -10287,6 +10532,45 @@ var MIGRATIONS = [
|
|
|
10287
10532
|
{ table: "skill_invocations", column: "tool_use_id" }
|
|
10288
10533
|
]
|
|
10289
10534
|
}
|
|
10535
|
+
},
|
|
10536
|
+
{
|
|
10537
|
+
version: 83,
|
|
10538
|
+
name: "memory-lifecycle-repair",
|
|
10539
|
+
up: up83,
|
|
10540
|
+
artifacts: {
|
|
10541
|
+
tables: ["transcript_capture_jobs", "aggregate_evidence_sources", "entity_dependencies"],
|
|
10542
|
+
columns: [
|
|
10543
|
+
{ table: "documents", column: "agent_id" },
|
|
10544
|
+
{ table: "documents", column: "project" },
|
|
10545
|
+
{ table: "memories", column: "superseded_by" },
|
|
10546
|
+
{ table: "memories", column: "superseded_at" },
|
|
10547
|
+
{ table: "memories", column: "superseded_reason" }
|
|
10548
|
+
]
|
|
10549
|
+
}
|
|
10550
|
+
},
|
|
10551
|
+
{
|
|
10552
|
+
version: 84,
|
|
10553
|
+
name: "legacy-markdown-import-state",
|
|
10554
|
+
up: up84,
|
|
10555
|
+
artifacts: {
|
|
10556
|
+
tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
|
|
10557
|
+
}
|
|
10558
|
+
},
|
|
10559
|
+
{
|
|
10560
|
+
version: 85,
|
|
10561
|
+
name: "backfill-relations-to-dependencies",
|
|
10562
|
+
up: up85,
|
|
10563
|
+
artifacts: {
|
|
10564
|
+
tables: ["entity_dependencies"]
|
|
10565
|
+
}
|
|
10566
|
+
},
|
|
10567
|
+
{
|
|
10568
|
+
version: 86,
|
|
10569
|
+
name: "summary-jobs-content-hash",
|
|
10570
|
+
up: up86,
|
|
10571
|
+
artifacts: {
|
|
10572
|
+
columns: [{ table: "summary_jobs", column: "content_hash" }]
|
|
10573
|
+
}
|
|
10290
10574
|
}
|
|
10291
10575
|
];
|
|
10292
10576
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -17627,7 +17911,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
17627
17911
|
return true;
|
|
17628
17912
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
17629
17913
|
}
|
|
17630
|
-
function
|
|
17914
|
+
function up87(db) {
|
|
17631
17915
|
db.exec(`
|
|
17632
17916
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
17633
17917
|
version INTEGER PRIMARY KEY,
|
|
@@ -17716,31 +18000,31 @@ function up83(db) {
|
|
|
17716
18000
|
} catch {}
|
|
17717
18001
|
createMemoriesFts2(db);
|
|
17718
18002
|
}
|
|
17719
|
-
function
|
|
18003
|
+
function hasColumn13(db, table, column) {
|
|
17720
18004
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
17721
18005
|
return rows.some((r) => r.name === column);
|
|
17722
18006
|
}
|
|
17723
|
-
function
|
|
17724
|
-
if (!
|
|
18007
|
+
function addColumnIfMissing22(db, table, column, definition) {
|
|
18008
|
+
if (!hasColumn13(db, table, column)) {
|
|
17725
18009
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
17726
18010
|
}
|
|
17727
18011
|
}
|
|
17728
18012
|
function up210(db) {
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
18013
|
+
addColumnIfMissing22(db, "memories", "content_hash", "TEXT");
|
|
18014
|
+
addColumnIfMissing22(db, "memories", "normalized_content", "TEXT");
|
|
18015
|
+
addColumnIfMissing22(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
18016
|
+
addColumnIfMissing22(db, "memories", "deleted_at", "TEXT");
|
|
18017
|
+
addColumnIfMissing22(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
18018
|
+
addColumnIfMissing22(db, "memories", "embedding_model", "TEXT");
|
|
18019
|
+
addColumnIfMissing22(db, "memories", "extraction_model", "TEXT");
|
|
18020
|
+
addColumnIfMissing22(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
18021
|
+
addColumnIfMissing22(db, "memories", "who", "TEXT");
|
|
18022
|
+
addColumnIfMissing22(db, "memories", "why", "TEXT");
|
|
18023
|
+
addColumnIfMissing22(db, "memories", "project", "TEXT");
|
|
18024
|
+
addColumnIfMissing22(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
18025
|
+
addColumnIfMissing22(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
18026
|
+
addColumnIfMissing22(db, "memories", "last_accessed", "TEXT");
|
|
18027
|
+
addColumnIfMissing22(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
17744
18028
|
db.exec(`
|
|
17745
18029
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
17746
18030
|
id TEXT PRIMARY KEY,
|
|
@@ -17836,7 +18120,7 @@ function up210(db) {
|
|
|
17836
18120
|
ON memory_entity_mentions(entity_id);
|
|
17837
18121
|
`);
|
|
17838
18122
|
}
|
|
17839
|
-
function
|
|
18123
|
+
function addColumnIfMissing23(db, table, column, definition) {
|
|
17840
18124
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
17841
18125
|
if (rows.some((r) => r.name === column))
|
|
17842
18126
|
return false;
|
|
@@ -17844,8 +18128,8 @@ function addColumnIfMissing22(db, table, column, definition) {
|
|
|
17844
18128
|
return true;
|
|
17845
18129
|
}
|
|
17846
18130
|
function up310(db) {
|
|
17847
|
-
|
|
17848
|
-
|
|
18131
|
+
addColumnIfMissing23(db, "memories", "why", "TEXT");
|
|
18132
|
+
addColumnIfMissing23(db, "memories", "project", "TEXT");
|
|
17849
18133
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
17850
18134
|
db.exec(`
|
|
17851
18135
|
UPDATE memories
|
|
@@ -18002,7 +18286,7 @@ function up710(db) {
|
|
|
18002
18286
|
db.exec("ALTER TABLE memory_jobs ADD COLUMN document_id TEXT");
|
|
18003
18287
|
}
|
|
18004
18288
|
}
|
|
18005
|
-
function
|
|
18289
|
+
function up88(db) {
|
|
18006
18290
|
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='embeddings'").all();
|
|
18007
18291
|
if (tables.length === 0)
|
|
18008
18292
|
return;
|
|
@@ -19271,7 +19555,7 @@ function up492(db) {
|
|
|
19271
19555
|
);
|
|
19272
19556
|
`);
|
|
19273
19557
|
}
|
|
19274
|
-
function
|
|
19558
|
+
function hasTable4(db, name) {
|
|
19275
19559
|
return db.prepare(`SELECT name
|
|
19276
19560
|
FROM sqlite_master
|
|
19277
19561
|
WHERE type = 'table' AND name = ?
|
|
@@ -19301,7 +19585,7 @@ function up502(db) {
|
|
|
19301
19585
|
CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
|
|
19302
19586
|
ON entity_dependency_history(created_at DESC);
|
|
19303
19587
|
`);
|
|
19304
|
-
if (!
|
|
19588
|
+
if (!hasTable4(db, "entity_dependencies"))
|
|
19305
19589
|
return;
|
|
19306
19590
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
|
|
19307
19591
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
|
|
@@ -20311,11 +20595,256 @@ function up822(db) {
|
|
|
20311
20595
|
`);
|
|
20312
20596
|
db.exec("CREATE INDEX IF NOT EXISTS idx_skill_inv_harness ON skill_invocations(harness, created_at)");
|
|
20313
20597
|
}
|
|
20598
|
+
var DEPENDENCY_TYPES2 = new Set([
|
|
20599
|
+
"uses",
|
|
20600
|
+
"requires",
|
|
20601
|
+
"owned_by",
|
|
20602
|
+
"owns",
|
|
20603
|
+
"blocks",
|
|
20604
|
+
"informs",
|
|
20605
|
+
"maintains",
|
|
20606
|
+
"implements",
|
|
20607
|
+
"built",
|
|
20608
|
+
"depends_on",
|
|
20609
|
+
"related_to",
|
|
20610
|
+
"learned_from",
|
|
20611
|
+
"teaches",
|
|
20612
|
+
"knows",
|
|
20613
|
+
"assumes",
|
|
20614
|
+
"supports_claim",
|
|
20615
|
+
"authored_by",
|
|
20616
|
+
"links_to",
|
|
20617
|
+
"contains",
|
|
20618
|
+
"contains_note",
|
|
20619
|
+
"contradicts",
|
|
20620
|
+
"supersedes",
|
|
20621
|
+
"part_of",
|
|
20622
|
+
"produced_artifact",
|
|
20623
|
+
"precedes",
|
|
20624
|
+
"follows",
|
|
20625
|
+
"triggers",
|
|
20626
|
+
"may_execute",
|
|
20627
|
+
"requires_approval_from",
|
|
20628
|
+
"impacts",
|
|
20629
|
+
"produces",
|
|
20630
|
+
"consumes"
|
|
20631
|
+
]);
|
|
20632
|
+
function sqlStringList2(values) {
|
|
20633
|
+
return [...values].map((value) => `'${value}'`).join(", ");
|
|
20634
|
+
}
|
|
20635
|
+
function hasTable32(db, table) {
|
|
20636
|
+
return Boolean(db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table));
|
|
20637
|
+
}
|
|
20638
|
+
function hasColumn122(db, table, column) {
|
|
20639
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
20640
|
+
return rows.some((row) => row.name === column);
|
|
20641
|
+
}
|
|
20642
|
+
function addColumnIfMissing202(db, table, column, definition) {
|
|
20643
|
+
if (!hasColumn122(db, table, column))
|
|
20644
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
20645
|
+
}
|
|
20646
|
+
function documentScopeColumnsPreservingExisting2(db) {
|
|
20647
|
+
const preserveAgentId = hasColumn122(db, "documents", "agent_id");
|
|
20648
|
+
const preserveProject = hasColumn122(db, "documents", "project");
|
|
20649
|
+
if (preserveAgentId) {
|
|
20650
|
+
db.exec(`
|
|
20651
|
+
CREATE TEMP TABLE __signet_doc_agent_guard AS
|
|
20652
|
+
SELECT id, agent_id FROM documents
|
|
20653
|
+
WHERE NULLIF(TRIM(agent_id), '') IS NOT NULL
|
|
20654
|
+
AND NULLIF(TRIM(agent_id), '') <> 'default'
|
|
20655
|
+
`);
|
|
20656
|
+
}
|
|
20657
|
+
if (preserveProject) {
|
|
20658
|
+
db.exec(`
|
|
20659
|
+
CREATE TEMP TABLE __signet_doc_project_guard AS
|
|
20660
|
+
SELECT id, project FROM documents
|
|
20661
|
+
WHERE NULLIF(TRIM(project), '') IS NOT NULL
|
|
20662
|
+
`);
|
|
20663
|
+
}
|
|
20664
|
+
try {
|
|
20665
|
+
up802(db);
|
|
20666
|
+
if (preserveAgentId) {
|
|
20667
|
+
db.exec(`
|
|
20668
|
+
UPDATE documents
|
|
20669
|
+
SET agent_id = (SELECT agent_id FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
20670
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_agent_guard WHERE __signet_doc_agent_guard.id = documents.id)
|
|
20671
|
+
`);
|
|
20672
|
+
}
|
|
20673
|
+
if (preserveProject) {
|
|
20674
|
+
db.exec(`
|
|
20675
|
+
UPDATE documents
|
|
20676
|
+
SET project = (SELECT project FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
20677
|
+
WHERE EXISTS (SELECT 1 FROM __signet_doc_project_guard WHERE __signet_doc_project_guard.id = documents.id)
|
|
20678
|
+
`);
|
|
20679
|
+
}
|
|
20680
|
+
} finally {
|
|
20681
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_agent_guard");
|
|
20682
|
+
db.exec("DROP TABLE IF EXISTS temp.__signet_doc_project_guard");
|
|
20683
|
+
}
|
|
20684
|
+
}
|
|
20685
|
+
function up832(db) {
|
|
20686
|
+
up792(db);
|
|
20687
|
+
if (hasTable32(db, "documents")) {
|
|
20688
|
+
documentScopeColumnsPreservingExisting2(db);
|
|
20689
|
+
}
|
|
20690
|
+
up812(db);
|
|
20691
|
+
addColumnIfMissing202(db, "memories", "superseded_by", "TEXT");
|
|
20692
|
+
addColumnIfMissing202(db, "memories", "superseded_at", "TEXT");
|
|
20693
|
+
addColumnIfMissing202(db, "memories", "superseded_reason", "TEXT");
|
|
20694
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_superseded_by ON memories(superseded_by)");
|
|
20695
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memories_active_supersession ON memories(is_deleted, superseded_by)");
|
|
20696
|
+
if (!hasTable32(db, "relations") || !hasTable32(db, "entity_dependencies"))
|
|
20697
|
+
return;
|
|
20698
|
+
addColumnIfMissing202(db, "entity_dependencies", "confidence", "REAL");
|
|
20699
|
+
addColumnIfMissing202(db, "entity_dependencies", "reason", "TEXT");
|
|
20700
|
+
addColumnIfMissing202(db, "entity_dependencies", "source_id", "TEXT");
|
|
20701
|
+
addColumnIfMissing202(db, "entity_dependencies", "source_kind", "TEXT");
|
|
20702
|
+
addColumnIfMissing202(db, "entity_dependencies", "proposal_evidence", "TEXT NOT NULL DEFAULT '[]'");
|
|
20703
|
+
addColumnIfMissing202(db, "entity_dependencies", "status", "TEXT NOT NULL DEFAULT 'active'");
|
|
20704
|
+
const relationConfidence = hasColumn122(db, "relations", "confidence") ? "r.confidence" : "NULL";
|
|
20705
|
+
const relationUpdatedAt = hasColumn122(db, "relations", "updated_at") ? "r.updated_at" : "r.created_at";
|
|
20706
|
+
const sourceAgentId = hasColumn122(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(src.agent_id), ''), 'default')" : "'default'";
|
|
20707
|
+
const targetAgentId = hasColumn122(db, "entities", "agent_id") ? "COALESCE(NULLIF(TRIM(dst.agent_id), ''), 'default')" : "'default'";
|
|
20708
|
+
db.exec(`
|
|
20709
|
+
INSERT OR IGNORE INTO entity_dependencies (
|
|
20710
|
+
id,
|
|
20711
|
+
source_entity_id,
|
|
20712
|
+
target_entity_id,
|
|
20713
|
+
agent_id,
|
|
20714
|
+
dependency_type,
|
|
20715
|
+
strength,
|
|
20716
|
+
confidence,
|
|
20717
|
+
reason,
|
|
20718
|
+
created_at,
|
|
20719
|
+
updated_at,
|
|
20720
|
+
source_id,
|
|
20721
|
+
source_kind,
|
|
20722
|
+
proposal_evidence,
|
|
20723
|
+
status
|
|
20724
|
+
)
|
|
20725
|
+
SELECT
|
|
20726
|
+
'relation:' || r.id,
|
|
20727
|
+
r.source_entity_id,
|
|
20728
|
+
r.target_entity_id,
|
|
20729
|
+
COALESCE(${sourceAgentId}, ${targetAgentId}, 'default'),
|
|
20730
|
+
CASE WHEN r.relation_type IN (${sqlStringList2(DEPENDENCY_TYPES2)}) THEN r.relation_type ELSE 'related_to' END,
|
|
20731
|
+
MAX(0.1, MIN(1.0, COALESCE(r.strength, 0.5))),
|
|
20732
|
+
MAX(0.1, MIN(1.0, COALESCE(${relationConfidence}, 0.7))),
|
|
20733
|
+
'legacy relation backfill: ' || r.relation_type,
|
|
20734
|
+
COALESCE(r.created_at, datetime('now')),
|
|
20735
|
+
COALESCE(${relationUpdatedAt}, r.created_at, datetime('now')),
|
|
20736
|
+
r.id,
|
|
20737
|
+
'relation',
|
|
20738
|
+
'[]',
|
|
20739
|
+
'active'
|
|
20740
|
+
FROM relations r
|
|
20741
|
+
JOIN entities src ON src.id = r.source_entity_id
|
|
20742
|
+
JOIN entities dst ON dst.id = r.target_entity_id
|
|
20743
|
+
WHERE r.source_entity_id <> r.target_entity_id
|
|
20744
|
+
AND ${sourceAgentId} = ${targetAgentId}
|
|
20745
|
+
`);
|
|
20746
|
+
}
|
|
20747
|
+
function up842(db) {
|
|
20748
|
+
db.exec(`
|
|
20749
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
|
|
20750
|
+
path TEXT PRIMARY KEY,
|
|
20751
|
+
mtime_ms INTEGER NOT NULL,
|
|
20752
|
+
ctime_ms INTEGER NOT NULL,
|
|
20753
|
+
size INTEGER NOT NULL,
|
|
20754
|
+
content_hash TEXT NOT NULL,
|
|
20755
|
+
importer_version INTEGER NOT NULL,
|
|
20756
|
+
chunk_count INTEGER NOT NULL DEFAULT 0,
|
|
20757
|
+
last_imported_at TEXT NOT NULL,
|
|
20758
|
+
last_seen_at TEXT NOT NULL,
|
|
20759
|
+
status TEXT NOT NULL DEFAULT 'imported',
|
|
20760
|
+
error TEXT
|
|
20761
|
+
);
|
|
20762
|
+
|
|
20763
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_chunks (
|
|
20764
|
+
file_path TEXT NOT NULL,
|
|
20765
|
+
chunk_hash TEXT NOT NULL,
|
|
20766
|
+
chunk_index INTEGER NOT NULL,
|
|
20767
|
+
memory_id TEXT,
|
|
20768
|
+
source_id TEXT,
|
|
20769
|
+
created_at TEXT NOT NULL,
|
|
20770
|
+
PRIMARY KEY (file_path, chunk_hash)
|
|
20771
|
+
);
|
|
20772
|
+
|
|
20773
|
+
CREATE INDEX IF NOT EXISTS idx_legacy_markdown_chunks_memory_id
|
|
20774
|
+
ON legacy_markdown_chunks(memory_id);
|
|
20775
|
+
`);
|
|
20776
|
+
}
|
|
20777
|
+
function up852(db) {
|
|
20778
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
|
|
20779
|
+
const tableNames = new Set(tables.map((r) => String(r.name)));
|
|
20780
|
+
if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
|
|
20781
|
+
return;
|
|
20782
|
+
const relCols = db.prepare("PRAGMA table_info(relations)").all();
|
|
20783
|
+
const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
|
|
20784
|
+
const rel = new Set(relCols.map((c) => String(c.name)));
|
|
20785
|
+
const dep = new Set(depCols.map((c) => String(c.name)));
|
|
20786
|
+
if (!rel.has("source_entity_id") || !rel.has("relation_type"))
|
|
20787
|
+
return;
|
|
20788
|
+
if (!dep.has("source_entity_id") || !dep.has("dependency_type") || !dep.has("agent_id"))
|
|
20789
|
+
return;
|
|
20790
|
+
const hasRelConfidence = rel.has("confidence");
|
|
20791
|
+
const hasRelUpdated = rel.has("updated_at");
|
|
20792
|
+
const hasDepConfidence = dep.has("confidence");
|
|
20793
|
+
const hasDepReason = dep.has("reason");
|
|
20794
|
+
const hasDepStatus = dep.has("status");
|
|
20795
|
+
const selectParts = ["id", "source_entity_id", "target_entity_id"];
|
|
20796
|
+
const colParts = ["id", "source_entity_id", "target_entity_id"];
|
|
20797
|
+
selectParts.push("relation_type");
|
|
20798
|
+
colParts.push("dependency_type");
|
|
20799
|
+
selectParts.push("strength", "created_at");
|
|
20800
|
+
colParts.push("strength", "created_at");
|
|
20801
|
+
selectParts.push("'default'");
|
|
20802
|
+
colParts.push("agent_id");
|
|
20803
|
+
selectParts.push("NULL");
|
|
20804
|
+
colParts.push("aspect_id");
|
|
20805
|
+
if (hasRelConfidence && hasDepConfidence) {
|
|
20806
|
+
selectParts.push("confidence");
|
|
20807
|
+
colParts.push("confidence");
|
|
20808
|
+
}
|
|
20809
|
+
if (hasDepReason) {
|
|
20810
|
+
selectParts.push("'extracted'");
|
|
20811
|
+
colParts.push("reason");
|
|
20812
|
+
}
|
|
20813
|
+
if (hasDepStatus) {
|
|
20814
|
+
selectParts.push("'active'");
|
|
20815
|
+
colParts.push("status");
|
|
20816
|
+
}
|
|
20817
|
+
if (hasRelUpdated && dep.has("updated_at")) {
|
|
20818
|
+
selectParts.push("updated_at");
|
|
20819
|
+
colParts.push("updated_at");
|
|
20820
|
+
}
|
|
20821
|
+
const selectClause = selectParts.join(", ");
|
|
20822
|
+
const colsClause = colParts.join(", ");
|
|
20823
|
+
db.exec(`INSERT OR IGNORE INTO entity_dependencies (${colsClause})
|
|
20824
|
+
SELECT ${selectClause}
|
|
20825
|
+
FROM relations
|
|
20826
|
+
WHERE source_entity_id IS NOT NULL
|
|
20827
|
+
AND target_entity_id IS NOT NULL
|
|
20828
|
+
AND relation_type IS NOT NULL`);
|
|
20829
|
+
}
|
|
20830
|
+
function addColumnIfMissing212(db, table, column, definition) {
|
|
20831
|
+
const cols = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
20832
|
+
if (cols.some((col) => col.name === column))
|
|
20833
|
+
return;
|
|
20834
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
20835
|
+
}
|
|
20836
|
+
function up862(db) {
|
|
20837
|
+
addColumnIfMissing212(db, "summary_jobs", "content_hash", "TEXT");
|
|
20838
|
+
db.exec(`
|
|
20839
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
|
|
20840
|
+
ON summary_jobs(agent_id, session_key, content_hash)
|
|
20841
|
+
`);
|
|
20842
|
+
}
|
|
20314
20843
|
var MIGRATIONS2 = [
|
|
20315
20844
|
{
|
|
20316
20845
|
version: 1,
|
|
20317
20846
|
name: "baseline",
|
|
20318
|
-
up:
|
|
20847
|
+
up: up87,
|
|
20319
20848
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
20320
20849
|
},
|
|
20321
20850
|
{
|
|
@@ -20364,7 +20893,7 @@ var MIGRATIONS2 = [
|
|
|
20364
20893
|
{
|
|
20365
20894
|
version: 8,
|
|
20366
20895
|
name: "embeddings-unique-hash",
|
|
20367
|
-
up:
|
|
20896
|
+
up: up88
|
|
20368
20897
|
},
|
|
20369
20898
|
{
|
|
20370
20899
|
version: 9,
|
|
@@ -20975,6 +21504,45 @@ var MIGRATIONS2 = [
|
|
|
20975
21504
|
{ table: "skill_invocations", column: "tool_use_id" }
|
|
20976
21505
|
]
|
|
20977
21506
|
}
|
|
21507
|
+
},
|
|
21508
|
+
{
|
|
21509
|
+
version: 83,
|
|
21510
|
+
name: "memory-lifecycle-repair",
|
|
21511
|
+
up: up832,
|
|
21512
|
+
artifacts: {
|
|
21513
|
+
tables: ["transcript_capture_jobs", "aggregate_evidence_sources", "entity_dependencies"],
|
|
21514
|
+
columns: [
|
|
21515
|
+
{ table: "documents", column: "agent_id" },
|
|
21516
|
+
{ table: "documents", column: "project" },
|
|
21517
|
+
{ table: "memories", column: "superseded_by" },
|
|
21518
|
+
{ table: "memories", column: "superseded_at" },
|
|
21519
|
+
{ table: "memories", column: "superseded_reason" }
|
|
21520
|
+
]
|
|
21521
|
+
}
|
|
21522
|
+
},
|
|
21523
|
+
{
|
|
21524
|
+
version: 84,
|
|
21525
|
+
name: "legacy-markdown-import-state",
|
|
21526
|
+
up: up842,
|
|
21527
|
+
artifacts: {
|
|
21528
|
+
tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
|
|
21529
|
+
}
|
|
21530
|
+
},
|
|
21531
|
+
{
|
|
21532
|
+
version: 85,
|
|
21533
|
+
name: "backfill-relations-to-dependencies",
|
|
21534
|
+
up: up852,
|
|
21535
|
+
artifacts: {
|
|
21536
|
+
tables: ["entity_dependencies"]
|
|
21537
|
+
}
|
|
21538
|
+
},
|
|
21539
|
+
{
|
|
21540
|
+
version: 86,
|
|
21541
|
+
name: "summary-jobs-content-hash",
|
|
21542
|
+
up: up862,
|
|
21543
|
+
artifacts: {
|
|
21544
|
+
columns: [{ table: "summary_jobs", column: "content_hash" }]
|
|
21545
|
+
}
|
|
20978
21546
|
}
|
|
20979
21547
|
];
|
|
20980
21548
|
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-hermes-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.147.0",
|
|
4
4
|
"description": "Signet connector for Hermes Agent — installs Signet as a pluggable memory provider",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"typecheck": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@signetai/connector-base": "0.
|
|
29
|
-
"@signetai/core": "0.
|
|
28
|
+
"@signetai/connector-base": "0.147.0",
|
|
29
|
+
"@signetai/core": "0.147.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|