@dxos/client-services 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (131) 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-QCWEHHJW.mjs +24 -0
  4. package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-XT2YQZXS.mjs → chunk-QWDES2YZ.mjs} +1681 -2334
  6. package/dist/lib/browser/chunk-QWDES2YZ.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +513 -171
  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 +59 -76
  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-MDSLKO5V.mjs → chunk-2ZEVKBWH.mjs} +1231 -1753
  23. package/dist/lib/node-esm/chunk-2ZEVKBWH.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 +513 -171
  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 +59 -76
  38. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  39. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  40. package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
  41. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  42. package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
  43. package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
  44. package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
  45. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  46. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +2 -2
  47. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  48. package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -4
  49. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  50. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
  51. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  52. package/dist/types/src/packlets/identity/identity.d.ts +2 -2
  53. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  54. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
  55. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  56. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  57. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  58. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -3
  59. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  60. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
  61. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  62. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -2
  63. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  64. package/dist/types/src/packlets/locks/index.d.ts +1 -1
  65. package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
  66. package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
  67. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  68. package/dist/types/src/packlets/services/service-context.d.ts +13 -7
  69. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  70. package/dist/types/src/packlets/services/service-host.d.ts +19 -5
  71. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  72. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  73. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -5
  74. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  75. package/dist/types/src/packlets/spaces/data-space.d.ts +2 -2
  76. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  77. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
  78. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  79. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
  80. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  81. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  82. package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
  83. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  84. package/dist/types/src/packlets/testing/test-builder.d.ts +6 -5
  85. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  86. package/dist/types/src/packlets/worker/worker-runtime.d.ts +23 -4
  87. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  88. package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
  89. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  90. package/dist/types/src/version.d.ts +1 -1
  91. package/dist/types/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +70 -48
  93. package/src/packlets/agents/edge-agent-service.ts +11 -1
  94. package/src/packlets/devices/devices-service.ts +1 -1
  95. package/src/packlets/devtools/devtools.ts +2 -2
  96. package/src/packlets/diagnostics/index.ts +1 -1
  97. package/src/packlets/identity/authenticator.ts +2 -2
  98. package/src/packlets/identity/default-space-state-machine.ts +2 -2
  99. package/src/packlets/identity/identity-manager.ts +6 -6
  100. package/src/packlets/identity/identity-recovery-manager.ts +2 -2
  101. package/src/packlets/identity/identity.test.ts +4 -4
  102. package/src/packlets/identity/identity.ts +2 -2
  103. package/src/packlets/invitations/device-invitation-protocol.ts +5 -5
  104. package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
  105. package/src/packlets/invitations/invitation-host-extension.ts +6 -4
  106. package/src/packlets/invitations/invitation-protocol.ts +2 -3
  107. package/src/packlets/invitations/invitations-handler.ts +7 -7
  108. package/src/packlets/invitations/space-invitation-protocol.ts +7 -13
  109. package/src/packlets/locks/index.ts +1 -1
  110. package/src/packlets/logging/logging-service.ts +1 -1
  111. package/src/packlets/services/client-rpc-server.ts +4 -4
  112. package/src/packlets/services/service-context.ts +30 -19
  113. package/src/packlets/services/service-host.ts +62 -16
  114. package/src/packlets/space-export/space-archive-reader.ts +1 -1
  115. package/src/packlets/space-export/space-archive-writer.ts +3 -1
  116. package/src/packlets/spaces/data-space-manager.ts +56 -21
  117. package/src/packlets/spaces/data-space.ts +7 -6
  118. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  119. package/src/packlets/spaces/edge-feed-replicator.ts +3 -3
  120. package/src/packlets/spaces/epoch-migrations.ts +2 -2
  121. package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
  122. package/src/packlets/spaces/notarization-plugin.ts +8 -8
  123. package/src/packlets/spaces/spaces-service.ts +10 -7
  124. package/src/packlets/storage/storage.ts +4 -4
  125. package/src/packlets/testing/invitation-utils.ts +7 -4
  126. package/src/packlets/testing/test-builder.ts +36 -10
  127. package/src/packlets/worker/worker-runtime.ts +141 -11
  128. package/src/packlets/worker/worker-session.ts +4 -4
  129. package/src/version.ts +1 -1
  130. package/dist/lib/browser/chunk-XT2YQZXS.mjs.map +0 -7
  131. package/dist/lib/node-esm/chunk-MDSLKO5V.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";
@@ -274,25 +281,14 @@ var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
274
281
  });
275
282
 
276
283
  // src/packlets/devtools/devtools.ts
277
- function _define_property(obj, key, value) {
278
- if (key in obj) {
279
- Object.defineProperty(obj, key, {
280
- value,
281
- enumerable: true,
282
- configurable: true,
283
- writable: true
284
- });
285
- } else {
286
- obj[key] = value;
287
- }
288
- return obj;
289
- }
290
284
  var DevtoolsHostEvents = class {
291
- constructor() {
292
- _define_property(this, "ready", new AsyncEvent());
293
- }
285
+ ready = new AsyncEvent();
294
286
  };
295
287
  var DevtoolsServiceImpl = class {
288
+ params;
289
+ constructor(params) {
290
+ this.params = params;
291
+ }
296
292
  events(_request) {
297
293
  return new Stream6(({ next }) => {
298
294
  this.params.events.ready.on(() => {
@@ -395,10 +391,6 @@ var DevtoolsServiceImpl = class {
395
391
  context: this.params.context
396
392
  });
397
393
  }
398
- constructor(params) {
399
- _define_property(this, "params", void 0);
400
- this.params = params;
401
- }
402
394
  };
403
395
 
404
396
  // src/packlets/diagnostics/diagnostics.ts
@@ -411,7 +403,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
411
403
  import { TRACE_PROCESSOR } from "@dxos/tracing";
412
404
 
413
405
  // src/version.ts
414
- var DXOS_VERSION = "0.8.4-main.1da679c";
406
+ var DXOS_VERSION = "0.8.4-main.21d9917";
415
407
 
416
408
  // src/packlets/services/platform.ts
417
409
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -565,42 +557,15 @@ var getStorageDiagnostics = async () => {
565
557
  }));
566
558
  };
567
559
 
568
- // src/packlets/diagnostics/diagnostics-broadcast.ts
569
- var createCollectDiagnosticsBroadcastSender = () => {
570
- return {
571
- broadcastDiagnosticsRequest: async () => void 0
572
- };
573
- };
574
- var createCollectDiagnosticsBroadcastHandler = (_) => {
575
- return {
576
- start: () => {
577
- },
578
- stop: () => {
579
- }
580
- };
581
- };
582
-
583
560
  // src/packlets/diagnostics/diagnostics-collector.ts
584
561
  import { ClientServicesProviderResource } from "@dxos/client-protocol";
585
562
  import { ConfigResource } from "@dxos/config";
586
563
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
587
564
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
588
565
  import { isNonNullable, jsonKeyReplacer } from "@dxos/util";
589
- function _define_property2(obj, key, value) {
590
- if (key in obj) {
591
- Object.defineProperty(obj, key, {
592
- value,
593
- enumerable: true,
594
- configurable: true,
595
- writable: true
596
- });
597
- } else {
598
- obj[key] = value;
599
- }
600
- return obj;
601
- }
602
566
  var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
603
567
  var DiagnosticsCollector = class {
568
+ static broadcastSender = createCollectDiagnosticsBroadcastSender();
604
569
  static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
605
570
  const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
606
571
  keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
@@ -621,7 +586,6 @@ var DiagnosticsCollector = class {
621
586
  return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
622
587
  }
623
588
  };
624
- _define_property2(DiagnosticsCollector, "broadcastSender", createCollectDiagnosticsBroadcastSender());
625
589
  var findSystemServiceProvider = () => {
626
590
  const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
627
591
  const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
@@ -632,25 +596,21 @@ var findConfigs = () => {
632
596
  return configs.map((r) => r.instance.deref()).filter(isNonNullable);
633
597
  };
634
598
 
599
+ // src/packlets/diagnostics/index.ts
600
+ var diagnostics_exports = {};
601
+ __export(diagnostics_exports, {
602
+ DiagnosticsCollector: () => DiagnosticsCollector,
603
+ createDiagnostics: () => createDiagnostics
604
+ });
605
+ __reExport(diagnostics_exports, diagnostics_broadcast_star);
606
+ import * as diagnostics_broadcast_star from "#diagnostics-broadcast";
607
+
635
608
  // src/packlets/identity/authenticator.ts
636
609
  import { Trigger } from "@dxos/async";
637
610
  import { Context as Context2 } from "@dxos/context";
638
611
  import { verifyCredential } from "@dxos/credentials";
639
612
  import { log as log2 } from "@dxos/log";
640
613
  import { schema } from "@dxos/protocols/proto";
641
- function _define_property3(obj, key, value) {
642
- if (key in obj) {
643
- Object.defineProperty(obj, key, {
644
- value,
645
- enumerable: true,
646
- configurable: true,
647
- writable: true
648
- });
649
- } else {
650
- obj[key] = value;
651
- }
652
- return obj;
653
- }
654
614
  var __dxlog_file4 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
655
615
  var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
656
616
  var createAuthProvider = (signer) => async (nonce) => {
@@ -664,6 +624,14 @@ var createAuthProvider = (signer) => async (nonce) => {
664
624
  return Credential.encode(credential);
665
625
  };
666
626
  var TrustedKeySetAuthVerifier = class {
627
+ _params;
628
+ _ctx = new Context2(void 0, {
629
+ F: __dxlog_file4,
630
+ L: 45
631
+ });
632
+ constructor(_params) {
633
+ this._params = _params;
634
+ }
667
635
  async close() {
668
636
  await this._ctx.dispose();
669
637
  }
@@ -757,15 +725,6 @@ var TrustedKeySetAuthVerifier = class {
757
725
  const deviceSet = this._params.trustedKeysProvider();
758
726
  return deviceSet.has(deviceKey);
759
727
  }
760
- constructor(_params) {
761
- _define_property3(this, "_params", void 0);
762
- _define_property3(this, "_ctx", void 0);
763
- this._params = _params;
764
- this._ctx = new Context2(void 0, {
765
- F: __dxlog_file4,
766
- L: 45
767
- });
768
- }
769
728
  };
770
729
 
771
730
  // src/packlets/spaces/edge-feed-replicator.ts
@@ -781,19 +740,6 @@ import { buf } from "@dxos/protocols/buf";
781
740
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
782
741
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
783
742
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
784
- function _define_property4(obj, key, value) {
785
- if (key in obj) {
786
- Object.defineProperty(obj, key, {
787
- value,
788
- enumerable: true,
789
- configurable: true,
790
- writable: true
791
- });
792
- } else {
793
- obj[key] = value;
794
- }
795
- return obj;
796
- }
797
743
  function _ts_decorate(decorators, target, key, desc) {
798
744
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
799
745
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -867,6 +813,24 @@ function _ts_dispose_resources(env) {
867
813
  }
868
814
  var __dxlog_file5 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
869
815
  var EdgeFeedReplicator = class extends Resource {
816
+ _messenger;
817
+ _spaceId;
818
+ _feeds = new ComplexMap2(PublicKey3.hash);
819
+ _connectionCtx = void 0;
820
+ _connected = false;
821
+ /**
822
+ * Feed length at service.
823
+ */
824
+ _remoteLength = new ComplexMap2(PublicKey3.hash);
825
+ /**
826
+ * Protects against concurrent pushes so that remote length is updated consistently.
827
+ */
828
+ _pushMutex = new ComplexMap2(PublicKey3.hash);
829
+ constructor({ messenger, spaceId }) {
830
+ super();
831
+ this._messenger = messenger;
832
+ this._spaceId = spaceId;
833
+ }
870
834
  async _open() {
871
835
  log3("open", void 0, {
872
836
  F: __dxlog_file5,
@@ -914,7 +878,7 @@ var EdgeFeedReplicator = class extends Resource {
914
878
  }
915
879
  async _handleReconnect() {
916
880
  await this._resetConnection();
917
- if (this._messenger.status === EdgeStatus.CONNECTED) {
881
+ if (this._messenger.status.state === EdgeStatus.ConnectionState.CONNECTED) {
918
882
  this._startReplication();
919
883
  }
920
884
  }
@@ -1263,17 +1227,6 @@ var EdgeFeedReplicator = class extends Resource {
1263
1227
  });
1264
1228
  return connectionCtx;
1265
1229
  }
1266
- constructor({ messenger, spaceId }) {
1267
- super(), _define_property4(this, "_messenger", void 0), _define_property4(this, "_spaceId", void 0), _define_property4(this, "_feeds", new ComplexMap2(PublicKey3.hash)), _define_property4(this, "_connectionCtx", void 0), _define_property4(this, "_connected", false), /**
1268
- * Feed length at service.
1269
- */
1270
- _define_property4(this, "_remoteLength", new ComplexMap2(PublicKey3.hash)), /**
1271
- * Protects against concurrent pushes so that remote length is updated consistently.
1272
- */
1273
- _define_property4(this, "_pushMutex", new ComplexMap2(PublicKey3.hash));
1274
- this._messenger = messenger;
1275
- this._spaceId = spaceId;
1276
- }
1277
1230
  };
1278
1231
  _ts_decorate([
1279
1232
  logInfo
@@ -1295,7 +1248,7 @@ import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep
1295
1248
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
1296
1249
  import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1297
1250
  import { timed, warnAfterTimeout } from "@dxos/debug";
1298
- import { FIND_PARAMS as FIND_PARAMS2, createMappedFeedWriter } from "@dxos/echo-pipeline";
1251
+ import { createMappedFeedWriter } from "@dxos/echo-pipeline";
1299
1252
  import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
1300
1253
  import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
1301
1254
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -1323,15 +1276,16 @@ import { ComplexSet } from "@dxos/util";
1323
1276
  // src/packlets/spaces/data-space-manager.ts
1324
1277
  import { interpretAsDocumentId } from "@automerge/automerge-repo";
1325
1278
  import { Event as Event2, synchronized, trackLeaks } from "@dxos/async";
1326
- import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1279
+ import { SpaceProperties } from "@dxos/client-protocol";
1327
1280
  import { Context as Context4, LifecycleState, Resource as Resource2, cancelWithContext } from "@dxos/context";
1328
1281
  import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
1329
- import { AuthStatus, CredentialServerExtension, DatabaseRoot, FIND_PARAMS, findInlineObjectOfType } from "@dxos/echo-pipeline";
1330
- import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1331
- import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1282
+ import { Type } from "@dxos/echo";
1283
+ import { getSchemaDXN } from "@dxos/echo/internal";
1284
+ import { AuthStatus, CredentialServerExtension, DatabaseRoot, findInlineObjectOfType } from "@dxos/echo-pipeline";
1285
+ import { EncodedReference, SpaceDocVersion, createIdFromSpaceKey } from "@dxos/echo-protocol";
1332
1286
  import { writeMessages } from "@dxos/feed-store";
1333
1287
  import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
1334
- import { PublicKey as PublicKey4 } from "@dxos/keys";
1288
+ import { ObjectId, PublicKey as PublicKey4 } from "@dxos/keys";
1335
1289
  import { log as log4 } from "@dxos/log";
1336
1290
  import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
1337
1291
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
@@ -1412,19 +1366,6 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1412
1366
  };
1413
1367
 
1414
1368
  // src/packlets/spaces/data-space-manager.ts
1415
- function _define_property5(obj, key, value) {
1416
- if (key in obj) {
1417
- Object.defineProperty(obj, key, {
1418
- value,
1419
- enumerable: true,
1420
- configurable: true,
1421
- writable: true
1422
- });
1423
- } else {
1424
- obj[key] = value;
1425
- }
1426
- return obj;
1427
- }
1428
1369
  function _ts_decorate2(decorators, target, key, desc) {
1429
1370
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1430
1371
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1436,6 +1377,64 @@ var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1436
1377
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
1437
1378
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
1438
1379
  var DataSpaceManager = class extends Resource2 {
1380
+ updated = new Event2();
1381
+ _spaces = new ComplexMap3(PublicKey4.hash);
1382
+ _instanceId = PublicKey4.random().toHex();
1383
+ _spaceManager;
1384
+ _metadataStore;
1385
+ _keyring;
1386
+ _signingContext;
1387
+ _feedStore;
1388
+ _echoHost;
1389
+ _invitationsManager;
1390
+ _edgeConnection = void 0;
1391
+ _edgeHttpClient = void 0;
1392
+ _edgeFeatures = void 0;
1393
+ _meshReplicator = void 0;
1394
+ _echoEdgeReplicator = void 0;
1395
+ _runtimeProps = void 0;
1396
+ constructor(params) {
1397
+ super();
1398
+ this._spaceManager = params.spaceManager;
1399
+ this._metadataStore = params.metadataStore;
1400
+ this._keyring = params.keyring;
1401
+ this._signingContext = params.signingContext;
1402
+ this._feedStore = params.feedStore;
1403
+ this._echoHost = params.echoHost;
1404
+ this._meshReplicator = params.meshReplicator;
1405
+ this._invitationsManager = params.invitationsManager;
1406
+ this._edgeConnection = params.edgeConnection;
1407
+ this._edgeFeatures = params.edgeFeatures;
1408
+ this._echoEdgeReplicator = params.echoEdgeReplicator;
1409
+ this._edgeHttpClient = params.edgeHttpClient;
1410
+ this._runtimeProps = params.runtimeProps;
1411
+ trace.diagnostic({
1412
+ id: "spaces",
1413
+ name: "Spaces",
1414
+ fetch: async () => {
1415
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
1416
+ const rootUrl = space.automergeSpaceState.rootUrl;
1417
+ const rootHandle = rootUrl ? await this._echoHost.loadDoc(Context4.default(void 0, {
1418
+ F: __dxlog_file6,
1419
+ L: 187
1420
+ }), rootUrl) : void 0;
1421
+ await rootHandle?.whenReady();
1422
+ const rootDoc = rootHandle?.doc();
1423
+ const properties = rootDoc && findInlineObjectOfType(rootDoc, Type.getTypename(SpaceProperties));
1424
+ return {
1425
+ key: space.key.toHex(),
1426
+ state: SpaceState[space.state],
1427
+ name: properties?.[1].data.name ?? null,
1428
+ inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
1429
+ linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
1430
+ credentials: space.inner.spaceState.credentials.length,
1431
+ members: space.inner.spaceState.members.size,
1432
+ rootUrl
1433
+ };
1434
+ }));
1435
+ }
1436
+ });
1437
+ }
1439
1438
  // TODO(burdon): Remove.
1440
1439
  get spaces() {
1441
1440
  return this._spaces;
@@ -1448,7 +1447,7 @@ var DataSpaceManager = class extends Resource2 {
1448
1447
  async _open() {
1449
1448
  log4("open", void 0, {
1450
1449
  F: __dxlog_file6,
1451
- L: 216,
1450
+ L: 221,
1452
1451
  S: this,
1453
1452
  C: (f, a) => f(...a)
1454
1453
  });
@@ -1456,7 +1455,7 @@ var DataSpaceManager = class extends Resource2 {
1456
1455
  id: this._instanceId
1457
1456
  }), {
1458
1457
  F: __dxlog_file6,
1459
- L: 217,
1458
+ L: 222,
1460
1459
  S: this,
1461
1460
  C: (f, a) => f(...a)
1462
1461
  });
@@ -1464,39 +1463,64 @@ var DataSpaceManager = class extends Resource2 {
1464
1463
  spaces: this._metadataStore.spaces.length
1465
1464
  }, {
1466
1465
  F: __dxlog_file6,
1467
- L: 218,
1466
+ L: 223,
1468
1467
  S: this,
1469
1468
  C: (f, a) => f(...a)
1470
1469
  });
1470
+ const spacesToActivate = [];
1471
1471
  await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
1472
1472
  try {
1473
1473
  log4("load space", {
1474
1474
  spaceMetadata
1475
1475
  }, {
1476
1476
  F: __dxlog_file6,
1477
- L: 222,
1477
+ L: 228,
1478
1478
  S: this,
1479
1479
  C: (f, a) => f(...a)
1480
1480
  });
1481
- await this._constructSpace(spaceMetadata);
1481
+ const space = await this._constructSpace(spaceMetadata);
1482
+ if (this._runtimeProps?.autoActivateSpaces && spaceMetadata.state === SpaceState.SPACE_ACTIVE) {
1483
+ spacesToActivate.push(space);
1484
+ }
1482
1485
  } catch (err) {
1483
1486
  log4.error("Error loading space", {
1484
1487
  spaceMetadata,
1485
1488
  err
1486
1489
  }, {
1487
1490
  F: __dxlog_file6,
1488
- L: 225,
1491
+ L: 235,
1489
1492
  S: this,
1490
1493
  C: (f, a) => f(...a)
1491
1494
  });
1492
1495
  }
1493
1496
  });
1497
+ for (const space of spacesToActivate) {
1498
+ log4("auto-activating space", {
1499
+ spaceKey: space.key
1500
+ }, {
1501
+ F: __dxlog_file6,
1502
+ L: 241,
1503
+ S: this,
1504
+ C: (f, a) => f(...a)
1505
+ });
1506
+ space.activate().catch((err) => {
1507
+ log4.error("Error auto-activating space", {
1508
+ spaceKey: space.key,
1509
+ err
1510
+ }, {
1511
+ F: __dxlog_file6,
1512
+ L: 243,
1513
+ S: this,
1514
+ C: (f, a) => f(...a)
1515
+ });
1516
+ });
1517
+ }
1494
1518
  this.updated.emit();
1495
1519
  log4.trace("dxos.echo.data-space-manager.open", Trace.end({
1496
1520
  id: this._instanceId
1497
1521
  }), {
1498
1522
  F: __dxlog_file6,
1499
- L: 231,
1523
+ L: 249,
1500
1524
  S: this,
1501
1525
  C: (f, a) => f(...a)
1502
1526
  });
@@ -1504,7 +1528,7 @@ var DataSpaceManager = class extends Resource2 {
1504
1528
  async _close() {
1505
1529
  log4("close", void 0, {
1506
1530
  F: __dxlog_file6,
1507
- L: 236,
1531
+ L: 254,
1508
1532
  S: this,
1509
1533
  C: (f, a) => f(...a)
1510
1534
  });
@@ -1535,7 +1559,7 @@ var DataSpaceManager = class extends Resource2 {
1535
1559
  spaceKey
1536
1560
  }, {
1537
1561
  F: __dxlog_file6,
1538
- L: 269,
1562
+ L: 287,
1539
1563
  S: this,
1540
1564
  C: (f, a) => f(...a)
1541
1565
  });
@@ -1543,7 +1567,7 @@ var DataSpaceManager = class extends Resource2 {
1543
1567
  if (options.documents) {
1544
1568
  invariant3(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
1545
1569
  F: __dxlog_file6,
1546
- L: 274,
1570
+ L: 292,
1547
1571
  S: this,
1548
1572
  A: [
1549
1573
  "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
@@ -1555,13 +1579,18 @@ var DataSpaceManager = class extends Resource2 {
1555
1579
  documentId
1556
1580
  }, {
1557
1581
  F: __dxlog_file6,
1558
- L: 281,
1582
+ L: 299,
1559
1583
  S: this,
1560
1584
  C: (f, a) => f(...a)
1561
1585
  });
1562
1586
  const newDoc = await this._echoHost.createDoc(data, {
1563
1587
  preserveHistory: true
1564
1588
  });
1589
+ if (newDoc.doc().access !== void 0 && newDoc.doc().access.spaceKey !== spaceKey.toHex()) {
1590
+ newDoc.change((doc) => {
1591
+ doc.access.spaceKey = spaceKey.toHex();
1592
+ });
1593
+ }
1565
1594
  documentIdMapping[documentId] = newDoc.documentId;
1566
1595
  }));
1567
1596
  }
@@ -1569,7 +1598,7 @@ var DataSpaceManager = class extends Resource2 {
1569
1598
  spaceKey
1570
1599
  }, {
1571
1600
  F: __dxlog_file6,
1572
- L: 288,
1601
+ L: 317,
1573
1602
  S: this,
1574
1603
  C: (f, a) => f(...a)
1575
1604
  });
@@ -1578,18 +1607,19 @@ var DataSpaceManager = class extends Resource2 {
1578
1607
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
1579
1608
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
1580
1609
  F: __dxlog_file6,
1581
- L: 293
1610
+ L: 322
1582
1611
  }), newRootDocId);
1583
1612
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
1584
1613
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
1585
1614
  } else {
1586
1615
  root = await this._echoHost.createSpaceRoot(spaceKey);
1587
1616
  }
1617
+ await this._echoHost.flush();
1588
1618
  log4("constructing space...", {
1589
1619
  spaceKey
1590
1620
  }, {
1591
1621
  F: __dxlog_file6,
1592
- L: 301,
1622
+ L: 331,
1593
1623
  S: this,
1594
1624
  C: (f, a) => f(...a)
1595
1625
  });
@@ -1599,7 +1629,7 @@ var DataSpaceManager = class extends Resource2 {
1599
1629
  spaceKey
1600
1630
  }, {
1601
1631
  F: __dxlog_file6,
1602
- L: 306,
1632
+ L: 336,
1603
1633
  S: this,
1604
1634
  C: (f, a) => f(...a)
1605
1635
  });
