agentgui 1.0.808 → 1.0.809
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/lib/db-queries.js +18 -12
- package/package.json +1 -1
- package/server.js +6 -0
package/lib/db-queries.js
CHANGED
|
@@ -598,18 +598,24 @@ export function createQueries(db, prep, generateId) {
|
|
|
598
598
|
}
|
|
599
599
|
},
|
|
600
600
|
|
|
601
|
-
cleanup() {
|
|
602
|
-
const thirtyDaysAgo = Date.now() - (30 * 24 * 60 * 60 * 1000);
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
prep('DELETE FROM
|
|
608
|
-
prep('DELETE FROM
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
601
|
+
cleanup() {
|
|
602
|
+
const thirtyDaysAgo = Date.now() - (30 * 24 * 60 * 60 * 1000);
|
|
603
|
+
const sevenDaysAgo = Date.now() - (7 * 24 * 60 * 60 * 1000);
|
|
604
|
+
const now = Date.now();
|
|
605
|
+
|
|
606
|
+
const cleanupStmt = db.transaction(() => {
|
|
607
|
+
prep('DELETE FROM events WHERE created_at < ?').run(thirtyDaysAgo);
|
|
608
|
+
prep('DELETE FROM sessions WHERE completed_at IS NOT NULL AND completed_at < ?').run(thirtyDaysAgo);
|
|
609
|
+
prep('DELETE FROM idempotencyKeys WHERE (created_at + ttl) < ?').run(now);
|
|
610
|
+
// Prune chunks and stream_updates for completed sessions older than 7 days
|
|
611
|
+
prep('DELETE FROM chunks WHERE sessionId IN (SELECT id FROM sessions WHERE completed_at IS NOT NULL AND completed_at < ?)').run(sevenDaysAgo);
|
|
612
|
+
prep('DELETE FROM stream_updates WHERE sessionId IN (SELECT id FROM sessions WHERE completed_at IS NOT NULL AND completed_at < ?)').run(sevenDaysAgo);
|
|
613
|
+
// Clean expired voice cache
|
|
614
|
+
prep('DELETE FROM voice_cache WHERE expires_at <= ?').run(now);
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
cleanupStmt();
|
|
618
|
+
},
|
|
613
619
|
|
|
614
620
|
setIdempotencyKey(key, value) {
|
|
615
621
|
const now = Date.now();
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -3171,6 +3171,12 @@ function onServerReady() {
|
|
|
3171
3171
|
recoverStaleSessions();
|
|
3172
3172
|
warmAssetCache();
|
|
3173
3173
|
|
|
3174
|
+
// Run DB cleanup on startup and every 6 hours
|
|
3175
|
+
try { queries.cleanup(); console.log('[cleanup] Initial DB cleanup complete'); } catch (e) { console.error('[cleanup] Error:', e.message); }
|
|
3176
|
+
setInterval(() => {
|
|
3177
|
+
try { queries.cleanup(); console.log('[cleanup] Scheduled DB cleanup complete'); } catch (e) { console.error('[cleanup] Error:', e.message); }
|
|
3178
|
+
}, 6 * 60 * 60 * 1000);
|
|
3179
|
+
|
|
3174
3180
|
try {
|
|
3175
3181
|
jsonlWatcher = new JsonlWatcher({ broadcastSync, queries, ownedSessionIds });
|
|
3176
3182
|
jsonlWatcher.start();
|