@dxos/client-services 0.1.56-main.28af2e2 → 0.1.56-main.390ac2a

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 (73) hide show
  1. package/dist/lib/browser/{chunk-CSJSC47N.mjs → chunk-KSADD5WV.mjs} +978 -385
  2. package/dist/lib/browser/chunk-KSADD5WV.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +50 -31
  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 +12 -3
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +1121 -512
  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 +1268 -669
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  16. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  21. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  22. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  23. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  24. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  25. package/dist/types/src/packlets/services/index.d.ts +1 -0
  26. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  27. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  28. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  29. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/service-host.d.ts +4 -2
  31. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  32. package/dist/types/src/packlets/services/util.d.ts +6 -0
  33. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  34. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  35. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  36. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  37. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  38. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  39. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  40. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  41. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  42. package/dist/types/src/version.d.ts +2 -0
  43. package/dist/types/src/version.d.ts.map +1 -0
  44. package/package.json +33 -33
  45. package/src/packlets/identity/authenticator.test.ts +2 -2
  46. package/src/packlets/identity/identity-manager.ts +1 -2
  47. package/src/packlets/identity/identity-service.ts +1 -2
  48. package/src/packlets/identity/identity.ts +1 -2
  49. package/src/packlets/invitations/device-invitation-protocol.ts +1 -2
  50. package/src/packlets/invitations/invitation-extension.ts +1 -2
  51. package/src/packlets/invitations/invitations-handler.ts +1 -2
  52. package/src/packlets/invitations/invitations-service.ts +1 -2
  53. package/src/packlets/invitations/space-invitation-protocol.ts +1 -2
  54. package/src/packlets/locks/node.ts +1 -1
  55. package/src/packlets/logging/logging-service.ts +17 -9
  56. package/src/packlets/services/diagnostics.ts +211 -0
  57. package/src/packlets/services/index.ts +1 -0
  58. package/src/packlets/services/platform.ts +48 -0
  59. package/src/packlets/services/service-context.ts +3 -5
  60. package/src/packlets/services/service-host.test.ts +5 -5
  61. package/src/packlets/services/service-host.ts +23 -20
  62. package/src/packlets/services/service-registry.test.ts +1 -0
  63. package/src/packlets/services/util.ts +33 -0
  64. package/src/packlets/spaces/data-space-manager.ts +2 -3
  65. package/src/packlets/spaces/notarization-plugin.ts +1 -2
  66. package/src/packlets/spaces/spaces-service.ts +18 -12
  67. package/src/packlets/system/system-service.test.ts +1 -0
  68. package/src/packlets/system/system-service.ts +34 -2
  69. package/src/packlets/testing/invitation-utils.ts +1 -2
  70. package/src/packlets/vault/shell-runtime.ts +1 -2
  71. package/src/packlets/vault/worker-session.ts +7 -3
  72. package/src/version.ts +1 -0
  73. package/dist/lib/browser/chunk-CSJSC47N.mjs.map +0 -7
@@ -463,12 +463,12 @@ var TrustedKeySetAuthVerifier = class {
463
463
  };
464
464
 
465
465
  // packages/sdk/client-services/src/packlets/identity/identity.ts
466
- import invariant from "tiny-invariant";
467
466
  import { Event } from "@dxos/async";
468
467
  import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
469
468
  import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
470
469
  import { failUndefined } from "@dxos/debug";
471
470
  import { writeMessages } from "@dxos/feed-store";
471
+ import { invariant } from "@dxos/invariant";
472
472
  import { log as log2 } from "@dxos/log";
473
473
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
474
474
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
@@ -546,7 +546,15 @@ var Identity = class {
546
546
  * Requires identity to be ready.
547
547
  */
548
548
  getIdentityCredentialSigner() {
549
- invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
549
+ invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
550
+ F: __dxlog_file2,
551
+ L: 134,
552
+ S: this,
553
+ A: [
554
+ "this._deviceStateMachine.deviceCredentialChain",
555
+ "'Device credential chain is not ready.'"
556
+ ]
557
+ });
550
558
  return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
551
559
  }
