@signetai/connector-hermes-agent 0.211.16 → 0.211.20

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 (2) hide show
  1. package/dist/index.js +669 -27
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -15735,6 +15735,319 @@ function up137(db) {
15735
15735
  if (!cols.has(name))
15736
15736
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
15737
15737
  }
15738
+ function hasColumn25(db, table, column) {
15739
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
15740
+ return rows.some((row) => row.name === column);
15741
+ }
15742
+ function addColumnIfMissing27(db, table, column, definition) {
15743
+ if (!hasColumn25(db, table, column))
15744
+ db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
15745
+ }
15746
+ function up138(db) {
15747
+ addColumnIfMissing27(db, "memories", "manual_override", "INTEGER DEFAULT 0");
15748
+ db.exec(`
15749
+ CREATE TABLE IF NOT EXISTS transcript_capture_status (
15750
+ agent_id TEXT PRIMARY KEY,
15751
+ pending INTEGER NOT NULL DEFAULT 0,
15752
+ processing INTEGER NOT NULL DEFAULT 0,
15753
+ completed INTEGER NOT NULL DEFAULT 0,
15754
+ failed INTEGER NOT NULL DEFAULT 0,
15755
+ dead INTEGER NOT NULL DEFAULT 0,
15756
+ oldest_pending_at TEXT,
15757
+ last_error TEXT,
15758
+ last_error_at TEXT
15759
+ );
15760
+
15761
+ CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_agent_status_created_at
15762
+ ON transcript_capture_jobs(agent_id, status, created_at);
15763
+
15764
+ CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_error_updated_at
15765
+ ON transcript_capture_jobs(agent_id, updated_at DESC)
15766
+ WHERE error IS NOT NULL;
15767
+
15768
+ CREATE TABLE IF NOT EXISTS memories_duplicate_hash_counts (
15769
+ content_hash TEXT PRIMARY KEY,
15770
+ dup_count INTEGER NOT NULL
15771
+ );
15772
+
15773
+ CREATE INDEX IF NOT EXISTS idx_memories_dup_counts_active
15774
+ ON memories_duplicate_hash_counts(dup_count)
15775
+ WHERE dup_count > 1;
15776
+
15777
+ CREATE TABLE IF NOT EXISTS memories_diagnostics_state (
15778
+ id INTEGER PRIMARY KEY CHECK (id = 1),
15779
+ total_active INTEGER NOT NULL DEFAULT 0,
15780
+ exact_duplicates INTEGER NOT NULL DEFAULT 0,
15781
+ exact_clusters INTEGER NOT NULL DEFAULT 0
15782
+ );
15783
+
15784
+ CREATE INDEX IF NOT EXISTS idx_memories_active_hash_diagnostics
15785
+ ON memories(content_hash)
15786
+ WHERE is_deleted = 0
15787
+ AND content_hash IS NOT NULL
15788
+ AND pinned = 0
15789
+ AND manual_override = 0;
15790
+ `);
15791
+ db.exec(`
15792
+ CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ai
15793
+ AFTER INSERT ON transcript_capture_jobs
15794
+ BEGIN
15795
+ INSERT INTO transcript_capture_status (agent_id)
15796
+ VALUES (NEW.agent_id)
15797
+ ON CONFLICT(agent_id) DO NOTHING;
15798
+
15799
+ UPDATE transcript_capture_status
15800
+ SET pending = pending + (NEW.status = 'pending'),
15801
+ processing = processing + (NEW.status = 'processing'),
15802
+ completed = completed + (NEW.status = 'completed'),
15803
+ failed = failed + (NEW.status = 'failed'),
15804
+ dead = dead + (NEW.status = 'dead')
15805
+ WHERE agent_id = NEW.agent_id;
15806
+
15807
+ UPDATE transcript_capture_status
15808
+ SET oldest_pending_at = (
15809
+ SELECT MIN(created_at) FROM transcript_capture_jobs
15810
+ WHERE agent_id = NEW.agent_id AND status = 'pending'
15811
+ )
15812
+ WHERE agent_id = NEW.agent_id;
15813
+
15814
+ UPDATE transcript_capture_status
15815
+ SET last_error = (
15816
+ SELECT error FROM transcript_capture_jobs
15817
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
15818
+ ORDER BY updated_at DESC LIMIT 1
15819
+ ),
15820
+ last_error_at = (
15821
+ SELECT updated_at FROM transcript_capture_jobs
15822
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
15823
+ ORDER BY updated_at DESC LIMIT 1
15824
+ )
15825
+ WHERE agent_id = NEW.agent_id
15826
+ AND NEW.error IS NOT NULL;
15827
+ END;
15828
+
15829
+ CREATE TRIGGER IF NOT EXISTS transcript_capture_status_au
15830
+ AFTER UPDATE OF status, error, updated_at, created_at ON transcript_capture_jobs
15831
+ BEGIN
15832
+ UPDATE transcript_capture_status
15833
+ SET pending = pending + (NEW.status = 'pending') - (OLD.status = 'pending'),
15834
+ processing = processing + (NEW.status = 'processing') - (OLD.status = 'processing'),
15835
+ completed = completed + (NEW.status = 'completed') - (OLD.status = 'completed'),
15836
+ failed = failed + (NEW.status = 'failed') - (OLD.status = 'failed'),
15837
+ dead = dead + (NEW.status = 'dead') - (OLD.status = 'dead')
15838
+ WHERE agent_id = NEW.agent_id;
15839
+
15840
+ UPDATE transcript_capture_status
15841
+ SET oldest_pending_at = (
15842
+ SELECT MIN(created_at) FROM transcript_capture_jobs
15843
+ WHERE agent_id = NEW.agent_id AND status = 'pending'
15844
+ )
15845
+ WHERE agent_id = NEW.agent_id;
15846
+
15847
+ UPDATE transcript_capture_status
15848
+ SET last_error = (
15849
+ SELECT error FROM transcript_capture_jobs
15850
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
15851
+ ORDER BY updated_at DESC LIMIT 1
15852
+ ),
15853
+ last_error_at = (
15854
+ SELECT updated_at FROM transcript_capture_jobs
15855
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
15856
+ ORDER BY updated_at DESC LIMIT 1
15857
+ )
15858
+ WHERE agent_id = NEW.agent_id
15859
+ AND (NEW.error IS NOT NULL OR OLD.error IS NOT NULL);
15860
+ END;
15861
+
15862
+ CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ad
15863
+ AFTER DELETE ON transcript_capture_jobs
15864
+ BEGIN
15865
+ UPDATE transcript_capture_status
15866
+ SET pending = pending - (OLD.status = 'pending'),
15867
+ processing = processing - (OLD.status = 'processing'),
15868
+ completed = completed - (OLD.status = 'completed'),
15869
+ failed = failed - (OLD.status = 'failed'),
15870
+ dead = dead - (OLD.status = 'dead')
15871
+ WHERE agent_id = OLD.agent_id;
15872
+
15873
+ UPDATE transcript_capture_status
15874
+ SET oldest_pending_at = (
15875
+ SELECT MIN(created_at) FROM transcript_capture_jobs
15876
+ WHERE agent_id = OLD.agent_id AND status = 'pending'
15877
+ )
15878
+ WHERE agent_id = OLD.agent_id;
15879
+
15880
+ UPDATE transcript_capture_status
15881
+ SET last_error = (
15882
+ SELECT error FROM transcript_capture_jobs
15883
+ WHERE agent_id = OLD.agent_id AND error IS NOT NULL
15884
+ ORDER BY updated_at DESC LIMIT 1
15885
+ ),
15886
+ last_error_at = (
15887
+ SELECT updated_at FROM transcript_capture_jobs
15888
+ WHERE agent_id = OLD.agent_id AND error IS NOT NULL
15889
+ ORDER BY updated_at DESC LIMIT 1
15890
+ )
15891
+ WHERE agent_id = OLD.agent_id
15892
+ AND OLD.error IS NOT NULL;
15893
+ END;
15894
+ `);
15895
+ db.exec(`
15896
+ CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ai
15897
+ AFTER INSERT ON memories
15898
+ BEGIN
15899
+ UPDATE memories_diagnostics_state
15900
+ SET total_active = total_active + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END,
15901
+ exact_duplicates = exact_duplicates + CASE
15902
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
15903
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
15904
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
15905
+ THEN 1 ELSE 0 END,
15906
+ exact_clusters = exact_clusters + CASE
15907
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
15908
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
15909
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
15910
+ THEN 1 ELSE 0 END
15911
+ WHERE id = 1;
15912
+
15913
+ INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
15914
+ SELECT NEW.content_hash, 1
15915
+ WHERE NEW.is_deleted = 0
15916
+ AND NEW.content_hash IS NOT NULL
15917
+ AND NEW.pinned = 0
15918
+ AND NEW.manual_override = 0
15919
+ ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
15920
+ END;
15921
+
15922
+ CREATE TRIGGER IF NOT EXISTS memories_dup_projection_au
15923
+ AFTER UPDATE OF is_deleted, content_hash, pinned, manual_override ON memories
15924
+ BEGIN
15925
+ UPDATE memories_diagnostics_state
15926
+ SET total_active = total_active
15927
+ + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END
15928
+ - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
15929
+ exact_duplicates = exact_duplicates - CASE
15930
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
15931
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
15932
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
15933
+ THEN 1 ELSE 0 END,
15934
+ exact_clusters = exact_clusters - CASE
15935
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
15936
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
15937
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
15938
+ THEN 1 ELSE 0 END
15939
+ WHERE id = 1;
15940
+
15941
+ UPDATE memories_duplicate_hash_counts
15942
+ SET dup_count = dup_count - 1
15943
+ WHERE OLD.is_deleted = 0
15944
+ AND OLD.content_hash IS NOT NULL
15945
+ AND OLD.pinned = 0
15946
+ AND OLD.manual_override = 0
15947
+ AND content_hash = OLD.content_hash;
15948
+
15949
+ DELETE FROM memories_duplicate_hash_counts
15950
+ WHERE content_hash = OLD.content_hash
15951
+ AND dup_count <= 0;
15952
+
15953
+ UPDATE memories_diagnostics_state
15954
+ SET exact_duplicates = exact_duplicates + CASE
15955
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
15956
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
15957
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
15958
+ THEN 1 ELSE 0 END,
15959
+ exact_clusters = exact_clusters + CASE
15960
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
15961
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
15962
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
15963
+ THEN 1 ELSE 0 END
15964
+ WHERE id = 1;
15965
+
15966
+ INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
15967
+ SELECT NEW.content_hash, 1
15968
+ WHERE NEW.is_deleted = 0
15969
+ AND NEW.content_hash IS NOT NULL
15970
+ AND NEW.pinned = 0
15971
+ AND NEW.manual_override = 0
15972
+ ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
15973
+ END;
15974
+
15975
+ CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ad
15976
+ AFTER DELETE ON memories
15977
+ BEGIN
15978
+ UPDATE memories_diagnostics_state
15979
+ SET total_active = total_active - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
15980
+ exact_duplicates = exact_duplicates - CASE
15981
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
15982
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
15983
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
15984
+ THEN 1 ELSE 0 END,
15985
+ exact_clusters = exact_clusters - CASE
15986
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
15987
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
15988
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
15989
+ THEN 1 ELSE 0 END
15990
+ WHERE id = 1;
15991
+
15992
+ UPDATE memories_duplicate_hash_counts
15993
+ SET dup_count = dup_count - 1
15994
+ WHERE OLD.is_deleted = 0
15995
+ AND OLD.content_hash IS NOT NULL
15996
+ AND OLD.pinned = 0
15997
+ AND OLD.manual_override = 0
15998
+ AND content_hash = OLD.content_hash;
15999
+
16000
+ DELETE FROM memories_duplicate_hash_counts
16001
+ WHERE content_hash = OLD.content_hash
16002
+ AND dup_count <= 0;
16003
+ END;
16004
+ `);
16005
+ db.exec(`
16006
+ DELETE FROM transcript_capture_status;
16007
+ DELETE FROM memories_duplicate_hash_counts;
16008
+ INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
16009
+ SELECT content_hash, COUNT(*)
16010
+ FROM memories
16011
+ WHERE is_deleted = 0
16012
+ AND content_hash IS NOT NULL
16013
+ AND pinned = 0
16014
+ AND manual_override = 0
16015
+ GROUP BY content_hash;
16016
+
16017
+ INSERT INTO memories_diagnostics_state (id, total_active, exact_duplicates, exact_clusters)
16018
+ VALUES (
16019
+ 1,
16020
+ (SELECT COUNT(*) FROM memories WHERE is_deleted = 0),
16021
+ COALESCE((SELECT SUM(dup_count - 1) FROM memories_duplicate_hash_counts WHERE dup_count > 1), 0),
16022
+ (SELECT COUNT(*) FROM memories_duplicate_hash_counts WHERE dup_count > 1)
16023
+ )
16024
+ ON CONFLICT(id) DO UPDATE SET
16025
+ total_active = excluded.total_active,
16026
+ exact_duplicates = excluded.exact_duplicates,
16027
+ exact_clusters = excluded.exact_clusters;
16028
+
16029
+ INSERT INTO transcript_capture_status (
16030
+ agent_id, pending, processing, completed, failed, dead,
16031
+ oldest_pending_at, last_error, last_error_at
16032
+ )
16033
+ SELECT
16034
+ j.agent_id,
16035
+ SUM(j.status = 'pending'),
16036
+ SUM(j.status = 'processing'),
16037
+ SUM(j.status = 'completed'),
16038
+ SUM(j.status = 'failed'),
16039
+ SUM(j.status = 'dead'),
16040
+ MIN(CASE WHEN j.status = 'pending' THEN j.created_at END),
16041
+ (SELECT e2.error FROM transcript_capture_jobs e2
16042
+ WHERE e2.agent_id = j.agent_id AND e2.error IS NOT NULL
16043
+ ORDER BY e2.updated_at DESC LIMIT 1),
16044
+ (SELECT e3.updated_at FROM transcript_capture_jobs e3
16045
+ WHERE e3.agent_id = j.agent_id AND e3.error IS NOT NULL
16046
+ ORDER BY e3.updated_at DESC LIMIT 1)
16047
+ FROM transcript_capture_jobs j
16048
+ GROUP BY j.agent_id;
16049
+ `);
16050
+ }
15738
16051
  var MIGRATIONS = [
15739
16052
  {
15740
16053
  version: 1,
@@ -16824,6 +17137,14 @@ var MIGRATIONS = [
16824
17137
  { table: "dreaming_passes", column: "head_hash" }
16825
17138
  ]
16826
17139
  }
17140
+ },
17141
+ {
17142
+ version: 138,
17143
+ name: "bounded-status-projections",
17144
+ up: up138,
17145
+ artifacts: {
17146
+ tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
17147
+ }
16827
17148
  }
