@signetai/connector-codex 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.
- package/dist/index.js +669 -27
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -15734,6 +15734,319 @@ function up137(db) {
|
|
|
15734
15734
|
if (!cols.has(name))
|
|
15735
15735
|
db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
|
|
15736
15736
|
}
|
|
15737
|
+
function hasColumn25(db, table, column) {
|
|
15738
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
15739
|
+
return rows.some((row) => row.name === column);
|
|
15740
|
+
}
|
|
15741
|
+
function addColumnIfMissing27(db, table, column, definition) {
|
|
15742
|
+
if (!hasColumn25(db, table, column))
|
|
15743
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
15744
|
+
}
|
|
15745
|
+
function up138(db) {
|
|
15746
|
+
addColumnIfMissing27(db, "memories", "manual_override", "INTEGER DEFAULT 0");
|
|
15747
|
+
db.exec(`
|
|
15748
|
+
CREATE TABLE IF NOT EXISTS transcript_capture_status (
|
|
15749
|
+
agent_id TEXT PRIMARY KEY,
|
|
15750
|
+
pending INTEGER NOT NULL DEFAULT 0,
|
|
15751
|
+
processing INTEGER NOT NULL DEFAULT 0,
|
|
15752
|
+
completed INTEGER NOT NULL DEFAULT 0,
|
|
15753
|
+
failed INTEGER NOT NULL DEFAULT 0,
|
|
15754
|
+
dead INTEGER NOT NULL DEFAULT 0,
|
|
15755
|
+
oldest_pending_at TEXT,
|
|
15756
|
+
last_error TEXT,
|
|
15757
|
+
last_error_at TEXT
|
|
15758
|
+
);
|
|
15759
|
+
|
|
15760
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_agent_status_created_at
|
|
15761
|
+
ON transcript_capture_jobs(agent_id, status, created_at);
|
|
15762
|
+
|
|
15763
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_error_updated_at
|
|
15764
|
+
ON transcript_capture_jobs(agent_id, updated_at DESC)
|
|
15765
|
+
WHERE error IS NOT NULL;
|
|
15766
|
+
|
|
15767
|
+
CREATE TABLE IF NOT EXISTS memories_duplicate_hash_counts (
|
|
15768
|
+
content_hash TEXT PRIMARY KEY,
|
|
15769
|
+
dup_count INTEGER NOT NULL
|
|
15770
|
+
);
|
|
15771
|
+
|
|
15772
|
+
CREATE INDEX IF NOT EXISTS idx_memories_dup_counts_active
|
|
15773
|
+
ON memories_duplicate_hash_counts(dup_count)
|
|
15774
|
+
WHERE dup_count > 1;
|
|
15775
|
+
|
|
15776
|
+
CREATE TABLE IF NOT EXISTS memories_diagnostics_state (
|
|
15777
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
15778
|
+
total_active INTEGER NOT NULL DEFAULT 0,
|
|
15779
|
+
exact_duplicates INTEGER NOT NULL DEFAULT 0,
|
|
15780
|
+
exact_clusters INTEGER NOT NULL DEFAULT 0
|
|
15781
|
+
);
|
|
15782
|
+
|
|
15783
|
+
CREATE INDEX IF NOT EXISTS idx_memories_active_hash_diagnostics
|
|
15784
|
+
ON memories(content_hash)
|
|
15785
|
+
WHERE is_deleted = 0
|
|
15786
|
+
AND content_hash IS NOT NULL
|
|
15787
|
+
AND pinned = 0
|
|
15788
|
+
AND manual_override = 0;
|
|
15789
|
+
`);
|
|
15790
|
+
db.exec(`
|
|
15791
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ai
|
|
15792
|
+
AFTER INSERT ON transcript_capture_jobs
|
|
15793
|
+
BEGIN
|
|
15794
|
+
INSERT INTO transcript_capture_status (agent_id)
|
|
15795
|
+
VALUES (NEW.agent_id)
|
|
15796
|
+
ON CONFLICT(agent_id) DO NOTHING;
|
|
15797
|
+
|
|
15798
|
+
UPDATE transcript_capture_status
|
|
15799
|
+
SET pending = pending + (NEW.status = 'pending'),
|
|
15800
|
+
processing = processing + (NEW.status = 'processing'),
|
|
15801
|
+
completed = completed + (NEW.status = 'completed'),
|
|
15802
|
+
failed = failed + (NEW.status = 'failed'),
|
|
15803
|
+
dead = dead + (NEW.status = 'dead')
|
|
15804
|
+
WHERE agent_id = NEW.agent_id;
|
|
15805
|
+
|
|
15806
|
+
UPDATE transcript_capture_status
|
|
15807
|
+
SET oldest_pending_at = (
|
|
15808
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
15809
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
15810
|
+
)
|
|
15811
|
+
WHERE agent_id = NEW.agent_id;
|
|
15812
|
+
|
|
15813
|
+
UPDATE transcript_capture_status
|
|
15814
|
+
SET last_error = (
|
|
15815
|
+
SELECT error FROM transcript_capture_jobs
|
|
15816
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15817
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15818
|
+
),
|
|
15819
|
+
last_error_at = (
|
|
15820
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
15821
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15822
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15823
|
+
)
|
|
15824
|
+
WHERE agent_id = NEW.agent_id
|
|
15825
|
+
AND NEW.error IS NOT NULL;
|
|
15826
|
+
END;
|
|
15827
|
+
|
|
15828
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_au
|
|
15829
|
+
AFTER UPDATE OF status, error, updated_at, created_at ON transcript_capture_jobs
|
|
15830
|
+
BEGIN
|
|
15831
|
+
UPDATE transcript_capture_status
|
|
15832
|
+
SET pending = pending + (NEW.status = 'pending') - (OLD.status = 'pending'),
|
|
15833
|
+
processing = processing + (NEW.status = 'processing') - (OLD.status = 'processing'),
|
|
15834
|
+
completed = completed + (NEW.status = 'completed') - (OLD.status = 'completed'),
|
|
15835
|
+
failed = failed + (NEW.status = 'failed') - (OLD.status = 'failed'),
|
|
15836
|
+
dead = dead + (NEW.status = 'dead') - (OLD.status = 'dead')
|
|
15837
|
+
WHERE agent_id = NEW.agent_id;
|
|
15838
|
+
|
|
15839
|
+
UPDATE transcript_capture_status
|
|
15840
|
+
SET oldest_pending_at = (
|
|
15841
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
15842
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
15843
|
+
)
|
|
15844
|
+
WHERE agent_id = NEW.agent_id;
|
|
15845
|
+
|
|
15846
|
+
UPDATE transcript_capture_status
|
|
15847
|
+
SET last_error = (
|
|
15848
|
+
SELECT error FROM transcript_capture_jobs
|
|
15849
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15850
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15851
|
+
),
|
|
15852
|
+
last_error_at = (
|
|
15853
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
15854
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15855
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15856
|
+
)
|
|
15857
|
+
WHERE agent_id = NEW.agent_id
|
|
15858
|
+
AND (NEW.error IS NOT NULL OR OLD.error IS NOT NULL);
|
|
15859
|
+
END;
|
|
15860
|
+
|
|
15861
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ad
|
|
15862
|
+
AFTER DELETE ON transcript_capture_jobs
|
|
15863
|
+
BEGIN
|
|
15864
|
+
UPDATE transcript_capture_status
|
|
15865
|
+
SET pending = pending - (OLD.status = 'pending'),
|
|
15866
|
+
processing = processing - (OLD.status = 'processing'),
|
|
15867
|
+
completed = completed - (OLD.status = 'completed'),
|
|
15868
|
+
failed = failed - (OLD.status = 'failed'),
|
|
15869
|
+
dead = dead - (OLD.status = 'dead')
|
|
15870
|
+
WHERE agent_id = OLD.agent_id;
|
|
15871
|
+
|
|
15872
|
+
UPDATE transcript_capture_status
|
|
15873
|
+
SET oldest_pending_at = (
|
|
15874
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
15875
|
+
WHERE agent_id = OLD.agent_id AND status = 'pending'
|
|
15876
|
+
)
|
|
15877
|
+
WHERE agent_id = OLD.agent_id;
|
|
15878
|
+
|
|
15879
|
+
UPDATE transcript_capture_status
|
|
15880
|
+
SET last_error = (
|
|
15881
|
+
SELECT error FROM transcript_capture_jobs
|
|
15882
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
15883
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15884
|
+
),
|
|
15885
|
+
last_error_at = (
|
|
15886
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
15887
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
15888
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15889
|
+
)
|
|
15890
|
+
WHERE agent_id = OLD.agent_id
|
|
15891
|
+
AND OLD.error IS NOT NULL;
|
|
15892
|
+
END;
|
|
15893
|
+
`);
|
|
15894
|
+
db.exec(`
|
|
15895
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ai
|
|
15896
|
+
AFTER INSERT ON memories
|
|
15897
|
+
BEGIN
|
|
15898
|
+
UPDATE memories_diagnostics_state
|
|
15899
|
+
SET total_active = total_active + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
15900
|
+
exact_duplicates = exact_duplicates + CASE
|
|
15901
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15902
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15903
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
15904
|
+
THEN 1 ELSE 0 END,
|
|
15905
|
+
exact_clusters = exact_clusters + CASE
|
|
15906
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15907
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15908
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
15909
|
+
THEN 1 ELSE 0 END
|
|
15910
|
+
WHERE id = 1;
|
|
15911
|
+
|
|
15912
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
15913
|
+
SELECT NEW.content_hash, 1
|
|
15914
|
+
WHERE NEW.is_deleted = 0
|
|
15915
|
+
AND NEW.content_hash IS NOT NULL
|
|
15916
|
+
AND NEW.pinned = 0
|
|
15917
|
+
AND NEW.manual_override = 0
|
|
15918
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
15919
|
+
END;
|
|
15920
|
+
|
|
15921
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_au
|
|
15922
|
+
AFTER UPDATE OF is_deleted, content_hash, pinned, manual_override ON memories
|
|
15923
|
+
BEGIN
|
|
15924
|
+
UPDATE memories_diagnostics_state
|
|
15925
|
+
SET total_active = total_active
|
|
15926
|
+
+ CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END
|
|
15927
|
+
- CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
15928
|
+
exact_duplicates = exact_duplicates - CASE
|
|
15929
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
15930
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
15931
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
15932
|
+
THEN 1 ELSE 0 END,
|
|
15933
|
+
exact_clusters = exact_clusters - CASE
|
|
15934
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
15935
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
15936
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
15937
|
+
THEN 1 ELSE 0 END
|
|
15938
|
+
WHERE id = 1;
|
|
15939
|
+
|
|
15940
|
+
UPDATE memories_duplicate_hash_counts
|
|
15941
|
+
SET dup_count = dup_count - 1
|
|
15942
|
+
WHERE OLD.is_deleted = 0
|
|
15943
|
+
AND OLD.content_hash IS NOT NULL
|
|
15944
|
+
AND OLD.pinned = 0
|
|
15945
|
+
AND OLD.manual_override = 0
|
|
15946
|
+
AND content_hash = OLD.content_hash;
|
|
15947
|
+
|
|
15948
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
15949
|
+
WHERE content_hash = OLD.content_hash
|
|
15950
|
+
AND dup_count <= 0;
|
|
15951
|
+
|
|
15952
|
+
UPDATE memories_diagnostics_state
|
|
15953
|
+
SET exact_duplicates = exact_duplicates + CASE
|
|
15954
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15955
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15956
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
15957
|
+
THEN 1 ELSE 0 END,
|
|
15958
|
+
exact_clusters = exact_clusters + CASE
|
|
15959
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15960
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15961
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
15962
|
+
THEN 1 ELSE 0 END
|
|
15963
|
+
WHERE id = 1;
|
|
15964
|
+
|
|
15965
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
15966
|
+
SELECT NEW.content_hash, 1
|
|
15967
|
+
WHERE NEW.is_deleted = 0
|
|
15968
|
+
AND NEW.content_hash IS NOT NULL
|
|
15969
|
+
AND NEW.pinned = 0
|
|
15970
|
+
AND NEW.manual_override = 0
|
|
15971
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
15972
|
+
END;
|
|
15973
|
+
|
|
15974
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ad
|
|
15975
|
+
AFTER DELETE ON memories
|
|
15976
|
+
BEGIN
|
|
15977
|
+
UPDATE memories_diagnostics_state
|
|
15978
|
+
SET total_active = total_active - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
15979
|
+
exact_duplicates = exact_duplicates - CASE
|
|
15980
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
15981
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
15982
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
15983
|
+
THEN 1 ELSE 0 END,
|
|
15984
|
+
exact_clusters = exact_clusters - CASE
|
|
15985
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
15986
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
15987
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
15988
|
+
THEN 1 ELSE 0 END
|
|
15989
|
+
WHERE id = 1;
|
|
15990
|
+
|
|
15991
|
+
UPDATE memories_duplicate_hash_counts
|
|
15992
|
+
SET dup_count = dup_count - 1
|
|
15993
|
+
WHERE OLD.is_deleted = 0
|
|
15994
|
+
AND OLD.content_hash IS NOT NULL
|
|
15995
|
+
AND OLD.pinned = 0
|
|
15996
|
+
AND OLD.manual_override = 0
|
|
15997
|
+
AND content_hash = OLD.content_hash;
|
|
15998
|
+
|
|
15999
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
16000
|
+
WHERE content_hash = OLD.content_hash
|
|
16001
|
+
AND dup_count <= 0;
|
|
16002
|
+
END;
|
|
16003
|
+
`);
|
|
16004
|
+
db.exec(`
|
|
16005
|
+
DELETE FROM transcript_capture_status;
|
|
16006
|
+
DELETE FROM memories_duplicate_hash_counts;
|
|
16007
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
16008
|
+
SELECT content_hash, COUNT(*)
|
|
16009
|
+
FROM memories
|
|
16010
|
+
WHERE is_deleted = 0
|
|
16011
|
+
AND content_hash IS NOT NULL
|
|
16012
|
+
AND pinned = 0
|
|
16013
|
+
AND manual_override = 0
|
|
16014
|
+
GROUP BY content_hash;
|
|
16015
|
+
|
|
16016
|
+
INSERT INTO memories_diagnostics_state (id, total_active, exact_duplicates, exact_clusters)
|
|
16017
|
+
VALUES (
|
|
16018
|
+
1,
|
|
16019
|
+
(SELECT COUNT(*) FROM memories WHERE is_deleted = 0),
|
|
16020
|
+
COALESCE((SELECT SUM(dup_count - 1) FROM memories_duplicate_hash_counts WHERE dup_count > 1), 0),
|
|
16021
|
+
(SELECT COUNT(*) FROM memories_duplicate_hash_counts WHERE dup_count > 1)
|
|
16022
|
+
)
|
|
16023
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
16024
|
+
total_active = excluded.total_active,
|
|
16025
|
+
exact_duplicates = excluded.exact_duplicates,
|
|
16026
|
+
exact_clusters = excluded.exact_clusters;
|
|
16027
|
+
|
|
16028
|
+
INSERT INTO transcript_capture_status (
|
|
16029
|
+
agent_id, pending, processing, completed, failed, dead,
|
|
16030
|
+
oldest_pending_at, last_error, last_error_at
|
|
16031
|
+
)
|
|
16032
|
+
SELECT
|
|
16033
|
+
j.agent_id,
|
|
16034
|
+
SUM(j.status = 'pending'),
|
|
16035
|
+
SUM(j.status = 'processing'),
|
|
16036
|
+
SUM(j.status = 'completed'),
|
|
16037
|
+
SUM(j.status = 'failed'),
|
|
16038
|
+
SUM(j.status = 'dead'),
|
|
16039
|
+
MIN(CASE WHEN j.status = 'pending' THEN j.created_at END),
|
|
16040
|
+
(SELECT e2.error FROM transcript_capture_jobs e2
|
|
16041
|
+
WHERE e2.agent_id = j.agent_id AND e2.error IS NOT NULL
|
|
16042
|
+
ORDER BY e2.updated_at DESC LIMIT 1),
|
|
16043
|
+
(SELECT e3.updated_at FROM transcript_capture_jobs e3
|
|
16044
|
+
WHERE e3.agent_id = j.agent_id AND e3.error IS NOT NULL
|
|
16045
|
+
ORDER BY e3.updated_at DESC LIMIT 1)
|
|
16046
|
+
FROM transcript_capture_jobs j
|
|
16047
|
+
GROUP BY j.agent_id;
|
|
16048
|
+
`);
|
|
16049
|
+
}
|
|
15737
16050
|
var MIGRATIONS = [
|
|
15738
16051
|
{
|
|
15739
16052
|
version: 1,
|
|
@@ -16823,6 +17136,14 @@ var MIGRATIONS = [
|
|
|
16823
17136
|
{ table: "dreaming_passes", column: "head_hash" }
|
|
16824
17137
|
]
|
|
16825
17138
|
}
|
|
17139
|
+
},
|
|
17140
|
+
{
|
|
17141
|
+
version: 138,
|
|
17142
|
+
name: "bounded-status-projections",
|
|
17143
|
+
up: up138,
|
|
17144
|
+
artifacts: {
|
|
17145
|
+
tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
|
|
17146
|
+
}
|
|
16826
17147
|
}
|
|
16827
17148
|
];
|
|
16828
17149
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -28786,7 +29107,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
28786
29107
|
return true;
|
|
28787
29108
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
28788
29109
|
}
|
|
28789
|
-
function
|
|
29110
|
+
function up139(db) {
|
|
28790
29111
|
db.exec(`
|
|
28791
29112
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
28792
29113
|
version INTEGER PRIMARY KEY,
|
|
@@ -28875,31 +29196,31 @@ function up138(db) {
|
|
|
28875
29196
|
} catch {}
|
|
28876
29197
|
createMemoriesFts2(db);
|
|
28877
29198
|
}
|
|
28878
|
-
function
|
|
29199
|
+
function hasColumn26(db, table, column) {
|
|
28879
29200
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
28880
29201
|
return rows.some((r3) => r3.name === column);
|
|
28881
29202
|
}
|
|
28882
|
-
function
|
|
28883
|
-
if (!
|
|
29203
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
29204
|
+
if (!hasColumn26(db, table, column)) {
|
|
28884
29205
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
28885
29206
|
}
|
|
28886
29207
|
}
|
|
28887
29208
|
function up210(db) {
|
|
28888
|
-
|
|
28889
|
-
|
|
28890
|
-
|
|
28891
|
-
|
|
28892
|
-
|
|
28893
|
-
|
|
28894
|
-
|
|
28895
|
-
|
|
28896
|
-
|
|
28897
|
-
|
|
28898
|
-
|
|
28899
|
-
|
|
28900
|
-
|
|
28901
|
-
|
|
28902
|
-
|
|
29209
|
+
addColumnIfMissing28(db, "memories", "content_hash", "TEXT");
|
|
29210
|
+
addColumnIfMissing28(db, "memories", "normalized_content", "TEXT");
|
|
29211
|
+
addColumnIfMissing28(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
29212
|
+
addColumnIfMissing28(db, "memories", "deleted_at", "TEXT");
|
|
29213
|
+
addColumnIfMissing28(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
29214
|
+
addColumnIfMissing28(db, "memories", "embedding_model", "TEXT");
|
|
29215
|
+
addColumnIfMissing28(db, "memories", "extraction_model", "TEXT");
|
|
29216
|
+
addColumnIfMissing28(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
29217
|
+
addColumnIfMissing28(db, "memories", "who", "TEXT");
|
|
29218
|
+
addColumnIfMissing28(db, "memories", "why", "TEXT");
|
|
29219
|
+
addColumnIfMissing28(db, "memories", "project", "TEXT");
|
|
29220
|
+
addColumnIfMissing28(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
29221
|
+
addColumnIfMissing28(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
29222
|
+
addColumnIfMissing28(db, "memories", "last_accessed", "TEXT");
|
|
29223
|
+
addColumnIfMissing28(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
28903
29224
|
db.exec(`
|
|
28904
29225
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
28905
29226
|
id TEXT PRIMARY KEY,
|
|
@@ -28995,7 +29316,7 @@ function up210(db) {
|
|
|
28995
29316
|
ON memory_entity_mentions(entity_id);
|
|
28996
29317
|
`);
|
|
28997
29318
|
}
|
|
28998
|
-
function
|
|
29319
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
28999
29320
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29000
29321
|
if (rows.some((r3) => r3.name === column))
|
|
29001
29322
|
return false;
|
|
@@ -29003,8 +29324,8 @@ function addColumnIfMissing28(db, table, column, definition) {
|
|
|
29003
29324
|
return true;
|
|
29004
29325
|
}
|
|
29005
29326
|
function up310(db) {
|
|
29006
|
-
|
|
29007
|
-
|
|
29327
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
29328
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
29008
29329
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
29009
29330
|
db.exec(`
|
|
29010
29331
|
UPDATE memories
|
|
@@ -29030,12 +29351,12 @@ function up310(db) {
|
|
|
29030
29351
|
WHERE content_hash IS NOT NULL AND is_deleted = 0
|
|
29031
29352
|
`);
|
|
29032
29353
|
}
|
|
29033
|
-
function
|
|
29354
|
+
function hasColumn27(db, table, column) {
|
|
29034
29355
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29035
29356
|
return rows.some((r3) => r3.name === column);
|
|
29036
29357
|
}
|
|
29037
29358
|
function addColumnIfMissing32(db, table, column, definition) {
|
|
29038
|
-
if (!
|
|
29359
|
+
if (!hasColumn27(db, table, column)) {
|
|
29039
29360
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29040
29361
|
}
|
|
29041
29362
|
}
|
|
@@ -29270,7 +29591,7 @@ function addColumnIfMissing52(db, table, column, definition) {
|
|
|
29270
29591
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29271
29592
|
}
|
|
29272
29593
|
}
|
|
29273
|
-
function
|
|
29594
|
+
function up1310(db) {
|
|
29274
29595
|
db.exec(`
|
|
29275
29596
|
CREATE TABLE IF NOT EXISTS ingestion_jobs (
|
|
29276
29597
|
id TEXT PRIMARY KEY,
|
|
@@ -33139,11 +33460,324 @@ function up1372(db) {
|
|
|
33139
33460
|
if (!cols.has(name))
|
|
33140
33461
|
db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
|
|
33141
33462
|
}
|
|
33463
|
+
function hasColumn252(db, table, column) {
|
|
33464
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
33465
|
+
return rows.some((row) => row.name === column);
|
|
33466
|
+
}
|
|
33467
|
+
function addColumnIfMissing272(db, table, column, definition) {
|
|
33468
|
+
if (!hasColumn252(db, table, column))
|
|
33469
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
33470
|
+
}
|
|
33471
|
+
function up1382(db) {
|
|
33472
|
+
addColumnIfMissing272(db, "memories", "manual_override", "INTEGER DEFAULT 0");
|
|
33473
|
+
db.exec(`
|
|
33474
|
+
CREATE TABLE IF NOT EXISTS transcript_capture_status (
|
|
33475
|
+
agent_id TEXT PRIMARY KEY,
|
|
33476
|
+
pending INTEGER NOT NULL DEFAULT 0,
|
|
33477
|
+
processing INTEGER NOT NULL DEFAULT 0,
|
|
33478
|
+
completed INTEGER NOT NULL DEFAULT 0,
|
|
33479
|
+
failed INTEGER NOT NULL DEFAULT 0,
|
|
33480
|
+
dead INTEGER NOT NULL DEFAULT 0,
|
|
33481
|
+
oldest_pending_at TEXT,
|
|
33482
|
+
last_error TEXT,
|
|
33483
|
+
last_error_at TEXT
|
|
33484
|
+
);
|
|
33485
|
+
|
|
33486
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_agent_status_created_at
|
|
33487
|
+
ON transcript_capture_jobs(agent_id, status, created_at);
|
|
33488
|
+
|
|
33489
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_error_updated_at
|
|
33490
|
+
ON transcript_capture_jobs(agent_id, updated_at DESC)
|
|
33491
|
+
WHERE error IS NOT NULL;
|
|
33492
|
+
|
|
33493
|
+
CREATE TABLE IF NOT EXISTS memories_duplicate_hash_counts (
|
|
33494
|
+
content_hash TEXT PRIMARY KEY,
|
|
33495
|
+
dup_count INTEGER NOT NULL
|
|
33496
|
+
);
|
|
33497
|
+
|
|
33498
|
+
CREATE INDEX IF NOT EXISTS idx_memories_dup_counts_active
|
|
33499
|
+
ON memories_duplicate_hash_counts(dup_count)
|
|
33500
|
+
WHERE dup_count > 1;
|
|
33501
|
+
|
|
33502
|
+
CREATE TABLE IF NOT EXISTS memories_diagnostics_state (
|
|
33503
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
33504
|
+
total_active INTEGER NOT NULL DEFAULT 0,
|
|
33505
|
+
exact_duplicates INTEGER NOT NULL DEFAULT 0,
|
|
33506
|
+
exact_clusters INTEGER NOT NULL DEFAULT 0
|
|
33507
|
+
);
|
|
33508
|
+
|
|
33509
|
+
CREATE INDEX IF NOT EXISTS idx_memories_active_hash_diagnostics
|
|
33510
|
+
ON memories(content_hash)
|
|
33511
|
+
WHERE is_deleted = 0
|
|
33512
|
+
AND content_hash IS NOT NULL
|
|
33513
|
+
AND pinned = 0
|
|
33514
|
+
AND manual_override = 0;
|
|
33515
|
+
`);
|
|
33516
|
+
db.exec(`
|
|
33517
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ai
|
|
33518
|
+
AFTER INSERT ON transcript_capture_jobs
|
|
33519
|
+
BEGIN
|
|
33520
|
+
INSERT INTO transcript_capture_status (agent_id)
|
|
33521
|
+
VALUES (NEW.agent_id)
|
|
33522
|
+
ON CONFLICT(agent_id) DO NOTHING;
|
|
33523
|
+
|
|
33524
|
+
UPDATE transcript_capture_status
|
|
33525
|
+
SET pending = pending + (NEW.status = 'pending'),
|
|
33526
|
+
processing = processing + (NEW.status = 'processing'),
|
|
33527
|
+
completed = completed + (NEW.status = 'completed'),
|
|
33528
|
+
failed = failed + (NEW.status = 'failed'),
|
|
33529
|
+
dead = dead + (NEW.status = 'dead')
|
|
33530
|
+
WHERE agent_id = NEW.agent_id;
|
|
33531
|
+
|
|
33532
|
+
UPDATE transcript_capture_status
|
|
33533
|
+
SET oldest_pending_at = (
|
|
33534
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
33535
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
33536
|
+
)
|
|
33537
|
+
WHERE agent_id = NEW.agent_id;
|
|
33538
|
+
|
|
33539
|
+
UPDATE transcript_capture_status
|
|
33540
|
+
SET last_error = (
|
|
33541
|
+
SELECT error FROM transcript_capture_jobs
|
|
33542
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33543
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33544
|
+
),
|
|
33545
|
+
last_error_at = (
|
|
33546
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
33547
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33548
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33549
|
+
)
|
|
33550
|
+
WHERE agent_id = NEW.agent_id
|
|
33551
|
+
AND NEW.error IS NOT NULL;
|
|
33552
|
+
END;
|
|
33553
|
+
|
|
33554
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_au
|
|
33555
|
+
AFTER UPDATE OF status, error, updated_at, created_at ON transcript_capture_jobs
|
|
33556
|
+
BEGIN
|
|
33557
|
+
UPDATE transcript_capture_status
|
|
33558
|
+
SET pending = pending + (NEW.status = 'pending') - (OLD.status = 'pending'),
|
|
33559
|
+
processing = processing + (NEW.status = 'processing') - (OLD.status = 'processing'),
|
|
33560
|
+
completed = completed + (NEW.status = 'completed') - (OLD.status = 'completed'),
|
|
33561
|
+
failed = failed + (NEW.status = 'failed') - (OLD.status = 'failed'),
|
|
33562
|
+
dead = dead + (NEW.status = 'dead') - (OLD.status = 'dead')
|
|
33563
|
+
WHERE agent_id = NEW.agent_id;
|
|
33564
|
+
|
|
33565
|
+
UPDATE transcript_capture_status
|
|
33566
|
+
SET oldest_pending_at = (
|
|
33567
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
33568
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
33569
|
+
)
|
|
33570
|
+
WHERE agent_id = NEW.agent_id;
|
|
33571
|
+
|
|
33572
|
+
UPDATE transcript_capture_status
|
|
33573
|
+
SET last_error = (
|
|
33574
|
+
SELECT error FROM transcript_capture_jobs
|
|
33575
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33576
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33577
|
+
),
|
|
33578
|
+
last_error_at = (
|
|
33579
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
33580
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33581
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33582
|
+
)
|
|
33583
|
+
WHERE agent_id = NEW.agent_id
|
|
33584
|
+
AND (NEW.error IS NOT NULL OR OLD.error IS NOT NULL);
|
|
33585
|
+
END;
|
|
33586
|
+
|
|
33587
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ad
|
|
33588
|
+
AFTER DELETE ON transcript_capture_jobs
|
|
33589
|
+
BEGIN
|
|
33590
|
+
UPDATE transcript_capture_status
|
|
33591
|
+
SET pending = pending - (OLD.status = 'pending'),
|
|
33592
|
+
processing = processing - (OLD.status = 'processing'),
|
|
33593
|
+
completed = completed - (OLD.status = 'completed'),
|
|
33594
|
+
failed = failed - (OLD.status = 'failed'),
|
|
33595
|
+
dead = dead - (OLD.status = 'dead')
|
|
33596
|
+
WHERE agent_id = OLD.agent_id;
|
|
33597
|
+
|
|
33598
|
+
UPDATE transcript_capture_status
|
|
33599
|
+
SET oldest_pending_at = (
|
|
33600
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
33601
|
+
WHERE agent_id = OLD.agent_id AND status = 'pending'
|
|
33602
|
+
)
|
|
33603
|
+
WHERE agent_id = OLD.agent_id;
|
|
33604
|
+
|
|
33605
|
+
UPDATE transcript_capture_status
|
|
33606
|
+
SET last_error = (
|
|
33607
|
+
SELECT error FROM transcript_capture_jobs
|
|
33608
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
33609
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33610
|
+
),
|
|
33611
|
+
last_error_at = (
|
|
33612
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
33613
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
33614
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33615
|
+
)
|
|
33616
|
+
WHERE agent_id = OLD.agent_id
|
|
33617
|
+
AND OLD.error IS NOT NULL;
|
|
33618
|
+
END;
|
|
33619
|
+
`);
|
|
33620
|
+
db.exec(`
|
|
33621
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ai
|
|
33622
|
+
AFTER INSERT ON memories
|
|
33623
|
+
BEGIN
|
|
33624
|
+
UPDATE memories_diagnostics_state
|
|
33625
|
+
SET total_active = total_active + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
33626
|
+
exact_duplicates = exact_duplicates + CASE
|
|
33627
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33628
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33629
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
33630
|
+
THEN 1 ELSE 0 END,
|
|
33631
|
+
exact_clusters = exact_clusters + CASE
|
|
33632
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33633
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33634
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
33635
|
+
THEN 1 ELSE 0 END
|
|
33636
|
+
WHERE id = 1;
|
|
33637
|
+
|
|
33638
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
33639
|
+
SELECT NEW.content_hash, 1
|
|
33640
|
+
WHERE NEW.is_deleted = 0
|
|
33641
|
+
AND NEW.content_hash IS NOT NULL
|
|
33642
|
+
AND NEW.pinned = 0
|
|
33643
|
+
AND NEW.manual_override = 0
|
|
33644
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
33645
|
+
END;
|
|
33646
|
+
|
|
33647
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_au
|
|
33648
|
+
AFTER UPDATE OF is_deleted, content_hash, pinned, manual_override ON memories
|
|
33649
|
+
BEGIN
|
|
33650
|
+
UPDATE memories_diagnostics_state
|
|
33651
|
+
SET total_active = total_active
|
|
33652
|
+
+ CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END
|
|
33653
|
+
- CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
33654
|
+
exact_duplicates = exact_duplicates - CASE
|
|
33655
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33656
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33657
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
33658
|
+
THEN 1 ELSE 0 END,
|
|
33659
|
+
exact_clusters = exact_clusters - CASE
|
|
33660
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33661
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33662
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
33663
|
+
THEN 1 ELSE 0 END
|
|
33664
|
+
WHERE id = 1;
|
|
33665
|
+
|
|
33666
|
+
UPDATE memories_duplicate_hash_counts
|
|
33667
|
+
SET dup_count = dup_count - 1
|
|
33668
|
+
WHERE OLD.is_deleted = 0
|
|
33669
|
+
AND OLD.content_hash IS NOT NULL
|
|
33670
|
+
AND OLD.pinned = 0
|
|
33671
|
+
AND OLD.manual_override = 0
|
|
33672
|
+
AND content_hash = OLD.content_hash;
|
|
33673
|
+
|
|
33674
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
33675
|
+
WHERE content_hash = OLD.content_hash
|
|
33676
|
+
AND dup_count <= 0;
|
|
33677
|
+
|
|
33678
|
+
UPDATE memories_diagnostics_state
|
|
33679
|
+
SET exact_duplicates = exact_duplicates + CASE
|
|
33680
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33681
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33682
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
33683
|
+
THEN 1 ELSE 0 END,
|
|
33684
|
+
exact_clusters = exact_clusters + CASE
|
|
33685
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33686
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33687
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
33688
|
+
THEN 1 ELSE 0 END
|
|
33689
|
+
WHERE id = 1;
|
|
33690
|
+
|
|
33691
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
33692
|
+
SELECT NEW.content_hash, 1
|
|
33693
|
+
WHERE NEW.is_deleted = 0
|
|
33694
|
+
AND NEW.content_hash IS NOT NULL
|
|
33695
|
+
AND NEW.pinned = 0
|
|
33696
|
+
AND NEW.manual_override = 0
|
|
33697
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
33698
|
+
END;
|
|
33699
|
+
|
|
33700
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ad
|
|
33701
|
+
AFTER DELETE ON memories
|
|
33702
|
+
BEGIN
|
|
33703
|
+
UPDATE memories_diagnostics_state
|
|
33704
|
+
SET total_active = total_active - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
33705
|
+
exact_duplicates = exact_duplicates - CASE
|
|
33706
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33707
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33708
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
33709
|
+
THEN 1 ELSE 0 END,
|
|
33710
|
+
exact_clusters = exact_clusters - CASE
|
|
33711
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33712
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33713
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
33714
|
+
THEN 1 ELSE 0 END
|
|
33715
|
+
WHERE id = 1;
|
|
33716
|
+
|
|
33717
|
+
UPDATE memories_duplicate_hash_counts
|
|
33718
|
+
SET dup_count = dup_count - 1
|
|
33719
|
+
WHERE OLD.is_deleted = 0
|
|
33720
|
+
AND OLD.content_hash IS NOT NULL
|
|
33721
|
+
AND OLD.pinned = 0
|
|
33722
|
+
AND OLD.manual_override = 0
|
|
33723
|
+
AND content_hash = OLD.content_hash;
|
|
33724
|
+
|
|
33725
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
33726
|
+
WHERE content_hash = OLD.content_hash
|
|
33727
|
+
AND dup_count <= 0;
|
|
33728
|
+
END;
|
|
33729
|
+
`);
|
|
33730
|
+
db.exec(`
|
|
33731
|
+
DELETE FROM transcript_capture_status;
|
|
33732
|
+
DELETE FROM memories_duplicate_hash_counts;
|
|
33733
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
33734
|
+
SELECT content_hash, COUNT(*)
|
|
33735
|
+
FROM memories
|
|
33736
|
+
WHERE is_deleted = 0
|
|
33737
|
+
AND content_hash IS NOT NULL
|
|
33738
|
+
AND pinned = 0
|
|
33739
|
+
AND manual_override = 0
|
|
33740
|
+
GROUP BY content_hash;
|
|
33741
|
+
|
|
33742
|
+
INSERT INTO memories_diagnostics_state (id, total_active, exact_duplicates, exact_clusters)
|
|
33743
|
+
VALUES (
|
|
33744
|
+
1,
|
|
33745
|
+
(SELECT COUNT(*) FROM memories WHERE is_deleted = 0),
|
|
33746
|
+
COALESCE((SELECT SUM(dup_count - 1) FROM memories_duplicate_hash_counts WHERE dup_count > 1), 0),
|
|
33747
|
+
(SELECT COUNT(*) FROM memories_duplicate_hash_counts WHERE dup_count > 1)
|
|
33748
|
+
)
|
|
33749
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
33750
|
+
total_active = excluded.total_active,
|
|
33751
|
+
exact_duplicates = excluded.exact_duplicates,
|
|
33752
|
+
exact_clusters = excluded.exact_clusters;
|
|
33753
|
+
|
|
33754
|
+
INSERT INTO transcript_capture_status (
|
|
33755
|
+
agent_id, pending, processing, completed, failed, dead,
|
|
33756
|
+
oldest_pending_at, last_error, last_error_at
|
|
33757
|
+
)
|
|
33758
|
+
SELECT
|
|
33759
|
+
j.agent_id,
|
|
33760
|
+
SUM(j.status = 'pending'),
|
|
33761
|
+
SUM(j.status = 'processing'),
|
|
33762
|
+
SUM(j.status = 'completed'),
|
|
33763
|
+
SUM(j.status = 'failed'),
|
|
33764
|
+
SUM(j.status = 'dead'),
|
|
33765
|
+
MIN(CASE WHEN j.status = 'pending' THEN j.created_at END),
|
|
33766
|
+
(SELECT e2.error FROM transcript_capture_jobs e2
|
|
33767
|
+
WHERE e2.agent_id = j.agent_id AND e2.error IS NOT NULL
|
|
33768
|
+
ORDER BY e2.updated_at DESC LIMIT 1),
|
|
33769
|
+
(SELECT e3.updated_at FROM transcript_capture_jobs e3
|
|
33770
|
+
WHERE e3.agent_id = j.agent_id AND e3.error IS NOT NULL
|
|
33771
|
+
ORDER BY e3.updated_at DESC LIMIT 1)
|
|
33772
|
+
FROM transcript_capture_jobs j
|
|
33773
|
+
GROUP BY j.agent_id;
|
|
33774
|
+
`);
|
|
33775
|
+
}
|
|
33142
33776
|
var MIGRATIONS2 = [
|
|
33143
33777
|
{
|
|
33144
33778
|
version: 1,
|
|
33145
33779
|
name: "baseline",
|
|
33146
|
-
up:
|
|
33780
|
+
up: up139,
|
|
33147
33781
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
33148
33782
|
},
|
|
33149
33783
|
{
|
|
@@ -33221,7 +33855,7 @@ var MIGRATIONS2 = [
|
|
|
33221
33855
|
{
|
|
33222
33856
|
version: 13,
|
|
33223
33857
|
name: "ingestion-tracking",
|
|
33224
|
-
up:
|
|
33858
|
+
up: up1310,
|
|
33225
33859
|
artifacts: {
|
|
33226
33860
|
columns: [
|
|
33227
33861
|
{ table: "memories", column: "source_path" },
|
|
@@ -34228,6 +34862,14 @@ var MIGRATIONS2 = [
|
|
|
34228
34862
|
{ table: "dreaming_passes", column: "head_hash" }
|
|
34229
34863
|
]
|
|
34230
34864
|
}
|
|
34865
|
+
},
|
|
34866
|
+
{
|
|
34867
|
+
version: 138,
|
|
34868
|
+
name: "bounded-status-projections",
|
|
34869
|
+
up: up1382,
|
|
34870
|
+
artifacts: {
|
|
34871
|
+
tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
|
|
34872
|
+
}
|
|
34231
34873
|
}
|
|
34232
34874
|
];
|
|
34233
34875
|
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-codex",
|
|
3
|
-
"version": "0.211.
|
|
3
|
+
"version": "0.211.20",
|
|
4
4
|
"description": "Signet connector for Codex CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@signetai/connector-base": "0.211.
|
|
28
|
-
"@signetai/core": "0.211.
|
|
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",
|