@dxos/client-services 0.1.56-main.a25bb93 → 0.1.56-main.ad054df

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 (45) hide show
  1. package/dist/lib/browser/{chunk-MAHWP5I6.mjs → chunk-U5CCSPX6.mjs} +215 -140
  2. package/dist/lib/browser/chunk-U5CCSPX6.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +14 -12
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +2 -2
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +210 -133
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +197 -122
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  16. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  19. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts +3 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  22. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  23. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  24. package/dist/types/src/version.d.ts +1 -1
  25. package/package.json +34 -33
  26. package/src/packlets/devices/devices-service.test.ts +2 -1
  27. package/src/packlets/identity/identity-manager.test.ts +4 -3
  28. package/src/packlets/identity/identity-manager.ts +9 -5
  29. package/src/packlets/identity/identity-service.test.ts +2 -1
  30. package/src/packlets/identity/identity.test.ts +7 -6
  31. package/src/packlets/identity/identity.ts +8 -3
  32. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  33. package/src/packlets/network/network-service.test.ts +2 -1
  34. package/src/packlets/services/client-rpc-server.ts +4 -4
  35. package/src/packlets/services/service-context.ts +11 -6
  36. package/src/packlets/services/service-host.test.ts +6 -5
  37. package/src/packlets/services/service-host.ts +15 -3
  38. package/src/packlets/services/service-registry.test.ts +2 -1
  39. package/src/packlets/spaces/data-space.ts +1 -1
  40. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  41. package/src/packlets/testing/test-builder.ts +1 -1
  42. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  43. package/src/packlets/vault/worker-runtime.ts +2 -1
  44. package/src/version.ts +1 -1
  45. package/dist/lib/browser/chunk-MAHWP5I6.mjs.map +0 -7
@@ -471,8 +471,19 @@ import { writeMessages } from "@dxos/feed-store";
471
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
+ 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
+ }
474
485
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
475
- var Identity = class {
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);
@@ -548,7 +559,7 @@ var Identity = class {
548
559
  getIdentityCredentialSigner() {
549
560
  invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
550
561
  F: __dxlog_file2,
551
- L: 134,
562
+ L: 139,
552
563
  S: this,
553
564
  A: [
554
565
  "this._deviceStateMachine.deviceCredentialChain",
@@ -572,7 +583,7 @@ var Identity = class {
572
583
  dataFeedKey
573
584
  }, {
574
585
  F: __dxlog_file2,
575
- L: 150,
586
+ L: 155,
576
587
  S: this,
577
588
  C: (f, a) => f(...a)
578
589
  });
@@ -613,18 +624,39 @@ var Identity = class {
613
624
  })));
614
625
  }
615
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);
616
636
 
617
637
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
618
638
  import { Event as Event2 } from "@dxos/async";
639
+ import { Context as Context3 } from "@dxos/context";
619
640
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
620
641
  import { invariant as invariant2 } from "@dxos/invariant";
621
642
  import { PublicKey as PublicKey3 } from "@dxos/keys";
622
643
  import { log as log3 } from "@dxos/log";
