@signetai/connector-forge 0.211.17 → 0.212.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +669 -27
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -15759,6 +15759,319 @@ function up137(db) {
|
|
|
15759
15759
|
if (!cols.has(name))
|
|
15760
15760
|
db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
|
|
15761
15761
|
}
|
|
15762
|
+
function hasColumn25(db, table, column) {
|
|
15763
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
15764
|
+
return rows.some((row) => row.name === column);
|
|
15765
|
+
}
|
|
15766
|
+
function addColumnIfMissing27(db, table, column, definition) {
|
|
15767
|
+
if (!hasColumn25(db, table, column))
|
|
15768
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
15769
|
+
}
|
|
15770
|
+
function up138(db) {
|
|
15771
|
+
addColumnIfMissing27(db, "memories", "manual_override", "INTEGER DEFAULT 0");
|
|
15772
|
+
db.exec(`
|
|
15773
|
+
CREATE TABLE IF NOT EXISTS transcript_capture_status (
|
|
15774
|
+
agent_id TEXT PRIMARY KEY,
|
|
15775
|
+
pending INTEGER NOT NULL DEFAULT 0,
|
|
15776
|
+
processing INTEGER NOT NULL DEFAULT 0,
|
|
15777
|
+
completed INTEGER NOT NULL DEFAULT 0,
|
|
15778
|
+
failed INTEGER NOT NULL DEFAULT 0,
|
|
15779
|
+
dead INTEGER NOT NULL DEFAULT 0,
|
|
15780
|
+
oldest_pending_at TEXT,
|
|
15781
|
+
last_error TEXT,
|
|
15782
|
+
last_error_at TEXT
|
|
15783
|
+
);
|
|
15784
|
+
|
|
15785
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_agent_status_created_at
|
|
15786
|
+
ON transcript_capture_jobs(agent_id, status, created_at);
|
|
15787
|
+
|
|
15788
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_error_updated_at
|
|
15789
|
+
ON transcript_capture_jobs(agent_id, updated_at DESC)
|
|
15790
|
+
WHERE error IS NOT NULL;
|
|
15791
|
+
|
|
15792
|
+
CREATE TABLE IF NOT EXISTS memories_duplicate_hash_counts (
|
|
15793
|
+
content_hash TEXT PRIMARY KEY,
|
|
15794
|
+
dup_count INTEGER NOT NULL
|
|
15795
|
+
);
|
|
15796
|
+
|
|
15797
|
+
CREATE INDEX IF NOT EXISTS idx_memories_dup_counts_active
|
|
15798
|
+
ON memories_duplicate_hash_counts(dup_count)
|
|
15799
|
+
WHERE dup_count > 1;
|
|
15800
|
+
|
|
15801
|
+
CREATE TABLE IF NOT EXISTS memories_diagnostics_state (
|
|
15802
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
15803
|
+
total_active INTEGER NOT NULL DEFAULT 0,
|
|
15804
|
+
exact_duplicates INTEGER NOT NULL DEFAULT 0,
|
|
15805
|
+
exact_clusters INTEGER NOT NULL DEFAULT 0
|
|
15806
|
+
);
|
|
15807
|
+
|
|
15808
|
+
CREATE INDEX IF NOT EXISTS idx_memories_active_hash_diagnostics
|
|
15809
|
+
ON memories(content_hash)
|
|
15810
|
+
WHERE is_deleted = 0
|
|
15811
|
+
AND content_hash IS NOT NULL
|
|
15812
|
+
AND pinned = 0
|
|
15813
|
+
AND manual_override = 0;
|
|
15814
|
+
`);
|
|
15815
|
+
db.exec(`
|
|
15816
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ai
|
|
15817
|
+
AFTER INSERT ON transcript_capture_jobs
|
|
15818
|
+
BEGIN
|
|
15819
|
+
INSERT INTO transcript_capture_status (agent_id)
|
|
15820
|
+
VALUES (NEW.agent_id)
|
|
15821
|
+
ON CONFLICT(agent_id) DO NOTHING;
|
|
15822
|
+
|
|
15823
|
+
UPDATE transcript_capture_status
|
|
15824
|
+
SET pending = pending + (NEW.status = 'pending'),
|
|
15825
|
+
processing = processing + (NEW.status = 'processing'),
|
|
15826
|
+
completed = completed + (NEW.status = 'completed'),
|
|
15827
|
+
failed = failed + (NEW.status = 'failed'),
|
|
15828
|
+
dead = dead + (NEW.status = 'dead')
|
|
15829
|
+
WHERE agent_id = NEW.agent_id;
|
|
15830
|
+
|
|
15831
|
+
UPDATE transcript_capture_status
|
|
15832
|
+
SET oldest_pending_at = (
|
|
15833
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
15834
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
15835
|
+
)
|
|
15836
|
+
WHERE agent_id = NEW.agent_id;
|
|
15837
|
+
|
|
15838
|
+
UPDATE transcript_capture_status
|
|
15839
|
+
SET last_error = (
|
|
15840
|
+
SELECT error FROM transcript_capture_jobs
|
|
15841
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15842
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15843
|
+
),
|
|
15844
|
+
last_error_at = (
|
|
15845
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
15846
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15847
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15848
|
+
)
|
|
15849
|
+
WHERE agent_id = NEW.agent_id
|
|
15850
|
+
AND NEW.error IS NOT NULL;
|
|
15851
|
+
END;
|
|
15852
|
+
|
|
15853
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_au
|
|
15854
|
+
AFTER UPDATE OF status, error, updated_at, created_at ON transcript_capture_jobs
|
|
15855
|
+
BEGIN
|
|
15856
|
+
UPDATE transcript_capture_status
|
|
15857
|
+
SET pending = pending + (NEW.status = 'pending') - (OLD.status = 'pending'),
|
|
15858
|
+
processing = processing + (NEW.status = 'processing') - (OLD.status = 'processing'),
|
|
15859
|
+
completed = completed + (NEW.status = 'completed') - (OLD.status = 'completed'),
|
|
15860
|
+
failed = failed + (NEW.status = 'failed') - (OLD.status = 'failed'),
|
|
15861
|
+
dead = dead + (NEW.status = 'dead') - (OLD.status = 'dead')
|
|
15862
|
+
WHERE agent_id = NEW.agent_id;
|
|
15863
|
+
|
|
15864
|
+
UPDATE transcript_capture_status
|
|
15865
|
+
SET oldest_pending_at = (
|
|
15866
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
15867
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
15868
|
+
)
|
|
15869
|
+
WHERE agent_id = NEW.agent_id;
|
|
15870
|
+
|
|
15871
|
+
UPDATE transcript_capture_status
|
|
15872
|
+
SET last_error = (
|
|
15873
|
+
SELECT error FROM transcript_capture_jobs
|
|
15874
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15875
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15876
|
+
),
|
|
15877
|
+
last_error_at = (
|
|
15878
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
15879
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
15880
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15881
|
+
)
|
|
15882
|
+
WHERE agent_id = NEW.agent_id
|
|
15883
|
+
AND (NEW.error IS NOT NULL OR OLD.error IS NOT NULL);
|
|
15884
|
+
END;
|
|
15885
|
+
|
|
15886
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ad
|
|
15887
|
+
AFTER DELETE ON transcript_capture_jobs
|
|
15888
|
+
BEGIN
|
|
15889
|
+
UPDATE transcript_capture_status
|
|
15890
|
+
SET pending = pending - (OLD.status = 'pending'),
|
|
15891
|
+
processing = processing - (OLD.status = 'processing'),
|
|
15892
|
+
completed = completed - (OLD.status = 'completed'),
|
|
15893
|
+
failed = failed - (OLD.status = 'failed'),
|
|
15894
|
+
dead = dead - (OLD.status = 'dead')
|
|
15895
|
+
WHERE agent_id = OLD.agent_id;
|
|
15896
|
+
|
|
15897
|
+
UPDATE transcript_capture_status
|
|
15898
|
+
SET oldest_pending_at = (
|
|
15899
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
15900
|
+
WHERE agent_id = OLD.agent_id AND status = 'pending'
|
|
15901
|
+
)
|
|
15902
|
+
WHERE agent_id = OLD.agent_id;
|
|
15903
|
+
|
|
15904
|
+
UPDATE transcript_capture_status
|
|
15905
|
+
SET last_error = (
|
|
15906
|
+
SELECT error FROM transcript_capture_jobs
|
|
15907
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
15908
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15909
|
+
),
|
|
15910
|
+
last_error_at = (
|
|
15911
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
15912
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
15913
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
15914
|
+
)
|
|
15915
|
+
WHERE agent_id = OLD.agent_id
|
|
15916
|
+
AND OLD.error IS NOT NULL;
|
|
15917
|
+
END;
|
|
15918
|
+
`);
|
|
15919
|
+
db.exec(`
|
|
15920
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ai
|
|
15921
|
+
AFTER INSERT ON memories
|
|
15922
|
+
BEGIN
|
|
15923
|
+
UPDATE memories_diagnostics_state
|
|
15924
|
+
SET total_active = total_active + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
15925
|
+
exact_duplicates = exact_duplicates + CASE
|
|
15926
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15927
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15928
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
15929
|
+
THEN 1 ELSE 0 END,
|
|
15930
|
+
exact_clusters = exact_clusters + CASE
|
|
15931
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15932
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15933
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
15934
|
+
THEN 1 ELSE 0 END
|
|
15935
|
+
WHERE id = 1;
|
|
15936
|
+
|
|
15937
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
15938
|
+
SELECT NEW.content_hash, 1
|
|
15939
|
+
WHERE NEW.is_deleted = 0
|
|
15940
|
+
AND NEW.content_hash IS NOT NULL
|
|
15941
|
+
AND NEW.pinned = 0
|
|
15942
|
+
AND NEW.manual_override = 0
|
|
15943
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
15944
|
+
END;
|
|
15945
|
+
|
|
15946
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_au
|
|
15947
|
+
AFTER UPDATE OF is_deleted, content_hash, pinned, manual_override ON memories
|
|
15948
|
+
BEGIN
|
|
15949
|
+
UPDATE memories_diagnostics_state
|
|
15950
|
+
SET total_active = total_active
|
|
15951
|
+
+ CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END
|
|
15952
|
+
- CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
15953
|
+
exact_duplicates = exact_duplicates - CASE
|
|
15954
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
15955
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
15956
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
15957
|
+
THEN 1 ELSE 0 END,
|
|
15958
|
+
exact_clusters = exact_clusters - CASE
|
|
15959
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
15960
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
15961
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
15962
|
+
THEN 1 ELSE 0 END
|
|
15963
|
+
WHERE id = 1;
|
|
15964
|
+
|
|
15965
|
+
UPDATE memories_duplicate_hash_counts
|
|
15966
|
+
SET dup_count = dup_count - 1
|
|
15967
|
+
WHERE OLD.is_deleted = 0
|
|
15968
|
+
AND OLD.content_hash IS NOT NULL
|
|
15969
|
+
AND OLD.pinned = 0
|
|
15970
|
+
AND OLD.manual_override = 0
|
|
15971
|
+
AND content_hash = OLD.content_hash;
|
|
15972
|
+
|
|
15973
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
15974
|
+
WHERE content_hash = OLD.content_hash
|
|
15975
|
+
AND dup_count <= 0;
|
|
15976
|
+
|
|
15977
|
+
UPDATE memories_diagnostics_state
|
|
15978
|
+
SET exact_duplicates = exact_duplicates + CASE
|
|
15979
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15980
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15981
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
15982
|
+
THEN 1 ELSE 0 END,
|
|
15983
|
+
exact_clusters = exact_clusters + CASE
|
|
15984
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
15985
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
15986
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
15987
|
+
THEN 1 ELSE 0 END
|
|
15988
|
+
WHERE id = 1;
|
|
15989
|
+
|
|
15990
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
15991
|
+
SELECT NEW.content_hash, 1
|
|
15992
|
+
WHERE NEW.is_deleted = 0
|
|
15993
|
+
AND NEW.content_hash IS NOT NULL
|
|
15994
|
+
AND NEW.pinned = 0
|
|
15995
|
+
AND NEW.manual_override = 0
|
|
15996
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
15997
|
+
END;
|
|
15998
|
+
|
|
15999
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ad
|
|
16000
|
+
AFTER DELETE ON memories
|
|
16001
|
+
BEGIN
|
|
16002
|
+
UPDATE memories_diagnostics_state
|
|
16003
|
+
SET total_active = total_active - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
16004
|
+
exact_duplicates = exact_duplicates - CASE
|
|
16005
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
16006
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
16007
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
16008
|
+
THEN 1 ELSE 0 END,
|
|
16009
|
+
exact_clusters = exact_clusters - CASE
|
|
16010
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
16011
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
16012
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
16013
|
+
THEN 1 ELSE 0 END
|
|
16014
|
+
WHERE id = 1;
|
|
16015
|
+
|
|
16016
|
+
UPDATE memories_duplicate_hash_counts
|
|
16017
|
+
SET dup_count = dup_count - 1
|
|
16018
|
+
WHERE OLD.is_deleted = 0
|
|
16019
|
+
AND OLD.content_hash IS NOT NULL
|
|
16020
|
+
AND OLD.pinned = 0
|
|
16021
|
+
AND OLD.manual_override = 0
|
|
16022
|
+
AND content_hash = OLD.content_hash;
|
|
16023
|
+
|
|
16024
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
16025
|
+
WHERE content_hash = OLD.content_hash
|
|
16026
|
+
AND dup_count <= 0;
|
|
16027
|
+
END;
|
|
16028
|
+
`);
|
|
16029
|
+
db.exec(`
|
|
16030
|
+
DELETE FROM transcript_capture_status;
|
|
16031
|
+
DELETE FROM memories_duplicate_hash_counts;
|
|
16032
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
16033
|
+
SELECT content_hash, COUNT(*)
|
|
16034
|
+
FROM memories
|
|
16035
|
+
WHERE is_deleted = 0
|
|
16036
|
+
AND content_hash IS NOT NULL
|
|
16037
|
+
AND pinned = 0
|
|
16038
|
+
AND manual_override = 0
|
|
16039
|
+
GROUP BY content_hash;
|
|
16040
|
+
|
|
16041
|
+
INSERT INTO memories_diagnostics_state (id, total_active, exact_duplicates, exact_clusters)
|
|
16042
|
+
VALUES (
|
|
16043
|
+
1,
|
|
16044
|
+
(SELECT COUNT(*) FROM memories WHERE is_deleted = 0),
|
|
16045
|
+
COALESCE((SELECT SUM(dup_count - 1) FROM memories_duplicate_hash_counts WHERE dup_count > 1), 0),
|
|
16046
|
+
(SELECT COUNT(*) FROM memories_duplicate_hash_counts WHERE dup_count > 1)
|
|
16047
|
+
)
|
|
16048
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
16049
|
+
total_active = excluded.total_active,
|
|
16050
|
+
exact_duplicates = excluded.exact_duplicates,
|
|
16051
|
+
exact_clusters = excluded.exact_clusters;
|
|
16052
|
+
|
|
16053
|
+
INSERT INTO transcript_capture_status (
|
|
16054
|
+
agent_id, pending, processing, completed, failed, dead,
|
|
16055
|
+
oldest_pending_at, last_error, last_error_at
|
|
16056
|
+
)
|
|
16057
|
+
SELECT
|
|
16058
|
+
j.agent_id,
|
|
16059
|
+
SUM(j.status = 'pending'),
|
|
16060
|
+
SUM(j.status = 'processing'),
|
|
16061
|
+
SUM(j.status = 'completed'),
|
|
16062
|
+
SUM(j.status = 'failed'),
|
|
16063
|
+
SUM(j.status = 'dead'),
|
|
16064
|
+
MIN(CASE WHEN j.status = 'pending' THEN j.created_at END),
|
|
16065
|
+
(SELECT e2.error FROM transcript_capture_jobs e2
|
|
16066
|
+
WHERE e2.agent_id = j.agent_id AND e2.error IS NOT NULL
|
|
16067
|
+
ORDER BY e2.updated_at DESC LIMIT 1),
|
|
16068
|
+
(SELECT e3.updated_at FROM transcript_capture_jobs e3
|
|
16069
|
+
WHERE e3.agent_id = j.agent_id AND e3.error IS NOT NULL
|
|
16070
|
+
ORDER BY e3.updated_at DESC LIMIT 1)
|
|
16071
|
+
FROM transcript_capture_jobs j
|
|
16072
|
+
GROUP BY j.agent_id;
|
|
16073
|
+
`);
|
|
16074
|
+
}
|
|
15762
16075
|
var MIGRATIONS = [
|
|
15763
16076
|
{
|
|
15764
16077
|
version: 1,
|
|
@@ -16848,6 +17161,14 @@ var MIGRATIONS = [
|
|
|
16848
17161
|
{ table: "dreaming_passes", column: "head_hash" }
|
|
16849
17162
|
]
|
|
16850
17163
|
}
|
|
17164
|
+
},
|
|
17165
|
+
{
|
|
17166
|
+
version: 138,
|
|
17167
|
+
name: "bounded-status-projections",
|
|
17168
|
+
up: up138,
|
|
17169
|
+
artifacts: {
|
|
17170
|
+
tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
|
|
17171
|
+
}
|
|
16851
17172
|
}
|
|
16852
17173
|
];
|
|
16853
17174
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -28952,7 +29273,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
28952
29273
|
return true;
|
|
28953
29274
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
28954
29275
|
}
|
|
28955
|
-
function
|
|
29276
|
+
function up139(db) {
|
|
28956
29277
|
db.exec(`
|
|
28957
29278
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
28958
29279
|
version INTEGER PRIMARY KEY,
|
|
@@ -29041,31 +29362,31 @@ function up138(db) {
|
|
|
29041
29362
|
} catch {}
|
|
29042
29363
|
createMemoriesFts2(db);
|
|
29043
29364
|
}
|
|
29044
|
-
function
|
|
29365
|
+
function hasColumn26(db, table, column) {
|
|
29045
29366
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29046
29367
|
return rows.some((r3) => r3.name === column);
|
|
29047
29368
|
}
|
|
29048
|
-
function
|
|
29049
|
-
if (!
|
|
29369
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
29370
|
+
if (!hasColumn26(db, table, column)) {
|
|
29050
29371
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29051
29372
|
}
|
|
29052
29373
|
}
|
|
29053
29374
|
function up210(db) {
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
|
|
29375
|
+
addColumnIfMissing28(db, "memories", "content_hash", "TEXT");
|
|
29376
|
+
addColumnIfMissing28(db, "memories", "normalized_content", "TEXT");
|
|
29377
|
+
addColumnIfMissing28(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
29378
|
+
addColumnIfMissing28(db, "memories", "deleted_at", "TEXT");
|
|
29379
|
+
addColumnIfMissing28(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
29380
|
+
addColumnIfMissing28(db, "memories", "embedding_model", "TEXT");
|
|
29381
|
+
addColumnIfMissing28(db, "memories", "extraction_model", "TEXT");
|
|
29382
|
+
addColumnIfMissing28(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
29383
|
+
addColumnIfMissing28(db, "memories", "who", "TEXT");
|
|
29384
|
+
addColumnIfMissing28(db, "memories", "why", "TEXT");
|
|
29385
|
+
addColumnIfMissing28(db, "memories", "project", "TEXT");
|
|
29386
|
+
addColumnIfMissing28(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
29387
|
+
addColumnIfMissing28(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
29388
|
+
addColumnIfMissing28(db, "memories", "last_accessed", "TEXT");
|
|
29389
|
+
addColumnIfMissing28(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
29069
29390
|
db.exec(`
|
|
29070
29391
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
29071
29392
|
id TEXT PRIMARY KEY,
|
|
@@ -29161,7 +29482,7 @@ function up210(db) {
|
|
|
29161
29482
|
ON memory_entity_mentions(entity_id);
|
|
29162
29483
|
`);
|
|
29163
29484
|
}
|
|
29164
|
-
function
|
|
29485
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
29165
29486
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29166
29487
|
if (rows.some((r3) => r3.name === column))
|
|
29167
29488
|
return false;
|
|
@@ -29169,8 +29490,8 @@ function addColumnIfMissing28(db, table, column, definition) {
|
|
|
29169
29490
|
return true;
|
|
29170
29491
|
}
|
|
29171
29492
|
function up310(db) {
|
|
29172
|
-
|
|
29173
|
-
|
|
29493
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
29494
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
29174
29495
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
29175
29496
|
db.exec(`
|
|
29176
29497
|
UPDATE memories
|
|
@@ -29196,12 +29517,12 @@ function up310(db) {
|
|
|
29196
29517
|
WHERE content_hash IS NOT NULL AND is_deleted = 0
|
|
29197
29518
|
`);
|
|
29198
29519
|
}
|
|
29199
|
-
function
|
|
29520
|
+
function hasColumn27(db, table, column) {
|
|
29200
29521
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29201
29522
|
return rows.some((r3) => r3.name === column);
|
|
29202
29523
|
}
|
|
29203
29524
|
function addColumnIfMissing32(db, table, column, definition) {
|
|
29204
|
-
if (!
|
|
29525
|
+
if (!hasColumn27(db, table, column)) {
|
|
29205
29526
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29206
29527
|
}
|
|
29207
29528
|
}
|
|
@@ -29436,7 +29757,7 @@ function addColumnIfMissing52(db, table, column, definition) {
|
|
|
29436
29757
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29437
29758
|
}
|
|
29438
29759
|
}
|
|
29439
|
-
function
|
|
29760
|
+
function up1310(db) {
|
|
29440
29761
|
db.exec(`
|
|
29441
29762
|
CREATE TABLE IF NOT EXISTS ingestion_jobs (
|
|
29442
29763
|
id TEXT PRIMARY KEY,
|
|
@@ -33305,11 +33626,324 @@ function up1372(db) {
|
|
|
33305
33626
|
if (!cols.has(name))
|
|
33306
33627
|
db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
|
|
33307
33628
|
}
|
|
33629
|
+
function hasColumn252(db, table, column) {
|
|
33630
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
33631
|
+
return rows.some((row) => row.name === column);
|
|
33632
|
+
}
|
|
33633
|
+
function addColumnIfMissing272(db, table, column, definition) {
|
|
33634
|
+
if (!hasColumn252(db, table, column))
|
|
33635
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
33636
|
+
}
|
|
33637
|
+
function up1382(db) {
|
|
33638
|
+
addColumnIfMissing272(db, "memories", "manual_override", "INTEGER DEFAULT 0");
|
|
33639
|
+
db.exec(`
|
|
33640
|
+
CREATE TABLE IF NOT EXISTS transcript_capture_status (
|
|
33641
|
+
agent_id TEXT PRIMARY KEY,
|
|
33642
|
+
pending INTEGER NOT NULL DEFAULT 0,
|
|
33643
|
+
processing INTEGER NOT NULL DEFAULT 0,
|
|
33644
|
+
completed INTEGER NOT NULL DEFAULT 0,
|
|
33645
|
+
failed INTEGER NOT NULL DEFAULT 0,
|
|
33646
|
+
dead INTEGER NOT NULL DEFAULT 0,
|
|
33647
|
+
oldest_pending_at TEXT,
|
|
33648
|
+
last_error TEXT,
|
|
33649
|
+
last_error_at TEXT
|
|
33650
|
+
);
|
|
33651
|
+
|
|
33652
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_agent_status_created_at
|
|
33653
|
+
ON transcript_capture_jobs(agent_id, status, created_at);
|
|
33654
|
+
|
|
33655
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_capture_jobs_error_updated_at
|
|
33656
|
+
ON transcript_capture_jobs(agent_id, updated_at DESC)
|
|
33657
|
+
WHERE error IS NOT NULL;
|
|
33658
|
+
|
|
33659
|
+
CREATE TABLE IF NOT EXISTS memories_duplicate_hash_counts (
|
|
33660
|
+
content_hash TEXT PRIMARY KEY,
|
|
33661
|
+
dup_count INTEGER NOT NULL
|
|
33662
|
+
);
|
|
33663
|
+
|
|
33664
|
+
CREATE INDEX IF NOT EXISTS idx_memories_dup_counts_active
|
|
33665
|
+
ON memories_duplicate_hash_counts(dup_count)
|
|
33666
|
+
WHERE dup_count > 1;
|
|
33667
|
+
|
|
33668
|
+
CREATE TABLE IF NOT EXISTS memories_diagnostics_state (
|
|
33669
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
33670
|
+
total_active INTEGER NOT NULL DEFAULT 0,
|
|
33671
|
+
exact_duplicates INTEGER NOT NULL DEFAULT 0,
|
|
33672
|
+
exact_clusters INTEGER NOT NULL DEFAULT 0
|
|
33673
|
+
);
|
|
33674
|
+
|
|
33675
|
+
CREATE INDEX IF NOT EXISTS idx_memories_active_hash_diagnostics
|
|
33676
|
+
ON memories(content_hash)
|
|
33677
|
+
WHERE is_deleted = 0
|
|
33678
|
+
AND content_hash IS NOT NULL
|
|
33679
|
+
AND pinned = 0
|
|
33680
|
+
AND manual_override = 0;
|
|
33681
|
+
`);
|
|
33682
|
+
db.exec(`
|
|
33683
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ai
|
|
33684
|
+
AFTER INSERT ON transcript_capture_jobs
|
|
33685
|
+
BEGIN
|
|
33686
|
+
INSERT INTO transcript_capture_status (agent_id)
|
|
33687
|
+
VALUES (NEW.agent_id)
|
|
33688
|
+
ON CONFLICT(agent_id) DO NOTHING;
|
|
33689
|
+
|
|
33690
|
+
UPDATE transcript_capture_status
|
|
33691
|
+
SET pending = pending + (NEW.status = 'pending'),
|
|
33692
|
+
processing = processing + (NEW.status = 'processing'),
|
|
33693
|
+
completed = completed + (NEW.status = 'completed'),
|
|
33694
|
+
failed = failed + (NEW.status = 'failed'),
|
|
33695
|
+
dead = dead + (NEW.status = 'dead')
|
|
33696
|
+
WHERE agent_id = NEW.agent_id;
|
|
33697
|
+
|
|
33698
|
+
UPDATE transcript_capture_status
|
|
33699
|
+
SET oldest_pending_at = (
|
|
33700
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
33701
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
33702
|
+
)
|
|
33703
|
+
WHERE agent_id = NEW.agent_id;
|
|
33704
|
+
|
|
33705
|
+
UPDATE transcript_capture_status
|
|
33706
|
+
SET last_error = (
|
|
33707
|
+
SELECT error FROM transcript_capture_jobs
|
|
33708
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33709
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33710
|
+
),
|
|
33711
|
+
last_error_at = (
|
|
33712
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
33713
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33714
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33715
|
+
)
|
|
33716
|
+
WHERE agent_id = NEW.agent_id
|
|
33717
|
+
AND NEW.error IS NOT NULL;
|
|
33718
|
+
END;
|
|
33719
|
+
|
|
33720
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_au
|
|
33721
|
+
AFTER UPDATE OF status, error, updated_at, created_at ON transcript_capture_jobs
|
|
33722
|
+
BEGIN
|
|
33723
|
+
UPDATE transcript_capture_status
|
|
33724
|
+
SET pending = pending + (NEW.status = 'pending') - (OLD.status = 'pending'),
|
|
33725
|
+
processing = processing + (NEW.status = 'processing') - (OLD.status = 'processing'),
|
|
33726
|
+
completed = completed + (NEW.status = 'completed') - (OLD.status = 'completed'),
|
|
33727
|
+
failed = failed + (NEW.status = 'failed') - (OLD.status = 'failed'),
|
|
33728
|
+
dead = dead + (NEW.status = 'dead') - (OLD.status = 'dead')
|
|
33729
|
+
WHERE agent_id = NEW.agent_id;
|
|
33730
|
+
|
|
33731
|
+
UPDATE transcript_capture_status
|
|
33732
|
+
SET oldest_pending_at = (
|
|
33733
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
33734
|
+
WHERE agent_id = NEW.agent_id AND status = 'pending'
|
|
33735
|
+
)
|
|
33736
|
+
WHERE agent_id = NEW.agent_id;
|
|
33737
|
+
|
|
33738
|
+
UPDATE transcript_capture_status
|
|
33739
|
+
SET last_error = (
|
|
33740
|
+
SELECT error FROM transcript_capture_jobs
|
|
33741
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33742
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33743
|
+
),
|
|
33744
|
+
last_error_at = (
|
|
33745
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
33746
|
+
WHERE agent_id = NEW.agent_id AND error IS NOT NULL
|
|
33747
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33748
|
+
)
|
|
33749
|
+
WHERE agent_id = NEW.agent_id
|
|
33750
|
+
AND (NEW.error IS NOT NULL OR OLD.error IS NOT NULL);
|
|
33751
|
+
END;
|
|
33752
|
+
|
|
33753
|
+
CREATE TRIGGER IF NOT EXISTS transcript_capture_status_ad
|
|
33754
|
+
AFTER DELETE ON transcript_capture_jobs
|
|
33755
|
+
BEGIN
|
|
33756
|
+
UPDATE transcript_capture_status
|
|
33757
|
+
SET pending = pending - (OLD.status = 'pending'),
|
|
33758
|
+
processing = processing - (OLD.status = 'processing'),
|
|
33759
|
+
completed = completed - (OLD.status = 'completed'),
|
|
33760
|
+
failed = failed - (OLD.status = 'failed'),
|
|
33761
|
+
dead = dead - (OLD.status = 'dead')
|
|
33762
|
+
WHERE agent_id = OLD.agent_id;
|
|
33763
|
+
|
|
33764
|
+
UPDATE transcript_capture_status
|
|
33765
|
+
SET oldest_pending_at = (
|
|
33766
|
+
SELECT MIN(created_at) FROM transcript_capture_jobs
|
|
33767
|
+
WHERE agent_id = OLD.agent_id AND status = 'pending'
|
|
33768
|
+
)
|
|
33769
|
+
WHERE agent_id = OLD.agent_id;
|
|
33770
|
+
|
|
33771
|
+
UPDATE transcript_capture_status
|
|
33772
|
+
SET last_error = (
|
|
33773
|
+
SELECT error FROM transcript_capture_jobs
|
|
33774
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
33775
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33776
|
+
),
|
|
33777
|
+
last_error_at = (
|
|
33778
|
+
SELECT updated_at FROM transcript_capture_jobs
|
|
33779
|
+
WHERE agent_id = OLD.agent_id AND error IS NOT NULL
|
|
33780
|
+
ORDER BY updated_at DESC LIMIT 1
|
|
33781
|
+
)
|
|
33782
|
+
WHERE agent_id = OLD.agent_id
|
|
33783
|
+
AND OLD.error IS NOT NULL;
|
|
33784
|
+
END;
|
|
33785
|
+
`);
|
|
33786
|
+
db.exec(`
|
|
33787
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ai
|
|
33788
|
+
AFTER INSERT ON memories
|
|
33789
|
+
BEGIN
|
|
33790
|
+
UPDATE memories_diagnostics_state
|
|
33791
|
+
SET total_active = total_active + CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
33792
|
+
exact_duplicates = exact_duplicates + CASE
|
|
33793
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33794
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33795
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
33796
|
+
THEN 1 ELSE 0 END,
|
|
33797
|
+
exact_clusters = exact_clusters + CASE
|
|
33798
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33799
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33800
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
33801
|
+
THEN 1 ELSE 0 END
|
|
33802
|
+
WHERE id = 1;
|
|
33803
|
+
|
|
33804
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
33805
|
+
SELECT NEW.content_hash, 1
|
|
33806
|
+
WHERE NEW.is_deleted = 0
|
|
33807
|
+
AND NEW.content_hash IS NOT NULL
|
|
33808
|
+
AND NEW.pinned = 0
|
|
33809
|
+
AND NEW.manual_override = 0
|
|
33810
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
33811
|
+
END;
|
|
33812
|
+
|
|
33813
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_au
|
|
33814
|
+
AFTER UPDATE OF is_deleted, content_hash, pinned, manual_override ON memories
|
|
33815
|
+
BEGIN
|
|
33816
|
+
UPDATE memories_diagnostics_state
|
|
33817
|
+
SET total_active = total_active
|
|
33818
|
+
+ CASE WHEN NEW.is_deleted = 0 THEN 1 ELSE 0 END
|
|
33819
|
+
- CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
33820
|
+
exact_duplicates = exact_duplicates - CASE
|
|
33821
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33822
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33823
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
33824
|
+
THEN 1 ELSE 0 END,
|
|
33825
|
+
exact_clusters = exact_clusters - CASE
|
|
33826
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33827
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33828
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
33829
|
+
THEN 1 ELSE 0 END
|
|
33830
|
+
WHERE id = 1;
|
|
33831
|
+
|
|
33832
|
+
UPDATE memories_duplicate_hash_counts
|
|
33833
|
+
SET dup_count = dup_count - 1
|
|
33834
|
+
WHERE OLD.is_deleted = 0
|
|
33835
|
+
AND OLD.content_hash IS NOT NULL
|
|
33836
|
+
AND OLD.pinned = 0
|
|
33837
|
+
AND OLD.manual_override = 0
|
|
33838
|
+
AND content_hash = OLD.content_hash;
|
|
33839
|
+
|
|
33840
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
33841
|
+
WHERE content_hash = OLD.content_hash
|
|
33842
|
+
AND dup_count <= 0;
|
|
33843
|
+
|
|
33844
|
+
UPDATE memories_diagnostics_state
|
|
33845
|
+
SET exact_duplicates = exact_duplicates + CASE
|
|
33846
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33847
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33848
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) >= 1
|
|
33849
|
+
THEN 1 ELSE 0 END,
|
|
33850
|
+
exact_clusters = exact_clusters + CASE
|
|
33851
|
+
WHEN NEW.is_deleted = 0 AND NEW.content_hash IS NOT NULL
|
|
33852
|
+
AND NEW.pinned = 0 AND NEW.manual_override = 0
|
|
33853
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = NEW.content_hash), 0) = 1
|
|
33854
|
+
THEN 1 ELSE 0 END
|
|
33855
|
+
WHERE id = 1;
|
|
33856
|
+
|
|
33857
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
33858
|
+
SELECT NEW.content_hash, 1
|
|
33859
|
+
WHERE NEW.is_deleted = 0
|
|
33860
|
+
AND NEW.content_hash IS NOT NULL
|
|
33861
|
+
AND NEW.pinned = 0
|
|
33862
|
+
AND NEW.manual_override = 0
|
|
33863
|
+
ON CONFLICT(content_hash) DO UPDATE SET dup_count = dup_count + 1;
|
|
33864
|
+
END;
|
|
33865
|
+
|
|
33866
|
+
CREATE TRIGGER IF NOT EXISTS memories_dup_projection_ad
|
|
33867
|
+
AFTER DELETE ON memories
|
|
33868
|
+
BEGIN
|
|
33869
|
+
UPDATE memories_diagnostics_state
|
|
33870
|
+
SET total_active = total_active - CASE WHEN OLD.is_deleted = 0 THEN 1 ELSE 0 END,
|
|
33871
|
+
exact_duplicates = exact_duplicates - CASE
|
|
33872
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33873
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33874
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) > 1
|
|
33875
|
+
THEN 1 ELSE 0 END,
|
|
33876
|
+
exact_clusters = exact_clusters - CASE
|
|
33877
|
+
WHEN OLD.is_deleted = 0 AND OLD.content_hash IS NOT NULL
|
|
33878
|
+
AND OLD.pinned = 0 AND OLD.manual_override = 0
|
|
33879
|
+
AND COALESCE((SELECT dup_count FROM memories_duplicate_hash_counts WHERE content_hash = OLD.content_hash), 0) = 2
|
|
33880
|
+
THEN 1 ELSE 0 END
|
|
33881
|
+
WHERE id = 1;
|
|
33882
|
+
|
|
33883
|
+
UPDATE memories_duplicate_hash_counts
|
|
33884
|
+
SET dup_count = dup_count - 1
|
|
33885
|
+
WHERE OLD.is_deleted = 0
|
|
33886
|
+
AND OLD.content_hash IS NOT NULL
|
|
33887
|
+
AND OLD.pinned = 0
|
|
33888
|
+
AND OLD.manual_override = 0
|
|
33889
|
+
AND content_hash = OLD.content_hash;
|
|
33890
|
+
|
|
33891
|
+
DELETE FROM memories_duplicate_hash_counts
|
|
33892
|
+
WHERE content_hash = OLD.content_hash
|
|
33893
|
+
AND dup_count <= 0;
|
|
33894
|
+
END;
|
|
33895
|
+
`);
|
|
33896
|
+
db.exec(`
|
|
33897
|
+
DELETE FROM transcript_capture_status;
|
|
33898
|
+
DELETE FROM memories_duplicate_hash_counts;
|
|
33899
|
+
INSERT INTO memories_duplicate_hash_counts (content_hash, dup_count)
|
|
33900
|
+
SELECT content_hash, COUNT(*)
|
|
33901
|
+
FROM memories
|
|
33902
|
+
WHERE is_deleted = 0
|
|
33903
|
+
AND content_hash IS NOT NULL
|
|
33904
|
+
AND pinned = 0
|
|
33905
|
+
AND manual_override = 0
|
|
33906
|
+
GROUP BY content_hash;
|
|
33907
|
+
|
|
33908
|
+
INSERT INTO memories_diagnostics_state (id, total_active, exact_duplicates, exact_clusters)
|
|
33909
|
+
VALUES (
|
|
33910
|
+
1,
|
|
33911
|
+
(SELECT COUNT(*) FROM memories WHERE is_deleted = 0),
|
|
33912
|
+
COALESCE((SELECT SUM(dup_count - 1) FROM memories_duplicate_hash_counts WHERE dup_count > 1), 0),
|
|
33913
|
+
(SELECT COUNT(*) FROM memories_duplicate_hash_counts WHERE dup_count > 1)
|
|
33914
|
+
)
|
|
33915
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
33916
|
+
total_active = excluded.total_active,
|
|
33917
|
+
exact_duplicates = excluded.exact_duplicates,
|
|
33918
|
+
exact_clusters = excluded.exact_clusters;
|
|
33919
|
+
|
|
33920
|
+
INSERT INTO transcript_capture_status (
|
|
33921
|
+
agent_id, pending, processing, completed, failed, dead,
|
|
33922
|
+
oldest_pending_at, last_error, last_error_at
|
|
33923
|
+
)
|
|
33924
|
+
SELECT
|
|
33925
|
+
j.agent_id,
|
|
33926
|
+
SUM(j.status = 'pending'),
|
|
33927
|
+
SUM(j.status = 'processing'),
|
|
33928
|
+
SUM(j.status = 'completed'),
|
|
33929
|
+
SUM(j.status = 'failed'),
|
|
33930
|
+
SUM(j.status = 'dead'),
|
|
33931
|
+
MIN(CASE WHEN j.status = 'pending' THEN j.created_at END),
|
|
33932
|
+
(SELECT e2.error FROM transcript_capture_jobs e2
|
|
33933
|
+
WHERE e2.agent_id = j.agent_id AND e2.error IS NOT NULL
|
|
33934
|
+
ORDER BY e2.updated_at DESC LIMIT 1),
|
|
33935
|
+
(SELECT e3.updated_at FROM transcript_capture_jobs e3
|
|
33936
|
+
WHERE e3.agent_id = j.agent_id AND e3.error IS NOT NULL
|
|
33937
|
+
ORDER BY e3.updated_at DESC LIMIT 1)
|
|
33938
|
+
FROM transcript_capture_jobs j
|
|
33939
|
+
GROUP BY j.agent_id;
|
|
33940
|
+
`);
|
|
33941
|
+
}
|
|
33308
33942
|
var MIGRATIONS2 = [
|
|
33309
33943
|
{
|
|
33310
33944
|
version: 1,
|
|
33311
33945
|
name: "baseline",
|
|
33312
|
-
up:
|
|
33946
|
+
up: up139,
|
|
33313
33947
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
33314
33948
|
},
|
|
33315
33949
|
{
|
|
@@ -33387,7 +34021,7 @@ var MIGRATIONS2 = [
|
|
|
33387
34021
|
{
|
|
33388
34022
|
version: 13,
|
|
33389
34023
|
name: "ingestion-tracking",
|
|
33390
|
-
up:
|
|
34024
|
+
up: up1310,
|
|
33391
34025
|
artifacts: {
|
|
33392
34026
|
columns: [
|
|
33393
34027
|
{ table: "memories", column: "source_path" },
|
|
@@ -34394,6 +35028,14 @@ var MIGRATIONS2 = [
|
|
|
34394
35028
|
{ table: "dreaming_passes", column: "head_hash" }
|
|
34395
35029
|
]
|
|
34396
35030
|
}
|
|
35031
|
+
},
|
|
35032
|
+
{
|
|
35033
|
+
version: 138,
|
|
35034
|
+
name: "bounded-status-projections",
|
|
35035
|
+
up: up1382,
|
|
35036
|
+
artifacts: {
|
|
35037
|
+
tables: ["transcript_capture_status", "memories_duplicate_hash_counts", "memories_diagnostics_state"]
|
|
35038
|
+
}
|
|
34397
35039
|
}
|
|
34398
35040
|
];
|
|
34399
35041
|
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-forge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.212.0",
|
|
4
4
|
"description": "Signet connector for ForgeCode - installs MCP, identity, and skills integration",
|
|
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.
|
|
28
|
-
"@signetai/core": "0.
|
|
27
|
+
"@signetai/connector-base": "0.212.0",
|
|
28
|
+
"@signetai/core": "0.212.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|