552
560
  /**
@@ -564,7 +572,7 @@ var Identity = class {
564
572
  dataFeedKey
565
573
  }, {
566
574
  F: __dxlog_file2,
567
- L: 151,
575
+ L: 150,
568
576
  S: this,
569
577
  C: (f, a) => f(...a)
570
578
  });
@@ -607,9 +615,9 @@ var Identity = class {
607
615
  };
608
616
 
609
617
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
610
- import invariant2 from "tiny-invariant";
611
618
  import { Event as Event2 } from "@dxos/async";
612
619
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
620
+ import { invariant as invariant2 } from "@dxos/invariant";
613
621
  import { PublicKey as PublicKey3 } from "@dxos/keys";
614
622
  import { log as log3 } from "@dxos/log";
615
623
  import { trace } from "@dxos/protocols";
@@ -636,7 +644,7 @@ var IdentityManager = class {
636
644
  id: traceId
637
645
  }), {
638
646
  F: __dxlog_file3,
639
- L: 70,
647
+ L: 69,
640
648
  S: this,
641
649
  C: (f, a) => f(...a)
642
650
  });
@@ -646,7 +654,7 @@ var IdentityManager = class {
646
654
  identityRecord
647
655
  }, {
648
656
  F: __dxlog_file3,
649
- L: 74,
657
+ L: 73,
650
658
  S: this,
651
659
  C: (f, a) => f(...a)
652
660
  });
@@ -659,7 +667,7 @@ var IdentityManager = class {
659
667
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
660
668
  }, {
661
669
  F: __dxlog_file3,
662
- L: 79,
670
+ L: 78,
663
671
  S: this,
664
672
  C: (f, a) => f(...a)
665
673
  });
@@ -669,7 +677,7 @@ var IdentityManager = class {
669
677
  id: traceId
670
678
  }), {
671
679
  F: __dxlog_file3,
672
- L: 85,
680
+ L: 84,
673
681
  S: this,
674
682
  C: (f, a) => f(...a)
675
683
  });
@@ -680,10 +688,18 @@ var IdentityManager = class {
680
688
  }
681
689
  async createIdentity({ displayName } = {}) {
682
690
  var _a;
683
- invariant2(!this._identity, "Identity already exists.");
691
+ invariant2(!this._identity, "Identity already exists.", {
692
+ F: __dxlog_file3,
693
+ L: 92,
694
+ S: this,
695
+ A: [
696
+ "!this._identity",
697
+ "'Identity already exists.'"
698
+ ]
699
+ });
684
700
  log3("creating identity...", void 0, {
685
701
  F: __dxlog_file3,
686
- L: 94,
702
+ L: 93,
687
703
  S: this,
688
704
  C: (f, a) => f(...a)
689
705
  });
@@ -702,8 +718,24 @@ var IdentityManager = class {
702
718
  await identity.open();
703
719
  {
704
720
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
705
- invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
706
- invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
721
+ invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
722
+ F: __dxlog_file3,
723
+ L: 112,
724
+ S: this,
725
+ A: [
726
+ "identityRecord.haloSpace.genesisFeedKey",
727
+ "'Genesis feed key is required.'"
728
+ ]
729
+ });
730
+ invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
731
+ F: __dxlog_file3,
732
+ L: 113,
733
+ S: this,
734
+ A: [
735
+ "identityRecord.haloSpace.dataFeedKey",
736
+ "'Data feed key is required.'"
737
+ ]
738
+ });
707
739
  const credentials = [
708
740
  // Space genesis.
709
741
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
@@ -732,7 +764,7 @@ var IdentityManager = class {
732
764
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
733
765
  }, {
734
766
  F: __dxlog_file3,
735
- L: 149,
767
+ L: 148,
736
768
  S: this,
737
769
  C: (f, a) => f(...a)
738
770
  });
@@ -742,7 +774,7 @@ var IdentityManager = class {
742
774
  deviceKey: identity.deviceKey
743
775
  }, {
744
776
  F: __dxlog_file3,
745
- L: 155,
777
+ L: 154,
746
778
  S: this,
747
779
  C: (f, a) => f(...a)
748
780
  });
@@ -757,11 +789,19 @@ var IdentityManager = class {
757
789
  params
758
790
  }, {
759
791
  F: __dxlog_file3,
760
- L: 163,
792
+ L: 162,
761
793
  S: this,
762
794
  C: (f, a) => f(...a)
763
795
  });
764
- invariant2(!this._identity, "Identity already exists.");
796
+ invariant2(!this._identity, "Identity already exists.", {
797
+ F: __dxlog_file3,
798
+ L: 163,
799
+ S: this,
800
+ A: [
801
+ "!this._identity",
802
+ "'Identity already exists.'"
803
+ ]
804
+ });
765
805
  const identityRecord = {
766
806
  identityKey: params.identityKey,
767
807
  deviceKey: params.deviceKey,
@@ -783,7 +823,7 @@ var IdentityManager = class {
783
823
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
784
824
  }, {
785
825
  F: __dxlog_file3,
786
- L: 183,
826
+ L: 182,
787
827
  S: this,
788
828
  C: (f, a) => f(...a)
789
829
  });
@@ -793,27 +833,51 @@ var IdentityManager = class {
793
833
  deviceKey: identity.deviceKey
794
834
  }, {
795
835
  F: __dxlog_file3,
796
- L: 189,
836
+ L: 188,
797
837
  S: this,
798
838
  C: (f, a) => f(...a)
799
839
  });
800
840
  return identity;
801
841
  }
802
842
  async _constructIdentity(identityRecord) {
803
- invariant2(!this._identity);
843
+ invariant2(!this._identity, void 0, {
844
+ F: __dxlog_file3,
845
+ L: 193,
846
+ S: this,
847
+ A: [
848
+ "!this._identity",
849
+ ""
850
+ ]
851
+ });
804
852
  log3("constructing identity", {
805
853
  identityRecord
806
854
  }, {
807
855
  F: __dxlog_file3,
808
- L: 195,
856
+ L: 194,
809
857
  S: this,
810
858
  C: (f, a) => f(...a)
811
859
  });
812
- invariant2(identityRecord.haloSpace.controlFeedKey);
860
+ invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
861
+ F: __dxlog_file3,
862
+ L: 197,
863
+ S: this,
864
+ A: [
865
+ "identityRecord.haloSpace.controlFeedKey",
866
+ ""
867
+ ]
868
+ });
813
869
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
814
870
  writable: true
815
871
  });
816
- invariant2(identityRecord.haloSpace.dataFeedKey);
872
+ invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
873
+ F: __dxlog_file3,
874
+ L: 201,
875
+ S: this,
876
+ A: [
877
+ "identityRecord.haloSpace.dataFeedKey",
878
+ ""
879
+ ]
880
+ });
817
881
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
818
882
  writable: true,
819
883
  sparse: true
@@ -839,7 +903,7 @@ var IdentityManager = class {
839
903
  identityKey: identityRecord.identityKey
840
904
  }, {
841
905
  F: __dxlog_file3,
842
- L: 226,
906
+ L: 225,
843
907
  S: this,
844
908
  C: (f, a) => f(...a)
845
909
  });
@@ -860,7 +924,7 @@ var IdentityManager = class {
860
924
  onAuthFailure: () => {
861
925
  log3.warn("auth failure", void 0, {
862
926
  F: __dxlog_file3,
863
- L: 245,
927
+ L: 244,
864
928
  S: this,
865
929
  C: (f, a) => f(...a)
866
930
  });
@@ -871,10 +935,11 @@ var IdentityManager = class {
871
935
  };
872
936
 
873
937
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
874
- import invariant3 from "tiny-invariant";
875
938
  import { Stream as Stream7 } from "@dxos/codec-protobuf";
876
939
  import { signPresentation } from "@dxos/credentials";
877
940
  import { todo } from "@dxos/debug";
941
+ import { invariant as invariant3 } from "@dxos/invariant";
942
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
878
943
  var IdentityServiceImpl = class {
879
944
  // TODO(wittjosiah): Remove dependency on service context.
880
945
  constructor(_serviceContext) {
@@ -907,7 +972,15 @@ var IdentityServiceImpl = class {
907
972
  };
908
973
  }
909
974
  async signPresentation({ presentation, nonce }) {
910
- invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.");
975
+ invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.", {
976
+ F: __dxlog_file4,
977
+ L: 56,
978
+ S: this,
979
+ A: [
980
+ "this._serviceContext.identityManager.identity",
981
+ "'Identity not initialized.'"
982
+ ]
983
+ });
911
984
  return await signPresentation({
912
985
  presentation,
913
986
  signer: this._serviceContext.keyring,
@@ -919,8 +992,9 @@ var IdentityServiceImpl = class {
919
992
  };
920
993
 
921
994
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
922
- import invariant4 from "tiny-invariant";
995
+ import { invariant as invariant4 } from "@dxos/invariant";
923
996
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
997
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
924
998
  var DeviceInvitationProtocol = class {
925
999
  constructor(_keyring, _getIdentity, _acceptIdentity) {
926
1000
  this._keyring = _keyring;
@@ -936,7 +1010,15 @@ var DeviceInvitationProtocol = class {
936
1010
  };
937
1011
  }
938
1012
  async admit(request) {
939
- invariant4(request.device);
1013
+ invariant4(request.device, void 0, {
1014
+ F: __dxlog_file5,
1015
+ L: 31,
1016
+ S: this,
1017
+ A: [
1018
+ "request.device",
1019
+ ""
1020
+ ]
1021
+ });
940
1022
  const identity = this._getIdentity();
941
1023
  await identity.admitDevice(request.device);
942
1024
  return {
@@ -964,9 +1046,25 @@ var DeviceInvitationProtocol = class {
964
1046
  };
965
1047
  }
966
1048
  async accept(response, request) {
967
- invariant4(response.device);
1049
+ invariant4(response.device, void 0, {
1050
+ F: __dxlog_file5,
1051
+ L: 64,
1052
+ S: this,
1053
+ A: [
1054
+ "response.device",
1055
+ ""
1056
+ ]
1057
+ });
968
1058
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
969
- invariant4(request.device);
1059
+ invariant4(request.device, void 0, {
1060
+ F: __dxlog_file5,
1061
+ L: 67,
1062
+ S: this,
1063
+ A: [
1064
+ "request.device",
1065
+ ""
1066
+ ]
1067
+ });
970
1068
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
971
1069
  await this._acceptIdentity({
972
1070
  identityKey,
@@ -984,12 +1082,12 @@ var DeviceInvitationProtocol = class {
984
1082
  };
985
1083
 
986
1084
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
987
- import invariant6 from "tiny-invariant";
988
1085
  import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
989
1086
  import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
990
1087
  import { Context as Context4 } from "@dxos/context";
991
1088
  import { generatePasscode } from "@dxos/credentials";
992
1089
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
1090
+ import { invariant as invariant6 } from "@dxos/invariant";
993
1091
  import { PublicKey as PublicKey5 } from "@dxos/keys";
994
1092
  import { log as log5 } from "@dxos/log";
995
1093
  import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
@@ -998,17 +1096,17 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
998
1096
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
999
1097
 
1000
1098
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1001
- import invariant5 from "tiny-invariant";
1002
1099
  import { Trigger as Trigger2 } from "@dxos/async";
1003
1100
  import { cancelWithContext, Context as Context3 } from "@dxos/context";
1004
1101
  import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
1102
+ import { invariant as invariant5 } from "@dxos/invariant";
1005
1103
  import { PublicKey as PublicKey4 } from "@dxos/keys";
1006
1104
  import { log as log4 } from "@dxos/log";
1007
1105
  import { schema as schema2, trace as trace2 } from "@dxos/protocols";
1008
1106
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
1009
1107
  import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1010
1108
  import { RpcExtension } from "@dxos/teleport";
1011
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1109
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1012
1110
  var OPTIONS_TIMEOUT = 1e4;
1013
1111
  var MAX_OTP_ATTEMPTS = 3;
1014
1112
  var InvitationHostExtension = class extends RpcExtension {
@@ -1036,7 +1134,15 @@ var InvitationHostExtension = class extends RpcExtension {
1036
1134
  // Perhaps in the future we will have more complex logic here.
1037
1135
  InvitationHostService: {
1038
1136
  options: async (options) => {
1039
- invariant5(!this._remoteOptions, "Remote options already set.");
1137
+ invariant5(!this._remoteOptions, "Remote options already set.", {
1138
+ F: __dxlog_file6,
1139
+ L: 88,
1140
+ S: this,
1141
+ A: [
1142
+ "!this._remoteOptions",
1143
+ "'Remote options already set.'"
1144
+ ]
1145
+ });
1040
1146
  this._remoteOptions = options;
1041
1147
  this._remoteOptionsTrigger.wake();
1042
1148
  },
@@ -1046,8 +1152,8 @@ var InvitationHostExtension = class extends RpcExtension {
1046
1152
  log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
1047
1153
  id: traceId
1048
1154
  }), {
1049
- F: __dxlog_file4,
1050
- L: 98,
1155
+ F: __dxlog_file6,
1156
+ L: 97,
1051
1157
  S: this,
1052
1158
  C: (f, a) => f(...a)
1053
1159
  });
@@ -1056,8 +1162,8 @@ var InvitationHostExtension = class extends RpcExtension {
1056
1162
  log4.warn("invitation not found", {
1057
1163
  invitationId
1058
1164
  }, {
1059
- F: __dxlog_file4,
1060
- L: 102,
1165
+ F: __dxlog_file6,
1166
+ L: 101,
1061
1167
  S: this,
1062
1168
  C: (f, a) => f(...a)
1063
1169
  });
@@ -1070,8 +1176,8 @@ var InvitationHostExtension = class extends RpcExtension {
1070
1176
  log4("guest introduced itself", {
1071
1177
  guestProfile: profile
1072
1178
  }, {
1073
- F: __dxlog_file4,
1074
- L: 111,
1179
+ F: __dxlog_file6,
1180
+ L: 110,
1075
1181
  S: this,
1076
1182
  C: (f, a) => f(...a)
1077
1183
  });
@@ -1083,8 +1189,8 @@ var InvitationHostExtension = class extends RpcExtension {
1083
1189
  log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
1084
1190
  id: traceId
1085
1191
  }), {
1086
- F: __dxlog_file4,
1087
- L: 118,
1192
+ F: __dxlog_file6,
1193
+ L: 117,
1088
1194
  S: this,
1089
1195
  C: (f, a) => f(...a)
1090
1196
  });
@@ -1098,26 +1204,34 @@ var InvitationHostExtension = class extends RpcExtension {
1098
1204
  log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
1099
1205
  id: traceId
1100
1206
  }), {
1101
- F: __dxlog_file4,
1102
- L: 127,
1207
+ F: __dxlog_file6,
1208
+ L: 126,
1103
1209
  S: this,
1104
1210
  C: (f, a) => f(...a)
1105
1211
  });
1106
1212
  log4("received authentication request", {
1107
1213
  authCode: code
1108
1214
  }, {
1109
- F: __dxlog_file4,
1110
- L: 128,
1215
+ F: __dxlog_file6,
1216
+ L: 127,
1111
1217
  S: this,
1112
1218
  C: (f, a) => f(...a)
1113
1219
  });
1114
1220
  let status = AuthenticationResponse.Status.OK;
1115
- invariant5(this.invitation, "Invitation is not set.");
1221
+ invariant5(this.invitation, "Invitation is not set.", {
1222
+ F: __dxlog_file6,
1223
+ L: 130,
1224
+ S: this,
1225
+ A: [
1226
+ "this.invitation",
1227
+ "'Invitation is not set.'"
1228
+ ]
1229
+ });
1116
1230
  switch (this.invitation.authMethod) {
1117
1231
  case Invitation2.AuthMethod.NONE: {
1118
1232
  log4("authentication not required", void 0, {
1119
- F: __dxlog_file4,
1120
- L: 134,
1233
+ F: __dxlog_file6,
1234
+ L: 133,
1121
1235
  S: this,
1122
1236
  C: (f, a) => f(...a)
1123
1237
  });
@@ -1141,8 +1255,8 @@ var InvitationHostExtension = class extends RpcExtension {
1141
1255
  log4.error("invalid authentication method", {
1142
1256
  authMethod: this.invitation.authMethod
1143
1257
  }, {
1144
- F: __dxlog_file4,
1145
- L: 152,
1258
+ F: __dxlog_file6,
1259
+ L: 151,
1146
1260
  S: this,
1147
1261
  C: (f, a) => f(...a)
1148
1262
  });
@@ -1156,8 +1270,8 @@ var InvitationHostExtension = class extends RpcExtension {
1156
1270
  status
1157
1271
  }
1158
1272
  }), {
1159
- F: __dxlog_file4,
1160
- L: 158,
1273
+ F: __dxlog_file6,
1274
+ L: 157,
1161
1275
  S: this,
1162
1276
  C: (f, a) => f(...a)
1163
1277
  });
@@ -1170,13 +1284,21 @@ var InvitationHostExtension = class extends RpcExtension {
1170
1284
  log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
1171
1285
  id: traceId
1172
1286
  }), {
1173
- F: __dxlog_file4,
1174
- L: 164,
1287
+ F: __dxlog_file6,
1288
+ L: 163,
1175
1289
  S: this,
1176
1290
  C: (f, a) => f(...a)
1177
1291
  });
1178
1292
  try {
1179
- invariant5(this.invitation, "Invitation is not set.");
1293
+ invariant5(this.invitation, "Invitation is not set.", {
1294
+ F: __dxlog_file6,
1295
+ L: 166,
1296
+ S: this,
1297
+ A: [
1298
+ "this.invitation",
1299
+ "'Invitation is not set.'"
1300
+ ]
1301
+ });
1180
1302
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1181
1303
  throw new Error("Not authenticated");
1182
1304
  }
@@ -1184,8 +1306,8 @@ var InvitationHostExtension = class extends RpcExtension {
1184
1306
  log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
1185
1307
  id: traceId
1186
1308
  }), {
1187
- F: __dxlog_file4,
1188
- L: 175,
1309
+ F: __dxlog_file6,
1310
+ L: 174,
1189
1311
  S: this,
1190
1312
  C: (f, a) => f(...a)
1191
1313
  });
@@ -1241,7 +1363,15 @@ var InvitationGuestExtension = class extends RpcExtension {
1241
1363
  return {
1242
1364
  InvitationHostService: {
1243
1365
  options: async (options) => {
1244
- invariant5(!this._remoteOptions, "Remote options already set.");
1366
+ invariant5(!this._remoteOptions, "Remote options already set.", {
1367
+ F: __dxlog_file6,
1368
+ L: 241,
1369
+ S: this,
1370
+ A: [
1371
+ "!this._remoteOptions",
1372
+ "'Remote options already set.'"
1373
+ ]
1374
+ });
1245
1375
  this._remoteOptions = options;
1246
1376
  this._remoteOptionsTrigger.wake();
1247
1377
  },
@@ -1262,8 +1392,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1262
1392
  await super.onOpen(context);
1263
1393
  try {
1264
1394
  log4("begin options", void 0, {
1265
- F: __dxlog_file4,
1266
- L: 263,
1395
+ F: __dxlog_file6,
1396
+ L: 262,
1267
1397
  S: this,
1268
1398
  C: (f, a) => f(...a)
1269
1399
  });
@@ -1274,8 +1404,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1274
1404
  timeout: OPTIONS_TIMEOUT
1275
1405
  }));
1276
1406
  log4("end options", void 0, {
1277
- F: __dxlog_file4,
1278
- L: 266,
1407
+ F: __dxlog_file6,
1408
+ L: 265,
1279
1409
  S: this,
1280
1410
  C: (f, a) => f(...a)
1281
1411
  });
@@ -1288,8 +1418,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1288
1418
  this._callbacks.onOpen(this._ctx);
1289
1419
  } catch (err) {
1290
1420
  log4("openError", err, {
1291
- F: __dxlog_file4,
1292
- L: 276,
1421
+ F: __dxlog_file6,
1422
+ L: 275,
1293
1423
  S: this,
1294
1424
  C: (f, a) => f(...a)
1295
1425
  });
@@ -1298,8 +1428,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1298
1428
  }
1299
1429
  async onClose() {
1300
1430
  log4("onClose", void 0, {
1301
- F: __dxlog_file4,
1302
- L: 282,
1431
+ F: __dxlog_file6,
1432
+ L: 281,
1303
1433
  S: this,
1304
1434
  C: (f, a) => f(...a)
1305
1435
  });
@@ -1309,7 +1439,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1309
1439
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation2.AuthMethod.NONE;
1310
1440
 
1311
1441
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1312
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1442
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1313
1443
  var InvitationsHandler = class {
1314
1444
  /**
1315
1445
  * @internal
@@ -1321,7 +1451,15 @@ var InvitationsHandler = class {
1321
1451
  var _a;
1322
1452
  const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options != null ? options : {};
1323
1453
  const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
1324
- invariant6(protocol);
1454
+ invariant6(protocol, void 0, {
1455
+ F: __dxlog_file7,
1456
+ L: 76,
1457
+ S: this,
1458
+ A: [
1459
+ "protocol",
1460
+ ""
1461
+ ]
1462
+ });
1325
1463
  const invitation = {
1326
1464
  invitationId,
1327
1465
  type,
@@ -1343,8 +1481,8 @@ var InvitationsHandler = class {
1343
1481
  log5("complete", {
1344
1482
  ...protocol.toJSON()
1345
1483
  }, {
1346
- F: __dxlog_file5,
1347
- L: 99,
1484
+ F: __dxlog_file7,
1485
+ L: 98,
1348
1486
  S: this,
1349
1487
  C: (f, a) => f(...a)
1350
1488
  });
@@ -1368,7 +1506,15 @@ var InvitationsHandler = class {
1368
1506
  var _a2, _b, _c;
1369
1507
  try {
1370
1508
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1371
- invariant6(deviceKey);
1509
+ invariant6(deviceKey, void 0, {
1510
+ F: __dxlog_file7,
1511
+ L: 119,
1512
+ S: this,
1513
+ A: [
1514
+ "deviceKey",
1515
+ ""
1516
+ ]
1517
+ });
1372
1518
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1373
1519
  extension.completedTrigger.wake(deviceKey);
1374
1520
  return admissionResponse;
@@ -1384,16 +1530,16 @@ var InvitationsHandler = class {
1384
1530
  log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
1385
1531
  id: traceId
1386
1532
  }), {
1387
- F: __dxlog_file5,
1388
- L: 138,
1533
+ F: __dxlog_file7,
1534
+ L: 137,
1389
1535
  S: this,
1390
1536
  C: (f, a) => f(...a)
1391
1537
  });
1392
1538
  log5("connected", {
1393
1539
  ...protocol.toJSON()
1394
1540
  }, {
1395
- F: __dxlog_file5,
1396
- L: 139,
1541
+ F: __dxlog_file7,
1542
+ L: 138,
1397
1543
  S: this,
1398
1544
  C: (f, a) => f(...a)
1399
1545
  });
@@ -1408,8 +1554,8 @@ var InvitationsHandler = class {
1408
1554
  guest: deviceKey,
1409
1555
  ...protocol.toJSON()
1410
1556
  }, {
1411
- F: __dxlog_file5,
1412
- L: 142,
1557
+ F: __dxlog_file7,
1558
+ L: 141,
1413
1559
  S: this,
1414
1560
  C: (f, a) => f(...a)
1415
1561
  });
@@ -1420,8 +1566,8 @@ var InvitationsHandler = class {
1420
1566
  log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
1421
1567
  id: traceId
1422
1568
  }), {
1423
- F: __dxlog_file5,
1424
- L: 144,
1569
+ F: __dxlog_file7,
1570
+ L: 143,
1425
1571
  S: this,
1426
1572
  C: (f, a) => f(...a)
1427
1573
  });
@@ -1430,8 +1576,8 @@ var InvitationsHandler = class {
1430
1576
  log5("timeout", {
1431
1577
  ...protocol.toJSON()
1432
1578
  }, {
1433
- F: __dxlog_file5,
1434
- L: 147,
1579
+ F: __dxlog_file7,
1580
+ L: 146,
1435
1581
  S: this,
1436
1582
  C: (f, a) => f(...a)
1437
1583
  });
@@ -1441,8 +1587,8 @@ var InvitationsHandler = class {
1441
1587
  });
1442
1588
  } else {
1443
1589
  log5.error("failed", err, {
1444
- F: __dxlog_file5,
1445
- L: 150,
1590
+ F: __dxlog_file7,
1591
+ L: 149,
1446
1592
  S: this,
1447
1593
  C: (f, a) => f(...a)
1448
1594
  });
@@ -1452,8 +1598,8 @@ var InvitationsHandler = class {
1452
1598
  id: traceId,
1453
1599
  error: err
1454
1600
  }), {
1455
- F: __dxlog_file5,
1456
- L: 153,
1601
+ F: __dxlog_file7,
1602
+ L: 152,
1457
1603
  S: this,
1458
1604
  C: (f, a) => f(...a)
1459
1605
  });
@@ -1473,8 +1619,8 @@ var InvitationsHandler = class {
1473
1619
  log5("timeout", {
1474
1620
  ...protocol.toJSON()
1475
1621
  }, {
1476
- F: __dxlog_file5,
1477
- L: 168,
1622
+ F: __dxlog_file7,
1623
+ L: 167,
1478
1624
  S: this,
1479
1625
  C: (f, a) => f(...a)
1480
1626
  });
@@ -1484,8 +1630,8 @@ var InvitationsHandler = class {
1484
1630
  });
1485
1631
  } else {
1486
1632
  log5.error("failed", err, {
1487
- F: __dxlog_file5,
1488
- L: 171,
1633
+ F: __dxlog_file7,
1634
+ L: 170,
1489
1635
  S: this,
1490
1636
  C: (f, a) => f(...a)
1491
1637
  });
@@ -1527,13 +1673,29 @@ var InvitationsHandler = class {
1527
1673
  }
1528
1674
  acceptInvitation(protocol, invitation) {
1529
1675
  const { timeout = INVITATION_TIMEOUT } = invitation;
1530
- invariant6(protocol);
1676
+ invariant6(protocol, void 0, {
1677
+ F: __dxlog_file7,
1678
+ L: 210,
1679
+ S: this,
1680
+ A: [
1681
+ "protocol",
1682
+ ""
1683
+ ]
1684
+ });
1531
1685
  const authenticated = new Trigger3();
1532
1686
  let admitted = false;
1533
1687
  let currentState;
1534
1688
  const stream = new PushStream();
1535
1689
  const setState = (newData) => {
1536
- invariant6(newData.state !== void 0);
1690
+ invariant6(newData.state !== void 0, void 0, {
1691
+ F: __dxlog_file7,
1692
+ L: 221,
1693
+ S: this,
1694
+ A: [
1695
+ "newData.state !== undefined",
1696
+ ""
1697
+ ]
1698
+ });
1537
1699
  currentState = newData.state;
1538
1700
  stream.next({
1539
1701
  ...invitation,
@@ -1546,8 +1708,8 @@ var InvitationsHandler = class {
1546
1708
  log5("timeout", {
1547
1709
  ...protocol.toJSON()
1548
1710
  }, {
1549
- F: __dxlog_file5,
1550
- L: 230,
1711
+ F: __dxlog_file7,
1712
+ L: 229,
1551
1713
  S: this,
1552
1714
  C: (f, a) => f(...a)
1553
1715
  });
@@ -1556,8 +1718,8 @@ var InvitationsHandler = class {
1556
1718
  });
1557
1719
  } else {
1558
1720
  log5.warn("auth failed", err, {
1559
- F: __dxlog_file5,
1560
- L: 233,
1721
+ F: __dxlog_file7,
1722
+ L: 232,
1561
1723
  S: this,
1562
1724
  C: (f, a) => f(...a)
1563
1725
  });
@@ -1570,8 +1732,8 @@ var InvitationsHandler = class {
1570
1732
  log5("complete", {
1571
1733
  ...protocol.toJSON()
1572
1734
  }, {
1573
- F: __dxlog_file5,
1574
- L: 241,
1735
+ F: __dxlog_file7,
1736
+ L: 240,
1575
1737
  S: this,
1576
1738
  C: (f, a) => f(...a)
1577
1739
  });
@@ -1585,8 +1747,8 @@ var InvitationsHandler = class {
1585
1747
  log5("extension disposed", {
1586
1748
  currentState
1587
1749
  }, {
1588
- F: __dxlog_file5,
1589
- L: 251,
1750
+ F: __dxlog_file7,
1751
+ L: 250,
1590
1752
  S: this,
1591
1753
  C: (f, a) => f(...a)
1592
1754
  });
@@ -1600,8 +1762,8 @@ var InvitationsHandler = class {
1600
1762
  log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
1601
1763
  id: traceId
1602
1764
  }), {
1603
- F: __dxlog_file5,
1604
- L: 260,
1765
+ F: __dxlog_file7,
1766
+ L: 259,
1605
1767
  S: this,
1606
1768
  C: (f, a) => f(...a)
1607
1769
  });
@@ -1612,8 +1774,8 @@ var InvitationsHandler = class {
1612
1774
  log5("connected", {
1613
1775
  ...protocol.toJSON()
1614
1776
  }, {
1615
- F: __dxlog_file5,
1616
- L: 268,
1777
+ F: __dxlog_file7,
1778
+ L: 267,
1617
1779
  S: this,
1618
1780
  C: (f, a) => f(...a)
1619
1781
  });
@@ -1623,8 +1785,8 @@ var InvitationsHandler = class {
1623
1785
  log5("introduce", {
1624
1786
  ...protocol.toJSON()
1625
1787
  }, {
1626
- F: __dxlog_file5,
1627
- L: 272,
1788
+ F: __dxlog_file7,
1789
+ L: 271,
1628
1790
  S: this,
1629
1791
  C: (f, a) => f(...a)
1630
1792
  });
@@ -1633,8 +1795,8 @@ var InvitationsHandler = class {
1633
1795
  ...protocol.toJSON(),
1634
1796
  response: introductionResponse
1635
1797
  }, {
1636
- F: __dxlog_file5,
1637
- L: 276,
1798
+ F: __dxlog_file7,
1799
+ L: 275,
1638
1800
  S: this,
1639
1801
  C: (f, a) => f(...a)
1640
1802
  });
@@ -1645,8 +1807,8 @@ var InvitationsHandler = class {
1645
1807
  if (isAuthenticationRequired(invitation)) {
1646
1808
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1647
1809
  log5("guest waiting for authentication code...", void 0, {
1648
- F: __dxlog_file5,
1649
- L: 285,
1810
+ F: __dxlog_file7,
1811
+ L: 284,
1650
1812
  S: this,
1651
1813
  C: (f, a) => f(...a)
1652
1814
  });
@@ -1657,8 +1819,8 @@ var InvitationsHandler = class {
1657
1819
  timeout
1658
1820
  });
1659
1821
  log5("sending authentication request", void 0, {
1660
- F: __dxlog_file5,
1661
- L: 289,
1822
+ F: __dxlog_file7,
1823
+ L: 288,
1662
1824
  S: this,
1663
1825
  C: (f, a) => f(...a)
1664
1826
  });
@@ -1678,8 +1840,8 @@ var InvitationsHandler = class {
1678
1840
  log5("retrying invalid code", {
1679
1841
  attempt
1680
1842
  }, {
1681
- F: __dxlog_file5,
1682
- L: 300,
1843
+ F: __dxlog_file7,
1844
+ L: 299,
1683
1845
  S: this,
1684
1846
  C: (f, a) => f(...a)
1685
1847
  });
@@ -1695,8 +1857,8 @@ var InvitationsHandler = class {
1695
1857
  log5("request admission", {
1696
1858
  ...protocol.toJSON()
1697
1859
  }, {
1698
- F: __dxlog_file5,
1699
- L: 311,
1860
+ F: __dxlog_file7,
1861
+ L: 310,
1700
1862
  S: this,
1701
1863
  C: (f, a) => f(...a)
1702
1864
  });
@@ -1707,8 +1869,8 @@ var InvitationsHandler = class {
1707
1869
  log5("admitted by host", {
1708
1870
  ...protocol.toJSON()
1709
1871
  }, {
1710
- F: __dxlog_file5,
1711
- L: 322,
1872
+ F: __dxlog_file7,
1873
+ L: 321,
1712
1874
  S: this,
1713
1875
  C: (f, a) => f(...a)
1714
1876
  });
@@ -1719,8 +1881,8 @@ var InvitationsHandler = class {
1719
1881
  log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
1720
1882
  id: traceId
1721
1883
  }), {
1722
- F: __dxlog_file5,
1723
- L: 324,
1884
+ F: __dxlog_file7,
1885
+ L: 323,
1724
1886
  S: this,
1725
1887
  C: (f, a) => f(...a)
1726
1888
  });
@@ -1729,8 +1891,8 @@ var InvitationsHandler = class {
1729
1891
  log5("timeout", {
1730
1892
  ...protocol.toJSON()
1731
1893
  }, {
1732
- F: __dxlog_file5,
1733
- L: 327,
1894
+ F: __dxlog_file7,
1895
+ L: 326,
1734
1896
  S: this,
1735
1897
  C: (f, a) => f(...a)
1736
1898
  });
@@ -1739,8 +1901,8 @@ var InvitationsHandler = class {
1739
1901
  });
1740
1902
  } else {
1741
1903
  log5("auth failed", err, {
1742
- F: __dxlog_file5,
1743
- L: 330,
1904
+ F: __dxlog_file7,
1905
+ L: 329,
1744
1906
  S: this,
1745
1907
  C: (f, a) => f(...a)
1746
1908
  });
@@ -1750,8 +1912,8 @@ var InvitationsHandler = class {
1750
1912
  id: traceId,
1751
1913
  error: err
1752
1914
  }), {
1753
- F: __dxlog_file5,
1754
- L: 333,
1915
+ F: __dxlog_file7,
1916
+ L: 332,
1755
1917
  S: this,
1756
1918
  C: (f, a) => f(...a)
1757
1919
  });
@@ -1768,8 +1930,8 @@ var InvitationsHandler = class {
1768
1930
  log5("timeout", {
1769
1931
  ...protocol.toJSON()
1770
1932
  }, {
1771
- F: __dxlog_file5,
1772
- L: 344,
1933
+ F: __dxlog_file7,
1934
+ L: 343,
1773
1935
  S: this,
1774
1936
  C: (f, a) => f(...a)
1775
1937
  });
@@ -1778,8 +1940,8 @@ var InvitationsHandler = class {
1778
1940
  });
1779
1941
  } else {
1780
1942
  log5("auth failed", err, {
1781
- F: __dxlog_file5,
1782
- L: 347,
1943
+ F: __dxlog_file7,
1944
+ L: 346,
1783
1945
  S: this,
1784
1946
  C: (f, a) => f(...a)
1785
1947
  });
@@ -1790,7 +1952,15 @@ var InvitationsHandler = class {
1790
1952
  return extension;
1791
1953
  };
1792
1954
  scheduleTask2(ctx, async () => {
1793
- invariant6(invitation.swarmKey);
1955
+ invariant6(invitation.swarmKey, void 0, {
1956
+ F: __dxlog_file7,
1957
+ L: 356,
1958
+ S: this,
1959
+ A: [
1960
+ "invitation.swarmKey",
1961
+ ""
1962
+ ]
1963
+ });
1794
1964
  const topic = invitation.swarmKey;
1795
1965
  const swarmConnection = await this._networkManager.joinSwarm({
1796
1966
  topic,
@@ -1823,12 +1993,12 @@ var InvitationsHandler = class {
1823
1993
  };
1824
1994
 
1825
1995
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1826
- import invariant7 from "tiny-invariant";
1827
1996
  import { Event as Event3 } from "@dxos/async";
1828
1997
  import { Stream as Stream8 } from "@dxos/codec-protobuf";
1998
+ import { invariant as invariant7 } from "@dxos/invariant";
1829
1999
  import { log as log6 } from "@dxos/log";
1830
2000
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
1831
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2001
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1832
2002
  var InvitationsServiceImpl = class {
1833
2003
  constructor(_invitationsHandler, _getHandler) {
1834
2004
  this._invitationsHandler = _invitationsHandler;
@@ -1890,19 +2060,27 @@ var InvitationsServiceImpl = class {
1890
2060
  }
1891
2061
  async authenticate({ invitationId, authCode }) {
1892
2062
  log6("authenticating...", void 0, {
1893
- F: __dxlog_file6,
1894
- L: 103,
2063
+ F: __dxlog_file8,
2064
+ L: 102,
1895
2065
  S: this,
1896
2066
  C: (f, a) => f(...a)
1897
2067
  });
1898
- invariant7(invitationId);
2068
+ invariant7(invitationId, void 0, {
2069
+ F: __dxlog_file8,
2070
+ L: 103,
2071
+ S: this,
2072
+ A: [
2073
+ "invitationId",
2074
+ ""
2075
+ ]
2076
+ });
1899
2077
  const observable = this._acceptInvitations.get(invitationId);
1900
2078
  if (!observable) {
1901
2079
  log6.warn("invalid invitation", {
1902
2080
  invitationId
1903
2081
  }, {
1904
- F: __dxlog_file6,
1905
- L: 107,
2082
+ F: __dxlog_file8,
2083
+ L: 106,
1906
2084
  S: this,
1907
2085
  C: (f, a) => f(...a)
1908
2086
  });
@@ -1912,12 +2090,20 @@ var InvitationsServiceImpl = class {
1912
2090
  }
1913
2091
  async cancelInvitation({ invitationId }) {
1914
2092
  log6("deleting...", void 0, {
1915
- F: __dxlog_file6,
1916
- L: 114,
2093
+ F: __dxlog_file8,
2094
+ L: 113,
1917
2095
  S: this,
1918
2096
  C: (f, a) => f(...a)
1919
2097
  });
1920
- invariant7(invitationId);
2098
+ invariant7(invitationId, void 0, {
2099
+ F: __dxlog_file8,
2100
+ L: 114,
2101
+ S: this,
2102
+ A: [
2103
+ "invitationId",
2104
+ ""
2105
+ ]
2106
+ });
1921
2107
  const created = this._createInvitations.get(invitationId);
1922
2108
  const accepted = this._acceptInvitations.get(invitationId);
1923
2109
  if (created) {
@@ -1932,8 +2118,8 @@ var InvitationsServiceImpl = class {
1932
2118
  log6.warn("invalid invitation", {
1933
2119
  invitationId
1934
2120
  }, {
1935
- F: __dxlog_file6,
1936
- L: 127,
2121
+ F: __dxlog_file8,
2122
+ L: 126,
1937
2123
  S: this,
1938
2124
  C: (f, a) => f(...a)
1939
2125
  });
@@ -1992,12 +2178,12 @@ var InvitationsServiceImpl = class {
1992
2178
  };
1993
2179
 
1994
2180
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
1995
- import invariant8 from "tiny-invariant";
1996
2181
  import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
1997
2182
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2183
+ import { invariant as invariant8 } from "@dxos/invariant";
1998
2184
  import { log as log7 } from "@dxos/log";
1999
2185
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
2000
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2186
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2001
2187
  var SpaceInvitationProtocol = class {
2002
2188
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2003
2189
  this._spaceManager = _spaceManager;
@@ -2019,24 +2205,64 @@ var SpaceInvitationProtocol = class {
2019
2205
  }
2020
2206
  async admit(request, guestProfile) {
2021
2207
  var _a;
2022
- invariant8(this._spaceKey);
2208
+ invariant8(this._spaceKey, void 0, {
2209
+ F: __dxlog_file9,
2210
+ L: 42,
2211
+ S: this,
2212
+ A: [
2213
+ "this._spaceKey",
2214
+ ""
2215
+ ]
2216
+ });
2023
2217
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2024
- invariant8(space);
2025
- invariant8(request.space);
2218
+ invariant8(space, void 0, {
2219
+ F: __dxlog_file9,
2220
+ L: 44,
2221
+ S: this,
2222
+ A: [
2223
+ "space",
2224
+ ""
2225
+ ]
2226
+ });
2227
+ invariant8(request.space, void 0, {
2228
+ F: __dxlog_file9,
2229
+ L: 46,
2230
+ S: this,
2231
+ A: [
2232
+ "request.space",
2233
+ ""
2234
+ ]
2235
+ });
2026
2236
  const { identityKey, deviceKey } = request.space;
2027
2237
  log7("writing guest credentials", {
2028
2238
  host: this._signingContext.deviceKey,
2029
2239
  guest: deviceKey
2030
2240
  }, {
2031
- F: __dxlog_file7,
2032
- L: 50,
2241
+ F: __dxlog_file9,
2242
+ L: 49,
2033
2243
  S: this,
2034
2244
  C: (f, a) => f(...a)
2035
2245
  });
2036
2246
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2037
- invariant8(credentials[0].credential);
2247
+ invariant8(credentials[0].credential, void 0, {
2248
+ F: __dxlog_file9,
2249
+ L: 60,
2250
+ S: this,
2251
+ A: [
2252
+ "credentials[0].credential",
2253
+ ""
2254
+ ]
2255
+ });
2038
2256
  const spaceMemberCredential = credentials[0].credential.credential;
2039
- invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2257
+ invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2258
+ F: __dxlog_file9,
2259
+ L: 62,
2260
+ S: this,
2261
+ A: [
2262
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
2263
+ ""
2264
+ ]
2265
+ });
2040
2266
  await writeMessages2(space.inner.controlPipeline.writer, credentials);
2041
2267
  return {
2042
2268
  space: {
@@ -2064,11 +2290,35 @@ var SpaceInvitationProtocol = class {
2064
2290
  };
2065
2291
  }
2066
2292
  async accept(response) {
2067
- invariant8(response.space);
2293
+ invariant8(response.space, void 0, {
2294
+ F: __dxlog_file9,
2295
+ L: 97,
2296
+ S: this,
2297
+ A: [
2298
+ "response.space",
2299
+ ""
2300
+ ]
2301
+ });
2068
2302
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2069
2303
  const assertion = getCredentialAssertion(credential);
2070
- invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2071
- invariant8(credential.subject.id.equals(this._signingContext.identityKey));
2304
+ invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2305
+ F: __dxlog_file9,
2306
+ L: 100,
2307
+ S: this,
2308
+ A: [
2309
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
2310
+ "'Invalid credential'"
2311
+ ]
2312
+ });
2313
+ invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2314
+ F: __dxlog_file9,
2315
+ L: 101,
2316
+ S: this,
2317
+ A: [
2318
+ "credential.subject.id.equals(this._signingContext.identityKey)",
2319
+ ""
2320
+ ]
2321
+ });
2072
2322
  await this._spaceManager.acceptSpace({
2073
2323
  spaceKey: assertion.spaceKey,
2074
2324
  genesisFeedKey: assertion.genesisFeedKey,
@@ -2135,6 +2385,172 @@ var ClientRpcServer = class {
2135
2385
  }
2136
2386
  };
2137
2387
 
2388
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2389
+ import { getFirstStreamValue } from "@dxos/codec-protobuf";
2390
+ import { credentialTypeFilter } from "@dxos/credentials";
2391
+ import { DocumentModel } from "@dxos/document-model";
2392
+ import { invariant as invariant9 } from "@dxos/invariant";
2393
+ import { log as log8 } from "@dxos/log";
2394
+ import { STORAGE_VERSION } from "@dxos/protocols";
2395
+ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2396
+
2397
+ // packages/sdk/client-services/src/version.ts
2398
+ var DXOS_VERSION = "0.1.56-main.390ac2a";
2399
+
2400
+ // packages/sdk/client-services/src/packlets/services/platform.ts
2401
+ var getPlatform = () => {
2402
+ if (process.browser) {
2403
+ if (typeof window !== "undefined") {
2404
+ const { userAgent } = window.navigator;
2405
+ return {
2406
+ type: "browser",
2407
+ userAgent,
2408
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2409
+ };
2410
+ } else {
2411
+ return {
2412
+ type: "shared-worker",
2413
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2414
+ };
2415
+ }
2416
+ } else {
2417
+ const { platform, version, arch } = process;
2418
+ return {
2419
+ type: "node",
2420
+ platform: `${platform} ${version} ${arch}`,
2421
+ runtime: process.version,
2422
+ uptime: Math.floor(process.uptime()),
2423
+ memory: process.memoryUsage()
2424
+ };
2425
+ }
2426
+ };
2427
+
2428
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2429
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2430
+ var DEFAULT_TIMEOUT = 1e3;
2431
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
2432
+ var _a, _b, _c;
2433
+ const diagnostics = {
2434
+ created: new Date().toISOString(),
2435
+ platform: getPlatform(),
2436
+ client: {
2437
+ version: DXOS_VERSION,
2438
+ storage: {
2439
+ version: STORAGE_VERSION
2440
+ }
2441
+ }
2442
+ };
2443
+ {
2444
+ invariant9(clientServices.LoggingService, "SystemService is not available.", {
2445
+ F: __dxlog_file10,
2446
+ L: 87,
2447
+ S: void 0,
2448
+ A: [
2449
+ "clientServices.LoggingService",
2450
+ "'SystemService is not available.'"
2451
+ ]
2452
+ });
2453
+ diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
2454
+ timeout: DEFAULT_TIMEOUT
2455
+ }).catch(() => void 0);
2456
+ }
2457
+ const identity = serviceContext.identityManager.identity;
2458
+ if (identity) {
2459
+ diagnostics.identity = {
2460
+ identityKey: identity.identityKey,
2461
+ spaceKey: identity.space.key,
2462
+ profile: identity.profileDocument
2463
+ };
2464
+ const { devices } = (_a = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
2465
+ timeout: DEFAULT_TIMEOUT
2466
+ }).catch(() => void 0)) != null ? _a : {};
2467
+ diagnostics.devices = devices;
2468
+ if (serviceContext.dataSpaceManager) {
2469
+ diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
2470
+ }
2471
+ const { feeds = [] } = (_c = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2472
+ timeout: DEFAULT_TIMEOUT
2473
+ }).catch(() => void 0)) != null ? _c : {};
2474
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2475
+ feedKey,
2476
+ bytes,
2477
+ length
2478
+ }));
2479
+ }
2480
+ diagnostics.config = config.values;
2481
+ return diagnostics;
2482
+ };
2483
+ var getProperties = (space) => {
2484
+ let properties = {};
2485
+ try {
2486
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
2487
+ var _a, _b;
2488
+ return ((_a = item.modelMeta) == null ? void 0 : _a.type) === DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
2489
+ });
2490
+ const state = propertiesItem == null ? void 0 : propertiesItem.state;
2491
+ properties = state == null ? void 0 : state.data;
2492
+ } catch (err) {
2493
+ log8.warn(err.message, void 0, {
2494
+ F: __dxlog_file10,
2495
+ L: 144,
2496
+ S: void 0,
2497
+ C: (f, a) => f(...a)
2498
+ });
2499
+ }
2500
+ return properties;
2501
+ };
2502
+ var getSpaceStats = async (space) => {
2503
+ var _a, _b, _c, _d, _e, _f;
2504
+ const stats = {
2505
+ key: space.key,
2506
+ metrics: space.metrics,
2507
+ epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
2508
+ ...credential.subject.assertion,
2509
+ id: credential.id
2510
+ })),
2511
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2512
+ var _a2;
2513
+ return {
2514
+ identity: {
2515
+ identityKey: member.key,
2516
+ profile: {
2517
+ displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
2518
+ }
2519
+ },
2520
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
2521
+ };
2522
+ }),
2523
+ pipeline: {
2524
+ // TODO(burdon): Pick properties from credentials if needed.
2525
+ // currentEpoch: space.dataPipeline.currentEpoch,
2526
+ // appliedEpoch: space.dataPipeline.appliedEpoch,
2527
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2528
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2529
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2530
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
2531
+ // TODO(burdon): Empty?
2532
+ dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
2533
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
2534
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
2535
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
2536
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
2537
+ }
2538
+ };
2539
+ if (space.dataPipeline.itemManager) {
2540
+ Object.assign(stats, {
2541
+ properties: getProperties(space),
2542
+ db: {
2543
+ objects: space.dataPipeline.itemManager.entities.size
2544
+ }
2545
+ });
2546
+ }
2547
+ if (stats.metrics) {
2548
+ const { open, ready } = stats.metrics;
2549
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2550
+ }
2551
+ return stats;
2552
+ };
2553
+
2138
2554
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2139
2555
  import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
2140
2556
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
@@ -2143,22 +2559,22 @@ import { timed } from "@dxos/debug";
2143
2559
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2144
2560
  import { CancelledError, SystemError } from "@dxos/errors";
2145
2561
  import { PublicKey as PublicKey7 } from "@dxos/keys";
2146
- import { log as log9 } from "@dxos/log";
2562
+ import { log as log10 } from "@dxos/log";
2147
2563
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
2148
2564
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2149
2565
  import { Timeframe } from "@dxos/timeframe";
2150
2566
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2151
2567
 
2152
2568
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2153
- import invariant9 from "tiny-invariant";
2154
2569
  import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
2155
2570
  import { Context as Context5, rejectOnDispose } from "@dxos/context";
2571
+ import { invariant as invariant10 } from "@dxos/invariant";
2156
2572
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2157
- import { log as log8 } from "@dxos/log";
2573
+ import { log as log9 } from "@dxos/log";
2158
2574
  import { schema as schema3 } from "@dxos/protocols";
2159
2575
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
2160
2576
  import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
2161
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2577
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2162
2578
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2163
2579
  var DEFAULT_SUCCESS_DELAY = 1e3;
2164
2580
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -2183,23 +2599,31 @@ var NotarizationPlugin = class {
2183
2599
  * Request credentials to be notarized.
2184
2600
  */
