@dxos/client-services 0.1.56-main.bf228a7 → 0.1.56-main.c19b7cd

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 (69) hide show
  1. package/dist/lib/browser/{chunk-FD4L7N4K.mjs → chunk-ZOTHWLK5.mjs} +623 -335
  2. package/dist/lib/browser/chunk-ZOTHWLK5.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +23 -19
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +2 -2
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +752 -461
  9. package/dist/lib/node/index.cjs.map +4 -4
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +1016 -729
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  16. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  17. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  18. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  21. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  22. package/dist/types/src/packlets/services/index.d.ts +1 -0
  23. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  24. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  25. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  26. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  27. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  28. package/dist/types/src/packlets/services/service-host.d.ts +7 -3
  29. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/util.d.ts +6 -0
  31. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  32. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  33. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  34. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  35. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  36. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  37. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  38. package/dist/types/src/version.d.ts +2 -0
  39. package/dist/types/src/version.d.ts.map +1 -0
  40. package/package.json +34 -33
  41. package/src/packlets/devices/devices-service.test.ts +2 -1
  42. package/src/packlets/identity/identity-manager.test.ts +4 -3
  43. package/src/packlets/identity/identity-manager.ts +9 -5
  44. package/src/packlets/identity/identity-service.test.ts +2 -1
  45. package/src/packlets/identity/identity.test.ts +7 -6
  46. package/src/packlets/identity/identity.ts +8 -3
  47. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  48. package/src/packlets/logging/logging-service.ts +17 -9
  49. package/src/packlets/network/network-service.test.ts +2 -1
  50. package/src/packlets/services/client-rpc-server.ts +4 -4
  51. package/src/packlets/services/diagnostics.ts +211 -0
  52. package/src/packlets/services/index.ts +1 -0
  53. package/src/packlets/services/platform.ts +48 -0
  54. package/src/packlets/services/service-context.test.ts +59 -0
  55. package/src/packlets/services/service-context.ts +13 -9
  56. package/src/packlets/services/service-host.test.ts +11 -10
  57. package/src/packlets/services/service-host.ts +37 -21
  58. package/src/packlets/services/service-registry.test.ts +3 -1
  59. package/src/packlets/services/util.ts +33 -0
  60. package/src/packlets/spaces/data-space.ts +17 -5
  61. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  62. package/src/packlets/system/system-service.test.ts +1 -0
  63. package/src/packlets/system/system-service.ts +34 -2
  64. package/src/packlets/testing/test-builder.ts +1 -1
  65. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  66. package/src/packlets/vault/worker-runtime.ts +2 -1
  67. package/src/packlets/vault/worker-session.ts +6 -1
  68. package/src/version.ts +1 -0
  69. package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
@@ -45,6 +45,7 @@ __export(src_exports, {
45
45
  WorkerSession: () => WorkerSession,
46
46
  createAuthProvider: () => createAuthProvider,
47
47
  createDefaultModelFactory: () => createDefaultModelFactory,
48
+ createDiagnostics: () => createDiagnostics,
48
49
  createStorageObjects: () => createStorageObjects,
49
50
  getNetworkPeers: () => getNetworkPeers,
50
51
  isLocked: () => isLocked,
@@ -529,8 +530,19 @@ var import_feed_store2 = require("@dxos/feed-store");
529
530
  var import_invariant = require("@dxos/invariant");
530
531
  var import_log2 = require("@dxos/log");
531
532
  var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
533
+ var import_tracing = require("@dxos/tracing");
534
+ function _ts_decorate(decorators, target, key, desc) {
535
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
536
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
537
+ r = Reflect.decorate(decorators, target, key, desc);
538
+ else
539
+ for (var i = decorators.length - 1; i >= 0; i--)
540
+ if (d = decorators[i])
541
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
542
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
543
+ }
532
544
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
533
- var Identity = class {
545
+ var Identity = class Identity2 {
534
546
  constructor({ space, signer, identityKey, deviceKey }) {
535
547
  this.stateUpdate = new import_async5.Event();
536
548
  this.space = space;
@@ -556,12 +568,12 @@ var Identity = class {
556
568
  get authorizedDeviceKeys() {
557
569
  return this._deviceStateMachine.authorizedDeviceKeys;
558
570
  }
559
- async open() {
571
+ async open(ctx) {
560
572
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
561
573
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
562
- await this.space.open();
574
+ await this.space.open(ctx);
563
575
  }
564
- async close() {
576
+ async close(ctx) {
565
577
  await this.authVerifier.close();
566
578
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
567
579
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
@@ -606,7 +618,7 @@ var Identity = class {
606
618
  getIdentityCredentialSigner() {
607
619
  (0, import_invariant.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
608
620
  F: __dxlog_file2,
609
- L: 134,
621
+ L: 139,
610
622
  S: this,
611
623
  A: [
612
624
  "this._deviceStateMachine.deviceCredentialChain",
@@ -630,7 +642,7 @@ var Identity = class {
630
642
  dataFeedKey
631
643
  }, {
632
644
  F: __dxlog_file2,
633
- L: 150,
645
+ L: 155,
634
646
  S: this,
635
647
  C: (f, a) => f(...a)
636
648
  });
@@ -671,18 +683,39 @@ var Identity = class {
671
683
  })));
672
684
  }
673
685
  };
686
+ _ts_decorate([
687
+ import_tracing.trace.span()
688
+ ], Identity.prototype, "open", null);
689
+ _ts_decorate([
690
+ import_tracing.trace.span()
691
+ ], Identity.prototype, "close", null);
692
+ Identity = _ts_decorate([
693
+ import_tracing.trace.resource()
694
+ ], Identity);
674
695
 
675
696
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
676
697
  var import_async6 = require("@dxos/async");
698
+ var import_context3 = require("@dxos/context");
677
699
  var import_credentials4 = require("@dxos/credentials");
678
700
  var import_invariant2 = require("@dxos/invariant");
679
701
  var import_keys4 = require("@dxos/keys");
680
702
  var import_log3 = require("@dxos/log");
681
703
  var import_protocols2 = require("@dxos/protocols");
682
704
  var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
705
+ var import_tracing2 = require("@dxos/tracing");
683
706
  var import_util2 = require("@dxos/util");
707
+ function _ts_decorate2(decorators, target, key, desc) {
708
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
709
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
710
+ r = Reflect.decorate(decorators, target, key, desc);
711
+ else
712
+ for (var i = decorators.length - 1; i >= 0; i--)
713
+ if (d = decorators[i])
714
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
715
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
716
+ }
684
717
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
685
- var IdentityManager = class {
718
+ var IdentityManager = class IdentityManager2 {
686
719
  // TODO(burdon): IdentityManagerParams.
687
720
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
688
721
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -695,14 +728,14 @@ var IdentityManager = class {
695
728
  get identity() {
696
729
  return this._identity;
697
730
  }
698
- async open() {
731
+ async open(ctx) {
699
732
  var _a;
700
733
  const traceId = import_keys4.PublicKey.random().toHex();
701
734
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
702
735
  id: traceId
703
736
  }), {
704
737
  F: __dxlog_file3,
705
- L: 69,
738
+ L: 73,
706
739
  S: this,
707
740
  C: (f, a) => f(...a)
708
741
  });
@@ -712,20 +745,20 @@ var IdentityManager = class {
712
745
  identityRecord
713
746
  }, {
714
747
  F: __dxlog_file3,
715
- L: 73,
748
+ L: 77,
716
749
  S: this,
717
750
  C: (f, a) => f(...a)
718
751
  });
719
752
  if (identityRecord) {
720
753
  this._identity = await this._constructIdentity(identityRecord);
721
- await this._identity.open();
754
+ await this._identity.open(ctx);
722
755
  await this._identity.ready();
723
756
  import_log3.log.trace("dxos.halo.identity", {
724
757
  identityKey: identityRecord.identityKey,
725
758
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
726
759
  }, {
727
760
  F: __dxlog_file3,
728
- L: 78,
761
+ L: 82,
729
762
  S: this,
730
763
  C: (f, a) => f(...a)
731
764
  });
@@ -735,20 +768,20 @@ var IdentityManager = class {
735
768
  id: traceId
736
769
  }), {
737
770
  F: __dxlog_file3,
738
- L: 84,
771
+ L: 88,
739
772
  S: this,
740
773
  C: (f, a) => f(...a)
741
774
  });
742
775
  }
743
776
  async close() {
744
777
  var _a;
745
- await ((_a = this._identity) == null ? void 0 : _a.close());
778
+ await ((_a = this._identity) == null ? void 0 : _a.close(new import_context3.Context()));
746
779
  }
747
780
  async createIdentity({ displayName } = {}) {
748
781
  var _a;
749
782
  (0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
750
783
  F: __dxlog_file3,
751
- L: 92,
784
+ L: 96,
752
785
  S: this,
753
786
  A: [
754
787
  "!this._identity",
@@ -757,7 +790,7 @@ var IdentityManager = class {
757
790
  });
758
791
  (0, import_log3.log)("creating identity...", void 0, {
759
792
  F: __dxlog_file3,
760
- L: 93,
793
+ L: 97,
761
794
  S: this,
762
795
  C: (f, a) => f(...a)
763
796
  });
@@ -773,12 +806,12 @@ var IdentityManager = class {
773
806
  }
774
807
  };
775
808
  const identity = await this._constructIdentity(identityRecord);
776
- await identity.open();
809
+ await identity.open(new import_context3.Context());
777
810
  {
778
811
  const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
779
812
  (0, import_invariant2.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
780
813
  F: __dxlog_file3,
781
- L: 112,
814
+ L: 116,
782
815
  S: this,
783
816
  A: [
784
817
  "identityRecord.haloSpace.genesisFeedKey",
@@ -787,7 +820,7 @@ var IdentityManager = class {
787
820
  });
788
821
  (0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
789
822
  F: __dxlog_file3,
790
- L: 113,
823
+ L: 117,
791
824
  S: this,
792
825
  A: [
793
826
  "identityRecord.haloSpace.dataFeedKey",
@@ -822,7 +855,7 @@ var IdentityManager = class {
822
855
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
823
856
  }, {
824
857
  F: __dxlog_file3,
825
- L: 148,
858
+ L: 152,
826
859
  S: this,
827
860
  C: (f, a) => f(...a)
828
861
  });
@@ -832,7 +865,7 @@ var IdentityManager = class {
832
865
  deviceKey: identity.deviceKey
833
866
  }, {
834
867
  F: __dxlog_file3,
835
- L: 154,
868
+ L: 158,
836
869
  S: this,
837
870
  C: (f, a) => f(...a)
838
871
  });
@@ -847,13 +880,13 @@ var IdentityManager = class {
847
880
  params
848
881
  }, {
849
882
  F: __dxlog_file3,
850
- L: 162,
883
+ L: 166,
851
884
  S: this,
852
885
  C: (f, a) => f(...a)
853
886
  });
854
887
  (0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
855
888
  F: __dxlog_file3,
856
- L: 163,
889
+ L: 167,
857
890
  S: this,
858
891
  A: [
859
892
  "!this._identity",
@@ -872,7 +905,7 @@ var IdentityManager = class {
872
905
  }
873
906
  };
874
907
  const identity = await this._constructIdentity(identityRecord);
875
- await identity.open();
908
+ await identity.open(new import_context3.Context());
876
909
  this._identity = identity;
877
910
  await this._metadataStore.setIdentityRecord(identityRecord);
878
911
  await this._identity.ready();
@@ -881,7 +914,7 @@ var IdentityManager = class {
881
914
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
882
915
  }, {
883
916
  F: __dxlog_file3,
884
- L: 182,
917
+ L: 186,
885
918
  S: this,
886
919
  C: (f, a) => f(...a)
887
920
  });
@@ -891,7 +924,7 @@ var IdentityManager = class {
891
924
  deviceKey: identity.deviceKey
892
925
  }, {
893
926
  F: __dxlog_file3,
894
- L: 188,
927
+ L: 192,
895
928
  S: this,
896
929
  C: (f, a) => f(...a)
897
930
  });
@@ -900,7 +933,7 @@ var IdentityManager = class {
900
933
  async _constructIdentity(identityRecord) {
901
934
  (0, import_invariant2.invariant)(!this._identity, void 0, {
902
935
  F: __dxlog_file3,
903
- L: 193,
936
+ L: 197,
904
937
  S: this,
905
938
  A: [
906
939
  "!this._identity",
@@ -911,13 +944,13 @@ var IdentityManager = class {
911
944
  identityRecord
912
945
  }, {
913
946
  F: __dxlog_file3,
914
- L: 194,
947
+ L: 198,
915
948
  S: this,
916
949
  C: (f, a) => f(...a)
917
950
  });
918
951
  (0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
919
952
  F: __dxlog_file3,
920
- L: 197,
953
+ L: 201,
921
954
  S: this,
922
955
  A: [
923
956
  "identityRecord.haloSpace.controlFeedKey",
@@ -929,7 +962,7 @@ var IdentityManager = class {
929
962
  });
930
963
  (0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
931
964
  F: __dxlog_file3,
932
- L: 201,
965
+ L: 205,
933
966
  S: this,
934
967
  A: [
935
968
  "identityRecord.haloSpace.dataFeedKey",
@@ -961,7 +994,7 @@ var IdentityManager = class {
961
994
  identityKey: identityRecord.identityKey
962
995
  }, {
963
996
  F: __dxlog_file3,
964
- L: 225,
997
+ L: 229,
965
998
  S: this,
966
999
  C: (f, a) => f(...a)
967
1000
  });
@@ -982,7 +1015,7 @@ var IdentityManager = class {
982
1015
  onAuthFailure: () => {
983
1016
  import_log3.log.warn("auth failure", void 0, {
984
1017
  F: __dxlog_file3,
985
- L: 244,
1018
+ L: 248,
986
1019
  S: this,
987
1020
  C: (f, a) => f(...a)
988
1021
  });
@@ -991,6 +1024,12 @@ var IdentityManager = class {
991
1024
  });
992
1025
  }
993
1026
  };
1027
+ _ts_decorate2([
1028
+ import_tracing2.trace.span()
1029
+ ], IdentityManager.prototype, "open", null);
1030
+ IdentityManager = _ts_decorate2([
1031
+ import_tracing2.trace.resource()
1032
+ ], IdentityManager);
994
1033
 
995
1034
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
996
1035
  var import_codec_protobuf7 = require("@dxos/codec-protobuf");
@@ -1142,7 +1181,7 @@ var DeviceInvitationProtocol = class {
1142
1181
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1143
1182
  var import_async8 = require("@dxos/async");
1144
1183
  var import_client_protocol2 = require("@dxos/client-protocol");
1145
- var import_context4 = require("@dxos/context");
1184
+ var import_context5 = require("@dxos/context");
1146
1185
  var import_credentials7 = require("@dxos/credentials");
1147
1186
  var import_errors2 = require("@dxos/errors");
1148
1187
  var import_invariant6 = require("@dxos/invariant");
@@ -1155,7 +1194,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
1155
1194
 
1156
1195
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1157
1196
  var import_async7 = require("@dxos/async");
1158
- var import_context3 = require("@dxos/context");
1197
+ var import_context4 = require("@dxos/context");
1159
1198
  var import_errors = require("@dxos/errors");
1160
1199
  var import_invariant5 = require("@dxos/invariant");
1161
1200
  var import_keys5 = require("@dxos/keys");
@@ -1178,7 +1217,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1178
1217
  }
1179
1218
  });
1180
1219
  this._callbacks = _callbacks;
1181
- this._ctx = new import_context3.Context();
1220
+ this._ctx = new import_context4.Context();
1182
1221
  this._remoteOptionsTrigger = new import_async7.Trigger();
1183
1222
  this.invitation = void 0;
1184
1223
  this.guestProfile = void 0;
@@ -1385,7 +1424,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1385
1424
  await this.rpc.InvitationHostService.options({
1386
1425
  role: import_invitations.Options.Role.HOST
1387
1426
  });
1388
- await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1427
+ await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1389
1428
  timeout: OPTIONS_TIMEOUT
1390
1429
  }));
1391
1430
  if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.GUEST) {
@@ -1414,7 +1453,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1414
1453
  }
1415
1454
  });
1416
1455
  this._callbacks = _callbacks;
1417
- this._ctx = new import_context3.Context();
1456
+ this._ctx = new import_context4.Context();
1418
1457
  this._remoteOptionsTrigger = new import_async7.Trigger();
1419
1458
  }
1420
1459
  async getHandlers() {
@@ -1455,10 +1494,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1455
1494
  S: this,
1456
1495
  C: (f, a) => f(...a)
1457
1496
  });
1458
- await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1497
+ await (0, import_context4.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1459
1498
  role: import_invitations.Options.Role.GUEST
1460
1499
  }));
