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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/lib/browser/{chunk-K67JOICT.mjs → chunk-ZOTHWLK5.mjs} +228 -149
  2. package/dist/lib/browser/chunk-ZOTHWLK5.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 +223 -142
  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 +210 -131
  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/spaces/data-space.d.ts.map +1 -1
  23. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  24. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +34 -33
  27. package/src/packlets/devices/devices-service.test.ts +2 -1
  28. package/src/packlets/identity/identity-manager.test.ts +4 -3
  29. package/src/packlets/identity/identity-manager.ts +9 -5
  30. package/src/packlets/identity/identity-service.test.ts +2 -1
  31. package/src/packlets/identity/identity.test.ts +7 -6
  32. package/src/packlets/identity/identity.ts +8 -3
  33. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  34. package/src/packlets/network/network-service.test.ts +2 -1
  35. package/src/packlets/services/client-rpc-server.ts +4 -4
  36. package/src/packlets/services/service-context.test.ts +59 -0
  37. package/src/packlets/services/service-context.ts +11 -6
  38. package/src/packlets/services/service-host.test.ts +6 -5
  39. package/src/packlets/services/service-host.ts +15 -3
  40. package/src/packlets/services/service-registry.test.ts +2 -1
  41. package/src/packlets/spaces/data-space.ts +17 -5
  42. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  43. package/src/packlets/testing/test-builder.ts +1 -1
  44. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  45. package/src/packlets/vault/worker-runtime.ts +2 -1
  46. package/src/version.ts +1 -1
  47. package/dist/lib/browser/chunk-K67JOICT.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.be59a09";
2436
+ var DXOS_VERSION = "0.1.56-main.c19b7cd";
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);
@@ -2847,9 +2885,10 @@ function _ts_decorate(decorators, target, key, desc) {
2847
2885
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2848
2886
  }
