@morlay/session-rdb 0.0.12 → 0.0.13
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/artifact.d.mts +64 -0
- package/dist/artifact.mjs +3 -0
- package/dist/import-D2vUnUZe.mjs +438 -0
- package/dist/import.d.mts +24 -0
- package/dist/import.mjs +2 -0
- package/dist/index-uUvn6gYp.d.mts +111 -0
- package/dist/index.d.mts +3 -203
- package/dist/index.mjs +7 -1571
- package/dist/invariant.d.mts +1 -2
- package/dist/invariant.mjs +0 -2
- package/dist/magic-string.es-BWtG0AyA.mjs +1017 -0
- package/dist/schema-B-8G4lWc.mjs +852 -0
- package/dist/schema-CFXZURX7.d.mts +116 -0
- package/dist/sqlite-DIXY-dFZ.mjs +356 -0
- package/dist/storage.d.mts +44 -0
- package/dist/storage.mjs +3 -0
- package/dist/testing.d.mts +31 -0
- package/dist/testing.mjs +16051 -0
- package/package.json +19 -2
- package/src/artifact.ts +4 -0
- package/src/index.ts +4 -0
- package/src/log.ts +86 -0
- package/src/storage.ts +5 -0
- package/src/testing/contract.ts +562 -0
- package/src/testing/coordinator-contract.ts +1723 -0
- package/src/testing/helpers.ts +20 -0
- package/src/testing.ts +12 -0
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/invariant.d.mts.map +0 -1
- package/dist/invariant.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,203 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { BranchAnchorMode, BranchBoundary, ForkFromOptions, SessionBranch, SessionBranchProvider } from "@morlay/session-branch";
|
|
5
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
6
|
-
//#region src/backend.d.ts
|
|
7
|
-
interface SessionRow {
|
|
8
|
-
fSessionId: string;
|
|
9
|
-
fHeadEventId: string;
|
|
10
|
-
fHeadSequence: number;
|
|
11
|
-
fVersion: number;
|
|
12
|
-
fCreatedAt: number;
|
|
13
|
-
fCwd: string | null;
|
|
14
|
-
fParentSession: string | null;
|
|
15
|
-
fSeedLength: number | null;
|
|
16
|
-
fOrigin: string | null;
|
|
17
|
-
fDelegationDepth: number | null;
|
|
18
|
-
fIncarnation: string;
|
|
19
|
-
fRevision: number;
|
|
20
|
-
}
|
|
21
|
-
interface EventInsert {
|
|
22
|
-
fEventId: string;
|
|
23
|
-
fParentId: string;
|
|
24
|
-
fType: string;
|
|
25
|
-
fKind: string;
|
|
26
|
-
fRole: string;
|
|
27
|
-
fName: string;
|
|
28
|
-
fActionId: string;
|
|
29
|
-
fEncoding: string;
|
|
30
|
-
fData: string;
|
|
31
|
-
fCreatedAt: number;
|
|
32
|
-
}
|
|
33
|
-
interface EventRow {
|
|
34
|
-
fEventId: string;
|
|
35
|
-
fSequence: number;
|
|
36
|
-
fOriginalSeq: number;
|
|
37
|
-
fType: string;
|
|
38
|
-
fKind: string;
|
|
39
|
-
fRole: string;
|
|
40
|
-
fName: string;
|
|
41
|
-
fActionId: string;
|
|
42
|
-
fCreatedAt: number;
|
|
43
|
-
fData: string;
|
|
44
|
-
fSurfaceOp: string | null;
|
|
45
|
-
}
|
|
46
|
-
interface BackendTx {
|
|
47
|
-
upsertSession(storage: SessionStorageMetadata, incarnation: string): Promise<void>;
|
|
48
|
-
getHead(id: SessionId): Promise<Pick<SessionRow, "fHeadEventId" | "fHeadSequence">>;
|
|
49
|
-
getSeedLength(id: SessionId): Promise<number | null>;
|
|
50
|
-
updateSeedLength(id: SessionId, seedLength: number): Promise<void>;
|
|
51
|
-
insertEvents(events: EventInsert[]): Promise<void>;
|
|
52
|
-
insertBridges(rows: Array<{
|
|
53
|
-
fSessionId: SessionId;
|
|
54
|
-
fEventId: string;
|
|
55
|
-
fSequence: number;
|
|
56
|
-
fOriginalSeq: number;
|
|
57
|
-
fSurfaceOp: string | null;
|
|
58
|
-
}>): Promise<void>;
|
|
59
|
-
updateHead(id: SessionId, headEventId: string, headSequence: number): Promise<void>;
|
|
60
|
-
bumpRevision(id: SessionId): Promise<void>;
|
|
61
|
-
deleteBridgeTail(id: SessionId, fromSequence: number): Promise<void>;
|
|
62
|
-
getPrevBridge(id: SessionId, sequence: number): Promise<{
|
|
63
|
-
fEventId: string;
|
|
64
|
-
fSequence: number;
|
|
65
|
-
} | undefined>;
|
|
66
|
-
getLastBridge(id: SessionId): Promise<{
|
|
67
|
-
fEventId: string;
|
|
68
|
-
fSequence: number;
|
|
69
|
-
} | undefined>;
|
|
70
|
-
}
|
|
71
|
-
interface Backend {
|
|
72
|
-
readonly kind: "sqlite" | "postgres";
|
|
73
|
-
readonly storeIdentity: string;
|
|
74
|
-
open(): Promise<void>;
|
|
75
|
-
getSession(id: SessionId): Promise<SessionRow | undefined>;
|
|
76
|
-
getSeqMapRows(id: SessionId): Promise<Array<{
|
|
77
|
-
fSequence: number;
|
|
78
|
-
fOriginalSeq: number;
|
|
79
|
-
}>>;
|
|
80
|
-
getEventRows(id: SessionId, fromSequence?: number): Promise<EventRow[]>;
|
|
81
|
-
listSessions(): Promise<SessionRow[]>;
|
|
82
|
-
transaction<T>(fn: (tx: BackendTx) => Promise<T>): Promise<T>;
|
|
83
|
-
close(): Promise<void>;
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/write-guard.d.ts
|
|
87
|
-
declare class WriteGuard {
|
|
88
|
-
private readonly headSeqs;
|
|
89
|
-
confirmHead(id: SessionId, head: number): void;
|
|
90
|
-
assertNoConcurrentWriter(id: SessionId, storedHead: number): void;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/schema.d.ts
|
|
94
|
-
declare const SCHEMA_VERSION = 2;
|
|
95
|
-
declare const EPHEMERAL_EVENT_TYPES: readonly ["assistant/chunk"];
|
|
96
|
-
type JournalMode = "wal" | "delete" | "truncate" | "persist";
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/branch.d.ts
|
|
99
|
-
declare function locateTurnEnd(events: readonly SessionEvent[], atSeq?: number, mode?: BranchAnchorMode): number;
|
|
100
|
-
interface LiveSessionHooks {
|
|
101
|
-
getSession(id: SessionId): Session | undefined;
|
|
102
|
-
getAgent(id: SessionId): LiveAgentLike | undefined;
|
|
103
|
-
flush(session: Session): Promise<boolean>;
|
|
104
|
-
setCoordinatorCursor(id: SessionId, cursor: number): void;
|
|
105
|
-
setCoordinatorState(id: SessionId, cursor: number, meta: SessionHeader): void;
|
|
106
|
-
setCoordinatorSeedLength(id: SessionId, seedLength: number): void;
|
|
107
|
-
}
|
|
108
|
-
interface LiveAgentLike {
|
|
109
|
-
session: Session;
|
|
110
|
-
requestHeaderLogged?: boolean;
|
|
111
|
-
}
|
|
112
|
-
declare class SessionBranchRdbProvider implements SessionBranchProvider {
|
|
113
|
-
private readonly persistence;
|
|
114
|
-
private readonly live;
|
|
115
|
-
readonly name = "session-rdb";
|
|
116
|
-
constructor(persistence: SessionPersistenceRdb, live?: LiveSessionHooks);
|
|
117
|
-
readBranchPrefix(id: SessionId, atSeq?: number, mode?: BranchAnchorMode, signal?: AbortSignal): Promise<BranchBoundary>;
|
|
118
|
-
readRawEvents(id: SessionId, signal?: AbortSignal): Promise<{
|
|
119
|
-
meta: SessionHeader;
|
|
120
|
-
events: readonly SessionEvent[];
|
|
121
|
-
}>;
|
|
122
|
-
forkFrom(sourceId: SessionId, options?: ForkFromOptions, signal?: AbortSignal): Promise<SessionId>;
|
|
123
|
-
rewind(id: SessionId, toBoundary: number, signal?: AbortSignal): Promise<SessionPersistenceSnapshot>;
|
|
124
|
-
}
|
|
125
|
-
declare class SessionBranchRdb extends SessionBranch {
|
|
126
|
-
static inject: string[];
|
|
127
|
-
constructor(ctx: import("@deepseek-ai/cordis").Context);
|
|
128
|
-
private readonly provider;
|
|
129
|
-
readBranchPrefix(id: SessionId, atSeq?: number, mode?: BranchAnchorMode, signal?: AbortSignal): Promise<BranchBoundary>;
|
|
130
|
-
readRawEvents(id: SessionId, signal?: AbortSignal): Promise<{
|
|
131
|
-
meta: SessionHeader;
|
|
132
|
-
events: readonly SessionEvent[];
|
|
133
|
-
}>;
|
|
134
|
-
forkFrom(sourceId: SessionId, options?: ForkFromOptions, signal?: AbortSignal): Promise<SessionId>;
|
|
135
|
-
rewind(id: SessionId, toBoundary: number, signal?: AbortSignal): Promise<SessionPersistenceSnapshot>;
|
|
136
|
-
syncLiveCursor(sessionId: SessionId): void;
|
|
137
|
-
timeline(sessionId: SessionId, signal?: AbortSignal): Promise<import("@morlay/session-branch").BranchTimeline>;
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/index.d.ts
|
|
141
|
-
interface SessionPersistenceRdbInternals {
|
|
142
|
-
readonly backend: Backend;
|
|
143
|
-
readonly writeGuard: WriteGuard;
|
|
144
|
-
create(meta: SessionHeader, inheritedEventCount?: number): Promise<void>;
|
|
145
|
-
append(id: SessionId, events: readonly SessionEvent[]): Promise<void>;
|
|
146
|
-
load(id: SessionId): Promise<import("@deepseek-ai/dsh-session-persistence").SessionInspection>;
|
|
147
|
-
inspect(id: SessionId, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").SessionInspection>;
|
|
148
|
-
readFrom(id: SessionId, fromSeq: number, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").SessionEventSuffix>;
|
|
149
|
-
listSnapshots(signal?: AbortSignal): Promise<SessionPersistenceSnapshot[]>;
|
|
150
|
-
readStoredRevision(id: SessionId, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").SessionPersistenceRevision | undefined>;
|
|
151
|
-
registerReuseEventIds(childId: SessionId, map: ReadonlyMap<number, string>): void;
|
|
152
|
-
}
|
|
153
|
-
type Config = {
|
|
154
|
-
type: "sqlite";
|
|
155
|
-
path: string;
|
|
156
|
-
journalMode?: JournalMode;
|
|
157
|
-
busyTimeout?: number;
|
|
158
|
-
} | {
|
|
159
|
-
type: "postgres";
|
|
160
|
-
connectionString: string;
|
|
161
|
-
schema?: string;
|
|
162
|
-
};
|
|
163
|
-
declare class SessionPersistenceRdb extends SessionPersistence implements PersistenceBackend<number> {
|
|
164
|
-
config: Config;
|
|
165
|
-
static inject: string[];
|
|
166
|
-
static Config: z<Config>;
|
|
167
|
-
static readonly settingsNs = "session-rdb";
|
|
168
|
-
readonly name = "session-rdb";
|
|
169
|
-
readonly supportsRawArtifacts = true;
|
|
170
|
-
readRaw(id: SessionId, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").SessionRawArtifact | undefined>;
|
|
171
|
-
private readonly backend;
|
|
172
|
-
private storeIdentity;
|
|
173
|
-
private readonly ready;
|
|
174
|
-
private readonly coordinator;
|
|
175
|
-
private readonly writeGuard;
|
|
176
|
-
private readonly reuseEventIds;
|
|
177
|
-
constructor(ctx: Context, config: Config, injectedBackend?: Backend);
|
|
178
|
-
private init;
|
|
179
|
-
locate(_meta: SessionHeader): SessionLocation | undefined;
|
|
180
|
-
create(meta: SessionHeader, inheritedEventCount?: number): Promise<void>;
|
|
181
|
-
append(id: SessionId, events: readonly SessionEvent[]): Promise<void>;
|
|
182
|
-
load(id: SessionId): Promise<import("@deepseek-ai/dsh-session-persistence").SessionInspection>;
|
|
183
|
-
inspect(id: SessionId, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").SessionInspection>;
|
|
184
|
-
readFrom(id: SessionId, fromSeq: number, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").SessionEventSuffix>;
|
|
185
|
-
borrowSession(id: SessionId, signal?: AbortSignal): Promise<import("@deepseek-ai/dsh-session-persistence").BorrowedSessionSource>;
|
|
186
|
-
loadStored(id: SessionId, signal?: AbortSignal): Promise<StoredPrefix<number> | undefined>;
|
|
187
|
-
loadStoredFrom(id: SessionId, fromSeq: number, signal?: AbortSignal): Promise<StoredSuffix | undefined>;
|
|
188
|
-
private readPrefix;
|
|
189
|
-
readStoredRevision(id: SessionId, signal?: AbortSignal): Promise<SessionPersistenceRevision | undefined>;
|
|
190
|
-
private readLog;
|
|
191
|
-
appendBatch(storage: SessionStorageMetadata, events: readonly SessionEvent[], _isMaterialized: boolean): Promise<void>;
|
|
192
|
-
commitRepair(storage: SessionStorageMetadata, tornMarker: number | undefined, closers: readonly SessionEvent[]): Promise<void>;
|
|
193
|
-
list(signal?: AbortSignal): Promise<SessionHeader[]>;
|
|
194
|
-
listSnapshots(signal?: AbortSignal): Promise<Array<SessionPersistenceSnapshot & {
|
|
195
|
-
inheritedEventCount: number;
|
|
196
|
-
}>>;
|
|
197
|
-
close(): Promise<void>;
|
|
198
|
-
registerReuseEventIds(childId: SessionId, map: ReadonlyMap<number, string>): void;
|
|
199
|
-
internals(): SessionPersistenceRdbInternals;
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
export { Config, EPHEMERAL_EVENT_TYPES, SCHEMA_VERSION, SessionBranchRdb, SessionBranchRdbProvider, SessionPersistenceRdb, SessionPersistenceRdb as default, SessionPersistenceRdbInternals, locateTurnEnd };
|
|
203
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { n as EPHEMERAL_EVENT_TYPES, s as SCHEMA_VERSION } from "./schema-CFXZURX7.mjs";
|
|
2
|
+
import { a as SessionBranchRdbProvider, i as SessionBranchRdb, n as SessionPersistenceRdb, o as locateTurnEnd, r as SessionPersistenceRdbInternals, t as Config } from "./index-uUvn6gYp.mjs";
|
|
3
|
+
export { Config, EPHEMERAL_EVENT_TYPES, SCHEMA_VERSION, SessionBranchRdb, SessionBranchRdbProvider, SessionPersistenceRdb, SessionPersistenceRdb as default, SessionPersistenceRdbInternals, locateTurnEnd };
|