1461
- await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1500
+ await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1462
1501
  timeout: OPTIONS_TIMEOUT
1463
1502
  }));
1464
1503
  (0, import_log4.log)("end options", void 0, {
@@ -1529,7 +1568,7 @@ var InvitationsHandler = class {
1529
1568
  ...protocol.getInvitationContext()
1530
1569
  };
1531
1570
  const stream = new import_async8.PushStream();
1532
- const ctx = new import_context4.Context({
1571
+ const ctx = new import_context5.Context({
1533
1572
  onError: (err) => {
1534
1573
  void ctx.dispose();
1535
1574
  stream.error(err);
@@ -1760,7 +1799,7 @@ var InvitationsHandler = class {
1760
1799
  ...newData
1761
1800
  });
1762
1801
  };
1763
- const ctx = new import_context4.Context({
1802
+ const ctx = new import_context5.Context({
1764
1803
  onError: (err) => {
1765
1804
  if (err instanceof import_async8.TimeoutError) {
1766
1805
  (0, import_log5.log)("timeout", {
@@ -2443,63 +2482,231 @@ var ClientRpcServer = class {
2443
2482
  }
2444
2483
  };
2445
2484
 
2485
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2486
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2487
+ var import_credentials9 = require("@dxos/credentials");
2488
+ var import_document_model = require("@dxos/document-model");
2489
+ var import_invariant9 = require("@dxos/invariant");
2490
+ var import_log8 = require("@dxos/log");
2491
+ var import_protocols5 = require("@dxos/protocols");
2492
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2493
+
2494
+ // packages/sdk/client-services/src/version.ts
2495
+ var DXOS_VERSION = "0.1.56-main.c19b7cd";
2496
+
2497
+ // packages/sdk/client-services/src/packlets/services/platform.ts
2498
+ var getPlatform = () => {
2499
+ if (process.browser) {
2500
+ if (typeof window !== "undefined") {
2501
+ const { userAgent } = window.navigator;
2502
+ return {
2503
+ type: "browser",
2504
+ userAgent,
2505
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2506
+ };
2507
+ } else {
2508
+ return {
2509
+ type: "shared-worker",
2510
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2511
+ };
2512
+ }
2513
+ } else {
2514
+ const { platform, version, arch } = process;
2515
+ return {
2516
+ type: "node",
2517
+ platform: `${platform} ${version} ${arch}`,
2518
+ runtime: process.version,
2519
+ uptime: Math.floor(process.uptime()),
2520
+ memory: process.memoryUsage()
2521
+ };
2522
+ }
2523
+ };
2524
+
2525
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2526
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2527
+ var DEFAULT_TIMEOUT = 1e3;
2528
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
2529
+ var _a, _b, _c;
2530
+ const diagnostics = {
2531
+ created: new Date().toISOString(),
2532
+ platform: getPlatform(),
2533
+ client: {
2534
+ version: DXOS_VERSION,
2535
+ storage: {
2536
+ version: import_protocols5.STORAGE_VERSION
2537
+ }
2538
+ }
2539
+ };
2540
+ {
2541
+ (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2542
+ F: __dxlog_file10,
2543
+ L: 87,
2544
+ S: void 0,
2545
+ A: [
2546
+ "clientServices.LoggingService",
2547
+ "'SystemService is not available.'"
2548
+ ]
2549
+ });
2550
+ diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
2551
+ timeout: DEFAULT_TIMEOUT
2552
+ }).catch(() => void 0);
2553
+ }
2554
+ const identity = serviceContext.identityManager.identity;
2555
+ if (identity) {
2556
+ diagnostics.identity = {
2557
+ identityKey: identity.identityKey,
2558
+ spaceKey: identity.space.key,
2559
+ profile: identity.profileDocument
2560
+ };
2561
+ const { devices } = (_a = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2562
+ timeout: DEFAULT_TIMEOUT
2563
+ }).catch(() => void 0)) != null ? _a : {};
2564
+ diagnostics.devices = devices;
2565
+ if (serviceContext.dataSpaceManager) {
2566
+ diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
2567
+ }
2568
+ const { feeds = [] } = (_c = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2569
+ timeout: DEFAULT_TIMEOUT
2570
+ }).catch(() => void 0)) != null ? _c : {};
2571
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2572
+ feedKey,
2573
+ bytes,
2574
+ length
2575
+ }));
2576
+ }
2577
+ diagnostics.config = config.values;
2578
+ return diagnostics;
2579
+ };
2580
+ var getProperties = (space) => {
2581
+ let properties = {};
2582
+ try {
2583
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
2584
+ var _a, _b;
2585
+ return ((_a = item.modelMeta) == null ? void 0 : _a.type) === import_document_model.DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
2586
+ });
2587
+ const state = propertiesItem == null ? void 0 : propertiesItem.state;
2588
+ properties = state == null ? void 0 : state.data;
2589
+ } catch (err) {
2590
+ import_log8.log.warn(err.message, void 0, {
2591
+ F: __dxlog_file10,
2592
+ L: 144,
2593
+ S: void 0,
2594
+ C: (f, a) => f(...a)
2595
+ });
2596
+ }
2597
+ return properties;
2598
+ };
2599
+ var getSpaceStats = async (space) => {
2600
+ var _a, _b, _c, _d, _e, _f;
2601
+ const stats = {
2602
+ key: space.key,
2603
+ metrics: space.metrics,
2604
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
2605
+ ...credential.subject.assertion,
2606
+ id: credential.id
2607
+ })),
2608
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2609
+ var _a2;
2610
+ return {
2611
+ identity: {
2612
+ identityKey: member.key,
2613
+ profile: {
2614
+ displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
2615
+ }
2616
+ },
2617
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
2618
+ };
2619
+ }),
2620
+ pipeline: {
2621
+ // TODO(burdon): Pick properties from credentials if needed.
2622
+ // currentEpoch: space.dataPipeline.currentEpoch,
2623
+ // appliedEpoch: space.dataPipeline.appliedEpoch,
2624
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2625
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2626
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2627
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
2628
+ // TODO(burdon): Empty?
2629
+ dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
2630
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
2631
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
2632
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
2633
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
2634
+ }
2635
+ };
2636
+ if (space.dataPipeline.itemManager) {
2637
+ Object.assign(stats, {
2638
+ properties: getProperties(space),
2639
+ db: {
2640
+ objects: space.dataPipeline.itemManager.entities.size
2641
+ }
2642
+ });
2643
+ }
2644
+ if (stats.metrics) {
2645
+ const { open, ready } = stats.metrics;
2646
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2647
+ }
2648
+ return stats;
2649
+ };
2650
+
2446
2651
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2447
2652
  var import_async14 = require("@dxos/async");
2448
- var import_credentials13 = require("@dxos/credentials");
2653
+ var import_context9 = require("@dxos/context");
2654
+ var import_credentials14 = require("@dxos/credentials");
2449
2655
  var import_debug7 = require("@dxos/debug");
2450
2656
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
2451
2657
  var import_feed_store4 = require("@dxos/feed-store");
2452
- var import_invariant11 = require("@dxos/invariant");
2658
+ var import_invariant12 = require("@dxos/invariant");
2453
2659
  var import_keyring = require("@dxos/keyring");
2454
2660
  var import_keys10 = require("@dxos/keys");
2455
- var import_log12 = require("@dxos/log");
2456
- var import_protocols8 = require("@dxos/protocols");
2457
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2661
+ var import_log13 = require("@dxos/log");
2662
+ var import_protocols9 = require("@dxos/protocols");
2663
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
2458
2664
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2665
+ var import_tracing3 = require("@dxos/tracing");
2459
2666
 
2460
2667
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2461
2668
  var import_async12 = require("@dxos/async");
2462
- var import_context7 = require("@dxos/context");
2463
- var import_credentials12 = require("@dxos/credentials");
2464
- var import_invariant10 = require("@dxos/invariant");
2669
+ var import_context8 = require("@dxos/context");
2670
+ var import_credentials13 = require("@dxos/credentials");
2671
+ var import_invariant11 = require("@dxos/invariant");
2465
2672
  var import_keys9 = require("@dxos/keys");
2466
- var import_log10 = require("@dxos/log");
2467
- var import_protocols6 = require("@dxos/protocols");
2468
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2673
+ var import_log11 = require("@dxos/log");
2674
+ var import_protocols7 = require("@dxos/protocols");
2675
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2469
2676
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2470
2677
  var import_util5 = require("@dxos/util");
2471
2678
 
2472
2679
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2473
2680
  var import_async11 = require("@dxos/async");
2474
2681
  var import_client_protocol3 = require("@dxos/client-protocol");
2475
- var import_context6 = require("@dxos/context");
2682
+ var import_context7 = require("@dxos/context");
2476
2683
  var import_debug4 = require("@dxos/debug");
2477
2684
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2478
2685
  var import_errors3 = require("@dxos/errors");
2479
2686
  var import_keys8 = require("@dxos/keys");
2480
- var import_log9 = require("@dxos/log");
2481
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2482
- var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
2687
+ var import_log10 = require("@dxos/log");
2688
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2689
+ var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2483
2690
  var import_timeframe = require("@dxos/timeframe");
2484
2691
  var import_util4 = require("@dxos/util");
2485
2692
 
2486
2693
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2487
2694
  var import_async10 = require("@dxos/async");
2488
- var import_context5 = require("@dxos/context");
2489
- var import_invariant9 = require("@dxos/invariant");
2695
+ var import_context6 = require("@dxos/context");
2696
+ var import_invariant10 = require("@dxos/invariant");
2490
2697
  var import_keys7 = require("@dxos/keys");
2491
- var import_log8 = require("@dxos/log");
2492
- var import_protocols5 = require("@dxos/protocols");
2698
+ var import_log9 = require("@dxos/log");
2699
+ var import_protocols6 = require("@dxos/protocols");
2493
2700
  var import_teleport2 = require("@dxos/teleport");
2494
2701
  var import_util3 = require("@dxos/util");
2495
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2702
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2496
2703
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2497
2704
  var DEFAULT_SUCCESS_DELAY = 1e3;