@@ -1608,7 +1638,7 @@ var DataSpaceManager = class extends Resource2 {
1608
1638
  const memberCredential = credentials[1];
1609
1639
  invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1610
1640
  F: __dxlog_file6,
1611
- L: 312,
1641
+ L: 342,
1612
1642
  S: this,
1613
1643
  A: [
1614
1644
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1622,7 +1652,7 @@ var DataSpaceManager = class extends Resource2 {
1622
1652
  spaceKey
1623
1653
  }, {
1624
1654
  F: __dxlog_file6,
1625
- L: 317,
1655
+ L: 347,
1626
1656
  S: this,
1627
1657
  C: (f, a) => f(...a)
1628
1658
  });
@@ -1640,13 +1670,13 @@ var DataSpaceManager = class extends Resource2 {
1640
1670
  spaceId: space.id
1641
1671
  }, {
1642
1672
  F: __dxlog_file6,
1643
- L: 330,
1673
+ L: 360,
1644
1674
  S: this,
1645
1675
  C: (f, a) => f(...a)
1646
1676
  });
1647
1677
  await space.databaseRoot.handle.whenReady();
1648
1678
  }
1649
- const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), TYPE_PROPERTIES) ?? [];
1679
+ const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), Type.getTypename(SpaceProperties)) ?? [];
1650
1680
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
1651
1681
  }
1652
1682
  case SpaceDocVersion.LEGACY: {
@@ -1658,7 +1688,7 @@ var DataSpaceManager = class extends Resource2 {
1658
1688
  spaceId: space.id
1659
1689
  }, {
1660
1690
  F: __dxlog_file6,
1661
- L: 341,
1691
+ L: 374,
1662
1692
  S: this,
1663
1693
  C: (f, a) => f(...a)
1664
1694
  });
