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