meridian-sdk 1.2.0 → 1.3.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -0
  3. package/dist/agents.d.ts +143 -8
  4. package/dist/agents.d.ts.map +1 -1
  5. package/dist/agents.js +141 -14
  6. package/dist/agents.js.map +1 -1
  7. package/dist/client.d.ts +35 -2
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +45 -3
  10. package/dist/client.js.map +1 -1
  11. package/dist/conflict/types.d.ts +54 -0
  12. package/dist/conflict/types.d.ts.map +1 -0
  13. package/dist/conflict/types.js +9 -0
  14. package/dist/conflict/types.js.map +1 -0
  15. package/dist/crdt/rga.d.ts +20 -4
  16. package/dist/crdt/rga.d.ts.map +1 -1
  17. package/dist/crdt/rga.js +42 -6
  18. package/dist/crdt/rga.js.map +1 -1
  19. package/dist/crdt/tree.d.ts +128 -0
  20. package/dist/crdt/tree.d.ts.map +1 -0
  21. package/dist/crdt/tree.js +304 -0
  22. package/dist/crdt/tree.js.map +1 -0
  23. package/dist/index.d.ts +13 -4
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +10 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/schema.d.ts +63 -3
  28. package/dist/schema.d.ts.map +1 -1
  29. package/dist/schema.js +18 -1
  30. package/dist/schema.js.map +1 -1
  31. package/dist/sync/delta.d.ts +35 -0
  32. package/dist/sync/delta.d.ts.map +1 -1
  33. package/dist/sync/delta.js +4 -0
  34. package/dist/sync/delta.js.map +1 -1
  35. package/dist/undo/UndoManager.d.ts +74 -0
  36. package/dist/undo/UndoManager.d.ts.map +1 -0
  37. package/dist/undo/UndoManager.js +318 -0
  38. package/dist/undo/UndoManager.js.map +1 -0
  39. package/dist/undo/types.d.ts +63 -0
  40. package/dist/undo/types.d.ts.map +1 -0
  41. package/dist/undo/types.js +9 -0
  42. package/dist/undo/types.js.map +1 -0
  43. package/dist/utils/fractional.d.ts +78 -0
  44. package/dist/utils/fractional.d.ts.map +1 -0
  45. package/dist/utils/fractional.js +159 -0
  46. package/dist/utils/fractional.js.map +1 -0
  47. package/dist/validation/index.d.ts +107 -0
  48. package/dist/validation/index.d.ts.map +1 -0
  49. package/dist/validation/index.js +123 -0
  50. package/dist/validation/index.js.map +1 -0
  51. package/package.json +1 -1
  52. package/src/agents.ts +224 -15
  53. package/src/client.ts +52 -3
  54. package/src/conflict/types.ts +60 -0
  55. package/src/crdt/rga.ts +46 -7
  56. package/src/crdt/tree.ts +367 -0
  57. package/src/index.ts +31 -1
  58. package/src/schema.ts +24 -1
  59. package/src/sync/delta.ts +30 -1
  60. package/src/undo/UndoManager.ts +369 -0
  61. package/src/undo/types.ts +74 -0
  62. package/src/utils/fractional.ts +166 -0
  63. package/src/validation/index.ts +137 -0
  64. package/test/conflict.test.ts +242 -0
  65. package/test/fractional.test.ts +127 -0
  66. package/test/undo.test.ts +272 -0
  67. package/test/validation.test.ts +137 -0
