@dxos/client-services 0.1.55 → 0.1.56-main.01afb72

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 (91) hide show
  1. package/dist/lib/browser/{chunk-XSZIBW37.mjs → chunk-53BV3Q7V.mjs} +1131 -463
  2. package/dist/lib/browser/chunk-53BV3Q7V.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +63 -42
  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 +13 -4
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +1279 -593
  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 +1410 -736
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  16. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  17. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  21. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  22. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  23. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  24. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  25. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  26. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  27. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  28. package/dist/types/src/packlets/services/index.d.ts +1 -0
  29. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  31. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  32. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  33. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  34. package/dist/types/src/packlets/services/service-host.d.ts +7 -3
  35. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  36. package/dist/types/src/packlets/services/util.d.ts +6 -0
  37. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  38. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  39. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  40. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  41. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  42. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  43. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  44. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  45. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  46. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  47. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  48. package/dist/types/src/version.d.ts +2 -0
  49. package/dist/types/src/version.d.ts.map +1 -0
  50. package/package.json +34 -33
  51. package/src/packlets/devices/devices-service.test.ts +2 -1
  52. package/src/packlets/identity/authenticator.test.ts +2 -2
  53. package/src/packlets/identity/identity-manager.test.ts +4 -3
  54. package/src/packlets/identity/identity-manager.ts +10 -7
  55. package/src/packlets/identity/identity-service.test.ts +2 -1
  56. package/src/packlets/identity/identity-service.ts +1 -2
  57. package/src/packlets/identity/identity.test.ts +7 -6
  58. package/src/packlets/identity/identity.ts +9 -5
  59. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  60. package/src/packlets/invitations/device-invitation-protocol.ts +1 -2
  61. package/src/packlets/invitations/invitation-extension.ts +1 -2
  62. package/src/packlets/invitations/invitations-handler.ts +1 -2
  63. package/src/packlets/invitations/invitations-service.ts +1 -2
  64. package/src/packlets/invitations/space-invitation-protocol.ts +1 -2
  65. package/src/packlets/locks/node.ts +1 -1
  66. package/src/packlets/logging/logging-service.ts +17 -9
  67. package/src/packlets/network/network-service.test.ts +2 -1
  68. package/src/packlets/services/client-rpc-server.ts +4 -4
  69. package/src/packlets/services/diagnostics.ts +211 -0
  70. package/src/packlets/services/index.ts +1 -0
  71. package/src/packlets/services/platform.ts +48 -0
  72. package/src/packlets/services/service-context.ts +14 -11
  73. package/src/packlets/services/service-host.test.ts +11 -10
  74. package/src/packlets/services/service-host.ts +38 -23
  75. package/src/packlets/services/service-registry.test.ts +3 -1
  76. package/src/packlets/services/util.ts +33 -0
  77. package/src/packlets/spaces/data-space-manager.ts +2 -3
  78. package/src/packlets/spaces/data-space.ts +1 -1
  79. package/src/packlets/spaces/notarization-plugin.ts +1 -2
  80. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  81. package/src/packlets/spaces/spaces-service.ts +18 -12
  82. package/src/packlets/system/system-service.test.ts +1 -0
  83. package/src/packlets/system/system-service.ts +34 -2
  84. package/src/packlets/testing/invitation-utils.ts +1 -2
  85. package/src/packlets/testing/test-builder.ts +1 -1
  86. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  87. package/src/packlets/vault/shell-runtime.ts +1 -2
  88. package/src/packlets/vault/worker-runtime.ts +2 -1
  89. package/src/packlets/vault/worker-session.ts +7 -3
  90. package/src/version.ts +1 -0
  91. package/dist/lib/browser/chunk-XSZIBW37.mjs.map +0 -7
@@ -352,7 +352,7 @@ import { Context as Context2 } from "@dxos/context";
352
352
  import { verifyCredential } from "@dxos/credentials";
353
353
  import { log } from "@dxos/log";
354
354
  import { schema } from "@dxos/protocols";
355
- var __dxlog_file = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
355
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
356
356
  var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
