gestalt-mobile 0.60.1 → 0.60.2
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.
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
export const eventRetentionMs = 48 * 60 * 60 * 1000;
|
|
7
|
+
/** Idle turns, recovery and attention do not close a durable session. */
|
|
8
|
+
export const closedSessionIds = `SELECT id FROM relay_sessions
|
|
9
|
+
WHERE state IN ('stopped', 'released') AND desired_state = 'stopped'
|
|
10
|
+
AND active_turn_id IS NULL`;
|
|
7
11
|
export function eventRetentionCutoff(occurredAt) {
|
|
8
12
|
const timestamp = Date.parse(occurredAt);
|
|
9
13
|
return Number.isFinite(timestamp) ? new Date(timestamp - eventRetentionMs).toISOString() : null;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { boundedAttentionReport } from '../../../shared/contracts/attention-report.js';
|
|
7
|
-
import { eventRetentionCutoff } from './retention.js';
|
|
7
|
+
import { closedSessionIds, eventRetentionCutoff } from './retention.js';
|
|
8
8
|
import { replayOrResync } from '../events/replay.js';
|
|
9
9
|
import { mcpStartupActivity, parseMcpStartupStatus, } from '../../../shared/contracts/mcp-startup-failure.js';
|
|
10
10
|
export const autopilotAuditEventTypes = [
|
|
@@ -91,15 +91,15 @@ export class SqliteEventJournal {
|
|
|
91
91
|
.run(sessionId);
|
|
92
92
|
if (this.retain !== undefined) {
|
|
93
93
|
this.db
|
|
94
|
-
.prepare(
|
|
94
|
+
.prepare(`DELETE FROM session_events WHERE session_id = ? AND session_id IN (${closedSessionIds}) AND sequence NOT IN (SELECT sequence FROM session_events WHERE session_id = ? ORDER BY sequence DESC LIMIT ?)`)
|
|
95
95
|
.run(sessionId, sessionId, this.retain);
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
const cutoff = eventRetentionCutoff(occurredAt);
|
|
99
99
|
if (cutoff)
|
|
100
100
|
this.db
|
|
101
|
-
.prepare(
|
|
102
|
-
.run(
|
|
101
|
+
.prepare(`DELETE FROM session_events WHERE session_id IN (${closedSessionIds}) AND julianday(occurred_at) < julianday(?)`)
|
|
102
|
+
.run(cutoff);
|
|
103
103
|
}
|
|
104
104
|
const event = { sessionId, sequence: row.sequence, type, occurredAt, payload };
|
|
105
105
|
this.db.exec('COMMIT');
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
+
import { closedSessionIds } from './retention.js';
|
|
6
7
|
export const transportLimit = 2048;
|
|
7
8
|
export const transportRetentionMs = 48 * 60 * 60 * 1000;
|
|
8
9
|
/** Separate from the replay journal: recording transport must never generate transport traffic. */
|
|
@@ -21,7 +22,7 @@ export class SqliteTransportDiagnostics {
|
|
|
21
22
|
.prepare('INSERT INTO chat_transport_diagnostics(session_id, occurred_at, metadata_json) VALUES (?, ?, ?)')
|
|
22
23
|
.run(sessionId, now, JSON.stringify(fields));
|
|
23
24
|
this.database
|
|
24
|
-
.prepare(
|
|
25
|
+
.prepare(`DELETE FROM chat_transport_diagnostics WHERE session_id IN (${closedSessionIds}) AND (occurred_at < ? OR id <= COALESCE((SELECT id FROM chat_transport_diagnostics WHERE session_id IN (${closedSessionIds}) ORDER BY id DESC LIMIT 1 OFFSET ?), 0))`)
|
|
25
26
|
.run(now - transportRetentionMs, transportLimit);
|
|
26
27
|
}
|
|
27
28
|
catch {
|
|
@@ -35,14 +36,15 @@ export function readTransportDiagnostics(database, sessionId, now = Date.now())
|
|
|
35
36
|
.get());
|
|
36
37
|
const rows = available
|
|
37
38
|
? database
|
|
38
|
-
.prepare(
|
|
39
|
+
.prepare(`SELECT id, occurred_at AS occurredAt, metadata_json FROM chat_transport_diagnostics WHERE session_id = ? AND (session_id NOT IN (${closedSessionIds}) OR occurred_at >= ?) ORDER BY id DESC LIMIT ?`)
|
|
39
40
|
.all(sessionId, now - transportRetentionMs, transportLimit)
|
|
40
41
|
.reverse()
|
|
41
42
|
: [];
|
|
42
43
|
return {
|
|
43
44
|
available,
|
|
44
45
|
coverage: 'retained-only',
|
|
45
|
-
|
|
46
|
+
closedSessionRecordLimit: transportLimit,
|
|
47
|
+
exportRecordLimit: transportLimit,
|
|
46
48
|
retentionMs: transportRetentionMs,
|
|
47
49
|
records: rows.flatMap((row) => {
|
|
48
50
|
try {
|