@signetai/core 0.221.8 → 0.221.9

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 CHANGED
@@ -11713,6 +11713,68 @@ function isDaemonDerivedMemorySourceType(sourceType) {
11713
11713
  return sourceType !== null && sourceType !== undefined && DAEMON_DERIVED_MEMORY_SOURCE_TYPES.includes(sourceType);
11714
11714
  }
11715
11715
 
11716
+ // src/migrations/151-transcript-import-bytes.ts
11717
+ function up(db) {
11718
+ const hasColumn = (table, column) => {
11719
+ const statement = db.prepare(`SELECT 1 FROM pragma_table_info('${table}') WHERE name = ?`);
11720
+ try {
11721
+ return statement.get(column) != null;
11722
+ } finally {
11723
+ statement.finalize?.();
11724
+ }
11725
+ };
11726
+ for (const [column, definition] of [
11727
+ ["upload_generation", "INTEGER NOT NULL DEFAULT 0"],
11728
+ ["upload_offset", "INTEGER NOT NULL DEFAULT 0"],
11729
+ ["upload_size", "INTEGER"],
11730
+ ["upload_digest", "TEXT NOT NULL DEFAULT ''"],
11731
+ ["checkpoint_line_number", "INTEGER NOT NULL DEFAULT 0"],
11732
+ ["reserved_bytes", "INTEGER NOT NULL DEFAULT 0"],
11733
+ ["original_path", "TEXT"],
11734
+ [
11735
+ "storage_state",
11736
+ "TEXT NOT NULL DEFAULT 'legacy' CHECK (storage_state IN ('legacy','uploading','sealed','purging','purged'))"
11737
+ ]
11738
+ ]) {
11739
+ if (!hasColumn("source_import_files", column))
11740
+ db.exec(`ALTER TABLE source_import_files ADD COLUMN ${column} ${definition}`);
11741
+ }
11742
+ if (!hasColumn("source_import_jobs", "retry_count"))
11743
+ db.exec("ALTER TABLE source_import_jobs ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0");
11744
+ if (!hasColumn("source_import_jobs", "cleanup_state"))
11745
+ db.exec("ALTER TABLE source_import_jobs ADD COLUMN cleanup_state TEXT NOT NULL DEFAULT 'idle'");
11746
+ if (!hasColumn("source_import_jobs", "retry_cursor"))
11747
+ db.exec("ALTER TABLE source_import_jobs ADD COLUMN retry_cursor TEXT NOT NULL DEFAULT ''");
11748
+ if (!hasColumn("source_import_jobs", "retry_requested"))
11749
+ db.exec("ALTER TABLE source_import_jobs ADD COLUMN retry_requested INTEGER NOT NULL DEFAULT 0");
11750
+ db.exec(`
11751
+ CREATE TABLE IF NOT EXISTS source_import_migrations (agent_id TEXT PRIMARY KEY, state TEXT NOT NULL DEFAULT 'pending', cursor TEXT NOT NULL DEFAULT '', error TEXT);
11752
+ CREATE TABLE IF NOT EXISTS source_import_migration_counts (agent_id TEXT NOT NULL, job_id TEXT NOT NULL, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0, duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(agent_id,job_id)) WITHOUT ROWID;
11753
+ CREATE TABLE IF NOT EXISTS source_import_migration_streams (agent_id TEXT NOT NULL, stem TEXT NOT NULL, PRIMARY KEY(agent_id,stem)) WITHOUT ROWID;
11754
+ INSERT OR IGNORE INTO source_import_migrations(agent_id) SELECT DISTINCT agent_id FROM source_import_files WHERE storage_state = 'legacy';
11755
+ CREATE TABLE IF NOT EXISTS source_import_capacity (id INTEGER PRIMARY KEY CHECK (id = 1), reserved_bytes INTEGER NOT NULL DEFAULT 0 CHECK (reserved_bytes >= 0));
11756
+ INSERT OR IGNORE INTO source_import_capacity(id) VALUES (1);
11757
+ CREATE TRIGGER IF NOT EXISTS source_import_capacity_update AFTER UPDATE OF reserved_bytes ON source_import_files
11758
+ BEGIN UPDATE source_import_capacity SET reserved_bytes = reserved_bytes - OLD.reserved_bytes + NEW.reserved_bytes WHERE id = 1; END;
11759
+ CREATE TRIGGER IF NOT EXISTS source_import_capacity_delete AFTER DELETE ON source_import_files
11760
+ BEGIN UPDATE source_import_capacity SET reserved_bytes = reserved_bytes - OLD.reserved_bytes WHERE id = 1; END;
11761
+ CREATE TABLE IF NOT EXISTS source_import_chunks (
11762
+ file_id TEXT NOT NULL REFERENCES source_import_files(id),
11763
+ agent_id TEXT NOT NULL, generation INTEGER NOT NULL, byte_offset INTEGER NOT NULL,
11764
+ checksum TEXT NOT NULL, content BLOB NOT NULL CHECK (length(content) BETWEEN 1 AND 65536),
11765
+ PRIMARY KEY (agent_id, file_id, generation, byte_offset)
11766
+ ) WITHOUT ROWID;
11767
+ CREATE INDEX IF NOT EXISTS idx_source_import_files_storage ON source_import_files(agent_id, storage_state, id);
11768
+ CREATE INDEX IF NOT EXISTS idx_source_import_cleanup ON source_import_jobs(agent_id,id) WHERE cleanup_state = 'pending';
11769
+ CREATE INDEX IF NOT EXISTS idx_source_import_records_file_pending ON source_import_records(agent_id, file_id, status, ordinal);
11770
+ CREATE INDEX IF NOT EXISTS idx_source_import_records_agent_cursor ON source_import_records(agent_id,id);
11771
+ CREATE INDEX IF NOT EXISTS idx_source_import_records_job_cursor ON source_import_records(job_id,agent_id,status,id);
11772
+ CREATE INDEX IF NOT EXISTS idx_source_import_files_agent_cursor ON source_import_files(agent_id,id);
11773
+ CREATE INDEX IF NOT EXISTS idx_session_transcripts_export ON session_transcripts(agent_id,created_at,session_key);
11774
+ CREATE INDEX IF NOT EXISTS idx_transcript_import_harness ON transcript_import_conversations(agent_id,harness);
11775
+ `);
11776
+ }
11777
+
11716
11778
  // src/fts-schema.ts
11717
11779
  var MEMORIES_FTS_TOKENIZER = "unicode61";
11718
11780
  var FTS_STATE_TABLE = "memories_fts_state";
@@ -11880,7 +11942,7 @@ function memoriesFtsNeedsTokenizerRepair(sql) {
11880
11942
  }
11881
11943
 
11882
11944
  // src/migrations/001-baseline.ts