2185
2601
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2186
- log8("notarize", {
2602
+ log9("notarize", {
2187
2603
  credentials
2188
2604
  }, {
2189
- F: __dxlog_file8,
2190
- L: 91,
2605
+ F: __dxlog_file11,
2606
+ L: 90,
2191
2607
  S: this,
2192
2608
  C: (f, a) => f(...a)
2193
2609
  });
2194
- invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
2610
+ invariant10(credentials.every((credential) => credential.id), "Credentials must have an id", {
2611
+ F: __dxlog_file11,
2612
+ L: 91,
2613
+ S: this,
2614
+ A: [
2615
+ "credentials.every((credential) => credential.id)",
2616
+ "'Credentials must have an id'"
2617
+ ]
2618
+ });
2195
2619
  const errors = new Trigger4();
2196
2620
  const ctx = this._ctx.derive({
2197
2621
  onError: (err) => {
2198
- log8.warn("Notarization error", {
2622
+ log9.warn("Notarization error", {
2199
2623
  err
2200
2624
  }, {
2201
- F: __dxlog_file8,
2202
- L: 100,
2625
+ F: __dxlog_file11,
2626
+ L: 99,
2203
2627
  S: this,
2204
2628
  C: (f, a) => f(...a)
2205
2629
  });
@@ -2210,12 +2634,12 @@ var NotarizationPlugin = class {
2210
2634
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2211
2635
  if (timeout !== 0) {
2212
2636
  scheduleTask3(ctx, () => {
2213
- log8.warn("Notarization timeout", {
2637
+ log9.warn("Notarization timeout", {
2214
2638
  timeout,
2215
2639
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2216
2640
  }, {
2217
- F: __dxlog_file8,
2218
- L: 112,
2641
+ F: __dxlog_file11,
2642
+ L: 111,
2219
2643
  S: this,
2220
2644
  C: (f, a) => f(...a)
2221
2645
  });
@@ -2234,11 +2658,11 @@ var NotarizationPlugin = class {
2234
2658
  ...this._extensions
2235
2659
  ].find((peer2) => !peersTried.has(peer2));
2236
2660
  if (!peer) {
2237
- log8.warn("Exhausted all peers to notarize with", {
2661
+ log9.warn("Exhausted all peers to notarize with", {
2238
2662
  retryIn: retryTimeout
2239
2663
  }, {
2240
- F: __dxlog_file8,
2241
- L: 137,
2664
+ F: __dxlog_file11,
2665
+ L: 136,
2242
2666
  S: this,
2243
2667
  C: (f, a) => f(...a)
2244
2668
  });
@@ -2247,30 +2671,30 @@ var NotarizationPlugin = class {
2247
2671
  return;
2248
2672
  }
2249
2673
  peersTried.add(peer);
2250
- log8("try notarizing", {
2674
+ log9("try notarizing", {
2251
2675
  peer: peer.localPeerId,
2252
2676
  credentialId: credentials.map((credential) => credential.id)
2253
2677
  }, {
2254
- F: __dxlog_file8,
2255
- L: 144,
2678
+ F: __dxlog_file11,
2679
+ L: 143,
2256
2680
  S: this,
2257
2681
  C: (f, a) => f(...a)
2258
2682
  });
2259
2683
  await peer.rpc.NotarizationService.notarize({
2260
2684
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2261
2685
  });
2262
- log8("success", void 0, {
2263
- F: __dxlog_file8,
2264
- L: 148,
2686
+ log9("success", void 0, {
2687
+ F: __dxlog_file11,
2688
+ L: 147,
2265
2689
  S: this,
2266
2690
  C: (f, a) => f(...a)
2267
2691
  });
2268
2692
  await sleep(successDelay);
2269
2693
  } catch (err) {
2270
2694
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2271
- log8.warn("error notarizing (recoverable)", err, {
2272
- F: __dxlog_file8,
2273
- L: 152,
2695
+ log9.warn("error notarizing (recoverable)", err, {
2696
+ F: __dxlog_file11,
2697
+ L: 151,
2274
2698
  S: this,
2275
2699
  C: (f, a) => f(...a)
2276
2700
  });
@@ -2286,9 +2710,9 @@ var NotarizationPlugin = class {
2286
2710
  allNotarized,
2287
2711
  errors.wait()
2288
2712
  ]);
2289
- log8("done", void 0, {
2290
- F: __dxlog_file8,
2291
- L: 163,
2713
+ log9("done", void 0, {
2714
+ F: __dxlog_file11,
2715
+ L: 162,
2292
2716
  S: this,
2293
2717
  C: (f, a) => f(...a)
2294
2718
  });
@@ -2309,7 +2733,15 @@ var NotarizationPlugin = class {
2309
2733
  this._processCredentialsTriggers.delete(credential.id);
2310
2734
  }
2311
2735
  setWriter(writer) {
2312
- invariant9(!this._writer, "Writer already set.");
2736
+ invariant10(!this._writer, "Writer already set.", {
2737
+ F: __dxlog_file11,
2738
+ L: 181,
2739
+ S: this,
2740
+ A: [
2741
+ "!this._writer",
2742
+ "'Writer already set.'"
2743
+ ]
2744
+ });
2313
2745
  this._writer = writer;
2314
2746
  }
2315
2747
  async _waitUntilProcessed(id) {
@@ -2327,7 +2759,15 @@ var NotarizationPlugin = class {
2327
2759
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2328
2760
  }
2329
2761
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2330
- invariant9(credential.id, "Credential must have an id");
2762
+ invariant10(credential.id, "Credential must have an id", {
2763
+ F: __dxlog_file11,
2764
+ L: 200,
2765
+ S: this,
2766
+ A: [
2767
+ "credential.id",
2768
+ "'Credential must have an id'"
2769
+ ]
2770
+ });
2331
2771
  if (this._processedCredentials.has(credential.id)) {
2332
2772
  continue;
2333
2773
  }
@@ -2337,11 +2777,11 @@ var NotarizationPlugin = class {
2337
2777
  createExtension() {
2338
2778
  const extension = new NotarizationTeleportExtension({
2339
2779
  onOpen: async () => {
2340
- log8("extension opened", {
2780
+ log9("extension opened", {
2341
2781
  peer: extension.localPeerId
2342
2782
  }, {
2343
- F: __dxlog_file8,
2344
- L: 212,
2783
+ F: __dxlog_file11,
2784
+ L: 211,
2345
2785
  S: this,
2346
2786
  C: (f, a) => f(...a)
2347
2787
  });
@@ -2349,11 +2789,11 @@ var NotarizationPlugin = class {
2349
2789
  this._extensionOpened.emit();
2350
2790
  },
2351
2791
  onClose: async () => {
2352
- log8("extension closed", {
2792
+ log9("extension closed", {
2353
2793
  peer: extension.localPeerId
2354
2794
  }, {
2355
- F: __dxlog_file8,
2356
- L: 217,
2795
+ F: __dxlog_file11,
2796
+ L: 216,
2357
2797
  S: this,
2358
2798
  C: (f, a) => f(...a)
2359
2799
  });
@@ -2406,7 +2846,7 @@ function _ts_decorate(decorators, target, key, desc) {
2406
2846
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2407
2847
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2408
2848
  }
2409
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2849
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2410
2850
  var DataSpace = class DataSpace2 {
2411
2851
  constructor(params) {
2412
2852
  this._ctx = new Context6();
@@ -2504,16 +2944,16 @@ var DataSpace = class DataSpace2 {
2504
2944
  await this.initializeDataPipeline();
2505
2945
  } catch (err) {
2506
2946
  if (err instanceof CancelledError) {
2507
- log9("data pipeline initialization cancelled", err, {
2508
- F: __dxlog_file9,
2947
+ log10("data pipeline initialization cancelled", err, {
2948
+ F: __dxlog_file12,
2509
2949
  L: 193,
2510
2950
  S: this,
2511
2951
  C: (f, a) => f(...a)
2512
2952
  });
2513
2953
  return;
2514
2954
  }
2515
- log9.error("Error initializing data pipeline", err, {
2516
- F: __dxlog_file9,
2955
+ log10.error("Error initializing data pipeline", err, {
2956
+ F: __dxlog_file12,
2517
2957
  L: 197,
2518
2958
  S: this,
2519
2959
  C: (f, a) => f(...a)
@@ -2538,8 +2978,8 @@ var DataSpace = class DataSpace2 {
2538
2978
  });
2539
2979
  this.metrics.controlPipelineReady = new Date();
2540
2980
  await this._createWritableFeeds();
2541
- log9("writable feeds created", void 0, {
2542
- F: __dxlog_file9,
2981
+ log10("writable feeds created", void 0, {
2982
+ F: __dxlog_file12,
2543
2983
  L: 221,
2544
2984
  S: this,
2545
2985
  C: (f, a) => f(...a)
@@ -2555,8 +2995,8 @@ var DataSpace = class DataSpace2 {
2555
2995
  await this._inner.initializeDataPipeline();
2556
2996
  this.metrics.dataPipelineOpen = new Date();
2557
2997
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2558
- log9("waiting for data pipeline to reach target timeframe", void 0, {
2559
- F: __dxlog_file9,
2998
+ log10("waiting for data pipeline to reach target timeframe", void 0, {
2999
+ F: __dxlog_file12,
2560
3000
  L: 242,
2561
3001
  S: this,
2562
3002
  C: (f, a) => f(...a)
@@ -2566,8 +3006,8 @@ var DataSpace = class DataSpace2 {
2566
3006
  breakOnStall: false
2567
3007
  });
2568
3008
  this.metrics.dataPipelineReady = new Date();
2569
- log9("data pipeline ready", void 0, {
2570
- F: __dxlog_file9,
3009
+ log10("data pipeline ready", void 0, {
3010
+ F: __dxlog_file12,
2571
3011
  L: 251,
2572
3012
  S: this,
2573
3013
  C: (f, a) => f(...a)
@@ -2686,12 +3126,12 @@ DataSpace = _ts_decorate([
2686
3126
  ], DataSpace);
2687
3127
 
2688
3128
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2689
- import invariant10 from "tiny-invariant";
2690
3129
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
2691
3130
  import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
2692
3131
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3132
+ import { invariant as invariant11 } from "@dxos/invariant";
2693
3133
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2694
- import { log as log10 } from "@dxos/log";
3134
+ import { log as log11 } from "@dxos/log";
2695
3135
  import { trace as trace4 } from "@dxos/protocols";
2696
3136
  import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
2697
3137
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
@@ -2700,7 +3140,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
2700
3140
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
2701
3141
  import { createCredential } from "@dxos/credentials";
2702
3142
  import { failUndefined as failUndefined2 } from "@dxos/debug";
2703
- import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
3143
+ import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
2704
3144
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2705
3145
  var spaceGenesis = async (keyring, signingContext, space) => {
2706
3146
  var _a, _b, _c, _d;
@@ -2721,7 +3161,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2721
3161
  assertion: {
2722
3162
  "@type": "dxos.halo.credentials.SpaceMember",
2723
3163
  spaceKey: space.key,
2724
- role: SpaceMember.Role.ADMIN,
3164
+ role: SpaceMember2.Role.ADMIN,
2725
3165
  profile: signingContext.profile,
2726
3166
  genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : failUndefined2()
2727
3167
  }
@@ -2778,7 +3218,7 @@ function _ts_decorate2(decorators, target, key, desc) {
2778
3218
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2779
3219
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2780
3220
  }
2781
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3221
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2782
3222
  var DataSpaceManager = class DataSpaceManager2 {
2783
3223
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2784
3224
  this._spaceManager = _spaceManager;
@@ -2798,36 +3238,36 @@ var DataSpaceManager = class DataSpaceManager2 {
2798
3238
  return this._spaces;
2799
3239
  }
2800
3240
  async open() {
2801
- log10("open", void 0, {
2802
- F: __dxlog_file10,
2803
- L: 80,
3241
+ log11("open", void 0, {
3242
+ F: __dxlog_file13,
3243
+ L: 79,
2804
3244
  S: this,
2805
3245
  C: (f, a) => f(...a)
2806
3246
  });
2807
- log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
3247
+ log11.trace("dxos.echo.data-space-manager.open", trace4.begin({
2808
3248
  id: this._instanceId
2809
3249
  }), {
2810
- F: __dxlog_file10,
2811
- L: 81,
3250
+ F: __dxlog_file13,
3251
+ L: 80,
2812
3252
  S: this,
2813
3253
  C: (f, a) => f(...a)
2814
3254
  });
2815
3255
  await this._metadataStore.load();
2816
- log10("metadata loaded", {
3256
+ log11("metadata loaded", {
2817
3257
  spaces: this._metadataStore.spaces.length
2818
3258
  }, {
2819
- F: __dxlog_file10,
2820
- L: 83,
3259
+ F: __dxlog_file13,
3260
+ L: 82,
2821
3261
  S: this,
2822
3262
  C: (f, a) => f(...a)
2823
3263
  });
2824
3264
  for (const spaceMetadata of this._metadataStore.spaces) {
2825
3265
  try {
2826
- log10("load space", {
3266
+ log11("load space", {
2827
3267
  spaceMetadata
2828
3268
  }, {
2829
- F: __dxlog_file10,
2830
- L: 87,
3269
+ F: __dxlog_file13,
3270
+ L: 86,
2831
3271
  S: this,
2832
3272
  C: (f, a) => f(...a)
2833
3273
  });
@@ -2836,12 +3276,12 @@ var DataSpaceManager = class DataSpaceManager2 {
2836
3276
  space.initializeDataPipelineAsync();
2837
3277
  }
2838
3278
  } catch (err) {
2839
- log10.error("Error loading space", {
3279
+ log11.error("Error loading space", {
2840
3280
  spaceMetadata,
2841
3281
  err
2842
3282
  }, {
2843
- F: __dxlog_file10,
2844
- L: 93,
3283
+ F: __dxlog_file13,
3284
+ L: 92,
2845
3285
  S: this,
2846
3286
  C: (f, a) => f(...a)
2847
3287
  });
@@ -2849,19 +3289,19 @@ var DataSpaceManager = class DataSpaceManager2 {
2849
3289
  }
2850
3290
  this._isOpen = true;
2851
3291
  this.updated.emit();
2852
- log10.trace("dxos.echo.data-space-manager.open", trace4.end({
3292
+ log11.trace("dxos.echo.data-space-manager.open", trace4.end({
2853
3293
  id: this._instanceId
2854
3294
  }), {
2855
- F: __dxlog_file10,
2856
- L: 99,
3295
+ F: __dxlog_file13,
3296
+ L: 98,
2857
3297
  S: this,
2858
3298
  C: (f, a) => f(...a)
2859
3299
  });
2860
3300
  }
2861
3301
  async close() {
2862
- log10("close", void 0, {
2863
- F: __dxlog_file10,
2864
- L: 104,
3302
+ log11("close", void 0, {
3303
+ F: __dxlog_file13,
3304
+ L: 103,
2865
3305
  S: this,
2866
3306
  C: (f, a) => f(...a)
2867
3307
  });
@@ -2875,7 +3315,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2875
3315
  * Creates a new space writing the genesis credentials to the control feed.
2876
3316
  */
2877
3317
  async createSpace() {
2878
- invariant10(this._isOpen, "Not open.");
3318
+ invariant11(this._isOpen, "Not open.", {
3319
+ F: __dxlog_file13,
3320
+ L: 116,
3321
+ S: this,
3322
+ A: [
3323
+ "this._isOpen",
3324
+ "'Not open.'"
3325
+ ]
3326
+ });
2879
3327
  const spaceKey = await this._keyring.createKey();
2880
3328
  const controlFeedKey = await this._keyring.createKey();
2881
3329
  const dataFeedKey = await this._keyring.createKey();
@@ -2886,11 +3334,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2886
3334
  dataFeedKey,
2887
3335
  state: SpaceState2.ACTIVE
2888
3336
  };
2889
- log10("creating space...", {
3337
+ log11("creating space...", {
2890
3338
  spaceKey
2891
3339
  }, {
2892
- F: __dxlog_file10,
2893
- L: 129,
3340
+ F: __dxlog_file13,
3341
+ L: 128,
2894
3342
  S: this,
2895
3343
  C: (f, a) => f(...a)
2896
3344
  });
@@ -2898,7 +3346,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2898
3346
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2899
3347
  await this._metadataStore.addSpace(metadata);
2900
3348
  const memberCredential = credentials[1];
2901
- invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
3349
+ invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3350
+ F: __dxlog_file13,
3351
+ L: 135,
3352
+ S: this,
3353
+ A: [
3354
+ "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3355
+ ""
3356
+ ]
3357
+ });
2902
3358
  await this._signingContext.recordCredential(memberCredential);
2903
3359
  await space.initializeDataPipeline();
2904
3360
  this.updated.emit();
@@ -2906,16 +3362,32 @@ var DataSpaceManager = class DataSpaceManager2 {
2906
3362
  }
2907
3363
  // TODO(burdon): Rename join space.
2908
3364
  async acceptSpace(opts) {
2909
- log10("accept space", {
3365
+ log11("accept space", {
2910
3366
  opts
2911
3367
  }, {
2912
- F: __dxlog_file10,
2913
- L: 148,
3368
+ F: __dxlog_file13,
3369
+ L: 147,
2914
3370
  S: this,
2915
3371
  C: (f, a) => f(...a)
2916
3372
  });
2917
- invariant10(this._isOpen, "Not open.");
2918
- invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
3373
+ invariant11(this._isOpen, "Not open.", {
3374
+ F: __dxlog_file13,
3375
+ L: 148,
3376
+ S: this,
3377
+ A: [
3378
+ "this._isOpen",
3379
+ "'Not open.'"
3380
+ ]
3381
+ });
3382
+ invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3383
+ F: __dxlog_file13,
3384
+ L: 149,
3385
+ S: this,
3386
+ A: [
3387
+ "!this._spaces.has(opts.spaceKey)",
3388
+ "'Space already exists.'"
3389
+ ]
3390
+ });
2919
3391
  const metadata = {
2920
3392
  key: opts.spaceKey,
2921
3393
  genesisFeedKey: opts.genesisFeedKey,
@@ -2940,11 +3412,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2940
3412
  }));
2941
3413
  }
2942
3414
  async _constructSpace(metadata) {
2943
- log10("construct space", {
3415
+ log11("construct space", {
2944
3416
  metadata
2945
3417
  }, {
2946
- F: __dxlog_file10,
2947
- L: 183,
3418
+ F: __dxlog_file13,
3419
+ L: 182,
2948
3420
  S: this,
2949
3421
  C: (f, a) => f(...a)
2950
3422
  });
@@ -2952,7 +3424,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2952
3424
  localPeerId: this._signingContext.deviceKey
2953
3425
  });
2954
3426
  const presence = new Presence({
2955
- announceInterval: 500,
3427
+ announceInterval: 1e3,
2956
3428
  offlineTimeout: 5e3,
2957
3429
  identityKey: this._signingContext.identityKey,
2958
3430
  gossip
@@ -2978,9 +3450,9 @@ var DataSpaceManager = class DataSpaceManager2 {
2978
3450
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2979
3451
  },
2980
3452
  onAuthFailure: () => {
2981
- log10.warn("auth failure", void 0, {
2982
- F: __dxlog_file10,
2983
- L: 214,
3453
+ log11.warn("auth failure", void 0, {
3454
+ F: __dxlog_file13,
3455
+ L: 213,
2984
3456
  S: this,
2985
3457
  C: (f, a) => f(...a)
2986
3458
  });
@@ -3000,23 +3472,23 @@ var DataSpaceManager = class DataSpaceManager2 {
3000
3472
  signingContext: this._signingContext,
3001
3473
  callbacks: {
3002
3474
  beforeReady: async () => {
3003
- log10("before space ready", {
3475
+ log11("before space ready", {
3004
3476
  space: space.key
3005
3477
  }, {
3006
- F: __dxlog_file10,
3007
- L: 232,
3478
+ F: __dxlog_file13,
3479
+ L: 231,
3008
3480
  S: this,
3009
3481
  C: (f, a) => f(...a)
3010
3482
  });
3011
3483
  await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3012
3484
  },
3013
3485
  afterReady: async () => {
3014
- log10("after space ready", {
3486
+ log11("after space ready", {
3015
3487
  space: space.key,
3016
3488
  open: this._isOpen
3017
3489
  }, {
3018
- F: __dxlog_file10,
3019
- L: 239,
3490
+ F: __dxlog_file13,
3491
+ L: 238,
3020
3492
  S: this,
3021
3493
  C: (f, a) => f(...a)
3022
3494
  });
@@ -3025,11 +3497,11 @@ var DataSpaceManager = class DataSpaceManager2 {
3025
3497
  }
3026
3498
  },
3027
3499
  beforeClose: async () => {
3028
- log10("before space close", {
3500
+ log11("before space close", {
3029
3501
  space: space.key
3030
3502
  }, {
3031
- F: __dxlog_file10,
3032
- L: 245,
3503
+ F: __dxlog_file13,
3504
+ L: 244,
3033
3505
  S: this,
3034
3506
  C: (f, a) => f(...a)
3035
3507
  });
@@ -3073,11 +3545,11 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
3073
3545
  import { raise as raise2 } from "@dxos/debug";
3074
3546
  import { SpaceNotFoundError } from "@dxos/echo-pipeline";
3075
3547
  import { ApiError } from "@dxos/errors";
3076
- import { log as log11 } from "@dxos/log";
3548
+ import { log as log12 } from "@dxos/log";
3077
3549
  import { encodeError } from "@dxos/protocols";
3078
- import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3550
+ import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3079
3551
  import { humanize } from "@dxos/util";
3080
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3552
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3081
3553
  var SpacesServiceImpl = class {
3082
3554
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3083
3555
  this._identityManager = _identityManager;
@@ -3115,10 +3587,10 @@ var SpacesServiceImpl = class {
3115
3587
  const scheduler = new UpdateScheduler(ctx, async () => {
3116
3588
  const dataSpaceManager = await this._getDataSpaceManager();
3117
3589
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
3118
- log11("update", {
3590
+ log12("update", {
3119
3591
  spaces
3120
3592
  }, {
3121
- F: __dxlog_file11,
3593
+ F: __dxlog_file14,
3122
3594
  L: 78,
3123
3595
  S: this,
3124
3596
  C: (f, a) => f(...a)
@@ -3229,14 +3701,20 @@ var SpacesServiceImpl = class {
3229
3701
  },
3230
3702
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3231
3703
  var _a2, _b2, _c2;
3704
+ const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
3705
+ const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
3706
+ if (isMe) {
3707
+ peers.push(space.presence.getLocalState());
3708
+ }
3232
3709
  return {
3233
3710
  identity: {
3234
3711
  identityKey: member.key,
3235
3712
  profile: {
3236
- displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : humanize(member.key)
3713
+ displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : humanize(member.key)
3237
3714
  }
3238
3715
  },
3239
- presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember2.PresenceState.ONLINE : SpaceMember2.PresenceState.OFFLINE
3716
+ presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
3717
+ peerStates: peers
3240
3718
  };
3241
3719
  }),
3242
3720
  creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
@@ -3248,19 +3726,19 @@ var SpacesServiceImpl = class {
3248
3726
  var getChannelId = (channel) => `user-channel/${channel}`;
3249
3727
 
3250
3728
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3251
- import invariant11 from "tiny-invariant";
3252
3729
  import { Trigger as Trigger5 } from "@dxos/async";
3253
3730
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
3254
3731
  import { failUndefined as failUndefined3 } from "@dxos/debug";
3255
3732
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
3256
3733
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
3734
+ import { invariant as invariant12 } from "@dxos/invariant";
3257
3735
  import { Keyring } from "@dxos/keyring";
3258
3736
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3259
- import { log as log12 } from "@dxos/log";
3260
- import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
3737
+ import { log as log13 } from "@dxos/log";
3738
+ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace5 } from "@dxos/protocols";
3261
3739
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3262
3740
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
3263
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3741
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3264
3742
  var ServiceContext = class {
3265
3743
  // prettier-ignore
3266
3744
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3301,18 +3779,18 @@ var ServiceContext = class {
3301
3779
  }, this._acceptIdentity.bind(this)));
3302
3780
  }
3303
3781
  async open() {
3304
- log12.trace("dxos.sdk.service-context.open", trace5.begin({
3305
- id: this._instanceId
3306
- }), {
3307
- F: __dxlog_file12,
3308
- L: 126,
3782
+ await this._checkStorageVersion();
3783
+ log13("opening...", void 0, {
3784
+ F: __dxlog_file15,
3785
+ L: 127,
3309
3786
  S: this,
3310
3787
  C: (f, a) => f(...a)
3311
3788
  });
3312
- await this._checkStorageVersion();
3313
- log12("opening...", void 0, {
3314
- F: __dxlog_file12,
3315
- L: 130,
3789
+ log13.trace("dxos.sdk.service-context.open", trace5.begin({
3790
+ id: this._instanceId
3791
+ }), {
3792
+ F: __dxlog_file15,
3793
+ L: 128,
3316
3794
  S: this,
3317
3795
  C: (f, a) => f(...a)
3318
3796
  });
@@ -3323,26 +3801,26 @@ var ServiceContext = class {
3323
3801
  if (this.identityManager.identity) {
3324
3802
  await this._initialize();
3325
3803
  }
3326
- log12("opened", void 0, {
3327
- F: __dxlog_file12,
3328
- L: 138,
3804
+ log13.trace("dxos.sdk.service-context.open", trace5.end({
3805
+ id: this._instanceId
3806
+ }), {
3807
+ F: __dxlog_file15,
3808
+ L: 136,
3329
3809
  S: this,
3330
3810
  C: (f, a) => f(...a)
3331
3811
  });
3332
- log12.trace("dxos.sdk.service-context.open", trace5.end({
3333
- id: this._instanceId
3334
- }), {
3335
- F: __dxlog_file12,
3336
- L: 139,
3812
+ log13("opened", void 0, {
3813
+ F: __dxlog_file15,
3814
+ L: 137,
3337
3815
  S: this,
3338
3816
  C: (f, a) => f(...a)
3339
3817
  });
3340
3818
  }
3341
3819
  async close() {
3342
3820
  var _a;
3343
- log12("closing...", void 0, {
3344
- F: __dxlog_file12,
3345
- L: 143,
3821
+ log13("closing...", void 0, {
3822
+ F: __dxlog_file15,
3823
+ L: 141,
3346
3824
  S: this,
3347
3825
  C: (f, a) => f(...a)
3348
3826
  });
@@ -3356,9 +3834,9 @@ var ServiceContext = class {
3356
3834
  await this.networkManager.close();
3357
3835
  await this.signalManager.close();
3358
3836
  this.dataServiceSubscriptions.clear();
3359
- log12("closed", void 0, {
3360
- F: __dxlog_file12,
3361
- L: 154,
3837
+ log13("closed", void 0, {
3838
+ F: __dxlog_file15,
3839
+ L: 152,
3362
3840
  S: this,
3363
3841
  C: (f, a) => f(...a)
3364
3842
  });
@@ -3370,7 +3848,15 @@ var ServiceContext = class {
3370
3848
  }
3371
3849
  getInvitationHandler(invitation) {
3372
3850
  const factory = this._handlerFactories.get(invitation.kind);
3373
- invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
3851
+ invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
3852
+ F: __dxlog_file15,
3853
+ L: 164,
3854
+ S: this,
3855
+ A: [
3856
+ "factory",
3857
+ "`Unknown invitation kind: ${invitation.kind}`"
3858
+ ]
3859
+ });
3374
3860
  return factory(invitation);
3375
3861
  }
3376
3862
  async _acceptIdentity(params) {
@@ -3380,16 +3866,16 @@ var ServiceContext = class {
3380
3866
  }
3381
3867
  async _checkStorageVersion() {
3382
3868
  await this.metadataStore.load();
3383
- if (this.metadataStore.version !== STORAGE_VERSION) {
3384
- throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION}`);
3869
+ if (this.metadataStore.version !== STORAGE_VERSION2) {
3870
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION2}`);
3385
3871
  }
3386
3872
  }
3387
3873
  // Called when identity is created.
3388
3874
  async _initialize() {
3389
3875
  var _a;
3390
- log12("initializing spaces...", void 0, {
3391
- F: __dxlog_file12,
3392
- L: 187,
3876
+ log13("initializing spaces...", void 0, {
3877
+ F: __dxlog_file15,
3878
+ L: 185,
3393
3879
  S: this,
3394
3880
  C: (f, a) => f(...a)
3395
3881
  });
@@ -3410,7 +3896,15 @@ var ServiceContext = class {
3410
3896
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3411
3897
  await this.dataSpaceManager.open();
3412
3898
  this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
3413
- invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3899
+ invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3900
+ F: __dxlog_file15,
3901
+ L: 208,
3902
+ S: this,
3903
+ A: [
3904
+ "this.dataSpaceManager",
3905
+ "'dataSpaceManager not initialized yet'"
3906
+ ]
3907
+ });
3414
3908
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3415
3909
  });
3416
3910
  this.initialized.wake();
@@ -3424,33 +3918,33 @@ var ServiceContext = class {
3424
3918
  return;
3425
3919
  }
3426
3920
  if (!this.dataSpaceManager) {
3427
- log12("dataSpaceManager not initialized yet, ignoring space admission", {
3921
+ log13("dataSpaceManager not initialized yet, ignoring space admission", {
3428
3922
  details: assertion
3429
3923
  }, {
3430
- F: __dxlog_file12,
3431
- L: 226,
3924
+ F: __dxlog_file15,
3925
+ L: 224,
3432
3926
  S: this,
3433
3927
  C: (f, a) => f(...a)
3434
3928
  });
3435
3929
  return;
3436
3930
  }
3437
3931
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3438
- log12("space already exists, ignoring space admission", {
3932
+ log13("space already exists, ignoring space admission", {
3439
3933
  details: assertion
3440
3934
  }, {
3441
- F: __dxlog_file12,
3442
- L: 230,
3935
+ F: __dxlog_file15,
3936
+ L: 228,
3443
3937
  S: this,
3444
3938
  C: (f, a) => f(...a)
3445
3939
  });
3446
3940
  return;
3447
3941
  }
3448
3942
  try {
3449
- log12("accepting space recorded in halo", {
3943
+ log13("accepting space recorded in halo", {
3450
3944
  details: assertion
3451
3945
  }, {
3452
- F: __dxlog_file12,
3453
- L: 235,
3946
+ F: __dxlog_file15,
3947
+ L: 233,
3454
3948
  S: this,
3455
3949
  C: (f, a) => f(...a)
3456
3950
  });
@@ -3459,9 +3953,9 @@ var ServiceContext = class {
3459
3953
  genesisFeedKey: assertion.genesisFeedKey
3460
3954
  });
3461
3955
  } catch (err) {
3462
- log12.catch(err, void 0, {
3463
- F: __dxlog_file12,
3464
- L: 241,
3956
+ log13.catch(err, void 0, {
3957
+ F: __dxlog_file15,
3958
+ L: 239,
3465
3959
  S: this,
3466
3960
  C: (f, a) => f(...a)
3467
3961
  });
@@ -3475,7 +3969,7 @@ var ServiceContext = class {
3475
3969
  // packages/sdk/client-services/src/packlets/locks/browser.ts
3476
3970
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3477
3971
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3478
- import { log as log13, logInfo } from "@dxos/log";
3972
+ import { log as log14, logInfo } from "@dxos/log";
3479
3973
  function _ts_decorate3(decorators, target, key, desc) {
3480
3974
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3481
3975
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3486,7 +3980,7 @@ function _ts_decorate3(decorators, target, key, desc) {
3486
3980
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3487
3981
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3488
3982
  }
3489
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
3983
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
3490
3984
  var Message;
3491
3985
  (function(Message2) {
3492
3986
  Message2["ACQUIRING"] = "acquiring";
@@ -3508,29 +4002,29 @@ var Lock = class {
3508
4002
  message: Message.ACQUIRING
3509
4003
  });
3510
4004
  try {
3511
- log13("aquiring lock...", void 0, {
3512
- F: __dxlog_file13,
4005
+ log14("aquiring lock...", void 0, {
4006
+ F: __dxlog_file16,
3513
4007
  L: 42,
3514
4008
  S: this,
3515
4009
  C: (f, a) => f(...a)
3516
4010
  });
3517
4011
  await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
3518
- log13("acquired lock", void 0, {
3519
- F: __dxlog_file13,
4012
+ log14("acquired lock", void 0, {
4013
+ F: __dxlog_file16,
3520
4014
  L: 44,
3521
4015
  S: this,
3522
4016
  C: (f, a) => f(...a)
3523
4017
  });
3524
4018
  } catch (e) {
3525
- log13("stealing lock...", void 0, {
3526
- F: __dxlog_file13,
4019
+ log14("stealing lock...", void 0, {
4020
+ F: __dxlog_file16,
3527
4021
  L: 46,
3528
4022
  S: this,
3529
4023
  C: (f, a) => f(...a)
3530
4024
  });
3531
4025
  await this._requestLock(true);
3532
- log13("stolen lock", void 0, {
3533
- F: __dxlog_file13,
4026
+ log14("stolen lock", void 0, {
4027
+ F: __dxlog_file16,
3534
4028
  L: 48,
3535
4029
  S: this,
3536
4030
  C: (f, a) => f(...a)
@@ -3546,10 +4040,10 @@ var Lock = class {
3546
4040
  }
3547
4041
  }
3548
4042
  async _requestLock(steal = false) {
3549
- log13("requesting lock...", {
4043
+ log14("requesting lock...", {
3550
4044
  steal
3551
4045
  }, {
3552
- F: __dxlog_file13,
4046
+ F: __dxlog_file16,
3553
4047
  L: 63,
3554
4048
  S: this,
3555
4049
  C: (f, a) => f(...a)
@@ -3563,15 +4057,15 @@ var Lock = class {
3563
4057
  acquired.wake();
3564
4058
  this._releaseTrigger = new Trigger6();
3565
4059
  await this._releaseTrigger.wait();
3566
- log13("releasing lock...", void 0, {
3567
- F: __dxlog_file13,
4060
+ log14("releasing lock...", void 0, {
4061
+ F: __dxlog_file16,
3568
4062
  L: 72,
3569
4063
  S: this,
3570
4064
  C: (f, a) => f(...a)
3571
4065
  });
3572
4066
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3573
- log13("released lock", void 0, {
3574
- F: __dxlog_file13,
4067
+ log14("released lock", void 0, {
4068
+ F: __dxlog_file16,
3575
4069
  L: 74,
3576
4070
  S: this,
3577
4071
  C: (f, a) => f(...a)
@@ -3581,10 +4075,10 @@ var Lock = class {
3581
4075
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3582
4076
  });
3583
4077
  await acquired.wait();
3584
- log13("recieved lock", {
4078
+ log14("recieved lock", {
3585
4079
  steal
3586
4080
  }, {
3587
- F: __dxlog_file13,
4081
+ F: __dxlog_file16,
3588
4082
  L: 81,
3589
4083
  S: this,
3590
4084
  C: (f, a) => f(...a)
@@ -3672,13 +4166,13 @@ var ServiceRegistry = class {
3672
4166
  };
3673
4167
 
3674
4168
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3675
- import invariant12 from "tiny-invariant";
3676
4169
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
3677
4170
  import { clientServiceBundle } from "@dxos/client-protocol";
3678
- import { DocumentModel } from "@dxos/document-model";
4171
+ import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
3679
4172
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4173
+ import { invariant as invariant13 } from "@dxos/invariant";
3680
4174
  import { PublicKey as PublicKey10 } from "@dxos/keys";
3681
- import { log as log15 } from "@dxos/log";
4175
+ import { log as log16 } from "@dxos/log";
3682
4176
  import { WebsocketSignalManager } from "@dxos/messaging";
3683
4177
  import { ModelFactory } from "@dxos/model-factory";
3684
4178
  import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
@@ -3736,22 +4230,23 @@ var DevicesServiceImpl = class {
3736
4230
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3737
4231
  import { Event as Event7 } from "@dxos/async";
3738
4232
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
3739
- import { getContextFromEntry, log as log14 } from "@dxos/log";
4233
+ import { getContextFromEntry, log as log15 } from "@dxos/log";
3740
4234
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
3741
4235
  import { jsonify, numericalValues, tracer } from "@dxos/util";
3742
4236
  var LoggingServiceImpl = class {
3743
4237
  constructor() {
3744
4238
  this._logs = new Event7();
4239
+ this._started = new Date();
3745
4240
  this._logProcessor = (_config, entry2) => {
3746
4241
  this._logs.emit(entry2);
3747
4242
  };
3748
4243
  }
3749
4244
  async open() {
3750
- log14.runtimeConfig.processors.push(this._logProcessor);
4245
+ log15.runtimeConfig.processors.push(this._logProcessor);
3751
4246
  }
3752
4247
  async close() {
3753
- const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3754
- log14.runtimeConfig.processors.splice(index, 1);
4248
+ const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4249
+ log15.runtimeConfig.processors.splice(index, 1);
3755
4250
  }
3756
4251
  async controlMetrics({ reset, record }) {
3757
4252
  if (reset) {
@@ -3766,13 +4261,16 @@ var LoggingServiceImpl = class {
3766
4261
  recording: tracer.recording
3767
4262
  };
3768
4263
  }
3769
- queryMetrics({ interval }) {
3770
- const createNumericalValues = (key) => {
4264
+ /**
4265
+ * @deprecated (Move to diagnostics).
4266
+ */
4267
+ queryMetrics({ interval = 5e3 }) {
4268
+ const getNumericalValues = (key) => {
3771
4269
  var _a;
3772
- const consume = (_a = tracer.get(key)) != null ? _a : [];
4270
+ const events = (_a = tracer.get(key)) != null ? _a : [];
3773
4271
  return {
3774
4272
  key,
3775
- stats: numericalValues(consume, "duration")
4273
+ stats: numericalValues(events, "duration")
3776
4274
  };
3777
4275
  };
3778
4276
  return new Stream12(({ next }) => {
@@ -3780,14 +4278,17 @@ var LoggingServiceImpl = class {
3780
4278
  const metrics = {
3781
4279
  timestamp: new Date(),
3782
4280
  values: [
3783
- createNumericalValues("dxos.echo.pipeline.control"),
3784
- createNumericalValues("dxos.echo.pipeline.data")
3785
- ]
4281
+ getNumericalValues("dxos.echo.pipeline.control"),
4282
+ getNumericalValues("dxos.echo.pipeline.data")
4283
+ ].filter(Boolean)
3786
4284
  };
3787
- next(metrics);
4285
+ next({
4286
+ timestamp: new Date(),
4287
+ metrics
4288
+ });
3788
4289
  };
3789
4290
  update();
3790
- const i = setInterval(update, interval);
4291
+ const i = setInterval(update, Math.max(interval, 1e3));
3791
4292
  return () => {
3792
4293
  clearInterval(i);
3793
4294
  };
@@ -3883,11 +4384,14 @@ var NetworkServiceImpl = class {
3883
4384
 
3884
4385
  // packages/sdk/client-services/src/packlets/system/system-service.ts
3885
4386
  import { Stream as Stream14 } from "@dxos/codec-protobuf";
4387
+ import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
4388
+ import { jsonKeyReplacer } from "@dxos/util";
3886
4389
  var SystemServiceImpl = class {
3887
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
4390
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
3888
4391
  this._config = config;
3889
4392
  this._statusUpdate = statusUpdate;
3890
4393
  this._getCurrentStatus = getCurrentStatus;
4394
+ this._getDiagnostics = getDiagnostics;
3891
4395
  this._onUpdateStatus = onUpdateStatus;
3892
4396
  this._onReset = onReset;
3893
4397
  }
@@ -3895,6 +4399,19 @@ var SystemServiceImpl = class {
3895
4399
  var _a, _b;
3896
4400
  return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
3897
4401
  }
4402
+ /**
4403
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
4404
+ */
4405
+ async getDiagnostics({ keys } = {}) {
4406
+ const diagnostics = await this._getDiagnostics();
4407
+ return {
4408
+ timestamp: new Date(),
4409
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
4410
+ truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4411
+ humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4412
+ })))
4413
+ };
4414
+ }
3898
4415
  async updateStatus({ status }) {
3899
4416
  await this._onUpdateStatus(status);
3900
4417
  }
@@ -3931,18 +4448,16 @@ function _ts_decorate4(decorators, target, key, desc) {
3931
4448
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3932
4449
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3933
4450
  }
3934
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4451
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
3935
4452
  var createDefaultModelFactory = () => {
3936
- return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
4453
+ return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
3937
4454
  };
3938
4455
  var ClientServicesHost = class {
3939
4456
  constructor({
3940
4457
  config,
3941
4458
  modelFactory = createDefaultModelFactory(),
3942
- // TODO(burdon): Create ApolloLink abstraction (see Client).
3943
4459
  transportFactory,
3944
4460
  signalManager,
3945
- connectionLog,
3946
4461
  storage,
3947
4462
  // TODO(wittjosiah): Turn this on by default.
3948
4463
  lockKey,
@@ -3976,6 +4491,9 @@ var ClientServicesHost = class {
3976
4491
  config: this._config,
3977
4492
  statusUpdate: this._statusUpdate,
3978
4493
  getCurrentStatus: () => this.isOpen ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
4494
+ getDiagnostics: () => {
4495
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4496
+ },
3979
4497
  onUpdateStatus: async (status) => {
3980
4498
  var _a, _b;
3981
4499
  if (!this.isOpen && status === SystemStatus.ACTIVE) {
@@ -3996,6 +4514,12 @@ var ClientServicesHost = class {
3996
4514
  get isOpen() {
3997
4515
  return this._open;
3998
4516
  }
4517
+ get config() {
4518
+ return this._config;
4519
+ }
4520
+ get context() {
4521
+ return this._serviceContext;
4522
+ }
3999
4523
  get serviceRegistry() {
4000
4524
  return this._serviceRegistry;
4001
4525
  }
@@ -4012,9 +4536,31 @@ var ClientServicesHost = class {
4012
4536
  */
4013
4537
  initialize({ config, ...options }) {
4014
4538
  var _a, _b, _c;
4015
- invariant12(!this._open, "service host is open");
4539
+ invariant13(!this._open, "service host is open", {
4540
+ F: __dxlog_file17,
4541
+ L: 172,
4542
+ S: this,
4543
+ A: [
4544
+ "!this._open",
4545
+ "'service host is open'"
4546
+ ]
4547
+ });
4548
+ log16.info("initializing...", void 0, {
4549
+ F: __dxlog_file17,
4550
+ L: 173,
4551
+ S: this,
4552
+ C: (f, a) => f(...a)
4553
+ });
4016
4554
  if (config) {
4017
- invariant12(!this._config, "config already set");
4555
+ invariant13(!this._config, "config already set", {
4556
+ F: __dxlog_file17,
4557
+ L: 176,
4558
+ S: this,
4559
+ A: [
4560
+ "!this._config",
4561
+ "'config already set'"
4562
+ ]
4563
+ });
4018
4564
  this._config = config;
4019
4565
  if (!this._storage) {
4020
4566
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -4024,12 +4570,26 @@ var ClientServicesHost = class {
4024
4570
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4025
4571
  }), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4026
4572
  this._signalManager = signalManager;
4027
- invariant12(!this._networkManager, "network manager already set");
4573
+ invariant13(!this._networkManager, "network manager already set", {
4574
+ F: __dxlog_file17,
4575
+ L: 192,
4576
+ S: this,
4577
+ A: [
4578
+ "!this._networkManager",
4579
+ "'network manager already set'"
4580
+ ]
4581
+ });
4028
4582
  this._networkManager = new NetworkManager({
4029
4583
  log: connectionLog,
4030
4584
  transportFactory,
4031
4585
  signalManager
4032
4586
  });
4587
+ log16.info("initialized", void 0, {
4588
+ F: __dxlog_file17,
4589
+ L: 199,
4590
+ S: this,
4591
+ C: (f, a) => f(...a)
4592
+ });
4033
4593
  }
4034
4594
  async open() {
4035
4595
  var _a, _b, _c;
@@ -4037,24 +4597,56 @@ var ClientServicesHost = class {
4037
4597
  return;
4038
4598
  }
4039
4599
  const traceId = PublicKey10.random().toHex();
4040
- log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
4600
+ log16.trace("dxos.client-services.host.open", trace6.begin({
4041
4601
  id: traceId
4042
4602
  }), {
4043
- F: __dxlog_file14,
4044
- L: 203,
4603
+ F: __dxlog_file17,
4604
+ L: 209,
4045
4605
  S: this,
4046
4606
  C: (f, a) => f(...a)
4047
4607
  });
4048
- invariant12(this._config, "config not set");
4049
- invariant12(this._storage, "storage not set");
4050
- invariant12(this._signalManager, "signal manager not set");
4051
- invariant12(this._networkManager, "network manager not set");
4608
+ invariant13(this._config, "config not set", {
4609
+ F: __dxlog_file17,
4610
+ L: 211,
4611
+ S: this,
4612
+ A: [
4613
+ "this._config",
4614
+ "'config not set'"
4615
+ ]
4616
+ });
4617
+ invariant13(this._storage, "storage not set", {
4618
+ F: __dxlog_file17,
4619
+ L: 212,
4620
+ S: this,
4621
+ A: [
4622
+ "this._storage",
4623
+ "'storage not set'"
4624
+ ]
4625
+ });
4626
+ invariant13(this._signalManager, "signal manager not set", {
4627
+ F: __dxlog_file17,
4628
+ L: 213,
4629
+ S: this,
4630
+ A: [
4631
+ "this._signalManager",
4632
+ "'signal manager not set'"
4633
+ ]
4634
+ });
4635
+ invariant13(this._networkManager, "network manager not set", {
4636
+ F: __dxlog_file17,
4637
+ L: 214,
4638
+ S: this,
4639
+ A: [
4640
+ "this._networkManager",
4641
+ "'network manager not set'"
4642
+ ]
4643
+ });
4052
4644
  this._opening = true;
4053
- log15("opening...", {
4645
+ log16.info("opening...", {
4054
4646
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4055
4647
  }, {
4056
- F: __dxlog_file14,
4057
- L: 211,
4648
+ F: __dxlog_file17,
4649
+ L: 217,
4058
4650
  S: this,
4059
4651
  C: (f, a) => f(...a)
4060
4652
  });
@@ -4085,19 +4677,19 @@ var ClientServicesHost = class {
4085
4677
  this._open = true;
4086
4678
  this._statusUpdate.emit();
4087
4679
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4088
- log15("opened", {
4680
+ log16.info("opened", {
4089
4681
  deviceKey
4090
4682
  }, {
4091
- F: __dxlog_file14,
4092
- L: 266,
4683
+ F: __dxlog_file17,
4684
+ L: 269,
4093
4685
  S: this,
4094
4686
  C: (f, a) => f(...a)
4095
4687
  });
4096
- log15.trace("dxos.sdk.client-services-host.open", trace6.end({
4688
+ log16.trace("dxos.client-services.host.open", trace6.end({
4097
4689
  id: traceId
4098
4690
  }), {
4099
- F: __dxlog_file14,
4100
- L: 267,
4691
+ F: __dxlog_file17,
4692
+ L: 270,
4101
4693
  S: this,
4102
4694
  C: (f, a) => f(...a)
4103
4695
  });
@@ -4108,11 +4700,11 @@ var ClientServicesHost = class {
4108
4700
  return;
4109
4701
  }
4110
4702
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4111
- log15("closing...", {
4703
+ log16.info("closing...", {
4112
4704
  deviceKey
4113
4705
  }, {
4114
- F: __dxlog_file14,
4115
- L: 277,
4706
+ F: __dxlog_file17,
4707
+ L: 280,
4116
4708
  S: this,
4117
4709
  C: (f, a) => f(...a)
4118
4710
  });
@@ -4123,11 +4715,11 @@ var ClientServicesHost = class {
4123
4715
  await this._serviceContext.close();
4124
4716
  this._open = false;
4125
4717
  this._statusUpdate.emit();
4126
- log15("closed", {
4718
+ log16.info("closed", {
4127
4719
  deviceKey
4128
4720
  }, {
4129
- F: __dxlog_file14,
4130
- L: 283,
4721
+ F: __dxlog_file17,
4722
+ L: 286,
4131
4723
  S: this,
4132
4724
  C: (f, a) => f(...a)
4133
4725
  });
@@ -4135,33 +4727,33 @@ var ClientServicesHost = class {
4135
4727
  async reset() {
4136
4728
  var _a, _b, _c;
4137
4729
  const traceId = PublicKey10.random().toHex();
4138
- log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4730
+ log16.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4139
4731
  id: traceId
4140
4732
  }), {
4141
- F: __dxlog_file14,
4142
- L: 288,
4733
+ F: __dxlog_file17,
4734
+ L: 291,
4143
4735
  S: this,
4144
4736
  C: (f, a) => f(...a)
4145
4737
  });
4146
- log15("resetting...", void 0, {
4147
- F: __dxlog_file14,
4148
- L: 290,
4738
+ log16("resetting...", void 0, {
4739
+ F: __dxlog_file17,
4740
+ L: 293,
4149
4741
  S: this,
4150
4742
  C: (f, a) => f(...a)
4151
4743
  });
4152
4744
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4153
4745
  await this._storage.reset();
4154
- log15("reset", void 0, {
4155
- F: __dxlog_file14,
4156
- L: 293,
4746
+ log16("reset", void 0, {
4747
+ F: __dxlog_file17,
4748
+ L: 296,
4157
4749
  S: this,
4158
4750
  C: (f, a) => f(...a)
4159
4751
  });
4160
- log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
4752
+ log16.trace("dxos.sdk.client-services-host.reset", trace6.end({
4161
4753
  id: traceId
4162
4754
  }), {
4163
- F: __dxlog_file14,
4164
- L: 294,
4755
+ F: __dxlog_file17,
4756
+ L: 297,
4165
4757
  S: this,
4166
4758
  C: (f, a) => f(...a)
4167
4759
  });
@@ -4196,6 +4788,7 @@ export {
4196
4788
  InvitationsServiceImpl,
4197
4789
  SpaceInvitationProtocol,
4198
4790
  ClientRpcServer,
4791
+ createDiagnostics,
4199
4792
  DataSpace,
4200
4793
  DataSpaceManager,
4201
4794
  SpacesServiceImpl,
@@ -4207,4 +4800,4 @@ export {
4207
4800
  createDefaultModelFactory,
4208
4801
  ClientServicesHost
4209
4802
  };
4210
- //# sourceMappingURL=chunk-CSJSC47N.mjs.map
4803
+ //# sourceMappingURL=chunk-KSADD5WV.mjs.map