@@ -0,0 +1,367 @@
1
+ import { Chunk, Effect, Stream } from "effect";
2
+ import { encode } from "../codec.js";
3
+ import type { WsTransport } from "../transport/websocket.js";
4
+ import type { TreeDelta, TreeNodeValue } from "../sync/delta.js";
5
+ import type { ConflictEvent, LwwOverwriteEvent, MoveDiscardedEvent, MoveReorderedEvent } from "../conflict/types.js";
6
+ import type { DiscardedMove } from "../sync/delta.js";
7
+ import { type CrdtValidator, runValidator } from "../validation/index.js";
8
+
9
+ /**
10
+ * Low-level handle for a TreeCRDT — a convergent hierarchical tree.
11
+ *
12
+ * Obtained via `MeridianClient.tree()`. Supports add, move, update, and delete
13
+ * operations on tree nodes. Concurrent moves use Kleppmann et al. (2021)
14
+ * move semantics — cycles are prevented, all replicas converge.
15
+ *
16
+ * Node IDs are returned by `addNode()` as opaque strings of the form
17
+ * "wall_ms:logical:node_id" matching the Rust HLC serialization.
18
+ */
19
+ export interface TreeNodeMeta {
20
+ parentId: string | null;
21
+ position: string;
22
+ /** HLC string "wall_ms:logical:node_id" of the last UpdateNode op on this node. */
23
+ updatedAt: string;
24
+ value: string;
25
+ }
26
+
27
+ /** Maximum number of conflict events retained in the in-memory log. */
28
+ const CONFLICT_LOG_CAP = 200;
29
+
30
+ export class TreeHandle {
31
+ private roots: TreeNodeValue[] = [];
32
+ private readonly crdtId: string;
33
+ private readonly clientId: number;
34
+ private readonly transport: WsTransport;
35
+ private readonly validator: CrdtValidator | undefined;
36
+ private readonly listeners = new Set<(value: { roots: TreeNodeValue[] }) => void>();
37
+ private readonly conflictListeners = new Set<(event: ConflictEvent) => void>();
38
+ private readonly conflictHistory: ConflictEvent[] = [];
39
+ private opCounter = 0;
40
+ /** Tracks parent, position, updatedAt, and value per node for undo support. */
41
+ private readonly nodeMetaMap = new Map<string, TreeNodeMeta>();
42
+
43
+ constructor(opts: {
44
+ crdtId: string;
45
+ clientId: number;
46
+ transport: WsTransport;
47
+ validator?: CrdtValidator;
48
+ }) {
49
+ this.crdtId = opts.crdtId;
50
+ this.clientId = opts.clientId;
51
+ this.transport = opts.transport;
52
+ this.validator = opts.validator;
53
+ }
54
+
55
+ /** The CRDT key this handle is bound to. */
56
+ get id(): string { return this.crdtId; }
57
+
58
+ /** Returns the current tree value. */
59
+ value(): { roots: TreeNodeValue[] } {
60
+ return { roots: this.roots };
61
+ }
62
+
63
+ /**
64
+ * Registers a listener called whenever the tree changes.
65
+ *
66
+ * @returns An unsubscribe function.
67
+ */
68
+ onChange(listener: (value: { roots: TreeNodeValue[] }) => void): () => void {
69
+ this.listeners.add(listener);
70
+ return () => { this.listeners.delete(listener); };
71
+ }
72
+
73
+ /** Returns an Effect Stream that emits the tree on every change. */
74
+ stream(): Stream.Stream<{ roots: TreeNodeValue[] }, never, never> {
75
+ return Stream.async<{ roots: TreeNodeValue[] }>((emit) => {
76
+ const unsub = this.onChange((value) => { void emit(Effect.succeed(Chunk.of(value))); });
77
+ return Effect.sync(unsub);
78
+ });
79
+ }
80
+
81
+ /**
82
+ * Adds a new node to the tree.
83
+ *
84
+ * @param parentId - ID of the parent node, or null for a root-level node.
85
+ * @param position - Fractional index string for sibling ordering (e.g. "a0", "b0").
86
+ * @param value - String content of the node.
87
+ * @param ttlMs - Optional TTL.
88
+ * @returns The new node's ID as a string.
89
+ */
90
+ addNode(parentId: string | null, position: string, value: string, ttlMs?: number): string {
91
+ runValidator(this.validator, value);
92
+ const wallMs = Date.now();
93
+ const logical = this.opCounter++;
94
+ const id = { wall_ms: wallMs, logical, node_id: this.clientId };
95
+ const idStr = `${wallMs}:${logical}:${this.clientId}`;
96
+
97
+ // Optimistic meta update — allows UndoManager to read state immediately.
98
+ this.nodeMetaMap.set(idStr, {
99
+ parentId,
100
+ position,
101
+ updatedAt: idStr,
102
+ value,
103
+ });
104
+
105
+ const op = encode({
106
+ Tree: {
107
+ AddNode: {
108
+ id,
109
+ parent_id: parentId !== null ? this.parseHlc(parentId) : null,
110
+ position,
111
+ value,
112
+ },
113
+ },
114
+ });
115
+
116
+ this.transport.send({
117
+ Op: {
118
+ crdt_id: this.crdtId,
119
+ op_bytes: op,
120
+ ...(ttlMs !== undefined && { ttl_ms: ttlMs }),
121
+ },
122
+ });
123
+
124
+ return idStr;
125
+ }
126
+
127
+ /**
128
+ * Moves a node to a new parent and/or position.
129
+ *
130
+ * @param nodeId - ID of the node to move.
131
+ * @param newParentId - New parent node ID, or null for root level.
132
+ * @param newPosition - New fractional index position.
133
+ * @param ttlMs - Optional TTL.
134
+ */
135
+ moveNode(nodeId: string, newParentId: string | null, newPosition: string, ttlMs?: number): void {
136
+ const wallMs = Date.now();
137
+ const logical = this.opCounter++;
138
+ const opId = { wall_ms: wallMs, logical, node_id: this.clientId };
139
+
140
+ // Optimistic meta update.
141
+ const existing = this.nodeMetaMap.get(nodeId);
142
+ if (existing !== undefined) {
143
+ this.nodeMetaMap.set(nodeId, { ...existing, parentId: newParentId, position: newPosition });
144
+ }
145
+
146
+ const op = encode({
147
+ Tree: {
148
+ MoveNode: {
149
+ op_id: opId,
150
+ node_id: this.parseHlc(nodeId),
151
+ new_parent_id: newParentId !== null ? this.parseHlc(newParentId) : null,
152
+ new_position: newPosition,
153
+ },
154
+ },
155
+ });
156
+
157
+ this.transport.send({
158
+ Op: {
159
+ crdt_id: this.crdtId,
160
+ op_bytes: op,
161
+ ...(ttlMs !== undefined && { ttl_ms: ttlMs }),
162
+ },
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Updates the value of an existing node (LWW — last write wins).
168
+ *
169
+ * @param nodeId - ID of the node to update.
170
+ * @param value - New string value.
171
+ * @param ttlMs - Optional TTL.
172
+ */
173
+ updateNode(nodeId: string, value: string, ttlMs?: number): void {
174
+ runValidator(this.validator, value);
175
+ const wallMs = Date.now();
176
+ const logical = this.opCounter++;
177
+ const updatedAt = { wall_ms: wallMs, logical, node_id: this.clientId };
178
+ const updatedAtStr = `${wallMs}:${logical}:${this.clientId}`;
179
+
180
+ // Optimistic meta update.
181
+ const existing = this.nodeMetaMap.get(nodeId);
182
+ if (existing !== undefined) {
183
+ this.nodeMetaMap.set(nodeId, { ...existing, value, updatedAt: updatedAtStr });
184
+ }
185
+
186
+ const op = encode({
187
+ Tree: {
188
+ UpdateNode: {
189
+ id: this.parseHlc(nodeId),
190
+ value,
191
+ updated_at: updatedAt,
192
+ },
193
+ },
194
+ });
195
+
196
+ this.transport.send({
197
+ Op: {
198
+ crdt_id: this.crdtId,
199
+ op_bytes: op,
200
+ ...(ttlMs !== undefined && { ttl_ms: ttlMs }),
201
+ },
202
+ });
203
+ }
204
+
205
+ /**
206
+ * Tombstone-deletes a node. Children are preserved in the tree structure
207
+ * but become invisible until the node is undeleted via a concurrent move.
208
+ *
209
+ * @param nodeId - ID of the node to delete.
210
+ * @param ttlMs - Optional TTL.
211
+ */
212
+ deleteNode(nodeId: string, ttlMs?: number): void {
213
+ const op = encode({
214
+ Tree: {
215
+ DeleteNode: {
216
+ id: this.parseHlc(nodeId),
217
+ },
218
+ },
219
+ });
220
+
221
+ this.transport.send({
222
+ Op: {
223
+ crdt_id: this.crdtId,
224
+ op_bytes: op,
225
+ ...(ttlMs !== undefined && { ttl_ms: ttlMs }),
226
+ },
227
+ });
228
+ }
229
+
230
+ /**
231
+ * Returns the last-known metadata for a node (parent, position, value, updatedAt).
232
+ * Used by UndoManager to capture pre-op state before mutations.
233
+ */
234
+ getNodeMeta(nodeId: string): TreeNodeMeta | undefined {
235
+ return this.nodeMetaMap.get(nodeId);
236
+ }
237
+
238
+ /**
239
+ * Registers a listener called whenever a conflict is detected in an incoming delta.
240
+ * Conflicts include concurrent move resolutions, LWW overwrites, and discarded moves.
241
+ *
242
+ * @returns An unsubscribe function.
243
+ */
244
+ onConflict(listener: (event: ConflictEvent) => void): () => void {
245
+ this.conflictListeners.add(listener);
246
+ return () => { this.conflictListeners.delete(listener); };
247
+ }
248
+
249
+ /**
250
+ * Returns the last up-to-200 conflict events in chronological order.
251
+ * Useful for rendering an audit log or "track changes" UI.
252
+ */
253
+ conflictLog(): readonly ConflictEvent[] {
254
+ return this.conflictHistory;
255
+ }
256
+
257
+ /** Apply a delta received from the server. Replaces local state with authoritative tree. */
258
+ applyDelta(delta: TreeDelta): void {
259
+ this.detectConflicts(delta.roots, null, delta.discarded_moves ?? []);
260
+ this.roots = delta.roots;
261
+ this.rebuildMetaMap(delta.roots, null);
262
+ this.emit();
263
+ }
264
+
265
+ /** Emit a conflict event to all listeners and append to history. */
266
+ private emitConflict(event: ConflictEvent): void {
267
+ if (this.conflictHistory.length >= CONFLICT_LOG_CAP) {
268
+ this.conflictHistory.shift();
269
+ }
270
+ this.conflictHistory.push(event);
271
+ for (const listener of this.conflictListeners) listener(event);
272
+ }
273
+
274
+ /**
275
+ * Walks the incoming delta tree and compares each node's server-authoritative
276
+ * parent/position/value against what the local client last recorded.
277
+ * Also processes discarded_moves from the server to emit move_discarded events.
278
+ * Emits conflict events for discrepancies caused by concurrent op resolution.
279
+ */
280
+ private detectConflicts(
281
+ nodes: TreeNodeValue[],
282
+ serverParentId: string | null,
283
+ discardedMoves: DiscardedMove[],
284
+ ): void {
285
+ const now = Date.now();
286
+
287
+ // Emit move_discarded events for server-rejected cycle moves.
288
+ for (const dm of discardedMoves) {
289
+ const hlcToStr = (hlc: { wall_ms: number; logical: number; node_id: number }): string =>
290
+ `${hlc.wall_ms}:${hlc.logical}:${hlc.node_id}`;
291
+ const event: MoveDiscardedEvent = {
292
+ kind: "move_discarded",
293
+ nodeId: hlcToStr(dm.node_id),
294
+ attemptedParentId: dm.attempted_parent_id !== null ? hlcToStr(dm.attempted_parent_id) : null,
295
+ attemptedPosition: dm.attempted_position,
296
+ actualParentId: dm.actual_parent_id !== null ? hlcToStr(dm.actual_parent_id) : null,
297
+ actualPosition: dm.actual_position,
298
+ at: now,
299
+ };
300
+ this.emitConflict(event);
301
+ }
302
+
303
+ for (const node of nodes) {
304
+ const local = this.nodeMetaMap.get(node.id);
305
+ if (local !== undefined) {
306
+ // Detect move reordering: server placed the node somewhere different
307
+ // from what the local optimistic update recorded.
308
+ if (local.parentId !== serverParentId || local.position !== node.position) {
309
+ const event: MoveReorderedEvent = {
310
+ kind: "move_reordered",
311
+ nodeId: node.id,
312
+ localParentId: local.parentId,
313
+ localPosition: local.position,
314
+ serverParentId,
315
+ serverPosition: node.position,
316
+ at: now,
317
+ };
318
+ this.emitConflict(event);
319
+ }
320
+
321
+ // Detect LWW overwrite: server has a different value than local recorded.
322
+ if (local.value !== node.value) {
323
+ const event: LwwOverwriteEvent = {
324
+ kind: "lww_overwrite",
325
+ nodeId: node.id,
326
+ discardedValue: local.value,
327
+ winnerValue: node.value,
328
+ at: now,
329
+ };
330
+ this.emitConflict(event);
331
+ }
332
+ }
333
+ // Recurse into children — serverParentId for children is this node's id.
334
+ // discardedMoves are top-level only (already processed above).
335
+ this.detectConflicts(node.children, node.id, []);
336
+ }
337
+ }
338
+
339
+ /** Rebuilds nodeMetaMap from a full tree snapshot (called on each server delta). */
340
+ private rebuildMetaMap(nodes: TreeNodeValue[], parentId: string | null): void {
341
+ for (const node of nodes) {
342
+ const existing = this.nodeMetaMap.get(node.id);
343
+ this.nodeMetaMap.set(node.id, {
344
+ parentId,
345
+ position: node.position,
346
+ updatedAt: existing?.updatedAt ?? node.id,
347
+ value: node.value,
348
+ });
349
+ this.rebuildMetaMap(node.children, node.id);
350
+ }
351
+ }
352
+
353
+ private emit(): void {
354
+ const v = { roots: this.roots };
355
+ for (const listener of this.listeners) listener(v);
356
+ }
357
+
358
+ /** Parse an HLC string "wall_ms:logical:node_id" back to a Rust-compatible object. */
359
+ private parseHlc(id: string): { wall_ms: number; logical: number; node_id: number } {
360
+ const parts = id.split(":");
361
+ return {
362
+ wall_ms: Number(parts[0]),
363
+ logical: Number(parts[1]),
364
+ node_id: Number(parts[2]),
365
+ };
366
+ }
367
+ }
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ export type {
13
13
  PresenceSnapshotEntry,
14
14
  CRDTMapSnapshotEntry,
15
15
  RGASnapshotEntry,
16
+ TreeSnapshotEntry,
16
17
  } from "./client.js";
17
18
 
18
19
  // CRDT handles
@@ -27,6 +28,8 @@ export type { CrdtMapValue } from "./crdt/crdtmap.js";
27
28
  export { AwarenessHandle } from "./crdt/awareness.js";
28
29
  export type { AwarenessEntry } from "./crdt/awareness.js";
29
30
  export { RGAHandle } from "./crdt/rga.js";
31
+ export { TreeHandle } from "./crdt/tree.js";
32
+ export type { TreeNodeValue, TreeDelta } from "./sync/delta.js";
30
33
 
31
34
  // Transport
32
35
  export { HttpClient } from "./transport/http.js";
@@ -51,6 +54,9 @@ export {
51
54
  export {
52
55
  TokenClaims,
53
56
  Permissions,
57
+ PermissionsV1,
58
+ PermissionsV2,
59
+ PermEntry,
54
60
  VectorClock,
55
61
  ClientMsg,
56
62
  ServerMsg,
@@ -65,14 +71,38 @@ export {
65
71
  } from "./schema.js";
66
72
  export type { TimestampMs, ClientId } from "./schema.js";
67
73
 
68
- // AI Agents — Claude tool use helpers
74
+ // Undo/redo
75
+ export { UndoManager } from "./undo/UndoManager.js";
76
+ export type { UndoEntry, UndoBatch, RgaInsertEntry, TreeAddEntry, TreeDeleteEntry, TreeMoveEntry, TreeUpdateEntry } from "./undo/types.js";
77
+
78
+ // Fractional indexing — position helpers for TreeCRDT
79
+ export { fi, between, before, after, start, end, spread } from "./utils/fractional.js";
80
+
81
+ // Validation — runtime validators for CRDT string values
82
+ export { CrdtValidationError, zodValidator, fnValidator } from "./validation/index.js";
83
+ export type { CrdtValidator } from "./validation/index.js";
84
+
85
+ // Conflict visualization — events emitted by TreeHandle on concurrent op resolution
86
+ export type { ConflictEvent, MoveDiscardedEvent, MoveReorderedEvent, LwwOverwriteEvent } from "./conflict/types.js";
87
+ export type { DiscardedMove } from "./sync/delta.js";
88
+
89
+ // AI Agents — provider-agnostic tool use helpers (Anthropic, OpenAI, Gemini)
69
90
  export {
70
91
  getMeridianTools,
92
+ toOpenAITools,
93
+ toGeminiTools,
71
94
  executeMeridianTool,
95
+ executeOpenAITool,
96
+ executeGeminiTool,
72
97
  } from "./agents.js";
73
98
  export type {
74
99
  Tool,
100
+ OpenAITool,
101
+ GeminiFunctionDeclaration,
102
+ GeminiTool,
75
103
  ToolUseBlock,
104
+ OpenAIToolCall,
105
+ GeminiFunctionCall,
76
106
  MeridianAgentConfig,
77
107
  } from "./agents.js";
78
108
 
package/src/schema.ts CHANGED
@@ -21,11 +21,34 @@ export const ClientId = Schema.Union(Schema.Number, Schema.BigIntFromSelf.pipe(S
21
21
  )));
22
22
  export type ClientId = number;
23
23
 
24
- export const Permissions = Schema.Struct({
24
+ /** V1 permissions glob-list style (legacy tokens). */
25
+ export const PermissionsV1 = Schema.Struct({
25
26
  read: Schema.Array(Schema.String),
26
27
  write: Schema.Array(Schema.String),
27
28
  admin: Schema.Boolean,
28
29
  });
30
+ export type PermissionsV1 = typeof PermissionsV1.Type;
31
+
32
+ /** A single permission rule in a V2 token. */
33
+ export const PermEntry = Schema.Struct({
34
+ p: Schema.String,
35
+ o: Schema.optional(Schema.Number),
36
+ e: Schema.optional(Schema.Number),
37
+ });
38
+ export type PermEntry = typeof PermEntry.Type;
39
+
40
+ /** V2 fine-grained permissions. */
41
+ export const PermissionsV2 = Schema.Struct({
42
+ v: Schema.Literal(2),
43
+ r: Schema.Array(PermEntry),
44
+ w: Schema.Array(PermEntry),
45
+ admin: Schema.Boolean,
46
+ rl: Schema.optional(Schema.Number),
47
+ });
48
+ export type PermissionsV2 = typeof PermissionsV2.Type;
49
+
50
+ /** Token permissions — V1 or V2. */
51
+ export const Permissions = Schema.Union(PermissionsV2, PermissionsV1);
29
52
  export type Permissions = typeof Permissions.Type;
30
53
 
31
54
  export const TokenClaims = Schema.Struct({
package/src/sync/delta.ts CHANGED
@@ -81,13 +81,42 @@ export const decodeRGADelta = (bytes: Uint8Array): RGADelta => {
81
81
  return { text: raw.text ?? "" };
82
82
  };
83
83
 
84
+ export interface TreeNodeValue {
85
+ id: string;
86
+ value: string;
87
+ /** Fractional index string for sibling ordering (e.g. "a0", "b0"). */
88
+ position: string;
89
+ children: TreeNodeValue[];
90
+ }
91
+
92
+ /** A MoveNode op that was rejected by the server due to cycle prevention. */
93
+ export interface DiscardedMove {
94
+ node_id: { wall_ms: number; logical: number; node_id: number };
95
+ attempted_parent_id: { wall_ms: number; logical: number; node_id: number } | null;
96
+ attempted_position: string;
97
+ actual_parent_id: { wall_ms: number; logical: number; node_id: number } | null;
98
+ actual_position: string;
99
+ }
100
+
101
+ export interface TreeDelta {
102
+ roots: TreeNodeValue[];
103
+ /** MoveNode ops discarded due to cycle prevention. Empty in the common case. */
104
+ discarded_moves?: DiscardedMove[];
105
+ }
106
+
107
+ export const decodeTreeDelta = (bytes: Uint8Array): TreeDelta => {
108
+ const raw = decode(bytes) as { roots?: TreeNodeValue[]; discarded_moves?: DiscardedMove[] };
109
+ return { roots: raw.roots ?? [], discarded_moves: raw.discarded_moves ?? [] };
110
+ };
111
+
84
112
  export type CrdtValueDelta =
85
113
  | { GCounter: GCounterDelta }
86
114
  | { PNCounter: PNCounterDelta }
87
115
  | { ORSet: ORSetDelta }
88
116
  | { LwwRegister: LwwDelta }
89
117
  | { Presence: PresenceDelta }
90
- | { RGA: RGADelta };
118
+ | { RGA: RGADelta }
119
+ | { Tree: TreeDelta };
91
120
 
92
121
  export interface CRDTMapDelta {
93
122
  deltas: Record<string, CrdtValueDelta>;