11883
- function up(db) {
11945
+ function up2(db) {
11884
11946
  db.exec(`
11885
11947
  CREATE TABLE IF NOT EXISTS schema_migrations (
11886
11948
  version INTEGER PRIMARY KEY,
@@ -11980,7 +12042,7 @@ function addColumnIfMissing(db, table, column, definition) {
11980
12042
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11981
12043
  }
11982
12044
  }
11983
- function up2(db) {
12045
+ function up3(db) {
11984
12046
  addColumnIfMissing(db, "memories", "content_hash", "TEXT");
11985
12047
  addColumnIfMissing(db, "memories", "normalized_content", "TEXT");
11986
12048
  addColumnIfMissing(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
@@ -12100,7 +12162,7 @@ function addColumnIfMissing2(db, table, column, definition) {
12100
12162
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12101
12163
  return true;
12102
12164
  }
12103
- function up3(db) {
12165
+ function up4(db) {
12104
12166
  addColumnIfMissing2(db, "memories", "why", "TEXT");
12105
12167
  addColumnIfMissing2(db, "memories", "project", "TEXT");
12106
12168
  db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
@@ -12139,7 +12201,7 @@ function addColumnIfMissing3(db, table, column, definition) {
12139
12201
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12140
12202
  }
12141
12203
  }
12142
- function up4(db) {
12204
+ function up5(db) {
12143
12205
  addColumnIfMissing3(db, "memory_history", "actor_type", "TEXT");
12144
12206
  addColumnIfMissing3(db, "memory_history", "session_id", "TEXT");
12145
12207
  addColumnIfMissing3(db, "memory_history", "request_id", "TEXT");
@@ -12174,7 +12236,7 @@ function addColumnIfMissing4(db, table, column, definition) {
12174
12236
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12175
12237
  }
12176
12238
  }
12177
- function up5(db) {
12239
+ function up6(db) {
12178
12240
  addColumnIfMissing4(db, "entities", "canonical_name", "TEXT");
12179
12241
  addColumnIfMissing4(db, "entities", "mentions", "INTEGER DEFAULT 0");
12180
12242
  addColumnIfMissing4(db, "entities", "embedding", "BLOB");
@@ -12193,7 +12255,7 @@ function hasColumn4(db, table, column) {
12193
12255
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
12194
12256
  return rows.some((r) => r.name === column);
12195
12257
  }
12196
- function up6(db) {
12258
+ function up7(db) {
12197
12259
  if (!hasColumn4(db, "memories", "idempotency_key")) {
12198
12260
  db.exec("ALTER TABLE memories ADD COLUMN idempotency_key TEXT");
12199
12261
  }
@@ -12210,7 +12272,7 @@ function hasColumn5(db, table, column) {
12210
12272
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
12211
12273
  return rows.some((r) => r.name === column);
12212
12274
  }
12213
- function up7(db) {
12275
+ function up8(db) {
12214
12276
  db.exec(`
12215
12277
  CREATE TABLE IF NOT EXISTS documents (
12216
12278
  id TEXT PRIMARY KEY,
@@ -12269,7 +12331,7 @@ function up7(db) {
12269
12331
  }
12270
12332
 
12271
12333
  // src/migrations/008-embeddings-unique-hash.ts
12272
- function up8(db) {
12334
+ function up9(db) {
12273
12335
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='embeddings'").all();
12274
12336
  if (tables.length === 0)
12275
12337
  return;
@@ -12288,7 +12350,7 @@ function up8(db) {
12288
12350
  }
12289
12351
 
12290
12352
  // src/migrations/009-summary-jobs.ts
12291
- function up9(db) {
12353
+ function up10(db) {
12292
12354
  db.exec(`
12293
12355
  CREATE TABLE IF NOT EXISTS summary_jobs (
12294
12356
  id TEXT PRIMARY KEY,
@@ -12310,7 +12372,7 @@ function up9(db) {
12310
12372
  }
12311
12373
 
12312
12374
  // src/migrations/010-umap-cache.ts
12313
- function up10(db) {
12375
+ function up11(db) {
12314
12376
  db.exec(`
12315
12377
  CREATE TABLE IF NOT EXISTS umap_cache (
12316
12378
  id INTEGER PRIMARY KEY,
@@ -12323,7 +12385,7 @@ function up10(db) {
12323
12385
  }
12324
12386
 
12325
12387
  // src/migrations/011-session-scores.ts
12326
- function up11(db) {
12388
+ function up12(db) {
12327
12389
  db.exec(`
12328
12390
  CREATE TABLE IF NOT EXISTS session_scores (
12329
12391
  id TEXT PRIMARY KEY,
@@ -12345,7 +12407,7 @@ function up11(db) {
12345
12407
  }
12346
12408
 
12347
12409
  // src/migrations/012-scheduled-tasks.ts
12348
- function up12(db) {
12410
+ function up13(db) {
12349
12411
  db.exec(`
12350
12412
  CREATE TABLE IF NOT EXISTS scheduled_tasks (
12351
12413
  id TEXT PRIMARY KEY,
@@ -12388,7 +12450,7 @@ function addColumnIfMissing5(db, table, column, definition) {
12388
12450
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12389
12451
  }
12390
12452
  }
12391
- function up13(db) {
12453
+ function up14(db) {
12392
12454
  db.exec(`
12393
12455
  CREATE TABLE IF NOT EXISTS ingestion_jobs (
12394
12456
  id TEXT PRIMARY KEY,
@@ -12416,7 +12478,7 @@ function up13(db) {
12416
12478
  }
12417
12479
 
12418
12480
  // src/migrations/014-telemetry.ts
12419
- function up14(db) {
12481
+ function up15(db) {
12420
12482
  db.exec(`
12421
12483
  CREATE TABLE IF NOT EXISTS telemetry_events (
12422
12484
  id TEXT PRIMARY KEY,
@@ -12443,7 +12505,7 @@ function addColumnIfMissing6(db, table, column, definition) {
12443
12505
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12444
12506
  }
12445
12507
  }
12446
- function up15(db) {
12508
+ function up16(db) {
12447
12509
  db.exec(`
12448
12510
  CREATE TABLE IF NOT EXISTS session_memories (
12449
12511
  id TEXT PRIMARY KEY,
@@ -12472,7 +12534,7 @@ function up15(db) {
12472
12534
  }
12473
12535
 
12474
12536
  // src/migrations/016-session-checkpoints.ts
12475
- function up16(db) {
12537
+ function up17(db) {
12476
12538
  db.exec(`
12477
12539
  CREATE TABLE IF NOT EXISTS session_checkpoints (
12478
12540
  id TEXT PRIMARY KEY,
@@ -12496,7 +12558,7 @@ function up16(db) {
12496
12558
  }
12497
12559
 
12498
12560
  // src/migrations/017-task-skills.ts
12499
- function up17(db) {
12561
+ function up18(db) {
12500
12562
  const cols = db.prepare("PRAGMA table_info(scheduled_tasks)").all();
12501
12563
  const colNames = new Set(cols.flatMap((c) => typeof c.name === "string" ? [c.name] : []));
12502
12564
  if (!colNames.has("skill_name")) {
@@ -12509,7 +12571,7 @@ function up17(db) {
12509
12571
  }
12510
12572
 
12511
12573
  // src/migrations/018-skill-meta.ts
12512
- function up18(db) {
12574
+ function up19(db) {
12513
12575
  const existing = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='skill_meta'").get();
12514
12576
  if (existing)
12515
12577
  return;
@@ -12543,7 +12605,7 @@ function up18(db) {
12543
12605
  }
12544
12606
 
12545
12607
  // src/migrations/019-knowledge-structure.ts
12546
- function up19(db) {
12608
+ function up20(db) {
12547
12609
  const entityCols = db.prepare("PRAGMA table_info(entities)").all();
12548
12610
  const entityColNames = new Set(entityCols.flatMap((c) => typeof c.name === "string" ? [c.name] : []));
12549
12611
  if (!entityColNames.has("agent_id")) {
@@ -12630,7 +12692,7 @@ function addColumnIfMissing7(db, table, column, definition) {
12630
12692
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12631
12693
  }
12632
12694
  }
12633
- function up20(db) {
12695
+ function up21(db) {
12634
12696
  addColumnIfMissing7(db, "session_memories", "entity_slot", "INTEGER");
12635
12697
  addColumnIfMissing7(db, "session_memories", "aspect_slot", "INTEGER");
12636
12698
  addColumnIfMissing7(db, "session_memories", "is_constraint", "INTEGER NOT NULL DEFAULT 0");
@@ -12638,7 +12700,7 @@ function up20(db) {
12638
12700
  }
12639
12701
 
12640
12702
  // src/migrations/021-checkpoint-structural.ts
12641
- function up21(db) {
12703
+ function up22(db) {
12642
12704
  const columns = db.prepare("PRAGMA table_info(session_checkpoints)").all();
12643
12705
  const columnNames = new Set(columns.flatMap((column) => typeof column.name === "string" ? [column.name] : []));
12644
12706
  if (!columnNames.has("focal_entity_ids")) {
@@ -12665,17 +12727,17 @@ function addColumnIfMissing8(db, table, column, definition) {
12665
12727
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12666
12728
  }
12667
12729
  }
12668
- function up22(db) {
12730
+ function up23(db) {
12669
12731
  addColumnIfMissing8(db, "entities", "pinned", "INTEGER NOT NULL DEFAULT 0");
12670
12732
  addColumnIfMissing8(db, "entities", "pinned_at", "TEXT");
12671
12733
  db.exec("CREATE INDEX IF NOT EXISTS idx_entities_pinned ON entities(agent_id, pinned, pinned_at DESC)");
12672
12734
  }
12673
12735
 
12674
12736
  // src/migrations/023-predictor-columns.ts
12675
- function up23(_db) {}
12737
+ function up24(_db) {}
12676
12738
 
12677
12739
  // src/migrations/024-predictor-comparison-columns.ts
12678
- function up24(_db) {}
12740
+ function up25(_db) {}
12679
12741
 
12680
12742
  // src/migrations/025-agent-feedback.ts
12681
12743
  function addColumnIfMissing9(db, table, column, definition) {
@@ -12684,16 +12746,16 @@ function addColumnIfMissing9(db, table, column, definition) {
12684
12746
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12685
12747
  }
12686
12748
  }
12687
- function up25(db) {
12749
+ function up26(db) {
12688
12750
  addColumnIfMissing9(db, "session_memories", "agent_relevance_score", "REAL");
12689
12751
  addColumnIfMissing9(db, "session_memories", "agent_feedback_count", "INTEGER DEFAULT 0");
12690
12752
  }
12691
12753
 
12692
12754
  // src/migrations/026-predictor-training-pairs.ts
12693
- function up26(_db) {}
12755
+ function up27(_db) {}
12694
12756
 
12695
12757
  // src/migrations/027-backfill-canonical-names.ts
12696
- function up27(db) {
12758
+ function up28(db) {
12697
12759
  db.exec(`
12698
12760
  UPDATE entities
12699
12761
  SET canonical_name = REPLACE(REPLACE(REPLACE(
@@ -12704,7 +12766,7 @@ function up27(db) {
12704
12766
  }
12705
12767
 
12706
12768
  // src/migrations/028-lossless-retention.ts
12707
- function up28(db) {
12769
+ function up29(db) {
12708
12770
  db.exec(`
12709
12771
  CREATE TABLE IF NOT EXISTS memories_cold (
12710
12772
  archive_id TEXT PRIMARY KEY,
@@ -12743,7 +12805,7 @@ function up28(db) {
12743
12805
  }
12744
12806
 
12745
12807
  // src/migrations/029-session-summary-dag.ts
12746
- function up29(db) {
12808
+ function up30(db) {
12747
12809
  db.exec(`
12748
12810
  CREATE TABLE IF NOT EXISTS session_summaries (
12749
12811
  id TEXT PRIMARY KEY,
@@ -12790,7 +12852,7 @@ function up29(db) {
12790
12852
  }
12791
12853
 
12792
12854
  // src/migrations/030-nullable-memory-job-memory-id.ts
12793
- function up30(db) {
12855
+ function up31(db) {
12794
12856
  db.exec(`
12795
12857
  CREATE TABLE IF NOT EXISTS memory_jobs_new (
12796
12858
  id TEXT PRIMARY KEY,
@@ -12837,7 +12899,7 @@ function up30(db) {
12837
12899
  }
12838
12900
 
12839
12901
  // src/migrations/031-dependency-reason.ts
12840
- function up31(db) {
12902
+ function up32(db) {
12841
12903
  const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
12842
12904
  if (!depCols.some((c) => c.name === "reason")) {
12843
12905
  db.exec("ALTER TABLE entity_dependencies ADD COLUMN reason TEXT");
@@ -12849,7 +12911,7 @@ function up31(db) {
12849
12911
  }
12850
12912
 
12851
12913
  // src/migrations/032-embeddings-vector-column.ts
12852
- function up32(db) {
12914
+ function up33(db) {
12853
12915
  const cols = db.prepare("PRAGMA table_info(embeddings)").all();
12854
12916
  if (cols.length === 0)
12855
12917
  return;
@@ -12859,7 +12921,7 @@ function up32(db) {
12859
12921
  }
12860
12922
 
12861
12923
  // src/migrations/033-scope.ts
12862
- function up33(db) {
12924
+ function up34(db) {
12863
12925
  const cols = db.prepare("PRAGMA table_info(memories)").all();
12864
12926
  if (!cols.some((c) => c.name === "scope")) {
12865
12927
  db.exec("ALTER TABLE memories ADD COLUMN scope TEXT DEFAULT NULL");
@@ -12868,7 +12930,7 @@ function up33(db) {
12868
12930
  }
12869
12931
 
12870
12932
  // src/migrations/034-scope-aware-dedup.ts
12871
- function up34(db) {
12933
+ function up35(db) {
12872
12934
  db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
12873
12935
  db.exec(`
12874
12936
  CREATE UNIQUE INDEX idx_memories_content_hash_unique
@@ -12878,7 +12940,7 @@ function up34(db) {
12878
12940
  }
12879
12941
 
12880
12942
  // src/migrations/035-entity-fts.ts
12881
- function up35(db) {
12943
+ function up36(db) {
12882
12944
  db.exec(`
12883
12945
  CREATE VIRTUAL TABLE IF NOT EXISTS entities_fts USING fts5(
12884
12946
  name, canonical_name,
@@ -12912,7 +12974,7 @@ function up35(db) {
12912
12974
  }
12913
12975
 
12914
12976
  // src/migrations/036-dependency-confidence.ts
12915
- function up36(db) {
12977
+ function up37(db) {
12916
12978
  const cols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
12917
12979
  if (!cols.some((c) => c.name === "confidence")) {
12918
12980
  db.exec("ALTER TABLE entity_dependencies ADD COLUMN confidence REAL DEFAULT 0.7");
@@ -12920,7 +12982,7 @@ function up36(db) {
12920
12982
  }
12921
12983
 
12922
12984
  // src/migrations/037-entity-communities.ts
12923
- function up37(db) {
12985
+ function up38(db) {
12924
12986
  db.exec(`
12925
12987
  CREATE TABLE IF NOT EXISTS entity_communities (
12926
12988
  id TEXT PRIMARY KEY,
@@ -12940,7 +13002,7 @@ function up37(db) {
12940
13002
  }
12941
13003
 
12942
13004
  // src/migrations/038-memory-hints.ts
12943
- function up38(db) {
13005
+ function up39(db) {
12944
13006
  db.exec(`
12945
13007
  CREATE TABLE IF NOT EXISTS memory_hints (
12946
13008
  id TEXT PRIMARY KEY,
@@ -12982,7 +13044,7 @@ function up38(db) {
12982
13044
  }
12983
13045
 
12984
13046
  // src/migrations/039-dedup-entity-dependencies.ts
12985
- function up39(db) {
13047
+ function up40(db) {
12986
13048
  db.exec(`
12987
13049
  DELETE FROM entity_dependencies
12988
13050
  WHERE id NOT IN (
@@ -13002,7 +13064,7 @@ function up39(db) {
13002
13064
  }
13003
13065
 
13004
13066
  // src/migrations/040-session-transcripts.ts
13005
- function up40(db) {
13067
+ function up41(db) {
13006
13068
  db.exec(`
13007
13069
  CREATE TABLE IF NOT EXISTS session_transcripts (
13008
13070
  session_key TEXT PRIMARY KEY,
@@ -13027,7 +13089,7 @@ function addColumnIfMissing10(db, table, column, definition) {
13027
13089
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13028
13090
  }
13029
13091
  }
13030
- function up41(db) {
13092
+ function up42(db) {
13031
13093
  addColumnIfMissing10(db, "session_memories", "path_json", "TEXT");
13032
13094
  db.exec(`
13033
13095
  CREATE TABLE IF NOT EXISTS path_feedback_events (
@@ -13104,7 +13166,7 @@ function addColumnIfMissing11(db, table, column, definition) {
13104
13166
  return;
13105
13167
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13106
13168
  }
13107
- function up42(db) {
13169
+ function up43(db) {
13108
13170
  addColumnIfMissing11(db, "session_memories", "entity_slot", "INTEGER");
13109
13171
  addColumnIfMissing11(db, "session_memories", "aspect_slot", "INTEGER");
13110
13172
  addColumnIfMissing11(db, "session_memories", "is_constraint", "INTEGER NOT NULL DEFAULT 0");
@@ -13194,7 +13256,7 @@ function addColumnIfMissing12(db, table, column, definition) {
13194
13256
  return;
13195
13257
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13196
13258
  }
13197
- function up43(db) {
13259
+ function up44(db) {
13198
13260
  db.exec(`
13199
13261
  CREATE TABLE IF NOT EXISTS agents (
13200
13262
  id TEXT PRIMARY KEY,
@@ -13225,7 +13287,7 @@ function addColumnIfMissing13(db, table, column, definition) {
13225
13287
  return;
13226
13288
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13227
13289
  }
13228
- function up44(db) {
13290
+ function up45(db) {
13229
13291
  addColumnIfMissing13(db, "session_summaries", "source_type", "TEXT");
13230
13292
  addColumnIfMissing13(db, "session_summaries", "source_ref", "TEXT");
13231
13293
  addColumnIfMissing13(db, "session_summaries", "meta_json", "TEXT");
@@ -13253,7 +13315,7 @@ function addColumnIfMissing14(db, table, column, definition) {
13253
13315
  return;
13254
13316
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13255
13317
  }
13256
- function up45(db) {
13318
+ function up46(db) {
13257
13319
  addColumnIfMissing14(db, "session_transcripts", "updated_at", "TEXT");
13258
13320
  addColumnIfMissing14(db, "summary_jobs", "agent_id", "TEXT NOT NULL DEFAULT 'default'");
13259
13321
  addColumnIfMissing14(db, "session_scores", "agent_id", "TEXT NOT NULL DEFAULT 'default'");
@@ -13326,7 +13388,7 @@ function up45(db) {
13326
13388
  }
13327
13389
 
13328
13390
  // src/migrations/046-session-summary-uniqueness.ts
13329
- function up46(db) {
13391
+ function up47(db) {
13330
13392
  db.exec(`
13331
13393
  DROP INDEX IF EXISTS idx_summaries_session_depth;
13332
13394
 
@@ -13389,7 +13451,7 @@ function up46(db) {
13389
13451
  }
13390
13452
 
13391
13453
  // src/migrations/047-agent-scoped-temporal-uniqueness.ts
13392
- function up47(db) {
13454
+ function up48(db) {
13393
13455
  db.exec(`
13394
13456
  DROP TRIGGER IF EXISTS session_transcripts_fts_ai;
13395
13457
  DROP TRIGGER IF EXISTS session_transcripts_fts_ad;
@@ -13489,7 +13551,7 @@ function up47(db) {
13489
13551
  }
13490
13552
 
13491
13553
  // src/migrations/048-thread-heads.ts
13492
- function up48(db) {
13554
+ function up49(db) {
13493
13555
  db.exec(`
13494
13556
  CREATE TABLE IF NOT EXISTS memory_thread_heads (
13495
13557
  agent_id TEXT NOT NULL DEFAULT 'default',
@@ -13609,7 +13671,7 @@ function up48(db) {
13609
13671
  }
13610
13672
 
13611
13673
  // src/migrations/049-session-extract-cursors.ts
13612
- function up49(db) {
13674
+ function up50(db) {
13613
13675
  db.exec(`
13614
13676
  CREATE TABLE IF NOT EXISTS session_extract_cursors (
13615
13677
  session_key TEXT NOT NULL,
@@ -13628,7 +13690,7 @@ function hasTable(db, name) {
13628
13690
  WHERE type = 'table' AND name = ?
13629
13691
  LIMIT 1`).get(name) !== undefined;
13630
13692
  }
13631
- function up50(db) {
13693
+ function up51(db) {
13632
13694
  db.exec(`
13633
13695
  CREATE TABLE IF NOT EXISTS entity_dependency_history (
13634
13696
  id TEXT PRIMARY KEY,
@@ -13800,7 +13862,7 @@ function addColumnIfMissing15(db, table, column, definition) {
13800
13862
  return;
13801
13863
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13802
13864
  }
13803
- function up51(db) {
13865
+ function up52(db) {
13804
13866
  addColumnIfMissing15(db, "summary_jobs", "session_id", "TEXT");
13805
13867
  addColumnIfMissing15(db, "summary_jobs", "trigger", "TEXT NOT NULL DEFAULT 'session_end'");
13806
13868
  addColumnIfMissing15(db, "summary_jobs", "captured_at", "TEXT");
@@ -13894,7 +13956,7 @@ function up51(db) {
13894
13956
  }
13895
13957
 
13896
13958
  // src/migrations/052-mcp-invocations.ts
13897
- function up52(db) {
13959
+ function up53(db) {
13898
13960
  db.exec(`
13899
13961
  CREATE TABLE IF NOT EXISTS mcp_invocations (
13900
13962
  id TEXT PRIMARY KEY,
@@ -13913,7 +13975,7 @@ function up52(db) {
13913
13975
  }
13914
13976
 
13915
13977
  // src/migrations/053-skill-invocations.ts
13916
- function up53(db) {
13978
+ function up54(db) {
13917
13979
  db.exec(`
13918
13980
  CREATE TABLE IF NOT EXISTS skill_invocations (
13919
13981
  id TEXT PRIMARY KEY,
@@ -13931,7 +13993,7 @@ function up53(db) {
13931
13993
  }
13932
13994
 
13933
13995
  // src/migrations/054-task-agent-scope.ts
13934
- function up54(db) {
13996
+ function up55(db) {
13935
13997
  db.exec(`
13936
13998
  CREATE TABLE IF NOT EXISTS task_scope_hints (
13937
13999
  task_id TEXT PRIMARY KEY REFERENCES scheduled_tasks(id) ON DELETE CASCADE,
@@ -13964,7 +14026,7 @@ function up54(db) {
13964
14026
  }
13965
14027
 
13966
14028
  // src/migrations/055-dreaming-state.ts
13967
- function up55(db) {
14029
+ function up56(db) {
13968
14030
  db.exec(`
13969
14031
  CREATE TABLE IF NOT EXISTS dreaming_state (
13970
14032
  agent_id TEXT PRIMARY KEY NOT NULL,
@@ -14009,7 +14071,7 @@ function ensureMemoriesScopeColumns(db) {
14009
14071
  if (!names.has("scope"))
14010
14072
  db.exec("ALTER TABLE memories ADD COLUMN scope TEXT");
14011
14073
  }
14012
- function up56(db) {
14074
+ function up57(db) {
14013
14075
  ensureMemoriesScopeColumns(db);
14014
14076
  db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
14015
14077
  db.exec(`
@@ -14024,7 +14086,7 @@ function up56(db) {
14024
14086
  }
14025
14087
 
14026
14088
  // src/migrations/057-memories-fts-tokenizer-repair.ts
14027
- function up57(db) {
14089
+ function up58(db) {
14028
14090
  const sql = readMemoriesFtsSql(db);
14029
14091
  if (sql !== null && !memoriesFtsNeedsTokenizerRepair(sql))
14030
14092
  return;
@@ -14032,7 +14094,7 @@ function up57(db) {
14032
14094
  }
14033
14095
 
14034
14096
  // src/migrations/058-knowledge-graph-indices.ts
14035
- function up58(db) {
14097
+ function up59(db) {
14036
14098
  db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_order
14037
14099
  ON entities(agent_id, pinned DESC, pinned_at DESC, mentions DESC, updated_at DESC, name)`);
14038
14100
  db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_extracted_mentions
@@ -14041,7 +14103,7 @@ function up58(db) {
14041
14103
  }
14042
14104
 
14043
14105
  // src/migrations/059-entity-attribute-claim-key.ts
14044
- function up59(db) {
14106
+ function up60(db) {
14045
14107
  const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
14046
14108
  if (!cols.some((col) => col.name === "claim_key")) {
14047
14109
  db.exec("ALTER TABLE entity_attributes ADD COLUMN claim_key TEXT");
@@ -14052,7 +14114,7 @@ function up59(db) {
14052
14114
  }
14053
14115
 
14054
14116
  // src/migrations/060-entity-attribute-group-key.ts
14055
- function up60(db) {
14117
+ function up61(db) {
14056
14118
  const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
14057
14119
  if (!cols.some((col) => col.name === "group_key")) {
14058
14120
  db.exec("ALTER TABLE entity_attributes ADD COLUMN group_key TEXT");
@@ -14066,7 +14128,7 @@ function up60(db) {
14066
14128
  }
14067
14129
 
14068
14130
  // src/migrations/061-memory-artifact-source-mtime.ts
14069
- function up61(db) {
14131
+ function up62(db) {
14070
14132
  const cols = db.prepare("PRAGMA table_info(memory_artifacts)").all();
14071
14133
  if (cols.some((col) => col.name === "source_mtime_ms"))
14072
14134
  return;
@@ -14074,7 +14136,7 @@ function up61(db) {
14074
14136
  }
14075
14137
 
14076
14138
  // src/migrations/062-memory-artifact-soft-delete.ts
14077
- function up62(db) {
14139
+ function up63(db) {
14078
14140
  const cols = db.prepare("PRAGMA table_info(memory_artifacts)").all();
14079
14141
  const names = new Set(cols.map((col) => col.name));
14080
14142
  if (!names.has("is_deleted")) {
@@ -14090,7 +14152,7 @@ function up62(db) {
14090
14152
  }
14091
14153
 
14092
14154
  // src/migrations/063-content-only-memories-fts-update.ts
14093
- function up63(db) {
14155
+ function up64(db) {
14094
14156
  db.exec("DROP TRIGGER IF EXISTS memories_au");
14095
14157
  db.exec(`
14096
14158
  CREATE TRIGGER IF NOT EXISTS memories_au AFTER UPDATE OF content ON memories BEGIN
@@ -14110,7 +14172,7 @@ function addColumnIfMissing16(db, table, column, definition) {
14110
14172
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
14111
14173
  }
14112
14174
  }
14113
- function up64(db) {
14175
+ function up65(db) {
14114
14176
  for (const table of ["entities", "entity_communities", "entity_attributes", "entity_dependencies"]) {
14115
14177
  addColumnIfMissing16(db, table, "source_id", "TEXT");
14116
14178
  addColumnIfMissing16(db, table, "source_kind", "TEXT");
@@ -14132,7 +14194,7 @@ function hasColumn7(db, table, column) {
14132
14194
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
14133
14195
  return rows.some((row) => row.name === column);
14134
14196
  }
14135
- function up65(db) {
14197
+ function up66(db) {
14136
14198
  if (!hasTable2(db, "embeddings"))
14137
14199
  return;
14138
14200
  if (!hasColumn7(db, "embeddings", "agent_id")) {
@@ -14142,7 +14204,7 @@ function up65(db) {
14142
14204
  }
14143
14205
 
14144
14206
  // src/migrations/066-memory-search-telemetry.ts
14145
- function up66(db) {
14207
+ function up67(db) {
14146
14208
  db.exec(`
14147
14209
  CREATE TABLE IF NOT EXISTS memory_search_telemetry (
14148
14210
  id TEXT PRIMARY KEY,
@@ -14185,7 +14247,7 @@ function addColumnIfMissing17(db, table, column, definition) {
14185
14247
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
14186
14248
  }
14187
14249
  }
14188
- function up67(db) {
14250
+ function up68(db) {
14189
14251
  db.exec(`
14190
14252
  CREATE TABLE IF NOT EXISTS ontology_proposals (
14191
14253
  id TEXT PRIMARY KEY,
@@ -14230,7 +14292,7 @@ function up67(db) {
14230
14292
  }
14231
14293
 
14232
14294
  // src/migrations/068-daily-reflections.ts
14233
- function up68(db) {
14295
+ function up69(db) {
14234
14296
  db.exec(`
14235
14297
  CREATE TABLE IF NOT EXISTS daily_reflections (
14236
14298
  id TEXT PRIMARY KEY,
@@ -14259,7 +14321,7 @@ function up68(db) {
14259
14321
  }
14260
14322
 
14261
14323
  // src/migrations/069-daily-reflections-multiple-insights.ts
14262
- function up69(db) {
14324
+ function up70(db) {
14263
14325
  const cols = db.prepare("PRAGMA table_info(daily_reflections)").all();
14264
14326
  const colNames = new Set(cols.flatMap((c) => typeof c.name === "string" ? [c.name] : []));
14265
14327
  if (!colNames.has("content_key")) {
@@ -14298,7 +14360,7 @@ function backfillVersionRoots(db) {
14298
14360
  WHERE version_root_id IS NULL
14299
14361
  `);
14300
14362
  }
14301
- function up70(db) {
14363
+ function up71(db) {
14302
14364
  for (const table of ["entities", "entity_aspects", "entity_dependencies"]) {
14303
14365
  addColumnIfMissing18(db, table, "status", "TEXT NOT NULL DEFAULT 'active'");
14304
14366
  addColumnIfMissing18(db, table, "archived_at", "TEXT");
@@ -14335,7 +14397,7 @@ function up70(db) {
14335
14397
  }
14336
14398
 
14337
14399
  // src/migrations/071-epistemic-assertions.ts
14338
- function up71(db) {
14400
+ function up72(db) {
14339
14401
  db.exec(`
14340
14402
  CREATE TABLE IF NOT EXISTS epistemic_assertions (
14341
14403
  id TEXT PRIMARY KEY,
@@ -14393,7 +14455,7 @@ function ensureMemoriesScopeColumns2(db) {
14393
14455
  if (!names.has("runtime_path"))
14394
14456
  db.exec("ALTER TABLE memories ADD COLUMN runtime_path TEXT");
14395
14457
  }
14396
- function up72(db) {
14458
+ function up73(db) {
14397
14459
  ensureMemoriesScopeColumns2(db);
14398
14460
  db.exec("DROP INDEX IF EXISTS idx_memories_idempotency_key");
14399
14461
  db.exec(`
@@ -14409,7 +14471,7 @@ function up72(db) {
14409
14471
  }
14410
14472
 
14411
14473
  // src/migrations/073-recall-context-dedupe.ts
14412
- function up73(db) {
14474
+ function up74(db) {
14413
14475
  db.exec(`
14414
14476
  CREATE TABLE IF NOT EXISTS session_context_epochs (
14415
14477
  session_key TEXT NOT NULL,
@@ -14446,7 +14508,7 @@ function up73(db) {
14446
14508
  }
14447
14509
 
14448
14510
  // src/migrations/074-aggregate-memory-links.ts
14449
- function up74(db) {
14511
+ function up75(db) {
14450
14512
  db.exec(`
14451
14513
  CREATE TABLE IF NOT EXISTS aggregate_memory_sources (
14452
14514
  aggregate_memory_id TEXT NOT NULL,
@@ -14467,7 +14529,7 @@ function addColumnIfMissing19(db, table, column, definition) {
14467
14529
  return;
14468
14530
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
14469
14531
  }
14470
- function up75(db) {
14532
+ function up76(db) {
14471
14533
  addColumnIfMissing19(db, "memory_artifacts", "source_id", "TEXT");
14472
14534
  addColumnIfMissing19(db, "memory_artifacts", "source_root", "TEXT");
14473
14535
  addColumnIfMissing19(db, "memory_artifacts", "source_external_id", "TEXT");
@@ -14482,7 +14544,7 @@ function up75(db) {
14482
14544
  }
14483
14545
 
14484
14546
  // src/migrations/076-temporal-edges.ts
14485
- function up76(db) {
14547
+ function up77(db) {
14486
14548
  db.exec(`
14487
14549
  CREATE TABLE IF NOT EXISTS temporal_edges (
14488
14550
  id TEXT PRIMARY KEY,
@@ -14507,7 +14569,7 @@ function up76(db) {
14507
14569
  }
14508
14570
 
14509
14571
  // src/migrations/077-entity-aliases.ts
14510
- function up77(db) {
14572
+ function up78(db) {
14511
14573
  db.exec(`
14512
14574
  CREATE TABLE IF NOT EXISTS entity_aliases (
14513
14575
  id TEXT PRIMARY KEY,
@@ -14533,7 +14595,7 @@ function up77(db) {
14533
14595
  }
14534
14596
 
14535
14597
  // src/migrations/078-api-keys.ts
14536
- function up78(db) {
14598
+ function up79(db) {
14537
14599
  db.exec(`
14538
14600
  CREATE TABLE IF NOT EXISTS api_keys (
14539
14601
  id TEXT PRIMARY KEY,
@@ -14563,7 +14625,7 @@ function up78(db) {
14563
14625
  }
14564
14626
 
14565
14627
  // src/migrations/079-transcript-capture-jobs.ts
14566
- function up79(db) {
14628
+ function up80(db) {
14567
14629
  db.exec(`
14568
14630
  CREATE TABLE IF NOT EXISTS transcript_capture_jobs (
14569
14631
  id TEXT PRIMARY KEY,
@@ -14600,7 +14662,7 @@ function hasColumn10(db, table, column) {
14600
14662
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
14601
14663
  return rows.some((row) => row.name === column);
14602
14664
  }
14603
- function up80(db) {
14665
+ function up81(db) {
14604
14666
  if (!hasColumn10(db, "documents", "agent_id")) {
14605
14667
  db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
14606
14668
  }
@@ -14688,7 +14750,7 @@ function up80(db) {
14688
14750
  }
14689
14751
 
14690
14752
  // src/migrations/081-aggregate-evidence-sources.ts
14691
- function up81(db) {
14753
+ function up82(db) {
14692
14754
  db.exec(`
14693
14755
  CREATE TABLE IF NOT EXISTS aggregate_evidence_sources (
14694
14756
  aggregate_memory_id TEXT NOT NULL,
@@ -14712,7 +14774,7 @@ function hasColumn11(db, table, column) {
14712
14774
  return rows.some((row) => row.name === column);
14713
14775
  }
14714
14776
  var COLUMNS = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
14715
- function up82(db) {
14777
+ function up83(db) {
14716
14778
  for (const column of COLUMNS) {
14717
14779
  if (!hasColumn11(db, "skill_invocations", column)) {
14718
14780
  db.exec(`ALTER TABLE skill_invocations ADD COLUMN ${column} TEXT`);
@@ -14795,7 +14857,7 @@ function documentScopeColumnsPreservingExisting(db) {
14795
14857
  `);
14796
14858
  }
14797
14859
  try {
14798
- up80(db);
14860
+ up81(db);
14799
14861
  if (preserveAgentId) {
14800
14862
  db.exec(`
14801
14863
  UPDATE documents
@@ -14815,12 +14877,12 @@ function documentScopeColumnsPreservingExisting(db) {
14815
14877
  db.exec("DROP TABLE IF EXISTS temp.__signet_doc_project_guard");
14816
14878
  }
14817
14879
  }
14818
- function up83(db) {
14819
- up79(db);
14880
+ function up84(db) {
14881
+ up80(db);
14820
14882
  if (hasTable3(db, "documents")) {
14821
14883
  documentScopeColumnsPreservingExisting(db);
14822
14884
  }
14823
- up81(db);
14885
+ up82(db);
14824
14886
  addColumnIfMissing20(db, "memories", "superseded_by", "TEXT");
14825
14887
  addColumnIfMissing20(db, "memories", "superseded_at", "TEXT");
14826
14888
  addColumnIfMissing20(db, "memories", "superseded_reason", "TEXT");
@@ -14879,7 +14941,7 @@ function up83(db) {
14879
14941
  }
14880
14942
 
14881
14943
  // src/migrations/084-legacy-markdown-import-state.ts
14882
- function up84(db) {
14944
+ function up85(db) {
14883
14945
  db.exec(`
14884
14946
  CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
14885
14947
  path TEXT PRIMARY KEY,
@@ -14911,7 +14973,7 @@ function up84(db) {
14911
14973
  }
14912
14974
 
14913
14975
  // src/migrations/085-backfill-relations-to-dependencies.ts
14914
- function up85(db) {
14976
+ function up86(db) {
14915
14977
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
14916
14978
  const tableNames = new Set(tables.map((r) => String(r.name)));
14917
14979
  if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
@@ -14972,7 +15034,7 @@ function addColumnIfMissing21(db, table, column, definition) {
14972
15034
  return;
14973
15035
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
14974
15036
  }
14975
- function up86(db) {
15037
+ function up87(db) {
14976
15038
  addColumnIfMissing21(db, "summary_jobs", "content_hash", "TEXT");
14977
15039
  db.exec(`
14978
15040
  CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
@@ -14987,7 +15049,7 @@ function addColumnIfMissing22(db, table, column, definition) {
14987
15049
  return;
14988
15050
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
14989
15051
  }
14990
- function up87(db) {
15052
+ function up88(db) {
14991
15053
  addColumnIfMissing22(db, "summary_jobs", "boundary_reason", "TEXT");
14992
15054
  db.exec(`
14993
15055
  CREATE INDEX IF NOT EXISTS idx_summary_jobs_boundary_reason
@@ -14996,7 +15058,7 @@ function up87(db) {
14996
15058
  }
14997
15059
 
14998
15060
  // src/migrations/088-transcript-recovery-files.ts
14999
- function up88(db) {
15061
+ function up89(db) {
15000
15062
  db.exec(`
15001
15063
  CREATE TABLE IF NOT EXISTS transcript_recovery_files (
15002
15064
  agent_id TEXT NOT NULL,
@@ -15016,7 +15078,7 @@ function up88(db) {
15016
15078
  }
15017
15079
 
15018
15080
  // src/migrations/089-job-cancellations.ts
15019
- function up89(db) {
15081
+ function up90(db) {
15020
15082
  db.exec(`
15021
15083
  CREATE TABLE IF NOT EXISTS job_cancellations (
15022
15084
  id TEXT PRIMARY KEY,
@@ -15046,7 +15108,7 @@ function indexExists(db, table, indexName) {
15046
15108
  }
15047
15109
 
15048
15110
  // src/migrations/090-job-archive.ts
15049
- function up90(db) {
15111
+ function up91(db) {
15050
15112
  db.exec(`
15051
15113
  CREATE TABLE IF NOT EXISTS job_archive (
15052
15114
  id TEXT PRIMARY KEY,
@@ -15075,7 +15137,7 @@ function indexExists2(db, table, indexName) {
15075
15137
  }
15076
15138
 
15077
15139
  // src/migrations/091-embedding-index-generations.ts
15078
- function up91(db) {
15140
+ function up92(db) {
15079
15141
  db.exec(`
15080
15142
  CREATE TABLE IF NOT EXISTS embedding_index_state (
15081
15143
  id INTEGER PRIMARY KEY CHECK (id = 1),
@@ -15090,7 +15152,7 @@ function up91(db) {
15090
15152
  }
15091
15153
 
15092
15154
  // src/migrations/092-embedding-staging-store.ts
15093
- function up92(db) {
15155
+ function up93(db) {
15094
15156
  db.exec(`
15095
15157
  CREATE TABLE IF NOT EXISTS embeddings_staging (
15096
15158
  id TEXT PRIMARY KEY,
@@ -15111,7 +15173,7 @@ function up92(db) {
15111
15173
  }
15112
15174
 
15113
15175
  // src/migrations/093-dreaming-evidence-cursor.ts
15114
- function up93(db) {
15176
+ function up94(db) {
15115
15177
  const columns = db.prepare("PRAGMA table_info(dreaming_state)").all();
15116
15178
  if (!columns.some((column) => column.name === "evidence_cursor")) {
15117
15179
  db.exec("ALTER TABLE dreaming_state ADD COLUMN evidence_cursor TEXT");
@@ -15124,7 +15186,7 @@ function hasColumn13(db, table, column) {
15124
15186
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
15125
15187
  return rows.some((r) => r.name === column);
15126
15188
  }
15127
- function up94(db) {
15189
+ function up95(db) {
15128
15190
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = 'memories'").all();
15129
15191
  if (tables.length === 0)
15130
15192
  return;
@@ -15151,7 +15213,7 @@ function up94(db) {
15151
15213
  function hasColumn14(db, table, column) {
15152
15214
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15153
15215
  }
15154
- function up95(db) {
15216
+ function up96(db) {
15155
15217
  const hasMemories = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'memories'").get();
15156
15218
  if (!hasMemories || !hasColumn14(db, "memories", "memory_kind") || !hasColumn14(db, "memories", "type"))
15157
15219
  return;
@@ -15159,12 +15221,12 @@ function up95(db) {
15159
15221
  }
15160
15222
 
15161
15223
  // src/migrations/096-retire-legacy-ingestion.ts
15162
- function up96(db) {
15224
+ function up97(db) {
15163
15225
  db.exec("DROP TABLE IF EXISTS ingestion_jobs");
15164
15226
  }
15165
15227
 
15166
15228
  // src/migrations/097-dreaming-failure-backoff.ts
15167
- function up97(db) {
15229
+ function up98(db) {
15168
15230
  const columns = db.prepare("PRAGMA table_info(dreaming_state)").all();
15169
15231
  if (!columns.some((column) => column.name === "last_failure_at")) {
15170
15232
  db.exec("ALTER TABLE dreaming_state ADD COLUMN last_failure_at TEXT");
@@ -15173,7 +15235,7 @@ function up97(db) {
15173
15235
  }
15174
15236
 
15175
15237
  // src/migrations/098-dreaming-evidence-exclusions.ts
15176
- function up98(db) {
15238
+ function up99(db) {
15177
15239
  db.exec(`
15178
15240
  CREATE TABLE IF NOT EXISTS dreaming_evidence_exclusions (
15179
15241
  agent_id TEXT NOT NULL,
@@ -15192,7 +15254,7 @@ function up98(db) {
15192
15254
  }
15193
15255
 
15194
15256
  // src/migrations/099-dreaming-tool-calls.ts
15195
- function up99(db) {
15257
+ function up100(db) {
15196
15258
  db.exec(`
15197
15259
  CREATE TABLE IF NOT EXISTS dreaming_tool_calls (
15198
15260
  id TEXT PRIMARY KEY,
@@ -15214,7 +15276,7 @@ function up99(db) {
15214
15276
  }
15215
15277
 
15216
15278
  // src/migrations/100-dreaming-runbook.ts
15217
- function up100(db) {
15279
+ function up101(db) {
15218
15280
  const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
15219
15281
  if (!columns.some((column) => column.name === "evidence_window_json")) {
15220
15282
  db.exec("ALTER TABLE dreaming_passes ADD COLUMN evidence_window_json TEXT");
@@ -15225,7 +15287,7 @@ function up100(db) {
15225
15287
  }
15226
15288
 
15227
15289
  // src/migrations/101-dreaming-attention.ts
15228
- function up101(db) {
15290
+ function up102(db) {
15229
15291
  db.exec(`
15230
15292
  CREATE TABLE IF NOT EXISTS dreaming_attention (
15231
15293
  id TEXT PRIMARY KEY,
@@ -15249,7 +15311,7 @@ function up101(db) {
15249
15311
  function hasColumn15(db, table, column) {
15250
15312
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15251
15313
  }
15252
- function up102(db) {
15314
+ function up103(db) {
15253
15315
  const requiredMemoryColumns = [
15254
15316
  "content_hash",
15255
15317
  "normalized_content",
@@ -15302,7 +15364,7 @@ function up102(db) {
15302
15364
  }
15303
15365
 
15304
15366
  // src/migrations/103-semantic-memory-kind.ts
15305
- function up103(db) {
15367
+ function up104(db) {
15306
15368
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('memories', 'entity_attributes')").all();
15307
15369
  if (tables.length !== 2)
15308
15370
  return;
@@ -15327,7 +15389,7 @@ function tableExists(db, table) {
15327
15389
  function hasColumn16(db, table, column) {
15328
15390
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15329
15391
  }
15330
- function up104(db) {
15392
+ function up105(db) {
15331
15393
  db.exec(`
15332
15394
  CREATE TABLE IF NOT EXISTS derived_memory_sources (
15333
15395
  derived_memory_id TEXT NOT NULL,
@@ -15372,7 +15434,7 @@ function up104(db) {
15372
15434
  }
15373
15435
 
15374
15436
  // src/migrations/105-agent-scoped-entity-name.ts
15375
- function up105(db) {
15437
+ function up106(db) {
15376
15438
  db.exec(`
15377
15439
  DROP TRIGGER IF EXISTS entities_fts_ai;
15378
15440
  DROP TRIGGER IF EXISTS entities_fts_ad;
@@ -15463,7 +15525,7 @@ function up105(db) {
15463
15525
  function hasColumn17(db, table, column) {
15464
15526
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15465
15527
  }
15466
- function up106(db) {
15528
+ function up107(db) {
15467
15529
  if (!hasColumn17(db, "memories", "review_after")) {
15468
15530
  db.exec("ALTER TABLE memories ADD COLUMN review_after TEXT;");
15469
15531
  }
@@ -15481,7 +15543,7 @@ var TOKEN_COLUMNS = [
15481
15543
  ["tokens_cache_write", "INTEGER"],
15482
15544
  ["tokens_cost", "REAL"]
15483
15545
  ];
15484
- function up107(db) {
15546
+ function up108(db) {
15485
15547
  for (const [column, type] of TOKEN_COLUMNS) {
15486
15548
  if (!hasColumn18(db, "dreaming_passes", column)) {
15487
15549
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${column} ${type};`);
@@ -15490,7 +15552,7 @@ function up107(db) {
15490
15552
  }
15491
15553
 
15492
15554
  // src/migrations/108-embedding-usage.ts
15493
- function up108(db) {
15555
+ function up109(db) {
15494
15556
  db.exec(`
15495
15557
  CREATE TABLE IF NOT EXISTS embedding_usage (
15496
15558
  day TEXT NOT NULL,
@@ -15505,7 +15567,7 @@ function up108(db) {
15505
15567
  }
15506
15568
 
15507
15569
  // src/migrations/109-telemetry-install.ts
15508
- function up109(db) {
15570
+ function up110(db) {
15509
15571
  db.exec(`
15510
15572
  CREATE TABLE IF NOT EXISTS telemetry_install (
15511
15573
  id TEXT PRIMARY KEY,
@@ -15515,7 +15577,7 @@ function up109(db) {
15515
15577
  }
15516
15578
 
15517
15579
  // src/migrations/110-memory-mention-join-index.ts
15518
- function up110(db) {
15580
+ function up111(db) {
15519
15581
  db.exec(`
15520
15582
  CREATE INDEX IF NOT EXISTS idx_memory_entity_mentions_entity_memory
15521
15583
  ON memory_entity_mentions(entity_id, memory_id);
@@ -15528,7 +15590,7 @@ function hasColumn19(db, table, column) {
15528
15590
  return rows.some((row) => row.name === column);
15529
15591
  }
15530
15592
  var COLUMNS2 = ["first_remember_at", "first_recall_at"];
15531
- function up111(db) {
15593
+ function up112(db) {
15532
15594
  for (const column of COLUMNS2) {
15533
15595
  if (!hasColumn19(db, "telemetry_install", column)) {
15534
15596
  db.exec(`ALTER TABLE telemetry_install ADD COLUMN ${column} TEXT`);
@@ -15546,7 +15608,7 @@ function addColumnIfMissing23(db, column, definition) {
15546
15608
  db.exec(`ALTER TABLE telemetry_events ADD COLUMN ${column} ${definition}`);
15547
15609
  }
15548
15610
  }
15549
- function up112(db) {
15611
+ function up113(db) {
15550
15612
  addColumnIfMissing23(db, "source", "TEXT NOT NULL DEFAULT 'daemon'");
15551
15613
  addColumnIfMissing23(db, "claim_token", "TEXT");
15552
15614
  addColumnIfMissing23(db, "claimed_at", "TEXT");
@@ -15557,7 +15619,7 @@ function up112(db) {
15557
15619
  }
15558
15620
 
15559
15621
  // src/migrations/113-session-claims.ts
15560
- function up113(db) {
15622
+ function up114(db) {
15561
15623
  db.exec(`
15562
15624
  CREATE TABLE IF NOT EXISTS session_claims (
15563
15625
  session_key TEXT NOT NULL,
@@ -15580,7 +15642,7 @@ function up113(db) {
15580
15642
  }
15581
15643
 
15582
15644
  // src/migrations/114-memory-traversal-hydration-index.ts
15583
- function up114(db) {
15645
+ function up115(db) {
15584
15646
  const table = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'entity_attributes'").get();
15585
15647
  if (table == null)
15586
15648
  return;
@@ -15591,7 +15653,7 @@ function up114(db) {
15591
15653
  }
15592
15654
 
15593
15655
  // src/migrations/115-cross-agent-message-notifications.ts
15594
- function up115(db) {
15656
+ function up116(db) {
15595
15657
  db.exec(`
15596
15658
  CREATE TABLE IF NOT EXISTS cross_agent_messages (
15597
15659
  id TEXT PRIMARY KEY,
@@ -15650,7 +15712,7 @@ function addColumnIfMissing24(db, column, definition) {
15650
15712
  db.exec(`ALTER TABLE cross_agent_messages ADD COLUMN ${column} ${definition}`);
15651
15713
  }
15652
15714
  }
15653
- function up116(db) {
15715
+ function up117(db) {
15654
15716
  const table = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'cross_agent_messages'").get();
15655
15717
  if (table == null)
15656
15718
  return;
@@ -15854,7 +15916,7 @@ function backfillTranscriptsFromSummaryJobs(db) {
15854
15916
  insert.run(...values);
15855
15917
  }
15856
15918
  }
15857
- function up117(db) {
15919
+ function up118(db) {
15858
15920
  if (!hasTable4(db, "session_transcripts"))
15859
15921
  return;
15860
15922
  addColumnIfMissing25(db, "session_transcripts", "completed_at", "TEXT");
@@ -15909,7 +15971,7 @@ function up117(db) {
15909
15971
  }
15910
15972
 
15911
15973
  // src/migrations/118-queue-pressure-indices.ts
15912
- function up118(db) {
15974
+ function up119(db) {
15913
15975
  db.exec(`
15914
15976
  CREATE INDEX IF NOT EXISTS idx_memory_jobs_pressure_status
15915
15977
  ON memory_jobs(status)
@@ -15930,14 +15992,14 @@ function up118(db) {
15930
15992
  function hasColumn22(db, table, column) {
15931
15993
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15932
15994
  }
15933
- function up119(db) {
15995
+ function up120(db) {
15934
15996
  if (!hasColumn22(db, "telemetry_install", "last_seen_version")) {
15935
15997
  db.exec("ALTER TABLE telemetry_install ADD COLUMN last_seen_version TEXT");
15936
15998
  }
15937
15999
  }
15938
16000
 
15939
16001
  // src/migrations/120-source-lifecycle-telemetry.ts
15940
- function up120(db) {
16002
+ function up121(db) {
15941
16003
  db.exec(`
15942
16004
  CREATE TABLE IF NOT EXISTS source_lifecycle_state (
15943
16005
  agent_id TEXT NOT NULL,
@@ -15968,7 +16030,7 @@ function addColumnIfMissing26(db, column, definition) {
15968
16030
  db.exec(`ALTER TABLE telemetry_events ADD COLUMN ${column} ${definition}`);
15969
16031
  }
15970
16032
  }
15971
- function up121(db) {
16033
+ function up122(db) {
15972
16034
  addColumnIfMissing26(db, "delivery_attempts", "INTEGER NOT NULL DEFAULT 0");
15973
16035
  addColumnIfMissing26(db, "last_attempt_at", "TEXT");
15974
16036
  addColumnIfMissing26(db, "sent_at", "TEXT");
@@ -15991,7 +16053,7 @@ function up121(db) {
15991
16053
  }
15992
16054
 
15993
16055
  // src/migrations/122-dreaming-evidence-retry.ts
15994
- function up122(db) {
16056
+ function up123(db) {
15995
16057
  const columns = db.prepare("PRAGMA table_info(dreaming_evidence_exclusions)").all();
15996
16058
  const names = new Set(columns.map((column) => column.name));
15997
16059
  if (!names.has("failure_class")) {
@@ -16010,7 +16072,7 @@ function up122(db) {
16010
16072
  }
16011
16073
 
16012
16074
  // src/migrations/123-embedding-index-failures.ts
16013
- function up123(db) {
16075
+ function up124(db) {
16014
16076
  db.exec(`
16015
16077
  CREATE TABLE IF NOT EXISTS embedding_index_failures (
16016
16078
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -16036,7 +16098,7 @@ function up123(db) {
16036
16098
  }
16037
16099
 
16038
16100
  // src/migrations/124-import-derived-lifecycle.ts
16039
- function up124(db) {
16101
+ function up125(db) {
16040
16102
  db.exec(`
16041
16103
  CREATE TABLE IF NOT EXISTS imported_source_lifecycle (
16042
16104
  id TEXT PRIMARY KEY,
@@ -16088,7 +16150,7 @@ function backfillTable(db, params) {
16088
16150
  FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
16089
16151
  backfill(db, rows, params.sourceKind, params.scannedAt);
16090
16152
  }
16091
- function up125(db) {
16153
+ function up126(db) {
16092
16154
  db.exec(`
16093
16155
  CREATE TABLE IF NOT EXISTS memory_content_safety (
16094
16156
  agent_id TEXT NOT NULL,
@@ -16147,7 +16209,7 @@ function up125(db) {
16147
16209
  }
16148
16210
 
16149
16211
  // src/migrations/126-dreaming-surprisal-attention.ts
16150
- function up126(db) {
16212
+ function up127(db) {
16151
16213
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
16152
16214
  if (!table)
16153
16215
  return;
@@ -16183,7 +16245,7 @@ function up126(db) {
16183
16245
  }
16184
16246
 
16185
16247
  // src/migrations/127-ontology-contradictions.ts
16186
- function up127(db) {
16248
+ function up128(db) {
16187
16249
  db.exec(`
16188
16250
  CREATE TABLE IF NOT EXISTS ontology_contradictions (
16189
16251
  id TEXT PRIMARY KEY,
@@ -16241,7 +16303,7 @@ function up127(db) {
16241
16303
  }
16242
16304
 
16243
16305
  // src/migrations/128-bounded-queue-diagnostics.ts
16244
- function up128(db) {
16306
+ function up129(db) {
16245
16307
  db.exec(`
16246
16308
  CREATE INDEX IF NOT EXISTS idx_memory_jobs_diagnostics_status_created_at
16247
16309
  ON memory_jobs(status, created_at)
@@ -16258,7 +16320,7 @@ function up128(db) {
16258
16320
  function tableExists3(db, table) {
16259
16321
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
16260
16322
  }
16261
- function up129(db) {
16323
+ function up130(db) {
16262
16324
  if (!tableExists3(db, "memory_jobs"))
16263
16325
  return;
16264
16326
  if (!tableExists3(db, "job_cancellations")) {
@@ -16309,7 +16371,7 @@ function up129(db) {
16309
16371
  }
16310
16372
 
16311
16373
  // src/migrations/130-embedding-repair-state.ts
16312
- function up130(db) {
16374
+ function up131(db) {
16313
16375
  db.exec(`
16314
16376
  CREATE TABLE IF NOT EXISTS embedding_repair_budget (
16315
16377
  id INTEGER PRIMARY KEY CHECK (id = 1),
@@ -16351,7 +16413,7 @@ function up130(db) {
16351
16413
  }
16352
16414
 
16353
16415
  // src/migrations/131-dreaming-evidence-consumption.ts
16354
- function up131(db) {
16416
+ function up132(db) {
16355
16417
  db.exec(`
16356
16418
  CREATE TABLE IF NOT EXISTS dreaming_evidence_consumption (
16357
16419
  agent_id TEXT NOT NULL,
@@ -16376,7 +16438,7 @@ function up131(db) {
16376
16438
  }
16377
16439
 
16378
16440
  // src/migrations/132-observer-scoped-epistemic-assertions.ts
16379
- function up132(db) {
16441
+ function up133(db) {
16380
16442
  db.exec(`
16381
16443
  CREATE INDEX IF NOT EXISTS idx_epistemic_assertions_observer_entity
16382
16444
  ON epistemic_assertions(agent_id, subject_entity_id, status, asserted_at DESC, created_at DESC);
@@ -16384,7 +16446,7 @@ function up132(db) {
16384
16446
  }
16385
16447
 
16386
16448
  // src/migrations/133-dreaming-memory-head.ts
16387
- function up133(db) {
16449
+ function up134(db) {
16388
16450
  db.exec(`
16389
16451
  CREATE TABLE IF NOT EXISTS memory_head_revisions (
16390
16452
  id TEXT PRIMARY KEY,
@@ -16438,7 +16500,7 @@ function up133(db) {
16438
16500
  }
16439
16501
 
16440
16502
  // src/migrations/134-scope-memory-head-entries.ts
16441
- function up134(db) {
16503
+ function up135(db) {
16442
16504
  db.exec(`
16443
16505
  CREATE TABLE memory_head_entries_v134 (
16444
16506
  entry_id TEXT NOT NULL, agent_id TEXT NOT NULL, canonical_text TEXT NOT NULL,
@@ -16458,7 +16520,7 @@ function up134(db) {
16458
16520
  }
16459
16521
 
16460
16522
  // src/migrations/135-memory-head-publication.ts
16461
- function up135(db) {
16523
+ function up136(db) {
16462
16524
  db.exec(`
16463
16525
  CREATE TABLE IF NOT EXISTS memory_head_publications (
16464
16526
  agent_id TEXT NOT NULL,
@@ -16476,7 +16538,7 @@ function up135(db) {
16476
16538
  }
16477
16539
 
16478
16540
  // src/migrations/136-memory-head-revisions.ts
16479
- function up136(db) {
16541
+ function up137(db) {
16480
16542
  const cols = new Set(db.prepare("PRAGMA table_info(memory_head_revisions)").all().map((r) => r.name));
16481
16543
  for (const [name, type] of [
16482
16544
  ["entry_id", "TEXT"],
@@ -16492,7 +16554,7 @@ function up136(db) {
16492
16554
  }
16493
16555
 
16494
16556
  // src/migrations/137-dreaming-head-manifest.ts
16495
- function up137(db) {
16557
+ function up138(db) {
16496
16558
  const cols = new Set(db.prepare("PRAGMA table_info(dreaming_passes)").all().map((r) => r.name));
16497
16559
  for (const [name, type] of [
16498
16560
  ["head_revision", "INTEGER"],
@@ -16516,7 +16578,7 @@ function addColumnIfMissing27(db, table, column, definition) {
16516
16578
  if (!hasColumn25(db, table, column))
16517
16579
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
16518
16580
  }
16519
- function up138(db) {
16581
+ function up139(db) {
16520
16582
  addColumnIfMissing27(db, "memories", "manual_override", "INTEGER DEFAULT 0");
16521
16583
  db.exec(`
16522
16584
  CREATE TABLE IF NOT EXISTS transcript_capture_status (
@@ -16823,7 +16885,7 @@ function up138(db) {
16823
16885
  }
16824
16886
 
16825
16887
  // src/migrations/139-native-source-sync-state.ts
16826
- function up139(db) {
16888
+ function up140(db) {
16827
16889
  db.exec(`
16828
16890
  CREATE TABLE IF NOT EXISTS native_source_sync_state (
16829
16891
  agent_id TEXT NOT NULL,
@@ -16841,7 +16903,7 @@ function up139(db) {
16841
16903
  }
16842
16904
 
16843
16905
  // src/migrations/140-transcript-recovery-frontier.ts
16844
- function up140(db) {
16906
+ function up141(db) {
16845
16907
  db.exec(`
16846
16908
  CREATE TABLE IF NOT EXISTS transcript_recovery_frontiers (
16847
16909
  agent_id TEXT NOT NULL,
@@ -16855,7 +16917,7 @@ function up140(db) {
16855
16917
  }
16856
16918
 
16857
16919
  // src/migrations/141-source-sync-checkpoints.ts
16858
- function up141(db) {
16920
+ function up142(db) {
16859
16921
  db.exec(`
16860
16922
  CREATE TABLE IF NOT EXISTS source_sync_checkpoints (
16861
16923
  agent_id TEXT NOT NULL,
@@ -16871,7 +16933,7 @@ function up141(db) {
16871
16933
  }
16872
16934
 
16873
16935
  // src/migrations/142-source-sync-frontier.ts
16874
- function up142(db) {
16936
+ function up143(db) {
16875
16937
  const columns = db.prepare("PRAGMA table_info(source_sync_checkpoints)").all();
16876
16938
  if (!columns.some((column) => column.name === "frontier")) {
16877
16939
  db.exec("ALTER TABLE source_sync_checkpoints ADD COLUMN frontier TEXT");
@@ -16879,7 +16941,7 @@ function up142(db) {
16879
16941
  }
16880
16942
 
16881
16943
  // src/migrations/143-embedding-index-progress.ts
16882
- function up143(db) {
16944
+ function up144(db) {
16883
16945
  const columns = new Set(db.prepare("PRAGMA table_info(embedding_index_state)").all().map((row) => row.name).filter((name) => typeof name === "string"));
16884
16946
  const additions = [
16885
16947
  ["migration_phase", "TEXT"],
@@ -16916,7 +16978,7 @@ function up143(db) {
16916
16978
  }
16917
16979
 
16918
16980
  // src/migrations/144-memory-job-lease-token.ts
16919
- function up144(db) {
16981
+ function up145(db) {
16920
16982
  const columns = new Set(db.prepare("PRAGMA table_info(memory_jobs)").all().map((row) => row.name).filter((name) => typeof name === "string"));
16921
16983
  if (!columns.has("lease_token")) {
16922
16984
  db.exec("ALTER TABLE memory_jobs ADD COLUMN lease_token TEXT");
@@ -16924,7 +16986,7 @@ function up144(db) {
16924
16986
  }
16925
16987
 
16926
16988
  // src/migrations/145-dreaming-evidence-reviews.ts
16927
- function up145(db) {
16989
+ function up146(db) {
16928
16990
  db.exec(`
16929
16991
  CREATE TABLE IF NOT EXISTS dreaming_evidence_reviews (
16930
16992
  agent_id TEXT NOT NULL,
@@ -16944,7 +17006,7 @@ function up145(db) {
16944
17006
  }
16945
17007
 
16946
17008
  // src/migrations/146-source-transcript-import.ts
16947
- function up146(db) {
17009
+ function up147(db) {
16948
17010
  db.exec(`
16949
17011
  CREATE TABLE IF NOT EXISTS source_import_jobs (
16950
17012
  id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
@@ -16999,7 +17061,13 @@ function up146(db) {
16999
17061
  CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
17000
17062
  `);
17001
17063
  for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
17002
- const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
17064
+ const statement = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?");
17065
+ let exists;
17066
+ try {
17067
+ exists = statement.get(column);
17068
+ } finally {
17069
+ statement.finalize?.();
17070
+ }
17003
17071
  if (exists == null)
17004
17072
  db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
17005
17073
  }
@@ -17007,12 +17075,12 @@ function up146(db) {
17007
17075
  }
17008
17076
 
17009
17077
  // src/migrations/147-source-import-replay-file-slots.ts
17010
- function up147(db) {
17078
+ function up148(db) {
17011
17079
  db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
17012
17080
  }
17013
17081
 
17014
17082
  // src/migrations/148-source-import-attempt-provenance.ts
17015
- function up148(db) {
17083
+ function up149(db) {
17016
17084
  const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
17017
17085
  if (!columns.some((column) => column.name === "source_id")) {
17018
17086
  db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
@@ -17020,9 +17088,15 @@ function up148(db) {
17020
17088
  }
17021
17089
 
17022
17090
  // src/migrations/149-transcript-import-state-machine.ts
17023
- function up149(db) {
17091
+ function up150(db) {
17024
17092
  const addColumn = (table, column, definition) => {
17025
- const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
17093
+ const statement = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?");
17094
+ let exists;
17095
+ try {
17096
+ exists = statement.get(table, column);
17097
+ } finally {
17098
+ statement.finalize?.();
17099
+ }
17026
17100
  if (exists == null)
17027
17101
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
17028
17102
  };
@@ -17037,7 +17111,7 @@ function addColumnIfMissing28(db, table, column, definition) {
17037
17111
  if (!columns.some((row) => row.name === column))
17038
17112
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
17039
17113
  }
17040
- function up150(db) {
17114
+ function up151(db) {
17041
17115
  addColumnIfMissing28(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
17042
17116
  addColumnIfMissing28(db, "dreaming_passes", "head_base_revision", "INTEGER");
17043
17117
  db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
@@ -17193,13 +17267,13 @@ var MIGRATIONS = [
17193
17267
  {
17194
17268
  version: 1,
17195
17269
  name: "baseline",
17196
- up,
17270
+ up: up2,
17197
17271
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
17198
17272
  },
17199
17273
  {
17200
17274
  version: 2,
17201
17275
  name: "pipeline-v2",
17202
- up: up2,
17276
+ up: up3,
17203
17277
  artifacts: {
17204
17278
  tables: ["memory_history", "memory_jobs", "entities", "relations", "memory_entity_mentions"]
17205
17279
  }
@@ -17207,12 +17281,12 @@ var MIGRATIONS = [
17207
17281
  {
17208
17282
  version: 3,
17209
17283
  name: "unique-content-hash",
17210
- up: up3
17284
+ up: up4
17211
17285
  },
17212
17286
  {
17213
17287
  version: 4,
17214
17288
  name: "history-actor-and-retention",
17215
- up: up4,
17289
+ up: up5,
17216
17290
  artifacts: {
17217
17291
  columns: [{ table: "memory_history", column: "actor_type" }]
17218
17292
  }
@@ -17220,7 +17294,7 @@ var MIGRATIONS = [
17220
17294
  {
17221
17295
  version: 5,
17222
17296
  name: "graph-extended",
17223
- up: up5,
17297
+ up: up6,
17224
17298
  artifacts: {
17225
17299
  columns: [{ table: "entities", column: "canonical_name" }]
17226
17300
  }
@@ -17228,7 +17302,7 @@ var MIGRATIONS = [
17228
17302
  {
17229
17303
  version: 6,
17230
17304
  name: "idempotency-key",
17231
- up: up6,
17305
+ up: up7,
17232
17306
  artifacts: {
17233
17307
  columns: [{ table: "memories", column: "idempotency_key" }]
17234
17308
  }
@@ -17236,42 +17310,42 @@ var MIGRATIONS = [
17236
17310
  {
17237
17311
  version: 7,
17238
17312
  name: "documents-and-connectors",
17239
- up: up7,
17313
+ up: up8,
17240
17314
  artifacts: { tables: ["documents", "document_memories", "connectors"] }
17241
17315
  },
17242
17316
  {
17243
17317
  version: 8,
17244
17318
  name: "embeddings-unique-hash",
17245
- up: up8
17319
+ up: up9
17246
17320
  },
17247
17321
  {
17248
17322
  version: 9,
17249
17323
  name: "summary-jobs",
17250
- up: up9,
17324
+ up: up10,
17251
17325
  artifacts: { tables: ["summary_jobs"] }
17252
17326
  },
17253
17327
  {
17254
17328
  version: 10,
17255
17329
  name: "umap-cache",
17256
- up: up10,
17330
+ up: up11,
17257
17331
  artifacts: { tables: ["umap_cache"] }
17258
17332
  },
17259
17333
  {
17260
17334
  version: 11,
17261
17335
  name: "session-scores",
17262
- up: up11,
17336
+ up: up12,
17263
17337
  artifacts: { tables: ["session_scores"] }
17264
17338
  },
17265
17339
  {
17266
17340
  version: 12,
17267
17341
  name: "scheduled-tasks",
17268
- up: up12,
17342
+ up: up13,
17269
17343
  artifacts: { tables: ["scheduled_tasks", "task_runs"] }
17270
17344
  },
17271
17345
  {
17272
17346
  version: 13,
17273
17347
  name: "ingestion-tracking",
17274
- up: up13,
17348
+ up: up14,
17275
17349
  artifacts: {
17276
17350
  columns: [
17277
17351
  { table: "memories", column: "source_path" },
@@ -17282,13 +17356,13 @@ var MIGRATIONS = [
17282
17356
  {
17283
17357
  version: 14,
17284
17358
  name: "telemetry",
17285
- up: up14,
17359
+ up: up15,
17286
17360
  artifacts: { tables: ["telemetry_events"] }
17287
17361
  },
17288
17362
  {
17289
17363
  version: 15,
17290
17364
  name: "session-memories",
17291
- up: up15,
17365
+ up: up16,
17292
17366
  artifacts: {
17293
17367
  tables: ["session_memories"],
17294
17368
  columns: [
@@ -17300,13 +17374,13 @@ var MIGRATIONS = [
17300
17374
  {
17301
17375
  version: 16,
17302
17376
  name: "session-checkpoints",
17303
- up: up16,
17377
+ up: up17,
17304
17378
  artifacts: { tables: ["session_checkpoints"] }
17305
17379
  },
17306
17380
  {
17307
17381
  version: 17,
17308
17382
  name: "task-skills",
17309
- up: up17,
17383
+ up: up18,
17310
17384
  artifacts: {
17311
17385
  columns: [{ table: "scheduled_tasks", column: "skill_name" }]
17312
17386
  }
@@ -17314,13 +17388,13 @@ var MIGRATIONS = [
17314
17388
  {
17315
17389
  version: 18,
17316
17390
  name: "skill-meta",
17317
- up: up18,
17391
+ up: up19,
17318
17392
  artifacts: { tables: ["skill_meta"] }
17319
17393
  },
17320
17394
  {
17321
17395
  version: 19,
17322
17396
  name: "knowledge-structure",
17323
- up: up19,
17397
+ up: up20,
17324
17398
  artifacts: {
17325
17399
  tables: ["entity_aspects", "entity_attributes", "entity_dependencies", "task_meta"],
17326
17400
  columns: [{ table: "entities", column: "agent_id" }]
@@ -17329,7 +17403,7 @@ var MIGRATIONS = [
17329
17403
  {
17330
17404
  version: 20,
17331
17405
  name: "session-structural-columns",
17332
- up: up20,
17406
+ up: up21,
17333
17407
  artifacts: {
17334
17408
  columns: [
17335
17409
  { table: "session_memories", column: "entity_slot" },
@@ -17342,7 +17416,7 @@ var MIGRATIONS = [
17342
17416
  {
17343
17417
  version: 21,
17344
17418
  name: "checkpoint-structural",
17345
- up: up21,
17419
+ up: up22,
17346
17420
  artifacts: {
17347
17421
  columns: [{ table: "session_checkpoints", column: "focal_entity_ids" }]
17348
17422
  }
@@ -17350,7 +17424,7 @@ var MIGRATIONS = [
17350
17424
  {
17351
17425
  version: 22,
17352
17426
  name: "entity-pinning",
17353
- up: up22,
17427
+ up: up23,
17354
17428
  artifacts: {
17355
17429
  columns: [
17356
17430
  { table: "entities", column: "pinned" },
@@ -17361,17 +17435,17 @@ var MIGRATIONS = [
17361
17435
  {
17362
17436
  version: 23,
17363
17437
  name: "retired-scorer-gap",
17364
- up: up23
17438
+ up: up24
17365
17439
  },
17366
17440
  {
17367
17441
  version: 24,
17368
17442
  name: "retired-scorer-gap",
17369
- up: up24
17443
+ up: up25
17370
17444
  },
17371
17445
  {
17372
17446
  version: 25,
17373
17447
  name: "agent-feedback",
17374
- up: up25,
17448
+ up: up26,
17375
17449
  artifacts: {
17376
17450
  columns: [{ table: "session_memories", column: "agent_relevance_score" }]
17377
17451
  }
@@ -17379,32 +17453,32 @@ var MIGRATIONS = [
17379
17453
  {
17380
17454
  version: 26,
17381
17455
  name: "retired-scorer-gap",
17382
- up: up26
17456
+ up: up27
17383
17457
  },
17384
17458
  {
17385
17459
  version: 27,
17386
17460
  name: "backfill-canonical-names",
17387
- up: up27
17461
+ up: up28
17388
17462
  },
17389
17463
  {
17390
17464
  version: 28,
17391
17465
  name: "lossless-retention",
17392
- up: up28
17466
+ up: up29
17393
17467
  },
17394
17468
  {
17395
17469
  version: 29,
17396
17470
  name: "session-summary-dag",
17397
- up: up29
17471
+ up: up30
17398
17472
  },
17399
17473
  {
17400
17474
  version: 30,
17401
17475
  name: "nullable-memory-job-memory-id",
17402
- up: up30
17476
+ up: up31
17403
17477
  },
17404
17478
  {
17405
17479
  version: 31,
17406
17480
  name: "dependency-reason",
17407
- up: up31,
17481
+ up: up32,
17408
17482
  artifacts: {
17409
17483
  columns: [
17410
17484
  { table: "entity_dependencies", column: "reason" },
@@ -17415,7 +17489,7 @@ var MIGRATIONS = [
17415
17489
  {
17416
17490
  version: 32,
17417
17491
  name: "embeddings-vector-column",
17418
- up: up32,
17492
+ up: up33,
17419
17493
  artifacts: {
17420
17494
  columns: [{ table: "embeddings", column: "vector", optional: true }]
17421
17495
  }
@@ -17423,7 +17497,7 @@ var MIGRATIONS = [
17423
17497
  {
17424
17498
  version: 33,
17425
17499
  name: "scope",
17426
- up: up33,
17500
+ up: up34,
17427
17501
  artifacts: {
17428
17502
  columns: [{ table: "memories", column: "scope" }]
17429
17503
  }
@@ -17431,17 +17505,17 @@ var MIGRATIONS = [
17431
17505
  {
17432
17506
  version: 34,
17433
17507
  name: "scope-aware-dedup",
17434
- up: up34
17508
+ up: up35
17435
17509
  },
17436
17510
  {
17437
17511
  version: 35,
17438
17512
  name: "entity-fts",
17439
- up: up35
17513
+ up: up36
17440
17514
  },
17441
17515
  {
17442
17516
  version: 36,
17443
17517
  name: "dependency-confidence",
17444
- up: up36,
17518
+ up: up37,
17445
17519
  artifacts: {
17446
17520
  columns: [{ table: "entity_dependencies", column: "confidence" }]
17447
17521
  }
@@ -17449,7 +17523,7 @@ var MIGRATIONS = [
17449
17523
  {
17450
17524
  version: 37,
17451
17525
  name: "entity-communities",
17452
- up: up37,
17526
+ up: up38,
17453
17527
  artifacts: {
17454
17528
  tables: ["entity_communities"],
17455
17529
  columns: [{ table: "entities", column: "community_id" }]
@@ -17458,24 +17532,24 @@ var MIGRATIONS = [
17458
17532
  {
17459
17533
  version: 38,
17460
17534
  name: "memory-hints",
17461
- up: up38,
17535
+ up: up39,
17462
17536
  artifacts: { tables: ["memory_hints"] }
17463
17537
  },
17464
17538
  {
17465
17539
  version: 39,
17466
17540
  name: "dedup-entity-dependencies",
17467
- up: up39
17541
+ up: up40
17468
17542
  },
17469
17543
  {
17470
17544
  version: 40,
17471
17545
  name: "session-transcripts",
17472
- up: up40,
17546
+ up: up41,
17473
17547
  artifacts: { tables: ["session_transcripts"] }
17474
17548
  },
17475
17549
  {
17476
17550
  version: 41,
17477
17551
  name: "path-feedback",
17478
- up: up41,
17552
+ up: up42,
17479
17553
  artifacts: {
17480
17554
  tables: [
17481
17555
  "path_feedback_events",
@@ -17490,7 +17564,7 @@ var MIGRATIONS = [
17490
17564
  {
17491
17565
  version: 42,
17492
17566
  name: "session-memories-agent-id",
17493
- up: up42,
17567
+ up: up43,
17494
17568
  artifacts: {
17495
17569
  columns: [{ table: "session_memories", column: "agent_id" }]
17496
17570
  }
@@ -17498,7 +17572,7 @@ var MIGRATIONS = [
17498
17572
  {
17499
17573
  version: 43,
17500
17574
  name: "agents-table",
17501
- up: up43,
17575
+ up: up44,
17502
17576
  artifacts: {
17503
17577
  tables: ["agents"],
17504
17578
  columns: [
@@ -17510,7 +17584,7 @@ var MIGRATIONS = [
17510
17584
  {
17511
17585
  version: 44,
17512
17586
  name: "memory-md-temporal-head",
17513
- up: up44,
17587
+ up: up45,
17514
17588
  artifacts: {
17515
17589
  columns: [
17516
17590
  { table: "session_summaries", column: "source_type" },
@@ -17522,7 +17596,7 @@ var MIGRATIONS = [
17522
17596
  {
17523
17597
  version: 45,
17524
17598
  name: "lossless-working-memory-hardening",
17525
- up: up45,
17599
+ up: up46,
17526
17600
  artifacts: {
17527
17601
  tables: ["session_transcripts_fts", "memory_md_heads"],
17528
17602
  columns: [
@@ -17535,17 +17609,17 @@ var MIGRATIONS = [
17535
17609
  {
17536
17610
  version: 46,
17537
17611
  name: "session-summary-uniqueness",
17538
- up: up46
17612
+ up: up47
17539
17613
  },
17540
17614
  {
17541
17615
  version: 47,
17542
17616
  name: "agent-scoped-temporal-uniqueness",
17543
- up: up47
17617
+ up: up48
17544
17618
  },
17545
17619
  {
17546
17620
  version: 48,
17547
17621
  name: "thread-heads",
17548
- up: up48,
17622
+ up: up49,
17549
17623
  artifacts: {
17550
17624
  tables: ["memory_thread_heads"]
17551
17625
  }
@@ -17553,7 +17627,7 @@ var MIGRATIONS = [
17553
17627
  {
17554
17628
  version: 49,
17555
17629
  name: "session-extract-cursors",
17556
- up: up49,
17630
+ up: up50,
17557
17631
  artifacts: {
17558
17632
  tables: ["session_extract_cursors"]
17559
17633
  }
@@ -17561,7 +17635,7 @@ var MIGRATIONS = [
17561
17635
  {
17562
17636
  version: 50,
17563
17637
  name: "related-to-audit",
17564
- up: up50,
17638
+ up: up51,
17565
17639
  artifacts: {
17566
17640
  tables: ["entity_dependency_history"]
17567
17641
  }
@@ -17569,7 +17643,7 @@ var MIGRATIONS = [
17569
17643
  {
17570
17644
  version: 51,
17571
17645
  name: "memory-md-rolling-window-lineage",
17572
- up: up51,
17646
+ up: up52,
17573
17647
  artifacts: {
17574
17648
  tables: ["memory_artifacts", "memory_artifact_tombstones", "memory_artifacts_fts"],
17575
17649
  columns: [
@@ -17584,7 +17658,7 @@ var MIGRATIONS = [
17584
17658
  {
17585
17659
  version: 52,
17586
17660
  name: "mcp-invocations",
17587
- up: up52,
17661
+ up: up53,
17588
17662
  artifacts: {
17589
17663
  tables: ["mcp_invocations"]
17590
17664
  }
@@ -17592,7 +17666,7 @@ var MIGRATIONS = [
17592
17666
  {
17593
17667
  version: 53,
17594
17668
  name: "skill-invocations",
17595
- up: up53,
17669
+ up: up54,
17596
17670
  artifacts: {
17597
17671
  tables: ["skill_invocations"]
17598
17672
  }
@@ -17600,7 +17674,7 @@ var MIGRATIONS = [
17600
17674
  {
17601
17675
  version: 54,
17602
17676
  name: "task-agent-scope",
17603
- up: up54,
17677
+ up: up55,
17604
17678
  artifacts: {
17605
17679
  tables: ["task_scope_hints"]
17606
17680
  }
@@ -17608,7 +17682,7 @@ var MIGRATIONS = [
17608
17682
  {
17609
17683
  version: 55,
17610
17684
  name: "dreaming-state",
17611
- up: up55,
17685
+ up: up56,
17612
17686
  artifacts: {
17613
17687
  tables: ["dreaming_state", "dreaming_passes"]
17614
17688
  }
@@ -17616,22 +17690,22 @@ var MIGRATIONS = [
17616
17690
  {
17617
17691
  version: 56,
17618
17692
  name: "agent-scoped-content-hash",
17619
- up: up56
17693
+ up: up57
17620
17694
  },
17621
17695
  {
17622
17696
  version: 57,
17623
17697
  name: "memories-fts-tokenizer-repair",
17624
- up: up57
17698
+ up: up58
17625
17699
  },
17626
17700
  {
17627
17701
  version: 58,
17628
17702
  name: "knowledge-graph-indices",
17629
- up: up58
17703
+ up: up59
17630
17704
  },
17631
17705
  {
17632
17706
  version: 59,
17633
17707
  name: "entity-attribute-claim-key",
17634
- up: up59,
17708
+ up: up60,
17635
17709
  artifacts: {
17636
17710
  columns: [{ table: "entity_attributes", column: "claim_key" }]
17637
17711
  }
@@ -17639,7 +17713,7 @@ var MIGRATIONS = [
17639
17713
  {
17640
17714
  version: 60,
17641
17715
  name: "entity-attribute-group-key",
17642
- up: up60,
17716
+ up: up61,
17643
17717
  artifacts: {
17644
17718
  columns: [{ table: "entity_attributes", column: "group_key" }]
17645
17719
  }
@@ -17647,7 +17721,7 @@ var MIGRATIONS = [
17647
17721
  {
17648
17722
  version: 61,
17649
17723
  name: "memory-artifact-source-mtime",
17650
- up: up61,
17724
+ up: up62,
17651
17725
  artifacts: {
17652
17726
  columns: [{ table: "memory_artifacts", column: "source_mtime_ms" }]
17653
17727
  }
@@ -17655,7 +17729,7 @@ var MIGRATIONS = [
17655
17729
  {
17656
17730
  version: 62,
17657
17731
  name: "memory-artifact-soft-delete",
17658
- up: up62,
17732
+ up: up63,
17659
17733
  artifacts: {
17660
17734
  columns: [
17661
17735
  { table: "memory_artifacts", column: "is_deleted" },
@@ -17666,12 +17740,12 @@ var MIGRATIONS = [
17666
17740
  {
17667
17741
  version: 63,
17668
17742
  name: "content-only-memories-fts-update",
17669
- up: up63
17743
+ up: up64
17670
17744
  },
17671
17745
  {
17672
17746
  version: 64,
17673
17747
  name: "source-graph-provenance",
17674
- up: up64,
17748
+ up: up65,
17675
17749
  artifacts: {
17676
17750
  columns: [
17677
17751
  { table: "entities", column: "source_path" },
@@ -17684,7 +17758,7 @@ var MIGRATIONS = [
17684
17758
  {
17685
17759
  version: 65,
17686
17760
  name: "source-embedding-agent-scope",
17687
- up: up65,
17761
+ up: up66,
17688
17762
  artifacts: {
17689
17763
  columns: [{ table: "embeddings", column: "agent_id", optional: true }]
17690
17764
  }
@@ -17692,7 +17766,7 @@ var MIGRATIONS = [
17692
17766
  {
17693
17767
  version: 66,
17694
17768
  name: "memory-search-telemetry",
17695
- up: up66,
17769
+ up: up67,
17696
17770
  artifacts: {
17697
17771
  tables: ["memory_search_telemetry"]
17698
17772
  }
@@ -17700,7 +17774,7 @@ var MIGRATIONS = [
17700
17774
  {
17701
17775
  version: 67,
17702
17776
  name: "ontology-proposals",
17703
- up: up67,
17777
+ up: up68,
17704
17778
  artifacts: {
17705
17779
  tables: ["ontology_proposals"],
17706
17780
  columns: [
@@ -17714,7 +17788,7 @@ var MIGRATIONS = [
17714
17788
  {
17715
17789
  version: 68,
17716
17790
  name: "daily-reflections",
17717
- up: up68,
17791
+ up: up69,
17718
17792
  artifacts: {
17719
17793
  tables: ["daily_reflections"]
17720
17794
  }
@@ -17722,7 +17796,7 @@ var MIGRATIONS = [
17722
17796
  {
17723
17797
  version: 69,
17724
17798
  name: "daily-reflections-multiple-insights",
17725
- up: up69,
17799
+ up: up70,
17726
17800
  artifacts: {
17727
17801
  tables: ["daily_reflections"]
17728
17802
  }
@@ -17730,7 +17804,7 @@ var MIGRATIONS = [
17730
17804
  {
17731
17805
  version: 70,
17732
17806
  name: "ontology-control-plane-state",
17733
- up: up70,
17807
+ up: up71,
17734
17808
  artifacts: {
17735
17809
  columns: [
17736
17810
  { table: "entities", column: "status" },
@@ -17745,7 +17819,7 @@ var MIGRATIONS = [
17745
17819
  {
17746
17820
  version: 71,
17747
17821
  name: "epistemic-assertions",
17748
- up: up71,
17822
+ up: up72,
17749
17823
  artifacts: {
17750
17824
  tables: ["epistemic_assertions"]
17751
17825
  }
@@ -17753,7 +17827,7 @@ var MIGRATIONS = [
17753
17827
  {
17754
17828
  version: 72,
17755
17829
  name: "agent-scoped-idempotency-key",
17756
- up: up72,
17830
+ up: up73,
17757
17831
  artifacts: {
17758
17832
  columns: [
17759
17833
  { table: "memories", column: "idempotency_key" },
@@ -17764,7 +17838,7 @@ var MIGRATIONS = [
17764
17838
  {
17765
17839
  version: 73,
17766
17840
  name: "recall-context-dedupe",
17767
- up: up73,
17841
+ up: up74,
17768
17842
  artifacts: {
17769
17843
  tables: ["session_context_epochs", "session_recall_events"]
17770
17844
  }
@@ -17772,7 +17846,7 @@ var MIGRATIONS = [
17772
17846
  {
17773
17847
  version: 74,
17774
17848
  name: "aggregate-memory-links",
17775
- up: up74,
17849
+ up: up75,
17776
17850
  artifacts: {
17777
17851
  tables: ["aggregate_memory_sources"]
17778
17852
  }
@@ -17780,7 +17854,7 @@ var MIGRATIONS = [
17780
17854
  {
17781
17855
  version: 75,
17782
17856
  name: "memory-artifact-source-provenance",
17783
- up: up75,
17857
+ up: up76,
17784
17858
  artifacts: {
17785
17859
  columns: [
17786
17860
  { table: "memory_artifacts", column: "source_id" },
@@ -17794,7 +17868,7 @@ var MIGRATIONS = [
17794
17868
  {
17795
17869
  version: 76,
17796
17870
  name: "temporal-edges",
17797
- up: up76,
17871
+ up: up77,
17798
17872
  artifacts: {
17799
17873
  tables: ["temporal_edges"]
17800
17874
  }
@@ -17802,7 +17876,7 @@ var MIGRATIONS = [
17802
17876
  {
17803
17877
  version: 77,
17804
17878
  name: "entity-aliases",
17805
- up: up77,
17879
+ up: up78,
17806
17880
  artifacts: {
17807
17881
  tables: ["entity_aliases"]
17808
17882
  }
@@ -17810,7 +17884,7 @@ var MIGRATIONS = [
17810
17884
  {
17811
17885
  version: 78,
17812
17886
  name: "api-keys",
17813
- up: up78,
17887
+ up: up79,
17814
17888
  artifacts: {
17815
17889
  tables: ["api_keys"]
17816
17890
  }
@@ -17818,7 +17892,7 @@ var MIGRATIONS = [
17818
17892
  {
17819
17893
  version: 79,
17820
17894
  name: "transcript-capture-jobs",
17821
- up: up79,
17895
+ up: up80,
17822
17896
  artifacts: {
17823
17897
  tables: ["transcript_capture_jobs"]
17824
17898
  }
@@ -17826,7 +17900,7 @@ var MIGRATIONS = [
17826
17900
  {
17827
17901
  version: 80,
17828
17902
  name: "document-scope-columns",
17829
- up: up80,
17903
+ up: up81,
17830
17904
  artifacts: {
17831
17905
  columns: [
17832
17906
  { table: "documents", column: "agent_id" },
@@ -17837,7 +17911,7 @@ var MIGRATIONS = [
17837
17911
  {
17838
17912
  version: 81,
17839
17913
  name: "aggregate-evidence-sources",
17840
- up: up81,
17914
+ up: up82,
17841
17915
  artifacts: {
17842
17916
  tables: ["aggregate_evidence_sources"]
17843
17917
  }
@@ -17845,7 +17919,7 @@ var MIGRATIONS = [
17845
17919
  {
17846
17920
  version: 82,
17847
17921
  name: "skill-invocations-harness",
17848
- up: up82,
17922
+ up: up83,
17849
17923
  artifacts: {
17850
17924
  columns: [
17851
17925
  { table: "skill_invocations", column: "harness" },
@@ -17856,7 +17930,7 @@ var MIGRATIONS = [
17856
17930
  {
17857
17931
  version: 83,
17858
17932
  name: "memory-lifecycle-repair",
17859
- up: up83,
17933
+ up: up84,
17860
17934
  artifacts: {
17861
17935
  tables: ["transcript_capture_jobs", "aggregate_evidence_sources", "entity_dependencies"],
17862
17936
  columns: [
@@ -17871,7 +17945,7 @@ var MIGRATIONS = [
17871
17945
  {
17872
17946
  version: 84,
17873
17947
  name: "legacy-markdown-import-state",
17874
- up: up84,
17948
+ up: up85,
17875
17949
  artifacts: {
17876
17950
  tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
17877
17951
  }
@@ -17879,7 +17953,7 @@ var MIGRATIONS = [
17879
17953
  {
17880
17954
  version: 85,
17881
17955
  name: "backfill-relations-to-dependencies",
17882
- up: up85,
17956
+ up: up86,
17883
17957
  artifacts: {
17884
17958
  tables: ["entity_dependencies"]
17885
17959
  }
@@ -17887,7 +17961,7 @@ var MIGRATIONS = [
17887
17961
  {
17888
17962
  version: 86,
17889
17963
  name: "summary-jobs-content-hash",
17890
- up: up86,
17964
+ up: up87,
17891
17965
  artifacts: {
17892
17966
  columns: [{ table: "summary_jobs", column: "content_hash" }]
17893
17967
  }
@@ -17895,7 +17969,7 @@ var MIGRATIONS = [
17895
17969
  {
17896
17970
  version: 87,
17897
17971
  name: "summary-jobs-boundary-reason",
17898
- up: up87,
17972
+ up: up88,
17899
17973
  artifacts: {
17900
17974
  columns: [{ table: "summary_jobs", column: "boundary_reason" }]
17901
17975
  }
@@ -17903,7 +17977,7 @@ var MIGRATIONS = [
17903
17977
  {
17904
17978
  version: 88,
17905
17979
  name: "transcript-recovery-files",
17906
- up: up88,
17980
+ up: up89,
17907
17981
  artifacts: {
17908
17982
  tables: ["transcript_recovery_files"]
17909
17983
  }
@@ -17911,7 +17985,7 @@ var MIGRATIONS = [
17911
17985
  {
17912
17986
  version: 89,
17913
17987
  name: "job-cancellations",
17914
- up: up89,
17988
+ up: up90,
17915
17989
  artifacts: {
17916
17990
  tables: ["job_cancellations"]
17917
17991
  }
@@ -17919,7 +17993,7 @@ var MIGRATIONS = [
17919
17993
  {
17920
17994
  version: 90,
17921
17995
  name: "job-archive",
17922
- up: up90,
17996
+ up: up91,
17923
17997
  artifacts: {
17924
17998
  tables: ["job_archive"]
17925
17999
  }
@@ -17927,25 +18001,25 @@ var MIGRATIONS = [
17927
18001
  {
17928
18002
  version: 91,
17929
18003
  name: "embedding-index-generations",
17930
- up: up91,
18004
+ up: up92,
17931
18005
  artifacts: { tables: ["embedding_index_state"] }
17932
18006
  },
17933
18007
  {
17934
18008
  version: 92,
17935
18009
  name: "embedding-staging-store",
17936
- up: up92,
18010
+ up: up93,
17937
18011
  artifacts: { tables: ["embeddings_staging"] }
17938
18012
  },
17939
18013
  {
17940
18014
  version: 93,
17941
18015
  name: "dreaming-evidence-cursor",
17942
- up: up93,
18016
+ up: up94,
17943
18017
  artifacts: { columns: [{ table: "dreaming_state", column: "evidence_cursor" }] }
17944
18018
  },
17945
18019
  {
17946
18020
  version: 94,
17947
18021
  name: "memory-kind",
17948
- up: up94,
18022
+ up: up95,
17949
18023
  artifacts: {
17950
18024
  columns: [
17951
18025
  { table: "memories", column: "memory_kind" },
@@ -17956,35 +18030,35 @@ var MIGRATIONS = [
17956
18030
  {
17957
18031
  version: 95,
17958
18032
  name: "compaction-recall-projections",
17959
- up: up95
18033
+ up: up96
17960
18034
  },
17961
18035
  {
17962
18036
  version: 96,
17963
18037
  name: "retire-legacy-ingestion",
17964
- up: up96
18038
+ up: up97
17965
18039
  },
17966
18040
  {
17967
18041
  version: 97,
17968
18042
  name: "dreaming-failure-backoff",
17969
- up: up97,
18043
+ up: up98,
17970
18044
  artifacts: { columns: [{ table: "dreaming_state", column: "last_failure_at" }] }
17971
18045
  },
17972
18046
  {
17973
18047
  version: 98,
17974
18048
  name: "dreaming-evidence-exclusions",
17975
- up: up98,
18049
+ up: up99,
17976
18050
  artifacts: { tables: ["dreaming_evidence_exclusions"] }
17977
18051
  },
17978
18052
  {
17979
18053
  version: 99,
17980
18054
  name: "dreaming-tool-calls",
17981
- up: up99,
18055
+ up: up100,
17982
18056
  artifacts: { tables: ["dreaming_tool_calls"] }
17983
18057
  },
17984
18058
  {
17985
18059
  version: 100,
17986
18060
  name: "dreaming-runbook",
17987
- up: up100,
18061
+ up: up101,
17988
18062
  artifacts: {
17989
18063
  columns: [
17990
18064
  { table: "dreaming_passes", column: "evidence_window_json" },
@@ -17995,23 +18069,23 @@ var MIGRATIONS = [
17995
18069
  {
17996
18070
  version: 101,
17997
18071
  name: "dreaming-attention",
17998
- up: up101,
18072
+ up: up102,
17999
18073
  artifacts: { tables: ["dreaming_attention"] }
18000
18074
  },
18001
18075
  {
18002
18076
  version: 102,
18003
18077
  name: "attribute-semantic-memories",
18004
- up: up102
18078
+ up: up103
18005
18079
  },
18006
18080
  {
18007
18081
  version: 103,
18008
18082
  name: "semantic-memory-kind",
18009
- up: up103
18083
+ up: up104
18010
18084
  },
18011
18085
  {
18012
18086
  version: 104,
18013
18087
  name: "derived-memory-provenance",
18014
- up: up104,
18088
+ up: up105,
18015
18089
  artifacts: {
18016
18090
  tables: ["derived_memory_sources"],
18017
18091
  columns: [{ table: "memories", column: "stale_at" }]
@@ -18020,12 +18094,12 @@ var MIGRATIONS = [
18020
18094
  {
18021
18095
  version: 105,
18022
18096
  name: "agent-scoped-entity-name",
18023
- up: up105
18097
+ up: up106
18024
18098
  },
18025
18099
  {
18026
18100
  version: 106,
18027
18101
  name: "memory-review-after",
18028
- up: up106,
18102
+ up: up107,
18029
18103
  artifacts: {
18030
18104
  columns: [{ table: "memories", column: "review_after" }]
18031
18105
  }
@@ -18033,7 +18107,7 @@ var MIGRATIONS = [
18033
18107
  {
18034
18108
  version: 107,
18035
18109
  name: "dreaming-pass-usage",
18036
- up: up107,
18110
+ up: up108,
18037
18111
  artifacts: {
18038
18112
  columns: [
18039
18113
  { table: "dreaming_passes", column: "tokens_input" },
@@ -18047,7 +18121,7 @@ var MIGRATIONS = [
18047
18121
  {
18048
18122
  version: 108,
18049
18123
  name: "embedding-usage",
18050
- up: up108,
18124
+ up: up109,
18051
18125
  artifacts: {
18052
18126
  tables: ["embedding_usage"]
18053
18127
  }
@@ -18055,7 +18129,7 @@ var MIGRATIONS = [
18055
18129
  {
18056
18130
  version: 109,
18057
18131
  name: "telemetry-install",
18058
- up: up109,
18132
+ up: up110,
18059
18133
  artifacts: {
18060
18134
  tables: ["telemetry_install"]
18061
18135
  }
@@ -18063,12 +18137,12 @@ var MIGRATIONS = [
18063
18137
  {
18064
18138
  version: 110,
18065
18139
  name: "memory-mention-join-index",
18066
- up: up110
18140
+ up: up111
18067
18141
  },
18068
18142
  {
18069
18143
  version: 111,
18070
18144
  name: "telemetry-first-use",
18071
- up: up111,
18145
+ up: up112,
18072
18146
  artifacts: {
18073
18147
  columns: [
18074
18148
  { table: "telemetry_install", column: "first_remember_at" },
@@ -18079,7 +18153,7 @@ var MIGRATIONS = [
18079
18153
  {
18080
18154
  version: 112,
18081
18155
  name: "telemetry-queue-ownership",
18082
- up: up112,
18156
+ up: up113,
18083
18157
  artifacts: {
18084
18158
  columns: [
18085
18159
  { table: "telemetry_events", column: "source" },
@@ -18091,7 +18165,7 @@ var MIGRATIONS = [
18091
18165
  {
18092
18166
  version: 113,
18093
18167
  name: "session-claims",
18094
- up: up113,
18168
+ up: up114,
18095
18169
  artifacts: {
18096
18170
  tables: ["session_claims"],
18097
18171
  columns: [
@@ -18105,12 +18179,12 @@ var MIGRATIONS = [
18105
18179
  {
18106
18180
  version: 114,
18107
18181
  name: "memory-traversal-hydration-index",
18108
- up: up114
18182
+ up: up115
18109
18183
  },
18110
18184
  {
18111
18185
  version: 115,
18112
18186
  name: "cross-agent-message-notifications",
18113
- up: up115,
18187
+ up: up116,
18114
18188
  artifacts: {
18115
18189
  tables: ["cross_agent_messages", "cross_agent_message_receipts"]
18116
18190
  }
@@ -18118,7 +18192,7 @@ var MIGRATIONS = [
18118
18192
  {
18119
18193
  version: 116,
18120
18194
  name: "acp-delivery-reconciliation",
18121
- up: up116,
18195
+ up: up117,
18122
18196
  artifacts: {
18123
18197
  columns: [
18124
18198
  { table: "cross_agent_messages", column: "delivery_state" },
@@ -18132,7 +18206,7 @@ var MIGRATIONS = [
18132
18206
  {
18133
18207
  version: 117,
18134
18208
  name: "retire-summary-worker",
18135
- up: up117,
18209
+ up: up118,
18136
18210
  artifacts: {
18137
18211
  columns: [
18138
18212
  { table: "session_transcripts", column: "completed_at" },
@@ -18143,24 +18217,24 @@ var MIGRATIONS = [
18143
18217
  {
18144
18218
  version: 118,
18145
18219
  name: "queue-pressure-indices",
18146
- up: up118
18220
+ up: up119
18147
18221
  },
18148
18222
  {
18149
18223
  version: 119,
18150
18224
  name: "telemetry-version-observation",
18151
- up: up119,
18225
+ up: up120,
18152
18226
  artifacts: { columns: [{ table: "telemetry_install", column: "last_seen_version" }] }
18153
18227
  },
18154
18228
  {
18155
18229
  version: 120,
18156
18230
  name: "source-lifecycle-telemetry",
18157
- up: up120,
18231
+ up: up121,
18158
18232
  artifacts: { tables: ["source_lifecycle_state"] }
18159
18233
  },
18160
18234
  {
18161
18235
  version: 121,
18162
18236
  name: "telemetry-delivery-health",
18163
- up: up121,
18237
+ up: up122,
18164
18238
  artifacts: {
18165
18239
  tables: ["telemetry_delivery_state"],
18166
18240
  columns: [
@@ -18174,7 +18248,7 @@ var MIGRATIONS = [
18174
18248
  {
18175
18249
  version: 122,
18176
18250
  name: "dreaming-evidence-retry",
18177
- up: up122,
18251
+ up: up123,
18178
18252
  artifacts: {
18179
18253
  columns: [
18180
18254
  { table: "dreaming_evidence_exclusions", column: "failure_class" },
@@ -18187,13 +18261,13 @@ var MIGRATIONS = [
18187
18261
  {
18188
18262
  version: 123,
18189
18263
  name: "embedding-index-failures",
18190
- up: up123,
18264
+ up: up124,
18191
18265
  artifacts: { tables: ["embedding_index_failures"] }
18192
18266
  },
18193
18267
  {
18194
18268
  version: 124,
18195
18269
  name: "import-derived-lifecycle",
18196
- up: up124,
18270
+ up: up125,
18197
18271
  artifacts: {
18198
18272
  tables: ["imported_source_lifecycle"]
18199
18273
  }
@@ -18201,77 +18275,77 @@ var MIGRATIONS = [
18201
18275
  {
18202
18276
  version: 125,
18203
18277
  name: "memory-content-safety",
18204
- up: up125,
18278
+ up: up126,
18205
18279
  artifacts: { tables: ["memory_content_safety"] }
18206
18280
  },
18207
18281
  {
18208
18282
  version: 126,
18209
18283
  name: "dreaming-surprisal-attention",
18210
- up: up126,
18284
+ up: up127,
18211
18285
  artifacts: { tables: ["dreaming_attention"] }
18212
18286
  },
18213
18287
  {
18214
18288
  version: 127,
18215
18289
  name: "ontology-contradictions",
18216
- up: up127,
18290
+ up: up128,
18217
18291
  artifacts: { tables: ["ontology_contradictions"] }
18218
18292
  },
18219
18293
  {
18220
18294
  version: 128,
18221
18295
  name: "bounded-queue-diagnostics",
18222
- up: up128
18296
+ up: up129
18223
18297
  },
18224
18298
  {
18225
18299
  version: 129,
18226
18300
  name: "retire-structural-jobs",
18227
- up: up129
18301
+ up: up130
18228
18302
  },
18229
18303
  {
18230
18304
  version: 130,
18231
18305
  name: "embedding-repair-state",
18232
- up: up130,
18306
+ up: up131,
18233
18307
  artifacts: { tables: ["embedding_repair_budget", "embedding_repair_backoff"] }
18234
18308
  },
18235
18309
  {
18236
18310
  version: 131,
18237
18311
  name: "dreaming-evidence-consumption",
18238
- up: up131,
18312
+ up: up132,
18239
18313
  artifacts: { tables: ["dreaming_evidence_consumption"] }
18240
18314
  },
18241
18315
  {
18242
18316
  version: 132,
18243
18317
  name: "observer-scoped-epistemic-assertions",
18244
- up: up132,
18318
+ up: up133,
18245
18319
  artifacts: { tables: ["epistemic_assertions"] }
18246
18320
  },
18247
18321
  {
18248
18322
  version: 133,
18249
18323
  name: "dreaming-memory-head",
18250
- up: up133,
18324
+ up: up134,
18251
18325
  artifacts: { tables: ["memory_head_revisions", "memory_head_entries", "memory_head_revision_entries"] }
18252
18326
  },
18253
18327
  {
18254
18328
  version: 134,
18255
18329
  name: "scope-memory-head-entries",
18256
- up: up134,
18330
+ up: up135,
18257
18331
  artifacts: { tables: ["memory_head_entries"] }
18258
18332
  },
18259
18333
  {
18260
18334
  version: 135,
18261
18335
  name: "memory-head-publication",
18262
- up: up135,
18336
+ up: up136,
18263
18337
  artifacts: { tables: ["memory_head_publications"] }
18264
18338
  },
18265
18339
  {
18266
18340
  version: 136,
18267
18341
  name: "memory-head-revisions",
18268
- up: up136,
18342
+ up: up137,
18269
18343
  artifacts: { tables: ["memory_head_revisions"] }
18270
18344
  },
18271
18345
  {
18272
18346
  version: 137,
18273
18347
  name: "dreaming-head-manifest",
18274
- up: up137,
18348
+ up: up138,
18275
18349
  artifacts: {
18276
18350
  columns: [
18277
18351
  { table: "dreaming_passes", column: "head_revision" },
@@ -18282,7 +18356,7 @@ var MIGRATIONS = [
18282
18356
  {
18283
18357
  version: 138,
18284
18358
  name: "bounded-status-projections",
18285
- up: up138,
18359
+ up: up139,
18286
18360
  artifacts: {
18287
18361
  tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
18288
18362
  }
@@ -18290,31 +18364,31 @@ var MIGRATIONS = [
18290
18364
  {
18291
18365
  version: 139,
18292
18366
  name: "native-source-sync-state",
18293
- up: up139,
18367
+ up: up140,
18294
18368
  artifacts: { tables: ["native_source_sync_state"] }
18295
18369
  },
18296
18370
  {
18297
18371
  version: 140,
18298
18372
  name: "transcript-recovery-frontier",
18299
- up: up140,
18373
+ up: up141,
18300
18374
  artifacts: { tables: ["transcript_recovery_frontiers"] }
18301
18375
  },
18302
18376
  {
18303
18377
  version: 141,
18304
18378
  name: "source-sync-checkpoints",
18305
- up: up141,
18379
+ up: up142,
18306
18380
  artifacts: { tables: ["source_sync_checkpoints"] }
18307
18381
  },
18308
18382
  {
18309
18383
  version: 142,
18310
18384
  name: "source-sync-frontier",
18311
- up: up142,
18385
+ up: up143,
18312
18386
  artifacts: { columns: [{ table: "source_sync_checkpoints", column: "frontier" }] }
18313
18387
  },
18314
18388
  {
18315
18389
  version: 143,
18316
18390
  name: "embedding-index-progress",
18317
- up: up143,
18391
+ up: up144,
18318
18392
  artifacts: {
18319
18393
  columns: [
18320
18394
  { table: "embedding_index_state", column: "migration_phase" },
@@ -18330,19 +18404,19 @@ var MIGRATIONS = [
18330
18404
  {
18331
18405
  version: 144,
18332
18406
  name: "memory-job-lease-token",
18333
- up: up144,
18407
+ up: up145,
18334
18408
  artifacts: { columns: [{ table: "memory_jobs", column: "lease_token" }] }
18335
18409
  },
18336
18410
  {
18337
18411
  version: 145,
18338
18412
  name: "dreaming-evidence-reviews",
18339
- up: up145,
18413
+ up: up146,
18340
18414
  artifacts: { tables: ["dreaming_evidence_reviews"] }
18341
18415
  },
18342
18416
  {
18343
18417
  version: 146,
18344
18418
  name: "source-transcript-import",
18345
- up: up146,
18419
+ up: up147,
18346
18420
  artifacts: {
18347
18421
  tables: [
18348
18422
  "source_import_jobs",
@@ -18361,19 +18435,19 @@ var MIGRATIONS = [
18361
18435
  {
18362
18436
  version: 147,
18363
18437
  name: "source-import-replay-file-slots",
18364
- up: up147,
18438
+ up: up148,
18365
18439
  artifacts: { tables: ["source_import_files"] }
18366
18440
  },
18367
18441
  {
18368
18442
  version: 148,
18369
18443
  name: "source-import-attempt-provenance",
18370
- up: up148,
18444
+ up: up149,
18371
18445
  artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
18372
18446
  },
18373
18447
  {
18374
18448
  version: 149,
18375
18449
  name: "transcript-import-state-machine",
18376
- up: up149,
18450
+ up: up150,
18377
18451
  artifacts: {
18378
18452
  columns: [
18379
18453
  { table: "source_import_jobs", column: "duplicate_mode" },
@@ -18385,13 +18459,42 @@ var MIGRATIONS = [
18385
18459
  {
18386
18460
  version: 150,
18387
18461
  name: "memory-head-freshness",
18388
- up: up150,
18462
+ up: up151,
18389
18463
  artifacts: {
18390
18464
  columns: [
18391
18465
  { table: "memory_md_heads", column: "is_current" },
18392
18466
  { table: "dreaming_passes", column: "head_base_revision" }
18393
18467
  ]
18394
18468
  }
18469
+ },
18470
+ {
18471
+ version: 151,
18472
+ name: "transcript-import-bytes",
18473
+ up,
18474
+ artifacts: {
18475
+ tables: [
18476
+ "source_import_chunks",
18477
+ "source_import_capacity",
18478
+ "source_import_migrations",
18479
+ "source_import_migration_streams",
18480
+ "source_import_migration_counts"
18481
+ ],
18482
+ columns: [
18483
+ { table: "source_import_files", column: "storage_state" },
18484
+ { table: "source_import_files", column: "upload_generation" },
18485
+ { table: "source_import_files", column: "upload_offset" },
18486
+ { table: "source_import_files", column: "upload_size" },
18487
+ { table: "source_import_files", column: "upload_digest" },
18488
+ ...["checkpoint_line_number", "reserved_bytes", "original_path"].map((column) => ({
18489
+ table: "source_import_files",
18490
+ column
18491
+ })),
18492
+ ...["retry_count", "cleanup_state", "retry_cursor", "retry_requested"].map((column) => ({
18493
+ table: "source_import_jobs",
18494
+ column
18495
+ }))
18496
+ ]
18497
+ }
18395
18498
  }
18396
18499
  ];
18397
18500
  function checksum(m) {
@@ -23268,6 +23371,12 @@ function addImportedSource(input, agentsDir = getAgentsDir2()) {
23268
23371
  const now = input.now ?? new Date().toISOString();
23269
23372
  const config = loadSourcesConfigForWrite(agentsDir);
23270
23373
  const mode = input.duplicateMode ?? "skip";
23374
+ const replay = input.importKey === undefined ? undefined : config.sources.find((source2) => source2.kind === "import" && source2.providerSettings?.agentId === agentId && source2.providerSettings?.importKey === input.importKey);
23375
+ if (replay) {
23376
+ if (replay.providerSettings?.contentHash !== contentHash)
23377
+ return { ok: false, error: "Import identity content mismatch" };
23378
+ return { ok: true, source: replay, created: false, duplicate: true };
23379
+ }
23271
23380
  const duplicate = config.sources.find((source2) => source2.kind === "import" && source2.providerSettings?.contentHash === contentHash && (agentId === undefined || source2.providerSettings?.agentId === agentId));
23272
23381
  if (duplicate && mode === "skip") {
23273
23382
  return { ok: true, source: duplicate, created: false, duplicate: true };
@@ -23288,6 +23397,7 @@ function addImportedSource(input, agentsDir = getAgentsDir2()) {
23288
23397
  fileName: basename(fileName),
23289
23398
  contentHash,
23290
23399
  format,
23400
+ ...input.importKey === undefined ? {} : { importKey: input.importKey },
23291
23401
  ...agentId === undefined ? {} : { agentId }
23292
23402
  }
23293
23403
  };
@@ -27145,6 +27255,95 @@ var DOCUMENT_STATUSES = [
27145
27255
  var DOCUMENT_SOURCE_TYPES = ["text", "url", "file"];
27146
27256
  // src/signet-os-types.ts
27147
27257
  var DEFAULT_APP_SIZE = { w: 4, h: 3 };
27258
+ // src/transcript-export.ts
27259
+ var ROLE_PREFIX = /^(user|assistant|system|tool(?:_result)?|human):\s?(.*)$/i;
27260
+ function normalizeRole(role) {
27261
+ switch (role.toLowerCase()) {
27262
+ case "user":
27263
+ case "human":
27264
+ return "user";
27265
+ case "assistant":
27266
+ return "assistant";
27267
+ case "system":
27268
+ return "system";
27269
+ case "tool":
27270
+ case "tool_result":
27271
+ return "tool";
27272
+ default:
27273
+ return "unknown";
27274
+ }
27275
+ }
27276
+ function parseTranscriptMessages(content) {
27277
+ try {
27278
+ const value = JSON.parse(content);
27279
+ if (Array.isArray(value) && value.every((m2) => m2 !== null && typeof m2 === "object" && typeof m2.role === "string" && typeof m2.content === "string"))
27280
+ return value.map((m2) => ({ role: normalizeRole(m2.role), content: m2.content }));
27281
+ } catch {}
27282
+ const jsonl = parseJsonlMessages(content);
27283
+ if (jsonl.length >= 2)
27284
+ return jsonl;
27285
+ const prefixed = parsePrefixedMessages(content);
27286
+ return prefixed.length ? prefixed : jsonl;
27287
+ }
27288
+ function parseJsonlMessages(content) {
27289
+ const messages = [];
27290
+ for (const line of content.split(/\r\n|\r|\n/)) {
27291
+ const trimmed = line.trim();
27292
+ if (trimmed.length === 0)
27293
+ continue;
27294
+ try {
27295
+ const entry = JSON.parse(trimmed);
27296
+ if (typeof entry.role === "string" && typeof entry.content === "string" && entry.content.length > 0) {
27297
+ messages.push({ role: normalizeRole(entry.role), content: entry.content });
27298
+ }
27299
+ } catch {}
27300
+ }
27301
+ return messages;
27302
+ }
27303
+ function parsePrefixedMessages(content) {
27304
+ const messages = [];
27305
+ let currentRole = null;
27306
+ let currentLines = [];
27307
+ const flush = () => {
27308
+ if (currentRole !== null) {
27309
+ const text = currentLines.join(`
27310
+ `).trim();
27311
+ if (text.length > 0) {
27312
+ messages.push({ role: currentRole, content: text });
27313
+ }
27314
+ }
27315
+ currentRole = null;
27316
+ currentLines = [];
27317
+ };
27318
+ for (const rawLine of content.split(/\r\n|\r|\n/)) {
27319
+ const line = rawLine.trim();
27320
+ const match = ROLE_PREFIX.exec(line);
27321
+ if (match) {
27322
+ flush();
27323
+ currentRole = normalizeRole(match[1] ?? "");
27324
+ const rest = match[2] ?? "";
27325
+ currentLines = rest.length > 0 ? [rest] : [];
27326
+ } else if (currentRole !== null) {
27327
+ currentLines.push(line);
27328
+ }
27329
+ }
27330
+ flush();
27331
+ return messages;
27332
+ }
27333
+ function buildExportTranscriptRecord(row) {
27334
+ const messages = parseTranscriptMessages(row.content);
27335
+ return {
27336
+ id: `signet-db-${row.session_key}`,
27337
+ source: "signet",
27338
+ harness: row.harness ?? "signet",
27339
+ agent_id: row.agent_id,
27340
+ session_key: row.session_key,
27341
+ project: row.project ?? null,
27342
+ timestamp: row.created_at,
27343
+ message_count: messages.length,
27344
+ messages
27345
+ };
27346
+ }
27148
27347
  export {
27149
27348
  writeRegistry,
27150
27349
  writeGraphiqState,
@@ -27228,6 +27427,7 @@ export {
27228
27427
  parseYamlDocument,
27229
27428
  parseWebSettings,
27230
27429
  parseTranscriptSkills,
27430
+ parseTranscriptMessages,
27231
27431
  parseSoul,
27232
27432
  parseSimpleYaml,
27233
27433
  parseRuntimeYaml,
@@ -27348,6 +27548,7 @@ export {
27348
27548
  buildLaunchdPlist,
27349
27549
  buildLaunchdEnvironment,
27350
27550
  buildFtsMatchQuery,
27551
+ buildExportTranscriptRecord,
27351
27552
  buildArchitectureDoc,
27352
27553
  buildAgentMemoryConfig,
27353
27554
  assessMemoryContent,