@estebanforge/pi-antigravity-bridge 1.13.3 → 1.15.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/CHANGELOG.md +27 -0
- package/README.md +2 -2
- package/extensions/index.ts +55 -18
- package/package.json +2 -2
- package/src/acp/driver.ts +59 -1
- package/src/acp/history-sync.ts +221 -0
- package/src/ask-tool.ts +3 -3
- package/src/bridge-catalog.ts +23 -3
- package/src/config.ts +41 -5
- package/src/driver-types.ts +34 -0
- package/src/history-projection.ts +188 -0
- package/src/history-sync.ts +299 -0
- package/src/models.ts +16 -11
- package/src/provider.ts +456 -59
- package/src/sessions.ts +12 -0
package/src/sessions.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import fs from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { bridgeDir } from "./config.js";
|
|
14
|
+
import { narrowSessionSync, type SessionSyncState } from "./history-sync.js";
|
|
14
15
|
|
|
15
16
|
function defaultStorePath(): string {
|
|
16
17
|
return path.join(bridgeDir(), "sessions.json");
|
|
@@ -35,6 +36,11 @@ export interface AgySession {
|
|
|
35
36
|
* builder neither re-injects that summary nor restarts its window on
|
|
36
37
|
* it. Optional/absent when no compaction existed at write time. */
|
|
37
38
|
digestSummaryId?: string;
|
|
39
|
+
/** History-sync protocol journal (handoff = "sync"). Absent on digest
|
|
40
|
+
* records and on records predating the sync mode. Zeroed digest
|
|
41
|
+
* watermark fields accompany it (the sync persist contract), so a
|
|
42
|
+
* later flip back to digest re-offers the backlog once, safely. */
|
|
43
|
+
sync?: SessionSyncState;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
type StoreMap = Record<string, AgySession>;
|
|
@@ -56,12 +62,17 @@ function narrowStoreMap(parsed: unknown): StoreMap {
|
|
|
56
62
|
const mc = (value as { lastMessageCount?: unknown }).lastMessageCount;
|
|
57
63
|
const db = (value as { digestBoundary?: unknown }).digestBoundary;
|
|
58
64
|
const dci = (value as { digestSummaryId?: unknown }).digestSummaryId;
|
|
65
|
+
// Malformed sync journals narrow to an invalid-sync-state marker
|
|
66
|
+
// (never throws; self-heals via a named rebuild), so the field is
|
|
67
|
+
// kept but flagged.
|
|
68
|
+
const sync = narrowSessionSync((value as { sync?: unknown }).sync);
|
|
59
69
|
clean[key] = {
|
|
60
70
|
conversationId,
|
|
61
71
|
lastStepIdx: typeof idx === "number" && Number.isFinite(idx) ? idx : -1,
|
|
62
72
|
lastMessageCount: typeof mc === "number" && Number.isFinite(mc) ? mc : 0,
|
|
63
73
|
...(typeof db === "string" ? { digestBoundary: db } : {}),
|
|
64
74
|
...(typeof dci === "string" ? { digestSummaryId: dci } : {}),
|
|
75
|
+
...(sync ? { sync } : {}),
|
|
65
76
|
};
|
|
66
77
|
}
|
|
67
78
|
return clean;
|
|
@@ -105,6 +116,7 @@ export class SessionStore {
|
|
|
105
116
|
lastMessageCount: s.lastMessageCount ?? 0,
|
|
106
117
|
...(s.digestBoundary !== undefined ? { digestBoundary: s.digestBoundary } : {}),
|
|
107
118
|
...(s.digestSummaryId !== undefined ? { digestSummaryId: s.digestSummaryId } : {}),
|
|
119
|
+
...(s.sync !== undefined ? { sync: structuredClone(s.sync) } : {}),
|
|
108
120
|
};
|
|
109
121
|
}
|
|
110
122
|
|