@dxos/client-services 0.1.53 → 0.1.54-main.270ec56

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 (69) hide show
  1. package/dist/lib/browser/{chunk-6ITWCQIT.mjs → chunk-F4BHRFH4.mjs} +861 -702
  2. package/dist/lib/browser/chunk-F4BHRFH4.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +115 -173
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +24 -7
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +951 -853
  9. package/dist/lib/node/index.cjs.map +4 -4
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +832 -708
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/index.d.ts +1 -0
  16. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/service-host.d.ts +7 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
  22. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
  24. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  25. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  26. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  27. package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
  28. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  29. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
  30. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  31. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
  32. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  33. package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
  34. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  35. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  36. package/package.json +33 -32
  37. package/src/packlets/identity/authenticator.ts +4 -2
  38. package/src/packlets/identity/identity-manager.test.ts +1 -1
  39. package/src/packlets/identity/identity-manager.ts +8 -8
  40. package/src/packlets/identity/identity-service.ts +2 -2
  41. package/src/packlets/identity/identity.test.ts +1 -1
  42. package/src/packlets/identity/identity.ts +22 -27
  43. package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
  44. package/src/packlets/invitations/invitation-extension.ts +5 -5
  45. package/src/packlets/invitations/invitations-handler.ts +6 -6
  46. package/src/packlets/invitations/invitations-service.ts +3 -3
  47. package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
  48. package/src/packlets/locks/node.ts +2 -2
  49. package/src/packlets/logging/logging-service.ts +4 -4
  50. package/src/packlets/services/index.ts +1 -0
  51. package/src/packlets/services/service-context.test.ts +1 -1
  52. package/src/packlets/services/service-context.ts +12 -10
  53. package/src/packlets/services/service-host.test.ts +50 -2
  54. package/src/packlets/services/service-host.ts +25 -9
  55. package/src/packlets/spaces/data-space-manager.test.ts +75 -119
  56. package/src/packlets/spaces/data-space-manager.ts +18 -9
  57. package/src/packlets/spaces/data-space.ts +66 -20
  58. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  59. package/src/packlets/spaces/notarization-plugin.ts +9 -5
  60. package/src/packlets/spaces/spaces-service.test.ts +5 -3
  61. package/src/packlets/spaces/spaces-service.ts +26 -8
  62. package/src/packlets/testing/invitation-utils.ts +2 -2
  63. package/src/packlets/testing/test-builder.ts +36 -4
  64. package/src/packlets/vault/iframe-host-runtime.ts +2 -2
  65. package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
  66. package/src/packlets/vault/shell-runtime.ts +3 -49
  67. package/src/packlets/vault/worker-runtime.ts +1 -1
  68. package/src/packlets/vault/worker-session.ts +7 -6
  69. package/dist/lib/browser/chunk-6ITWCQIT.mjs.map +0 -7
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // packages/sdk/client-services/src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ ClientRpcServer: () => ClientRpcServer,
33
34
  ClientServicesHost: () => ClientServicesHost,
34
35
  DataSpace: () => DataSpace,
35
36
  DataSpaceManager: () => DataSpaceManager,