2498
2705
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2499
2706
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2500
2707
  var NotarizationPlugin = class {
2501
2708
  constructor() {
2502
- this._ctx = new import_context5.Context();
2709
+ this._ctx = new import_context6.Context();
2503
2710
  this._extensionOpened = new import_async10.Event();
2504
2711
  this._extensions = /* @__PURE__ */ new Set();
2505
2712
  this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
@@ -2517,16 +2724,16 @@ var NotarizationPlugin = class {
2517
2724
  * Request credentials to be notarized.
2518
2725
  */
2519
2726
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2520
- (0, import_log8.log)("notarize", {
2727
+ (0, import_log9.log)("notarize", {
2521
2728
  credentials
2522
2729
  }, {
2523
- F: __dxlog_file10,
2730
+ F: __dxlog_file11,
2524
2731
  L: 90,
2525
2732
  S: this,
2526
2733
  C: (f, a) => f(...a)
2527
2734
  });
2528
- (0, import_invariant9.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2529
- F: __dxlog_file10,
2735
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2736
+ F: __dxlog_file11,
2530
2737
  L: 91,
2531
2738
  S: this,
2532
2739
  A: [
@@ -2537,10 +2744,10 @@ var NotarizationPlugin = class {
2537
2744
  const errors = new import_async10.Trigger();
2538
2745
  const ctx = this._ctx.derive({
2539
2746
  onError: (err) => {
2540
- import_log8.log.warn("Notarization error", {
2747
+ import_log9.log.warn("Notarization error", {
2541
2748
  err
2542
2749
  }, {
2543
- F: __dxlog_file10,
2750
+ F: __dxlog_file11,
2544
2751
  L: 99,
2545
2752
  S: this,
2546
2753
  C: (f, a) => f(...a)
@@ -2552,11 +2759,11 @@ var NotarizationPlugin = class {
2552
2759
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2553
2760
  if (timeout !== 0) {
2554
2761
  (0, import_async10.scheduleTask)(ctx, () => {
2555
- import_log8.log.warn("Notarization timeout", {
2762
+ import_log9.log.warn("Notarization timeout", {
2556
2763
  timeout,
2557
2764
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2558
2765
  }, {
2559
- F: __dxlog_file10,
2766
+ F: __dxlog_file11,
2560
2767
  L: 111,
2561
2768
  S: this,
2562
2769
  C: (f, a) => f(...a)
@@ -2576,10 +2783,10 @@ var NotarizationPlugin = class {
2576
2783
  ...this._extensions
2577
2784
  ].find((peer2) => !peersTried.has(peer2));
2578
2785
  if (!peer) {
2579
- import_log8.log.warn("Exhausted all peers to notarize with", {
2786
+ import_log9.log.warn("Exhausted all peers to notarize with", {
2580
2787
  retryIn: retryTimeout
2581
2788
  }, {
2582
- F: __dxlog_file10,
2789
+ F: __dxlog_file11,
2583
2790
  L: 136,
2584
2791
  S: this,
2585
2792
  C: (f, a) => f(...a)
@@ -2589,11 +2796,11 @@ var NotarizationPlugin = class {
2589
2796
  return;
2590
2797
  }
2591
2798
  peersTried.add(peer);
2592
- (0, import_log8.log)("try notarizing", {
2799
+ (0, import_log9.log)("try notarizing", {
2593
2800
  peer: peer.localPeerId,
2594
2801
  credentialId: credentials.map((credential) => credential.id)
2595
2802
  }, {
2596
- F: __dxlog_file10,
2803
+ F: __dxlog_file11,
2597
2804
  L: 143,
2598
2805
  S: this,
2599
2806
  C: (f, a) => f(...a)
@@ -2601,8 +2808,8 @@ var NotarizationPlugin = class {
2601
2808
  await peer.rpc.NotarizationService.notarize({
2602
2809
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2603
2810
  });
2604
- (0, import_log8.log)("success", void 0, {
2605
- F: __dxlog_file10,
2811
+ (0, import_log9.log)("success", void 0, {
2812
+ F: __dxlog_file11,
2606
2813
  L: 147,
2607
2814
  S: this,
2608
2815
  C: (f, a) => f(...a)
@@ -2610,8 +2817,8 @@ var NotarizationPlugin = class {
2610
2817
  await (0, import_async10.sleep)(successDelay);
2611
2818
  } catch (err) {
2612
2819
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2613
- import_log8.log.warn("error notarizing (recoverable)", err, {
2614
- F: __dxlog_file10,
2820
+ import_log9.log.warn("error notarizing (recoverable)", err, {
2821
+ F: __dxlog_file11,
2615
2822
  L: 151,
2616
2823
  S: this,
2617
2824
  C: (f, a) => f(...a)
@@ -2624,12 +2831,12 @@ var NotarizationPlugin = class {
2624
2831
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
2625
2832
  try {
2626
2833
  await Promise.race([
2627
- (0, import_context5.rejectOnDispose)(ctx),
2834
+ (0, import_context6.rejectOnDispose)(ctx),
2628
2835
  allNotarized,
2629
2836
  errors.wait()
2630
2837
  ]);
2631
- (0, import_log8.log)("done", void 0, {
2632
- F: __dxlog_file10,
2838
+ (0, import_log9.log)("done", void 0, {
2839
+ F: __dxlog_file11,
2633
2840
  L: 162,
2634
2841
  S: this,
2635
2842
  C: (f, a) => f(...a)
@@ -2651,8 +2858,8 @@ var NotarizationPlugin = class {
2651
2858
  this._processCredentialsTriggers.delete(credential.id);
2652
2859
  }
2653
2860
  setWriter(writer) {
2654
- (0, import_invariant9.invariant)(!this._writer, "Writer already set.", {
2655
- F: __dxlog_file10,
2861
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
2862
+ F: __dxlog_file11,
2656
2863
  L: 181,
2657
2864
  S: this,
2658
2865
  A: [
@@ -2677,8 +2884,8 @@ var NotarizationPlugin = class {
2677
2884
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2678
2885
  }
2679
2886
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2680
- (0, import_invariant9.invariant)(credential.id, "Credential must have an id", {
2681
- F: __dxlog_file10,
2887
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
2888
+ F: __dxlog_file11,
2682
2889
  L: 200,
2683
2890
  S: this,
2684
2891
  A: [
@@ -2695,10 +2902,10 @@ var NotarizationPlugin = class {
2695
2902
  createExtension() {
2696
2903
  const extension = new NotarizationTeleportExtension({
2697
2904
  onOpen: async () => {
2698
- (0, import_log8.log)("extension opened", {
2905
+ (0, import_log9.log)("extension opened", {
2699
2906
  peer: extension.localPeerId
2700
2907
  }, {
2701
- F: __dxlog_file10,
2908
+ F: __dxlog_file11,
2702
2909
  L: 211,
2703
2910
  S: this,
2704
2911
  C: (f, a) => f(...a)
@@ -2707,10 +2914,10 @@ var NotarizationPlugin = class {
2707
2914
  this._extensionOpened.emit();
2708
2915
  },
2709
2916
  onClose: async () => {
2710
- (0, import_log8.log)("extension closed", {
2917
+ (0, import_log9.log)("extension closed", {
2711
2918
  peer: extension.localPeerId
2712
2919
  }, {
2713
- F: __dxlog_file10,
2920
+ F: __dxlog_file11,
2714
2921
  L: 216,
2715
2922
  S: this,
2716
2923
  C: (f, a) => f(...a)
@@ -2726,10 +2933,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2726
2933
  constructor(_params) {
2727
2934
  super({
2728
2935
  requested: {
2729
- NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2936
+ NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2730
2937
  },
2731
2938
  exposed: {
2732
- NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2939
+ NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2733
2940
  }
2734
2941
  });
2735
2942
  this._params = _params;
@@ -2754,7 +2961,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2754
2961
  };
2755
2962
 
2756
2963
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2757
- function _ts_decorate(decorators, target, key, desc) {
2964
+ function _ts_decorate3(decorators, target, key, desc) {
2758
2965
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2759
2966
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2760
2967
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2764,12 +2971,13 @@ function _ts_decorate(decorators, target, key, desc) {
2764
2971
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2765
2972
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2766
2973
  }
2767
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2974
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2975
+ var ENABLE_FEED_PURGE = false;
2768
2976
  var DataSpace = class DataSpace2 {
2769
2977
  constructor(params) {
2770
- this._ctx = new import_context6.Context();
2978
+ this._ctx = new import_context7.Context();
2771
2979
  this._notarizationPlugin = new NotarizationPlugin();
2772
- this._state = import_services6.SpaceState.CLOSED;
2980
+ this._state = import_services7.SpaceState.CLOSED;
2773
2981
  /**
2774
2982
  * Error for _state === SpaceState.ERROR.
2775
2983
  */
@@ -2825,8 +3033,8 @@ var DataSpace = class DataSpace2 {
2825
3033
  async _open() {
2826
3034
  await this._notarizationPlugin.open();
2827
3035
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2828
- await this._inner.open();
2829
- this._state = import_services6.SpaceState.CONTROL_ONLY;
3036
+ await this._inner.open(new import_context7.Context());
3037
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
2830
3038
  this.stateUpdate.emit();
2831
3039
  this.metrics = {};
2832
3040
  this.metrics.open = new Date();
@@ -2837,9 +3045,9 @@ var DataSpace = class DataSpace2 {
2837
3045
  async _close() {
2838
3046
  var _a, _b;
2839
3047
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2840
- this._state = import_services6.SpaceState.CLOSED;
3048
+ this._state = import_services7.SpaceState.CLOSED;
2841
3049
  await this._ctx.dispose();
2842
- this._ctx = new import_context6.Context();
3050
+ this._ctx = new import_context7.Context();
2843
3051
  await this.authVerifier.close();
2844
3052
  await this._inner.close();
2845
3053
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -2862,21 +3070,21 @@ var DataSpace = class DataSpace2 {
2862
3070
  await this.initializeDataPipeline();
2863
3071
  } catch (err) {
2864
3072
  if (err instanceof import_errors3.CancelledError) {
2865
- (0, import_log9.log)("data pipeline initialization cancelled", err, {
2866
- F: __dxlog_file11,
2867
- L: 193,
3073
+ (0, import_log10.log)("data pipeline initialization cancelled", err, {
3074
+ F: __dxlog_file12,
3075
+ L: 199,
2868
3076
  S: this,
2869
3077
  C: (f, a) => f(...a)
2870
3078
  });
2871
3079
  return;
2872
3080
  }
2873
- import_log9.log.error("Error initializing data pipeline", err, {
2874
- F: __dxlog_file11,
2875
- L: 197,
3081
+ import_log10.log.error("Error initializing data pipeline", err, {
3082
+ F: __dxlog_file12,
3083
+ L: 203,
2876
3084
  S: this,
2877
3085
  C: (f, a) => f(...a)
2878
3086
  });
2879
- this._state = import_services6.SpaceState.ERROR;
3087
+ this._state = import_services7.SpaceState.ERROR;
2880
3088
  this.error = err;
2881
3089
  this.stateUpdate.emit();
2882
3090
  } finally {
@@ -2886,19 +3094,19 @@ var DataSpace = class DataSpace2 {
2886
3094
  }
2887
3095
  async initializeDataPipeline() {
2888
3096
  var _a, _b, _c, _d;
2889
- if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
3097
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
2890
3098
  throw new import_errors3.SystemError("Invalid operation");
2891
3099
  }
2892
- this._state = import_services6.SpaceState.INITIALIZING;
3100
+ this._state = import_services7.SpaceState.INITIALIZING;
2893
3101
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2894
3102
  ctx: this._ctx,
2895
3103
  breakOnStall: false
2896
3104
  });
2897
3105
  this.metrics.controlPipelineReady = new Date();
2898
3106
  await this._createWritableFeeds();
2899
- (0, import_log9.log)("writable feeds created", void 0, {
2900
- F: __dxlog_file11,
2901
- L: 221,
3107
+ (0, import_log10.log)("writable feeds created", void 0, {
3108
+ F: __dxlog_file12,
3109
+ L: 227,
2902
3110
  S: this,
2903
3111
  C: (f, a) => f(...a)
2904
3112
  });
@@ -2912,10 +3120,10 @@ var DataSpace = class DataSpace2 {
2912
3120
  }
2913
3121
  await this._inner.initializeDataPipeline();
2914
3122
  this.metrics.dataPipelineOpen = new Date();
2915
- await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2916
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
2917
- F: __dxlog_file11,
2918
- L: 242,
3123
+ await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3124
+ (0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
3125
+ F: __dxlog_file12,
3126
+ L: 248,
2919
3127
  S: this,
2920
3128
  C: (f, a) => f(...a)
2921
3129
  });
@@ -2924,14 +3132,14 @@ var DataSpace = class DataSpace2 {
2924
3132
  breakOnStall: false
2925
3133
  });
2926
3134
  this.metrics.dataPipelineReady = new Date();
2927
- (0, import_log9.log)("data pipeline ready", void 0, {
2928
- F: __dxlog_file11,
2929
- L: 251,
3135
+ (0, import_log10.log)("data pipeline ready", void 0, {
3136
+ F: __dxlog_file12,
3137
+ L: 257,
2930
3138
  S: this,
2931
3139
  C: (f, a) => f(...a)
2932
3140
  });
2933
3141
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2934
- this._state = import_services6.SpaceState.READY;
3142
+ this._state = import_services7.SpaceState.READY;
2935
3143
  this.stateUpdate.emit();
2936
3144
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2937
3145
  }
@@ -2949,7 +3157,7 @@ var DataSpace = class DataSpace2 {
2949
3157
  spaceKey: this.key,
2950
3158
  deviceKey: this._signingContext.deviceKey,
2951
3159
  identityKey: this._signingContext.identityKey,
2952
- designation: import_credentials9.AdmittedFeed.Designation.CONTROL
3160
+ designation: import_credentials10.AdmittedFeed.Designation.CONTROL
2953
3161
  }
2954
3162
  }));
2955
3163
  }
@@ -2966,7 +3174,7 @@ var DataSpace = class DataSpace2 {
2966
3174
  spaceKey: this.key,
2967
3175
  deviceKey: this._signingContext.deviceKey,
2968
3176
  identityKey: this._signingContext.identityKey,
2969
- designation: import_credentials9.AdmittedFeed.Designation.DATA
3177
+ designation: import_credentials10.AdmittedFeed.Designation.DATA
2970
3178
  }
2971
3179
  }));
2972
3180
  }
@@ -2999,59 +3207,62 @@ var DataSpace = class DataSpace2 {
2999
3207
  receipt.seq
3000
3208
  ]
3001
3209
  ]));
3002
- for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
3003
- const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3004
- if (indexBeforeEpoch) {
3005
- await feed.clear(0, indexBeforeEpoch + 1);
3210
+ if (ENABLE_FEED_PURGE) {
3211
+ for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
3212
+ const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3213
+ if (indexBeforeEpoch === void 0) {
3214
+ continue;
3215
+ }
3216
+ await feed.safeClear(0, indexBeforeEpoch + 1);
3006
3217
  }
3007
3218
  }
3008
3219
  }
3009
3220
  async activate() {
3010
- if (this._state !== import_services6.SpaceState.INACTIVE) {
3221
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
3011
3222
  return;
3012
3223
  }
3013
- await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
3224
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
3014
3225
  await this._open();
3015
3226
  this.initializeDataPipelineAsync();
3016
3227
  }
3017
3228
  async deactivate() {
3018
- if (this._state === import_services6.SpaceState.INACTIVE) {
3229
+ if (this._state === import_services7.SpaceState.INACTIVE) {
3019
3230
  return;
3020
3231
  }
3021
- await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
3232
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
3022
3233
  await this._close();
3023
- this._state = import_services6.SpaceState.INACTIVE;
3234
+ this._state = import_services7.SpaceState.INACTIVE;
3024
3235
  this.stateUpdate.emit();
3025
3236
  }
3026
3237
  };
3027
- _ts_decorate([
3238
+ _ts_decorate3([
3028
3239
  import_async11.synchronized
3029
3240
  ], DataSpace.prototype, "open", null);
3030
- _ts_decorate([
3241
+ _ts_decorate3([
3031
3242
  import_async11.synchronized
3032
3243
  ], DataSpace.prototype, "close", null);
3033
- _ts_decorate([
3244
+ _ts_decorate3([
3034
3245
  (0, import_debug4.timed)(1e4)
3035
3246
  ], DataSpace.prototype, "_createWritableFeeds", null);
3036
- _ts_decorate([
3247
+ _ts_decorate3([
3037
3248
  import_async11.synchronized
3038
3249
  ], DataSpace.prototype, "activate", null);
3039
- _ts_decorate([
3250
+ _ts_decorate3([
3040
3251
  import_async11.synchronized
3041
3252
  ], DataSpace.prototype, "deactivate", null);
3042
- DataSpace = _ts_decorate([
3253
+ DataSpace = _ts_decorate3([
3043
3254
  (0, import_async11.trackLeaks)("open", "close")
3044
3255
  ], DataSpace);
3045
3256
 
3046
3257
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
3047
- var import_credentials10 = require("@dxos/credentials");
3258
+ var import_credentials11 = require("@dxos/credentials");
3048
3259
  var import_debug5 = require("@dxos/debug");
3049
- var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
3260
+ var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
3050
3261
  var import_timeframe2 = require("@dxos/timeframe");
3051
3262
  var spaceGenesis = async (keyring, signingContext, space) => {
3052
3263
  var _a, _b, _c, _d;
3053
3264
  const credentials = [
3054
- await (0, import_credentials10.createCredential)({
3265
+ await (0, import_credentials11.createCredential)({
3055
3266
  signer: keyring,
3056
3267
  issuer: space.key,
3057
3268
  subject: space.key,
@@ -3060,14 +3271,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3060
3271
  spaceKey: space.key
3061
3272
  }
3062
3273
  }),
3063
- await (0, import_credentials10.createCredential)({
3274
+ await (0, import_credentials11.createCredential)({
3064
3275
  signer: keyring,
3065
3276
  issuer: space.key,
3066
3277
  subject: signingContext.identityKey,
3067
3278
  assertion: {
3068
3279
  "@type": "dxos.halo.credentials.SpaceMember",
3069
3280
  spaceKey: space.key,
3070
- role: import_credentials11.SpaceMember.Role.ADMIN,
3281
+ role: import_credentials12.SpaceMember.Role.ADMIN,
3071
3282
  profile: signingContext.profile,
3072
3283
  genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
3073
3284
  }
@@ -3079,7 +3290,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3079
3290
  spaceKey: space.key,
3080
3291
  identityKey: signingContext.identityKey,
3081
3292
  deviceKey: signingContext.deviceKey,
3082
- designation: import_credentials11.AdmittedFeed.Designation.CONTROL
3293
+ designation: import_credentials12.AdmittedFeed.Designation.CONTROL
3083
3294
  }
3084
3295
  }),
3085
3296
  await signingContext.credentialSigner.createCredential({
@@ -3089,7 +3300,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3089
3300
  spaceKey: space.key,
3090
3301
  identityKey: signingContext.identityKey,
3091
3302
  deviceKey: signingContext.deviceKey,
3092
- designation: import_credentials11.AdmittedFeed.Designation.DATA
3303
+ designation: import_credentials12.AdmittedFeed.Designation.DATA
3093
3304
  }
3094
3305
  }),
3095
3306
  await signingContext.credentialSigner.createCredential({
@@ -3114,7 +3325,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3114
3325
  };
3115
3326
 
3116
3327
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3117
- function _ts_decorate2(decorators, target, key, desc) {
3328
+ function _ts_decorate4(decorators, target, key, desc) {
3118
3329
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3119
3330
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3120
3331
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3124,7 +3335,7 @@ function _ts_decorate2(decorators, target, key, desc) {
3124
3335
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3125
3336
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3126
3337
  }
3127
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3338
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3128
3339
  var DataSpaceManager = class DataSpaceManager2 {
3129
3340
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
3130
3341
  this._spaceManager = _spaceManager;
@@ -3133,7 +3344,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3133
3344
  this._keyring = _keyring;
3134
3345
  this._signingContext = _signingContext;
3135
3346
  this._feedStore = _feedStore;
3136
- this._ctx = new import_context7.Context();
3347
+ this._ctx = new import_context8.Context();
3137
3348
  this.updated = new import_async12.Event();
3138
3349
  this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
3139
3350
  this._isOpen = false;
@@ -3144,49 +3355,49 @@ var DataSpaceManager = class DataSpaceManager2 {
3144
3355
  return this._spaces;
3145
3356
  }
3146
3357
  async open() {
3147
- (0, import_log10.log)("open", void 0, {
3148
- F: __dxlog_file12,
3358
+ (0, import_log11.log)("open", void 0, {
3359
+ F: __dxlog_file13,
3149
3360
  L: 79,
3150
3361
  S: this,
3151
3362
  C: (f, a) => f(...a)
3152
3363
  });
3153
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
3364
+ import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
3154
3365
  id: this._instanceId
3155
3366
  }), {
3156
- F: __dxlog_file12,
3367
+ F: __dxlog_file13,
3157
3368
  L: 80,
3158
3369
  S: this,
3159
3370
  C: (f, a) => f(...a)
3160
3371
  });
3161
3372
  await this._metadataStore.load();
3162
- (0, import_log10.log)("metadata loaded", {
3373
+ (0, import_log11.log)("metadata loaded", {
3163
3374
  spaces: this._metadataStore.spaces.length
3164
3375
  }, {
3165
- F: __dxlog_file12,
3376
+ F: __dxlog_file13,
3166
3377
  L: 82,
3167
3378
  S: this,
3168
3379
  C: (f, a) => f(...a)
3169
3380
  });
3170
3381
  for (const spaceMetadata of this._metadataStore.spaces) {
3171
3382
  try {
3172
- (0, import_log10.log)("load space", {
3383
+ (0, import_log11.log)("load space", {
3173
3384
  spaceMetadata
3174
3385
  }, {
3175
- F: __dxlog_file12,
3386
+ F: __dxlog_file13,
3176
3387
  L: 86,
3177
3388
  S: this,
3178
3389
  C: (f, a) => f(...a)
3179
3390
  });
3180
3391
  const space = await this._constructSpace(spaceMetadata);
3181
- if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
3392
+ if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
3182
3393
  space.initializeDataPipelineAsync();
3183
3394
  }
3184
3395
  } catch (err) {
3185
- import_log10.log.error("Error loading space", {
3396
+ import_log11.log.error("Error loading space", {
3186
3397
  spaceMetadata,
3187
3398
  err
3188
3399
  }, {
3189
- F: __dxlog_file12,
3400
+ F: __dxlog_file13,
3190
3401
  L: 92,
3191
3402
  S: this,
3192
3403
  C: (f, a) => f(...a)
@@ -3195,18 +3406,18 @@ var DataSpaceManager = class DataSpaceManager2 {
3195
3406
  }
3196
3407
  this._isOpen = true;
3197
3408
  this.updated.emit();
3198
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
3409
+ import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
3199
3410
  id: this._instanceId
3200
3411
  }), {
3201
- F: __dxlog_file12,
3412
+ F: __dxlog_file13,
3202
3413
  L: 98,
3203
3414
  S: this,
3204
3415
  C: (f, a) => f(...a)
3205
3416
  });
3206
3417
  }
3207
3418
  async close() {
3208
- (0, import_log10.log)("close", void 0, {
3209
- F: __dxlog_file12,
3419
+ (0, import_log11.log)("close", void 0, {
3420
+ F: __dxlog_file13,
3210
3421
  L: 103,
3211
3422
  S: this,
3212
3423
  C: (f, a) => f(...a)
@@ -3221,8 +3432,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3221
3432
  * Creates a new space writing the genesis credentials to the control feed.
3222
3433
  */
3223
3434
  async createSpace() {
3224
- (0, import_invariant10.invariant)(this._isOpen, "Not open.", {
3225
- F: __dxlog_file12,
3435
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3436
+ F: __dxlog_file13,
3226
3437
  L: 116,
3227
3438
  S: this,
3228
3439
  A: [
@@ -3238,12 +3449,12 @@ var DataSpaceManager = class DataSpaceManager2 {
3238
3449
  genesisFeedKey: controlFeedKey,
3239
3450
  controlFeedKey,
3240
3451
  dataFeedKey,
3241
- state: import_services7.SpaceState.ACTIVE
3452
+ state: import_services8.SpaceState.ACTIVE
3242
3453
  };
3243
- (0, import_log10.log)("creating space...", {
3454
+ (0, import_log11.log)("creating space...", {
3244
3455
  spaceKey
3245
3456
  }, {
3246
- F: __dxlog_file12,
3457
+ F: __dxlog_file13,
3247
3458
  L: 128,
3248
3459
  S: this,
3249
3460
  C: (f, a) => f(...a)
@@ -3252,8 +3463,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3252
3463
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
3253
3464
  await this._metadataStore.addSpace(metadata);
3254
3465
  const memberCredential = credentials[1];
3255
- (0, import_invariant10.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3256
- F: __dxlog_file12,
3466
+ (0, import_invariant11.invariant)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3467
+ F: __dxlog_file13,
3257
3468
  L: 135,
3258
3469
  S: this,
3259
3470
  A: [
@@ -3268,16 +3479,16 @@ var DataSpaceManager = class DataSpaceManager2 {
3268
3479
  }
3269
3480
  // TODO(burdon): Rename join space.
3270
3481
  async acceptSpace(opts) {
3271
- (0, import_log10.log)("accept space", {
3482
+ (0, import_log11.log)("accept space", {
3272
3483
  opts
3273
3484
  }, {
3274
- F: __dxlog_file12,
3485
+ F: __dxlog_file13,
3275
3486
  L: 147,
3276
3487
  S: this,
3277
3488
  C: (f, a) => f(...a)
3278
3489
  });
3279
- (0, import_invariant10.invariant)(this._isOpen, "Not open.", {
3280
- F: __dxlog_file12,
3490
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3491
+ F: __dxlog_file13,
3281
3492
  L: 148,
3282
3493
  S: this,
3283
3494
  A: [
@@ -3285,8 +3496,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3285
3496
  "'Not open.'"
3286
3497
  ]
3287
3498
  });
3288
- (0, import_invariant10.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3289
- F: __dxlog_file12,
3499
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3500
+ F: __dxlog_file13,
3290
3501
  L: 149,
3291
3502
  S: this,
3292
3503
  A: [
@@ -3312,16 +3523,16 @@ var DataSpaceManager = class DataSpaceManager2 {
3312
3523
  * TODO(dmaretskyi): Consider removing.
3313
3524
  */
3314
3525
  async waitUntilSpaceReady(spaceKey) {
3315
- await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3526
+ await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3316
3527
  const space = this._spaces.get(spaceKey);
3317
- return !!space && space.state === import_services7.SpaceState.READY;
3528
+ return !!space && space.state === import_services8.SpaceState.READY;
3318
3529
  }));
3319
3530
  }
3320
3531
  async _constructSpace(metadata) {
3321
- (0, import_log10.log)("construct space", {
3532
+ (0, import_log11.log)("construct space", {
3322
3533
  metadata
3323
3534
  }, {
3324
- F: __dxlog_file12,
3535
+ F: __dxlog_file13,
3325
3536
  L: 182,
3326
3537
  S: this,
3327
3538
  C: (f, a) => f(...a)
@@ -3356,8 +3567,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3356
3567
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3357
3568
  },
3358
3569
  onAuthFailure: () => {
3359
- import_log10.log.warn("auth failure", void 0, {
3360
- F: __dxlog_file12,
3570
+ import_log11.log.warn("auth failure", void 0, {
3571
+ F: __dxlog_file13,
3361
3572
  L: 213,
3362
3573
  S: this,
3363
3574
  C: (f, a) => f(...a)
@@ -3369,7 +3580,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3369
3580
  dataFeed && space.setDataFeed(dataFeed);
3370
3581
  const dataSpace = new DataSpace({
3371
3582
  inner: space,
3372
- initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
3583
+ initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
3373
3584
  metadataStore: this._metadataStore,
3374
3585
  gossip,
3375
3586
  presence,
@@ -3378,10 +3589,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3378
3589
  signingContext: this._signingContext,
3379
3590
  callbacks: {
3380
3591
  beforeReady: async () => {
3381
- (0, import_log10.log)("before space ready", {
3592
+ (0, import_log11.log)("before space ready", {
3382
3593
  space: space.key
3383
3594
  }, {
3384
- F: __dxlog_file12,
3595
+ F: __dxlog_file13,
3385
3596
  L: 231,
3386
3597
  S: this,
3387
3598
  C: (f, a) => f(...a)
@@ -3389,11 +3600,11 @@ var DataSpaceManager = class DataSpaceManager2 {
3389
3600
  await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3390
3601
  },
3391
3602
  afterReady: async () => {
3392
- (0, import_log10.log)("after space ready", {
3603
+ (0, import_log11.log)("after space ready", {
3393
3604
  space: space.key,
3394
3605
  open: this._isOpen
3395
3606
  }, {
3396
- F: __dxlog_file12,
3607
+ F: __dxlog_file13,
3397
3608
  L: 238,
3398
3609
  S: this,
3399
3610
  C: (f, a) => f(...a)
@@ -3403,10 +3614,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3403
3614
  }
3404
3615
  },
3405
3616
  beforeClose: async () => {
3406
- (0, import_log10.log)("before space close", {
3617
+ (0, import_log11.log)("before space close", {
3407
3618
  space: space.key
3408
3619
  }, {
3409
- F: __dxlog_file12,
3620
+ F: __dxlog_file13,
3410
3621
  L: 244,
3411
3622
  S: this,
3412
3623
  C: (f, a) => f(...a)
@@ -3416,7 +3627,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3416
3627
  },
3417
3628
  cache: metadata.cache
3418
3629
  });
3419
- if (metadata.state !== import_services7.SpaceState.INACTIVE) {
3630
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
3420
3631
  await dataSpace.open();
3421
3632
  }
3422
3633
  if (metadata.controlTimeframe) {
@@ -3429,33 +3640,33 @@ var DataSpaceManager = class DataSpaceManager2 {
3429
3640
  return dataSpace;
3430
3641
  }
3431
3642
  };
3432
- _ts_decorate2([
3643
+ _ts_decorate4([
3433
3644
  import_async12.synchronized
3434
3645
  ], DataSpaceManager.prototype, "open", null);
3435
- _ts_decorate2([
3646
+ _ts_decorate4([
3436
3647
  import_async12.synchronized
3437
3648
  ], DataSpaceManager.prototype, "close", null);
3438
- _ts_decorate2([
3649
+ _ts_decorate4([
3439
3650
  import_async12.synchronized
3440
3651
  ], DataSpaceManager.prototype, "createSpace", null);
3441
- _ts_decorate2([
3652
+ _ts_decorate4([
3442
3653
  import_async12.synchronized
3443
3654
  ], DataSpaceManager.prototype, "acceptSpace", null);
3444
- DataSpaceManager = _ts_decorate2([
3655
+ DataSpaceManager = _ts_decorate4([
3445
3656
  (0, import_async12.trackLeaks)("open", "close")
3446
3657
  ], DataSpaceManager);
3447
3658
 
3448
3659
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3449
3660
  var import_async13 = require("@dxos/async");
3450
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3661
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3451
3662
  var import_debug6 = require("@dxos/debug");
3452
3663
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3453
3664
  var import_errors4 = require("@dxos/errors");
3454
- var import_log11 = require("@dxos/log");
3455
- var import_protocols7 = require("@dxos/protocols");
3456
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3665
+ var import_log12 = require("@dxos/log");
3666
+ var import_protocols8 = require("@dxos/protocols");
3667
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
3457
3668
  var import_util6 = require("@dxos/util");
3458
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3669
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3459
3670
  var SpacesServiceImpl = class {
3460
3671
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3461
3672
  this._identityManager = _identityManager;
@@ -3477,10 +3688,10 @@ var SpacesServiceImpl = class {
3477
3688
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3478
3689
  if (state) {
3479
3690
  switch (state) {
3480
- case import_services8.SpaceState.ACTIVE:
3691
+ case import_services9.SpaceState.ACTIVE:
3481
3692
  await space.activate();
3482
3693
  break;
3483
- case import_services8.SpaceState.INACTIVE:
3694
+ case import_services9.SpaceState.INACTIVE:
3484
3695
  await space.deactivate();
3485
3696
  break;
3486
3697
  default:
@@ -3489,14 +3700,14 @@ var SpacesServiceImpl = class {
3489
3700
  }
3490
3701
  }
3491
3702
  querySpaces() {
3492
- return new import_codec_protobuf10.Stream(({ next, ctx }) => {
3703
+ return new import_codec_protobuf11.Stream(({ next, ctx }) => {
3493
3704
  const scheduler = new import_async13.UpdateScheduler(ctx, async () => {
3494
3705
  const dataSpaceManager = await this._getDataSpaceManager();
3495
3706
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
3496
- (0, import_log11.log)("update", {
3707
+ (0, import_log12.log)("update", {
3497
3708
  spaces
3498
3709
  }, {
3499
- F: __dxlog_file13,
3710
+ F: __dxlog_file14,
3500
3711
  L: 78,
3501
3712
  S: this,
3502
3713
  C: (f, a) => f(...a)
@@ -3544,7 +3755,7 @@ var SpacesServiceImpl = class {
3544
3755
  await space.postMessage(getChannelId(channel), message);
3545
3756
  }
3546
3757
  subscribeMessages({ spaceKey, channel }) {
3547
- return new import_codec_protobuf10.Stream(({ ctx, next }) => {
3758
+ return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3548
3759
  (0, import_async13.scheduleTask)(ctx, async () => {
3549
3760
  var _a;
3550
3761
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -3557,7 +3768,7 @@ var SpacesServiceImpl = class {
3557
3768
  });
3558
3769
  }
3559
3770
  queryCredentials({ spaceKey }) {
3560
- return new import_codec_protobuf10.Stream(({ ctx, next }) => {
3771
+ return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3561
3772
  var _a;
3562
3773
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3563
3774
  const processor = {
@@ -3591,7 +3802,7 @@ var SpacesServiceImpl = class {
3591
3802
  return {
3592
3803
  spaceKey: space.key,
3593
3804
  state: space.state,
3594
- error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
3805
+ error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
3595
3806
  pipeline: {
3596
3807
  currentEpoch: space.dataPipeline.currentEpoch,
3597
3808
  appliedEpoch: space.dataPipeline.appliedEpoch,
@@ -3619,7 +3830,7 @@ var SpacesServiceImpl = class {
3619
3830
  displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util6.humanize)(member.key)
3620
3831
  }
3621
3832
  },
3622
- presence: isMe || peers.length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE,
3833
+ presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
3623
3834
  peerStates: peers
3624
3835
  };
3625
3836
  }),
@@ -3632,8 +3843,18 @@ var SpacesServiceImpl = class {
3632
3843
  var getChannelId = (channel) => `user-channel/${channel}`;
3633
3844
 
3634
3845
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3635
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3636
- var ServiceContext = class {
3846
+ function _ts_decorate5(decorators, target, key, desc) {
3847
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3848
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3849
+ r = Reflect.decorate(decorators, target, key, desc);
3850
+ else
3851
+ for (var i = decorators.length - 1; i >= 0; i--)
3852
+ if (d = decorators[i])
3853
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3854
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3855
+ }
3856
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3857
+ var ServiceContext = class ServiceContext2 {
3637
3858
  // prettier-ignore
3638
3859
  constructor(storage, networkManager, signalManager, modelFactory) {
3639
3860
  this.storage = storage;
@@ -3667,54 +3888,54 @@ var ServiceContext = class {
3667
3888
  });
3668
3889
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3669
3890
  this.invitations = new InvitationsHandler(this.networkManager);
3670
- this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3891
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3671
3892
  var _a;
3672
3893
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3673
3894
  }, this._acceptIdentity.bind(this)));
3674
3895
  }
3675
- async open() {
3676
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3677
- id: this._instanceId
3678
- }), {
3679
- F: __dxlog_file14,
3680
- L: 125,
3896
+ async open(ctx) {
3897
+ await this._checkStorageVersion();
3898
+ (0, import_log13.log)("opening...", void 0, {
3899
+ F: __dxlog_file15,
3900
+ L: 131,
3681
3901
  S: this,
3682
3902
  C: (f, a) => f(...a)
3683
3903
  });
3684
- await this._checkStorageVersion();
3685
- (0, import_log12.log)("opening...", void 0, {
3686
- F: __dxlog_file14,
3687
- L: 129,
3904
+ import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
3905
+ id: this._instanceId
3906
+ }), {
3907
+ F: __dxlog_file15,
3908
+ L: 132,
3688
3909
  S: this,
3689
3910
  C: (f, a) => f(...a)
3690
3911
  });
3691
3912
  await this.signalManager.open();
3692
3913
  await this.networkManager.open();
3693
3914
  await this.spaceManager.open();
3694
- await this.identityManager.open();
3915
+ await this.identityManager.open(ctx);
3695
3916
  if (this.identityManager.identity) {
3696
- await this._initialize();
3917
+ await this._initialize(ctx);
3697
3918
  }
3698
- (0, import_log12.log)("opened", void 0, {
3699
- F: __dxlog_file14,
3700
- L: 137,
3919
+ import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
3920
+ id: this._instanceId
3921
+ }), {
3922
+ F: __dxlog_file15,
3923
+ L: 140,
3701
3924
  S: this,
3702
3925
  C: (f, a) => f(...a)
3703
3926
  });
3704
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3705
- id: this._instanceId
3706
- }), {
3707
- F: __dxlog_file14,
3708
- L: 138,
3927
+ (0, import_log13.log)("opened", void 0, {
3928
+ F: __dxlog_file15,
3929
+ L: 141,
3709
3930
  S: this,
3710
3931
  C: (f, a) => f(...a)
3711
3932
  });
3712
3933
  }
3713
3934
  async close() {
3714
3935
  var _a;
3715
- (0, import_log12.log)("closing...", void 0, {
3716
- F: __dxlog_file14,
3717
- L: 142,
3936
+ (0, import_log13.log)("closing...", void 0, {
3937
+ F: __dxlog_file15,
3938
+ L: 145,
3718
3939
  S: this,
3719
3940
  C: (f, a) => f(...a)
3720
3941
  });
@@ -3728,23 +3949,23 @@ var ServiceContext = class {
3728
3949
  await this.networkManager.close();
3729
3950
  await this.signalManager.close();
3730
3951
  this.dataServiceSubscriptions.clear();
3731
- (0, import_log12.log)("closed", void 0, {
3732
- F: __dxlog_file14,
3733
- L: 153,
3952
+ (0, import_log13.log)("closed", void 0, {
3953
+ F: __dxlog_file15,
3954
+ L: 156,
3734
3955
  S: this,
3735
3956
  C: (f, a) => f(...a)
3736
3957
  });
3737
3958
  }
3738
3959
  async createIdentity(params = {}) {
3739
3960
  const identity = await this.identityManager.createIdentity(params);
3740
- await this._initialize();
3961
+ await this._initialize(new import_context9.Context());
3741
3962
  return identity;
3742
3963
  }
3743
3964
  getInvitationHandler(invitation) {
3744
3965
  const factory = this._handlerFactories.get(invitation.kind);
3745
- (0, import_invariant11.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3746
- F: __dxlog_file14,
3747
- L: 165,
3966
+ (0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3967
+ F: __dxlog_file15,
3968
+ L: 168,
3748
3969
  S: this,
3749
3970
  A: [
3750
3971
  "factory",
@@ -3755,21 +3976,21 @@ var ServiceContext = class {
3755
3976
  }
3756
3977
  async _acceptIdentity(params) {
3757
3978
  const identity = await this.identityManager.acceptIdentity(params);
3758
- await this._initialize();
3979
+ await this._initialize(new import_context9.Context());
3759
3980
  return identity;
3760
3981
  }
3761
3982
  async _checkStorageVersion() {
3762
3983
  await this.metadataStore.load();
3763
- if (this.metadataStore.version !== import_protocols8.STORAGE_VERSION) {
3764
- throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols8.STORAGE_VERSION}`);
3984
+ if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
3985
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
3765
3986
  }
3766
3987
  }
3767
3988
  // Called when identity is created.
3768
- async _initialize() {
3989
+ async _initialize(ctx) {
3769
3990
  var _a;
3770
- (0, import_log12.log)("initializing spaces...", void 0, {
3771
- F: __dxlog_file14,
3772
- L: 186,
3991
+ (0, import_log13.log)("initializing spaces...", void 0, {
3992
+ F: __dxlog_file15,
3993
+ L: 190,
3773
3994
  S: this,
3774
3995
  C: (f, a) => f(...a)
3775
3996
  });
@@ -3789,10 +4010,10 @@ var ServiceContext = class {
3789
4010
  };
3790
4011
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3791
4012
  await this.dataSpaceManager.open();
3792
- this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3793
- (0, import_invariant11.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3794
- F: __dxlog_file14,
3795
- L: 209,
4013
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4014
+ (0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4015
+ F: __dxlog_file15,
4016
+ L: 213,
3796
4017
  S: this,
3797
4018
  A: [
3798
4019
  "this.dataSpaceManager",
@@ -3804,7 +4025,7 @@ var ServiceContext = class {
3804
4025
  this.initialized.wake();
3805
4026
  this._deviceSpaceSync = {
3806
4027
  processCredential: async (credential) => {
3807
- const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
4028
+ const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
3808
4029
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
3809
4030
  return;
3810
4031
  }
@@ -3812,33 +4033,33 @@ var ServiceContext = class {
3812
4033
  return;
3813
4034
  }
3814
4035
  if (!this.dataSpaceManager) {
3815
- (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4036
+ (0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3816
4037
  details: assertion
3817
4038
  }, {
3818
- F: __dxlog_file14,
3819
- L: 225,
4039
+ F: __dxlog_file15,
4040
+ L: 229,
3820
4041
  S: this,
3821
4042
  C: (f, a) => f(...a)
3822
4043
  });
3823
4044
  return;
3824
4045
  }
3825
4046
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3826
- (0, import_log12.log)("space already exists, ignoring space admission", {
4047
+ (0, import_log13.log)("space already exists, ignoring space admission", {
3827
4048
  details: assertion
3828
4049
  }, {
3829
- F: __dxlog_file14,
3830
- L: 229,
4050
+ F: __dxlog_file15,
4051
+ L: 233,
3831
4052
  S: this,
3832
4053
  C: (f, a) => f(...a)
3833
4054
  });
3834
4055
  return;
3835
4056
  }
3836
4057
  try {
3837
- (0, import_log12.log)("accepting space recorded in halo", {
4058
+ (0, import_log13.log)("accepting space recorded in halo", {
3838
4059
  details: assertion
3839
4060
  }, {
3840
- F: __dxlog_file14,
3841
- L: 234,
4061
+ F: __dxlog_file15,
4062
+ L: 238,
3842
4063
  S: this,
3843
4064
  C: (f, a) => f(...a)
3844
4065
  });
@@ -3847,9 +4068,9 @@ var ServiceContext = class {
3847
4068
  genesisFeedKey: assertion.genesisFeedKey
3848
4069
  });
3849
4070
  } catch (err) {
3850
- import_log12.log.catch(err, void 0, {
3851
- F: __dxlog_file14,
3852
- L: 240,
4071
+ import_log13.log.catch(err, void 0, {
4072
+ F: __dxlog_file15,
4073
+ L: 244,
3853
4074
  S: this,
3854
4075
  C: (f, a) => f(...a)
3855
4076
  });
@@ -3859,26 +4080,37 @@ var ServiceContext = class {
3859
4080
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3860
4081
  }
3861
4082
  };
4083
+ _ts_decorate5([
4084
+ import_tracing3.trace.span()
4085
+ ], ServiceContext.prototype, "open", null);
4086
+ _ts_decorate5([
4087
+ import_tracing3.trace.span()
4088
+ ], ServiceContext.prototype, "_initialize", null);
4089
+ ServiceContext = _ts_decorate5([
4090
+ import_tracing3.trace.resource()
4091
+ ], ServiceContext);
3862
4092
 
3863
4093
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3864
4094
  var import_async17 = require("@dxos/async");
3865
4095
  var import_client_protocol5 = require("@dxos/client-protocol");
3866
- var import_document_model = require("@dxos/document-model");
4096
+ var import_context10 = require("@dxos/context");
4097
+ var import_document_model2 = require("@dxos/document-model");
3867
4098
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3868
- var import_invariant13 = require("@dxos/invariant");
4099
+ var import_invariant14 = require("@dxos/invariant");
3869
4100
  var import_keys11 = require("@dxos/keys");
3870
- var import_log15 = require("@dxos/log");
4101
+ var import_log16 = require("@dxos/log");
3871
4102
  var import_messaging = require("@dxos/messaging");
3872
4103
  var import_model_factory = require("@dxos/model-factory");
3873
4104
  var import_network_manager2 = require("@dxos/network-manager");
3874
- var import_protocols9 = require("@dxos/protocols");
3875
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
4105
+ var import_protocols10 = require("@dxos/protocols");
4106
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
3876
4107
  var import_text_model = require("@dxos/text-model");
4108
+ var import_tracing4 = require("@dxos/tracing");
3877
4109
 
3878
4110
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3879
4111
  var import_async15 = require("@dxos/async");
3880
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3881
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
4112
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
4113
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3882
4114
  var DevicesServiceImpl = class {
3883
4115
  constructor(_identityManager) {
3884
4116
  this._identityManager = _identityManager;
@@ -3887,7 +4119,7 @@ var DevicesServiceImpl = class {
3887
4119
  throw new Error("Method not implemented.");
3888
4120
  }
3889
4121
  queryDevices() {
3890
- return new import_codec_protobuf11.Stream(({ next }) => {
4122
+ return new import_codec_protobuf12.Stream(({ next }) => {
3891
4123
  const update = () => {
3892
4124
  var _a;
3893
4125
  const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
@@ -3901,7 +4133,7 @@ var DevicesServiceImpl = class {
3901
4133
  var _a2;
3902
4134
  return {
3903
4135
  deviceKey: key,
3904
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
4136
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
3905
4137
  };
3906
4138
  })
3907
4139
  });
@@ -3923,10 +4155,10 @@ var DevicesServiceImpl = class {
3923
4155
  };
3924
4156
 
3925
4157
  // packages/sdk/client-services/src/packlets/locks/node.ts
3926
- var import_invariant12 = require("@dxos/invariant");
4158
+ var import_invariant13 = require("@dxos/invariant");
3927
4159
  var import_lock_file = require("@dxos/lock-file");
3928
- var import_log13 = require("@dxos/log");
3929
- function _ts_decorate3(decorators, target, key, desc) {
4160
+ var import_log14 = require("@dxos/log");
4161
+ function _ts_decorate6(decorators, target, key, desc) {
3930
4162
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3931
4163
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3932
4164
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3936,7 +4168,7 @@ function _ts_decorate3(decorators, target, key, desc) {
3936
4168
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3937
4169
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3938
4170
  }
3939
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4171
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
3940
4172
  var Lock = class {
3941
4173
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3942
4174
  this._lockPath = lockPath;
@@ -3948,16 +4180,16 @@ var Lock = class {
3948
4180
  }
3949
4181
  async acquire() {
3950
4182
  var _a;
3951
- (0, import_log13.log)("acquiring lock...", void 0, {
3952
- F: __dxlog_file15,
4183
+ (0, import_log14.log)("acquiring lock...", void 0, {
4184
+ F: __dxlog_file16,
3953
4185
  L: 32,
3954
4186
  S: this,
3955
4187
  C: (f, a) => f(...a)
3956
4188
  });
3957
4189
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3958
4190
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3959
- (0, import_log13.log)("acquired lock", void 0, {
3960
- F: __dxlog_file15,
4191
+ (0, import_log14.log)("acquired lock", void 0, {
4192
+ F: __dxlog_file16,
3961
4193
  L: 37,
3962
4194
  S: this,
3963
4195
  C: (f, a) => f(...a)
@@ -3966,8 +4198,8 @@ var Lock = class {
3966
4198
  async release() {
3967
4199
  var _a;
3968
4200
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3969
- (0, import_invariant12.invariant)(this._fileHandle, "Lock is not acquired", {
3970
- F: __dxlog_file15,
4201
+ (0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
4202
+ F: __dxlog_file16,
3971
4203
  L: 42,
3972
4204
  S: this,
3973
4205
  A: [
@@ -3978,30 +4210,31 @@ var Lock = class {
3978
4210
  await import_lock_file.LockFile.release(this._fileHandle);
3979
4211
  }
3980
4212
  };
3981
- _ts_decorate3([
3982
- import_log13.logInfo
4213
+ _ts_decorate6([
4214
+ import_log14.logInfo
3983
4215
  ], Lock.prototype, "lockKey", null);
3984
4216
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
3985
4217
 
3986
4218
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3987
4219
  var import_async16 = require("@dxos/async");
3988
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3989
- var import_log14 = require("@dxos/log");
3990
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
4220
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4221
+ var import_log15 = require("@dxos/log");
4222
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3991
4223
  var import_util7 = require("@dxos/util");
3992
4224
  var LoggingServiceImpl = class {
3993
4225
  constructor() {
3994
4226
  this._logs = new import_async16.Event();
4227
+ this._started = new Date();
3995
4228
  this._logProcessor = (_config, entry2) => {
3996
4229
  this._logs.emit(entry2);
3997
4230
  };
3998
4231
  }
3999
4232
  async open() {
4000
- import_log14.log.runtimeConfig.processors.push(this._logProcessor);
4233
+ import_log15.log.runtimeConfig.processors.push(this._logProcessor);
4001
4234
  }
4002
4235
  async close() {
4003
- const index = import_log14.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4004
- import_log14.log.runtimeConfig.processors.splice(index, 1);
4236
+ const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4237
+ import_log15.log.runtimeConfig.processors.splice(index, 1);
4005
4238
  }
4006
4239
  async controlMetrics({ reset, record }) {
4007
4240
  if (reset) {
@@ -4016,35 +4249,41 @@ var LoggingServiceImpl = class {
4016
4249
  recording: import_util7.tracer.recording
4017
4250
  };
4018
4251
  }
4019
- queryMetrics({ interval }) {
4020
- const createNumericalValues = (key) => {
4252
+ /**
4253
+ * @deprecated (Move to diagnostics).
4254
+ */
4255
+ queryMetrics({ interval = 5e3 }) {
4256
+ const getNumericalValues = (key) => {
4021
4257
  var _a;
4022
- const consume = (_a = import_util7.tracer.get(key)) != null ? _a : [];
4258
+ const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
4023
4259
  return {
4024
4260
  key,
4025
- stats: (0, import_util7.numericalValues)(consume, "duration")
4261
+ stats: (0, import_util7.numericalValues)(events, "duration")
4026
4262
  };
4027
4263
  };
4028
- return new import_codec_protobuf12.Stream(({ next }) => {
4264
+ return new import_codec_protobuf13.Stream(({ next }) => {
4029
4265
  const update = () => {
4030
4266
  const metrics = {
4031
4267
  timestamp: new Date(),
4032
4268
  values: [
4033
- createNumericalValues("dxos.echo.pipeline.control"),
4034
- createNumericalValues("dxos.echo.pipeline.data")
4035
- ]
4269
+ getNumericalValues("dxos.echo.pipeline.control"),
4270
+ getNumericalValues("dxos.echo.pipeline.data")
4271
+ ].filter(Boolean)
4036
4272
  };
4037
- next(metrics);
4273
+ next({
4274
+ timestamp: new Date(),
4275
+ metrics
4276
+ });
4038
4277
  };
4039
4278
  update();
4040
- const i = setInterval(update, interval);
4279
+ const i = setInterval(update, Math.max(interval, 1e3));
4041
4280
  return () => {
4042
4281
  clearInterval(i);
4043
4282
  };
4044
4283
  });
4045
4284
  }
4046
4285
  queryLogs(request) {
4047
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
4286
+ return new import_codec_protobuf13.Stream(({ ctx, next }) => {
4048
4287
  const handler = (entry2) => {
4049
4288
  var _a, _b, _c, _d, _e;
4050
4289
  if (LOG_PROCESSING > 0) {
@@ -4058,7 +4297,7 @@ var LoggingServiceImpl = class {
4058
4297
  }
4059
4298
  const record = {
4060
4299
  ...entry2,
4061
- context: (0, import_util7.jsonify)((0, import_log14.getContextFromEntry)(entry2)),
4300
+ context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
4062
4301
  timestamp: new Date(),
4063
4302
  meta: {
4064
4303
  // TODO(dmaretskyi): Fix proto.
@@ -4079,17 +4318,17 @@ var LoggingServiceImpl = class {
4079
4318
  };
4080
4319
  var matchFilter = (filter, level, path, options) => {
4081
4320
  switch (options) {
4082
- case import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE:
4321
+ case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
4083
4322
  return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
4084
- case import_services11.QueryLogsRequest.MatchingOptions.EXPLICIT:
4323
+ case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
4085
4324
  return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
4086
4325
  }
4087
4326
  };
4088
4327
  var shouldLog = (entry2, request) => {
4089
4328
  var _a;
4090
- const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4329
+ const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4091
4330
  if (request.filters === void 0) {
4092
- return options === import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4331
+ return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4093
4332
  } else {
4094
4333
  return request.filters.some((filter) => {
4095
4334
  var _a2, _b;
@@ -4100,14 +4339,14 @@ var shouldLog = (entry2, request) => {
4100
4339
  var LOG_PROCESSING = 0;
4101
4340
 
4102
4341
  // packages/sdk/client-services/src/packlets/network/network-service.ts
4103
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4342
+ var import_codec_protobuf14 = require("@dxos/codec-protobuf");
4104
4343
  var NetworkServiceImpl = class {
4105
4344
  constructor(networkManager, signalManager) {
4106
4345
  this.networkManager = networkManager;
4107
4346
  this.signalManager = signalManager;
4108
4347
  }
4109
4348
  queryStatus() {
4110
- return new import_codec_protobuf13.Stream(({ next }) => {
4349
+ return new import_codec_protobuf14.Stream(({ next }) => {
4111
4350
  const update = () => {
4112
4351
  next({
4113
4352
  swarm: this.networkManager.connectionState,
@@ -4181,12 +4420,15 @@ var toStorageType = (type) => {
4181
4420
  };
4182
4421
 
4183
4422
  // packages/sdk/client-services/src/packlets/system/system-service.ts
4184
- var import_codec_protobuf14 = require("@dxos/codec-protobuf");
4423
+ var import_codec_protobuf15 = require("@dxos/codec-protobuf");
4424
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
4425
+ var import_util9 = require("@dxos/util");
4185
4426
  var SystemServiceImpl = class {
4186
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
4427
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
4187
4428
  this._config = config;
4188
4429
  this._statusUpdate = statusUpdate;
4189
4430
  this._getCurrentStatus = getCurrentStatus;
4431
+ this._getDiagnostics = getDiagnostics;
4190
4432
  this._onUpdateStatus = onUpdateStatus;
4191
4433
  this._onReset = onReset;
4192
4434
  }
@@ -4194,12 +4436,25 @@ var SystemServiceImpl = class {
4194
4436
  var _a, _b;
4195
4437
  return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
4196
4438
  }
4439
+ /**
4440
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
4441
+ */
4442
+ async getDiagnostics({ keys } = {}) {
4443
+ const diagnostics = await this._getDiagnostics();
4444
+ return {
4445
+ timestamp: new Date(),
4446
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
4447
+ truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4448
+ humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4449
+ })))
4450
+ };
4451
+ }
4197
4452
  async updateStatus({ status }) {
4198
4453
  await this._onUpdateStatus(status);
4199
4454
  }
4200
4455
  // TODO(burdon): Standardize interval option in stream request?
4201
4456
  queryStatus({ interval = 3e3 } = {}) {
4202
- return new import_codec_protobuf14.Stream(({ next }) => {
4457
+ return new import_codec_protobuf15.Stream(({ next }) => {
4203
4458
  const update = () => {
4204
4459
  next({
4205
4460
  status: this._getCurrentStatus()
@@ -4244,7 +4499,7 @@ var ServiceRegistry = class {
4244
4499
  };
4245
4500
 
4246
4501
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4247
- function _ts_decorate4(decorators, target, key, desc) {
4502
+ function _ts_decorate7(decorators, target, key, desc) {
4248
4503
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4249
4504
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4250
4505
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4254,23 +4509,22 @@ function _ts_decorate4(decorators, target, key, desc) {
4254
4509
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4255
4510
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4256
4511
  }
4257
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4512
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4258
4513
  var createDefaultModelFactory = () => {
4259
- return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
4514
+ return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
4260
4515
  };
4261
- var ClientServicesHost = class {
4516
+ var ClientServicesHost = class ClientServicesHost2 {
4262
4517
  constructor({
4263
4518
  config,
4264
4519
  modelFactory = createDefaultModelFactory(),
4265
- // TODO(burdon): Create ApolloLink abstraction (see Client).
4266
4520
  transportFactory,
4267
4521
  signalManager,
4268
- connectionLog,
4269
4522
  storage,
4270
4523
  // TODO(wittjosiah): Turn this on by default.
4271
4524
  lockKey,
4272
4525
  callbacks
4273
4526
  } = {}) {
4527
+ this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
4274
4528
  this._statusUpdate = new import_async17.Event();
4275
4529
  this._opening = false;
4276
4530
  this._open = false;
@@ -4289,7 +4543,7 @@ var ClientServicesHost = class {
4289
4543
  lockKey,
4290
4544
  onAcquire: () => {
4291
4545
  if (!this._opening) {
4292
- void this.open();
4546
+ void this.open(new import_context10.Context());
4293
4547
  }
4294
4548
  },
4295
4549
  onRelease: () => this.close()
@@ -4298,12 +4552,15 @@ var ClientServicesHost = class {
4298
4552
  this._systemService = new SystemServiceImpl({
4299
4553
  config: this._config,
4300
4554
  statusUpdate: this._statusUpdate,
4301
- getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
4555
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
4556
+ getDiagnostics: () => {
4557
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4558
+ },
4302
4559
  onUpdateStatus: async (status) => {
4303
4560
  var _a, _b;
4304
- if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
4561
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
4305
4562
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4306
- } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
4563
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
4307
4564
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4308
4565
  }
4309
4566
  },
@@ -4313,12 +4570,19 @@ var ClientServicesHost = class {
4313
4570
  });
4314
4571
  this._loggingService = new LoggingServiceImpl();
4315
4572
  this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
4316
- SystemService: this._systemService
4573
+ SystemService: this._systemService,
4574
+ TracingService: this._tracingService
4317
4575
  });
4318
4576
  }
4319
4577
  get isOpen() {
4320
4578
  return this._open;
4321
4579
  }
4580
+ get config() {
4581
+ return this._config;
4582
+ }
4583
+ get context() {
4584
+ return this._serviceContext;
4585
+ }
4322
4586
  get serviceRegistry() {
4323
4587
  return this._serviceRegistry;
4324
4588
  }
@@ -4335,19 +4599,25 @@ var ClientServicesHost = class {
4335
4599
  */
4336
4600
  initialize({ config, ...options }) {
4337
4601
  var _a, _b, _c;
4338
- (0, import_invariant13.invariant)(!this._open, "service host is open", {
4339
- F: __dxlog_file16,
4340
- L: 167,
4602
+ (0, import_invariant14.invariant)(!this._open, "service host is open", {
4603
+ F: __dxlog_file17,
4604
+ L: 181,
4341
4605
  S: this,
4342
4606
  A: [
4343
4607
  "!this._open",
4344
4608
  "'service host is open'"
4345
4609
  ]
4346
4610
  });
4611
+ import_log16.log.info("initializing...", void 0, {
4612
+ F: __dxlog_file17,
4613
+ L: 182,
4614
+ S: this,
4615
+ C: (f, a) => f(...a)
4616
+ });
4347
4617
  if (config) {
4348
- (0, import_invariant13.invariant)(!this._config, "config already set", {
4349
- F: __dxlog_file16,
4350
- L: 170,
4618
+ (0, import_invariant14.invariant)(!this._config, "config already set", {
4619
+ F: __dxlog_file17,
4620
+ L: 185,
4351
4621
  S: this,
4352
4622
  A: [
4353
4623
  "!this._config",
@@ -4363,9 +4633,9 @@ var ClientServicesHost = class {
4363
4633
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4364
4634
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4365
4635
  this._signalManager = signalManager;
4366
- (0, import_invariant13.invariant)(!this._networkManager, "network manager already set", {
4367
- F: __dxlog_file16,
4368
- L: 187,
4636
+ (0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
4637
+ F: __dxlog_file17,
4638
+ L: 201,
4369
4639
  S: this,
4370
4640
  A: [
4371
4641
  "!this._networkManager",
@@ -4377,51 +4647,57 @@ var ClientServicesHost = class {
4377
4647
  transportFactory,
4378
4648
  signalManager
4379
4649
  });
4650
+ import_log16.log.info("initialized", void 0, {
4651
+ F: __dxlog_file17,
4652
+ L: 208,
4653
+ S: this,
4654
+ C: (f, a) => f(...a)
4655
+ });
4380
4656
  }
4381
- async open() {
4657
+ async open(ctx) {
4382
4658
  var _a, _b, _c;
4383
4659
  if (this._open) {
4384
4660
  return;
4385
4661
  }
4386
4662
  const traceId = import_keys11.PublicKey.random().toHex();
4387
- import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
4663
+ import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
4388
4664
  id: traceId
4389
4665
  }), {
4390
- F: __dxlog_file16,
4391
- L: 202,
4666
+ F: __dxlog_file17,
4667
+ L: 219,
4392
4668
  S: this,
4393
4669
  C: (f, a) => f(...a)
4394
4670
  });
4395
- (0, import_invariant13.invariant)(this._config, "config not set", {
4396
- F: __dxlog_file16,
4397
- L: 204,
4671
+ (0, import_invariant14.invariant)(this._config, "config not set", {
4672
+ F: __dxlog_file17,
4673
+ L: 221,
4398
4674
  S: this,
4399
4675
  A: [
4400
4676
  "this._config",
4401
4677
  "'config not set'"
4402
4678
  ]
4403
4679
  });
4404
- (0, import_invariant13.invariant)(this._storage, "storage not set", {
4405
- F: __dxlog_file16,
4406
- L: 205,
4680
+ (0, import_invariant14.invariant)(this._storage, "storage not set", {
4681
+ F: __dxlog_file17,
4682
+ L: 222,
4407
4683
  S: this,
4408
4684
  A: [
4409
4685
  "this._storage",
4410
4686
  "'storage not set'"
4411
4687
  ]
4412
4688
  });
4413
- (0, import_invariant13.invariant)(this._signalManager, "signal manager not set", {
4414
- F: __dxlog_file16,
4415
- L: 206,
4689
+ (0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
4690
+ F: __dxlog_file17,
4691
+ L: 223,
4416
4692
  S: this,
4417
4693
  A: [
4418
4694
  "this._signalManager",
4419
4695
  "'signal manager not set'"
4420
4696
  ]
4421
4697
  });
4422
- (0, import_invariant13.invariant)(this._networkManager, "network manager not set", {
4423
- F: __dxlog_file16,
4424
- L: 207,
4698
+ (0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
4699
+ F: __dxlog_file17,
4700
+ L: 224,
4425
4701
  S: this,
4426
4702
  A: [
4427
4703
  "this._networkManager",
@@ -4429,11 +4705,11 @@ var ClientServicesHost = class {
4429
4705
  ]
4430
4706
  });
4431
4707
  this._opening = true;
4432
- (0, import_log15.log)("opening...", {
4708
+ import_log16.log.info("opening...", {
4433
4709
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4434
4710
  }, {
4435
- F: __dxlog_file16,
4436
- L: 210,
4711
+ F: __dxlog_file17,
4712
+ L: 227,
4437
4713
  S: this,
4438
4714
  C: (f, a) => f(...a)
4439
4715
  });
@@ -4452,6 +4728,7 @@ var ClientServicesHost = class {
4452
4728
  DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4453
4729
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4454
4730
  LoggingService: this._loggingService,
4731
+ TracingService: this._tracingService,
4455
4732
  // TODO(burdon): Move to new protobuf definitions.
4456
4733
  DevtoolsHost: new DevtoolsServiceImpl({
4457
4734
  events: new DevtoolsHostEvents(),
@@ -4459,24 +4736,24 @@ var ClientServicesHost = class {
4459
4736
  context: this._serviceContext
4460
4737
  })
4461
4738
  });
4462
- await this._serviceContext.open();
4739
+ await this._serviceContext.open(ctx);
4463
4740
  this._opening = false;
4464
4741
  this._open = true;
4465
4742
  this._statusUpdate.emit();
4466
4743
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4467
- (0, import_log15.log)("opened", {
4744
+ import_log16.log.info("opened", {
4468
4745
  deviceKey
4469
4746
  }, {
4470
- F: __dxlog_file16,
4471
- L: 265,
4747
+ F: __dxlog_file17,
4748
+ L: 280,
4472
4749
  S: this,
4473
4750
  C: (f, a) => f(...a)
4474
4751
  });
4475
- import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
4752
+ import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
4476
4753
  id: traceId
4477
4754
  }), {
4478
- F: __dxlog_file16,
4479
- L: 266,
4755
+ F: __dxlog_file17,
4756
+ L: 281,
4480
4757
  S: this,
4481
4758
  C: (f, a) => f(...a)
4482
4759
  });
@@ -4487,11 +4764,11 @@ var ClientServicesHost = class {
4487
4764
  return;
4488
4765
  }
4489
4766
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4490
- (0, import_log15.log)("closing...", {
4767
+ import_log16.log.info("closing...", {
4491
4768
  deviceKey
4492
4769
  }, {
4493
- F: __dxlog_file16,
4494
- L: 276,
4770
+ F: __dxlog_file17,
4771
+ L: 292,
4495
4772
  S: this,
4496
4773
  C: (f, a) => f(...a)
4497
4774
  });
@@ -4502,11 +4779,11 @@ var ClientServicesHost = class {
4502
4779
  await this._serviceContext.close();
4503
4780
  this._open = false;
4504
4781
  this._statusUpdate.emit();
4505
- (0, import_log15.log)("closed", {
4782
+ import_log16.log.info("closed", {
4506
4783
  deviceKey
4507
4784
  }, {
4508
- F: __dxlog_file16,
4509
- L: 282,
4785
+ F: __dxlog_file17,
4786
+ L: 298,
4510
4787
  S: this,
4511
4788
  C: (f, a) => f(...a)
4512
4789
  });
@@ -4514,61 +4791,73 @@ var ClientServicesHost = class {
4514
4791
  async reset() {
4515
4792
  var _a, _b, _c;
4516
4793
  const traceId = import_keys11.PublicKey.random().toHex();
4517
- import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
4794
+ import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
4518
4795
  id: traceId
4519
4796
  }), {
4520
- F: __dxlog_file16,
4521
- L: 287,
4797
+ F: __dxlog_file17,
4798
+ L: 303,
4522
4799
  S: this,
4523
4800
  C: (f, a) => f(...a)
4524
4801
  });
4525
- (0, import_log15.log)("resetting...", void 0, {
4526
- F: __dxlog_file16,
4527
- L: 289,
4802
+ (0, import_log16.log)("resetting...", void 0, {
4803
+ F: __dxlog_file17,
4804
+ L: 305,
4528
4805
  S: this,
4529
4806
  C: (f, a) => f(...a)
4530
4807
  });
4531
4808
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4532
4809
  await this._storage.reset();
4533
- (0, import_log15.log)("reset", void 0, {
4534
- F: __dxlog_file16,
4535
- L: 292,
4810
+ (0, import_log16.log)("reset", void 0, {
4811
+ F: __dxlog_file17,
4812
+ L: 308,
4536
4813
  S: this,
4537
4814
  C: (f, a) => f(...a)
4538
4815
  });
4539
- import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
4816
+ import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
4540
4817
  id: traceId
4541
4818
  }), {
4542
- F: __dxlog_file16,
4543
- L: 293,
4819
+ F: __dxlog_file17,
4820
+ L: 309,
4544
4821
  S: this,
4545
4822
  C: (f, a) => f(...a)
4546
4823
  });
4547
4824
  await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4548
4825
  }
4549
4826
  };
4550
- _ts_decorate4([
4551
- import_async17.synchronized
4827
+ _ts_decorate7([
4828
+ import_tracing4.trace.info()
4829
+ ], ClientServicesHost.prototype, "_opening", void 0);
4830
+ _ts_decorate7([
4831
+ import_tracing4.trace.info()
4832
+ ], ClientServicesHost.prototype, "_open", void 0);
4833
+ _ts_decorate7([
4834
+ import_async17.synchronized,
4835
+ import_tracing4.trace.span()
4552
4836
  ], ClientServicesHost.prototype, "open", null);
4553
- _ts_decorate4([
4554
- import_async17.synchronized
4837
+ _ts_decorate7([
4838
+ import_async17.synchronized,
4839
+ import_tracing4.trace.span()
4555
4840
  ], ClientServicesHost.prototype, "close", null);
4841
+ ClientServicesHost = _ts_decorate7([
4842
+ import_tracing4.trace.resource()
4843
+ ], ClientServicesHost);
4556
4844
 
4557
4845
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
4558
4846
  var import_async19 = require("@dxos/async");
4559
4847
  var import_client_protocol7 = require("@dxos/client-protocol");
4560
- var import_log16 = require("@dxos/log");
4848
+ var import_context11 = require("@dxos/context");
4849
+ var import_log17 = require("@dxos/log");
4561
4850
  var import_messaging2 = require("@dxos/messaging");
4562
4851
  var import_network_manager3 = require("@dxos/network-manager");
4563
- var import_util9 = require("@dxos/util");
4852
+ var import_util10 = require("@dxos/util");
4564
4853
 
4565
4854
  // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
4566
4855
  var import_async18 = require("@dxos/async");
4567
4856
  var import_client_protocol6 = require("@dxos/client-protocol");
4568
- var import_invariant14 = require("@dxos/invariant");
4857
+ var import_invariant15 = require("@dxos/invariant");
4569
4858
  var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
4570
4859
  var import_rpc2 = require("@dxos/rpc");
4571
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
4860
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
4572
4861
  var ShellRuntimeImpl = class {
4573
4862
  constructor(_port) {
4574
4863
  this._port = _port;
@@ -4594,8 +4883,8 @@ var ShellRuntimeImpl = class {
4594
4883
  });
4595
4884
  }
4596
4885
  async setAppContext(context) {
4597
- (0, import_invariant14.invariant)(this._appRpc, "runtime not open", {
4598
- F: __dxlog_file17,
4886
+ (0, import_invariant15.invariant)(this._appRpc, "runtime not open", {
4887
+ F: __dxlog_file18,
4599
4888
  L: 44,
4600
4889
  S: this,
4601
4890
  A: [
@@ -4631,7 +4920,7 @@ var ShellRuntimeImpl = class {
4631
4920
  };
4632
4921
 
4633
4922
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
4634
- function _ts_decorate5(decorators, target, key, desc) {
4923
+ function _ts_decorate8(decorators, target, key, desc) {
4635
4924
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4636
4925
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4637
4926
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4641,7 +4930,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4641
4930
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4642
4931
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4643
4932
  }
4644
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
4933
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
4645
4934
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
4646
4935
  var IFrameHostRuntime = class {
4647
4936
  constructor({ config, origin, appPort, shellPort }) {
@@ -4662,14 +4951,14 @@ var IFrameHostRuntime = class {
4662
4951
  }
4663
4952
  async start() {
4664
4953
  var _a;
4665
- (0, import_log16.log)("starting...", void 0, {
4666
- F: __dxlog_file18,
4667
- L: 70,
4954
+ (0, import_log17.log)("starting...", void 0, {
4955
+ F: __dxlog_file19,
4956
+ L: 71,
4668
4957
  S: this,
4669
4958
  C: (f, a) => f(...a)
4670
4959
  });
4671
4960
  try {
4672
- this._config = await (0, import_util9.getAsyncValue)(this._configProvider);
4961
+ this._config = await (0, import_util10.getAsyncValue)(this._configProvider);
4673
4962
  this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
4674
4963
  iceServers: this._config.get("runtime.services.ice")
4675
4964
  });
@@ -4706,22 +4995,22 @@ var IFrameHostRuntime = class {
4706
4995
  ...middleware
4707
4996
  });
4708
4997
  await Promise.all([
4709
- this._clientServices.open(),
4998
+ this._clientServices.open(new import_context11.Context()),
4710
4999
  this._clientRpc.open(),
4711
5000
  (_a = this._shellRuntime) == null ? void 0 : _a.open()
4712
5001
  ]);
4713
5002
  this._ready.wake(void 0);
4714
- (0, import_log16.log)("started", void 0, {
4715
- F: __dxlog_file18,
4716
- L: 113,
5003
+ (0, import_log17.log)("started", void 0, {
5004
+ F: __dxlog_file19,
5005
+ L: 114,
4717
5006
  S: this,
4718
5007
  C: (f, a) => f(...a)
4719
5008
  });
4720
5009
  } catch (err) {
4721
5010
  this._ready.wake(err);
4722
- import_log16.log.catch(err, void 0, {
4723
- F: __dxlog_file18,
4724
- L: 116,
5011
+ import_log17.log.catch(err, void 0, {
5012
+ F: __dxlog_file19,
5013
+ L: 117,
4725
5014
  S: this,
4726
5015
  C: (f, a) => f(...a)
4727
5016
  });
@@ -4729,36 +5018,36 @@ var IFrameHostRuntime = class {
4729
5018
  }
4730
5019
  async stop() {
4731
5020
  var _a;
4732
- (0, import_log16.log)("stopping...", void 0, {
4733
- F: __dxlog_file18,
4734
- L: 121,
5021
+ (0, import_log17.log)("stopping...", void 0, {
5022
+ F: __dxlog_file19,
5023
+ L: 122,
4735
5024
  S: this,
4736
5025
  C: (f, a) => f(...a)
4737
5026
  });
4738
5027
  await this._clientRpc.close();
4739
5028
  await this._clientServices.close();
4740
5029
  await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
4741
- (0, import_log16.log)("stopped", void 0, {
4742
- F: __dxlog_file18,
4743
- L: 125,
5030
+ (0, import_log17.log)("stopped", void 0, {
5031
+ F: __dxlog_file19,
5032
+ L: 126,
4744
5033
  S: this,
4745
5034
  C: (f, a) => f(...a)
4746
5035
  });
4747
5036
  }
4748
5037
  };
4749
- _ts_decorate5([
4750
- import_log16.logInfo
5038
+ _ts_decorate8([
5039
+ import_log17.logInfo
4751
5040
  ], IFrameHostRuntime.prototype, "origin", void 0);
4752
5041
 
4753
5042
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
4754
5043
  var import_async20 = require("@dxos/async");
4755
5044
  var import_client_protocol8 = require("@dxos/client-protocol");
4756
5045
  var import_errors6 = require("@dxos/errors");
4757
- var import_log17 = require("@dxos/log");
5046
+ var import_log18 = require("@dxos/log");
4758
5047
  var import_network_manager4 = require("@dxos/network-manager");
4759
5048
  var import_rpc3 = require("@dxos/rpc");
4760
- var import_util10 = require("@dxos/util");
4761
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
5049
+ var import_util11 = require("@dxos/util");
5050
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
4762
5051
  var IFrameProxyRuntime = class {
4763
5052
  constructor({ config, systemPort, shellPort }) {
4764
5053
  this._id = String(Math.floor(Math.random() * 1e6));
@@ -4775,7 +5064,7 @@ var IFrameProxyRuntime = class {
4775
5064
  }
4776
5065
  async open(origin) {
4777
5066
  var _a;
4778
- this._config = await (0, import_util10.getAsyncValue)(this._configProvider);
5067
+ this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
4779
5068
  this._transportService = new import_network_manager4.WebRTCTransportService({
4780
5069
  iceServers: this._config.get("runtime.services.ice")
4781
5070
  });
@@ -4806,8 +5095,8 @@ var IFrameProxyRuntime = class {
4806
5095
  lockKey
4807
5096
  });
4808
5097
  } catch (err) {
4809
- import_log17.log.catch(err, void 0, {
4810
- F: __dxlog_file19,
5098
+ import_log18.log.catch(err, void 0, {
5099
+ F: __dxlog_file20,
4811
5100
  L: 85,
4812
5101
  S: this,
4813
5102
  C: (f, a) => f(...a)
@@ -4830,18 +5119,19 @@ var IFrameProxyRuntime = class {
4830
5119
 
4831
5120
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
4832
5121
  var import_async22 = require("@dxos/async");
4833
- var import_log19 = require("@dxos/log");
5122
+ var import_context12 = require("@dxos/context");
5123
+ var import_log20 = require("@dxos/log");
4834
5124
  var import_messaging3 = require("@dxos/messaging");
4835
5125
  var import_network_manager5 = require("@dxos/network-manager");
4836
5126
 
4837
5127
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
4838
5128
  var import_async21 = require("@dxos/async");
4839
5129
  var import_client_protocol9 = require("@dxos/client-protocol");
4840
- var import_invariant15 = require("@dxos/invariant");
4841
- var import_log18 = require("@dxos/log");
5130
+ var import_invariant16 = require("@dxos/invariant");
5131
+ var import_log19 = require("@dxos/log");
4842
5132
  var import_rpc4 = require("@dxos/rpc");
4843
- var import_util11 = require("@dxos/util");
4844
- function _ts_decorate6(decorators, target, key, desc) {
5133
+ var import_util12 = require("@dxos/util");
5134
+ function _ts_decorate9(decorators, target, key, desc) {
4845
5135
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4846
5136
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4847
5137
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4851,13 +5141,13 @@ function _ts_decorate6(decorators, target, key, desc) {
4851
5141
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4852
5142
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4853
5143
  }
4854
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
5144
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
4855
5145
  var WorkerSession = class {
4856
5146
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
4857
5147
  this._startTrigger = new import_async21.Trigger();
4858
- this.onClose = new import_util11.Callback();
4859
- (0, import_invariant15.invariant)(serviceHost, void 0, {
4860
- F: __dxlog_file20,
5148
+ this.onClose = new import_util12.Callback();
5149
+ (0, import_invariant16.invariant)(serviceHost, void 0, {
5150
+ F: __dxlog_file21,
4861
5151
  L: 49,
4862
5152
  S: this,
4863
5153
  A: [
@@ -4911,9 +5201,9 @@ var WorkerSession = class {
4911
5201
  try {
4912
5202
  await this.close();
4913
5203
  } catch (err) {
4914
- import_log18.log.catch(err, void 0, {
4915
- F: __dxlog_file20,
4916
- L: 98,
5204
+ import_log19.log.catch(err, void 0, {
5205
+ F: __dxlog_file21,
5206
+ L: 99,
4917
5207
  S: this,
4918
5208
  C: (f, a) => f(...a)
4919
5209
  });
@@ -4928,9 +5218,9 @@ var WorkerSession = class {
4928
5218
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
4929
5219
  }
4930
5220
  async open() {
4931
- import_log18.log.info("opening...", void 0, {
4932
- F: __dxlog_file20,
4933
- L: 112,
5221
+ import_log19.log.info("opening...", void 0, {
5222
+ F: __dxlog_file21,
5223
+ L: 113,
4934
5224
  S: this,
4935
5225
  C: (f, a) => f(...a)
4936
5226
  });
@@ -4945,26 +5235,26 @@ var WorkerSession = class {
4945
5235
  if (this.lockKey) {
4946
5236
  void this._afterLockReleases(this.lockKey, () => this.close());
4947
5237
  }
4948
- import_log18.log.info("opened", void 0, {
4949
- F: __dxlog_file20,
4950
- L: 119,
5238
+ import_log19.log.info("opened", void 0, {
5239
+ F: __dxlog_file21,
5240
+ L: 124,
4951
5241
  S: this,
4952
5242
  C: (f, a) => f(...a)
4953
5243
  });
4954
5244
  }
4955
5245
  async close() {
4956
- import_log18.log.info("closing...", void 0, {
4957
- F: __dxlog_file20,
4958
- L: 123,
5246
+ import_log19.log.info("closing...", void 0, {
5247
+ F: __dxlog_file21,
5248
+ L: 128,
4959
5249
  S: this,
4960
5250
  C: (f, a) => f(...a)
4961
5251
  });
4962
5252
  try {
4963
5253
  await this.onClose.callIfSet();
4964
5254
  } catch (err) {
4965
- import_log18.log.catch(err, void 0, {
4966
- F: __dxlog_file20,
4967
- L: 127,
5255
+ import_log19.log.catch(err, void 0, {
5256
+ F: __dxlog_file21,
5257
+ L: 132,
4968
5258
  S: this,
4969
5259
  C: (f, a) => f(...a)
4970
5260
  });
@@ -4973,9 +5263,9 @@ var WorkerSession = class {
4973
5263
  this._clientRpc.close(),
4974
5264
  this._iframeRpc.close()
4975
5265
  ]);
4976
- import_log18.log.info("closed", void 0, {
4977
- F: __dxlog_file20,
4978
- L: 131,
5266
+ import_log19.log.info("closed", void 0, {
5267
+ F: __dxlog_file21,
5268
+ L: 136,
4979
5269
  S: this,
4980
5270
  C: (f, a) => f(...a)
4981
5271
  });
@@ -4984,9 +5274,9 @@ var WorkerSession = class {
4984
5274
  try {
4985
5275
  await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
4986
5276
  } catch (e) {
4987
- import_log18.log.info("No shell connected.", void 0, {
4988
- F: __dxlog_file20,
4989
- L: 138,
5277
+ import_log19.log.info("No shell connected.", void 0, {
5278
+ F: __dxlog_file21,
5279
+ L: 143,
4990
5280
  S: this,
4991
5281
  C: (f, a) => f(...a)
4992
5282
  });
@@ -4997,15 +5287,15 @@ var WorkerSession = class {
4997
5287
  }).then(callback);
4998
5288
  }
4999
5289
  };
5000
- _ts_decorate6([
5001
- import_log18.logInfo
5290
+ _ts_decorate9([
5291
+ import_log19.logInfo
5002
5292
  ], WorkerSession.prototype, "origin", void 0);
5003
- _ts_decorate6([
5004
- import_log18.logInfo
5293
+ _ts_decorate9([
5294
+ import_log19.logInfo
5005
5295
  ], WorkerSession.prototype, "lockKey", void 0);
5006
5296
 
5007
5297
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
5008
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
5298
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
5009
5299
  var WorkerRuntime = class {
5010
5300
  // prettier-ignore
5011
5301
  constructor(_configProvider) {
@@ -5025,9 +5315,9 @@ var WorkerRuntime = class {
5025
5315
  return this._clientServices;
5026
5316
  }
5027
5317
  async start() {
5028
- (0, import_log19.log)("starting...", void 0, {
5029
- F: __dxlog_file21,
5030
- L: 48,
5318
+ (0, import_log20.log)("starting...", void 0, {
5319
+ F: __dxlog_file22,
5320
+ L: 49,
5031
5321
  S: this,
5032
5322
  C: (f, a) => f(...a)
5033
5323
  });
@@ -5039,19 +5329,19 @@ var WorkerRuntime = class {
5039
5329
  signalManager: signals ? new import_messaging3.WebsocketSignalManager(signals) : new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
5040
5330
  transportFactory: this._transportFactory
5041
5331
  });
5042
- await this._clientServices.open();
5332
+ await this._clientServices.open(new import_context12.Context());
5043
5333
  this._ready.wake(void 0);
5044
- (0, import_log19.log)("started", void 0, {
5045
- F: __dxlog_file21,
5046
- L: 62,
5334
+ (0, import_log20.log)("started", void 0, {
5335
+ F: __dxlog_file22,
5336
+ L: 63,
5047
5337
  S: this,
5048
5338
  C: (f, a) => f(...a)
5049
5339
  });
5050
5340
  } catch (err) {
5051
5341
  this._ready.wake(err);
5052
- import_log19.log.catch(err, void 0, {
5053
- F: __dxlog_file21,
5054
- L: 65,
5342
+ import_log20.log.catch(err, void 0, {
5343
+ F: __dxlog_file22,
5344
+ L: 66,
5055
5345
  S: this,
5056
5346
  C: (f, a) => f(...a)
5057
5347
  });
@@ -5083,9 +5373,9 @@ var WorkerRuntime = class {
5083
5373
  * Selects one of the existing session fro WebRTC networking.
5084
5374
  */
5085
5375
  _reconnectWebrtc() {
5086
- (0, import_log19.log)("reconnecting webrtc...", void 0, {
5087
- F: __dxlog_file21,
5088
- L: 102,
5376
+ (0, import_log20.log)("reconnecting webrtc...", void 0, {
5377
+ F: __dxlog_file22,
5378
+ L: 103,
5089
5379
  S: this,
5090
5380
  C: (f, a) => f(...a)
5091
5381
  });
@@ -5132,6 +5422,7 @@ var WorkerRuntime = class {
5132
5422
  WorkerSession,
5133
5423
  createAuthProvider,
5134
5424
  createDefaultModelFactory,
5425
+ createDiagnostics,
5135
5426
  createStorageObjects,
5136
5427
  getNetworkPeers,
5137
5428
  isLocked,