@signetai/connector-base 0.226.26 → 0.228.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/agent-dir.js +562 -435
  2. package/dist/index.js +558 -431
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import { dirname as dirname2, isAbsolute, join as join3, relative, sep } from "n
40
40
 
41
41
  // ../../platform/core/dist/index.js
42
42
  import { createRequire } from "node:module";
43
- import { dirname, join } from "node:path";
43
+ import { dirname, join, resolve } from "node:path";
44
44
  import { fileURLToPath } from "node:url";
45
45
  import {
46
46
  execFile as nodeExecFile,
@@ -52,29 +52,30 @@ import {
52
52
  import { promisify } from "node:util";
53
53
  import { createHash } from "node:crypto";
54
54
  import { homedir as homedir2 } from "node:os";
55
- import { join as join2, resolve } from "node:path";
55
+ import { join as join2, resolve as resolve2 } from "node:path";
56
+ import { constants as fsConstants } from "node:fs";
56
57
  import {
57
- closeSync as closeSync2,
58
- existsSync as existsSync7,
58
+ closeSync as closeSync3,
59
+ existsSync as existsSync12,
59
60
  fsyncSync as fsyncSync2,
60
- mkdirSync as mkdirSync3,
61
- openSync as openSync2,
62
- readFileSync as readFileSync5,
63
- renameSync as renameSync2,
64
- rmSync,
65
- statSync as statSync3,
61
+ mkdirSync as mkdirSync6,
62
+ openSync as openSync3,
63
+ readFileSync as readFileSync9,
64
+ renameSync as renameSync3,
65
+ rmSync as rmSync3,
66
+ statSync as statSync5,
66
67
  writeSync
67
68
  } from "node:fs";
68
69
  import { homedir as homedir4 } from "node:os";
69
- import { dirname as dirname4, join as join8, resolve as resolve2 } from "node:path";
70
+ import { dirname as dirname5, join as join13, resolve as resolve7 } from "node:path";
70
71
  import { createRequire as createRequire2 } from "node:module";
71
72
  import { homedir as homedir5 } from "node:os";
72
- import { dirname as dirname5, join as join9, resolve as resolve3 } from "node:path";
73
+ import { dirname as dirname6, join as join14, resolve as resolve8 } from "node:path";
73
74
  import { homedir as homedir6, platform as platform2 } from "node:os";
74
- import { basename, dirname as dirname6, resolve as resolve5 } from "node:path";
75
+ import { basename, dirname as dirname7, resolve as resolve9 } from "node:path";
75
76
  import { homedir as homedir8 } from "node:os";
76
- import { existsSync as existsSync14, lstatSync, mkdirSync as mkdirSync8, readdirSync as readdirSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
77
- import { join as join14 } from "node:path";
77
+ import { existsSync as existsSync18, lstatSync as lstatSync3, mkdirSync as mkdirSync10, readdirSync as readdirSync9, symlinkSync as symlinkSync2, unlinkSync as unlinkSync2 } from "node:fs";
78
+ import { join as join18 } from "node:path";
78
79
  var __create2 = Object.create;
79
80
  var __getProtoOf2 = Object.getPrototypeOf;
80
81
  var __defProp2 = Object.defineProperty;
@@ -10752,6 +10753,9 @@ function up4(db) {
10752
10753
  WHERE resolved_at IS NULL;
10753
10754
  `);
10754
10755
  }
10756
+ function up5(db) {
10757
+ db.exec("DROP TABLE IF EXISTS mcp_invocations");
10758
+ }
10755
10759
  var MEMORIES_FTS_TOKENIZER = "unicode61";
10756
10760
  var FTS_STATE_TABLE = "memories_fts_state";
10757
10761
  function normalizeSql(sql) {
@@ -10867,7 +10871,7 @@ function memoriesFtsNeedsTokenizerRepair(sql) {
10867
10871
  return true;
10868
10872
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER}'`);
10869
10873
  }
10870
- function up5(db) {
10874
+ function up6(db) {
10871
10875
  db.exec(`
10872
10876
  CREATE TABLE IF NOT EXISTS schema_migrations (
10873
10877
  version INTEGER PRIMARY KEY,
@@ -10965,7 +10969,7 @@ function addColumnIfMissing2(db, table, column, definition) {
10965
10969
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
10966
10970
  }
10967
10971
  }
10968
- function up6(db) {
10972
+ function up7(db) {
10969
10973
  addColumnIfMissing2(db, "memories", "content_hash", "TEXT");
10970
10974
  addColumnIfMissing2(db, "memories", "normalized_content", "TEXT");
10971
10975
  addColumnIfMissing2(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
@@ -11083,7 +11087,7 @@ function addColumnIfMissing3(db, table, column, definition) {
11083
11087
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11084
11088
  return true;
11085
11089
  }
11086
- function up7(db) {
11090
+ function up8(db) {
11087
11091
  addColumnIfMissing3(db, "memories", "why", "TEXT");
11088
11092
  addColumnIfMissing3(db, "memories", "project", "TEXT");
11089
11093
  db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
@@ -11120,7 +11124,7 @@ function addColumnIfMissing4(db, table, column, definition) {
11120
11124
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11121
11125
  }
11122
11126
  }
11123
- function up8(db) {
11127
+ function up9(db) {
11124
11128
  addColumnIfMissing4(db, "memory_history", "actor_type", "TEXT");
11125
11129
  addColumnIfMissing4(db, "memory_history", "session_id", "TEXT");
11126
11130
  addColumnIfMissing4(db, "memory_history", "request_id", "TEXT");
@@ -11153,7 +11157,7 @@ function addColumnIfMissing5(db, table, column, definition) {
11153
11157
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11154
11158
  }
11155
11159
  }
11156
- function up9(db) {
11160
+ function up10(db) {
11157
11161
  addColumnIfMissing5(db, "entities", "canonical_name", "TEXT");
11158
11162
  addColumnIfMissing5(db, "entities", "mentions", "INTEGER DEFAULT 0");
11159
11163
  addColumnIfMissing5(db, "entities", "embedding", "BLOB");
@@ -11170,7 +11174,7 @@ function hasColumn4(db, table, column) {
11170
11174
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
11171
11175
  return rows.some((r2) => r2.name === column);
11172
11176
  }
11173
- function up10(db) {
11177
+ function up11(db) {
11174
11178
  if (!hasColumn4(db, "memories", "idempotency_key")) {
11175
11179
  db.exec("ALTER TABLE memories ADD COLUMN idempotency_key TEXT");
11176
11180
  }
@@ -11185,7 +11189,7 @@ function hasColumn5(db, table, column) {
11185
11189
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
11186
11190
  return rows.some((r2) => r2.name === column);
11187
11191
  }
11188
- function up11(db) {
11192
+ function up12(db) {
11189
11193
  db.exec(`
11190
11194
  CREATE TABLE IF NOT EXISTS documents (
11191
11195
  id TEXT PRIMARY KEY,
@@ -11242,7 +11246,7 @@ function up11(db) {
11242
11246
  db.exec("ALTER TABLE memory_jobs ADD COLUMN document_id TEXT");
11243
11247
  }
11244
11248
  }
11245
- function up12(db) {
11249
+ function up13(db) {
11246
11250
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='embeddings'").all();
11247
11251
  if (tables.length === 0)
11248
11252
  return;
@@ -11259,7 +11263,7 @@ function up12(db) {
11259
11263
  ON embeddings(content_hash)
11260
11264
  `);
11261
11265
  }
11262
- function up13(db) {
11266
+ function up14(db) {
11263
11267
  db.exec(`
11264
11268
  CREATE TABLE IF NOT EXISTS summary_jobs (
11265
11269
  id TEXT PRIMARY KEY,
@@ -11279,7 +11283,7 @@ function up13(db) {
11279
11283
  db.exec(`CREATE INDEX IF NOT EXISTS idx_summary_jobs_status
11280
11284
  ON summary_jobs(status)`);
11281
11285
  }
11282
- function up14(db) {
11286
+ function up15(db) {
11283
11287
  db.exec(`
11284
11288
  CREATE TABLE IF NOT EXISTS umap_cache (
11285
11289
  id INTEGER PRIMARY KEY,
@@ -11290,7 +11294,7 @@ function up14(db) {
11290
11294
  )
11291
11295
  `);
11292
11296
  }
11293
- function up15(db) {
11297
+ function up16(db) {
11294
11298
  db.exec(`
11295
11299
  CREATE TABLE IF NOT EXISTS session_scores (
11296
11300
  id TEXT PRIMARY KEY,
@@ -11310,7 +11314,7 @@ function up15(db) {
11310
11314
  ON session_scores(session_key);
11311
11315
  `);
11312
11316
  }
11313
- function up16(db) {
11317
+ function up17(db) {
11314
11318
  db.exec(`
11315
11319
  CREATE TABLE IF NOT EXISTS scheduled_tasks (
11316
11320
  id TEXT PRIMARY KEY,
@@ -11351,7 +11355,7 @@ function addColumnIfMissing6(db, table, column, definition) {
11351
11355
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11352
11356
  }
11353
11357
  }
11354
- function up17(db) {
11358
+ function up18(db) {
11355
11359
  db.exec(`
11356
11360
  CREATE TABLE IF NOT EXISTS ingestion_jobs (
11357
11361
  id TEXT PRIMARY KEY,
@@ -11377,7 +11381,7 @@ function up17(db) {
11377
11381
  addColumnIfMissing6(db, "memories", "source_path", "TEXT");
11378
11382
  addColumnIfMissing6(db, "memories", "source_section", "TEXT");
11379
11383
  }
11380
- function up18(db) {
11384
+ function up19(db) {
11381
11385
  db.exec(`
11382
11386
  CREATE TABLE IF NOT EXISTS telemetry_events (
11383
11387
  id TEXT PRIMARY KEY,
@@ -11402,7 +11406,7 @@ function addColumnIfMissing7(db, table, column, definition) {
11402
11406
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11403
11407
  }
11404
11408
  }
11405
- function up19(db) {
11409
+ function up20(db) {
11406
11410
  db.exec(`
11407
11411
  CREATE TABLE IF NOT EXISTS session_memories (
11408
11412
  id TEXT PRIMARY KEY,
@@ -11429,7 +11433,7 @@ function up19(db) {
11429
11433
  addColumnIfMissing7(db, "session_scores", "confidence", "REAL");
11430
11434
  addColumnIfMissing7(db, "session_scores", "continuity_reasoning", "TEXT");
11431
11435
  }
11432
- function up20(db) {
11436
+ function up21(db) {
11433
11437
  db.exec(`
11434
11438
  CREATE TABLE IF NOT EXISTS session_checkpoints (
11435
11439
  id TEXT PRIMARY KEY,
@@ -11451,7 +11455,7 @@ function up20(db) {
11451
11455
  ON session_checkpoints(project_normalized, created_at DESC);
11452
11456
  `);
11453
11457
  }
11454
- function up21(db) {
11458
+ function up22(db) {
11455
11459
  const cols = db.prepare("PRAGMA table_info(scheduled_tasks)").all();
11456
11460
  const colNames = new Set(cols.flatMap((c2) => typeof c2.name === "string" ? [c2.name] : []));
11457
11461
  if (!colNames.has("skill_name")) {
@@ -11462,7 +11466,7 @@ function up21(db) {
11462
11466
  CHECK (skill_mode IN ('inject', 'slash') OR skill_mode IS NULL)`);
11463
11467
  }
11464
11468
  }
11465
- function up22(db) {
11469
+ function up23(db) {
11466
11470
  const existing = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='skill_meta'").get();
11467
11471
  if (existing)
11468
11472
  return;
@@ -11494,7 +11498,7 @@ function up22(db) {
11494
11498
  CREATE INDEX idx_skill_meta_source ON skill_meta(source);
11495
11499
  `);
11496
11500
  }
11497
- function up23(db) {
11501
+ function up24(db) {
11498
11502
  const entityCols = db.prepare("PRAGMA table_info(entities)").all();
11499
11503
  const entityColNames = new Set(entityCols.flatMap((c2) => typeof c2.name === "string" ? [c2.name] : []));
11500
11504
  if (!entityColNames.has("agent_id")) {
@@ -11579,13 +11583,13 @@ function addColumnIfMissing8(db, table, column, definition) {
11579
11583
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11580
11584
  }
11581
11585
  }
11582
- function up24(db) {
11586
+ function up25(db) {
11583
11587
  addColumnIfMissing8(db, "session_memories", "entity_slot", "INTEGER");
11584
11588
  addColumnIfMissing8(db, "session_memories", "aspect_slot", "INTEGER");
11585
11589
  addColumnIfMissing8(db, "session_memories", "is_constraint", "INTEGER NOT NULL DEFAULT 0");
11586
11590
  addColumnIfMissing8(db, "session_memories", "structural_density", "INTEGER");
11587
11591
  }
11588
- function up25(db) {
11592
+ function up26(db) {
11589
11593
  const columns = db.prepare("PRAGMA table_info(session_checkpoints)").all();
11590
11594
  const columnNames = new Set(columns.flatMap((column) => typeof column.name === "string" ? [column.name] : []));
11591
11595
  if (!columnNames.has("focal_entity_ids")) {
@@ -11610,25 +11614,25 @@ function addColumnIfMissing9(db, table, column, definition) {
11610
11614
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11611
11615
  }
11612
11616
  }
11613
- function up26(db) {
11617
+ function up27(db) {
11614
11618
  addColumnIfMissing9(db, "entities", "pinned", "INTEGER NOT NULL DEFAULT 0");
11615
11619
  addColumnIfMissing9(db, "entities", "pinned_at", "TEXT");
11616
11620
  db.exec("CREATE INDEX IF NOT EXISTS idx_entities_pinned ON entities(agent_id, pinned, pinned_at DESC)");
11617
11621
  }
11618
- function up27(_db) {}
11619
11622
  function up28(_db) {}
11623
+ function up29(_db) {}
11620
11624
  function addColumnIfMissing10(db, table, column, definition) {
11621
11625
  const cols = db.prepare(`PRAGMA table_info(${table})`).all();
11622
11626
  if (!cols.some((c2) => c2.name === column)) {
11623
11627
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11624
11628
  }
11625
11629
  }
11626
- function up29(db) {
11630
+ function up30(db) {
11627
11631
  addColumnIfMissing10(db, "session_memories", "agent_relevance_score", "REAL");
11628
11632
  addColumnIfMissing10(db, "session_memories", "agent_feedback_count", "INTEGER DEFAULT 0");
11629
11633
  }
11630
- function up30(_db) {}
11631
- function up31(db) {
11634
+ function up31(_db) {}
11635
+ function up32(db) {
11632
11636
  db.exec(`
11633
11637
  UPDATE entities
11634
11638
  SET canonical_name = REPLACE(REPLACE(REPLACE(
@@ -11637,7 +11641,7 @@ function up31(db) {
11637
11641
  WHERE canonical_name IS NULL
11638
11642
  `);
11639
11643
  }
11640
- function up32(db) {
11644
+ function up33(db) {
11641
11645
  db.exec(`
11642
11646
  CREATE TABLE IF NOT EXISTS memories_cold (
11643
11647
  archive_id TEXT PRIMARY KEY,
@@ -11674,7 +11678,7 @@ function up32(db) {
11674
11678
  CREATE INDEX IF NOT EXISTS idx_cold_source ON memories_cold(cold_source_id);
11675
11679
  `);
11676
11680
  }
11677
- function up33(db) {
11681
+ function up34(db) {
11678
11682
  db.exec(`
11679
11683
  CREATE TABLE IF NOT EXISTS session_summaries (
11680
11684
  id TEXT PRIMARY KEY,
@@ -11719,7 +11723,7 @@ function up33(db) {
11719
11723
  WHERE session_key IS NOT NULL;
11720
11724
  `);
11721
11725
  }
11722
- function up34(db) {
11726
+ function up35(db) {
11723
11727
  db.exec(`
11724
11728
  CREATE TABLE IF NOT EXISTS memory_jobs_new (
11725
11729
  id TEXT PRIMARY KEY,
@@ -11764,7 +11768,7 @@ function up34(db) {
11764
11768
  ON memory_jobs(failed_at);
11765
11769
  `);
11766
11770
  }
11767
- function up35(db) {
11771
+ function up36(db) {
11768
11772
  const depCols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
11769
11773
  if (!depCols.some((c2) => c2.name === "reason")) {
11770
11774
  db.exec("ALTER TABLE entity_dependencies ADD COLUMN reason TEXT");
@@ -11774,7 +11778,7 @@ function up35(db) {
11774
11778
  db.exec("ALTER TABLE entities ADD COLUMN last_synthesized_at TEXT");
11775
11779
  }
11776
11780
  }
11777
- function up36(db) {
11781
+ function up37(db) {
11778
11782
  const cols = db.prepare("PRAGMA table_info(embeddings)").all();
11779
11783
  if (cols.length === 0)
11780
11784
  return;
@@ -11782,14 +11786,14 @@ function up36(db) {
11782
11786
  db.exec("ALTER TABLE embeddings ADD COLUMN vector BLOB");
11783
11787
  }
11784
11788
  }
11785
- function up37(db) {
11789
+ function up38(db) {
11786
11790
  const cols = db.prepare("PRAGMA table_info(memories)").all();
11787
11791
  if (!cols.some((c2) => c2.name === "scope")) {
11788
11792
  db.exec("ALTER TABLE memories ADD COLUMN scope TEXT DEFAULT NULL");
11789
11793
  }
11790
11794
  db.exec("CREATE INDEX IF NOT EXISTS idx_memories_scope ON memories(scope) WHERE scope IS NOT NULL");
11791
11795
  }
11792
- function up38(db) {
11796
+ function up39(db) {
11793
11797
  db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
11794
11798
  db.exec(`
11795
11799
  CREATE UNIQUE INDEX idx_memories_content_hash_unique
@@ -11797,7 +11801,7 @@ function up38(db) {
11797
11801
  WHERE content_hash IS NOT NULL AND is_deleted = 0
11798
11802
  `);
11799
11803
  }
11800
- function up39(db) {
11804
+ function up40(db) {
11801
11805
  db.exec(`
11802
11806
  CREATE VIRTUAL TABLE IF NOT EXISTS entities_fts USING fts5(
11803
11807
  name, canonical_name,
@@ -11829,13 +11833,13 @@ function up39(db) {
11829
11833
  END
11830
11834
  `);
11831
11835
  }
11832
- function up40(db) {
11836
+ function up41(db) {
11833
11837
  const cols = db.prepare("PRAGMA table_info(entity_dependencies)").all();
11834
11838
  if (!cols.some((c2) => c2.name === "confidence")) {
11835
11839
  db.exec("ALTER TABLE entity_dependencies ADD COLUMN confidence REAL DEFAULT 0.7");
11836
11840
  }
11837
11841
  }
11838
- function up41(db) {
11842
+ function up42(db) {
11839
11843
  db.exec(`
11840
11844
  CREATE TABLE IF NOT EXISTS entity_communities (
11841
11845
  id TEXT PRIMARY KEY,
@@ -11853,7 +11857,7 @@ function up41(db) {
11853
11857
  db.exec("ALTER TABLE entities ADD COLUMN community_id TEXT REFERENCES entity_communities(id)");
11854
11858
  }
11855
11859
  }
11856
- function up42(db) {
11860
+ function up43(db) {
11857
11861
  db.exec(`
11858
11862
  CREATE TABLE IF NOT EXISTS memory_hints (
11859
11863
  id TEXT PRIMARY KEY,
@@ -11893,7 +11897,7 @@ function up42(db) {
11893
11897
  END
11894
11898
  `);
11895
11899
  }
11896
- function up43(db) {
11900
+ function up44(db) {
11897
11901
  db.exec(`
11898
11902
  DELETE FROM entity_dependencies
11899
11903
  WHERE id NOT IN (
@@ -11911,7 +11915,7 @@ function up43(db) {
11911
11915
  )
11912
11916
  `);
11913
11917
  }
11914
- function up44(db) {
11918
+ function up45(db) {
11915
11919
  db.exec(`
11916
11920
  CREATE TABLE IF NOT EXISTS session_transcripts (
11917
11921
  session_key TEXT PRIMARY KEY,
@@ -11934,7 +11938,7 @@ function addColumnIfMissing11(db, table, column, definition) {
11934
11938
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
11935
11939
  }
11936
11940
  }
11937
- function up45(db) {
11941
+ function up46(db) {
11938
11942
  addColumnIfMissing11(db, "session_memories", "path_json", "TEXT");
11939
11943
  db.exec(`
11940
11944
  CREATE TABLE IF NOT EXISTS path_feedback_events (
@@ -12009,7 +12013,7 @@ function addColumnIfMissing12(db, table, column, definition) {
12009
12013
  return;
12010
12014
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12011
12015
  }
12012
- function up46(db) {
12016
+ function up47(db) {
12013
12017
  addColumnIfMissing12(db, "session_memories", "entity_slot", "INTEGER");
12014
12018
  addColumnIfMissing12(db, "session_memories", "aspect_slot", "INTEGER");
12015
12019
  addColumnIfMissing12(db, "session_memories", "is_constraint", "INTEGER NOT NULL DEFAULT 0");
@@ -12097,7 +12101,7 @@ function addColumnIfMissing13(db, table, column, definition) {
12097
12101
  return;
12098
12102
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12099
12103
  }
12100
- function up47(db) {
12104
+ function up48(db) {
12101
12105
  db.exec(`
12102
12106
  CREATE TABLE IF NOT EXISTS agents (
12103
12107
  id TEXT PRIMARY KEY,
@@ -12126,7 +12130,7 @@ function addColumnIfMissing14(db, table, column, definition) {
12126
12130
  return;
12127
12131
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12128
12132
  }
12129
- function up48(db) {
12133
+ function up49(db) {
12130
12134
  addColumnIfMissing14(db, "session_summaries", "source_type", "TEXT");
12131
12135
  addColumnIfMissing14(db, "session_summaries", "source_ref", "TEXT");
12132
12136
  addColumnIfMissing14(db, "session_summaries", "meta_json", "TEXT");
@@ -12152,7 +12156,7 @@ function addColumnIfMissing15(db, table, column, definition) {
12152
12156
  return;
12153
12157
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12154
12158
  }
12155
- function up49(db) {
12159
+ function up50(db) {
12156
12160
  addColumnIfMissing15(db, "session_transcripts", "updated_at", "TEXT");
12157
12161
  addColumnIfMissing15(db, "summary_jobs", "agent_id", "TEXT NOT NULL DEFAULT 'default'");
12158
12162
  addColumnIfMissing15(db, "session_scores", "agent_id", "TEXT NOT NULL DEFAULT 'default'");
@@ -12223,7 +12227,7 @@ function up49(db) {
12223
12227
  ON memory_md_heads(lease_expires_at);
12224
12228
  `);
12225
12229
  }
12226
- function up50(db) {
12230
+ function up51(db) {
12227
12231
  db.exec(`
12228
12232
  DROP INDEX IF EXISTS idx_summaries_session_depth;
12229
12233
 
@@ -12284,7 +12288,7 @@ function up50(db) {
12284
12288
  AND COALESCE(source_type, 'summary') = 'summary';
12285
12289
  `);
12286
12290
  }
12287
- function up51(db) {
12291
+ function up52(db) {
12288
12292
  db.exec(`
12289
12293
  DROP TRIGGER IF EXISTS session_transcripts_fts_ai;
12290
12294
  DROP TRIGGER IF EXISTS session_transcripts_fts_ad;
@@ -12382,7 +12386,7 @@ function up51(db) {
12382
12386
  AND COALESCE(source_type, 'summary') = 'summary';
12383
12387
  `);
12384
12388
  }
12385
- function up52(db) {
12389
+ function up53(db) {
12386
12390
  db.exec(`
12387
12391
  CREATE TABLE IF NOT EXISTS memory_thread_heads (
12388
12392
  agent_id TEXT NOT NULL DEFAULT 'default',
@@ -12500,7 +12504,7 @@ function up52(db) {
12500
12504
  WHERE excluded.latest_at >= memory_thread_heads.latest_at;
12501
12505
  `);
12502
12506
  }
12503
- function up53(db) {
12507
+ function up54(db) {
12504
12508
  db.exec(`
12505
12509
  CREATE TABLE IF NOT EXISTS session_extract_cursors (
12506
12510
  session_key TEXT NOT NULL,
@@ -12517,7 +12521,7 @@ function hasTable(db, name) {
12517
12521
  WHERE type = 'table' AND name = ?
12518
12522
  LIMIT 1`).get(name) !== undefined;
12519
12523
  }
12520
- function up54(db) {
12524
+ function up55(db) {
12521
12525
  db.exec(`
12522
12526
  CREATE TABLE IF NOT EXISTS entity_dependency_history (
12523
12527
  id TEXT PRIMARY KEY,
@@ -12687,7 +12691,7 @@ function addColumnIfMissing16(db, table, column, definition) {
12687
12691
  return;
12688
12692
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12689
12693
  }
12690
- function up55(db) {
12694
+ function up56(db) {
12691
12695
  addColumnIfMissing16(db, "summary_jobs", "session_id", "TEXT");
12692
12696
  addColumnIfMissing16(db, "summary_jobs", "trigger", "TEXT NOT NULL DEFAULT 'session_end'");
12693
12697
  addColumnIfMissing16(db, "summary_jobs", "captured_at", "TEXT");
@@ -12779,24 +12783,8 @@ function up55(db) {
12779
12783
  VALUES ('rebuild');
12780
12784
  `);
12781
12785
  }
12782
- function up56(db) {
12783
- db.exec(`
12784
- CREATE TABLE IF NOT EXISTS mcp_invocations (
12785
- id TEXT PRIMARY KEY,
12786
- server_id TEXT NOT NULL,
12787
- tool_name TEXT NOT NULL,
12788
- agent_id TEXT NOT NULL DEFAULT 'default',
12789
- source TEXT NOT NULL CHECK(source IN ('cli','agent','mcp','dashboard')),
12790
- latency_ms INTEGER NOT NULL,
12791
- success INTEGER NOT NULL DEFAULT 1,
12792
- error_text TEXT,
12793
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
12794
- );
12795
- CREATE INDEX IF NOT EXISTS idx_mcp_inv_server ON mcp_invocations(server_id, created_at);
12796
- CREATE INDEX IF NOT EXISTS idx_mcp_inv_agent ON mcp_invocations(agent_id, created_at);
12797
- `);
12798
- }
12799
- function up57(db) {
12786
+ function up57(_db) {}
12787
+ function up58(db) {
12800
12788
  db.exec(`
12801
12789
  CREATE TABLE IF NOT EXISTS skill_invocations (
12802
12790
  id TEXT PRIMARY KEY,
@@ -12812,7 +12800,7 @@ function up57(db) {
12812
12800
  CREATE INDEX IF NOT EXISTS idx_skill_inv_agent ON skill_invocations(agent_id, created_at);
12813
12801
  `);
12814
12802
  }
12815
- function up58(db) {
12803
+ function up59(db) {
12816
12804
  db.exec(`
12817
12805
  CREATE TABLE IF NOT EXISTS task_scope_hints (
12818
12806
  task_id TEXT PRIMARY KEY REFERENCES scheduled_tasks(id) ON DELETE CASCADE,
@@ -12843,7 +12831,7 @@ function up58(db) {
12843
12831
  ON task_scope_hints(agent_id, updated_at);
12844
12832
  `);
12845
12833
  }
12846
- function up59(db) {
12834
+ function up60(db) {
12847
12835
  db.exec(`
12848
12836
  CREATE TABLE IF NOT EXISTS dreaming_state (
12849
12837
  agent_id TEXT PRIMARY KEY NOT NULL,
@@ -12886,7 +12874,7 @@ function ensureMemoriesScopeColumns(db) {
12886
12874
  if (!names.has("scope"))
12887
12875
  db.exec("ALTER TABLE memories ADD COLUMN scope TEXT");
12888
12876
  }
12889
- function up60(db) {
12877
+ function up61(db) {
12890
12878
  ensureMemoriesScopeColumns(db);
12891
12879
  db.exec("DROP INDEX IF EXISTS idx_memories_content_hash_unique");
12892
12880
  db.exec(`
@@ -12899,20 +12887,20 @@ function up60(db) {
12899
12887
  WHERE content_hash IS NOT NULL AND is_deleted = 0
12900
12888
  `);
12901
12889
  }
12902
- function up61(db) {
12890
+ function up62(db) {
12903
12891
  const sql = readMemoriesFtsSql(db);
12904
12892
  if (sql !== null && !memoriesFtsNeedsTokenizerRepair(sql))
12905
12893
  return;
12906
12894
  recreateMemoriesFts(db);
12907
12895
  }
12908
- function up62(db) {
12896
+ function up63(db) {
12909
12897
  db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_order
12910
12898
  ON entities(agent_id, pinned DESC, pinned_at DESC, mentions DESC, updated_at DESC, name)`);
12911
12899
  db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_extracted_mentions
12912
12900
  ON entities(entity_type, mentions)
12913
12901
  WHERE entity_type = 'extracted'`);
12914
12902
  }
12915
- function up63(db) {
12903
+ function up64(db) {
12916
12904
  const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
12917
12905
  if (!cols.some((col) => col.name === "claim_key")) {
12918
12906
  db.exec("ALTER TABLE entity_attributes ADD COLUMN claim_key TEXT");
@@ -12921,7 +12909,7 @@ function up63(db) {
12921
12909
  ON entity_attributes(agent_id, aspect_id, claim_key, status)
12922
12910
  WHERE claim_key IS NOT NULL`);
12923
12911
  }
12924
- function up64(db) {
12912
+ function up65(db) {
12925
12913
  const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
12926
12914
  if (!cols.some((col) => col.name === "group_key")) {
12927
12915
  db.exec("ALTER TABLE entity_attributes ADD COLUMN group_key TEXT");
@@ -12933,13 +12921,13 @@ function up64(db) {
12933
12921
  ON entity_attributes(agent_id, aspect_id, group_key, claim_key, status)
12934
12922
  WHERE claim_key IS NOT NULL`);
12935
12923
  }
12936
- function up65(db) {
12924
+ function up66(db) {
12937
12925
  const cols = db.prepare("PRAGMA table_info(memory_artifacts)").all();
12938
12926
  if (cols.some((col) => col.name === "source_mtime_ms"))
12939
12927
  return;
12940
12928
  db.exec("ALTER TABLE memory_artifacts ADD COLUMN source_mtime_ms REAL");
12941
12929
  }
12942
- function up66(db) {
12930
+ function up67(db) {
12943
12931
  const cols = db.prepare("PRAGMA table_info(memory_artifacts)").all();
12944
12932
  const names = new Set(cols.map((col) => col.name));
12945
12933
  if (!names.has("is_deleted")) {
@@ -12953,7 +12941,7 @@ function up66(db) {
12953
12941
  ON memory_artifacts(agent_id, is_deleted, deleted_at)
12954
12942
  `);
12955
12943
  }
12956
- function up67(db) {
12944
+ function up68(db) {
12957
12945
  db.exec("DROP TRIGGER IF EXISTS memories_au");
12958
12946
  db.exec(`
12959
12947
  CREATE TRIGGER IF NOT EXISTS memories_au AFTER UPDATE OF content ON memories BEGIN
@@ -12971,7 +12959,7 @@ function addColumnIfMissing17(db, table, column, definition) {
12971
12959
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
12972
12960
  }
12973
12961
  }
12974
- function up68(db) {
12962
+ function up69(db) {
12975
12963
  for (const table of ["entities", "entity_communities", "entity_attributes", "entity_dependencies"]) {
12976
12964
  addColumnIfMissing17(db, table, "source_id", "TEXT");
12977
12965
  addColumnIfMissing17(db, table, "source_kind", "TEXT");
@@ -12991,7 +12979,7 @@ function hasColumn7(db, table, column) {
12991
12979
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
12992
12980
  return rows.some((row) => row.name === column);
12993
12981
  }
12994
- function up69(db) {
12982
+ function up70(db) {
12995
12983
  if (!hasTable2(db, "embeddings"))
12996
12984
  return;
12997
12985
  if (!hasColumn7(db, "embeddings", "agent_id")) {
@@ -12999,7 +12987,7 @@ function up69(db) {
12999
12987
  }
13000
12988
  db.exec("CREATE INDEX IF NOT EXISTS idx_embeddings_agent_source ON embeddings(agent_id, source_type, source_id)");
13001
12989
  }
13002
- function up70(db) {
12990
+ function up71(db) {
13003
12991
  db.exec(`
13004
12992
  CREATE TABLE IF NOT EXISTS memory_search_telemetry (
13005
12993
  id TEXT PRIMARY KEY,
@@ -13040,7 +13028,7 @@ function addColumnIfMissing18(db, table, column, definition) {
13040
13028
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13041
13029
  }
13042
13030
  }
13043
- function up71(db) {
13031
+ function up72(db) {
13044
13032
  db.exec(`
13045
13033
  CREATE TABLE IF NOT EXISTS ontology_proposals (
13046
13034
  id TEXT PRIMARY KEY,
@@ -13083,7 +13071,7 @@ function up71(db) {
13083
13071
  db.exec(`CREATE INDEX IF NOT EXISTS idx_${table}_proposal ON ${table}(agent_id, proposal_id)`);
13084
13072
  }
13085
13073
  }
13086
- function up72(db) {
13074
+ function up73(db) {
13087
13075
  db.exec(`
13088
13076
  CREATE TABLE IF NOT EXISTS daily_reflections (
13089
13077
  id TEXT PRIMARY KEY,
@@ -13110,7 +13098,7 @@ function up72(db) {
13110
13098
  WHERE content_key IS NOT NULL;
13111
13099
  `);
13112
13100
  }
13113
- function up73(db) {
13101
+ function up74(db) {
13114
13102
  const cols = db.prepare("PRAGMA table_info(daily_reflections)").all();
13115
13103
  const colNames = new Set(cols.flatMap((c2) => typeof c2.name === "string" ? [c2.name] : []));
13116
13104
  if (!colNames.has("content_key")) {
@@ -13147,7 +13135,7 @@ function backfillVersionRoots(db) {
13147
13135
  WHERE version_root_id IS NULL
13148
13136
  `);
13149
13137
  }
13150
- function up74(db) {
13138
+ function up75(db) {
13151
13139
  for (const table of ["entities", "entity_aspects", "entity_dependencies"]) {
13152
13140
  addColumnIfMissing19(db, table, "status", "TEXT NOT NULL DEFAULT 'active'");
13153
13141
  addColumnIfMissing19(db, table, "archived_at", "TEXT");
@@ -13182,7 +13170,7 @@ function up74(db) {
13182
13170
  ON entity_aspects(agent_id, proposal_id);
13183
13171
  `);
13184
13172
  }
13185
- function up75(db) {
13173
+ function up76(db) {
13186
13174
  db.exec(`
13187
13175
  CREATE TABLE IF NOT EXISTS epistemic_assertions (
13188
13176
  id TEXT PRIMARY KEY,
@@ -13238,7 +13226,7 @@ function ensureMemoriesScopeColumns2(db) {
13238
13226
  if (!names.has("runtime_path"))
13239
13227
  db.exec("ALTER TABLE memories ADD COLUMN runtime_path TEXT");
13240
13228
  }
13241
- function up76(db) {
13229
+ function up77(db) {
13242
13230
  ensureMemoriesScopeColumns2(db);
13243
13231
  db.exec("DROP INDEX IF EXISTS idx_memories_idempotency_key");
13244
13232
  db.exec(`
@@ -13252,7 +13240,7 @@ function up76(db) {
13252
13240
  WHERE idempotency_key IS NOT NULL AND is_deleted = 0
13253
13241
  `);
13254
13242
  }
13255
- function up77(db) {
13243
+ function up78(db) {
13256
13244
  db.exec(`
13257
13245
  CREATE TABLE IF NOT EXISTS session_context_epochs (
13258
13246
  session_key TEXT NOT NULL,
@@ -13287,7 +13275,7 @@ function up77(db) {
13287
13275
  ON session_recall_events(item_kind, item_id, created_at DESC);
13288
13276
  `);
13289
13277
  }
13290
- function up78(db) {
13278
+ function up79(db) {
13291
13279
  db.exec(`
13292
13280
  CREATE TABLE IF NOT EXISTS aggregate_memory_sources (
13293
13281
  aggregate_memory_id TEXT NOT NULL,
@@ -13306,7 +13294,7 @@ function addColumnIfMissing20(db, table, column, definition) {
13306
13294
  return;
13307
13295
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13308
13296
  }
13309
- function up79(db) {
13297
+ function up80(db) {
13310
13298
  addColumnIfMissing20(db, "memory_artifacts", "source_id", "TEXT");
13311
13299
  addColumnIfMissing20(db, "memory_artifacts", "source_root", "TEXT");
13312
13300
  addColumnIfMissing20(db, "memory_artifacts", "source_external_id", "TEXT");
@@ -13319,7 +13307,7 @@ function up79(db) {
13319
13307
  ON memory_artifacts(agent_id, source_id, source_root);
13320
13308
  `);
13321
13309
  }
13322
- function up80(db) {
13310
+ function up81(db) {
13323
13311
  db.exec(`
13324
13312
  CREATE TABLE IF NOT EXISTS temporal_edges (
13325
13313
  id TEXT PRIMARY KEY,
@@ -13342,7 +13330,7 @@ function up80(db) {
13342
13330
  ON temporal_edges(agent_id, subject_type, subject_id);
13343
13331
  `);
13344
13332
  }
13345
- function up81(db) {
13333
+ function up82(db) {
13346
13334
  db.exec(`
13347
13335
  CREATE TABLE IF NOT EXISTS entity_aliases (
13348
13336
  id TEXT PRIMARY KEY,
@@ -13366,7 +13354,7 @@ function up81(db) {
13366
13354
  ON entity_aliases(agent_id, canonical_alias, status);
13367
13355
  `);
13368
13356
  }
13369
- function up82(db) {
13357
+ function up83(db) {
13370
13358
  db.exec(`
13371
13359
  CREATE TABLE IF NOT EXISTS api_keys (
13372
13360
  id TEXT PRIMARY KEY,
@@ -13394,7 +13382,7 @@ function up82(db) {
13394
13382
  ON api_keys(connector, harness);
13395
13383
  `);
13396
13384
  }
13397
- function up83(db) {
13385
+ function up84(db) {
13398
13386
  db.exec(`
13399
13387
  CREATE TABLE IF NOT EXISTS transcript_capture_jobs (
13400
13388
  id TEXT PRIMARY KEY,
@@ -13429,7 +13417,7 @@ function hasColumn10(db, table, column) {
13429
13417
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
13430
13418
  return rows.some((row) => row.name === column);
13431
13419
  }
13432
- function up84(db) {
13420
+ function up85(db) {
13433
13421
  if (!hasColumn10(db, "documents", "agent_id")) {
13434
13422
  db.exec("ALTER TABLE documents ADD COLUMN agent_id TEXT NOT NULL DEFAULT 'default'");
13435
13423
  }
@@ -13515,7 +13503,7 @@ function up84(db) {
13515
13503
  db.exec("CREATE INDEX IF NOT EXISTS idx_documents_agent_project ON documents(agent_id, project)");
13516
13504
  db.exec("CREATE INDEX IF NOT EXISTS idx_documents_source_scope ON documents(source_url, agent_id, project)");
13517
13505
  }
13518
- function up85(db) {
13506
+ function up86(db) {
13519
13507
  db.exec(`
13520
13508
  CREATE TABLE IF NOT EXISTS aggregate_evidence_sources (
13521
13509
  aggregate_memory_id TEXT NOT NULL,
@@ -13537,7 +13525,7 @@ function hasColumn11(db, table, column) {
13537
13525
  return rows.some((row) => row.name === column);
13538
13526
  }
13539
13527
  var COLUMNS = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
13540
- function up86(db) {
13528
+ function up87(db) {
13541
13529
  for (const column of COLUMNS) {
13542
13530
  if (!hasColumn11(db, "skill_invocations", column)) {
13543
13531
  db.exec(`ALTER TABLE skill_invocations ADD COLUMN ${column} TEXT`);
@@ -13618,7 +13606,7 @@ function documentScopeColumnsPreservingExisting(db) {
13618
13606
  `);
13619
13607
  }
13620
13608
  try {
13621
- up84(db);
13609
+ up85(db);
13622
13610
  if (preserveAgentId) {
13623
13611
  db.exec(`
13624
13612
  UPDATE documents
@@ -13638,12 +13626,12 @@ function documentScopeColumnsPreservingExisting(db) {
13638
13626
  db.exec("DROP TABLE IF EXISTS temp.__signet_doc_project_guard");
13639
13627
  }
13640
13628
  }
13641
- function up87(db) {
13642
- up83(db);
13629
+ function up88(db) {
13630
+ up84(db);
13643
13631
  if (hasTable3(db, "documents")) {
13644
13632
  documentScopeColumnsPreservingExisting(db);
13645
13633
  }
13646
- up85(db);
13634
+ up86(db);
13647
13635
  addColumnIfMissing21(db, "memories", "superseded_by", "TEXT");
13648
13636
  addColumnIfMissing21(db, "memories", "superseded_at", "TEXT");
13649
13637
  addColumnIfMissing21(db, "memories", "superseded_reason", "TEXT");
@@ -13700,7 +13688,7 @@ function up87(db) {
13700
13688
  AND ${sourceAgentId} = ${targetAgentId}
13701
13689
  `);
13702
13690
  }
13703
- function up88(db) {
13691
+ function up89(db) {
13704
13692
  db.exec(`
13705
13693
  CREATE TABLE IF NOT EXISTS legacy_markdown_imports (
13706
13694
  path TEXT PRIMARY KEY,
@@ -13730,7 +13718,7 @@ function up88(db) {
13730
13718
  ON legacy_markdown_chunks(memory_id);
13731
13719
  `);
13732
13720
  }
13733
- function up89(db) {
13721
+ function up90(db) {
13734
13722
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name IN ('relations', 'entity_dependencies')").all();
13735
13723
  const tableNames = new Set(tables.map((r2) => String(r2.name)));
13736
13724
  if (!tableNames.has("relations") || !tableNames.has("entity_dependencies"))
@@ -13789,7 +13777,7 @@ function addColumnIfMissing22(db, table, column, definition) {
13789
13777
  return;
13790
13778
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13791
13779
  }
13792
- function up90(db) {
13780
+ function up91(db) {
13793
13781
  addColumnIfMissing22(db, "summary_jobs", "content_hash", "TEXT");
13794
13782
  db.exec(`
13795
13783
  CREATE INDEX IF NOT EXISTS idx_summary_jobs_agent_session_content_hash
@@ -13802,14 +13790,14 @@ function addColumnIfMissing23(db, table, column, definition) {
13802
13790
  return;
13803
13791
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
13804
13792
  }
13805
- function up91(db) {
13793
+ function up92(db) {
13806
13794
  addColumnIfMissing23(db, "summary_jobs", "boundary_reason", "TEXT");
13807
13795
  db.exec(`
13808
13796
  CREATE INDEX IF NOT EXISTS idx_summary_jobs_boundary_reason
13809
13797
  ON summary_jobs(agent_id, session_key, boundary_reason)
13810
13798
  `);
13811
13799
  }
13812
- function up92(db) {
13800
+ function up93(db) {
13813
13801
  db.exec(`
13814
13802
  CREATE TABLE IF NOT EXISTS transcript_recovery_files (
13815
13803
  agent_id TEXT NOT NULL,
@@ -13827,7 +13815,7 @@ function up92(db) {
13827
13815
  ON transcript_capture_jobs(agent_id, session_id, status);
13828
13816
  `);
13829
13817
  }
13830
- function up93(db) {
13818
+ function up94(db) {
13831
13819
  db.exec(`
13832
13820
  CREATE TABLE IF NOT EXISTS job_cancellations (
13833
13821
  id TEXT PRIMARY KEY,
@@ -13855,7 +13843,7 @@ function indexExists(db, table, indexName) {
13855
13843
  const rows = db.prepare(`PRAGMA index_list(${table})`).all();
13856
13844
  return rows.some((row) => row.name === indexName);
13857
13845
  }
13858
- function up94(db) {
13846
+ function up95(db) {
13859
13847
  db.exec(`
13860
13848
  CREATE TABLE IF NOT EXISTS job_archive (
13861
13849
  id TEXT PRIMARY KEY,
@@ -13882,7 +13870,7 @@ function indexExists2(db, table, indexName) {
13882
13870
  const rows = db.prepare(`PRAGMA index_list(${table})`).all();
13883
13871
  return rows.some((row) => row.name === indexName);
13884
13872
  }
13885
- function up95(db) {
13873
+ function up96(db) {
13886
13874
  db.exec(`
13887
13875
  CREATE TABLE IF NOT EXISTS embedding_index_state (
13888
13876
  id INTEGER PRIMARY KEY CHECK (id = 1),
@@ -13895,7 +13883,7 @@ function up95(db) {
13895
13883
  )
13896
13884
  `);
13897
13885
  }
13898
- function up96(db) {
13886
+ function up97(db) {
13899
13887
  db.exec(`
13900
13888
  CREATE TABLE IF NOT EXISTS embeddings_staging (
13901
13889
  id TEXT PRIMARY KEY,
@@ -13914,7 +13902,7 @@ function up96(db) {
13914
13902
  ON embeddings_staging(agent_id, source_type, source_id);
13915
13903
  `);
13916
13904
  }
13917
- function up97(db) {
13905
+ function up98(db) {
13918
13906
  const columns = db.prepare("PRAGMA table_info(dreaming_state)").all();
13919
13907
  if (!columns.some((column) => column.name === "evidence_cursor")) {
13920
13908
  db.exec("ALTER TABLE dreaming_state ADD COLUMN evidence_cursor TEXT");
@@ -13925,7 +13913,7 @@ function hasColumn13(db, table, column) {
13925
13913
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
13926
13914
  return rows.some((r2) => r2.name === column);
13927
13915
  }
13928
- function up98(db) {
13916
+ function up99(db) {
13929
13917
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = 'memories'").all();
13930
13918
  if (tables.length === 0)
13931
13919
  return;
@@ -13950,23 +13938,23 @@ function up98(db) {
13950
13938
  function hasColumn14(db, table, column) {
13951
13939
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
13952
13940
  }
13953
- function up99(db) {
13941
+ function up100(db) {
13954
13942
  const hasMemories = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'memories'").get();
13955
13943
  if (!hasMemories || !hasColumn14(db, "memories", "memory_kind") || !hasColumn14(db, "memories", "type"))
13956
13944
  return;
13957
13945
  db.exec("UPDATE memories SET memory_kind = NULL WHERE type = 'session_summary'");
13958
13946
  }
13959
- function up100(db) {
13947
+ function up101(db) {
13960
13948
  db.exec("DROP TABLE IF EXISTS ingestion_jobs");
13961
13949
  }
13962
- function up101(db) {
13950
+ function up102(db) {
13963
13951
  const columns = db.prepare("PRAGMA table_info(dreaming_state)").all();
13964
13952
  if (!columns.some((column) => column.name === "last_failure_at")) {
13965
13953
  db.exec("ALTER TABLE dreaming_state ADD COLUMN last_failure_at TEXT");
13966
13954
  }
13967
13955
  db.exec("UPDATE dreaming_state SET last_failure_at = updated_at WHERE consecutive_failures > 0 AND last_failure_at IS NULL");
13968
13956
  }
13969
- function up102(db) {
13957
+ function up103(db) {
13970
13958
  db.exec(`
13971
13959
  CREATE TABLE IF NOT EXISTS dreaming_evidence_exclusions (
13972
13960
  agent_id TEXT NOT NULL,
@@ -13983,7 +13971,7 @@ function up102(db) {
13983
13971
  ON dreaming_evidence_exclusions (agent_id, resolved_at, requeue_requested_at, excluded_at DESC);
13984
13972
  `);
13985
13973
  }
13986
- function up103(db) {
13974
+ function up104(db) {
13987
13975
  db.exec(`
13988
13976
  CREATE TABLE IF NOT EXISTS dreaming_tool_calls (
13989
13977
  id TEXT PRIMARY KEY,
@@ -14003,7 +13991,7 @@ function up103(db) {
14003
13991
  ON dreaming_tool_calls (agent_id, pass_id, sequence ASC);
14004
13992
  `);
14005
13993
  }
14006
- function up104(db) {
13994
+ function up105(db) {
14007
13995
  const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
14008
13996
  if (!columns.some((column) => column.name === "evidence_window_json")) {
14009
13997
  db.exec("ALTER TABLE dreaming_passes ADD COLUMN evidence_window_json TEXT");
@@ -14012,7 +14000,7 @@ function up104(db) {
14012
14000
  db.exec("ALTER TABLE dreaming_passes ADD COLUMN runbook_json TEXT");
14013
14001
  }
14014
14002
  }
14015
- function up105(db) {
14003
+ function up106(db) {
14016
14004
  db.exec(`
14017
14005
  CREATE TABLE IF NOT EXISTS dreaming_attention (
14018
14006
  id TEXT PRIMARY KEY,
@@ -14034,7 +14022,7 @@ function up105(db) {
14034
14022
  function hasColumn15(db, table, column) {
14035
14023
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
14036
14024
  }
14037
- function up106(db) {
14025
+ function up107(db) {
14038
14026
  const requiredMemoryColumns = [
14039
14027
  "content_hash",
14040
14028
  "normalized_content",
@@ -14085,7 +14073,7 @@ function up106(db) {
14085
14073
  WHERE EXISTS (SELECT 1 FROM memory_entity_mentions WHERE entity_id = entities.id)
14086
14074
  `);
14087
14075
  }
14088
- function up107(db) {
14076
+ function up108(db) {
14089
14077
  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('memories', 'entity_attributes')").all();
14090
14078
  if (tables.length !== 2)
14091
14079
  return;
@@ -14108,7 +14096,7 @@ function tableExists(db, table) {
14108
14096
  function hasColumn16(db, table, column) {
14109
14097
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
14110
14098
  }
14111
- function up108(db) {
14099
+ function up109(db) {
14112
14100
  db.exec(`
14113
14101
  CREATE TABLE IF NOT EXISTS derived_memory_sources (
14114
14102
  derived_memory_id TEXT NOT NULL,
@@ -14151,7 +14139,7 @@ function up108(db) {
14151
14139
  `);
14152
14140
  }
14153
14141
  }
14154
- function up109(db) {
14142
+ function up110(db) {
14155
14143
  db.exec(`
14156
14144
  DROP TRIGGER IF EXISTS entities_fts_ai;
14157
14145
  DROP TRIGGER IF EXISTS entities_fts_ad;
@@ -14240,7 +14228,7 @@ function up109(db) {
14240
14228
  function hasColumn17(db, table, column) {
14241
14229
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
14242
14230
  }
14243
- function up110(db) {
14231
+ function up111(db) {
14244
14232
  if (!hasColumn17(db, "memories", "review_after")) {
14245
14233
  db.exec("ALTER TABLE memories ADD COLUMN review_after TEXT;");
14246
14234
  }
@@ -14256,14 +14244,14 @@ var TOKEN_COLUMNS = [
14256
14244
  ["tokens_cache_write", "INTEGER"],
14257
14245
  ["tokens_cost", "REAL"]
14258
14246
  ];
14259
- function up111(db) {
14247
+ function up112(db) {
14260
14248
  for (const [column, type] of TOKEN_COLUMNS) {
14261
14249
  if (!hasColumn18(db, "dreaming_passes", column)) {
14262
14250
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${column} ${type};`);
14263
14251
  }
14264
14252
  }
14265
14253
  }
14266
- function up112(db) {
14254
+ function up113(db) {
14267
14255
  db.exec(`
14268
14256
  CREATE TABLE IF NOT EXISTS embedding_usage (
14269
14257
  day TEXT NOT NULL,
@@ -14276,7 +14264,7 @@ function up112(db) {
14276
14264
  );
14277
14265
  `);
14278
14266
  }
14279
- function up113(db) {
14267
+ function up114(db) {
14280
14268
  db.exec(`
14281
14269
  CREATE TABLE IF NOT EXISTS telemetry_install (
14282
14270
  id TEXT PRIMARY KEY,
@@ -14284,7 +14272,7 @@ function up113(db) {
14284
14272
  );
14285
14273
  `);
14286
14274
  }
14287
- function up114(db) {
14275
+ function up115(db) {
14288
14276
  db.exec(`
14289
14277
  CREATE INDEX IF NOT EXISTS idx_memory_entity_mentions_entity_memory
14290
14278
  ON memory_entity_mentions(entity_id, memory_id);
@@ -14295,7 +14283,7 @@ function hasColumn19(db, table, column) {
14295
14283
  return rows.some((row) => row.name === column);
14296
14284
  }
14297
14285
  var COLUMNS2 = ["first_remember_at", "first_recall_at"];
14298
- function up115(db) {
14286
+ function up116(db) {
14299
14287
  for (const column of COLUMNS2) {
14300
14288
  if (!hasColumn19(db, "telemetry_install", column)) {
14301
14289
  db.exec(`ALTER TABLE telemetry_install ADD COLUMN ${column} TEXT`);
@@ -14311,7 +14299,7 @@ function addColumnIfMissing24(db, column, definition) {
14311
14299
  db.exec(`ALTER TABLE telemetry_events ADD COLUMN ${column} ${definition}`);
14312
14300
  }
14313
14301
  }
14314
- function up116(db) {
14302
+ function up117(db) {
14315
14303
  addColumnIfMissing24(db, "source", "TEXT NOT NULL DEFAULT 'daemon'");
14316
14304
  addColumnIfMissing24(db, "claim_token", "TEXT");
14317
14305
  addColumnIfMissing24(db, "claimed_at", "TEXT");
@@ -14320,7 +14308,7 @@ function up116(db) {
14320
14308
  ON telemetry_events(source, sent_to_posthog, claimed_at, timestamp);
14321
14309
  `);
14322
14310
  }
14323
- function up117(db) {
14311
+ function up118(db) {
14324
14312
  db.exec(`
14325
14313
  CREATE TABLE IF NOT EXISTS session_claims (
14326
14314
  session_key TEXT NOT NULL,
@@ -14341,7 +14329,7 @@ function up117(db) {
14341
14329
  ON session_claims(agent_id, state, expires_at);
14342
14330
  `);
14343
14331
  }
14344
- function up118(db) {
14332
+ function up119(db) {
14345
14333
  const table = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'entity_attributes'").get();
14346
14334
  if (table == null)
14347
14335
  return;
@@ -14350,7 +14338,7 @@ function up118(db) {
14350
14338
  ON entity_attributes(memory_id, agent_id, status, importance);
14351
14339
  `);
14352
14340
  }
14353
- function up119(db) {
14341
+ function up120(db) {
14354
14342
  db.exec(`
14355
14343
  CREATE TABLE IF NOT EXISTS cross_agent_messages (
14356
14344
  id TEXT PRIMARY KEY,
@@ -14407,7 +14395,7 @@ function addColumnIfMissing25(db, column, definition) {
14407
14395
  db.exec(`ALTER TABLE cross_agent_messages ADD COLUMN ${column} ${definition}`);
14408
14396
  }
14409
14397
  }
14410
- function up120(db) {
14398
+ function up121(db) {
14411
14399
  const table = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'cross_agent_messages'").get();
14412
14400
  if (table == null)
14413
14401
  return;
@@ -14608,7 +14596,7 @@ function backfillTranscriptsFromSummaryJobs(db) {
14608
14596
  insert.run(...values);
14609
14597
  }
14610
14598
  }
14611
- function up121(db) {
14599
+ function up122(db) {
14612
14600
  if (!hasTable4(db, "session_transcripts"))
14613
14601
  return;
14614
14602
  addColumnIfMissing26(db, "session_transcripts", "completed_at", "TEXT");
@@ -14661,7 +14649,7 @@ function up121(db) {
14661
14649
  ON session_transcripts(agent_id, content_hash);
14662
14650
  `);
14663
14651
  }
14664
- function up122(db) {
14652
+ function up123(db) {
14665
14653
  db.exec(`
14666
14654
  CREATE INDEX IF NOT EXISTS idx_memory_jobs_pressure_status
14667
14655
  ON memory_jobs(status)
@@ -14680,12 +14668,12 @@ function up122(db) {
14680
14668
  function hasColumn22(db, table, column) {
14681
14669
  return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
14682
14670
  }
14683
- function up123(db) {
14671
+ function up124(db) {
14684
14672
  if (!hasColumn22(db, "telemetry_install", "last_seen_version")) {
14685
14673
  db.exec("ALTER TABLE telemetry_install ADD COLUMN last_seen_version TEXT");
14686
14674
  }
14687
14675
  }
14688
- function up124(db) {
14676
+ function up125(db) {
14689
14677
  db.exec(`
14690
14678
  CREATE TABLE IF NOT EXISTS source_lifecycle_state (
14691
14679
  agent_id TEXT NOT NULL,
@@ -14714,7 +14702,7 @@ function addColumnIfMissing27(db, column, definition) {
14714
14702
  db.exec(`ALTER TABLE telemetry_events ADD COLUMN ${column} ${definition}`);
14715
14703
  }
14716
14704
  }
14717
- function up125(db) {
14705
+ function up126(db) {
14718
14706
  addColumnIfMissing27(db, "delivery_attempts", "INTEGER NOT NULL DEFAULT 0");
14719
14707
  addColumnIfMissing27(db, "last_attempt_at", "TEXT");
14720
14708
  addColumnIfMissing27(db, "sent_at", "TEXT");
@@ -14735,7 +14723,7 @@ function up125(db) {
14735
14723
  VALUES (1, CURRENT_TIMESTAMP);
14736
14724
  `);
14737
14725
  }
14738
- function up126(db) {
14726
+ function up127(db) {
14739
14727
  const columns = db.prepare("PRAGMA table_info(dreaming_evidence_exclusions)").all();
14740
14728
  const names = new Set(columns.map((column) => column.name));
14741
14729
  if (!names.has("failure_class")) {
@@ -14752,7 +14740,7 @@ function up126(db) {
14752
14740
  }
14753
14741
  db.exec("CREATE INDEX IF NOT EXISTS idx_dreaming_evidence_exclusions_retry ON dreaming_evidence_exclusions (resolved_at, requeue_requested_at, failure_class, retry_count, last_requeued_at)");
14754
14742
  }
14755
- function up127(db) {
14743
+ function up128(db) {
14756
14744
  db.exec(`
14757
14745
  CREATE TABLE IF NOT EXISTS embedding_index_failures (
14758
14746
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -14776,7 +14764,7 @@ function up127(db) {
14776
14764
  ON embedding_index_failures(source_type, source_id);
14777
14765
  `);
14778
14766
  }
14779
- function up128(db) {
14767
+ function up129(db) {
14780
14768
  db.exec(`
14781
14769
  CREATE TABLE IF NOT EXISTS imported_source_lifecycle (
14782
14770
  id TEXT PRIMARY KEY,
@@ -14826,7 +14814,7 @@ function backfillTable(db, params) {
14826
14814
  FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
14827
14815
  backfill(db, rows, params.sourceKind, params.scannedAt);
14828
14816
  }
14829
- function up129(db) {
14817
+ function up130(db) {
14830
14818
  db.exec(`
14831
14819
  CREATE TABLE IF NOT EXISTS memory_content_safety (
14832
14820
  agent_id TEXT NOT NULL,
@@ -14883,7 +14871,7 @@ function up129(db) {
14883
14871
  scannedAt
14884
14872
  });
14885
14873
  }
14886
- function up130(db) {
14874
+ function up131(db) {
14887
14875
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
14888
14876
  if (!table)
14889
14877
  return;
@@ -14917,7 +14905,7 @@ function up130(db) {
14917
14905
  ON dreaming_attention (agent_id, resolved_at, priority DESC, created_at ASC);
14918
14906
  `);
14919
14907
  }
14920
- function up131(db) {
14908
+ function up132(db) {
14921
14909
  db.exec(`
14922
14910
  CREATE TABLE IF NOT EXISTS ontology_contradictions (
14923
14911
  id TEXT PRIMARY KEY,
@@ -14973,7 +14961,7 @@ function up131(db) {
14973
14961
  ON ontology_contradictions(agent_id, left_source_id, right_source_id);
14974
14962
  `);
14975
14963
  }
14976
- function up132(db) {
14964
+ function up133(db) {
14977
14965
  db.exec(`
14978
14966
  CREATE INDEX IF NOT EXISTS idx_memory_jobs_diagnostics_status_created_at
14979
14967
  ON memory_jobs(status, created_at)
@@ -14988,7 +14976,7 @@ function up132(db) {
14988
14976
  function tableExists3(db, table) {
14989
14977
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
14990
14978
  }
14991
- function up133(db) {
14979
+ function up134(db) {
14992
14980
  if (!tableExists3(db, "memory_jobs"))
14993
14981
  return;
14994
14982
  if (!tableExists3(db, "job_cancellations")) {
@@ -15037,7 +15025,7 @@ function up133(db) {
15037
15025
  AND status IN ('pending', 'leased');
15038
15026
  `);
15039
15027
  }
15040
- function up134(db) {
15028
+ function up135(db) {
15041
15029
  db.exec(`
15042
15030
  CREATE TABLE IF NOT EXISTS embedding_repair_budget (
15043
15031
  id INTEGER PRIMARY KEY CHECK (id = 1),
@@ -15077,7 +15065,7 @@ function up134(db) {
15077
15065
  END;
15078
15066
  `);
15079
15067
  }
15080
- function up135(db) {
15068
+ function up136(db) {
15081
15069
  db.exec(`
15082
15070
  CREATE TABLE IF NOT EXISTS dreaming_evidence_consumption (
15083
15071
  agent_id TEXT NOT NULL,
@@ -15100,13 +15088,13 @@ function up135(db) {
15100
15088
  ON dreaming_evidence_consumption(agent_id, pass_id, delivered_offset, source_length);
15101
15089
  `);
15102
15090
  }
15103
- function up136(db) {
15091
+ function up137(db) {
15104
15092
  db.exec(`
15105
15093
  CREATE INDEX IF NOT EXISTS idx_epistemic_assertions_observer_entity
15106
15094
  ON epistemic_assertions(agent_id, subject_entity_id, status, asserted_at DESC, created_at DESC);
15107
15095
  `);
15108
15096
  }
15109
- function up137(db) {
15097
+ function up138(db) {
15110
15098
  db.exec(`
15111
15099
  CREATE TABLE IF NOT EXISTS memory_head_revisions (
15112
15100
  id TEXT PRIMARY KEY,
@@ -15158,7 +15146,7 @@ function up137(db) {
15158
15146
  if (!names.has("format_version"))
15159
15147
  db.exec("ALTER TABLE memory_md_heads ADD COLUMN format_version INTEGER NOT NULL DEFAULT 1");
15160
15148
  }
15161
- function up138(db) {
15149
+ function up139(db) {
15162
15150
  db.exec(`
15163
15151
  CREATE TABLE memory_head_entries_v134 (
15164
15152
  entry_id TEXT NOT NULL, agent_id TEXT NOT NULL, canonical_text TEXT NOT NULL,
@@ -15176,7 +15164,7 @@ function up138(db) {
15176
15164
  ON memory_head_entries(agent_id, entry_id, last_revision DESC);
15177
15165
  `);
15178
15166
  }
15179
- function up139(db) {
15167
+ function up140(db) {
15180
15168
  db.exec(`
15181
15169
  CREATE TABLE IF NOT EXISTS memory_head_publications (
15182
15170
  agent_id TEXT NOT NULL,
@@ -15192,7 +15180,7 @@ function up139(db) {
15192
15180
  ON memory_head_publications(agent_id, status, revision DESC);
15193
15181
  `);
15194
15182
  }
15195
- function up140(db) {
15183
+ function up141(db) {
15196
15184
  const cols = new Set(db.prepare("PRAGMA table_info(memory_head_revisions)").all().map((r2) => r2.name));
15197
15185
  for (const [name, type] of [
15198
15186
  ["entry_id", "TEXT"],
@@ -15206,7 +15194,7 @@ function up140(db) {
15206
15194
  }
15207
15195
  db.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_memory_head_revisions_entry ON memory_head_revisions(agent_id, revision, entry_id)");
15208
15196
  }
15209
- function up141(db) {
15197
+ function up142(db) {
15210
15198
  const cols = new Set(db.prepare("PRAGMA table_info(dreaming_passes)").all().map((r2) => r2.name));
15211
15199
  for (const [name, type] of [
15212
15200
  ["head_revision", "INTEGER"],
@@ -15228,7 +15216,7 @@ function addColumnIfMissing28(db, table, column, definition) {
15228
15216
  if (!hasColumn25(db, table, column))
15229
15217
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
15230
15218
  }
15231
- function up142(db) {
15219
+ function up143(db) {
15232
15220
  addColumnIfMissing28(db, "memories", "manual_override", "INTEGER DEFAULT 0");
15233
15221
  db.exec(`
15234
15222
  CREATE TABLE IF NOT EXISTS transcript_capture_status (
@@ -15533,7 +15521,7 @@ function up142(db) {
15533
15521
  GROUP BY j.agent_id;
15534
15522
  `);
15535
15523
  }
15536
- function up143(db) {
15524
+ function up144(db) {
15537
15525
  db.exec(`
15538
15526
  CREATE TABLE IF NOT EXISTS native_source_sync_state (
15539
15527
  agent_id TEXT NOT NULL,
@@ -15549,7 +15537,7 @@ function up143(db) {
15549
15537
  ON native_source_sync_state(agent_id, status);
15550
15538
  `);
15551
15539
  }
15552
- function up144(db) {
15540
+ function up145(db) {
15553
15541
  db.exec(`
15554
15542
  CREATE TABLE IF NOT EXISTS transcript_recovery_frontiers (
15555
15543
  agent_id TEXT NOT NULL,
@@ -15561,7 +15549,7 @@ function up144(db) {
15561
15549
  );
15562
15550
  `);
15563
15551
  }
15564
- function up145(db) {
15552
+ function up146(db) {
15565
15553
  db.exec(`
15566
15554
  CREATE TABLE IF NOT EXISTS source_sync_checkpoints (
15567
15555
  agent_id TEXT NOT NULL,
@@ -15575,13 +15563,13 @@ function up145(db) {
15575
15563
  );
15576
15564
  `);
15577
15565
  }
15578
- function up146(db) {
15566
+ function up147(db) {
15579
15567
  const columns = db.prepare("PRAGMA table_info(source_sync_checkpoints)").all();
15580
15568
  if (!columns.some((column) => column.name === "frontier")) {
15581
15569
  db.exec("ALTER TABLE source_sync_checkpoints ADD COLUMN frontier TEXT");
15582
15570
  }
15583
15571
  }
15584
- function up147(db) {
15572
+ function up148(db) {
15585
15573
  const columns = new Set(db.prepare("PRAGMA table_info(embedding_index_state)").all().map((row) => row.name).filter((name) => typeof name === "string"));
15586
15574
  const additions = [
15587
15575
  ["migration_phase", "TEXT"],
@@ -15616,13 +15604,13 @@ function up147(db) {
15616
15604
  `);
15617
15605
  }
15618
15606
  }
15619
- function up148(db) {
15607
+ function up149(db) {
15620
15608
  const columns = new Set(db.prepare("PRAGMA table_info(memory_jobs)").all().map((row) => row.name).filter((name) => typeof name === "string"));
15621
15609
  if (!columns.has("lease_token")) {
15622
15610
  db.exec("ALTER TABLE memory_jobs ADD COLUMN lease_token TEXT");
15623
15611
  }
15624
15612
  }
15625
- function up149(db) {
15613
+ function up150(db) {
15626
15614
  db.exec(`
15627
15615
  CREATE TABLE IF NOT EXISTS dreaming_evidence_reviews (
15628
15616
  agent_id TEXT NOT NULL,
@@ -15640,7 +15628,7 @@ function up149(db) {
15640
15628
  ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
15641
15629
  `);
15642
15630
  }
15643
- function up150(db) {
15631
+ function up151(db) {
15644
15632
  db.exec(`
15645
15633
  CREATE TABLE IF NOT EXISTS source_import_jobs (
15646
15634
  id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
@@ -15707,16 +15695,16 @@ function up150(db) {
15707
15695
  }
15708
15696
  db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
15709
15697
  }
15710
- function up151(db) {
15698
+ function up152(db) {
15711
15699
  db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
15712
15700
  }
15713
- function up152(db) {
15701
+ function up153(db) {
15714
15702
  const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
15715
15703
  if (!columns.some((column) => column.name === "source_id")) {
15716
15704
  db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
15717
15705
  }
15718
15706
  }
15719
- function up153(db) {
15707
+ function up154(db) {
15720
15708
  const addColumn = (table, column, definition) => {
15721
15709
  const statement = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?");
15722
15710
  let exists;
@@ -15737,7 +15725,7 @@ function addColumnIfMissing29(db, table, column, definition) {
15737
15725
  if (!columns.some((row) => row.name === column))
15738
15726
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
15739
15727
  }
15740
- function up154(db) {
15728
+ function up155(db) {
15741
15729
  addColumnIfMissing29(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
15742
15730
  addColumnIfMissing29(db, "dreaming_passes", "head_base_revision", "INTEGER");
15743
15731
  db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
@@ -15887,7 +15875,7 @@ function up154(db) {
15887
15875
  `);
15888
15876
  }
15889
15877
  }
15890
- function up155(db) {
15878
+ function up156(db) {
15891
15879
  db.exec(`
15892
15880
  CREATE TABLE IF NOT EXISTS vector_repair_checkpoints (
15893
15881
  operation TEXT NOT NULL CHECK (operation IN ('resync', 'clean-orphans')),
@@ -15912,7 +15900,7 @@ function up155(db) {
15912
15900
  ON vector_repair_checkpoints(status, updated_at);
15913
15901
  `);
15914
15902
  }
15915
- function up156(db) {
15903
+ function up157(db) {
15916
15904
  db.exec(`
15917
15905
  CREATE TABLE IF NOT EXISTS embedding_repair_checkpoints (
15918
15906
  checkpoint_id TEXT PRIMARY KEY,
@@ -15933,7 +15921,7 @@ function up156(db) {
15933
15921
  ON embedding_repair_checkpoints(status, updated_at);
15934
15922
  `);
15935
15923
  }
15936
- function up157(db) {
15924
+ function up158(db) {
15937
15925
  const columns = new Set(db.prepare("PRAGMA table_info(embedding_repair_checkpoints)").all().map((row) => row.name));
15938
15926
  if (!columns.has("profile_fingerprint")) {
15939
15927
  db.exec("ALTER TABLE embedding_repair_checkpoints ADD COLUMN profile_fingerprint TEXT");
@@ -15948,23 +15936,119 @@ function up157(db) {
15948
15936
  );
15949
15937
  `);
15950
15938
  }
15951
- function up158(db) {
15939
+ function up159(db) {
15952
15940
  db.exec(`
15953
15941
  CREATE INDEX IF NOT EXISTS idx_memories_agent_kind
15954
15942
  ON memories(agent_id, memory_kind);
15955
15943
  `);
15956
15944
  }
15945
+ var ledgerColumns = [
15946
+ "key",
15947
+ "agent_id",
15948
+ "workspace_id",
15949
+ "file_name",
15950
+ "status",
15951
+ "original_path",
15952
+ "sha256",
15953
+ "size_bytes",
15954
+ "request_fingerprint",
15955
+ "source_id",
15956
+ "lease_token",
15957
+ "lease_expires_at",
15958
+ "attempt_count",
15959
+ "error",
15960
+ "created_at",
15961
+ "updated_at"
15962
+ ];
15963
+ function columns(db, table) {
15964
+ return new Set(db.prepare(`PRAGMA table_info(${table})`).all().map((row) => String(row.name)));
15965
+ }
15966
+ function addMissingColumns(db, table, definitions) {
15967
+ const present = columns(db, table);
15968
+ for (const definition of definitions) {
15969
+ const name = definition.split(" ", 1)[0];
15970
+ if (!present.has(name))
15971
+ db.exec(`ALTER TABLE ${table} ADD COLUMN ${definition}`);
15972
+ }
15973
+ }
15974
+ function rebuildLedgerWithoutGlobalKeyPrimaryKey(db) {
15975
+ const keyInfo = db.prepare("PRAGMA table_info(import_admission_ledger)").all().find((row) => row.name === "key");
15976
+ if (!keyInfo || Number(keyInfo.pk) === 0)
15977
+ return;
15978
+ const savepoint = "migration_158_rebuild_ledger";
15979
+ db.exec(`SAVEPOINT ${savepoint}`);
15980
+ try {
15981
+ db.exec(`
15982
+ CREATE TABLE import_admission_ledger_v158 (
15983
+ key TEXT NOT NULL, agent_id TEXT NOT NULL DEFAULT '', workspace_id TEXT NOT NULL DEFAULT '',
15984
+ file_name TEXT NOT NULL, status TEXT NOT NULL CHECK (status IN ('pending','processing','imported','duplicate','failed','quarantined','original_unavailable')),
15985
+ original_path TEXT NOT NULL, sha256 TEXT NOT NULL, size_bytes INTEGER NOT NULL,
15986
+ request_fingerprint TEXT NOT NULL DEFAULT '', source_id TEXT, lease_token TEXT, lease_expires_at TEXT,
15987
+ attempt_count INTEGER NOT NULL DEFAULT 0, error TEXT, created_at TEXT NOT NULL, updated_at TEXT NOT NULL
15988
+ );
15989
+ INSERT INTO import_admission_ledger_v158 (${ledgerColumns.join(",")})
15990
+ SELECT ${ledgerColumns.join(",")} FROM import_admission_ledger;
15991
+ DROP TABLE import_admission_ledger;
15992
+ ALTER TABLE import_admission_ledger_v158 RENAME TO import_admission_ledger;
15993
+ `);
15994
+ db.exec(`RELEASE ${savepoint}`);
15995
+ } catch (error) {
15996
+ try {
15997
+ db.exec(`ROLLBACK TO SAVEPOINT ${savepoint}`);
15998
+ } finally {
15999
+ try {
16000
+ db.exec(`RELEASE ${savepoint}`);
16001
+ } catch {}
16002
+ }
16003
+ throw error;
16004
+ }
16005
+ }
16006
+ function up160(db) {
16007
+ db.exec(`
16008
+ CREATE TABLE IF NOT EXISTS import_admission_ledger (
16009
+ key TEXT NOT NULL, agent_id TEXT NOT NULL, workspace_id TEXT NOT NULL DEFAULT '', file_name TEXT NOT NULL,
16010
+ status TEXT NOT NULL CHECK (status IN ('pending','processing','imported','duplicate','failed','quarantined','original_unavailable')),
16011
+ original_path TEXT NOT NULL, sha256 TEXT NOT NULL, size_bytes INTEGER NOT NULL,
16012
+ request_fingerprint TEXT NOT NULL DEFAULT '', source_id TEXT, lease_token TEXT, lease_expires_at TEXT,
16013
+ attempt_count INTEGER NOT NULL DEFAULT 0, error TEXT, created_at TEXT NOT NULL, updated_at TEXT NOT NULL
16014
+ );
16015
+ CREATE TABLE IF NOT EXISTS import_admission_events (
16016
+ id INTEGER PRIMARY KEY AUTOINCREMENT, admission_key TEXT NOT NULL, agent_id TEXT NOT NULL DEFAULT '',
16017
+ workspace_id TEXT NOT NULL DEFAULT '', event TEXT NOT NULL, created_at TEXT NOT NULL
16018
+ );
16019
+ `);
16020
+ addMissingColumns(db, "import_admission_ledger", [
16021
+ "agent_id TEXT NOT NULL DEFAULT ''",
16022
+ "workspace_id TEXT NOT NULL DEFAULT ''",
16023
+ "request_fingerprint TEXT NOT NULL DEFAULT ''",
16024
+ "source_id TEXT",
16025
+ "lease_token TEXT",
16026
+ "lease_expires_at TEXT",
16027
+ "attempt_count INTEGER NOT NULL DEFAULT 0",
16028
+ "error TEXT"
16029
+ ]);
16030
+ addMissingColumns(db, "import_admission_events", [
16031
+ "agent_id TEXT NOT NULL DEFAULT ''",
16032
+ "workspace_id TEXT NOT NULL DEFAULT ''"
16033
+ ]);
16034
+ rebuildLedgerWithoutGlobalKeyPrimaryKey(db);
16035
+ db.exec(`
16036
+ CREATE UNIQUE INDEX IF NOT EXISTS uq_import_admission_scope_key ON import_admission_ledger(key, agent_id, workspace_id);
16037
+ CREATE INDEX IF NOT EXISTS idx_import_admission_status ON import_admission_ledger(agent_id, workspace_id, status, updated_at);
16038
+ CREATE INDEX IF NOT EXISTS idx_import_admission_events_key ON import_admission_events(admission_key, agent_id, workspace_id, id);
16039
+ `);
16040
+ }
15957
16041
  var MIGRATIONS = [
15958
16042
  {
15959
16043
  version: 1,
15960
16044
  name: "baseline",
15961
- up: up5,
16045
+ up: up6,
15962
16046
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
15963
16047
  },
15964
16048
  {
15965
16049
  version: 2,
15966
16050
  name: "pipeline-v2",
15967
- up: up6,
16051
+ up: up7,
15968
16052
  artifacts: {
15969
16053
  tables: ["memory_history", "memory_jobs", "entities", "relations", "memory_entity_mentions"]
15970
16054
  }
@@ -15972,12 +16056,12 @@ var MIGRATIONS = [
15972
16056
  {
15973
16057
  version: 3,
15974
16058
  name: "unique-content-hash",
15975
- up: up7
16059
+ up: up8
15976
16060
  },
15977
16061
  {
15978
16062
  version: 4,
15979
16063
  name: "history-actor-and-retention",
15980
- up: up8,
16064
+ up: up9,
15981
16065
  artifacts: {
15982
16066
  columns: [{ table: "memory_history", column: "actor_type" }]
15983
16067
  }
@@ -15985,7 +16069,7 @@ var MIGRATIONS = [
15985
16069
  {
15986
16070
  version: 5,
15987
16071
  name: "graph-extended",
15988
- up: up9,
16072
+ up: up10,
15989
16073
  artifacts: {
15990
16074
  columns: [{ table: "entities", column: "canonical_name" }]
15991
16075
  }
@@ -15993,7 +16077,7 @@ var MIGRATIONS = [
15993
16077
  {
15994
16078
  version: 6,
15995
16079
  name: "idempotency-key",
15996
- up: up10,
16080
+ up: up11,
15997
16081
  artifacts: {
15998
16082
  columns: [{ table: "memories", column: "idempotency_key" }]
15999
16083
  }
@@ -16001,42 +16085,42 @@ var MIGRATIONS = [
16001
16085
  {
16002
16086
  version: 7,
16003
16087
  name: "documents-and-connectors",
16004
- up: up11,
16088
+ up: up12,
16005
16089
  artifacts: { tables: ["documents", "document_memories", "connectors"] }
16006
16090
  },
16007
16091
  {
16008
16092
  version: 8,
16009
16093
  name: "embeddings-unique-hash",
16010
- up: up12
16094
+ up: up13
16011
16095
  },
16012
16096
  {
16013
16097
  version: 9,
16014
16098
  name: "summary-jobs",
16015
- up: up13,
16099
+ up: up14,
16016
16100
  artifacts: { tables: ["summary_jobs"] }
16017
16101
  },
16018
16102
  {
16019
16103
  version: 10,
16020
16104
  name: "umap-cache",
16021
- up: up14,
16105
+ up: up15,
16022
16106
  artifacts: { tables: ["umap_cache"] }
16023
16107
  },
16024
16108
  {
16025
16109
  version: 11,
16026
16110
  name: "session-scores",
16027
- up: up15,
16111
+ up: up16,
16028
16112
  artifacts: { tables: ["session_scores"] }
16029
16113
  },
16030
16114
  {
16031
16115
  version: 12,
16032
16116
  name: "scheduled-tasks",
16033
- up: up16,
16117
+ up: up17,
16034
16118
  artifacts: { tables: ["scheduled_tasks", "task_runs"] }
16035
16119
  },
16036
16120
  {
16037
16121
  version: 13,
16038
16122
  name: "ingestion-tracking",
16039
- up: up17,
16123
+ up: up18,
16040
16124
  artifacts: {
16041
16125
  columns: [
16042
16126
  { table: "memories", column: "source_path" },
@@ -16047,13 +16131,13 @@ var MIGRATIONS = [
16047
16131
  {
16048
16132
  version: 14,
16049
16133
  name: "telemetry",
16050
- up: up18,
16134
+ up: up19,
16051
16135
  artifacts: { tables: ["telemetry_events"] }
16052
16136
  },
16053
16137
  {
16054
16138
  version: 15,
16055
16139
  name: "session-memories",
16056
- up: up19,
16140
+ up: up20,
16057
16141
  artifacts: {
16058
16142
  tables: ["session_memories"],
16059
16143
  columns: [
@@ -16065,13 +16149,13 @@ var MIGRATIONS = [
16065
16149
  {
16066
16150
  version: 16,
16067
16151
  name: "session-checkpoints",
16068
- up: up20,
16152
+ up: up21,
16069
16153
  artifacts: { tables: ["session_checkpoints"] }
16070
16154
  },
16071
16155
  {
16072
16156
  version: 17,
16073
16157
  name: "task-skills",
16074
- up: up21,
16158
+ up: up22,
16075
16159
  artifacts: {
16076
16160
  columns: [{ table: "scheduled_tasks", column: "skill_name" }]
16077
16161
  }
@@ -16079,13 +16163,13 @@ var MIGRATIONS = [
16079
16163
  {
16080
16164
  version: 18,
16081
16165
  name: "skill-meta",
16082
- up: up22,
16166
+ up: up23,
16083
16167
  artifacts: { tables: ["skill_meta"] }
16084
16168
  },
16085
16169
  {
16086
16170
  version: 19,
16087
16171
  name: "knowledge-structure",
16088
- up: up23,
16172
+ up: up24,
16089
16173
  artifacts: {
16090
16174
  tables: ["entity_aspects", "entity_attributes", "entity_dependencies", "task_meta"],
16091
16175
  columns: [{ table: "entities", column: "agent_id" }]
@@ -16094,7 +16178,7 @@ var MIGRATIONS = [
16094
16178
  {
16095
16179
  version: 20,
16096
16180
  name: "session-structural-columns",
16097
- up: up24,
16181
+ up: up25,
16098
16182
  artifacts: {
16099
16183
  columns: [
16100
16184
  { table: "session_memories", column: "entity_slot" },
@@ -16107,7 +16191,7 @@ var MIGRATIONS = [
16107
16191
  {
16108
16192
  version: 21,
16109
16193
  name: "checkpoint-structural",
16110
- up: up25,
16194
+ up: up26,
16111
16195
  artifacts: {
16112
16196
  columns: [{ table: "session_checkpoints", column: "focal_entity_ids" }]
16113
16197
  }
@@ -16115,7 +16199,7 @@ var MIGRATIONS = [
16115
16199
  {
16116
16200
  version: 22,
16117
16201
  name: "entity-pinning",
16118
- up: up26,
16202
+ up: up27,
16119
16203
  artifacts: {
16120
16204
  columns: [
16121
16205
  { table: "entities", column: "pinned" },
@@ -16126,17 +16210,17 @@ var MIGRATIONS = [
16126
16210
  {
16127
16211
  version: 23,
16128
16212
  name: "retired-scorer-gap",
16129
- up: up27
16213
+ up: up28
16130
16214
  },
16131
16215
  {
16132
16216
  version: 24,
16133
16217
  name: "retired-scorer-gap",
16134
- up: up28
16218
+ up: up29
16135
16219
  },
16136
16220
  {
16137
16221
  version: 25,
16138
16222
  name: "agent-feedback",
16139
- up: up29,
16223
+ up: up30,
16140
16224
  artifacts: {
16141
16225
  columns: [{ table: "session_memories", column: "agent_relevance_score" }]
16142
16226
  }
@@ -16144,32 +16228,32 @@ var MIGRATIONS = [
16144
16228
  {
16145
16229
  version: 26,
16146
16230
  name: "retired-scorer-gap",
16147
- up: up30
16231
+ up: up31
16148
16232
  },
16149
16233
  {
16150
16234
  version: 27,
16151
16235
  name: "backfill-canonical-names",
16152
- up: up31
16236
+ up: up32
16153
16237
  },
16154
16238
  {
16155
16239
  version: 28,
16156
16240
  name: "lossless-retention",
16157
- up: up32
16241
+ up: up33
16158
16242
  },
16159
16243
  {
16160
16244
  version: 29,
16161
16245
  name: "session-summary-dag",
16162
- up: up33
16246
+ up: up34
16163
16247
  },
16164
16248
  {
16165
16249
  version: 30,
16166
16250
  name: "nullable-memory-job-memory-id",
16167
- up: up34
16251
+ up: up35
16168
16252
  },
16169
16253
  {
16170
16254
  version: 31,
16171
16255
  name: "dependency-reason",
16172
- up: up35,
16256
+ up: up36,
16173
16257
  artifacts: {
16174
16258
  columns: [
16175
16259
  { table: "entity_dependencies", column: "reason" },
@@ -16180,7 +16264,7 @@ var MIGRATIONS = [
16180
16264
  {
16181
16265
  version: 32,
16182
16266
  name: "embeddings-vector-column",
16183
- up: up36,
16267
+ up: up37,
16184
16268
  artifacts: {
16185
16269
  columns: [{ table: "embeddings", column: "vector", optional: true }]
16186
16270
  }
@@ -16188,7 +16272,7 @@ var MIGRATIONS = [
16188
16272
  {
16189
16273
  version: 33,
16190
16274
  name: "scope",
16191
- up: up37,
16275
+ up: up38,
16192
16276
  artifacts: {
16193
16277
  columns: [{ table: "memories", column: "scope" }]
16194
16278
  }
@@ -16196,17 +16280,17 @@ var MIGRATIONS = [
16196
16280
  {
16197
16281
  version: 34,
16198
16282
  name: "scope-aware-dedup",
16199
- up: up38
16283
+ up: up39
16200
16284
  },
16201
16285
  {
16202
16286
  version: 35,
16203
16287
  name: "entity-fts",
16204
- up: up39
16288
+ up: up40
16205
16289
  },
16206
16290
  {
16207
16291
  version: 36,
16208
16292
  name: "dependency-confidence",
16209
- up: up40,
16293
+ up: up41,
16210
16294
  artifacts: {
16211
16295
  columns: [{ table: "entity_dependencies", column: "confidence" }]
16212
16296
  }
@@ -16214,7 +16298,7 @@ var MIGRATIONS = [
16214
16298
  {
16215
16299
  version: 37,
16216
16300
  name: "entity-communities",
16217
- up: up41,
16301
+ up: up42,
16218
16302
  artifacts: {
16219
16303
  tables: ["entity_communities"],
16220
16304
  columns: [{ table: "entities", column: "community_id" }]
@@ -16223,24 +16307,24 @@ var MIGRATIONS = [
16223
16307
  {
16224
16308
  version: 38,
16225
16309
  name: "memory-hints",
16226
- up: up42,
16310
+ up: up43,
16227
16311
  artifacts: { tables: ["memory_hints"] }
16228
16312
  },
16229
16313
  {
16230
16314
  version: 39,
16231
16315
  name: "dedup-entity-dependencies",
16232
- up: up43
16316
+ up: up44
16233
16317
  },
16234
16318
  {
16235
16319
  version: 40,
16236
16320
  name: "session-transcripts",
16237
- up: up44,
16321
+ up: up45,
16238
16322
  artifacts: { tables: ["session_transcripts"] }
16239
16323
  },
16240
16324
  {
16241
16325
  version: 41,
16242
16326
  name: "path-feedback",
16243
- up: up45,
16327
+ up: up46,
16244
16328
  artifacts: {
16245
16329
  tables: [
16246
16330
  "path_feedback_events",
@@ -16255,7 +16339,7 @@ var MIGRATIONS = [
16255
16339
  {
16256
16340
  version: 42,
16257
16341
  name: "session-memories-agent-id",
16258
- up: up46,
16342
+ up: up47,
16259
16343
  artifacts: {
16260
16344
  columns: [{ table: "session_memories", column: "agent_id" }]
16261
16345
  }
@@ -16263,7 +16347,7 @@ var MIGRATIONS = [
16263
16347
  {
16264
16348
  version: 43,
16265
16349
  name: "agents-table",
16266
- up: up47,
16350
+ up: up48,
16267
16351
  artifacts: {
16268
16352
  tables: ["agents"],
16269
16353
  columns: [
@@ -16275,7 +16359,7 @@ var MIGRATIONS = [
16275
16359
  {
16276
16360
  version: 44,
16277
16361
  name: "memory-md-temporal-head",
16278
- up: up48,
16362
+ up: up49,
16279
16363
  artifacts: {
16280
16364
  columns: [
16281
16365
  { table: "session_summaries", column: "source_type" },
@@ -16287,7 +16371,7 @@ var MIGRATIONS = [
16287
16371
  {
16288
16372
  version: 45,
16289
16373
  name: "lossless-working-memory-hardening",
16290
- up: up49,
16374
+ up: up50,
16291
16375
  artifacts: {
16292
16376
  tables: ["session_transcripts_fts", "memory_md_heads"],
16293
16377
  columns: [
@@ -16300,17 +16384,17 @@ var MIGRATIONS = [
16300
16384
  {
16301
16385
  version: 46,
16302
16386
  name: "session-summary-uniqueness",
16303
- up: up50
16387
+ up: up51
16304
16388
  },
16305
16389
  {
16306
16390
  version: 47,
16307
16391
  name: "agent-scoped-temporal-uniqueness",
16308
- up: up51
16392
+ up: up52
16309
16393
  },
16310
16394
  {
16311
16395
  version: 48,
16312
16396
  name: "thread-heads",
16313
- up: up52,
16397
+ up: up53,
16314
16398
  artifacts: {
16315
16399
  tables: ["memory_thread_heads"]
16316
16400
  }
@@ -16318,7 +16402,7 @@ var MIGRATIONS = [
16318
16402
  {
16319
16403
  version: 49,
16320
16404
  name: "session-extract-cursors",
16321
- up: up53,
16405
+ up: up54,
16322
16406
  artifacts: {
16323
16407
  tables: ["session_extract_cursors"]
16324
16408
  }
@@ -16326,7 +16410,7 @@ var MIGRATIONS = [
16326
16410
  {
16327
16411
  version: 50,
16328
16412
  name: "related-to-audit",
16329
- up: up54,
16413
+ up: up55,
16330
16414
  artifacts: {
16331
16415
  tables: ["entity_dependency_history"]
16332
16416
  }
@@ -16334,7 +16418,7 @@ var MIGRATIONS = [
16334
16418
  {
16335
16419
  version: 51,
16336
16420
  name: "memory-md-rolling-window-lineage",
16337
- up: up55,
16421
+ up: up56,
16338
16422
  artifacts: {
16339
16423
  tables: ["memory_artifacts", "memory_artifact_tombstones", "memory_artifacts_fts"],
16340
16424
  columns: [
@@ -16349,15 +16433,12 @@ var MIGRATIONS = [
16349
16433
  {
16350
16434
  version: 52,
16351
16435
  name: "mcp-invocations",
16352
- up: up56,
16353
- artifacts: {
16354
- tables: ["mcp_invocations"]
16355
- }
16436
+ up: up57
16356
16437
  },
16357
16438
  {
16358
16439
  version: 53,
16359
16440
  name: "skill-invocations",
16360
- up: up57,
16441
+ up: up58,
16361
16442
  artifacts: {
16362
16443
  tables: ["skill_invocations"]
16363
16444
  }
@@ -16365,7 +16446,7 @@ var MIGRATIONS = [
16365
16446
  {
16366
16447
  version: 54,
16367
16448
  name: "task-agent-scope",
16368
- up: up58,
16449
+ up: up59,
16369
16450
  artifacts: {
16370
16451
  tables: ["task_scope_hints"]
16371
16452
  }
@@ -16373,7 +16454,7 @@ var MIGRATIONS = [
16373
16454
  {
16374
16455
  version: 55,
16375
16456
  name: "dreaming-state",
16376
- up: up59,
16457
+ up: up60,
16377
16458
  artifacts: {
16378
16459
  tables: ["dreaming_state", "dreaming_passes"]
16379
16460
  }
@@ -16381,22 +16462,22 @@ var MIGRATIONS = [
16381
16462
  {
16382
16463
  version: 56,
16383
16464
  name: "agent-scoped-content-hash",
16384
- up: up60
16465
+ up: up61
16385
16466
  },
16386
16467
  {
16387
16468
  version: 57,
16388
16469
  name: "memories-fts-tokenizer-repair",
16389
- up: up61
16470
+ up: up62
16390
16471
  },
16391
16472
  {
16392
16473
  version: 58,
16393
16474
  name: "knowledge-graph-indices",
16394
- up: up62
16475
+ up: up63
16395
16476
  },
16396
16477
  {
16397
16478
  version: 59,
16398
16479
  name: "entity-attribute-claim-key",
16399
- up: up63,
16480
+ up: up64,
16400
16481
  artifacts: {
16401
16482
  columns: [{ table: "entity_attributes", column: "claim_key" }]
16402
16483
  }
@@ -16404,7 +16485,7 @@ var MIGRATIONS = [
16404
16485
  {
16405
16486
  version: 60,
16406
16487
  name: "entity-attribute-group-key",
16407
- up: up64,
16488
+ up: up65,
16408
16489
  artifacts: {
16409
16490
  columns: [{ table: "entity_attributes", column: "group_key" }]
16410
16491
  }
@@ -16412,7 +16493,7 @@ var MIGRATIONS = [
16412
16493
  {
16413
16494
  version: 61,
16414
16495
  name: "memory-artifact-source-mtime",
16415
- up: up65,
16496
+ up: up66,
16416
16497
  artifacts: {
16417
16498
  columns: [{ table: "memory_artifacts", column: "source_mtime_ms" }]
16418
16499
  }
@@ -16420,7 +16501,7 @@ var MIGRATIONS = [
16420
16501
  {
16421
16502
  version: 62,
16422
16503
  name: "memory-artifact-soft-delete",
16423
- up: up66,
16504
+ up: up67,
16424
16505
  artifacts: {
16425
16506
  columns: [
16426
16507
  { table: "memory_artifacts", column: "is_deleted" },
@@ -16431,12 +16512,12 @@ var MIGRATIONS = [
16431
16512
  {
16432
16513
  version: 63,
16433
16514
  name: "content-only-memories-fts-update",
16434
- up: up67
16515
+ up: up68
16435
16516
  },
16436
16517
  {
16437
16518
  version: 64,
16438
16519
  name: "source-graph-provenance",
16439
- up: up68,
16520
+ up: up69,
16440
16521
  artifacts: {
16441
16522
  columns: [
16442
16523
  { table: "entities", column: "source_path" },
@@ -16449,7 +16530,7 @@ var MIGRATIONS = [
16449
16530
  {
16450
16531
  version: 65,
16451
16532
  name: "source-embedding-agent-scope",
16452
- up: up69,
16533
+ up: up70,
16453
16534
  artifacts: {
16454
16535
  columns: [{ table: "embeddings", column: "agent_id", optional: true }]
16455
16536
  }
@@ -16457,7 +16538,7 @@ var MIGRATIONS = [
16457
16538
  {
16458
16539
  version: 66,
16459
16540
  name: "memory-search-telemetry",
16460
- up: up70,
16541
+ up: up71,
16461
16542
  artifacts: {
16462
16543
  tables: ["memory_search_telemetry"]
16463
16544
  }
@@ -16465,7 +16546,7 @@ var MIGRATIONS = [
16465
16546
  {
16466
16547
  version: 67,
16467
16548
  name: "ontology-proposals",
16468
- up: up71,
16549
+ up: up72,
16469
16550
  artifacts: {
16470
16551
  tables: ["ontology_proposals"],
16471
16552
  columns: [
@@ -16479,7 +16560,7 @@ var MIGRATIONS = [
16479
16560
  {
16480
16561
  version: 68,
16481
16562
  name: "daily-reflections",
16482
- up: up72,
16563
+ up: up73,
16483
16564
  artifacts: {
16484
16565
  tables: ["daily_reflections"]
16485
16566
  }
@@ -16487,7 +16568,7 @@ var MIGRATIONS = [
16487
16568
  {
16488
16569
  version: 69,
16489
16570
  name: "daily-reflections-multiple-insights",
16490
- up: up73,
16571
+ up: up74,
16491
16572
  artifacts: {
16492
16573
  tables: ["daily_reflections"]
16493
16574
  }
@@ -16495,7 +16576,7 @@ var MIGRATIONS = [
16495
16576
  {
16496
16577
  version: 70,
16497
16578
  name: "ontology-control-plane-state",
16498
- up: up74,
16579
+ up: up75,
16499
16580
  artifacts: {
16500
16581
  columns: [
16501
16582
  { table: "entities", column: "status" },
@@ -16510,7 +16591,7 @@ var MIGRATIONS = [
16510
16591
  {
16511
16592
  version: 71,
16512
16593
  name: "epistemic-assertions",
16513
- up: up75,
16594
+ up: up76,
16514
16595
  artifacts: {
16515
16596
  tables: ["epistemic_assertions"]
16516
16597
  }
@@ -16518,7 +16599,7 @@ var MIGRATIONS = [
16518
16599
  {
16519
16600
  version: 72,
16520
16601
  name: "agent-scoped-idempotency-key",
16521
- up: up76,
16602
+ up: up77,
16522
16603
  artifacts: {
16523
16604
  columns: [
16524
16605
  { table: "memories", column: "idempotency_key" },
@@ -16529,7 +16610,7 @@ var MIGRATIONS = [
16529
16610
  {
16530
16611
  version: 73,
16531
16612
  name: "recall-context-dedupe",
16532
- up: up77,
16613
+ up: up78,
16533
16614
  artifacts: {
16534
16615
  tables: ["session_context_epochs", "session_recall_events"]
16535
16616
  }
@@ -16537,7 +16618,7 @@ var MIGRATIONS = [
16537
16618
  {
16538
16619
  version: 74,
16539
16620
  name: "aggregate-memory-links",
16540
- up: up78,
16621
+ up: up79,
16541
16622
  artifacts: {
16542
16623
  tables: ["aggregate_memory_sources"]
16543
16624
  }
@@ -16545,7 +16626,7 @@ var MIGRATIONS = [
16545
16626
  {
16546
16627
  version: 75,
16547
16628
  name: "memory-artifact-source-provenance",
16548
- up: up79,
16629
+ up: up80,
16549
16630
  artifacts: {
16550
16631
  columns: [
16551
16632
  { table: "memory_artifacts", column: "source_id" },
@@ -16559,7 +16640,7 @@ var MIGRATIONS = [
16559
16640
  {
16560
16641
  version: 76,
16561
16642
  name: "temporal-edges",
16562
- up: up80,
16643
+ up: up81,
16563
16644
  artifacts: {
16564
16645
  tables: ["temporal_edges"]
16565
16646
  }
@@ -16567,7 +16648,7 @@ var MIGRATIONS = [
16567
16648
  {
16568
16649
  version: 77,
16569
16650
  name: "entity-aliases",
16570
- up: up81,
16651
+ up: up82,
16571
16652
  artifacts: {
16572
16653
  tables: ["entity_aliases"]
16573
16654
  }
@@ -16575,7 +16656,7 @@ var MIGRATIONS = [
16575
16656
  {
16576
16657
  version: 78,
16577
16658
  name: "api-keys",
16578
- up: up82,
16659
+ up: up83,
16579
16660
  artifacts: {
16580
16661
  tables: ["api_keys"]
16581
16662
  }
@@ -16583,7 +16664,7 @@ var MIGRATIONS = [
16583
16664
  {
16584
16665
  version: 79,
16585
16666
  name: "transcript-capture-jobs",
16586
- up: up83,
16667
+ up: up84,
16587
16668
  artifacts: {
16588
16669
  tables: ["transcript_capture_jobs"]
16589
16670
  }
@@ -16591,7 +16672,7 @@ var MIGRATIONS = [
16591
16672
  {
16592
16673
  version: 80,
16593
16674
  name: "document-scope-columns",
16594
- up: up84,
16675
+ up: up85,
16595
16676
  artifacts: {
16596
16677
  columns: [
16597
16678
  { table: "documents", column: "agent_id" },
@@ -16602,7 +16683,7 @@ var MIGRATIONS = [
16602
16683
  {
16603
16684
  version: 81,
16604
16685
  name: "aggregate-evidence-sources",
16605
- up: up85,
16686
+ up: up86,
16606
16687
  artifacts: {
16607
16688
  tables: ["aggregate_evidence_sources"]
16608
16689
  }
@@ -16610,7 +16691,7 @@ var MIGRATIONS = [
16610
16691
  {
16611
16692
  version: 82,
16612
16693
  name: "skill-invocations-harness",
16613
- up: up86,
16694
+ up: up87,
16614
16695
  artifacts: {
16615
16696
  columns: [
16616
16697
  { table: "skill_invocations", column: "harness" },
@@ -16621,7 +16702,7 @@ var MIGRATIONS = [
16621
16702
  {
16622
16703
  version: 83,
16623
16704
  name: "memory-lifecycle-repair",
16624
- up: up87,
16705
+ up: up88,
16625
16706
  artifacts: {
16626
16707
  tables: ["transcript_capture_jobs", "aggregate_evidence_sources", "entity_dependencies"],
16627
16708
  columns: [
@@ -16636,7 +16717,7 @@ var MIGRATIONS = [
16636
16717
  {
16637
16718
  version: 84,
16638
16719
  name: "legacy-markdown-import-state",
16639
- up: up88,
16720
+ up: up89,
16640
16721
  artifacts: {
16641
16722
  tables: ["legacy_markdown_imports", "legacy_markdown_chunks"]
16642
16723
  }
@@ -16644,7 +16725,7 @@ var MIGRATIONS = [
16644
16725
  {
16645
16726
  version: 85,
16646
16727
  name: "backfill-relations-to-dependencies",
16647
- up: up89,
16728
+ up: up90,
16648
16729
  artifacts: {
16649
16730
  tables: ["entity_dependencies"]
16650
16731
  }
@@ -16652,7 +16733,7 @@ var MIGRATIONS = [
16652
16733
  {
16653
16734
  version: 86,
16654
16735
  name: "summary-jobs-content-hash",
16655
- up: up90,
16736
+ up: up91,
16656
16737
  artifacts: {
16657
16738
  columns: [{ table: "summary_jobs", column: "content_hash" }]
16658
16739
  }
@@ -16660,7 +16741,7 @@ var MIGRATIONS = [
16660
16741
  {
16661
16742
  version: 87,
16662
16743
  name: "summary-jobs-boundary-reason",
16663
- up: up91,
16744
+ up: up92,
16664
16745
  artifacts: {
16665
16746
  columns: [{ table: "summary_jobs", column: "boundary_reason" }]
16666
16747
  }
@@ -16668,7 +16749,7 @@ var MIGRATIONS = [
16668
16749
  {
16669
16750
  version: 88,
16670
16751
  name: "transcript-recovery-files",
16671
- up: up92,
16752
+ up: up93,
16672
16753
  artifacts: {
16673
16754
  tables: ["transcript_recovery_files"]
16674
16755
  }
@@ -16676,7 +16757,7 @@ var MIGRATIONS = [
16676
16757
  {
16677
16758
  version: 89,
16678
16759
  name: "job-cancellations",
16679
- up: up93,
16760
+ up: up94,
16680
16761
  artifacts: {
16681
16762
  tables: ["job_cancellations"]
16682
16763
  }
@@ -16684,7 +16765,7 @@ var MIGRATIONS = [
16684
16765
  {
16685
16766
  version: 90,
16686
16767
  name: "job-archive",
16687
- up: up94,
16768
+ up: up95,
16688
16769
  artifacts: {
16689
16770
  tables: ["job_archive"]
16690
16771
  }
@@ -16692,25 +16773,25 @@ var MIGRATIONS = [
16692
16773
  {
16693
16774
  version: 91,
16694
16775
  name: "embedding-index-generations",
16695
- up: up95,
16776
+ up: up96,
16696
16777
  artifacts: { tables: ["embedding_index_state"] }
16697
16778
  },
16698
16779
  {
16699
16780
  version: 92,
16700
16781
  name: "embedding-staging-store",
16701
- up: up96,
16782
+ up: up97,
16702
16783
  artifacts: { tables: ["embeddings_staging"] }
16703
16784
  },
16704
16785
  {
16705
16786
  version: 93,
16706
16787
  name: "dreaming-evidence-cursor",
16707
- up: up97,
16788
+ up: up98,
16708
16789
  artifacts: { columns: [{ table: "dreaming_state", column: "evidence_cursor" }] }
16709
16790
  },
16710
16791
  {
16711
16792
  version: 94,
16712
16793
  name: "memory-kind",
16713
- up: up98,
16794
+ up: up99,
16714
16795
  artifacts: {
16715
16796
  columns: [
16716
16797
  { table: "memories", column: "memory_kind" },
@@ -16721,35 +16802,35 @@ var MIGRATIONS = [
16721
16802
  {
16722
16803
  version: 95,
16723
16804
  name: "compaction-recall-projections",
16724
- up: up99
16805
+ up: up100
16725
16806
  },
16726
16807
  {
16727
16808
  version: 96,
16728
16809
  name: "retire-legacy-ingestion",
16729
- up: up100
16810
+ up: up101
16730
16811
  },
16731
16812
  {
16732
16813
  version: 97,
16733
16814
  name: "dreaming-failure-backoff",
16734
- up: up101,
16815
+ up: up102,
16735
16816
  artifacts: { columns: [{ table: "dreaming_state", column: "last_failure_at" }] }
16736
16817
  },
16737
16818
  {
16738
16819
  version: 98,
16739
16820
  name: "dreaming-evidence-exclusions",
16740
- up: up102,
16821
+ up: up103,
16741
16822
  artifacts: { tables: ["dreaming_evidence_exclusions"] }
16742
16823
  },
16743
16824
  {
16744
16825
  version: 99,
16745
16826
  name: "dreaming-tool-calls",
16746
- up: up103,
16827
+ up: up104,
16747
16828
  artifacts: { tables: ["dreaming_tool_calls"] }
16748
16829
  },
16749
16830
  {
16750
16831
  version: 100,
16751
16832
  name: "dreaming-runbook",
16752
- up: up104,
16833
+ up: up105,
16753
16834
  artifacts: {
16754
16835
  columns: [
16755
16836
  { table: "dreaming_passes", column: "evidence_window_json" },
@@ -16760,23 +16841,23 @@ var MIGRATIONS = [
16760
16841
  {
16761
16842
  version: 101,
16762
16843
  name: "dreaming-attention",
16763
- up: up105,
16844
+ up: up106,
16764
16845
  artifacts: { tables: ["dreaming_attention"] }
16765
16846
  },
16766
16847
  {
16767
16848
  version: 102,
16768
16849
  name: "attribute-semantic-memories",
16769
- up: up106
16850
+ up: up107
16770
16851
  },
16771
16852
  {
16772
16853
  version: 103,
16773
16854
  name: "semantic-memory-kind",
16774
- up: up107
16855
+ up: up108
16775
16856
  },
16776
16857
  {
16777
16858
  version: 104,
16778
16859
  name: "derived-memory-provenance",
16779
- up: up108,
16860
+ up: up109,
16780
16861
  artifacts: {
16781
16862
  tables: ["derived_memory_sources"],
16782
16863
  columns: [{ table: "memories", column: "stale_at" }]
@@ -16785,12 +16866,12 @@ var MIGRATIONS = [
16785
16866
  {
16786
16867
  version: 105,
16787
16868
  name: "agent-scoped-entity-name",
16788
- up: up109
16869
+ up: up110
16789
16870
  },
16790
16871
  {
16791
16872
  version: 106,
16792
16873
  name: "memory-review-after",
16793
- up: up110,
16874
+ up: up111,
16794
16875
  artifacts: {
16795
16876
  columns: [{ table: "memories", column: "review_after" }]
16796
16877
  }
@@ -16798,7 +16879,7 @@ var MIGRATIONS = [
16798
16879
  {
16799
16880
  version: 107,
16800
16881
  name: "dreaming-pass-usage",
16801
- up: up111,
16882
+ up: up112,
16802
16883
  artifacts: {
16803
16884
  columns: [
16804
16885
  { table: "dreaming_passes", column: "tokens_input" },
@@ -16812,7 +16893,7 @@ var MIGRATIONS = [
16812
16893
  {
16813
16894
  version: 108,
16814
16895
  name: "embedding-usage",
16815
- up: up112,
16896
+ up: up113,
16816
16897
  artifacts: {
16817
16898
  tables: ["embedding_usage"]
16818
16899
  }
@@ -16820,7 +16901,7 @@ var MIGRATIONS = [
16820
16901
  {
16821
16902
  version: 109,
16822
16903
  name: "telemetry-install",
16823
- up: up113,
16904
+ up: up114,
16824
16905
  artifacts: {
16825
16906
  tables: ["telemetry_install"]
16826
16907
  }
@@ -16828,12 +16909,12 @@ var MIGRATIONS = [
16828
16909
  {
16829
16910
  version: 110,
16830
16911
  name: "memory-mention-join-index",
16831
- up: up114
16912
+ up: up115
16832
16913
  },
16833
16914
  {
16834
16915
  version: 111,
16835
16916
  name: "telemetry-first-use",
16836
- up: up115,
16917
+ up: up116,
16837
16918
  artifacts: {
16838
16919
  columns: [
16839
16920
  { table: "telemetry_install", column: "first_remember_at" },
@@ -16844,7 +16925,7 @@ var MIGRATIONS = [
16844
16925
  {
16845
16926
  version: 112,
16846
16927
  name: "telemetry-queue-ownership",
16847
- up: up116,
16928
+ up: up117,
16848
16929
  artifacts: {
16849
16930
  columns: [
16850
16931
  { table: "telemetry_events", column: "source" },
@@ -16856,7 +16937,7 @@ var MIGRATIONS = [
16856
16937
  {
16857
16938
  version: 113,
16858
16939
  name: "session-claims",
16859
- up: up117,
16940
+ up: up118,
16860
16941
  artifacts: {
16861
16942
  tables: ["session_claims"],
16862
16943
  columns: [
@@ -16870,12 +16951,12 @@ var MIGRATIONS = [
16870
16951
  {
16871
16952
  version: 114,
16872
16953
  name: "memory-traversal-hydration-index",
16873
- up: up118
16954
+ up: up119
16874
16955
  },
16875
16956
  {
16876
16957
  version: 115,
16877
16958
  name: "cross-agent-message-notifications",
16878
- up: up119,
16959
+ up: up120,
16879
16960
  artifacts: {
16880
16961
  tables: ["cross_agent_messages", "cross_agent_message_receipts"]
16881
16962
  }
@@ -16883,7 +16964,7 @@ var MIGRATIONS = [
16883
16964
  {
16884
16965
  version: 116,
16885
16966
  name: "acp-delivery-reconciliation",
16886
- up: up120,
16967
+ up: up121,
16887
16968
  artifacts: {
16888
16969
  columns: [
16889
16970
  { table: "cross_agent_messages", column: "delivery_state" },
@@ -16897,7 +16978,7 @@ var MIGRATIONS = [
16897
16978
  {
16898
16979
  version: 117,
16899
16980
  name: "retire-summary-worker",
16900
- up: up121,
16981
+ up: up122,
16901
16982
  artifacts: {
16902
16983
  columns: [
16903
16984
  { table: "session_transcripts", column: "completed_at" },
@@ -16908,24 +16989,24 @@ var MIGRATIONS = [
16908
16989
  {
16909
16990
  version: 118,
16910
16991
  name: "queue-pressure-indices",
16911
- up: up122
16992
+ up: up123
16912
16993
  },
16913
16994
  {
16914
16995
  version: 119,
16915
16996
  name: "telemetry-version-observation",
16916
- up: up123,
16997
+ up: up124,
16917
16998
  artifacts: { columns: [{ table: "telemetry_install", column: "last_seen_version" }] }
16918
16999
  },
16919
17000
  {
16920
17001
  version: 120,
16921
17002
  name: "source-lifecycle-telemetry",
16922
- up: up124,
17003
+ up: up125,
16923
17004
  artifacts: { tables: ["source_lifecycle_state"] }
16924
17005
  },
16925
17006
  {
16926
17007
  version: 121,
16927
17008
  name: "telemetry-delivery-health",
16928
- up: up125,
17009
+ up: up126,
16929
17010
  artifacts: {
16930
17011
  tables: ["telemetry_delivery_state"],
16931
17012
  columns: [
@@ -16939,7 +17020,7 @@ var MIGRATIONS = [
16939
17020
  {
16940
17021
  version: 122,
16941
17022
  name: "dreaming-evidence-retry",
16942
- up: up126,
17023
+ up: up127,
16943
17024
  artifacts: {
16944
17025
  columns: [
16945
17026
  { table: "dreaming_evidence_exclusions", column: "failure_class" },
@@ -16952,13 +17033,13 @@ var MIGRATIONS = [
16952
17033
  {
16953
17034
  version: 123,
16954
17035
  name: "embedding-index-failures",
16955
- up: up127,
17036
+ up: up128,
16956
17037
  artifacts: { tables: ["embedding_index_failures"] }
16957
17038
  },
16958
17039
  {
16959
17040
  version: 124,
16960
17041
  name: "import-derived-lifecycle",
16961
- up: up128,
17042
+ up: up129,
16962
17043
  artifacts: {
16963
17044
  tables: ["imported_source_lifecycle"]
16964
17045
  }
@@ -16966,77 +17047,77 @@ var MIGRATIONS = [
16966
17047
  {
16967
17048
  version: 125,
16968
17049
  name: "memory-content-safety",
16969
- up: up129,
17050
+ up: up130,
16970
17051
  artifacts: { tables: ["memory_content_safety"] }
16971
17052
  },
16972
17053
  {
16973
17054
  version: 126,
16974
17055
  name: "dreaming-surprisal-attention",
16975
- up: up130,
17056
+ up: up131,
16976
17057
  artifacts: { tables: ["dreaming_attention"] }
16977
17058
  },
16978
17059
  {
16979
17060
  version: 127,
16980
17061
  name: "ontology-contradictions",
16981
- up: up131,
17062
+ up: up132,
16982
17063
  artifacts: { tables: ["ontology_contradictions"] }
16983
17064
  },
16984
17065
  {
16985
17066
  version: 128,
16986
17067
  name: "bounded-queue-diagnostics",
16987
- up: up132
17068
+ up: up133
16988
17069
  },
16989
17070
  {
16990
17071
  version: 129,
16991
17072
  name: "retire-structural-jobs",
16992
- up: up133
17073
+ up: up134
16993
17074
  },
16994
17075
  {
16995
17076
  version: 130,
16996
17077
  name: "embedding-repair-state",
16997
- up: up134,
17078
+ up: up135,
16998
17079
  artifacts: { tables: ["embedding_repair_budget", "embedding_repair_backoff"] }
16999
17080
  },
17000
17081
  {
17001
17082
  version: 131,
17002
17083
  name: "dreaming-evidence-consumption",
17003
- up: up135,
17084
+ up: up136,
17004
17085
  artifacts: { tables: ["dreaming_evidence_consumption"] }
17005
17086
  },
17006
17087
  {
17007
17088
  version: 132,
17008
17089
  name: "observer-scoped-epistemic-assertions",
17009
- up: up136,
17090
+ up: up137,
17010
17091
  artifacts: { tables: ["epistemic_assertions"] }
17011
17092
  },
17012
17093
  {
17013
17094
  version: 133,
17014
17095
  name: "dreaming-memory-head",
17015
- up: up137,
17096
+ up: up138,
17016
17097
  artifacts: { tables: ["memory_head_revisions", "memory_head_entries", "memory_head_revision_entries"] }
17017
17098
  },
17018
17099
  {
17019
17100
  version: 134,
17020
17101
  name: "scope-memory-head-entries",
17021
- up: up138,
17102
+ up: up139,
17022
17103
  artifacts: { tables: ["memory_head_entries"] }
17023
17104
  },
17024
17105
  {
17025
17106
  version: 135,
17026
17107
  name: "memory-head-publication",
17027
- up: up139,
17108
+ up: up140,
17028
17109
  artifacts: { tables: ["memory_head_publications"] }
17029
17110
  },
17030
17111
  {
17031
17112
  version: 136,
17032
17113
  name: "memory-head-revisions",
17033
- up: up140,
17114
+ up: up141,
17034
17115
  artifacts: { tables: ["memory_head_revisions"] }
17035
17116
  },
17036
17117
  {
17037
17118
  version: 137,
17038
17119
  name: "dreaming-head-manifest",
17039
- up: up141,
17120
+ up: up142,
17040
17121
  artifacts: {
17041
17122
  columns: [
17042
17123
  { table: "dreaming_passes", column: "head_revision" },
@@ -17047,7 +17128,7 @@ var MIGRATIONS = [
17047
17128
  {
17048
17129
  version: 138,
17049
17130
  name: "bounded-status-projections",
17050
- up: up142,
17131
+ up: up143,
17051
17132
  artifacts: {
17052
17133
  tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
17053
17134
  }
@@ -17055,31 +17136,31 @@ var MIGRATIONS = [
17055
17136
  {
17056
17137
  version: 139,
17057
17138
  name: "native-source-sync-state",
17058
- up: up143,
17139
+ up: up144,
17059
17140
  artifacts: { tables: ["native_source_sync_state"] }
17060
17141
  },
17061
17142
  {
17062
17143
  version: 140,
17063
17144
  name: "transcript-recovery-frontier",
17064
- up: up144,
17145
+ up: up145,
17065
17146
  artifacts: { tables: ["transcript_recovery_frontiers"] }
17066
17147
  },
17067
17148
  {
17068
17149
  version: 141,
17069
17150
  name: "source-sync-checkpoints",
17070
- up: up145,
17151
+ up: up146,
17071
17152
  artifacts: { tables: ["source_sync_checkpoints"] }
17072
17153
  },
17073
17154
  {
17074
17155
  version: 142,
17075
17156
  name: "source-sync-frontier",
17076
- up: up146,
17157
+ up: up147,
17077
17158
  artifacts: { columns: [{ table: "source_sync_checkpoints", column: "frontier" }] }
17078
17159
  },
17079
17160
  {
17080
17161
  version: 143,
17081
17162
  name: "embedding-index-progress",
17082
- up: up147,
17163
+ up: up148,
17083
17164
  artifacts: {
17084
17165
  columns: [
17085
17166
  { table: "embedding_index_state", column: "migration_phase" },
@@ -17095,19 +17176,19 @@ var MIGRATIONS = [
17095
17176
  {
17096
17177
  version: 144,
17097
17178
  name: "memory-job-lease-token",
17098
- up: up148,
17179
+ up: up149,
17099
17180
  artifacts: { columns: [{ table: "memory_jobs", column: "lease_token" }] }
17100
17181
  },
17101
17182
  {
17102
17183
  version: 145,
17103
17184
  name: "dreaming-evidence-reviews",
17104
- up: up149,
17185
+ up: up150,
17105
17186
  artifacts: { tables: ["dreaming_evidence_reviews"] }
17106
17187
  },
17107
17188
  {
17108
17189
  version: 146,
17109
17190
  name: "source-transcript-import",
17110
- up: up150,
17191
+ up: up151,
17111
17192
  artifacts: {
17112
17193
  tables: [
17113
17194
  "source_import_jobs",
@@ -17126,19 +17207,19 @@ var MIGRATIONS = [
17126
17207
  {
17127
17208
  version: 147,
17128
17209
  name: "source-import-replay-file-slots",
17129
- up: up151,
17210
+ up: up152,
17130
17211
  artifacts: { tables: ["source_import_files"] }
17131
17212
  },
17132
17213
  {
17133
17214
  version: 148,
17134
17215
  name: "source-import-attempt-provenance",
17135
- up: up152,
17216
+ up: up153,
17136
17217
  artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
17137
17218
  },
17138
17219
  {
17139
17220
  version: 149,
17140
17221
  name: "transcript-import-state-machine",
17141
- up: up153,
17222
+ up: up154,
17142
17223
  artifacts: {
17143
17224
  columns: [
17144
17225
  { table: "source_import_jobs", column: "duplicate_mode" },
@@ -17150,7 +17231,7 @@ var MIGRATIONS = [
17150
17231
  {
17151
17232
  version: 150,
17152
17233
  name: "memory-head-freshness",
17153
- up: up154,
17234
+ up: up155,
17154
17235
  artifacts: {
17155
17236
  columns: [
17156
17237
  { table: "memory_md_heads", column: "is_current" },
@@ -17196,7 +17277,7 @@ var MIGRATIONS = [
17196
17277
  {
17197
17278
  version: 153,
17198
17279
  name: "vector-repair-checkpoints",
17199
- up: up155,
17280
+ up: up156,
17200
17281
  artifacts: { tables: ["vector_repair_checkpoints"] }
17201
17282
  },
17202
17283
  {
@@ -17223,13 +17304,13 @@ var MIGRATIONS = [
17223
17304
  {
17224
17305
  version: 156,
17225
17306
  name: "embedding-repair-checkpoints",
17226
- up: up156,
17307
+ up: up157,
17227
17308
  artifacts: { tables: ["embedding_repair_checkpoints"] }
17228
17309
  },
17229
17310
  {
17230
17311
  version: 157,
17231
17312
  name: "embedding-repair-progress",
17232
- up: up157,
17313
+ up: up158,
17233
17314
  artifacts: {
17234
17315
  tables: ["embedding_repair_progress"],
17235
17316
  columns: [{ table: "embedding_repair_checkpoints", column: "profile_fingerprint" }]
@@ -17238,8 +17319,25 @@ var MIGRATIONS = [
17238
17319
  {
17239
17320
  version: 158,
17240
17321
  name: "dreaming-candidate-scan-index",
17241
- up: up158,
17322
+ up: up159,
17242
17323
  artifacts: { indexes: ["idx_memories_agent_kind"] }
17324
+ },
17325
+ {
17326
+ version: 159,
17327
+ name: "retire-obsolete-invocation-ledger",
17328
+ up: up5
17329
+ },
17330
+ {
17331
+ version: 160,
17332
+ name: "import-admission-ledger",
17333
+ up: up160,
17334
+ artifacts: {
17335
+ tables: ["import_admission_ledger", "import_admission_events"],
17336
+ indexes: ["idx_import_admission_status", "idx_import_admission_events_key"],
17337
+ columns: [
17338
+ ...["workspace_id", "request_fingerprint", "source_id", "lease_token", "lease_expires_at", "attempt_count"].map((column) => ({ table: "import_admission_ledger", column }))
17339
+ ]
17340
+ }
17243
17341
  }
17244
17342
  ];
17245
17343
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -17254,6 +17352,98 @@ function expandHome(p2, home = homedir2()) {
17254
17352
  return join2(home, p2.slice(2));
17255
17353
  return p2;
17256
17354
  }
17355
+ var SIGNET_SOURCE_CHECKOUT_DIRNAME = "signetai";
17356
+ var SIGNET_GIT_ALLOWED_DIRECTORIES = ["skills", "tools", "dreaming"];
17357
+ var SIGNET_GIT_PROTECTED_PATHS = [
17358
+ ".daemon",
17359
+ ".secrets",
17360
+ ".shadow",
17361
+ "cache",
17362
+ "data",
17363
+ "files",
17364
+ "runtime",
17365
+ "workspace-layout.json",
17366
+ "node_modules",
17367
+ ":(glob)**/node_modules/**",
17368
+ `${SIGNET_SOURCE_CHECKOUT_DIRNAME}`,
17369
+ "memory/backups",
17370
+ "memory/memories.db",
17371
+ ":(glob)memory/memories.db*",
17372
+ ":(glob)memory/**/*.db",
17373
+ ":(glob)memory/**/*.db-*",
17374
+ ":(glob)memory/**/*.db-journal",
17375
+ ":(glob)memory/**/*.db-shm",
17376
+ ":(glob)memory/**/*.db-wal",
17377
+ ":(glob)memory/**/*.sqlite",
17378
+ ":(glob)memory/**/*.sqlite3",
17379
+ ":(glob)**/*.db",
17380
+ ":(glob)**/*.db-*",
17381
+ ":(glob)**/*.db-journal",
17382
+ ":(glob)**/*.db-shm",
17383
+ ":(glob)**/*.db-wal",
17384
+ ":(glob)**/*.sqlite",
17385
+ ":(glob)**/*.sqlite3"
17386
+ ];
17387
+ var SIGNET_GIT_TRACKED_PATHS = [
17388
+ "*.md",
17389
+ ":(glob)**/*.md",
17390
+ "*.json",
17391
+ ":(glob)**/*.json",
17392
+ "*.jsonl",
17393
+ ":(glob)**/*.jsonl",
17394
+ "*.html",
17395
+ ":(glob)**/*.html",
17396
+ "*.yaml",
17397
+ ":(glob)**/*.yaml",
17398
+ "*.yml",
17399
+ ":(glob)**/*.yml",
17400
+ ...SIGNET_GIT_ALLOWED_DIRECTORIES
17401
+ ];
17402
+ var SIGNET_GITIGNORE_PROTECTED_PATTERNS = [
17403
+ ".daemon/",
17404
+ ".secrets/",
17405
+ ".shadow/",
17406
+ "cache/",
17407
+ "data/",
17408
+ "files/",
17409
+ "runtime/",
17410
+ "workspace-layout.json",
17411
+ "node_modules/",
17412
+ `${SIGNET_SOURCE_CHECKOUT_DIRNAME}/`,
17413
+ "memory/memories.db*",
17414
+ "memory/**/*.db",
17415
+ "memory/**/*.db-*",
17416
+ "memory/**/*.db-journal",
17417
+ "memory/**/*.db-shm",
17418
+ "memory/**/*.db-wal",
17419
+ "memory/**/*.sqlite",
17420
+ "memory/**/*.sqlite3",
17421
+ "memory/backups/",
17422
+ "*.db",
17423
+ "*.db-*",
17424
+ "*.db-journal",
17425
+ "*.db-shm",
17426
+ "*.db-wal",
17427
+ "*.sqlite",
17428
+ "*.sqlite3"
17429
+ ];
17430
+ var DESCRIPTOR_ROOT = process.platform === "linux" ? "/proc/self/fd" : process.platform === "darwin" ? "/dev/fd" : undefined;
17431
+ var DIRECTORY_FLAGS = fsConstants.O_RDONLY | (fsConstants.O_DIRECTORY ?? 0) | (fsConstants.O_NOFOLLOW ?? 0);
17432
+ var FILE_FLAGS = fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0) | (fsConstants.O_NONBLOCK ?? 0);
17433
+ var NOFOLLOW = fsConstants.O_NOFOLLOW ?? 0;
17434
+ var PROTECTION_COMPONENT_IDS = [
17435
+ "root-authored",
17436
+ "skills",
17437
+ "managed-originals",
17438
+ "sqlite",
17439
+ "transcripts",
17440
+ "external-sources",
17441
+ "runtime",
17442
+ "filesystem-cache",
17443
+ "secrets"
17444
+ ];
17445
+ var ORDER = new Map(PROTECTION_COMPONENT_IDS.map((id, index) => [id, index]));
17446
+ var BLOCKING = new Set(["missing", "stale", "degraded"]);
17257
17447
  var STATES = new Set([
17258
17448
  "found",
17259
17449
  "missing",
@@ -17350,7 +17540,7 @@ function resolveSignetDaemonUrl(opts = {}) {
17350
17540
  var WORKSPACE_ENV_KEYS = ["SIGNET_PATH", "SIGNET_WORKSPACE"];
17351
17541
  var DEFAULT_AGENTS_DIRNAME = ".agents";
17352
17542
  function normalizeWorkspacePath(pathValue, home = homedir4()) {
17353
- return resolve2(expandHome(pathValue.trim(), home));
17543
+ return resolve7(expandHome(pathValue.trim(), home));
17354
17544
  }
17355
17545
  function readTrimmedEnv(env, name) {
17356
17546
  const value = env[name];
@@ -17362,13 +17552,13 @@ function readTrimmedEnv(env, name) {
17362
17552
  function readConfigHome(env, home) {
17363
17553
  const raw = env.XDG_CONFIG_HOME;
17364
17554
  if (typeof raw !== "string")
17365
- return join8(home, ".config");
17555
+ return join13(home, ".config");
17366
17556
  const trimmed = raw.trim();
17367
- return trimmed.length > 0 ? normalizeWorkspacePath(trimmed, home) : join8(home, ".config");
17557
+ return trimmed.length > 0 ? normalizeWorkspacePath(trimmed, home) : join13(home, ".config");
17368
17558
  }
17369
17559
  function isExistingDirectory(path) {
17370
17560
  try {
17371
- return statSync3(path).isDirectory();
17561
+ return statSync5(path).isDirectory();
17372
17562
  } catch {
17373
17563
  return false;
17374
17564
  }
@@ -17377,16 +17567,16 @@ function isRecord5(value) {
17377
17567
  return typeof value === "object" && value !== null && !Array.isArray(value);
17378
17568
  }
17379
17569
  function getWorkspaceConfigPath(env = process.env, home = homedir4()) {
17380
- return join8(readConfigHome(env, home), "signet", "workspace.json");
17570
+ return join13(readConfigHome(env, home), "signet", "workspace.json");
17381
17571
  }
17382
17572
  function readConfiguredWorkspacePath(env = process.env, home = homedir4(), options = {}) {
17383
17573
  const strict = options.strict ?? true;
17384
17574
  const configPath = getWorkspaceConfigPath(env, home);
17385
- if (!existsSync7(configPath))
17575
+ if (!existsSync12(configPath))
17386
17576
  return null;
17387
17577
  let raw;
17388
17578
  try {
17389
- raw = JSON.parse(readFileSync5(configPath, "utf-8"));
17579
+ raw = JSON.parse(readFileSync9(configPath, "utf-8"));
17390
17580
  } catch (err) {
17391
17581
  if (!strict)
17392
17582
  return null;
@@ -17431,7 +17621,7 @@ function resolveWorkspacePath(options = {}) {
17431
17621
  };
17432
17622
  }
17433
17623
  return {
17434
- path: join8(home, DEFAULT_AGENTS_DIRNAME),
17624
+ path: join13(home, DEFAULT_AGENTS_DIRNAME),
17435
17625
  source: "default",
17436
17626
  configPath,
17437
17627
  configuredPath: configValue
@@ -17454,81 +17644,18 @@ try {
17454
17644
  const esmRequire = createRequire2(import.meta.url);
17455
17645
  native = esmRequire("@signet/native");
17456
17646
  } catch {}
17457
- var GRAPHIQ_DEFAULT_INSTALL_DIR = join9(homedir5(), ".local", "bin");
17458
- var SIGNET_SOURCE_CHECKOUT_DIRNAME = "signetai";
17459
- var SIGNET_GIT_ALLOWED_DIRECTORIES = ["skills", "tools", "dreaming"];
17460
- var SIGNET_GIT_PROTECTED_PATHS = [
17461
- ".daemon",
17462
- ".shadow",
17463
- "node_modules",
17464
- ":(glob)**/node_modules/**",
17465
- `${SIGNET_SOURCE_CHECKOUT_DIRNAME}`,
17466
- "memory/backups",
17467
- "memory/memories.db",
17468
- ":(glob)memory/memories.db*",
17469
- ":(glob)memory/**/*.db",
17470
- ":(glob)memory/**/*.db-*",
17471
- ":(glob)memory/**/*.db-journal",
17472
- ":(glob)memory/**/*.db-shm",
17473
- ":(glob)memory/**/*.db-wal",
17474
- ":(glob)memory/**/*.sqlite",
17475
- ":(glob)memory/**/*.sqlite3",
17476
- ":(glob)**/*.db",
17477
- ":(glob)**/*.db-*",
17478
- ":(glob)**/*.db-journal",
17479
- ":(glob)**/*.db-shm",
17480
- ":(glob)**/*.db-wal",
17481
- ":(glob)**/*.sqlite",
17482
- ":(glob)**/*.sqlite3"
17483
- ];
17484
- var SIGNET_GIT_TRACKED_PATHS = [
17485
- "*.md",
17486
- ":(glob)**/*.md",
17487
- "*.json",
17488
- ":(glob)**/*.json",
17489
- "*.jsonl",
17490
- ":(glob)**/*.jsonl",
17491
- "*.html",
17492
- ":(glob)**/*.html",
17493
- "*.yaml",
17494
- ":(glob)**/*.yaml",
17495
- "*.yml",
17496
- ":(glob)**/*.yml",
17497
- ...SIGNET_GIT_ALLOWED_DIRECTORIES
17498
- ];
17499
- var SIGNET_GITIGNORE_PROTECTED_PATTERNS = [
17500
- ".daemon/",
17501
- ".shadow/",
17502
- "node_modules/",
17503
- `${SIGNET_SOURCE_CHECKOUT_DIRNAME}/`,
17504
- "memory/memories.db*",
17505
- "memory/**/*.db",
17506
- "memory/**/*.db-*",
17507
- "memory/**/*.db-journal",
17508
- "memory/**/*.db-shm",
17509
- "memory/**/*.db-wal",
17510
- "memory/**/*.sqlite",
17511
- "memory/**/*.sqlite3",
17512
- "memory/backups/",
17513
- "*.db",
17514
- "*.db-*",
17515
- "*.db-journal",
17516
- "*.db-shm",
17517
- "*.db-wal",
17518
- "*.sqlite",
17519
- "*.sqlite3"
17520
- ];
17647
+ var GRAPHIQ_DEFAULT_INSTALL_DIR = join14(homedir5(), ".local", "bin");
17521
17648
  var DEFAULT_DISCORD_DESKTOP_CACHE_PATH = defaultDiscordDesktopCachePath();
17522
17649
  var DEFAULT_GITHUB_RESOURCE_TYPES = ["issues", "pulls", "discussions", "docs"];
17523
17650
  var VALID_GITHUB_RESOURCE_TYPES = new Set(DEFAULT_GITHUB_RESOURCE_TYPES);
17524
17651
  function defaultDiscordDesktopCachePath() {
17525
17652
  switch (platform2()) {
17526
17653
  case "darwin":
17527
- return resolve5(homedir6(), "Library", "Application Support", "discord");
17654
+ return resolve9(homedir6(), "Library", "Application Support", "discord");
17528
17655
  case "win32":
17529
- return resolve5(process.env.APPDATA || resolve5(homedir6(), "AppData", "Roaming"), "discord");
17656
+ return resolve9(process.env.APPDATA || resolve9(homedir6(), "AppData", "Roaming"), "discord");
17530
17657
  default:
17531
- return resolve5(process.env.XDG_CONFIG_HOME || resolve5(homedir6(), ".config"), "discord");
17658
+ return resolve9(process.env.XDG_CONFIG_HOME || resolve9(homedir6(), ".config"), "discord");
17532
17659
  }
17533
17660
  }
17534
17661
  var IDENTITY_FILES = {
@@ -17588,7 +17715,7 @@ var REQUIRED_IDENTITY_KEYS = Object.entries(IDENTITY_FILES).filter(([, spec]) =>
17588
17715
  var OPTIONAL_IDENTITY_KEYS = Object.entries(IDENTITY_FILES).filter(([, spec]) => spec.optional).map(([key]) => key);
17589
17716
  function linkDirSync(target, path) {
17590
17717
  const type = process.platform === "win32" ? "junction" : "dir";
17591
- symlinkSync(target, path, type);
17718
+ symlinkSync2(target, path, type);
17592
17719
  }
17593
17720
  function symlinkSkills(sourceDir, targetDir, options = {}) {
17594
17721
  const result = {
@@ -17596,19 +17723,19 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
17596
17723
  skipped: [],
17597
17724
  errors: []
17598
17725
  };
17599
- if (!existsSync14(sourceDir)) {
17726
+ if (!existsSync18(sourceDir)) {
17600
17727
  return result;
17601
17728
  }
17602
- const targetParent = join14(targetDir, "..");
17603
- if (!existsSync14(targetParent)) {
17604
- mkdirSync8(targetParent, { recursive: true });
17729
+ const targetParent = join18(targetDir, "..");
17730
+ if (!existsSync18(targetParent)) {
17731
+ mkdirSync10(targetParent, { recursive: true });
17605
17732
  }
17606
- if (!existsSync14(targetDir)) {
17607
- mkdirSync8(targetDir, { recursive: true });
17733
+ if (!existsSync18(targetDir)) {
17734
+ mkdirSync10(targetDir, { recursive: true });
17608
17735
  }
17609
17736
  let entries;
17610
17737
  try {
17611
- entries = readdirSync6(sourceDir);
17738
+ entries = readdirSync9(sourceDir);
17612
17739
  } catch (e) {
17613
17740
  result.errors.push({
17614
17741
  path: sourceDir,
@@ -17617,10 +17744,10 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
17617
17744
  return result;
17618
17745
  }
17619
17746
  for (const entry of entries) {
17620
- const srcPath = join14(sourceDir, entry);
17621
- const destPath = join14(targetDir, entry);
17747
+ const srcPath = join18(sourceDir, entry);
17748
+ const destPath = join18(targetDir, entry);
17622
17749
  try {
17623
- const src = lstatSync(srcPath);
17750
+ const src = lstatSync3(srcPath);
17624
17751
  if (src.isSymbolicLink() || !src.isDirectory()) {
17625
17752
  result.skipped.push(srcPath);
17626
17753
  continue;
@@ -17633,7 +17760,7 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
17633
17760
  continue;
17634
17761
  }
17635
17762
  try {
17636
- const destStat = lstatSync(destPath);
17763
+ const destStat = lstatSync3(destPath);
17637
17764
  if (destStat.isSymbolicLink()) {
17638
17765
  if (!options.dryRun) {
17639
17766
  unlinkSync2(destPath);