@@ -44,7 +45,6 @@ __export(src_exports, {
44
45
  InvitationsHandler: () => InvitationsHandler,
45
46
  InvitationsServiceImpl: () => InvitationsServiceImpl,
46
47
  Lock: () => Lock,
47
- MemoryShellRuntime: () => MemoryShellRuntime,
48
48
  ServiceContext: () => ServiceContext,
49
49
  ServiceRegistry: () => ServiceRegistry,
50
50
  ShellRuntimeImpl: () => ShellRuntimeImpl,
@@ -54,6 +54,7 @@ __export(src_exports, {
54
54
  WorkerRuntime: () => WorkerRuntime,
55
55
  WorkerSession: () => WorkerSession,
56
56
  createAuthProvider: () => createAuthProvider,
57
+ createDefaultModelFactory: () => createDefaultModelFactory,
57
58
  createStorageObjects: () => createStorageObjects,
58
59
  getNetworkPeers: () => getNetworkPeers,
59
60
  isLocked: () => isLocked,
@@ -419,6 +420,8 @@ var import_context2 = require("@dxos/context");
419
420
  var import_credentials = require("@dxos/credentials");
420
421
  var import_log = require("@dxos/log");
421
422
  var import_protocols = require("@dxos/protocols");
423
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
424
+ var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
422
425
  var createAuthProvider = (signer) => async (nonce) => {
423
426
  const credential = await signer.createCredential({
424
427
  assertion: {
@@ -427,7 +430,7 @@ var createAuthProvider = (signer) => async (nonce) => {
427
430
  subject: signer.getIssuer(),
428
431
  nonce
429
432
  });
430
- return import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").encode(credential);
433
+ return Credential.encode(credential);
431
434
  };
432
435
  var TrustedKeySetAuthVerifier = class {
433
436
  // prettier-ignore
@@ -440,24 +443,24 @@ var TrustedKeySetAuthVerifier = class {
440
443
  }
441
444
  get verifier() {
442
445
  return async (nonce, auth) => {
443
- const credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").decode(auth);
446
+ const credential = Credential.decode(auth);
444
447
  (0, import_log.log)("authenticating...", {
445
448
  credential
446
449
  }, {
447
- file: "authenticator.ts",
448
- line: 57,
449
- scope: this,
450
- callSite: (f, a) => f(...a)
450
+ F: __dxlog_file,
451
+ L: 59,
452
+ S: this,
453
+ C: (f, a) => f(...a)
451
454
  });
452
455
  const result = await (0, import_credentials.verifyCredential)(credential);
453
456
  if (result.kind === "fail") {
454
457
  (0, import_log.log)("Invalid credential", {
455
458
  result
456
459
  }, {
457
- file: "authenticator.ts",
458
- line: 61,
459
- scope: this,
460
- callSite: (f, a) => f(...a)
460
+ F: __dxlog_file,
461
+ L: 63,
462
+ S: this,
463
+ C: (f, a) => f(...a)
461
464
  });
462
465
  return false;
463
466
  }
@@ -466,10 +469,10 @@ var TrustedKeySetAuthVerifier = class {
466
469
  nonce,
467
470
  credential
468
471
  }, {
469
- file: "authenticator.ts",
470
- line: 66,
471
- scope: this,
472
- callSite: (f, a) => f(...a)
472
+ F: __dxlog_file,
473
+ L: 68,
474
+ S: this,
475
+ C: (f, a) => f(...a)
473
476
  });
474
477
  return false;
475
478
  }
@@ -477,10 +480,10 @@ var TrustedKeySetAuthVerifier = class {
477
480
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
478
481
  key: credential.issuer
479
482
  }, {
480
- file: "authenticator.ts",
481
- line: 71,
482
- scope: this,
483
- callSite: (f, a) => f(...a)
483
+ F: __dxlog_file,
484
+ L: 73,
485
+ S: this,
486
+ C: (f, a) => f(...a)
484
487
  });
485
488
  return true;
486
489
  }
@@ -493,20 +496,20 @@ var TrustedKeySetAuthVerifier = class {
493
496
  (0, import_log.log)("auth success", {
494
497
  key: credential.issuer
495
498
  }, {
496
- file: "authenticator.ts",
497
- line: 82,
498
- scope: this,
499
- callSite: (f, a) => f(...a)
499
+ F: __dxlog_file,
500
+ L: 84,
501
+ S: this,
502
+ C: (f, a) => f(...a)
500
503
  });
501
504
  trigger.wake(true);
502
505
  } else {
503
506
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
504
507
  key: credential.issuer
505
508
  }, {
506
- file: "authenticator.ts",
507
- line: 85,
508
- scope: this,
509
- callSite: (f, a) => f(...a)
509
+ F: __dxlog_file,
510
+ L: 87,
511
+ S: this,
512
+ C: (f, a) => f(...a)
510
513
  });
511
514
  }
512
515
  });
@@ -528,7 +531,7 @@ var TrustedKeySetAuthVerifier = class {
528
531
  };
529
532
 
530
533
  // packages/sdk/client-services/src/packlets/identity/identity.ts
531
- var import_node_assert = __toESM(require("node:assert"));
534
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
532
535
  var import_async5 = require("@dxos/async");
533
536
  var import_client_protocol = require("@dxos/client-protocol");
534
537
  var import_credentials2 = require("@dxos/credentials");
@@ -536,6 +539,7 @@ var import_debug = require("@dxos/debug");
536
539
  var import_feed_store2 = require("@dxos/feed-store");
537
540
  var import_log2 = require("@dxos/log");
538
541
  var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
542
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
539
543
  var Identity = class {
540
544
  constructor({ space, signer, identityKey, deviceKey }) {
541
545
  this.stateUpdate = new import_async5.Event();
@@ -543,15 +547,15 @@ var Identity = class {
543
547
  this._signer = signer;
544
548
  this.identityKey = identityKey;
545
549
  this.deviceKey = deviceKey;
546
- this._deviceStateMachine = this.space.spaceState.registerProcessor(new import_credentials2.DeviceStateMachine({
550
+ this._deviceStateMachine = new import_credentials2.DeviceStateMachine({
547
551
  identityKey: this.identityKey,
548
552
  deviceKey: this.deviceKey,
549
553
  onUpdate: () => this.stateUpdate.emit()
550
- }));
551
- this._profileStateMachine = this.space.spaceState.registerProcessor(new import_credentials2.ProfileStateMachine({
554
+ });
555
+ this._profileStateMachine = new import_credentials2.ProfileStateMachine({
552
556
  identityKey: this.identityKey,
553
557
  onUpdate: () => this.stateUpdate.emit()
554
- }));
558
+ });
555
559
  this.authVerifier = new TrustedKeySetAuthVerifier({
556
560
  trustedKeysProvider: () => this.authorizedDeviceKeys,
557
561
  update: this.stateUpdate,
@@ -560,27 +564,27 @@ var Identity = class {
560
564
  }
561
565
  // TODO(burdon): Expose state object?
562
566
  get authorizedDeviceKeys() {
563
- return this._deviceStateMachine.processor.authorizedDeviceKeys;
567
+ return this._deviceStateMachine.authorizedDeviceKeys;
564
568
  }
565
569
  async open() {
566
- await this._deviceStateMachine.open();
567
- await this._profileStateMachine.open();
570
+ await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
571
+ await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
568
572
  await this.space.open();
569
573
  }
570
574
  async close() {
571
575
  await this.authVerifier.close();
572
- await this._deviceStateMachine.close();
573
- await this._profileStateMachine.close();
576
+ await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
577
+ await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
574
578
  await this.space.close();
575
579
  }
576
580
  async ready() {
577
- await this._deviceStateMachine.processor.deviceChainReady.wait();
581
+ await this._deviceStateMachine.deviceChainReady.wait();
578
582
  await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
579
583
  timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
580
584
  });
581
585
  }
582
586
  get profileDocument() {
583
- return this._profileStateMachine.processor.profile;
587
+ return this._profileStateMachine.profile;
584
588
  }
585
589
  /**
586
590
  * @test-only
@@ -595,7 +599,7 @@ var Identity = class {
595
599
  return this.space.genesisFeedKey;
596
600
  }
597
601
  get deviceCredentialChain() {
598
- return this._deviceStateMachine.processor.deviceCredentialChain;
602
+ return this._deviceStateMachine.deviceCredentialChain;
599
603
  }
600
604
  getAdmissionCredentials() {
601
605
  var _a, _b;
@@ -610,8 +614,8 @@ var Identity = class {
610
614
  * Requires identity to be ready.
611
615
  */
612
616
  getIdentityCredentialSigner() {
613
- (0, import_node_assert.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
614
- return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
617
+ (0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
618
+ return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
615
619
  }
616
620
  /**
617
621
  * Issues credentials as device.
@@ -627,10 +631,10 @@ var Identity = class {
627
631
  controlFeedKey,
628
632
  dataFeedKey
629
633
  }, {
630
- file: "identity.ts",
631
- line: 156,
632
- scope: this,
633
- callSite: (f, a) => f(...a)
634
+ F: __dxlog_file2,
635
+ L: 151,
636
+ S: this,
637
+ C: (f, a) => f(...a)
634
638
  });
635
639
  const signer = this.getIdentityCredentialSigner();
636
640
  await (0, import_feed_store2.writeMessages)(this.controlPipeline.writer, [
@@ -671,7 +675,7 @@ var Identity = class {
671
675
  };
672
676
 
673
677
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
674
- var import_node_assert2 = __toESM(require("node:assert"));
678
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
675
679
  var import_async6 = require("@dxos/async");
676
680
  var import_credentials4 = require("@dxos/credentials");
677
681
  var import_keys4 = require("@dxos/keys");
@@ -679,6 +683,7 @@ var import_log3 = require("@dxos/log");
679
683
  var import_protocols2 = require("@dxos/protocols");
680
684
  var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
681
685
  var import_util2 = require("@dxos/util");
686
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
682
687
  var IdentityManager = class {
683
688
  // TODO(burdon): IdentityManagerParams.
684
689
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
@@ -698,20 +703,20 @@ var IdentityManager = class {
698
703
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
699
704
  id: traceId
700
705
  }), {
701
- file: "identity-manager.ts",
702
- line: 70,
703
- scope: this,
704
- callSite: (f, a) => f(...a)
706
+ F: __dxlog_file3,
707
+ L: 70,
708
+ S: this,
709
+ C: (f, a) => f(...a)
705
710
  });
706
711
  await this._metadataStore.load();
707
712
  const identityRecord = this._metadataStore.getIdentityRecord();
708
713
  (0, import_log3.log)("identity record", {
709
714
  identityRecord
710
715
  }, {
711
- file: "identity-manager.ts",
712
- line: 74,
713
- scope: this,
714
- callSite: (f, a) => f(...a)
716
+ F: __dxlog_file3,
717
+ L: 74,
718
+ S: this,
719
+ C: (f, a) => f(...a)
715
720
  });
716
721
  if (identityRecord) {
717
722
  this._identity = await this._constructIdentity(identityRecord);
@@ -721,20 +726,20 @@ var IdentityManager = class {
721
726
  identityKey: identityRecord.identityKey,
722
727
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
723
728
  }, {
724
- file: "identity-manager.ts",
725
- line: 79,
726
- scope: this,
727
- callSite: (f, a) => f(...a)
729
+ F: __dxlog_file3,
730
+ L: 79,
731
+ S: this,
732
+ C: (f, a) => f(...a)
728
733
  });
729
734
  this.stateUpdate.emit();
730
735
  }
731
736
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
732
737
  id: traceId
733
738
  }), {
734
- file: "identity-manager.ts",
735
- line: 85,
736
- scope: this,
737
- callSite: (f, a) => f(...a)
739
+ F: __dxlog_file3,
740
+ L: 85,
741
+ S: this,
742
+ C: (f, a) => f(...a)
738
743
  });
739
744
  }
740
745
  async close() {
@@ -743,12 +748,12 @@ var IdentityManager = class {
743
748
  }
744
749
  async createIdentity({ displayName } = {}) {
745
750
  var _a;
746
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
747
- (0, import_log3.log)("creating identity...", {}, {
748
- file: "identity-manager.ts",
749
- line: 94,
750
- scope: this,
751
- callSite: (f, a) => f(...a)
751
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
752
+ (0, import_log3.log)("creating identity...", void 0, {
753
+ F: __dxlog_file3,
754
+ L: 94,
755
+ S: this,
756
+ C: (f, a) => f(...a)
752
757
  });
753
758
  const controlFeedKey = await this._keyring.createKey();
754
759
  const identityRecord = {
@@ -765,8 +770,8 @@ var IdentityManager = class {
765
770
  await identity.open();
766
771
  {
767
772
  const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
768
- (0, import_node_assert2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
769
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
773
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
774
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
770
775
  const credentials = [
771
776
  // Space genesis.
772
777
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
@@ -794,20 +799,20 @@ var IdentityManager = class {
794
799
  identityKey: identityRecord.identityKey,
795
800
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
796
801
  }, {
797
- file: "identity-manager.ts",
798
- line: 149,
799
- scope: this,
800
- callSite: (f, a) => f(...a)
802
+ F: __dxlog_file3,
803
+ L: 149,
804
+ S: this,
805
+ C: (f, a) => f(...a)
801
806
  });
802
807
  this.stateUpdate.emit();
803
808
  (0, import_log3.log)("created identity", {
804
809
  identityKey: identity.identityKey,
805
810
  deviceKey: identity.deviceKey
806
811
  }, {
807
- file: "identity-manager.ts",
808
- line: 155,
809
- scope: this,
810
- callSite: (f, a) => f(...a)
812
+ F: __dxlog_file3,
813
+ L: 155,
814
+ S: this,
815
+ C: (f, a) => f(...a)
811
816
  });
812
817
  return identity;
813
818
  }
@@ -819,12 +824,12 @@ var IdentityManager = class {
819
824
  (0, import_log3.log)("accepting identity", {
820
825
  params
821
826
  }, {
822
- file: "identity-manager.ts",
823
- line: 163,
824
- scope: this,
825
- callSite: (f, a) => f(...a)
827
+ F: __dxlog_file3,
828
+ L: 163,
829
+ S: this,
830
+ C: (f, a) => f(...a)
826
831
  });
827
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
832
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
828
833
  const identityRecord = {
829
834
  identityKey: params.identityKey,
830
835
  deviceKey: params.deviceKey,
@@ -845,38 +850,38 @@ var IdentityManager = class {
845
850
  identityKey: identityRecord.identityKey,
846
851
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
847
852
  }, {
848
- file: "identity-manager.ts",
849
- line: 183,
850
- scope: this,
851
- callSite: (f, a) => f(...a)
853
+ F: __dxlog_file3,
854
+ L: 183,
855
+ S: this,
856
+ C: (f, a) => f(...a)
852
857
  });
853
858
  this.stateUpdate.emit();
854
859
  (0, import_log3.log)("accepted identity", {
855
860
  identityKey: identity.identityKey,
856
861
  deviceKey: identity.deviceKey
857
862
  }, {
858
- file: "identity-manager.ts",
859
- line: 189,
860
- scope: this,
861
- callSite: (f, a) => f(...a)
863
+ F: __dxlog_file3,
864
+ L: 189,
865
+ S: this,
866
+ C: (f, a) => f(...a)
862
867
  });
863
868
  return identity;
864
869
  }
865
870
  async _constructIdentity(identityRecord) {
866
- (0, import_node_assert2.default)(!this._identity);
871
+ (0, import_tiny_invariant2.default)(!this._identity);
867
872
  (0, import_log3.log)("constructing identity", {
868
873
  identityRecord
869
874
  }, {
870
- file: "identity-manager.ts",
871
- line: 195,
872
- scope: this,
873
- callSite: (f, a) => f(...a)
875
+ F: __dxlog_file3,
876
+ L: 195,
877
+ S: this,
878
+ C: (f, a) => f(...a)
874
879
  });
875
- (0, import_node_assert2.default)(identityRecord.haloSpace.controlFeedKey);
880
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
876
881
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
877
882
  writable: true
878
883
  });
879
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey);
884
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
880
885
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
881
886
  writable: true,
882
887
  sparse: true
@@ -901,10 +906,10 @@ var IdentityManager = class {
901
906
  (0, import_log3.log)("done", {
902
907
  identityKey: identityRecord.identityKey
903
908
  }, {
904
- file: "identity-manager.ts",
905
- line: 226,
906
- scope: this,
907
- callSite: (f, a) => f(...a)
909
+ F: __dxlog_file3,
910
+ L: 226,
911
+ S: this,
912
+ C: (f, a) => f(...a)
908
913
  });
909
914
  if (identityRecord.haloSpace.controlTimeframe) {
910
915
  identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
@@ -921,11 +926,11 @@ var IdentityManager = class {
921
926
  onNetworkConnection: () => {
922
927
  },
923
928
  onAuthFailure: () => {
924
- import_log3.log.warn("auth failure", {}, {
925
- file: "identity-manager.ts",
926
- line: 245,
927
- scope: this,
928
- callSite: (f, a) => f(...a)
929
+ import_log3.log.warn("auth failure", void 0, {
930
+ F: __dxlog_file3,
931
+ L: 245,
932
+ S: this,
933
+ C: (f, a) => f(...a)
929
934
  });
930
935
  },
931
936
  memberKey: identityKey
@@ -934,7 +939,7 @@ var IdentityManager = class {
934
939
  };
935
940
 
936
941
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
937
- var import_node_assert3 = __toESM(require("node:assert"));
942
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
938
943
  var import_codec_protobuf7 = require("@dxos/codec-protobuf");
939
944
  var import_credentials6 = require("@dxos/credentials");
940
945
  var import_debug2 = require("@dxos/debug");
@@ -970,7 +975,7 @@ var IdentityServiceImpl = class {
970
975
  };
971
976
  }
972
977
  async signPresentation({ presentation, nonce }) {
973
- (0, import_node_assert3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
978
+ (0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
974
979
  return await (0, import_credentials6.signPresentation)({
975
980
  presentation,
976
981
  signer: this._serviceContext.keyring,
@@ -982,7 +987,7 @@ var IdentityServiceImpl = class {
982
987
  };
983
988
 
984
989
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
985
- var import_node_assert4 = __toESM(require("node:assert"));
990
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
986
991
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
987
992
  var DeviceInvitationProtocol = class {
988
993
  constructor(_keyring, _getIdentity, _acceptIdentity) {
@@ -999,7 +1004,7 @@ var DeviceInvitationProtocol = class {
999
1004
  };
1000
1005
  }
1001
1006
  async admit(request) {
1002
- (0, import_node_assert4.default)(request.device);
1007
+ (0, import_tiny_invariant4.default)(request.device);
1003
1008
  const identity = this._getIdentity();
1004
1009
  await identity.admitDevice(request.device);
1005
1010
  return {
@@ -1027,9 +1032,9 @@ var DeviceInvitationProtocol = class {
1027
1032
  };
1028
1033
  }
1029
1034
  async accept(response, request) {
1030
- (0, import_node_assert4.default)(response.device);
1035
+ (0, import_tiny_invariant4.default)(response.device);
1031
1036
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1032
- (0, import_node_assert4.default)(request.device);
1037
+ (0, import_tiny_invariant4.default)(request.device);
1033
1038
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
1034
1039
  await this._acceptIdentity({
1035
1040
  identityKey,
@@ -1047,7 +1052,7 @@ var DeviceInvitationProtocol = class {
1047
1052
  };
1048
1053
 
1049
1054
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1050
- var import_node_assert6 = __toESM(require("node:assert"));
1055
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1051
1056
  var import_async8 = require("@dxos/async");
1052
1057
  var import_client_protocol2 = require("@dxos/client-protocol");
1053
1058
  var import_context4 = require("@dxos/context");
@@ -1061,7 +1066,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1061
1066
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
1062
1067
 
1063
1068
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1064
- var import_node_assert5 = __toESM(require("node:assert"));
1069
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
1065
1070
  var import_async7 = require("@dxos/async");
1066
1071
  var import_context3 = require("@dxos/context");
1067
1072
  var import_errors = require("@dxos/errors");
@@ -1071,6 +1076,7 @@ var import_protocols3 = require("@dxos/protocols");
1071
1076
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
1072
1077
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
1073
1078
  var import_teleport = require("@dxos/teleport");
1079
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1074
1080
  var OPTIONS_TIMEOUT = 1e4;
1075
1081
  var MAX_OTP_ATTEMPTS = 3;
1076
1082
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
@@ -1098,7 +1104,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1098
1104
  // Perhaps in the future we will have more complex logic here.
1099
1105
  InvitationHostService: {
1100
1106
  options: async (options) => {
1101
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
1107
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1102
1108
  this._remoteOptions = options;
1103
1109
  this._remoteOptionsTrigger.wake();
1104
1110
  },
@@ -1108,20 +1114,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1108
1114
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1109
1115
  id: traceId
1110
1116
  }), {
1111
- file: "invitation-extension.ts",
1112
- line: 98,
1113
- scope: this,
1114
- callSite: (f, a) => f(...a)
1117
+ F: __dxlog_file4,
1118
+ L: 98,
1119
+ S: this,
1120
+ C: (f, a) => f(...a)
1115
1121
  });
1116
1122
  const invitation = await this._callbacks.resolveInvitation(request);
1117
1123
  if (!invitation) {
1118
1124
  import_log4.log.warn("invitation not found", {
1119
1125
  invitationId
1120
1126
  }, {
1121
- file: "invitation-extension.ts",
1122
- line: 102,
1123
- scope: this,
1124
- callSite: (f, a) => f(...a)
1127
+ F: __dxlog_file4,
1128
+ L: 102,
1129
+ S: this,
1130
+ C: (f, a) => f(...a)
1125
1131
  });
1126
1132
  this._callbacks.onError(new Error("Invitation not found."));
1127
1133
  return {
@@ -1132,10 +1138,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1132
1138
  (0, import_log4.log)("guest introduced itself", {
1133
1139
  guestProfile: profile
1134
1140
  }, {
1135
- file: "invitation-extension.ts",
1136
- line: 111,
1137
- scope: this,
1138
- callSite: (f, a) => f(...a)
1141
+ F: __dxlog_file4,
1142
+ L: 111,
1143
+ S: this,
1144
+ C: (f, a) => f(...a)
1139
1145
  });
1140
1146
  this.guestProfile = profile;
1141
1147
  this._callbacks.onStateUpdate({
@@ -1145,10 +1151,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1145
1151
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1146
1152
  id: traceId
1147
1153
  }), {
1148
- file: "invitation-extension.ts",
1149
- line: 118,
1150
- scope: this,
1151
- callSite: (f, a) => f(...a)
1154
+ F: __dxlog_file4,
1155
+ L: 118,
1156
+ S: this,
1157
+ C: (f, a) => f(...a)
1152
1158
  });
1153
1159
  return {
1154
1160
  spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
@@ -1160,28 +1166,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1160
1166
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1161
1167
  id: traceId
1162
1168
  }), {
1163
- file: "invitation-extension.ts",
1164
- line: 127,
1165
- scope: this,
1166
- callSite: (f, a) => f(...a)
1169
+ F: __dxlog_file4,
1170
+ L: 127,
1171
+ S: this,
1172
+ C: (f, a) => f(...a)
1167
1173
  });
1168
1174
  (0, import_log4.log)("received authentication request", {
1169
1175
  authCode: code
1170
1176
  }, {
1171
- file: "invitation-extension.ts",
1172
- line: 128,
1173
- scope: this,
1174
- callSite: (f, a) => f(...a)
1177
+ F: __dxlog_file4,
1178
+ L: 128,
1179
+ S: this,
1180
+ C: (f, a) => f(...a)
1175
1181
  });
1176
1182
  let status = import_invitations.AuthenticationResponse.Status.OK;
1177
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1183
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1178
1184
  switch (this.invitation.authMethod) {
1179
1185
  case import_services2.Invitation.AuthMethod.NONE: {
1180
- (0, import_log4.log)("authentication not required", {}, {
1181
- file: "invitation-extension.ts",
1182
- line: 134,
1183
- scope: this,
1184
- callSite: (f, a) => f(...a)
1186
+ (0, import_log4.log)("authentication not required", void 0, {
1187
+ F: __dxlog_file4,
1188
+ L: 134,
1189
+ S: this,
1190
+ C: (f, a) => f(...a)
1185
1191
  });
1186
1192
  return {
1187
1193
  status: import_invitations.AuthenticationResponse.Status.OK
@@ -1203,10 +1209,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1203
1209
  import_log4.log.error("invalid authentication method", {
1204
1210
  authMethod: this.invitation.authMethod
1205
1211
  }, {
1206
- file: "invitation-extension.ts",
1207
- line: 152,
1208
- scope: this,
1209
- callSite: (f, a) => f(...a)
1212
+ F: __dxlog_file4,
1213
+ L: 152,
1214
+ S: this,
1215
+ C: (f, a) => f(...a)
1210
1216
  });
1211
1217
  status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
1212
1218
  break;
@@ -1218,10 +1224,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1218
1224
  status
1219
1225
  }
1220
1226
  }), {
1221
- file: "invitation-extension.ts",
1222
- line: 158,
1223
- scope: this,
1224
- callSite: (f, a) => f(...a)
1227
+ F: __dxlog_file4,
1228
+ L: 158,
1229
+ S: this,
1230
+ C: (f, a) => f(...a)
1225
1231
  });
1226
1232
  return {
1227
1233
  status
@@ -1232,13 +1238,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1232
1238
  import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
1233
1239
  id: traceId
1234
1240
  }), {
1235
- file: "invitation-extension.ts",
1236
- line: 164,
1237
- scope: this,
1238
- callSite: (f, a) => f(...a)
1241
+ F: __dxlog_file4,
1242
+ L: 164,
1243
+ S: this,
1244
+ C: (f, a) => f(...a)
1239
1245
  });
1240
1246
  try {
1241
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1247
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1242
1248
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1243
1249
  throw new Error("Not authenticated");
1244
1250
  }
@@ -1246,10 +1252,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1246
1252
  import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1247
1253
  id: traceId
1248
1254
  }), {
1249
- file: "invitation-extension.ts",
1250
- line: 175,
1251
- scope: this,
1252
- callSite: (f, a) => f(...a)
1255
+ F: __dxlog_file4,
1256
+ L: 175,
1257
+ S: this,
1258
+ C: (f, a) => f(...a)
1253
1259
  });
1254
1260
  return response;
1255
1261
  } catch (err) {
@@ -1303,7 +1309,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1303
1309
  return {
1304
1310
  InvitationHostService: {
1305
1311
  options: async (options) => {
1306
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
1312
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1307
1313
  this._remoteOptions = options;
1308
1314
  this._remoteOptionsTrigger.wake();
1309
1315
  },
@@ -1323,11 +1329,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1323
1329
  var _a;
1324
1330
  await super.onOpen(context);
1325
1331
  try {
1326
- (0, import_log4.log)("begin options", {}, {
1327
- file: "invitation-extension.ts",
1328
- line: 263,
1329
- scope: this,
1330
- callSite: (f, a) => f(...a)
1332
+ (0, import_log4.log)("begin options", void 0, {
1333
+ F: __dxlog_file4,
1334
+ L: 263,
1335
+ S: this,
1336
+ C: (f, a) => f(...a)
1331
1337
  });
1332
1338
  await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1333
1339
  role: import_invitations.Options.Role.GUEST
@@ -1335,11 +1341,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1335
1341
  await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1336
1342
  timeout: OPTIONS_TIMEOUT
1337
1343
  }));
1338
- (0, import_log4.log)("end options", {}, {
1339
- file: "invitation-extension.ts",
1340
- line: 266,
1341
- scope: this,
1342
- callSite: (f, a) => f(...a)
1344
+ (0, import_log4.log)("end options", void 0, {
1345
+ F: __dxlog_file4,
1346
+ L: 266,
1347
+ S: this,
1348
+ C: (f, a) => f(...a)
1343
1349
  });
1344
1350
  if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
1345
1351
  throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
@@ -1350,20 +1356,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1350
1356
  this._callbacks.onOpen(this._ctx);
1351
1357
  } catch (err) {
1352
1358
  (0, import_log4.log)("openError", err, {
1353
- file: "invitation-extension.ts",
1354
- line: 276,
1355
- scope: this,
1356
- callSite: (f, a) => f(...a)
1359
+ F: __dxlog_file4,
1360
+ L: 276,
1361
+ S: this,
1362
+ C: (f, a) => f(...a)
1357
1363
  });
1358
1364
  this._callbacks.onError(err);
1359
1365
  }
1360
1366
  }
1361
1367
  async onClose() {
1362
- (0, import_log4.log)("onClose", {}, {
1363
- file: "invitation-extension.ts",
1364
- line: 282,
1365
- scope: this,
1366
- callSite: (f, a) => f(...a)
1368
+ (0, import_log4.log)("onClose", void 0, {
1369
+ F: __dxlog_file4,
1370
+ L: 282,
1371
+ S: this,
1372
+ C: (f, a) => f(...a)
1367
1373
  });
1368
1374
  await this._ctx.dispose();
1369
1375
  }
@@ -1371,6 +1377,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1371
1377
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1372
1378
 
1373
1379
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1380
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1374
1381
  var InvitationsHandler = class {
1375
1382
  /**
1376
1383
  * @internal
@@ -1382,7 +1389,7 @@ var InvitationsHandler = class {
1382
1389
  var _a;
1383
1390
  const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
1384
1391
  const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1385
- (0, import_node_assert6.default)(protocol);
1392
+ (0, import_tiny_invariant6.default)(protocol);
1386
1393
  const invitation = {
1387
1394
  invitationId,
1388
1395
  type,
@@ -1404,10 +1411,10 @@ var InvitationsHandler = class {
1404
1411
  (0, import_log5.log)("complete", {
1405
1412
  ...protocol.toJSON()
1406
1413
  }, {
1407
- file: "invitations-handler.ts",
1408
- line: 99,
1409
- scope: this,
1410
- callSite: (f, a) => f(...a)
1414
+ F: __dxlog_file5,
1415
+ L: 99,
1416
+ S: this,
1417
+ C: (f, a) => f(...a)
1411
1418
  });
1412
1419
  stream.complete();
1413
1420
  });
@@ -1429,7 +1436,7 @@ var InvitationsHandler = class {
1429
1436
  var _a2, _b, _c;
1430
1437
  try {
1431
1438
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1432
- (0, import_node_assert6.default)(deviceKey);
1439
+ (0, import_tiny_invariant6.default)(deviceKey);
1433
1440
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1434
1441
  extension.completedTrigger.wake(deviceKey);
1435
1442
  return admissionResponse;
@@ -1445,18 +1452,18 @@ var InvitationsHandler = class {
1445
1452
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
1446
1453
  id: traceId
1447
1454
  }), {
1448
- file: "invitations-handler.ts",
1449
- line: 138,
1450
- scope: this,
1451
- callSite: (f, a) => f(...a)
1455
+ F: __dxlog_file5,
1456
+ L: 138,
1457
+ S: this,
1458
+ C: (f, a) => f(...a)
1452
1459
  });
1453
1460
  (0, import_log5.log)("connected", {
1454
1461
  ...protocol.toJSON()
1455
1462
  }, {
1456
- file: "invitations-handler.ts",
1457
- line: 139,
1458
- scope: this,
1459
- callSite: (f, a) => f(...a)
1463
+ F: __dxlog_file5,
1464
+ L: 139,
1465
+ S: this,
1466
+ C: (f, a) => f(...a)
1460
1467
  });
1461
1468
  stream.next({
1462
1469
  ...invitation,
@@ -1469,10 +1476,10 @@ var InvitationsHandler = class {
1469
1476
  guest: deviceKey,
1470
1477
  ...protocol.toJSON()
1471
1478
  }, {
1472
- file: "invitations-handler.ts",
1473
- line: 142,
1474
- scope: this,
1475
- callSite: (f, a) => f(...a)
1479
+ F: __dxlog_file5,
1480
+ L: 142,
1481
+ S: this,
1482
+ C: (f, a) => f(...a)
1476
1483
  });
1477
1484
  stream.next({
1478
1485
  ...invitation,
@@ -1481,20 +1488,20 @@ var InvitationsHandler = class {
1481
1488
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1482
1489
  id: traceId
1483
1490
  }), {
1484
- file: "invitations-handler.ts",
1485
- line: 144,
1486
- scope: this,
1487
- callSite: (f, a) => f(...a)
1491
+ F: __dxlog_file5,
1492
+ L: 144,
1493
+ S: this,
1494
+ C: (f, a) => f(...a)
1488
1495
  });
1489
1496
  } catch (err) {
1490
1497
  if (err instanceof import_async8.TimeoutError) {
1491
1498
  (0, import_log5.log)("timeout", {
1492
1499
  ...protocol.toJSON()
1493
1500
  }, {
1494
- file: "invitations-handler.ts",
1495
- line: 147,
1496
- scope: this,
1497
- callSite: (f, a) => f(...a)
1501
+ F: __dxlog_file5,
1502
+ L: 147,
1503
+ S: this,
1504
+ C: (f, a) => f(...a)
1498
1505
  });
1499
1506
  stream.next({
1500
1507
  ...invitation,
@@ -1502,10 +1509,10 @@ var InvitationsHandler = class {
1502
1509
  });
1503
1510
  } else {
1504
1511
  import_log5.log.error("failed", err, {
1505
- file: "invitations-handler.ts",
1506
- line: 150,
1507
- scope: this,
1508
- callSite: (f, a) => f(...a)
1512
+ F: __dxlog_file5,
1513
+ L: 150,
1514
+ S: this,
1515
+ C: (f, a) => f(...a)
1509
1516
  });
1510
1517
  stream.error(err);
1511
1518
  }
@@ -1513,10 +1520,10 @@ var InvitationsHandler = class {
1513
1520
  id: traceId,
1514
1521
  error: err
1515
1522
  }), {
1516
- file: "invitations-handler.ts",
1517
- line: 153,
1518
- scope: this,
1519
- callSite: (f, a) => f(...a)
1523
+ F: __dxlog_file5,
1524
+ L: 153,
1525
+ S: this,
1526
+ C: (f, a) => f(...a)
1520
1527
  });
1521
1528
  } finally {
1522
1529
  if (type !== import_services3.Invitation.Type.MULTIUSE) {
@@ -1534,10 +1541,10 @@ var InvitationsHandler = class {
1534
1541
  (0, import_log5.log)("timeout", {
1535
1542
  ...protocol.toJSON()
1536
1543
  }, {
1537
- file: "invitations-handler.ts",
1538
- line: 168,
1539
- scope: this,
1540
- callSite: (f, a) => f(...a)
1544
+ F: __dxlog_file5,
1545
+ L: 168,
1546
+ S: this,
1547
+ C: (f, a) => f(...a)
1541
1548
  });
1542
1549
  stream.next({
1543
1550
  ...invitation,
@@ -1545,10 +1552,10 @@ var InvitationsHandler = class {
1545
1552
  });
1546
1553
  } else {
1547
1554
  import_log5.log.error("failed", err, {
1548
- file: "invitations-handler.ts",
1549
- line: 171,
1550
- scope: this,
1551
- callSite: (f, a) => f(...a)
1555
+ F: __dxlog_file5,
1556
+ L: 171,
1557
+ S: this,
1558
+ C: (f, a) => f(...a)
1552
1559
  });
1553
1560
  stream.error(err);
1554
1561
  }
@@ -1588,13 +1595,13 @@ var InvitationsHandler = class {
1588
1595
  }
1589
1596
  acceptInvitation(protocol, invitation) {
1590
1597
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1591
- (0, import_node_assert6.default)(protocol);
1598
+ (0, import_tiny_invariant6.default)(protocol);
1592
1599
  const authenticated = new import_async8.Trigger();
1593
1600
  let admitted = false;
1594
1601
  let currentState;
1595
1602
  const stream = new import_async8.PushStream();
1596
1603
  const setState = (newData) => {
1597
- (0, import_node_assert6.default)(newData.state !== void 0);
1604
+ (0, import_tiny_invariant6.default)(newData.state !== void 0);
1598
1605
  currentState = newData.state;
1599
1606
  stream.next({
1600
1607
  ...invitation,
@@ -1607,20 +1614,20 @@ var InvitationsHandler = class {
1607
1614
  (0, import_log5.log)("timeout", {
1608
1615
  ...protocol.toJSON()
1609
1616
  }, {
1610
- file: "invitations-handler.ts",
1611
- line: 230,
1612
- scope: this,
1613
- callSite: (f, a) => f(...a)
1617
+ F: __dxlog_file5,
1618
+ L: 230,
1619
+ S: this,
1620
+ C: (f, a) => f(...a)
1614
1621
  });
1615
1622
  setState({
1616
1623
  state: import_services3.Invitation.State.TIMEOUT
1617
1624
  });
1618
1625
  } else {
1619
1626
  import_log5.log.warn("auth failed", err, {
1620
- file: "invitations-handler.ts",
1621
- line: 233,
1622
- scope: this,
1623
- callSite: (f, a) => f(...a)
1627
+ F: __dxlog_file5,
1628
+ L: 233,
1629
+ S: this,
1630
+ C: (f, a) => f(...a)
1624
1631
  });
1625
1632
  stream.error(err);
1626
1633
  }
@@ -1631,10 +1638,10 @@ var InvitationsHandler = class {
1631
1638
  (0, import_log5.log)("complete", {
1632
1639
  ...protocol.toJSON()
1633
1640
  }, {
1634
- file: "invitations-handler.ts",
1635
- line: 241,
1636
- scope: this,
1637
- callSite: (f, a) => f(...a)
1641
+ F: __dxlog_file5,
1642
+ L: 241,
1643
+ S: this,
1644
+ C: (f, a) => f(...a)
1638
1645
  });
1639
1646
  stream.complete();
1640
1647
  });
@@ -1646,10 +1653,10 @@ var InvitationsHandler = class {
1646
1653
  (0, import_log5.log)("extension disposed", {
1647
1654
  currentState
1648
1655
  }, {
1649
- file: "invitations-handler.ts",
1650
- line: 251,
1651
- scope: this,
1652
- callSite: (f, a) => f(...a)
1656
+ F: __dxlog_file5,
1657
+ L: 251,
1658
+ S: this,
1659
+ C: (f, a) => f(...a)
1653
1660
  });
1654
1661
  if (!admitted) {
1655
1662
  stream.error(new Error("Remote peer disconnected."));
@@ -1661,10 +1668,10 @@ var InvitationsHandler = class {
1661
1668
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
1662
1669
  id: traceId
1663
1670
  }), {
1664
- file: "invitations-handler.ts",
1665
- line: 260,
1666
- scope: this,
1667
- callSite: (f, a) => f(...a)
1671
+ F: __dxlog_file5,
1672
+ L: 260,
1673
+ S: this,
1674
+ C: (f, a) => f(...a)
1668
1675
  });
1669
1676
  if (++connectionCount > 1) {
1670
1677
  throw new Error(`multiple connections detected: ${connectionCount}`);
@@ -1673,10 +1680,10 @@ var InvitationsHandler = class {
1673
1680
  (0, import_log5.log)("connected", {
1674
1681
  ...protocol.toJSON()
1675
1682
  }, {
1676
- file: "invitations-handler.ts",
1677
- line: 268,
1678
- scope: this,
1679
- callSite: (f, a) => f(...a)
1683
+ F: __dxlog_file5,
1684
+ L: 268,
1685
+ S: this,
1686
+ C: (f, a) => f(...a)
1680
1687
  });
1681
1688
  setState({
1682
1689
  state: import_services3.Invitation.State.CONNECTED
@@ -1684,20 +1691,20 @@ var InvitationsHandler = class {
1684
1691
  (0, import_log5.log)("introduce", {
1685
1692
  ...protocol.toJSON()
1686
1693
  }, {
1687
- file: "invitations-handler.ts",
1688
- line: 272,
1689
- scope: this,
1690
- callSite: (f, a) => f(...a)
1694
+ F: __dxlog_file5,
1695
+ L: 272,
1696
+ S: this,
1697
+ C: (f, a) => f(...a)
1691
1698
  });
1692
1699
  const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
1693
1700
  (0, import_log5.log)("introduce response", {
1694
1701
  ...protocol.toJSON(),
1695
1702
  response: introductionResponse
1696
1703
  }, {
1697
- file: "invitations-handler.ts",
1698
- line: 276,
1699
- scope: this,
1700
- callSite: (f, a) => f(...a)
1704
+ F: __dxlog_file5,
1705
+ L: 276,
1706
+ S: this,
1707
+ C: (f, a) => f(...a)
1701
1708
  });
1702
1709
  invitation.authMethod = introductionResponse.authMethod;
1703
1710
  if (introductionResponse.spaceKey) {
@@ -1705,11 +1712,11 @@ var InvitationsHandler = class {
1705
1712
  }
1706
1713
  if (isAuthenticationRequired(invitation)) {
1707
1714
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1708
- (0, import_log5.log)("guest waiting for authentication code...", {}, {
1709
- file: "invitations-handler.ts",
1710
- line: 285,
1711
- scope: this,
1712
- callSite: (f, a) => f(...a)
1715
+ (0, import_log5.log)("guest waiting for authentication code...", void 0, {
1716
+ F: __dxlog_file5,
1717
+ L: 285,
1718
+ S: this,
1719
+ C: (f, a) => f(...a)
1713
1720
  });
1714
1721
  setState({
1715
1722
  state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
@@ -1717,11 +1724,11 @@ var InvitationsHandler = class {
1717
1724
  const authCode = await authenticated.wait({
1718
1725
  timeout
1719
1726
  });
1720
- (0, import_log5.log)("sending authentication request", {}, {
1721
- file: "invitations-handler.ts",
1722
- line: 289,
1723
- scope: this,
1724
- callSite: (f, a) => f(...a)
1727
+ (0, import_log5.log)("sending authentication request", void 0, {
1728
+ F: __dxlog_file5,
1729
+ L: 289,
1730
+ S: this,
1731
+ C: (f, a) => f(...a)
1725
1732
  });
1726
1733
  setState({
1727
1734
  state: import_services3.Invitation.State.AUTHENTICATING
@@ -1739,10 +1746,10 @@ var InvitationsHandler = class {
1739
1746
  (0, import_log5.log)("retrying invalid code", {
1740
1747
  attempt
1741
1748
  }, {
1742
- file: "invitations-handler.ts",
1743
- line: 300,
1744
- scope: this,
1745
- callSite: (f, a) => f(...a)
1749
+ F: __dxlog_file5,
1750
+ L: 300,
1751
+ S: this,
1752
+ C: (f, a) => f(...a)
1746
1753
  });
1747
1754
  authenticated.reset();
1748
1755
  }
@@ -1756,10 +1763,10 @@ var InvitationsHandler = class {
1756
1763
  (0, import_log5.log)("request admission", {
1757
1764
  ...protocol.toJSON()
1758
1765
  }, {
1759
- file: "invitations-handler.ts",
1760
- line: 311,
1761
- scope: this,
1762
- callSite: (f, a) => f(...a)
1766
+ F: __dxlog_file5,
1767
+ L: 311,
1768
+ S: this,
1769
+ C: (f, a) => f(...a)
1763
1770
  });
1764
1771
  const admissionRequest = await protocol.createAdmissionRequest();
1765
1772
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
@@ -1768,10 +1775,10 @@ var InvitationsHandler = class {
1768
1775
  (0, import_log5.log)("admitted by host", {
1769
1776
  ...protocol.toJSON()
1770
1777
  }, {
1771
- file: "invitations-handler.ts",
1772
- line: 322,
1773
- scope: this,
1774
- callSite: (f, a) => f(...a)
1778
+ F: __dxlog_file5,
1779
+ L: 322,
1780
+ S: this,
1781
+ C: (f, a) => f(...a)
1775
1782
  });
1776
1783
  setState({
1777
1784
  ...result,
@@ -1780,30 +1787,30 @@ var InvitationsHandler = class {
1780
1787
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1781
1788
  id: traceId
1782
1789
  }), {
1783
- file: "invitations-handler.ts",
1784
- line: 324,
1785
- scope: this,
1786
- callSite: (f, a) => f(...a)
1790
+ F: __dxlog_file5,
1791
+ L: 324,
1792
+ S: this,
1793
+ C: (f, a) => f(...a)
1787
1794
  });
1788
1795
  } catch (err) {
1789
1796
  if (err instanceof import_async8.TimeoutError) {
1790
1797
  (0, import_log5.log)("timeout", {
1791
1798
  ...protocol.toJSON()
1792
1799
  }, {
1793
- file: "invitations-handler.ts",
1794
- line: 327,
1795
- scope: this,
1796
- callSite: (f, a) => f(...a)
1800
+ F: __dxlog_file5,
1801
+ L: 327,
1802
+ S: this,
1803
+ C: (f, a) => f(...a)
1797
1804
  });
1798
1805
  setState({
1799
1806
  state: import_services3.Invitation.State.TIMEOUT
1800
1807
  });
1801
1808
  } else {
1802
1809
  (0, import_log5.log)("auth failed", err, {
1803
- file: "invitations-handler.ts",
1804
- line: 330,
1805
- scope: this,
1806
- callSite: (f, a) => f(...a)
1810
+ F: __dxlog_file5,
1811
+ L: 330,
1812
+ S: this,
1813
+ C: (f, a) => f(...a)
1807
1814
  });
1808
1815
  stream.error(err);
1809
1816
  }
@@ -1811,10 +1818,10 @@ var InvitationsHandler = class {
1811
1818
  id: traceId,
1812
1819
  error: err
1813
1820
  }), {
1814
- file: "invitations-handler.ts",
1815
- line: 333,
1816
- scope: this,
1817
- callSite: (f, a) => f(...a)
1821
+ F: __dxlog_file5,
1822
+ L: 333,
1823
+ S: this,
1824
+ C: (f, a) => f(...a)
1818
1825
  });
1819
1826
  } finally {
1820
1827
  await ctx.dispose();
@@ -1829,20 +1836,20 @@ var InvitationsHandler = class {
1829
1836
  (0, import_log5.log)("timeout", {
1830
1837
  ...protocol.toJSON()
1831
1838
  }, {
1832
- file: "invitations-handler.ts",
1833
- line: 344,
1834
- scope: this,
1835
- callSite: (f, a) => f(...a)
1839
+ F: __dxlog_file5,
1840
+ L: 344,
1841
+ S: this,
1842
+ C: (f, a) => f(...a)
1836
1843
  });
1837
1844
  setState({
1838
1845
  state: import_services3.Invitation.State.TIMEOUT
1839
1846
  });
1840
1847
  } else {
1841
1848
  (0, import_log5.log)("auth failed", err, {
1842
- file: "invitations-handler.ts",
1843
- line: 347,
1844
- scope: this,
1845
- callSite: (f, a) => f(...a)
1849
+ F: __dxlog_file5,
1850
+ L: 347,
1851
+ S: this,
1852
+ C: (f, a) => f(...a)
1846
1853
  });
1847
1854
  stream.error(err);
1848
1855
  }
@@ -1851,7 +1858,7 @@ var InvitationsHandler = class {
1851
1858
  return extension;
1852
1859
  };
1853
1860
  (0, import_async8.scheduleTask)(ctx, async () => {
1854
- (0, import_node_assert6.default)(invitation.swarmKey);
1861
+ (0, import_tiny_invariant6.default)(invitation.swarmKey);
1855
1862
  const topic = invitation.swarmKey;
1856
1863
  const swarmConnection = await this._networkManager.joinSwarm({
1857
1864
  topic,
@@ -1884,11 +1891,12 @@ var InvitationsHandler = class {
1884
1891
  };
1885
1892
 
1886
1893
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1887
- var import_node_assert7 = __toESM(require("node:assert"));
1894
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1888
1895
  var import_async9 = require("@dxos/async");
1889
1896
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
1890
1897
  var import_log6 = require("@dxos/log");
1891
1898
  var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1899
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1892
1900
  var InvitationsServiceImpl = class {
1893
1901
  constructor(_invitationsHandler, _getHandler) {
1894
1902
  this._invitationsHandler = _invitationsHandler;
@@ -1949,35 +1957,35 @@ var InvitationsServiceImpl = class {
1949
1957
  });
1950
1958
  }
1951
1959
  async authenticate({ invitationId, authCode }) {
1952
- (0, import_log6.log)("authenticating...", {}, {
1953
- file: "invitations-service.ts",
1954
- line: 103,
1955
- scope: this,
1956
- callSite: (f, a) => f(...a)
1960
+ (0, import_log6.log)("authenticating...", void 0, {
1961
+ F: __dxlog_file6,
1962
+ L: 103,
1963
+ S: this,
1964
+ C: (f, a) => f(...a)
1957
1965
  });
1958
- (0, import_node_assert7.default)(invitationId);
1966
+ (0, import_tiny_invariant7.default)(invitationId);
1959
1967
  const observable = this._acceptInvitations.get(invitationId);
1960
1968
  if (!observable) {
1961
1969
  import_log6.log.warn("invalid invitation", {
1962
1970
  invitationId
1963
1971
  }, {
1964
- file: "invitations-service.ts",
1965
- line: 107,
1966
- scope: this,
1967
- callSite: (f, a) => f(...a)
1972
+ F: __dxlog_file6,
1973
+ L: 107,
1974
+ S: this,
1975
+ C: (f, a) => f(...a)
1968
1976
  });
1969
1977
  } else {
1970
1978
  await observable.authenticate(authCode);
1971
1979
  }
1972
1980
  }
1973
1981
  async cancelInvitation({ invitationId }) {
1974
- (0, import_log6.log)("deleting...", {}, {
1975
- file: "invitations-service.ts",
1976
- line: 114,
1977
- scope: this,
1978
- callSite: (f, a) => f(...a)
1982
+ (0, import_log6.log)("deleting...", void 0, {
1983
+ F: __dxlog_file6,
1984
+ L: 114,
1985
+ S: this,
1986
+ C: (f, a) => f(...a)
1979
1987
  });
1980
- (0, import_node_assert7.default)(invitationId);
1988
+ (0, import_tiny_invariant7.default)(invitationId);
1981
1989
  const created = this._createInvitations.get(invitationId);
1982
1990
  const accepted = this._acceptInvitations.get(invitationId);
1983
1991
  if (created) {
@@ -1992,10 +2000,10 @@ var InvitationsServiceImpl = class {
1992
2000
  import_log6.log.warn("invalid invitation", {
1993
2001
  invitationId
1994
2002
  }, {
1995
- file: "invitations-service.ts",
1996
- line: 127,
1997
- scope: this,
1998
- callSite: (f, a) => f(...a)
2003
+ F: __dxlog_file6,
2004
+ L: 127,
2005
+ S: this,
2006
+ C: (f, a) => f(...a)
1999
2007
  });
2000
2008
  }
2001
2009
  }
@@ -2052,11 +2060,12 @@ var InvitationsServiceImpl = class {
2052
2060
  };
2053
2061
 
2054
2062
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
2055
- var import_node_assert8 = __toESM(require("node:assert"));
2063
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
2056
2064
  var import_credentials8 = require("@dxos/credentials");
2057
2065
  var import_feed_store3 = require("@dxos/feed-store");
2058
2066
  var import_log7 = require("@dxos/log");
2059
2067
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
2068
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2060
2069
  var SpaceInvitationProtocol = class {
2061
2070
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2062
2071
  this._spaceManager = _spaceManager;
@@ -2078,24 +2087,24 @@ var SpaceInvitationProtocol = class {
2078
2087
  }
2079
2088
  async admit(request, guestProfile) {
2080
2089
  var _a;
2081
- (0, import_node_assert8.default)(this._spaceKey);
2090
+ (0, import_tiny_invariant8.default)(this._spaceKey);
2082
2091
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2083
- (0, import_node_assert8.default)(space);
2084
- (0, import_node_assert8.default)(request.space);
2092
+ (0, import_tiny_invariant8.default)(space);
2093
+ (0, import_tiny_invariant8.default)(request.space);
2085
2094
  const { identityKey, deviceKey } = request.space;
2086
2095
  (0, import_log7.log)("writing guest credentials", {
2087
2096
  host: this._signingContext.deviceKey,
2088
2097
  guest: deviceKey
2089
2098
  }, {
2090
- file: "space-invitation-protocol.ts",
2091
- line: 50,
2092
- scope: this,
2093
- callSite: (f, a) => f(...a)
2099
+ F: __dxlog_file7,
2100
+ L: 50,
2101
+ S: this,
2102
+ C: (f, a) => f(...a)
2094
2103
  });
2095
2104
  const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2096
- (0, import_node_assert8.default)(credentials[0].credential);
2105
+ (0, import_tiny_invariant8.default)(credentials[0].credential);
2097
2106
  const spaceMemberCredential = credentials[0].credential.credential;
2098
- (0, import_node_assert8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2107
+ (0, import_tiny_invariant8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2099
2108
  await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
2100
2109
  return {
2101
2110
  space: {
@@ -2123,11 +2132,11 @@ var SpaceInvitationProtocol = class {
2123
2132
  };
2124
2133
  }
2125
2134
  async accept(response) {
2126
- (0, import_node_assert8.default)(response.space);
2135
+ (0, import_tiny_invariant8.default)(response.space);
2127
2136
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2128
2137
  const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
2129
- (0, import_node_assert8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2130
- (0, import_node_assert8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2138
+ (0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2139
+ (0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2131
2140
  await this._spaceManager.acceptSpace({
2132
2141
  spaceKey: assertion.spaceKey,
2133
2142
  genesisFeedKey: assertion.genesisFeedKey,
@@ -2141,11 +2150,64 @@ var SpaceInvitationProtocol = class {
2141
2150
  }
2142
2151
  };
2143
2152
 
2153
+ // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
2154
+ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
2155
+ var import_debug3 = require("@dxos/debug");
2156
+ var import_rpc = require("@dxos/rpc");
2157
+ var ClientRpcServer = class {
2158
+ constructor(params) {
2159
+ this._handlerCache = /* @__PURE__ */ new Map();
2160
+ const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
2161
+ this._handleCall = handleCall;
2162
+ this._handleStream = handleStream;
2163
+ this._serviceRegistry = serviceRegistry;
2164
+ this._rpcPeer = new import_rpc.RpcPeer({
2165
+ ...rpcOptions,
2166
+ callHandler: (method, params2) => {
2167
+ const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
2168
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
2169
+ if (this._handleCall) {
2170
+ return this._handleCall(methodName, params2, handler);
2171
+ } else {
2172
+ return handler(methodName, params2);
2173
+ }
2174
+ },
2175
+ streamHandler: (method, params2) => {
2176
+ const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
2177
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
2178
+ if (this._handleStream) {
2179
+ return import_codec_protobuf9.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
2180
+ } else {
2181
+ return handler(methodName, params2);
2182
+ }
2183
+ }
2184
+ });
2185
+ }
2186
+ async open() {
2187
+ await this._rpcPeer.open();
2188
+ }
2189
+ async close() {
2190
+ await this._rpcPeer.close();
2191
+ }
2192
+ _getServiceHandler(serviceName) {
2193
+ var _a;
2194
+ if (!this._handlerCache.has(serviceName)) {
2195
+ const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
2196
+ const service = this._serviceRegistry.services[key];
2197
+ if (!service) {
2198
+ throw new Error(`Service not available: ${serviceName}`);
2199
+ }
2200
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
2201
+ }
2202
+ return this._handlerCache.get(serviceName);
2203
+ }
2204
+ };
2205
+
2144
2206
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2145
- var import_node_assert11 = __toESM(require("node:assert"));
2207
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
2146
2208
  var import_async14 = require("@dxos/async");
2147
2209
  var import_credentials13 = require("@dxos/credentials");
2148
- var import_debug6 = require("@dxos/debug");
2210
+ var import_debug7 = require("@dxos/debug");
2149
2211
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
2150
2212
  var import_feed_store4 = require("@dxos/feed-store");
2151
2213
  var import_keyring = require("@dxos/keyring");
@@ -2156,7 +2218,7 @@ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2156
2218
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2157
2219
 
2158
2220
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2159
- var import_node_assert10 = __toESM(require("node:assert"));
2221
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
2160
2222
  var import_async12 = require("@dxos/async");
2161
2223
  var import_context7 = require("@dxos/context");
2162
2224
  var import_credentials12 = require("@dxos/credentials");
@@ -2171,7 +2233,7 @@ var import_util5 = require("@dxos/util");
2171
2233
  var import_async11 = require("@dxos/async");
2172
2234
  var import_client_protocol3 = require("@dxos/client-protocol");
2173
2235
  var import_context6 = require("@dxos/context");
2174
- var import_debug3 = require("@dxos/debug");
2236
+ var import_debug4 = require("@dxos/debug");
2175
2237
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2176
2238
  var import_errors3 = require("@dxos/errors");
2177
2239
  var import_keys8 = require("@dxos/keys");
@@ -2182,7 +2244,7 @@ var import_timeframe = require("@dxos/timeframe");
2182
2244
  var import_util4 = require("@dxos/util");
2183
2245
 
2184
2246
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2185
- var import_node_assert9 = __toESM(require("node:assert"));
2247
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
2186
2248
  var import_async10 = require("@dxos/async");
2187
2249
  var import_context5 = require("@dxos/context");
2188
2250
  var import_keys7 = require("@dxos/keys");
@@ -2190,6 +2252,7 @@ var import_log8 = require("@dxos/log");
2190
2252
  var import_protocols5 = require("@dxos/protocols");
2191
2253
  var import_teleport2 = require("@dxos/teleport");
2192
2254
  var import_util3 = require("@dxos/util");
2255
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2193
2256
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2194
2257
  var DEFAULT_SUCCESS_DELAY = 1e3;
2195
2258
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -2202,6 +2265,9 @@ var NotarizationPlugin = class {
2202
2265
  this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
2203
2266
  this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
2204
2267
  }
2268
+ get hasWriter() {
2269
+ return !!this._writer;
2270
+ }
2205
2271
  async open() {
2206
2272
  }
2207
2273
  async close() {
@@ -2214,22 +2280,22 @@ var NotarizationPlugin = class {
2214
2280
  (0, import_log8.log)("notarize", {
2215
2281
  credentials
2216
2282
  }, {
2217
- file: "notarization-plugin.ts",
2218
- line: 87,
2219
- scope: this,
2220
- callSite: (f, a) => f(...a)
2283
+ F: __dxlog_file8,
2284
+ L: 91,
2285
+ S: this,
2286
+ C: (f, a) => f(...a)
2221
2287
  });
2222
- (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2288
+ (0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2223
2289
  const errors = new import_async10.Trigger();
2224
2290
  const ctx = this._ctx.derive({
2225
2291
  onError: (err) => {
2226
2292
  import_log8.log.warn("Notarization error", {
2227
2293
  err
2228
2294
  }, {
2229
- file: "notarization-plugin.ts",
2230
- line: 96,
2231
- scope: this,
2232
- callSite: (f, a) => f(...a)
2295
+ F: __dxlog_file8,
2296
+ L: 100,
2297
+ S: this,
2298
+ C: (f, a) => f(...a)
2233
2299
  });
2234
2300
  void ctx.dispose();
2235
2301
  errors.throw(err);
@@ -2242,10 +2308,10 @@ var NotarizationPlugin = class {
2242
2308
  timeout,
2243
2309
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2244
2310
  }, {
2245
- file: "notarization-plugin.ts",
2246
- line: 108,
2247
- scope: this,
2248
- callSite: (f, a) => f(...a)
2311
+ F: __dxlog_file8,
2312
+ L: 112,
2313
+ S: this,
2314
+ C: (f, a) => f(...a)
2249
2315
  });
2250
2316
  void ctx.dispose();
2251
2317
  errors.throw(new import_async10.TimeoutError(timeout, "Notarization timed out"));
@@ -2265,10 +2331,10 @@ var NotarizationPlugin = class {
2265
2331
  import_log8.log.warn("Exhausted all peers to notarize with", {
2266
2332
  retryIn: retryTimeout
2267
2333
  }, {
2268
- file: "notarization-plugin.ts",
2269
- line: 133,
2270
- scope: this,
2271
- callSite: (f, a) => f(...a)
2334
+ F: __dxlog_file8,
2335
+ L: 137,
2336
+ S: this,
2337
+ C: (f, a) => f(...a)
2272
2338
  });
2273
2339
  peersTried.clear();
2274
2340
  (0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
@@ -2279,28 +2345,28 @@ var NotarizationPlugin = class {
2279
2345
  peer: peer.localPeerId,
2280
2346
  credentialId: credentials.map((credential) => credential.id)
2281
2347
  }, {
2282
- file: "notarization-plugin.ts",
2283
- line: 140,
2284
- scope: this,
2285
- callSite: (f, a) => f(...a)
2348
+ F: __dxlog_file8,
2349
+ L: 144,
2350
+ S: this,
2351
+ C: (f, a) => f(...a)
2286
2352
  });
2287
2353
  await peer.rpc.NotarizationService.notarize({
2288
2354
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2289
2355
  });
2290
- (0, import_log8.log)("success", {}, {
2291
- file: "notarization-plugin.ts",
2292
- line: 144,
2293
- scope: this,
2294
- callSite: (f, a) => f(...a)
2356
+ (0, import_log8.log)("success", void 0, {
2357
+ F: __dxlog_file8,
2358
+ L: 148,
2359
+ S: this,
2360
+ C: (f, a) => f(...a)
2295
2361
  });
2296
2362
  await (0, import_async10.sleep)(successDelay);
2297
2363
  } catch (err) {
2298
2364
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2299
2365
  import_log8.log.warn("error notarizing (recoverable)", err, {
2300
- file: "notarization-plugin.ts",
2301
- line: 148,
2302
- scope: this,
2303
- callSite: (f, a) => f(...a)
2366
+ F: __dxlog_file8,
2367
+ L: 152,
2368
+ S: this,
2369
+ C: (f, a) => f(...a)
2304
2370
  });
2305
2371
  }
2306
2372
  notarizeTask.schedule();
@@ -2314,11 +2380,11 @@ var NotarizationPlugin = class {
2314
2380
  allNotarized,
2315
2381
  errors.wait()
2316
2382
  ]);
2317
- (0, import_log8.log)("done", {}, {
2318
- file: "notarization-plugin.ts",
2319
- line: 159,
2320
- scope: this,
2321
- callSite: (f, a) => f(...a)
2383
+ (0, import_log8.log)("done", void 0, {
2384
+ F: __dxlog_file8,
2385
+ L: 163,
2386
+ S: this,
2387
+ C: (f, a) => f(...a)
2322
2388
  });
2323
2389
  } finally {
2324
2390
  await ctx.dispose();
@@ -2327,7 +2393,7 @@ var NotarizationPlugin = class {
2327
2393
  /**
2328
2394
  * Called with credentials arriving from the control pipeline.
2329
2395
  */
2330
- async process(credential) {
2396
+ async processCredential(credential) {
2331
2397
  var _a;
2332
2398
  if (!credential.id) {
2333
2399
  return;
@@ -2337,7 +2403,7 @@ var NotarizationPlugin = class {
2337
2403
  this._processCredentialsTriggers.delete(credential.id);
2338
2404
  }
2339
2405
  setWriter(writer) {
2340
- (0, import_node_assert9.default)(!this._writer, "Writer already set.");
2406
+ (0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
2341
2407
  this._writer = writer;
2342
2408
  }
2343
2409
  async _waitUntilProcessed(id) {
@@ -2355,7 +2421,7 @@ var NotarizationPlugin = class {
2355
2421
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2356
2422
  }
2357
2423
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2358
- (0, import_node_assert9.default)(credential.id, "Credential must have an id");
2424
+ (0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
2359
2425
  if (this._processedCredentials.has(credential.id)) {
2360
2426
  continue;
2361
2427
  }
@@ -2368,10 +2434,10 @@ var NotarizationPlugin = class {
2368
2434
  (0, import_log8.log)("extension opened", {
2369
2435
  peer: extension.localPeerId
2370
2436
  }, {
2371
- file: "notarization-plugin.ts",
2372
- line: 208,
2373
- scope: this,
2374
- callSite: (f, a) => f(...a)
2437
+ F: __dxlog_file8,
2438
+ L: 212,
2439
+ S: this,
2440
+ C: (f, a) => f(...a)
2375
2441
  });
2376
2442
  this._extensions.add(extension);
2377
2443
  this._extensionOpened.emit();
@@ -2380,10 +2446,10 @@ var NotarizationPlugin = class {
2380
2446
  (0, import_log8.log)("extension closed", {
2381
2447
  peer: extension.localPeerId
2382
2448
  }, {
2383
- file: "notarization-plugin.ts",
2384
- line: 213,
2385
- scope: this,
2386
- callSite: (f, a) => f(...a)
2449
+ F: __dxlog_file8,
2450
+ L: 217,
2451
+ S: this,
2452
+ C: (f, a) => f(...a)
2387
2453
  });
2388
2454
  this._extensions.delete(extension);
2389
2455
  },
@@ -2424,7 +2490,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2424
2490
  };
2425
2491
 
2426
2492
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2427
- var __decorate = function(decorators, target, key, desc) {
2493
+ function _ts_decorate(decorators, target, key, desc) {
2428
2494
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2429
2495
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2430
2496
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2433,10 +2499,12 @@ var __decorate = function(decorators, target, key, desc) {
2433
2499
  if (d = decorators[i])
2434
2500
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2435
2501
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2436
- };
2502
+ }
2503
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2437
2504
  var DataSpace = class DataSpace2 {
2438
2505
  constructor(params) {
2439
2506
  this._ctx = new import_context6.Context();
2507
+ this._notarizationPlugin = new NotarizationPlugin();
2440
2508
  this._state = import_services6.SpaceState.CLOSED;
2441
2509
  /**
2442
2510
  * Error for _state === SpaceState.ERROR.
@@ -2459,8 +2527,8 @@ var DataSpace = class DataSpace2 {
2459
2527
  update: this._inner.stateUpdate,
2460
2528
  authTimeout: import_client_protocol3.AUTH_TIMEOUT
2461
2529
  });
2462
- this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
2463
2530
  this._cache = params.cache;
2531
+ this._state = params.initialState;
2464
2532
  }
2465
2533
  get key() {
2466
2534
  return this._inner.key;
@@ -2482,25 +2550,36 @@ var DataSpace = class DataSpace2 {
2482
2550
  return this._presence;
2483
2551
  }
2484
2552
  get notarizationPlugin() {
2485
- return this._notarizationPluginConsumer.processor;
2553
+ return this._notarizationPlugin;
2486
2554
  }
2487
2555
  get cache() {
2488
2556
  return this._cache;
2489
2557
  }
2490
2558
  async open() {
2491
- await this.notarizationPlugin.open();
2492
- await this._notarizationPluginConsumer.open();
2559
+ await this._open();
2560
+ }
2561
+ async _open() {
2562
+ await this._notarizationPlugin.open();
2563
+ await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2493
2564
  await this._inner.open();
2494
- this._state = import_services6.SpaceState.INACTIVE;
2565
+ this._state = import_services6.SpaceState.CONTROL_ONLY;
2566
+ this.stateUpdate.emit();
2567
+ this.metrics = {};
2495
2568
  this.metrics.open = new Date();
2496
2569
  }
2497
2570
  async close() {
2571
+ await this._close();
2572
+ }
2573
+ async _close() {
2574
+ var _a, _b;
2575
+ await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2498
2576
  this._state = import_services6.SpaceState.CLOSED;
2499
2577
  await this._ctx.dispose();
2578
+ this._ctx = new import_context6.Context();
2500
2579
  await this.authVerifier.close();
2501
2580
  await this._inner.close();
2502
- await this._notarizationPluginConsumer.close();
2503
- await this.notarizationPlugin.close();
2581
+ await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
2582
+ await this._notarizationPlugin.close();
2504
2583
  await this._presence.destroy();
2505
2584
  }
2506
2585
  async postMessage(channel, message) {
@@ -2520,18 +2599,18 @@ var DataSpace = class DataSpace2 {
2520
2599
  } catch (err) {
2521
2600
  if (err instanceof import_errors3.CancelledError) {
2522
2601
  (0, import_log9.log)("Data pipeline initialization cancelled", err, {
2523
- file: "data-space.ts",
2524
- line: 173,
2525
- scope: this,
2526
- callSite: (f, a) => f(...a)
2602
+ F: __dxlog_file9,
2603
+ L: 193,
2604
+ S: this,
2605
+ C: (f, a) => f(...a)
2527
2606
  });
2528
2607
  return;
2529
2608
  }
2530
2609
  import_log9.log.error("Error initializing data pipeline", err, {
2531
- file: "data-space.ts",
2532
- line: 177,
2533
- scope: this,
2534
- callSite: (f, a) => f(...a)
2610
+ F: __dxlog_file9,
2611
+ L: 197,
2612
+ S: this,
2613
+ C: (f, a) => f(...a)
2535
2614
  });
2536
2615
  this._state = import_services6.SpaceState.ERROR;
2537
2616
  this.error = err;
@@ -2543,7 +2622,7 @@ var DataSpace = class DataSpace2 {
2543
2622
  }
2544
2623
  async initializeDataPipeline() {
2545
2624
  var _a, _b, _c, _d;
2546
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2625
+ if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
2547
2626
  throw new import_errors3.SystemError("Invalid operation");
2548
2627
  }
2549
2628
  this._state = import_services6.SpaceState.INITIALIZING;
@@ -2553,37 +2632,39 @@ var DataSpace = class DataSpace2 {
2553
2632
  });
2554
2633
  this.metrics.controlPipelineReady = new Date();
2555
2634
  await this._createWritableFeeds();
2556
- (0, import_log9.log)("Writable feeds created", {}, {
2557
- file: "data-space.ts",
2558
- line: 201,
2559
- scope: this,
2560
- callSite: (f, a) => f(...a)
2635
+ (0, import_log9.log)("Writable feeds created", void 0, {
2636
+ F: __dxlog_file9,
2637
+ L: 221,
2638
+ S: this,
2639
+ C: (f, a) => f(...a)
2561
2640
  });
2562
2641
  this.stateUpdate.emit();
2563
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2564
- credential: {
2565
- credential
2566
- }
2567
- }), this._inner.controlPipeline.writer));
2642
+ if (!this.notarizationPlugin.hasWriter) {
2643
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2644
+ credential: {
2645
+ credential
2646
+ }
2647
+ }), this._inner.controlPipeline.writer));
2648
+ }
2568
2649
  await this._inner.initializeDataPipeline();
2569
2650
  this.metrics.dataPipelineOpen = new Date();
2570
2651
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2571
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", {}, {
2572
- file: "data-space.ts",
2573
- line: 220,
2574
- scope: this,
2575
- callSite: (f, a) => f(...a)
2652
+ (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
2653
+ F: __dxlog_file9,
2654
+ L: 242,
2655
+ S: this,
2656
+ C: (f, a) => f(...a)
2576
2657
  });
2577
2658
  await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
2578
2659
  ctx: this._ctx,
2579
2660
  breakOnStall: false
2580
2661
  });
2581
2662
  this.metrics.dataPipelineReady = new Date();
2582
- (0, import_log9.log)("data pipeline ready", {}, {
2583
- file: "data-space.ts",
2584
- line: 229,
2585
- scope: this,
2586
- callSite: (f, a) => f(...a)
2663
+ (0, import_log9.log)("data pipeline ready", void 0, {
2664
+ F: __dxlog_file9,
2665
+ L: 251,
2666
+ S: this,
2667
+ C: (f, a) => f(...a)
2587
2668
  });
2588
2669
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2589
2670
  this._state = import_services6.SpaceState.READY;
@@ -2661,17 +2742,46 @@ var DataSpace = class DataSpace2 {
2661
2742
  }
2662
2743
  }
2663
2744
  }
2745
+ async activate() {
2746
+ if (this._state !== import_services6.SpaceState.INACTIVE) {
2747
+ throw new import_errors3.SystemError("Invalid operation");
2748
+ }
2749
+ await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
2750
+ await this._open();
2751
+ this.initializeDataPipelineAsync();
2752
+ }
2753
+ async deactivate() {
2754
+ if (this._state === import_services6.SpaceState.INACTIVE) {
2755
+ throw new import_errors3.SystemError("Invalid operation");
2756
+ }
2757
+ await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
2758
+ await this._close();
2759
+ this._state = import_services6.SpaceState.INACTIVE;
2760
+ this.stateUpdate.emit();
2761
+ }
2664
2762
  };
2665
- __decorate([
2666
- (0, import_debug3.timed)(1e4)
2763
+ _ts_decorate([
2764
+ import_async11.synchronized
2765
+ ], DataSpace.prototype, "open", null);
2766
+ _ts_decorate([
2767
+ import_async11.synchronized
2768
+ ], DataSpace.prototype, "close", null);
2769
+ _ts_decorate([
2770
+ (0, import_debug4.timed)(1e4)
2667
2771
  ], DataSpace.prototype, "_createWritableFeeds", null);
2668
- DataSpace = __decorate([
2772
+ _ts_decorate([
2773
+ import_async11.synchronized
2774
+ ], DataSpace.prototype, "activate", null);
2775
+ _ts_decorate([
2776
+ import_async11.synchronized
2777
+ ], DataSpace.prototype, "deactivate", null);
2778
+ DataSpace = _ts_decorate([
2669
2779
  (0, import_async11.trackLeaks)("open", "close")
2670
2780
  ], DataSpace);
2671
2781
 
2672
2782
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
2673
2783
  var import_credentials10 = require("@dxos/credentials");
2674
- var import_debug4 = require("@dxos/debug");
2784
+ var import_debug5 = require("@dxos/debug");
2675
2785
  var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
2676
2786
  var import_timeframe2 = require("@dxos/timeframe");
2677
2787
  var spaceGenesis = async (keyring, signingContext, space) => {
@@ -2695,11 +2805,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2695
2805
  spaceKey: space.key,
2696
2806
  role: import_credentials11.SpaceMember.Role.ADMIN,
2697
2807
  profile: signingContext.profile,
2698
- genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug4.failUndefined)()
2808
+ genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
2699
2809
  }
2700
2810
  }),
2701
2811
  await signingContext.credentialSigner.createCredential({
2702
- subject: (_b = space.controlFeedKey) != null ? _b : (0, import_debug4.failUndefined)(),
2812
+ subject: (_b = space.controlFeedKey) != null ? _b : (0, import_debug5.failUndefined)(),
2703
2813
  assertion: {
2704
2814
  "@type": "dxos.halo.credentials.AdmittedFeed",
2705
2815
  spaceKey: space.key,
@@ -2709,7 +2819,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2709
2819
  }
2710
2820
  }),
2711
2821
  await signingContext.credentialSigner.createCredential({
2712
- subject: (_c = space.dataFeedKey) != null ? _c : (0, import_debug4.failUndefined)(),
2822
+ subject: (_c = space.dataFeedKey) != null ? _c : (0, import_debug5.failUndefined)(),
2713
2823
  assertion: {
2714
2824
  "@type": "dxos.halo.credentials.AdmittedFeed",
2715
2825
  spaceKey: space.key,
@@ -2719,7 +2829,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2719
2829
  }
2720
2830
  }),
2721
2831
  await signingContext.credentialSigner.createCredential({
2722
- subject: (_d = space.key) != null ? _d : (0, import_debug4.failUndefined)(),
2832
+ subject: (_d = space.key) != null ? _d : (0, import_debug5.failUndefined)(),
2723
2833
  assertion: {
2724
2834
  "@type": "dxos.halo.credentials.Epoch",
2725
2835
  number: 0,
@@ -2740,7 +2850,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2740
2850
  };
2741
2851
 
2742
2852
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2743
- var __decorate2 = function(decorators, target, key, desc) {
2853
+ function _ts_decorate2(decorators, target, key, desc) {
2744
2854
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2745
2855
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2746
2856
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2749,7 +2859,8 @@ var __decorate2 = function(decorators, target, key, desc) {
2749
2859
  if (d = decorators[i])
2750
2860
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2751
2861
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2752
- };
2862
+ }
2863
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2753
2864
  var DataSpaceManager = class DataSpaceManager2 {
2754
2865
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2755
2866
  this._spaceManager = _spaceManager;
@@ -2769,50 +2880,52 @@ var DataSpaceManager = class DataSpaceManager2 {
2769
2880
  return this._spaces;
2770
2881
  }
2771
2882
  async open() {
2772
- (0, import_log10.log)("open", {}, {
2773
- file: "data-space-manager.ts",
2774
- line: 80,
2775
- scope: this,
2776
- callSite: (f, a) => f(...a)
2883
+ (0, import_log10.log)("open", void 0, {
2884
+ F: __dxlog_file10,
2885
+ L: 80,
2886
+ S: this,
2887
+ C: (f, a) => f(...a)
2777
2888
  });
2778
2889
  import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2779
2890
  id: this._instanceId
2780
2891
  }), {
2781
- file: "data-space-manager.ts",
2782
- line: 81,
2783
- scope: this,
2784
- callSite: (f, a) => f(...a)
2892
+ F: __dxlog_file10,
2893
+ L: 81,
2894
+ S: this,
2895
+ C: (f, a) => f(...a)
2785
2896
  });
2786
2897
  await this._metadataStore.load();
2787
2898
  (0, import_log10.log)("metadata loaded", {
2788
2899
  spaces: this._metadataStore.spaces.length
2789
2900
  }, {
2790
- file: "data-space-manager.ts",
2791
- line: 83,
2792
- scope: this,
2793
- callSite: (f, a) => f(...a)
2901
+ F: __dxlog_file10,
2902
+ L: 83,
2903
+ S: this,
2904
+ C: (f, a) => f(...a)
2794
2905
  });
2795
2906
  for (const spaceMetadata of this._metadataStore.spaces) {
2796
2907
  try {
2797
2908
  (0, import_log10.log)("load space", {
2798
2909
  spaceMetadata
2799
2910
  }, {
2800
- file: "data-space-manager.ts",
2801
- line: 87,
2802
- scope: this,
2803
- callSite: (f, a) => f(...a)
2911
+ F: __dxlog_file10,
2912
+ L: 87,
2913
+ S: this,
2914
+ C: (f, a) => f(...a)
2804
2915
  });
2805
2916
  const space = await this._constructSpace(spaceMetadata);
2806
- space.initializeDataPipelineAsync();
2917
+ if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
2918
+ space.initializeDataPipelineAsync();
2919
+ }
2807
2920
  } catch (err) {
2808
2921
  import_log10.log.error("Error loading space", {
2809
2922
  spaceMetadata,
2810
2923
  err
2811
2924
  }, {
2812
- file: "data-space-manager.ts",
2813
- line: 91,
2814
- scope: this,
2815
- callSite: (f, a) => f(...a)
2925
+ F: __dxlog_file10,
2926
+ L: 93,
2927
+ S: this,
2928
+ C: (f, a) => f(...a)
2816
2929
  });
2817
2930
  }
2818
2931
  }
@@ -2821,18 +2934,18 @@ var DataSpaceManager = class DataSpaceManager2 {
2821
2934
  import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2822
2935
  id: this._instanceId
2823
2936
  }), {
2824
- file: "data-space-manager.ts",
2825
- line: 97,
2826
- scope: this,
2827
- callSite: (f, a) => f(...a)
2937
+ F: __dxlog_file10,
2938
+ L: 99,
2939
+ S: this,
2940
+ C: (f, a) => f(...a)
2828
2941
  });
2829
2942
  }
2830
2943
  async close() {
2831
- (0, import_log10.log)("close", {}, {
2832
- file: "data-space-manager.ts",
2833
- line: 102,
2834
- scope: this,
2835
- callSite: (f, a) => f(...a)
2944
+ (0, import_log10.log)("close", void 0, {
2945
+ F: __dxlog_file10,
2946
+ L: 104,
2947
+ S: this,
2948
+ C: (f, a) => f(...a)
2836
2949
  });
2837
2950
  this._isOpen = false;
2838
2951
  await this._ctx.dispose();
@@ -2844,7 +2957,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2844
2957
  * Creates a new space writing the genesis credentials to the control feed.
2845
2958
  */
2846
2959
  async createSpace() {
2847
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2960
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2848
2961
  const spaceKey = await this._keyring.createKey();
2849
2962
  const controlFeedKey = await this._keyring.createKey();
2850
2963
  const dataFeedKey = await this._keyring.createKey();
@@ -2852,21 +2965,22 @@ var DataSpaceManager = class DataSpaceManager2 {
2852
2965
  key: spaceKey,
2853
2966
  genesisFeedKey: controlFeedKey,
2854
2967
  controlFeedKey,
2855
- dataFeedKey
2968
+ dataFeedKey,
2969
+ state: import_services7.SpaceState.ACTIVE
2856
2970
  };
2857
2971
  (0, import_log10.log)("creating space...", {
2858
2972
  spaceKey
2859
2973
  }, {
2860
- file: "data-space-manager.ts",
2861
- line: 126,
2862
- scope: this,
2863
- callSite: (f, a) => f(...a)
2974
+ F: __dxlog_file10,
2975
+ L: 129,
2976
+ S: this,
2977
+ C: (f, a) => f(...a)
2864
2978
  });
2865
2979
  const space = await this._constructSpace(metadata);
2866
2980
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2867
2981
  await this._metadataStore.addSpace(metadata);
2868
2982
  const memberCredential = credentials[1];
2869
- (0, import_node_assert10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2983
+ (0, import_tiny_invariant10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2870
2984
  await this._signingContext.recordCredential(memberCredential);
2871
2985
  await space.initializeDataPipeline();
2872
2986
  this.updated.emit();
@@ -2877,13 +2991,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2877
2991
  (0, import_log10.log)("accept space", {
2878
2992
  opts
2879
2993
  }, {
2880
- file: "data-space-manager.ts",
2881
- line: 145,
2882
- scope: this,
2883
- callSite: (f, a) => f(...a)
2994
+ F: __dxlog_file10,
2995
+ L: 148,
2996
+ S: this,
2997
+ C: (f, a) => f(...a)
2884
2998
  });
2885
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2886
- (0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2999
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
3000
+ (0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2887
3001
  const metadata = {
2888
3002
  key: opts.spaceKey,
2889
3003
  genesisFeedKey: opts.genesisFeedKey,
@@ -2911,10 +3025,10 @@ var DataSpaceManager = class DataSpaceManager2 {
2911
3025
  (0, import_log10.log)("construct space", {
2912
3026
  metadata
2913
3027
  }, {
2914
- file: "data-space-manager.ts",
2915
- line: 181,
2916
- scope: this,
2917
- callSite: (f, a) => f(...a)
3028
+ F: __dxlog_file10,
3029
+ L: 183,
3030
+ S: this,
3031
+ C: (f, a) => f(...a)
2918
3032
  });
2919
3033
  const gossip = new import_teleport_extension_gossip.Gossip({
2920
3034
  localPeerId: this._signingContext.deviceKey
@@ -2946,11 +3060,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2946
3060
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2947
3061
  },
2948
3062
  onAuthFailure: () => {
2949
- import_log10.log.warn("auth failure", {}, {
2950
- file: "data-space-manager.ts",
2951
- line: 212,
2952
- scope: this,
2953
- callSite: (f, a) => f(...a)
3063
+ import_log10.log.warn("auth failure", void 0, {
3064
+ F: __dxlog_file10,
3065
+ L: 214,
3066
+ S: this,
3067
+ C: (f, a) => f(...a)
2954
3068
  });
2955
3069
  },
2956
3070
  memberKey: this._signingContext.identityKey
@@ -2959,6 +3073,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2959
3073
  dataFeed && space.setDataFeed(dataFeed);
2960
3074
  const dataSpace = new DataSpace({
2961
3075
  inner: space,
3076
+ initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
2962
3077
  metadataStore: this._metadataStore,
2963
3078
  gossip,
2964
3079
  presence,
@@ -2970,31 +3085,44 @@ var DataSpaceManager = class DataSpaceManager2 {
2970
3085
  (0, import_log10.log)("before space ready", {
2971
3086
  space: space.key
2972
3087
  }, {
2973
- file: "data-space-manager.ts",
2974
- line: 229,
2975
- scope: this,
2976
- callSite: (f, a) => f(...a)
3088
+ F: __dxlog_file10,
3089
+ L: 232,
3090
+ S: this,
3091
+ C: (f, a) => f(...a)
2977
3092
  });
2978
- this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3093
+ await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2979
3094
  },
2980
3095
  afterReady: async () => {
2981
3096
  (0, import_log10.log)("after space ready", {
2982
3097
  space: space.key,
2983
3098
  open: this._isOpen
2984
3099
  }, {
2985
- file: "data-space-manager.ts",
2986
- line: 236,
2987
- scope: this,
2988
- callSite: (f, a) => f(...a)
3100
+ F: __dxlog_file10,
3101
+ L: 239,
3102
+ S: this,
3103
+ C: (f, a) => f(...a)
2989
3104
  });
2990
3105
  if (this._isOpen) {
2991
3106
  this.updated.emit();
2992
3107
  }
3108
+ },
3109
+ beforeClose: async () => {
3110
+ (0, import_log10.log)("before space close", {
3111
+ space: space.key
3112
+ }, {
3113
+ F: __dxlog_file10,
3114
+ L: 245,
3115
+ S: this,
3116
+ C: (f, a) => f(...a)
3117
+ });
3118
+ await this._dataServiceSubscriptions.unregisterSpace(space.key);
2993
3119
  }
2994
3120
  },
2995
3121
  cache: metadata.cache
2996
3122
  });
2997
- await dataSpace.open();
3123
+ if (metadata.state !== import_services7.SpaceState.INACTIVE) {
3124
+ await dataSpace.open();
3125
+ }
2998
3126
  if (metadata.controlTimeframe) {
2999
3127
  dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
3000
3128
  }
@@ -3005,31 +3133,33 @@ var DataSpaceManager = class DataSpaceManager2 {
3005
3133
  return dataSpace;
3006
3134
  }
3007
3135
  };
3008
- __decorate2([
3136
+ _ts_decorate2([
3009
3137
  import_async12.synchronized
3010
3138
  ], DataSpaceManager.prototype, "open", null);
3011
- __decorate2([
3139
+ _ts_decorate2([
3012
3140
  import_async12.synchronized
3013
3141
  ], DataSpaceManager.prototype, "close", null);
3014
- __decorate2([
3142
+ _ts_decorate2([
3015
3143
  import_async12.synchronized
3016
3144
  ], DataSpaceManager.prototype, "createSpace", null);
3017
- __decorate2([
3145
+ _ts_decorate2([
3018
3146
  import_async12.synchronized
3019
3147
  ], DataSpaceManager.prototype, "acceptSpace", null);
3020
- DataSpaceManager = __decorate2([
3148
+ DataSpaceManager = _ts_decorate2([
3021
3149
  (0, import_async12.trackLeaks)("open", "close")
3022
3150
  ], DataSpaceManager);
3023
3151
 
3024
3152
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3025
3153
  var import_async13 = require("@dxos/async");
3026
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3027
- var import_debug5 = require("@dxos/debug");
3154
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3155
+ var import_debug6 = require("@dxos/debug");
3028
3156
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3157
+ var import_errors4 = require("@dxos/errors");
3029
3158
  var import_log11 = require("@dxos/log");
3030
3159
  var import_protocols7 = require("@dxos/protocols");
3031
3160
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3032
3161
  var import_util6 = require("@dxos/util");
3162
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3033
3163
  var SpacesServiceImpl = class {
3034
3164
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3035
3165
  this._identityManager = _identityManager;
@@ -3045,21 +3175,35 @@ var SpacesServiceImpl = class {
3045
3175
  const space = await dataSpaceManager.createSpace();
3046
3176
  return this._serializeSpace(space);
3047
3177
  }
3048
- async updateSpace(request) {
3049
- (0, import_debug5.todo)();
3178
+ async updateSpace({ spaceKey, state }) {
3179
+ var _a;
3180
+ const dataSpaceManager = await this._getDataSpaceManager();
3181
+ const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3182
+ if (state) {
3183
+ switch (state) {
3184
+ case import_services8.SpaceState.ACTIVE:
3185
+ await space.activate();
3186
+ break;
3187
+ case import_services8.SpaceState.INACTIVE:
3188
+ await space.deactivate();
3189
+ break;
3190
+ default:
3191
+ throw new import_errors4.ApiError("Invalid space state");
3192
+ }
3193
+ }
3050
3194
  }
3051
3195
  querySpaces() {
3052
- return new import_codec_protobuf9.Stream(({ next, ctx }) => {
3196
+ return new import_codec_protobuf10.Stream(({ next, ctx }) => {
3053
3197
  const scheduler = new import_async13.UpdateScheduler(ctx, async () => {
3054
3198
  const dataSpaceManager = await this._getDataSpaceManager();
3055
3199
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
3056
3200
  (0, import_log11.log)("update", {
3057
3201
  spaces
3058
3202
  }, {
3059
- file: "spaces-service.ts",
3060
- line: 60,
3061
- scope: this,
3062
- callSite: (f, a) => f(...a)
3203
+ F: __dxlog_file11,
3204
+ L: 78,
3205
+ S: this,
3206
+ C: (f, a) => f(...a)
3063
3207
  });
3064
3208
  next({
3065
3209
  spaces
@@ -3100,15 +3244,15 @@ var SpacesServiceImpl = class {
3100
3244
  async postMessage({ spaceKey, channel, message }) {
3101
3245
  var _a;
3102
3246
  const dataSpaceManager = await this._getDataSpaceManager();
3103
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3247
+ const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3104
3248
  await space.postMessage(getChannelId(channel), message);
3105
3249
  }
3106
3250
  subscribeMessages({ spaceKey, channel }) {
3107
- return new import_codec_protobuf9.Stream(({ ctx, next }) => {
3251
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
3108
3252
  (0, import_async13.scheduleTask)(ctx, async () => {
3109
3253
  var _a;
3110
3254
  const dataSpaceManager = await this._getDataSpaceManager();
3111
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3255
+ const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3112
3256
  const handle = space.listen(getChannelId(channel), (message) => {
3113
3257
  next(message);
3114
3258
  });
@@ -3117,21 +3261,21 @@ var SpacesServiceImpl = class {
3117
3261
  });
3118
3262
  }
3119
3263
  queryCredentials({ spaceKey }) {
3120
- return new import_codec_protobuf9.Stream(({ ctx, next }) => {
3264
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
3121
3265
  var _a;
3122
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3123
- const processor = space.spaceState.registerProcessor({
3124
- process: async (credential) => {
3266
+ const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3267
+ const processor = {
3268
+ processCredential: async (credential) => {
3125
3269
  next(credential);
3126
3270
  }
3127
- });
3128
- ctx.onDispose(() => processor.close());
3129
- (0, import_async13.scheduleTask)(ctx, () => processor.open());
3271
+ };
3272
+ ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
3273
+ (0, import_async13.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
3130
3274
  });
3131
3275
  }
3132
3276
  async writeCredentials({ spaceKey, credentials }) {
3133
3277
  var _a;
3134
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3278
+ const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3135
3279
  for (const credential of credentials != null ? credentials : []) {
3136
3280
  await space.controlPipeline.writer.write({
3137
3281
  credential: {
@@ -3143,7 +3287,7 @@ var SpacesServiceImpl = class {
3143
3287
  async createEpoch({ spaceKey }) {
3144
3288
  var _a;
3145
3289
  const dataSpaceManager = await this._getDataSpaceManager();
3146
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3290
+ const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3147
3291
  await space.createEpoch();
3148
3292
  }
3149
3293
  _serializeSpace(space) {
@@ -3186,6 +3330,7 @@ var SpacesServiceImpl = class {
3186
3330
  var getChannelId = (channel) => `user-channel/${channel}`;
3187
3331
 
3188
3332
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3333
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3189
3334
  var ServiceContext = class {
3190
3335
  // prettier-ignore
3191
3336
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3222,24 +3367,24 @@ var ServiceContext = class {
3222
3367
  this.invitations = new InvitationsHandler(this.networkManager);
3223
3368
  this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3224
3369
  var _a;
3225
- return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3370
+ return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3226
3371
  }, this._acceptIdentity.bind(this)));
3227
3372
  }
3228
3373
  async open() {
3229
3374
  import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3230
3375
  id: this._instanceId
3231
3376
  }), {
3232
- file: "service-context.ts",
3233
- line: 126,
3234
- scope: this,
3235
- callSite: (f, a) => f(...a)
3377
+ F: __dxlog_file12,
3378
+ L: 126,
3379
+ S: this,
3380
+ C: (f, a) => f(...a)
3236
3381
  });
3237
3382
  await this._checkStorageVersion();
3238
- (0, import_log12.log)("opening...", {}, {
3239
- file: "service-context.ts",
3240
- line: 130,
3241
- scope: this,
3242
- callSite: (f, a) => f(...a)
3383
+ (0, import_log12.log)("opening...", void 0, {
3384
+ F: __dxlog_file12,
3385
+ L: 130,
3386
+ S: this,
3387
+ C: (f, a) => f(...a)
3243
3388
  });
3244
3389
  await this.signalManager.open();
3245
3390
  await this.networkManager.open();
@@ -3248,42 +3393,44 @@ var ServiceContext = class {
3248
3393
  if (this.identityManager.identity) {
3249
3394
  await this._initialize();
3250
3395
  }
3251
- (0, import_log12.log)("opened", {}, {
3252
- file: "service-context.ts",
3253
- line: 138,
3254
- scope: this,
3255
- callSite: (f, a) => f(...a)
3396
+ (0, import_log12.log)("opened", void 0, {
3397
+ F: __dxlog_file12,
3398
+ L: 138,
3399
+ S: this,
3400
+ C: (f, a) => f(...a)
3256
3401
  });
3257
3402
  import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3258
3403
  id: this._instanceId
3259
3404
  }), {
3260
- file: "service-context.ts",
3261
- line: 139,
3262
- scope: this,
3263
- callSite: (f, a) => f(...a)
3405
+ F: __dxlog_file12,
3406
+ L: 139,
3407
+ S: this,
3408
+ C: (f, a) => f(...a)
3264
3409
  });
3265
3410
  }
3266
3411
  async close() {
3267
- var _a, _b;
3268
- (0, import_log12.log)("closing...", {}, {
3269
- file: "service-context.ts",
3270
- line: 143,
3271
- scope: this,
3272
- callSite: (f, a) => f(...a)
3273
- });
3274
- await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
3275
- await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
3412
+ var _a;
3413
+ (0, import_log12.log)("closing...", void 0, {
3414
+ F: __dxlog_file12,
3415
+ L: 143,
3416
+ S: this,
3417
+ C: (f, a) => f(...a)
3418
+ });
3419
+ if (this._deviceSpaceSync && this.identityManager.identity) {
3420
+ await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
3421
+ }
3422
+ await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
3276
3423
  await this.identityManager.close();
3277
3424
  await this.spaceManager.close();
3278
3425
  await this.feedStore.close();
3279
3426
  await this.networkManager.close();
3280
3427
  await this.signalManager.close();
3281
3428
  this.dataServiceSubscriptions.clear();
3282
- (0, import_log12.log)("closed", {}, {
3283
- file: "service-context.ts",
3284
- line: 152,
3285
- scope: this,
3286
- callSite: (f, a) => f(...a)
3429
+ (0, import_log12.log)("closed", void 0, {
3430
+ F: __dxlog_file12,
3431
+ L: 154,
3432
+ S: this,
3433
+ C: (f, a) => f(...a)
3287
3434
  });
3288
3435
  }
3289
3436
  async createIdentity(params = {}) {
@@ -3293,7 +3440,7 @@ var ServiceContext = class {
3293
3440
  }
3294
3441
  getInvitationHandler(invitation) {
3295
3442
  const factory = this._handlerFactories.get(invitation.kind);
3296
- (0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3443
+ (0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3297
3444
  return factory(invitation);
3298
3445
  }
3299
3446
  async _acceptIdentity(params) {
@@ -3310,13 +3457,13 @@ var ServiceContext = class {
3310
3457
  // Called when identity is created.
3311
3458
  async _initialize() {
3312
3459
  var _a;
3313
- (0, import_log12.log)("initializing spaces...", {}, {
3314
- file: "service-context.ts",
3315
- line: 185,
3316
- scope: this,
3317
- callSite: (f, a) => f(...a)
3460
+ (0, import_log12.log)("initializing spaces...", void 0, {
3461
+ F: __dxlog_file12,
3462
+ L: 187,
3463
+ S: this,
3464
+ C: (f, a) => f(...a)
3318
3465
  });
3319
- const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3466
+ const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3320
3467
  const signingContext = {
3321
3468
  credentialSigner: identity.getIdentityCredentialSigner(),
3322
3469
  identityKey: identity.identityKey,
@@ -3333,12 +3480,12 @@ var ServiceContext = class {
3333
3480
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3334
3481
  await this.dataSpaceManager.open();
3335
3482
  this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3336
- (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3483
+ (0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3337
3484
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3338
3485
  });
3339
3486
  this.initialized.wake();
3340
- this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
3341
- process: async (credential) => {
3487
+ this._deviceSpaceSync = {
3488
+ processCredential: async (credential) => {
3342
3489
  const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
3343
3490
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
3344
3491
  return;
@@ -3350,10 +3497,10 @@ var ServiceContext = class {
3350
3497
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3351
3498
  details: assertion
3352
3499
  }, {
3353
- file: "service-context.ts",
3354
- line: 224,
3355
- scope: this,
3356
- callSite: (f, a) => f(...a)
3500
+ F: __dxlog_file12,
3501
+ L: 226,
3502
+ S: this,
3503
+ C: (f, a) => f(...a)
3357
3504
  });
3358
3505
  return;
3359
3506
  }
@@ -3361,10 +3508,10 @@ var ServiceContext = class {
3361
3508
  (0, import_log12.log)("space already exists, ignoring space admission", {
3362
3509
  details: assertion
3363
3510
  }, {
3364
- file: "service-context.ts",
3365
- line: 228,
3366
- scope: this,
3367
- callSite: (f, a) => f(...a)
3511
+ F: __dxlog_file12,
3512
+ L: 230,
3513
+ S: this,
3514
+ C: (f, a) => f(...a)
3368
3515
  });
3369
3516
  return;
3370
3517
  }
@@ -3372,44 +3519,47 @@ var ServiceContext = class {
3372
3519
  (0, import_log12.log)("accepting space recorded in halo", {
3373
3520
  details: assertion
3374
3521
  }, {
3375
- file: "service-context.ts",
3376
- line: 233,
3377
- scope: this,
3378
- callSite: (f, a) => f(...a)
3522
+ F: __dxlog_file12,
3523
+ L: 235,
3524
+ S: this,
3525
+ C: (f, a) => f(...a)
3379
3526
  });
3380
3527
  await this.dataSpaceManager.acceptSpace({
3381
3528
  spaceKey: assertion.spaceKey,
3382
3529
  genesisFeedKey: assertion.genesisFeedKey
3383
3530
  });
3384
3531
  } catch (err) {
3385
- import_log12.log.catch(err, {}, {
3386
- file: "service-context.ts",
3387
- line: 239,
3388
- scope: this,
3389
- callSite: (f, a) => f(...a)
3532
+ import_log12.log.catch(err, void 0, {
3533
+ F: __dxlog_file12,
3534
+ L: 241,
3535
+ S: this,
3536
+ C: (f, a) => f(...a)
3390
3537
  });
3391
3538
  }
3392
3539
  }
3393
- });
3394
- await this._deviceSpaceSync.open();
3540
+ };
3541
+ await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3395
3542
  }
3396
3543
  };
3397
3544
 
3398
3545
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3399
- var import_node_assert13 = __toESM(require("node:assert"));
3546
+ var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
3400
3547
  var import_async17 = require("@dxos/async");
3401
3548
  var import_client_protocol5 = require("@dxos/client-protocol");
3549
+ var import_document_model = require("@dxos/document-model");
3402
3550
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3403
3551
  var import_keys11 = require("@dxos/keys");
3404
3552
  var import_log15 = require("@dxos/log");
3405
3553
  var import_messaging = require("@dxos/messaging");
3554
+ var import_model_factory = require("@dxos/model-factory");
3406
3555
  var import_network_manager2 = require("@dxos/network-manager");
3407
3556
  var import_protocols9 = require("@dxos/protocols");
3408
3557
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3558
+ var import_text_model = require("@dxos/text-model");
3409
3559
 
3410
3560
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3411
3561
  var import_async15 = require("@dxos/async");
3412
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3562
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3413
3563
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3414
3564
  var DevicesServiceImpl = class {
3415
3565
  constructor(_identityManager) {
@@ -3419,7 +3569,7 @@ var DevicesServiceImpl = class {
3419
3569
  throw new Error("Method not implemented.");
3420
3570
  }
3421
3571
  queryDevices() {
3422
- return new import_codec_protobuf10.Stream(({ next }) => {
3572
+ return new import_codec_protobuf11.Stream(({ next }) => {
3423
3573
  const update = () => {
3424
3574
  var _a;
3425
3575
  const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
@@ -3455,10 +3605,10 @@ var DevicesServiceImpl = class {
3455
3605
  };
3456
3606
 
3457
3607
  // packages/sdk/client-services/src/packlets/locks/node.ts
3458
- var import_node_assert12 = __toESM(require("node:assert"));
3608
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
3459
3609
  var import_lock_file = require("@dxos/lock-file");
3460
3610
  var import_log13 = require("@dxos/log");
3461
- var __decorate3 = function(decorators, target, key, desc) {
3611
+ function _ts_decorate3(decorators, target, key, desc) {
3462
3612
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3463
3613
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3464
3614
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3467,7 +3617,8 @@ var __decorate3 = function(decorators, target, key, desc) {
3467
3617
  if (d = decorators[i])
3468
3618
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3469
3619
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3470
- };
3620
+ }
3621
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
3471
3622
  var Lock = class {
3472
3623
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3473
3624
  this._lockPath = lockPath;
@@ -3479,36 +3630,36 @@ var Lock = class {
3479
3630
  }
3480
3631
  async acquire() {
3481
3632
  var _a;
3482
- (0, import_log13.log)("acquiring lock...", {}, {
3483
- file: "node.ts",
3484
- line: 32,
3485
- scope: this,
3486
- callSite: (f, a) => f(...a)
3633
+ (0, import_log13.log)("acquiring lock...", void 0, {
3634
+ F: __dxlog_file13,
3635
+ L: 32,
3636
+ S: this,
3637
+ C: (f, a) => f(...a)
3487
3638
  });
3488
3639
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3489
3640
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3490
- (0, import_log13.log)("acquired lock", {}, {
3491
- file: "node.ts",
3492
- line: 37,
3493
- scope: this,
3494
- callSite: (f, a) => f(...a)
3641
+ (0, import_log13.log)("acquired lock", void 0, {
3642
+ F: __dxlog_file13,
3643
+ L: 37,
3644
+ S: this,
3645
+ C: (f, a) => f(...a)
3495
3646
  });
3496
3647
  }
3497
3648
  async release() {
3498
3649
  var _a;
3499
3650
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3500
- (0, import_node_assert12.default)(this._fileHandle, "Lock is not acquired");
3651
+ (0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
3501
3652
  await import_lock_file.LockFile.release(this._fileHandle);
3502
3653
  }
3503
3654
  };
3504
- __decorate3([
3655
+ _ts_decorate3([
3505
3656
  import_log13.logInfo
3506
3657
  ], Lock.prototype, "lockKey", null);
3507
3658
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
3508
3659
 
3509
3660
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3510
3661
  var import_async16 = require("@dxos/async");
3511
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3662
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3512
3663
  var import_log14 = require("@dxos/log");
3513
3664
  var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3514
3665
  var import_util7 = require("@dxos/util");
@@ -3527,13 +3678,13 @@ var LoggingServiceImpl = class {
3527
3678
  import_log14.log.runtimeConfig.processors.splice(index, 1);
3528
3679
  }
3529
3680
  queryLogs(request) {
3530
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3681
+ return new import_codec_protobuf12.Stream(({ ctx, next }) => {
3531
3682
  const handler = (entry2) => {
3532
3683
  var _a, _b, _c, _d, _e;
3533
3684
  if (LOG_PROCESSING > 0) {
3534
3685
  return;
3535
3686
  }
3536
- if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3687
+ if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3537
3688
  return;
3538
3689
  }
3539
3690
  if (!shouldLog(entry2, request)) {
@@ -3545,8 +3696,8 @@ var LoggingServiceImpl = class {
3545
3696
  timestamp: new Date(),
3546
3697
  meta: {
3547
3698
  // TODO(dmaretskyi): Fix proto.
3548
- file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
3549
- line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
3699
+ file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
3700
+ line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
3550
3701
  }
3551
3702
  };
3552
3703
  try {
@@ -3576,21 +3727,21 @@ var shouldLog = (entry2, request) => {
3576
3727
  } else {
3577
3728
  return request.filters.some((filter) => {
3578
3729
  var _a2, _b;
3579
- return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
3730
+ return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
3580
3731
  });
3581
3732
  }
3582
3733
  };
3583
3734
  var LOG_PROCESSING = 0;
3584
3735
 
3585
3736
  // packages/sdk/client-services/src/packlets/network/network-service.ts
3586
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3737
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3587
3738
  var NetworkServiceImpl = class {
3588
3739
  constructor(networkManager, signalManager) {
3589
3740
  this.networkManager = networkManager;
3590
3741
  this.signalManager = signalManager;
3591
3742
  }
3592
3743
  queryStatus() {
3593
- return new import_codec_protobuf12.Stream(({ next }) => {
3744
+ return new import_codec_protobuf13.Stream(({ next }) => {
3594
3745
  const update = () => {
3595
3746
  next({
3596
3747
  swarm: this.networkManager.connectionState,
@@ -3616,7 +3767,7 @@ var NetworkServiceImpl = class {
3616
3767
 
3617
3768
  // packages/sdk/client-services/src/packlets/storage/storage.ts
3618
3769
  var import_client_protocol4 = require("@dxos/client-protocol");
3619
- var import_errors4 = require("@dxos/errors");
3770
+ var import_errors5 = require("@dxos/errors");
3620
3771
  var import_config = require("@dxos/protocols/proto/dxos/config");
3621
3772
  var import_random_access_storage = require("@dxos/random-access-storage");
3622
3773
  var import_util8 = require("@dxos/util");
@@ -3624,16 +3775,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
3624
3775
  var createStorageObjects = (config) => {
3625
3776
  const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
3626
3777
  if (persistent && storageType === StorageDriver.RAM) {
3627
- throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3778
+ throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3628
3779
  }
3629
3780
  if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
3630
- throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3781
+ throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3631
3782
  }
3632
3783
  if (persistent && keyStorage === StorageDriver.RAM) {
3633
- throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3784
+ throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3634
3785
  }
3635
3786
  if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
3636
- throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3787
+ throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3637
3788
  }
3638
3789
  return {
3639
3790
  storage: (0, import_random_access_storage.createStorage)({
@@ -3664,7 +3815,7 @@ var toStorageType = (type) => {
3664
3815
  };
3665
3816
 
3666
3817
  // packages/sdk/client-services/src/packlets/system/system-service.ts
3667
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3818
+ var import_codec_protobuf14 = require("@dxos/codec-protobuf");
3668
3819
  var SystemServiceImpl = class {
3669
3820
  constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3670
3821
  this._config = config;
@@ -3681,7 +3832,7 @@ var SystemServiceImpl = class {
3681
3832
  await this._onUpdateStatus(status);
3682
3833
  }
3683
3834
  queryStatus() {
3684
- return new import_codec_protobuf13.Stream(({ next }) => {
3835
+ return new import_codec_protobuf14.Stream(({ next }) => {
3685
3836
  const update = () => {
3686
3837
  next({
3687
3838
  status: this._getCurrentStatus()
@@ -3726,7 +3877,7 @@ var ServiceRegistry = class {
3726
3877
  };
3727
3878
 
3728
3879
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3729
- var __decorate4 = function(decorators, target, key, desc) {
3880
+ function _ts_decorate4(decorators, target, key, desc) {
3730
3881
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3731
3882
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3732
3883
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3735,24 +3886,30 @@ var __decorate4 = function(decorators, target, key, desc) {
3735
3886
  if (d = decorators[i])
3736
3887
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3737
3888
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3889
+ }
3890
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
3891
+ var createDefaultModelFactory = () => {
3892
+ return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
3738
3893
  };
3739
3894
  var ClientServicesHost = class {
3740
3895
  constructor({
3741
3896
  config,
3742
- modelFactory = (0, import_client_protocol5.createDefaultModelFactory)(),
3897
+ modelFactory = createDefaultModelFactory(),
3743
3898
  // TODO(burdon): Create ApolloLink abstraction (see Client).
3744
3899
  transportFactory,
3745
3900
  signalManager,
3746
3901
  connectionLog,
3747
3902
  storage,
3748
3903
  // TODO(wittjosiah): Turn this on by default.
3749
- lockKey
3904
+ lockKey,
3905
+ callbacks
3750
3906
  } = {}) {
3751
3907
  this._statusUpdate = new import_async17.Event();
3752
3908
  this._opening = false;
3753
3909
  this._open = false;
3754
3910
  this._storage = storage;
3755
3911
  this._modelFactory = modelFactory;
3912
+ this._callbacks = callbacks;
3756
3913
  if (config) {
3757
3914
  this.initialize({
3758
3915
  config,
@@ -3811,9 +3968,9 @@ var ClientServicesHost = class {
3811
3968
  */
3812
3969
  initialize({ config, ...options }) {
3813
3970
  var _a, _b, _c;
3814
- (0, import_node_assert13.default)(!this._open, "service host is open");
3971
+ (0, import_tiny_invariant13.default)(!this._open, "service host is open");
3815
3972
  if (config) {
3816
- (0, import_node_assert13.default)(!this._config, "config already set");
3973
+ (0, import_tiny_invariant13.default)(!this._config, "config already set");
3817
3974
  this._config = config;
3818
3975
  if (!this._storage) {
3819
3976
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -3823,7 +3980,7 @@ var ClientServicesHost = class {
3823
3980
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
3824
3981
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
3825
3982
  this._signalManager = signalManager;
3826
- (0, import_node_assert13.default)(!this._networkManager, "network manager already set");
3983
+ (0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
3827
3984
  this._networkManager = new import_network_manager2.NetworkManager({
3828
3985
  log: connectionLog,
3829
3986
  transportFactory,
@@ -3839,23 +3996,23 @@ var ClientServicesHost = class {
3839
3996
  import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
3840
3997
  id: traceId
3841
3998
  }), {
3842
- file: "service-host.ts",
3843
- line: 188,
3844
- scope: this,
3845
- callSite: (f, a) => f(...a)
3846
- });
3847
- (0, import_node_assert13.default)(this._config, "config not set");
3848
- (0, import_node_assert13.default)(this._storage, "storage not set");
3849
- (0, import_node_assert13.default)(this._signalManager, "signal manager not set");
3850
- (0, import_node_assert13.default)(this._networkManager, "network manager not set");
3999
+ F: __dxlog_file14,
4000
+ L: 203,
4001
+ S: this,
4002
+ C: (f, a) => f(...a)
4003
+ });
4004
+ (0, import_tiny_invariant13.default)(this._config, "config not set");
4005
+ (0, import_tiny_invariant13.default)(this._storage, "storage not set");
4006
+ (0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
4007
+ (0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
3851
4008
  this._opening = true;
3852
4009
  (0, import_log15.log)("opening...", {
3853
4010
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
3854
4011
  }, {
3855
- file: "service-host.ts",
3856
- line: 196,
3857
- scope: this,
3858
- callSite: (f, a) => f(...a)
4012
+ F: __dxlog_file14,
4013
+ L: 211,
4014
+ S: this,
4015
+ C: (f, a) => f(...a)
3859
4016
  });
3860
4017
  await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
3861
4018
  await this._loggingService.open();
@@ -3887,18 +4044,18 @@ var ClientServicesHost = class {
3887
4044
  (0, import_log15.log)("opened", {
3888
4045
  deviceKey
3889
4046
  }, {
3890
- file: "service-host.ts",
3891
- line: 251,
3892
- scope: this,
3893
- callSite: (f, a) => f(...a)
4047
+ F: __dxlog_file14,
4048
+ L: 266,
4049
+ S: this,
4050
+ C: (f, a) => f(...a)
3894
4051
  });
3895
4052
  import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
3896
4053
  id: traceId
3897
4054
  }), {
3898
- file: "service-host.ts",
3899
- line: 252,
3900
- scope: this,
3901
- callSite: (f, a) => f(...a)
4055
+ F: __dxlog_file14,
4056
+ L: 267,
4057
+ S: this,
4058
+ C: (f, a) => f(...a)
3902
4059
  });
3903
4060
  }
3904
4061
  async close() {
@@ -3910,10 +4067,10 @@ var ClientServicesHost = class {
3910
4067
  (0, import_log15.log)("closing...", {
3911
4068
  deviceKey
3912
4069
  }, {
3913
- file: "service-host.ts",
3914
- line: 262,
3915
- scope: this,
3916
- callSite: (f, a) => f(...a)
4070
+ F: __dxlog_file14,
4071
+ L: 277,
4072
+ S: this,
4073
+ C: (f, a) => f(...a)
3917
4074
  });
3918
4075
  this._serviceRegistry.setServices({
3919
4076
  SystemService: this._systemService
@@ -3925,51 +4082,52 @@ var ClientServicesHost = class {
3925
4082
  (0, import_log15.log)("closed", {
3926
4083
  deviceKey
3927
4084
  }, {
3928
- file: "service-host.ts",
3929
- line: 268,
3930
- scope: this,
3931
- callSite: (f, a) => f(...a)
4085
+ F: __dxlog_file14,
4086
+ L: 283,
4087
+ S: this,
4088
+ C: (f, a) => f(...a)
3932
4089
  });
3933
4090
  }
3934
4091
  async reset() {
3935
- var _a;
4092
+ var _a, _b, _c;
3936
4093
  const traceId = import_keys11.PublicKey.random().toHex();
3937
4094
  import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
3938
4095
  id: traceId
3939
4096
  }), {
3940
- file: "service-host.ts",
3941
- line: 273,
3942
- scope: this,
3943
- callSite: (f, a) => f(...a)
4097
+ F: __dxlog_file14,
4098
+ L: 288,
4099
+ S: this,
4100
+ C: (f, a) => f(...a)
3944
4101
  });
3945
- (0, import_log15.log)("resetting...", {}, {
3946
- file: "service-host.ts",
3947
- line: 275,
3948
- scope: this,
3949
- callSite: (f, a) => f(...a)
4102
+ (0, import_log15.log)("resetting...", void 0, {
4103
+ F: __dxlog_file14,
4104
+ L: 290,
4105
+ S: this,
4106
+ C: (f, a) => f(...a)
3950
4107
  });
3951
4108
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
3952
4109
  await this._storage.reset();
3953
- (0, import_log15.log)("reset", {}, {
3954
- file: "service-host.ts",
3955
- line: 278,
3956
- scope: this,
3957
- callSite: (f, a) => f(...a)
4110
+ (0, import_log15.log)("reset", void 0, {
4111
+ F: __dxlog_file14,
4112
+ L: 293,
4113
+ S: this,
4114
+ C: (f, a) => f(...a)
3958
4115
  });
3959
4116
  import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
3960
4117
  id: traceId
3961
4118
  }), {
3962
- file: "service-host.ts",
3963
- line: 279,
3964
- scope: this,
3965
- callSite: (f, a) => f(...a)
4119
+ F: __dxlog_file14,
4120
+ L: 294,
4121
+ S: this,
4122
+ C: (f, a) => f(...a)
3966
4123
  });
4124
+ await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
3967
4125
  }
3968
4126
  };
3969
- __decorate4([
4127
+ _ts_decorate4([
3970
4128
  import_async17.synchronized
3971
4129
  ], ClientServicesHost.prototype, "open", null);
3972
- __decorate4([
4130
+ _ts_decorate4([
3973
4131
  import_async17.synchronized
3974
4132
  ], ClientServicesHost.prototype, "close", null);
3975
4133
 
@@ -3981,61 +4139,8 @@ var import_messaging2 = require("@dxos/messaging");
3981
4139
  var import_network_manager3 = require("@dxos/network-manager");
3982
4140
  var import_util9 = require("@dxos/util");
3983
4141
 
3984
- // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
3985
- var import_codec_protobuf14 = require("@dxos/codec-protobuf");
3986
- var import_debug7 = require("@dxos/debug");
3987
- var import_rpc = require("@dxos/rpc");
3988
- var ClientRpcServer = class {
3989
- constructor(params) {
3990
- this._handlerCache = /* @__PURE__ */ new Map();
3991
- const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
3992
- this._handleCall = handleCall;
3993
- this._handleStream = handleStream;
3994
- this._serviceRegistry = serviceRegistry;
3995
- this._rpcPeer = new import_rpc.RpcPeer({
3996
- ...rpcOptions,
3997
- callHandler: (method, params2) => {
3998
- const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
3999
- const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
4000
- if (this._handleCall) {
4001
- return this._handleCall(methodName, params2, handler);
4002
- } else {
4003
- return handler(methodName, params2);
4004
- }
4005
- },
4006
- streamHandler: (method, params2) => {
4007
- const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
4008
- const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
4009
- if (this._handleStream) {
4010
- return import_codec_protobuf14.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
4011
- } else {
4012
- return handler(methodName, params2);
4013
- }
4014
- }
4015
- });
4016
- }
4017
- async open() {
4018
- await this._rpcPeer.open();
4019
- }
4020
- async close() {
4021
- await this._rpcPeer.close();
4022
- }
4023
- _getServiceHandler(serviceName) {
4024
- var _a;
4025
- if (!this._handlerCache.has(serviceName)) {
4026
- const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug7.raise)(new Error(`Service not available: ${serviceName}`));
4027
- const service = this._serviceRegistry.services[key];
4028
- if (!service) {
4029
- throw new Error(`Service not available: ${serviceName}`);
4030
- }
4031
- this._handlerCache.set(serviceName, descriptor.createServer(service));
4032
- }
4033
- return this._handlerCache.get(serviceName);
4034
- }
4035
- };
4036
-
4037
4142
  // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
4038
- var import_node_assert14 = __toESM(require("node:assert"));
4143
+ var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
4039
4144
  var import_async18 = require("@dxos/async");
4040
4145
  var import_client_protocol6 = require("@dxos/client-protocol");
4041
4146
  var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
@@ -4065,7 +4170,7 @@ var ShellRuntimeImpl = class {
4065
4170
  });
4066
4171
  }
4067
4172
  async setAppContext(context) {
4068
- (0, import_node_assert14.default)(this._appRpc, "runtime not open");
4173
+ (0, import_tiny_invariant14.default)(this._appRpc, "runtime not open");
4069
4174
  await this._appRpc.rpc.AppService.setContext(context);
4070
4175
  }
4071
4176
  async open() {
@@ -4092,39 +4197,9 @@ var ShellRuntimeImpl = class {
4092
4197
  this._appRpc = void 0;
4093
4198
  }
4094
4199
  };
4095
- var MemoryShellRuntime = class {
4096
- constructor({ layout, invitationCode, spaceKey } = {}) {
4097
- this.layoutUpdate = new import_async18.Event();
4098
- this.contextUpdate = new import_async18.Event();
4099
- this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
4100
- this._invitationCode = invitationCode;
4101
- this._spaceKey = spaceKey;
4102
- }
4103
- get layout() {
4104
- return this._layout;
4105
- }
4106
- get invitationCode() {
4107
- return this._invitationCode;
4108
- }
4109
- get spaceKey() {
4110
- return this._spaceKey;
4111
- }
4112
- setLayout(layout, options = {}) {
4113
- this._layout = layout;
4114
- this._invitationCode = options.invitationCode;
4115
- this._spaceKey = options.spaceKey;
4116
- this.layoutUpdate.emit({
4117
- layout,
4118
- ...options
4119
- });
4120
- }
4121
- async setAppContext(context) {
4122
- this.contextUpdate.emit(context);
4123
- }
4124
- };
4125
4200
 
4126
4201
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
4127
- var __decorate5 = function(decorators, target, key, desc) {
4202
+ function _ts_decorate5(decorators, target, key, desc) {
4128
4203
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4129
4204
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4130
4205
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4133,7 +4208,8 @@ var __decorate5 = function(decorators, target, key, desc) {
4133
4208
  if (d = decorators[i])
4134
4209
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4135
4210
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4136
- };
4211
+ }
4212
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
4137
4213
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
4138
4214
  var IFrameHostRuntime = class {
4139
4215
  constructor({ config, origin, appPort, shellPort }) {
@@ -4154,11 +4230,11 @@ var IFrameHostRuntime = class {
4154
4230
  }
4155
4231
  async start() {
4156
4232
  var _a;
4157
- (0, import_log16.log)("starting...", {}, {
4158
- file: "iframe-host-runtime.ts",
4159
- line: 70,
4160
- scope: this,
4161
- callSite: (f, a) => f(...a)
4233
+ (0, import_log16.log)("starting...", void 0, {
4234
+ F: __dxlog_file15,
4235
+ L: 70,
4236
+ S: this,
4237
+ C: (f, a) => f(...a)
4162
4238
  });
4163
4239
  try {
4164
4240
  this._config = await (0, import_util9.getAsyncValue)(this._configProvider);
@@ -4203,53 +4279,54 @@ var IFrameHostRuntime = class {
4203
4279
  (_a = this._shellRuntime) == null ? void 0 : _a.open()
4204
4280
  ]);
4205
4281
  this._ready.wake(void 0);
4206
- (0, import_log16.log)("started", {}, {
4207
- file: "iframe-host-runtime.ts",
4208
- line: 113,
4209
- scope: this,
4210
- callSite: (f, a) => f(...a)
4282
+ (0, import_log16.log)("started", void 0, {
4283
+ F: __dxlog_file15,
4284
+ L: 113,
4285
+ S: this,
4286
+ C: (f, a) => f(...a)
4211
4287
  });
4212
4288
  } catch (err) {
4213
4289
  this._ready.wake(err);
4214
- import_log16.log.catch(err, {}, {
4215
- file: "iframe-host-runtime.ts",
4216
- line: 116,
4217
- scope: this,
4218
- callSite: (f, a) => f(...a)
4290
+ import_log16.log.catch(err, void 0, {
4291
+ F: __dxlog_file15,
4292
+ L: 116,
4293
+ S: this,
4294
+ C: (f, a) => f(...a)
4219
4295
  });
4220
4296
  }
4221
4297
  }
4222
4298
  async stop() {
4223
4299
  var _a;
4224
- (0, import_log16.log)("stopping...", {}, {
4225
- file: "iframe-host-runtime.ts",
4226
- line: 121,
4227
- scope: this,
4228
- callSite: (f, a) => f(...a)
4300
+ (0, import_log16.log)("stopping...", void 0, {
4301
+ F: __dxlog_file15,
4302
+ L: 121,
4303
+ S: this,
4304
+ C: (f, a) => f(...a)
4229
4305
  });
4230
4306
  await this._clientRpc.close();
4231
4307
  await this._clientServices.close();
4232
4308
  await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
4233
- (0, import_log16.log)("stopped", {}, {
4234
- file: "iframe-host-runtime.ts",
4235
- line: 125,
4236
- scope: this,
4237
- callSite: (f, a) => f(...a)
4309
+ (0, import_log16.log)("stopped", void 0, {
4310
+ F: __dxlog_file15,
4311
+ L: 125,
4312
+ S: this,
4313
+ C: (f, a) => f(...a)
4238
4314
  });
4239
4315
  }
4240
4316
  };
4241
- __decorate5([
4317
+ _ts_decorate5([
4242
4318
  import_log16.logInfo
4243
4319
  ], IFrameHostRuntime.prototype, "origin", void 0);
4244
4320
 
4245
4321
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
4246
4322
  var import_async20 = require("@dxos/async");
4247
4323
  var import_client_protocol8 = require("@dxos/client-protocol");
4248
- var import_errors5 = require("@dxos/errors");
4324
+ var import_errors6 = require("@dxos/errors");
4249
4325
  var import_log17 = require("@dxos/log");
4250
4326
  var import_network_manager4 = require("@dxos/network-manager");
4251
4327
  var import_rpc3 = require("@dxos/rpc");
4252
4328
  var import_util10 = require("@dxos/util");
4329
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
4253
4330
  var IFrameProxyRuntime = class {
4254
4331
  constructor({ config, systemPort, shellPort }) {
4255
4332
  this._id = String(Math.floor(Math.random() * 1e6));
@@ -4297,13 +4374,13 @@ var IFrameProxyRuntime = class {
4297
4374
  lockKey
4298
4375
  });
4299
4376
  } catch (err) {
4300
- import_log17.log.catch(err, {}, {
4301
- file: "iframe-proxy-runtime.ts",
4302
- line: 85,
4303
- scope: this,
4304
- callSite: (f, a) => f(...a)
4377
+ import_log17.log.catch(err, void 0, {
4378
+ F: __dxlog_file16,
4379
+ L: 85,
4380
+ S: this,
4381
+ C: (f, a) => f(...a)
4305
4382
  });
4306
- throw new import_errors5.RemoteServiceConnectionError("Failed to connect to worker");
4383
+ throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
4307
4384
  }
4308
4385
  await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
4309
4386
  }
@@ -4326,13 +4403,13 @@ var import_messaging3 = require("@dxos/messaging");
4326
4403
  var import_network_manager5 = require("@dxos/network-manager");
4327
4404
 
4328
4405
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
4329
- var import_node_assert15 = __toESM(require("node:assert"));
4406
+ var import_tiny_invariant15 = __toESM(require("tiny-invariant"));
4330
4407
  var import_async21 = require("@dxos/async");
4331
4408
  var import_client_protocol9 = require("@dxos/client-protocol");
4332
4409
  var import_log18 = require("@dxos/log");
4333
4410
  var import_rpc4 = require("@dxos/rpc");
4334
4411
  var import_util11 = require("@dxos/util");
4335
- var __decorate6 = function(decorators, target, key, desc) {
4412
+ function _ts_decorate6(decorators, target, key, desc) {
4336
4413
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4337
4414
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4338
4415
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4341,12 +4418,13 @@ var __decorate6 = function(decorators, target, key, desc) {
4341
4418
  if (d = decorators[i])
4342
4419
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4343
4420
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4344
- };
4421
+ }
4422
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
4345
4423
  var WorkerSession = class {
4346
4424
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
4347
4425
  this._startTrigger = new import_async21.Trigger();
4348
4426
  this.onClose = new import_util11.Callback();
4349
- (0, import_node_assert15.default)(serviceHost);
4427
+ (0, import_tiny_invariant15.default)(serviceHost);
4350
4428
  this._serviceHost = serviceHost;
4351
4429
  const middleware = {
4352
4430
  handleCall: async (method, params, handler) => {
@@ -4393,11 +4471,11 @@ var WorkerSession = class {
4393
4471
  try {
4394
4472
  await this.close();
4395
4473
  } catch (err) {
4396
- import_log18.log.catch(err, {}, {
4397
- file: "worker-session.ts",
4398
- line: 100,
4399
- scope: this,
4400
- callSite: (f, a) => f(...a)
4474
+ import_log18.log.catch(err, void 0, {
4475
+ F: __dxlog_file17,
4476
+ L: 99,
4477
+ S: this,
4478
+ C: (f, a) => f(...a)
4401
4479
  });
4402
4480
  }
4403
4481
  });
@@ -4410,11 +4488,11 @@ var WorkerSession = class {
4410
4488
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
4411
4489
  }
4412
4490
  async open() {
4413
- import_log18.log.info("opening..", {}, {
4414
- file: "worker-session.ts",
4415
- line: 114,
4416
- scope: this,
4417
- callSite: (f, a) => f(...a)
4491
+ import_log18.log.info("opening...", void 0, {
4492
+ F: __dxlog_file17,
4493
+ L: 113,
4494
+ S: this,
4495
+ C: (f, a) => f(...a)
4418
4496
  });
4419
4497
  await Promise.all([
4420
4498
  this._clientRpc.open(),
@@ -4427,38 +4505,50 @@ var WorkerSession = class {
4427
4505
  if (this.lockKey) {
4428
4506
  void this._afterLockReleases(this.lockKey, () => this.close());
4429
4507
  }
4508
+ import_log18.log.info("opened", void 0, {
4509
+ F: __dxlog_file17,
4510
+ L: 120,
4511
+ S: this,
4512
+ C: (f, a) => f(...a)
4513
+ });
4430
4514
  }
4431
4515
  async close() {
4432
- import_log18.log.info("closing..", {}, {
4433
- file: "worker-session.ts",
4434
- line: 124,
4435
- scope: this,
4436
- callSite: (f, a) => f(...a)
4516
+ import_log18.log.info("closing...", void 0, {
4517
+ F: __dxlog_file17,
4518
+ L: 124,
4519
+ S: this,
4520
+ C: (f, a) => f(...a)
4437
4521
  });
4438
4522
  try {
4439
4523
  await this.onClose.callIfSet();
4440
4524
  } catch (err) {
4441
- import_log18.log.catch(err, {}, {
4442
- file: "worker-session.ts",
4443
- line: 128,
4444
- scope: this,
4445
- callSite: (f, a) => f(...a)
4525
+ import_log18.log.catch(err, void 0, {
4526
+ F: __dxlog_file17,
4527
+ L: 128,
4528
+ S: this,
4529
+ C: (f, a) => f(...a)
4446
4530
  });
4447
4531
  }
4448
4532
  await Promise.all([
4449
4533
  this._clientRpc.close(),
4450
4534
  this._iframeRpc.close()
4451
4535
  ]);
4536
+ import_log18.log.info("closed", void 0, {
4537
+ F: __dxlog_file17,
4538
+ L: 132,
4539
+ S: this,
4540
+ C: (f, a) => f(...a)
4541
+ });
4452
4542
  }
4453
4543
  async _maybeOpenShell() {
4454
4544
  try {
4455
4545
  await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
4456
4546
  } catch (e) {
4457
- import_log18.log.info("No shell connected.", {}, {
4458
- file: "worker-session.ts",
4459
- line: 138,
4460
- scope: this,
4461
- callSite: (f, a) => f(...a)
4547
+ import_log18.log.info("No shell connected.", void 0, {
4548
+ F: __dxlog_file17,
4549
+ L: 139,
4550
+ S: this,
4551
+ C: (f, a) => f(...a)
4462
4552
  });
4463
4553
  }
4464
4554
  }
@@ -4467,14 +4557,15 @@ var WorkerSession = class {
4467
4557
  }).then(callback);
4468
4558
  }
4469
4559
  };
4470
- __decorate6([
4560
+ _ts_decorate6([
4471
4561
  import_log18.logInfo
4472
4562
  ], WorkerSession.prototype, "origin", void 0);
4473
- __decorate6([
4563
+ _ts_decorate6([
4474
4564
  import_log18.logInfo
4475
4565
  ], WorkerSession.prototype, "lockKey", void 0);
4476
4566
 
4477
4567
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
4568
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
4478
4569
  var WorkerRuntime = class {
4479
4570
  // prettier-ignore
4480
4571
  constructor(_configProvider) {
@@ -4482,17 +4573,23 @@ var WorkerRuntime = class {
4482
4573
  this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
4483
4574
  this._ready = new import_async22.Trigger();
4484
4575
  this.sessions = /* @__PURE__ */ new Set();
4485
- this._clientServices = new ClientServicesHost();
4576
+ this._clientServices = new ClientServicesHost({
4577
+ callbacks: {
4578
+ onReset: async () => {
4579
+ self.close();
4580
+ }
4581
+ }
4582
+ });
4486
4583
  }
4487
4584
  get host() {
4488
4585
  return this._clientServices;
4489
4586
  }
4490
4587
  async start() {
4491
- (0, import_log19.log)("starting...", {}, {
4492
- file: "worker-runtime.ts",
4493
- line: 48,
4494
- scope: this,
4495
- callSite: (f, a) => f(...a)
4588
+ (0, import_log19.log)("starting...", void 0, {
4589
+ F: __dxlog_file18,
4590
+ L: 48,
4591
+ S: this,
4592
+ C: (f, a) => f(...a)
4496
4593
  });
4497
4594
  try {
4498
4595
  this._config = await this._configProvider();
@@ -4504,19 +4601,19 @@ var WorkerRuntime = class {
4504
4601
  });
4505
4602
  await this._clientServices.open();
4506
4603
  this._ready.wake(void 0);
4507
- (0, import_log19.log)("started", {}, {
4508
- file: "worker-runtime.ts",
4509
- line: 62,
4510
- scope: this,
4511
- callSite: (f, a) => f(...a)
4604
+ (0, import_log19.log)("started", void 0, {
4605
+ F: __dxlog_file18,
4606
+ L: 62,
4607
+ S: this,
4608
+ C: (f, a) => f(...a)
4512
4609
  });
4513
4610
  } catch (err) {
4514
4611
  this._ready.wake(err);
4515
- import_log19.log.catch(err, {}, {
4516
- file: "worker-runtime.ts",
4517
- line: 65,
4518
- scope: this,
4519
- callSite: (f, a) => f(...a)
4612
+ import_log19.log.catch(err, void 0, {
4613
+ F: __dxlog_file18,
4614
+ L: 65,
4615
+ S: this,
4616
+ C: (f, a) => f(...a)
4520
4617
  });
4521
4618
  }
4522
4619
  }
@@ -4546,11 +4643,11 @@ var WorkerRuntime = class {
4546
4643
  * Selects one of the existing session fro WebRTC networking.
4547
4644
  */
4548
4645
  _reconnectWebrtc() {
4549
- (0, import_log19.log)("reconnecting webrtc...", {}, {
4550
- file: "worker-runtime.ts",
4551
- line: 102,
4552
- scope: this,
4553
- callSite: (f, a) => f(...a)
4646
+ (0, import_log19.log)("reconnecting webrtc...", void 0, {
4647
+ F: __dxlog_file18,
4648
+ L: 102,
4649
+ S: this,
4650
+ C: (f, a) => f(...a)
4554
4651
  });
4555
4652
  if (this._sessionForNetworking) {
4556
4653
  if (!this.sessions.has(this._sessionForNetworking)) {
@@ -4570,6 +4667,7 @@ var WorkerRuntime = class {
4570
4667
  };
4571
4668
  // Annotate the CommonJS export names for ESM import in node:
4572
4669
  0 && (module.exports = {
4670
+ ClientRpcServer,
4573
4671
  ClientServicesHost,
4574
4672
  DataSpace,
4575
4673
  DataSpaceManager,
@@ -4584,7 +4682,6 @@ var WorkerRuntime = class {
4584
4682
  InvitationsHandler,
4585
4683
  InvitationsServiceImpl,
4586
4684
  Lock,
4587
- MemoryShellRuntime,
4588
4685
  ServiceContext,
4589
4686
  ServiceRegistry,
4590
4687
  ShellRuntimeImpl,
@@ -4594,6 +4691,7 @@ var WorkerRuntime = class {
4594
4691
  WorkerRuntime,
4595
4692
  WorkerSession,
4596
4693
  createAuthProvider,
4694
+ createDefaultModelFactory,
4597
4695
  createStorageObjects,
4598
4696
  getNetworkPeers,
4599
4697
  isLocked,