@dxos/client-services 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44

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 (134) hide show
  1. package/dist/lib/browser/chunk-NQSC7HOE.mjs +22 -0
  2. package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-CZSLDMSL.mjs → chunk-NTZOEM4P.mjs} +1197 -1338
  4. package/dist/lib/browser/chunk-NTZOEM4P.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
  6. package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +441 -66
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
  11. package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
  12. package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
  13. package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
  14. package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
  15. package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
  16. package/dist/lib/browser/packlets/locks/node.mjs +66 -0
  17. package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
  18. package/dist/lib/browser/testing/index.mjs +24 -12
  19. package/dist/lib/browser/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
  21. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
  22. package/dist/lib/node-esm/{chunk-EUNILIU5.mjs → chunk-DQWA5ILA.mjs} +689 -699
  23. package/dist/lib/node-esm/chunk-DQWA5ILA.mjs.map +7 -0
  24. package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
  25. package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
  26. package/dist/lib/node-esm/index.mjs +441 -66
  27. package/dist/lib/node-esm/index.mjs.map +4 -4
  28. package/dist/lib/node-esm/meta.json +1 -1
  29. package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
  30. package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
  31. package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
  32. package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
  33. package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
  34. package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
  35. package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
  36. package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
  37. package/dist/lib/node-esm/testing/index.mjs +24 -12
  38. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  39. package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
  40. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  41. package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
  42. package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
  43. package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
  44. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  45. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +2 -2
  46. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  47. package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -4
  48. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  49. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
  50. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  51. package/dist/types/src/packlets/identity/identity.d.ts +2 -2
  52. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  53. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
  54. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  55. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  56. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  57. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -3
  58. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  59. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
  60. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  61. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -2
  62. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  63. package/dist/types/src/packlets/locks/index.d.ts +1 -1
  64. package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
  65. package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
  66. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  67. package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
  68. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  69. package/dist/types/src/packlets/services/feed-syncer.d.ts +41 -0
  70. package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
  71. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  72. package/dist/types/src/packlets/services/service-context.d.ts +13 -7
  73. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  74. package/dist/types/src/packlets/services/service-host.d.ts +19 -5
  75. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  76. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  77. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -5
  78. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  79. package/dist/types/src/packlets/spaces/data-space.d.ts +2 -2
  80. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  81. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
  82. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  83. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
  84. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  85. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  86. package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
  87. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  88. package/dist/types/src/packlets/testing/test-builder.d.ts +6 -5
  89. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  90. package/dist/types/src/packlets/worker/worker-runtime.d.ts +31 -4
  91. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  92. package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
  93. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  94. package/dist/types/src/version.d.ts +1 -1
  95. package/dist/types/src/version.d.ts.map +1 -1
  96. package/dist/types/tsconfig.tsbuildinfo +1 -1
  97. package/package.json +70 -48
  98. package/src/packlets/devtools/devtools.ts +2 -2
  99. package/src/packlets/diagnostics/index.ts +1 -1
  100. package/src/packlets/identity/authenticator.ts +2 -2
  101. package/src/packlets/identity/default-space-state-machine.ts +2 -2
  102. package/src/packlets/identity/identity-manager.ts +6 -6
  103. package/src/packlets/identity/identity-recovery-manager.ts +2 -2
  104. package/src/packlets/identity/identity.ts +2 -2
  105. package/src/packlets/invitations/device-invitation-protocol.ts +5 -5
  106. package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
  107. package/src/packlets/invitations/invitation-host-extension.ts +6 -4
  108. package/src/packlets/invitations/invitation-protocol.ts +2 -3
  109. package/src/packlets/invitations/invitations-handler.ts +7 -7
  110. package/src/packlets/invitations/space-invitation-protocol.ts +7 -13
  111. package/src/packlets/locks/index.ts +1 -1
  112. package/src/packlets/logging/logging-service.ts +4 -0
  113. package/src/packlets/services/client-rpc-server.ts +4 -4
  114. package/src/packlets/services/feed-syncer.ts +227 -0
  115. package/src/packlets/services/platform.ts +7 -1
  116. package/src/packlets/services/service-context.ts +47 -21
  117. package/src/packlets/services/service-host.ts +56 -16
  118. package/src/packlets/space-export/space-archive-reader.ts +1 -1
  119. package/src/packlets/space-export/space-archive-writer.ts +3 -2
  120. package/src/packlets/spaces/data-space-manager.ts +43 -20
  121. package/src/packlets/spaces/data-space.ts +10 -6
  122. package/src/packlets/spaces/edge-feed-replicator.ts +2 -2
  123. package/src/packlets/spaces/epoch-migrations.ts +2 -2
  124. package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
  125. package/src/packlets/spaces/notarization-plugin.ts +8 -8
  126. package/src/packlets/spaces/spaces-service.ts +10 -7
  127. package/src/packlets/storage/storage.ts +4 -4
  128. package/src/packlets/testing/invitation-utils.ts +7 -4
  129. package/src/packlets/testing/test-builder.ts +36 -10
  130. package/src/packlets/worker/worker-runtime.ts +149 -11
  131. package/src/packlets/worker/worker-session.ts +4 -4
  132. package/src/version.ts +1 -1
  133. package/dist/lib/browser/chunk-CZSLDMSL.mjs.map +0 -7
  134. package/dist/lib/node-esm/chunk-EUNILIU5.mjs.map +0 -7
@@ -1,4 +1,11 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ createCollectDiagnosticsBroadcastSender
4
+ } from "./chunk-PKEGMOQ4.mjs";
5
+ import {
6
+ __export,
7
+ __reExport
8
+ } from "./chunk-2SZHAWBN.mjs";
2
9
 
3
10
  // src/packlets/devtools/feeds.ts
4
11
  import { SubscriptionList } from "@dxos/async";
@@ -396,7 +403,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
396
403
  import { TRACE_PROCESSOR } from "@dxos/tracing";
397
404
 
398
405
  // src/version.ts
399
- var DXOS_VERSION = "0.8.4-main.e8ec1fe";
406
+ var DXOS_VERSION = "0.8.4-main.ef1bc66f44";
400
407
 
401
408
  // src/packlets/services/platform.ts
402
409
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -409,11 +416,16 @@ var getPlatform = () => {
409
416
  userAgent,
410
417
  uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
411
418
  };
412
- } else {
419
+ } else if (typeof SharedWorkerGlobalScope !== "undefined") {
413
420
  return {
414
421
  type: Platform.PLATFORM_TYPE.SHARED_WORKER,
415
422
  uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
416
423
  };
424
+ } else {
425
+ return {
426
+ type: Platform.PLATFORM_TYPE.DEDICATED_WORKER,
427
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
428
+ };
417
429
  }
418
430
  } else {
419
431
  const { platform: platform2, version, arch } = process;
@@ -550,21 +562,6 @@ var getStorageDiagnostics = async () => {
550
562
  }));
551
563
  };
552
564
 
553
- // src/packlets/diagnostics/diagnostics-broadcast.ts
554
- var createCollectDiagnosticsBroadcastSender = () => {
555
- return {
556
- broadcastDiagnosticsRequest: async () => void 0
557
- };
558
- };
559
- var createCollectDiagnosticsBroadcastHandler = (_) => {
560
- return {
561
- start: () => {
562
- },
563
- stop: () => {
564
- }
565
- };
566
- };
567
-
568
565
  // src/packlets/diagnostics/diagnostics-collector.ts
569
566
  import { ClientServicesProviderResource } from "@dxos/client-protocol";
570
567
  import { ConfigResource } from "@dxos/config";
@@ -604,6 +601,15 @@ var findConfigs = () => {
604
601
  return configs.map((r) => r.instance.deref()).filter(isNonNullable);
605
602
  };
606
603
 
604
+ // src/packlets/diagnostics/index.ts
605
+ var diagnostics_exports = {};
606
+ __export(diagnostics_exports, {
607
+ DiagnosticsCollector: () => DiagnosticsCollector,
608
+ createDiagnostics: () => createDiagnostics
609
+ });
610
+ __reExport(diagnostics_exports, diagnostics_broadcast_star);
611
+ import * as diagnostics_broadcast_star from "#diagnostics-broadcast";
612
+
607
613
  // src/packlets/identity/authenticator.ts
608
614
  import { Trigger } from "@dxos/async";
609
615
  import { Context as Context2 } from "@dxos/context";
@@ -1247,7 +1253,7 @@ import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep
1247
1253
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
1248
1254
  import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1249
1255
  import { timed, warnAfterTimeout } from "@dxos/debug";
1250
- import { FIND_PARAMS as FIND_PARAMS2, createMappedFeedWriter } from "@dxos/echo-pipeline";
1256
+ import { createMappedFeedWriter } from "@dxos/echo-pipeline";
1251
1257
  import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
1252
1258
  import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
1253
1259
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -1275,15 +1281,16 @@ import { ComplexSet } from "@dxos/util";
1275
1281
  // src/packlets/spaces/data-space-manager.ts
1276
1282
  import { interpretAsDocumentId } from "@automerge/automerge-repo";
1277
1283
  import { Event as Event2, synchronized, trackLeaks } from "@dxos/async";
1278
- import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1284
+ import { SpaceProperties } from "@dxos/client-protocol";
1279
1285
  import { Context as Context4, LifecycleState, Resource as Resource2, cancelWithContext } from "@dxos/context";
1280
1286
  import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
1281
- import { ObjectId, getTypeReference } from "@dxos/echo/internal";
1282
- import { AuthStatus, CredentialServerExtension, DatabaseRoot, FIND_PARAMS, findInlineObjectOfType } from "@dxos/echo-pipeline";
1283
- import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1287
+ import { Type } from "@dxos/echo";
1288
+ import { getSchemaDXN } from "@dxos/echo/internal";
1289
+ import { AuthStatus, CredentialServerExtension, DatabaseRoot, findInlineObjectOfType } from "@dxos/echo-pipeline";
1290
+ import { EncodedReference, SpaceDocVersion, createIdFromSpaceKey } from "@dxos/echo-protocol";
1284
1291
  import { writeMessages } from "@dxos/feed-store";
1285
1292
  import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
1286
- import { PublicKey as PublicKey4 } from "@dxos/keys";
1293
+ import { ObjectId, PublicKey as PublicKey4 } from "@dxos/keys";
1287
1294
  import { log as log4 } from "@dxos/log";
1288
1295
  import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
1289
1296
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
@@ -1390,7 +1397,7 @@ var DataSpaceManager = class extends Resource2 {
1390
1397
  _edgeFeatures = void 0;
1391
1398
  _meshReplicator = void 0;
1392
1399
  _echoEdgeReplicator = void 0;
1393
- _runtimeParams = void 0;
1400
+ _runtimeProps = void 0;
1394
1401
  constructor(params) {
1395
1402
  super();
1396
1403
  this._spaceManager = params.spaceManager;
@@ -1405,17 +1412,20 @@ var DataSpaceManager = class extends Resource2 {
1405
1412
  this._edgeFeatures = params.edgeFeatures;
1406
1413
  this._echoEdgeReplicator = params.echoEdgeReplicator;
1407
1414
  this._edgeHttpClient = params.edgeHttpClient;
1408
- this._runtimeParams = params.runtimeParams;
1415
+ this._runtimeProps = params.runtimeProps;
1409
1416
  trace.diagnostic({
1410
1417
  id: "spaces",
1411
1418
  name: "Spaces",
1412
1419
  fetch: async () => {
1413
1420
  return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
1414
1421
  const rootUrl = space.automergeSpaceState.rootUrl;
1415
- const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
1422
+ const rootHandle = rootUrl ? await this._echoHost.loadDoc(Context4.default(void 0, {
1423
+ F: __dxlog_file6,
1424
+ L: 187
1425
+ }), rootUrl) : void 0;
1416
1426
  await rootHandle?.whenReady();
1417
1427
  const rootDoc = rootHandle?.doc();
1418
- const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
1428
+ const properties = rootDoc && findInlineObjectOfType(rootDoc, Type.getTypename(SpaceProperties));
1419
1429
  return {
1420
1430
  key: space.key.toHex(),
1421
1431
  state: SpaceState[space.state],
@@ -1442,7 +1452,7 @@ var DataSpaceManager = class extends Resource2 {
1442
1452
  async _open() {
1443
1453
  log4("open", void 0, {
1444
1454
  F: __dxlog_file6,
1445
- L: 216,
1455
+ L: 221,
1446
1456
  S: this,
1447
1457
  C: (f, a) => f(...a)
1448
1458
  });
@@ -1450,7 +1460,7 @@ var DataSpaceManager = class extends Resource2 {
1450
1460
  id: this._instanceId
1451
1461
  }), {
1452
1462
  F: __dxlog_file6,
1453
- L: 217,
1463
+ L: 222,
1454
1464
  S: this,
1455
1465
  C: (f, a) => f(...a)
1456
1466
  });
@@ -1458,39 +1468,64 @@ var DataSpaceManager = class extends Resource2 {
1458
1468
  spaces: this._metadataStore.spaces.length
1459
1469
  }, {
1460
1470
  F: __dxlog_file6,
1461
- L: 218,
1471
+ L: 223,
1462
1472
  S: this,
1463
1473
  C: (f, a) => f(...a)
1464
1474
  });
1475
+ const spacesToActivate = [];
1465
1476
  await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
1466
1477
  try {
1467
1478
  log4("load space", {
1468
1479
  spaceMetadata
1469
1480
  }, {
1470
1481
  F: __dxlog_file6,
1471
- L: 222,
1482
+ L: 228,
1472
1483
  S: this,
1473
1484
  C: (f, a) => f(...a)
1474
1485
  });
1475
- await this._constructSpace(spaceMetadata);
1486
+ const space = await this._constructSpace(spaceMetadata);
1487
+ if (this._runtimeProps?.autoActivateSpaces && spaceMetadata.state === SpaceState.SPACE_ACTIVE) {
1488
+ spacesToActivate.push(space);
1489
+ }
1476
1490
  } catch (err) {
1477
1491
  log4.error("Error loading space", {
1478
1492
  spaceMetadata,
1479
1493
  err
1480
1494
  }, {
1481
1495
  F: __dxlog_file6,
1482
- L: 225,
1496
+ L: 235,
1483
1497
  S: this,
1484
1498
  C: (f, a) => f(...a)
1485
1499
  });
1486
1500
  }
1487
1501
  });
1502
+ for (const space of spacesToActivate) {
1503
+ log4("auto-activating space", {
1504
+ spaceKey: space.key
1505
+ }, {
1506
+ F: __dxlog_file6,
1507
+ L: 241,
1508
+ S: this,
1509
+ C: (f, a) => f(...a)
1510
+ });
1511
+ space.activate().catch((err) => {
1512
+ log4.error("Error auto-activating space", {
1513
+ spaceKey: space.key,
1514
+ err
1515
+ }, {
1516
+ F: __dxlog_file6,
1517
+ L: 243,
1518
+ S: this,
1519
+ C: (f, a) => f(...a)
1520
+ });
1521
+ });
1522
+ }
1488
1523
  this.updated.emit();
1489
1524
  log4.trace("dxos.echo.data-space-manager.open", Trace.end({
1490
1525
  id: this._instanceId
1491
1526
  }), {
1492
1527
  F: __dxlog_file6,
1493
- L: 231,
1528
+ L: 249,
1494
1529
  S: this,
1495
1530
  C: (f, a) => f(...a)
1496
1531
  });
@@ -1498,7 +1533,7 @@ var DataSpaceManager = class extends Resource2 {
1498
1533
  async _close() {
1499
1534
  log4("close", void 0, {
1500
1535
  F: __dxlog_file6,
1501
- L: 236,
1536
+ L: 254,
1502
1537
  S: this,
1503
1538
  C: (f, a) => f(...a)
1504
1539
  });
@@ -1529,7 +1564,7 @@ var DataSpaceManager = class extends Resource2 {
1529
1564
  spaceKey
1530
1565
  }, {
1531
1566
  F: __dxlog_file6,
1532
- L: 269,
1567
+ L: 287,
1533
1568
  S: this,
1534
1569
  C: (f, a) => f(...a)
1535
1570
  });
@@ -1537,7 +1572,7 @@ var DataSpaceManager = class extends Resource2 {
1537
1572
  if (options.documents) {
1538
1573
  invariant3(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
1539
1574
  F: __dxlog_file6,
1540
- L: 274,
1575
+ L: 292,
1541
1576
  S: this,
1542
1577
  A: [
1543
1578
  "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
@@ -1549,7 +1584,7 @@ var DataSpaceManager = class extends Resource2 {
1549
1584
  documentId
1550
1585
  }, {
1551
1586
  F: __dxlog_file6,
1552
- L: 281,
1587
+ L: 299,
1553
1588
  S: this,
1554
1589
  C: (f, a) => f(...a)
1555
1590
  });
@@ -1568,7 +1603,7 @@ var DataSpaceManager = class extends Resource2 {
1568
1603
  spaceKey
1569
1604
  }, {
1570
1605
  F: __dxlog_file6,
1571
- L: 299,
1606
+ L: 317,
1572
1607
  S: this,
1573
1608
  C: (f, a) => f(...a)
1574
1609
  });
@@ -1577,7 +1612,7 @@ var DataSpaceManager = class extends Resource2 {
1577
1612
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
1578
1613
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
1579
1614
  F: __dxlog_file6,
1580
- L: 304
1615
+ L: 322
1581
1616
  }), newRootDocId);
1582
1617
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
1583
1618
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
@@ -1589,7 +1624,7 @@ var DataSpaceManager = class extends Resource2 {
1589
1624
  spaceKey
1590
1625
  }, {
1591
1626
  F: __dxlog_file6,
1592
- L: 313,
1627
+ L: 331,
1593
1628
  S: this,
1594
1629
  C: (f, a) => f(...a)
1595
1630
  });
@@ -1599,7 +1634,7 @@ var DataSpaceManager = class extends Resource2 {
1599
1634
  spaceKey
1600
1635
  }, {
1601
1636
  F: __dxlog_file6,
1602
- L: 318,
1637
+ L: 336,
1603
1638
  S: this,
1604
1639
  C: (f, a) => f(...a)
1605
1640
  });
@@ -1608,7 +1643,7 @@ var DataSpaceManager = class extends Resource2 {
1608
1643
  const memberCredential = credentials[1];
1609
1644
  invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1610
1645
  F: __dxlog_file6,
1611
- L: 324,
1646
+ L: 342,
1612
1647
  S: this,
1613
1648
  A: [
1614
1649
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1622,7 +1657,7 @@ var DataSpaceManager = class extends Resource2 {
1622
1657
  spaceKey
1623
1658
  }, {
1624
1659
  F: __dxlog_file6,
1625
- L: 329,
1660
+ L: 347,
1626
1661
  S: this,
1627
1662
  C: (f, a) => f(...a)
1628
1663
  });
@@ -1640,13 +1675,13 @@ var DataSpaceManager = class extends Resource2 {
1640
1675
  spaceId: space.id
1641
1676
  }, {
1642
1677
  F: __dxlog_file6,
1643
- L: 342,
1678
+ L: 360,
1644
1679
  S: this,
1645
1680
  C: (f, a) => f(...a)
1646
1681
  });
1647
1682
  await space.databaseRoot.handle.whenReady();
1648
1683
  }
1649
- const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), TYPE_PROPERTIES) ?? [];
1684
+ const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), Type.getTypename(SpaceProperties)) ?? [];
1650
1685
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
1651
1686
  }
