@signetai/connector-gemini 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
|
@@ -16179,6 +16179,241 @@ function up145(db) {
|
|
|
16179
16179
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
16180
16180
|
`);
|
|
16181
16181
|
}
|
|
16182
|
+
function up146(db) {
|
|
16183
|
+
db.exec(`
|
|
16184
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
16185
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
16186
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
16187
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
16188
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
16189
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
16190
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
16191
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16192
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
16193
|
+
);
|
|
16194
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
16195
|
+
|
|
16196
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
16197
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16198
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
16199
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
16200
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
16201
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
16202
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
16203
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16204
|
+
UNIQUE(job_id, ordinal)
|
|
16205
|
+
);
|
|
16206
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
16207
|
+
|
|
16208
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
16209
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16210
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
16211
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
16212
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
16213
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
16214
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16215
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
16216
|
+
);
|
|
16217
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
16218
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
16219
|
+
|
|
16220
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
16221
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
16222
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
16223
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
16224
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
16225
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16226
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
16227
|
+
);
|
|
16228
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
16229
|
+
|
|
16230
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
16231
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
16232
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
16233
|
+
);
|
|
16234
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
16235
|
+
`);
|
|
16236
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
16237
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
16238
|
+
if (exists == null)
|
|
16239
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
16240
|
+
}
|
|
16241
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
16242
|
+
}
|
|
16243
|
+
function up147(db) {
|
|
16244
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
16245
|
+
}
|
|
16246
|
+
function up148(db) {
|
|
16247
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
16248
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
16249
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
function up149(db) {
|
|
16253
|
+
const addColumn = (table, column, definition) => {
|
|
16254
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
16255
|
+
if (exists == null)
|
|
16256
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16257
|
+
};
|
|
16258
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
16259
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
16260
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
16261
|
+
}
|
|
16262
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
16263
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
16264
|
+
if (!columns.some((row) => row.name === column))
|
|
16265
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16266
|
+
}
|
|
16267
|
+
function up150(db) {
|
|
16268
|
+
addColumnIfMissing28(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
16269
|
+
addColumnIfMissing28(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
16270
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
16271
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
16272
|
+
db.exec(`
|
|
16273
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
16274
|
+
AFTER INSERT ON dreaming_passes
|
|
16275
|
+
WHEN NEW.mode = 'incremental-content'
|
|
16276
|
+
BEGIN
|
|
16277
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
16278
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
16279
|
+
UPDATE dreaming_passes
|
|
16280
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
16281
|
+
WHERE id = NEW.id;
|
|
16282
|
+
END;
|
|
16283
|
+
|
|
16284
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
16285
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
16286
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
16287
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
16288
|
+
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
|
|
16289
|
+
BEGIN
|
|
16290
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16291
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16292
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
16293
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16294
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16295
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
16296
|
+
END;
|
|
16297
|
+
|
|
16298
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
16299
|
+
AFTER DELETE ON memories
|
|
16300
|
+
BEGIN
|
|
16301
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16302
|
+
WHERE agent_id = OLD.agent_id
|
|
16303
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
16304
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16305
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16306
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
16307
|
+
END;
|
|
16308
|
+
|
|
16309
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
16310
|
+
AFTER DELETE ON agents
|
|
16311
|
+
BEGIN
|
|
16312
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16313
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
16314
|
+
END;
|
|
16315
|
+
|
|
16316
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
16317
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
16318
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
16319
|
+
BEGIN
|
|
16320
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16321
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
16322
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16323
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
16324
|
+
END;
|
|
16325
|
+
`);
|
|
16326
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
16327
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16328
|
+
if (!exists)
|
|
16329
|
+
continue;
|
|
16330
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
16331
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
16332
|
+
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" : ""}`;
|
|
16333
|
+
db.exec(`
|
|
16334
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16335
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16336
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
16337
|
+
BEGIN
|
|
16338
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16339
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16340
|
+
END;
|
|
16341
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16342
|
+
AFTER DELETE ON ${table}
|
|
16343
|
+
BEGIN
|
|
16344
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16345
|
+
END;
|
|
16346
|
+
`);
|
|
16347
|
+
}
|
|
16348
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
16349
|
+
db.exec(`
|
|
16350
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
16351
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
16352
|
+
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)
|
|
16353
|
+
BEGIN
|
|
16354
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16355
|
+
END;
|
|
16356
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
16357
|
+
AFTER DELETE ON session_summaries
|
|
16358
|
+
WHEN OLD.depth = 0
|
|
16359
|
+
BEGIN
|
|
16360
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16361
|
+
END;
|
|
16362
|
+
`);
|
|
16363
|
+
}
|
|
16364
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
16365
|
+
if (safetyExists) {
|
|
16366
|
+
db.exec(`
|
|
16367
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
16368
|
+
AFTER INSERT ON memory_content_safety
|
|
16369
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
16370
|
+
BEGIN
|
|
16371
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16372
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
16373
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
16374
|
+
END;
|
|
16375
|
+
|
|
16376
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
16377
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
16378
|
+
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)
|
|
16379
|
+
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)
|
|
16380
|
+
BEGIN
|
|
16381
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16382
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16383
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16384
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
16385
|
+
END;
|
|
16386
|
+
`);
|
|
16387
|
+
}
|
|
16388
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
16389
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16390
|
+
if (!exists)
|
|
16391
|
+
continue;
|
|
16392
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
16393
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
16394
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
16395
|
+
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";
|
|
16396
|
+
db.exec(`
|
|
16397
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
16398
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
16399
|
+
BEGIN
|
|
16400
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
16401
|
+
END;
|
|
16402
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16403
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16404
|
+
WHEN ${lifecycleWhen}
|
|
16405
|
+
BEGIN
|
|
16406
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16407
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16408
|
+
END;
|
|
16409
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16410
|
+
AFTER DELETE ON ${table}
|
|
16411
|
+
BEGIN
|
|
16412
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16413
|
+
END;
|
|
16414
|
+
`);
|
|
16415
|
+
}
|
|
16416
|
+
}
|
|
16182
16417
|
var MIGRATIONS = [
|
|
16183
16418
|
{
|
|
16184
16419
|
version: 1,
|
|
@@ -17328,6 +17563,60 @@ var MIGRATIONS = [
|
|
|
17328
17563
|
name: "dreaming-evidence-reviews",
|
|
17329
17564
|
up: up145,
|
|
17330
17565
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
17566
|
+
},
|
|
17567
|
+
{
|
|
17568
|
+
version: 146,
|
|
17569
|
+
name: "source-transcript-import",
|
|
17570
|
+
up: up146,
|
|
17571
|
+
artifacts: {
|
|
17572
|
+
tables: [
|
|
17573
|
+
"source_import_jobs",
|
|
17574
|
+
"source_import_files",
|
|
17575
|
+
"source_import_records",
|
|
17576
|
+
"transcript_import_conversations",
|
|
17577
|
+
"source_import_record_attempts"
|
|
17578
|
+
],
|
|
17579
|
+
columns: [
|
|
17580
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
17581
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
17582
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
17583
|
+
]
|
|
17584
|
+
}
|
|
17585
|
+
},
|
|
17586
|
+
{
|
|
17587
|
+
version: 147,
|
|
17588
|
+
name: "source-import-replay-file-slots",
|
|
17589
|
+
up: up147,
|
|
17590
|
+
artifacts: { tables: ["source_import_files"] }
|
|
17591
|
+
},
|
|
17592
|
+
{
|
|
17593
|
+
version: 148,
|
|
17594
|
+
name: "source-import-attempt-provenance",
|
|
17595
|
+
up: up148,
|
|
17596
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
17597
|
+
},
|
|
17598
|
+
{
|
|
17599
|
+
version: 149,
|
|
17600
|
+
name: "transcript-import-state-machine",
|
|
17601
|
+
up: up149,
|
|
17602
|
+
artifacts: {
|
|
17603
|
+
columns: [
|
|
17604
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
17605
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
17606
|
+
{ table: "source_import_files", column: "error" }
|
|
17607
|
+
]
|
|
17608
|
+
}
|
|
17609
|
+
},
|
|
17610
|
+
{
|
|
17611
|
+
version: 150,
|
|
17612
|
+
name: "memory-head-freshness",
|
|
17613
|
+
up: up150,
|
|
17614
|
+
artifacts: {
|
|
17615
|
+
columns: [
|
|
17616
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
17617
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
17618
|
+
]
|
|
17619
|
+
}
|
|
17331
17620
|
}
|
|
17332
17621
|
];
|
|
17333
17622
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -29303,7 +29592,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
29303
29592
|
return true;
|
|
29304
29593
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
29305
29594
|
}
|
|
29306
|
-
function
|
|
29595
|
+
function up151(db) {
|
|
29307
29596
|
db.exec(`
|
|
29308
29597
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
29309
29598
|
version INTEGER PRIMARY KEY,
|
|
@@ -29396,27 +29685,27 @@ function hasColumn26(db, table, column) {
|
|
|
29396
29685
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29397
29686
|
return rows.some((r3) => r3.name === column);
|
|
29398
29687
|
}
|
|
29399
|
-
function
|
|
29688
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
29400
29689
|
if (!hasColumn26(db, table, column)) {
|
|
29401
29690
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29402
29691
|
}
|
|
29403
29692
|
}
|
|
29404
29693
|
function up210(db) {
|
|
29405
|
-
|
|
29406
|
-
|
|
29407
|
-
|
|
29408
|
-
|
|
29409
|
-
|
|
29410
|
-
|
|
29411
|
-
|
|
29412
|
-
|
|
29413
|
-
|
|
29414
|
-
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
|
|
29418
|
-
|
|
29419
|
-
|
|
29694
|
+
addColumnIfMissing29(db, "memories", "content_hash", "TEXT");
|
|
29695
|
+
addColumnIfMissing29(db, "memories", "normalized_content", "TEXT");
|
|
29696
|
+
addColumnIfMissing29(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
29697
|
+
addColumnIfMissing29(db, "memories", "deleted_at", "TEXT");
|
|
29698
|
+
addColumnIfMissing29(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
29699
|
+
addColumnIfMissing29(db, "memories", "embedding_model", "TEXT");
|
|
29700
|
+
addColumnIfMissing29(db, "memories", "extraction_model", "TEXT");
|
|
29701
|
+
addColumnIfMissing29(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
29702
|
+
addColumnIfMissing29(db, "memories", "who", "TEXT");
|
|
29703
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
29704
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
29705
|
+
addColumnIfMissing29(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
29706
|
+
addColumnIfMissing29(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
29707
|
+
addColumnIfMissing29(db, "memories", "last_accessed", "TEXT");
|
|
29708
|
+
addColumnIfMissing29(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
29420
29709
|
db.exec(`
|
|
29421
29710
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
29422
29711
|
id TEXT PRIMARY KEY,
|
|
@@ -29512,7 +29801,7 @@ function up210(db) {
|
|
|
29512
29801
|
ON memory_entity_mentions(entity_id);
|
|
29513
29802
|
`);
|
|
29514
29803
|
}
|
|
29515
|
-
function
|
|
29804
|
+
function addColumnIfMissing210(db, table, column, definition) {
|
|
29516
29805
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29517
29806
|
if (rows.some((r3) => r3.name === column))
|
|
29518
29807
|
return false;
|
|
@@ -29520,8 +29809,8 @@ function addColumnIfMissing29(db, table, column, definition) {
|
|
|
29520
29809
|
return true;
|
|
29521
29810
|
}
|
|
29522
29811
|
function up310(db) {
|
|
29523
|
-
|
|
29524
|
-
|
|
29812
|
+
addColumnIfMissing210(db, "memories", "why", "TEXT");
|
|
29813
|
+
addColumnIfMissing210(db, "memories", "project", "TEXT");
|
|
29525
29814
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
29526
29815
|
db.exec(`
|
|
29527
29816
|
UPDATE memories
|
|
@@ -29813,7 +30102,7 @@ function up1310(db) {
|
|
|
29813
30102
|
addColumnIfMissing52(db, "memories", "source_path", "TEXT");
|
|
29814
30103
|
addColumnIfMissing52(db, "memories", "source_section", "TEXT");
|
|
29815
30104
|
}
|
|
29816
|
-
function
|
|
30105
|
+
function up1410(db) {
|
|
29817
30106
|
db.exec(`
|
|
29818
30107
|
CREATE TABLE IF NOT EXISTS telemetry_events (
|
|
29819
30108
|
id TEXT PRIMARY KEY,
|
|
@@ -34076,11 +34365,246 @@ function up1452(db) {
|
|
|
34076
34365
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
34077
34366
|
`);
|
|
34078
34367
|
}
|
|
34368
|
+
function up1462(db) {
|
|
34369
|
+
db.exec(`
|
|
34370
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
34371
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
34372
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
34373
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
34374
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
34375
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
34376
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
34377
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34378
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
34379
|
+
);
|
|
34380
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
34381
|
+
|
|
34382
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
34383
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34384
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
34385
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
34386
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
34387
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
34388
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
34389
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34390
|
+
UNIQUE(job_id, ordinal)
|
|
34391
|
+
);
|
|
34392
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
34393
|
+
|
|
34394
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
34395
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34396
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
34397
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
34398
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
34399
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
34400
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34401
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
34402
|
+
);
|
|
34403
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
34404
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
34405
|
+
|
|
34406
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
34407
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
34408
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
34409
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
34410
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
34411
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34412
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
34413
|
+
);
|
|
34414
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
34415
|
+
|
|
34416
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
34417
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
34418
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
34419
|
+
);
|
|
34420
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
34421
|
+
`);
|
|
34422
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
34423
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
34424
|
+
if (exists == null)
|
|
34425
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
34426
|
+
}
|
|
34427
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
34428
|
+
}
|
|
34429
|
+
function up1472(db) {
|
|
34430
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
34431
|
+
}
|
|
34432
|
+
function up1482(db) {
|
|
34433
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
34434
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
34435
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
34436
|
+
}
|
|
34437
|
+
}
|
|
34438
|
+
function up1492(db) {
|
|
34439
|
+
const addColumn = (table, column, definition) => {
|
|
34440
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
34441
|
+
if (exists == null)
|
|
34442
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34443
|
+
};
|
|
34444
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
34445
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
34446
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
34447
|
+
}
|
|
34448
|
+
function addColumnIfMissing282(db, table, column, definition) {
|
|
34449
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
34450
|
+
if (!columns.some((row) => row.name === column))
|
|
34451
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34452
|
+
}
|
|
34453
|
+
function up1502(db) {
|
|
34454
|
+
addColumnIfMissing282(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
34455
|
+
addColumnIfMissing282(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
34456
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
34457
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
34458
|
+
db.exec(`
|
|
34459
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
34460
|
+
AFTER INSERT ON dreaming_passes
|
|
34461
|
+
WHEN NEW.mode = 'incremental-content'
|
|
34462
|
+
BEGIN
|
|
34463
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
34464
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
34465
|
+
UPDATE dreaming_passes
|
|
34466
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
34467
|
+
WHERE id = NEW.id;
|
|
34468
|
+
END;
|
|
34469
|
+
|
|
34470
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
34471
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
34472
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
34473
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
34474
|
+
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
|
|
34475
|
+
BEGIN
|
|
34476
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34477
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34478
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
34479
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34480
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34481
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
34482
|
+
END;
|
|
34483
|
+
|
|
34484
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
34485
|
+
AFTER DELETE ON memories
|
|
34486
|
+
BEGIN
|
|
34487
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34488
|
+
WHERE agent_id = OLD.agent_id
|
|
34489
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
34490
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34491
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34492
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
34493
|
+
END;
|
|
34494
|
+
|
|
34495
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
34496
|
+
AFTER DELETE ON agents
|
|
34497
|
+
BEGIN
|
|
34498
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34499
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
34500
|
+
END;
|
|
34501
|
+
|
|
34502
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
34503
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
34504
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
34505
|
+
BEGIN
|
|
34506
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34507
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
34508
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34509
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
34510
|
+
END;
|
|
34511
|
+
`);
|
|
34512
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
34513
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34514
|
+
if (!exists)
|
|
34515
|
+
continue;
|
|
34516
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
34517
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
34518
|
+
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" : ""}`;
|
|
34519
|
+
db.exec(`
|
|
34520
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34521
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34522
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
34523
|
+
BEGIN
|
|
34524
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34525
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34526
|
+
END;
|
|
34527
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34528
|
+
AFTER DELETE ON ${table}
|
|
34529
|
+
BEGIN
|
|
34530
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34531
|
+
END;
|
|
34532
|
+
`);
|
|
34533
|
+
}
|
|
34534
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
34535
|
+
db.exec(`
|
|
34536
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
34537
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
34538
|
+
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)
|
|
34539
|
+
BEGIN
|
|
34540
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34541
|
+
END;
|
|
34542
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
34543
|
+
AFTER DELETE ON session_summaries
|
|
34544
|
+
WHEN OLD.depth = 0
|
|
34545
|
+
BEGIN
|
|
34546
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34547
|
+
END;
|
|
34548
|
+
`);
|
|
34549
|
+
}
|
|
34550
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
34551
|
+
if (safetyExists) {
|
|
34552
|
+
db.exec(`
|
|
34553
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
34554
|
+
AFTER INSERT ON memory_content_safety
|
|
34555
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
34556
|
+
BEGIN
|
|
34557
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34558
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
34559
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
34560
|
+
END;
|
|
34561
|
+
|
|
34562
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
34563
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
34564
|
+
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)
|
|
34565
|
+
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)
|
|
34566
|
+
BEGIN
|
|
34567
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34568
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34569
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34570
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
34571
|
+
END;
|
|
34572
|
+
`);
|
|
34573
|
+
}
|
|
34574
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
34575
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34576
|
+
if (!exists)
|
|
34577
|
+
continue;
|
|
34578
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
34579
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
34580
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
34581
|
+
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";
|
|
34582
|
+
db.exec(`
|
|
34583
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
34584
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
34585
|
+
BEGIN
|
|
34586
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
34587
|
+
END;
|
|
34588
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34589
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34590
|
+
WHEN ${lifecycleWhen}
|
|
34591
|
+
BEGIN
|
|
34592
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34593
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34594
|
+
END;
|
|
34595
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34596
|
+
AFTER DELETE ON ${table}
|
|
34597
|
+
BEGIN
|
|
34598
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34599
|
+
END;
|
|
34600
|
+
`);
|
|
34601
|
+
}
|
|
34602
|
+
}
|
|
34079
34603
|
var MIGRATIONS2 = [
|
|
34080
34604
|
{
|
|
34081
34605
|
version: 1,
|
|
34082
34606
|
name: "baseline",
|
|
34083
|
-
up:
|
|
34607
|
+
up: up151,
|
|
34084
34608
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
34085
34609
|
},
|
|
34086
34610
|
{
|
|
@@ -34169,7 +34693,7 @@ var MIGRATIONS2 = [
|
|
|
34169
34693
|
{
|
|
34170
34694
|
version: 14,
|
|
34171
34695
|
name: "telemetry",
|
|
34172
|
-
up:
|
|
34696
|
+
up: up1410,
|
|
34173
34697
|
artifacts: { tables: ["telemetry_events"] }
|
|
34174
34698
|
},
|
|
34175
34699
|
{
|
|
@@ -35225,6 +35749,60 @@ var MIGRATIONS2 = [
|
|
|
35225
35749
|
name: "dreaming-evidence-reviews",
|
|
35226
35750
|
up: up1452,
|
|
35227
35751
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
35752
|
+
},
|
|
35753
|
+
{
|
|
35754
|
+
version: 146,
|
|
35755
|
+
name: "source-transcript-import",
|
|
35756
|
+
up: up1462,
|
|
35757
|
+
artifacts: {
|
|
35758
|
+
tables: [
|
|
35759
|
+
"source_import_jobs",
|
|
35760
|
+
"source_import_files",
|
|
35761
|
+
"source_import_records",
|
|
35762
|
+
"transcript_import_conversations",
|
|
35763
|
+
"source_import_record_attempts"
|
|
35764
|
+
],
|
|
35765
|
+
columns: [
|
|
35766
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
35767
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
35768
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
35769
|
+
]
|
|
35770
|
+
}
|
|
35771
|
+
},
|
|
35772
|
+
{
|
|
35773
|
+
version: 147,
|
|
35774
|
+
name: "source-import-replay-file-slots",
|
|
35775
|
+
up: up1472,
|
|
35776
|
+
artifacts: { tables: ["source_import_files"] }
|
|
35777
|
+
},
|
|
35778
|
+
{
|
|
35779
|
+
version: 148,
|
|
35780
|
+
name: "source-import-attempt-provenance",
|
|
35781
|
+
up: up1482,
|
|
35782
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
35783
|
+
},
|
|
35784
|
+
{
|
|
35785
|
+
version: 149,
|
|
35786
|
+
name: "transcript-import-state-machine",
|
|
35787
|
+
up: up1492,
|
|
35788
|
+
artifacts: {
|
|
35789
|
+
columns: [
|
|
35790
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
35791
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
35792
|
+
{ table: "source_import_files", column: "error" }
|
|
35793
|
+
]
|
|
35794
|
+
}
|
|
35795
|
+
},
|
|
35796
|
+
{
|
|
35797
|
+
version: 150,
|
|
35798
|
+
name: "memory-head-freshness",
|
|
35799
|
+
up: up1502,
|
|
35800
|
+
artifacts: {
|
|
35801
|
+
columns: [
|
|
35802
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
35803
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
35804
|
+
]
|
|
35805
|
+
}
|
|
35228
35806
|
}
|
|
35229
35807
|
];
|
|
35230
35808
|
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-gemini",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.217.1",
|
|
4
4
|
"description": "Signet connector for Gemini CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@signetai/connector-base": "0.
|
|
28
|
-
"@signetai/core": "0.
|
|
27
|
+
"@signetai/connector-base": "0.217.1",
|
|
28
|
+
"@signetai/core": "0.217.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|