623
- import { trace } from "@dxos/protocols";
644
+ import { trace as trace2 } from "@dxos/protocols";
624
645
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
646
+ import { trace as Trace } from "@dxos/tracing";
625
647
  import { deferFunction } from "@dxos/util";
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
+ }
626
658
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
627
- var IdentityManager = class {
659
+ var IdentityManager = class IdentityManager2 {
628
660
  // TODO(burdon): IdentityManagerParams.
629
661
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
630
662
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -637,14 +669,14 @@ var IdentityManager = class {
637
669
  get identity() {
638
670
  return this._identity;
639
671
  }
640
- async open() {
672
+ async open(ctx) {
641
673
  var _a;
642
674
  const traceId = PublicKey3.random().toHex();
643
- log3.trace("dxos.halo.identity-manager.open", trace.begin({
675
+ log3.trace("dxos.halo.identity-manager.open", trace2.begin({
644
676
  id: traceId
645
677
  }), {
646
678
  F: __dxlog_file3,
647
- L: 69,
679
+ L: 73,
648
680
  S: this,
649
681
  C: (f, a) => f(...a)
650
682
  });
@@ -654,43 +686,43 @@ var IdentityManager = class {
654
686
  identityRecord
655
687
  }, {
656
688
  F: __dxlog_file3,
657
- L: 73,
689
+ L: 77,
658
690
  S: this,
659
691
  C: (f, a) => f(...a)
660
692
  });
661
693
  if (identityRecord) {
662
694
  this._identity = await this._constructIdentity(identityRecord);
663
- await this._identity.open();
695
+ await this._identity.open(ctx);
664
696
  await this._identity.ready();
665
697
  log3.trace("dxos.halo.identity", {
666
698
  identityKey: identityRecord.identityKey,
667
699
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
668
700
  }, {
669
701
  F: __dxlog_file3,
670
- L: 78,
702
+ L: 82,
671
703
  S: this,
672
704
  C: (f, a) => f(...a)
673
705
  });
674
706
  this.stateUpdate.emit();
675
707
  }
676
- log3.trace("dxos.halo.identity-manager.open", trace.end({
708
+ log3.trace("dxos.halo.identity-manager.open", trace2.end({
677
709
  id: traceId
678
710
  }), {
679
711
  F: __dxlog_file3,
680
- L: 84,
712
+ L: 88,
681
713
  S: this,
682
714
  C: (f, a) => f(...a)
683
715
  });
684
716
  }
685
717
  async close() {
686
718
  var _a;
687
- await ((_a = this._identity) == null ? void 0 : _a.close());
719
+ await ((_a = this._identity) == null ? void 0 : _a.close(new Context3()));
688
720
  }
689
721
  async createIdentity({ displayName } = {}) {
690
722
  var _a;
691
723
  invariant2(!this._identity, "Identity already exists.", {
692
724
  F: __dxlog_file3,
693
- L: 92,
725
+ L: 96,
694
726
  S: this,
695
727
  A: [
696
728
  "!this._identity",
@@ -699,7 +731,7 @@ var IdentityManager = class {
699
731
  });
700
732
  log3("creating identity...", void 0, {
701
733
  F: __dxlog_file3,
702
- L: 93,
734
+ L: 97,
703
735
  S: this,
704
736
  C: (f, a) => f(...a)
705
737
  });
@@ -715,12 +747,12 @@ var IdentityManager = class {
715
747
  }
716
748
  };
717
749
  const identity = await this._constructIdentity(identityRecord);
718
- await identity.open();
750
+ await identity.open(new Context3());
719
751
  {
720
752
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
721
753
  invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
722
754
  F: __dxlog_file3,
723
- L: 112,
755
+ L: 116,
724
756
  S: this,
725
757
  A: [
726
758
  "identityRecord.haloSpace.genesisFeedKey",
@@ -729,7 +761,7 @@ var IdentityManager = class {
729
761
  });
730
762
  invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
731
763
  F: __dxlog_file3,
732
- L: 113,
764
+ L: 117,
733
765
  S: this,
734
766
  A: [
735
767
  "identityRecord.haloSpace.dataFeedKey",
@@ -764,7 +796,7 @@ var IdentityManager = class {
764
796
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
765
797
  }, {
766
798
  F: __dxlog_file3,
767
- L: 148,
799
+ L: 152,
768
800
  S: this,
769
801
  C: (f, a) => f(...a)
770
802
  });
@@ -774,7 +806,7 @@ var IdentityManager = class {
774
806
  deviceKey: identity.deviceKey
775
807
  }, {
776
808
  F: __dxlog_file3,
777
- L: 154,
809
+ L: 158,
778
810
  S: this,
779
811
  C: (f, a) => f(...a)
780
812
  });
@@ -789,13 +821,13 @@ var IdentityManager = class {
789
821
  params
790
822
  }, {
791
823
  F: __dxlog_file3,
792
- L: 162,
824
+ L: 166,
793
825
  S: this,
794
826
  C: (f, a) => f(...a)
795
827
  });
796
828
  invariant2(!this._identity, "Identity already exists.", {
797
829
  F: __dxlog_file3,
798
- L: 163,
830
+ L: 167,
799
831
  S: this,
800
832
  A: [
801
833
  "!this._identity",
@@ -814,7 +846,7 @@ var IdentityManager = class {
814
846
  }
815
847
  };
816
848
  const identity = await this._constructIdentity(identityRecord);
817
- await identity.open();
849
+ await identity.open(new Context3());
818
850
  this._identity = identity;
819
851
  await this._metadataStore.setIdentityRecord(identityRecord);
820
852
  await this._identity.ready();
@@ -823,7 +855,7 @@ var IdentityManager = class {
823
855
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
824
856
  }, {
825
857
  F: __dxlog_file3,
826
- L: 182,
858
+ L: 186,
827
859
  S: this,
828
860
  C: (f, a) => f(...a)
829
861
  });
@@ -833,7 +865,7 @@ var IdentityManager = class {
833
865
  deviceKey: identity.deviceKey
834
866
  }, {
835
867
  F: __dxlog_file3,
836
- L: 188,
868
+ L: 192,
837
869
  S: this,
838
870
  C: (f, a) => f(...a)
839
871
  });
@@ -842,7 +874,7 @@ var IdentityManager = class {
842
874
  async _constructIdentity(identityRecord) {
843
875
  invariant2(!this._identity, void 0, {
844
876
  F: __dxlog_file3,
845
- L: 193,
877
+ L: 197,
846
878
  S: this,
847
879
  A: [
848
880
  "!this._identity",
@@ -853,13 +885,13 @@ var IdentityManager = class {
853
885
  identityRecord
854
886
  }, {
855
887
  F: __dxlog_file3,
856
- L: 194,
888
+ L: 198,
857
889
  S: this,
858
890
  C: (f, a) => f(...a)
859
891
  });
860
892
  invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
861
893
  F: __dxlog_file3,
862
- L: 197,
894
+ L: 201,
863
895
  S: this,
864
896
  A: [
865
897
  "identityRecord.haloSpace.controlFeedKey",
@@ -871,7 +903,7 @@ var IdentityManager = class {
871
903
  });
872
904
  invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
873
905
  F: __dxlog_file3,
874
- L: 201,
906
+ L: 205,
875
907
  S: this,
876
908
  A: [
877
909
  "identityRecord.haloSpace.dataFeedKey",
@@ -903,7 +935,7 @@ var IdentityManager = class {
903
935
  identityKey: identityRecord.identityKey
904
936
  }, {
905
937
  F: __dxlog_file3,
906
- L: 225,
938
+ L: 229,
907
939
  S: this,
908
940
  C: (f, a) => f(...a)
909
941
  });
@@ -924,7 +956,7 @@ var IdentityManager = class {
924
956
  onAuthFailure: () => {
925
957
  log3.warn("auth failure", void 0, {
926
958
  F: __dxlog_file3,
927
- L: 244,
959
+ L: 248,
928
960
  S: this,
929
961
  C: (f, a) => f(...a)
930
962
  });
@@ -933,6 +965,12 @@ var IdentityManager = class {
933
965
  });
934
966
  }
935
967
  };
968
+ _ts_decorate2([
969
+ Trace.span()
970
+ ], IdentityManager.prototype, "open", null);
971
+ IdentityManager = _ts_decorate2([
972
+ Trace.resource()
973
+ ], IdentityManager);
936
974
 
937
975
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
938
976
  import { Stream as Stream7 } from "@dxos/codec-protobuf";
@@ -1084,25 +1122,25 @@ var DeviceInvitationProtocol = class {
1084
1122
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1085
1123
  import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
1086
1124
  import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
1087
- import { Context as Context4 } from "@dxos/context";
1125
+ import { Context as Context5 } from "@dxos/context";
1088
1126
  import { generatePasscode } from "@dxos/credentials";
1089
1127
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
1090
1128
  import { invariant as invariant6 } from "@dxos/invariant";
1091
1129
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1092
1130
  import { log as log5 } from "@dxos/log";
1093
1131
  import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
1094
- import { trace as trace3 } from "@dxos/protocols";
1132
+ import { trace as trace4 } from "@dxos/protocols";
1095
1133
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1096
1134
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1097
1135
 
1098
1136
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1099
1137
  import { Trigger as Trigger2 } from "@dxos/async";
1100
- import { cancelWithContext, Context as Context3 } from "@dxos/context";
1138
+ import { cancelWithContext, Context as Context4 } from "@dxos/context";
1101
1139
  import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
1102
1140
  import { invariant as invariant5 } from "@dxos/invariant";
1103
1141
  import { PublicKey as PublicKey4 } from "@dxos/keys";
1104
1142
  import { log as log4 } from "@dxos/log";
1105
- import { schema as schema2, trace as trace2 } from "@dxos/protocols";
1143
+ import { schema as schema2, trace as trace3 } from "@dxos/protocols";
1106
1144
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
1107
1145
  import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1108
1146
  import { RpcExtension } from "@dxos/teleport";
@@ -1120,7 +1158,7 @@ var InvitationHostExtension = class extends RpcExtension {
1120
1158
  }
1121
1159
  });
1122
1160
  this._callbacks = _callbacks;
1123
- this._ctx = new Context3();
1161
+ this._ctx = new Context4();
1124
1162
  this._remoteOptionsTrigger = new Trigger2();
1125
1163
  this.invitation = void 0;
1126
1164
  this.guestProfile = void 0;
@@ -1149,7 +1187,7 @@ var InvitationHostExtension = class extends RpcExtension {
1149
1187
  introduce: async (request) => {
1150
1188
  const { profile, invitationId } = request;
1151
1189
  const traceId = PublicKey4.random().toHex();
1152
- log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
1190
+ log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
1153
1191
  id: traceId
1154
1192
  }), {
1155
1193
  F: __dxlog_file6,
@@ -1186,7 +1224,7 @@ var InvitationHostExtension = class extends RpcExtension {
1186
1224
  ...this.invitation,
1187
1225
  state: Invitation2.State.READY_FOR_AUTHENTICATION
1188
1226
  });
1189
- log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
1227
+ log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
1190
1228
  id: traceId
1191
1229
  }), {
1192
1230
  F: __dxlog_file6,
@@ -1201,7 +1239,7 @@ var InvitationHostExtension = class extends RpcExtension {
1201
1239
  },
1202
1240
  authenticate: async ({ authCode: code }) => {
1203
1241
  const traceId = PublicKey4.random().toHex();
1204
- log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
1242
+ log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
1205
1243
  id: traceId
1206
1244
  }), {
1207
1245
  F: __dxlog_file6,
@@ -1264,7 +1302,7 @@ var InvitationHostExtension = class extends RpcExtension {
1264
1302
  break;
1265
1303
  }
1266
1304
  }
1267
- log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.end({
1305
+ log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
1268
1306
  id: traceId,
1269
1307
  data: {
1270
1308
  status
@@ -1281,7 +1319,7 @@ var InvitationHostExtension = class extends RpcExtension {
1281
1319
  },
1282
1320
  admit: async (request) => {
1283
1321
  const traceId = PublicKey4.random().toHex();
1284
- log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
1322
+ log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
1285
1323
  id: traceId
1286
1324
  }), {
1287
1325
  F: __dxlog_file6,
@@ -1303,7 +1341,7 @@ var InvitationHostExtension = class extends RpcExtension {
1303
1341
  throw new Error("Not authenticated");
1304
1342
  }
1305
1343
  const response = await this._callbacks.admit(request);
1306
- log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
1344
+ log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
1307
1345
  id: traceId
1308
1346
  }), {
1309
1347
  F: __dxlog_file6,
@@ -1356,7 +1394,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1356
1394
  }
1357
1395
  });
1358
1396
  this._callbacks = _callbacks;
1359
- this._ctx = new Context3();
1397
+ this._ctx = new Context4();
1360
1398
  this._remoteOptionsTrigger = new Trigger2();
1361
1399
  }
1362
1400
  async getHandlers() {
@@ -1471,7 +1509,7 @@ var InvitationsHandler = class {
1471
1509
  ...protocol.getInvitationContext()
1472
1510
  };
1473
1511
  const stream = new PushStream();
1474
- const ctx = new Context4({
1512
+ const ctx = new Context5({
1475
1513
  onError: (err) => {
1476
1514
  void ctx.dispose();
1477
1515
  stream.error(err);
@@ -1527,7 +1565,7 @@ var InvitationsHandler = class {
1527
1565
  scheduleTask2(ctx, async () => {
1528
1566
  const traceId = PublicKey5.random().toHex();
1529
1567
  try {
1530
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
1568
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
1531
1569
  id: traceId
1532
1570
  }), {
1533
1571
  F: __dxlog_file7,
@@ -1563,7 +1601,7 @@ var InvitationsHandler = class {
1563
1601
  ...invitation,
1564
1602
  state: Invitation3.State.SUCCESS
1565
1603
  });
1566
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
1604
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
1567
1605
  id: traceId
1568
1606
  }), {
1569
1607
  F: __dxlog_file7,
@@ -1594,7 +1632,7 @@ var InvitationsHandler = class {
1594
1632
  });
1595
1633
  stream.error(err);
1596
1634
  }
1597
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.error({
1635
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
1598
1636
  id: traceId,
1599
1637
  error: err
1600
1638
  }), {
@@ -1702,7 +1740,7 @@ var InvitationsHandler = class {
1702
1740
  ...newData
1703
1741
  });
1704
1742
  };
1705
- const ctx = new Context4({
1743
+ const ctx = new Context5({
1706
1744
  onError: (err) => {
1707
1745
  if (err instanceof TimeoutError) {
1708
1746
  log5("timeout", {
@@ -1759,7 +1797,7 @@ var InvitationsHandler = class {
1759
1797
  scheduleTask2(ctx, async () => {
1760
1798
  const traceId = PublicKey5.random().toHex();
1761
1799
  try {
1762
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
1800
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
1763
1801
  id: traceId
1764
1802
  }), {
1765
1803
  F: __dxlog_file7,
@@ -1878,7 +1916,7 @@ var InvitationsHandler = class {
1878
1916
  ...result,
1879
1917
  state: Invitation3.State.SUCCESS
1880
1918
  });
1881
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
1919
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
1882
1920
  id: traceId
1883
1921
  }), {
1884
1922
  F: __dxlog_file7,
@@ -1908,7 +1946,7 @@ var InvitationsHandler = class {
1908
1946
  });
1909
1947
  stream.error(err);
1910
1948
  }
1911
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.error({
1949
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
1912
1950
  id: traceId,
1913
1951
  error: err
1914
1952
  }), {
@@ -2395,7 +2433,7 @@ import { STORAGE_VERSION } from "@dxos/protocols";
2395
2433
  import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2396
2434
 
2397
2435
  // packages/sdk/client-services/src/version.ts
2398
- var DXOS_VERSION = "0.1.56-main.a25bb93";
2436
+ var DXOS_VERSION = "0.1.56-main.ad054df";
2399
2437
 
2400
2438
  // packages/sdk/client-services/src/packlets/services/platform.ts
2401
2439
  var getPlatform = () => {
@@ -2554,7 +2592,7 @@ var getSpaceStats = async (space) => {
2554
2592
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2555
2593
  import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
2556
2594
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2557
- import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
2595
+ import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
2558
2596
  import { timed } from "@dxos/debug";
2559
2597
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2560
2598
  import { CancelledError, SystemError } from "@dxos/errors";
@@ -2567,7 +2605,7 @@ import { ComplexSet as ComplexSet2 } from "@dxos/util";
2567
2605
 
2568
2606
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2569
2607
  import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
2570
- import { Context as Context5, rejectOnDispose } from "@dxos/context";
2608
+ import { Context as Context6, rejectOnDispose } from "@dxos/context";
2571
2609
  import { invariant as invariant10 } from "@dxos/invariant";
2572
2610
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2573
2611
  import { log as log9 } from "@dxos/log";
@@ -2581,7 +2619,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2581
2619
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2582
2620
  var NotarizationPlugin = class {
2583
2621
  constructor() {
2584
- this._ctx = new Context5();
2622
+ this._ctx = new Context6();
2585
2623
  this._extensionOpened = new Event4();
2586
2624
  this._extensions = /* @__PURE__ */ new Set();
2587
2625
  this._processedCredentials = new ComplexSet(PublicKey6.hash);
@@ -2836,7 +2874,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
2836
2874
  };
2837
2875
 
2838
2876
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2839
- function _ts_decorate(decorators, target, key, desc) {
2877
+ function _ts_decorate3(decorators, target, key, desc) {
2840
2878
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2841
2879
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2842
2880
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2849,7 +2887,7 @@ function _ts_decorate(decorators, target, key, desc) {
2849
2887
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2850
2888
  var DataSpace = class DataSpace2 {
2851
2889
  constructor(params) {
2852
- this._ctx = new Context6();
2890
+ this._ctx = new Context7();
2853
2891
  this._notarizationPlugin = new NotarizationPlugin();
2854
2892
  this._state = SpaceState.CLOSED;
2855
2893
  /**
@@ -2907,7 +2945,7 @@ var DataSpace = class DataSpace2 {
2907
2945
  async _open() {
2908
2946
  await this._notarizationPlugin.open();
2909
2947
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2910
- await this._inner.open();
2948
+ await this._inner.open(new Context7());
2911
2949
  this._state = SpaceState.CONTROL_ONLY;
2912
2950
  this.stateUpdate.emit();
2913
2951
  this.metrics = {};
@@ -2921,7 +2959,7 @@ var DataSpace = class DataSpace2 {
2921
2959
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2922
2960
  this._state = SpaceState.CLOSED;
2923
2961
  await this._ctx.dispose();
2924
- this._ctx = new Context6();
2962
+ this._ctx = new Context7();
2925
2963
  await this.authVerifier.close();
2926
2964
  await this._inner.close();
2927
2965
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -3106,33 +3144,33 @@ var DataSpace = class DataSpace2 {
3106
3144
  this.stateUpdate.emit();
3107
3145
  }
3108
3146
  };
3109
- _ts_decorate([
3147
+ _ts_decorate3([
3110
3148
  synchronized
3111
3149
  ], DataSpace.prototype, "open", null);
3112
- _ts_decorate([
3150
+ _ts_decorate3([
3113
3151
  synchronized
3114
3152
  ], DataSpace.prototype, "close", null);
3115
- _ts_decorate([
3153
+ _ts_decorate3([
3116
3154
  timed(1e4)
3117
3155
  ], DataSpace.prototype, "_createWritableFeeds", null);
3118
- _ts_decorate([
3156
+ _ts_decorate3([
3119
3157
  synchronized
3120
3158
  ], DataSpace.prototype, "activate", null);
3121
- _ts_decorate([
3159
+ _ts_decorate3([
3122
3160
  synchronized
3123
3161
  ], DataSpace.prototype, "deactivate", null);
3124
- DataSpace = _ts_decorate([
3162
+ DataSpace = _ts_decorate3([
3125
3163
  trackLeaks("open", "close")
3126
3164
  ], DataSpace);
3127
3165
 
3128
3166
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3129
3167
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
3130
- import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
3168
+ import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
3131
3169
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3132
3170
  import { invariant as invariant11 } from "@dxos/invariant";
3133
3171
  import { PublicKey as PublicKey8 } from "@dxos/keys";
3134
3172
  import { log as log11 } from "@dxos/log";
3135
- import { trace as trace4 } from "@dxos/protocols";
3173
+ import { trace as trace5 } from "@dxos/protocols";
3136
3174
  import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
3137
3175
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
3138
3176
  import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
@@ -3208,7 +3246,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3208
3246
  };
3209
3247
 
3210
3248
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3211
- function _ts_decorate2(decorators, target, key, desc) {
3249
+ function _ts_decorate4(decorators, target, key, desc) {
3212
3250
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3213
3251
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3214
3252
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3227,7 +3265,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3227
3265
  this._keyring = _keyring;
3228
3266
  this._signingContext = _signingContext;
3229
3267
  this._feedStore = _feedStore;
3230
- this._ctx = new Context7();
3268
+ this._ctx = new Context8();
3231
3269
  this.updated = new Event6();
3232
3270
  this._spaces = new ComplexMap3(PublicKey8.hash);
3233
3271
  this._isOpen = false;
@@ -3244,7 +3282,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3244
3282
  S: this,
3245
3283
  C: (f, a) => f(...a)
3246
3284
  });
3247
- log11.trace("dxos.echo.data-space-manager.open", trace4.begin({
3285
+ log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
3248
3286
  id: this._instanceId
3249
3287
  }), {
3250
3288
  F: __dxlog_file13,
@@ -3289,7 +3327,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3289
3327
  }
3290
3328
  this._isOpen = true;
3291
3329
  this.updated.emit();
3292
- log11.trace("dxos.echo.data-space-manager.open", trace4.end({
3330
+ log11.trace("dxos.echo.data-space-manager.open", trace5.end({
3293
3331
  id: this._instanceId
3294
3332
  }), {
3295
3333
  F: __dxlog_file13,
@@ -3523,19 +3561,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3523
3561
  return dataSpace;
3524
3562
  }
3525
3563
  };
3526
- _ts_decorate2([
3564
+ _ts_decorate4([
3527
3565
  synchronized2
3528
3566
  ], DataSpaceManager.prototype, "open", null);
3529
- _ts_decorate2([
3567
+ _ts_decorate4([
3530
3568
  synchronized2
3531
3569
  ], DataSpaceManager.prototype, "close", null);
3532
- _ts_decorate2([
3570
+ _ts_decorate4([
3533
3571
  synchronized2
3534
3572
  ], DataSpaceManager.prototype, "createSpace", null);
3535
- _ts_decorate2([
3573
+ _ts_decorate4([
3536
3574
  synchronized2
3537
3575
  ], DataSpaceManager.prototype, "acceptSpace", null);
3538
- DataSpaceManager = _ts_decorate2([
3576
+ DataSpaceManager = _ts_decorate4([
3539
3577
  trackLeaks2("open", "close")
3540
3578
  ], DataSpaceManager);
3541
3579
 
@@ -3727,6 +3765,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
3727
3765
 
3728
3766
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3729
3767
  import { Trigger as Trigger5 } from "@dxos/async";
3768
+ import { Context as Context9 } from "@dxos/context";
3730
3769
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
3731
3770
  import { failUndefined as failUndefined3 } from "@dxos/debug";
3732
3771
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
@@ -3735,11 +3774,22 @@ import { invariant as invariant12 } from "@dxos/invariant";
3735
3774
  import { Keyring } from "@dxos/keyring";
3736
3775
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3737
3776
  import { log as log13 } from "@dxos/log";
3738
- import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace5 } from "@dxos/protocols";
3777
+ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
3739
3778
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3740
3779
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
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
+ }
3741
3791
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3742
- var ServiceContext = class {
3792
+ var ServiceContext = class ServiceContext2 {
3743
3793
  // prettier-ignore
3744
3794
  constructor(storage, networkManager, signalManager, modelFactory) {
3745
3795
  this.storage = storage;
@@ -3778,40 +3828,40 @@ var ServiceContext = class {
3778
3828
  return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
3779
3829
  }, this._acceptIdentity.bind(this)));
3780
3830
  }
3781
- async open() {
3831
+ async open(ctx) {
3782
3832
  await this._checkStorageVersion();
3783
3833
  log13("opening...", void 0, {
3784
3834
  F: __dxlog_file15,
3785
- L: 127,
3835
+ L: 131,
3786
3836
  S: this,
3787
3837
  C: (f, a) => f(...a)
3788
3838
  });
3789
- log13.trace("dxos.sdk.service-context.open", trace5.begin({
3839
+ log13.trace("dxos.sdk.service-context.open", trace6.begin({
3790
3840
  id: this._instanceId
3791
3841
  }), {
3792
3842
  F: __dxlog_file15,
3793
- L: 128,
3843
+ L: 132,
3794
3844
  S: this,
3795
3845
  C: (f, a) => f(...a)
3796
3846
  });
3797
3847
  await this.signalManager.open();
3798
3848
  await this.networkManager.open();
3799
3849
  await this.spaceManager.open();
3800
- await this.identityManager.open();
3850
+ await this.identityManager.open(ctx);
3801
3851
  if (this.identityManager.identity) {
3802
- await this._initialize();
3852
+ await this._initialize(ctx);
3803
3853
  }
3804
- log13.trace("dxos.sdk.service-context.open", trace5.end({
3854
+ log13.trace("dxos.sdk.service-context.open", trace6.end({
3805
3855
  id: this._instanceId
3806
3856
  }), {
3807
3857
  F: __dxlog_file15,
3808
- L: 136,
3858
+ L: 140,
3809
3859
  S: this,
3810
3860
  C: (f, a) => f(...a)
3811
3861
  });
3812
3862
  log13("opened", void 0, {
3813
3863
  F: __dxlog_file15,
3814
- L: 137,
3864
+ L: 141,
3815
3865
  S: this,
3816
3866
  C: (f, a) => f(...a)
3817
3867
  });
@@ -3820,7 +3870,7 @@ var ServiceContext = class {
3820
3870
  var _a;
3821
3871
  log13("closing...", void 0, {
3822
3872
  F: __dxlog_file15,
3823
- L: 141,
3873
+ L: 145,
3824
3874
  S: this,
3825
3875
  C: (f, a) => f(...a)
3826
3876
  });
@@ -3836,21 +3886,21 @@ var ServiceContext = class {
3836
3886
  this.dataServiceSubscriptions.clear();
3837
3887
  log13("closed", void 0, {
3838
3888
  F: __dxlog_file15,
3839
- L: 152,
3889
+ L: 156,
3840
3890
  S: this,
3841
3891
  C: (f, a) => f(...a)
3842
3892
  });
3843
3893
  }
3844
3894
  async createIdentity(params = {}) {
3845
3895
  const identity = await this.identityManager.createIdentity(params);
3846
- await this._initialize();
3896
+ await this._initialize(new Context9());
3847
3897
  return identity;
3848
3898
  }
3849
3899
  getInvitationHandler(invitation) {
3850
3900
  const factory = this._handlerFactories.get(invitation.kind);
3851
3901
  invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
3852
3902
  F: __dxlog_file15,
3853
- L: 164,
3903
+ L: 168,
3854
3904
  S: this,
3855
3905
  A: [
3856
3906
  "factory",
@@ -3861,7 +3911,7 @@ var ServiceContext = class {
3861
3911
  }
3862
3912
  async _acceptIdentity(params) {
3863
3913
  const identity = await this.identityManager.acceptIdentity(params);
3864
- await this._initialize();
3914
+ await this._initialize(new Context9());
3865
3915
  return identity;
3866
3916
  }
3867
3917
  async _checkStorageVersion() {
@@ -3871,11 +3921,11 @@ var ServiceContext = class {
3871
3921
  }
3872
3922
  }
3873
3923
  // Called when identity is created.
3874
- async _initialize() {
3924
+ async _initialize(ctx) {
3875
3925
  var _a;
3876
3926
  log13("initializing spaces...", void 0, {
3877
3927
  F: __dxlog_file15,
3878
- L: 185,
3928
+ L: 190,
3879
3929
  S: this,
3880
3930
  C: (f, a) => f(...a)
3881
3931
  });
@@ -3898,7 +3948,7 @@ var ServiceContext = class {
3898
3948
  this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
3899
3949
  invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3900
3950
  F: __dxlog_file15,
3901
- L: 208,
3951
+ L: 213,
3902
3952
  S: this,
3903
3953
  A: [
3904
3954
  "this.dataSpaceManager",
@@ -3922,7 +3972,7 @@ var ServiceContext = class {
3922
3972
  details: assertion
3923
3973
  }, {
3924
3974
  F: __dxlog_file15,
3925
- L: 224,
3975
+ L: 229,
3926
3976
  S: this,
3927
3977
  C: (f, a) => f(...a)
3928
3978
  });
@@ -3933,7 +3983,7 @@ var ServiceContext = class {
3933
3983
  details: assertion
3934
3984
  }, {
3935
3985
  F: __dxlog_file15,
3936
- L: 228,
3986
+ L: 233,
3937
3987
  S: this,
3938
3988
  C: (f, a) => f(...a)
3939
3989
  });
@@ -3944,7 +3994,7 @@ var ServiceContext = class {
3944
3994
  details: assertion
3945
3995
  }, {
3946
3996
  F: __dxlog_file15,
3947
- L: 233,
3997
+ L: 238,
3948
3998
  S: this,
3949
3999
  C: (f, a) => f(...a)
3950
4000
  });
@@ -3955,7 +4005,7 @@ var ServiceContext = class {
3955
4005
  } catch (err) {
3956
4006
  log13.catch(err, void 0, {
3957
4007
  F: __dxlog_file15,
3958
- L: 239,
4008
+ L: 244,
3959
4009
  S: this,
3960
4010
  C: (f, a) => f(...a)
3961
4011
  });
@@ -3965,12 +4015,21 @@ var ServiceContext = class {
3965
4015
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3966
4016
  }
3967
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);
3968
4027
 
3969
4028
  // packages/sdk/client-services/src/packlets/locks/browser.ts
3970
4029
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3971
4030
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3972
4031
  import { log as log14, logInfo } from "@dxos/log";
3973
- function _ts_decorate3(decorators, target, key, desc) {
4032
+ function _ts_decorate6(decorators, target, key, desc) {
3974
4033
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3975
4034
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3976
4035
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4085,7 +4144,7 @@ var Lock = class {
4085
4144
  });
4086
4145
  }
4087
4146
  };
4088
- _ts_decorate3([
4147
+ _ts_decorate6([
4089
4148
  logInfo
4090
4149
  ], Lock.prototype, "lockKey", null);
4091
4150
  var isLocked = (lockPath) => {
@@ -4168,6 +4227,7 @@ var ServiceRegistry = class {
4168
4227
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4169
4228
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
4170
4229
  import { clientServiceBundle } from "@dxos/client-protocol";
4230
+ import { Context as Context10 } from "@dxos/context";
4171
4231
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4172
4232
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4173
4233
  import { invariant as invariant13 } from "@dxos/invariant";
@@ -4176,9 +4236,10 @@ import { log as log16 } from "@dxos/log";
4176
4236
  import { WebsocketSignalManager } from "@dxos/messaging";
4177
4237
  import { ModelFactory } from "@dxos/model-factory";
4178
4238
  import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
4179
- import { trace as trace6 } from "@dxos/protocols";
4239
+ import { trace as trace7 } from "@dxos/protocols";
4180
4240
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
4181
4241
  import { TextModel } from "@dxos/text-model";
4242
+ import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
4182
4243
 
4183
4244
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
4184
4245
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
@@ -4438,7 +4499,7 @@ var SystemServiceImpl = class {
4438
4499
  };
4439
4500
 
4440
4501
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4441
- function _ts_decorate4(decorators, target, key, desc) {
4502
+ function _ts_decorate7(decorators, target, key, desc) {
4442
4503
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4443
4504
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4444
4505
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4452,7 +4513,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4452
4513
  var createDefaultModelFactory = () => {
4453
4514
  return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
4454
4515
  };
4455
- var ClientServicesHost = class {
4516
+ var ClientServicesHost = class ClientServicesHost2 {
4456
4517
  constructor({
4457
4518
  config,
4458
4519
  modelFactory = createDefaultModelFactory(),
@@ -4463,6 +4524,7 @@ var ClientServicesHost = class {
4463
4524
  lockKey,
4464
4525
  callbacks
4465
4526
  } = {}) {
4527
+ this._tracingService = TRACE_PROCESSOR.createTraceSender();
4466
4528
  this._statusUpdate = new Event8();
4467
4529
  this._opening = false;
4468
4530
  this._open = false;
@@ -4481,7 +4543,7 @@ var ClientServicesHost = class {
4481
4543
  lockKey,
4482
4544
  onAcquire: () => {
4483
4545
  if (!this._opening) {
4484
- void this.open();
4546
+ void this.open(new Context10());
4485
4547
  }
4486
4548
  },
4487
4549
  onRelease: () => this.close()
@@ -4508,7 +4570,8 @@ var ClientServicesHost = class {
4508
4570
  });
4509
4571
  this._loggingService = new LoggingServiceImpl();
4510
4572
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
4511
- SystemService: this._systemService
4573
+ SystemService: this._systemService,
4574
+ TracingService: this._tracingService
4512
4575
  });
4513
4576
  }
4514
4577
  get isOpen() {
@@ -4538,7 +4601,7 @@ var ClientServicesHost = class {
4538
4601
  var _a, _b, _c;
4539
4602
  invariant13(!this._open, "service host is open", {
4540
4603
  F: __dxlog_file17,
4541
- L: 172,
4604
+ L: 181,
4542
4605
  S: this,
4543
4606
  A: [
4544
4607
  "!this._open",
@@ -4547,14 +4610,14 @@ var ClientServicesHost = class {
4547
4610
  });
4548
4611
  log16.info("initializing...", void 0, {
4549
4612
  F: __dxlog_file17,
4550
- L: 173,
4613
+ L: 182,
4551
4614
  S: this,
4552
4615
  C: (f, a) => f(...a)
4553
4616
  });
4554
4617
  if (config) {
4555
4618
  invariant13(!this._config, "config already set", {
4556
4619
  F: __dxlog_file17,
4557
- L: 176,
4620
+ L: 185,
4558
4621
  S: this,
4559
4622
  A: [
4560
4623
  "!this._config",
@@ -4572,7 +4635,7 @@ var ClientServicesHost = class {
4572
4635
  this._signalManager = signalManager;
4573
4636
  invariant13(!this._networkManager, "network manager already set", {
4574
4637
  F: __dxlog_file17,
4575
- L: 192,
4638
+ L: 201,
4576
4639
  S: this,
4577
4640
  A: [
4578
4641
  "!this._networkManager",
@@ -4586,28 +4649,28 @@ var ClientServicesHost = class {
4586
4649
  });
4587
4650
  log16.info("initialized", void 0, {
4588
4651
  F: __dxlog_file17,
4589
- L: 199,
4652
+ L: 208,
4590
4653
  S: this,
4591
4654
  C: (f, a) => f(...a)
4592
4655
  });
4593
4656
  }
4594
- async open() {
4657
+ async open(ctx) {
4595
4658
  var _a, _b, _c;
4596
4659
  if (this._open) {
4597
4660
  return;
4598
4661
  }
4599
4662
  const traceId = PublicKey10.random().toHex();
4600
- log16.trace("dxos.client-services.host.open", trace6.begin({
4663
+ log16.trace("dxos.client-services.host.open", trace7.begin({
4601
4664
  id: traceId
4602
4665
  }), {
4603
4666
  F: __dxlog_file17,
4604
- L: 209,
4667
+ L: 219,
4605
4668
  S: this,
4606
4669
  C: (f, a) => f(...a)
4607
4670
  });
4608
4671
  invariant13(this._config, "config not set", {
4609
4672
  F: __dxlog_file17,
4610
- L: 211,
4673
+ L: 221,
4611
4674
  S: this,
4612
4675
  A: [
4613
4676
  "this._config",
@@ -4616,7 +4679,7 @@ var ClientServicesHost = class {
4616
4679
  });
4617
4680
  invariant13(this._storage, "storage not set", {
4618
4681
  F: __dxlog_file17,
4619
- L: 212,
4682
+ L: 222,
4620
4683
  S: this,
4621
4684
  A: [
4622
4685
  "this._storage",
@@ -4625,7 +4688,7 @@ var ClientServicesHost = class {
4625
4688
  });
4626
4689
  invariant13(this._signalManager, "signal manager not set", {
4627
4690
  F: __dxlog_file17,
4628
- L: 213,
4691
+ L: 223,
4629
4692
  S: this,
4630
4693
  A: [
4631
4694
  "this._signalManager",
@@ -4634,7 +4697,7 @@ var ClientServicesHost = class {
4634
4697
  });
4635
4698
  invariant13(this._networkManager, "network manager not set", {
4636
4699
  F: __dxlog_file17,
4637
- L: 214,
4700
+ L: 224,
4638
4701
  S: this,
4639
4702
  A: [
4640
4703
  "this._networkManager",
@@ -4646,7 +4709,7 @@ var ClientServicesHost = class {
4646
4709
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4647
4710
  }, {
4648
4711
  F: __dxlog_file17,
4649
- L: 217,
4712
+ L: 227,
4650
4713
  S: this,
4651
4714
  C: (f, a) => f(...a)
4652
4715
  });
@@ -4665,6 +4728,7 @@ var ClientServicesHost = class {
4665
4728
  DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4666
4729
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4667
4730
  LoggingService: this._loggingService,
4731
+ TracingService: this._tracingService,
4668
4732
  // TODO(burdon): Move to new protobuf definitions.
4669
4733
  DevtoolsHost: new DevtoolsServiceImpl({
4670
4734
  events: new DevtoolsHostEvents(),
@@ -4672,7 +4736,7 @@ var ClientServicesHost = class {
4672
4736
  context: this._serviceContext
4673
4737
  })
4674
4738
  });
4675
- await this._serviceContext.open();
4739
+ await this._serviceContext.open(ctx);
4676
4740
  this._opening = false;
4677
4741
  this._open = true;
4678
4742
  this._statusUpdate.emit();
@@ -4681,15 +4745,15 @@ var ClientServicesHost = class {
4681
4745
  deviceKey
4682
4746
  }, {
4683
4747
  F: __dxlog_file17,
4684
- L: 269,
4748
+ L: 280,
4685
4749
  S: this,
4686
4750
  C: (f, a) => f(...a)
4687
4751
  });
4688
- log16.trace("dxos.client-services.host.open", trace6.end({
4752
+ log16.trace("dxos.client-services.host.open", trace7.end({
4689
4753
  id: traceId
4690
4754
  }), {
4691
4755
  F: __dxlog_file17,
4692
- L: 270,
4756
+ L: 281,
4693
4757
  S: this,
4694
4758
  C: (f, a) => f(...a)
4695
4759
  });
@@ -4704,7 +4768,7 @@ var ClientServicesHost = class {
4704
4768
  deviceKey
4705
4769
  }, {
4706
4770
  F: __dxlog_file17,
4707
- L: 280,
4771
+ L: 292,
4708
4772
  S: this,
4709
4773
  C: (f, a) => f(...a)
4710
4774
  });
@@ -4719,7 +4783,7 @@ var ClientServicesHost = class {
4719
4783
  deviceKey
4720
4784
  }, {
4721
4785
  F: __dxlog_file17,
4722
- L: 286,
4786
+ L: 298,
4723
4787
  S: this,
4724
4788
  C: (f, a) => f(...a)
4725
4789
  });
@@ -4727,17 +4791,17 @@ var ClientServicesHost = class {
4727
4791
  async reset() {
4728
4792
  var _a, _b, _c;
4729
4793
  const traceId = PublicKey10.random().toHex();
4730
- log16.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4794
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
4731
4795
  id: traceId
4732
4796
  }), {
4733
4797
  F: __dxlog_file17,
4734
- L: 291,
4798
+ L: 303,
4735
4799
  S: this,
4736
4800
  C: (f, a) => f(...a)
4737
4801
  });
4738
4802
  log16("resetting...", void 0, {
4739
4803
  F: __dxlog_file17,
4740
- L: 293,
4804
+ L: 305,
4741
4805
  S: this,
4742
4806
  C: (f, a) => f(...a)
4743
4807
  });
@@ -4745,27 +4809,38 @@ var ClientServicesHost = class {
4745
4809
  await this._storage.reset();
4746
4810
  log16("reset", void 0, {
4747
4811
  F: __dxlog_file17,
4748
- L: 296,
4812
+ L: 308,
4749
4813
  S: this,
4750
4814
  C: (f, a) => f(...a)
4751
4815
  });
4752
- log16.trace("dxos.sdk.client-services-host.reset", trace6.end({
4816
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
4753
4817
  id: traceId
4754
4818
  }), {
4755
4819
  F: __dxlog_file17,
4756
- L: 297,
4820
+ L: 309,
4757
4821
  S: this,
4758
4822
  C: (f, a) => f(...a)
4759
4823
  });
4760
4824
  await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4761
4825
  }
4762
4826
  };
4763
- _ts_decorate4([
4764
- 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()
4765
4836
  ], ClientServicesHost.prototype, "open", null);
4766
- _ts_decorate4([
4767
- synchronized3
4837
+ _ts_decorate7([
4838
+ synchronized3,
4839
+ Trace3.span()
4768
4840
  ], ClientServicesHost.prototype, "close", null);
4841
+ ClientServicesHost = _ts_decorate7([
4842
+ Trace3.resource()
4843
+ ], ClientServicesHost);
4769
4844
 
4770
4845
  export {
4771
4846
  subscribeToFeeds,
@@ -4800,4 +4875,4 @@ export {
4800
4875
  createDefaultModelFactory,
4801
4876
  ClientServicesHost
4802
4877
  };
4803
- //# sourceMappingURL=chunk-MAHWP5I6.mjs.map
4878
+ //# sourceMappingURL=chunk-U5CCSPX6.mjs.map