@dxos/client-services 0.1.53-next.db41187 → 0.1.53-next.e9dc2bc

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