@affectively/aeon 1.3.0 → 1.3.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 (43) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +342 -342
  3. package/dist/compression/index.cjs.map +1 -1
  4. package/dist/compression/index.js.map +1 -1
  5. package/dist/core/index.d.cts +213 -213
  6. package/dist/core/index.d.ts +213 -213
  7. package/dist/crypto/index.cjs.map +1 -1
  8. package/dist/crypto/index.d.cts +441 -441
  9. package/dist/crypto/index.d.ts +441 -441
  10. package/dist/crypto/index.js.map +1 -1
  11. package/dist/distributed/index.cjs.map +1 -1
  12. package/dist/distributed/index.d.cts +1005 -1005
  13. package/dist/distributed/index.d.ts +1005 -1005
  14. package/dist/distributed/index.js.map +1 -1
  15. package/dist/index.cjs +32 -723
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +50 -5
  18. package/dist/index.d.ts +50 -5
  19. package/dist/index.js +29 -722
  20. package/dist/index.js.map +1 -1
  21. package/dist/offline/index.cjs.map +1 -1
  22. package/dist/offline/index.d.cts +148 -148
  23. package/dist/offline/index.d.ts +148 -148
  24. package/dist/offline/index.js.map +1 -1
  25. package/dist/optimization/index.cjs.map +1 -1
  26. package/dist/optimization/index.js.map +1 -1
  27. package/dist/persistence/index.cjs.map +1 -1
  28. package/dist/persistence/index.d.cts +57 -57
  29. package/dist/persistence/index.d.ts +57 -57
  30. package/dist/persistence/index.js.map +1 -1
  31. package/dist/presence/index.cjs.map +1 -1
  32. package/dist/presence/index.js.map +1 -1
  33. package/dist/{types-B7gCpNX9.d.cts → types-B7CxsoLh.d.cts} +30 -30
  34. package/dist/{types-B7gCpNX9.d.ts → types-B7CxsoLh.d.ts} +30 -30
  35. package/dist/utils/index.cjs.map +1 -1
  36. package/dist/utils/index.d.cts +35 -35
  37. package/dist/utils/index.d.ts +35 -35
  38. package/dist/utils/index.js.map +1 -1
  39. package/dist/versioning/index.cjs.map +1 -1
  40. package/dist/versioning/index.d.cts +1 -1
  41. package/dist/versioning/index.d.ts +1 -1
  42. package/dist/versioning/index.js.map +1 -1
  43. package/package.json +196 -196
package/dist/index.js CHANGED
@@ -193,230 +193,6 @@ var InMemoryStorageAdapter = class {
193
193
  }
194
194
  };
195
195
 