357
357
  var createAuthProvider = (signer) => async (nonce) => {
358
358
  const credential = await signer.createCredential({
@@ -463,16 +463,27 @@ var TrustedKeySetAuthVerifier = class {
463
463
  };
464
464
 
465
465
  // packages/sdk/client-services/src/packlets/identity/identity.ts
466
- import invariant from "tiny-invariant";
467
466
  import { Event } from "@dxos/async";
468
467
  import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
469
468
  import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
470
469
  import { failUndefined } from "@dxos/debug";
471
470
  import { writeMessages } from "@dxos/feed-store";
471
+ import { invariant } from "@dxos/invariant";
472
472
  import { log as log2 } from "@dxos/log";
473
473
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
474
- var __dxlog_file2 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/identity/identity.ts";
475
- var Identity = class {
474
+ import { trace } from "@dxos/tracing";
475
+ function _ts_decorate(decorators, target, key, desc) {
476
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
477
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
478
+ r = Reflect.decorate(decorators, target, key, desc);
479
+ else
480
+ for (var i = decorators.length - 1; i >= 0; i--)
481
+ if (d = decorators[i])
482
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
483
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
484
+ }
485
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
486
+ var Identity = class Identity2 {
476
487
  constructor({ space, signer, identityKey, deviceKey }) {
477
488
  this.stateUpdate = new Event();
478
489
  this.space = space;
@@ -498,12 +509,12 @@ var Identity = class {
498
509
  get authorizedDeviceKeys() {
499
510
  return this._deviceStateMachine.authorizedDeviceKeys;
500
511
  }
501
- async open() {
512
+ async open(ctx) {
502
513
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
503
514
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
504
- await this.space.open();
515
+ await this.space.open(ctx);
505
516
  }
506
- async close() {
517
+ async close(ctx) {
507
518
  await this.authVerifier.close();
508
519
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
509
520
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
@@ -546,7 +557,15 @@ var Identity = class {
546
557
  * Requires identity to be ready.
547
558
  */
548
559
  getIdentityCredentialSigner() {
549
- invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
560
+ invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
561
+ F: __dxlog_file2,
562
+ L: 139,
563
+ S: this,
564
+ A: [
565
+ "this._deviceStateMachine.deviceCredentialChain",
566
+ "'Device credential chain is not ready.'"
567
+ ]
568
+ });
550
569
  return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
551
570
  }
552
571
  /**
@@ -564,7 +583,7 @@ var Identity = class {
564
583
  dataFeedKey
565
584
  }, {
566
585
  F: __dxlog_file2,
567
- L: 151,
586
+ L: 155,
568
587
  S: this,
569
588
  C: (f, a) => f(...a)
570
589
  });
@@ -605,18 +624,39 @@ var Identity = class {
605
624
  })));
606
625
  }
607
626
  };
627
+ _ts_decorate([
628
+ trace.span()
629
+ ], Identity.prototype, "open", null);
630
+ _ts_decorate([
631
+ trace.span()
632
+ ], Identity.prototype, "close", null);
633
+ Identity = _ts_decorate([
634
+ trace.resource()
635
+ ], Identity);
608
636
 
609
637
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
610
- import invariant2 from "tiny-invariant";
611
638
  import { Event as Event2 } from "@dxos/async";
639
+ import { Context as Context3 } from "@dxos/context";
612
640
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
641
+ import { invariant as invariant2 } from "@dxos/invariant";
613
642
  import { PublicKey as PublicKey3 } from "@dxos/keys";
614
643
  import { log as log3 } from "@dxos/log";
615
- import { trace } from "@dxos/protocols";
644
+ import { trace as trace2 } from "@dxos/protocols";
616
645
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
646
+ import { trace as Trace } from "@dxos/tracing";
617
647
  import { deferFunction } from "@dxos/util";
618
- var __dxlog_file3 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
619
- var IdentityManager = class {
648
+ function _ts_decorate2(decorators, target, key, desc) {
649
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
650
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
651
+ r = Reflect.decorate(decorators, target, key, desc);
652
+ else
653
+ for (var i = decorators.length - 1; i >= 0; i--)
654
+ if (d = decorators[i])
655
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
656
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
657
+ }
658
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
659
+ var IdentityManager = class IdentityManager2 {
620
660
  // TODO(burdon): IdentityManagerParams.
621
661
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
622
662
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -629,14 +669,14 @@ var IdentityManager = class {
629
669
  get identity() {
630
670
  return this._identity;
631
671
  }
632
- async open() {
672
+ async open(ctx) {
633
673
  var _a;
634
674
  const traceId = PublicKey3.random().toHex();
635
- log3.trace("dxos.halo.identity-manager.open", trace.begin({
675
+ log3.trace("dxos.halo.identity-manager.open", trace2.begin({
636
676
  id: traceId
637
677
  }), {
638
678
  F: __dxlog_file3,
639
- L: 70,
679
+ L: 73,
640
680
  S: this,
641
681
  C: (f, a) => f(...a)
642
682
  });
@@ -646,44 +686,52 @@ var IdentityManager = class {
646
686
  identityRecord
647
687
  }, {
648
688
  F: __dxlog_file3,
649
- L: 74,
689
+ L: 77,
650
690
  S: this,
651
691
  C: (f, a) => f(...a)
652
692
  });
653
693
  if (identityRecord) {
654
694
  this._identity = await this._constructIdentity(identityRecord);
655
- await this._identity.open();
695
+ await this._identity.open(ctx);
656
696
  await this._identity.ready();
657
697
  log3.trace("dxos.halo.identity", {
658
698
  identityKey: identityRecord.identityKey,
659
699
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
660
700
  }, {
661
701
  F: __dxlog_file3,
662
- L: 79,
702
+ L: 82,
663
703
  S: this,
664
704
  C: (f, a) => f(...a)
665
705
  });
666
706
  this.stateUpdate.emit();
667
707
  }
668
- log3.trace("dxos.halo.identity-manager.open", trace.end({
708
+ log3.trace("dxos.halo.identity-manager.open", trace2.end({
669
709
  id: traceId
670
710
  }), {
671
711
  F: __dxlog_file3,
672
- L: 85,
712
+ L: 88,
673
713
  S: this,
674
714
  C: (f, a) => f(...a)
675
715
  });
676
716
  }
677
717
  async close() {
678
718
  var _a;
679
- await ((_a = this._identity) == null ? void 0 : _a.close());
719
+ await ((_a = this._identity) == null ? void 0 : _a.close(new Context3()));
680
720
  }
681
721
  async createIdentity({ displayName } = {}) {
682
722
  var _a;
683
- invariant2(!this._identity, "Identity already exists.");
723
+ invariant2(!this._identity, "Identity already exists.", {
724
+ F: __dxlog_file3,
725
+ L: 96,
726
+ S: this,
727
+ A: [
728
+ "!this._identity",
729
+ "'Identity already exists.'"
730
+ ]
731
+ });
684
732
  log3("creating identity...", void 0, {
685
733
  F: __dxlog_file3,
686
- L: 94,
734
+ L: 97,
687
735
  S: this,
688
736
  C: (f, a) => f(...a)
689
737
  });
@@ -699,11 +747,27 @@ var IdentityManager = class {
699
747
  }
700
748
  };
701
749
  const identity = await this._constructIdentity(identityRecord);
702
- await identity.open();
750
+ await identity.open(new Context3());
703
751
  {
704
752
  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.");
753
+ invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
754
+ F: __dxlog_file3,
755
+ L: 116,
756
+ S: this,
757
+ A: [
758
+ "identityRecord.haloSpace.genesisFeedKey",
759
+ "'Genesis feed key is required.'"
760
+ ]
761
+ });
762
+ invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
763
+ F: __dxlog_file3,
764
+ L: 117,
765
+ S: this,
766
+ A: [
767
+ "identityRecord.haloSpace.dataFeedKey",
768
+ "'Data feed key is required.'"
769
+ ]
770
+ });
707
771
  const credentials = [
708
772
  // Space genesis.
709
773
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
@@ -732,7 +796,7 @@ var IdentityManager = class {
732
796
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
733
797
  }, {
734
798
  F: __dxlog_file3,
735
- L: 149,
799
+ L: 152,
736
800
  S: this,
737
801
  C: (f, a) => f(...a)
738
802
  });
@@ -742,7 +806,7 @@ var IdentityManager = class {
742
806
  deviceKey: identity.deviceKey
743
807
  }, {
744
808
  F: __dxlog_file3,
745
- L: 155,
809
+ L: 158,
746
810
  S: this,
747
811
  C: (f, a) => f(...a)
748
812
  });
@@ -757,11 +821,19 @@ var IdentityManager = class {
757
821
  params
758
822
  }, {
759
823
  F: __dxlog_file3,
760
- L: 163,
824
+ L: 166,
761
825
  S: this,
762
826
  C: (f, a) => f(...a)
763
827
  });
764
- invariant2(!this._identity, "Identity already exists.");
828
+ invariant2(!this._identity, "Identity already exists.", {
829
+ F: __dxlog_file3,
830
+ L: 167,
831
+ S: this,
832
+ A: [
833
+ "!this._identity",
834
+ "'Identity already exists.'"
835
+ ]
836
+ });
765
837
  const identityRecord = {
766
838
  identityKey: params.identityKey,
767
839
  deviceKey: params.deviceKey,
@@ -774,7 +846,7 @@ var IdentityManager = class {
774
846
  }
775
847
  };
776
848
  const identity = await this._constructIdentity(identityRecord);
777
- await identity.open();
849
+ await identity.open(new Context3());
778
850
  this._identity = identity;
779
851
  await this._metadataStore.setIdentityRecord(identityRecord);
780
852
  await this._identity.ready();
@@ -783,7 +855,7 @@ var IdentityManager = class {
783
855
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
784
856
  }, {
785
857
  F: __dxlog_file3,
786
- L: 183,
858
+ L: 186,
787
859
  S: this,
788
860
  C: (f, a) => f(...a)
789
861
  });
@@ -793,27 +865,51 @@ var IdentityManager = class {
793
865
  deviceKey: identity.deviceKey
794
866
  }, {
795
867
  F: __dxlog_file3,
796
- L: 189,
868
+ L: 192,
797
869
  S: this,
798
870
  C: (f, a) => f(...a)
799
871
  });
800
872
  return identity;
801
873
  }
802
874
  async _constructIdentity(identityRecord) {
803
- invariant2(!this._identity);
875
+ invariant2(!this._identity, void 0, {
876
+ F: __dxlog_file3,
877
+ L: 197,
878
+ S: this,
879
+ A: [
880
+ "!this._identity",
881
+ ""
882
+ ]
883
+ });
804
884
  log3("constructing identity", {
805
885
  identityRecord
806
886
  }, {
807
887
  F: __dxlog_file3,
808
- L: 195,
888
+ L: 198,
809
889
  S: this,
810
890
  C: (f, a) => f(...a)
811
891
  });
812
- invariant2(identityRecord.haloSpace.controlFeedKey);
892
+ invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
893
+ F: __dxlog_file3,
894
+ L: 201,
895
+ S: this,
896
+ A: [
897
+ "identityRecord.haloSpace.controlFeedKey",
898
+ ""
899
+ ]
900
+ });
813
901
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
814
902
  writable: true
815
903
  });
816
- invariant2(identityRecord.haloSpace.dataFeedKey);
904
+ invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
905
+ F: __dxlog_file3,
906
+ L: 205,
907
+ S: this,
908
+ A: [
909
+ "identityRecord.haloSpace.dataFeedKey",
910
+ ""
911
+ ]
912
+ });
817
913
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
818
914
  writable: true,
819
915
  sparse: true
@@ -839,7 +935,7 @@ var IdentityManager = class {
839
935
  identityKey: identityRecord.identityKey
840
936
  }, {
841
937
  F: __dxlog_file3,
842
- L: 226,
938
+ L: 229,
843
939
  S: this,
844
940
  C: (f, a) => f(...a)
845
941
  });
@@ -860,7 +956,7 @@ var IdentityManager = class {
860
956
  onAuthFailure: () => {
861
957
  log3.warn("auth failure", void 0, {
862
958
  F: __dxlog_file3,
863
- L: 245,
959
+ L: 248,
864
960
  S: this,
865
961
  C: (f, a) => f(...a)
866
962
  });
@@ -869,12 +965,19 @@ var IdentityManager = class {
869
965
  });
870
966
  }
871
967
  };
968
+ _ts_decorate2([
969
+ Trace.span()
970
+ ], IdentityManager.prototype, "open", null);
971
+ IdentityManager = _ts_decorate2([
972
+ Trace.resource()
973
+ ], IdentityManager);
872
974
 
873
975
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
874
- import invariant3 from "tiny-invariant";
875
976
  import { Stream as Stream7 } from "@dxos/codec-protobuf";
876
977
  import { signPresentation } from "@dxos/credentials";
877
978
  import { todo } from "@dxos/debug";
979
+ import { invariant as invariant3 } from "@dxos/invariant";
980
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
878
981
  var IdentityServiceImpl = class {
879
982
  // TODO(wittjosiah): Remove dependency on service context.
880
983
  constructor(_serviceContext) {
@@ -907,7 +1010,15 @@ var IdentityServiceImpl = class {
907
1010
  };
908
1011
  }
909
1012
  async signPresentation({ presentation, nonce }) {
910
- invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.");
1013
+ invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.", {
1014
+ F: __dxlog_file4,
1015
+ L: 56,
1016
+ S: this,
1017
+ A: [
1018
+ "this._serviceContext.identityManager.identity",
1019
+ "'Identity not initialized.'"
1020
+ ]
1021
+ });
911
1022
  return await signPresentation({
912
1023
  presentation,
913
1024
  signer: this._serviceContext.keyring,
@@ -919,8 +1030,9 @@ var IdentityServiceImpl = class {
919
1030
  };
920
1031
 
921
1032
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
922
- import invariant4 from "tiny-invariant";
1033
+ import { invariant as invariant4 } from "@dxos/invariant";
923
1034
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
1035
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
924
1036
  var DeviceInvitationProtocol = class {
925
1037
  constructor(_keyring, _getIdentity, _acceptIdentity) {
926
1038
  this._keyring = _keyring;
@@ -936,7 +1048,15 @@ var DeviceInvitationProtocol = class {
936
1048
  };
937
1049
  }
938
1050
  async admit(request) {
939
- invariant4(request.device);
1051
+ invariant4(request.device, void 0, {
1052
+ F: __dxlog_file5,
1053
+ L: 31,
1054
+ S: this,
1055
+ A: [
1056
+ "request.device",
1057
+ ""
1058
+ ]
1059
+ });
940
1060
  const identity = this._getIdentity();
941
1061
  await identity.admitDevice(request.device);
942
1062
  return {
@@ -964,9 +1084,25 @@ var DeviceInvitationProtocol = class {
964
1084
  };
965
1085
  }
966
1086
  async accept(response, request) {
967
- invariant4(response.device);
1087
+ invariant4(response.device, void 0, {
1088
+ F: __dxlog_file5,
1089
+ L: 64,
1090
+ S: this,
1091
+ A: [
1092
+ "response.device",
1093
+ ""
1094
+ ]
1095
+ });
968
1096
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
969
- invariant4(request.device);
1097
+ invariant4(request.device, void 0, {
1098
+ F: __dxlog_file5,
1099
+ L: 67,
1100
+ S: this,
1101
+ A: [
1102
+ "request.device",
1103
+ ""
1104
+ ]
1105
+ });
970
1106
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
971
1107
  await this._acceptIdentity({
972
1108
  identityKey,
@@ -984,31 +1120,31 @@ var DeviceInvitationProtocol = class {
984
1120
  };
985
1121
 
986
1122
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
987
- import invariant6 from "tiny-invariant";
988
1123
  import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
989
1124
  import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
990
- import { Context as Context4 } from "@dxos/context";
1125
+ import { Context as Context5 } from "@dxos/context";
991
1126
  import { generatePasscode } from "@dxos/credentials";
992
1127
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
1128
+ import { invariant as invariant6 } from "@dxos/invariant";
993
1129
  import { PublicKey as PublicKey5 } from "@dxos/keys";
994
1130
  import { log as log5 } from "@dxos/log";
995
1131
  import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
996
- import { trace as trace3 } from "@dxos/protocols";
1132
+ import { trace as trace4 } from "@dxos/protocols";
997
1133
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
998
1134
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
999
1135
 
1000
1136
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1001
- import invariant5 from "tiny-invariant";
1002
1137
  import { Trigger as Trigger2 } from "@dxos/async";
1003
- import { cancelWithContext, Context as Context3 } from "@dxos/context";
1138
+ import { cancelWithContext, Context as Context4 } from "@dxos/context";
1004
1139
  import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
1140
+ import { invariant as invariant5 } from "@dxos/invariant";
1005
1141
  import { PublicKey as PublicKey4 } from "@dxos/keys";
1006
1142
  import { log as log4 } from "@dxos/log";
1007
- import { schema as schema2, trace as trace2 } from "@dxos/protocols";
1143
+ import { schema as schema2, trace as trace3 } from "@dxos/protocols";
1008
1144
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
1009
1145
  import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1010
1146
  import { RpcExtension } from "@dxos/teleport";
1011
- var __dxlog_file4 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1147
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1012
1148
  var OPTIONS_TIMEOUT = 1e4;
1013
1149
  var MAX_OTP_ATTEMPTS = 3;
1014
1150
  var InvitationHostExtension = class extends RpcExtension {
@@ -1022,7 +1158,7 @@ var InvitationHostExtension = class extends RpcExtension {
1022
1158
  }
1023
1159
  });
1024
1160
  this._callbacks = _callbacks;
1025
- this._ctx = new Context3();
1161
+ this._ctx = new Context4();
1026
1162
  this._remoteOptionsTrigger = new Trigger2();
1027
1163
  this.invitation = void 0;
1028
1164
  this.guestProfile = void 0;
@@ -1036,18 +1172,26 @@ var InvitationHostExtension = class extends RpcExtension {
1036
1172
  // Perhaps in the future we will have more complex logic here.
1037
1173
  InvitationHostService: {
1038
1174
  options: async (options) => {
1039
- invariant5(!this._remoteOptions, "Remote options already set.");
1175
+ invariant5(!this._remoteOptions, "Remote options already set.", {
1176
+ F: __dxlog_file6,
1177
+ L: 88,
1178
+ S: this,
1179
+ A: [
1180
+ "!this._remoteOptions",
1181
+ "'Remote options already set.'"
1182
+ ]
1183
+ });
1040
1184
  this._remoteOptions = options;
1041
1185
  this._remoteOptionsTrigger.wake();
1042
1186
  },
1043
1187
  introduce: async (request) => {
1044
1188
  const { profile, invitationId } = request;
1045
1189
  const traceId = PublicKey4.random().toHex();
1046
- log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
1190
+ log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
1047
1191
  id: traceId
1048
1192
  }), {
1049
- F: __dxlog_file4,
1050
- L: 98,
1193
+ F: __dxlog_file6,
1194
+ L: 97,
1051
1195
  S: this,
1052
1196
  C: (f, a) => f(...a)
1053
1197
  });
@@ -1056,8 +1200,8 @@ var InvitationHostExtension = class extends RpcExtension {
1056
1200
  log4.warn("invitation not found", {
1057
1201
  invitationId
1058
1202
  }, {
1059
- F: __dxlog_file4,
1060
- L: 102,
1203
+ F: __dxlog_file6,
1204
+ L: 101,
1061
1205
  S: this,
1062
1206
  C: (f, a) => f(...a)
1063
1207
  });
@@ -1070,8 +1214,8 @@ var InvitationHostExtension = class extends RpcExtension {
1070
1214
  log4("guest introduced itself", {
1071
1215
  guestProfile: profile
1072
1216
  }, {
1073
- F: __dxlog_file4,
1074
- L: 111,
1217
+ F: __dxlog_file6,
1218
+ L: 110,
1075
1219
  S: this,
1076
1220
  C: (f, a) => f(...a)
1077
1221
  });
@@ -1080,11 +1224,11 @@ var InvitationHostExtension = class extends RpcExtension {
1080
1224
  ...this.invitation,
1081
1225
  state: Invitation2.State.READY_FOR_AUTHENTICATION
1082
1226
  });
1083
- log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
1227
+ log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
1084
1228
  id: traceId
1085
1229
  }), {
1086
- F: __dxlog_file4,
1087
- L: 118,
1230
+ F: __dxlog_file6,
1231
+ L: 117,
1088
1232
  S: this,
1089
1233
  C: (f, a) => f(...a)
1090
1234
  });
@@ -1095,29 +1239,37 @@ var InvitationHostExtension = class extends RpcExtension {
1095
1239
  },
1096
1240
  authenticate: async ({ authCode: code }) => {
1097
1241
  const traceId = PublicKey4.random().toHex();
1098
- log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
1242
+ log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
1099
1243
  id: traceId
1100
1244
  }), {
1101
- F: __dxlog_file4,
1102
- L: 127,
1245
+ F: __dxlog_file6,
1246
+ L: 126,
1103
1247
  S: this,
1104
1248
  C: (f, a) => f(...a)
1105
1249
  });
1106
1250
  log4("received authentication request", {
1107
1251
  authCode: code
1108
1252
  }, {
1109
- F: __dxlog_file4,
1110
- L: 128,
1253
+ F: __dxlog_file6,
1254
+ L: 127,
1111
1255
  S: this,
1112
1256
  C: (f, a) => f(...a)
1113
1257
  });
1114
1258
  let status = AuthenticationResponse.Status.OK;
1115
- invariant5(this.invitation, "Invitation is not set.");
1259
+ invariant5(this.invitation, "Invitation is not set.", {
1260
+ F: __dxlog_file6,
1261
+ L: 130,
1262
+ S: this,
1263
+ A: [
1264
+ "this.invitation",
1265
+ "'Invitation is not set.'"
1266
+ ]
1267
+ });
1116
1268
  switch (this.invitation.authMethod) {
1117
1269
  case Invitation2.AuthMethod.NONE: {
1118
1270
  log4("authentication not required", void 0, {
1119
- F: __dxlog_file4,
1120
- L: 134,
1271
+ F: __dxlog_file6,
1272
+ L: 133,
1121
1273
  S: this,
1122
1274
  C: (f, a) => f(...a)
1123
1275
  });
@@ -1141,8 +1293,8 @@ var InvitationHostExtension = class extends RpcExtension {
1141
1293
  log4.error("invalid authentication method", {
1142
1294
  authMethod: this.invitation.authMethod
1143
1295
  }, {
1144
- F: __dxlog_file4,
1145
- L: 152,
1296
+ F: __dxlog_file6,
1297
+ L: 151,
1146
1298
  S: this,
1147
1299
  C: (f, a) => f(...a)
1148
1300
  });
@@ -1150,14 +1302,14 @@ var InvitationHostExtension = class extends RpcExtension {
1150
1302
  break;
1151
1303
  }
1152
1304
  }
1153
- log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.end({
1305
+ log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
1154
1306
  id: traceId,
1155
1307
  data: {
1156
1308
  status
1157
1309
  }
1158
1310
  }), {
1159
- F: __dxlog_file4,
1160
- L: 158,
1311
+ F: __dxlog_file6,
1312
+ L: 157,
1161
1313
  S: this,
1162
1314
  C: (f, a) => f(...a)
1163
1315
  });
@@ -1167,25 +1319,33 @@ var InvitationHostExtension = class extends RpcExtension {
1167
1319
  },
1168
1320
  admit: async (request) => {
1169
1321
  const traceId = PublicKey4.random().toHex();
1170
- log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
1322
+ log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
1171
1323
  id: traceId
1172
1324
  }), {
1173
- F: __dxlog_file4,
1174
- L: 164,
1325
+ F: __dxlog_file6,
1326
+ L: 163,
1175
1327
  S: this,
1176
1328
  C: (f, a) => f(...a)
1177
1329
  });
1178
1330
  try {
1179
- invariant5(this.invitation, "Invitation is not set.");
1331
+ invariant5(this.invitation, "Invitation is not set.", {
1332
+ F: __dxlog_file6,
1333
+ L: 166,
1334
+ S: this,
1335
+ A: [
1336
+ "this.invitation",
1337
+ "'Invitation is not set.'"
1338
+ ]
1339
+ });
1180
1340
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1181
1341
  throw new Error("Not authenticated");
1182
1342
  }
1183
1343
  const response = await this._callbacks.admit(request);
1184
- log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
1344
+ log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
1185
1345
  id: traceId
1186
1346
  }), {
1187
- F: __dxlog_file4,
1188
- L: 175,
1347
+ F: __dxlog_file6,
1348
+ L: 174,
1189
1349
  S: this,
1190
1350
  C: (f, a) => f(...a)
1191
1351
  });
@@ -1234,14 +1394,22 @@ var InvitationGuestExtension = class extends RpcExtension {
1234
1394
  }
1235
1395
  });
1236
1396
  this._callbacks = _callbacks;
1237
- this._ctx = new Context3();
1397
+ this._ctx = new Context4();
1238
1398
  this._remoteOptionsTrigger = new Trigger2();
1239
1399
  }
1240
1400
  async getHandlers() {
1241
1401
  return {
1242
1402
  InvitationHostService: {
1243
1403
  options: async (options) => {
1244
- invariant5(!this._remoteOptions, "Remote options already set.");
1404
+ invariant5(!this._remoteOptions, "Remote options already set.", {
1405
+ F: __dxlog_file6,
1406
+ L: 241,
1407
+ S: this,
1408
+ A: [
1409
+ "!this._remoteOptions",
1410
+ "'Remote options already set.'"
1411
+ ]
1412
+ });
1245
1413
  this._remoteOptions = options;
1246
1414
  this._remoteOptionsTrigger.wake();
1247
1415
  },
@@ -1262,8 +1430,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1262
1430
  await super.onOpen(context);
1263
1431
  try {
1264
1432
  log4("begin options", void 0, {
1265
- F: __dxlog_file4,
1266
- L: 263,
1433
+ F: __dxlog_file6,
1434
+ L: 262,
1267
1435
  S: this,
1268
1436
  C: (f, a) => f(...a)
1269
1437
  });
@@ -1274,8 +1442,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1274
1442
  timeout: OPTIONS_TIMEOUT
1275
1443
  }));
1276
1444
  log4("end options", void 0, {
1277
- F: __dxlog_file4,
1278
- L: 266,
1445
+ F: __dxlog_file6,
1446
+ L: 265,
1279
1447
  S: this,
1280
1448
  C: (f, a) => f(...a)
1281
1449
  });
@@ -1288,8 +1456,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1288
1456
  this._callbacks.onOpen(this._ctx);
1289
1457
  } catch (err) {
1290
1458
  log4("openError", err, {
1291
- F: __dxlog_file4,
1292
- L: 276,
1459
+ F: __dxlog_file6,
1460
+ L: 275,
1293
1461
  S: this,
1294
1462
  C: (f, a) => f(...a)
1295
1463
  });
@@ -1298,8 +1466,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1298
1466
  }
1299
1467
  async onClose() {
1300
1468
  log4("onClose", void 0, {
1301
- F: __dxlog_file4,
1302
- L: 282,
1469
+ F: __dxlog_file6,
1470
+ L: 281,
1303
1471
  S: this,
1304
1472
  C: (f, a) => f(...a)
1305
1473
  });
@@ -1309,7 +1477,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1309
1477
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation2.AuthMethod.NONE;
1310
1478
 
1311
1479
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1312
- var __dxlog_file5 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1480
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1313
1481
  var InvitationsHandler = class {
1314
1482
  /**
1315
1483
  * @internal
@@ -1321,7 +1489,15 @@ var InvitationsHandler = class {
1321
1489
  var _a;
1322
1490
  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
1491
  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);
1492
+ invariant6(protocol, void 0, {
1493
+ F: __dxlog_file7,
1494
+ L: 76,
1495
+ S: this,
1496
+ A: [
1497
+ "protocol",
1498
+ ""
1499
+ ]
1500
+ });
1325
1501
  const invitation = {
1326
1502
  invitationId,
1327
1503
  type,
@@ -1333,7 +1509,7 @@ var InvitationsHandler = class {
1333
1509
  ...protocol.getInvitationContext()
1334
1510
  };
1335
1511
  const stream = new PushStream();
1336
- const ctx = new Context4({
1512
+ const ctx = new Context5({
1337
1513
  onError: (err) => {
1338
1514
  void ctx.dispose();
1339
1515
  stream.error(err);
@@ -1343,8 +1519,8 @@ var InvitationsHandler = class {
1343
1519
  log5("complete", {
1344
1520
  ...protocol.toJSON()
1345
1521
  }, {
1346
- F: __dxlog_file5,
1347
- L: 99,
1522
+ F: __dxlog_file7,
1523
+ L: 98,
1348
1524
  S: this,
1349
1525
  C: (f, a) => f(...a)
1350
1526
  });
@@ -1368,7 +1544,15 @@ var InvitationsHandler = class {
1368
1544
  var _a2, _b, _c;
1369
1545
  try {
1370
1546
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1371
- invariant6(deviceKey);
1547
+ invariant6(deviceKey, void 0, {
1548
+ F: __dxlog_file7,
1549
+ L: 119,
1550
+ S: this,
1551
+ A: [
1552
+ "deviceKey",
1553
+ ""
1554
+ ]
1555
+ });
1372
1556
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1373
1557
  extension.completedTrigger.wake(deviceKey);
1374
1558
  return admissionResponse;
@@ -1381,19 +1565,19 @@ var InvitationsHandler = class {
1381
1565
  scheduleTask2(ctx, async () => {
1382
1566
  const traceId = PublicKey5.random().toHex();
1383
1567
  try {
1384
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
1568
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
1385
1569
  id: traceId
1386
1570
  }), {
1387
- F: __dxlog_file5,
1388
- L: 138,
1571
+ F: __dxlog_file7,
1572
+ L: 137,
1389
1573
  S: this,
1390
1574
  C: (f, a) => f(...a)
1391
1575
  });
1392
1576
  log5("connected", {
1393
1577
  ...protocol.toJSON()
1394
1578
  }, {
1395
- F: __dxlog_file5,
1396
- L: 139,
1579
+ F: __dxlog_file7,
1580
+ L: 138,
1397
1581
  S: this,
1398
1582
  C: (f, a) => f(...a)
1399
1583
  });
@@ -1408,8 +1592,8 @@ var InvitationsHandler = class {
1408
1592
  guest: deviceKey,
1409
1593
  ...protocol.toJSON()
1410
1594
  }, {
1411
- F: __dxlog_file5,
1412
- L: 142,
1595
+ F: __dxlog_file7,
1596
+ L: 141,
1413
1597
  S: this,
1414
1598
  C: (f, a) => f(...a)
1415
1599
  });
@@ -1417,11 +1601,11 @@ var InvitationsHandler = class {
1417
1601
  ...invitation,
1418
1602
  state: Invitation3.State.SUCCESS
1419
1603
  });
1420
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
1604
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
1421
1605
  id: traceId
1422
1606
  }), {
1423
- F: __dxlog_file5,
1424
- L: 144,
1607
+ F: __dxlog_file7,
1608
+ L: 143,
1425
1609
  S: this,
1426
1610
  C: (f, a) => f(...a)
1427
1611
  });
@@ -1430,8 +1614,8 @@ var InvitationsHandler = class {
1430
1614
  log5("timeout", {
1431
1615
  ...protocol.toJSON()
1432
1616
  }, {
1433
- F: __dxlog_file5,
1434
- L: 147,
1617
+ F: __dxlog_file7,
1618
+ L: 146,
1435
1619
  S: this,
1436
1620
  C: (f, a) => f(...a)
1437
1621
  });
@@ -1441,19 +1625,19 @@ var InvitationsHandler = class {
1441
1625
  });
1442
1626
  } else {
1443
1627
  log5.error("failed", err, {
1444
- F: __dxlog_file5,
1445
- L: 150,
1628
+ F: __dxlog_file7,
1629
+ L: 149,
1446
1630
  S: this,
1447
1631
  C: (f, a) => f(...a)
1448
1632
  });
1449
1633
  stream.error(err);
1450
1634
  }
1451
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.error({
1635
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
1452
1636
  id: traceId,
1453
1637
  error: err
1454
1638
  }), {
1455
- F: __dxlog_file5,
1456
- L: 153,
1639
+ F: __dxlog_file7,
1640
+ L: 152,
1457
1641
  S: this,
1458
1642
  C: (f, a) => f(...a)
1459
1643
  });
@@ -1473,8 +1657,8 @@ var InvitationsHandler = class {
1473
1657
  log5("timeout", {
1474
1658
  ...protocol.toJSON()
1475
1659
  }, {
1476
- F: __dxlog_file5,
1477
- L: 168,
1660
+ F: __dxlog_file7,
1661
+ L: 167,
1478
1662
  S: this,
1479
1663
  C: (f, a) => f(...a)
1480
1664
  });
@@ -1484,8 +1668,8 @@ var InvitationsHandler = class {
1484
1668
  });
1485
1669
  } else {
1486
1670
  log5.error("failed", err, {
1487
- F: __dxlog_file5,
1488
- L: 171,
1671
+ F: __dxlog_file7,
1672
+ L: 170,
1489
1673
  S: this,
1490
1674
  C: (f, a) => f(...a)
1491
1675
  });
@@ -1527,27 +1711,43 @@ var InvitationsHandler = class {
1527
1711
  }
1528
1712
  acceptInvitation(protocol, invitation) {
1529
1713
  const { timeout = INVITATION_TIMEOUT } = invitation;
1530
- invariant6(protocol);
1714
+ invariant6(protocol, void 0, {
1715
+ F: __dxlog_file7,
1716
+ L: 210,
1717
+ S: this,
1718
+ A: [
1719
+ "protocol",
1720
+ ""
1721
+ ]
1722
+ });
1531
1723
  const authenticated = new Trigger3();
1532
1724
  let admitted = false;
1533
1725
  let currentState;
1534
1726
  const stream = new PushStream();
1535
1727
  const setState = (newData) => {
1536
- invariant6(newData.state !== void 0);
1728
+ invariant6(newData.state !== void 0, void 0, {
1729
+ F: __dxlog_file7,
1730
+ L: 221,
1731
+ S: this,
1732
+ A: [
1733
+ "newData.state !== undefined",
1734
+ ""
1735
+ ]
1736
+ });
1537
1737
  currentState = newData.state;
1538
1738
  stream.next({
1539
1739
  ...invitation,
1540
1740
  ...newData
1541
1741
  });
1542
1742
  };
1543
- const ctx = new Context4({
1743
+ const ctx = new Context5({
1544
1744
  onError: (err) => {
1545
1745
  if (err instanceof TimeoutError) {
1546
1746
  log5("timeout", {
1547
1747
  ...protocol.toJSON()
1548
1748
  }, {
1549
- F: __dxlog_file5,
1550
- L: 230,
1749
+ F: __dxlog_file7,
1750
+ L: 229,
1551
1751
  S: this,
1552
1752
  C: (f, a) => f(...a)
1553
1753
  });
@@ -1556,8 +1756,8 @@ var InvitationsHandler = class {
1556
1756
  });
1557
1757
  } else {
1558
1758
  log5.warn("auth failed", err, {
1559
- F: __dxlog_file5,
1560
- L: 233,
1759
+ F: __dxlog_file7,
1760
+ L: 232,
1561
1761
  S: this,
1562
1762
  C: (f, a) => f(...a)
1563
1763
  });
@@ -1570,8 +1770,8 @@ var InvitationsHandler = class {
1570
1770
  log5("complete", {
1571
1771
  ...protocol.toJSON()
1572
1772
  }, {
1573
- F: __dxlog_file5,
1574
- L: 241,
1773
+ F: __dxlog_file7,
1774
+ L: 240,
1575
1775
  S: this,
1576
1776
  C: (f, a) => f(...a)
1577
1777
  });
@@ -1585,8 +1785,8 @@ var InvitationsHandler = class {
1585
1785
  log5("extension disposed", {
1586
1786
  currentState
1587
1787
  }, {
1588
- F: __dxlog_file5,
1589
- L: 251,
1788
+ F: __dxlog_file7,
1789
+ L: 250,
1590
1790
  S: this,
1591
1791
  C: (f, a) => f(...a)
1592
1792
  });
@@ -1597,11 +1797,11 @@ var InvitationsHandler = class {
1597
1797
  scheduleTask2(ctx, async () => {
1598
1798
  const traceId = PublicKey5.random().toHex();
1599
1799
  try {
1600
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
1800
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
1601
1801
  id: traceId
1602
1802
  }), {
1603
- F: __dxlog_file5,
1604
- L: 260,
1803
+ F: __dxlog_file7,
1804
+ L: 259,
1605
1805
  S: this,
1606
1806
  C: (f, a) => f(...a)
1607
1807
  });
@@ -1612,8 +1812,8 @@ var InvitationsHandler = class {
1612
1812
  log5("connected", {
1613
1813
  ...protocol.toJSON()
1614
1814
  }, {
1615
- F: __dxlog_file5,
1616
- L: 268,
1815
+ F: __dxlog_file7,
1816
+ L: 267,
1617
1817
  S: this,
1618
1818
  C: (f, a) => f(...a)
1619
1819
  });
@@ -1623,8 +1823,8 @@ var InvitationsHandler = class {
1623
1823
  log5("introduce", {
1624
1824
  ...protocol.toJSON()
1625
1825
  }, {
1626
- F: __dxlog_file5,
1627
- L: 272,
1826
+ F: __dxlog_file7,
1827
+ L: 271,
1628
1828
  S: this,
1629
1829
  C: (f, a) => f(...a)
1630
1830
  });
@@ -1633,8 +1833,8 @@ var InvitationsHandler = class {
1633
1833
  ...protocol.toJSON(),
1634
1834
  response: introductionResponse
1635
1835
  }, {
1636
- F: __dxlog_file5,
1637
- L: 276,
1836
+ F: __dxlog_file7,
1837
+ L: 275,
1638
1838
  S: this,
1639
1839
  C: (f, a) => f(...a)
1640
1840
  });
@@ -1645,8 +1845,8 @@ var InvitationsHandler = class {
1645
1845
  if (isAuthenticationRequired(invitation)) {
1646
1846
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1647
1847
  log5("guest waiting for authentication code...", void 0, {
1648
- F: __dxlog_file5,
1649
- L: 285,
1848
+ F: __dxlog_file7,
1849
+ L: 284,
1650
1850
  S: this,
1651
1851
  C: (f, a) => f(...a)
1652
1852
  });
@@ -1657,8 +1857,8 @@ var InvitationsHandler = class {
1657
1857
  timeout
1658
1858
  });
1659
1859
  log5("sending authentication request", void 0, {
1660
- F: __dxlog_file5,
1661
- L: 289,
1860
+ F: __dxlog_file7,
1861
+ L: 288,
1662
1862
  S: this,
1663
1863
  C: (f, a) => f(...a)
1664
1864
  });
@@ -1678,8 +1878,8 @@ var InvitationsHandler = class {
1678
1878
  log5("retrying invalid code", {
1679
1879
  attempt
1680
1880
  }, {
1681
- F: __dxlog_file5,
1682
- L: 300,
1881
+ F: __dxlog_file7,
1882
+ L: 299,
1683
1883
  S: this,
1684
1884
  C: (f, a) => f(...a)
1685
1885
  });
@@ -1695,8 +1895,8 @@ var InvitationsHandler = class {
1695
1895
  log5("request admission", {
1696
1896
  ...protocol.toJSON()
1697
1897
  }, {
1698
- F: __dxlog_file5,
1699
- L: 311,
1898
+ F: __dxlog_file7,
1899
+ L: 310,
1700
1900
  S: this,
1701
1901
  C: (f, a) => f(...a)
1702
1902
  });
@@ -1707,8 +1907,8 @@ var InvitationsHandler = class {
1707
1907
  log5("admitted by host", {
1708
1908
  ...protocol.toJSON()
1709
1909
  }, {
1710
- F: __dxlog_file5,
1711
- L: 322,
1910
+ F: __dxlog_file7,
1911
+ L: 321,
1712
1912
  S: this,
1713
1913
  C: (f, a) => f(...a)
1714
1914
  });
@@ -1716,11 +1916,11 @@ var InvitationsHandler = class {
1716
1916
  ...result,
1717
1917
  state: Invitation3.State.SUCCESS
1718
1918
  });
1719
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
1919
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
1720
1920
  id: traceId
1721
1921
  }), {
1722
- F: __dxlog_file5,
1723
- L: 324,
1922
+ F: __dxlog_file7,
1923
+ L: 323,
1724
1924
  S: this,
1725
1925
  C: (f, a) => f(...a)
1726
1926
  });
@@ -1729,8 +1929,8 @@ var InvitationsHandler = class {
1729
1929
  log5("timeout", {
1730
1930
  ...protocol.toJSON()
1731
1931
  }, {
1732
- F: __dxlog_file5,
1733
- L: 327,
1932
+ F: __dxlog_file7,
1933
+ L: 326,
1734
1934
  S: this,
1735
1935
  C: (f, a) => f(...a)
1736
1936
  });
@@ -1739,19 +1939,19 @@ var InvitationsHandler = class {
1739
1939
  });
1740
1940
  } else {
1741
1941
  log5("auth failed", err, {
1742
- F: __dxlog_file5,
1743
- L: 330,
1942
+ F: __dxlog_file7,
1943
+ L: 329,
1744
1944
  S: this,
1745
1945
  C: (f, a) => f(...a)
1746
1946
  });
1747
1947
  stream.error(err);
1748
1948
  }
1749
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.error({
1949
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
1750
1950
  id: traceId,
1751
1951
  error: err
1752
1952
  }), {
1753
- F: __dxlog_file5,
1754
- L: 333,
1953
+ F: __dxlog_file7,
1954
+ L: 332,
1755
1955
  S: this,
1756
1956
  C: (f, a) => f(...a)
1757
1957
  });
@@ -1768,8 +1968,8 @@ var InvitationsHandler = class {
1768
1968
  log5("timeout", {
1769
1969
  ...protocol.toJSON()
1770
1970
  }, {
1771
- F: __dxlog_file5,
1772
- L: 344,
1971
+ F: __dxlog_file7,
1972
+ L: 343,
1773
1973
  S: this,
1774
1974
  C: (f, a) => f(...a)
1775
1975
  });
@@ -1778,8 +1978,8 @@ var InvitationsHandler = class {
1778
1978
  });
1779
1979
  } else {
1780
1980
  log5("auth failed", err, {
1781
- F: __dxlog_file5,
1782
- L: 347,
1981
+ F: __dxlog_file7,
1982
+ L: 346,
1783
1983
  S: this,
1784
1984
  C: (f, a) => f(...a)
1785
1985
  });
@@ -1790,7 +1990,15 @@ var InvitationsHandler = class {
1790
1990
  return extension;
1791
1991
  };
1792
1992
  scheduleTask2(ctx, async () => {
1793
- invariant6(invitation.swarmKey);
1993
+ invariant6(invitation.swarmKey, void 0, {
1994
+ F: __dxlog_file7,
1995
+ L: 356,
1996
+ S: this,
1997
+ A: [
1998
+ "invitation.swarmKey",
1999
+ ""
2000
+ ]
2001
+ });
1794
2002
  const topic = invitation.swarmKey;
1795
2003
  const swarmConnection = await this._networkManager.joinSwarm({
1796
2004
  topic,
@@ -1823,12 +2031,12 @@ var InvitationsHandler = class {
1823
2031
  };
1824
2032
 
1825
2033
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1826
- import invariant7 from "tiny-invariant";
1827
2034
  import { Event as Event3 } from "@dxos/async";
1828
2035
  import { Stream as Stream8 } from "@dxos/codec-protobuf";
2036
+ import { invariant as invariant7 } from "@dxos/invariant";
1829
2037
  import { log as log6 } from "@dxos/log";
1830
2038
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
1831
- var __dxlog_file6 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2039
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1832
2040
  var InvitationsServiceImpl = class {
1833
2041
  constructor(_invitationsHandler, _getHandler) {
1834
2042
  this._invitationsHandler = _invitationsHandler;
@@ -1890,19 +2098,27 @@ var InvitationsServiceImpl = class {
1890
2098
  }
1891
2099
  async authenticate({ invitationId, authCode }) {
1892
2100
  log6("authenticating...", void 0, {
1893
- F: __dxlog_file6,
1894
- L: 103,
2101
+ F: __dxlog_file8,
2102
+ L: 102,
1895
2103
  S: this,
1896
2104
  C: (f, a) => f(...a)
1897
2105
  });
1898
- invariant7(invitationId);
2106
+ invariant7(invitationId, void 0, {
2107
+ F: __dxlog_file8,
2108
+ L: 103,
2109
+ S: this,
2110
+ A: [
2111
+ "invitationId",
2112
+ ""
2113
+ ]
2114
+ });
1899
2115
  const observable = this._acceptInvitations.get(invitationId);
1900
2116
  if (!observable) {
1901
2117
  log6.warn("invalid invitation", {
1902
2118
  invitationId
1903
2119
  }, {
1904
- F: __dxlog_file6,
1905
- L: 107,
2120
+ F: __dxlog_file8,
2121
+ L: 106,
1906
2122
  S: this,
1907
2123
  C: (f, a) => f(...a)
1908
2124
  });
@@ -1912,12 +2128,20 @@ var InvitationsServiceImpl = class {
1912
2128
  }
1913
2129
  async cancelInvitation({ invitationId }) {
1914
2130
  log6("deleting...", void 0, {
1915
- F: __dxlog_file6,
1916
- L: 114,
2131
+ F: __dxlog_file8,
2132
+ L: 113,
1917
2133
  S: this,
1918
2134
  C: (f, a) => f(...a)
1919
2135
  });
1920
- invariant7(invitationId);
2136
+ invariant7(invitationId, void 0, {
2137
+ F: __dxlog_file8,
2138
+ L: 114,
2139
+ S: this,
2140
+ A: [
2141
+ "invitationId",
2142
+ ""
2143
+ ]
2144
+ });
1921
2145
  const created = this._createInvitations.get(invitationId);
1922
2146
  const accepted = this._acceptInvitations.get(invitationId);
1923
2147
  if (created) {
@@ -1932,8 +2156,8 @@ var InvitationsServiceImpl = class {
1932
2156
  log6.warn("invalid invitation", {
1933
2157
  invitationId
1934
2158
  }, {
1935
- F: __dxlog_file6,
1936
- L: 127,
2159
+ F: __dxlog_file8,
2160
+ L: 126,
1937
2161
  S: this,
1938
2162
  C: (f, a) => f(...a)
1939
2163
  });
@@ -1992,12 +2216,12 @@ var InvitationsServiceImpl = class {
1992
2216
  };
1993
2217
 
1994
2218
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
1995
- import invariant8 from "tiny-invariant";
1996
2219
  import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
1997
2220
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2221
+ import { invariant as invariant8 } from "@dxos/invariant";
1998
2222
  import { log as log7 } from "@dxos/log";
1999
2223
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
2000
- var __dxlog_file7 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2224
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2001
2225
  var SpaceInvitationProtocol = class {
2002
2226
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2003
2227
  this._spaceManager = _spaceManager;
@@ -2019,24 +2243,64 @@ var SpaceInvitationProtocol = class {
2019
2243
  }
2020
2244
  async admit(request, guestProfile) {
2021
2245
  var _a;
2022
- invariant8(this._spaceKey);
2246
+ invariant8(this._spaceKey, void 0, {
2247
+ F: __dxlog_file9,
2248
+ L: 42,
2249
+ S: this,
2250
+ A: [
2251
+ "this._spaceKey",
2252
+ ""
2253
+ ]
2254
+ });
2023
2255
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2024
- invariant8(space);
2025
- invariant8(request.space);
2256
+ invariant8(space, void 0, {
2257
+ F: __dxlog_file9,
2258
+ L: 44,
2259
+ S: this,
2260
+ A: [
2261
+ "space",
2262
+ ""
2263
+ ]
2264
+ });
2265
+ invariant8(request.space, void 0, {
2266
+ F: __dxlog_file9,
2267
+ L: 46,
2268
+ S: this,
2269
+ A: [
2270
+ "request.space",
2271
+ ""
2272
+ ]
2273
+ });
2026
2274
  const { identityKey, deviceKey } = request.space;
2027
2275
  log7("writing guest credentials", {
2028
2276
  host: this._signingContext.deviceKey,
2029
2277
  guest: deviceKey
2030
2278
  }, {
2031
- F: __dxlog_file7,
2032
- L: 50,
2279
+ F: __dxlog_file9,
2280
+ L: 49,
2033
2281
  S: this,
2034
2282
  C: (f, a) => f(...a)
2035
2283
  });
2036
2284
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2037
- invariant8(credentials[0].credential);
2285
+ invariant8(credentials[0].credential, void 0, {
2286
+ F: __dxlog_file9,
2287
+ L: 60,
2288
+ S: this,
2289
+ A: [
2290
+ "credentials[0].credential",
2291
+ ""
2292
+ ]
2293
+ });
2038
2294
  const spaceMemberCredential = credentials[0].credential.credential;
2039
- invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2295
+ invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2296
+ F: __dxlog_file9,
2297
+ L: 62,
2298
+ S: this,
2299
+ A: [
2300
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
2301
+ ""
2302
+ ]
2303
+ });
2040
2304
  await writeMessages2(space.inner.controlPipeline.writer, credentials);
2041
2305
  return {
2042
2306
  space: {
@@ -2064,11 +2328,35 @@ var SpaceInvitationProtocol = class {
2064
2328
  };
2065
2329
  }
2066
2330
  async accept(response) {
2067
- invariant8(response.space);
2331
+ invariant8(response.space, void 0, {
2332
+ F: __dxlog_file9,
2333
+ L: 97,
2334
+ S: this,
2335
+ A: [
2336
+ "response.space",
2337
+ ""
2338
+ ]
2339
+ });
2068
2340
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2069
2341
  const assertion = getCredentialAssertion(credential);
2070
- invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2071
- invariant8(credential.subject.id.equals(this._signingContext.identityKey));
2342
+ invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2343
+ F: __dxlog_file9,
2344
+ L: 100,
2345
+ S: this,
2346
+ A: [
2347
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
2348
+ "'Invalid credential'"
2349
+ ]
2350
+ });
2351
+ invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2352
+ F: __dxlog_file9,
2353
+ L: 101,
2354
+ S: this,
2355
+ A: [
2356
+ "credential.subject.id.equals(this._signingContext.identityKey)",
2357
+ ""
2358
+ ]
2359
+ });
2072
2360
  await this._spaceManager.acceptSpace({
2073
2361
  spaceKey: assertion.spaceKey,
2074
2362
  genesisFeedKey: assertion.genesisFeedKey,
@@ -2135,37 +2423,203 @@ var ClientRpcServer = class {
2135
2423
  }
2136
2424
  };
2137
2425
 
2426
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2427
+ import { getFirstStreamValue } from "@dxos/codec-protobuf";
2428
+ import { credentialTypeFilter } from "@dxos/credentials";
2429
+ import { DocumentModel } from "@dxos/document-model";
2430
+ import { invariant as invariant9 } from "@dxos/invariant";
2431
+ import { log as log8 } from "@dxos/log";
2432
+ import { STORAGE_VERSION } from "@dxos/protocols";
2433
+ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2434
+
2435
+ // packages/sdk/client-services/src/version.ts
2436
+ var DXOS_VERSION = "0.1.56-main.01afb72";
2437
+
2438
+ // packages/sdk/client-services/src/packlets/services/platform.ts
2439
+ var getPlatform = () => {
2440
+ if (process.browser) {
2441
+ if (typeof window !== "undefined") {
2442
+ const { userAgent } = window.navigator;
2443
+ return {
2444
+ type: "browser",
2445
+ userAgent,
2446
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2447
+ };
2448
+ } else {
2449
+ return {
2450
+ type: "shared-worker",
2451
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2452
+ };
2453
+ }
2454
+ } else {
2455
+ const { platform, version, arch } = process;
2456
+ return {
2457
+ type: "node",
2458
+ platform: `${platform} ${version} ${arch}`,
2459
+ runtime: process.version,
2460
+ uptime: Math.floor(process.uptime()),
2461
+ memory: process.memoryUsage()
2462
+ };
2463
+ }
2464
+ };
2465
+
2466
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2467
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2468
+ var DEFAULT_TIMEOUT = 1e3;
2469
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
2470
+ var _a, _b, _c;
2471
+ const diagnostics = {
2472
+ created: new Date().toISOString(),
2473
+ platform: getPlatform(),
2474
+ client: {
2475
+ version: DXOS_VERSION,
2476
+ storage: {
2477
+ version: STORAGE_VERSION
2478
+ }
2479
+ }
2480
+ };
2481
+ {
2482
+ invariant9(clientServices.LoggingService, "SystemService is not available.", {
2483
+ F: __dxlog_file10,
2484
+ L: 87,
2485
+ S: void 0,
2486
+ A: [
2487
+ "clientServices.LoggingService",
2488
+ "'SystemService is not available.'"
2489
+ ]
2490
+ });
2491
+ diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
2492
+ timeout: DEFAULT_TIMEOUT
2493
+ }).catch(() => void 0);
2494
+ }
2495
+ const identity = serviceContext.identityManager.identity;
2496
+ if (identity) {
2497
+ diagnostics.identity = {
2498
+ identityKey: identity.identityKey,
2499
+ spaceKey: identity.space.key,
2500
+ profile: identity.profileDocument
2501
+ };
2502
+ const { devices } = (_a = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
2503
+ timeout: DEFAULT_TIMEOUT
2504
+ }).catch(() => void 0)) != null ? _a : {};
2505
+ diagnostics.devices = devices;
2506
+ if (serviceContext.dataSpaceManager) {
2507
+ diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
2508
+ }
2509
+ const { feeds = [] } = (_c = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2510
+ timeout: DEFAULT_TIMEOUT
2511
+ }).catch(() => void 0)) != null ? _c : {};
2512
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2513
+ feedKey,
2514
+ bytes,
2515
+ length
2516
+ }));
2517
+ }
2518
+ diagnostics.config = config.values;
2519
+ return diagnostics;
2520
+ };
2521
+ var getProperties = (space) => {
2522
+ let properties = {};
2523
+ try {
2524
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
2525
+ var _a, _b;
2526
+ return ((_a = item.modelMeta) == null ? void 0 : _a.type) === DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
2527
+ });
2528
+ const state = propertiesItem == null ? void 0 : propertiesItem.state;
2529
+ properties = state == null ? void 0 : state.data;
2530
+ } catch (err) {
2531
+ log8.warn(err.message, void 0, {
2532
+ F: __dxlog_file10,
2533
+ L: 144,
2534
+ S: void 0,
2535
+ C: (f, a) => f(...a)
2536
+ });
2537
+ }
2538
+ return properties;
2539
+ };
2540
+ var getSpaceStats = async (space) => {
2541
+ var _a, _b, _c, _d, _e, _f;
2542
+ const stats = {
2543
+ key: space.key,
2544
+ metrics: space.metrics,
2545
+ epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
2546
+ ...credential.subject.assertion,
2547
+ id: credential.id
2548
+ })),
2549
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2550
+ var _a2;
2551
+ return {
2552
+ identity: {
2553
+ identityKey: member.key,
2554
+ profile: {
2555
+ displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
2556
+ }
2557
+ },
2558
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
2559
+ };
2560
+ }),
2561
+ pipeline: {
2562
+ // TODO(burdon): Pick properties from credentials if needed.
2563
+ // currentEpoch: space.dataPipeline.currentEpoch,
2564
+ // appliedEpoch: space.dataPipeline.appliedEpoch,
2565
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2566
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2567
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2568
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
2569
+ // TODO(burdon): Empty?
2570
+ dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
2571
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
2572
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
2573
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
2574
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
2575
+ }
2576
+ };
2577
+ if (space.dataPipeline.itemManager) {
2578
+ Object.assign(stats, {
2579
+ properties: getProperties(space),
2580
+ db: {
2581
+ objects: space.dataPipeline.itemManager.entities.size
2582
+ }
2583
+ });
2584
+ }
2585
+ if (stats.metrics) {
2586
+ const { open, ready } = stats.metrics;
2587
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2588
+ }
2589
+ return stats;
2590
+ };
2591
+
2138
2592
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2139
2593
  import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
2140
2594
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2141
- import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
2595
+ import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
2142
2596
  import { timed } from "@dxos/debug";
2143
2597
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2144
2598
  import { CancelledError, SystemError } from "@dxos/errors";
2145
2599
  import { PublicKey as PublicKey7 } from "@dxos/keys";
2146
- import { log as log9 } from "@dxos/log";
2600
+ import { log as log10 } from "@dxos/log";
2147
2601
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
2148
2602
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2149
2603
  import { Timeframe } from "@dxos/timeframe";
2150
2604
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2151
2605
 
2152
2606
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2153
- import invariant9 from "tiny-invariant";
2154
2607
  import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
2155
- import { Context as Context5, rejectOnDispose } from "@dxos/context";
2608
+ import { Context as Context6, rejectOnDispose } from "@dxos/context";
2609
+ import { invariant as invariant10 } from "@dxos/invariant";
2156
2610
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2157
- import { log as log8 } from "@dxos/log";
2611
+ import { log as log9 } from "@dxos/log";
2158
2612
  import { schema as schema3 } from "@dxos/protocols";
2159
2613
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
2160
2614
  import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
2161
- var __dxlog_file8 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2615
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2162
2616
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2163
2617
  var DEFAULT_SUCCESS_DELAY = 1e3;
2164
2618
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2165
2619
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2166
2620
  var NotarizationPlugin = class {
2167
2621
  constructor() {
2168
- this._ctx = new Context5();
2622
+ this._ctx = new Context6();
2169
2623
  this._extensionOpened = new Event4();
2170
2624
  this._extensions = /* @__PURE__ */ new Set();
2171
2625
  this._processedCredentials = new ComplexSet(PublicKey6.hash);
@@ -2183,23 +2637,31 @@ var NotarizationPlugin = class {
2183
2637
  * Request credentials to be notarized.
2184
2638
  */
2185
2639
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2186
- log8("notarize", {
2640
+ log9("notarize", {
2187
2641
  credentials
2188
2642
  }, {
2189
- F: __dxlog_file8,
2190
- L: 91,
2643
+ F: __dxlog_file11,
2644
+ L: 90,
2191
2645
  S: this,
2192
2646
  C: (f, a) => f(...a)
2193
2647
  });
2194
- invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
2648
+ invariant10(credentials.every((credential) => credential.id), "Credentials must have an id", {
2649
+ F: __dxlog_file11,
2650
+ L: 91,
2651
+ S: this,
2652
+ A: [
2653
+ "credentials.every((credential) => credential.id)",
2654
+ "'Credentials must have an id'"
2655
+ ]
2656
+ });
2195
2657
  const errors = new Trigger4();
2196
2658
  const ctx = this._ctx.derive({
2197
2659
  onError: (err) => {
2198
- log8.warn("Notarization error", {
2660
+ log9.warn("Notarization error", {
2199
2661
  err
2200
2662
  }, {
2201
- F: __dxlog_file8,
2202
- L: 100,
2663
+ F: __dxlog_file11,
2664
+ L: 99,
2203
2665
  S: this,
2204
2666
  C: (f, a) => f(...a)
2205
2667
  });
@@ -2210,12 +2672,12 @@ var NotarizationPlugin = class {
2210
2672
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2211
2673
  if (timeout !== 0) {
2212
2674
  scheduleTask3(ctx, () => {
2213
- log8.warn("Notarization timeout", {
2675
+ log9.warn("Notarization timeout", {
2214
2676
  timeout,
2215
2677
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2216
2678
  }, {
2217
- F: __dxlog_file8,
2218
- L: 112,
2679
+ F: __dxlog_file11,
2680
+ L: 111,
2219
2681
  S: this,
2220
2682
  C: (f, a) => f(...a)
2221
2683
  });
@@ -2234,11 +2696,11 @@ var NotarizationPlugin = class {
2234
2696
  ...this._extensions
2235
2697
  ].find((peer2) => !peersTried.has(peer2));
2236
2698
  if (!peer) {
2237
- log8.warn("Exhausted all peers to notarize with", {
2699
+ log9.warn("Exhausted all peers to notarize with", {
2238
2700
  retryIn: retryTimeout
2239
2701
  }, {
2240
- F: __dxlog_file8,
2241
- L: 137,
2702
+ F: __dxlog_file11,
2703
+ L: 136,
2242
2704
  S: this,
2243
2705
  C: (f, a) => f(...a)
2244
2706
  });
@@ -2247,30 +2709,30 @@ var NotarizationPlugin = class {
2247
2709
  return;
2248
2710
  }
2249
2711
  peersTried.add(peer);
2250
- log8("try notarizing", {
2712
+ log9("try notarizing", {
2251
2713
  peer: peer.localPeerId,
2252
2714
  credentialId: credentials.map((credential) => credential.id)
2253
2715
  }, {
2254
- F: __dxlog_file8,
2255
- L: 144,
2716
+ F: __dxlog_file11,
2717
+ L: 143,
2256
2718
  S: this,
2257
2719
  C: (f, a) => f(...a)
2258
2720
  });
2259
2721
  await peer.rpc.NotarizationService.notarize({
2260
2722
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2261
2723
  });
2262
- log8("success", void 0, {
2263
- F: __dxlog_file8,
2264
- L: 148,
2724
+ log9("success", void 0, {
2725
+ F: __dxlog_file11,
2726
+ L: 147,
2265
2727
  S: this,
2266
2728
  C: (f, a) => f(...a)
2267
2729
  });
2268
2730
  await sleep(successDelay);
2269
2731
  } catch (err) {
2270
2732
  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,
2733
+ log9.warn("error notarizing (recoverable)", err, {
2734
+ F: __dxlog_file11,
2735
+ L: 151,
2274
2736
  S: this,
2275
2737
  C: (f, a) => f(...a)
2276
2738
  });
@@ -2286,9 +2748,9 @@ var NotarizationPlugin = class {
2286
2748
  allNotarized,
2287
2749
  errors.wait()
2288
2750
  ]);
2289
- log8("done", void 0, {
2290
- F: __dxlog_file8,
2291
- L: 163,
2751
+ log9("done", void 0, {
2752
+ F: __dxlog_file11,
2753
+ L: 162,
2292
2754
  S: this,
2293
2755
  C: (f, a) => f(...a)
2294
2756
  });
@@ -2309,7 +2771,15 @@ var NotarizationPlugin = class {
2309
2771
  this._processCredentialsTriggers.delete(credential.id);
2310
2772
  }
2311
2773
  setWriter(writer) {
2312
- invariant9(!this._writer, "Writer already set.");
2774
+ invariant10(!this._writer, "Writer already set.", {
2775
+ F: __dxlog_file11,
2776
+ L: 181,
2777
+ S: this,
2778
+ A: [
2779
+ "!this._writer",
2780
+ "'Writer already set.'"
2781
+ ]
2782
+ });
2313
2783
  this._writer = writer;
2314
2784
  }
2315
2785
  async _waitUntilProcessed(id) {
@@ -2327,7 +2797,15 @@ var NotarizationPlugin = class {
2327
2797
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2328
2798
  }
2329
2799
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2330
- invariant9(credential.id, "Credential must have an id");
2800
+ invariant10(credential.id, "Credential must have an id", {
2801
+ F: __dxlog_file11,
2802
+ L: 200,
2803
+ S: this,
2804
+ A: [
2805
+ "credential.id",
2806
+ "'Credential must have an id'"
2807
+ ]
2808
+ });
2331
2809
  if (this._processedCredentials.has(credential.id)) {
2332
2810
  continue;
2333
2811
  }
@@ -2337,11 +2815,11 @@ var NotarizationPlugin = class {
2337
2815
  createExtension() {
2338
2816
  const extension = new NotarizationTeleportExtension({
2339
2817
  onOpen: async () => {
2340
- log8("extension opened", {
2818
+ log9("extension opened", {
2341
2819
  peer: extension.localPeerId
2342
2820
  }, {
2343
- F: __dxlog_file8,
2344
- L: 212,
2821
+ F: __dxlog_file11,
2822
+ L: 211,
2345
2823
  S: this,
2346
2824
  C: (f, a) => f(...a)
2347
2825
  });
@@ -2349,11 +2827,11 @@ var NotarizationPlugin = class {
2349
2827
  this._extensionOpened.emit();
2350
2828
  },
2351
2829
  onClose: async () => {
2352
- log8("extension closed", {
2830
+ log9("extension closed", {
2353
2831
  peer: extension.localPeerId
2354
2832
  }, {
2355
- F: __dxlog_file8,
2356
- L: 217,
2833
+ F: __dxlog_file11,
2834
+ L: 216,
2357
2835
  S: this,
2358
2836
  C: (f, a) => f(...a)
2359
2837
  });
@@ -2396,7 +2874,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
2396
2874
  };
2397
2875
 
2398
2876
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2399
- function _ts_decorate(decorators, target, key, desc) {
2877
+ function _ts_decorate3(decorators, target, key, desc) {
2400
2878
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2401
2879
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2402
2880
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2406,10 +2884,10 @@ function _ts_decorate(decorators, target, key, desc) {
2406
2884
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2407
2885
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2408
2886
  }
2409
- var __dxlog_file9 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2887
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2410
2888
  var DataSpace = class DataSpace2 {
2411
2889
  constructor(params) {
2412
- this._ctx = new Context6();
2890
+ this._ctx = new Context7();
2413
2891
  this._notarizationPlugin = new NotarizationPlugin();
2414
2892
  this._state = SpaceState.CLOSED;
2415
2893
  /**
@@ -2467,7 +2945,7 @@ var DataSpace = class DataSpace2 {
2467
2945
  async _open() {
2468
2946
  await this._notarizationPlugin.open();
2469
2947
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2470
- await this._inner.open();
2948
+ await this._inner.open(new Context7());
2471
2949
  this._state = SpaceState.CONTROL_ONLY;
2472
2950
  this.stateUpdate.emit();
2473
2951
  this.metrics = {};
@@ -2481,7 +2959,7 @@ var DataSpace = class DataSpace2 {
2481
2959
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2482
2960
  this._state = SpaceState.CLOSED;
2483
2961
  await this._ctx.dispose();
2484
- this._ctx = new Context6();
2962
+ this._ctx = new Context7();
2485
2963
  await this.authVerifier.close();
2486
2964
  await this._inner.close();
2487
2965
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -2504,16 +2982,16 @@ var DataSpace = class DataSpace2 {
2504
2982
  await this.initializeDataPipeline();
2505
2983
  } catch (err) {
2506
2984
  if (err instanceof CancelledError) {
2507
- log9("data pipeline initialization cancelled", err, {
2508
- F: __dxlog_file9,
2985
+ log10("data pipeline initialization cancelled", err, {
2986
+ F: __dxlog_file12,
2509
2987
  L: 193,
2510
2988
  S: this,
2511
2989
  C: (f, a) => f(...a)
2512
2990
  });
2513
2991
  return;
2514
2992
  }
2515
- log9.error("Error initializing data pipeline", err, {
2516
- F: __dxlog_file9,
2993
+ log10.error("Error initializing data pipeline", err, {
2994
+ F: __dxlog_file12,
2517
2995
  L: 197,
2518
2996
  S: this,
2519
2997
  C: (f, a) => f(...a)
@@ -2538,8 +3016,8 @@ var DataSpace = class DataSpace2 {
2538
3016
  });
2539
3017
  this.metrics.controlPipelineReady = new Date();
2540
3018
  await this._createWritableFeeds();
2541
- log9("writable feeds created", void 0, {
2542
- F: __dxlog_file9,
3019
+ log10("writable feeds created", void 0, {
3020
+ F: __dxlog_file12,
2543
3021
  L: 221,
2544
3022
  S: this,
2545
3023
  C: (f, a) => f(...a)
@@ -2555,8 +3033,8 @@ var DataSpace = class DataSpace2 {
2555
3033
  await this._inner.initializeDataPipeline();
2556
3034
  this.metrics.dataPipelineOpen = new Date();
2557
3035
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2558
- log9("waiting for data pipeline to reach target timeframe", void 0, {
2559
- F: __dxlog_file9,
3036
+ log10("waiting for data pipeline to reach target timeframe", void 0, {
3037
+ F: __dxlog_file12,
2560
3038
  L: 242,
2561
3039
  S: this,
2562
3040
  C: (f, a) => f(...a)
@@ -2566,8 +3044,8 @@ var DataSpace = class DataSpace2 {
2566
3044
  breakOnStall: false
2567
3045
  });
2568
3046
  this.metrics.dataPipelineReady = new Date();
2569
- log9("data pipeline ready", void 0, {
2570
- F: __dxlog_file9,
3047
+ log10("data pipeline ready", void 0, {
3048
+ F: __dxlog_file12,
2571
3049
  L: 251,
2572
3050
  S: this,
2573
3051
  C: (f, a) => f(...a)
@@ -2666,33 +3144,33 @@ var DataSpace = class DataSpace2 {
2666
3144
  this.stateUpdate.emit();
2667
3145
  }
2668
3146
  };
2669
- _ts_decorate([
3147
+ _ts_decorate3([
2670
3148
  synchronized
2671
3149
  ], DataSpace.prototype, "open", null);
2672
- _ts_decorate([
3150
+ _ts_decorate3([
2673
3151
  synchronized
2674
3152
  ], DataSpace.prototype, "close", null);
2675
- _ts_decorate([
3153
+ _ts_decorate3([
2676
3154
  timed(1e4)
2677
3155
  ], DataSpace.prototype, "_createWritableFeeds", null);
2678
- _ts_decorate([
3156
+ _ts_decorate3([
2679
3157
  synchronized
2680
3158
  ], DataSpace.prototype, "activate", null);
2681
- _ts_decorate([
3159
+ _ts_decorate3([
2682
3160
  synchronized
2683
3161
  ], DataSpace.prototype, "deactivate", null);
2684
- DataSpace = _ts_decorate([
3162
+ DataSpace = _ts_decorate3([
2685
3163
  trackLeaks("open", "close")
2686
3164
  ], DataSpace);
2687
3165
 
2688
3166
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2689
- import invariant10 from "tiny-invariant";
2690
3167
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
2691
- import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
3168
+ import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
2692
3169
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3170
+ import { invariant as invariant11 } from "@dxos/invariant";
2693
3171
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2694
- import { log as log10 } from "@dxos/log";
2695
- import { trace as trace4 } from "@dxos/protocols";
3172
+ import { log as log11 } from "@dxos/log";
3173
+ import { trace as trace5 } from "@dxos/protocols";
2696
3174
  import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
2697
3175
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
2698
3176
  import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
@@ -2700,7 +3178,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
2700
3178
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
2701
3179
  import { createCredential } from "@dxos/credentials";
2702
3180
  import { failUndefined as failUndefined2 } from "@dxos/debug";
2703
- import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
3181
+ import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
2704
3182
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2705
3183
  var spaceGenesis = async (keyring, signingContext, space) => {
2706
3184
  var _a, _b, _c, _d;
@@ -2721,7 +3199,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2721
3199
  assertion: {
2722
3200
  "@type": "dxos.halo.credentials.SpaceMember",
2723
3201
  spaceKey: space.key,
2724
- role: SpaceMember.Role.ADMIN,
3202
+ role: SpaceMember2.Role.ADMIN,
2725
3203
  profile: signingContext.profile,
2726
3204
  genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : failUndefined2()
2727
3205
  }
@@ -2768,7 +3246,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2768
3246
  };
2769
3247
 
2770
3248
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2771
- function _ts_decorate2(decorators, target, key, desc) {
3249
+ function _ts_decorate4(decorators, target, key, desc) {
2772
3250
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2773
3251
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2774
3252
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2778,7 +3256,7 @@ function _ts_decorate2(decorators, target, key, desc) {
2778
3256
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2779
3257
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2780
3258
  }
2781
- var __dxlog_file10 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3259
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2782
3260
  var DataSpaceManager = class DataSpaceManager2 {
2783
3261
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2784
3262
  this._spaceManager = _spaceManager;
@@ -2787,7 +3265,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2787
3265
  this._keyring = _keyring;
2788
3266
  this._signingContext = _signingContext;
2789
3267
  this._feedStore = _feedStore;
2790
- this._ctx = new Context7();
3268
+ this._ctx = new Context8();
2791
3269
  this.updated = new Event6();
2792
3270
  this._spaces = new ComplexMap3(PublicKey8.hash);
2793
3271
  this._isOpen = false;
@@ -2798,36 +3276,36 @@ var DataSpaceManager = class DataSpaceManager2 {
2798
3276
  return this._spaces;
2799
3277
  }
2800
3278
  async open() {
2801
- log10("open", void 0, {
2802
- F: __dxlog_file10,
2803
- L: 80,
3279
+ log11("open", void 0, {
3280
+ F: __dxlog_file13,
3281
+ L: 79,
2804
3282
  S: this,
2805
3283
  C: (f, a) => f(...a)
2806
3284
  });
2807
- log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
3285
+ log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
2808
3286
  id: this._instanceId
2809
3287
  }), {
2810
- F: __dxlog_file10,
2811
- L: 81,
3288
+ F: __dxlog_file13,
3289
+ L: 80,
2812
3290
  S: this,
2813
3291
  C: (f, a) => f(...a)
2814
3292
  });
2815
3293
  await this._metadataStore.load();
2816
- log10("metadata loaded", {
3294
+ log11("metadata loaded", {
2817
3295
  spaces: this._metadataStore.spaces.length
2818
3296
  }, {
2819
- F: __dxlog_file10,
2820
- L: 83,
3297
+ F: __dxlog_file13,
3298
+ L: 82,
2821
3299
  S: this,
2822
3300
  C: (f, a) => f(...a)
2823
3301
  });
2824
3302
  for (const spaceMetadata of this._metadataStore.spaces) {
2825
3303
  try {
2826
- log10("load space", {
3304
+ log11("load space", {
2827
3305
  spaceMetadata
2828
3306
  }, {
2829
- F: __dxlog_file10,
2830
- L: 87,
3307
+ F: __dxlog_file13,
3308
+ L: 86,
2831
3309
  S: this,
2832
3310
  C: (f, a) => f(...a)
2833
3311
  });
@@ -2836,12 +3314,12 @@ var DataSpaceManager = class DataSpaceManager2 {
2836
3314
  space.initializeDataPipelineAsync();
2837
3315
  }
2838
3316
  } catch (err) {
2839
- log10.error("Error loading space", {
3317
+ log11.error("Error loading space", {
2840
3318
  spaceMetadata,
2841
3319
  err
2842
3320
  }, {
2843
- F: __dxlog_file10,
2844
- L: 93,
3321
+ F: __dxlog_file13,
3322
+ L: 92,
2845
3323
  S: this,
2846
3324
  C: (f, a) => f(...a)
2847
3325
  });
@@ -2849,19 +3327,19 @@ var DataSpaceManager = class DataSpaceManager2 {
2849
3327
  }
2850
3328
  this._isOpen = true;
2851
3329
  this.updated.emit();
2852
- log10.trace("dxos.echo.data-space-manager.open", trace4.end({
3330
+ log11.trace("dxos.echo.data-space-manager.open", trace5.end({
2853
3331
  id: this._instanceId
2854
3332
  }), {
2855
- F: __dxlog_file10,
2856
- L: 99,
3333
+ F: __dxlog_file13,
3334
+ L: 98,
2857
3335
  S: this,
2858
3336
  C: (f, a) => f(...a)
2859
3337
  });
2860
3338
  }
2861
3339
  async close() {
2862
- log10("close", void 0, {
2863
- F: __dxlog_file10,
2864
- L: 104,
3340
+ log11("close", void 0, {
3341
+ F: __dxlog_file13,
3342
+ L: 103,
2865
3343
  S: this,
2866
3344
  C: (f, a) => f(...a)
2867
3345
  });
@@ -2875,7 +3353,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2875
3353
  * Creates a new space writing the genesis credentials to the control feed.
2876
3354
  */
2877
3355
  async createSpace() {
2878
- invariant10(this._isOpen, "Not open.");
3356
+ invariant11(this._isOpen, "Not open.", {
3357
+ F: __dxlog_file13,
3358
+ L: 116,
3359
+ S: this,
3360
+ A: [
3361
+ "this._isOpen",
3362
+ "'Not open.'"
3363
+ ]
3364
+ });
2879
3365
  const spaceKey = await this._keyring.createKey();
2880
3366
  const controlFeedKey = await this._keyring.createKey();
2881
3367
  const dataFeedKey = await this._keyring.createKey();
@@ -2886,11 +3372,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2886
3372
  dataFeedKey,
2887
3373
  state: SpaceState2.ACTIVE
2888
3374
  };
2889
- log10("creating space...", {
3375
+ log11("creating space...", {
2890
3376
  spaceKey
2891
3377
  }, {
2892
- F: __dxlog_file10,
2893
- L: 129,
3378
+ F: __dxlog_file13,
3379
+ L: 128,
2894
3380
  S: this,
2895
3381
  C: (f, a) => f(...a)
2896
3382
  });
@@ -2898,7 +3384,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2898
3384
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2899
3385
  await this._metadataStore.addSpace(metadata);
2900
3386
  const memberCredential = credentials[1];
2901
- invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
3387
+ invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3388
+ F: __dxlog_file13,
3389
+ L: 135,
3390
+ S: this,
3391
+ A: [
3392
+ "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3393
+ ""
3394
+ ]
3395
+ });
2902
3396
  await this._signingContext.recordCredential(memberCredential);
2903
3397
  await space.initializeDataPipeline();
2904
3398
  this.updated.emit();
@@ -2906,16 +3400,32 @@ var DataSpaceManager = class DataSpaceManager2 {
2906
3400
  }
2907
3401
  // TODO(burdon): Rename join space.
2908
3402
  async acceptSpace(opts) {
2909
- log10("accept space", {
3403
+ log11("accept space", {
2910
3404
  opts
2911
3405
  }, {
2912
- F: __dxlog_file10,
2913
- L: 148,
3406
+ F: __dxlog_file13,
3407
+ L: 147,
2914
3408
  S: this,
2915
3409
  C: (f, a) => f(...a)
2916
3410
  });
2917
- invariant10(this._isOpen, "Not open.");
2918
- invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
3411
+ invariant11(this._isOpen, "Not open.", {
3412
+ F: __dxlog_file13,
3413
+ L: 148,
3414
+ S: this,
3415
+ A: [
3416
+ "this._isOpen",
3417
+ "'Not open.'"
3418
+ ]
3419
+ });
3420
+ invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3421
+ F: __dxlog_file13,
3422
+ L: 149,
3423
+ S: this,
3424
+ A: [
3425
+ "!this._spaces.has(opts.spaceKey)",
3426
+ "'Space already exists.'"
3427
+ ]
3428
+ });
2919
3429
  const metadata = {
2920
3430
  key: opts.spaceKey,
2921
3431
  genesisFeedKey: opts.genesisFeedKey,
@@ -2940,11 +3450,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2940
3450
  }));
2941
3451
  }
2942
3452
  async _constructSpace(metadata) {
2943
- log10("construct space", {
3453
+ log11("construct space", {
2944
3454
  metadata
2945
3455
  }, {
2946
- F: __dxlog_file10,
2947
- L: 183,
3456
+ F: __dxlog_file13,
3457
+ L: 182,
2948
3458
  S: this,
2949
3459
  C: (f, a) => f(...a)
2950
3460
  });
@@ -2952,7 +3462,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2952
3462
  localPeerId: this._signingContext.deviceKey
2953
3463
  });
2954
3464
  const presence = new Presence({
2955
- announceInterval: 500,
3465
+ announceInterval: 1e3,
2956
3466
  offlineTimeout: 5e3,
2957
3467
  identityKey: this._signingContext.identityKey,
2958
3468
  gossip
@@ -2978,9 +3488,9 @@ var DataSpaceManager = class DataSpaceManager2 {
2978
3488
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2979
3489
  },
2980
3490
  onAuthFailure: () => {
2981
- log10.warn("auth failure", void 0, {
2982
- F: __dxlog_file10,
2983
- L: 214,
3491
+ log11.warn("auth failure", void 0, {
3492
+ F: __dxlog_file13,
3493
+ L: 213,
2984
3494
  S: this,
2985
3495
  C: (f, a) => f(...a)
2986
3496
  });
@@ -3000,23 +3510,23 @@ var DataSpaceManager = class DataSpaceManager2 {
3000
3510
  signingContext: this._signingContext,
3001
3511
  callbacks: {
3002
3512
  beforeReady: async () => {
3003
- log10("before space ready", {
3513
+ log11("before space ready", {
3004
3514
  space: space.key
3005
3515
  }, {
3006
- F: __dxlog_file10,
3007
- L: 232,
3516
+ F: __dxlog_file13,
3517
+ L: 231,
3008
3518
  S: this,
3009
3519
  C: (f, a) => f(...a)
3010
3520
  });
3011
3521
  await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3012
3522
  },
3013
3523
  afterReady: async () => {
3014
- log10("after space ready", {
3524
+ log11("after space ready", {
3015
3525
  space: space.key,
3016
3526
  open: this._isOpen
3017
3527
  }, {
3018
- F: __dxlog_file10,
3019
- L: 239,
3528
+ F: __dxlog_file13,
3529
+ L: 238,
3020
3530
  S: this,
3021
3531
  C: (f, a) => f(...a)
3022
3532
  });
@@ -3025,11 +3535,11 @@ var DataSpaceManager = class DataSpaceManager2 {
3025
3535
  }
3026
3536
  },
3027
3537
  beforeClose: async () => {
3028
- log10("before space close", {
3538
+ log11("before space close", {
3029
3539
  space: space.key
3030
3540
  }, {
3031
- F: __dxlog_file10,
3032
- L: 245,
3541
+ F: __dxlog_file13,
3542
+ L: 244,
3033
3543
  S: this,
3034
3544
  C: (f, a) => f(...a)
3035
3545
  });
@@ -3051,19 +3561,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3051
3561
  return dataSpace;
3052
3562
  }
3053
3563
  };
3054
- _ts_decorate2([
3564
+ _ts_decorate4([
3055
3565
  synchronized2
3056
3566
  ], DataSpaceManager.prototype, "open", null);
3057
- _ts_decorate2([
3567
+ _ts_decorate4([
3058
3568
  synchronized2
3059
3569
  ], DataSpaceManager.prototype, "close", null);
3060
- _ts_decorate2([
3570
+ _ts_decorate4([
3061
3571
  synchronized2
3062
3572
  ], DataSpaceManager.prototype, "createSpace", null);
3063
- _ts_decorate2([
3573
+ _ts_decorate4([
3064
3574
  synchronized2
3065
3575
  ], DataSpaceManager.prototype, "acceptSpace", null);
3066
- DataSpaceManager = _ts_decorate2([
3576
+ DataSpaceManager = _ts_decorate4([
3067
3577
  trackLeaks2("open", "close")
3068
3578
  ], DataSpaceManager);
3069
3579
 
@@ -3073,11 +3583,11 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
3073
3583
  import { raise as raise2 } from "@dxos/debug";
3074
3584
  import { SpaceNotFoundError } from "@dxos/echo-pipeline";
3075
3585
  import { ApiError } from "@dxos/errors";
3076
- import { log as log11 } from "@dxos/log";
3586
+ import { log as log12 } from "@dxos/log";
3077
3587
  import { encodeError } from "@dxos/protocols";
3078
- import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3588
+ import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3079
3589
  import { humanize } from "@dxos/util";
3080
- var __dxlog_file11 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3590
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3081
3591
  var SpacesServiceImpl = class {
3082
3592
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3083
3593
  this._identityManager = _identityManager;
@@ -3115,10 +3625,10 @@ var SpacesServiceImpl = class {
3115
3625
  const scheduler = new UpdateScheduler(ctx, async () => {
3116
3626
  const dataSpaceManager = await this._getDataSpaceManager();
3117
3627
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
3118
- log11("update", {
3628
+ log12("update", {
3119
3629
  spaces
3120
3630
  }, {
3121
- F: __dxlog_file11,
3631
+ F: __dxlog_file14,
3122
3632
  L: 78,
3123
3633
  S: this,
3124
3634
  C: (f, a) => f(...a)
@@ -3229,14 +3739,20 @@ var SpacesServiceImpl = class {
3229
3739
  },
3230
3740
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3231
3741
  var _a2, _b2, _c2;
3742
+ const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
3743
+ const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
3744
+ if (isMe) {
3745
+ peers.push(space.presence.getLocalState());
3746
+ }
3232
3747
  return {
3233
3748
  identity: {
3234
3749
  identityKey: member.key,
3235
3750
  profile: {
3236
- displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : humanize(member.key)
3751
+ displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : humanize(member.key)
3237
3752
  }
3238
3753
  },
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
3754
+ presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
3755
+ peerStates: peers
3240
3756
  };
3241
3757
  }),
3242
3758
  creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
@@ -3248,20 +3764,32 @@ var SpacesServiceImpl = class {
3248
3764
  var getChannelId = (channel) => `user-channel/${channel}`;
3249
3765
 
3250
3766
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3251
- import invariant11 from "tiny-invariant";
3252
3767
  import { Trigger as Trigger5 } from "@dxos/async";
3768
+ import { Context as Context9 } from "@dxos/context";
3253
3769
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
3254
3770
  import { failUndefined as failUndefined3 } from "@dxos/debug";
3255
3771
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
3256
3772
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
3773
+ import { invariant as invariant12 } from "@dxos/invariant";
3257
3774
  import { Keyring } from "@dxos/keyring";
3258
3775
  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";
3776
+ import { log as log13 } from "@dxos/log";
3777
+ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
3261
3778
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3262
3779
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
3263
- var __dxlog_file12 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/services/service-context.ts";
3264
- var ServiceContext = class {
3780
+ import { trace as Trace2 } from "@dxos/tracing";
3781
+ function _ts_decorate5(decorators, target, key, desc) {
3782
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3783
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3784
+ r = Reflect.decorate(decorators, target, key, desc);
3785
+ else
3786
+ for (var i = decorators.length - 1; i >= 0; i--)
3787
+ if (d = decorators[i])
3788
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3789
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3790
+ }
3791
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3792
+ var ServiceContext = class ServiceContext2 {
3265
3793
  // prettier-ignore
3266
3794
  constructor(storage, networkManager, signalManager, modelFactory) {
3267
3795
  this.storage = storage;
@@ -3300,49 +3828,49 @@ var ServiceContext = class {
3300
3828
  return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
3301
3829
  }, this._acceptIdentity.bind(this)));
3302
3830
  }
3303
- async open() {
3304
- log12.trace("dxos.sdk.service-context.open", trace5.begin({
3305
- id: this._instanceId
3306
- }), {
3307
- F: __dxlog_file12,
3308
- L: 126,
3831
+ async open(ctx) {
3832
+ await this._checkStorageVersion();
3833
+ log13("opening...", void 0, {
3834
+ F: __dxlog_file15,
3835
+ L: 131,
3309
3836
  S: this,
3310
3837
  C: (f, a) => f(...a)
3311
3838
  });
3312
- await this._checkStorageVersion();
3313
- log12("opening...", void 0, {
3314
- F: __dxlog_file12,
3315
- L: 130,
3839
+ log13.trace("dxos.sdk.service-context.open", trace6.begin({
3840
+ id: this._instanceId
3841
+ }), {
3842
+ F: __dxlog_file15,
3843
+ L: 132,
3316
3844
  S: this,
3317
3845
  C: (f, a) => f(...a)
3318
3846
  });
3319
3847
  await this.signalManager.open();
3320
3848
  await this.networkManager.open();
3321
3849
  await this.spaceManager.open();
3322
- await this.identityManager.open();
3850
+ await this.identityManager.open(ctx);
3323
3851
  if (this.identityManager.identity) {
3324
- await this._initialize();
3852
+ await this._initialize(ctx);
3325
3853
  }
3326
- log12("opened", void 0, {
3327
- F: __dxlog_file12,
3328
- L: 138,
3854
+ log13.trace("dxos.sdk.service-context.open", trace6.end({
3855
+ id: this._instanceId
3856
+ }), {
3857
+ F: __dxlog_file15,
3858
+ L: 140,
3329
3859
  S: this,
3330
3860
  C: (f, a) => f(...a)
3331
3861
  });
3332
- log12.trace("dxos.sdk.service-context.open", trace5.end({
3333
- id: this._instanceId
3334
- }), {
3335
- F: __dxlog_file12,
3336
- L: 139,
3862
+ log13("opened", void 0, {
3863
+ F: __dxlog_file15,
3864
+ L: 141,
3337
3865
  S: this,
3338
3866
  C: (f, a) => f(...a)
3339
3867
  });
3340
3868
  }
3341
3869
  async close() {
3342
3870
  var _a;
3343
- log12("closing...", void 0, {
3344
- F: __dxlog_file12,
3345
- L: 143,
3871
+ log13("closing...", void 0, {
3872
+ F: __dxlog_file15,
3873
+ L: 145,
3346
3874
  S: this,
3347
3875
  C: (f, a) => f(...a)
3348
3876
  });
@@ -3356,40 +3884,48 @@ var ServiceContext = class {
3356
3884
  await this.networkManager.close();
3357
3885
  await this.signalManager.close();
3358
3886
  this.dataServiceSubscriptions.clear();
3359
- log12("closed", void 0, {
3360
- F: __dxlog_file12,
3361
- L: 154,
3887
+ log13("closed", void 0, {
3888
+ F: __dxlog_file15,
3889
+ L: 156,
3362
3890
  S: this,
3363
3891
  C: (f, a) => f(...a)
3364
3892
  });
3365
3893
  }
3366
3894
  async createIdentity(params = {}) {
3367
3895
  const identity = await this.identityManager.createIdentity(params);
3368
- await this._initialize();
3896
+ await this._initialize(new Context9());
3369
3897
  return identity;
3370
3898
  }
3371
3899
  getInvitationHandler(invitation) {
3372
3900
  const factory = this._handlerFactories.get(invitation.kind);
3373
- invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
3901
+ invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
3902
+ F: __dxlog_file15,
3903
+ L: 168,
3904
+ S: this,
3905
+ A: [
3906
+ "factory",
3907
+ "`Unknown invitation kind: ${invitation.kind}`"
3908
+ ]
3909
+ });
3374
3910
  return factory(invitation);
3375
3911
  }
3376
3912
  async _acceptIdentity(params) {
3377
3913
  const identity = await this.identityManager.acceptIdentity(params);
3378
- await this._initialize();
3914
+ await this._initialize(new Context9());
3379
3915
  return identity;
3380
3916
  }
3381
3917
  async _checkStorageVersion() {
3382
3918
  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}`);
3919
+ if (this.metadataStore.version !== STORAGE_VERSION2) {
3920
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION2}`);
3385
3921
  }
3386
3922
  }
3387
3923
  // Called when identity is created.
3388
- async _initialize() {
3924
+ async _initialize(ctx) {
3389
3925
  var _a;
3390
- log12("initializing spaces...", void 0, {
3391
- F: __dxlog_file12,
3392
- L: 187,
3926
+ log13("initializing spaces...", void 0, {
3927
+ F: __dxlog_file15,
3928
+ L: 190,
3393
3929
  S: this,
3394
3930
  C: (f, a) => f(...a)
3395
3931
  });
@@ -3410,7 +3946,15 @@ var ServiceContext = class {
3410
3946
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3411
3947
  await this.dataSpaceManager.open();
3412
3948
  this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
3413
- invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3949
+ invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3950
+ F: __dxlog_file15,
3951
+ L: 213,
3952
+ S: this,
3953
+ A: [
3954
+ "this.dataSpaceManager",
3955
+ "'dataSpaceManager not initialized yet'"
3956
+ ]
3957
+ });
3414
3958
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3415
3959
  });
3416
3960
  this.initialized.wake();
@@ -3424,33 +3968,33 @@ var ServiceContext = class {
3424
3968
  return;
3425
3969
  }
3426
3970
  if (!this.dataSpaceManager) {
3427
- log12("dataSpaceManager not initialized yet, ignoring space admission", {
3971
+ log13("dataSpaceManager not initialized yet, ignoring space admission", {
3428
3972
  details: assertion
3429
3973
  }, {
3430
- F: __dxlog_file12,
3431
- L: 226,
3974
+ F: __dxlog_file15,
3975
+ L: 229,
3432
3976
  S: this,
3433
3977
  C: (f, a) => f(...a)
3434
3978
  });
3435
3979
  return;
3436
3980
  }
3437
3981
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3438
- log12("space already exists, ignoring space admission", {
3982
+ log13("space already exists, ignoring space admission", {
3439
3983
  details: assertion
3440
3984
  }, {
3441
- F: __dxlog_file12,
3442
- L: 230,
3985
+ F: __dxlog_file15,
3986
+ L: 233,
3443
3987
  S: this,
3444
3988
  C: (f, a) => f(...a)
3445
3989
  });
3446
3990
  return;
3447
3991
  }
3448
3992
  try {
3449
- log12("accepting space recorded in halo", {
3993
+ log13("accepting space recorded in halo", {
3450
3994
  details: assertion
3451
3995
  }, {
3452
- F: __dxlog_file12,
3453
- L: 235,
3996
+ F: __dxlog_file15,
3997
+ L: 238,
3454
3998
  S: this,
3455
3999
  C: (f, a) => f(...a)
3456
4000
  });
@@ -3459,9 +4003,9 @@ var ServiceContext = class {
3459
4003
  genesisFeedKey: assertion.genesisFeedKey
3460
4004
  });
3461
4005
  } catch (err) {
3462
- log12.catch(err, void 0, {
3463
- F: __dxlog_file12,
3464
- L: 241,
4006
+ log13.catch(err, void 0, {
4007
+ F: __dxlog_file15,
4008
+ L: 244,
3465
4009
  S: this,
3466
4010
  C: (f, a) => f(...a)
3467
4011
  });
@@ -3471,12 +4015,21 @@ var ServiceContext = class {
3471
4015
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3472
4016
  }
3473
4017
  };
4018
+ _ts_decorate5([
4019
+ Trace2.span()
4020
+ ], ServiceContext.prototype, "open", null);
4021
+ _ts_decorate5([
4022
+ Trace2.span()
4023
+ ], ServiceContext.prototype, "_initialize", null);
4024
+ ServiceContext = _ts_decorate5([
4025
+ Trace2.resource()
4026
+ ], ServiceContext);
3474
4027
 
3475
4028
  // packages/sdk/client-services/src/packlets/locks/browser.ts
3476
4029
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3477
4030
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3478
- import { log as log13, logInfo } from "@dxos/log";
3479
- function _ts_decorate3(decorators, target, key, desc) {
4031
+ import { log as log14, logInfo } from "@dxos/log";
4032
+ function _ts_decorate6(decorators, target, key, desc) {
3480
4033
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3481
4034
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3482
4035
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3486,7 +4039,7 @@ function _ts_decorate3(decorators, target, key, desc) {
3486
4039
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3487
4040
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3488
4041
  }
3489
- var __dxlog_file13 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/locks/browser.ts";
4042
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
3490
4043
  var Message;
3491
4044
  (function(Message2) {
3492
4045
  Message2["ACQUIRING"] = "acquiring";
@@ -3508,29 +4061,29 @@ var Lock = class {
3508
4061
  message: Message.ACQUIRING
3509
4062
  });
3510
4063
  try {
3511
- log13("aquiring lock...", void 0, {
3512
- F: __dxlog_file13,
4064
+ log14("aquiring lock...", void 0, {
4065
+ F: __dxlog_file16,
3513
4066
  L: 42,
3514
4067
  S: this,
3515
4068
  C: (f, a) => f(...a)
3516
4069
  });
3517
4070
  await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
3518
- log13("acquired lock", void 0, {
3519
- F: __dxlog_file13,
4071
+ log14("acquired lock", void 0, {
4072
+ F: __dxlog_file16,
3520
4073
  L: 44,
3521
4074
  S: this,
3522
4075
  C: (f, a) => f(...a)
3523
4076
  });
3524
4077
  } catch (e) {
3525
- log13("stealing lock...", void 0, {
3526
- F: __dxlog_file13,
4078
+ log14("stealing lock...", void 0, {
4079
+ F: __dxlog_file16,
3527
4080
  L: 46,
3528
4081
  S: this,
3529
4082
  C: (f, a) => f(...a)
3530
4083
  });
3531
4084
  await this._requestLock(true);
3532
- log13("stolen lock", void 0, {
3533
- F: __dxlog_file13,
4085
+ log14("stolen lock", void 0, {
4086
+ F: __dxlog_file16,
3534
4087
  L: 48,
3535
4088
  S: this,
3536
4089
  C: (f, a) => f(...a)
@@ -3546,10 +4099,10 @@ var Lock = class {
3546
4099
  }
3547
4100
  }
3548
4101
  async _requestLock(steal = false) {
3549
- log13("requesting lock...", {
4102
+ log14("requesting lock...", {
3550
4103
  steal
3551
4104
  }, {
3552
- F: __dxlog_file13,
4105
+ F: __dxlog_file16,
3553
4106
  L: 63,
3554
4107
  S: this,
3555
4108
  C: (f, a) => f(...a)
@@ -3563,15 +4116,15 @@ var Lock = class {
3563
4116
  acquired.wake();
3564
4117
  this._releaseTrigger = new Trigger6();
3565
4118
  await this._releaseTrigger.wait();
3566
- log13("releasing lock...", void 0, {
3567
- F: __dxlog_file13,
4119
+ log14("releasing lock...", void 0, {
4120
+ F: __dxlog_file16,
3568
4121
  L: 72,
3569
4122
  S: this,
3570
4123
  C: (f, a) => f(...a)
3571
4124
  });
3572
4125
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3573
- log13("released lock", void 0, {
3574
- F: __dxlog_file13,
4126
+ log14("released lock", void 0, {
4127
+ F: __dxlog_file16,
3575
4128
  L: 74,
3576
4129
  S: this,
3577
4130
  C: (f, a) => f(...a)
@@ -3581,17 +4134,17 @@ var Lock = class {
3581
4134
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3582
4135
  });
3583
4136
  await acquired.wait();
3584
- log13("recieved lock", {
4137
+ log14("recieved lock", {
3585
4138
  steal
3586
4139
  }, {
3587
- F: __dxlog_file13,
4140
+ F: __dxlog_file16,
3588
4141
  L: 81,
3589
4142
  S: this,
3590
4143
  C: (f, a) => f(...a)
3591
4144
  });
3592
4145
  }
3593
4146
  };
3594
- _ts_decorate3([
4147
+ _ts_decorate6([
3595
4148
  logInfo
3596
4149
  ], Lock.prototype, "lockKey", null);
3597
4150
  var isLocked = (lockPath) => {
@@ -3672,19 +4225,21 @@ var ServiceRegistry = class {
3672
4225
  };
3673
4226
 
3674
4227
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3675
- import invariant12 from "tiny-invariant";
3676
4228
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
3677
4229
  import { clientServiceBundle } from "@dxos/client-protocol";
3678
- import { DocumentModel } from "@dxos/document-model";
4230
+ import { Context as Context10 } from "@dxos/context";
4231
+ import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
3679
4232
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4233
+ import { invariant as invariant13 } from "@dxos/invariant";
3680
4234
  import { PublicKey as PublicKey10 } from "@dxos/keys";
3681
- import { log as log15 } from "@dxos/log";
4235
+ import { log as log16 } from "@dxos/log";
3682
4236
  import { WebsocketSignalManager } from "@dxos/messaging";
3683
4237
  import { ModelFactory } from "@dxos/model-factory";
3684
4238
  import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
3685
- import { trace as trace6 } from "@dxos/protocols";
4239
+ import { trace as trace7 } from "@dxos/protocols";
3686
4240
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
3687
4241
  import { TextModel } from "@dxos/text-model";
4242
+ import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
3688
4243
 
3689
4244
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3690
4245
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
@@ -3736,22 +4291,23 @@ var DevicesServiceImpl = class {
3736
4291
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3737
4292
  import { Event as Event7 } from "@dxos/async";
3738
4293
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
3739
- import { getContextFromEntry, log as log14 } from "@dxos/log";
4294
+ import { getContextFromEntry, log as log15 } from "@dxos/log";
3740
4295
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
3741
4296
  import { jsonify, numericalValues, tracer } from "@dxos/util";
3742
4297
  var LoggingServiceImpl = class {
3743
4298
  constructor() {
3744
4299
  this._logs = new Event7();
4300
+ this._started = new Date();
3745
4301
  this._logProcessor = (_config, entry2) => {
3746
4302
  this._logs.emit(entry2);
3747
4303
  };
3748
4304
  }
3749
4305
  async open() {
3750
- log14.runtimeConfig.processors.push(this._logProcessor);
4306
+ log15.runtimeConfig.processors.push(this._logProcessor);
3751
4307
  }
3752
4308
  async close() {
3753
- const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3754
- log14.runtimeConfig.processors.splice(index, 1);
4309
+ const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4310
+ log15.runtimeConfig.processors.splice(index, 1);
3755
4311
  }
3756
4312
  async controlMetrics({ reset, record }) {
3757
4313
  if (reset) {
@@ -3766,13 +4322,16 @@ var LoggingServiceImpl = class {
3766
4322
  recording: tracer.recording
3767
4323
  };
3768
4324
  }
3769
- queryMetrics({ interval }) {
3770
- const createNumericalValues = (key) => {
4325
+ /**
4326
+ * @deprecated (Move to diagnostics).
4327
+ */
4328
+ queryMetrics({ interval = 5e3 }) {
4329
+ const getNumericalValues = (key) => {
3771
4330
  var _a;
3772
- const consume = (_a = tracer.get(key)) != null ? _a : [];
4331
+ const events = (_a = tracer.get(key)) != null ? _a : [];
3773
4332
  return {
3774
4333
  key,
3775
- stats: numericalValues(consume, "duration")
4334
+ stats: numericalValues(events, "duration")
3776
4335
  };
3777
4336
  };
3778
4337
  return new Stream12(({ next }) => {
@@ -3780,14 +4339,17 @@ var LoggingServiceImpl = class {
3780
4339
  const metrics = {
3781
4340
  timestamp: new Date(),
3782
4341
  values: [
3783
- createNumericalValues("dxos.echo.pipeline.control"),
3784
- createNumericalValues("dxos.echo.pipeline.data")
3785
- ]
4342
+ getNumericalValues("dxos.echo.pipeline.control"),
4343
+ getNumericalValues("dxos.echo.pipeline.data")
4344
+ ].filter(Boolean)
3786
4345
  };
3787
- next(metrics);
4346
+ next({
4347
+ timestamp: new Date(),
4348
+ metrics
4349
+ });
3788
4350
  };
3789
4351
  update();
3790
- const i = setInterval(update, interval);
4352
+ const i = setInterval(update, Math.max(interval, 1e3));
3791
4353
  return () => {
3792
4354
  clearInterval(i);
3793
4355
  };
@@ -3883,11 +4445,14 @@ var NetworkServiceImpl = class {
3883
4445
 
3884
4446
  // packages/sdk/client-services/src/packlets/system/system-service.ts
3885
4447
  import { Stream as Stream14 } from "@dxos/codec-protobuf";
4448
+ import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
4449
+ import { jsonKeyReplacer } from "@dxos/util";
3886
4450
  var SystemServiceImpl = class {
3887
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
4451
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
3888
4452
  this._config = config;
3889
4453
  this._statusUpdate = statusUpdate;
3890
4454
  this._getCurrentStatus = getCurrentStatus;
4455
+ this._getDiagnostics = getDiagnostics;
3891
4456
  this._onUpdateStatus = onUpdateStatus;
3892
4457
  this._onReset = onReset;
3893
4458
  }
@@ -3895,6 +4460,19 @@ var SystemServiceImpl = class {
3895
4460
  var _a, _b;
3896
4461
  return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
3897
4462
  }
4463
+ /**
4464
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
4465
+ */
4466
+ async getDiagnostics({ keys } = {}) {
4467
+ const diagnostics = await this._getDiagnostics();
4468
+ return {
4469
+ timestamp: new Date(),
4470
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
4471
+ truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4472
+ humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4473
+ })))
4474
+ };
4475
+ }
3898
4476
  async updateStatus({ status }) {
3899
4477
  await this._onUpdateStatus(status);
3900
4478
  }
@@ -3921,7 +4499,7 @@ var SystemServiceImpl = class {
3921
4499
  };
3922
4500
 
3923
4501
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3924
- function _ts_decorate4(decorators, target, key, desc) {
4502
+ function _ts_decorate7(decorators, target, key, desc) {
3925
4503
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3926
4504
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3927
4505
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3931,23 +4509,22 @@ function _ts_decorate4(decorators, target, key, desc) {
3931
4509
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3932
4510
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3933
4511
  }
3934
- var __dxlog_file14 = "/mnt/ramdisk/work/packages/sdk/client-services/src/packlets/services/service-host.ts";
4512
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
3935
4513
  var createDefaultModelFactory = () => {
3936
- return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
4514
+ return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
3937
4515
  };
3938
- var ClientServicesHost = class {
4516
+ var ClientServicesHost = class ClientServicesHost2 {
3939
4517
  constructor({
3940
4518
  config,
3941
4519
  modelFactory = createDefaultModelFactory(),
3942
- // TODO(burdon): Create ApolloLink abstraction (see Client).
3943
4520
  transportFactory,
3944
4521
  signalManager,
3945
- connectionLog,
3946
4522
  storage,
3947
4523
  // TODO(wittjosiah): Turn this on by default.
3948
4524
  lockKey,
3949
4525
  callbacks
3950
4526
  } = {}) {
4527
+ this._tracingService = TRACE_PROCESSOR.createTraceSender();
3951
4528
  this._statusUpdate = new Event8();
3952
4529
  this._opening = false;
3953
4530
  this._open = false;
@@ -3966,7 +4543,7 @@ var ClientServicesHost = class {
3966
4543
  lockKey,
3967
4544
  onAcquire: () => {
3968
4545
  if (!this._opening) {
3969
- void this.open();
4546
+ void this.open(new Context10());
3970
4547
  }
3971
4548
  },
3972
4549
  onRelease: () => this.close()
@@ -3976,6 +4553,9 @@ var ClientServicesHost = class {
3976
4553
  config: this._config,
3977
4554
  statusUpdate: this._statusUpdate,
3978
4555
  getCurrentStatus: () => this.isOpen ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
4556
+ getDiagnostics: () => {
4557
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4558
+ },
3979
4559
  onUpdateStatus: async (status) => {
3980
4560
  var _a, _b;
3981
4561
  if (!this.isOpen && status === SystemStatus.ACTIVE) {
@@ -3990,12 +4570,19 @@ var ClientServicesHost = class {
3990
4570
  });
3991
4571
  this._loggingService = new LoggingServiceImpl();
3992
4572
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
3993
- SystemService: this._systemService
4573
+ SystemService: this._systemService,
4574
+ TracingService: this._tracingService
3994
4575
  });
3995
4576
  }
3996
4577
  get isOpen() {
3997
4578
  return this._open;
3998
4579
  }
4580
+ get config() {
4581
+ return this._config;
4582
+ }
4583
+ get context() {
4584
+ return this._serviceContext;
4585
+ }
3999
4586
  get serviceRegistry() {
4000
4587
  return this._serviceRegistry;
4001
4588
  }
@@ -4012,9 +4599,31 @@ var ClientServicesHost = class {
4012
4599
  */
4013
4600
  initialize({ config, ...options }) {
4014
4601
  var _a, _b, _c;
4015
- invariant12(!this._open, "service host is open");
4602
+ invariant13(!this._open, "service host is open", {
4603
+ F: __dxlog_file17,
4604
+ L: 181,
4605
+ S: this,
4606
+ A: [
4607
+ "!this._open",
4608
+ "'service host is open'"
4609
+ ]
4610
+ });
4611
+ log16.info("initializing...", void 0, {
4612
+ F: __dxlog_file17,
4613
+ L: 182,
4614
+ S: this,
4615
+ C: (f, a) => f(...a)
4616
+ });
4016
4617
  if (config) {
4017
- invariant12(!this._config, "config already set");
4618
+ invariant13(!this._config, "config already set", {
4619
+ F: __dxlog_file17,
4620
+ L: 185,
4621
+ S: this,
4622
+ A: [
4623
+ "!this._config",
4624
+ "'config already set'"
4625
+ ]
4626
+ });
4018
4627
  this._config = config;
4019
4628
  if (!this._storage) {
4020
4629
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -4024,37 +4633,83 @@ var ClientServicesHost = class {
4024
4633
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4025
4634
  }), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4026
4635
  this._signalManager = signalManager;
4027
- invariant12(!this._networkManager, "network manager already set");
4636
+ invariant13(!this._networkManager, "network manager already set", {
4637
+ F: __dxlog_file17,
4638
+ L: 201,
4639
+ S: this,
4640
+ A: [
4641
+ "!this._networkManager",
4642
+ "'network manager already set'"
4643
+ ]
4644
+ });
4028
4645
  this._networkManager = new NetworkManager({
4029
4646
  log: connectionLog,
4030
4647
  transportFactory,
4031
4648
  signalManager
4032
4649
  });
4650
+ log16.info("initialized", void 0, {
4651
+ F: __dxlog_file17,
4652
+ L: 208,
4653
+ S: this,
4654
+ C: (f, a) => f(...a)
4655
+ });
4033
4656
  }
4034
- async open() {
4657
+ async open(ctx) {
4035
4658
  var _a, _b, _c;
4036
4659
  if (this._open) {
4037
4660
  return;
4038
4661
  }
4039
4662
  const traceId = PublicKey10.random().toHex();
4040
- log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
4663
+ log16.trace("dxos.client-services.host.open", trace7.begin({
4041
4664
  id: traceId
4042
4665
  }), {
4043
- F: __dxlog_file14,
4044
- L: 203,
4666
+ F: __dxlog_file17,
4667
+ L: 219,
4045
4668
  S: this,
4046
4669
  C: (f, a) => f(...a)
4047
4670
  });
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");
4671
+ invariant13(this._config, "config not set", {
4672
+ F: __dxlog_file17,
4673
+ L: 221,
4674
+ S: this,
4675
+ A: [
4676
+ "this._config",
4677
+ "'config not set'"
4678
+ ]
4679
+ });
4680
+ invariant13(this._storage, "storage not set", {
4681
+ F: __dxlog_file17,
4682
+ L: 222,
4683
+ S: this,
4684
+ A: [
4685
+ "this._storage",
4686
+ "'storage not set'"
4687
+ ]
4688
+ });
4689
+ invariant13(this._signalManager, "signal manager not set", {
4690
+ F: __dxlog_file17,
4691
+ L: 223,
4692
+ S: this,
4693
+ A: [
4694
+ "this._signalManager",
4695
+ "'signal manager not set'"
4696
+ ]
4697
+ });
4698
+ invariant13(this._networkManager, "network manager not set", {
4699
+ F: __dxlog_file17,
4700
+ L: 224,
4701
+ S: this,
4702
+ A: [
4703
+ "this._networkManager",
4704
+ "'network manager not set'"
4705
+ ]
4706
+ });
4052
4707
  this._opening = true;
4053
- log15("opening...", {
4708
+ log16.info("opening...", {
4054
4709
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4055
4710
  }, {
4056
- F: __dxlog_file14,
4057
- L: 211,
4711
+ F: __dxlog_file17,
4712
+ L: 227,
4058
4713
  S: this,
4059
4714
  C: (f, a) => f(...a)
4060
4715
  });
@@ -4073,6 +4728,7 @@ var ClientServicesHost = class {
4073
4728
  DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4074
4729
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4075
4730
  LoggingService: this._loggingService,
4731
+ TracingService: this._tracingService,
4076
4732
  // TODO(burdon): Move to new protobuf definitions.
4077
4733
  DevtoolsHost: new DevtoolsServiceImpl({
4078
4734
  events: new DevtoolsHostEvents(),
@@ -4080,24 +4736,24 @@ var ClientServicesHost = class {
4080
4736
  context: this._serviceContext
4081
4737
  })
4082
4738
  });
4083
- await this._serviceContext.open();
4739
+ await this._serviceContext.open(ctx);
4084
4740
  this._opening = false;
4085
4741
  this._open = true;
4086
4742
  this._statusUpdate.emit();
4087
4743
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4088
- log15("opened", {
4744
+ log16.info("opened", {
4089
4745
  deviceKey
4090
4746
  }, {
4091
- F: __dxlog_file14,
4092
- L: 266,
4747
+ F: __dxlog_file17,
4748
+ L: 280,
4093
4749
  S: this,
4094
4750
  C: (f, a) => f(...a)
4095
4751
  });
4096
- log15.trace("dxos.sdk.client-services-host.open", trace6.end({
4752
+ log16.trace("dxos.client-services.host.open", trace7.end({
4097
4753
  id: traceId
4098
4754
  }), {
4099
- F: __dxlog_file14,
4100
- L: 267,
4755
+ F: __dxlog_file17,
4756
+ L: 281,
4101
4757
  S: this,
4102
4758
  C: (f, a) => f(...a)
4103
4759
  });
@@ -4108,11 +4764,11 @@ var ClientServicesHost = class {
4108
4764
  return;
4109
4765
  }
4110
4766
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4111
- log15("closing...", {
4767
+ log16.info("closing...", {
4112
4768
  deviceKey
4113
4769
  }, {
4114
- F: __dxlog_file14,
4115
- L: 277,
4770
+ F: __dxlog_file17,
4771
+ L: 292,
4116
4772
  S: this,
4117
4773
  C: (f, a) => f(...a)
4118
4774
  });
@@ -4123,11 +4779,11 @@ var ClientServicesHost = class {
4123
4779
  await this._serviceContext.close();
4124
4780
  this._open = false;
4125
4781
  this._statusUpdate.emit();
4126
- log15("closed", {
4782
+ log16.info("closed", {
4127
4783
  deviceKey
4128
4784
  }, {
4129
- F: __dxlog_file14,
4130
- L: 283,
4785
+ F: __dxlog_file17,
4786
+ L: 298,
4131
4787
  S: this,
4132
4788
  C: (f, a) => f(...a)
4133
4789
  });
@@ -4135,45 +4791,56 @@ var ClientServicesHost = class {
4135
4791
  async reset() {
4136
4792
  var _a, _b, _c;
4137
4793
  const traceId = PublicKey10.random().toHex();
4138
- log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4794
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
4139
4795
  id: traceId
4140
4796
  }), {
4141
- F: __dxlog_file14,
4142
- L: 288,
4797
+ F: __dxlog_file17,
4798
+ L: 303,
4143
4799
  S: this,
4144
4800
  C: (f, a) => f(...a)
4145
4801
  });
4146
- log15("resetting...", void 0, {
4147
- F: __dxlog_file14,
4148
- L: 290,
4802
+ log16("resetting...", void 0, {
4803
+ F: __dxlog_file17,
4804
+ L: 305,
4149
4805
  S: this,
4150
4806
  C: (f, a) => f(...a)
4151
4807
  });
4152
4808
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4153
4809
  await this._storage.reset();
4154
- log15("reset", void 0, {
4155
- F: __dxlog_file14,
4156
- L: 293,
4810
+ log16("reset", void 0, {
4811
+ F: __dxlog_file17,
4812
+ L: 308,
4157
4813
  S: this,
4158
4814
  C: (f, a) => f(...a)
4159
4815
  });
4160
- log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
4816
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
4161
4817
  id: traceId
4162
4818
  }), {
4163
- F: __dxlog_file14,
4164
- L: 294,
4819
+ F: __dxlog_file17,
4820
+ L: 309,
4165
4821
  S: this,
4166
4822
  C: (f, a) => f(...a)
4167
4823
  });
4168
4824
  await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4169
4825
  }
4170
4826
  };
4171
- _ts_decorate4([
4172
- synchronized3
4827
+ _ts_decorate7([
4828
+ Trace3.info()
4829
+ ], ClientServicesHost.prototype, "_opening", void 0);
4830
+ _ts_decorate7([
4831
+ Trace3.info()
4832
+ ], ClientServicesHost.prototype, "_open", void 0);
4833
+ _ts_decorate7([
4834
+ synchronized3,
4835
+ Trace3.span()
4173
4836
  ], ClientServicesHost.prototype, "open", null);
4174
- _ts_decorate4([
4175
- synchronized3
4837
+ _ts_decorate7([
4838
+ synchronized3,
4839
+ Trace3.span()
4176
4840
  ], ClientServicesHost.prototype, "close", null);
4841
+ ClientServicesHost = _ts_decorate7([
4842
+ Trace3.resource()
4843
+ ], ClientServicesHost);
4177
4844
 
4178
4845
  export {
4179
4846
  subscribeToFeeds,
@@ -4196,6 +4863,7 @@ export {
4196
4863
  InvitationsServiceImpl,
4197
4864
  SpaceInvitationProtocol,
4198
4865
  ClientRpcServer,
4866
+ createDiagnostics,
4199
4867
  DataSpace,
4200
4868
  DataSpaceManager,
4201
4869
  SpacesServiceImpl,
@@ -4207,4 +4875,4 @@ export {
4207
4875
  createDefaultModelFactory,
4208
4876
  ClientServicesHost
4209
4877
  };
4210
- //# sourceMappingURL=chunk-XSZIBW37.mjs.map
4878
+ //# sourceMappingURL=chunk-53BV3Q7V.mjs.map