@dxos/client-services 0.1.56-main.b25ef1c → 0.1.56-main.b3438d9

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