16828
17149
  ];
16829
17150
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -28665,7 +28986,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
28665
28986
  return true;
28666
28987
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
28667
28988
  }
28668
- function up138(db) {
28989
+ function up139(db) {
28669
28990
  db.exec(`
28670
28991
  CREATE TABLE IF NOT EXISTS schema_migrations (
28671
28992
  version INTEGER PRIMARY KEY,
@@ -28754,31 +29075,31 @@ function up138(db) {
28754
29075
  } catch {}
28755
29076
  createMemoriesFts2(db);
28756
29077
  }
28757
- function hasColumn25(db, table, column) {
29078
+ function hasColumn26(db, table, column) {
28758
29079
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
28759
29080
  return rows.some((r3) => r3.name === column);
28760
29081
  }
28761
- function addColumnIfMissing27(db, table, column, definition) {
28762
- if (!hasColumn25(db, table, column)) {
29082
+ function addColumnIfMissing28(db, table, column, definition) {
29083
+ if (!hasColumn26(db, table, column)) {
28763
29084
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
28764
29085
  }
28765
29086
  }
28766
29087
  function up210(db) {
28767
- addColumnIfMissing27(db, "memories", "content_hash", "TEXT");
28768
- addColumnIfMissing27(db, "memories", "normalized_content", "TEXT");
28769
- addColumnIfMissing27(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
28770
- addColumnIfMissing27(db, "memories", "deleted_at", "TEXT");
28771
- addColumnIfMissing27(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
28772
- addColumnIfMissing27(db, "memories", "embedding_model", "TEXT");
28773
- addColumnIfMissing27(db, "memories", "extraction_model", "TEXT");
28774
- addColumnIfMissing27(db, "memories", "update_count", "INTEGER DEFAULT 0");
28775
- addColumnIfMissing27(db, "memories", "who", "TEXT");
28776
- addColumnIfMissing27(db, "memories", "why", "TEXT");
28777
- addColumnIfMissing27(db, "memories", "project", "TEXT");
28778
- addColumnIfMissing27(db, "memories", "pinned", "INTEGER DEFAULT 0");
28779
- addColumnIfMissing27(db, "memories", "importance", "REAL DEFAULT 0.5");
28780
- addColumnIfMissing27(db, "memories", "last_accessed", "TEXT");
28781
- addColumnIfMissing27(db, "memories", "access_count", "INTEGER DEFAULT 0");
29088
+ addColumnIfMissing28(db, "memories", "content_hash", "TEXT");
29089
+ addColumnIfMissing28(db, "memories", "normalized_content", "TEXT");
29090
+ addColumnIfMissing28(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
29091
+ addColumnIfMissing28(db, "memories", "deleted_at", "TEXT");
29092
+ addColumnIfMissing28(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
29093
+ addColumnIfMissing28(db, "memories", "embedding_model", "TEXT");
29094
+ addColumnIfMissing28(db, "memories", "extraction_model", "TEXT");
29095
+ addColumnIfMissing28(db, "memories", "update_count", "INTEGER DEFAULT 0");
29096
+ addColumnIfMissing28(db, "memories", "who", "TEXT");
29097
+ addColumnIfMissing28(db, "memories", "why", "TEXT");
29098
+ addColumnIfMissing28(db, "memories", "project", "TEXT");
29099
+ addColumnIfMissing28(db, "memories", "pinned", "INTEGER DEFAULT 0");
29100
+ addColumnIfMissing28(db, "memories", "importance", "REAL DEFAULT 0.5");
29101
+ addColumnIfMissing28(db, "memories", "last_accessed", "TEXT");
29102
+ addColumnIfMissing28(db, "memories", "access_count", "INTEGER DEFAULT 0");
28782
29103
  db.exec(`
28783
29104
  CREATE TABLE IF NOT EXISTS memory_history (
28784
29105
  id TEXT PRIMARY KEY,
@@ -28874,7 +29195,7 @@ function up210(db) {
28874
29195
  ON memory_entity_mentions(entity_id);
28875
29196
  `);
28876
29197
  }
28877
- function addColumnIfMissing28(db, table, column, definition) {
29198
+ function addColumnIfMissing29(db, table, column, definition) {
28878
29199
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
28879
29200
  if (rows.some((r3) => r3.name === column))
28880
29201
  return false;
@@ -28882,8 +29203,8 @@ function addColumnIfMissing28(db, table, column, definition) {
28882
29203
  return true;
28883
29204
  }
28884
29205
  function up310(db) {
28885
- addColumnIfMissing28(db, "memories", "why", "TEXT");
28886
- addColumnIfMissing28(db, "memories", "project", "TEXT");
29206
+ addColumnIfMissing29(db, "memories", "why", "TEXT");
29207
+ addColumnIfMissing29(db, "memories", "project", "TEXT");
28887
29208
  db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
28888
29209
  db.exec(`
28889
29210
  UPDATE memories
@@ -28909,12 +29230,12 @@ function up310(db) {
28909
29230
  WHERE content_hash IS NOT NULL AND is_deleted = 0
28910
29231
  `);
28911
29232
  }
28912
- function hasColumn26(db, table, column) {
29233
+ function hasColumn27(db, table, column) {
28913
29234
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
28914
29235
  return rows.some((r3) => r3.name === column);
28915
29236
  }
28916
29237
  function addColumnIfMissing32(db, table, column, definition) {
28917
- if (!hasColumn26(db, table, column)) {
29238
+ if (!hasColumn27(db, table, column)) {
28918
29239
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
28919
29240
  }
28920
29241
  }
@@ -29149,7 +29470,7 @@ function addColumnIfMissing52(db, table, column, definition) {
29149
29470
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
29150
29471
  }
29151
29472
  }
29152
- function up139(db) {
29473
+ function up1310(db) {
29153
29474
  db.exec(`
29154
29475
  CREATE TABLE IF NOT EXISTS ingestion_jobs (
29155
29476
  id TEXT PRIMARY KEY,
@@ -33018,11 +33339,324 @@ function up1372(db) {
33018
33339
  if (!cols.has(name))
33019
33340
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
33020
33341
  }
33342
+ function hasColumn252(db, table, column) {
33343
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
33344
+ return rows.some((row) => row.name === column);
33345
+ }
33346
+ function addColumnIfMissing272(db, table, column, definition) {
33347
+ if (!hasColumn252(db, table, column))
33348
+ db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
33349
+ }
33350
+ function up1382(db) {
33351
+ addColumnIfMissing272(db, "memories", "manual_override", "INTEGER DEFAULT 0");
33352
+ db.exec(`
33353
+ CREATE TABLE IF NOT EXISTS transcript_capture_status (
33354
+ agent_id TEXT PRIMARY KEY,
33355
+ pending INTEGER NOT NULL DEFAULT 0,
33356
+ processing INTEGER NOT NULL DEFAULT 0,
33357
+ completed INTEGER NOT NULL DEFAULT 0,
33358
+ failed INTEGER NOT NULL DEFAULT 0,
33359
+ dead INTEGER NOT NULL DEFAULT 0,
33360
+ oldest_pending_at TEXT,
33361
+ last_error TEXT,
33362
+ last_error_at TEXT
33363
+ );
33364
+
33365
+ CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_agent_status_created_at
33366
+ ON transcript_capture_jobs(agent_id, status, created_at);
33367
+
33368
+ CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_error_updated_at
33369
+ ON transcript_capture_jobs(agent_id, updated_at DESC)
33370
+ WHERE error IS NOT NULL;
33371
+
33372
+ CREATE TABLE IF NOT EXISTS memories_duplicate_hash_counts (
33373
+ content_hash TEXT PRIMARY KEY,
33374
+ dup_count INTEGER NOT NULL
33375
+ );
33376
+
33377
+ CREATE INDEX IF NOT EXISTS idx_memories_dup_counts_active
33378
+ ON memories_duplicate_hash_counts(dup_count)
33379
+ WHERE dup_count > 1;
33380
+
33381
+ CREATE TABLE IF NOT EXISTS memories_diagnostics_state (
33382
+ id INTEGER PRIMARY KEY CHECK (id = 1),
33383
+ total_active INTEGER NOT NULL DEFAULT 0,
33384
+ exact_duplicates INTEGER NOT NULL DEFAULT 0,
33385
+ exact_clusters INTEGER NOT NULL DEFAULT 0
33386
+ );
33387
+
33388
+ CREATE INDEX IF NOT EXISTS idx_memories_active_hash_diagnostics
33389
+ ON memories(content_hash)
33390
+ WHERE is_deleted = 0
33391
+ AND content_hash IS NOT NULL
33392
+ AND pinned = 0
33393
+ AND manual_override = 0;
33394
+ `);
33395
+ db.exec(`
33396
+ CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ai
33397
+ AFTER INSERT ON transcript_capture_jobs
33398
+ BEGIN
33399
+ INSERT INTO transcript_capture_status (agent_id)
33400
+ VALUES (NEW.agent_id)
33401
+ ON CONFLICT(agent_id) DO NOTHING;
33402
+
33403
+ UPDATE transcript_capture_status
33404
+ SET pending = pending + (NEW.status = 'pending'),
33405
+ processing = processing + (NEW.status = 'processing'),
33406
+ completed = completed + (NEW.status = 'completed'),
33407
+ failed = failed + (NEW.status = 'failed'),
33408
+ dead = dead + (NEW.status = 'dead')
33409
+ WHERE agent_id = NEW.agent_id;
33410
+
33411
+ UPDATE transcript_capture_status
33412
+ SET oldest_pending_at = (
33413
+ SELECT MIN(created_at) FROM transcript_capture_jobs
33414
+ WHERE agent_id = NEW.agent_id AND status = 'pending'
33415
+ )
33416
+ WHERE agent_id = NEW.agent_id;
33417
+
33418
+ UPDATE transcript_capture_status
33419
+ SET last_error = (
33420
+ SELECT error FROM transcript_capture_jobs
33421
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
33422
+ ORDER BY updated_at DESC LIMIT 1
33423
+ ),
33424
+ last_error_at = (
33425
+ SELECT updated_at FROM transcript_capture_jobs
33426
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
33427
+ ORDER BY updated_at DESC LIMIT 1
33428
+ )
33429
+ WHERE agent_id = NEW.agent_id
33430
+ AND NEW.error IS NOT NULL;
33431
+ END;
33432
+
33433
+ CREATE TRIGGER IF NOT EXISTS transcript_capture_status_au
33434
+ AFTER UPDATE OF status, error, updated_at, created_at ON transcript_capture_jobs
33435
+ BEGIN
33436
+ UPDATE transcript_capture_status
33437
+ SET pending = pending + (NEW.status = 'pending') - (OLD.status = 'pending'),
33438
+ processing = processing + (NEW.status = 'processing') - (OLD.status = 'processing'),
33439
+ completed = completed + (NEW.status = 'completed') - (OLD.status = 'completed'),
33440
+ failed = failed + (NEW.status = 'failed') - (OLD.status = 'failed'),
33441
+ dead = dead + (NEW.status = 'dead') - (OLD.status = 'dead')
33442
+ WHERE agent_id = NEW.agent_id;
33443
+
33444
+ UPDATE transcript_capture_status
33445
+ SET oldest_pending_at = (
33446
+ SELECT MIN(created_at) FROM transcript_capture_jobs
33447
+ WHERE agent_id = NEW.agent_id AND status = 'pending'
33448
+ )
33449
+ WHERE agent_id = NEW.agent_id;
33450
+
33451
+ UPDATE transcript_capture_status
33452
+ SET last_error = (
33453
+ SELECT error FROM transcript_capture_jobs
33454
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
33455
+ ORDER BY updated_at DESC LIMIT 1
33456
+ ),
33457
+ last_error_at = (
33458
+ SELECT updated_at FROM transcript_capture_jobs
33459
+ WHERE agent_id = NEW.agent_id AND error IS NOT NULL
33460
+ ORDER BY updated_at DESC LIMIT 1
33461
+ )
33462
+ WHERE agent_id = NEW.agent_id
33463
+ AND (NEW.error IS NOT NULL OR OLD.error IS NOT NULL);
33464
+ END;
33465
+
33466
+ CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ad
33467
+ AFTER DELETE ON transcript_capture_jobs
33468
+ BEGIN
33469
+ UPDATE transcript_capture_status
33470
+ SET pending = pending - (OLD.status = 'pending'),
33471
+ processing = processing - (OLD.status = 'processing'),
33472
+ completed = completed - (OLD.status = 'completed'),
33473
+ failed = failed - (OLD.status = 'failed'),
33474
+ dead = dead - (OLD.status = 'dead')
33475
+ WHERE agent_id = OLD.agent_id;
33476
+
33477
+ UPDATE transcript_capture_status
33478
+ SET oldest_pending_at = (
33479
+ SELECT MIN(created_at) FROM transcript_capture_jobs
33480
+ WHERE agent_id = OLD.agent_id AND status = 'pending'
33481
+ )
33482
+ WHERE agent_id = OLD.agent_id;
33483
+
33484
+ UPDATE transcript_capture_status
33485
+ SET last_error = (
33486
+ SELECT error FROM transcript_capture_jobs
33487
+ WHERE agent_id = OLD.agent_id AND error IS NOT NULL
33488
+ ORDER BY updated_at DESC LIMIT 1
33489
+ ),
33490
+ last_error_at = (
33491
+ SELECT updated_at FROM transcript_capture_jobs
33492
+ WHERE agent_id = OLD.agent_id AND error IS NOT NULL
33493
+ ORDER BY updated_at DESC LIMIT 1
33494
+ )
33495
+ WHERE agent_id = OLD.agent_id
33496
+ AND OLD.error IS NOT NULL;
33497
+ END;
33498
+ `);
33499
+ db.exec(`
33500
+ CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ai
33501
+ AFTER INSERT ON memories
33502
+ BEGIN
33503
+ UPDATE memories_diagnostics_state
33504
+ SET total_active = total_active + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END,
33505
+ exact_duplicates = exact_duplicates + CASE
33506
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
33507
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
33508
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
33509
+ THEN 1 ELSE 0 END,
33510
+ exact_clusters = exact_clusters + CASE
33511
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
33512
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
33513
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
33514
+ THEN 1 ELSE 0 END
33515
+ WHERE id = 1;
33516
+
33517
+ INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
33518
+ SELECT NEW.content_hash, 1
33519
+ WHERE NEW.is_deleted = 0
33520
+ AND NEW.content_hash IS NOT NULL
33521
+ AND NEW.pinned = 0
33522
+ AND NEW.manual_override = 0
33523
+ ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
33524
+ END;
33525
+
33526
+ CREATE TRIGGER IF NOT EXISTS memories_dup_projection_au
33527
+ AFTER UPDATE OF is_deleted, content_hash, pinned, manual_override ON memories
33528
+ BEGIN
33529
+ UPDATE memories_diagnostics_state
33530
+ SET total_active = total_active
33531
+ + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END
33532
+ - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
33533
+ exact_duplicates = exact_duplicates - CASE
33534
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
33535
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
33536
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
33537
+ THEN 1 ELSE 0 END,
33538
+ exact_clusters = exact_clusters - CASE
33539
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
33540
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
33541
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
33542
+ THEN 1 ELSE 0 END
33543
+ WHERE id = 1;
33544
+
33545
+ UPDATE memories_duplicate_hash_counts
33546
+ SET dup_count = dup_count - 1
33547
+ WHERE OLD.is_deleted = 0
33548
+ AND OLD.content_hash IS NOT NULL
33549
+ AND OLD.pinned = 0
33550
+ AND OLD.manual_override = 0
33551
+ AND content_hash = OLD.content_hash;
33552
+
33553
+ DELETE FROM memories_duplicate_hash_counts
33554
+ WHERE content_hash = OLD.content_hash
33555
+ AND dup_count <= 0;
33556
+
33557
+ UPDATE memories_diagnostics_state
33558
+ SET exact_duplicates = exact_duplicates + CASE
33559
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
33560
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
33561
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
33562
+ THEN 1 ELSE 0 END,
33563
+ exact_clusters = exact_clusters + CASE
33564
+ WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
33565
+ AND NEW.pinned = 0 AND NEW.manual_override = 0
33566
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
33567
+ THEN 1 ELSE 0 END
33568
+ WHERE id = 1;
33569
+
33570
+ INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
33571
+ SELECT NEW.content_hash, 1
33572
+ WHERE NEW.is_deleted = 0
33573
+ AND NEW.content_hash IS NOT NULL
33574
+ AND NEW.pinned = 0
33575
+ AND NEW.manual_override = 0
33576
+ ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
33577
+ END;
33578
+
33579
+ CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ad
33580
+ AFTER DELETE ON memories
33581
+ BEGIN
33582
+ UPDATE memories_diagnostics_state
33583
+ SET total_active = total_active - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
33584
+ exact_duplicates = exact_duplicates - CASE
33585
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
33586
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
33587
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
33588
+ THEN 1 ELSE 0 END,
33589
+ exact_clusters = exact_clusters - CASE
33590
+ WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
33591
+ AND OLD.pinned = 0 AND OLD.manual_override = 0
33592
+ AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
33593
+ THEN 1 ELSE 0 END
33594
+ WHERE id = 1;
33595
+
33596
+ UPDATE memories_duplicate_hash_counts
33597
+ SET dup_count = dup_count - 1
33598
+ WHERE OLD.is_deleted = 0
33599
+ AND OLD.content_hash IS NOT NULL
33600
+ AND OLD.pinned = 0
33601
+ AND OLD.manual_override = 0
33602
+ AND content_hash = OLD.content_hash;
33603
+
33604
+ DELETE FROM memories_duplicate_hash_counts
33605
+ WHERE content_hash = OLD.content_hash
33606
+ AND dup_count <= 0;
33607
+ END;
33608
+ `);
33609
+ db.exec(`
33610
+ DELETE FROM transcript_capture_status;
33611
+ DELETE FROM memories_duplicate_hash_counts;
33612
+ INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
33613
+ SELECT content_hash, COUNT(*)
33614
+ FROM memories
33615
+ WHERE is_deleted = 0
33616
+ AND content_hash IS NOT NULL
33617
+ AND pinned = 0
33618
+ AND manual_override = 0
33619
+ GROUP BY content_hash;
33620
+
33621
+ INSERT INTO memories_diagnostics_state (id, total_active, exact_duplicates, exact_clusters)
33622
+ VALUES (
33623
+ 1,
33624
+ (SELECT COUNT(*) FROM memories WHERE is_deleted = 0),
33625
+ COALESCE((SELECT SUM(dup_count - 1) FROM memories_duplicate_hash_counts WHERE dup_count > 1), 0),
33626
+ (SELECT COUNT(*) FROM memories_duplicate_hash_counts WHERE dup_count > 1)
33627
+ )
33628
+ ON CONFLICT(id) DO UPDATE SET
33629
+ total_active = excluded.total_active,
33630
+ exact_duplicates = excluded.exact_duplicates,
33631
+ exact_clusters = excluded.exact_clusters;
33632
+
33633
+ INSERT INTO transcript_capture_status (
33634
+ agent_id, pending, processing, completed, failed, dead,
33635
+ oldest_pending_at, last_error, last_error_at
33636
+ )
33637
+ SELECT
33638
+ j.agent_id,
33639
+ SUM(j.status = 'pending'),
33640
+ SUM(j.status = 'processing'),
33641
+ SUM(j.status = 'completed'),
33642
+ SUM(j.status = 'failed'),
33643
+ SUM(j.status = 'dead'),
33644
+ MIN(CASE WHEN j.status = 'pending' THEN j.created_at END),
33645
+ (SELECT e2.error FROM transcript_capture_jobs e2
33646
+ WHERE e2.agent_id = j.agent_id AND e2.error IS NOT NULL
33647
+ ORDER BY e2.updated_at DESC LIMIT 1),
33648
+ (SELECT e3.updated_at FROM transcript_capture_jobs e3
33649
+ WHERE e3.agent_id = j.agent_id AND e3.error IS NOT NULL
33650
+ ORDER BY e3.updated_at DESC LIMIT 1)
33651
+ FROM transcript_capture_jobs j
33652
+ GROUP BY j.agent_id;
33653
+ `);
33654
+ }
33021
33655
  var MIGRATIONS2 = [
33022
33656
  {
33023
33657
  version: 1,
33024
33658
  name: "baseline",
33025
- up: up138,
33659
+ up: up139,
33026
33660
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
33027
33661
  },
33028
33662
  {
@@ -33100,7 +33734,7 @@ var MIGRATIONS2 = [
33100
33734
  {
33101
33735
  version: 13,
33102
33736
  name: "ingestion-tracking",
33103
- up: up139,
33737
+ up: up1310,
33104
33738
  artifacts: {
33105
33739
  columns: [
33106
33740
  { table: "memories", column: "source_path" },
@@ -34107,6 +34741,14 @@ var MIGRATIONS2 = [
34107
34741
  { table: "dreaming_passes", column: "head_hash" }
34108
34742
  ]
34109
34743
  }
34744
+ },
34745
+ {
34746
+ version: 138,
34747
+ name: "bounded-status-projections",
34748
+ up: up1382,
34749
+ artifacts: {
34750
+ tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
34751
+ }
34110
34752
  }
34111
34753
  ];
34112
34754
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-hermes-agent",
3
- "version": "0.211.16",
3
+ "version": "0.211.20",
4
4
  "description": "Signet connector for Hermes Agent — installs Signet as a pluggable memory provider",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "typecheck": "tsc --noEmit"
26
26
  },
27
27
  "dependencies": {
28
- "@signetai/connector-base": "0.211.16",
29
- "@signetai/core": "0.211.16"
28
+ "@signetai/connector-base": "0.211.20",
29
+ "@signetai/core": "0.211.20"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.0.0",