196
- // src/versioning/SchemaVersionManager.ts
197
- var SchemaVersionManager = class {
198
- versions = /* @__PURE__ */ new Map();
199
- versionHistory = [];
200
- compatibilityMatrix = /* @__PURE__ */ new Map();
201
- currentVersion = null;
202
- constructor() {
203
- this.initializeDefaultVersions();
204
- }
205
- /**
206
- * Initialize default versions
207
- */
208
- initializeDefaultVersions() {
209
- const v1_0_0 = {
210
- major: 1,
211
- minor: 0,
212
- patch: 0,
213
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
214
- description: "Initial schema version",
215
- breaking: false
216
- };
217
- this.registerVersion(v1_0_0);
218
- this.currentVersion = v1_0_0;
219
- }
220
- /**
221
- * Register a new schema version
222
- */
223
- registerVersion(version) {
224
- const versionString = this.versionToString(version);
225
- this.versions.set(versionString, version);
226
- this.versionHistory.push(version);
227
- logger.debug("[SchemaVersionManager] Version registered", {
228
- version: versionString,
229
- breaking: version.breaking,
230
- description: version.description
231
- });
232
- }
233
- /**
234
- * Get current version
235
- */
236
- getCurrentVersion() {
237
- if (!this.currentVersion) {
238
- throw new Error("No current version set");
239
- }
240
- return this.currentVersion;
241
- }
242
- /**
243
- * Set current version
244
- */
245
- setCurrentVersion(version) {
246
- if (!this.versions.has(this.versionToString(version))) {
247
- throw new Error(
248
- `Version ${this.versionToString(version)} not registered`
249
- );
250
- }
251
- this.currentVersion = version;
252
- logger.debug("[SchemaVersionManager] Current version set", {
253
- version: this.versionToString(version)
254
- });
255
- }
256
- /**
257
- * Get version history
258
- */
259
- getVersionHistory() {
260
- return [...this.versionHistory];
261
- }
262
- /**
263
- * Check if version exists
264
- */
265
- hasVersion(version) {
266
- return this.versions.has(this.versionToString(version));
267
- }
268
- /**
269
- * Get version by string (e.g., "1.2.3")
270
- */
271
- getVersion(versionString) {
272
- return this.versions.get(versionString);
273
- }
274
- /**
275
- * Register compatibility rule
276
- */
277
- registerCompatibility(rule) {
278
- if (!this.compatibilityMatrix.has(rule.from)) {
279
- this.compatibilityMatrix.set(rule.from, []);
280
- }
281
- const rules = this.compatibilityMatrix.get(rule.from);
282
- if (rules) {
283
- rules.push(rule);
284
- }
285
- logger.debug("[SchemaVersionManager] Compatibility rule registered", {
286
- from: rule.from,
287
- to: rule.to,
288
- compatible: rule.compatible,
289
- requiresMigration: rule.requiresMigration
290
- });
291
- }
292
- /**
293
- * Check if migration path exists
294
- */
295
- canMigrate(fromVersion, toVersion) {
296
- const fromStr = typeof fromVersion === "string" ? fromVersion : this.versionToString(fromVersion);
297
- const toStr = typeof toVersion === "string" ? toVersion : this.versionToString(toVersion);
298
- const rules = this.compatibilityMatrix.get(fromStr) || [];
299
- return rules.some((r) => r.to === toStr && r.requiresMigration);
300
- }
301
- /**
302
- * Get migration path
303
- */
304
- getMigrationPath(fromVersion, toVersion) {
305
- const path = [];
306
- let current = fromVersion;
307
- const maxSteps = 100;
308
- let steps = 0;
309
- while (this.compareVersions(current, toVersion) !== 0 && steps < maxSteps) {
310
- const fromStr = this.versionToString(current);
311
- const rules = this.compatibilityMatrix.get(fromStr) || [];
312
- let found = false;
313
- for (const rule of rules) {
314
- const nextVersion = this.getVersion(rule.to);
315
- if (nextVersion) {
316
- if (this.compareVersions(nextVersion, toVersion) <= 0 || this.compareVersions(current, nextVersion) < this.compareVersions(current, toVersion)) {
317
- current = nextVersion;
318
- path.push(current);
319
- found = true;
320
- break;
321
- }
322
- }
323
- }
324
- if (!found) {
325
- break;
326
- }
327
- steps++;
328
- }
329
- return path;
330
- }
331
- /**
332
- * Compare two versions
333
- * Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
334
- */
335
- compareVersions(v1, v2) {
336
- const ver1 = typeof v1 === "string" ? this.parseVersion(v1) : v1;
337
- const ver2 = typeof v2 === "string" ? this.parseVersion(v2) : v2;
338
- if (ver1.major !== ver2.major) {
339
- return ver1.major < ver2.major ? -1 : 1;
340
- }
341
- if (ver1.minor !== ver2.minor) {
342
- return ver1.minor < ver2.minor ? -1 : 1;
343
- }
344
- if (ver1.patch !== ver2.patch) {
345
- return ver1.patch < ver2.patch ? -1 : 1;
346
- }
347
- return 0;
348
- }
349
- /**
350
- * Parse version string to SchemaVersion
351
- */
352
- parseVersion(versionString) {
353
- const parts = versionString.split(".").map(Number);
354
- return {
355
- major: parts[0] || 0,
356
- minor: parts[1] || 0,
357
- patch: parts[2] || 0,
358
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
359
- description: "",
360
- breaking: false
361
- };
362
- }
363
- /**
364
- * Create new version
365
- */
366
- createVersion(major, minor, patch, description, breaking = false) {
367
- return {
368
- major,
369
- minor,
370
- patch,
371
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
372
- description,
373
- breaking
374
- };
375
- }
376
- /**
377
- * Convert version to string
378
- */
379
- versionToString(version) {
380
- return `${version.major}.${version.minor}.${version.patch}`;
381
- }
382
- /**
383
- * Get version metadata
384
- */
385
- getVersionMetadata(version) {
386
- const history = this.versionHistory;
387
- const currentIndex = history.findIndex(
388
- (v) => this.versionToString(v) === this.versionToString(version)
389
- );
390
- return {
391
- version,
392
- previousVersion: currentIndex > 0 ? history[currentIndex - 1] : void 0,
393
- changes: [version.description],
394
- migrationsRequired: this.canMigrate(
395
- this.currentVersion || version,
396
- version
397
- ) ? [this.versionToString(version)] : [],
398
- rollbackPossible: currentIndex > 0
399
- };
400
- }
401
- /**
402
- * Get all registered versions
403
- */
404
- getAllVersions() {
405
- return Array.from(this.versions.values()).sort(
406
- (a, b) => this.compareVersions(a, b)
407
- );
408
- }
409
- /**
410
- * Clear all versions (for testing)
411
- */
412
- clear() {
413
- this.versions.clear();
414
- this.versionHistory = [];
415
- this.compatibilityMatrix.clear();
416
- this.currentVersion = null;
417
- }
418
- };
419
-
420
196
  // src/versioning/MigrationEngine.ts