1652
1687
  case SpaceDocVersion.LEGACY: {
@@ -1658,7 +1693,7 @@ var DataSpaceManager = class extends Resource2 {
1658
1693
  spaceId: space.id
1659
1694
  }, {
1660
1695
  F: __dxlog_file6,
1661
- L: 353,
1696
+ L: 374,
1662
1697
  S: this,
1663
1698
  C: (f, a) => f(...a)
1664
1699
  });
@@ -1670,7 +1705,7 @@ var DataSpaceManager = class extends Resource2 {
1670
1705
  const document = await this._getSpaceRootDocument(space);
1671
1706
  const properties = {
1672
1707
  system: {
1673
- type: encodeReference(getTypeReference(PropertiesType))
1708
+ type: EncodedReference.fromDXN(getSchemaDXN(SpaceProperties))
1674
1709
  },
1675
1710
  data: {
1676
1711
  [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
@@ -1693,14 +1728,19 @@ var DataSpaceManager = class extends Resource2 {
1693
1728
  const automergeIndex = space.automergeSpaceState.rootUrl;
1694
1729
  invariant3(automergeIndex, void 0, {
1695
1730
  F: __dxlog_file6,
1696
- L: 386,
1731
+ L: 407,
1697
1732
  S: this,
1698
1733
  A: [
1699
1734
  "automergeIndex",
1700
1735
  ""
1701
1736
  ]
1702
1737
  });
1703
- const document = await this._echoHost.automergeRepo.find(automergeIndex, FIND_PARAMS);
1738
+ const document = await this._echoHost.loadDoc(Context4.default(void 0, {
1739
+ F: __dxlog_file6,
1740
+ L: 408
1741
+ }), automergeIndex, {
1742
+ fetchFromNetwork: true
1743
+ });
1704
1744
  await document.whenReady();
1705
1745
  return document;
1706
1746
  }
@@ -1710,13 +1750,13 @@ var DataSpaceManager = class extends Resource2 {
1710
1750
  opts
1711
1751
  }, {
1712
1752
  F: __dxlog_file6,
1713
- L: 395,
1753
+ L: 418,
1714
1754
  S: this,
1715
1755
  C: (f, a) => f(...a)
1716
1756
  });
1717
1757
  invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
1718
1758
  F: __dxlog_file6,
1719
- L: 396,
1759
+ L: 419,
1720
1760
  S: this,
1721
1761
  A: [
1722
1762
  "this._lifecycleState === LifecycleState.OPEN",
@@ -1725,7 +1765,7 @@ var DataSpaceManager = class extends Resource2 {
1725
1765
  });
1726
1766
  invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
1727
1767
  F: __dxlog_file6,
1728
- L: 397,
1768
+ L: 420,
1729
1769
  S: this,
1730
1770
  A: [
1731
1771
  "!this._spaces.has(opts.spaceKey)",
@@ -1749,7 +1789,7 @@ var DataSpaceManager = class extends Resource2 {
1749
1789
  const space = this._spaceManager.spaces.get(options.spaceKey);
1750
1790
  invariant3(space, void 0, {
1751
1791
  F: __dxlog_file6,
1752
- L: 417,
1792
+ L: 440,
1753
1793
  S: this,
1754
1794
  A: [
1755
1795
  "space",
@@ -1762,7 +1802,7 @@ var DataSpaceManager = class extends Resource2 {
1762
1802
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
1763
1803
  invariant3(credentials[0].credential, void 0, {
1764
1804
  F: __dxlog_file6,
1765
- L: 436,
1805
+ L: 459,
1766
1806
  S: this,
1767
1807
  A: [
1768
1808
  "credentials[0].credential",
@@ -1772,7 +1812,7 @@ var DataSpaceManager = class extends Resource2 {
1772
1812
  const spaceMemberCredential = credentials[0].credential.credential;
1773
1813
  invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1774
1814
  F: __dxlog_file6,
1775
- L: 438,
1815
+ L: 461,
1776
1816
  S: this,
1777
1817
  A: [
1778
1818
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1810,7 +1850,7 @@ var DataSpaceManager = class extends Resource2 {
1810
1850
  const space = this._spaces.get(spaceKey);
1811
1851
  invariant3(space, "Space not found.", {
1812
1852
  F: __dxlog_file6,
1813
- L: 475,
1853
+ L: 498,
1814
1854
  S: this,
1815
1855
  A: [
1816
1856
  "space",
@@ -1835,7 +1875,7 @@ var DataSpaceManager = class extends Resource2 {
1835
1875
  metadata
1836
1876
  }, {
1837
1877
  F: __dxlog_file6,
1838
- L: 494,
1878
+ L: 517,
1839
1879
  S: this,
1840
1880
  C: (f, a) => f(...a)
1841
1881
  });
@@ -1843,8 +1883,8 @@ var DataSpaceManager = class extends Resource2 {
1843
1883
  localPeerId: this._signingContext.deviceKey
1844
1884
  });
1845
1885
  const presence = new Presence({
1846
- announceInterval: this._runtimeParams?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
1847
- offlineTimeout: this._runtimeParams?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
1886
+ announceInterval: this._runtimeProps?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
1887
+ offlineTimeout: this._runtimeProps?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
1848
1888
  identityKey: this._signingContext.identityKey,
1849
1889
  gossip
1850
1890
  });
@@ -1879,7 +1919,7 @@ var DataSpaceManager = class extends Resource2 {
1879
1919
  err
1880
1920
  }, {
1881
1921
  F: __dxlog_file6,
1882
- L: 536,
1922
+ L: 559,
1883
1923
  S: this,
1884
1924
  C: (f, a) => f(...a)
1885
1925
  });
@@ -1889,7 +1929,7 @@ var DataSpaceManager = class extends Resource2 {
1889
1929
  onAuthFailure: () => {
1890
1930
  log4.warn("auth failure", void 0, {
1891
1931
  F: __dxlog_file6,
1892
- L: 541,
1932
+ L: 564,
1893
1933
  S: this,
1894
1934
  C: (f, a) => f(...a)
1895
1935
  });
@@ -1922,7 +1962,7 @@ var DataSpaceManager = class extends Resource2 {
1922
1962
  space: space.key
1923
1963
  }, {
1924
1964
  F: __dxlog_file6,
1925
- L: 568,
1965
+ L: 591,
1926
1966
  S: this,
1927
1967
  C: (f, a) => f(...a)
1928
1968
  });
@@ -1933,7 +1973,7 @@ var DataSpaceManager = class extends Resource2 {
1933
1973
  open: this._lifecycleState === LifecycleState.OPEN
1934
1974
  }, {
1935
1975
  F: __dxlog_file6,
1936
- L: 571,
1976
+ L: 594,
1937
1977
  S: this,
1938
1978
  C: (f, a) => f(...a)
1939
1979
  });
@@ -1952,7 +1992,7 @@ var DataSpaceManager = class extends Resource2 {
1952
1992
  space: space.key
1953
1993
  }, {
1954
1994
  F: __dxlog_file6,
1955
- L: 579,
1995
+ L: 602,
1956
1996
  S: this,
1957
1997
  C: (f, a) => f(...a)
1958
1998
  });
@@ -1962,7 +2002,7 @@ var DataSpaceManager = class extends Resource2 {
1962
2002
  edgeConnection: this._edgeConnection,
1963
2003
  edgeHttpClient: this._edgeHttpClient,
1964
2004
  edgeFeatures: this._edgeFeatures,
1965
- activeEdgeNotarizationPollingInterval: this._runtimeParams?.activeEdgeNotarizationPollingInterval
2005
+ activeEdgeNotarizationPollingInterval: this._runtimeProps?.activeEdgeNotarizationPollingInterval
1966
2006
  });
1967
2007
  dataSpace.postOpen.append(async () => {
1968
2008
  const setting = dataSpace.getEdgeReplicationSetting();
@@ -1973,7 +2013,7 @@ var DataSpaceManager = class extends Resource2 {
1973
2013
  spaceId: dataSpace.id
1974
2014
  }, {
1975
2015
  F: __dxlog_file6,
1976
- L: 593,
2016
+ L: 616,
1977
2017
  S: this,
1978
2018
  C: (f, a) => f(...a)
1979
2019
  });
@@ -2003,7 +2043,7 @@ var DataSpaceManager = class extends Resource2 {
2003
2043
  space: space.key
2004
2044
  }, {
2005
2045
  F: __dxlog_file6,
2006
- L: 620,
2046
+ L: 643,
2007
2047
  S: this,
2008
2048
  C: (f, a) => f(...a)
2009
2049
  });
@@ -2036,7 +2076,7 @@ var DataSpaceManager = class extends Resource2 {
2036
2076
  closedSessions
2037
2077
  }, {
2038
2078
  F: __dxlog_file6,
2039
- L: 646,
2079
+ L: 669,
2040
2080
  S: this,
2041
2081
  C: (f, a) => f(...a)
2042
2082
  });
@@ -2051,7 +2091,7 @@ var DataSpaceManager = class extends Resource2 {
2051
2091
  peerId: peerState.peerId
2052
2092
  }, {
2053
2093
  F: __dxlog_file6,
2054
- L: 660,
2094
+ L: 683,
2055
2095
  S: this,
2056
2096
  C: (f, a) => f(...a)
2057
2097
  });
@@ -2128,6 +2168,7 @@ import { trace as trace2 } from "@dxos/tracing";
2128
2168
  import { Resource as Resource3 } from "@dxos/context";
2129
2169
  import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
2130
2170
  import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
2171
+ import { createFilename } from "@dxos/util";
2131
2172
  var CURRENT_VERSION = SpaceArchiveVersion.V1;
2132
2173
  var SpaceArchiveWriter = class extends Resource3 {
2133
2174
  _tar;
@@ -2160,6 +2201,7 @@ var SpaceArchiveWriter = class extends Resource3 {
2160
2201
  async finish() {
2161
2202
  assertState2(this._archive, "Not open");
2162
2203
  assertState2(this._meta, "Not started");
2204
+ assertState2(this._meta.spaceId, "No space ID set");
2163
2205
  assertState2(this._currentRootUrl, "No root URL set");
2164
2206
  const metadata = {
2165
2207
  version: CURRENT_VERSION,
@@ -2173,8 +2215,12 @@ var SpaceArchiveWriter = class extends Resource3 {
2173
2215
  this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
2174
2216
  const binary = this._archive.toUint8Array();
2175
2217
  return {
2176
- // TODO(wittjosiah): Factor out file name construction.
2177
- filename: `${(/* @__PURE__ */ new Date()).toISOString()}-${this._meta.spaceId}.tar`,
2218
+ filename: createFilename({
2219
+ parts: [
2220
+ this._meta.spaceId
2221
+ ],
2222
+ ext: "tar"
2223
+ }),
2178
2224
  contents: binary
2179
2225
  };
2180
2226
  }
@@ -2205,7 +2251,7 @@ var extractSpaceArchive = async (archive) => {
2205
2251
  });
2206
2252
  documents[documentId] = entry2.content ?? failedInvariant2();
2207
2253
  }
2208
- log5.info("extracted space archive", {
2254
+ log5("extracted space archive", {
2209
2255
  metadata,
2210
2256
  documents
2211
2257
  }, {
@@ -2315,7 +2361,9 @@ var SpacesServiceImpl = class {
2315
2361
  await space.deactivate();
2316
2362
  break;
2317
2363
  default:
2318
- throw new ApiError("Invalid space state");
2364
+ throw new ApiError({
2365
+ message: "Invalid space state"
2366
+ });
2319
2367
  }
2320
2368
  }
2321
2369
  if (edgeReplication !== void 0) {
@@ -2329,15 +2377,18 @@ var SpacesServiceImpl = class {
2329
2377
  throw new SpaceNotFoundError(request.spaceKey);
2330
2378
  }
2331
2379
  if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
2332
- throw new AuthorizationError("No member management permission.", {
2333
- spaceKey: space.key,
2334
- role: space.spaceState.getMemberRole(identity.identityKey)
2380
+ throw new AuthorizationError({
2381
+ message: "No member management permission.",
2382
+ context: {
2383
+ spaceKey: space.key,
2384
+ role: space.spaceState.getMemberRole(identity.identityKey)
2385
+ }
2335
2386
  });
2336
2387
  }
2337
2388
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2338
2389
  invariant5(credentials[0].credential, void 0, {
2339
2390
  F: __dxlog_file8,
2340
- L: 120,
2391
+ L: 123,
2341
2392
  S: this,
2342
2393
  A: [
2343
2394
  "credentials[0].credential",
@@ -2347,7 +2398,7 @@ var SpacesServiceImpl = class {
2347
2398
  const spaceMemberCredential = credentials[0].credential.credential;
2348
2399
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2349
2400
  F: __dxlog_file8,
2350
- L: 122,
2401
+ L: 125,
2351
2402
  S: this,
2352
2403
  A: [
2353
2404
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2365,7 +2416,7 @@ var SpacesServiceImpl = class {
2365
2416
  ids: spaces.map((space) => space.id)
2366
2417
  }), {
2367
2418
  F: __dxlog_file8,
2368
- L: 135,
2419
+ L: 138,
2369
2420
  S: this,
2370
2421
  C: (f, a) => f(...a)
2371
2422
  });
@@ -2457,7 +2508,7 @@ var SpacesServiceImpl = class {
2457
2508
  } else {
2458
2509
  invariant5(!credential.id, "Id on unsigned credentials is not allowed", {
2459
2510
  F: __dxlog_file8,
2460
- L: 233,
2511
+ L: 236,
2461
2512
  S: this,
2462
2513
  A: [
2463
2514
  "!credential.id",
@@ -2466,7 +2517,7 @@ var SpacesServiceImpl = class {
2466
2517
  });
2467
2518
  invariant5(this._identityManager.identity, "Identity is not available", {
2468
2519
  F: __dxlog_file8,
2469
- L: 234,
2520
+ L: 237,
2470
2521
  S: this,
2471
2522
  A: [
2472
2523
  "this._identityManager.identity",
@@ -2476,7 +2527,7 @@ var SpacesServiceImpl = class {
2476
2527
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2477
2528
  invariant5(credential.issuer.equals(signer.getIssuer()), void 0, {
2478
2529
  F: __dxlog_file8,
2479
- L: 236,
2530
+ L: 239,
2480
2531
  S: this,
2481
2532
  A: [
2482
2533
  "credential.issuer.equals(signer.getIssuer())",
@@ -2559,7 +2610,7 @@ var SpacesServiceImpl = class {
2559
2610
  const extracted = await extractSpaceArchive(request.archive);
2560
2611
  invariant5(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
2561
2612
  F: __dxlog_file8,
2562
- L: 290,
2613
+ L: 293,
2563
2614
  S: this,
2564
2615
  A: [
2565
2616
  "extracted.metadata.echo?.currentRootUrl",
@@ -2579,7 +2630,7 @@ var SpacesServiceImpl = class {
2579
2630
  const assertion = getCredentialAssertion2(credential);
2580
2631
  invariant5(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2581
2632
  F: __dxlog_file8,
2582
- L: 301,
2633
+ L: 304,
2583
2634
  S: this,
2584
2635
  A: [
2585
2636
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2589,7 +2640,7 @@ var SpacesServiceImpl = class {
2589
2640
  const myIdentity = this._identityManager.identity;
2590
2641
  invariant5(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2591
2642
  F: __dxlog_file8,
2592
- L: 303,
2643
+ L: 306,
2593
2644
  S: this,
2594
2645
  A: [
2595
2646
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2658,7 +2709,9 @@ var SpacesServiceImpl = class {
2658
2709
  }
2659
2710
  _requireIdentity() {
2660
2711
  if (!this._identityManager.identity) {
2661
- throw new IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
2712
+ throw new IdentityNotInitializedError({
2713
+ message: "This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo"
2714
+ });
2662
2715
  }
2663
2716
  return this._identityManager.identity;
2664
2717
  }
@@ -3698,7 +3751,7 @@ var LOAD_DOC_TIMEOUT = 1e4;
3698
3751
  var runEpochMigration = async (ctx, context) => {
3699
3752
  switch (context.migration) {
3700
3753
  case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3701
- const document = context.echoHost.createDoc();
3754
+ const document = await context.echoHost.createDoc();
3702
3755
  await context.echoHost.flush();
3703
3756
  return {
3704
3757
  newRoot: document.url
@@ -3711,7 +3764,7 @@ var runEpochMigration = async (ctx, context) => {
3711
3764
  const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
3712
3765
  timeout: LOAD_DOC_TIMEOUT
3713
3766
  });
3714
- const newRoot = context.echoHost.createDoc(rootHandle.doc());
3767
+ const newRoot = await context.echoHost.createDoc(rootHandle.doc());
3715
3768
  await context.echoHost.flush();
3716
3769
  return {
3717
3770
  newRoot: newRoot.url
@@ -4151,7 +4204,7 @@ _ts_decorate5([
4151
4204
  logInfo2
4152
4205
  ], NotarizationPlugin.prototype, "_spaceId", void 0);
4153
4206
  var handleEdgeError = (error) => {
4154
- if (!(error instanceof EdgeCallFailedError) || error.errorData) {
4207
+ if (!(error instanceof EdgeCallFailedError) || error.data) {
4155
4208
  log11.catch(error, void 0, {
4156
4209
  F: __dxlog_file14,
4157
4210
  L: 396,
@@ -4160,7 +4213,7 @@ var handleEdgeError = (error) => {
4160
4213
  });
4161
4214
  } else {
4162
4215
  log11.info("Edge notarization failure", {
4163
- reason: error.reason
4216
+ message: error.message
4164
4217
  }, {
4165
4218
  F: __dxlog_file14,
4166
4219
  L: 398,
@@ -4276,7 +4329,7 @@ var __dxlog_file15 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/s
4276
4329
  var DataSpace = class {
4277
4330
  _ctx = new Context6(void 0, {
4278
4331
  F: __dxlog_file15,
4279
- L: 101
4332
+ L: 100
4280
4333
  });
4281
4334
  _inner;
4282
4335
  _gossip;
@@ -4338,7 +4391,7 @@ var DataSpace = class {
4338
4391
  state: SpaceState4[this._state]
4339
4392
  }, {
4340
4393
  F: __dxlog_file15,
4341
- L: 177,
4394
+ L: 176,
4342
4395
  S: this,
4343
4396
  C: (f, a) => f(...a)
4344
4397
  });
@@ -4397,7 +4450,7 @@ var DataSpace = class {
4397
4450
  }
4398
4451
  await this._inner.open(new Context6(void 0, {
4399
4452
  F: __dxlog_file15,
4400
- L: 251
4453
+ L: 250
4401
4454
  }));
4402
4455
  await this._inner.startProtocol();
4403
4456
  await this._edgeFeedReplicator?.open();
@@ -4406,7 +4459,7 @@ var DataSpace = class {
4406
4459
  state: SpaceState4[this._state]
4407
4460
  }, {
4408
4461
  F: __dxlog_file15,
4409
- L: 257,
4462
+ L: 256,
4410
4463
  S: this,
4411
4464
  C: (f, a) => f(...a)
4412
4465
  });
@@ -4426,14 +4479,14 @@ var DataSpace = class {
4426
4479
  state: SpaceState4[this._state]
4427
4480
  }, {
4428
4481
  F: __dxlog_file15,
4429
- L: 276,
4482
+ L: 275,
4430
4483
  S: this,
4431
4484
  C: (f, a) => f(...a)
4432
4485
  });
4433
4486
  await this._ctx.dispose();
4434
4487
  this._ctx = new Context6(void 0, {
4435
4488
  F: __dxlog_file15,
4436
- L: 278
4489
+ L: 277
4437
4490
  });
4438
4491
  if (this._edgeFeedReplicator) {
4439
4492
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4466,7 +4519,7 @@ var DataSpace = class {
4466
4519
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
4467
4520
  log12("data pipeline initialization cancelled", err, {
4468
4521
  F: __dxlog_file15,
4469
- L: 316,
4522
+ L: 315,
4470
4523
  S: this,
4471
4524
  C: (f, a) => f(...a)
4472
4525
  });
@@ -4474,7 +4527,7 @@ var DataSpace = class {
4474
4527
  }
4475
4528
  log12.error("Error initializing data pipeline", err, {
4476
4529
  F: __dxlog_file15,
4477
- L: 320,
4530
+ L: 319,
4478
4531
  S: this,
4479
4532
  C: (f, a) => f(...a)
4480
4533
  });
@@ -4483,7 +4536,7 @@ var DataSpace = class {
4483
4536
  state: SpaceState4[this._state]
4484
4537
  }, {
4485
4538
  F: __dxlog_file15,
4486
- L: 322,
4539
+ L: 321,
4487
4540
  S: this,
4488
4541
  C: (f, a) => f(...a)
4489
4542
  });
@@ -4496,20 +4549,22 @@ var DataSpace = class {
4496
4549
  }
4497
4550
  async initializeDataPipeline() {
4498
4551
  if (this._state !== SpaceState4.SPACE_CONTROL_ONLY) {
4499
- throw new SystemError("Invalid operation");
4552
+ throw new SystemError({
4553
+ message: "Invalid operation"
4554
+ });
4500
4555
  }
4501
4556
  this._state = SpaceState4.SPACE_INITIALIZING;
4502
4557
  log12("new state", {
4503
4558
  state: SpaceState4[this._state]
4504
4559
  }, {
4505
4560
  F: __dxlog_file15,
4506
- L: 338,
4561
+ L: 337,
4507
4562
  S: this,
4508
4563
  C: (f, a) => f(...a)
4509
4564
  });
4510
4565
  log12("initializing control pipeline", void 0, {
4511
4566
  F: __dxlog_file15,
4512
- L: 340,
4567
+ L: 339,
4513
4568
  S: this,
4514
4569
  C: (f, a) => f(...a)
4515
4570
  });
@@ -4518,21 +4573,21 @@ var DataSpace = class {
4518
4573
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4519
4574
  log12("initializing automerge root", void 0, {
4520
4575
  F: __dxlog_file15,
4521
- L: 348,
4576
+ L: 347,
4522
4577
  S: this,
4523
4578
  C: (f, a) => f(...a)
4524
4579
  });
4525
4580
  this._automergeSpaceState.startProcessingRootDocs();
4526
4581
  log12("waiting for space to be ready", void 0, {
4527
4582
  F: __dxlog_file15,
4528
- L: 352,
4583
+ L: 351,
4529
4584
  S: this,
4530
4585
  C: (f, a) => f(...a)
4531
4586
  });
4532
4587
  await ready;
4533
4588
  log12("space is ready", void 0, {
4534
4589
  F: __dxlog_file15,
4535
- L: 354,
4590
+ L: 353,
4536
4591
  S: this,
4537
4592
  C: (f, a) => f(...a)
4538
4593
  });
@@ -4540,7 +4595,7 @@ var DataSpace = class {
4540
4595
  async *getAllDocuments() {
4541
4596
  invariant11(this._databaseRoot, "Space is not ready", {
4542
4597
  F: __dxlog_file15,
4543
- L: 358,
4598
+ L: 357,
4544
4599
  S: this,
4545
4600
  A: [
4546
4601
  "this._databaseRoot",
@@ -4556,7 +4611,7 @@ var DataSpace = class {
4556
4611
  for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
4557
4612
  const data = await this._echoHost.exportDoc(Context6.default(void 0, {
4558
4613
  F: __dxlog_file15,
4559
- L: 364
4614
+ L: 363
4560
4615
  }), documentUrl);
4561
4616
  yield [
4562
4617
  documentUrl.replace(/^automerge:/, ""),
@@ -4571,7 +4626,7 @@ var DataSpace = class {
4571
4626
  state: SpaceState4[this._state]
4572
4627
  }, {
4573
4628
  F: __dxlog_file15,
4574
- L: 373,
4629
+ L: 372,
4575
4630
  S: this,
4576
4631
  C: (f, a) => f(...a)
4577
4632
  });
@@ -4588,7 +4643,7 @@ var DataSpace = class {
4588
4643
  await this._createWritableFeeds();
4589
4644
  log12("writable feeds created", void 0, {
4590
4645
  F: __dxlog_file15,
4591
- L: 390,
4646
+ L: 389,
4592
4647
  S: this,
4593
4648
  C: (f, a) => f(...a)
4594
4649
  });
@@ -4642,7 +4697,7 @@ var DataSpace = class {
4642
4697
  count: credentials.length
4643
4698
  }, {
4644
4699
  F: __dxlog_file15,
4645
- L: 448,
4700
+ L: 447,
4646
4701
  S: this,
4647
4702
  C: (f, a) => f(...a)
4648
4703
  });
@@ -4653,14 +4708,17 @@ var DataSpace = class {
4653
4708
  });
4654
4709
  log12("credentials notarized", void 0, {
4655
4710
  F: __dxlog_file15,
4656
- L: 452,
4711
+ L: 451,
4657
4712
  S: this,
4658
4713
  C: (f, a) => f(...a)
4659
4714
  });
4660
4715
  } catch (err) {
4716
+ if (err instanceof ContextDisposedError) {
4717
+ return;
4718
+ }
4661
4719
  log12.error("error notarizing credentials for feed admission", err, {
4662
4720
  F: __dxlog_file15,
4663
- L: 454,
4721
+ L: 456,
4664
4722
  S: this,
4665
4723
  C: (f, a) => f(...a)
4666
4724
  });
@@ -4675,7 +4733,7 @@ var DataSpace = class {
4675
4733
  rootUrl
4676
4734
  }, {
4677
4735
  F: __dxlog_file15,
4678
- L: 464,
4736
+ L: 466,
4679
4737
  S: this,
4680
4738
  C: (f, a) => f(...a)
4681
4739
  });
@@ -4689,7 +4747,12 @@ var DataSpace = class {
4689
4747
  };
4690
4748
  try {
4691
4749
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4692
- handle = await cancelWithContext2(this._ctx, this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS2));
4750
+ handle = await cancelWithContext2(this._ctx, this._echoHost.loadDoc(Context6.default(void 0, {
4751
+ F: __dxlog_file15,
4752
+ L: 476
4753
+ }), rootUrl, {
4754
+ fetchFromNetwork: true
4755
+ }));
4693
4756
  await cancelWithContext2(this._ctx, handle.whenReady());
4694
4757
  });
4695
4758
  if (this._ctx.disposed) {
@@ -4730,7 +4793,7 @@ var DataSpace = class {
4730
4793
  err
4731
4794
  }, {
4732
4795
  F: __dxlog_file15,
4733
- L: 511,
4796
+ L: 515,
4734
4797
  S: this,
4735
4798
  C: (f, a) => f(...a)
4736
4799
  });
@@ -4820,7 +4883,7 @@ var DataSpace = class {
4820
4883
  state: SpaceState4[this._state]
4821
4884
  }, {
4822
4885
  F: __dxlog_file15,
4823
- L: 593,
4886
+ L: 597,
4824
4887
  S: this,
4825
4888
  C: (f, a) => f(...a)
4826
4889
  });
@@ -4951,7 +5014,9 @@ var DeviceInvitationProtocol = class {
4951
5014
  try {
4952
5015
  const identity = this._getIdentity();
4953
5016
  if (identity) {
4954
- return new AlreadyJoinedError2("Currently only one identity per client is supported.");
5017
+ return new AlreadyJoinedError2({
5018
+ message: "Currently only one identity per client is supported."
5019
+ });
4955
5020
  }
4956
5021
  } catch {
4957
5022
  }
@@ -5322,10 +5387,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5322
5387
  C: (f, a) => f(...a)
5323
5388
  });
5324
5389
  if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
5325
- throw new InvalidInvitationExtensionRoleError(void 0, {
5326
- expected: InvitationOptions.Role.HOST,
5327
- remoteOptions: this._remoteOptions,
5328
- remotePeerId: context.remotePeerId
5390
+ throw new InvalidInvitationExtensionRoleError({
5391
+ context: {
5392
+ expected: InvitationOptions.Role.HOST,
5393
+ remoteOptions: this._remoteOptions,
5394
+ remotePeerId: context.remotePeerId
5395
+ }
5329
5396
  });
5330
5397
  }
5331
5398
  this._callbacks.onOpen(this._ctx, context);
@@ -5351,7 +5418,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5351
5418
  this._invitationFlowLock = null;
5352
5419
  log14.verbose("invitation flow lock released", void 0, {
5353
5420
  F: __dxlog_file18,
5354
- L: 131,
5421
+ L: 133,
5355
5422
  S: this,
5356
5423
  C: (f, a) => f(...a)
5357
5424
  });
@@ -5657,10 +5724,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
5657
5724
  C: (f, a) => f(...a)
5658
5725
  });
5659
5726
  if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
5660
- throw new InvalidInvitationExtensionRoleError2(void 0, {
5661
- expected: InvitationOptions2.Role.GUEST,
5662
- remoteOptions: this._remoteOptions,
5663
- remotePeerId: context.remotePeerId
5727
+ throw new InvalidInvitationExtensionRoleError2({
5728
+ context: {
5729
+ expected: InvitationOptions2.Role.GUEST,
5730
+ remoteOptions: this._remoteOptions,
5731
+ remotePeerId: context.remotePeerId
5732
+ }
5664
5733
  });
5665
5734
  }
5666
5735
  this._callbacks.onStateUpdate(Invitation5.State.CONNECTED);
@@ -5705,7 +5774,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
5705
5774
  this._invitationFlowLock = null;
5706
5775
  log15.verbose("invitation flow lock released", void 0, {
5707
5776
  F: __dxlog_file19,
5708
- L: 299,
5777
+ L: 301,
5709
5778
  S: this,
5710
5779
  C: (f, a) => f(...a)
5711
5780
  });
@@ -5905,14 +5974,14 @@ var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
5905
5974
  var InvitationsHandler = class {
5906
5975
  _networkManager;
5907
5976
  _edgeClient;
5908
- _connectionParams;
5977
+ _connectionProps;
5909
5978
  /**
5910
5979
  * @internal
5911
5980
  */
5912
- constructor(_networkManager, _edgeClient, _connectionParams) {
5981
+ constructor(_networkManager, _edgeClient, _connectionProps) {
5913
5982
  this._networkManager = _networkManager;
5914
5983
  this._edgeClient = _edgeClient;
5915
- this._connectionParams = _connectionParams;
5984
+ this._connectionProps = _connectionProps;
5916
5985
  }
5917
5986
  handleInvitationFlow(ctx, stream, protocol, invitation) {
5918
5987
  log18.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
@@ -6356,7 +6425,7 @@ var InvitationsHandler = class {
6356
6425
  });
6357
6426
  return extension;
6358
6427
  };
6359
- const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
6428
+ const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionProps?.edgeInvitations, this._edgeClient, {
6360
6429
  onInvitationSuccess: async (admissionResponse, admissionRequest) => {
6361
6430
  const result = await protocol.accept(admissionResponse, admissionRequest);
6362
6431
  log18.info("admitted by edge", {
@@ -6416,7 +6485,7 @@ var InvitationsHandler = class {
6416
6485
  topic: invitation.swarmKey,
6417
6486
  protocolProvider: createTeleportProtocolFactory(async (teleport) => {
6418
6487
  teleport.addExtension("dxos.halo.invitations", extensionFactory());
6419
- }, this._connectionParams?.teleport),
6488
+ }, this._connectionProps?.teleport),
6420
6489
  topology: new InvitationTopology(role),
6421
6490
  label
6422
6491
  });
@@ -6488,7 +6557,9 @@ var InvitationsHandler = class {
6488
6557
  var checkInvitation = (protocol, invitation) => {
6489
6558
  const expiresOn = getExpirationTime(invitation);
6490
6559
  if (expiresOn && expiresOn.getTime() < Date.now()) {
6491
- return new InvalidInvitationError("Invitation already expired.");
6560
+ return new InvalidInvitationError({
6561
+ message: "Invitation already expired."
6562
+ });
6492
6563
  }
6493
6564
  return protocol.checkInvitation(invitation);
6494
6565
  };
@@ -6631,21 +6702,25 @@ var SpaceInvitationProtocol = class {
6631
6702
  }
6632
6703
  checkCanInviteNewMembers() {
6633
6704
  if (this._spaceKey == null) {
6634
- return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6705
+ return new InvalidInvitationError2({
6706
+ message: "No spaceKey was provided for a space invitation."
6707
+ });
6635
6708
  }
6636
6709
  const space = this._spaceManager.spaces.get(this._spaceKey);
6637
6710
  if (space == null) {
6638
6711
  return new SpaceNotFoundError2(this._spaceKey);
6639
6712
  }
6640
6713
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
6641
- return new AuthorizationError2("No member management permission.");
6714
+ return new AuthorizationError2({
6715
+ message: "No member management permission."
6716
+ });
6642
6717
  }
6643
6718
  return void 0;
6644
6719
  }
6645
6720
  getInvitationContext() {
6646
6721
  invariant18(this._spaceKey, void 0, {
6647
6722
  F: __dxlog_file23,
6648
- L: 66,
6723
+ L: 60,
6649
6724
  S: this,
6650
6725
  A: [
6651
6726
  "this._spaceKey",
@@ -6655,7 +6730,7 @@ var SpaceInvitationProtocol = class {
6655
6730
  const space = this._spaceManager.spaces.get(this._spaceKey);
6656
6731
  invariant18(space, void 0, {
6657
6732
  F: __dxlog_file23,
6658
- L: 68,
6733
+ L: 62,
6659
6734
  S: this,
6660
6735
  A: [
6661
6736
  "space",
@@ -6671,7 +6746,7 @@ var SpaceInvitationProtocol = class {
6671
6746
  async admit(invitation, request, guestProfile) {
6672
6747
  invariant18(this._spaceKey && request.space, void 0, {
6673
6748
  F: __dxlog_file23,
6674
- L: 81,
6749
+ L: 75,
6675
6750
  S: this,
6676
6751
  A: [
6677
6752
  "this._spaceKey && request.space",
@@ -6683,7 +6758,7 @@ var SpaceInvitationProtocol = class {
6683
6758
  guest: request.space.deviceKey
6684
6759
  }, {
6685
6760
  F: __dxlog_file23,
6686
- L: 82,
6761
+ L: 76,
6687
6762
  S: this,
6688
6763
  C: (f, a) => f(...a)
6689
6764
  });
@@ -6705,7 +6780,7 @@ var SpaceInvitationProtocol = class {
6705
6780
  async delegate(invitation) {
6706
6781
  invariant18(this._spaceKey, void 0, {
6707
6782
  F: __dxlog_file23,
6708
- L: 102,
6783
+ L: 96,
6709
6784
  S: this,
6710
6785
  A: [
6711
6786
  "this._spaceKey",
@@ -6715,7 +6790,7 @@ var SpaceInvitationProtocol = class {
6715
6790
  const space = this._spaceManager.spaces.get(this._spaceKey);
6716
6791
  invariant18(space, void 0, {
6717
6792
  F: __dxlog_file23,
6718
- L: 104,
6793
+ L: 98,
6719
6794
  S: this,
6720
6795
  A: [
6721
6796
  "space",
@@ -6725,7 +6800,7 @@ var SpaceInvitationProtocol = class {
6725
6800
  if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6726
6801
  invariant18(invitation.guestKeypair?.publicKey, void 0, {
6727
6802
  F: __dxlog_file23,
6728
- L: 106,
6803
+ L: 100,
6729
6804
  S: this,
6730
6805
  A: [
6731
6806
  "invitation.guestKeypair?.publicKey",
@@ -6738,7 +6813,7 @@ var SpaceInvitationProtocol = class {
6738
6813
  id: invitation.invitationId
6739
6814
  }, {
6740
6815
  F: __dxlog_file23,
6741
- L: 109,
6816
+ L: 103,
6742
6817
  S: this,
6743
6818
  C: (f, a) => f(...a)
6744
6819
  });
@@ -6753,7 +6828,7 @@ var SpaceInvitationProtocol = class {
6753
6828
  });
6754
6829
  invariant18(credential.credential, void 0, {
6755
6830
  F: __dxlog_file23,
6756
- L: 127,
6831
+ L: 121,
6757
6832
  S: this,
6758
6833
  A: [
6759
6834
  "credential.credential",
@@ -6768,7 +6843,7 @@ var SpaceInvitationProtocol = class {
6768
6843
  async cancelDelegation(invitation) {
6769
6844
  invariant18(this._spaceKey, void 0, {
6770
6845
  F: __dxlog_file23,
6771
- L: 133,
6846
+ L: 127,
6772
6847
  S: this,
6773
6848
  A: [
6774
6849
  "this._spaceKey",
@@ -6777,7 +6852,7 @@ var SpaceInvitationProtocol = class {
6777
6852
  });
6778
6853
  invariant18(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6779
6854
  F: __dxlog_file23,
6780
- L: 134,
6855
+ L: 128,
6781
6856
  S: this,
6782
6857
  A: [
6783
6858
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6787,7 +6862,7 @@ var SpaceInvitationProtocol = class {
6787
6862
  const space = this._spaceManager.spaces.get(this._spaceKey);
6788
6863
  invariant18(space, void 0, {
6789
6864
  F: __dxlog_file23,
6790
- L: 136,
6865
+ L: 130,
6791
6866
  S: this,
6792
6867
  A: [
6793
6868
  "space",
@@ -6799,14 +6874,14 @@ var SpaceInvitationProtocol = class {
6799
6874
  id: invitation.invitationId
6800
6875
  }, {
6801
6876
  F: __dxlog_file23,
6802
- L: 138,
6877
+ L: 132,
6803
6878
  S: this,
6804
6879
  C: (f, a) => f(...a)
6805
6880
  });
6806
6881
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6807
6882
  invariant18(credential.credential, void 0, {
6808
6883
  F: __dxlog_file23,
6809
- L: 145,
6884
+ L: 139,
6810
6885
  S: this,
6811
6886
  A: [
6812
6887
  "credential.credential",
@@ -6819,10 +6894,14 @@ var SpaceInvitationProtocol = class {
6819
6894
  }
6820
6895
  checkInvitation(invitation) {
6821
6896
  if (invitation.spaceKey == null) {
6822
- return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6897
+ return new InvalidInvitationError2({
6898
+ message: "No spaceKey was provided for a space invitation."
6899
+ });
6823
6900
  }
6824
6901
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
6825
- return new AlreadyJoinedError3("Already joined space.");
6902
+ return new AlreadyJoinedError3({
6903
+ message: "Already joined space."
6904
+ });
6826
6905
  }
6827
6906
  }
6828
6907
  createIntroduction() {
@@ -6845,7 +6924,7 @@ var SpaceInvitationProtocol = class {
6845
6924
  async accept(response) {
6846
6925
  invariant18(response.space, void 0, {
6847
6926
  F: __dxlog_file23,
6848
- L: 180,
6927
+ L: 174,
6849
6928
  S: this,
6850
6929
  A: [
6851
6930
  "response.space",
@@ -6856,7 +6935,7 @@ var SpaceInvitationProtocol = class {
6856
6935
  const assertion = getCredentialAssertion5(credential);
6857
6936
  invariant18(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6858
6937
  F: __dxlog_file23,
6859
- L: 183,
6938
+ L: 177,
6860
6939
  S: this,
6861
6940
  A: [
6862
6941
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -6865,7 +6944,7 @@ var SpaceInvitationProtocol = class {
6865
6944
  });
6866
6945
  invariant18(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6867
6946
  F: __dxlog_file23,
6868
- L: 184,
6947
+ L: 178,
6869
6948
  S: this,
6870
6949
  A: [
6871
6950
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6873,7 +6952,9 @@ var SpaceInvitationProtocol = class {
6873
6952
  ]
6874
6953
  });
6875
6954
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
6876
- throw new AlreadyJoinedError3("Already joined space.");
6955
+ throw new AlreadyJoinedError3({
6956
+ message: "Already joined space."
6957
+ });
6877
6958
  }
6878
6959
  await this._spaceManager.acceptSpace({
6879
6960
  spaceKey: assertion.spaceKey,
@@ -7263,162 +7344,27 @@ var InvitationsManager = class {
7263
7344
  }
7264
7345
  };
7265
7346
 
7266
- // src/packlets/locks/node.ts
7267
- import { invariant as invariant20 } from "@dxos/invariant";
7268
- import { LockFile } from "@dxos/lock-file";
7269
- import { log as log21, logInfo as logInfo3 } from "@dxos/log";
7270
- function _ts_decorate7(decorators, target, key, desc) {
7271
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7272
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7273
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7274
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7275
- }
7276
- var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
7277
- var Lock = class {
7278
- _lockPath;
7279
- _onAcquire;
7280
- _onRelease;
7281
- _fileHandle;
7282
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
7283
- this._lockPath = lockPath;
7284
- this._onAcquire = onAcquire;
7285
- this._onRelease = onRelease;
7286
- }
7287
- get lockKey() {
7288
- return this._lockPath;
7289
- }
7290
- async acquire() {
7291
- log21("acquiring lock...", void 0, {
7292
- F: __dxlog_file25,
7293
- L: 32,
7294
- S: this,
7295
- C: (f, a) => f(...a)
7296
- });
7297
- this._fileHandle = await LockFile.acquire(this._lockPath);
7298
- await this._onAcquire?.();
7299
- log21("acquired lock", void 0, {
7300
- F: __dxlog_file25,
7301
- L: 37,
7302
- S: this,
7303
- C: (f, a) => f(...a)
7304
- });
7305
- }
7306
- async release() {
7307
- await this._onRelease?.();
7308
- invariant20(this._fileHandle, "Lock is not acquired", {
7309
- F: __dxlog_file25,
7310
- L: 42,
7311
- S: this,
7312
- A: [
7313
- "this._fileHandle",
7314
- "'Lock is not acquired'"
7315
- ]
7316
- });
7317
- await LockFile.release(this._fileHandle);
7318
- }
7319
- };
7320
- _ts_decorate7([
7321
- logInfo3
7322
- ], Lock.prototype, "lockKey", null);
7323
- var isLocked = (lockPath) => LockFile.isLocked(lockPath);
7324
-
7325
- // src/packlets/services/client-rpc-server.ts
7326
- import { Stream as Stream10 } from "@dxos/codec-protobuf";
7327
- import { raise as raise2 } from "@dxos/debug";
7328
- import { RpcPeer, parseMethodName } from "@dxos/rpc";
7329
- import { MapCounter, trace as trace9 } from "@dxos/tracing";
7330
- function _ts_decorate8(decorators, target, key, desc) {
7331
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7332
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7333
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7334
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7335
- }
7336
- var ClientRpcServer = class {
7337
- _serviceRegistry;
7338
- _rpcPeer;
7339
- _handlerCache = /* @__PURE__ */ new Map();
7340
- _handleCall;
7341
- _handleStream;
7342
- _callMetrics = new MapCounter();
7343
- get _services() {
7344
- return Object.keys(this._serviceRegistry.services);
7345
- }
7346
- constructor(params) {
7347
- const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7348
- this._handleCall = handleCall;
7349
- this._handleStream = handleStream;
7350
- this._serviceRegistry = serviceRegistry;
7351
- this._rpcPeer = new RpcPeer({
7352
- ...rpcOptions,
7353
- callHandler: (method, params2) => {
7354
- const [serviceName, methodName] = parseMethodName(method);
7355
- const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
7356
- this._callMetrics.inc(`${serviceName}.${methodName} request`);
7357
- if (this._handleCall) {
7358
- return this._handleCall(methodName, params2, handler);
7359
- } else {
7360
- return handler(methodName, params2);
7361
- }
7362
- },
7363
- streamHandler: (method, params2) => {
7364
- const [serviceName, methodName] = parseMethodName(method);
7365
- const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
7366
- this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
7367
- if (this._handleStream) {
7368
- return Stream10.map(Stream10.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
7369
- this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
7370
- return data;
7371
- });
7372
- } else {
7373
- return handler(methodName, params2);
7374
- }
7375
- }
7376
- });
7377
- }
7378
- async open() {
7379
- await this._rpcPeer.open();
7380
- }
7381
- async close() {
7382
- await this._rpcPeer.close();
7383
- }
7384
- _getServiceHandler(serviceName) {
7385
- if (!this._handlerCache.has(serviceName)) {
7386
- const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7387
- const service = this._serviceRegistry.services[key];
7388
- if (!service) {
7389
- throw new Error(`Service not available: ${serviceName}`);
7390
- }
7391
- this._handlerCache.set(serviceName, descriptor.createServer(service));
7392
- }
7393
- return this._handlerCache.get(serviceName);
7394
- }
7395
- };
7396
- _ts_decorate8([
7397
- trace9.metricsCounter()
7398
- ], ClientRpcServer.prototype, "_callMetrics", void 0);
7399
- _ts_decorate8([
7400
- trace9.info()
7401
- ], ClientRpcServer.prototype, "_services", null);
7402
- ClientRpcServer = _ts_decorate8([
7403
- trace9.resource()
7404
- ], ClientRpcServer);
7347
+ // src/packlets/locks/index.ts
7348
+ var locks_exports = {};
7349
+ __reExport(locks_exports, locks_platform_star);
7350
+ import * as locks_platform_star from "#locks-platform";
7405
7351
 
7406
7352
  // src/packlets/agents/edge-agent-manager.ts
7407
7353
  import { DeferredTask as DeferredTask2, Event as Event9, scheduleTask as scheduleTask8, synchronized as synchronized3 } from "@dxos/async";
7408
7354
  import { Resource as Resource7 } from "@dxos/context";
7409
- import { invariant as invariant21 } from "@dxos/invariant";
7355
+ import { invariant as invariant20 } from "@dxos/invariant";
7410
7356
  import { PublicKey as PublicKey13 } from "@dxos/keys";
7411
- import { log as log22 } from "@dxos/log";
7357
+ import { log as log21 } from "@dxos/log";
7412
7358
  import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7413
7359
  import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7414
7360
  import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
7415
- function _ts_decorate9(decorators, target, key, desc) {
7361
+ function _ts_decorate7(decorators, target, key, desc) {
7416
7362
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7417
7363
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7418
7364
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7419
7365
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7420
7366
  }
7421
- var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7367
+ var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7422
7368
  var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7423
7369
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7424
7370
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
@@ -7442,8 +7388,8 @@ var EdgeAgentManager = class extends Resource7 {
7442
7388
  return this._agentStatus && this._agentStatus !== EdgeAgentStatus.NOT_FOUND;
7443
7389
  }
7444
7390
  async createAgent() {
7445
- invariant21(this.isOpen, void 0, {
7446
- F: __dxlog_file26,
7391
+ invariant20(this.isOpen, void 0, {
7392
+ F: __dxlog_file25,
7447
7393
  L: 54,
7448
7394
  S: this,
7449
7395
  A: [
@@ -7451,8 +7397,8 @@ var EdgeAgentManager = class extends Resource7 {
7451
7397
  ""
7452
7398
  ]
7453
7399
  });
7454
- invariant21(this._edgeHttpClient, void 0, {
7455
- F: __dxlog_file26,
7400
+ invariant20(this._edgeHttpClient, void 0, {
7401
+ F: __dxlog_file25,
7456
7402
  L: 55,
7457
7403
  S: this,
7458
7404
  A: [
@@ -7460,8 +7406,8 @@ var EdgeAgentManager = class extends Resource7 {
7460
7406
  ""
7461
7407
  ]
7462
7408
  });
7463
- invariant21(this._edgeFeatures?.agents, void 0, {
7464
- F: __dxlog_file26,
7409
+ invariant20(this._edgeFeatures?.agents, void 0, {
7410
+ F: __dxlog_file25,
7465
7411
  L: 56,
7466
7412
  S: this,
7467
7413
  A: [
@@ -7476,10 +7422,10 @@ var EdgeAgentManager = class extends Resource7 {
7476
7422
  });
7477
7423
  const deviceKey = PublicKey13.fromHex(response.deviceKey);
7478
7424
  if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7479
- log22.info("agent was already added to HALO, ignoring response", {
7425
+ log21.info("agent was already added to HALO, ignoring response", {
7480
7426
  response
7481
7427
  }, {
7482
- F: __dxlog_file26,
7428
+ F: __dxlog_file25,
7483
7429
  L: 67,
7484
7430
  S: this,
7485
7431
  C: (f, a) => f(...a)
@@ -7493,8 +7439,8 @@ var EdgeAgentManager = class extends Resource7 {
7493
7439
  // TODO: agents don't have data feed, should be removed
7494
7440
  dataFeedKey: PublicKey13.random()
7495
7441
  });
7496
- log22("agent created", response, {
7497
- F: __dxlog_file26,
7442
+ log21("agent created", response, {
7443
+ F: __dxlog_file25,
7498
7444
  L: 79,
7499
7445
  S: this,
7500
7446
  C: (f, a) => f(...a)
@@ -7503,10 +7449,10 @@ var EdgeAgentManager = class extends Resource7 {
7503
7449
  }
7504
7450
  async _open() {
7505
7451
  const isEnabled = this._edgeHttpClient && this._edgeFeatures?.agents;
7506
- log22("edge agent manager open", {
7452
+ log21("edge agent manager open", {
7507
7453
  isEnabled
7508
7454
  }, {
7509
- F: __dxlog_file26,
7455
+ F: __dxlog_file25,
7510
7456
  L: 87,
7511
7457
  S: this,
7512
7458
  C: (f, a) => f(...a)
@@ -7538,8 +7484,8 @@ var EdgeAgentManager = class extends Resource7 {
7538
7484
  this._lastKnownDeviceCount = 0;
7539
7485
  }
7540
7486
  async _fetchAgentStatus() {
7541
- invariant21(this._edgeHttpClient, void 0, {
7542
- F: __dxlog_file26,
7487
+ invariant20(this._edgeHttpClient, void 0, {
7488
+ F: __dxlog_file25,
7543
7489
  L: 121,
7544
7490
  S: this,
7545
7491
  A: [
@@ -7548,8 +7494,8 @@ var EdgeAgentManager = class extends Resource7 {
7548
7494
  ]
7549
7495
  });
7550
7496
  try {
7551
- log22("fetching agent status", void 0, {
7552
- F: __dxlog_file26,
7497
+ log21("fetching agent status", void 0, {
7498
+ F: __dxlog_file25,
7553
7499
  L: 123,
7554
7500
  S: this,
7555
7501
  C: (f, a) => f(...a)
@@ -7565,10 +7511,10 @@ var EdgeAgentManager = class extends Resource7 {
7565
7511
  } catch (err) {
7566
7512
  if (err instanceof EdgeCallFailedError3) {
7567
7513
  if (!err.isRetryable) {
7568
- log22.warn("non retryable error on agent status fetch attempt", {
7514
+ log21.warn("non retryable error on agent status fetch attempt", {
7569
7515
  err
7570
7516
  }, {
7571
- F: __dxlog_file26,
7517
+ F: __dxlog_file25,
7572
7518
  L: 133,
7573
7519
  S: this,
7574
7520
  C: (f, a) => f(...a)
@@ -7577,11 +7523,11 @@ var EdgeAgentManager = class extends Resource7 {
7577
7523
  }
7578
7524
  }
7579
7525
  const retryAfterMs = AGENT_STATUS_QUERY_RETRY_INTERVAL + Math.random() * AGENT_STATUS_QUERY_RETRY_JITTER;
7580
- log22.info("agent status fetching failed", {
7526
+ log21.info("agent status fetching failed", {
7581
7527
  err,
7582
7528
  retryAfterMs
7583
7529
  }, {
7584
- F: __dxlog_file26,
7530
+ F: __dxlog_file25,
7585
7531
  L: 138,
7586
7532
  S: this,
7587
7533
  C: (f, a) => f(...a)
@@ -7613,11 +7559,11 @@ var EdgeAgentManager = class extends Resource7 {
7613
7559
  ].some((feed) => feed.assertion.deviceKey.equals(agentDeviceKey));
7614
7560
  space.notarizationPlugin.setActiveEdgePollingEnabled(agentFeedNeedsNotarization);
7615
7561
  activePollingEnabled = activePollingEnabled || agentFeedNeedsNotarization;
7616
- log22.verbose("set active edge polling", {
7562
+ log21.verbose("set active edge polling", {
7617
7563
  enabled: agentFeedNeedsNotarization,
7618
7564
  spaceId: space.id
7619
7565
  }, {
7620
- F: __dxlog_file26,
7566
+ F: __dxlog_file25,
7621
7567
  L: 165,
7622
7568
  S: this,
7623
7569
  C: (f, a) => f(...a)
@@ -7634,22 +7580,22 @@ var EdgeAgentManager = class extends Resource7 {
7634
7580
  if (deviceKey) {
7635
7581
  this._ensureAgentIsInSpaces(deviceKey);
7636
7582
  }
7637
- log22.verbose("agent status update", {
7583
+ log21.verbose("agent status update", {
7638
7584
  status
7639
7585
  }, {
7640
- F: __dxlog_file26,
7586
+ F: __dxlog_file25,
7641
7587
  L: 181,
7642
7588
  S: this,
7643
7589
  C: (f, a) => f(...a)
7644
7590
  });
7645
7591
  }
7646
7592
  };
7647
- _ts_decorate9([
7593
+ _ts_decorate7([
7648
7594
  synchronized3
7649
7595
  ], EdgeAgentManager.prototype, "createAgent", null);
7650
7596
 
7651
7597
  // src/packlets/agents/edge-agent-service.ts
7652
- import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7598
+ import { Stream as Stream10 } from "@dxos/codec-protobuf/stream";
7653
7599
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7654
7600
  import { EdgeStatus as EdgeStatus2, QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7655
7601
  var EdgeAgentServiceImpl = class {
@@ -7661,7 +7607,7 @@ var EdgeAgentServiceImpl = class {
7661
7607
  }
7662
7608
  // TODO(mykola): Reconcile with NetworkService.queryStatus.
7663
7609
  queryEdgeStatus() {
7664
- return new Stream11(({ ctx, next }) => {
7610
+ return new Stream10(({ ctx, next }) => {
7665
7611
  const update = () => {
7666
7612
  next({
7667
7613
  status: this._edgeConnection?.status ?? {
@@ -7683,7 +7629,7 @@ var EdgeAgentServiceImpl = class {
7683
7629
  return (await this._agentManagerProvider()).createAgent();
7684
7630
  }
7685
7631
  queryAgentStatus() {
7686
- return new Stream11(({ ctx, next }) => {
7632
+ return new Stream10(({ ctx, next }) => {
7687
7633
  next({
7688
7634
  status: QueryAgentStatusResponse.AgentStatus.UNKNOWN
7689
7635
  });
@@ -7715,17 +7661,18 @@ var mapStatus = (agentStatus) => {
7715
7661
 
7716
7662
  // src/packlets/services/service-context.ts
7717
7663
  import { Mutex as Mutex4, Trigger as Trigger7 } from "@dxos/async";
7718
- import { Context as Context10, Resource as Resource8 } from "@dxos/context";
7664
+ import { Context as Context10, Resource as Resource9 } from "@dxos/context";
7719
7665
  import { getCredentialAssertion as getCredentialAssertion6 } from "@dxos/credentials";
7720
7666
  import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
7721
7667
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
7722
7668
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
7723
7669
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
7724
- import { invariant as invariant23 } from "@dxos/invariant";
7670
+ import { invariant as invariant22 } from "@dxos/invariant";
7725
7671
  import { Keyring } from "@dxos/keyring";
7726
7672
  import { PublicKey as PublicKey15 } from "@dxos/keys";
7727
- import { log as log24 } from "@dxos/log";
7728
- import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace10 } from "@dxos/protocols";
7673
+ import { log as log23 } from "@dxos/log";
7674
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
7675
+ import { FeedProtocol as FeedProtocol2 } from "@dxos/protocols";
7729
7676
  import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
7730
7677
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
7731
7678
  import { trace as Trace3 } from "@dxos/tracing";
@@ -7734,13 +7681,13 @@ import { safeInstanceof } from "@dxos/util";
7734
7681
  // src/packlets/identity/identity-recovery-manager.ts
7735
7682
  import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
7736
7683
  import { sign as sign3 } from "@dxos/crypto";
7737
- import { invariant as invariant22 } from "@dxos/invariant";
7684
+ import { invariant as invariant21 } from "@dxos/invariant";
7738
7685
  import { PublicKey as PublicKey14 } from "@dxos/keys";
7739
- import { log as log23 } from "@dxos/log";
7686
+ import { log as log22 } from "@dxos/log";
7740
7687
  import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
7741
7688
  import { schema as schema6 } from "@dxos/protocols/proto";
7742
7689
  import { Timeframe as Timeframe5 } from "@dxos/timeframe";
7743
- var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
7690
+ var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
7744
7691
  var EdgeIdentityRecoveryManager = class {
7745
7692
  _keyring;
7746
7693
  _edgeClient;
@@ -7754,8 +7701,8 @@ var EdgeIdentityRecoveryManager = class {
7754
7701
  }
7755
7702
  async createRecoveryCredential({ data }) {
7756
7703
  const identity = this._identityProvider();
7757
- invariant22(identity, void 0, {
7758
- F: __dxlog_file27,
7704
+ invariant21(identity, void 0, {
7705
+ F: __dxlog_file26,
7759
7706
  L: 39,
7760
7707
  S: this,
7761
7708
  A: [
@@ -7805,8 +7752,8 @@ var EdgeIdentityRecoveryManager = class {
7805
7752
  };
7806
7753
  }
7807
7754
  async requestRecoveryChallenge() {
7808
- invariant22(this._edgeClient, "Not connected to EDGE.", {
7809
- F: __dxlog_file27,
7755
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7756
+ F: __dxlog_file26,
7810
7757
  L: 76,
7811
7758
  S: this,
7812
7759
  A: [
@@ -7835,8 +7782,8 @@ var EdgeIdentityRecoveryManager = class {
7835
7782
  }
7836
7783
  }
7837
7784
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7838
- invariant22(this._edgeClient, "Not connected to EDGE.", {
7839
- F: __dxlog_file27,
7785
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7786
+ F: __dxlog_file26,
7840
7787
  L: 108,
7841
7788
  S: this,
7842
7789
  A: [
@@ -7869,8 +7816,8 @@ var EdgeIdentityRecoveryManager = class {
7869
7816
  * Recovery identity using an opaque token sent to the user's email.
7870
7817
  */
7871
7818
  async recoverIdentityWithToken({ token }) {
7872
- invariant22(this._edgeClient, "Not connected to EDGE.", {
7873
- F: __dxlog_file27,
7819
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7820
+ F: __dxlog_file26,
7874
7821
  L: 141,
7875
7822
  S: this,
7876
7823
  A: [
@@ -7897,8 +7844,8 @@ var EdgeIdentityRecoveryManager = class {
7897
7844
  });
7898
7845
  }
7899
7846
  async recoverIdentity({ recoveryCode }) {
7900
- invariant22(this._edgeClient, "Not connected to EDGE.", {
7901
- F: __dxlog_file27,
7847
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7848
+ F: __dxlog_file26,
7902
7849
  L: 165,
7903
7850
  S: this,
7904
7851
  A: [
@@ -7928,8 +7875,8 @@ var EdgeIdentityRecoveryManager = class {
7928
7875
  signature: Buffer.from(signature).toString("base64")
7929
7876
  });
7930
7877
  }
7931
- log23.info("recovering identity", response, {
7932
- F: __dxlog_file27,
7878
+ log22.info("recovering identity", response, {
7879
+ F: __dxlog_file26,
7933
7880
  L: 191,
7934
7881
  S: this,
7935
7882
  C: (f, a) => f(...a)
@@ -7951,8 +7898,156 @@ var decodeCredential = (credentialBase64) => {
7951
7898
  return codec.decode(credentialBytes);
7952
7899
  };
7953
7900
 
7901
+ // src/packlets/services/feed-syncer.ts
7902
+ import { Encoder, decode as cborXdecode } from "cbor-x";
7903
+ import * as Effect from "effect/Effect";
7904
+ import * as Schema from "effect/Schema";
7905
+ import { AsyncTask, scheduleTask as scheduleTask9 } from "@dxos/async";
7906
+ import { Resource as Resource8 } from "@dxos/context";
7907
+ import { MessageSchema } from "@dxos/edge-client";
7908
+ import { RuntimeProvider } from "@dxos/effect";
7909
+ import { SyncClient } from "@dxos/feed";
7910
+ import { FeedProtocol } from "@dxos/protocols";
7911
+ import { EdgeService as EdgeService2 } from "@dxos/protocols";
7912
+ import { createBuf } from "@dxos/protocols/buf";
7913
+ import { bufferToArray as bufferToArray2 } from "@dxos/util";
7914
+ var encoder = new Encoder({
7915
+ tagUint8Array: false,
7916
+ useRecords: false
7917
+ });
7918
+ var DEFAULT_MESSAGE_BLOCKS_LIMIT = 50;
7919
+ var DEFAULT_SYNC_CONCURRENCY = 5;
7920
+ var DEFAULT_POLLING_INTERVAL = 1e4;
7921
+ var FeedSyncer = class extends Resource8 {
7922
+ #syncNamespace;
7923
+ #messageBlocksLimit;
7924
+ #syncConcurrency;
7925
+ #pollingInterval;
7926
+ #runtime;
7927
+ #feedStore;
7928
+ #edgeClient;
7929
+ #syncClient;
7930
+ #getSpaceIds;
7931
+ #spacesToPoll = /* @__PURE__ */ new Set();
7932
+ /** Last time full poll was completed. */
7933
+ #lastFullPoll = null;
7934
+ constructor(options) {
7935
+ super();
7936
+ this.#runtime = options.runtime;
7937
+ this.#feedStore = options.feedStore;
7938
+ this.#edgeClient = options.edgeClient;
7939
+ this.#syncClient = new SyncClient({
7940
+ peerId: options.peerId,
7941
+ feedStore: options.feedStore,
7942
+ sendMessage: this.#sendMessage.bind(this)
7943
+ });
7944
+ this.#getSpaceIds = options.getSpaceIds;
7945
+ this.#syncNamespace = options.syncNamespace;
7946
+ this.#messageBlocksLimit = options.messageBlocksLimit ?? DEFAULT_MESSAGE_BLOCKS_LIMIT;
7947
+ this.#syncConcurrency = options.syncConcurrency ?? DEFAULT_SYNC_CONCURRENCY;
7948
+ this.#pollingInterval = options.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
7949
+ }
7950
+ async _open() {
7951
+ this._ctx.onDispose(this.#edgeClient.onMessage((msg) => {
7952
+ if (!msg.serviceId) {
7953
+ return;
7954
+ }
7955
+ const service = msg.serviceId.split(":")[0];
7956
+ if (service !== EdgeService2.QUEUE_REPLICATOR) {
7957
+ return;
7958
+ }
7959
+ const handleMessageEffect = Effect.gen(this, function* () {
7960
+ const decoded = yield* Effect.try({
7961
+ try: () => cborXdecode(msg.payload.value),
7962
+ catch: (error) => new Error(`Failed to decode feed sync message: ${error}`)
7963
+ });
7964
+ const payload = yield* Schema.decodeUnknown(FeedProtocol.ProtocolMessage)(decoded);
7965
+ yield* this.#syncClient.handleMessage(payload);
7966
+ });
7967
+ void RuntimeProvider.runPromise(this.#runtime)(handleMessageEffect);
7968
+ }));
7969
+ this._ctx.onDispose(
7970
+ // NOTE: This will fire immediately if the connection is already open.
7971
+ this.#edgeClient.onReconnected(async () => {
7972
+ })
7973
+ );
7974
+ this.#feedStore.onNewBlocks.on(this._ctx, () => {
7975
+ this.#pushTask.schedule();
7976
+ });
7977
+ await this.#pollTask.open();
7978
+ await this.#pushTask.open();
7979
+ this.#resetSpacesToPoll();
7980
+ }
7981
+ async _close() {
7982
+ await this.#pollTask.close();
7983
+ await this.#pushTask.close();
7984
+ }
7985
+ #resetSpacesToPoll() {
7986
+ this.#spacesToPoll.clear();
7987
+ this.#getSpaceIds().forEach((spaceId) => {
7988
+ this.#spacesToPoll.add(spaceId);
7989
+ });
7990
+ this.#lastFullPoll = Date.now();
7991
+ }
7992
+ #sendMessage(message) {
7993
+ return Effect.gen(this, function* () {
7994
+ const encoded = encoder.encode(message);
7995
+ yield* Effect.tryPromise(async () => this.#edgeClient.send(createBuf(MessageSchema, {
7996
+ source: {
7997
+ identityKey: this.#edgeClient.identityKey,
7998
+ peerKey: this.#edgeClient.peerKey
7999
+ },
8000
+ serviceId: this.#getTargetServiceId(message),
8001
+ payload: {
8002
+ value: bufferToArray2(encoded)
8003
+ }
8004
+ })));
8005
+ });
8006
+ }
8007
+ #getTargetServiceId(message) {
8008
+ return FeedProtocol.encodeServiceId(message.feedNamespace, message.spaceId);
8009
+ }
8010
+ #pollTask = new AsyncTask(async () => Effect.gen(this, function* () {
8011
+ yield* Effect.forEach(this.#spacesToPoll, (spaceId) => Effect.gen(this, function* () {
8012
+ const { done } = yield* this.#syncClient.pull({
8013
+ spaceId,
8014
+ feedNamespace: this.#syncNamespace,
8015
+ limit: this.#messageBlocksLimit
8016
+ });
8017
+ if (done) {
8018
+ this.#spacesToPoll.delete(spaceId);
8019
+ }
8020
+ }), {
8021
+ concurrency: this.#syncConcurrency
8022
+ });
8023
+ if (this.#lastFullPoll == null || Date.now() - this.#lastFullPoll > this.#pollingInterval) {
8024
+ this.#resetSpacesToPoll();
8025
+ this.#pollTask.schedule();
8026
+ } else if (this.#spacesToPoll.size > 0) {
8027
+ this.#pollTask.schedule();
8028
+ } else {
8029
+ this.#resetSpacesToPoll();
8030
+ scheduleTask9(this._ctx, () => this.#pollTask.schedule(), Math.max(this.#pollingInterval - (Date.now() - (this.#lastFullPoll ?? 0)), 0));
8031
+ }
8032
+ }).pipe(RuntimeProvider.runPromise(this.#runtime)));
8033
+ #pushTask = new AsyncTask(async () => Effect.gen(this, function* () {
8034
+ yield* Effect.forEach(this.#getSpaceIds(), (spaceId) => Effect.gen(this, function* () {
8035
+ const { done } = yield* this.#syncClient.push({
8036
+ spaceId,
8037
+ feedNamespace: this.#syncNamespace,
8038
+ limit: this.#messageBlocksLimit
8039
+ });
8040
+ if (!done) {
8041
+ this.#pushTask.schedule();
8042
+ }
8043
+ }), {
8044
+ concurrency: this.#syncConcurrency
8045
+ });
8046
+ }).pipe(RuntimeProvider.runPromise(this.#runtime)));
8047
+ };
8048
+
7954
8049
  // src/packlets/services/service-context.ts
7955
- function _ts_decorate10(decorators, target, key, desc) {
8050
+ function _ts_decorate8(decorators, target, key, desc) {
7956
8051
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7957
8052
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7958
8053
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -8023,15 +8118,16 @@ function _ts_dispose_resources4(env) {
8023
8118
  return next();
8024
8119
  })(env);
8025
8120
  }
8026
- var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8027
- var ServiceContext = class extends Resource8 {
8121
+ var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8122
+ var ServiceContext = class extends Resource9 {
8028
8123
  storage;
8029
8124
  level;
8030
8125
  networkManager;
8031
8126
  signalManager;
8032
8127
  _edgeConnection;
8033
8128
  _edgeHttpClient;
8034
- _runtimeParams;
8129
+ _runtime;
8130
+ _runtimeProps;
8035
8131
  _edgeFeatures;
8036
8132
  _edgeIdentityUpdateMutex = new Mutex4();
8037
8133
  initialized = new Trigger7();
@@ -8047,14 +8143,27 @@ var ServiceContext = class extends Resource8 {
8047
8143
  echoHost;
8048
8144
  _meshReplicator = void 0;
8049
8145
  _echoEdgeReplicator = void 0;
8146
+ _feedSyncer = void 0;
8050
8147
  // Initialized after identity is initialized.
8051
8148
  dataSpaceManager;
8052
8149
  edgeAgentManager;
8053
8150
  _handlerFactories = /* @__PURE__ */ new Map();
8054
8151
  _deviceSpaceSync;
8055
8152
  _instanceId = PublicKey15.random().toHex();
8056
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8057
- super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures;
8153
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtime, _runtimeProps, _edgeFeatures) {
8154
+ super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtime = _runtime, this._runtimeProps = _runtimeProps, this._edgeFeatures = _edgeFeatures;
8155
+ log23("runtimeProps", this._runtimeProps, {
8156
+ F: __dxlog_file27,
8157
+ L: 123,
8158
+ S: this,
8159
+ C: (f, a) => f(...a)
8160
+ });
8161
+ log23("edgeFeatures", this._edgeFeatures, {
8162
+ F: __dxlog_file27,
8163
+ L: 124,
8164
+ S: this,
8165
+ C: (f, a) => f(...a)
8166
+ });
8058
8167
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8059
8168
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8060
8169
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -8073,15 +8182,15 @@ var ServiceContext = class extends Resource8 {
8073
8182
  networkManager: this.networkManager,
8074
8183
  blobStore: this.blobStore,
8075
8184
  metadataStore: this.metadataStore,
8076
- disableP2pReplication: this._runtimeParams?.disableP2pReplication
8185
+ disableP2pReplication: this._runtimeProps?.disableP2pReplication
8077
8186
  });
8078
8187
  this.identityManager = new IdentityManager({
8079
8188
  metadataStore: this.metadataStore,
8080
8189
  keyring: this.keyring,
8081
8190
  feedStore: this.feedStore,
8082
8191
  spaceManager: this.spaceManager,
8083
- devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8084
- devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8192
+ devicePresenceOfflineTimeout: this._runtimeProps?.devicePresenceOfflineTimeout,
8193
+ devicePresenceAnnounceInterval: this._runtimeProps?.devicePresenceAnnounceInterval,
8085
8194
  edgeConnection: this._edgeConnection,
8086
8195
  edgeFeatures: this._edgeFeatures
8087
8196
  });
@@ -8090,15 +8199,13 @@ var ServiceContext = class extends Resource8 {
8090
8199
  kv: this.level,
8091
8200
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8092
8201
  getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8093
- indexing: {
8094
- vector: this._runtimeParams?.enableVectorIndexing
8095
- }
8202
+ runtime: this._runtime,
8203
+ localQueues: this._runtimeProps?.enableLocalQueues
8096
8204
  });
8097
- this._meshReplicator = new MeshEchoReplicator();
8098
- this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8205
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeProps?.invitationConnectionDefaultProps);
8099
8206
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8100
8207
  this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8101
- if (!this._runtimeParams?.disableP2pReplication) {
8208
+ if (!this._runtimeProps?.disableP2pReplication) {
8102
8209
  this._meshReplicator = new MeshEchoReplicator();
8103
8210
  }
8104
8211
  if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
@@ -8107,20 +8214,30 @@ var ServiceContext = class extends Resource8 {
8107
8214
  edgeHttpClient: this._edgeHttpClient
8108
8215
  });
8109
8216
  }
8217
+ if (this.echoHost.feedStore && this._edgeConnection) {
8218
+ this._feedSyncer = new FeedSyncer({
8219
+ runtime: this._runtime,
8220
+ feedStore: this.echoHost.feedStore,
8221
+ edgeClient: this._edgeConnection,
8222
+ peerId: this.identityManager.identity?.deviceKey?.toHex() ?? "",
8223
+ getSpaceIds: () => this.echoHost.spaceIds,
8224
+ syncNamespace: FeedProtocol2.WellKnownNamespaces.data
8225
+ });
8226
+ }
8110
8227
  }
8111
8228
  async _open(ctx) {
8112
8229
  await this._checkStorageVersion();
8113
- log24("opening...", void 0, {
8114
- F: __dxlog_file28,
8115
- L: 204,
8230
+ log23("opening...", void 0, {
8231
+ F: __dxlog_file27,
8232
+ L: 225,
8116
8233
  S: this,
8117
8234
  C: (f, a) => f(...a)
8118
8235
  });
8119
- log24.trace("dxos.sdk.service-context.open", trace10.begin({
8236
+ log23.trace("dxos.sdk.service-context.open", trace9.begin({
8120
8237
  id: this._instanceId
8121
8238
  }), {
8122
- F: __dxlog_file28,
8123
- L: 205,
8239
+ F: __dxlog_file27,
8240
+ L: 226,
8124
8241
  S: this,
8125
8242
  C: (f, a) => f(...a)
8126
8243
  });
@@ -8142,37 +8259,39 @@ var ServiceContext = class extends Resource8 {
8142
8259
  await this.identityManager.identity.joinNetwork();
8143
8260
  await this._initialize(ctx);
8144
8261
  }
8262
+ await this._feedSyncer?.open();
8145
8263
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
8146
- log24("loaded persistent invitations", {
8264
+ log23("loaded persistent invitations", {
8147
8265
  count: loadedInvitations.invitations?.length
8148
8266
  }, {
8149
- F: __dxlog_file28,
8150
- L: 233,
8267
+ F: __dxlog_file27,
8268
+ L: 256,
8151
8269
  S: this,
8152
8270
  C: (f, a) => f(...a)
8153
8271
  });
8154
- log24.trace("dxos.sdk.service-context.open", trace10.end({
8272
+ log23.trace("dxos.sdk.service-context.open", trace9.end({
8155
8273
  id: this._instanceId
8156
8274
  }), {
8157
- F: __dxlog_file28,
8158
- L: 235,
8275
+ F: __dxlog_file27,
8276
+ L: 258,
8159
8277
  S: this,
8160
8278
  C: (f, a) => f(...a)
8161
8279
  });
8162
- log24("opened", void 0, {
8163
- F: __dxlog_file28,
8164
- L: 236,
8280
+ log23("opened", void 0, {
8281
+ F: __dxlog_file27,
8282
+ L: 259,
8165
8283
  S: this,
8166
8284
  C: (f, a) => f(...a)
8167
8285
  });
8168
8286
  }
8169
8287
  async _close(ctx) {
8170
- log24("closing...", void 0, {
8171
- F: __dxlog_file28,
8172
- L: 240,
8288
+ log23("closing...", void 0, {
8289
+ F: __dxlog_file27,
8290
+ L: 263,
8173
8291
  S: this,
8174
8292
  C: (f, a) => f(...a)
8175
8293
  });
8294
+ await this._feedSyncer?.close();
8176
8295
  if (this._deviceSpaceSync && this.identityManager.identity) {
8177
8296
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
8178
8297
  }
@@ -8186,9 +8305,9 @@ var ServiceContext = class extends Resource8 {
8186
8305
  await this._edgeConnection?.close();
8187
8306
  await this.feedStore.close();
8188
8307
  await this.metadataStore.close();
8189
- log24("closed", void 0, {
8190
- F: __dxlog_file28,
8191
- L: 256,
8308
+ log23("closed", void 0, {
8309
+ F: __dxlog_file27,
8310
+ L: 282,
8192
8311
  S: this,
8193
8312
  C: (f, a) => f(...a)
8194
8313
  });
@@ -8198,8 +8317,8 @@ var ServiceContext = class extends Resource8 {
8198
8317
  await this._setNetworkIdentity();
8199
8318
  await identity.joinNetwork();
8200
8319
  await this._initialize(new Context10(void 0, {
8201
- F: __dxlog_file28,
8202
- L: 263
8320
+ F: __dxlog_file27,
8321
+ L: 289
8203
8322
  }));
8204
8323
  return identity;
8205
8324
  }
@@ -8208,9 +8327,9 @@ var ServiceContext = class extends Resource8 {
8208
8327
  throw new Error("Identity must be created before joining a space.");
8209
8328
  }
8210
8329
  const factory = this._handlerFactories.get(invitation.kind);
8211
- invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
8212
- F: __dxlog_file28,
8213
- L: 272,
8330
+ invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8331
+ F: __dxlog_file27,
8332
+ L: 298,
8214
8333
  S: this,
8215
8334
  A: [
8216
8335
  "factory",
@@ -8235,8 +8354,8 @@ var ServiceContext = class extends Resource8 {
8235
8354
  await identity.joinNetwork();
8236
8355
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8237
8356
  await this._initialize(new Context10(void 0, {
8238
- F: __dxlog_file28,
8239
- L: 291
8357
+ F: __dxlog_file27,
8358
+ L: 317
8240
8359
  }));
8241
8360
  return identity;
8242
8361
  }
@@ -8248,9 +8367,9 @@ var ServiceContext = class extends Resource8 {
8248
8367
  }
8249
8368
  // Called when identity is created.
8250
8369
  async _initialize(ctx) {
8251
- log24("initializing spaces...", void 0, {
8252
- F: __dxlog_file28,
8253
- L: 306,
8370
+ log23("initializing spaces...", void 0, {
8371
+ F: __dxlog_file27,
8372
+ L: 332,
8254
8373
  S: this,
8255
8374
  C: (f, a) => f(...a)
8256
8375
  });
@@ -8280,16 +8399,16 @@ var ServiceContext = class extends Resource8 {
8280
8399
  edgeHttpClient: this._edgeHttpClient,
8281
8400
  echoEdgeReplicator: this._echoEdgeReplicator,
8282
8401
  meshReplicator: this._meshReplicator,
8283
- runtimeParams: this._runtimeParams,
8402
+ runtimeProps: this._runtimeProps,
8284
8403
  edgeFeatures: this._edgeFeatures
8285
8404
  });
8286
8405
  await this.dataSpaceManager.open();
8287
8406
  this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
8288
8407
  await this.edgeAgentManager.open();
8289
8408
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8290
- invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8291
- F: __dxlog_file28,
8292
- L: 344,
8409
+ invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8410
+ F: __dxlog_file27,
8411
+ L: 370,
8293
8412
  S: this,
8294
8413
  A: [
8295
8414
  "this.dataSpaceManager",
@@ -8309,33 +8428,33 @@ var ServiceContext = class extends Resource8 {
8309
8428
  return;
8310
8429
  }
8311
8430
  if (!this.dataSpaceManager) {
8312
- log24("dataSpaceManager not initialized yet, ignoring space admission", {
8431
+ log23("dataSpaceManager not initialized yet, ignoring space admission", {
8313
8432
  details: assertion
8314
8433
  }, {
8315
- F: __dxlog_file28,
8316
- L: 360,
8434
+ F: __dxlog_file27,
8435
+ L: 386,
8317
8436
  S: this,
8318
8437
  C: (f, a) => f(...a)
8319
8438
  });
8320
8439
  return;
8321
8440
  }
8322
8441
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
8323
- log24("space already exists, ignoring space admission", {
8442
+ log23("space already exists, ignoring space admission", {
8324
8443
  details: assertion
8325
8444
  }, {
8326
- F: __dxlog_file28,
8327
- L: 364,
8445
+ F: __dxlog_file27,
8446
+ L: 390,
8328
8447
  S: this,
8329
8448
  C: (f, a) => f(...a)
8330
8449
  });
8331
8450
  return;
8332
8451
  }
8333
8452
  try {
8334
- log24("accepting space recorded in halo", {
8453
+ log23("accepting space recorded in halo", {
8335
8454
  details: assertion
8336
8455
  }, {
8337
- F: __dxlog_file28,
8338
- L: 369,
8456
+ F: __dxlog_file27,
8457
+ L: 395,
8339
8458
  S: this,
8340
8459
  C: (f, a) => f(...a)
8341
8460
  });
@@ -8344,9 +8463,9 @@ var ServiceContext = class extends Resource8 {
8344
8463
  genesisFeedKey: assertion.genesisFeedKey
8345
8464
  });
8346
8465
  } catch (err) {
8347
- log24.catch(err, void 0, {
8348
- F: __dxlog_file28,
8349
- L: 375,
8466
+ log23.catch(err, void 0, {
8467
+ F: __dxlog_file27,
8468
+ L: 401,
8350
8469
  S: this,
8351
8470
  C: (f, a) => f(...a)
8352
8471
  });
@@ -8366,12 +8485,12 @@ var ServiceContext = class extends Resource8 {
8366
8485
  let edgeIdentity;
8367
8486
  const identity = this.identityManager.identity;
8368
8487
  if (identity) {
8369
- log24("setting identity on edge connection", {
8488
+ log23("setting identity on edge connection", {
8370
8489
  identity: identity.identityKey.toHex(),
8371
8490
  swarms: this.networkManager.topics
8372
8491
  }, {
8373
- F: __dxlog_file28,
8374
- L: 389,
8492
+ F: __dxlog_file27,
8493
+ L: 415,
8375
8494
  S: this,
8376
8495
  C: (f, a) => f(...a)
8377
8496
  });
@@ -8383,9 +8502,9 @@ var ServiceContext = class extends Resource8 {
8383
8502
  await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
8384
8503
  await identity.ready();
8385
8504
  });
8386
- invariant23(identity.deviceCredentialChain, void 0, {
8387
- F: __dxlog_file28,
8388
- L: 408,
8505
+ invariant22(identity.deviceCredentialChain, void 0, {
8506
+ F: __dxlog_file27,
8507
+ L: 434,
8389
8508
  S: this,
8390
8509
  A: [
8391
8510
  "identity.deviceCredentialChain",
@@ -8411,13 +8530,13 @@ var ServiceContext = class extends Resource8 {
8411
8530
  }
8412
8531
  }
8413
8532
  };
8414
- _ts_decorate10([
8533
+ _ts_decorate8([
8415
8534
  Trace3.span()
8416
8535
  ], ServiceContext.prototype, "_open", null);
8417
- _ts_decorate10([
8536
+ _ts_decorate8([
8418
8537
  Trace3.span()
8419
8538
  ], ServiceContext.prototype, "_initialize", null);
8420
- ServiceContext = _ts_decorate10([
8539
+ ServiceContext = _ts_decorate8([
8421
8540
  safeInstanceof("dxos.client-services.ServiceContext"),
8422
8541
  Trace3.resource()
8423
8542
  ], ServiceContext);
@@ -8445,16 +8564,24 @@ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
8445
8564
  var createStorageObjects = (config) => {
8446
8565
  const { persistent = false, keyStore, dataStore } = config ?? {};
8447
8566
  if (persistent && dataStore === StorageDriver.RAM) {
8448
- throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
8567
+ throw new InvalidConfigError({
8568
+ message: "RAM storage cannot be used in persistent mode."
8569
+ });
8449
8570
  }
8450
8571
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
8451
- throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
8572
+ throw new InvalidConfigError({
8573
+ message: "Cannot use a persistent storage in not persistent mode."
8574
+ });
8452
8575
  }
8453
8576
  if (persistent && keyStore === StorageDriver.RAM) {
8454
- throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
8577
+ throw new InvalidConfigError({
8578
+ message: "RAM key storage cannot be used in persistent mode."
8579
+ });
8455
8580
  }
8456
8581
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
8457
- throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
8582
+ throw new InvalidConfigError({
8583
+ message: "Cannot use a persistent key storage in not persistent mode."
8584
+ });
8458
8585
  }
8459
8586
  return {
8460
8587
  storage: createStorage({
@@ -8496,165 +8623,6 @@ var createLevel = async (config) => {
8496
8623
  return level;
8497
8624
  };
8498
8625
 
8499
- // src/packlets/storage/profile-archive.ts
8500
- import { cbor } from "@automerge/automerge-repo";
8501
- import { invariant as invariant24 } from "@dxos/invariant";
8502
- import { log as log25 } from "@dxos/log";
8503
- import { ProfileArchiveEntryType } from "@dxos/protocols";
8504
- import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
8505
- var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
8506
- var encodeProfileArchive = (profile) => cbor.encode(profile);
8507
- var decodeProfileArchive = (data) => cbor.decode(data);
8508
- var exportProfileData = async ({ storage, level }) => {
8509
- const archive = {
8510
- storage: [],
8511
- meta: {
8512
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
8513
- }
8514
- };
8515
- {
8516
- const directory = await storage.createDirectory();
8517
- const files = await directory.list();
8518
- log25.info("begin exporting files", {
8519
- count: files.length
8520
- }, {
8521
- F: __dxlog_file29,
8522
- L: 31,
8523
- S: void 0,
8524
- C: (f, a) => f(...a)
8525
- });
8526
- for (const filename of files) {
8527
- const file = await directory.getOrCreateFile(filename);
8528
- const { size } = await file.stat();
8529
- const data = await file.read(0, size);
8530
- archive.storage.push({
8531
- type: ProfileArchiveEntryType.FILE,
8532
- key: filename,
8533
- value: data
8534
- });
8535
- }
8536
- log25.info("done exporting files", {
8537
- count: files.length
8538
- }, {
8539
- F: __dxlog_file29,
8540
- L: 42,
8541
- S: void 0,
8542
- C: (f, a) => f(...a)
8543
- });
8544
- }
8545
- {
8546
- log25.info("begin exporting kv pairs", void 0, {
8547
- F: __dxlog_file29,
8548
- L: 46,
8549
- S: void 0,
8550
- C: (f, a) => f(...a)
8551
- });
8552
- const iter = await level.iterator({
8553
- keyEncoding: "binary",
8554
- valueEncoding: "binary"
8555
- });
8556
- let count = 0;
8557
- for await (const [key, value] of iter) {
8558
- archive.storage.push({
8559
- type: ProfileArchiveEntryType.KEY_VALUE,
8560
- key,
8561
- value
8562
- });
8563
- count++;
8564
- }
8565
- log25.info("done exporting kv pairs", {
8566
- count
8567
- }, {
8568
- F: __dxlog_file29,
8569
- L: 57,
8570
- S: void 0,
8571
- C: (f, a) => f(...a)
8572
- });
8573
- }
8574
- return archive;
8575
- };
8576
- var importProfileData = async ({ storage, level }, archive) => {
8577
- let batch = level.batch();
8578
- let count = 0;
8579
- for (const entry2 of archive.storage) {
8580
- switch (entry2.type) {
8581
- case ProfileArchiveEntryType.FILE: {
8582
- const directory = await storage.createDirectory();
8583
- invariant24(typeof entry2.key === "string", "Invalid key type", {
8584
- F: __dxlog_file29,
8585
- L: 80,
8586
- S: void 0,
8587
- A: [
8588
- "typeof entry.key === 'string'",
8589
- "'Invalid key type'"
8590
- ]
8591
- });
8592
- const file = await directory.getOrCreateFile(entry2.key);
8593
- invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
8594
- F: __dxlog_file29,
8595
- L: 82,
8596
- S: void 0,
8597
- A: [
8598
- "entry.value instanceof Uint8Array",
8599
- "'Invalid value type'"
8600
- ]
8601
- });
8602
- await file.write(0, arrayToBuffer2(entry2.value));
8603
- await file.close();
8604
- break;
8605
- }
8606
- case ProfileArchiveEntryType.KEY_VALUE: {
8607
- invariant24(entry2.key instanceof Uint8Array, "Invalid key type", {
8608
- F: __dxlog_file29,
8609
- L: 88,
8610
- S: void 0,
8611
- A: [
8612
- "entry.key instanceof Uint8Array",
8613
- "'Invalid key type'"
8614
- ]
8615
- });
8616
- invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
8617
- F: __dxlog_file29,
8618
- L: 89,
8619
- S: void 0,
8620
- A: [
8621
- "entry.value instanceof Uint8Array",
8622
- "'Invalid value type'"
8623
- ]
8624
- });
8625
- batch.put(entry2.key, entry2.value, {
8626
- keyEncoding: "binary",
8627
- valueEncoding: "binary"
8628
- });
8629
- break;
8630
- }
8631
- default:
8632
- throw new Error(`Invalid entry type: ${entry2.type}`);
8633
- }
8634
- if (++count % 1e3 === 0) {
8635
- await batch.write();
8636
- batch = level.batch();
8637
- log25.info("importing", {
8638
- count,
8639
- total: archive.storage.length,
8640
- progress: `${(count / archive.storage.length * 100).toFixed()}%`
8641
- }, {
8642
- F: __dxlog_file29,
8643
- L: 102,
8644
- S: void 0,
8645
- C: (f, a) => f(...a)
8646
- });
8647
- }
8648
- }
8649
- log25.info("committing changes..", void 0, {
8650
- F: __dxlog_file29,
8651
- L: 110,
8652
- S: void 0,
8653
- C: (f, a) => f(...a)
8654
- });
8655
- await batch.write();
8656
- };
8657
-
8658
8626
  // src/packlets/services/service-registry.ts
8659
8627
  var ServiceRegistry = class {
8660
8628
  _serviceBundle;
@@ -8682,26 +8650,30 @@ var ServiceRegistry = class {
8682
8650
  };
8683
8651
 
8684
8652
  // src/packlets/services/service-host.ts
8653
+ import * as SqlClient from "@effect/sql/SqlClient";
8654
+ import * as Effect2 from "effect/Effect";
8685
8655
  import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
8686
8656
  import { clientServiceBundle } from "@dxos/client-protocol";
8687
8657
  import { Context as Context11 } from "@dxos/context";
8688
8658
  import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
8689
- import { invariant as invariant26 } from "@dxos/invariant";
8659
+ import { RuntimeProvider as RuntimeProvider2 } from "@dxos/effect";
8660
+ import { invariant as invariant24 } from "@dxos/invariant";
8690
8661
  import { PublicKey as PublicKey19 } from "@dxos/keys";
8691
- import { log as log27 } from "@dxos/log";
8662
+ import { log as log25 } from "@dxos/log";
8692
8663
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
8693
8664
  import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
8694
- import { trace as trace11 } from "@dxos/protocols";
8665
+ import { trace as trace10 } from "@dxos/protocols";
8695
8666
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
8667
+ import * as SqlExport from "@dxos/sql-sqlite/SqlExport";
8696
8668
  import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
8697
8669
  import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8698
8670
 
8699
8671
  // src/packlets/devices/devices-service.ts
8700
8672
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8701
- import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8702
- import { invariant as invariant25 } from "@dxos/invariant";
8673
+ import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
8674
+ import { invariant as invariant23 } from "@dxos/invariant";
8703
8675
  import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8704
- var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8676
+ var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8705
8677
  var DevicesServiceImpl = class {
8706
8678
  _identityManager;
8707
8679
  _edgeConnection;
@@ -8713,7 +8685,7 @@ var DevicesServiceImpl = class {
8713
8685
  return this._identityManager.updateDeviceProfile(profile);
8714
8686
  }
8715
8687
  queryDevices() {
8716
- return new Stream12(({ next }) => {
8688
+ return new Stream11(({ next }) => {
8717
8689
  const update = () => {
8718
8690
  const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
8719
8691
  if (!deviceKeys) {
@@ -8721,8 +8693,8 @@ var DevicesServiceImpl = class {
8721
8693
  devices: []
8722
8694
  });
8723
8695
  } else {
8724
- invariant25(this._identityManager.identity?.presence, "presence not present", {
8725
- F: __dxlog_file30,
8696
+ invariant23(this._identityManager.identity?.presence, "presence not present", {
8697
+ F: __dxlog_file28,
8726
8698
  L: 37,
8727
8699
  S: this,
8728
8700
  A: [
@@ -8789,8 +8761,8 @@ var DevicesServiceImpl = class {
8789
8761
  };
8790
8762
 
8791
8763
  // src/packlets/identity/contacts-service.ts
8792
- import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask9 } from "@dxos/async";
8793
- import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8764
+ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask10 } from "@dxos/async";
8765
+ import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8794
8766
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8795
8767
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
8796
8768
  var ContactsServiceImpl = class {
@@ -8844,14 +8816,14 @@ var ContactsServiceImpl = class {
8844
8816
  }
8845
8817
  queryContacts() {
8846
8818
  const subscribedSpaceKeySet = new ComplexSet6(PublicKey17.hash);
8847
- return new Stream13(({ next, ctx }) => {
8819
+ return new Stream12(({ next, ctx }) => {
8848
8820
  const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
8849
8821
  const contacts = await this.getContacts();
8850
8822
  next(contacts);
8851
8823
  }, {
8852
8824
  maxFrequency: 2
8853
8825
  });
8854
- scheduleTask9(ctx, async () => {
8826
+ scheduleTask10(ctx, async () => {
8855
8827
  const subscriptions = new SubscriptionList4();
8856
8828
  ctx.onDispose(() => subscriptions.clear());
8857
8829
  const subscribeToSpaceAndUpdate = () => {
@@ -8876,9 +8848,9 @@ var ContactsServiceImpl = class {
8876
8848
 
8877
8849
  // src/packlets/logging/logging-service.ts
8878
8850
  import { Event as Event10 } from "@dxos/async";
8879
- import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
8851
+ import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8880
8852
  import { PublicKey as PublicKey18 } from "@dxos/keys";
8881
- import { getContextFromEntry, log as log26 } from "@dxos/log";
8853
+ import { getContextFromEntry, log as log24 } from "@dxos/log";
8882
8854
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
8883
8855
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
8884
8856
  var LoggingServiceImpl = class {
@@ -8886,11 +8858,11 @@ var LoggingServiceImpl = class {
8886
8858
  _started = Date.now();
8887
8859
  _sessionId = PublicKey18.random().toHex();
8888
8860
  async open() {
8889
- log26.runtimeConfig.processors.push(this._logProcessor);
8861
+ log24.runtimeConfig.processors.push(this._logProcessor);
8890
8862
  }
8891
8863
  async close() {
8892
- const index = log26.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
8893
- log26.runtimeConfig.processors.splice(index, 1);
8864
+ const index = log24.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
8865
+ log24.runtimeConfig.processors.splice(index, 1);
8894
8866
  }
8895
8867
  async controlMetrics({ reset, record }) {
8896
8868
  if (reset) {
@@ -8916,7 +8888,7 @@ var LoggingServiceImpl = class {
8916
8888
  stats: numericalValues(events, "duration")
8917
8889
  };
8918
8890
  };
8919
- return new Stream14(({ next }) => {
8891
+ return new Stream13(({ next }) => {
8920
8892
  const update = () => {
8921
8893
  const metrics2 = {
8922
8894
  timestamp: /* @__PURE__ */ new Date(),
@@ -8938,7 +8910,7 @@ var LoggingServiceImpl = class {
8938
8910
  });
8939
8911
  }
8940
8912
  queryLogs(request) {
8941
- return new Stream14(({ ctx, next }) => {
8913
+ return new Stream13(({ ctx, next }) => {
8942
8914
  const handler = (entry2) => {
8943
8915
  if (LOG_PROCESSING > 0) {
8944
8916
  return;
@@ -8998,7 +8970,7 @@ var shouldLog = (entry2, request) => {
8998
8970
  var LOG_PROCESSING = 0;
8999
8971
 
9000
8972
  // src/packlets/network/network-service.ts
9001
- import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8973
+ import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
9002
8974
  var NetworkServiceImpl = class {
9003
8975
  networkManager;
9004
8976
  signalManager;
@@ -9009,7 +8981,7 @@ var NetworkServiceImpl = class {
9009
8981
  this.edgeConnection = edgeConnection;
9010
8982
  }
9011
8983
  queryStatus() {
9012
- return new Stream15(({ ctx, next }) => {
8984
+ return new Stream14(({ ctx, next }) => {
9013
8985
  const update = () => {
9014
8986
  next({
9015
8987
  swarm: this.networkManager.connectionState,
@@ -9038,7 +9010,7 @@ var NetworkServiceImpl = class {
9038
9010
  return this.signalManager.query(request);
9039
9011
  }
9040
9012
  subscribeSwarmState(request) {
9041
- return new Stream15(({ ctx, next }) => {
9013
+ return new Stream14(({ ctx, next }) => {
9042
9014
  this.signalManager.swarmState?.on(ctx, (state) => {
9043
9015
  if (request.topic.equals(state.swarmKey)) {
9044
9016
  next(state);
@@ -9050,7 +9022,7 @@ var NetworkServiceImpl = class {
9050
9022
  return this.signalManager.sendMessage(message);
9051
9023
  }
9052
9024
  subscribeMessages(peer) {
9053
- return new Stream15(({ ctx, next }) => {
9025
+ return new Stream14(({ ctx, next }) => {
9054
9026
  this.signalManager.onMessage.on(ctx, (message) => {
9055
9027
  if (message.recipient.peerKey === peer.peerKey) {
9056
9028
  next(message);
@@ -9061,7 +9033,7 @@ var NetworkServiceImpl = class {
9061
9033
  };
9062
9034
 
9063
9035
  // src/packlets/system/system-service.ts
9064
- import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
9036
+ import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
9065
9037
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
9066
9038
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
9067
9039
  var SystemServiceImpl = class {
@@ -9103,7 +9075,7 @@ var SystemServiceImpl = class {
9103
9075
  }
9104
9076
  // TODO(burdon): Standardize interval option in stream request?
9105
9077
  queryStatus({ interval = 3e3 } = {}) {
9106
- return new Stream16(({ next }) => {
9078
+ return new Stream15(({ next }) => {
9107
9079
  const update = () => {
9108
9080
  next({
9109
9081
  status: this._getCurrentStatus()
@@ -9124,13 +9096,13 @@ var SystemServiceImpl = class {
9124
9096
  };
9125
9097
 
9126
9098
  // src/packlets/services/service-host.ts
9127
- function _ts_decorate11(decorators, target, key, desc) {
9099
+ function _ts_decorate9(decorators, target, key, desc) {
9128
9100
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9129
9101
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9130
9102
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9131
9103
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9132
9104
  }
9133
- var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9105
+ var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9134
9106
  var ClientServicesHost = class {
9135
9107
  _resourceLock;
9136
9108
  _serviceRegistry;
@@ -9148,7 +9120,8 @@ var ClientServicesHost = class {
9148
9120
  _edgeConnection = void 0;
9149
9121
  _edgeHttpClient = void 0;
9150
9122
  _serviceContext;
9151
- _runtimeParams;
9123
+ _runtime;
9124
+ _runtimeProps;
9152
9125
  diagnosticsBroadcastHandler;
9153
9126
  _opening = false;
9154
9127
  _open = false;
@@ -9162,18 +9135,14 @@ var ClientServicesHost = class {
9162
9135
  // TODO(wittjosiah): Turn this on by default.
9163
9136
  lockKey,
9164
9137
  callbacks,
9165
- runtimeParams
9166
- } = {}) {
9138
+ runtime,
9139
+ runtimeProps
9140
+ }) {
9167
9141
  this._storage = storage;
9168
9142
  this._level = level;
9169
9143
  this._callbacks = callbacks;
9170
- this._runtimeParams = runtimeParams ?? {};
9171
- if (this._runtimeParams.disableP2pReplication === void 0) {
9172
- this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9173
- }
9174
- if (this._runtimeParams.enableVectorIndexing === void 0) {
9175
- this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9176
- }
9144
+ this._runtime = runtime;
9145
+ this._runtimeProps = runtimeProps ?? {};
9177
9146
  if (config) {
9178
9147
  this.initialize({
9179
9148
  config,
@@ -9182,13 +9151,13 @@ var ClientServicesHost = class {
9182
9151
  });
9183
9152
  }
9184
9153
  if (lockKey) {
9185
- this._resourceLock = new Lock({
9154
+ this._resourceLock = new locks_exports.Lock({
9186
9155
  lockKey,
9187
9156
  onAcquire: () => {
9188
9157
  if (!this._opening) {
9189
9158
  void this.open(new Context11(void 0, {
9190
- F: __dxlog_file31,
9191
- L: 143
9159
+ F: __dxlog_file29,
9160
+ L: 147
9192
9161
  }));
9193
9162
  }
9194
9163
  },
@@ -9213,7 +9182,7 @@ var ClientServicesHost = class {
9213
9182
  await this.reset();
9214
9183
  }
9215
9184
  });
9216
- this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9185
+ this.diagnosticsBroadcastHandler = (0, diagnostics_exports.createCollectDiagnosticsBroadcastHandler)(this._systemService);
9217
9186
  this._loggingService = new LoggingServiceImpl();
9218
9187
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9219
9188
  SystemService: this._systemService,
@@ -9239,30 +9208,57 @@ var ClientServicesHost = class {
9239
9208
  return this._serviceRegistry.services;
9240
9209
  }
9241
9210
  /**
9211
+ * Debugging util.
9212
+ */
9213
+ async exportSqliteDatabase() {
9214
+ return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
9215
+ const sql = yield* SqlExport.SqlExport;
9216
+ return yield* sql.export;
9217
+ }));
9218
+ }
9219
+ /**
9220
+ * Debugging util.
9221
+ */
9222
+ async runSqliteQuery(query, params) {
9223
+ return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
9224
+ const sql = yield* SqlClient.SqlClient;
9225
+ return yield* sql`${sql.unsafe(query, params)}`;
9226
+ }));
9227
+ }
9228
+ /**
9242
9229
  * Initialize the service host with the config.
9243
9230
  * Config can also be provided in the constructor.
9244
9231
  * Can only be called once.
9245
9232
  */
9246
9233
  initialize({ config, ...options }) {
9247
- invariant26(!this._open, "service host is open", {
9248
- F: __dxlog_file31,
9249
- L: 209,
9234
+ invariant24(!this._open, "service host is open", {
9235
+ F: __dxlog_file29,
9236
+ L: 237,
9250
9237
  S: this,
9251
9238
  A: [
9252
9239
  "!this._open",
9253
9240
  "'service host is open'"
9254
9241
  ]
9255
9242
  });
9256
- log27("initializing...", void 0, {
9257
- F: __dxlog_file31,
9258
- L: 210,
9243
+ log25("initializing...", void 0, {
9244
+ F: __dxlog_file29,
9245
+ L: 238,
9259
9246
  S: this,
9260
9247
  C: (f, a) => f(...a)
9261
9248
  });
9262
9249
  if (config) {
9263
- invariant26(!this._config, "config already set", {
9264
- F: __dxlog_file31,
9265
- L: 213,
9250
+ if (this._runtimeProps.disableP2pReplication === void 0) {
9251
+ this._runtimeProps.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9252
+ }
9253
+ if (this._runtimeProps.enableVectorIndexing === void 0) {
9254
+ this._runtimeProps.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9255
+ }
9256
+ if (this._runtimeProps.enableLocalQueues === void 0) {
9257
+ this._runtimeProps.enableLocalQueues = config?.get("runtime.client.enableLocalQueues", false);
9258
+ }
9259
+ invariant24(!this._config, "config already set", {
9260
+ F: __dxlog_file29,
9261
+ L: 251,
9266
9262
  S: this,
9267
9263
  A: [
9268
9264
  "!this._config",
@@ -9289,9 +9285,9 @@ var ClientServicesHost = class {
9289
9285
  edgeConnection: this._edgeConnection
9290
9286
  }) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
9291
9287
  this._signalManager = signalManager;
9292
- invariant26(!this._networkManager, "network manager already set", {
9293
- F: __dxlog_file31,
9294
- L: 244,
9288
+ invariant24(!this._networkManager, "network manager already set", {
9289
+ F: __dxlog_file29,
9290
+ L: 282,
9295
9291
  S: this,
9296
9292
  A: [
9297
9293
  "!this._networkManager",
@@ -9307,9 +9303,9 @@ var ClientServicesHost = class {
9307
9303
  peerKey: this._edgeConnection.peerKey
9308
9304
  } : void 0
9309
9305
  });
9310
- log27("initialized", void 0, {
9311
- F: __dxlog_file31,
9312
- L: 257,
9306
+ log25("initialized", void 0, {
9307
+ F: __dxlog_file29,
9308
+ L: 295,
9313
9309
  S: this,
9314
9310
  C: (f, a) => f(...a)
9315
9311
  });
@@ -9319,44 +9315,44 @@ var ClientServicesHost = class {
9319
9315
  return;
9320
9316
  }
9321
9317
  const traceId = PublicKey19.random().toHex();
9322
- log27.trace("dxos.client-services.host.open", trace11.begin({
9318
+ log25.trace("dxos.client-services.host.open", trace10.begin({
9323
9319
  id: traceId
9324
9320
  }), {
9325
- F: __dxlog_file31,
9326
- L: 268,
9321
+ F: __dxlog_file29,
9322
+ L: 306,
9327
9323
  S: this,
9328
9324
  C: (f, a) => f(...a)
9329
9325
  });
9330
- invariant26(this._config, "config not set", {
9331
- F: __dxlog_file31,
9332
- L: 270,
9326
+ invariant24(this._config, "config not set", {
9327
+ F: __dxlog_file29,
9328
+ L: 308,
9333
9329
  S: this,
9334
9330
  A: [
9335
9331
  "this._config",
9336
9332
  "'config not set'"
9337
9333
  ]
9338
9334
  });
9339
- invariant26(this._storage, "storage not set", {
9340
- F: __dxlog_file31,
9341
- L: 271,
9335
+ invariant24(this._storage, "storage not set", {
9336
+ F: __dxlog_file29,
9337
+ L: 309,
9342
9338
  S: this,
9343
9339
  A: [
9344
9340
  "this._storage",
9345
9341
  "'storage not set'"
9346
9342
  ]
9347
9343
  });
9348
- invariant26(this._signalManager, "signal manager not set", {
9349
- F: __dxlog_file31,
9350
- L: 272,
9344
+ invariant24(this._signalManager, "signal manager not set", {
9345
+ F: __dxlog_file29,
9346
+ L: 310,
9351
9347
  S: this,
9352
9348
  A: [
9353
9349
  "this._signalManager",
9354
9350
  "'signal manager not set'"
9355
9351
  ]
9356
9352
  });
9357
- invariant26(this._networkManager, "network manager not set", {
9358
- F: __dxlog_file31,
9359
- L: 273,
9353
+ invariant24(this._networkManager, "network manager not set", {
9354
+ F: __dxlog_file29,
9355
+ L: 311,
9360
9356
  S: this,
9361
9357
  A: [
9362
9358
  "this._networkManager",
@@ -9364,11 +9360,11 @@ var ClientServicesHost = class {
9364
9360
  ]
9365
9361
  });
9366
9362
  this._opening = true;
9367
- log27("opening...", {
9363
+ log25("opening...", {
9368
9364
  lockKey: this._resourceLock?.lockKey
9369
9365
  }, {
9370
- F: __dxlog_file31,
9371
- L: 276,
9366
+ F: __dxlog_file29,
9367
+ L: 314,
9372
9368
  S: this,
9373
9369
  C: (f, a) => f(...a)
9374
9370
  });
@@ -9378,7 +9374,7 @@ var ClientServicesHost = class {
9378
9374
  }
9379
9375
  await this._level.open();
9380
9376
  await this._loggingService.open();
9381
- this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
9377
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtime, this._runtimeProps, this._config.get("runtime.client.edgeFeatures"));
9382
9378
  const dataSpaceManagerProvider = async () => {
9383
9379
  await this._serviceContext.initialized.wait();
9384
9380
  return this._serviceContext.dataSpaceManager;
@@ -9397,6 +9393,7 @@ var ClientServicesHost = class {
9397
9393
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
9398
9394
  DataService: this._serviceContext.echoHost.dataService,
9399
9395
  QueryService: this._serviceContext.echoHost.queryService,
9396
+ QueueService: this._serviceContext.echoHost.queuesService,
9400
9397
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager, this._edgeConnection),
9401
9398
  LoggingService: this._loggingService,
9402
9399
  TracingService: this._tracingService,
@@ -9425,19 +9422,19 @@ var ClientServicesHost = class {
9425
9422
  this._open = true;
9426
9423
  this._statusUpdate.emit();
9427
9424
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
9428
- log27("opened", {
9425
+ log25("opened", {
9429
9426
  deviceKey
9430
9427
  }, {
9431
- F: __dxlog_file31,
9432
- L: 377,
9428
+ F: __dxlog_file29,
9429
+ L: 417,
9433
9430
  S: this,
9434
9431
  C: (f, a) => f(...a)
9435
9432
  });
9436
- log27.trace("dxos.client-services.host.open", trace11.end({
9433
+ log25.trace("dxos.client-services.host.open", trace10.end({
9437
9434
  id: traceId
9438
9435
  }), {
9439
- F: __dxlog_file31,
9440
- L: 378,
9436
+ F: __dxlog_file29,
9437
+ L: 418,
9441
9438
  S: this,
9442
9439
  C: (f, a) => f(...a)
9443
9440
  });
@@ -9447,11 +9444,11 @@ var ClientServicesHost = class {
9447
9444
  return;
9448
9445
  }
9449
9446
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
9450
- log27("closing...", {
9447
+ log25("closing...", {
9451
9448
  deviceKey
9452
9449
  }, {
9453
- F: __dxlog_file31,
9454
- L: 389,
9450
+ F: __dxlog_file29,
9451
+ L: 429,
9455
9452
  S: this,
9456
9453
  C: (f, a) => f(...a)
9457
9454
  });
@@ -9465,28 +9462,28 @@ var ClientServicesHost = class {
9465
9462
  await this._level?.close();
9466
9463
  this._open = false;
9467
9464
  this._statusUpdate.emit();
9468
- log27("closed", {
9465
+ log25("closed", {
9469
9466
  deviceKey
9470
9467
  }, {
9471
- F: __dxlog_file31,
9472
- L: 398,
9468
+ F: __dxlog_file29,
9469
+ L: 438,
9473
9470
  S: this,
9474
9471
  C: (f, a) => f(...a)
9475
9472
  });
9476
9473
  }
9477
9474
  async reset() {
9478
9475
  const traceId = PublicKey19.random().toHex();
9479
- log27.trace("dxos.sdk.client-services-host.reset", trace11.begin({
9476
+ log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
9480
9477
  id: traceId
9481
9478
  }), {
9482
- F: __dxlog_file31,
9483
- L: 403,
9479
+ F: __dxlog_file29,
9480
+ L: 443,
9484
9481
  S: this,
9485
9482
  C: (f, a) => f(...a)
9486
9483
  });
9487
- log27.info("resetting...", void 0, {
9488
- F: __dxlog_file31,
9489
- L: 405,
9484
+ log25.info("resetting...", void 0, {
9485
+ F: __dxlog_file29,
9486
+ L: 445,
9490
9487
  S: this,
9491
9488
  C: (f, a) => f(...a)
9492
9489
  });
@@ -9496,27 +9493,27 @@ var ClientServicesHost = class {
9496
9493
  try {
9497
9494
  await this._level.clear();
9498
9495
  } catch (err) {
9499
- log27.warn("failed to clear leveldb during reset", {
9496
+ log25.warn("failed to clear leveldb during reset", {
9500
9497
  err
9501
9498
  }, {
9502
- F: __dxlog_file31,
9503
- L: 415,
9499
+ F: __dxlog_file29,
9500
+ L: 455,
9504
9501
  S: this,
9505
9502
  C: (f, a) => f(...a)
9506
9503
  });
9507
9504
  }
9508
9505
  await this._storage.reset();
9509
- log27.info("reset", void 0, {
9510
- F: __dxlog_file31,
9511
- L: 418,
9506
+ log25.info("reset", void 0, {
9507
+ F: __dxlog_file29,
9508
+ L: 458,
9512
9509
  S: this,
9513
9510
  C: (f, a) => f(...a)
9514
9511
  });
9515
- log27.trace("dxos.sdk.client-services-host.reset", trace11.end({
9512
+ log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
9516
9513
  id: traceId
9517
9514
  }), {
9518
- F: __dxlog_file31,
9519
- L: 419,
9515
+ F: __dxlog_file29,
9516
+ L: 459,
9520
9517
  S: this,
9521
9518
  C: (f, a) => f(...a)
9522
9519
  });
@@ -9528,24 +9525,24 @@ var ClientServicesHost = class {
9528
9525
  return identity;
9529
9526
  }
9530
9527
  };
9531
- _ts_decorate11([
9528
+ _ts_decorate9([
9532
9529
  Trace4.info()
9533
9530
  ], ClientServicesHost.prototype, "_opening", void 0);
9534
- _ts_decorate11([
9531
+ _ts_decorate9([
9535
9532
  Trace4.info()
9536
9533
  ], ClientServicesHost.prototype, "_open", void 0);
9537
- _ts_decorate11([
9534
+ _ts_decorate9([
9538
9535
  Trace4.info()
9539
9536
  ], ClientServicesHost.prototype, "_resetting", void 0);
9540
- _ts_decorate11([
9537
+ _ts_decorate9([
9541
9538
  synchronized4,
9542
9539
  Trace4.span()
9543
9540
  ], ClientServicesHost.prototype, "open", null);
9544
- _ts_decorate11([
9541
+ _ts_decorate9([
9545
9542
  synchronized4,
9546
9543
  Trace4.span()
9547
9544
  ], ClientServicesHost.prototype, "close", null);
9548
- ClientServicesHost = _ts_decorate11([
9545
+ ClientServicesHost = _ts_decorate9([
9549
9546
  Trace4.resource()
9550
9547
  ], ClientServicesHost);
9551
9548
 
@@ -9561,9 +9558,8 @@ export {
9561
9558
  DevtoolsHostEvents,
9562
9559
  DevtoolsServiceImpl,
9563
9560
  createDiagnostics,
9564
- createCollectDiagnosticsBroadcastSender,
9565
- createCollectDiagnosticsBroadcastHandler,
9566
9561
  DiagnosticsCollector,
9562
+ diagnostics_exports,
9567
9563
  createAuthProvider,
9568
9564
  TrustedKeySetAuthVerifier,
9569
9565
  EdgeFeedReplicator,
@@ -9579,19 +9575,13 @@ export {
9579
9575
  InvitationsServiceImpl,
9580
9576
  SpaceInvitationProtocol,
9581
9577
  InvitationsManager,
9582
- Lock,
9583
- isLocked,
9584
- ClientRpcServer,
9578
+ locks_exports,
9585
9579
  EdgeAgentManager,
9586
9580
  EdgeAgentServiceImpl,
9587
9581
  ServiceContext,
9588
9582
  createStorageObjects,
9589
9583
  createLevel,
9590
- encodeProfileArchive,
9591
- decodeProfileArchive,
9592
- exportProfileData,
9593
- importProfileData,
9594
9584
  ServiceRegistry,
9595
9585
  ClientServicesHost
9596
9586
  };
9597
- //# sourceMappingURL=chunk-EUNILIU5.mjs.map
9587
+ //# sourceMappingURL=chunk-DQWA5ILA.mjs.map