@signetai/connector-openclaw 0.216.7 → 0.217.3
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
|
@@ -16152,6 +16152,241 @@ function up145(db) {
|
|
|
16152
16152
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
16153
16153
|
`);
|
|
16154
16154
|
}
|
|
16155
|
+
function up146(db) {
|
|
16156
|
+
db.exec(`
|
|
16157
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
16158
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
16159
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
16160
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
16161
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
16162
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
16163
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
16164
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16165
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
16166
|
+
);
|
|
16167
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
16168
|
+
|
|
16169
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
16170
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16171
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
16172
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
16173
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
16174
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
16175
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
16176
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16177
|
+
UNIQUE(job_id, ordinal)
|
|
16178
|
+
);
|
|
16179
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
16180
|
+
|
|
16181
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
16182
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16183
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
16184
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
16185
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
16186
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
16187
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16188
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
16189
|
+
);
|
|
16190
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
16191
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
16192
|
+
|
|
16193
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
16194
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
16195
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
16196
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
16197
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
16198
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16199
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
16200
|
+
);
|
|
16201
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
16202
|
+
|
|
16203
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
16204
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
16205
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
16206
|
+
);
|
|
16207
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
16208
|
+
`);
|
|
16209
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
16210
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
16211
|
+
if (exists == null)
|
|
16212
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
16213
|
+
}
|
|
16214
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
16215
|
+
}
|
|
16216
|
+
function up147(db) {
|
|
16217
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
16218
|
+
}
|
|
16219
|
+
function up148(db) {
|
|
16220
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
16221
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
16222
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
16223
|
+
}
|
|
16224
|
+
}
|
|
16225
|
+
function up149(db) {
|
|
16226
|
+
const addColumn = (table, column, definition) => {
|
|
16227
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
16228
|
+
if (exists == null)
|
|
16229
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16230
|
+
};
|
|
16231
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
16232
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
16233
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
16234
|
+
}
|
|
16235
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
16236
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
16237
|
+
if (!columns.some((row) => row.name === column))
|
|
16238
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16239
|
+
}
|
|
16240
|
+
function up150(db) {
|
|
16241
|
+
addColumnIfMissing28(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
16242
|
+
addColumnIfMissing28(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
16243
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
16244
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
16245
|
+
db.exec(`
|
|
16246
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
16247
|
+
AFTER INSERT ON dreaming_passes
|
|
16248
|
+
WHEN NEW.mode = 'incremental-content'
|
|
16249
|
+
BEGIN
|
|
16250
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
16251
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
16252
|
+
UPDATE dreaming_passes
|
|
16253
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
16254
|
+
WHERE id = NEW.id;
|
|
16255
|
+
END;
|
|
16256
|
+
|
|
16257
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
16258
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
16259
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
16260
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
16261
|
+
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
|
|
16262
|
+
BEGIN
|
|
16263
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16264
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16265
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
16266
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16267
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16268
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
16269
|
+
END;
|
|
16270
|
+
|
|
16271
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
16272
|
+
AFTER DELETE ON memories
|
|
16273
|
+
BEGIN
|
|
16274
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16275
|
+
WHERE agent_id = OLD.agent_id
|
|
16276
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
16277
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16278
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16279
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
16280
|
+
END;
|
|
16281
|
+
|
|
16282
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
16283
|
+
AFTER DELETE ON agents
|
|
16284
|
+
BEGIN
|
|
16285
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16286
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
16287
|
+
END;
|
|
16288
|
+
|
|
16289
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
16290
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
16291
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
16292
|
+
BEGIN
|
|
16293
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16294
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
16295
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16296
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
16297
|
+
END;
|
|
16298
|
+
`);
|
|
16299
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
16300
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16301
|
+
if (!exists)
|
|
16302
|
+
continue;
|
|
16303
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
16304
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
16305
|
+
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" : ""}`;
|
|
16306
|
+
db.exec(`
|
|
16307
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16308
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16309
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
16310
|
+
BEGIN
|
|
16311
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16312
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16313
|
+
END;
|
|
16314
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16315
|
+
AFTER DELETE ON ${table}
|
|
16316
|
+
BEGIN
|
|
16317
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16318
|
+
END;
|
|
16319
|
+
`);
|
|
16320
|
+
}
|
|
16321
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
16322
|
+
db.exec(`
|
|
16323
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
16324
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
16325
|
+
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)
|
|
16326
|
+
BEGIN
|
|
16327
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16328
|
+
END;
|
|
16329
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
16330
|
+
AFTER DELETE ON session_summaries
|
|
16331
|
+
WHEN OLD.depth = 0
|
|
16332
|
+
BEGIN
|
|
16333
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16334
|
+
END;
|
|
16335
|
+
`);
|
|
16336
|
+
}
|
|
16337
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
16338
|
+
if (safetyExists) {
|
|
16339
|
+
db.exec(`
|
|
16340
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
16341
|
+
AFTER INSERT ON memory_content_safety
|
|
16342
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
16343
|
+
BEGIN
|
|
16344
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16345
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
16346
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
16347
|
+
END;
|
|
16348
|
+
|
|
16349
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
16350
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
16351
|
+
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)
|
|
16352
|
+
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)
|
|
16353
|
+
BEGIN
|
|
16354
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16355
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16356
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16357
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
16358
|
+
END;
|
|
16359
|
+
`);
|
|
16360
|
+
}
|
|
16361
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
16362
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16363
|
+
if (!exists)
|
|
16364
|
+
continue;
|
|
16365
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
16366
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
16367
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
16368
|
+
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";
|
|
16369
|
+
db.exec(`
|
|
16370
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
16371
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
16372
|
+
BEGIN
|
|
16373
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
16374
|
+
END;
|
|
16375
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16376
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16377
|
+
WHEN ${lifecycleWhen}
|
|
16378
|
+
BEGIN
|
|
16379
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16380
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16381
|
+
END;
|
|
16382
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16383
|
+
AFTER DELETE ON ${table}
|
|
16384
|
+
BEGIN
|
|
16385
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16386
|
+
END;
|
|
16387
|
+
`);
|
|
16388
|
+
}
|
|
16389
|
+
}
|
|
16155
16390
|
var MIGRATIONS = [
|
|
16156
16391
|
{
|
|
16157
16392
|
version: 1,
|
|
@@ -17301,6 +17536,60 @@ var MIGRATIONS = [
|
|
|
17301
17536
|
name: "dreaming-evidence-reviews",
|
|
17302
17537
|
up: up145,
|
|
17303
17538
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
17539
|
+
},
|
|
17540
|
+
{
|
|
17541
|
+
version: 146,
|
|
17542
|
+
name: "source-transcript-import",
|
|
17543
|
+
up: up146,
|
|
17544
|
+
artifacts: {
|
|
17545
|
+
tables: [
|
|
17546
|
+
"source_import_jobs",
|
|
17547
|
+
"source_import_files",
|
|
17548
|
+
"source_import_records",
|
|
17549
|
+
"transcript_import_conversations",
|
|
17550
|
+
"source_import_record_attempts"
|
|
17551
|
+
],
|
|
17552
|
+
columns: [
|
|
17553
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
17554
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
17555
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
17556
|
+
]
|
|
17557
|
+
}
|
|
17558
|
+
},
|
|
17559
|
+
{
|
|
17560
|
+
version: 147,
|
|
17561
|
+
name: "source-import-replay-file-slots",
|
|
17562
|
+
up: up147,
|
|
17563
|
+
artifacts: { tables: ["source_import_files"] }
|
|
17564
|
+
},
|
|
17565
|
+
{
|
|
17566
|
+
version: 148,
|
|
17567
|
+
name: "source-import-attempt-provenance",
|
|
17568
|
+
up: up148,
|
|
17569
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
17570
|
+
},
|
|
17571
|
+
{
|
|
17572
|
+
version: 149,
|
|
17573
|
+
name: "transcript-import-state-machine",
|
|
17574
|
+
up: up149,
|
|
17575
|
+
artifacts: {
|
|
17576
|
+
columns: [
|
|
17577
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
17578
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
17579
|
+
{ table: "source_import_files", column: "error" }
|
|
17580
|
+
]
|
|
17581
|
+
}
|
|
17582
|
+
},
|
|
17583
|
+
{
|
|
17584
|
+
version: 150,
|
|
17585
|
+
name: "memory-head-freshness",
|
|
17586
|
+
up: up150,
|
|
17587
|
+
artifacts: {
|
|
17588
|
+
columns: [
|
|
17589
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
17590
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
17591
|
+
]
|
|
17592
|
+
}
|
|
17304
17593
|
}
|
|
17305
17594
|
];
|
|
17306
17595
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -31143,7 +31432,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
31143
31432
|
return true;
|
|
31144
31433
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
31145
31434
|
}
|
|
31146
|
-
function
|
|
31435
|
+
function up151(db) {
|
|
31147
31436
|
db.exec(`
|
|
31148
31437
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
31149
31438
|
version INTEGER PRIMARY KEY,
|
|
@@ -31236,27 +31525,27 @@ function hasColumn26(db, table, column) {
|
|
|
31236
31525
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
31237
31526
|
return rows.some((r3) => r3.name === column);
|
|
31238
31527
|
}
|
|
31239
|
-
function
|
|
31528
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
31240
31529
|
if (!hasColumn26(db, table, column)) {
|
|
31241
31530
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
31242
31531
|
}
|
|
31243
31532
|
}
|
|
31244
31533
|
function up210(db) {
|
|
31245
|
-
|
|
31246
|
-
|
|
31247
|
-
|
|
31248
|
-
|
|
31249
|
-
|
|
31250
|
-
|
|
31251
|
-
|
|
31252
|
-
|
|
31253
|
-
|
|
31254
|
-
|
|
31255
|
-
|
|
31256
|
-
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
|
|
31534
|
+
addColumnIfMissing29(db, "memories", "content_hash", "TEXT");
|
|
31535
|
+
addColumnIfMissing29(db, "memories", "normalized_content", "TEXT");
|
|
31536
|
+
addColumnIfMissing29(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
31537
|
+
addColumnIfMissing29(db, "memories", "deleted_at", "TEXT");
|
|
31538
|
+
addColumnIfMissing29(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
31539
|
+
addColumnIfMissing29(db, "memories", "embedding_model", "TEXT");
|
|
31540
|
+
addColumnIfMissing29(db, "memories", "extraction_model", "TEXT");
|
|
31541
|
+
addColumnIfMissing29(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
31542
|
+
addColumnIfMissing29(db, "memories", "who", "TEXT");
|
|
31543
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
31544
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
31545
|
+
addColumnIfMissing29(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
31546
|
+
addColumnIfMissing29(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
31547
|
+
addColumnIfMissing29(db, "memories", "last_accessed", "TEXT");
|
|
31548
|
+
addColumnIfMissing29(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
31260
31549
|
db.exec(`
|
|
31261
31550
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
31262
31551
|
id TEXT PRIMARY KEY,
|
|
@@ -31352,7 +31641,7 @@ function up210(db) {
|
|
|
31352
31641
|
ON memory_entity_mentions(entity_id);
|
|
31353
31642
|
`);
|
|
31354
31643
|
}
|
|
31355
|
-
function
|
|
31644
|
+
function addColumnIfMissing210(db, table, column, definition) {
|
|
31356
31645
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
31357
31646
|
if (rows.some((r3) => r3.name === column))
|
|
31358
31647
|
return false;
|
|
@@ -31360,8 +31649,8 @@ function addColumnIfMissing29(db, table, column, definition) {
|
|
|
31360
31649
|
return true;
|
|
31361
31650
|
}
|
|
31362
31651
|
function up310(db) {
|
|
31363
|
-
|
|
31364
|
-
|
|
31652
|
+
addColumnIfMissing210(db, "memories", "why", "TEXT");
|
|
31653
|
+
addColumnIfMissing210(db, "memories", "project", "TEXT");
|
|
31365
31654
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
31366
31655
|
db.exec(`
|
|
31367
31656
|
UPDATE memories
|
|
@@ -31653,7 +31942,7 @@ function up1310(db) {
|
|
|
31653
31942
|
addColumnIfMissing52(db, "memories", "source_path", "TEXT");
|
|
31654
31943
|
addColumnIfMissing52(db, "memories", "source_section", "TEXT");
|
|
31655
31944
|
}
|
|
31656
|
-
function
|
|
31945
|
+
function up1410(db) {
|
|
31657
31946
|
db.exec(`
|
|
31658
31947
|
CREATE TABLE IF NOT EXISTS telemetry_events (
|
|
31659
31948
|
id TEXT PRIMARY KEY,
|
|
@@ -35916,11 +36205,246 @@ function up1452(db) {
|
|
|
35916
36205
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
35917
36206
|
`);
|
|
35918
36207
|
}
|
|
36208
|
+
function up1462(db) {
|
|
36209
|
+
db.exec(`
|
|
36210
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
36211
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
36212
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
36213
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
36214
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
36215
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
36216
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
36217
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
36218
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
36219
|
+
);
|
|
36220
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
36221
|
+
|
|
36222
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
36223
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
36224
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
36225
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
36226
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
36227
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
36228
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
36229
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
36230
|
+
UNIQUE(job_id, ordinal)
|
|
36231
|
+
);
|
|
36232
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
36233
|
+
|
|
36234
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
36235
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
36236
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
36237
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
36238
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
36239
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
36240
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
36241
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
36242
|
+
);
|
|
36243
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
36244
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
36245
|
+
|
|
36246
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
36247
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
36248
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
36249
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
36250
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
36251
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
36252
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
36253
|
+
);
|
|
36254
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
36255
|
+
|
|
36256
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
36257
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
36258
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
36259
|
+
);
|
|
36260
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
36261
|
+
`);
|
|
36262
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
36263
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
36264
|
+
if (exists == null)
|
|
36265
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
36266
|
+
}
|
|
36267
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
36268
|
+
}
|
|
36269
|
+
function up1472(db) {
|
|
36270
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
36271
|
+
}
|
|
36272
|
+
function up1482(db) {
|
|
36273
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
36274
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
36275
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
36276
|
+
}
|
|
36277
|
+
}
|
|
36278
|
+
function up1492(db) {
|
|
36279
|
+
const addColumn = (table, column, definition) => {
|
|
36280
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
36281
|
+
if (exists == null)
|
|
36282
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
36283
|
+
};
|
|
36284
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
36285
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
36286
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
36287
|
+
}
|
|
36288
|
+
function addColumnIfMissing282(db, table, column, definition) {
|
|
36289
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
36290
|
+
if (!columns.some((row) => row.name === column))
|
|
36291
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
36292
|
+
}
|
|
36293
|
+
function up1502(db) {
|
|
36294
|
+
addColumnIfMissing282(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
36295
|
+
addColumnIfMissing282(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
36296
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
36297
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
36298
|
+
db.exec(`
|
|
36299
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
36300
|
+
AFTER INSERT ON dreaming_passes
|
|
36301
|
+
WHEN NEW.mode = 'incremental-content'
|
|
36302
|
+
BEGIN
|
|
36303
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
36304
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
36305
|
+
UPDATE dreaming_passes
|
|
36306
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
36307
|
+
WHERE id = NEW.id;
|
|
36308
|
+
END;
|
|
36309
|
+
|
|
36310
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
36311
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
36312
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
36313
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
36314
|
+
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
|
|
36315
|
+
BEGIN
|
|
36316
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36317
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
36318
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
36319
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
36320
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
36321
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
36322
|
+
END;
|
|
36323
|
+
|
|
36324
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
36325
|
+
AFTER DELETE ON memories
|
|
36326
|
+
BEGIN
|
|
36327
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36328
|
+
WHERE agent_id = OLD.agent_id
|
|
36329
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
36330
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
36331
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
36332
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
36333
|
+
END;
|
|
36334
|
+
|
|
36335
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
36336
|
+
AFTER DELETE ON agents
|
|
36337
|
+
BEGIN
|
|
36338
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36339
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
36340
|
+
END;
|
|
36341
|
+
|
|
36342
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
36343
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
36344
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
36345
|
+
BEGIN
|
|
36346
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36347
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
36348
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
36349
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
36350
|
+
END;
|
|
36351
|
+
`);
|
|
36352
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
36353
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
36354
|
+
if (!exists)
|
|
36355
|
+
continue;
|
|
36356
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
36357
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
36358
|
+
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" : ""}`;
|
|
36359
|
+
db.exec(`
|
|
36360
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
36361
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
36362
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
36363
|
+
BEGIN
|
|
36364
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36365
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
36366
|
+
END;
|
|
36367
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
36368
|
+
AFTER DELETE ON ${table}
|
|
36369
|
+
BEGIN
|
|
36370
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
36371
|
+
END;
|
|
36372
|
+
`);
|
|
36373
|
+
}
|
|
36374
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
36375
|
+
db.exec(`
|
|
36376
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
36377
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
36378
|
+
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)
|
|
36379
|
+
BEGIN
|
|
36380
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
36381
|
+
END;
|
|
36382
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
36383
|
+
AFTER DELETE ON session_summaries
|
|
36384
|
+
WHEN OLD.depth = 0
|
|
36385
|
+
BEGIN
|
|
36386
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
36387
|
+
END;
|
|
36388
|
+
`);
|
|
36389
|
+
}
|
|
36390
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
36391
|
+
if (safetyExists) {
|
|
36392
|
+
db.exec(`
|
|
36393
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
36394
|
+
AFTER INSERT ON memory_content_safety
|
|
36395
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
36396
|
+
BEGIN
|
|
36397
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36398
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
36399
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
36400
|
+
END;
|
|
36401
|
+
|
|
36402
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
36403
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
36404
|
+
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)
|
|
36405
|
+
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)
|
|
36406
|
+
BEGIN
|
|
36407
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36408
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
36409
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
36410
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
36411
|
+
END;
|
|
36412
|
+
`);
|
|
36413
|
+
}
|
|
36414
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
36415
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
36416
|
+
if (!exists)
|
|
36417
|
+
continue;
|
|
36418
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
36419
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
36420
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
36421
|
+
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";
|
|
36422
|
+
db.exec(`
|
|
36423
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
36424
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
36425
|
+
BEGIN
|
|
36426
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
36427
|
+
END;
|
|
36428
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
36429
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
36430
|
+
WHEN ${lifecycleWhen}
|
|
36431
|
+
BEGIN
|
|
36432
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
36433
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
36434
|
+
END;
|
|
36435
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
36436
|
+
AFTER DELETE ON ${table}
|
|
36437
|
+
BEGIN
|
|
36438
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
36439
|
+
END;
|
|
36440
|
+
`);
|
|
36441
|
+
}
|
|
36442
|
+
}
|
|
35919
36443
|
var MIGRATIONS2 = [
|
|
35920
36444
|
{
|
|
35921
36445
|
version: 1,
|
|
35922
36446
|
name: "baseline",
|
|
35923
|
-
up:
|
|
36447
|
+
up: up151,
|
|
35924
36448
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
35925
36449
|
},
|
|
35926
36450
|
{
|
|
@@ -36009,7 +36533,7 @@ var MIGRATIONS2 = [
|
|
|
36009
36533
|
{
|
|
36010
36534
|
version: 14,
|
|
36011
36535
|
name: "telemetry",
|
|
36012
|
-
up:
|
|
36536
|
+
up: up1410,
|
|
36013
36537
|
artifacts: { tables: ["telemetry_events"] }
|
|
36014
36538
|
},
|
|
36015
36539
|
{
|
|
@@ -37065,6 +37589,60 @@ var MIGRATIONS2 = [
|
|
|
37065
37589
|
name: "dreaming-evidence-reviews",
|
|
37066
37590
|
up: up1452,
|
|
37067
37591
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
37592
|
+
},
|
|
37593
|
+
{
|
|
37594
|
+
version: 146,
|
|
37595
|
+
name: "source-transcript-import",
|
|
37596
|
+
up: up1462,
|
|
37597
|
+
artifacts: {
|
|
37598
|
+
tables: [
|
|
37599
|
+
"source_import_jobs",
|
|
37600
|
+
"source_import_files",
|
|
37601
|
+
"source_import_records",
|
|
37602
|
+
"transcript_import_conversations",
|
|
37603
|
+
"source_import_record_attempts"
|
|
37604
|
+
],
|
|
37605
|
+
columns: [
|
|
37606
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
37607
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
37608
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
37609
|
+
]
|
|
37610
|
+
}
|
|
37611
|
+
},
|
|
37612
|
+
{
|
|
37613
|
+
version: 147,
|
|
37614
|
+
name: "source-import-replay-file-slots",
|
|
37615
|
+
up: up1472,
|
|
37616
|
+
artifacts: { tables: ["source_import_files"] }
|
|
37617
|
+
},
|
|
37618
|
+
{
|
|
37619
|
+
version: 148,
|
|
37620
|
+
name: "source-import-attempt-provenance",
|
|
37621
|
+
up: up1482,
|
|
37622
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
37623
|
+
},
|
|
37624
|
+
{
|
|
37625
|
+
version: 149,
|
|
37626
|
+
name: "transcript-import-state-machine",
|
|
37627
|
+
up: up1492,
|
|
37628
|
+
artifacts: {
|
|
37629
|
+
columns: [
|
|
37630
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
37631
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
37632
|
+
{ table: "source_import_files", column: "error" }
|
|
37633
|
+
]
|
|
37634
|
+
}
|
|
37635
|
+
},
|
|
37636
|
+
{
|
|
37637
|
+
version: 150,
|
|
37638
|
+
name: "memory-head-freshness",
|
|
37639
|
+
up: up1502,
|
|
37640
|
+
artifacts: {
|
|
37641
|
+
columns: [
|
|
37642
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
37643
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
37644
|
+
]
|
|
37645
|
+
}
|
|
37068
37646
|
}
|
|
37069
37647
|
];
|
|
37070
37648
|
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-openclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.217.3",
|
|
4
4
|
"description": "Signet connector for OpenClaw - configures workspace and memory hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"test": "bun test"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@signetai/connector-base": "0.
|
|
29
|
-
"@signetai/core": "0.
|
|
28
|
+
"@signetai/connector-base": "0.217.3",
|
|
29
|
+
"@signetai/core": "0.217.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|