@signetai/connector-hermes-agent 0.216.7 → 0.217.1
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 +601 -23
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16155,6 +16155,241 @@ function up145(db) {
|
|
|
16155
16155
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
16156
16156
|
`);
|
|
16157
16157
|
}
|
|
16158
|
+
function up146(db) {
|
|
16159
|
+
db.exec(`
|
|
16160
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
16161
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
16162
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
16163
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
16164
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
16165
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
16166
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
16167
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16168
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
16169
|
+
);
|
|
16170
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
16171
|
+
|
|
16172
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
16173
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16174
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
16175
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
16176
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
16177
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
16178
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
16179
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16180
|
+
UNIQUE(job_id, ordinal)
|
|
16181
|
+
);
|
|
16182
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
16183
|
+
|
|
16184
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
16185
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16186
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
16187
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
16188
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
16189
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
16190
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16191
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
16192
|
+
);
|
|
16193
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
16194
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
16195
|
+
|
|
16196
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
16197
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
16198
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
16199
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
16200
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
16201
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16202
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
16203
|
+
);
|
|
16204
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
16205
|
+
|
|
16206
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
16207
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
16208
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
16209
|
+
);
|
|
16210
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
16211
|
+
`);
|
|
16212
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
16213
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
16214
|
+
if (exists == null)
|
|
16215
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
16216
|
+
}
|
|
16217
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
16218
|
+
}
|
|
16219
|
+
function up147(db) {
|
|
16220
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
16221
|
+
}
|
|
16222
|
+
function up148(db) {
|
|
16223
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
16224
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
16225
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
16226
|
+
}
|
|
16227
|
+
}
|
|
16228
|
+
function up149(db) {
|
|
16229
|
+
const addColumn = (table, column, definition) => {
|
|
16230
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
16231
|
+
if (exists == null)
|
|
16232
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16233
|
+
};
|
|
16234
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
16235
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
16236
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
16237
|
+
}
|
|
16238
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
16239
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
16240
|
+
if (!columns.some((row) => row.name === column))
|
|
16241
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16242
|
+
}
|
|
16243
|
+
function up150(db) {
|
|
16244
|
+
addColumnIfMissing28(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
16245
|
+
addColumnIfMissing28(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
16246
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
16247
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
16248
|
+
db.exec(`
|
|
16249
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
16250
|
+
AFTER INSERT ON dreaming_passes
|
|
16251
|
+
WHEN NEW.mode = 'incremental-content'
|
|
16252
|
+
BEGIN
|
|
16253
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
16254
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
16255
|
+
UPDATE dreaming_passes
|
|
16256
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
16257
|
+
WHERE id = NEW.id;
|
|
16258
|
+
END;
|
|
16259
|
+
|
|
16260
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
16261
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
16262
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
16263
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
16264
|
+
OR OLD.agent_id IS NOT NEW.agent_id OR OLD.visibility IS NOT NEW.visibility OR OLD.scope IS NOT NEW.scope OR OLD.memory_kind IS NOT NEW.memory_kind
|
|
16265
|
+
BEGIN
|
|
16266
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16267
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16268
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
16269
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16270
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16271
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
16272
|
+
END;
|
|
16273
|
+
|
|
16274
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
16275
|
+
AFTER DELETE ON memories
|
|
16276
|
+
BEGIN
|
|
16277
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16278
|
+
WHERE agent_id = OLD.agent_id
|
|
16279
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
16280
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16281
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16282
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
16283
|
+
END;
|
|
16284
|
+
|
|
16285
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
16286
|
+
AFTER DELETE ON agents
|
|
16287
|
+
BEGIN
|
|
16288
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16289
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
16290
|
+
END;
|
|
16291
|
+
|
|
16292
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
16293
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
16294
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
16295
|
+
BEGIN
|
|
16296
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16297
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
16298
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16299
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
16300
|
+
END;
|
|
16301
|
+
`);
|
|
16302
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
16303
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16304
|
+
if (!exists)
|
|
16305
|
+
continue;
|
|
16306
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
16307
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
16308
|
+
const contentChanged = table === "session_transcripts" ? "OLD.completed_at IS NOT NULL AND (OLD.content IS NOT NEW.content OR NEW.completed_at IS NULL)" : `OLD.content IS NOT NEW.content${hasIsDeleted ? " OR OLD.is_deleted IS NOT NEW.is_deleted" : ""}`;
|
|
16309
|
+
db.exec(`
|
|
16310
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16311
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16312
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
16313
|
+
BEGIN
|
|
16314
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16315
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16316
|
+
END;
|
|
16317
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16318
|
+
AFTER DELETE ON ${table}
|
|
16319
|
+
BEGIN
|
|
16320
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16321
|
+
END;
|
|
16322
|
+
`);
|
|
16323
|
+
}
|
|
16324
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
16325
|
+
db.exec(`
|
|
16326
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
16327
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
16328
|
+
WHEN OLD.depth = 0 AND (OLD.content IS NOT NEW.content OR OLD.source_ref IS NOT NEW.source_ref OR OLD.source_type IS NOT NEW.source_type OR OLD.depth IS NOT NEW.depth OR OLD.agent_id IS NOT NEW.agent_id)
|
|
16329
|
+
BEGIN
|
|
16330
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16331
|
+
END;
|
|
16332
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
16333
|
+
AFTER DELETE ON session_summaries
|
|
16334
|
+
WHEN OLD.depth = 0
|
|
16335
|
+
BEGIN
|
|
16336
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16337
|
+
END;
|
|
16338
|
+
`);
|
|
16339
|
+
}
|
|
16340
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
16341
|
+
if (safetyExists) {
|
|
16342
|
+
db.exec(`
|
|
16343
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
16344
|
+
AFTER INSERT ON memory_content_safety
|
|
16345
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
16346
|
+
BEGIN
|
|
16347
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16348
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
16349
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
16350
|
+
END;
|
|
16351
|
+
|
|
16352
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
16353
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
16354
|
+
WHEN (OLD.context_eligible IS NOT NEW.context_eligible OR OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)
|
|
16355
|
+
AND (OLD.status IS NOT 'clean' OR NEW.status IS NOT 'clean' OR OLD.context_eligible IS NOT 1 OR NEW.context_eligible IS NOT 1)
|
|
16356
|
+
BEGIN
|
|
16357
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16358
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16359
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16360
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
16361
|
+
END;
|
|
16362
|
+
`);
|
|
16363
|
+
}
|
|
16364
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
16365
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16366
|
+
if (!exists)
|
|
16367
|
+
continue;
|
|
16368
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
16369
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
16370
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
16371
|
+
const lifecycleWhen = table === "imported_source_lifecycle" ? `(OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)${lifecycleUpdateClause}` : "OLD.agent_id IS NOT NEW.agent_id";
|
|
16372
|
+
db.exec(`
|
|
16373
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
16374
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
16375
|
+
BEGIN
|
|
16376
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
16377
|
+
END;
|
|
16378
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16379
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16380
|
+
WHEN ${lifecycleWhen}
|
|
16381
|
+
BEGIN
|
|
16382
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16383
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16384
|
+
END;
|
|
16385
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16386
|
+
AFTER DELETE ON ${table}
|
|
16387
|
+
BEGIN
|
|
16388
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16389
|
+
END;
|
|
16390
|
+
`);
|
|
16391
|
+
}
|
|
16392
|
+
}
|
|
16158
16393
|
var MIGRATIONS = [
|
|
16159
16394
|
{
|
|
16160
16395
|
version: 1,
|
|
@@ -17304,6 +17539,60 @@ var MIGRATIONS = [
|
|
|
17304
17539
|
name: "dreaming-evidence-reviews",
|
|
17305
17540
|
up: up145,
|
|
17306
17541
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
17542
|
+
},
|
|
17543
|
+
{
|
|
17544
|
+
version: 146,
|
|
17545
|
+
name: "source-transcript-import",
|
|
17546
|
+
up: up146,
|
|
17547
|
+
artifacts: {
|
|
17548
|
+
tables: [
|
|
17549
|
+
"source_import_jobs",
|
|
17550
|
+
"source_import_files",
|
|
17551
|
+
"source_import_records",
|
|
17552
|
+
"transcript_import_conversations",
|
|
17553
|
+
"source_import_record_attempts"
|
|
17554
|
+
],
|
|
17555
|
+
columns: [
|
|
17556
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
17557
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
17558
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
17559
|
+
]
|
|
17560
|
+
}
|
|
17561
|
+
},
|
|
17562
|
+
{
|
|
17563
|
+
version: 147,
|
|
17564
|
+
name: "source-import-replay-file-slots",
|
|
17565
|
+
up: up147,
|
|
17566
|
+
artifacts: { tables: ["source_import_files"] }
|
|
17567
|
+
},
|
|
17568
|
+
{
|
|
17569
|
+
version: 148,
|
|
17570
|
+
name: "source-import-attempt-provenance",
|
|
17571
|
+
up: up148,
|
|
17572
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
17573
|
+
},
|
|
17574
|
+
{
|
|
17575
|
+
version: 149,
|
|
17576
|
+
name: "transcript-import-state-machine",
|
|
17577
|
+
up: up149,
|
|
17578
|
+
artifacts: {
|
|
17579
|
+
columns: [
|
|
17580
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
17581
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
17582
|
+
{ table: "source_import_files", column: "error" }
|
|
17583
|
+
]
|
|
17584
|
+
}
|
|
17585
|
+
},
|
|
17586
|
+
{
|
|
17587
|
+
version: 150,
|
|
17588
|
+
name: "memory-head-freshness",
|
|
17589
|
+
up: up150,
|
|
17590
|
+
artifacts: {
|
|
17591
|
+
columns: [
|
|
17592
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
17593
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
17594
|
+
]
|
|
17595
|
+
}
|
|
17307
17596
|
}
|
|
17308
17597
|
];
|
|
17309
17598
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -29145,7 +29434,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
29145
29434
|
return true;
|
|
29146
29435
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
29147
29436
|
}
|
|
29148
|
-
function
|
|
29437
|
+
function up151(db) {
|
|
29149
29438
|
db.exec(`
|
|
29150
29439
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
29151
29440
|
version INTEGER PRIMARY KEY,
|
|
@@ -29238,27 +29527,27 @@ function hasColumn26(db, table, column) {
|
|
|
29238
29527
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29239
29528
|
return rows.some((r3) => r3.name === column);
|
|
29240
29529
|
}
|
|
29241
|
-
function
|
|
29530
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
29242
29531
|
if (!hasColumn26(db, table, column)) {
|
|
29243
29532
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29244
29533
|
}
|
|
29245
29534
|
}
|
|
29246
29535
|
function up210(db) {
|
|
29247
|
-
|
|
29248
|
-
|
|
29249
|
-
|
|
29250
|
-
|
|
29251
|
-
|
|
29252
|
-
|
|
29253
|
-
|
|
29254
|
-
|
|
29255
|
-
|
|
29256
|
-
|
|
29257
|
-
|
|
29258
|
-
|
|
29259
|
-
|
|
29260
|
-
|
|
29261
|
-
|
|
29536
|
+
addColumnIfMissing29(db, "memories", "content_hash", "TEXT");
|
|
29537
|
+
addColumnIfMissing29(db, "memories", "normalized_content", "TEXT");
|
|
29538
|
+
addColumnIfMissing29(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
29539
|
+
addColumnIfMissing29(db, "memories", "deleted_at", "TEXT");
|
|
29540
|
+
addColumnIfMissing29(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
29541
|
+
addColumnIfMissing29(db, "memories", "embedding_model", "TEXT");
|
|
29542
|
+
addColumnIfMissing29(db, "memories", "extraction_model", "TEXT");
|
|
29543
|
+
addColumnIfMissing29(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
29544
|
+
addColumnIfMissing29(db, "memories", "who", "TEXT");
|
|
29545
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
29546
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
29547
|
+
addColumnIfMissing29(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
29548
|
+
addColumnIfMissing29(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
29549
|
+
addColumnIfMissing29(db, "memories", "last_accessed", "TEXT");
|
|
29550
|
+
addColumnIfMissing29(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
29262
29551
|
db.exec(`
|
|
29263
29552
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
29264
29553
|
id TEXT PRIMARY KEY,
|
|
@@ -29354,7 +29643,7 @@ function up210(db) {
|
|
|
29354
29643
|
ON memory_entity_mentions(entity_id);
|
|
29355
29644
|
`);
|
|
29356
29645
|
}
|
|
29357
|
-
function
|
|
29646
|
+
function addColumnIfMissing210(db, table, column, definition) {
|
|
29358
29647
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29359
29648
|
if (rows.some((r3) => r3.name === column))
|
|
29360
29649
|
return false;
|
|
@@ -29362,8 +29651,8 @@ function addColumnIfMissing29(db, table, column, definition) {
|
|
|
29362
29651
|
return true;
|
|
29363
29652
|
}
|
|
29364
29653
|
function up310(db) {
|
|
29365
|
-
|
|
29366
|
-
|
|
29654
|
+
addColumnIfMissing210(db, "memories", "why", "TEXT");
|
|
29655
|
+
addColumnIfMissing210(db, "memories", "project", "TEXT");
|
|
29367
29656
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
29368
29657
|
db.exec(`
|
|
29369
29658
|
UPDATE memories
|
|
@@ -29655,7 +29944,7 @@ function up1310(db) {
|
|
|
29655
29944
|
addColumnIfMissing52(db, "memories", "source_path", "TEXT");
|
|
29656
29945
|
addColumnIfMissing52(db, "memories", "source_section", "TEXT");
|
|
29657
29946
|
}
|
|
29658
|
-
function
|
|
29947
|
+
function up1410(db) {
|
|
29659
29948
|
db.exec(`
|
|
29660
29949
|
CREATE TABLE IF NOT EXISTS telemetry_events (
|
|
29661
29950
|
id TEXT PRIMARY KEY,
|
|
@@ -33918,11 +34207,246 @@ function up1452(db) {
|
|
|
33918
34207
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
33919
34208
|
`);
|
|
33920
34209
|
}
|
|
34210
|
+
function up1462(db) {
|
|
34211
|
+
db.exec(`
|
|
34212
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
34213
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
34214
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
34215
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
34216
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
34217
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
34218
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
34219
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34220
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
34221
|
+
);
|
|
34222
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
34223
|
+
|
|
34224
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
34225
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34226
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
34227
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
34228
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
34229
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
34230
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
34231
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34232
|
+
UNIQUE(job_id, ordinal)
|
|
34233
|
+
);
|
|
34234
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
34235
|
+
|
|
34236
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
34237
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34238
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
34239
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
34240
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
34241
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
34242
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34243
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
34244
|
+
);
|
|
34245
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
34246
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
34247
|
+
|
|
34248
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
34249
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
34250
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
34251
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
34252
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
34253
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34254
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
34255
|
+
);
|
|
34256
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
34257
|
+
|
|
34258
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
34259
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
34260
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
34261
|
+
);
|
|
34262
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
34263
|
+
`);
|
|
34264
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
34265
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
34266
|
+
if (exists == null)
|
|
34267
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
34268
|
+
}
|
|
34269
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
34270
|
+
}
|
|
34271
|
+
function up1472(db) {
|
|
34272
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
34273
|
+
}
|
|
34274
|
+
function up1482(db) {
|
|
34275
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
34276
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
34277
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
34278
|
+
}
|
|
34279
|
+
}
|
|
34280
|
+
function up1492(db) {
|
|
34281
|
+
const addColumn = (table, column, definition) => {
|
|
34282
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
34283
|
+
if (exists == null)
|
|
34284
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34285
|
+
};
|
|
34286
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
34287
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
34288
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
34289
|
+
}
|
|
34290
|
+
function addColumnIfMissing282(db, table, column, definition) {
|
|
34291
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
34292
|
+
if (!columns.some((row) => row.name === column))
|
|
34293
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34294
|
+
}
|
|
34295
|
+
function up1502(db) {
|
|
34296
|
+
addColumnIfMissing282(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
34297
|
+
addColumnIfMissing282(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
34298
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
34299
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
34300
|
+
db.exec(`
|
|
34301
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
34302
|
+
AFTER INSERT ON dreaming_passes
|
|
34303
|
+
WHEN NEW.mode = 'incremental-content'
|
|
34304
|
+
BEGIN
|
|
34305
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
34306
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
34307
|
+
UPDATE dreaming_passes
|
|
34308
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
34309
|
+
WHERE id = NEW.id;
|
|
34310
|
+
END;
|
|
34311
|
+
|
|
34312
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
34313
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
34314
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
34315
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
34316
|
+
OR OLD.agent_id IS NOT NEW.agent_id OR OLD.visibility IS NOT NEW.visibility OR OLD.scope IS NOT NEW.scope OR OLD.memory_kind IS NOT NEW.memory_kind
|
|
34317
|
+
BEGIN
|
|
34318
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34319
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34320
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
34321
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34322
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34323
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
34324
|
+
END;
|
|
34325
|
+
|
|
34326
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
34327
|
+
AFTER DELETE ON memories
|
|
34328
|
+
BEGIN
|
|
34329
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34330
|
+
WHERE agent_id = OLD.agent_id
|
|
34331
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
34332
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34333
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34334
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
34335
|
+
END;
|
|
34336
|
+
|
|
34337
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
34338
|
+
AFTER DELETE ON agents
|
|
34339
|
+
BEGIN
|
|
34340
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34341
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
34342
|
+
END;
|
|
34343
|
+
|
|
34344
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
34345
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
34346
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
34347
|
+
BEGIN
|
|
34348
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34349
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
34350
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34351
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
34352
|
+
END;
|
|
34353
|
+
`);
|
|
34354
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
34355
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34356
|
+
if (!exists)
|
|
34357
|
+
continue;
|
|
34358
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
34359
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
34360
|
+
const contentChanged = table === "session_transcripts" ? "OLD.completed_at IS NOT NULL AND (OLD.content IS NOT NEW.content OR NEW.completed_at IS NULL)" : `OLD.content IS NOT NEW.content${hasIsDeleted ? " OR OLD.is_deleted IS NOT NEW.is_deleted" : ""}`;
|
|
34361
|
+
db.exec(`
|
|
34362
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34363
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34364
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
34365
|
+
BEGIN
|
|
34366
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34367
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34368
|
+
END;
|
|
34369
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34370
|
+
AFTER DELETE ON ${table}
|
|
34371
|
+
BEGIN
|
|
34372
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34373
|
+
END;
|
|
34374
|
+
`);
|
|
34375
|
+
}
|
|
34376
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
34377
|
+
db.exec(`
|
|
34378
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
34379
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
34380
|
+
WHEN OLD.depth = 0 AND (OLD.content IS NOT NEW.content OR OLD.source_ref IS NOT NEW.source_ref OR OLD.source_type IS NOT NEW.source_type OR OLD.depth IS NOT NEW.depth OR OLD.agent_id IS NOT NEW.agent_id)
|
|
34381
|
+
BEGIN
|
|
34382
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34383
|
+
END;
|
|
34384
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
34385
|
+
AFTER DELETE ON session_summaries
|
|
34386
|
+
WHEN OLD.depth = 0
|
|
34387
|
+
BEGIN
|
|
34388
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34389
|
+
END;
|
|
34390
|
+
`);
|
|
34391
|
+
}
|
|
34392
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
34393
|
+
if (safetyExists) {
|
|
34394
|
+
db.exec(`
|
|
34395
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
34396
|
+
AFTER INSERT ON memory_content_safety
|
|
34397
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
34398
|
+
BEGIN
|
|
34399
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34400
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
34401
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
34402
|
+
END;
|
|
34403
|
+
|
|
34404
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
34405
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
34406
|
+
WHEN (OLD.context_eligible IS NOT NEW.context_eligible OR OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)
|
|
34407
|
+
AND (OLD.status IS NOT 'clean' OR NEW.status IS NOT 'clean' OR OLD.context_eligible IS NOT 1 OR NEW.context_eligible IS NOT 1)
|
|
34408
|
+
BEGIN
|
|
34409
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34410
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34411
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34412
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
34413
|
+
END;
|
|
34414
|
+
`);
|
|
34415
|
+
}
|
|
34416
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
34417
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34418
|
+
if (!exists)
|
|
34419
|
+
continue;
|
|
34420
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
34421
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
34422
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
34423
|
+
const lifecycleWhen = table === "imported_source_lifecycle" ? `(OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)${lifecycleUpdateClause}` : "OLD.agent_id IS NOT NEW.agent_id";
|
|
34424
|
+
db.exec(`
|
|
34425
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
34426
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
34427
|
+
BEGIN
|
|
34428
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
34429
|
+
END;
|
|
34430
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34431
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34432
|
+
WHEN ${lifecycleWhen}
|
|
34433
|
+
BEGIN
|
|
34434
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34435
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34436
|
+
END;
|
|
34437
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34438
|
+
AFTER DELETE ON ${table}
|
|
34439
|
+
BEGIN
|
|
34440
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34441
|
+
END;
|
|
34442
|
+
`);
|
|
34443
|
+
}
|
|
34444
|
+
}
|
|
33921
34445
|
var MIGRATIONS2 = [
|
|
33922
34446
|
{
|
|
33923
34447
|
version: 1,
|
|
33924
34448
|
name: "baseline",
|
|
33925
|
-
up:
|
|
34449
|
+
up: up151,
|
|
33926
34450
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
33927
34451
|
},
|
|
33928
34452
|
{
|
|
@@ -34011,7 +34535,7 @@ var MIGRATIONS2 = [
|
|
|
34011
34535
|
{
|
|
34012
34536
|
version: 14,
|
|
34013
34537
|
name: "telemetry",
|
|
34014
|
-
up:
|
|
34538
|
+
up: up1410,
|
|
34015
34539
|
artifacts: { tables: ["telemetry_events"] }
|
|
34016
34540
|
},
|
|
34017
34541
|
{
|
|
@@ -35067,6 +35591,60 @@ var MIGRATIONS2 = [
|
|
|
35067
35591
|
name: "dreaming-evidence-reviews",
|
|
35068
35592
|
up: up1452,
|
|
35069
35593
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
35594
|
+
},
|
|
35595
|
+
{
|
|
35596
|
+
version: 146,
|
|
35597
|
+
name: "source-transcript-import",
|
|
35598
|
+
up: up1462,
|
|
35599
|
+
artifacts: {
|
|
35600
|
+
tables: [
|
|
35601
|
+
"source_import_jobs",
|
|
35602
|
+
"source_import_files",
|
|
35603
|
+
"source_import_records",
|
|
35604
|
+
"transcript_import_conversations",
|
|
35605
|
+
"source_import_record_attempts"
|
|
35606
|
+
],
|
|
35607
|
+
columns: [
|
|
35608
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
35609
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
35610
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
35611
|
+
]
|
|
35612
|
+
}
|
|
35613
|
+
},
|
|
35614
|
+
{
|
|
35615
|
+
version: 147,
|
|
35616
|
+
name: "source-import-replay-file-slots",
|
|
35617
|
+
up: up1472,
|
|
35618
|
+
artifacts: { tables: ["source_import_files"] }
|
|
35619
|
+
},
|
|
35620
|
+
{
|
|
35621
|
+
version: 148,
|
|
35622
|
+
name: "source-import-attempt-provenance",
|
|
35623
|
+
up: up1482,
|
|
35624
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
35625
|
+
},
|
|
35626
|
+
{
|
|
35627
|
+
version: 149,
|
|
35628
|
+
name: "transcript-import-state-machine",
|
|
35629
|
+
up: up1492,
|
|
35630
|
+
artifacts: {
|
|
35631
|
+
columns: [
|
|
35632
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
35633
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
35634
|
+
{ table: "source_import_files", column: "error" }
|
|
35635
|
+
]
|
|
35636
|
+
}
|
|
35637
|
+
},
|
|
35638
|
+
{
|
|
35639
|
+
version: 150,
|
|
35640
|
+
name: "memory-head-freshness",
|
|
35641
|
+
up: up1502,
|
|
35642
|
+
artifacts: {
|
|
35643
|
+
columns: [
|
|
35644
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
35645
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
35646
|
+
]
|
|
35647
|
+
}
|
|
35070
35648
|
}
|
|
35071
35649
|
];
|
|
35072
35650
|
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.217.1",
|
|
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.217.1",
|
|
29
|
+
"@signetai/core": "0.217.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|