@@ -1670,7 +1700,7 @@ var DataSpaceManager = class extends Resource2 {
1670
1700
  const document = await this._getSpaceRootDocument(space);
1671
1701
  const properties = {
1672
1702
  system: {
1673
- type: encodeReference(getTypeReference(PropertiesType))
1703
+ type: EncodedReference.fromDXN(getSchemaDXN(SpaceProperties))
1674
1704
  },
1675
1705
  data: {
1676
1706
  [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
@@ -1693,14 +1723,19 @@ var DataSpaceManager = class extends Resource2 {
1693
1723
  const automergeIndex = space.automergeSpaceState.rootUrl;
1694
1724
  invariant3(automergeIndex, void 0, {
1695
1725
  F: __dxlog_file6,
1696
- L: 374,
1726
+ L: 407,
1697
1727
  S: this,
1698
1728
  A: [
1699
1729
  "automergeIndex",
1700
1730
  ""
1701
1731
  ]
1702
1732
  });
1703
- const document = await this._echoHost.automergeRepo.find(automergeIndex, FIND_PARAMS);
1733
+ const document = await this._echoHost.loadDoc(Context4.default(void 0, {
1734
+ F: __dxlog_file6,
1735
+ L: 408
1736
+ }), automergeIndex, {
1737
+ fetchFromNetwork: true
1738
+ });
1704
1739
  await document.whenReady();
1705
1740
  return document;
1706
1741
  }
@@ -1710,13 +1745,13 @@ var DataSpaceManager = class extends Resource2 {
1710
1745
  opts
1711
1746
  }, {
1712
1747
  F: __dxlog_file6,
1713
- L: 383,
1748
+ L: 418,
1714
1749
  S: this,
1715
1750
  C: (f, a) => f(...a)
1716
1751
  });
1717
1752
  invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
1718
1753
  F: __dxlog_file6,
1719
- L: 384,
1754
+ L: 419,
1720
1755
  S: this,
1721
1756
  A: [
1722
1757
  "this._lifecycleState === LifecycleState.OPEN",
@@ -1725,7 +1760,7 @@ var DataSpaceManager = class extends Resource2 {
1725
1760
  });
1726
1761
  invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
1727
1762
  F: __dxlog_file6,
1728
- L: 385,
1763
+ L: 420,
1729
1764
  S: this,
1730
1765
  A: [
1731
1766
  "!this._spaces.has(opts.spaceKey)",
@@ -1749,7 +1784,7 @@ var DataSpaceManager = class extends Resource2 {
1749
1784
  const space = this._spaceManager.spaces.get(options.spaceKey);
1750
1785
  invariant3(space, void 0, {
1751
1786
  F: __dxlog_file6,
1752
- L: 405,
1787
+ L: 440,
1753
1788
  S: this,
1754
1789
  A: [
1755
1790
  "space",
@@ -1762,7 +1797,7 @@ var DataSpaceManager = class extends Resource2 {
1762
1797
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
1763
1798
  invariant3(credentials[0].credential, void 0, {
1764
1799
  F: __dxlog_file6,
1765
- L: 424,
1800
+ L: 459,
1766
1801
  S: this,
1767
1802
  A: [
1768
1803
  "credentials[0].credential",
@@ -1772,7 +1807,7 @@ var DataSpaceManager = class extends Resource2 {
1772
1807
  const spaceMemberCredential = credentials[0].credential.credential;
1773
1808
  invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1774
1809
  F: __dxlog_file6,
1775
- L: 426,
1810
+ L: 461,
1776
1811
  S: this,
1777
1812
  A: [
1778
1813
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1810,7 +1845,7 @@ var DataSpaceManager = class extends Resource2 {
1810
1845
  const space = this._spaces.get(spaceKey);
1811
1846
  invariant3(space, "Space not found.", {
1812
1847
  F: __dxlog_file6,
1813
- L: 463,
1848
+ L: 498,
1814
1849
  S: this,
1815
1850
  A: [
1816
1851
  "space",
@@ -1835,7 +1870,7 @@ var DataSpaceManager = class extends Resource2 {
1835
1870
  metadata
1836
1871
  }, {
1837
1872
  F: __dxlog_file6,
1838
- L: 482,
1873
+ L: 517,
1839
1874
  S: this,
1840
1875
  C: (f, a) => f(...a)
1841
1876
  });
@@ -1843,8 +1878,8 @@ var DataSpaceManager = class extends Resource2 {
1843
1878
  localPeerId: this._signingContext.deviceKey
1844
1879
  });
1845
1880
  const presence = new Presence({
1846
- announceInterval: this._runtimeParams?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
1847
- offlineTimeout: this._runtimeParams?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
1881
+ announceInterval: this._runtimeProps?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
1882
+ offlineTimeout: this._runtimeProps?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
1848
1883
  identityKey: this._signingContext.identityKey,
1849
1884
  gossip
1850
1885
  });
@@ -1879,7 +1914,7 @@ var DataSpaceManager = class extends Resource2 {
1879
1914
  err
1880
1915
  }, {
1881
1916
  F: __dxlog_file6,
1882
- L: 524,
1917
+ L: 559,
1883
1918
  S: this,
1884
1919
  C: (f, a) => f(...a)
1885
1920
  });
@@ -1889,7 +1924,7 @@ var DataSpaceManager = class extends Resource2 {
1889
1924
  onAuthFailure: () => {
1890
1925
  log4.warn("auth failure", void 0, {
1891
1926
  F: __dxlog_file6,
1892
- L: 529,
1927
+ L: 564,
1893
1928
  S: this,
1894
1929
  C: (f, a) => f(...a)
1895
1930
  });
@@ -1922,7 +1957,7 @@ var DataSpaceManager = class extends Resource2 {
1922
1957
  space: space.key
1923
1958
  }, {
1924
1959
  F: __dxlog_file6,
1925
- L: 556,
1960
+ L: 591,
1926
1961
  S: this,
1927
1962
  C: (f, a) => f(...a)
1928
1963
  });
@@ -1933,7 +1968,7 @@ var DataSpaceManager = class extends Resource2 {
1933
1968
  open: this._lifecycleState === LifecycleState.OPEN
1934
1969
  }, {
1935
1970
  F: __dxlog_file6,
1936
- L: 559,
1971
+ L: 594,
1937
1972
  S: this,
1938
1973
  C: (f, a) => f(...a)
1939
1974
  });
@@ -1952,7 +1987,7 @@ var DataSpaceManager = class extends Resource2 {
1952
1987
  space: space.key
1953
1988
  }, {
1954
1989
  F: __dxlog_file6,
1955
- L: 567,
1990
+ L: 602,
1956
1991
  S: this,
1957
1992
  C: (f, a) => f(...a)
1958
1993
  });
@@ -1962,7 +1997,7 @@ var DataSpaceManager = class extends Resource2 {
1962
1997
  edgeConnection: this._edgeConnection,
1963
1998
  edgeHttpClient: this._edgeHttpClient,
1964
1999
  edgeFeatures: this._edgeFeatures,
1965
- activeEdgeNotarizationPollingInterval: this._runtimeParams?.activeEdgeNotarizationPollingInterval
2000
+ activeEdgeNotarizationPollingInterval: this._runtimeProps?.activeEdgeNotarizationPollingInterval
1966
2001
  });
1967
2002
  dataSpace.postOpen.append(async () => {
1968
2003
  const setting = dataSpace.getEdgeReplicationSetting();
@@ -1973,7 +2008,7 @@ var DataSpaceManager = class extends Resource2 {
1973
2008
  spaceId: dataSpace.id
1974
2009
  }, {
1975
2010
  F: __dxlog_file6,
1976
- L: 581,
2011
+ L: 616,
1977
2012
  S: this,
1978
2013
  C: (f, a) => f(...a)
1979
2014
  });
@@ -2003,7 +2038,7 @@ var DataSpaceManager = class extends Resource2 {
2003
2038
  space: space.key
2004
2039
  }, {
2005
2040
  F: __dxlog_file6,
2006
- L: 608,
2041
+ L: 643,
2007
2042
  S: this,
2008
2043
  C: (f, a) => f(...a)
2009
2044
  });
@@ -2036,7 +2071,7 @@ var DataSpaceManager = class extends Resource2 {
2036
2071
  closedSessions
2037
2072
  }, {
2038
2073
  F: __dxlog_file6,
2039
- L: 634,
2074
+ L: 669,
2040
2075
  S: this,
2041
2076
  C: (f, a) => f(...a)
2042
2077
  });
@@ -2051,7 +2086,7 @@ var DataSpaceManager = class extends Resource2 {
2051
2086
  peerId: peerState.peerId
2052
2087
  }, {
2053
2088
  F: __dxlog_file6,
2054
- L: 648,
2089
+ L: 683,
2055
2090
  S: this,
2056
2091
  C: (f, a) => f(...a)
2057
2092
  });
@@ -2094,45 +2129,6 @@ var DataSpaceManager = class extends Resource2 {
2094
2129
  });
2095
2130
  await Promise.all(tasks);
2096
2131
  }
2097
- constructor(params) {
2098
- super(), _define_property5(this, "updated", new Event2()), _define_property5(this, "_spaces", new ComplexMap3(PublicKey4.hash)), _define_property5(this, "_instanceId", PublicKey4.random().toHex()), _define_property5(this, "_spaceManager", void 0), _define_property5(this, "_metadataStore", void 0), _define_property5(this, "_keyring", void 0), _define_property5(this, "_signingContext", void 0), _define_property5(this, "_feedStore", void 0), _define_property5(this, "_echoHost", void 0), _define_property5(this, "_invitationsManager", void 0), _define_property5(this, "_edgeConnection", void 0), _define_property5(this, "_edgeHttpClient", void 0), _define_property5(this, "_edgeFeatures", void 0), _define_property5(this, "_meshReplicator", void 0), _define_property5(this, "_echoEdgeReplicator", void 0), _define_property5(this, "_runtimeParams", void 0);
2099
- this._spaceManager = params.spaceManager;
2100
- this._metadataStore = params.metadataStore;
2101
- this._keyring = params.keyring;
2102
- this._signingContext = params.signingContext;
2103
- this._feedStore = params.feedStore;
2104
- this._echoHost = params.echoHost;
2105
- this._meshReplicator = params.meshReplicator;
2106
- this._invitationsManager = params.invitationsManager;
2107
- this._edgeConnection = params.edgeConnection;
2108
- this._edgeFeatures = params.edgeFeatures;
2109
- this._echoEdgeReplicator = params.echoEdgeReplicator;
2110
- this._edgeHttpClient = params.edgeHttpClient;
2111
- this._runtimeParams = params.runtimeParams;
2112
- trace.diagnostic({
2113
- id: "spaces",
2114
- name: "Spaces",
2115
- fetch: async () => {
2116
- return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
2117
- const rootUrl = space.automergeSpaceState.rootUrl;
2118
- const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
2119
- await rootHandle?.whenReady();
2120
- const rootDoc = rootHandle?.doc();
2121
- const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
2122
- return {
2123
- key: space.key.toHex(),
2124
- state: SpaceState[space.state],
2125
- name: properties?.[1].data.name ?? null,
2126
- inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
2127
- linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
2128
- credentials: space.inner.spaceState.credentials.length,
2129
- members: space.inner.spaceState.members.size,
2130
- rootUrl
2131
- };
2132
- }));
2133
- }
2134
- });
2135
- }
2136
2132
  };
2137
2133
  _ts_decorate2([
2138
2134
  synchronized
@@ -2167,21 +2163,13 @@ import { trace as trace2 } from "@dxos/tracing";
2167
2163
  import { Resource as Resource3 } from "@dxos/context";
2168
2164
  import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
2169
2165
  import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
2170
- function _define_property6(obj, key, value) {
2171
- if (key in obj) {
2172
- Object.defineProperty(obj, key, {
2173
- value,
2174
- enumerable: true,
2175
- configurable: true,
2176
- writable: true
2177
- });
2178
- } else {
2179
- obj[key] = value;
2180
- }
2181
- return obj;
2182
- }
2166
+ import { createFilename } from "@dxos/util";
2183
2167
  var CURRENT_VERSION = SpaceArchiveVersion.V1;
2184
2168
  var SpaceArchiveWriter = class extends Resource3 {
2169
+ _tar;
2170
+ _archive;
2171
+ _meta = void 0;
2172
+ _currentRootUrl = void 0;
2185
2173
  async _open(ctx) {
2186
2174
  this._tar = await import("@obsidize/tar-browserify");
2187
2175
  }
@@ -2208,6 +2196,7 @@ var SpaceArchiveWriter = class extends Resource3 {
2208
2196
  async finish() {
2209
2197
  assertState2(this._archive, "Not open");
2210
2198
  assertState2(this._meta, "Not started");
2199
+ assertState2(this._meta.spaceId, "No space ID set");
2211
2200
  assertState2(this._currentRootUrl, "No root URL set");
2212
2201
  const metadata = {
2213
2202
  version: CURRENT_VERSION,
@@ -2221,13 +2210,15 @@ var SpaceArchiveWriter = class extends Resource3 {
2221
2210
  this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
2222
2211
  const binary = this._archive.toUint8Array();
2223
2212
  return {
2224
- filename: `${this._meta.spaceId}.tar`,
2213
+ filename: createFilename({
2214
+ parts: [
2215
+ this._meta.spaceId
2216
+ ],
2217
+ ext: "tar"
2218
+ }),
2225
2219
  contents: binary
2226
2220
  };
2227
2221
  }
2228
- constructor(...args) {
2229
- super(...args), _define_property6(this, "_tar", void 0), _define_property6(this, "_archive", void 0), _define_property6(this, "_meta", void 0), _define_property6(this, "_currentRootUrl", void 0);
2230
- }
2231
2222
  };
2232
2223
 
2233
2224
  // src/packlets/space-export/space-archive-reader.ts
@@ -2255,7 +2246,7 @@ var extractSpaceArchive = async (archive) => {
2255
2246
  });
2256
2247
  documents[documentId] = entry2.content ?? failedInvariant2();
2257
2248
  }
2258
- log5.info("extracted space archive", {
2249
+ log5("extracted space archive", {
2259
2250
  metadata,
2260
2251
  documents
2261
2252
  }, {
@@ -2271,19 +2262,6 @@ var extractSpaceArchive = async (archive) => {
2271
2262
  };
2272
2263
 
2273
2264
  // src/packlets/spaces/spaces-service.ts
2274
- function _define_property7(obj, key, value) {
2275
- if (key in obj) {
2276
- Object.defineProperty(obj, key, {
2277
- value,
2278
- enumerable: true,
2279
- configurable: true,
2280
- writable: true
2281
- });
2282
- } else {
2283
- obj[key] = value;
2284
- }
2285
- return obj;
2286
- }
2287
2265
  function _ts_add_disposable_resource2(env, value, async) {
2288
2266
  if (value !== null && value !== void 0) {
2289
2267
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -2351,6 +2329,14 @@ function _ts_dispose_resources2(env) {
2351
2329
  }
2352
2330
  var __dxlog_file8 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2353
2331
  var SpacesServiceImpl = class {
2332
+ _identityManager;
2333
+ _spaceManager;
2334
+ _getDataSpaceManager;
2335
+ constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2336
+ this._identityManager = _identityManager;
2337
+ this._spaceManager = _spaceManager;
2338
+ this._getDataSpaceManager = _getDataSpaceManager;
2339
+ }
2354
2340
  async createSpace() {
2355
2341
  this._requireIdentity();
2356
2342
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -2370,7 +2356,9 @@ var SpacesServiceImpl = class {
2370
2356
  await space.deactivate();
2371
2357
  break;
2372
2358
  default:
2373
- throw new ApiError("Invalid space state");
2359
+ throw new ApiError({
2360
+ message: "Invalid space state"
2361
+ });
2374
2362
  }
2375
2363
  }
2376
2364
  if (edgeReplication !== void 0) {
@@ -2384,15 +2372,18 @@ var SpacesServiceImpl = class {
2384
2372
  throw new SpaceNotFoundError(request.spaceKey);
2385
2373
  }
2386
2374
  if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
2387
- throw new AuthorizationError("No member management permission.", {
2388
- spaceKey: space.key,
2389
- role: space.spaceState.getMemberRole(identity.identityKey)
2375
+ throw new AuthorizationError({
2376
+ message: "No member management permission.",
2377
+ context: {
2378
+ spaceKey: space.key,
2379
+ role: space.spaceState.getMemberRole(identity.identityKey)
2380
+ }
2390
2381
  });
2391
2382
  }
2392
2383
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2393
2384
  invariant5(credentials[0].credential, void 0, {
2394
2385
  F: __dxlog_file8,
2395
- L: 120,
2386
+ L: 123,
2396
2387
  S: this,
2397
2388
  A: [
2398
2389
  "credentials[0].credential",
@@ -2402,7 +2393,7 @@ var SpacesServiceImpl = class {
2402
2393
  const spaceMemberCredential = credentials[0].credential.credential;
2403
2394
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2404
2395
  F: __dxlog_file8,
2405
- L: 122,
2396
+ L: 125,
2406
2397
  S: this,
2407
2398
  A: [
2408
2399
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2420,7 +2411,7 @@ var SpacesServiceImpl = class {
2420
2411
  ids: spaces.map((space) => space.id)
2421
2412
  }), {
2422
2413
  F: __dxlog_file8,
2423
- L: 135,
2414
+ L: 138,
2424
2415
  S: this,
2425
2416
  C: (f, a) => f(...a)
2426
2417
  });
@@ -2512,7 +2503,7 @@ var SpacesServiceImpl = class {
2512
2503
  } else {
2513
2504
  invariant5(!credential.id, "Id on unsigned credentials is not allowed", {
2514
2505
  F: __dxlog_file8,
2515
- L: 233,
2506
+ L: 236,
2516
2507
  S: this,
2517
2508
  A: [
2518
2509
  "!credential.id",
@@ -2521,7 +2512,7 @@ var SpacesServiceImpl = class {
2521
2512
  });
2522
2513
  invariant5(this._identityManager.identity, "Identity is not available", {
2523
2514
  F: __dxlog_file8,
2524
- L: 234,
2515
+ L: 237,
2525
2516
  S: this,
2526
2517
  A: [
2527
2518
  "this._identityManager.identity",
@@ -2531,7 +2522,7 @@ var SpacesServiceImpl = class {
2531
2522
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2532
2523
  invariant5(credential.issuer.equals(signer.getIssuer()), void 0, {
2533
2524
  F: __dxlog_file8,
2534
- L: 236,
2525
+ L: 239,
2535
2526
  S: this,
2536
2527
  A: [
2537
2528
  "credential.issuer.equals(signer.getIssuer())",
@@ -2614,7 +2605,7 @@ var SpacesServiceImpl = class {
2614
2605
  const extracted = await extractSpaceArchive(request.archive);
2615
2606
  invariant5(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
2616
2607
  F: __dxlog_file8,
2617
- L: 290,
2608
+ L: 293,
2618
2609
  S: this,
2619
2610
  A: [
2620
2611
  "extracted.metadata.echo?.currentRootUrl",
@@ -2634,7 +2625,7 @@ var SpacesServiceImpl = class {
2634
2625
  const assertion = getCredentialAssertion2(credential);
2635
2626
  invariant5(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2636
2627
  F: __dxlog_file8,
2637
- L: 301,
2628
+ L: 304,
2638
2629
  S: this,
2639
2630
  A: [
2640
2631
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2644,7 +2635,7 @@ var SpacesServiceImpl = class {
2644
2635
  const myIdentity = this._identityManager.identity;
2645
2636
  invariant5(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2646
2637
  F: __dxlog_file8,
2647
- L: 303,
2638
+ L: 306,
2648
2639
  S: this,
2649
2640
  A: [
2650
2641
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2713,7 +2704,9 @@ var SpacesServiceImpl = class {
2713
2704
  }
2714
2705
  _requireIdentity() {
2715
2706
  if (!this._identityManager.identity) {
2716
- throw new IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
2707
+ throw new IdentityNotInitializedError({
2708
+ message: "This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo"
2709
+ });
2717
2710
  }
2718
2711
  return this._identityManager.identity;
2719
2712
  }
@@ -2728,14 +2721,6 @@ var SpacesServiceImpl = class {
2728
2721
  });
2729
2722
  }
2730
2723
  }
2731
- constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2732
- _define_property7(this, "_identityManager", void 0);
2733
- _define_property7(this, "_spaceManager", void 0);
2734
- _define_property7(this, "_getDataSpaceManager", void 0);
2735
- this._identityManager = _identityManager;
2736
- this._spaceManager = _spaceManager;
2737
- this._getDataSpaceManager = _getDataSpaceManager;
2738
- }
2739
2724
  };
2740
2725
  var getChannelId = (channel) => `user-channel/${channel}`;
2741
2726
 
@@ -2743,21 +2728,13 @@ var getChannelId = (channel) => `user-channel/${channel}`;
2743
2728
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2744
2729
  import { SpaceId as SpaceId2 } from "@dxos/keys";
2745
2730
  import { log as log7 } from "@dxos/log";
2746
- function _define_property8(obj, key, value) {
2747
- if (key in obj) {
2748
- Object.defineProperty(obj, key, {
2749
- value,
2750
- enumerable: true,
2751
- configurable: true,
2752
- writable: true
2753
- });
2754
- } else {
2755
- obj[key] = value;
2756
- }
2757
- return obj;
2758
- }
2759
2731
  var __dxlog_file9 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
2760
2732
  var DefaultSpaceStateMachine = class {
2733
+ _params;
2734
+ _spaceId;
2735
+ constructor(_params) {
2736
+ this._params = _params;
2737
+ }
2761
2738
  get spaceId() {
2762
2739
  return this._spaceId;
2763
2740
  }
@@ -2793,27 +2770,9 @@ var DefaultSpaceStateMachine = class {
2793
2770
  }
2794
2771
  }
2795
2772
  }
2796
- constructor(_params) {
2797
- _define_property8(this, "_params", void 0);
2798
- _define_property8(this, "_spaceId", void 0);
2799
- this._params = _params;
2800
- }
2801
2773
  };
2802
2774
 
2803
2775
  // src/packlets/identity/identity.ts
2804
- function _define_property9(obj, key, value) {
2805
- if (key in obj) {
2806
- Object.defineProperty(obj, key, {
2807
- value,
2808
- enumerable: true,
2809
- configurable: true,
2810
- writable: true
2811
- });
2812
- } else {
2813
- obj[key] = value;
2814
- }
2815
- return obj;
2816
- }
2817
2776
  function _ts_decorate3(decorators, target, key, desc) {
2818
2777
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2819
2778
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2822,42 +2781,94 @@ function _ts_decorate3(decorators, target, key, desc) {
2822
2781
  }
2823
2782
  var __dxlog_file10 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
2824
2783
  var Identity = class {
2825
- // TODO(burdon): Expose state object?
2826
- get authorizedDeviceKeys() {
2827
- return this._deviceStateMachine.authorizedDeviceKeys;
2828
- }
2829
- get defaultSpaceId() {
2830
- return this._defaultSpaceStateMachine.spaceId;
2831
- }
2832
- async open(ctx) {
2833
- await this._presence?.open();
2834
- await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
2835
- await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
2836
- await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
2837
- if (this._edgeFeedReplicator) {
2838
- this.space.protocol.feedAdded.append(this._onFeedAdded);
2839
- }
2840
- await this.space.open(ctx);
2841
- }
2842
- async joinNetwork() {
2843
- await this.space.startProtocol();
2844
- await this._edgeFeedReplicator?.open();
2845
- }
2846
- async close(ctx) {
2847
- await this._presence?.close();
2848
- await this.authVerifier.close();
2849
- await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
2850
- await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
2851
- await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
2852
- if (this._edgeFeedReplicator) {
2853
- this.space.protocol.feedAdded.remove(this._onFeedAdded);
2854
- }
2855
- await this._edgeFeedReplicator?.close();
2856
- await this.space.close();
2857
- }
2858
- async ready() {
2859
- await this._deviceStateMachine.deviceChainReady.wait();
2860
- await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
2784
+ space;
2785
+ _signer;
2786
+ _presence;
2787
+ _deviceStateMachine;
2788
+ _profileStateMachine;
2789
+ _defaultSpaceStateMachine;
2790
+ _edgeFeedReplicator = void 0;
2791
+ authVerifier;
2792
+ did;
2793
+ identityKey;
2794
+ deviceKey;
2795
+ stateUpdate = new Event3();
2796
+ constructor(params) {
2797
+ this.space = params.space;
2798
+ this._signer = params.signer;
2799
+ this._presence = params.presence;
2800
+ this.did = params.did;
2801
+ this.identityKey = params.identityKey;
2802
+ this.deviceKey = params.deviceKey;
2803
+ log8.trace("dxos.halo.device", {
2804
+ deviceKey: params.deviceKey
2805
+ }, {
2806
+ F: __dxlog_file10,
2807
+ L: 83,
2808
+ S: this,
2809
+ C: (f, a) => f(...a)
2810
+ });
2811
+ this._deviceStateMachine = new DeviceStateMachine({
2812
+ identityKey: this.identityKey,
2813
+ deviceKey: this.deviceKey,
2814
+ onUpdate: () => this.stateUpdate.emit()
2815
+ });
2816
+ this._profileStateMachine = new ProfileStateMachine({
2817
+ identityKey: this.identityKey,
2818
+ onUpdate: () => this.stateUpdate.emit()
2819
+ });
2820
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
2821
+ identityKey: this.identityKey,
2822
+ onUpdate: () => this.stateUpdate.emit()
2823
+ });
2824
+ this.authVerifier = new TrustedKeySetAuthVerifier({
2825
+ trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
2826
+ update: this.stateUpdate,
2827
+ authTimeout: AUTH_TIMEOUT
2828
+ });
2829
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
2830
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
2831
+ messenger: params.edgeConnection,
2832
+ spaceId: this.space.id
2833
+ });
2834
+ }
2835
+ }
2836
+ // TODO(burdon): Expose state object?
2837
+ get authorizedDeviceKeys() {
2838
+ return this._deviceStateMachine.authorizedDeviceKeys;
2839
+ }
2840
+ get defaultSpaceId() {
2841
+ return this._defaultSpaceStateMachine.spaceId;
2842
+ }
2843
+ async open(ctx) {
2844
+ await this._presence?.open();
2845
+ await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
2846
+ await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
2847
+ await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
2848
+ if (this._edgeFeedReplicator) {
2849
+ this.space.protocol.feedAdded.append(this._onFeedAdded);
2850
+ }
2851
+ await this.space.open(ctx);
2852
+ }
2853
+ async joinNetwork() {
2854
+ await this.space.startProtocol();
2855
+ await this._edgeFeedReplicator?.open();
2856
+ }
2857
+ async close(ctx) {
2858
+ await this._presence?.close();
2859
+ await this.authVerifier.close();
2860
+ await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
2861
+ await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
2862
+ await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
2863
+ if (this._edgeFeedReplicator) {
2864
+ this.space.protocol.feedAdded.remove(this._onFeedAdded);
2865
+ }
2866
+ await this._edgeFeedReplicator?.close();
2867
+ await this.space.close();
2868
+ }
2869
+ async ready() {
2870
+ await this._deviceStateMachine.deviceChainReady.wait();
2871
+ await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
2861
2872
  timeout: LOAD_CONTROL_FEEDS_TIMEOUT
2862
2873
  });
2863
2874
  }
@@ -2981,61 +2992,9 @@ var Identity = class {
2981
2992
  })));
2982
2993
  return deviceCredential;
2983
2994
  }
2984
- constructor(params) {
2985
- _define_property9(this, "space", void 0);
2986
- _define_property9(this, "_signer", void 0);
2987
- _define_property9(this, "_presence", void 0);
2988
- _define_property9(this, "_deviceStateMachine", void 0);
2989
- _define_property9(this, "_profileStateMachine", void 0);
2990
- _define_property9(this, "_defaultSpaceStateMachine", void 0);
2991
- _define_property9(this, "_edgeFeedReplicator", void 0);
2992
- _define_property9(this, "authVerifier", void 0);
2993
- _define_property9(this, "did", void 0);
2994
- _define_property9(this, "identityKey", void 0);
2995
- _define_property9(this, "deviceKey", void 0);
2996
- _define_property9(this, "stateUpdate", new Event3());
2997
- _define_property9(this, "_onFeedAdded", async (feed) => {
2998
- await this._edgeFeedReplicator.addFeed(feed);
2999
- });
3000
- this.space = params.space;
3001
- this._signer = params.signer;
3002
- this._presence = params.presence;
3003
- this.did = params.did;
3004
- this.identityKey = params.identityKey;
3005
- this.deviceKey = params.deviceKey;
3006
- log8.trace("dxos.halo.device", {
3007
- deviceKey: params.deviceKey
3008
- }, {
3009
- F: __dxlog_file10,
3010
- L: 83,
3011
- S: this,
3012
- C: (f, a) => f(...a)
3013
- });
3014
- this._deviceStateMachine = new DeviceStateMachine({
3015
- identityKey: this.identityKey,
3016
- deviceKey: this.deviceKey,
3017
- onUpdate: () => this.stateUpdate.emit()
3018
- });
3019
- this._profileStateMachine = new ProfileStateMachine({
3020
- identityKey: this.identityKey,
3021
- onUpdate: () => this.stateUpdate.emit()
3022
- });
3023
- this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
3024
- identityKey: this.identityKey,
3025
- onUpdate: () => this.stateUpdate.emit()
3026
- });
3027
- this.authVerifier = new TrustedKeySetAuthVerifier({
3028
- trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
3029
- update: this.stateUpdate,
3030
- authTimeout: AUTH_TIMEOUT
3031
- });
3032
- if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
3033
- this._edgeFeedReplicator = new EdgeFeedReplicator({
3034
- messenger: params.edgeConnection,
3035
- spaceId: this.space.id
3036
- });
3037
- }
3038
- }
2995
+ _onFeedAdded = async (feed) => {
2996
+ await this._edgeFeedReplicator.addFeed(feed);
2997
+ };
3039
2998
  };
3040
2999
  _ts_decorate3([
3041
3000
  trace3.span()
@@ -3062,19 +3021,6 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
3062
3021
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3063
3022
  import { trace as Trace2 } from "@dxos/tracing";
3064
3023
  import { deferFunction as deferFunction2, isNode } from "@dxos/util";
3065
- function _define_property10(obj, key, value) {
3066
- if (key in obj) {
3067
- Object.defineProperty(obj, key, {
3068
- value,
3069
- enumerable: true,
3070
- configurable: true,
3071
- writable: true
3072
- });
3073
- } else {
3074
- obj[key] = value;
3075
- }
3076
- return obj;
3077
- }
3078
3024
  function _ts_decorate4(decorators, target, key, desc) {
3079
3025
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3080
3026
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3085,6 +3031,27 @@ var __dxlog_file11 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/i
3085
3031
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3086
3032
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
3087
3033
  var IdentityManager = class {
3034
+ stateUpdate = new Event4();
3035
+ _metadataStore;
3036
+ _keyring;
3037
+ _feedStore;
3038
+ _spaceManager;
3039
+ _devicePresenceAnnounceInterval;
3040
+ _devicePresenceOfflineTimeout;
3041
+ _edgeConnection;
3042
+ _edgeFeatures;
3043
+ _identity;
3044
+ // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
3045
+ constructor(params) {
3046
+ this._metadataStore = params.metadataStore;
3047
+ this._keyring = params.keyring;
3048
+ this._feedStore = params.feedStore;
3049
+ this._spaceManager = params.spaceManager;
3050
+ this._edgeConnection = params.edgeConnection;
3051
+ this._edgeFeatures = params.edgeFeatures;
3052
+ this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3053
+ this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3054
+ }
3088
3055
  get identity() {
3089
3056
  return this._identity;
3090
3057
  }
@@ -3519,27 +3486,6 @@ var IdentityManager = class {
3519
3486
  }
3520
3487
  });
3521
3488
  }
3522
- // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
3523
- constructor(params) {
3524
- _define_property10(this, "stateUpdate", new Event4());
3525
- _define_property10(this, "_metadataStore", void 0);
3526
- _define_property10(this, "_keyring", void 0);
3527
- _define_property10(this, "_feedStore", void 0);
3528
- _define_property10(this, "_spaceManager", void 0);
3529
- _define_property10(this, "_devicePresenceAnnounceInterval", void 0);
3530
- _define_property10(this, "_devicePresenceOfflineTimeout", void 0);
3531
- _define_property10(this, "_edgeConnection", void 0);
3532
- _define_property10(this, "_edgeFeatures", void 0);
3533
- _define_property10(this, "_identity", void 0);
3534
- this._metadataStore = params.metadataStore;
3535
- this._keyring = params.keyring;
3536
- this._feedStore = params.feedStore;
3537
- this._spaceManager = params.spaceManager;
3538
- this._edgeConnection = params.edgeConnection;
3539
- this._edgeFeatures = params.edgeFeatures;
3540
- this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3541
- this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3542
- }
3543
3489
  };
3544
3490
  _ts_decorate4([
3545
3491
  Trace2.span({
@@ -3559,22 +3505,18 @@ import { invariant as invariant8 } from "@dxos/invariant";
3559
3505
  import { log as log10 } from "@dxos/log";
3560
3506
  import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3561
3507
  import { safeAwaitAll } from "@dxos/util";
3562
- function _define_property11(obj, key, value) {
3563
- if (key in obj) {
3564
- Object.defineProperty(obj, key, {
3565
- value,
3566
- enumerable: true,
3567
- configurable: true,
3568
- writable: true
3569
- });
3570
- } else {
3571
- obj[key] = value;
3572
- }
3573
- return obj;
3574
- }
3575
3508
  var __dxlog_file12 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3576
3509
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3577
3510
  var IdentityServiceImpl = class extends Resource4 {
3511
+ _identityManager;
3512
+ _recoveryManager;
3513
+ _keyring;
3514
+ _dataSpaceManagerProvider;
3515
+ _createIdentity;
3516
+ _onProfileUpdate;
3517
+ constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3518
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3519
+ }
3578
3520
  async _open() {
3579
3521
  const identity = this._identityManager.identity;
3580
3522
  if (identity && !identity.defaultSpaceId) {
@@ -3749,29 +3691,21 @@ var IdentityServiceImpl = class extends Resource4 {
3749
3691
  await this._createDefaultSpace(dataSpaceManager);
3750
3692
  }
3751
3693
  }
3752
- constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3753
- super(), _define_property11(this, "_identityManager", void 0), _define_property11(this, "_recoveryManager", void 0), _define_property11(this, "_keyring", void 0), _define_property11(this, "_dataSpaceManagerProvider", void 0), _define_property11(this, "_createIdentity", void 0), _define_property11(this, "_onProfileUpdate", void 0), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3754
- }
3755
3694
  };
3756
3695
 
3757
3696
  // src/packlets/spaces/automerge-space-state.ts
3758
3697
  import { Event as Event5 } from "@dxos/async";
3759
3698
  import { Resource as Resource5 } from "@dxos/context";
3760
3699
  import { checkCredentialType } from "@dxos/credentials";
3761
- function _define_property12(obj, key, value) {
3762
- if (key in obj) {
3763
- Object.defineProperty(obj, key, {
3764
- value,
3765
- enumerable: true,
3766
- configurable: true,
3767
- writable: true
3768
- });
3769
- } else {
3770
- obj[key] = value;
3771
- }
3772
- return obj;
3773
- }
3774
3700
  var AutomergeSpaceState = class extends Resource5 {
3701
+ _onNewRoot;
3702
+ rootUrl = void 0;
3703
+ lastEpoch = void 0;
3704
+ onNewEpoch = new Event5();
3705
+ _isProcessingRootDocs = false;
3706
+ constructor(_onNewRoot) {
3707
+ super(), this._onNewRoot = _onNewRoot;
3708
+ }
3775
3709
  async _open(ctx) {
3776
3710
  }
3777
3711
  async _close(ctx) {
@@ -3802,9 +3736,6 @@ var AutomergeSpaceState = class extends Resource5 {
3802
3736
  async ensureEpochInitialized() {
3803
3737
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3804
3738
  }
3805
- constructor(_onNewRoot) {
3806
- super(), _define_property12(this, "_onNewRoot", void 0), _define_property12(this, "rootUrl", void 0), _define_property12(this, "lastEpoch", void 0), _define_property12(this, "onNewEpoch", void 0), _define_property12(this, "_isProcessingRootDocs", void 0), this._onNewRoot = _onNewRoot, this.rootUrl = void 0, this.lastEpoch = void 0, this.onNewEpoch = new Event5(), this._isProcessingRootDocs = false;
3807
- }
3808
3739
  };
3809
3740
 
3810
3741
  // src/packlets/spaces/epoch-migrations.ts
@@ -3815,7 +3746,7 @@ var LOAD_DOC_TIMEOUT = 1e4;
3815
3746
  var runEpochMigration = async (ctx, context) => {
3816
3747
  switch (context.migration) {
3817
3748
  case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3818
- const document = context.echoHost.createDoc();
3749
+ const document = await context.echoHost.createDoc();
3819
3750
  await context.echoHost.flush();
3820
3751
  return {
3821
3752
  newRoot: document.url
@@ -3828,7 +3759,7 @@ var runEpochMigration = async (ctx, context) => {
3828
3759
  const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
3829
3760
  timeout: LOAD_DOC_TIMEOUT
3830
3761
  });
3831
- const newRoot = context.echoHost.createDoc(rootHandle.doc());
3762
+ const newRoot = await context.echoHost.createDoc(rootHandle.doc());
3832
3763
  await context.echoHost.flush();
3833
3764
  return {
3834
3765
  newRoot: newRoot.url
@@ -3871,19 +3802,6 @@ import { EdgeCallFailedError } from "@dxos/protocols";
3871
3802
  import { schema as schema2 } from "@dxos/protocols/proto";
3872
3803
  import { RpcExtension } from "@dxos/teleport";
3873
3804
  import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet2, entry } from "@dxos/util";
3874
- function _define_property13(obj, key, value) {
3875
- if (key in obj) {
3876
- Object.defineProperty(obj, key, {
3877
- value,
3878
- enumerable: true,
3879
- configurable: true,
3880
- writable: true
3881
- });
3882
- } else {
3883
- obj[key] = value;
3884
- }
3885
- return obj;
3886
- }
3887
3805
  function _ts_decorate5(decorators, target, key, desc) {
3888
3806
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3889
3807
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3899,6 +3817,24 @@ var MAX_EDGE_RETRIES = 2;
3899
3817
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3900
3818
  var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
3901
3819
  var NotarizationPlugin = class extends Resource6 {
3820
+ _extensionOpened = new Event6();
3821
+ _writer;
3822
+ _extensions = /* @__PURE__ */ new Set();
3823
+ _processedCredentials = new ComplexSet2(PublicKey7.hash);
3824
+ _processCredentialsTriggers = new ComplexMap4(PublicKey7.hash);
3825
+ _activeEdgePollingIntervalHandle = void 0;
3826
+ _activeEdgePollingInterval;
3827
+ _activeEdgePollingEnabled = false;
3828
+ _spaceId;
3829
+ _edgeClient;
3830
+ constructor(params) {
3831
+ super();
3832
+ this._spaceId = params.spaceId;
3833
+ this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
3834
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
3835
+ this._edgeClient = params.edgeClient;
3836
+ }
3837
+ }
3902
3838
  setActiveEdgePollingEnabled(enabled) {
3903
3839
  const client = this._edgeClient;
3904
3840
  invariant10(client, void 0, {
@@ -4258,20 +4194,12 @@ var NotarizationPlugin = class extends Resource6 {
4258
4194
  errors.throw(new TimeoutError(timeout, "Notarization timed out"));
4259
4195
  }, timeout);
4260
4196
  }
4261
- constructor(params) {
4262
- super(), _define_property13(this, "_extensionOpened", new Event6()), _define_property13(this, "_writer", void 0), _define_property13(this, "_extensions", /* @__PURE__ */ new Set()), _define_property13(this, "_processedCredentials", new ComplexSet2(PublicKey7.hash)), _define_property13(this, "_processCredentialsTriggers", new ComplexMap4(PublicKey7.hash)), _define_property13(this, "_activeEdgePollingIntervalHandle", void 0), _define_property13(this, "_activeEdgePollingInterval", void 0), _define_property13(this, "_activeEdgePollingEnabled", false), _define_property13(this, "_spaceId", void 0), _define_property13(this, "_edgeClient", void 0);
4263
- this._spaceId = params.spaceId;
4264
- this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
4265
- if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
4266
- this._edgeClient = params.edgeClient;
4267
- }
4268
- }
4269
4197
  };
4270
4198
  _ts_decorate5([
4271
4199
  logInfo2
4272
4200
  ], NotarizationPlugin.prototype, "_spaceId", void 0);
4273
4201
  var handleEdgeError = (error) => {
4274
- if (!(error instanceof EdgeCallFailedError) || error.errorData) {
4202
+ if (!(error instanceof EdgeCallFailedError) || error.data) {
4275
4203
  log11.catch(error, void 0, {
4276
4204
  F: __dxlog_file14,
4277
4205
  L: 396,
@@ -4280,7 +4208,7 @@ var handleEdgeError = (error) => {
4280
4208
  });
4281
4209
  } else {
4282
4210
  log11.info("Edge notarization failure", {
4283
- reason: error.reason
4211
+ message: error.message
4284
4212
  }, {
4285
4213
  F: __dxlog_file14,
4286
4214
  L: 398,
@@ -4290,6 +4218,17 @@ var handleEdgeError = (error) => {
4290
4218
  }
4291
4219
  };
4292
4220
  var NotarizationTeleportExtension = class extends RpcExtension {
4221
+ _params;
4222
+ constructor(_params) {
4223
+ super({
4224
+ requested: {
4225
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4226
+ },
4227
+ exposed: {
4228
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4229
+ }
4230
+ }), this._params = _params;
4231
+ }
4293
4232
  async getHandlers() {
4294
4233
  return {
4295
4234
  NotarizationService: {
@@ -4307,32 +4246,9 @@ var NotarizationTeleportExtension = class extends RpcExtension {
4307
4246
  await this._params.onClose();
4308
4247
  await super.onClose(err);
4309
4248
  }
4310
- constructor(_params) {
4311
- super({
4312
- requested: {
4313
- NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4314
- },
4315
- exposed: {
4316
- NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4317
- }
4318
- }), _define_property13(this, "_params", void 0), this._params = _params;
4319
- }
4320
4249
  };
4321
4250
 
4322
4251
  // src/packlets/spaces/data-space.ts
4323
- function _define_property14(obj, key, value) {
4324
- if (key in obj) {
4325
- Object.defineProperty(obj, key, {
4326
- value,
4327
- enumerable: true,
4328
- configurable: true,
4329
- writable: true
4330
- });
4331
- } else {
4332
- obj[key] = value;
4333
- }
4334
- return obj;
4335
- }
4336
4252
  function _ts_decorate6(decorators, target, key, desc) {
4337
4253
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4338
4254
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4406,6 +4322,75 @@ function _ts_dispose_resources3(env) {
4406
4322
  }
4407
4323
  var __dxlog_file15 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4408
4324
  var DataSpace = class {
4325
+ _ctx = new Context6(void 0, {
4326
+ F: __dxlog_file15,
4327
+ L: 100
4328
+ });
4329
+ _inner;
4330
+ _gossip;
4331
+ _presence;
4332
+ _keyring;
4333
+ _feedStore;
4334
+ _metadataStore;
4335
+ _signingContext;
4336
+ _notarizationPlugin;
4337
+ _callbacks;
4338
+ _cache = void 0;
4339
+ _echoHost;
4340
+ _edgeFeedReplicator = void 0;
4341
+ // TODO(dmaretskyi): Move into Space?
4342
+ _automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4343
+ _epochProcessingMutex = new Mutex2();
4344
+ _state = SpaceState4.SPACE_CLOSED;
4345
+ _databaseRoot = null;
4346
+ /**
4347
+ * Error for _state === SpaceState.SPACE_ERROR.
4348
+ */
4349
+ error = void 0;
4350
+ authVerifier;
4351
+ stateUpdate = new Event7();
4352
+ postOpen = new CallbackCollection();
4353
+ preClose = new CallbackCollection();
4354
+ metrics = {};
4355
+ constructor(params) {
4356
+ this._inner = params.inner;
4357
+ this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4358
+ this._gossip = params.gossip;
4359
+ this._presence = params.presence;
4360
+ this._keyring = params.keyring;
4361
+ this._feedStore = params.feedStore;
4362
+ this._metadataStore = params.metadataStore;
4363
+ this._signingContext = params.signingContext;
4364
+ this._callbacks = params.callbacks ?? {};
4365
+ this._echoHost = params.echoHost;
4366
+ this._notarizationPlugin = new NotarizationPlugin({
4367
+ spaceId: this._inner.id,
4368
+ edgeClient: params.edgeHttpClient,
4369
+ edgeFeatures: params.edgeFeatures,
4370
+ activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4371
+ });
4372
+ this.authVerifier = new TrustedKeySetAuthVerifier({
4373
+ trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4374
+ update: this._inner.stateUpdate,
4375
+ authTimeout: AUTH_TIMEOUT2
4376
+ });
4377
+ this._cache = params.cache;
4378
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4379
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
4380
+ messenger: params.edgeConnection,
4381
+ spaceId: this.id
4382
+ });
4383
+ }
4384
+ this._state = params.initialState;
4385
+ log12("new state", {
4386
+ state: SpaceState4[this._state]
4387
+ }, {
4388
+ F: __dxlog_file15,
4389
+ L: 176,
4390
+ S: this,
4391
+ C: (f, a) => f(...a)
4392
+ });
4393
+ }
4409
4394
  get id() {
4410
4395
  return this._inner.id;
4411
4396
  }
@@ -4460,7 +4445,7 @@ var DataSpace = class {
4460
4445
  }
4461
4446
  await this._inner.open(new Context6(void 0, {
4462
4447
  F: __dxlog_file15,
4463
- L: 251
4448
+ L: 250
4464
4449
  }));
4465
4450
  await this._inner.startProtocol();
4466
4451
  await this._edgeFeedReplicator?.open();
@@ -4469,7 +4454,7 @@ var DataSpace = class {
4469
4454
  state: SpaceState4[this._state]
4470
4455
  }, {
4471
4456
  F: __dxlog_file15,
4472
- L: 257,
4457
+ L: 256,
4473
4458
  S: this,
4474
4459
  C: (f, a) => f(...a)
4475
4460
  });
@@ -4489,14 +4474,14 @@ var DataSpace = class {
4489
4474
  state: SpaceState4[this._state]
4490
4475
  }, {
4491
4476
  F: __dxlog_file15,
4492
- L: 276,
4477
+ L: 275,
4493
4478
  S: this,
4494
4479
  C: (f, a) => f(...a)
4495
4480
  });
4496
4481
  await this._ctx.dispose();
4497
4482
  this._ctx = new Context6(void 0, {
4498
4483
  F: __dxlog_file15,
4499
- L: 278
4484
+ L: 277
4500
4485
  });
4501
4486
  if (this._edgeFeedReplicator) {
4502
4487
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4529,7 +4514,7 @@ var DataSpace = class {
4529
4514
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
4530
4515
  log12("data pipeline initialization cancelled", err, {
4531
4516
  F: __dxlog_file15,
4532
- L: 316,
4517
+ L: 315,
4533
4518
  S: this,
4534
4519
  C: (f, a) => f(...a)
4535
4520
  });
@@ -4537,7 +4522,7 @@ var DataSpace = class {
4537
4522
  }
4538
4523
  log12.error("Error initializing data pipeline", err, {
4539
4524
  F: __dxlog_file15,
4540
- L: 320,
4525
+ L: 319,
4541
4526
  S: this,
4542
4527
  C: (f, a) => f(...a)
4543
4528
  });
@@ -4546,7 +4531,7 @@ var DataSpace = class {
4546
4531
  state: SpaceState4[this._state]
4547
4532
  }, {
4548
4533
  F: __dxlog_file15,
4549
- L: 322,
4534
+ L: 321,
4550
4535
  S: this,
4551
4536
  C: (f, a) => f(...a)
4552
4537
  });
@@ -4559,20 +4544,22 @@ var DataSpace = class {
4559
4544
  }
4560
4545
  async initializeDataPipeline() {
4561
4546
  if (this._state !== SpaceState4.SPACE_CONTROL_ONLY) {
4562
- throw new SystemError("Invalid operation");
4547
+ throw new SystemError({
4548
+ message: "Invalid operation"
4549
+ });
4563
4550
  }
4564
4551
  this._state = SpaceState4.SPACE_INITIALIZING;
4565
4552
  log12("new state", {
4566
4553
  state: SpaceState4[this._state]
4567
4554
  }, {
4568
4555
  F: __dxlog_file15,
4569
- L: 338,
4556
+ L: 337,
4570
4557
  S: this,
4571
4558
  C: (f, a) => f(...a)
4572
4559
  });
4573
4560
  log12("initializing control pipeline", void 0, {
4574
4561
  F: __dxlog_file15,
4575
- L: 340,
4562
+ L: 339,
4576
4563
  S: this,
4577
4564
  C: (f, a) => f(...a)
4578
4565
  });
@@ -4581,21 +4568,21 @@ var DataSpace = class {
4581
4568
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4582
4569
  log12("initializing automerge root", void 0, {
4583
4570
  F: __dxlog_file15,
4584
- L: 348,
4571
+ L: 347,
4585
4572
  S: this,
4586
4573
  C: (f, a) => f(...a)
4587
4574
  });
4588
4575
  this._automergeSpaceState.startProcessingRootDocs();
4589
4576
  log12("waiting for space to be ready", void 0, {
4590
4577
  F: __dxlog_file15,
4591
- L: 352,
4578
+ L: 351,
4592
4579
  S: this,
4593
4580
  C: (f, a) => f(...a)
4594
4581
  });
4595
4582
  await ready;
4596
4583
  log12("space is ready", void 0, {
4597
4584
  F: __dxlog_file15,
4598
- L: 354,
4585
+ L: 353,
4599
4586
  S: this,
4600
4587
  C: (f, a) => f(...a)
4601
4588
  });
@@ -4603,7 +4590,7 @@ var DataSpace = class {
4603
4590
  async *getAllDocuments() {
4604
4591
  invariant11(this._databaseRoot, "Space is not ready", {
4605
4592
  F: __dxlog_file15,
4606
- L: 358,
4593
+ L: 357,
4607
4594
  S: this,
4608
4595
  A: [
4609
4596
  "this._databaseRoot",
@@ -4619,7 +4606,7 @@ var DataSpace = class {
4619
4606
  for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
4620
4607
  const data = await this._echoHost.exportDoc(Context6.default(void 0, {
4621
4608
  F: __dxlog_file15,
4622
- L: 364
4609
+ L: 363
4623
4610
  }), documentUrl);
4624
4611
  yield [
4625
4612
  documentUrl.replace(/^automerge:/, ""),
@@ -4634,7 +4621,7 @@ var DataSpace = class {
4634
4621
  state: SpaceState4[this._state]
4635
4622
  }, {
4636
4623
  F: __dxlog_file15,
4637
- L: 373,
4624
+ L: 372,
4638
4625
  S: this,
4639
4626
  C: (f, a) => f(...a)
4640
4627
  });
@@ -4651,7 +4638,7 @@ var DataSpace = class {
4651
4638
  await this._createWritableFeeds();
4652
4639
  log12("writable feeds created", void 0, {
4653
4640
  F: __dxlog_file15,
4654
- L: 390,
4641
+ L: 389,
4655
4642
  S: this,
4656
4643
  C: (f, a) => f(...a)
4657
4644
  });
@@ -4705,7 +4692,7 @@ var DataSpace = class {
4705
4692
  count: credentials.length
4706
4693
  }, {
4707
4694
  F: __dxlog_file15,
4708
- L: 448,
4695
+ L: 447,
4709
4696
  S: this,
4710
4697
  C: (f, a) => f(...a)
4711
4698
  });
@@ -4716,14 +4703,14 @@ var DataSpace = class {
4716
4703
  });
4717
4704
  log12("credentials notarized", void 0, {
4718
4705
  F: __dxlog_file15,
4719
- L: 452,
4706
+ L: 451,
4720
4707
  S: this,
4721
4708
  C: (f, a) => f(...a)
4722
4709
  });
4723
4710
  } catch (err) {
4724
4711
  log12.error("error notarizing credentials for feed admission", err, {
4725
4712
  F: __dxlog_file15,
4726
- L: 454,
4713
+ L: 453,
4727
4714
  S: this,
4728
4715
  C: (f, a) => f(...a)
4729
4716
  });
@@ -4738,7 +4725,7 @@ var DataSpace = class {
4738
4725
  rootUrl
4739
4726
  }, {
4740
4727
  F: __dxlog_file15,
4741
- L: 464,
4728
+ L: 463,
4742
4729
  S: this,
4743
4730
  C: (f, a) => f(...a)
4744
4731
  });
@@ -4752,7 +4739,12 @@ var DataSpace = class {
4752
4739
  };
4753
4740
  try {
4754
4741
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4755
- handle = await cancelWithContext2(this._ctx, this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS2));
4742
+ handle = await cancelWithContext2(this._ctx, this._echoHost.loadDoc(Context6.default(void 0, {
4743
+ F: __dxlog_file15,
4744
+ L: 473
4745
+ }), rootUrl, {
4746
+ fetchFromNetwork: true
4747
+ }));
4756
4748
  await cancelWithContext2(this._ctx, handle.whenReady());
4757
4749
  });
4758
4750
  if (this._ctx.disposed) {
@@ -4793,7 +4785,7 @@ var DataSpace = class {
4793
4785
  err
4794
4786
  }, {
4795
4787
  F: __dxlog_file15,
4796
- L: 511,
4788
+ L: 512,
4797
4789
  S: this,
4798
4790
  C: (f, a) => f(...a)
4799
4791
  });
@@ -4883,7 +4875,7 @@ var DataSpace = class {
4883
4875
  state: SpaceState4[this._state]
4884
4876
  }, {
4885
4877
  F: __dxlog_file15,
4886
- L: 593,
4878
+ L: 594,
4887
4879
  S: this,
4888
4880
  C: (f, a) => f(...a)
4889
4881
  });
@@ -4892,74 +4884,9 @@ var DataSpace = class {
4892
4884
  getEdgeReplicationSetting() {
4893
4885
  return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4894
4886
  }
4895
- constructor(params) {
4896
- _define_property14(this, "_ctx", new Context6(void 0, {
4897
- F: __dxlog_file15,
4898
- L: 101
4899
- }));
4900
- _define_property14(this, "_inner", void 0);
4901
- _define_property14(this, "_gossip", void 0);
4902
- _define_property14(this, "_presence", void 0);
4903
- _define_property14(this, "_keyring", void 0);
4904
- _define_property14(this, "_feedStore", void 0);
4905
- _define_property14(this, "_metadataStore", void 0);
4906
- _define_property14(this, "_signingContext", void 0);
4907
- _define_property14(this, "_notarizationPlugin", void 0);
4908
- _define_property14(this, "_callbacks", void 0);
4909
- _define_property14(this, "_cache", void 0);
4910
- _define_property14(this, "_echoHost", void 0);
4911
- _define_property14(this, "_edgeFeedReplicator", void 0);
4912
- _define_property14(this, "_automergeSpaceState", new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl)));
4913
- _define_property14(this, "_epochProcessingMutex", new Mutex2());
4914
- _define_property14(this, "_state", SpaceState4.SPACE_CLOSED);
4915
- _define_property14(this, "_databaseRoot", null);
4916
- _define_property14(this, "error", void 0);
4917
- _define_property14(this, "authVerifier", void 0);
4918
- _define_property14(this, "stateUpdate", new Event7());
4919
- _define_property14(this, "postOpen", new CallbackCollection());
4920
- _define_property14(this, "preClose", new CallbackCollection());
4921
- _define_property14(this, "metrics", {});
4922
- _define_property14(this, "_onFeedAdded", async (feed) => {
4923
- await this._edgeFeedReplicator.addFeed(feed);
4924
- });
4925
- this._inner = params.inner;
4926
- this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4927
- this._gossip = params.gossip;
4928
- this._presence = params.presence;
4929
- this._keyring = params.keyring;
4930
- this._feedStore = params.feedStore;
4931
- this._metadataStore = params.metadataStore;
4932
- this._signingContext = params.signingContext;
4933
- this._callbacks = params.callbacks ?? {};
4934
- this._echoHost = params.echoHost;
4935
- this._notarizationPlugin = new NotarizationPlugin({
4936
- spaceId: this._inner.id,
4937
- edgeClient: params.edgeHttpClient,
4938
- edgeFeatures: params.edgeFeatures,
4939
- activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4940
- });
4941
- this.authVerifier = new TrustedKeySetAuthVerifier({
4942
- trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4943
- update: this._inner.stateUpdate,
4944
- authTimeout: AUTH_TIMEOUT2
4945
- });
4946
- this._cache = params.cache;
4947
- if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4948
- this._edgeFeedReplicator = new EdgeFeedReplicator({
4949
- messenger: params.edgeConnection,
4950
- spaceId: this.id
4951
- });
4952
- }
4953
- this._state = params.initialState;
4954
- log12("new state", {
4955
- state: SpaceState4[this._state]
4956
- }, {
4957
- F: __dxlog_file15,
4958
- L: 177,
4959
- S: this,
4960
- C: (f, a) => f(...a)
4961
- });
4962
- }
4887
+ _onFeedAdded = async (feed) => {
4888
+ await this._edgeFeedReplicator.addFeed(feed);
4889
+ };
4963
4890
  };
4964
4891
  _ts_decorate6([
4965
4892
  trace5.info()
@@ -5015,21 +4942,16 @@ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credent
5015
4942
  import { invariant as invariant12 } from "@dxos/invariant";
5016
4943
  import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
5017
4944
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
5018
- function _define_property15(obj, key, value) {
5019
- if (key in obj) {
5020
- Object.defineProperty(obj, key, {
5021
- value,
5022
- enumerable: true,
5023
- configurable: true,
5024
- writable: true
5025
- });
5026
- } else {
5027
- obj[key] = value;
5028
- }
5029
- return obj;
5030
- }
5031
4945
  var __dxlog_file16 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
5032
4946
  var DeviceInvitationProtocol = class {
4947
+ _keyring;
4948
+ _getIdentity;
4949
+ _acceptIdentity;
4950
+ constructor(_keyring, _getIdentity, _acceptIdentity) {
4951
+ this._keyring = _keyring;
4952
+ this._getIdentity = _getIdentity;
4953
+ this._acceptIdentity = _acceptIdentity;
4954
+ }
5033
4955
  toJSON() {
5034
4956
  return {
5035
4957
  kind: "device"
@@ -5084,7 +5006,9 @@ var DeviceInvitationProtocol = class {
5084
5006
  try {
5085
5007
  const identity = this._getIdentity();
5086
5008
  if (identity) {
5087
- return new AlreadyJoinedError2("Currently only one identity per client is supported.");
5009
+ return new AlreadyJoinedError2({
5010
+ message: "Currently only one identity per client is supported."
5011
+ });
5088
5012
  }
5089
5013
  } catch {
5090
5014
  }
@@ -5141,14 +5065,6 @@ var DeviceInvitationProtocol = class {
5141
5065
  identityKey
5142
5066
  };
5143
5067
  }
5144
- constructor(_keyring, _getIdentity, _acceptIdentity) {
5145
- _define_property15(this, "_keyring", void 0);
5146
- _define_property15(this, "_getIdentity", void 0);
5147
- _define_property15(this, "_acceptIdentity", void 0);
5148
- this._keyring = _keyring;
5149
- this._getIdentity = _getIdentity;
5150
- this._acceptIdentity = _acceptIdentity;
5151
- }
5152
5068
  };
5153
5069
 
5154
5070
  // src/packlets/invitations/invitations-handler.ts
@@ -5203,24 +5119,22 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
5203
5119
  };
5204
5120
 
5205
5121
  // src/packlets/invitations/edge-invitation-handler.ts
5206
- function _define_property16(obj, key, value) {
5207
- if (key in obj) {
5208
- Object.defineProperty(obj, key, {
5209
- value,
5210
- enumerable: true,
5211
- configurable: true,
5212
- writable: true
5213
- });
5214
- } else {
5215
- obj[key] = value;
5216
- }
5217
- return obj;
5218
- }
5219
5122
  var __dxlog_file17 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
5220
5123
  var MAX_RETRIES_PER_INVITATION = 5;
5221
5124
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
5222
5125
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
5223
5126
  var EdgeInvitationHandler = class {
5127
+ _client;
5128
+ _callbacks;
5129
+ _flowLock;
5130
+ _retryInterval;
5131
+ _retryJitter;
5132
+ constructor(config, _client, _callbacks) {
5133
+ this._client = _client;
5134
+ this._callbacks = _callbacks;
5135
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5136
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5137
+ }
5224
5138
  handle(ctx, guardedState, protocol, deviceProfile) {
5225
5139
  if (!this._client) {
5226
5140
  log13("edge disabled", void 0, {
@@ -5363,17 +5277,6 @@ var EdgeInvitationHandler = class {
5363
5277
  _calculateNextRetryMs() {
5364
5278
  return this._retryInterval + Math.random() * this._retryJitter;
5365
5279
  }
5366
- constructor(config, _client, _callbacks) {
5367
- _define_property16(this, "_client", void 0);
5368
- _define_property16(this, "_callbacks", void 0);
5369
- _define_property16(this, "_flowLock", void 0);
5370
- _define_property16(this, "_retryInterval", void 0);
5371
- _define_property16(this, "_retryJitter", void 0);
5372
- this._client = _client;
5373
- this._callbacks = _callbacks;
5374
- this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5375
- this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5376
- }
5377
5280
  };
5378
5281
 
5379
5282
  // src/packlets/invitations/invitation-guest-extenstion.ts
@@ -5385,22 +5288,31 @@ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
5385
5288
  import { schema as schema4 } from "@dxos/protocols/proto";
5386
5289
  import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
5387
5290
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
5388
- function _define_property17(obj, key, value) {
5389
- if (key in obj) {
5390
- Object.defineProperty(obj, key, {
5391
- value,
5392
- enumerable: true,
5393
- configurable: true,
5394
- writable: true
5395
- });
5396
- } else {
5397
- obj[key] = value;
5398
- }
5399
- return obj;
5400
- }
5401
5291
  var __dxlog_file18 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
5402
5292
  var OPTIONS_TIMEOUT = 1e4;
5403
5293
  var InvitationGuestExtension = class extends RpcExtension2 {
5294
+ _invitationFlowMutex;
5295
+ _callbacks;
5296
+ _ctx = new Context7(void 0, {
5297
+ F: __dxlog_file18,
5298
+ L: 38
5299
+ });
5300
+ _remoteOptions;
5301
+ _remoteOptionsTrigger = new Trigger4();
5302
+ /**
5303
+ * Held to allow only one invitation flow at a time to be active.
5304
+ */
5305
+ _invitationFlowLock = null;
5306
+ constructor(_invitationFlowMutex, _callbacks) {
5307
+ super({
5308
+ requested: {
5309
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5310
+ },
5311
+ exposed: {
5312
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5313
+ }
5314
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5315
+ }
5404
5316
  hasFlowLock() {
5405
5317
  return this._invitationFlowLock != null;
5406
5318
  }
@@ -5467,10 +5379,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5467
5379
  C: (f, a) => f(...a)
5468
5380
  });
5469
5381
  if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
5470
- throw new InvalidInvitationExtensionRoleError(void 0, {
5471
- expected: InvitationOptions.Role.HOST,
5472
- remoteOptions: this._remoteOptions,
5473
- remotePeerId: context.remotePeerId
5382
+ throw new InvalidInvitationExtensionRoleError({
5383
+ context: {
5384
+ expected: InvitationOptions.Role.HOST,
5385
+ remoteOptions: this._remoteOptions,
5386
+ remotePeerId: context.remotePeerId
5387
+ }
5474
5388
  });
5475
5389
  }
5476
5390
  this._callbacks.onOpen(this._ctx, context);
@@ -5496,28 +5410,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5496
5410
  this._invitationFlowLock = null;
5497
5411
  log14.verbose("invitation flow lock released", void 0, {
5498
5412
  F: __dxlog_file18,
5499
- L: 131,
5413
+ L: 133,
5500
5414
  S: this,
5501
5415
  C: (f, a) => f(...a)
5502
5416
  });
5503
5417
  }
5504
5418
  }
5505
- constructor(_invitationFlowMutex, _callbacks) {
5506
- super({
5507
- requested: {
5508
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5509
- },
5510
- exposed: {
5511
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5512
- }
5513
- }), _define_property17(this, "_invitationFlowMutex", void 0), _define_property17(this, "_callbacks", void 0), _define_property17(this, "_ctx", void 0), _define_property17(this, "_remoteOptions", void 0), _define_property17(this, "_remoteOptionsTrigger", void 0), /**
5514
- * Held to allow only one invitation flow at a time to be active.
5515
- */
5516
- _define_property17(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5517
- F: __dxlog_file18,
5518
- L: 38
5519
- }), this._remoteOptionsTrigger = new Trigger4(), this._invitationFlowLock = null;
5520
- }
5521
5419
  };
5522
5420
 
5523
5421
  // src/packlets/invitations/invitation-host-extension.ts
@@ -5532,23 +5430,46 @@ import { schema as schema5 } from "@dxos/protocols/proto";
5532
5430
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
5533
5431
  import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
5534
5432
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
5535
- function _define_property18(obj, key, value) {
5536
- if (key in obj) {
5537
- Object.defineProperty(obj, key, {
5538
- value,
5539
- enumerable: true,
5540
- configurable: true,
5541
- writable: true
5542
- });
5543
- } else {
5544
- obj[key] = value;
5545
- }
5546
- return obj;
5547
- }
5548
5433
  var __dxlog_file19 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5549
5434
  var OPTIONS_TIMEOUT2 = 1e4;
5550
5435
  var MAX_OTP_ATTEMPTS = 3;
5551
5436
  var InvitationHostExtension = class extends RpcExtension3 {
5437
+ _invitationFlowMutex;
5438
+ _callbacks;
5439
+ /**
5440
+ * @internal
5441
+ */
5442
+ _ctx = new Context8(void 0, {
5443
+ F: __dxlog_file19,
5444
+ L: 57
5445
+ });
5446
+ _remoteOptions;
5447
+ _remoteOptionsTrigger = new Trigger5();
5448
+ _challenge = void 0;
5449
+ guestProfile = void 0;
5450
+ authenticationPassed = false;
5451
+ /**
5452
+ * Retry counter for SHARED_SECRET authentication method.
5453
+ */
5454
+ authenticationRetry = 0;
5455
+ /**
5456
+ * Resolved when admission is completed.
5457
+ */
5458
+ completedTrigger = new Trigger5();
5459
+ /**
5460
+ * Held to allow only one invitation flow at a time to be active.
5461
+ */
5462
+ _invitationFlowLock = null;
5463
+ constructor(_invitationFlowMutex, _callbacks) {
5464
+ super({
5465
+ requested: {
5466
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5467
+ },
5468
+ exposed: {
5469
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5470
+ }
5471
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5472
+ }
5552
5473
  hasFlowLock() {
5553
5474
  return this._invitationFlowLock != null;
5554
5475
  }
@@ -5795,10 +5716,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
5795
5716
  C: (f, a) => f(...a)
5796
5717
  });
5797
5718
  if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
5798
- throw new InvalidInvitationExtensionRoleError2(void 0, {
5799
- expected: InvitationOptions2.Role.GUEST,
5800
- remoteOptions: this._remoteOptions,
5801
- remotePeerId: context.remotePeerId
5719
+ throw new InvalidInvitationExtensionRoleError2({
5720
+ context: {
5721
+ expected: InvitationOptions2.Role.GUEST,
5722
+ remoteOptions: this._remoteOptions,
5723
+ remotePeerId: context.remotePeerId
5724
+ }
5802
5725
  });
5803
5726
  }
5804
5727
  this._callbacks.onStateUpdate(Invitation5.State.CONNECTED);
@@ -5843,37 +5766,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
5843
5766
  this._invitationFlowLock = null;
5844
5767
  log15.verbose("invitation flow lock released", void 0, {
5845
5768
  F: __dxlog_file19,
5846
- L: 299,
5769
+ L: 301,
5847
5770
  S: this,
5848
5771
  C: (f, a) => f(...a)
5849
5772
  });
5850
5773
  }
5851
5774
  }
5852
- constructor(_invitationFlowMutex, _callbacks) {
5853
- super({
5854
- requested: {
5855
- InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5856
- },
5857
- exposed: {
5858
- InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5859
- }
5860
- }), _define_property18(this, "_invitationFlowMutex", void 0), _define_property18(this, "_callbacks", void 0), /**
5861
- * @internal
5862
- */
5863
- _define_property18(this, "_ctx", void 0), _define_property18(this, "_remoteOptions", void 0), _define_property18(this, "_remoteOptionsTrigger", void 0), _define_property18(this, "_challenge", void 0), _define_property18(this, "guestProfile", void 0), _define_property18(this, "authenticationPassed", void 0), /**
5864
- * Retry counter for SHARED_SECRET authentication method.
5865
- */
5866
- _define_property18(this, "authenticationRetry", void 0), /**
5867
- * Resolved when admission is completed.
5868
- */
5869
- _define_property18(this, "completedTrigger", void 0), /**
5870
- * Held to allow only one invitation flow at a time to be active.
5871
- */
5872
- _define_property18(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5873
- F: __dxlog_file19,
5874
- L: 57
5875
- }), this._remoteOptionsTrigger = new Trigger5(), this._challenge = void 0, this.guestProfile = void 0, this.authenticationPassed = false, this.authenticationRetry = 0, this.completedTrigger = new Trigger5(), this._invitationFlowLock = null;
5876
- }
5877
5775
  };
5878
5776
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
5879
5777
 
@@ -5979,21 +5877,22 @@ import { PublicKey as PublicKey10 } from "@dxos/keys";
5979
5877
  import { log as log17 } from "@dxos/log";
5980
5878
  import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
5981
5879
  import { ComplexSet as ComplexSet4 } from "@dxos/util";
5982
- function _define_property19(obj, key, value) {
5983
- if (key in obj) {
5984
- Object.defineProperty(obj, key, {
5985
- value,
5986
- enumerable: true,
5987
- configurable: true,
5988
- writable: true
5989
- });
5990
- } else {
5991
- obj[key] = value;
5992
- }
5993
- return obj;
5994
- }
5995
5880
  var __dxlog_file21 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5996
5881
  var InvitationTopology = class {
5882
+ _role;
5883
+ _controller;
5884
+ /**
5885
+ * Peers we tried to establish a connection with.
5886
+ * In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
5887
+ * a peer if they reload an invitation.
5888
+ *
5889
+ * Consider keeping a separate set for peers we know are hosts and have some retry timeout
5890
+ * for guests we failed an invitation flow with (potentially due to a network error).
5891
+ */
5892
+ _seenPeers = new ComplexSet4(PublicKey10.hash);
5893
+ constructor(_role) {
5894
+ this._role = _role;
5895
+ }
5997
5896
  init(controller) {
5998
5897
  invariant16(!this._controller, "Already initialized.", {
5999
5898
  F: __dxlog_file21,
@@ -6058,33 +5957,24 @@ var InvitationTopology = class {
6058
5957
  toString() {
6059
5958
  return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
6060
5959
  }
6061
- constructor(_role) {
6062
- _define_property19(this, "_role", void 0);
6063
- _define_property19(this, "_controller", void 0);
6064
- _define_property19(this, "_seenPeers", void 0);
6065
- this._role = _role;
6066
- this._seenPeers = new ComplexSet4(PublicKey10.hash);
6067
- }
6068
5960
  };
6069
5961
 
6070
5962
  // src/packlets/invitations/invitations-handler.ts
6071
- function _define_property20(obj, key, value) {
6072
- if (key in obj) {
6073
- Object.defineProperty(obj, key, {
6074
- value,
6075
- enumerable: true,
6076
- configurable: true,
6077
- writable: true
6078
- });
6079
- } else {
6080
- obj[key] = value;
6081
- }
6082
- return obj;
6083
- }
6084
5963
  var __dxlog_file22 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
6085
5964
  var metrics = _trace.metrics;
6086
5965
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
6087
5966
  var InvitationsHandler = class {
5967
+ _networkManager;
5968
+ _edgeClient;
5969
+ _connectionProps;
5970
+ /**
5971
+ * @internal
5972
+ */
5973
+ constructor(_networkManager, _edgeClient, _connectionProps) {
5974
+ this._networkManager = _networkManager;
5975
+ this._edgeClient = _edgeClient;
5976
+ this._connectionProps = _connectionProps;
5977
+ }
6088
5978
  handleInvitationFlow(ctx, stream, protocol, invitation) {
6089
5979
  log18.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
6090
5980
  state: invitation.state,
@@ -6527,7 +6417,7 @@ var InvitationsHandler = class {
6527
6417
  });
6528
6418
  return extension;
6529
6419
  };
6530
- const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
6420
+ const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionProps?.edgeInvitations, this._edgeClient, {
6531
6421
  onInvitationSuccess: async (admissionResponse, admissionRequest) => {
6532
6422
  const result = await protocol.accept(admissionResponse, admissionRequest);
6533
6423
  log18.info("admitted by edge", {
@@ -6587,7 +6477,7 @@ var InvitationsHandler = class {
6587
6477
  topic: invitation.swarmKey,
6588
6478
  protocolProvider: createTeleportProtocolFactory(async (teleport) => {
6589
6479
  teleport.addExtension("dxos.halo.invitations", extensionFactory());
6590
- }, this._connectionParams?.teleport),
6480
+ }, this._connectionProps?.teleport),
6591
6481
  topology: new InvitationTopology(role),
6592
6482
  label
6593
6483
  });
@@ -6655,22 +6545,13 @@ var InvitationsHandler = class {
6655
6545
  throw new Error(`Authentication failed with code: ${response.status}`);
6656
6546
  }
6657
6547
  }
6658
- /**
6659
- * @internal
6660
- */
6661
- constructor(_networkManager, _edgeClient, _connectionParams) {
6662
- _define_property20(this, "_networkManager", void 0);
6663
- _define_property20(this, "_edgeClient", void 0);
6664
- _define_property20(this, "_connectionParams", void 0);
6665
- this._networkManager = _networkManager;
6666
- this._edgeClient = _edgeClient;
6667
- this._connectionParams = _connectionParams;
6668
- }
6669
6548
  };
6670
6549
  var checkInvitation = (protocol, invitation) => {
6671
6550
  const expiresOn = getExpirationTime(invitation);
6672
6551
  if (expiresOn && expiresOn.getTime() < Date.now()) {
6673
- return new InvalidInvitationError("Invitation already expired.");
6552
+ return new InvalidInvitationError({
6553
+ message: "Invitation already expired."
6554
+ });
6674
6555
  }
6675
6556
  return protocol.checkInvitation(invitation);
6676
6557
  };
@@ -6686,20 +6567,11 @@ var createAdmissionKeypair = () => {
6686
6567
  import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6687
6568
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6688
6569
  import { trace as trace8 } from "@dxos/tracing";
6689
- function _define_property21(obj, key, value) {
6690
- if (key in obj) {
6691
- Object.defineProperty(obj, key, {
6692
- value,
6693
- enumerable: true,
6694
- configurable: true,
6695
- writable: true
6696
- });
6697
- } else {
6698
- obj[key] = value;
6699
- }
6700
- return obj;
6701
- }
6702
6570
  var InvitationsServiceImpl = class {
6571
+ _invitationsManager;
6572
+ constructor(_invitationsManager) {
6573
+ this._invitationsManager = _invitationsManager;
6574
+ }
6703
6575
  // TODO(burdon): Guest/host label.
6704
6576
  getLoggingContext() {
6705
6577
  return {};
@@ -6791,10 +6663,6 @@ var InvitationsServiceImpl = class {
6791
6663
  });
6792
6664
  });
6793
6665
  }
6794
- constructor(_invitationsManager) {
6795
- _define_property21(this, "_invitationsManager", void 0);
6796
- this._invitationsManager = _invitationsManager;
6797
- }
6798
6666
  };
6799
6667
 
6800
6668
  // src/packlets/invitations/space-invitation-protocol.ts
@@ -6805,21 +6673,18 @@ import { log as log19 } from "@dxos/log";
6805
6673
  import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6806
6674
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6807
6675
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
6808
- function _define_property22(obj, key, value) {
6809
- if (key in obj) {
6810
- Object.defineProperty(obj, key, {
6811
- value,
6812
- enumerable: true,
6813
- configurable: true,
6814
- writable: true
6815
- });
6816
- } else {
6817
- obj[key] = value;
6818
- }
6819
- return obj;
6820
- }
6821
6676
  var __dxlog_file23 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6822
6677
  var SpaceInvitationProtocol = class {
6678
+ _spaceManager;
6679
+ _signingContext;
6680
+ _keyring;
6681
+ _spaceKey;
6682
+ constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
6683
+ this._spaceManager = _spaceManager;
6684
+ this._signingContext = _signingContext;
6685
+ this._keyring = _keyring;
6686
+ this._spaceKey = _spaceKey;
6687
+ }
6823
6688
  toJSON() {
6824
6689
  return {
6825
6690
  kind: "space",
@@ -6829,21 +6694,25 @@ var SpaceInvitationProtocol = class {
6829
6694
  }
6830
6695
  checkCanInviteNewMembers() {
6831
6696
  if (this._spaceKey == null) {
6832
- return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6697
+ return new InvalidInvitationError2({
6698
+ message: "No spaceKey was provided for a space invitation."
6699
+ });
6833
6700
  }
6834
6701
  const space = this._spaceManager.spaces.get(this._spaceKey);
6835
6702
  if (space == null) {
6836
6703
  return new SpaceNotFoundError2(this._spaceKey);
6837
6704
  }
6838
6705
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
6839
- return new AuthorizationError2("No member management permission.");
6706
+ return new AuthorizationError2({
6707
+ message: "No member management permission."
6708
+ });
6840
6709
  }
6841
6710
  return void 0;
6842
6711
  }
6843
6712
  getInvitationContext() {
6844
6713
  invariant18(this._spaceKey, void 0, {
6845
6714
  F: __dxlog_file23,
6846
- L: 66,
6715
+ L: 60,
6847
6716
  S: this,
6848
6717
  A: [
6849
6718
  "this._spaceKey",
@@ -6853,7 +6722,7 @@ var SpaceInvitationProtocol = class {
6853
6722
  const space = this._spaceManager.spaces.get(this._spaceKey);
6854
6723
  invariant18(space, void 0, {
6855
6724
  F: __dxlog_file23,
6856
- L: 68,
6725
+ L: 62,
6857
6726
  S: this,
6858
6727
  A: [
6859
6728
  "space",
@@ -6869,7 +6738,7 @@ var SpaceInvitationProtocol = class {
6869
6738
  async admit(invitation, request, guestProfile) {
6870
6739
  invariant18(this._spaceKey && request.space, void 0, {
6871
6740
  F: __dxlog_file23,
6872
- L: 81,
6741
+ L: 75,
6873
6742
  S: this,
6874
6743
  A: [
6875
6744
  "this._spaceKey && request.space",
@@ -6881,7 +6750,7 @@ var SpaceInvitationProtocol = class {
6881
6750
  guest: request.space.deviceKey
6882
6751
  }, {
6883
6752
  F: __dxlog_file23,
6884
- L: 82,
6753
+ L: 76,
6885
6754
  S: this,
6886
6755
  C: (f, a) => f(...a)
6887
6756
  });
@@ -6903,7 +6772,7 @@ var SpaceInvitationProtocol = class {
6903
6772
  async delegate(invitation) {
6904
6773
  invariant18(this._spaceKey, void 0, {
6905
6774
  F: __dxlog_file23,
6906
- L: 102,
6775
+ L: 96,
6907
6776
  S: this,
6908
6777
  A: [
6909
6778
  "this._spaceKey",
@@ -6913,7 +6782,7 @@ var SpaceInvitationProtocol = class {
6913
6782
  const space = this._spaceManager.spaces.get(this._spaceKey);
6914
6783
  invariant18(space, void 0, {
6915
6784
  F: __dxlog_file23,
6916
- L: 104,
6785
+ L: 98,
6917
6786
  S: this,
6918
6787
  A: [
6919
6788
  "space",
@@ -6923,7 +6792,7 @@ var SpaceInvitationProtocol = class {
6923
6792
  if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6924
6793
  invariant18(invitation.guestKeypair?.publicKey, void 0, {
6925
6794
  F: __dxlog_file23,
6926
- L: 106,
6795
+ L: 100,
6927
6796
  S: this,
6928
6797
  A: [
6929
6798
  "invitation.guestKeypair?.publicKey",
@@ -6936,7 +6805,7 @@ var SpaceInvitationProtocol = class {
6936
6805
  id: invitation.invitationId
6937
6806
  }, {
6938
6807
  F: __dxlog_file23,
6939
- L: 109,
6808
+ L: 103,
6940
6809
  S: this,
6941
6810
  C: (f, a) => f(...a)
6942
6811
  });
@@ -6951,7 +6820,7 @@ var SpaceInvitationProtocol = class {
6951
6820
  });
6952
6821
  invariant18(credential.credential, void 0, {
6953
6822
  F: __dxlog_file23,
6954
- L: 127,
6823
+ L: 121,
6955
6824
  S: this,
6956
6825
  A: [
6957
6826
  "credential.credential",
@@ -6966,7 +6835,7 @@ var SpaceInvitationProtocol = class {
6966
6835
  async cancelDelegation(invitation) {
6967
6836
  invariant18(this._spaceKey, void 0, {
6968
6837
  F: __dxlog_file23,
6969
- L: 133,
6838
+ L: 127,
6970
6839
  S: this,
6971
6840
  A: [
6972
6841
  "this._spaceKey",
@@ -6975,7 +6844,7 @@ var SpaceInvitationProtocol = class {
6975
6844
  });
6976
6845
  invariant18(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6977
6846
  F: __dxlog_file23,
6978
- L: 134,
6847
+ L: 128,
6979
6848
  S: this,
6980
6849
  A: [
6981
6850
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6985,7 +6854,7 @@ var SpaceInvitationProtocol = class {
6985
6854
  const space = this._spaceManager.spaces.get(this._spaceKey);
6986
6855
  invariant18(space, void 0, {
6987
6856
  F: __dxlog_file23,
6988
- L: 136,
6857
+ L: 130,
6989
6858
  S: this,
6990
6859
  A: [
6991
6860
  "space",
@@ -6997,14 +6866,14 @@ var SpaceInvitationProtocol = class {
6997
6866
  id: invitation.invitationId
6998
6867
  }, {
6999
6868
  F: __dxlog_file23,
7000
- L: 138,
6869
+ L: 132,
7001
6870
  S: this,
7002
6871
  C: (f, a) => f(...a)
7003
6872
  });
7004
6873
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
7005
6874
  invariant18(credential.credential, void 0, {
7006
6875
  F: __dxlog_file23,
7007
- L: 145,
6876
+ L: 139,
7008
6877
  S: this,
7009
6878
  A: [
7010
6879
  "credential.credential",
@@ -7017,10 +6886,14 @@ var SpaceInvitationProtocol = class {
7017
6886
  }
7018
6887
  checkInvitation(invitation) {
7019
6888
  if (invitation.spaceKey == null) {
7020
- return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6889
+ return new InvalidInvitationError2({
6890
+ message: "No spaceKey was provided for a space invitation."
6891
+ });
7021
6892
  }
7022
6893
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
7023
- return new AlreadyJoinedError3("Already joined space.");
6894
+ return new AlreadyJoinedError3({
6895
+ message: "Already joined space."
6896
+ });
7024
6897
  }
7025
6898
  }
7026
6899
  createIntroduction() {
@@ -7043,7 +6916,7 @@ var SpaceInvitationProtocol = class {
7043
6916
  async accept(response) {
7044
6917
  invariant18(response.space, void 0, {
7045
6918
  F: __dxlog_file23,
7046
- L: 180,
6919
+ L: 174,
7047
6920
  S: this,
7048
6921
  A: [
7049
6922
  "response.space",
@@ -7054,7 +6927,7 @@ var SpaceInvitationProtocol = class {
7054
6927
  const assertion = getCredentialAssertion5(credential);
7055
6928
  invariant18(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
7056
6929
  F: __dxlog_file23,
7057
- L: 183,
6930
+ L: 177,
7058
6931
  S: this,
7059
6932
  A: [
7060
6933
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -7063,7 +6936,7 @@ var SpaceInvitationProtocol = class {
7063
6936
  });
7064
6937
  invariant18(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
7065
6938
  F: __dxlog_file23,
7066
- L: 184,
6939
+ L: 178,
7067
6940
  S: this,
7068
6941
  A: [
7069
6942
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -7071,7 +6944,9 @@ var SpaceInvitationProtocol = class {
7071
6944
  ]
7072
6945
  });
7073
6946
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
7074
- throw new AlreadyJoinedError3("Already joined space.");
6947
+ throw new AlreadyJoinedError3({
6948
+ message: "Already joined space."
6949
+ });
7075
6950
  }
7076
6951
  await this._spaceManager.acceptSpace({
7077
6952
  spaceKey: assertion.spaceKey,
@@ -7084,16 +6959,6 @@ var SpaceInvitationProtocol = class {
7084
6959
  spaceKey: assertion.spaceKey
7085
6960
  };
7086
6961
  }
7087
- constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
7088
- _define_property22(this, "_spaceManager", void 0);
7089
- _define_property22(this, "_signingContext", void 0);
7090
- _define_property22(this, "_keyring", void 0);
7091
- _define_property22(this, "_spaceKey", void 0);
7092
- this._spaceManager = _spaceManager;
7093
- this._signingContext = _signingContext;
7094
- this._keyring = _keyring;
7095
- this._spaceKey = _spaceKey;
7096
- }
7097
6962
  };
7098
6963
 
7099
6964
  // src/packlets/invitations/invitations-manager.ts
@@ -7107,21 +6972,25 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
7107
6972
  import { log as log20 } from "@dxos/log";
7108
6973
  import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
7109
6974
  import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/halo/credentials";
7110
- function _define_property23(obj, key, value) {
7111
- if (key in obj) {
7112
- Object.defineProperty(obj, key, {
7113
- value,
7114
- enumerable: true,
7115
- configurable: true,
7116
- writable: true
7117
- });
7118
- } else {
7119
- obj[key] = value;
7120
- }
7121
- return obj;
7122
- }
7123
6975
  var __dxlog_file24 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
7124
6976
  var InvitationsManager = class {
6977
+ _invitationsHandler;
6978
+ _getHandler;
6979
+ _metadataStore;
6980
+ _createInvitations = /* @__PURE__ */ new Map();
6981
+ _acceptInvitations = /* @__PURE__ */ new Map();
6982
+ invitationCreated = new Event8();
6983
+ invitationAccepted = new Event8();
6984
+ removedCreated = new Event8();
6985
+ removedAccepted = new Event8();
6986
+ saved = new Event8();
6987
+ _persistentInvitationsLoadedEvent = new Event8();
6988
+ _persistentInvitationsLoaded = false;
6989
+ constructor(_invitationsHandler, _getHandler, _metadataStore) {
6990
+ this._invitationsHandler = _invitationsHandler;
6991
+ this._getHandler = _getHandler;
6992
+ this._metadataStore = _metadataStore;
6993
+ }
7125
6994
  async createInvitation(options) {
7126
6995
  if (options.invitationId) {
7127
6996
  const existingInvitation = this._createInvitations.get(options.invitationId);
@@ -7465,233 +7334,45 @@ var InvitationsManager = class {
7465
7334
  }, () => {
7466
7335
  }, callback);
7467
7336
  }
7468
- constructor(_invitationsHandler, _getHandler, _metadataStore) {
7469
- _define_property23(this, "_invitationsHandler", void 0);
7470
- _define_property23(this, "_getHandler", void 0);
7471
- _define_property23(this, "_metadataStore", void 0);
7472
- _define_property23(this, "_createInvitations", void 0);
7473
- _define_property23(this, "_acceptInvitations", void 0);
7474
- _define_property23(this, "invitationCreated", void 0);
7475
- _define_property23(this, "invitationAccepted", void 0);
7476
- _define_property23(this, "removedCreated", void 0);
7477
- _define_property23(this, "removedAccepted", void 0);
7478
- _define_property23(this, "saved", void 0);
7479
- _define_property23(this, "_persistentInvitationsLoadedEvent", void 0);
7480
- _define_property23(this, "_persistentInvitationsLoaded", void 0);
7481
- this._invitationsHandler = _invitationsHandler;
7482
- this._getHandler = _getHandler;
7483
- this._metadataStore = _metadataStore;
7484
- this._createInvitations = /* @__PURE__ */ new Map();
7485
- this._acceptInvitations = /* @__PURE__ */ new Map();
7486
- this.invitationCreated = new Event8();
7487
- this.invitationAccepted = new Event8();
7488
- this.removedCreated = new Event8();
7489
- this.removedAccepted = new Event8();
7490
- this.saved = new Event8();
7491
- this._persistentInvitationsLoadedEvent = new Event8();
7492
- this._persistentInvitationsLoaded = false;
7493
- }
7494
7337
  };
7495
7338
 
7496
- // src/packlets/locks/node.ts
7339
+ // src/packlets/locks/index.ts
7340
+ var locks_exports = {};
7341
+ __reExport(locks_exports, locks_platform_star);
7342
+ import * as locks_platform_star from "#locks-platform";
7343
+
7344
+ // src/packlets/agents/edge-agent-manager.ts
7345
+ import { DeferredTask as DeferredTask2, Event as Event9, scheduleTask as scheduleTask8, synchronized as synchronized3 } from "@dxos/async";
7346
+ import { Resource as Resource7 } from "@dxos/context";
7497
7347
  import { invariant as invariant20 } from "@dxos/invariant";
7498
- import { LockFile } from "@dxos/lock-file";
7499
- import { log as log21, logInfo as logInfo3 } from "@dxos/log";
7500
- function _define_property24(obj, key, value) {
7501
- if (key in obj) {
7502
- Object.defineProperty(obj, key, {
7503
- value,
7504
- enumerable: true,
7505
- configurable: true,
7506
- writable: true
7507
- });
7508
- } else {
7509
- obj[key] = value;
7510
- }
7511
- return obj;
7512
- }
7348
+ import { PublicKey as PublicKey13 } from "@dxos/keys";
7349
+ import { log as log21 } from "@dxos/log";
7350
+ import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7351
+ import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7352
+ import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
7513
7353
  function _ts_decorate7(decorators, target, key, desc) {
7514
7354
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7515
7355
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7516
7356
  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;
7517
7357
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7518
7358
  }
7519
- var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
7520
- var Lock = class {
7521
- get lockKey() {
7522
- return this._lockPath;
7523
- }
7524
- async acquire() {
7525
- log21("acquiring lock...", void 0, {
7526
- F: __dxlog_file25,
7527
- L: 32,
7528
- S: this,
7529
- C: (f, a) => f(...a)
7530
- });
7531
- this._fileHandle = await LockFile.acquire(this._lockPath);
7532
- await this._onAcquire?.();
7533
- log21("acquired lock", void 0, {
7534
- F: __dxlog_file25,
7535
- L: 37,
7536
- S: this,
7537
- C: (f, a) => f(...a)
7538
- });
7539
- }
7540
- async release() {
7541
- await this._onRelease?.();
7542
- invariant20(this._fileHandle, "Lock is not acquired", {
7543
- F: __dxlog_file25,
7544
- L: 42,
7545
- S: this,
7546
- A: [
7547
- "this._fileHandle",
7548
- "'Lock is not acquired'"
7549
- ]
7550
- });
7551
- await LockFile.release(this._fileHandle);
7552
- }
7553
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
7554
- _define_property24(this, "_lockPath", void 0);
7555
- _define_property24(this, "_onAcquire", void 0);
7556
- _define_property24(this, "_onRelease", void 0);
7557
- _define_property24(this, "_fileHandle", void 0);
7558
- this._lockPath = lockPath;
7559
- this._onAcquire = onAcquire;
7560
- this._onRelease = onRelease;
7561
- }
7562
- };
7563
- _ts_decorate7([
7564
- logInfo3
7565
- ], Lock.prototype, "lockKey", null);
7566
- var isLocked = (lockPath) => LockFile.isLocked(lockPath);
7567
-
7568
- // src/packlets/services/client-rpc-server.ts
7569
- import { Stream as Stream10 } from "@dxos/codec-protobuf";
7570
- import { raise as raise2 } from "@dxos/debug";
7571
- import { RpcPeer, parseMethodName } from "@dxos/rpc";
7572
- import { MapCounter, trace as trace9 } from "@dxos/tracing";
7573
- function _define_property25(obj, key, value) {
7574
- if (key in obj) {
7575
- Object.defineProperty(obj, key, {
7576
- value,
7577
- enumerable: true,
7578
- configurable: true,
7579
- writable: true
7580
- });
7581
- } else {
7582
- obj[key] = value;
7583
- }
7584
- return obj;
7585
- }
7586
- function _ts_decorate8(decorators, target, key, desc) {
7587
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7588
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7589
- 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;
7590
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7591
- }
7592
- var ClientRpcServer = class {
7593
- get _services() {
7594
- return Object.keys(this._serviceRegistry.services);
7595
- }
7596
- async open() {
7597
- await this._rpcPeer.open();
7598
- }
7599
- async close() {
7600
- await this._rpcPeer.close();
7601
- }
7602
- _getServiceHandler(serviceName) {
7603
- if (!this._handlerCache.has(serviceName)) {
7604
- const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7605
- const service = this._serviceRegistry.services[key];
7606
- if (!service) {
7607
- throw new Error(`Service not available: ${serviceName}`);
7608
- }
7609
- this._handlerCache.set(serviceName, descriptor.createServer(service));
7610
- }
7611
- return this._handlerCache.get(serviceName);
7612
- }
7613
- constructor(params) {
7614
- _define_property25(this, "_serviceRegistry", void 0);
7615
- _define_property25(this, "_rpcPeer", void 0);
7616
- _define_property25(this, "_handlerCache", /* @__PURE__ */ new Map());
7617
- _define_property25(this, "_handleCall", void 0);
7618
- _define_property25(this, "_handleStream", void 0);
7619
- _define_property25(this, "_callMetrics", new MapCounter());
7620
- const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7621
- this._handleCall = handleCall;
7622
- this._handleStream = handleStream;
7623
- this._serviceRegistry = serviceRegistry;
7624
- this._rpcPeer = new RpcPeer({
7625
- ...rpcOptions,
7626
- callHandler: (method, params2) => {
7627
- const [serviceName, methodName] = parseMethodName(method);
7628
- const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
7629
- this._callMetrics.inc(`${serviceName}.${methodName} request`);
7630
- if (this._handleCall) {
7631
- return this._handleCall(methodName, params2, handler);
7632
- } else {
7633
- return handler(methodName, params2);
7634
- }
7635
- },
7636
- streamHandler: (method, params2) => {
7637
- const [serviceName, methodName] = parseMethodName(method);
7638
- const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
7639
- this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
7640
- if (this._handleStream) {
7641
- return Stream10.map(Stream10.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
7642
- this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
7643
- return data;
7644
- });
7645
- } else {
7646
- return handler(methodName, params2);
7647
- }
7648
- }
7649
- });
7650
- }
7651
- };
7652
- _ts_decorate8([
7653
- trace9.metricsCounter()
7654
- ], ClientRpcServer.prototype, "_callMetrics", void 0);
7655
- _ts_decorate8([
7656
- trace9.info()
7657
- ], ClientRpcServer.prototype, "_services", null);
7658
- ClientRpcServer = _ts_decorate8([
7659
- trace9.resource()
7660
- ], ClientRpcServer);
7661
-
7662
- // src/packlets/agents/edge-agent-manager.ts
7663
- import { DeferredTask as DeferredTask2, Event as Event9, scheduleTask as scheduleTask8, synchronized as synchronized3 } from "@dxos/async";
7664
- import { Resource as Resource7 } from "@dxos/context";
7665
- import { invariant as invariant21 } from "@dxos/invariant";
7666
- import { PublicKey as PublicKey13 } from "@dxos/keys";
7667
- import { log as log22 } from "@dxos/log";
7668
- import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7669
- import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7670
- import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
7671
- function _define_property26(obj, key, value) {
7672
- if (key in obj) {
7673
- Object.defineProperty(obj, key, {
7674
- value,
7675
- enumerable: true,
7676
- configurable: true,
7677
- writable: true
7678
- });
7679
- } else {
7680
- obj[key] = value;
7681
- }
7682
- return obj;
7683
- }
7684
- function _ts_decorate9(decorators, target, key, desc) {
7685
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7686
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7687
- 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;
7688
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7689
- }
7690
- var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7359
+ var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7691
7360
  var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7692
7361
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7693
7362
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7694
7363
  var EdgeAgentManager = class extends Resource7 {
7364
+ _edgeFeatures;
7365
+ _edgeHttpClient;
7366
+ _dataSpaceManager;
7367
+ _identity;
7368
+ agentStatusChanged = new Event9();
7369
+ _agentDeviceKey;
7370
+ _agentStatus;
7371
+ _lastKnownDeviceCount = 0;
7372
+ _fetchAgentStatusTask;
7373
+ constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7374
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity;
7375
+ }
7695
7376
  get agentStatus() {
7696
7377
  return this._agentStatus;
7697
7378
  }
@@ -7699,8 +7380,8 @@ var EdgeAgentManager = class extends Resource7 {
7699
7380
  return this._agentStatus && this._agentStatus !== EdgeAgentStatus.NOT_FOUND;
7700
7381
  }
7701
7382
  async createAgent() {
7702
- invariant21(this.isOpen, void 0, {
7703
- F: __dxlog_file26,
7383
+ invariant20(this.isOpen, void 0, {
7384
+ F: __dxlog_file25,
7704
7385
  L: 54,
7705
7386
  S: this,
7706
7387
  A: [
@@ -7708,8 +7389,8 @@ var EdgeAgentManager = class extends Resource7 {
7708
7389
  ""
7709
7390
  ]
7710
7391
  });
7711
- invariant21(this._edgeHttpClient, void 0, {
7712
- F: __dxlog_file26,
7392
+ invariant20(this._edgeHttpClient, void 0, {
7393
+ F: __dxlog_file25,
7713
7394
  L: 55,
7714
7395
  S: this,
7715
7396
  A: [
@@ -7717,8 +7398,8 @@ var EdgeAgentManager = class extends Resource7 {
7717
7398
  ""
7718
7399
  ]
7719
7400
  });
7720
- invariant21(this._edgeFeatures?.agents, void 0, {
7721
- F: __dxlog_file26,
7401
+ invariant20(this._edgeFeatures?.agents, void 0, {
7402
+ F: __dxlog_file25,
7722
7403
  L: 56,
7723
7404
  S: this,
7724
7405
  A: [
@@ -7733,10 +7414,10 @@ var EdgeAgentManager = class extends Resource7 {
7733
7414
  });
7734
7415
  const deviceKey = PublicKey13.fromHex(response.deviceKey);
7735
7416
  if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7736
- log22.info("agent was already added to HALO, ignoring response", {
7417
+ log21.info("agent was already added to HALO, ignoring response", {
7737
7418
  response
7738
7419
  }, {
7739
- F: __dxlog_file26,
7420
+ F: __dxlog_file25,
7740
7421
  L: 67,
7741
7422
  S: this,
7742
7423
  C: (f, a) => f(...a)
@@ -7750,8 +7431,8 @@ var EdgeAgentManager = class extends Resource7 {
7750
7431
  // TODO: agents don't have data feed, should be removed
7751
7432
  dataFeedKey: PublicKey13.random()
7752
7433
  });
7753
- log22("agent created", response, {
7754
- F: __dxlog_file26,
7434
+ log21("agent created", response, {
7435
+ F: __dxlog_file25,
7755
7436
  L: 79,
7756
7437
  S: this,
7757
7438
  C: (f, a) => f(...a)
@@ -7760,10 +7441,10 @@ var EdgeAgentManager = class extends Resource7 {
7760
7441
  }
7761
7442
  async _open() {
7762
7443
  const isEnabled = this._edgeHttpClient && this._edgeFeatures?.agents;
7763
- log22("edge agent manager open", {
7444
+ log21("edge agent manager open", {
7764
7445
  isEnabled
7765
7446
  }, {
7766
- F: __dxlog_file26,
7447
+ F: __dxlog_file25,
7767
7448
  L: 87,
7768
7449
  S: this,
7769
7450
  C: (f, a) => f(...a)
@@ -7795,8 +7476,8 @@ var EdgeAgentManager = class extends Resource7 {
7795
7476
  this._lastKnownDeviceCount = 0;
7796
7477
  }
7797
7478
  async _fetchAgentStatus() {
7798
- invariant21(this._edgeHttpClient, void 0, {
7799
- F: __dxlog_file26,
7479
+ invariant20(this._edgeHttpClient, void 0, {
7480
+ F: __dxlog_file25,
7800
7481
  L: 121,
7801
7482
  S: this,
7802
7483
  A: [
@@ -7805,8 +7486,8 @@ var EdgeAgentManager = class extends Resource7 {
7805
7486
  ]
7806
7487
  });
7807
7488
  try {
7808
- log22("fetching agent status", void 0, {
7809
- F: __dxlog_file26,
7489
+ log21("fetching agent status", void 0, {
7490
+ F: __dxlog_file25,
7810
7491
  L: 123,
7811
7492
  S: this,
7812
7493
  C: (f, a) => f(...a)
@@ -7822,10 +7503,10 @@ var EdgeAgentManager = class extends Resource7 {
7822
7503
  } catch (err) {
7823
7504
  if (err instanceof EdgeCallFailedError3) {
7824
7505
  if (!err.isRetryable) {
7825
- log22.warn("non retryable error on agent status fetch attempt", {
7506
+ log21.warn("non retryable error on agent status fetch attempt", {
7826
7507
  err
7827
7508
  }, {
7828
- F: __dxlog_file26,
7509
+ F: __dxlog_file25,
7829
7510
  L: 133,
7830
7511
  S: this,
7831
7512
  C: (f, a) => f(...a)
@@ -7834,11 +7515,11 @@ var EdgeAgentManager = class extends Resource7 {
7834
7515
  }
7835
7516
  }
7836
7517
  const retryAfterMs = AGENT_STATUS_QUERY_RETRY_INTERVAL + Math.random() * AGENT_STATUS_QUERY_RETRY_JITTER;
7837
- log22.info("agent status fetching failed", {
7518
+ log21.info("agent status fetching failed", {
7838
7519
  err,
7839
7520
  retryAfterMs
7840
7521
  }, {
7841
- F: __dxlog_file26,
7522
+ F: __dxlog_file25,
7842
7523
  L: 138,
7843
7524
  S: this,
7844
7525
  C: (f, a) => f(...a)
@@ -7870,11 +7551,11 @@ var EdgeAgentManager = class extends Resource7 {
7870
7551
  ].some((feed) => feed.assertion.deviceKey.equals(agentDeviceKey));
7871
7552
  space.notarizationPlugin.setActiveEdgePollingEnabled(agentFeedNeedsNotarization);
7872
7553
  activePollingEnabled = activePollingEnabled || agentFeedNeedsNotarization;
7873
- log22.verbose("set active edge polling", {
7554
+ log21.verbose("set active edge polling", {
7874
7555
  enabled: agentFeedNeedsNotarization,
7875
7556
  spaceId: space.id
7876
7557
  }, {
7877
- F: __dxlog_file26,
7558
+ F: __dxlog_file25,
7878
7559
  L: 165,
7879
7560
  S: this,
7880
7561
  C: (f, a) => f(...a)
@@ -7891,47 +7572,45 @@ var EdgeAgentManager = class extends Resource7 {
7891
7572
  if (deviceKey) {
7892
7573
  this._ensureAgentIsInSpaces(deviceKey);
7893
7574
  }
7894
- log22.verbose("agent status update", {
7575
+ log21.verbose("agent status update", {
7895
7576
  status
7896
7577
  }, {
7897
- F: __dxlog_file26,
7578
+ F: __dxlog_file25,
7898
7579
  L: 181,
7899
7580
  S: this,
7900
7581
  C: (f, a) => f(...a)
7901
7582
  });
7902
7583
  }
7903
- constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7904
- super(), _define_property26(this, "_edgeFeatures", void 0), _define_property26(this, "_edgeHttpClient", void 0), _define_property26(this, "_dataSpaceManager", void 0), _define_property26(this, "_identity", void 0), _define_property26(this, "agentStatusChanged", void 0), _define_property26(this, "_agentDeviceKey", void 0), _define_property26(this, "_agentStatus", void 0), _define_property26(this, "_lastKnownDeviceCount", void 0), _define_property26(this, "_fetchAgentStatusTask", void 0), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
7905
- }
7906
7584
  };
7907
- _ts_decorate9([
7585
+ _ts_decorate7([
7908
7586
  synchronized3
7909
7587
  ], EdgeAgentManager.prototype, "createAgent", null);
7910
7588
 
7911
7589
  // src/packlets/agents/edge-agent-service.ts
7912
- import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7590
+ import { Stream as Stream10 } from "@dxos/codec-protobuf/stream";
7913
7591
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7914
7592
  import { EdgeStatus as EdgeStatus2, QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7915
- function _define_property27(obj, key, value) {
7916
- if (key in obj) {
7917
- Object.defineProperty(obj, key, {
7918
- value,
7919
- enumerable: true,
7920
- configurable: true,
7921
- writable: true
7922
- });
7923
- } else {
7924
- obj[key] = value;
7925
- }
7926
- return obj;
7927
- }
7928
7593
  var EdgeAgentServiceImpl = class {
7594
+ _agentManagerProvider;
7595
+ _edgeConnection;
7596
+ constructor(_agentManagerProvider, _edgeConnection) {
7597
+ this._agentManagerProvider = _agentManagerProvider;
7598
+ this._edgeConnection = _edgeConnection;
7599
+ }
7929
7600
  // TODO(mykola): Reconcile with NetworkService.queryStatus.
7930
7601
  queryEdgeStatus() {
7931
- return new Stream11(({ ctx, next }) => {
7602
+ return new Stream10(({ ctx, next }) => {
7932
7603
  const update = () => {
7933
7604
  next({
7934
- status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7605
+ status: this._edgeConnection?.status ?? {
7606
+ state: EdgeStatus2.ConnectionState.NOT_CONNECTED,
7607
+ rtt: 0,
7608
+ uptime: 0,
7609
+ rateBytesUp: 0,
7610
+ rateBytesDown: 0,
7611
+ messagesSent: 0,
7612
+ messagesReceived: 0
7613
+ }
7935
7614
  });
7936
7615
  };
7937
7616
  this._edgeConnection?.statusChanged.on(ctx, update);
@@ -7942,7 +7621,7 @@ var EdgeAgentServiceImpl = class {
7942
7621
  return (await this._agentManagerProvider()).createAgent();
7943
7622
  }
7944
7623
  queryAgentStatus() {
7945
- return new Stream11(({ ctx, next }) => {
7624
+ return new Stream10(({ ctx, next }) => {
7946
7625
  next({
7947
7626
  status: QueryAgentStatusResponse.AgentStatus.UNKNOWN
7948
7627
  });
@@ -7958,12 +7637,6 @@ var EdgeAgentServiceImpl = class {
7958
7637
  });
7959
7638
  });
7960
7639
  }
7961
- constructor(_agentManagerProvider, _edgeConnection) {
7962
- _define_property27(this, "_agentManagerProvider", void 0);
7963
- _define_property27(this, "_edgeConnection", void 0);
7964
- this._agentManagerProvider = _agentManagerProvider;
7965
- this._edgeConnection = _edgeConnection;
7966
- }
7967
7640
  };
7968
7641
  var mapStatus = (agentStatus) => {
7969
7642
  switch (agentStatus) {
@@ -7986,11 +7659,11 @@ import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2
7986
7659
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
7987
7660
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
7988
7661
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
7989
- import { invariant as invariant23 } from "@dxos/invariant";
7662
+ import { invariant as invariant22 } from "@dxos/invariant";
7990
7663
  import { Keyring } from "@dxos/keyring";
7991
7664
  import { PublicKey as PublicKey15 } from "@dxos/keys";
7992
- import { log as log24 } from "@dxos/log";
7993
- import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace10 } from "@dxos/protocols";
7665
+ import { log as log23 } from "@dxos/log";
7666
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
7994
7667
  import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
7995
7668
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
7996
7669
  import { trace as Trace3 } from "@dxos/tracing";
@@ -7999,31 +7672,28 @@ import { safeInstanceof } from "@dxos/util";
7999
7672
  // src/packlets/identity/identity-recovery-manager.ts
8000
7673
  import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
8001
7674
  import { sign as sign3 } from "@dxos/crypto";
8002
- import { invariant as invariant22 } from "@dxos/invariant";
7675
+ import { invariant as invariant21 } from "@dxos/invariant";
8003
7676
  import { PublicKey as PublicKey14 } from "@dxos/keys";
8004
- import { log as log23 } from "@dxos/log";
7677
+ import { log as log22 } from "@dxos/log";
8005
7678
  import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
8006
7679
  import { schema as schema6 } from "@dxos/protocols/proto";
8007
7680
  import { Timeframe as Timeframe5 } from "@dxos/timeframe";
8008
- function _define_property28(obj, key, value) {
8009
- if (key in obj) {
8010
- Object.defineProperty(obj, key, {
8011
- value,
8012
- enumerable: true,
8013
- configurable: true,
8014
- writable: true
8015
- });
8016
- } else {
8017
- obj[key] = value;
8018
- }
8019
- return obj;
8020
- }
8021
- var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
7681
+ var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
8022
7682
  var EdgeIdentityRecoveryManager = class {
7683
+ _keyring;
7684
+ _edgeClient;
7685
+ _identityProvider;
7686
+ _acceptRecoveredIdentity;
7687
+ constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
7688
+ this._keyring = _keyring;
7689
+ this._edgeClient = _edgeClient;
7690
+ this._identityProvider = _identityProvider;
7691
+ this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7692
+ }
8023
7693
  async createRecoveryCredential({ data }) {
8024
7694
  const identity = this._identityProvider();
8025
- invariant22(identity, void 0, {
8026
- F: __dxlog_file27,
7695
+ invariant21(identity, void 0, {
7696
+ F: __dxlog_file26,
8027
7697
  L: 39,
8028
7698
  S: this,
8029
7699
  A: [
@@ -8073,8 +7743,8 @@ var EdgeIdentityRecoveryManager = class {
8073
7743
  };
8074
7744
  }
8075
7745
  async requestRecoveryChallenge() {
8076
- invariant22(this._edgeClient, "Not connected to EDGE.", {
8077
- F: __dxlog_file27,
7746
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7747
+ F: __dxlog_file26,
8078
7748
  L: 76,
8079
7749
  S: this,
8080
7750
  A: [
@@ -8103,8 +7773,8 @@ var EdgeIdentityRecoveryManager = class {
8103
7773
  }
8104
7774
  }
8105
7775
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
8106
- invariant22(this._edgeClient, "Not connected to EDGE.", {
8107
- F: __dxlog_file27,
7776
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7777
+ F: __dxlog_file26,
8108
7778
  L: 108,
8109
7779
  S: this,
8110
7780
  A: [
@@ -8137,8 +7807,8 @@ var EdgeIdentityRecoveryManager = class {
8137
7807
  * Recovery identity using an opaque token sent to the user's email.
8138
7808
  */
8139
7809
  async recoverIdentityWithToken({ token }) {
8140
- invariant22(this._edgeClient, "Not connected to EDGE.", {
8141
- F: __dxlog_file27,
7810
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7811
+ F: __dxlog_file26,
8142
7812
  L: 141,
8143
7813
  S: this,
8144
7814
  A: [
@@ -8165,8 +7835,8 @@ var EdgeIdentityRecoveryManager = class {
8165
7835
  });
8166
7836
  }
8167
7837
  async recoverIdentity({ recoveryCode }) {
8168
- invariant22(this._edgeClient, "Not connected to EDGE.", {
8169
- F: __dxlog_file27,
7838
+ invariant21(this._edgeClient, "Not connected to EDGE.", {
7839
+ F: __dxlog_file26,
8170
7840
  L: 165,
8171
7841
  S: this,
8172
7842
  A: [
@@ -8196,8 +7866,8 @@ var EdgeIdentityRecoveryManager = class {
8196
7866
  signature: Buffer.from(signature).toString("base64")
8197
7867
  });
8198
7868
  }
8199
- log23.info("recovering identity", response, {
8200
- F: __dxlog_file27,
7869
+ log22.info("recovering identity", response, {
7870
+ F: __dxlog_file26,
8201
7871
  L: 191,
8202
7872
  S: this,
8203
7873
  C: (f, a) => f(...a)
@@ -8212,16 +7882,6 @@ var EdgeIdentityRecoveryManager = class {
8212
7882
  dataFeedKey: await this._keyring.createKey()
8213
7883
  });
8214
7884
  }
8215
- constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
8216
- _define_property28(this, "_keyring", void 0);
8217
- _define_property28(this, "_edgeClient", void 0);
8218
- _define_property28(this, "_identityProvider", void 0);
8219
- _define_property28(this, "_acceptRecoveredIdentity", void 0);
8220
- this._keyring = _keyring;
8221
- this._edgeClient = _edgeClient;
8222
- this._identityProvider = _identityProvider;
8223
- this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
8224
- }
8225
7885
  };
8226
7886
  var decodeCredential = (credentialBase64) => {
8227
7887
  const credentialBytes = Buffer.from(credentialBase64, "base64");
@@ -8230,20 +7890,7 @@ var decodeCredential = (credentialBase64) => {
8230
7890
  };
8231
7891
 
8232
7892
  // src/packlets/services/service-context.ts
8233
- function _define_property29(obj, key, value) {
8234
- if (key in obj) {
8235
- Object.defineProperty(obj, key, {
8236
- value,
8237
- enumerable: true,
8238
- configurable: true,
8239
- writable: true
8240
- });
8241
- } else {
8242
- obj[key] = value;
8243
- }
8244
- return obj;
8245
- }
8246
- function _ts_decorate10(decorators, target, key, desc) {
7893
+ function _ts_decorate8(decorators, target, key, desc) {
8247
7894
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8248
7895
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8249
7896
  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;
@@ -8314,21 +7961,119 @@ function _ts_dispose_resources4(env) {
8314
7961
  return next();
8315
7962
  })(env);
8316
7963
  }
8317
- var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7964
+ var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8318
7965
  var ServiceContext = class extends Resource8 {
7966
+ storage;
7967
+ level;
7968
+ networkManager;
7969
+ signalManager;
7970
+ _edgeConnection;
7971
+ _edgeHttpClient;
7972
+ _runtime;
7973
+ _runtimeProps;
7974
+ _edgeFeatures;
7975
+ _edgeIdentityUpdateMutex = new Mutex4();
7976
+ initialized = new Trigger7();
7977
+ metadataStore;
7978
+ blobStore;
7979
+ feedStore;
7980
+ keyring;
7981
+ spaceManager;
7982
+ identityManager;
7983
+ recoveryManager;
7984
+ invitations;
7985
+ invitationsManager;
7986
+ echoHost;
7987
+ _meshReplicator = void 0;
7988
+ _echoEdgeReplicator = void 0;
7989
+ // Initialized after identity is initialized.
7990
+ dataSpaceManager;
7991
+ edgeAgentManager;
7992
+ _handlerFactories = /* @__PURE__ */ new Map();
7993
+ _deviceSpaceSync;
7994
+ _instanceId = PublicKey15.random().toHex();
7995
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtime, _runtimeProps, _edgeFeatures) {
7996
+ 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;
7997
+ log23("runtimeProps", this._runtimeProps, {
7998
+ F: __dxlog_file27,
7999
+ L: 120,
8000
+ S: this,
8001
+ C: (f, a) => f(...a)
8002
+ });
8003
+ log23("edgeFeatures", this._edgeFeatures, {
8004
+ F: __dxlog_file27,
8005
+ L: 121,
8006
+ S: this,
8007
+ C: (f, a) => f(...a)
8008
+ });
8009
+ this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8010
+ this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8011
+ this.keyring = new Keyring(storage.createDirectory("keyring"));
8012
+ this.feedStore = new FeedStore({
8013
+ factory: new FeedFactory({
8014
+ root: storage.createDirectory("feeds"),
8015
+ signer: this.keyring,
8016
+ hypercore: {
8017
+ valueEncoding,
8018
+ stats: true
8019
+ }
8020
+ })
8021
+ });
8022
+ this.spaceManager = new SpaceManager({
8023
+ feedStore: this.feedStore,
8024
+ networkManager: this.networkManager,
8025
+ blobStore: this.blobStore,
8026
+ metadataStore: this.metadataStore,
8027
+ disableP2pReplication: this._runtimeProps?.disableP2pReplication
8028
+ });
8029
+ this.identityManager = new IdentityManager({
8030
+ metadataStore: this.metadataStore,
8031
+ keyring: this.keyring,
8032
+ feedStore: this.feedStore,
8033
+ spaceManager: this.spaceManager,
8034
+ devicePresenceOfflineTimeout: this._runtimeProps?.devicePresenceOfflineTimeout,
8035
+ devicePresenceAnnounceInterval: this._runtimeProps?.devicePresenceAnnounceInterval,
8036
+ edgeConnection: this._edgeConnection,
8037
+ edgeFeatures: this._edgeFeatures
8038
+ });
8039
+ this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8040
+ this.echoHost = new EchoHost({
8041
+ kv: this.level,
8042
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8043
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8044
+ indexing: {
8045
+ vector: this._runtimeProps?.enableVectorIndexing,
8046
+ fullText: this._runtimeProps?.enableFullTextIndexing
8047
+ },
8048
+ runtime: this._runtime,
8049
+ localQueues: this._runtimeProps?.enableLocalQueues
8050
+ });
8051
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeProps?.invitationConnectionDefaultProps);
8052
+ this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8053
+ this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8054
+ if (!this._runtimeProps?.disableP2pReplication) {
8055
+ this._meshReplicator = new MeshEchoReplicator();
8056
+ }
8057
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8058
+ this._echoEdgeReplicator = new EchoEdgeReplicator({
8059
+ edgeConnection: this._edgeConnection,
8060
+ edgeHttpClient: this._edgeHttpClient
8061
+ });
8062
+ }
8063
+ }
8319
8064
  async _open(ctx) {
8320
8065
  await this._checkStorageVersion();
8321
- log24("opening...", void 0, {
8322
- F: __dxlog_file28,
8323
- L: 204,
8066
+ log23("opening...", void 0, {
8067
+ F: __dxlog_file27,
8068
+ L: 215,
8324
8069
  S: this,
8325
8070
  C: (f, a) => f(...a)
8326
8071
  });
8327
- log24.trace("dxos.sdk.service-context.open", trace10.begin({
8072
+ log23.trace("dxos.sdk.service-context.open", trace9.begin({
8328
8073
  id: this._instanceId
8329
8074
  }), {
8330
- F: __dxlog_file28,
8331
- L: 205,
8075
+ F: __dxlog_file27,
8076
+ L: 216,
8332
8077
  S: this,
8333
8078
  C: (f, a) => f(...a)
8334
8079
  });
@@ -8351,33 +8096,33 @@ var ServiceContext = class extends Resource8 {
8351
8096
  await this._initialize(ctx);
8352
8097
  }
8353
8098
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
8354
- log24("loaded persistent invitations", {
8099
+ log23("loaded persistent invitations", {
8355
8100
  count: loadedInvitations.invitations?.length
8356
8101
  }, {
8357
- F: __dxlog_file28,
8358
- L: 233,
8102
+ F: __dxlog_file27,
8103
+ L: 244,
8359
8104
  S: this,
8360
8105
  C: (f, a) => f(...a)
8361
8106
  });
8362
- log24.trace("dxos.sdk.service-context.open", trace10.end({
8107
+ log23.trace("dxos.sdk.service-context.open", trace9.end({
8363
8108
  id: this._instanceId
8364
8109
  }), {
8365
- F: __dxlog_file28,
8366
- L: 235,
8110
+ F: __dxlog_file27,
8111
+ L: 246,
8367
8112
  S: this,
8368
8113
  C: (f, a) => f(...a)
8369
8114
  });
8370
- log24("opened", void 0, {
8371
- F: __dxlog_file28,
8372
- L: 236,
8115
+ log23("opened", void 0, {
8116
+ F: __dxlog_file27,
8117
+ L: 247,
8373
8118
  S: this,
8374
8119
  C: (f, a) => f(...a)
8375
8120
  });
8376
8121
  }
8377
8122
  async _close(ctx) {
8378
- log24("closing...", void 0, {
8379
- F: __dxlog_file28,
8380
- L: 240,
8123
+ log23("closing...", void 0, {
8124
+ F: __dxlog_file27,
8125
+ L: 251,
8381
8126
  S: this,
8382
8127
  C: (f, a) => f(...a)
8383
8128
  });
@@ -8394,9 +8139,9 @@ var ServiceContext = class extends Resource8 {
8394
8139
  await this._edgeConnection?.close();
8395
8140
  await this.feedStore.close();
8396
8141
  await this.metadataStore.close();
8397
- log24("closed", void 0, {
8398
- F: __dxlog_file28,
8399
- L: 256,
8142
+ log23("closed", void 0, {
8143
+ F: __dxlog_file27,
8144
+ L: 267,
8400
8145
  S: this,
8401
8146
  C: (f, a) => f(...a)
8402
8147
  });
@@ -8406,8 +8151,8 @@ var ServiceContext = class extends Resource8 {
8406
8151
  await this._setNetworkIdentity();
8407
8152
  await identity.joinNetwork();
8408
8153
  await this._initialize(new Context10(void 0, {
8409
- F: __dxlog_file28,
8410
- L: 263
8154
+ F: __dxlog_file27,
8155
+ L: 274
8411
8156
  }));
8412
8157
  return identity;
8413
8158
  }
@@ -8416,9 +8161,9 @@ var ServiceContext = class extends Resource8 {
8416
8161
  throw new Error("Identity must be created before joining a space.");
8417
8162
  }
8418
8163
  const factory = this._handlerFactories.get(invitation.kind);
8419
- invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
8420
- F: __dxlog_file28,
8421
- L: 272,
8164
+ invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8165
+ F: __dxlog_file27,
8166
+ L: 283,
8422
8167
  S: this,
8423
8168
  A: [
8424
8169
  "factory",
@@ -8443,8 +8188,8 @@ var ServiceContext = class extends Resource8 {
8443
8188
  await identity.joinNetwork();
8444
8189
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8445
8190
  await this._initialize(new Context10(void 0, {
8446
- F: __dxlog_file28,
8447
- L: 291
8191
+ F: __dxlog_file27,
8192
+ L: 302
8448
8193
  }));
8449
8194
  return identity;
8450
8195
  }
@@ -8456,9 +8201,9 @@ var ServiceContext = class extends Resource8 {
8456
8201
  }
8457
8202
  // Called when identity is created.
8458
8203
  async _initialize(ctx) {
8459
- log24("initializing spaces...", void 0, {
8460
- F: __dxlog_file28,
8461
- L: 306,
8204
+ log23("initializing spaces...", void 0, {
8205
+ F: __dxlog_file27,
8206
+ L: 317,
8462
8207
  S: this,
8463
8208
  C: (f, a) => f(...a)
8464
8209
  });
@@ -8488,16 +8233,16 @@ var ServiceContext = class extends Resource8 {
8488
8233
  edgeHttpClient: this._edgeHttpClient,
8489
8234
  echoEdgeReplicator: this._echoEdgeReplicator,
8490
8235
  meshReplicator: this._meshReplicator,
8491
- runtimeParams: this._runtimeParams,
8236
+ runtimeProps: this._runtimeProps,
8492
8237
  edgeFeatures: this._edgeFeatures
8493
8238
  });
8494
8239
  await this.dataSpaceManager.open();
8495
8240
  this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
8496
8241
  await this.edgeAgentManager.open();
8497
8242
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8498
- invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8499
- F: __dxlog_file28,
8500
- L: 344,
8243
+ invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8244
+ F: __dxlog_file27,
8245
+ L: 355,
8501
8246
  S: this,
8502
8247
  A: [
8503
8248
  "this.dataSpaceManager",
@@ -8517,33 +8262,33 @@ var ServiceContext = class extends Resource8 {
8517
8262
  return;
8518
8263
  }
8519
8264
  if (!this.dataSpaceManager) {
8520
- log24("dataSpaceManager not initialized yet, ignoring space admission", {
8265
+ log23("dataSpaceManager not initialized yet, ignoring space admission", {
8521
8266
  details: assertion
8522
8267
  }, {
8523
- F: __dxlog_file28,
8524
- L: 360,
8268
+ F: __dxlog_file27,
8269
+ L: 371,
8525
8270
  S: this,
8526
8271
  C: (f, a) => f(...a)
8527
8272
  });
8528
8273
  return;
8529
8274
  }
8530
8275
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
8531
- log24("space already exists, ignoring space admission", {
8276
+ log23("space already exists, ignoring space admission", {
8532
8277
  details: assertion
8533
8278
  }, {
8534
- F: __dxlog_file28,
8535
- L: 364,
8279
+ F: __dxlog_file27,
8280
+ L: 375,
8536
8281
  S: this,
8537
8282
  C: (f, a) => f(...a)
8538
8283
  });
8539
8284
  return;
8540
8285
  }
8541
8286
  try {
8542
- log24("accepting space recorded in halo", {
8287
+ log23("accepting space recorded in halo", {
8543
8288
  details: assertion
8544
8289
  }, {
8545
- F: __dxlog_file28,
8546
- L: 369,
8290
+ F: __dxlog_file27,
8291
+ L: 380,
8547
8292
  S: this,
8548
8293
  C: (f, a) => f(...a)
8549
8294
  });
@@ -8552,9 +8297,9 @@ var ServiceContext = class extends Resource8 {
8552
8297
  genesisFeedKey: assertion.genesisFeedKey
8553
8298
  });
8554
8299
  } catch (err) {
8555
- log24.catch(err, void 0, {
8556
- F: __dxlog_file28,
8557
- L: 375,
8300
+ log23.catch(err, void 0, {
8301
+ F: __dxlog_file27,
8302
+ L: 386,
8558
8303
  S: this,
8559
8304
  C: (f, a) => f(...a)
8560
8305
  });
@@ -8574,12 +8319,12 @@ var ServiceContext = class extends Resource8 {
8574
8319
  let edgeIdentity;
8575
8320
  const identity = this.identityManager.identity;
8576
8321
  if (identity) {
8577
- log24("setting identity on edge connection", {
8322
+ log23("setting identity on edge connection", {
8578
8323
  identity: identity.identityKey.toHex(),
8579
8324
  swarms: this.networkManager.topics
8580
8325
  }, {
8581
- F: __dxlog_file28,
8582
- L: 389,
8326
+ F: __dxlog_file27,
8327
+ L: 400,
8583
8328
  S: this,
8584
8329
  C: (f, a) => f(...a)
8585
8330
  });
@@ -8591,9 +8336,9 @@ var ServiceContext = class extends Resource8 {
8591
8336
  await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
8592
8337
  await identity.ready();
8593
8338
  });
8594
- invariant23(identity.deviceCredentialChain, void 0, {
8595
- F: __dxlog_file28,
8596
- L: 408,
8339
+ invariant22(identity.deviceCredentialChain, void 0, {
8340
+ F: __dxlog_file27,
8341
+ L: 419,
8597
8342
  S: this,
8598
8343
  A: [
8599
8344
  "identity.deviceCredentialChain",
@@ -8618,70 +8363,14 @@ var ServiceContext = class extends Resource8 {
8618
8363
  _ts_dispose_resources4(env);
8619
8364
  }
8620
8365
  }
8621
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8622
- super(), _define_property29(this, "storage", void 0), _define_property29(this, "level", void 0), _define_property29(this, "networkManager", void 0), _define_property29(this, "signalManager", void 0), _define_property29(this, "_edgeConnection", void 0), _define_property29(this, "_edgeHttpClient", void 0), _define_property29(this, "_runtimeParams", void 0), _define_property29(this, "_edgeFeatures", void 0), _define_property29(this, "_edgeIdentityUpdateMutex", void 0), _define_property29(this, "initialized", void 0), _define_property29(this, "metadataStore", void 0), _define_property29(this, "blobStore", void 0), _define_property29(this, "feedStore", void 0), _define_property29(this, "keyring", void 0), _define_property29(this, "spaceManager", void 0), _define_property29(this, "identityManager", void 0), _define_property29(this, "recoveryManager", void 0), _define_property29(this, "invitations", void 0), _define_property29(this, "invitationsManager", void 0), _define_property29(this, "echoHost", void 0), _define_property29(this, "_meshReplicator", void 0), _define_property29(this, "_echoEdgeReplicator", void 0), // Initialized after identity is initialized.
8623
- _define_property29(this, "dataSpaceManager", void 0), _define_property29(this, "edgeAgentManager", void 0), _define_property29(this, "_handlerFactories", void 0), _define_property29(this, "_deviceSpaceSync", void 0), _define_property29(this, "_instanceId", void 0), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures, this._edgeIdentityUpdateMutex = new Mutex4(), this.initialized = new Trigger7(), this._meshReplicator = void 0, this._echoEdgeReplicator = void 0, this._handlerFactories = /* @__PURE__ */ new Map(), this._instanceId = PublicKey15.random().toHex();
8624
- this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8625
- this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8626
- this.keyring = new Keyring(storage.createDirectory("keyring"));
8627
- this.feedStore = new FeedStore({
8628
- factory: new FeedFactory({
8629
- root: storage.createDirectory("feeds"),
8630
- signer: this.keyring,
8631
- hypercore: {
8632
- valueEncoding,
8633
- stats: true
8634
- }
8635
- })
8636
- });
8637
- this.spaceManager = new SpaceManager({
8638
- feedStore: this.feedStore,
8639
- networkManager: this.networkManager,
8640
- blobStore: this.blobStore,
8641
- metadataStore: this.metadataStore,
8642
- disableP2pReplication: this._runtimeParams?.disableP2pReplication
8643
- });
8644
- this.identityManager = new IdentityManager({
8645
- metadataStore: this.metadataStore,
8646
- keyring: this.keyring,
8647
- feedStore: this.feedStore,
8648
- spaceManager: this.spaceManager,
8649
- devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8650
- devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8651
- edgeConnection: this._edgeConnection,
8652
- edgeFeatures: this._edgeFeatures
8653
- });
8654
- this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8655
- this.echoHost = new EchoHost({
8656
- kv: this.level,
8657
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8658
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8659
- indexing: {
8660
- vector: this._runtimeParams?.enableVectorIndexing
8661
- }
8662
- });
8663
- this._meshReplicator = new MeshEchoReplicator();
8664
- this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8665
- this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8666
- this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8667
- if (!this._runtimeParams?.disableP2pReplication) {
8668
- this._meshReplicator = new MeshEchoReplicator();
8669
- }
8670
- if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8671
- this._echoEdgeReplicator = new EchoEdgeReplicator({
8672
- edgeConnection: this._edgeConnection,
8673
- edgeHttpClient: this._edgeHttpClient
8674
- });
8675
- }
8676
- }
8677
8366
  };
8678
- _ts_decorate10([
8367
+ _ts_decorate8([
8679
8368
  Trace3.span()
8680
8369
  ], ServiceContext.prototype, "_open", null);
8681
- _ts_decorate10([
8370
+ _ts_decorate8([
8682
8371
  Trace3.span()
8683
8372
  ], ServiceContext.prototype, "_initialize", null);
8684
- ServiceContext = _ts_decorate10([
8373
+ ServiceContext = _ts_decorate8([
8685
8374
  safeInstanceof("dxos.client-services.ServiceContext"),
8686
8375
  Trace3.resource()
8687
8376
  ], ServiceContext);
@@ -8709,16 +8398,24 @@ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
8709
8398
  var createStorageObjects = (config) => {
8710
8399
  const { persistent = false, keyStore, dataStore } = config ?? {};
8711
8400
  if (persistent && dataStore === StorageDriver.RAM) {
8712
- throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
8401
+ throw new InvalidConfigError({
8402
+ message: "RAM storage cannot be used in persistent mode."
8403
+ });
8713
8404
  }
8714
8405
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
8715
- throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
8406
+ throw new InvalidConfigError({
8407
+ message: "Cannot use a persistent storage in not persistent mode."
8408
+ });
8716
8409
  }
8717
8410
  if (persistent && keyStore === StorageDriver.RAM) {
8718
- throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
8411
+ throw new InvalidConfigError({
8412
+ message: "RAM key storage cannot be used in persistent mode."
8413
+ });
8719
8414
  }
8720
8415
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
8721
- throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
8416
+ throw new InvalidConfigError({
8417
+ message: "Cannot use a persistent key storage in not persistent mode."
8418
+ });
8722
8419
  }
8723
8420
  return {
8724
8421
  storage: createStorage({
@@ -8760,180 +8457,15 @@ var createLevel = async (config) => {
8760
8457
  return level;
8761
8458
  };
8762
8459
 
8763
- // src/packlets/storage/profile-archive.ts
8764
- import { cbor } from "@automerge/automerge-repo";
8765
- import { invariant as invariant24 } from "@dxos/invariant";
8766
- import { log as log25 } from "@dxos/log";
8767
- import { ProfileArchiveEntryType } from "@dxos/protocols";
8768
- import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
8769
- var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
8770
- var encodeProfileArchive = (profile) => cbor.encode(profile);
8771
- var decodeProfileArchive = (data) => cbor.decode(data);
8772
- var exportProfileData = async ({ storage, level }) => {
8773
- const archive = {
8774
- storage: [],
8775
- meta: {
8776
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
8777
- }
8778
- };
8779
- {
8780
- const directory = await storage.createDirectory();
8781
- const files = await directory.list();
8782
- log25.info("begin exporting files", {
8783
- count: files.length
8784
- }, {
8785
- F: __dxlog_file29,
8786
- L: 31,
8787
- S: void 0,
8788
- C: (f, a) => f(...a)
8789
- });
8790
- for (const filename of files) {
8791
- const file = await directory.getOrCreateFile(filename);
8792
- const { size } = await file.stat();
8793
- const data = await file.read(0, size);
8794
- archive.storage.push({
8795
- type: ProfileArchiveEntryType.FILE,
8796
- key: filename,
8797
- value: data
8798
- });
8799
- }
8800
- log25.info("done exporting files", {
8801
- count: files.length
8802
- }, {
8803
- F: __dxlog_file29,
8804
- L: 42,
8805
- S: void 0,
8806
- C: (f, a) => f(...a)
8807
- });
8808
- }
8809
- {
8810
- log25.info("begin exporting kv pairs", void 0, {
8811
- F: __dxlog_file29,
8812
- L: 46,
8813
- S: void 0,
8814
- C: (f, a) => f(...a)
8815
- });
8816
- const iter = await level.iterator({
8817
- keyEncoding: "binary",
8818
- valueEncoding: "binary"
8819
- });
8820
- let count = 0;
8821
- for await (const [key, value] of iter) {
8822
- archive.storage.push({
8823
- type: ProfileArchiveEntryType.KEY_VALUE,
8824
- key,
8825
- value
8826
- });
8827
- count++;
8828
- }
8829
- log25.info("done exporting kv pairs", {
8830
- count
8831
- }, {
8832
- F: __dxlog_file29,
8833
- L: 57,
8834
- S: void 0,
8835
- C: (f, a) => f(...a)
8836
- });
8837
- }
8838
- return archive;
8839
- };
8840
- var importProfileData = async ({ storage, level }, archive) => {
8841
- let batch = level.batch();
8842
- let count = 0;
8843
- for (const entry2 of archive.storage) {
8844
- switch (entry2.type) {
8845
- case ProfileArchiveEntryType.FILE: {
8846
- const directory = await storage.createDirectory();
8847
- invariant24(typeof entry2.key === "string", "Invalid key type", {
8848
- F: __dxlog_file29,
8849
- L: 80,
8850
- S: void 0,
8851
- A: [
8852
- "typeof entry.key === 'string'",
8853
- "'Invalid key type'"
8854
- ]
8855
- });
8856
- const file = await directory.getOrCreateFile(entry2.key);
8857
- invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
8858
- F: __dxlog_file29,
8859
- L: 82,
8860
- S: void 0,
8861
- A: [
8862
- "entry.value instanceof Uint8Array",
8863
- "'Invalid value type'"
8864
- ]
8865
- });
8866
- await file.write(0, arrayToBuffer2(entry2.value));
8867
- await file.close();
8868
- break;
8869
- }
8870
- case ProfileArchiveEntryType.KEY_VALUE: {
8871
- invariant24(entry2.key instanceof Uint8Array, "Invalid key type", {
8872
- F: __dxlog_file29,
8873
- L: 88,
8874
- S: void 0,
8875
- A: [
8876
- "entry.key instanceof Uint8Array",
8877
- "'Invalid key type'"
8878
- ]
8879
- });
8880
- invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
8881
- F: __dxlog_file29,
8882
- L: 89,
8883
- S: void 0,
8884
- A: [
8885
- "entry.value instanceof Uint8Array",
8886
- "'Invalid value type'"
8887
- ]
8888
- });
8889
- batch.put(entry2.key, entry2.value, {
8890
- keyEncoding: "binary",
8891
- valueEncoding: "binary"
8892
- });
8893
- break;
8894
- }
8895
- default:
8896
- throw new Error(`Invalid entry type: ${entry2.type}`);
8897
- }
8898
- if (++count % 1e3 === 0) {
8899
- await batch.write();
8900
- batch = level.batch();
8901
- log25.info("importing", {
8902
- count,
8903
- total: archive.storage.length,
8904
- progress: `${(count / archive.storage.length * 100).toFixed()}%`
8905
- }, {
8906
- F: __dxlog_file29,
8907
- L: 102,
8908
- S: void 0,
8909
- C: (f, a) => f(...a)
8910
- });
8911
- }
8912
- }
8913
- log25.info("committing changes..", void 0, {
8914
- F: __dxlog_file29,
8915
- L: 110,
8916
- S: void 0,
8917
- C: (f, a) => f(...a)
8918
- });
8919
- await batch.write();
8920
- };
8921
-
8922
8460
  // src/packlets/services/service-registry.ts
8923
- function _define_property30(obj, key, value) {
8924
- if (key in obj) {
8925
- Object.defineProperty(obj, key, {
8926
- value,
8927
- enumerable: true,
8928
- configurable: true,
8929
- writable: true
8930
- });
8931
- } else {
8932
- obj[key] = value;
8933
- }
8934
- return obj;
8935
- }
8936
8461
  var ServiceRegistry = class {
8462
+ _serviceBundle;
8463
+ _handlers;
8464
+ // prettier-ignore
8465
+ constructor(_serviceBundle, _handlers = {}) {
8466
+ this._serviceBundle = _serviceBundle;
8467
+ this._handlers = _handlers;
8468
+ }
8937
8469
  get descriptors() {
8938
8470
  return this._serviceBundle;
8939
8471
  }
@@ -8949,55 +8481,45 @@ var ServiceRegistry = class {
8949
8481
  removeService(name) {
8950
8482
  delete this._handlers[name];
8951
8483
  }
8952
- // prettier-ignore
8953
- constructor(_serviceBundle, _handlers = {}) {
8954
- _define_property30(this, "_serviceBundle", void 0);
8955
- _define_property30(this, "_handlers", void 0);
8956
- this._serviceBundle = _serviceBundle;
8957
- this._handlers = _handlers;
8958
- }
8959
8484
  };
8960
8485
 
8961
8486
  // src/packlets/services/service-host.ts
8487
+ import * as SqlClient from "@effect/sql/SqlClient";
8488
+ import * as Effect from "effect/Effect";
8962
8489
  import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
8963
8490
  import { clientServiceBundle } from "@dxos/client-protocol";
8964
8491
  import { Context as Context11 } from "@dxos/context";
8965
8492
  import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
8966
- import { invariant as invariant26 } from "@dxos/invariant";
8493
+ import { RuntimeProvider } from "@dxos/effect";
8494
+ import { invariant as invariant24 } from "@dxos/invariant";
8967
8495
  import { PublicKey as PublicKey19 } from "@dxos/keys";
8968
- import { log as log27 } from "@dxos/log";
8496
+ import { log as log25 } from "@dxos/log";
8969
8497
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
8970
8498
  import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
8971
- import { trace as trace11 } from "@dxos/protocols";
8499
+ import { trace as trace10 } from "@dxos/protocols";
8972
8500
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
8501
+ import * as SqlExport from "@dxos/sql-sqlite/SqlExport";
8973
8502
  import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
8974
8503
  import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8975
8504
 
8976
8505
  // src/packlets/devices/devices-service.ts
8977
8506
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8978
- import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8979
- import { invariant as invariant25 } from "@dxos/invariant";
8507
+ import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
8508
+ import { invariant as invariant23 } from "@dxos/invariant";
8980
8509
  import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8981
- function _define_property31(obj, key, value) {
8982
- if (key in obj) {
8983
- Object.defineProperty(obj, key, {
8984
- value,
8985
- enumerable: true,
8986
- configurable: true,
8987
- writable: true
8988
- });
8989
- } else {
8990
- obj[key] = value;
8991
- }
8992
- return obj;
8993
- }
8994
- var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8510
+ var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8995
8511
  var DevicesServiceImpl = class {
8512
+ _identityManager;
8513
+ _edgeConnection;
8514
+ constructor(_identityManager, _edgeConnection) {
8515
+ this._identityManager = _identityManager;
8516
+ this._edgeConnection = _edgeConnection;
8517
+ }
8996
8518
  async updateDevice(profile) {
8997
8519
  return this._identityManager.updateDeviceProfile(profile);
8998
8520
  }
8999
8521
  queryDevices() {
9000
- return new Stream12(({ next }) => {
8522
+ return new Stream11(({ next }) => {
9001
8523
  const update = () => {
9002
8524
  const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
9003
8525
  if (!deviceKeys) {
@@ -9005,8 +8527,8 @@ var DevicesServiceImpl = class {
9005
8527
  devices: []
9006
8528
  });
9007
8529
  } else {
9008
- invariant25(this._identityManager.identity?.presence, "presence not present", {
9009
- F: __dxlog_file30,
8530
+ invariant23(this._identityManager.identity?.presence, "presence not present", {
8531
+ F: __dxlog_file28,
9010
8532
  L: 37,
9011
8533
  S: this,
9012
8534
  A: [
@@ -9022,7 +8544,7 @@ var DevicesServiceImpl = class {
9022
8544
  if (isMe) {
9023
8545
  presence = Device2.PresenceState.ONLINE;
9024
8546
  } else if (profile.os?.toUpperCase() === "EDGE") {
9025
- presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8547
+ presence = this._edgeConnection?.status.state === EdgeStatus3.ConnectionState.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9026
8548
  } else {
9027
8549
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9028
8550
  }
@@ -9070,33 +8592,22 @@ var DevicesServiceImpl = class {
9070
8592
  return () => subscriptions.clear();
9071
8593
  });
9072
8594
  }
9073
- constructor(_identityManager, _edgeConnection) {
9074
- _define_property31(this, "_identityManager", void 0);
9075
- _define_property31(this, "_edgeConnection", void 0);
9076
- this._identityManager = _identityManager;
9077
- this._edgeConnection = _edgeConnection;
9078
- }
9079
8595
  };
9080
8596
 
9081
8597
  // src/packlets/identity/contacts-service.ts
9082
8598
  import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask9 } from "@dxos/async";
9083
- import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8599
+ import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
9084
8600
  import { PublicKey as PublicKey17 } from "@dxos/keys";
9085
8601
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
9086
- function _define_property32(obj, key, value) {
9087
- if (key in obj) {
9088
- Object.defineProperty(obj, key, {
9089
- value,
9090
- enumerable: true,
9091
- configurable: true,
9092
- writable: true
9093
- });
9094
- } else {
9095
- obj[key] = value;
9096
- }
9097
- return obj;
9098
- }
9099
8602
  var ContactsServiceImpl = class {
8603
+ _identityManager;
8604
+ _spaceManager;
8605
+ _dataSpaceManagerProvider;
8606
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
8607
+ this._identityManager = _identityManager;
8608
+ this._spaceManager = _spaceManager;
8609
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
8610
+ }
9100
8611
  async getContacts() {
9101
8612
  const identity = this._identityManager.identity;
9102
8613
  if (identity == null) {
@@ -9118,8 +8629,7 @@ var ContactsServiceImpl = class {
9118
8629
  }
9119
8630
  const existing = acc.get(memberInfo.key);
9120
8631
  if (existing != null) {
9121
- var _existing;
9122
- (_existing = existing).profile ?? (_existing.profile = memberInfo.profile);
8632
+ existing.profile ??= memberInfo.profile;
9123
8633
  existing.commonSpaces?.push(spaceKey);
9124
8634
  } else {
9125
8635
  acc.set(memberInfo.key, {
@@ -9140,7 +8650,7 @@ var ContactsServiceImpl = class {
9140
8650
  }
9141
8651
  queryContacts() {
9142
8652
  const subscribedSpaceKeySet = new ComplexSet6(PublicKey17.hash);
9143
- return new Stream13(({ next, ctx }) => {
8653
+ return new Stream12(({ next, ctx }) => {
9144
8654
  const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
9145
8655
  const contacts = await this.getContacts();
9146
8656
  next(contacts);
@@ -9168,43 +8678,25 @@ var ContactsServiceImpl = class {
9168
8678
  });
9169
8679
  });
9170
8680
  }
9171
- constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
9172
- _define_property32(this, "_identityManager", void 0);
9173
- _define_property32(this, "_spaceManager", void 0);
9174
- _define_property32(this, "_dataSpaceManagerProvider", void 0);
9175
- this._identityManager = _identityManager;
9176
- this._spaceManager = _spaceManager;
9177
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
9178
- }
9179
8681
  };
9180
8682
 
9181
8683
  // src/packlets/logging/logging-service.ts
9182
8684
  import { Event as Event10 } from "@dxos/async";
9183
- import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
8685
+ import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
9184
8686
  import { PublicKey as PublicKey18 } from "@dxos/keys";
9185
- import { getContextFromEntry, log as log26 } from "@dxos/log";
8687
+ import { getContextFromEntry, log as log24 } from "@dxos/log";
9186
8688
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
9187
8689
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
9188
- function _define_property33(obj, key, value) {
9189
- if (key in obj) {
9190
- Object.defineProperty(obj, key, {
9191
- value,
9192
- enumerable: true,
9193
- configurable: true,
9194
- writable: true
9195
- });
9196
- } else {
9197
- obj[key] = value;
9198
- }
9199
- return obj;
9200
- }
9201
8690
  var LoggingServiceImpl = class {
8691
+ _logs = new Event10();
8692
+ _started = Date.now();
8693
+ _sessionId = PublicKey18.random().toHex();
9202
8694
  async open() {
9203
- log26.runtimeConfig.processors.push(this._logProcessor);
8695
+ log24.runtimeConfig.processors.push(this._logProcessor);
9204
8696
  }
9205
8697
  async close() {
9206
- const index = log26.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
9207
- log26.runtimeConfig.processors.splice(index, 1);
8698
+ const index = log24.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
8699
+ log24.runtimeConfig.processors.splice(index, 1);
9208
8700
  }
9209
8701
  async controlMetrics({ reset, record }) {
9210
8702
  if (reset) {
@@ -9230,7 +8722,7 @@ var LoggingServiceImpl = class {
9230
8722
  stats: numericalValues(events, "duration")
9231
8723
  };
9232
8724
  };
9233
- return new Stream14(({ next }) => {
8725
+ return new Stream13(({ next }) => {
9234
8726
  const update = () => {
9235
8727
  const metrics2 = {
9236
8728
  timestamp: /* @__PURE__ */ new Date(),
@@ -9252,7 +8744,7 @@ var LoggingServiceImpl = class {
9252
8744
  });
9253
8745
  }
9254
8746
  queryLogs(request) {
9255
- return new Stream14(({ ctx, next }) => {
8747
+ return new Stream13(({ ctx, next }) => {
9256
8748
  const handler = (entry2) => {
9257
8749
  if (LOG_PROCESSING > 0) {
9258
8750
  return;
@@ -9289,14 +8781,9 @@ var LoggingServiceImpl = class {
9289
8781
  this._logs.on(ctx, handler);
9290
8782
  });
9291
8783
  }
9292
- constructor() {
9293
- _define_property33(this, "_logs", new Event10());
9294
- _define_property33(this, "_started", Date.now());
9295
- _define_property33(this, "_sessionId", PublicKey18.random().toHex());
9296
- _define_property33(this, "_logProcessor", (_config, entry2) => {
9297
- this._logs.emit(entry2);
9298
- });
9299
- }
8784
+ _logProcessor = (_config, entry2) => {
8785
+ this._logs.emit(entry2);
8786
+ };
9300
8787
  };
9301
8788
  var matchFilter = (filter, level, path2, options) => {
9302
8789
  switch (options) {
@@ -9317,23 +8804,18 @@ var shouldLog = (entry2, request) => {
9317
8804
  var LOG_PROCESSING = 0;
9318
8805
 
9319
8806
  // src/packlets/network/network-service.ts
9320
- import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
9321
- function _define_property34(obj, key, value) {
9322
- if (key in obj) {
9323
- Object.defineProperty(obj, key, {
9324
- value,
9325
- enumerable: true,
9326
- configurable: true,
9327
- writable: true
9328
- });
9329
- } else {
9330
- obj[key] = value;
9331
- }
9332
- return obj;
9333
- }
8807
+ import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
9334
8808
  var NetworkServiceImpl = class {
8809
+ networkManager;
8810
+ signalManager;
8811
+ edgeConnection;
8812
+ constructor(networkManager, signalManager, edgeConnection) {
8813
+ this.networkManager = networkManager;
8814
+ this.signalManager = signalManager;
8815
+ this.edgeConnection = edgeConnection;
8816
+ }
9335
8817
  queryStatus() {
9336
- return new Stream15(({ ctx, next }) => {
8818
+ return new Stream14(({ ctx, next }) => {
9337
8819
  const update = () => {
9338
8820
  next({
9339
8821
  swarm: this.networkManager.connectionState,
@@ -9362,7 +8844,7 @@ var NetworkServiceImpl = class {
9362
8844
  return this.signalManager.query(request);
9363
8845
  }
9364
8846
  subscribeSwarmState(request) {
9365
- return new Stream15(({ ctx, next }) => {
8847
+ return new Stream14(({ ctx, next }) => {
9366
8848
  this.signalManager.swarmState?.on(ctx, (state) => {
9367
8849
  if (request.topic.equals(state.swarmKey)) {
9368
8850
  next(state);
@@ -9374,7 +8856,7 @@ var NetworkServiceImpl = class {
9374
8856
  return this.signalManager.sendMessage(message);
9375
8857
  }
9376
8858
  subscribeMessages(peer) {
9377
- return new Stream15(({ ctx, next }) => {
8859
+ return new Stream14(({ ctx, next }) => {
9378
8860
  this.signalManager.onMessage.on(ctx, (message) => {
9379
8861
  if (message.recipient.peerKey === peer.peerKey) {
9380
8862
  next(message);
@@ -9382,34 +8864,27 @@ var NetworkServiceImpl = class {
9382
8864
  });
9383
8865
  });
9384
8866
  }
9385
- constructor(networkManager, signalManager, edgeConnection) {
9386
- _define_property34(this, "networkManager", void 0);
9387
- _define_property34(this, "signalManager", void 0);
9388
- _define_property34(this, "edgeConnection", void 0);
9389
- this.networkManager = networkManager;
9390
- this.signalManager = signalManager;
9391
- this.edgeConnection = edgeConnection;
9392
- }
9393
8867
  };
9394
8868
 
9395
8869
  // src/packlets/system/system-service.ts
9396
- import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
8870
+ import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
9397
8871
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
9398
8872
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
9399
- function _define_property35(obj, key, value) {
9400
- if (key in obj) {
9401
- Object.defineProperty(obj, key, {
9402
- value,
9403
- enumerable: true,
9404
- configurable: true,
9405
- writable: true
9406
- });
9407
- } else {
9408
- obj[key] = value;
9409
- }
9410
- return obj;
9411
- }
9412
8873
  var SystemServiceImpl = class {
8874
+ _config;
8875
+ _statusUpdate;
8876
+ _getCurrentStatus;
8877
+ _onUpdateStatus;
8878
+ _onReset;
8879
+ _getDiagnostics;
8880
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
8881
+ this._config = config;
8882
+ this._statusUpdate = statusUpdate;
8883
+ this._getCurrentStatus = getCurrentStatus;
8884
+ this._getDiagnostics = getDiagnostics;
8885
+ this._onUpdateStatus = onUpdateStatus;
8886
+ this._onReset = onReset;
8887
+ }
9413
8888
  async getConfig() {
9414
8889
  return (await this._config?.())?.values ?? {};
9415
8890
  }
@@ -9434,7 +8909,7 @@ var SystemServiceImpl = class {
9434
8909
  }
9435
8910
  // TODO(burdon): Standardize interval option in stream request?
9436
8911
  queryStatus({ interval = 3e3 } = {}) {
9437
- return new Stream16(({ next }) => {
8912
+ return new Stream15(({ next }) => {
9438
8913
  const update = () => {
9439
8914
  next({
9440
8915
  status: this._getCurrentStatus()
@@ -9452,44 +8927,102 @@ var SystemServiceImpl = class {
9452
8927
  async reset() {
9453
8928
  await this._onReset();
9454
8929
  }
9455
- constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9456
- _define_property35(this, "_config", void 0);
9457
- _define_property35(this, "_statusUpdate", void 0);
9458
- _define_property35(this, "_getCurrentStatus", void 0);
9459
- _define_property35(this, "_onUpdateStatus", void 0);
9460
- _define_property35(this, "_onReset", void 0);
9461
- _define_property35(this, "_getDiagnostics", void 0);
9462
- this._config = config;
9463
- this._statusUpdate = statusUpdate;
9464
- this._getCurrentStatus = getCurrentStatus;
9465
- this._getDiagnostics = getDiagnostics;
9466
- this._onUpdateStatus = onUpdateStatus;
9467
- this._onReset = onReset;
9468
- }
9469
8930
  };
9470
8931
 
9471
8932
  // src/packlets/services/service-host.ts
9472
- function _define_property36(obj, key, value) {
9473
- if (key in obj) {
9474
- Object.defineProperty(obj, key, {
9475
- value,
9476
- enumerable: true,
9477
- configurable: true,
9478
- writable: true
9479
- });
9480
- } else {
9481
- obj[key] = value;
9482
- }
9483
- return obj;
9484
- }
9485
- function _ts_decorate11(decorators, target, key, desc) {
8933
+ function _ts_decorate9(decorators, target, key, desc) {
9486
8934
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9487
8935
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9488
8936
  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;
9489
8937
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9490
8938
  }
9491
- var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8939
+ var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9492
8940
  var ClientServicesHost = class {
8941
+ _resourceLock;
8942
+ _serviceRegistry;
8943
+ _systemService;
8944
+ _loggingService;
8945
+ _tracingService = TRACE_PROCESSOR3.createTraceSender();
8946
+ _statusUpdate = new Event11();
8947
+ _config;
8948
+ _signalManager;
8949
+ _networkManager;
8950
+ _storage;
8951
+ _level;
8952
+ _callbacks;
8953
+ _devtoolsProxy;
8954
+ _edgeConnection = void 0;
8955
+ _edgeHttpClient = void 0;
8956
+ _serviceContext;
8957
+ _runtime;
8958
+ _runtimeProps;
8959
+ diagnosticsBroadcastHandler;
8960
+ _opening = false;
8961
+ _open = false;
8962
+ _resetting = false;
8963
+ constructor({
8964
+ config,
8965
+ transportFactory,
8966
+ signalManager,
8967
+ storage,
8968
+ level,
8969
+ // TODO(wittjosiah): Turn this on by default.
8970
+ lockKey,
8971
+ callbacks,
8972
+ runtime,
8973
+ runtimeProps
8974
+ }) {
8975
+ this._storage = storage;
8976
+ this._level = level;
8977
+ this._callbacks = callbacks;
8978
+ this._runtime = runtime;
8979
+ this._runtimeProps = runtimeProps ?? {};
8980
+ if (config) {
8981
+ this.initialize({
8982
+ config,
8983
+ transportFactory,
8984
+ signalManager
8985
+ });
8986
+ }
8987
+ if (lockKey) {
8988
+ this._resourceLock = new locks_exports.Lock({
8989
+ lockKey,
8990
+ onAcquire: () => {
8991
+ if (!this._opening) {
8992
+ void this.open(new Context11(void 0, {
8993
+ F: __dxlog_file29,
8994
+ L: 147
8995
+ }));
8996
+ }
8997
+ },
8998
+ onRelease: () => this.close()
8999
+ });
9000
+ }
9001
+ this._systemService = new SystemServiceImpl({
9002
+ config: () => this._config,
9003
+ statusUpdate: this._statusUpdate,
9004
+ getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9005
+ getDiagnostics: () => {
9006
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9007
+ },
9008
+ onUpdateStatus: async (status) => {
9009
+ if (!this.isOpen && status === SystemStatus.ACTIVE) {
9010
+ await this._resourceLock?.acquire();
9011
+ } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9012
+ await this._resourceLock?.release();
9013
+ }
9014
+ },
9015
+ onReset: async () => {
9016
+ await this.reset();
9017
+ }
9018
+ });
9019
+ this.diagnosticsBroadcastHandler = (0, diagnostics_exports.createCollectDiagnosticsBroadcastHandler)(this._systemService);
9020
+ this._loggingService = new LoggingServiceImpl();
9021
+ this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9022
+ SystemService: this._systemService,
9023
+ TracingService: this._tracingService
9024
+ });
9025
+ }
9493
9026
  get isOpen() {
9494
9027
  return this._open;
9495
9028
  }
@@ -9509,30 +9042,57 @@ var ClientServicesHost = class {
9509
9042
  return this._serviceRegistry.services;
9510
9043
  }
9511
9044
  /**
9045
+ * Debugging util.
9046
+ */
9047
+ async exportSqliteDatabase() {
9048
+ return await RuntimeProvider.runPromise(this._runtime)(Effect.gen(function* () {
9049
+ const sql = yield* SqlExport.SqlExport;
9050
+ return yield* sql.export;
9051
+ }));
9052
+ }
9053
+ /**
9054
+ * Debugging util.
9055
+ */
9056
+ async runSqliteQuery(query, params) {
9057
+ return await RuntimeProvider.runPromise(this._runtime)(Effect.gen(function* () {
9058
+ const sql = yield* SqlClient.SqlClient;
9059
+ return yield* sql`${sql.unsafe(query, params)}`;
9060
+ }));
9061
+ }
9062
+ /**
9512
9063
  * Initialize the service host with the config.
9513
9064
  * Config can also be provided in the constructor.
9514
9065
  * Can only be called once.
9515
9066
  */
9516
9067
  initialize({ config, ...options }) {
9517
- invariant26(!this._open, "service host is open", {
9518
- F: __dxlog_file31,
9519
- L: 209,
9068
+ invariant24(!this._open, "service host is open", {
9069
+ F: __dxlog_file29,
9070
+ L: 237,
9520
9071
  S: this,
9521
9072
  A: [
9522
9073
  "!this._open",
9523
9074
  "'service host is open'"
9524
9075
  ]
9525
9076
  });
9526
- log27("initializing...", void 0, {
9527
- F: __dxlog_file31,
9528
- L: 210,
9077
+ log25("initializing...", void 0, {
9078
+ F: __dxlog_file29,
9079
+ L: 238,
9529
9080
  S: this,
9530
9081
  C: (f, a) => f(...a)
9531
9082
  });
9532
9083
  if (config) {
9533
- invariant26(!this._config, "config already set", {
9534
- F: __dxlog_file31,
9535
- L: 213,
9084
+ if (this._runtimeProps.disableP2pReplication === void 0) {
9085
+ this._runtimeProps.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9086
+ }
9087
+ if (this._runtimeProps.enableVectorIndexing === void 0) {
9088
+ this._runtimeProps.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9089
+ }
9090
+ if (this._runtimeProps.enableLocalQueues === void 0) {
9091
+ this._runtimeProps.enableLocalQueues = config?.get("runtime.client.enableLocalQueues", false);
9092
+ }
9093
+ invariant24(!this._config, "config already set", {
9094
+ F: __dxlog_file29,
9095
+ L: 251,
9536
9096
  S: this,
9537
9097
  A: [
9538
9098
  "!this._config",
@@ -9559,9 +9119,9 @@ var ClientServicesHost = class {
9559
9119
  edgeConnection: this._edgeConnection
9560
9120
  }) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
9561
9121
  this._signalManager = signalManager;
9562
- invariant26(!this._networkManager, "network manager already set", {
9563
- F: __dxlog_file31,
9564
- L: 244,
9122
+ invariant24(!this._networkManager, "network manager already set", {
9123
+ F: __dxlog_file29,
9124
+ L: 282,
9565
9125
  S: this,
9566
9126
  A: [
9567
9127
  "!this._networkManager",
@@ -9577,9 +9137,9 @@ var ClientServicesHost = class {
9577
9137
  peerKey: this._edgeConnection.peerKey
9578
9138
  } : void 0
9579
9139
  });
9580
- log27("initialized", void 0, {
9581
- F: __dxlog_file31,
9582
- L: 257,
9140
+ log25("initialized", void 0, {
9141
+ F: __dxlog_file29,
9142
+ L: 295,
9583
9143
  S: this,
9584
9144
  C: (f, a) => f(...a)
9585
9145
  });
@@ -9589,44 +9149,44 @@ var ClientServicesHost = class {
9589
9149
  return;
9590
9150
  }
9591
9151
  const traceId = PublicKey19.random().toHex();
9592
- log27.trace("dxos.client-services.host.open", trace11.begin({
9152
+ log25.trace("dxos.client-services.host.open", trace10.begin({
9593
9153
  id: traceId
9594
9154
  }), {
9595
- F: __dxlog_file31,
9596
- L: 268,
9155
+ F: __dxlog_file29,
9156
+ L: 306,
9597
9157
  S: this,
9598
9158
  C: (f, a) => f(...a)
9599
9159
  });
9600
- invariant26(this._config, "config not set", {
9601
- F: __dxlog_file31,
9602
- L: 270,
9160
+ invariant24(this._config, "config not set", {
9161
+ F: __dxlog_file29,
9162
+ L: 308,
9603
9163
  S: this,
9604
9164
  A: [
9605
9165
  "this._config",
9606
9166
  "'config not set'"
9607
9167
  ]
9608
9168
  });
9609
- invariant26(this._storage, "storage not set", {
9610
- F: __dxlog_file31,
9611
- L: 271,
9169
+ invariant24(this._storage, "storage not set", {
9170
+ F: __dxlog_file29,
9171
+ L: 309,
9612
9172
  S: this,
9613
9173
  A: [
9614
9174
  "this._storage",
9615
9175
  "'storage not set'"
9616
9176
  ]
9617
9177
  });
9618
- invariant26(this._signalManager, "signal manager not set", {
9619
- F: __dxlog_file31,
9620
- L: 272,
9178
+ invariant24(this._signalManager, "signal manager not set", {
9179
+ F: __dxlog_file29,
9180
+ L: 310,
9621
9181
  S: this,
9622
9182
  A: [
9623
9183
  "this._signalManager",
9624
9184
  "'signal manager not set'"
9625
9185
  ]
9626
9186
  });
9627
- invariant26(this._networkManager, "network manager not set", {
9628
- F: __dxlog_file31,
9629
- L: 273,
9187
+ invariant24(this._networkManager, "network manager not set", {
9188
+ F: __dxlog_file29,
9189
+ L: 311,
9630
9190
  S: this,
9631
9191
  A: [
9632
9192
  "this._networkManager",
@@ -9634,11 +9194,11 @@ var ClientServicesHost = class {
9634
9194
  ]
9635
9195
  });
9636
9196
  this._opening = true;
9637
- log27("opening...", {
9197
+ log25("opening...", {
9638
9198
  lockKey: this._resourceLock?.lockKey
9639
9199
  }, {
9640
- F: __dxlog_file31,
9641
- L: 276,
9200
+ F: __dxlog_file29,
9201
+ L: 314,
9642
9202
  S: this,
9643
9203
  C: (f, a) => f(...a)
9644
9204
  });
@@ -9648,7 +9208,7 @@ var ClientServicesHost = class {
9648
9208
  }
9649
9209
  await this._level.open();
9650
9210
  await this._loggingService.open();
9651
- this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
9211
+ 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"));
9652
9212
  const dataSpaceManagerProvider = async () => {
9653
9213
  await this._serviceContext.initialized.wait();
9654
9214
  return this._serviceContext.dataSpaceManager;
@@ -9667,6 +9227,7 @@ var ClientServicesHost = class {
9667
9227
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
9668
9228
  DataService: this._serviceContext.echoHost.dataService,
9669
9229
  QueryService: this._serviceContext.echoHost.queryService,
9230
+ QueueService: this._serviceContext.echoHost.queuesService,
9670
9231
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager, this._edgeConnection),
9671
9232
  LoggingService: this._loggingService,
9672
9233
  TracingService: this._tracingService,
@@ -9695,19 +9256,19 @@ var ClientServicesHost = class {
9695
9256
  this._open = true;
9696
9257
  this._statusUpdate.emit();
9697
9258
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
9698
- log27("opened", {
9259
+ log25("opened", {
9699
9260
  deviceKey
9700
9261
  }, {
9701
- F: __dxlog_file31,
9702
- L: 377,
9262
+ F: __dxlog_file29,
9263
+ L: 417,
9703
9264
  S: this,
9704
9265
  C: (f, a) => f(...a)
9705
9266
  });
9706
- log27.trace("dxos.client-services.host.open", trace11.end({
9267
+ log25.trace("dxos.client-services.host.open", trace10.end({
9707
9268
  id: traceId
9708
9269
  }), {
9709
- F: __dxlog_file31,
9710
- L: 378,
9270
+ F: __dxlog_file29,
9271
+ L: 418,
9711
9272
  S: this,
9712
9273
  C: (f, a) => f(...a)
9713
9274
  });
@@ -9717,11 +9278,11 @@ var ClientServicesHost = class {
9717
9278
  return;
9718
9279
  }
9719
9280
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
9720
- log27("closing...", {
9281
+ log25("closing...", {
9721
9282
  deviceKey
9722
9283
  }, {
9723
- F: __dxlog_file31,
9724
- L: 389,
9284
+ F: __dxlog_file29,
9285
+ L: 429,
9725
9286
  S: this,
9726
9287
  C: (f, a) => f(...a)
9727
9288
  });
@@ -9735,46 +9296,58 @@ var ClientServicesHost = class {
9735
9296
  await this._level?.close();
9736
9297
  this._open = false;
9737
9298
  this._statusUpdate.emit();
9738
- log27("closed", {
9299
+ log25("closed", {
9739
9300
  deviceKey
9740
9301
  }, {
9741
- F: __dxlog_file31,
9742
- L: 398,
9302
+ F: __dxlog_file29,
9303
+ L: 438,
9743
9304
  S: this,
9744
9305
  C: (f, a) => f(...a)
9745
9306
  });
9746
9307
  }
9747
9308
  async reset() {
9748
9309
  const traceId = PublicKey19.random().toHex();
9749
- log27.trace("dxos.sdk.client-services-host.reset", trace11.begin({
9310
+ log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
9750
9311
  id: traceId
9751
9312
  }), {
9752
- F: __dxlog_file31,
9753
- L: 403,
9313
+ F: __dxlog_file29,
9314
+ L: 443,
9754
9315
  S: this,
9755
9316
  C: (f, a) => f(...a)
9756
9317
  });
9757
- log27.info("resetting...", void 0, {
9758
- F: __dxlog_file31,
9759
- L: 405,
9318
+ log25.info("resetting...", void 0, {
9319
+ F: __dxlog_file29,
9320
+ L: 445,
9760
9321
  S: this,
9761
9322
  C: (f, a) => f(...a)
9762
9323
  });
9763
9324
  this._resetting = true;
9764
9325
  this._statusUpdate.emit();
9765
9326
  await this._serviceContext?.close();
9327
+ try {
9328
+ await this._level.clear();
9329
+ } catch (err) {
9330
+ log25.warn("failed to clear leveldb during reset", {
9331
+ err
9332
+ }, {
9333
+ F: __dxlog_file29,
9334
+ L: 455,
9335
+ S: this,
9336
+ C: (f, a) => f(...a)
9337
+ });
9338
+ }
9766
9339
  await this._storage.reset();
9767
- log27.info("reset", void 0, {
9768
- F: __dxlog_file31,
9769
- L: 412,
9340
+ log25.info("reset", void 0, {
9341
+ F: __dxlog_file29,
9342
+ L: 458,
9770
9343
  S: this,
9771
9344
  C: (f, a) => f(...a)
9772
9345
  });
9773
- log27.trace("dxos.sdk.client-services-host.reset", trace11.end({
9346
+ log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
9774
9347
  id: traceId
9775
9348
  }), {
9776
- F: __dxlog_file31,
9777
- L: 413,
9349
+ F: __dxlog_file29,
9350
+ L: 459,
9778
9351
  S: this,
9779
9352
  C: (f, a) => f(...a)
9780
9353
  });
@@ -9785,113 +9358,25 @@ var ClientServicesHost = class {
9785
9358
  await this._serviceContext.initialized.wait();
9786
9359
  return identity;
9787
9360
  }
9788
- constructor({
9789
- config,
9790
- transportFactory,
9791
- signalManager,
9792
- storage,
9793
- level,
9794
- // TODO(wittjosiah): Turn this on by default.
9795
- lockKey,
9796
- callbacks,
9797
- runtimeParams
9798
- } = {}) {
9799
- _define_property36(this, "_resourceLock", void 0);
9800
- _define_property36(this, "_serviceRegistry", void 0);
9801
- _define_property36(this, "_systemService", void 0);
9802
- _define_property36(this, "_loggingService", void 0);
9803
- _define_property36(this, "_tracingService", TRACE_PROCESSOR3.createTraceSender());
9804
- _define_property36(this, "_statusUpdate", new Event11());
9805
- _define_property36(this, "_config", void 0);
9806
- _define_property36(this, "_signalManager", void 0);
9807
- _define_property36(this, "_networkManager", void 0);
9808
- _define_property36(this, "_storage", void 0);
9809
- _define_property36(this, "_level", void 0);
9810
- _define_property36(this, "_callbacks", void 0);
9811
- _define_property36(this, "_devtoolsProxy", void 0);
9812
- _define_property36(this, "_edgeConnection", void 0);
9813
- _define_property36(this, "_edgeHttpClient", void 0);
9814
- _define_property36(this, "_serviceContext", void 0);
9815
- _define_property36(this, "_runtimeParams", void 0);
9816
- _define_property36(this, "diagnosticsBroadcastHandler", void 0);
9817
- _define_property36(this, "_opening", false);
9818
- _define_property36(this, "_open", false);
9819
- _define_property36(this, "_resetting", false);
9820
- this._storage = storage;
9821
- this._level = level;
9822
- this._callbacks = callbacks;
9823
- this._runtimeParams = runtimeParams ?? {};
9824
- if (this._runtimeParams.disableP2pReplication === void 0) {
9825
- this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9826
- }
9827
- if (this._runtimeParams.enableVectorIndexing === void 0) {
9828
- this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9829
- }
9830
- if (config) {
9831
- this.initialize({
9832
- config,
9833
- transportFactory,
9834
- signalManager
9835
- });
9836
- }
9837
- if (lockKey) {
9838
- this._resourceLock = new Lock({
9839
- lockKey,
9840
- onAcquire: () => {
9841
- if (!this._opening) {
9842
- void this.open(new Context11(void 0, {
9843
- F: __dxlog_file31,
9844
- L: 143
9845
- }));
9846
- }
9847
- },
9848
- onRelease: () => this.close()
9849
- });
9850
- }
9851
- this._systemService = new SystemServiceImpl({
9852
- config: () => this._config,
9853
- statusUpdate: this._statusUpdate,
9854
- getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9855
- getDiagnostics: () => {
9856
- return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9857
- },
9858
- onUpdateStatus: async (status) => {
9859
- if (!this.isOpen && status === SystemStatus.ACTIVE) {
9860
- await this._resourceLock?.acquire();
9861
- } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9862
- await this._resourceLock?.release();
9863
- }
9864
- },
9865
- onReset: async () => {
9866
- await this.reset();
9867
- }
9868
- });
9869
- this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9870
- this._loggingService = new LoggingServiceImpl();
9871
- this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9872
- SystemService: this._systemService,
9873
- TracingService: this._tracingService
9874
- });
9875
- }
9876
9361
  };
9877
- _ts_decorate11([
9362
+ _ts_decorate9([
9878
9363
  Trace4.info()
9879
9364
  ], ClientServicesHost.prototype, "_opening", void 0);
9880
- _ts_decorate11([
9365
+ _ts_decorate9([
9881
9366
  Trace4.info()
9882
9367
  ], ClientServicesHost.prototype, "_open", void 0);
9883
- _ts_decorate11([
9368
+ _ts_decorate9([
9884
9369
  Trace4.info()
9885
9370
  ], ClientServicesHost.prototype, "_resetting", void 0);
9886
- _ts_decorate11([
9371
+ _ts_decorate9([
9887
9372
  synchronized4,
9888
9373
  Trace4.span()
9889
9374
  ], ClientServicesHost.prototype, "open", null);
9890
- _ts_decorate11([
9375
+ _ts_decorate9([
9891
9376
  synchronized4,
9892
9377
  Trace4.span()
9893
9378
  ], ClientServicesHost.prototype, "close", null);
9894
- ClientServicesHost = _ts_decorate11([
9379
+ ClientServicesHost = _ts_decorate9([
9895
9380
  Trace4.resource()
9896
9381
  ], ClientServicesHost);
9897
9382
 
@@ -9907,9 +9392,8 @@ export {
9907
9392
  DevtoolsHostEvents,
9908
9393
  DevtoolsServiceImpl,
9909
9394
  createDiagnostics,
9910
- createCollectDiagnosticsBroadcastSender,
9911
- createCollectDiagnosticsBroadcastHandler,
9912
9395
  DiagnosticsCollector,
9396
+ diagnostics_exports,
9913
9397
  createAuthProvider,
9914
9398
  TrustedKeySetAuthVerifier,
9915
9399
  EdgeFeedReplicator,
@@ -9925,19 +9409,13 @@ export {
9925
9409
  InvitationsServiceImpl,
9926
9410
  SpaceInvitationProtocol,
9927
9411
  InvitationsManager,
9928
- Lock,
9929
- isLocked,
9930
- ClientRpcServer,
9412
+ locks_exports,
9931
9413
  EdgeAgentManager,
9932
9414
  EdgeAgentServiceImpl,
9933
9415
  ServiceContext,
9934
9416
  createStorageObjects,
9935
9417
  createLevel,
9936
- encodeProfileArchive,
9937
- decodeProfileArchive,
9938
- exportProfileData,
9939
- importProfileData,
9940
9418
  ServiceRegistry,
9941
9419
  ClientServicesHost
9942
9420
  };
9943
- //# sourceMappingURL=chunk-MDSLKO5V.mjs.map
9421
+ //# sourceMappingURL=chunk-2ZEVKBWH.mjs.map