@signetai/core 0.146.5 → 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 +126 -0
- package/dist/migrations/084-legacy-markdown-import-state.d.ts +3 -0
- package/dist/migrations/084-legacy-markdown-import-state.d.ts.map +1 -0
- package/dist/migrations/085-backfill-relations-to-dependencies.d.ts +17 -0
- package/dist/migrations/085-backfill-relations-to-dependencies.d.ts.map +1 -0
- package/dist/migrations/086-summary-jobs-content-hash.d.ts +3 -0
- package/dist/migrations/086-summary-jobs-content-hash.d.ts.map +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10155,6 +10155,108 @@ function up83(db) {
|
|
|
10155
10155
|
`);
|
|
10156
10156
|
}
|
|
10157
10157
|
|
|
10158
|
+
// src/migrations/084-legacy-markdown-import-state.ts
|
|
10159
|
+
function up84(db) {
|
|
10160
|
+
db.exec(`
|
|
10161
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
|
|
10162
|
+
path TEXT PRIMARY KEY,
|
|
10163
|
+
mtime_ms INTEGER NOT NULL,
|
|
10164
|
+
ctime_ms INTEGER NOT NULL,
|
|
10165
|
+
size INTEGER NOT NULL,
|
|
10166
|
+
content_hash TEXT NOT NULL,
|
|
10167
|
+
importer_version INTEGER NOT NULL,
|
|
10168
|
+
chunk_count INTEGER NOT NULL DEFAULT 0,
|
|
10169
|
+
last_imported_at TEXT NOT NULL,
|
|
10170
|
+
last_seen_at TEXT NOT NULL,
|
|
10171
|
+
status TEXT NOT NULL DEFAULT 'imported',
|
|
10172
|
+
error TEXT
|
|
10173
|
+
);
|
|
10174
|
+
|
|
10175
|
+
CREATE TABLE IF NOT EXISTS legacy_markdown_chunks (
|
|
10176
|
+
file_path TEXT NOT NULL,
|
|
10177
|
+
chunk_hash TEXT NOT NULL,
|
|
10178
|
+
chunk_index INTEGER NOT NULL,
|
|
10179
|
+
memory_id TEXT,
|
|
10180
|
+
source_id TEXT,
|
|
10181
|
+
created_at TEXT NOT NULL,
|
|
10182
|
+
PRIMARY KEY (file_path, chunk_hash)
|
|
10183
|
+
);
|
|
10184
|
+
|
|
10185
|
+
CREATE INDEX IF NOT EXISTS idx_legacy_markdown_chunks_memory_id
|
|
10186
|
+
ON legacy_markdown_chunks(memory_id);
|
|
10187
|
+
`);
|
|
10188
|
+
}
|
|
10189
|
+
|
|
10190
|
+
// src/migrations/085-backfill-relations-to-dependencies.ts
|
|
10191
|
+
function up85(db) {
|
|
10192
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
|
|
10193
|
+
const tableNames = new Set(tables.map((r) => String(r.name)));
|
|
10194
|
+
if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
|
|
10195
|
+
return;
|
|
10196
|
+
const relCols = db.prepare("PRAGMA table_info(relations)").all();
|
|
10197
|
+
const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
|
|
10198
|
+
const rel = new Set(relCols.map((c) => String(c.name)));
|
|
10199
|
+
const dep = new Set(depCols.map((c) => String(c.name)));
|
|
10200
|
+
if (!rel.has("source_entity_id") || !rel.has("relation_type"))
|
|
10201
|
+
return;
|
|
10202
|
+
if (!dep.has("source_entity_id") || !dep.has("dependency_type") || !dep.has("agent_id"))
|
|
10203
|
+
return;
|
|
10204
|
+
const hasRelConfidence = rel.has("confidence");
|
|
10205
|
+
const hasRelUpdated = rel.has("updated_at");
|
|
10206
|
+
const hasDepConfidence = dep.has("confidence");
|
|
10207
|
+
const hasDepReason = dep.has("reason");
|
|
10208
|
+
const hasDepStatus = dep.has("status");
|
|
10209
|
+
const selectParts = ["id", "source_entity_id", "target_entity_id"];
|
|
10210
|
+
const colParts = ["id", "source_entity_id", "target_entity_id"];
|
|
10211
|
+
selectParts.push("relation_type");
|
|
10212
|
+
colParts.push("dependency_type");
|
|
10213
|
+
selectParts.push("strength", "created_at");
|
|
10214
|
+
colParts.push("strength", "created_at");
|
|
10215
|
+
selectParts.push("'default'");
|
|
10216
|
+
colParts.push("agent_id");
|
|
10217
|
+
selectParts.push("NULL");
|
|
10218
|
+
colParts.push("aspect_id");
|
|
10219
|
+
if (hasRelConfidence && hasDepConfidence) {
|
|
10220
|
+
selectParts.push("confidence");
|
|
10221
|
+
colParts.push("confidence");
|
|
10222
|
+
}
|
|
10223
|
+
if (hasDepReason) {
|
|
10224
|
+
selectParts.push("'extracted'");
|
|
10225
|
+
colParts.push("reason");
|
|
10226
|
+
}
|
|
10227
|
+
if (hasDepStatus) {
|
|
10228
|
+
selectParts.push("'active'");
|
|
10229
|
+
colParts.push("status");
|
|
10230
|
+
}
|
|
10231
|
+
if (hasRelUpdated && dep.has("updated_at")) {
|
|
10232
|
+
selectParts.push("updated_at");
|
|
10233
|
+
colParts.push("updated_at");
|
|
10234
|
+
}
|
|
10235
|
+
const selectClause = selectParts.join(", ");
|
|
10236
|
+
const colsClause = colParts.join(", ");
|
|
10237
|
+
db.exec(`INSERT OR IGNORE INTO entity_dependencies (${colsClause})
|
|
10238
|
+
SELECT ${selectClause}
|
|
10239
|
+
FROM relations
|
|
10240
|
+
WHERE source_entity_id IS NOT NULL
|
|
10241
|
+
AND target_entity_id IS NOT NULL
|
|
10242
|
+
AND relation_type IS NOT NULL`);
|
|
10243
|
+
}
|
|
10244
|
+
|
|
10245
|
+
// src/migrations/086-summary-jobs-content-hash.ts
|
|
10246
|
+
function addColumnIfMissing21(db, table, column, definition) {
|
|
10247
|
+
const cols = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
10248
|
+
if (cols.some((col) => col.name === column))
|
|
10249
|
+
return;
|
|
10250
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
10251
|
+
}
|
|
10252
|
+
function up86(db) {
|
|
10253
|
+
addColumnIfMissing21(db, "summary_jobs", "content_hash", "TEXT");
|
|
10254
|
+
db.exec(`
|
|
10255
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
|
|
10256
|
+
ON summary_jobs(agent_id, session_key, content_hash)
|
|
10257
|
+
`);
|
|
10258
|
+
}
|
|
10259
|
+
|
|
10158
10260
|
// src/migrations/index.ts
|
|
10159
10261
|
var MIGRATIONS = [
|
|
10160
10262
|
{
|
|
@@ -10835,6 +10937,30 @@ var MIGRATIONS = [
|
|
|
10835
10937
|
{ table: "memories", column: "superseded_reason" }
|
|
10836
10938
|
]
|
|
10837
10939
|
}
|
|
10940
|
+
},
|
|
10941
|
+
{
|
|
10942
|
+
version: 84,
|
|
10943
|
+
name: "legacy-markdown-import-state",
|
|
10944
|
+
up: up84,
|
|
10945
|
+
artifacts: {
|
|
10946
|
+
tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
|
|
10947
|
+
}
|
|
10948
|
+
},
|
|
10949
|
+
{
|
|
10950
|
+
version: 85,
|
|
10951
|
+
name: "backfill-relations-to-dependencies",
|
|
10952
|
+
up: up85,
|
|
10953
|
+
artifacts: {
|
|
10954
|
+
tables: ["entity_dependencies"]
|
|
10955
|
+
}
|
|
10956
|
+
},
|
|
10957
|
+
{
|
|
10958
|
+
version: 86,
|
|
10959
|
+
name: "summary-jobs-content-hash",
|
|
10960
|
+
up: up86,
|
|
10961
|
+
artifacts: {
|
|
10962
|
+
columns: [{ table: "summary_jobs", column: "content_hash" }]
|
|
10963
|
+
}
|
|
10838
10964
|
}
|
|
10839
10965
|
];
|
|
10840
10966
|
function checksum(m) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"084-legacy-markdown-import-state.d.ts","sourceRoot":"","sources":["../../src/migrations/084-legacy-markdown-import-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CA6BxC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 085: Backfill relations into entity_dependencies.
|
|
3
|
+
*
|
|
4
|
+
* The extraction pipeline writes extracted entity triples into the `relations`
|
|
5
|
+
* table (legacy), while graph diagnostics and traversal read from
|
|
6
|
+
* `entity_dependencies` (current). No code was bridging them, so extracted
|
|
7
|
+
* relations were invisible to graph traversal: edgeCount was always 0.
|
|
8
|
+
*
|
|
9
|
+
* This migration copies every existing `relations` row into
|
|
10
|
+
* `entity_dependencies`, mapping columns across the schema difference.
|
|
11
|
+
* Idempotent — INSERT OR IGNORE skips rows that already exist (matched on
|
|
12
|
+
* source_entity_id, target_entity_id, dependency_type, agent_id via the
|
|
13
|
+
* idx_entity_deps_unique index).
|
|
14
|
+
*/
|
|
15
|
+
import type { MigrationDb } from "./index";
|
|
16
|
+
export declare function up(db: MigrationDb): void;
|
|
17
|
+
//# sourceMappingURL=085-backfill-relations-to-dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"085-backfill-relations-to-dependencies.d.ts","sourceRoot":"","sources":["../../src/migrations/085-backfill-relations-to-dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CA8ExC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"086-summary-jobs-content-hash.d.ts","sourceRoot":"","sources":["../../src/migrations/086-summary-jobs-content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQ3C,wBAAgB,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAOxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
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