2849
2887
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2888
+ var ENABLE_FEED_PURGE = false;
2850
2889
  var DataSpace = class DataSpace2 {
2851
2890
  constructor(params) {
2852
- this._ctx = new Context6();
2891
+ this._ctx = new Context7();
2853
2892
  this._notarizationPlugin = new NotarizationPlugin();
2854
2893
  this._state = SpaceState.CLOSED;
2855
2894
  /**
@@ -2907,7 +2946,7 @@ var DataSpace = class DataSpace2 {
2907
2946
  async _open() {
2908
2947
  await this._notarizationPlugin.open();
2909
2948
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2910
- await this._inner.open();
2949
+ await this._inner.open(new Context7());
2911
2950
  this._state = SpaceState.CONTROL_ONLY;
2912
2951
  this.stateUpdate.emit();
2913
2952
  this.metrics = {};
@@ -2921,7 +2960,7 @@ var DataSpace = class DataSpace2 {
2921
2960
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2922
2961
  this._state = SpaceState.CLOSED;
2923
2962
  await this._ctx.dispose();
2924
- this._ctx = new Context6();
2963
+ this._ctx = new Context7();
2925
2964
  await this.authVerifier.close();
2926
2965
  await this._inner.close();
2927
2966
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -2946,7 +2985,7 @@ var DataSpace = class DataSpace2 {
2946
2985
  if (err instanceof CancelledError) {
2947
2986
  log10("data pipeline initialization cancelled", err, {
2948
2987
  F: __dxlog_file12,
2949
- L: 193,
2988
+ L: 199,
2950
2989
  S: this,
2951
2990
  C: (f, a) => f(...a)
2952
2991
  });
@@ -2954,7 +2993,7 @@ var DataSpace = class DataSpace2 {
2954
2993
  }
2955
2994
  log10.error("Error initializing data pipeline", err, {
2956
2995
  F: __dxlog_file12,
2957
- L: 197,
2996
+ L: 203,
2958
2997
  S: this,
2959
2998
  C: (f, a) => f(...a)
2960
2999
  });
@@ -2980,7 +3019,7 @@ var DataSpace = class DataSpace2 {
2980
3019
  await this._createWritableFeeds();
2981
3020
  log10("writable feeds created", void 0, {
2982
3021
  F: __dxlog_file12,
2983
- L: 221,
3022
+ L: 227,
2984
3023
  S: this,
2985
3024
  C: (f, a) => f(...a)
2986
3025
  });
@@ -2997,7 +3036,7 @@ var DataSpace = class DataSpace2 {
2997
3036
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2998
3037
  log10("waiting for data pipeline to reach target timeframe", void 0, {
2999
3038
  F: __dxlog_file12,
3000
- L: 242,
3039
+ L: 248,
3001
3040
  S: this,
3002
3041
  C: (f, a) => f(...a)
3003
3042
  });
@@ -3008,7 +3047,7 @@ var DataSpace = class DataSpace2 {
3008
3047
  this.metrics.dataPipelineReady = new Date();
3009
3048
  log10("data pipeline ready", void 0, {
3010
3049
  F: __dxlog_file12,
3011
- L: 251,
3050
+ L: 257,
3012
3051
  S: this,
3013
3052
  C: (f, a) => f(...a)
3014
3053
  });
@@ -3081,10 +3120,13 @@ var DataSpace = class DataSpace2 {
3081
3120
  receipt.seq
3082
3121
  ]
3083
3122
  ]));
3084
- for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
3085
- const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3086
- if (indexBeforeEpoch) {
3087
- await feed.clear(0, indexBeforeEpoch + 1);
3123
+ if (ENABLE_FEED_PURGE) {
3124
+ for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
3125
+ const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3126
+ if (indexBeforeEpoch === void 0) {
3127
+ continue;
3128
+ }
3129
+ await feed.safeClear(0, indexBeforeEpoch + 1);
3088
3130
  }
3089
3131
  }
3090
3132
  }
@@ -3106,33 +3148,33 @@ var DataSpace = class DataSpace2 {
3106
3148
  this.stateUpdate.emit();
3107
3149
  }
3108
3150
  };
3109
- _ts_decorate([
3151
+ _ts_decorate3([
3110
3152
  synchronized
3111
3153
  ], DataSpace.prototype, "open", null);
3112
- _ts_decorate([
3154
+ _ts_decorate3([
3113
3155
  synchronized
3114
3156
  ], DataSpace.prototype, "close", null);
3115
- _ts_decorate([
3157
+ _ts_decorate3([
3116
3158
  timed(1e4)
3117
3159
  ], DataSpace.prototype, "_createWritableFeeds", null);
3118
- _ts_decorate([
3160
+ _ts_decorate3([
3119
3161
  synchronized
3120
3162
  ], DataSpace.prototype, "activate", null);
3121
- _ts_decorate([
3163
+ _ts_decorate3([
3122
3164
  synchronized
3123
3165
  ], DataSpace.prototype, "deactivate", null);
3124
- DataSpace = _ts_decorate([
3166
+ DataSpace = _ts_decorate3([
3125
3167
  trackLeaks("open", "close")
3126
3168
  ], DataSpace);
3127
3169
 
3128
3170
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3129
3171
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
3130
- import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
3172
+ import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
3131
3173
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3132
3174
  import { invariant as invariant11 } from "@dxos/invariant";
3133
3175
  import { PublicKey as PublicKey8 } from "@dxos/keys";
3134
3176
  import { log as log11 } from "@dxos/log";
3135
- import { trace as trace4 } from "@dxos/protocols";
3177
+ import { trace as trace5 } from "@dxos/protocols";
3136
3178
  import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
3137
3179
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
3138
3180
  import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
@@ -3208,7 +3250,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3208
3250
  };
3209
3251
 
3210
3252
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3211
- function _ts_decorate2(decorators, target, key, desc) {
3253
+ function _ts_decorate4(decorators, target, key, desc) {
3212
3254
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3213
3255
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3214
3256
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3227,7 +3269,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3227
3269
  this._keyring = _keyring;
3228
3270
  this._signingContext = _signingContext;
3229
3271
  this._feedStore = _feedStore;
3230
- this._ctx = new Context7();
3272
+ this._ctx = new Context8();
3231
3273
  this.updated = new Event6();
3232
3274
  this._spaces = new ComplexMap3(PublicKey8.hash);
3233
3275
  this._isOpen = false;
@@ -3244,7 +3286,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3244
3286
  S: this,
3245
3287
  C: (f, a) => f(...a)
3246
3288
  });
3247
- log11.trace("dxos.echo.data-space-manager.open", trace4.begin({
3289
+ log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
3248
3290
  id: this._instanceId
3249
3291
  }), {
3250
3292
  F: __dxlog_file13,
@@ -3289,7 +3331,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3289
3331
  }
3290
3332
  this._isOpen = true;
3291
3333
  this.updated.emit();
3292
- log11.trace("dxos.echo.data-space-manager.open", trace4.end({
3334
+ log11.trace("dxos.echo.data-space-manager.open", trace5.end({
3293
3335
  id: this._instanceId
3294
3336
  }), {
3295
3337
  F: __dxlog_file13,
@@ -3523,19 +3565,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3523
3565
  return dataSpace;
3524
3566
  }
3525
3567
  };
3526
- _ts_decorate2([
3568
+ _ts_decorate4([
3527
3569
  synchronized2
3528
3570
  ], DataSpaceManager.prototype, "open", null);
3529
- _ts_decorate2([
3571
+ _ts_decorate4([
3530
3572
  synchronized2
3531
3573
  ], DataSpaceManager.prototype, "close", null);
3532
- _ts_decorate2([
3574
+ _ts_decorate4([
3533
3575
  synchronized2
3534
3576
  ], DataSpaceManager.prototype, "createSpace", null);
3535
- _ts_decorate2([
3577
+ _ts_decorate4([
3536
3578
  synchronized2
3537
3579
  ], DataSpaceManager.prototype, "acceptSpace", null);
3538
- DataSpaceManager = _ts_decorate2([
3580
+ DataSpaceManager = _ts_decorate4([
3539
3581
  trackLeaks2("open", "close")
3540
3582
  ], DataSpaceManager);
3541
3583
 
@@ -3727,6 +3769,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
3727
3769
 
3728
3770
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3729
3771
  import { Trigger as Trigger5 } from "@dxos/async";
3772
+ import { Context as Context9 } from "@dxos/context";
3730
3773
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
3731
3774
  import { failUndefined as failUndefined3 } from "@dxos/debug";
3732
3775
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
@@ -3735,11 +3778,22 @@ import { invariant as invariant12 } from "@dxos/invariant";
3735
3778
  import { Keyring } from "@dxos/keyring";
3736
3779
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3737
3780
  import { log as log13 } from "@dxos/log";
3738
- import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace5 } from "@dxos/protocols";
3781
+ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
3739
3782
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3740
3783
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
3784
+ import { trace as Trace2 } from "@dxos/tracing";
3785
+ function _ts_decorate5(decorators, target, key, desc) {
3786
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3787
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3788
+ r = Reflect.decorate(decorators, target, key, desc);
3789
+ else
3790
+ for (var i = decorators.length - 1; i >= 0; i--)
3791
+ if (d = decorators[i])
3792
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3793
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3794
+ }
3741
3795
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3742
- var ServiceContext = class {
3796
+ var ServiceContext = class ServiceContext2 {
3743
3797
  // prettier-ignore
3744
3798
  constructor(storage, networkManager, signalManager, modelFactory) {
3745
3799
  this.storage = storage;
@@ -3778,40 +3832,40 @@ var ServiceContext = class {
3778
3832
  return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
3779
3833
  }, this._acceptIdentity.bind(this)));
3780
3834
  }
3781
- async open() {
3835
+ async open(ctx) {
3782
3836
  await this._checkStorageVersion();
3783
3837
  log13("opening...", void 0, {
3784
3838
  F: __dxlog_file15,
3785
- L: 127,
3839
+ L: 131,
3786
3840
  S: this,
3787
3841
  C: (f, a) => f(...a)
3788
3842
  });
3789
- log13.trace("dxos.sdk.service-context.open", trace5.begin({
3843
+ log13.trace("dxos.sdk.service-context.open", trace6.begin({
3790
3844
  id: this._instanceId
3791
3845
  }), {
3792
3846
  F: __dxlog_file15,
3793
- L: 128,
3847
+ L: 132,
3794
3848
  S: this,
3795
3849
  C: (f, a) => f(...a)
3796
3850
  });
3797
3851
  await this.signalManager.open();
3798
3852
  await this.networkManager.open();
3799
3853
  await this.spaceManager.open();
3800
- await this.identityManager.open();
3854
+ await this.identityManager.open(ctx);
3801
3855
  if (this.identityManager.identity) {
3802
- await this._initialize();
3856
+ await this._initialize(ctx);
3803
3857
  }
3804
- log13.trace("dxos.sdk.service-context.open", trace5.end({
3858
+ log13.trace("dxos.sdk.service-context.open", trace6.end({
3805
3859
  id: this._instanceId
3806
3860
  }), {
3807
3861
  F: __dxlog_file15,
3808
- L: 136,
3862
+ L: 140,
3809
3863
  S: this,
3810
3864
  C: (f, a) => f(...a)
3811
3865
  });
3812
3866
  log13("opened", void 0, {
3813
3867
  F: __dxlog_file15,
3814
- L: 137,
3868
+ L: 141,
3815
3869
  S: this,
3816
3870
  C: (f, a) => f(...a)
3817
3871
  });
@@ -3820,7 +3874,7 @@ var ServiceContext = class {
3820
3874
  var _a;
3821
3875
  log13("closing...", void 0, {
3822
3876
  F: __dxlog_file15,
3823
- L: 141,
3877
+ L: 145,
3824
3878
  S: this,
3825
3879
  C: (f, a) => f(...a)
3826
3880
  });
@@ -3836,21 +3890,21 @@ var ServiceContext = class {
3836
3890
  this.dataServiceSubscriptions.clear();
3837
3891
  log13("closed", void 0, {
3838
3892
  F: __dxlog_file15,
3839
- L: 152,
3893
+ L: 156,
3840
3894
  S: this,
3841
3895
  C: (f, a) => f(...a)
3842
3896
  });
3843
3897
  }
3844
3898
  async createIdentity(params = {}) {
3845
3899
  const identity = await this.identityManager.createIdentity(params);
3846
- await this._initialize();
3900
+ await this._initialize(new Context9());
3847
3901
  return identity;
3848
3902
  }
3849
3903
  getInvitationHandler(invitation) {
3850
3904
  const factory = this._handlerFactories.get(invitation.kind);
3851
3905
  invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
3852
3906
  F: __dxlog_file15,
3853
- L: 164,
3907
+ L: 168,
3854
3908
  S: this,
3855
3909
  A: [
3856
3910
  "factory",
@@ -3861,7 +3915,7 @@ var ServiceContext = class {
3861
3915
  }
3862
3916
  async _acceptIdentity(params) {
3863
3917
  const identity = await this.identityManager.acceptIdentity(params);
3864
- await this._initialize();
3918
+ await this._initialize(new Context9());
3865
3919
  return identity;
3866
3920
  }
3867
3921
  async _checkStorageVersion() {
@@ -3871,11 +3925,11 @@ var ServiceContext = class {
3871
3925
  }
3872
3926
  }
3873
3927
  // Called when identity is created.
3874
- async _initialize() {
3928
+ async _initialize(ctx) {
3875
3929
  var _a;
3876
3930
  log13("initializing spaces...", void 0, {
3877
3931
  F: __dxlog_file15,
3878
- L: 185,
3932
+ L: 190,
3879
3933
  S: this,
3880
3934
  C: (f, a) => f(...a)
3881
3935
  });
@@ -3898,7 +3952,7 @@ var ServiceContext = class {
3898
3952
  this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
3899
3953
  invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3900
3954
  F: __dxlog_file15,
3901
- L: 208,
3955
+ L: 213,
3902
3956
  S: this,
3903
3957
  A: [
3904
3958
  "this.dataSpaceManager",
@@ -3922,7 +3976,7 @@ var ServiceContext = class {
3922
3976
  details: assertion
3923
3977
  }, {
3924
3978
  F: __dxlog_file15,
3925
- L: 224,
3979
+ L: 229,
3926
3980
  S: this,
3927
3981
  C: (f, a) => f(...a)
3928
3982
  });
@@ -3933,7 +3987,7 @@ var ServiceContext = class {
3933
3987
  details: assertion
3934
3988
  }, {
3935
3989
  F: __dxlog_file15,
3936
- L: 228,
3990
+ L: 233,
3937
3991
  S: this,
3938
3992
  C: (f, a) => f(...a)
3939
3993
  });
@@ -3944,7 +3998,7 @@ var ServiceContext = class {
3944
3998
  details: assertion
3945
3999
  }, {
3946
4000
  F: __dxlog_file15,
3947
- L: 233,
4001
+ L: 238,
3948
4002
  S: this,
3949
4003
  C: (f, a) => f(...a)
3950
4004
  });
@@ -3955,7 +4009,7 @@ var ServiceContext = class {
3955
4009
  } catch (err) {
3956
4010
  log13.catch(err, void 0, {
3957
4011
  F: __dxlog_file15,
3958
- L: 239,
4012
+ L: 244,
3959
4013
  S: this,
3960
4014
  C: (f, a) => f(...a)
3961
4015
  });
@@ -3965,12 +4019,21 @@ var ServiceContext = class {
3965
4019
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3966
4020
  }
3967
4021
  };
4022
+ _ts_decorate5([
4023
+ Trace2.span()
4024
+ ], ServiceContext.prototype, "open", null);
4025
+ _ts_decorate5([
4026
+ Trace2.span()
4027
+ ], ServiceContext.prototype, "_initialize", null);
4028
+ ServiceContext = _ts_decorate5([
4029
+ Trace2.resource()
4030
+ ], ServiceContext);
3968
4031
 
3969
4032
  // packages/sdk/client-services/src/packlets/locks/browser.ts
3970
4033
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3971
4034
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3972
4035
  import { log as log14, logInfo } from "@dxos/log";
3973
- function _ts_decorate3(decorators, target, key, desc) {
4036
+ function _ts_decorate6(decorators, target, key, desc) {
3974
4037
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3975
4038
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3976
4039
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4085,7 +4148,7 @@ var Lock = class {
4085
4148
  });
4086
4149
  }
4087
4150
  };
4088
- _ts_decorate3([
4151
+ _ts_decorate6([
4089
4152
  logInfo
4090
4153
  ], Lock.prototype, "lockKey", null);
4091
4154
  var isLocked = (lockPath) => {
@@ -4168,6 +4231,7 @@ var ServiceRegistry = class {
4168
4231
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4169
4232
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
4170
4233
  import { clientServiceBundle } from "@dxos/client-protocol";
4234
+ import { Context as Context10 } from "@dxos/context";
4171
4235
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4172
4236
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4173
4237
  import { invariant as invariant13 } from "@dxos/invariant";
@@ -4176,9 +4240,10 @@ import { log as log16 } from "@dxos/log";
4176
4240
  import { WebsocketSignalManager } from "@dxos/messaging";
4177
4241
  import { ModelFactory } from "@dxos/model-factory";
4178
4242
  import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
4179
- import { trace as trace6 } from "@dxos/protocols";
4243
+ import { trace as trace7 } from "@dxos/protocols";
4180
4244
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
4181
4245
  import { TextModel } from "@dxos/text-model";
4246
+ import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
4182
4247
 
4183
4248
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
4184
4249
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
@@ -4438,7 +4503,7 @@ var SystemServiceImpl = class {
4438
4503
  };
4439
4504
 
4440
4505
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4441
- function _ts_decorate4(decorators, target, key, desc) {
4506
+ function _ts_decorate7(decorators, target, key, desc) {
4442
4507
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4443
4508
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4444
4509
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4452,7 +4517,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4452
4517
  var createDefaultModelFactory = () => {
4453
4518
  return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
4454
4519
  };
4455
- var ClientServicesHost = class {
4520
+ var ClientServicesHost = class ClientServicesHost2 {
4456
4521
  constructor({
4457
4522
  config,
4458
4523
  modelFactory = createDefaultModelFactory(),
@@ -4463,6 +4528,7 @@ var ClientServicesHost = class {
4463
4528
  lockKey,
4464
4529
  callbacks
4465
4530
  } = {}) {
4531
+ this._tracingService = TRACE_PROCESSOR.createTraceSender();
4466
4532
  this._statusUpdate = new Event8();
4467
4533
  this._opening = false;
4468
4534
  this._open = false;
@@ -4481,7 +4547,7 @@ var ClientServicesHost = class {
4481
4547
  lockKey,
4482
4548
  onAcquire: () => {
4483
4549
  if (!this._opening) {
4484
- void this.open();
4550
+ void this.open(new Context10());
4485
4551
  }
4486
4552
  },
4487
4553
  onRelease: () => this.close()
@@ -4508,7 +4574,8 @@ var ClientServicesHost = class {
4508
4574
  });
4509
4575
  this._loggingService = new LoggingServiceImpl();
4510
4576
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
4511
- SystemService: this._systemService
4577
+ SystemService: this._systemService,
4578
+ TracingService: this._tracingService
4512
4579
  });
4513
4580
  }
4514
4581
  get isOpen() {
@@ -4538,7 +4605,7 @@ var ClientServicesHost = class {
4538
4605
  var _a, _b, _c;
4539
4606
  invariant13(!this._open, "service host is open", {
4540
4607
  F: __dxlog_file17,
4541
- L: 172,
4608
+ L: 181,
4542
4609
  S: this,
4543
4610
  A: [
4544
4611
  "!this._open",
@@ -4547,14 +4614,14 @@ var ClientServicesHost = class {
4547
4614
  });
4548
4615
  log16.info("initializing...", void 0, {
4549
4616
  F: __dxlog_file17,
4550
- L: 173,
4617
+ L: 182,
4551
4618
  S: this,
4552
4619
  C: (f, a) => f(...a)
4553
4620
  });
4554
4621
  if (config) {
4555
4622
  invariant13(!this._config, "config already set", {
4556
4623
  F: __dxlog_file17,
4557
- L: 176,
4624
+ L: 185,
4558
4625
  S: this,
4559
4626
  A: [
4560
4627
  "!this._config",
@@ -4572,7 +4639,7 @@ var ClientServicesHost = class {
4572
4639
  this._signalManager = signalManager;
4573
4640
  invariant13(!this._networkManager, "network manager already set", {
4574
4641
  F: __dxlog_file17,
4575
- L: 192,
4642
+ L: 201,
4576
4643
  S: this,
4577
4644
  A: [
4578
4645
  "!this._networkManager",
@@ -4586,28 +4653,28 @@ var ClientServicesHost = class {
4586
4653
  });
4587
4654
  log16.info("initialized", void 0, {
4588
4655
  F: __dxlog_file17,
4589
- L: 199,
4656
+ L: 208,
4590
4657
  S: this,
4591
4658
  C: (f, a) => f(...a)
4592
4659
  });
4593
4660
  }
4594
- async open() {
4661
+ async open(ctx) {
4595
4662
  var _a, _b, _c;
4596
4663
  if (this._open) {
4597
4664
  return;
4598
4665
  }
4599
4666
  const traceId = PublicKey10.random().toHex();
4600
- log16.trace("dxos.client-services.host.open", trace6.begin({
4667
+ log16.trace("dxos.client-services.host.open", trace7.begin({
4601
4668
  id: traceId
4602
4669
  }), {
4603
4670
  F: __dxlog_file17,
4604
- L: 209,
4671
+ L: 219,
4605
4672
  S: this,
4606
4673
  C: (f, a) => f(...a)
4607
4674
  });
4608
4675
  invariant13(this._config, "config not set", {
4609
4676
  F: __dxlog_file17,
4610
- L: 211,
4677
+ L: 221,
4611
4678
  S: this,
4612
4679
  A: [
4613
4680
  "this._config",
@@ -4616,7 +4683,7 @@ var ClientServicesHost = class {
4616
4683
  });
4617
4684
  invariant13(this._storage, "storage not set", {
4618
4685
  F: __dxlog_file17,
4619
- L: 212,
4686
+ L: 222,
4620
4687
  S: this,
4621
4688
  A: [
4622
4689
  "this._storage",
@@ -4625,7 +4692,7 @@ var ClientServicesHost = class {
4625
4692
  });
4626
4693
  invariant13(this._signalManager, "signal manager not set", {
4627
4694
  F: __dxlog_file17,
4628
- L: 213,
4695
+ L: 223,
4629
4696
  S: this,
4630
4697
  A: [
4631
4698
  "this._signalManager",
@@ -4634,7 +4701,7 @@ var ClientServicesHost = class {
4634
4701
  });
4635
4702
  invariant13(this._networkManager, "network manager not set", {
4636
4703
  F: __dxlog_file17,
4637
- L: 214,
4704
+ L: 224,
4638
4705
  S: this,
4639
4706
  A: [
4640
4707
  "this._networkManager",
@@ -4646,7 +4713,7 @@ var ClientServicesHost = class {
4646
4713
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4647
4714
  }, {
4648
4715
  F: __dxlog_file17,
4649
- L: 217,
4716
+ L: 227,
4650
4717
  S: this,
4651
4718
  C: (f, a) => f(...a)
4652
4719
  });
@@ -4665,6 +4732,7 @@ var ClientServicesHost = class {
4665
4732
  DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4666
4733
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4667
4734
  LoggingService: this._loggingService,
4735
+ TracingService: this._tracingService,
4668
4736
  // TODO(burdon): Move to new protobuf definitions.
4669
4737
  DevtoolsHost: new DevtoolsServiceImpl({
4670
4738
  events: new DevtoolsHostEvents(),
@@ -4672,7 +4740,7 @@ var ClientServicesHost = class {
4672
4740
  context: this._serviceContext
4673
4741
  })
4674
4742
  });
4675
- await this._serviceContext.open();
4743
+ await this._serviceContext.open(ctx);
4676
4744
  this._opening = false;
4677
4745
  this._open = true;
4678
4746
  this._statusUpdate.emit();
@@ -4681,15 +4749,15 @@ var ClientServicesHost = class {
4681
4749
  deviceKey
4682
4750
  }, {
4683
4751
  F: __dxlog_file17,
4684
- L: 269,
4752
+ L: 280,
4685
4753
  S: this,
4686
4754
  C: (f, a) => f(...a)
4687
4755
  });
4688
- log16.trace("dxos.client-services.host.open", trace6.end({
4756
+ log16.trace("dxos.client-services.host.open", trace7.end({
4689
4757
  id: traceId
4690
4758
  }), {
4691
4759
  F: __dxlog_file17,
4692
- L: 270,
4760
+ L: 281,
4693
4761
  S: this,
4694
4762
  C: (f, a) => f(...a)
4695
4763
  });
@@ -4704,7 +4772,7 @@ var ClientServicesHost = class {
4704
4772
  deviceKey
4705
4773
  }, {
4706
4774
  F: __dxlog_file17,
4707
- L: 280,
4775
+ L: 292,
4708
4776
  S: this,
4709
4777
  C: (f, a) => f(...a)
4710
4778
  });
@@ -4719,7 +4787,7 @@ var ClientServicesHost = class {
4719
4787
  deviceKey
4720
4788
  }, {
4721
4789
  F: __dxlog_file17,
4722
- L: 286,
4790
+ L: 298,
4723
4791
  S: this,
4724
4792
  C: (f, a) => f(...a)
4725
4793
  });
@@ -4727,17 +4795,17 @@ var ClientServicesHost = class {
4727
4795
  async reset() {
4728
4796
  var _a, _b, _c;
4729
4797
  const traceId = PublicKey10.random().toHex();
4730
- log16.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4798
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
4731
4799
  id: traceId
4732
4800
  }), {
4733
4801
  F: __dxlog_file17,
4734
- L: 291,
4802
+ L: 303,
4735
4803
  S: this,
4736
4804
  C: (f, a) => f(...a)
4737
4805
  });
4738
4806
  log16("resetting...", void 0, {
4739
4807
  F: __dxlog_file17,
4740
- L: 293,
4808
+ L: 305,
4741
4809
  S: this,
4742
4810
  C: (f, a) => f(...a)
4743
4811
  });
@@ -4745,27 +4813,38 @@ var ClientServicesHost = class {
4745
4813
  await this._storage.reset();
4746
4814
  log16("reset", void 0, {
4747
4815
  F: __dxlog_file17,
4748
- L: 296,
4816
+ L: 308,
4749
4817
  S: this,
4750
4818
  C: (f, a) => f(...a)
4751
4819
  });
4752
- log16.trace("dxos.sdk.client-services-host.reset", trace6.end({
4820
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
4753
4821
  id: traceId
4754
4822
  }), {
4755
4823
  F: __dxlog_file17,
4756
- L: 297,
4824
+ L: 309,
4757
4825
  S: this,
4758
4826
  C: (f, a) => f(...a)
4759
4827
  });
4760
4828
  await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4761
4829
  }
4762
4830
  };
4763
- _ts_decorate4([
4764
- synchronized3
4831
+ _ts_decorate7([
4832
+ Trace3.info()
4833
+ ], ClientServicesHost.prototype, "_opening", void 0);
4834
+ _ts_decorate7([
4835
+ Trace3.info()
4836
+ ], ClientServicesHost.prototype, "_open", void 0);
4837
+ _ts_decorate7([
4838
+ synchronized3,
4839
+ Trace3.span()
4765
4840
  ], ClientServicesHost.prototype, "open", null);
4766
- _ts_decorate4([
4767
- synchronized3
4841
+ _ts_decorate7([
4842
+ synchronized3,
4843
+ Trace3.span()
4768
4844
  ], ClientServicesHost.prototype, "close", null);
4845
+ ClientServicesHost = _ts_decorate7([
4846
+ Trace3.resource()
4847
+ ], ClientServicesHost);
4769
4848
 
4770
4849
  export {
4771
4850
  subscribeToFeeds,
@@ -4800,4 +4879,4 @@ export {
4800
4879
  createDefaultModelFactory,
4801
4880
  ClientServicesHost
4802
4881
  };
4803
- //# sourceMappingURL=chunk-K67JOICT.mjs.map
4882
+ //# sourceMappingURL=chunk-ZOTHWLK5.mjs.map