421
197
  var MigrationEngine = class {
422
198
  migrations = /* @__PURE__ */ new Map();
@@ -1321,489 +1097,6 @@ var MigrationTracker = class _MigrationTracker {
1321
1097
  return (hash >>> 0).toString(16).padStart(8, "0");
1322
1098
  }
1323
1099
  };
1324
- var SyncCoordinator = class extends EventEmitter {
1325
- nodes = /* @__PURE__ */ new Map();
1326
- sessions = /* @__PURE__ */ new Map();
1327
- syncEvents = [];
1328
- nodeHeartbeats = /* @__PURE__ */ new Map();
1329
- heartbeatInterval = null;
1330
- // Crypto support
1331
- cryptoProvider = null;
1332
- nodesByDID = /* @__PURE__ */ new Map();
1333
- // DID -> nodeId
1334
- constructor() {
1335
- super();
1336
- }
1337
- /**
1338
- * Configure cryptographic provider for authenticated sync
1339
- */
1340
- configureCrypto(provider) {
1341
- this.cryptoProvider = provider;
1342
- logger.debug("[SyncCoordinator] Crypto configured", {
1343
- initialized: provider.isInitialized()
1344
- });
1345
- }
1346
- /**
1347
- * Check if crypto is configured
1348
- */
1349
- isCryptoEnabled() {
1350
- return this.cryptoProvider !== null && this.cryptoProvider.isInitialized();
1351
- }
1352
- /**
1353
- * Register a node with DID-based identity
1354
- */
1355
- async registerAuthenticatedNode(nodeInfo) {
1356
- const node = {
1357
- ...nodeInfo
1358
- };
1359
- this.nodes.set(node.id, node);
1360
- this.nodeHeartbeats.set(node.id, Date.now());
1361
- this.nodesByDID.set(nodeInfo.did, node.id);
1362
- if (this.cryptoProvider) {
1363
- await this.cryptoProvider.registerRemoteNode({
1364
- id: node.id,
1365
- did: nodeInfo.did,
1366
- publicSigningKey: nodeInfo.publicSigningKey,
1367
- publicEncryptionKey: nodeInfo.publicEncryptionKey
1368
- });
1369
- }
1370
- const event = {
1371
- type: "node-joined",
1372
- nodeId: node.id,
1373
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1374
- data: { did: nodeInfo.did, authenticated: true }
1375
- };
1376
- this.syncEvents.push(event);
1377
- this.emit("node-joined", node);
1378
- logger.debug("[SyncCoordinator] Authenticated node registered", {
1379
- nodeId: node.id,
1380
- did: nodeInfo.did,
1381
- version: node.version
1382
- });
1383
- return node;
1384
- }
1385
- /**
1386
- * Get node by DID
1387
- */
1388
- getNodeByDID(did) {
1389
- const nodeId = this.nodesByDID.get(did);
1390
- if (!nodeId) return void 0;
1391
- return this.nodes.get(nodeId);
1392
- }
1393
- /**
1394
- * Get all authenticated nodes (nodes with DIDs)
1395
- */
1396
- getAuthenticatedNodes() {
1397
- return Array.from(this.nodes.values()).filter((n) => n.did);
1398
- }
1399
- /**
1400
- * Create an authenticated sync session with UCAN-based authorization
1401
- */
1402
- async createAuthenticatedSyncSession(initiatorDID, participantDIDs, options) {
1403
- const initiatorNodeId = this.nodesByDID.get(initiatorDID);
1404
- if (!initiatorNodeId) {
1405
- throw new Error(`Initiator node with DID ${initiatorDID} not found`);
1406
- }
1407
- const participantIds = [];
1408
- for (const did of participantDIDs) {
1409
- const nodeId = this.nodesByDID.get(did);
1410
- if (nodeId) {
1411
- participantIds.push(nodeId);
1412
- }
1413
- }
1414
- let sessionToken;
1415
- if (this.cryptoProvider && this.cryptoProvider.isInitialized()) {
1416
- const capabilities = (options?.requiredCapabilities || ["aeon:sync:read", "aeon:sync:write"]).map((cap) => ({ can: cap, with: "*" }));
1417
- if (participantDIDs.length > 0) {
1418
- sessionToken = await this.cryptoProvider.createUCAN(
1419
- participantDIDs[0],
1420
- capabilities,
1421
- { expirationSeconds: 3600 }
1422
- // 1 hour
1423
- );
1424
- }
1425
- }
1426
- const session = {
1427
- id: `sync-${Date.now()}-${Math.random().toString(36).slice(2)}`,
1428
- initiatorId: initiatorNodeId,
1429
- participantIds,
1430
- status: "pending",
1431
- startTime: (/* @__PURE__ */ new Date()).toISOString(),
1432
- itemsSynced: 0,
1433
- itemsFailed: 0,
1434
- conflictsDetected: 0,
1435
- initiatorDID,
1436
- participantDIDs,
1437
- encryptionMode: options?.encryptionMode || "none",
1438
- requiredCapabilities: options?.requiredCapabilities,
1439
- sessionToken
1440
- };
1441
- this.sessions.set(session.id, session);
1442
- const event = {
1443
- type: "sync-started",
1444
- sessionId: session.id,
1445
- nodeId: initiatorNodeId,
1446
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1447
- data: {
1448
- authenticated: true,
1449
- initiatorDID,
1450
- participantCount: participantDIDs.length,
1451
- encryptionMode: session.encryptionMode
1452
- }
1453
- };
1454
- this.syncEvents.push(event);
1455
- this.emit("sync-started", session);
1456
- logger.debug("[SyncCoordinator] Authenticated sync session created", {
1457
- sessionId: session.id,
1458
- initiatorDID,
1459
- participants: participantDIDs.length,
1460
- encryptionMode: session.encryptionMode
1461
- });
1462
- return session;
1463
- }
1464
- /**
1465
- * Verify a node's UCAN capabilities for a session
1466
- */
1467
- async verifyNodeCapabilities(sessionId, nodeDID, token) {
1468
- if (!this.cryptoProvider) {
1469
- return { authorized: true };
1470
- }
1471
- const session = this.sessions.get(sessionId);
1472
- if (!session) {
1473
- return { authorized: false, error: `Session ${sessionId} not found` };
1474
- }
1475
- const result = await this.cryptoProvider.verifyUCAN(token, {
1476
- requiredCapabilities: session.requiredCapabilities?.map((cap) => ({
1477
- can: cap,
1478
- with: "*"
1479
- }))
1480
- });
1481
- if (!result.authorized) {
1482
- logger.warn("[SyncCoordinator] Node capability verification failed", {
1483
- sessionId,
1484
- nodeDID,
1485
- error: result.error
1486
- });
1487
- }
1488
- return result;
1489
- }
1490
- /**
1491
- * Register a node in the cluster
1492
- */
1493
- registerNode(node) {
1494
- this.nodes.set(node.id, node);
1495
- this.nodeHeartbeats.set(node.id, Date.now());
1496
- const event = {
1497
- type: "node-joined",
1498
- nodeId: node.id,
1499
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1500
- };
1501
- this.syncEvents.push(event);
1502
- this.emit("node-joined", node);
1503
- logger.debug("[SyncCoordinator] Node registered", {
1504
- nodeId: node.id,
1505
- address: node.address,
1506
- version: node.version
1507
- });
1508
- }
1509
- /**
1510
- * Deregister a node from the cluster
1511
- */
1512
- deregisterNode(nodeId) {
1513
- const node = this.nodes.get(nodeId);
1514
- if (!node) {
1515
- throw new Error(`Node ${nodeId} not found`);
1516
- }
1517
- this.nodes.delete(nodeId);
1518
- this.nodeHeartbeats.delete(nodeId);
1519
- const event = {
1520
- type: "node-left",
1521
- nodeId,
1522
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1523
- };
1524
- this.syncEvents.push(event);
1525
- this.emit("node-left", node);
1526
- logger.debug("[SyncCoordinator] Node deregistered", { nodeId });
1527
- }
1528
- /**
1529
- * Create a new sync session
1530
- */
1531
- createSyncSession(initiatorId, participantIds) {
1532
- const node = this.nodes.get(initiatorId);
1533
- if (!node) {
1534
- throw new Error(`Initiator node ${initiatorId} not found`);
1535
- }
1536
- const session = {
1537
- id: `sync-${Date.now()}-${Math.random().toString(36).slice(2)}`,
1538
- initiatorId,
1539
- participantIds,
1540
- status: "pending",
1541
- startTime: (/* @__PURE__ */ new Date()).toISOString(),
1542
- itemsSynced: 0,
1543
- itemsFailed: 0,
1544
- conflictsDetected: 0
1545
- };
1546
- this.sessions.set(session.id, session);
1547
- const event = {
1548
- type: "sync-started",
1549
- sessionId: session.id,
1550
- nodeId: initiatorId,
1551
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1552
- };
1553
- this.syncEvents.push(event);
1554
- this.emit("sync-started", session);
1555
- logger.debug("[SyncCoordinator] Sync session created", {
1556
- sessionId: session.id,
1557
- initiator: initiatorId,
1558
- participants: participantIds.length
1559
- });
1560
- return session;
1561
- }
1562
- /**
1563
- * Update sync session
1564
- */
1565
- updateSyncSession(sessionId, updates) {
1566
- const session = this.sessions.get(sessionId);
1567
- if (!session) {
1568
- throw new Error(`Session ${sessionId} not found`);
1569
- }
1570
- Object.assign(session, updates);
1571
- if (updates.status === "completed" || updates.status === "failed") {
1572
- session.endTime = (/* @__PURE__ */ new Date()).toISOString();
1573
- const event = {
1574
- type: "sync-completed",
1575
- sessionId,
1576
- nodeId: session.initiatorId,
1577
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1578
- data: { status: updates.status, itemsSynced: session.itemsSynced }
1579
- };
1580
- this.syncEvents.push(event);
1581
- this.emit("sync-completed", session);
1582
- }
1583
- logger.debug("[SyncCoordinator] Sync session updated", {
1584
- sessionId,
1585
- status: session.status,
1586
- itemsSynced: session.itemsSynced
1587
- });
1588
- }
1589
- /**
1590
- * Record a conflict during sync
1591
- */
1592
- recordConflict(sessionId, nodeId, conflictData) {
1593
- const session = this.sessions.get(sessionId);
1594
- if (session) {
1595
- session.conflictsDetected++;
1596
- const event = {
1597
- type: "conflict-detected",
1598
- sessionId,
1599
- nodeId,
1600
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1601
- data: conflictData
1602
- };
1603
- this.syncEvents.push(event);
1604
- this.emit("conflict-detected", { session, nodeId, conflictData });
1605
- logger.debug("[SyncCoordinator] Conflict recorded", {
1606
- sessionId,
1607
- nodeId,
1608
- totalConflicts: session.conflictsDetected
1609
- });
1610
- }
1611
- }
1612
- /**
1613
- * Update node status
1614
- */
1615
- updateNodeStatus(nodeId, status) {
1616
- const node = this.nodes.get(nodeId);
1617
- if (!node) {
1618
- throw new Error(`Node ${nodeId} not found`);
1619
- }
1620
- node.status = status;
1621
- this.nodeHeartbeats.set(nodeId, Date.now());
1622
- logger.debug("[SyncCoordinator] Node status updated", {
1623
- nodeId,
1624
- status
1625
- });
1626
- }
1627
- /**
1628
- * Record heartbeat from node
1629
- */
1630
- recordHeartbeat(nodeId) {
1631
- const node = this.nodes.get(nodeId);
1632
- if (!node) {
1633
- return;
1634
- }
1635
- node.lastHeartbeat = (/* @__PURE__ */ new Date()).toISOString();
1636
- this.nodeHeartbeats.set(nodeId, Date.now());
1637
- }
1638
- /**
1639
- * Get all nodes
1640
- */
1641
- getNodes() {
1642
- return Array.from(this.nodes.values());
1643
- }
1644
- /**
1645
- * Get node by ID
1646
- */
1647
- getNode(nodeId) {
1648
- return this.nodes.get(nodeId);
1649
- }
1650
- /**
1651
- * Get online nodes
1652
- */
1653
- getOnlineNodes() {
1654
- return Array.from(this.nodes.values()).filter((n) => n.status === "online");
1655
- }
1656
- /**
1657
- * Get nodes by capability
1658
- */
1659
- getNodesByCapability(capability) {
1660
- return Array.from(this.nodes.values()).filter(
1661
- (n) => n.capabilities.includes(capability)
1662
- );
1663
- }
1664
- /**
1665
- * Get sync session
1666
- */
1667
- getSyncSession(sessionId) {
1668
- return this.sessions.get(sessionId);
1669
- }
1670
- /**
1671
- * Get all sync sessions
1672
- */
1673
- getAllSyncSessions() {
1674
- return Array.from(this.sessions.values());
1675
- }
1676
- /**
1677
- * Get active sync sessions
1678
- */
1679
- getActiveSyncSessions() {
1680
- return Array.from(this.sessions.values()).filter(
1681
- (s) => s.status === "active"
1682
- );
1683
- }
1684
- /**
1685
- * Get sessions for a node
1686
- */
1687
- getSessionsForNode(nodeId) {
1688
- return Array.from(this.sessions.values()).filter(
1689
- (s) => s.initiatorId === nodeId || s.participantIds.includes(nodeId)
1690
- );
1691
- }
1692
- /**
1693
- * Get sync statistics
1694
- */
1695
- getStatistics() {
1696
- const sessions = Array.from(this.sessions.values());
1697
- const completed = sessions.filter((s) => s.status === "completed").length;
1698
- const failed = sessions.filter((s) => s.status === "failed").length;
1699
- const active = sessions.filter((s) => s.status === "active").length;
1700
- const totalItemsSynced = sessions.reduce(
1701
- (sum, s) => sum + s.itemsSynced,
1702
- 0
1703
- );
1704
- const totalConflicts = sessions.reduce(
1705
- (sum, s) => sum + s.conflictsDetected,
1706
- 0
1707
- );
1708
- return {
1709
- totalNodes: this.nodes.size,
1710
- onlineNodes: this.getOnlineNodes().length,
1711
- offlineNodes: this.nodes.size - this.getOnlineNodes().length,
1712
- totalSessions: sessions.length,
1713
- activeSessions: active,
1714
- completedSessions: completed,
1715
- failedSessions: failed,
1716
- successRate: sessions.length > 0 ? completed / sessions.length * 100 : 0,
1717
- totalItemsSynced,
1718
- totalConflicts,
1719
- averageConflictsPerSession: sessions.length > 0 ? totalConflicts / sessions.length : 0
1720
- };
1721
- }
1722
- /**
1723
- * Get sync events
1724
- */
1725
- getSyncEvents(limit) {
1726
- const events = [...this.syncEvents];
1727
- if (limit) {
1728
- return events.slice(-limit);
1729
- }
1730
- return events;
1731
- }
1732
- /**
1733
- * Get sync events for session
1734
- */
1735
- getSessionEvents(sessionId) {
1736
- return this.syncEvents.filter((e) => e.sessionId === sessionId);
1737
- }
1738
- /**
1739
- * Check node health
1740
- */
1741
- getNodeHealth() {
1742
- const health = {};
1743
- for (const [nodeId, lastHeartbeat] of this.nodeHeartbeats) {
1744
- const now = Date.now();
1745
- const downtime = now - lastHeartbeat;
1746
- const isHealthy = downtime < 3e4;
1747
- health[nodeId] = {
1748
- isHealthy,
1749
- downtime
1750
- };
1751
- }
1752
- return health;
1753
- }
1754
- /**
1755
- * Start heartbeat monitoring
1756
- */
1757
- startHeartbeatMonitoring(interval = 5e3) {
1758
- if (this.heartbeatInterval) {
1759
- return;
1760
- }
1761
- this.heartbeatInterval = setInterval(() => {
1762
- const health = this.getNodeHealth();
1763
- for (const [nodeId, { isHealthy }] of Object.entries(health)) {
1764
- const node = this.nodes.get(nodeId);
1765
- if (!node) {
1766
- continue;
1767
- }
1768
- const newStatus = isHealthy ? "online" : "offline";
1769
- if (node.status !== newStatus) {
1770
- this.updateNodeStatus(nodeId, newStatus);
1771
- }
1772
- }
1773
- }, interval);
1774
- logger.debug("[SyncCoordinator] Heartbeat monitoring started", {
1775
- interval
1776
- });
1777
- }
1778
- /**
1779
- * Stop heartbeat monitoring
1780
- */
1781
- stopHeartbeatMonitoring() {
1782
- if (this.heartbeatInterval) {
1783
- clearInterval(this.heartbeatInterval);
1784
- this.heartbeatInterval = null;
1785
- logger.debug("[SyncCoordinator] Heartbeat monitoring stopped");
1786
- }
1787
- }
1788
- /**
1789
- * Clear all state (for testing)
1790
- */
1791
- clear() {
1792
- this.nodes.clear();
1793
- this.sessions.clear();
1794
- this.syncEvents = [];
1795
- this.nodeHeartbeats.clear();
1796
- this.nodesByDID.clear();
1797
- this.cryptoProvider = null;
1798
- this.stopHeartbeatMonitoring();
1799
- }
1800
- /**
1801
- * Get the crypto provider (for advanced usage)
1802
- */
1803
- getCryptoProvider() {
1804
- return this.cryptoProvider;
1805
- }
1806
- };
1807
1100
 
