@openweave/weave-graph 0.2.0 → 0.2.1

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 (50) hide show
  1. package/dist/cjs/compression.d.ts +94 -0
  2. package/dist/cjs/compression.d.ts.map +1 -0
  3. package/dist/cjs/compression.js +215 -0
  4. package/dist/cjs/compression.js.map +1 -0
  5. package/dist/cjs/edge.d.ts +43 -0
  6. package/dist/cjs/edge.d.ts.map +1 -0
  7. package/dist/cjs/edge.js +83 -0
  8. package/dist/cjs/edge.js.map +1 -0
  9. package/dist/cjs/hebbian-weights.d.ts +100 -0
  10. package/dist/cjs/hebbian-weights.d.ts.map +1 -0
  11. package/dist/cjs/hebbian-weights.js +152 -0
  12. package/dist/cjs/hebbian-weights.js.map +1 -0
  13. package/dist/cjs/index.d.ts +193 -0
  14. package/dist/cjs/index.d.ts.map +1 -0
  15. package/dist/cjs/index.js +417 -0
  16. package/dist/cjs/index.js.map +1 -0
  17. package/dist/cjs/node.d.ts +43 -0
  18. package/dist/cjs/node.d.ts.map +1 -0
  19. package/dist/cjs/node.js +83 -0
  20. package/dist/cjs/node.js.map +1 -0
  21. package/dist/cjs/package.json +1 -0
  22. package/dist/cjs/persistence.d.ts +86 -0
  23. package/dist/cjs/persistence.d.ts.map +1 -0
  24. package/dist/cjs/persistence.js +215 -0
  25. package/dist/cjs/persistence.js.map +1 -0
  26. package/dist/cjs/synaptic-engine.d.ts +126 -0
  27. package/dist/cjs/synaptic-engine.d.ts.map +1 -0
  28. package/dist/cjs/synaptic-engine.js +243 -0
  29. package/dist/cjs/synaptic-engine.js.map +1 -0
  30. package/dist/cjs/types.d.ts +74 -0
  31. package/dist/cjs/types.d.ts.map +1 -0
  32. package/dist/cjs/types.js +30 -0
  33. package/dist/cjs/types.js.map +1 -0
  34. package/dist/hebbian-weights.d.ts +100 -0
  35. package/dist/hebbian-weights.d.ts.map +1 -0
  36. package/dist/hebbian-weights.js +148 -0
  37. package/dist/hebbian-weights.js.map +1 -0
  38. package/dist/index.d.ts +36 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +65 -3
  41. package/dist/index.js.map +1 -1
  42. package/dist/persistence.d.ts +43 -15
  43. package/dist/persistence.d.ts.map +1 -1
  44. package/dist/persistence.js +109 -119
  45. package/dist/persistence.js.map +1 -1
  46. package/dist/synaptic-engine.d.ts +126 -0
  47. package/dist/synaptic-engine.d.ts.map +1 -0
  48. package/dist/synaptic-engine.js +236 -0
  49. package/dist/synaptic-engine.js.map +1 -0
  50. package/package.json +6 -4
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HebbianWeights = exports.cosineSimilarity = exports.jaccardSimilarity = exports.tokenize = exports.SynapticEngine = exports.ErrorSuppression = exports.CompressionManager = exports.EdgeBuilder = exports.NodeBuilder = exports.PersistenceManager = exports.EdgeType = exports.NodeType = exports.ContextGraphManager = void 0;
4
+ const types_1 = require("./types");
5
+ const node_1 = require("./node");
6
+ const edge_1 = require("./edge");
7
+ const compression_1 = require("./compression");
8
+ /**
9
+ * ContextGraphManager
10
+ * Main interface for managing the WeaveGraph
11
+ * Handles node/edge operations, queries, and persistence metadata
12
+ */
13
+ class ContextGraphManager {
14
+ nodes;
15
+ edges;
16
+ edgesBySource; // sourceId -> Set<edgeId>
17
+ edgesByTarget; // targetId -> Set<edgeId>
18
+ nodesByLabel; // label (lowercased) -> Set<nodeId>
19
+ chatId;
20
+ compressionThreshold = 0.75;
21
+ version = "0.1.0";
22
+ createdAt;
23
+ updatedAt;
24
+ synapticEngine;
25
+ hebbianWeights;
26
+ constructor(chatId, compressionThreshold) {
27
+ this.chatId = chatId;
28
+ this.nodes = new Map();
29
+ this.edges = new Map();
30
+ this.edgesBySource = new Map();
31
+ this.edgesByTarget = new Map();
32
+ this.nodesByLabel = new Map();
33
+ this.createdAt = new Date();
34
+ this.updatedAt = new Date();
35
+ if (compressionThreshold !== undefined) {
36
+ this.compressionThreshold = compressionThreshold;
37
+ }
38
+ }
39
+ /**
40
+ * Attach a SynapticEngine to this graph. Once set, every subsequent
41
+ * `addNode()` call will automatically trigger retroactive linking.
42
+ */
43
+ setSynapticEngine(engine) {
44
+ this.synapticEngine = engine;
45
+ }
46
+ /**
47
+ * Attach a HebbianWeights instance to this graph. Once set,
48
+ * `queryNodesByLabel()` and `queryNodesByType()` will automatically
49
+ * strengthen edges between co-activated result nodes.
50
+ */
51
+ setHebbianWeights(hw) {
52
+ this.hebbianWeights = hw;
53
+ }
54
+ /**
55
+ * Add a node to the graph.
56
+ * If a SynapticEngine is attached, retroactive linking is performed
57
+ * immediately after the node is indexed.
58
+ */
59
+ addNode(node) {
60
+ this.nodes.set(node.id, node);
61
+ // Index by label for keyword search
62
+ const labelKey = node.label.toLowerCase();
63
+ if (!this.nodesByLabel.has(labelKey)) {
64
+ this.nodesByLabel.set(labelKey, new Set());
65
+ }
66
+ this.nodesByLabel.get(labelKey).add(node.id);
67
+ this.updatedAt = new Date();
68
+ // Retroactive linking — fires only when a SynapticEngine is attached
69
+ if (this.synapticEngine) {
70
+ this.synapticEngine.linkRetroactively(node, this);
71
+ }
72
+ return node;
73
+ }
74
+ /**
75
+ * Add a node to the graph and run embedding-based retroactive linking
76
+ * (async). If the attached SynapticEngine has an `embeddingService`,
77
+ * cosine similarity is used instead of Jaccard keyword overlap.
78
+ *
79
+ * If no SynapticEngine is attached, behaves identically to `addNode()`.
80
+ * If a SynapticEngine is attached but has no embedding service, the
81
+ * keyword-based path runs (same as `addNode()`).
82
+ *
83
+ * @returns The added node.
84
+ */
85
+ async addNodeAsync(node) {
86
+ this.nodes.set(node.id, node);
87
+ // Index by label
88
+ const labelKey = node.label.toLowerCase();
89
+ if (!this.nodesByLabel.has(labelKey)) {
90
+ this.nodesByLabel.set(labelKey, new Set());
91
+ }
92
+ this.nodesByLabel.get(labelKey).add(node.id);
93
+ this.updatedAt = new Date();
94
+ // Embedding-based retroactive linking (falls back to keyword if no embeddings)
95
+ if (this.synapticEngine) {
96
+ await this.synapticEngine.linkRetroactivelyEmbedding(node, this);
97
+ }
98
+ return node;
99
+ }
100
+ /**
101
+ * Get a node by ID
102
+ */
103
+ getNode(nodeId) {
104
+ return this.nodes.get(nodeId);
105
+ }
106
+ /**
107
+ * Update an existing node
108
+ */
109
+ updateNode(nodeId, updates) {
110
+ const node = this.nodes.get(nodeId);
111
+ if (!node)
112
+ return undefined;
113
+ const updated = node_1.NodeBuilder.clone(node, updates);
114
+ this.nodes.set(nodeId, updated);
115
+ this.updatedAt = new Date();
116
+ return updated;
117
+ }
118
+ /**
119
+ * Delete a node (and all related edges)
120
+ */
121
+ deleteNode(nodeId) {
122
+ const node = this.nodes.get(nodeId);
123
+ if (!node)
124
+ return false;
125
+ // Remove label index
126
+ const labelKey = node.label.toLowerCase();
127
+ const labelSet = this.nodesByLabel.get(labelKey);
128
+ if (labelSet) {
129
+ labelSet.delete(nodeId);
130
+ if (labelSet.size === 0) {
131
+ this.nodesByLabel.delete(labelKey);
132
+ }
133
+ }
134
+ // Remove all connected edges
135
+ const sourceEdges = this.edgesBySource.get(nodeId) || new Set();
136
+ const targetEdges = this.edgesByTarget.get(nodeId) || new Set();
137
+ [...sourceEdges, ...targetEdges].forEach((edgeId) => {
138
+ this.edges.delete(edgeId);
139
+ });
140
+ this.edgesBySource.delete(nodeId);
141
+ this.edgesByTarget.delete(nodeId);
142
+ this.nodes.delete(nodeId);
143
+ this.updatedAt = new Date();
144
+ return true;
145
+ }
146
+ /**
147
+ * Add an edge to the graph
148
+ */
149
+ addEdge(edge) {
150
+ this.edges.set(edge.id, edge);
151
+ // Index by source and target
152
+ if (!this.edgesBySource.has(edge.sourceId)) {
153
+ this.edgesBySource.set(edge.sourceId, new Set());
154
+ }
155
+ this.edgesBySource.get(edge.sourceId).add(edge.id);
156
+ if (!this.edgesByTarget.has(edge.targetId)) {
157
+ this.edgesByTarget.set(edge.targetId, new Set());
158
+ }
159
+ this.edgesByTarget.get(edge.targetId).add(edge.id);
160
+ this.updatedAt = new Date();
161
+ return edge;
162
+ }
163
+ /**
164
+ * Get an edge by ID
165
+ */
166
+ getEdge(edgeId) {
167
+ return this.edges.get(edgeId);
168
+ }
169
+ /**
170
+ * Update an existing edge
171
+ */
172
+ updateEdge(edgeId, updates) {
173
+ const edge = this.edges.get(edgeId);
174
+ if (!edge)
175
+ return undefined;
176
+ const updated = edge_1.EdgeBuilder.clone(edge, updates);
177
+ this.edges.set(edgeId, updated);
178
+ this.updatedAt = new Date();
179
+ return updated;
180
+ }
181
+ /**
182
+ * Delete an edge
183
+ */
184
+ deleteEdge(edgeId) {
185
+ const edge = this.edges.get(edgeId);
186
+ if (!edge)
187
+ return false;
188
+ this.edgesBySource.get(edge.sourceId)?.delete(edgeId);
189
+ this.edgesByTarget.get(edge.targetId)?.delete(edgeId);
190
+ this.edges.delete(edgeId);
191
+ this.updatedAt = new Date();
192
+ return true;
193
+ }
194
+ /**
195
+ * Get all edges from a source node
196
+ */
197
+ getEdgesFromNode(nodeId) {
198
+ const edgeIds = this.edgesBySource.get(nodeId) || new Set();
199
+ return Array.from(edgeIds)
200
+ .map((id) => this.edges.get(id))
201
+ .filter((edge) => edge !== undefined);
202
+ }
203
+ /**
204
+ * Get all edges to a target node
205
+ */
206
+ getEdgesToNode(nodeId) {
207
+ const edgeIds = this.edgesByTarget.get(nodeId) || new Set();
208
+ return Array.from(edgeIds)
209
+ .map((id) => this.edges.get(id))
210
+ .filter((edge) => edge !== undefined);
211
+ }
212
+ /**
213
+ * Query nodes by label (keyword search)
214
+ * Returns nodes where the label contains the query string
215
+ */
216
+ queryNodesByLabel(query) {
217
+ const lowerQuery = query.toLowerCase();
218
+ const results = [];
219
+ for (const [label, nodeIds] of this.nodesByLabel.entries()) {
220
+ if (label.includes(lowerQuery)) {
221
+ nodeIds.forEach((nodeId) => {
222
+ const node = this.nodes.get(nodeId);
223
+ if (node)
224
+ results.push(node);
225
+ });
226
+ }
227
+ }
228
+ const sorted = results.sort((a, b) => (b.frequency ?? 0) - (a.frequency ?? 0));
229
+ // Hebbian strengthening — reinforce edges between co-activated nodes
230
+ if (this.hebbianWeights && sorted.length >= 2) {
231
+ this.hebbianWeights.strengthenCoActivated(sorted.map((n) => n.id), this);
232
+ }
233
+ return sorted;
234
+ }
235
+ /**
236
+ * Query nodes by type
237
+ */
238
+ queryNodesByType(type) {
239
+ const results = Array.from(this.nodes.values()).filter((node) => node.type === type);
240
+ // Hebbian strengthening — reinforce edges between co-activated nodes
241
+ if (this.hebbianWeights && results.length >= 2) {
242
+ this.hebbianWeights.strengthenCoActivated(results.map((n) => n.id), this);
243
+ }
244
+ return results;
245
+ }
246
+ /**
247
+ * Query edges by type
248
+ */
249
+ queryEdgesByType(type) {
250
+ return Array.from(this.edges.values()).filter((edge) => edge.type === type);
251
+ }
252
+ /**
253
+ * Get graph statistics
254
+ */
255
+ getStats() {
256
+ const nodesByType = new Map();
257
+ const edgesByType = new Map();
258
+ for (const node of this.nodes.values()) {
259
+ nodesByType.set(node.type, (nodesByType.get(node.type) ?? 0) + 1);
260
+ }
261
+ for (const edge of this.edges.values()) {
262
+ edgesByType.set(edge.type, (edgesByType.get(edge.type) ?? 0) + 1);
263
+ }
264
+ return {
265
+ totalNodes: this.nodes.size,
266
+ totalEdges: this.edges.size,
267
+ nodesByType: Object.fromEntries(nodesByType),
268
+ edgesByType: Object.fromEntries(edgesByType),
269
+ chatId: this.chatId,
270
+ createdAt: this.createdAt,
271
+ updatedAt: this.updatedAt,
272
+ };
273
+ }
274
+ /**
275
+ * Snapshot the graph for serialization
276
+ */
277
+ snapshot() {
278
+ return {
279
+ nodes: Object.fromEntries(this.nodes),
280
+ edges: Object.fromEntries(this.edges),
281
+ metadata: {
282
+ chatId: this.chatId,
283
+ version: this.version,
284
+ createdAt: this.createdAt,
285
+ updatedAt: this.updatedAt,
286
+ compressionThreshold: this.compressionThreshold,
287
+ },
288
+ };
289
+ }
290
+ /**
291
+ * Restore graph from snapshot
292
+ */
293
+ static fromSnapshot(snapshot) {
294
+ const manager = new ContextGraphManager(snapshot.metadata.chatId, snapshot.metadata.compressionThreshold);
295
+ Object.values(snapshot.nodes).forEach((node) => {
296
+ manager.addNode(node);
297
+ });
298
+ Object.values(snapshot.edges).forEach((edge) => {
299
+ manager.addEdge(edge);
300
+ });
301
+ manager.createdAt = snapshot.metadata.createdAt;
302
+ manager.updatedAt = snapshot.metadata.updatedAt;
303
+ return manager;
304
+ }
305
+ /**
306
+ * Get the current window size percentage
307
+ * Calculates actual context window usage based on node and edge sizes
308
+ */
309
+ getContextWindowUsage() {
310
+ const contextSize = compression_1.CompressionManager.calculateContextSize(this.getAllNodes(), this.getAllEdges());
311
+ return compression_1.CompressionManager.calculateContextUsagePercentage(contextSize);
312
+ }
313
+ /**
314
+ * Get estimated context size in bytes
315
+ */
316
+ getContextSize() {
317
+ return compression_1.CompressionManager.calculateContextSize(this.getAllNodes(), this.getAllEdges());
318
+ }
319
+ /**
320
+ * Check if compression threshold has been reached
321
+ */
322
+ shouldCompress() {
323
+ return this.getContextWindowUsage() >= this.compressionThreshold;
324
+ }
325
+ /**
326
+ * Compress the graph by archiving low-frequency nodes
327
+ * Returns compression statistics
328
+ */
329
+ compress(targetReductionPercentage = 0.3) {
330
+ const archiveCandidates = compression_1.CompressionManager.identifyArchiveCandidates(this.getAllNodes(), this.getAllEdges(), targetReductionPercentage);
331
+ const compressionMgr = new compression_1.CompressionManager();
332
+ compressionMgr.archiveNodes(archiveCandidates, this.nodes, this.edges);
333
+ // Remove archived nodes from active graph
334
+ for (const nodeId of archiveCandidates) {
335
+ this.deleteNode(nodeId);
336
+ }
337
+ return {
338
+ archivedNodeCount: archiveCandidates.length,
339
+ archiveStats: compressionMgr.getArchiveStats(),
340
+ newContextSize: this.getContextSize(),
341
+ contextUsagePercentage: this.getContextWindowUsage(),
342
+ };
343
+ }
344
+ /**
345
+ * Suppress an error node and create a correction
346
+ */
347
+ suppressError(errorNodeId, correctionLabel, correctionDescription) {
348
+ const errorNode = this.getNode(errorNodeId);
349
+ if (!errorNode || errorNode.type !== types_1.NodeType.ERROR) {
350
+ throw new Error("Node must be an ERROR type to suppress it");
351
+ }
352
+ // Mark error as suppressed
353
+ const suppressedError = compression_1.ErrorSuppression.suppressNode(errorNode);
354
+ this.updateNode(errorNodeId, suppressedError);
355
+ // Create correction node and link it
356
+ const { correctionNode, correctionEdge } = compression_1.ErrorSuppression.createCorrection(errorNodeId, correctionLabel, correctionDescription);
357
+ this.addNode(correctionNode);
358
+ this.addEdge(correctionEdge);
359
+ return { correctionNode, correctionEdge };
360
+ }
361
+ /**
362
+ * Get all error nodes that have been corrected
363
+ */
364
+ getCorrectedErrors() {
365
+ return compression_1.ErrorSuppression.findCorrectedErrors(this.nodes, this.edges);
366
+ }
367
+ /**
368
+ * Get all error nodes that haven't been corrected yet
369
+ */
370
+ getUncorrectedErrors() {
371
+ return compression_1.ErrorSuppression.findUncorrectedErrors(this.nodes, this.edges);
372
+ }
373
+ /**
374
+ * Get all nodes
375
+ */
376
+ getAllNodes() {
377
+ return Array.from(this.nodes.values());
378
+ }
379
+ /**
380
+ * Get all edges
381
+ */
382
+ getAllEdges() {
383
+ return Array.from(this.edges.values());
384
+ }
385
+ /**
386
+ * Clear the entire graph
387
+ */
388
+ clear() {
389
+ this.nodes.clear();
390
+ this.edges.clear();
391
+ this.edgesBySource.clear();
392
+ this.edgesByTarget.clear();
393
+ this.nodesByLabel.clear();
394
+ this.updatedAt = new Date();
395
+ }
396
+ }
397
+ exports.ContextGraphManager = ContextGraphManager;
398
+ var types_2 = require("./types");
399
+ Object.defineProperty(exports, "NodeType", { enumerable: true, get: function () { return types_2.NodeType; } });
400
+ Object.defineProperty(exports, "EdgeType", { enumerable: true, get: function () { return types_2.EdgeType; } });
401
+ var persistence_1 = require("./persistence");
402
+ Object.defineProperty(exports, "PersistenceManager", { enumerable: true, get: function () { return persistence_1.PersistenceManager; } });
403
+ var node_2 = require("./node");
404
+ Object.defineProperty(exports, "NodeBuilder", { enumerable: true, get: function () { return node_2.NodeBuilder; } });
405
+ var edge_2 = require("./edge");
406
+ Object.defineProperty(exports, "EdgeBuilder", { enumerable: true, get: function () { return edge_2.EdgeBuilder; } });
407
+ var compression_2 = require("./compression");
408
+ Object.defineProperty(exports, "CompressionManager", { enumerable: true, get: function () { return compression_2.CompressionManager; } });
409
+ Object.defineProperty(exports, "ErrorSuppression", { enumerable: true, get: function () { return compression_2.ErrorSuppression; } });
410
+ var synaptic_engine_1 = require("./synaptic-engine");
411
+ Object.defineProperty(exports, "SynapticEngine", { enumerable: true, get: function () { return synaptic_engine_1.SynapticEngine; } });
412
+ Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return synaptic_engine_1.tokenize; } });
413
+ Object.defineProperty(exports, "jaccardSimilarity", { enumerable: true, get: function () { return synaptic_engine_1.jaccardSimilarity; } });
414
+ Object.defineProperty(exports, "cosineSimilarity", { enumerable: true, get: function () { return synaptic_engine_1.cosineSimilarity; } });
415
+ var hebbian_weights_1 = require("./hebbian-weights");
416
+ Object.defineProperty(exports, "HebbianWeights", { enumerable: true, get: function () { return hebbian_weights_1.HebbianWeights; } });
417
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAwE;AACxE,iCAAqC;AACrC,iCAAqC;AACrC,+CAAqE;AAIrE;;;;GAIG;AACH,MAAa,mBAAmB;IACtB,KAAK,CAAoB;IACzB,KAAK,CAAoB;IACzB,aAAa,CAA2B,CAAC,0BAA0B;IACnE,aAAa,CAA2B,CAAC,0BAA0B;IACnE,YAAY,CAA2B,CAAC,oCAAoC;IAC5E,MAAM,CAAS;IACf,oBAAoB,GAAW,IAAI,CAAC;IACpC,OAAO,GAAW,OAAO,CAAC;IAC1B,SAAS,CAAO;IAChB,SAAS,CAAO;IAChB,cAAc,CAAkB;IAChC,cAAc,CAAkB;IAExC,YAAY,MAAc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qDAAmD;AAA1C,iHAAA,cAAc,OAAA"}
@@ -0,0 +1,43 @@
1
+ import { Node, NodeType } from "./types";
2
+ /**
3
+ * NodeBuilder utility for creating and managing graph nodes
4
+ */
5
+ export declare class NodeBuilder {
6
+ /**
7
+ * Create a new node with the given type and label
8
+ */
9
+ static create(type: NodeType, label: string, description?: string, metadata?: Record<string, unknown>): Node;
10
+ /**
11
+ * Create a CONCEPT node
12
+ */
13
+ static concept(label: string, description?: string): Node;
14
+ /**
15
+ * Create a DECISION node
16
+ */
17
+ static decision(label: string, description?: string): Node;
18
+ /**
19
+ * Create a MILESTONE node
20
+ */
21
+ static milestone(label: string, description?: string): Node;
22
+ /**
23
+ * Create an ERROR node
24
+ */
25
+ static error(label: string, description?: string): Node;
26
+ /**
27
+ * Create a CORRECTION node
28
+ */
29
+ static correction(label: string, description?: string): Node;
30
+ /**
31
+ * Create a CODE_ENTITY node
32
+ */
33
+ static codeEntity(label: string, description?: string): Node;
34
+ /**
35
+ * Clone a node with updated values
36
+ */
37
+ static clone(node: Node, updates?: Partial<Node>): Node;
38
+ /**
39
+ * Increment frequency counter for a node
40
+ */
41
+ static incrementFrequency(node: Node): Node;
42
+ }
43
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGzC;;GAEG;AACH,qBAAa,WAAW;IACtB;;OAEG;IACH,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,IAAI;IAaP;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAIzD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAI1D;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3D;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAIvD;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5D;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5D;;OAEG;IACH,MAAM,CAAC,KAAK,CACV,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GACtB,IAAI;IAQP;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAO5C"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeBuilder = void 0;
4
+ const types_1 = require("./types");
5
+ const crypto_1 = require("crypto");
6
+ /**
7
+ * NodeBuilder utility for creating and managing graph nodes
8
+ */
9
+ class NodeBuilder {
10
+ /**
11
+ * Create a new node with the given type and label
12
+ */
13
+ static create(type, label, description, metadata) {
14
+ return {
15
+ id: (0, crypto_1.randomUUID)(),
16
+ type,
17
+ label,
18
+ description,
19
+ metadata: metadata ?? {},
20
+ createdAt: new Date(),
21
+ updatedAt: new Date(),
22
+ frequency: 1,
23
+ };
24
+ }
25
+ /**
26
+ * Create a CONCEPT node
27
+ */
28
+ static concept(label, description) {
29
+ return this.create(types_1.NodeType.CONCEPT, label, description);
30
+ }
31
+ /**
32
+ * Create a DECISION node
33
+ */
34
+ static decision(label, description) {
35
+ return this.create(types_1.NodeType.DECISION, label, description);
36
+ }
37
+ /**
38
+ * Create a MILESTONE node
39
+ */
40
+ static milestone(label, description) {
41
+ return this.create(types_1.NodeType.MILESTONE, label, description);
42
+ }
43
+ /**
44
+ * Create an ERROR node
45
+ */
46
+ static error(label, description) {
47
+ return this.create(types_1.NodeType.ERROR, label, description);
48
+ }
49
+ /**
50
+ * Create a CORRECTION node
51
+ */
52
+ static correction(label, description) {
53
+ return this.create(types_1.NodeType.CORRECTION, label, description);
54
+ }
55
+ /**
56
+ * Create a CODE_ENTITY node
57
+ */
58
+ static codeEntity(label, description) {
59
+ return this.create(types_1.NodeType.CODE_ENTITY, label, description);
60
+ }
61
+ /**
62
+ * Clone a node with updated values
63
+ */
64
+ static clone(node, updates) {
65
+ return {
66
+ ...node,
67
+ updatedAt: new Date(),
68
+ ...updates,
69
+ };
70
+ }
71
+ /**
72
+ * Increment frequency counter for a node
73
+ */
74
+ static incrementFrequency(node) {
75
+ return {
76
+ ...node,
77
+ frequency: (node.frequency ?? 1) + 1,
78
+ updatedAt: new Date(),
79
+ };
80
+ }
81
+ }
82
+ exports.NodeBuilder = NodeBuilder;
83
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AACzC,mCAAoC;AAEpC;;GAEG;AACH,MAAa,WAAW;IACtB;;OAEG;IACH,MAAM,CAAC,MAAM,CACX,IAAc,EACd,KAAa,EACb,WAAoB,EACpB,QAAkC;QAElC,OAAO;YACL,EAAE,EAAE,IAAA,mBAAU,GAAE;YAChB,IAAI;YACJ,KAAK;YACL,WAAW;YACX,QAAQ,EAAE,QAAQ,IAAI,EAAE;YACxB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,CAAC;SACb,CAAC;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AO;YACL,GAAG,IAAI;YACP,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,CAAC;YACpC,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;CACF;AAxFD,kCAwFC"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,86 @@
1
+ import { IWeaveProvider } from "@openweave/weave-provider";
2
+ import { ContextGraphManager } from "./index";
3
+ import { GraphSnapshot } from "./types";
4
+ type SerializedSnapshot = Record<string, unknown>;
5
+ /**
6
+ * PersistenceManager
7
+ *
8
+ * Handles saving and loading graph snapshots through a pluggable
9
+ * IWeaveProvider. If no provider is injected, it falls back to the
10
+ * built-in JsonProvider (same behaviour as before, backward-compatible).
11
+ *
12
+ * Key convention: `graph:<chatId>` — namespaced so multiple subsystems can
13
+ * share a single provider without key collisions.
14
+ */
15
+ export declare class PersistenceManager {
16
+ /** Kept for backward-compat (`getDataDir` / `setDataDir` / constructor). */
17
+ private dataDir;
18
+ private provider;
19
+ /**
20
+ * @param dataDir Root directory used by the default JsonProvider.
21
+ * Ignored when an explicit `provider` is supplied.
22
+ * @param provider Optional storage provider. Defaults to `JsonProvider(dataDir)`.
23
+ */
24
+ constructor(dataDir?: string, provider?: IWeaveProvider<SerializedSnapshot>);
25
+ private graphKey;
26
+ /**
27
+ * Serialize a GraphSnapshot to a plain object (dates → ISO strings).
28
+ */
29
+ private serialize;
30
+ /**
31
+ * Deserialize a plain object back to a GraphSnapshot (ISO strings → dates).
32
+ */
33
+ private deserialize;
34
+ /**
35
+ * Ensure the data directory exists.
36
+ * Delegates to the OS mkdir so callers that relied on the old
37
+ * PersistenceManager behaviour continue to work unchanged.
38
+ */
39
+ ensureDataDir(): Promise<void>;
40
+ /**
41
+ * Save a graph snapshot via the configured provider.
42
+ */
43
+ saveGraph(snapshot: GraphSnapshot): Promise<void>;
44
+ /**
45
+ * Load a graph snapshot from the configured provider.
46
+ * Returns `null` if the snapshot does not exist.
47
+ */
48
+ loadGraph(chatId: string): Promise<GraphSnapshot | null>;
49
+ /**
50
+ * Load or create a graph manager for a chat session.
51
+ */
52
+ loadOrCreateGraph(chatId: string, compressionThreshold?: number): Promise<ContextGraphManager>;
53
+ /**
54
+ * Check whether a graph exists in the provider.
55
+ */
56
+ graphExists(chatId: string): Promise<boolean>;
57
+ /**
58
+ * Delete a graph from the provider. No-op if it does not exist.
59
+ */
60
+ deleteGraph(chatId: string): Promise<void>;
61
+ /**
62
+ * List all saved chat sessions by querying the `graph:` namespace.
63
+ */
64
+ listSessions(): Promise<Array<{
65
+ chatId: string;
66
+ createdAt: Date;
67
+ updatedAt: Date;
68
+ nodeCount: number;
69
+ edgeCount: number;
70
+ }>>;
71
+ /**
72
+ * Swap in a different provider at runtime (e.g. after migration).
73
+ */
74
+ setProvider(provider: IWeaveProvider<SerializedSnapshot>): void;
75
+ /** Returns the active provider (useful for tests / diagnostics). */
76
+ getProvider(): IWeaveProvider<SerializedSnapshot>;
77
+ /**
78
+ * Change the data directory used by the default JsonProvider.
79
+ * Has no effect when an external provider was injected.
80
+ */
81
+ setDataDir(newDataDir: string): void;
82
+ /** Returns the configured data directory. */
83
+ getDataDir(): string;
84
+ }
85
+ export {};
86
+ //# sourceMappingURL=persistence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../src/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,KAAK,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD;;;;;;;;;GASG;AACH,qBAAa,kBAAkB;IAC7B,4EAA4E;IAC5E,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAqC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