1808
1101
  // src/distributed/ReplicationManager.ts
1809
1102
  var ReplicationManager = class _ReplicationManager {
@@ -5248,15 +4541,7 @@ var AdaptiveCompressionOptimizer = class {
5248
4541
  };
5249
4542
  }
5250
4543
  };
5251
- var adaptiveOptimizerInstance = null;
5252
- function getAdaptiveCompressionOptimizer() {
5253
- if (!adaptiveOptimizerInstance) {
5254
- adaptiveOptimizerInstance = new AdaptiveCompressionOptimizer();
5255
- }
5256
- return adaptiveOptimizerInstance;
5257
- }
5258
4544
  function resetAdaptiveCompressionOptimizer() {
5259
- adaptiveOptimizerInstance = null;
5260
4545
  }
5261
4546
  var logger8 = getLogger();
5262
4547
  var AgentPresenceManager = class extends EventEmitter {
@@ -5701,12 +4986,6 @@ var AgentPresenceManager = class extends EventEmitter {
5701
4986
  }
5702
4987
  };
5703
4988
  var instances = /* @__PURE__ */ new Map();
5704
- function getAgentPresenceManager(sessionId) {
5705
- if (!instances.has(sessionId)) {
5706
- instances.set(sessionId, new AgentPresenceManager(sessionId));
5707
- }
5708
- return instances.get(sessionId);
5709
- }
5710
4989
  function clearAgentPresenceManager(sessionId) {
5711
4990
  const instance = instances.get(sessionId);
5712
4991
  if (instance) {
@@ -5808,6 +5087,34 @@ var NullCryptoProvider = class {
5808
5087
  }
5809
5088
  };
5810
5089
 
5811
- export { AEON_CAPABILITIES, AdaptiveCompressionOptimizer, AgentPresenceManager, BatchTimingOptimizer, CompressionEngine, DEFAULT_CRYPTO_CONFIG, DashStorageAdapter, DataTransformer, DeltaSyncOptimizer, InMemoryStorageAdapter, MigrationEngine, MigrationTracker, NullCryptoProvider, OfflineOperationQueue, PrefetchingEngine, ReplicationManager, SchemaVersionManager, StateReconciler, SyncCoordinator, SyncProtocol, clearAgentPresenceManager, createNamespacedLogger, disableLogging, getAdaptiveCompressionOptimizer, getAgentPresenceManager, getBatchTimingOptimizer, getCompressionEngine, getDeltaSyncOptimizer, getLogger, getOfflineOperationQueue, getPrefetchingEngine, logger, resetAdaptiveCompressionOptimizer, resetBatchTimingOptimizer, resetCompressionEngine, resetDeltaSyncOptimizer, resetLogger, resetOfflineOperationQueue, resetPrefetchingEngine, setLogger };
5090
+ // src/index.ts
5091
+ var Link = (() => {
5092
+ throw new Error(
5093
+ "Link: Stub called from @affectively/aeon. Import from @affectively/aeon-flux-react or mock in tests."
5094
+ );
5095
+ });
5096
+ var useAeonPage = (() => {
5097
+ throw new Error(
5098
+ "useAeonPage: Stub called from @affectively/aeon. Import from @affectively/aeon-flux-react or mock in tests."
5099
+ );
5100
+ });
5101
+ var getAdaptiveCompressionOptimizer = (() => {
5102
+ throw new Error("getAdaptiveCompressionOptimizer: Stub");
5103
+ });
5104
+ var SchemaVersionManager2 = class {
5105
+ constructor() {
5106
+ throw new Error("SchemaVersionManager: Stub");
5107
+ }
5108
+ };
5109
+ var getAgentPresenceManager = (() => {
5110
+ throw new Error("getAgentPresenceManager: Stub");
5111
+ });
5112
+ var SyncCoordinator2 = class {
5113
+ constructor() {
5114
+ throw new Error("SyncCoordinator: Stub");
5115
+ }
5116
+ };
5117
+
5118
+ export { AEON_CAPABILITIES, AdaptiveCompressionOptimizer, AgentPresenceManager, BatchTimingOptimizer, CompressionEngine, DEFAULT_CRYPTO_CONFIG, DashStorageAdapter, DataTransformer, DeltaSyncOptimizer, InMemoryStorageAdapter, Link, MigrationEngine, MigrationTracker, NullCryptoProvider, OfflineOperationQueue, PrefetchingEngine, ReplicationManager, SchemaVersionManager2 as SchemaVersionManager, StateReconciler, SyncCoordinator2 as SyncCoordinator, SyncProtocol, clearAgentPresenceManager, createNamespacedLogger, disableLogging, getAdaptiveCompressionOptimizer, getAgentPresenceManager, getBatchTimingOptimizer, getCompressionEngine, getDeltaSyncOptimizer, getLogger, getOfflineOperationQueue, getPrefetchingEngine, logger, resetAdaptiveCompressionOptimizer, resetBatchTimingOptimizer, resetCompressionEngine, resetDeltaSyncOptimizer, resetLogger, resetOfflineOperationQueue, resetPrefetchingEngine, setLogger, useAeonPage };
5812
5119
  //# sourceMappingURL=index.js.map
5813
5120
  //# sourceMappingURL=index.js.map