@dxos/client-services 0.3.9-main.c2ac8a5 → 0.3.9-main.c64f707

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 (40) hide show
  1. package/dist/lib/browser/{chunk-GX2QS37G.mjs → chunk-LUA2PRME.mjs} +129 -65
  2. package/dist/lib/browser/chunk-LUA2PRME.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +7 -3
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-V5ZH44RD.cjs → chunk-OTXGXWD2.cjs} +130 -77
  8. package/dist/lib/node/chunk-OTXGXWD2.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +37 -37
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +11 -8
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/services/automerge-host.test.d.ts +2 -0
  14. package/dist/types/src/packlets/services/automerge-host.test.d.ts.map +1 -0
  15. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  16. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +8 -0
  19. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -0
  20. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +3 -2
  21. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space.d.ts +7 -2
  23. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
  25. package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
  26. package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
  27. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  28. package/dist/types/src/version.d.ts +1 -1
  29. package/package.json +35 -35
  30. package/src/packlets/services/automerge-host.test.ts +56 -0
  31. package/src/packlets/services/service-context.ts +6 -0
  32. package/src/packlets/services/service-host.ts +5 -2
  33. package/src/packlets/spaces/automerge-space-state.ts +22 -0
  34. package/src/packlets/spaces/data-space-manager.ts +13 -2
  35. package/src/packlets/spaces/data-space.ts +52 -6
  36. package/src/packlets/spaces/genesis.ts +7 -1
  37. package/src/packlets/testing/test-builder.ts +7 -0
  38. package/src/version.ts +1 -1
  39. package/dist/lib/browser/chunk-GX2QS37G.mjs.map +0 -7
  40. package/dist/lib/node/chunk-V5ZH44RD.cjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_V5ZH44RD_exports = {};
30
- __export(chunk_V5ZH44RD_exports, {
29
+ var chunk_OTXGXWD2_exports = {};
30
+ __export(chunk_OTXGXWD2_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_V5ZH44RD_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_V5ZH44RD_exports);
63
+ module.exports = __toCommonJS(chunk_OTXGXWD2_exports);
64
64
  var import_async = require("@dxos/async");
65
65
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
66
  var import_feed_store = require("@dxos/feed-store");
@@ -164,6 +164,7 @@ var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials"
164
164
  var import_timeframe2 = require("@dxos/timeframe");
165
165
  var import_tracing4 = require("@dxos/tracing");
166
166
  var import_util4 = require("@dxos/util");
167
+ var import_credentials11 = require("@dxos/credentials");
167
168
  var import_async11 = require("@dxos/async");
168
169
  var import_context7 = require("@dxos/context");
169
170
  var import_invariant10 = require("@dxos/invariant");
@@ -174,7 +175,7 @@ var import_teleport2 = require("@dxos/teleport");
174
175
  var import_util5 = require("@dxos/util");
175
176
  var import_async12 = require("@dxos/async");
176
177
  var import_context8 = require("@dxos/context");
177
- var import_credentials11 = require("@dxos/credentials");
178
+ var import_credentials12 = require("@dxos/credentials");
178
179
  var import_invariant11 = require("@dxos/invariant");
179
180
  var import_keys9 = require("@dxos/keys");
180
181
  var import_log11 = require("@dxos/log");
@@ -182,9 +183,9 @@ var import_protocols8 = require("@dxos/protocols");
182
183
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
183
184
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
184
185
  var import_util6 = require("@dxos/util");
185
- var import_credentials12 = require("@dxos/credentials");
186
+ var import_credentials13 = require("@dxos/credentials");
186
187
  var import_debug5 = require("@dxos/debug");
187
- var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
188
+ var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
188
189
  var import_timeframe3 = require("@dxos/timeframe");
189
190
  var import_async13 = require("@dxos/async");
190
191
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
@@ -195,7 +196,7 @@ var import_protocols9 = require("@dxos/protocols");
195
196
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
196
197
  var import_async14 = require("@dxos/async");
197
198
  var import_context9 = require("@dxos/context");
198
- var import_credentials14 = require("@dxos/credentials");
199
+ var import_credentials15 = require("@dxos/credentials");
199
200
  var import_debug7 = require("@dxos/debug");
200
201
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
201
202
  var import_feed_store4 = require("@dxos/feed-store");
@@ -2648,7 +2649,7 @@ var getPlatform = () => {
2648
2649
  };
2649
2650
  }
2650
2651
  };
2651
- var DXOS_VERSION = "0.3.9-main.c2ac8a5";
2652
+ var DXOS_VERSION = "0.3.9-main.c64f707";
2652
2653
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2653
2654
  var DEFAULT_TIMEOUT = 1e3;
2654
2655
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -2770,6 +2771,21 @@ var getSpaceStats = async (space) => {
2770
2771
  }
2771
2772
  return stats;
2772
2773
  };
2774
+ var AutomergeSpaceState = class {
2775
+ constructor() {
2776
+ this.rootUrl = void 0;
2777
+ this.lastEpoch = void 0;
2778
+ }
2779
+ async processCredential(credential) {
2780
+ if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
2781
+ return;
2782
+ }
2783
+ this.lastEpoch = credential;
2784
+ if (credential.subject.assertion.automergeRoot) {
2785
+ this.rootUrl = credential.subject.assertion.automergeRoot;
2786
+ }
2787
+ }
2788
+ };
2773
2789
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2774
2790
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2775
2791
  var DEFAULT_SUCCESS_DELAY = 1e3;
@@ -3044,6 +3060,8 @@ var DataSpace = class DataSpace2 {
3044
3060
  constructor(params) {
3045
3061
  this._ctx = new import_context6.Context();
3046
3062
  this._notarizationPlugin = new NotarizationPlugin();
3063
+ this._cache = void 0;
3064
+ this._automergeSpaceState = new AutomergeSpaceState();
3047
3065
  this._state = import_services7.SpaceState.CLOSED;
3048
3066
  this.error = void 0;
3049
3067
  this.stateUpdate = new import_async10.Event();
@@ -3057,6 +3075,7 @@ var DataSpace = class DataSpace2 {
3057
3075
  this._metadataStore = params.metadataStore;
3058
3076
  this._signingContext = params.signingContext;
3059
3077
  this._callbacks = params.callbacks ?? {};
3078
+ this._automergeHost = params.automergeHost;
3060
3079
  this.authVerifier = new TrustedKeySetAuthVerifier({
3061
3080
  trustedKeysProvider: () => new import_util4.ComplexSet(import_keys7.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
3062
3081
  update: this._inner.stateUpdate,
@@ -3068,7 +3087,7 @@ var DataSpace = class DataSpace2 {
3068
3087
  state: import_services7.SpaceState[this._state]
3069
3088
  }, {
3070
3089
  F: __dxlog_file12,
3071
- L: 118,
3090
+ L: 137,
3072
3091
  S: this,
3073
3092
  C: (f, a) => f(...a)
3074
3093
  });
@@ -3098,6 +3117,9 @@ var DataSpace = class DataSpace2 {
3098
3117
  get cache() {
3099
3118
  return this._cache;
3100
3119
  }
3120
+ get automergeSpaceState() {
3121
+ return this._automergeSpaceState;
3122
+ }
3101
3123
  async open() {
3102
3124
  await this._open();
3103
3125
  }
@@ -3105,13 +3127,14 @@ var DataSpace = class DataSpace2 {
3105
3127
  await this._gossip.open();
3106
3128
  await this._notarizationPlugin.open();
3107
3129
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3130
+ await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3108
3131
  await this._inner.open(new import_context6.Context());
3109
3132
  this._state = import_services7.SpaceState.CONTROL_ONLY;
3110
3133
  (0, import_log9.log)("new state", {
3111
3134
  state: import_services7.SpaceState[this._state]
3112
3135
  }, {
3113
3136
  F: __dxlog_file12,
3114
- L: 165,
3137
+ L: 189,
3115
3138
  S: this,
3116
3139
  C: (f, a) => f(...a)
3117
3140
  });
@@ -3129,7 +3152,7 @@ var DataSpace = class DataSpace2 {
3129
3152
  state: import_services7.SpaceState[this._state]
3130
3153
  }, {
3131
3154
  F: __dxlog_file12,
3132
- L: 179,
3155
+ L: 203,
3133
3156
  S: this,
3134
3157
  C: (f, a) => f(...a)
3135
3158
  });
@@ -3137,6 +3160,7 @@ var DataSpace = class DataSpace2 {
3137
3160
  this._ctx = new import_context6.Context();
3138
3161
  await this.authVerifier.close();
3139
3162
  await this._inner.close();
3163
+ await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
3140
3164
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
3141
3165
  await this._notarizationPlugin.close();
3142
3166
  await this._presence.destroy();
@@ -3160,7 +3184,7 @@ var DataSpace = class DataSpace2 {
3160
3184
  if (err instanceof import_protocols6.CancelledError) {
3161
3185
  (0, import_log9.log)("data pipeline initialization cancelled", err, {
3162
3186
  F: __dxlog_file12,
3163
- L: 211,
3187
+ L: 236,
3164
3188
  S: this,
3165
3189
  C: (f, a) => f(...a)
3166
3190
  });
@@ -3168,7 +3192,7 @@ var DataSpace = class DataSpace2 {
3168
3192
  }
3169
3193
  import_log9.log.error("Error initializing data pipeline", err, {
3170
3194
  F: __dxlog_file12,
3171
- L: 215,
3195
+ L: 240,
3172
3196
  S: this,
3173
3197
  C: (f, a) => f(...a)
3174
3198
  });
@@ -3177,7 +3201,7 @@ var DataSpace = class DataSpace2 {
3177
3201
  state: import_services7.SpaceState[this._state]
3178
3202
  }, {
3179
3203
  F: __dxlog_file12,
3180
- L: 217,
3204
+ L: 242,
3181
3205
  S: this,
3182
3206
  C: (f, a) => f(...a)
3183
3207
  });
@@ -3197,7 +3221,7 @@ var DataSpace = class DataSpace2 {
3197
3221
  state: import_services7.SpaceState[this._state]
3198
3222
  }, {
3199
3223
  F: __dxlog_file12,
3200
- L: 233,
3224
+ L: 258,
3201
3225
  S: this,
3202
3226
  C: (f, a) => f(...a)
3203
3227
  });
@@ -3208,7 +3232,7 @@ var DataSpace = class DataSpace2 {
3208
3232
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3209
3233
  (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
3210
3234
  F: __dxlog_file12,
3211
- L: 247,
3235
+ L: 272,
3212
3236
  S: this,
3213
3237
  C: (f, a) => f(...a)
3214
3238
  });
@@ -3219,7 +3243,7 @@ var DataSpace = class DataSpace2 {
3219
3243
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3220
3244
  (0, import_log9.log)("data pipeline ready", void 0, {
3221
3245
  F: __dxlog_file12,
3222
- L: 256,
3246
+ L: 281,
3223
3247
  S: this,
3224
3248
  C: (f, a) => f(...a)
3225
3249
  });
@@ -3229,7 +3253,7 @@ var DataSpace = class DataSpace2 {
3229
3253
  state: import_services7.SpaceState[this._state]
3230
3254
  }, {
3231
3255
  F: __dxlog_file12,
3232
- L: 260,
3256
+ L: 285,
3233
3257
  S: this,
3234
3258
  C: (f, a) => f(...a)
3235
3259
  });
@@ -3245,7 +3269,7 @@ var DataSpace = class DataSpace2 {
3245
3269
  await this._createWritableFeeds();
3246
3270
  (0, import_log9.log)("writable feeds created", void 0, {
3247
3271
  F: __dxlog_file12,
3248
- L: 276,
3272
+ L: 301,
3249
3273
  S: this,
3250
3274
  C: (f, a) => f(...a)
3251
3275
  });
@@ -3317,8 +3341,28 @@ var DataSpace = class DataSpace2 {
3317
3341
  }
3318
3342
  });
3319
3343
  }
3320
- async createEpoch() {
3321
- const epoch = await this.dataPipeline.createEpoch();
3344
+ async createEpoch(options) {
3345
+ let epoch;
3346
+ switch (options?.migration) {
3347
+ case void 0:
3348
+ case import_services7.CreateEpochRequest.Migration.NONE:
3349
+ {
3350
+ epoch = await this.dataPipeline.createEpoch();
3351
+ }
3352
+ break;
3353
+ case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3354
+ const document = this._automergeHost.repo.create();
3355
+ epoch = {
3356
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3357
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3358
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3359
+ automergeRoot: document.url
3360
+ };
3361
+ }
3362
+ }
3363
+ if (!epoch) {
3364
+ return;
3365
+ }
3322
3366
  const receipt = await this.inner.controlPipeline.writer.write({
3323
3367
  credential: {
3324
3368
  credential: await this._signingContext.credentialSigner.createCredential({
@@ -3365,7 +3409,7 @@ var DataSpace = class DataSpace2 {
3365
3409
  state: import_services7.SpaceState[this._state]
3366
3410
  }, {
3367
3411
  F: __dxlog_file12,
3368
- L: 404,
3412
+ L: 450,
3369
3413
  S: this,
3370
3414
  C: (f, a) => f(...a)
3371
3415
  });
@@ -3400,9 +3444,9 @@ _ts_decorate4([
3400
3444
  DataSpace = _ts_decorate4([
3401
3445
  (0, import_async10.trackLeaks)("open", "close")
3402
3446
  ], DataSpace);
3403
- var spaceGenesis = async (keyring, signingContext, space) => {
3447
+ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3404
3448
  const credentials = [
3405
- await (0, import_credentials12.createCredential)({
3449
+ await (0, import_credentials13.createCredential)({
3406
3450
  signer: keyring,
3407
3451
  issuer: space.key,
3408
3452
  subject: space.key,
@@ -3411,14 +3455,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3411
3455
  spaceKey: space.key
3412
3456
  }
3413
3457
  }),
3414
- await (0, import_credentials12.createCredential)({
3458
+ await (0, import_credentials13.createCredential)({
3415
3459
  signer: keyring,
3416
3460
  issuer: space.key,
3417
3461
  subject: signingContext.identityKey,
3418
3462
  assertion: {
3419
3463
  "@type": "dxos.halo.credentials.SpaceMember",
3420
3464
  spaceKey: space.key,
3421
- role: import_credentials13.SpaceMember.Role.ADMIN,
3465
+ role: import_credentials14.SpaceMember.Role.ADMIN,
3422
3466
  profile: signingContext.getProfile(),
3423
3467
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
3424
3468
  }
@@ -3430,7 +3474,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3430
3474
  spaceKey: space.key,
3431
3475
  identityKey: signingContext.identityKey,
3432
3476
  deviceKey: signingContext.deviceKey,
3433
- designation: import_credentials13.AdmittedFeed.Designation.CONTROL
3477
+ designation: import_credentials14.AdmittedFeed.Designation.CONTROL
3434
3478
  }
3435
3479
  }),
3436
3480
  await signingContext.credentialSigner.createCredential({
@@ -3440,7 +3484,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3440
3484
  spaceKey: space.key,
3441
3485
  identityKey: signingContext.identityKey,
3442
3486
  deviceKey: signingContext.deviceKey,
3443
- designation: import_credentials13.AdmittedFeed.Designation.DATA
3487
+ designation: import_credentials14.AdmittedFeed.Designation.DATA
3444
3488
  }
3445
3489
  }),
3446
3490
  await signingContext.credentialSigner.createCredential({
@@ -3450,7 +3494,8 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3450
3494
  number: 0,
3451
3495
  previousId: void 0,
3452
3496
  timeframe: new import_timeframe3.Timeframe(),
3453
- snapshotCid: void 0
3497
+ snapshotCid: void 0,
3498
+ automergeRoot
3454
3499
  }
3455
3500
  })
3456
3501
  ];
@@ -3477,13 +3522,14 @@ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
3477
3522
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3478
3523
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3479
3524
  var DataSpaceManager = class DataSpaceManager2 {
3480
- constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
3525
+ constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3481
3526
  this._spaceManager = _spaceManager;
3482
3527
  this._metadataStore = _metadataStore;
3483
3528
  this._dataServiceSubscriptions = _dataServiceSubscriptions;
3484
3529
  this._keyring = _keyring;
3485
3530
  this._signingContext = _signingContext;
3486
3531
  this._feedStore = _feedStore;
3532
+ this._automergeHost = _automergeHost;
3487
3533
  this._ctx = new import_context8.Context();
3488
3534
  this.updated = new import_async12.Event();
3489
3535
  this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
@@ -3497,7 +3543,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3497
3543
  async open() {
3498
3544
  (0, import_log11.log)("open", void 0, {
3499
3545
  F: __dxlog_file13,
3500
- L: 83,
3546
+ L: 90,
3501
3547
  S: this,
3502
3548
  C: (f, a) => f(...a)
3503
3549
  });
@@ -3505,7 +3551,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3505
3551
  id: this._instanceId
3506
3552
  }), {
3507
3553
  F: __dxlog_file13,
3508
- L: 84,
3554
+ L: 91,
3509
3555
  S: this,
3510
3556
  C: (f, a) => f(...a)
3511
3557
  });
@@ -3513,7 +3559,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3513
3559
  spaces: this._metadataStore.spaces.length
3514
3560
  }, {
3515
3561
  F: __dxlog_file13,
3516
- L: 85,
3562
+ L: 92,
3517
3563
  S: this,
3518
3564
  C: (f, a) => f(...a)
3519
3565
  });
@@ -3523,7 +3569,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3523
3569
  spaceMetadata
3524
3570
  }, {
3525
3571
  F: __dxlog_file13,
3526
- L: 89,
3572
+ L: 96,
3527
3573
  S: this,
3528
3574
  C: (f, a) => f(...a)
3529
3575
  });
@@ -3534,7 +3580,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3534
3580
  err
3535
3581
  }, {
3536
3582
  F: __dxlog_file13,
3537
- L: 92,
3583
+ L: 99,
3538
3584
  S: this,
3539
3585
  C: (f, a) => f(...a)
3540
3586
  });
@@ -3551,7 +3597,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3551
3597
  id: this._instanceId
3552
3598
  }), {
3553
3599
  F: __dxlog_file13,
3554
- L: 105,
3600
+ L: 112,
3555
3601
  S: this,
3556
3602
  C: (f, a) => f(...a)
3557
3603
  });
@@ -3559,7 +3605,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3559
3605
  async close() {
3560
3606
  (0, import_log11.log)("close", void 0, {
3561
3607
  F: __dxlog_file13,
3562
- L: 110,
3608
+ L: 117,
3563
3609
  S: this,
3564
3610
  C: (f, a) => f(...a)
3565
3611
  });
@@ -3575,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3575
3621
  async createSpace() {
3576
3622
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3577
3623
  F: __dxlog_file13,
3578
- L: 123,
3624
+ L: 130,
3579
3625
  S: this,
3580
3626
  A: [
3581
3627
  "this._isOpen",
@@ -3596,17 +3642,18 @@ var DataSpaceManager = class DataSpaceManager2 {
3596
3642
  spaceKey
3597
3643
  }, {
3598
3644
  F: __dxlog_file13,
3599
- L: 135,
3645
+ L: 142,
3600
3646
  S: this,
3601
3647
  C: (f, a) => f(...a)
3602
3648
  });
3603
3649
  const space = await this._constructSpace(metadata);
3604
- const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
3650
+ const automergeRoot = this._automergeHost.repo.create();
3651
+ const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3605
3652
  await this._metadataStore.addSpace(metadata);
3606
3653
  const memberCredential = credentials[1];
3607
- (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3654
+ (0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3608
3655
  F: __dxlog_file13,
3609
- L: 142,
3656
+ L: 151,
3610
3657
  S: this,
3611
3658
  A: [
3612
3659
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3624,13 +3671,13 @@ var DataSpaceManager = class DataSpaceManager2 {
3624
3671
  opts
3625
3672
  }, {
3626
3673
  F: __dxlog_file13,
3627
- L: 154,
3674
+ L: 163,
3628
3675
  S: this,
3629
3676
  C: (f, a) => f(...a)
3630
3677
  });
3631
3678
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3632
3679
  F: __dxlog_file13,
3633
- L: 155,
3680
+ L: 164,
3634
3681
  S: this,
3635
3682
  A: [
3636
3683
  "this._isOpen",
@@ -3639,7 +3686,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3639
3686
  });
3640
3687
  (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3641
3688
  F: __dxlog_file13,
3642
- L: 156,
3689
+ L: 165,
3643
3690
  S: this,
3644
3691
  A: [
3645
3692
  "!this._spaces.has(opts.spaceKey)",
@@ -3674,7 +3721,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3674
3721
  metadata
3675
3722
  }, {
3676
3723
  F: __dxlog_file13,
3677
- L: 189,
3724
+ L: 198,
3678
3725
  S: this,
3679
3726
  C: (f, a) => f(...a)
3680
3727
  });
@@ -3706,11 +3753,12 @@ var DataSpaceManager = class DataSpaceManager2 {
3706
3753
  remotePeerId: session.remotePeerId
3707
3754
  }));
3708
3755
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3756
+ session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
3709
3757
  },
3710
3758
  onAuthFailure: () => {
3711
3759
  import_log11.log.warn("auth failure", void 0, {
3712
3760
  F: __dxlog_file13,
3713
- L: 224,
3761
+ L: 234,
3714
3762
  S: this,
3715
3763
  C: (f, a) => f(...a)
3716
3764
  });
@@ -3734,7 +3782,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3734
3782
  space: space.key
3735
3783
  }, {
3736
3784
  F: __dxlog_file13,
3737
- L: 242,
3785
+ L: 252,
3738
3786
  S: this,
3739
3787
  C: (f, a) => f(...a)
3740
3788
  });
@@ -3746,7 +3794,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3746
3794
  open: this._isOpen
3747
3795
  }, {
3748
3796
  F: __dxlog_file13,
3749
- L: 249,
3797
+ L: 259,
3750
3798
  S: this,
3751
3799
  C: (f, a) => f(...a)
3752
3800
  });
@@ -3759,14 +3807,15 @@ var DataSpaceManager = class DataSpaceManager2 {
3759
3807
  space: space.key
3760
3808
  }, {
3761
3809
  F: __dxlog_file13,
3762
- L: 255,
3810
+ L: 265,
3763
3811
  S: this,
3764
3812
  C: (f, a) => f(...a)
3765
3813
  });
3766
3814
  await this._dataServiceSubscriptions.unregisterSpace(space.key);
3767
3815
  }
3768
3816
  },
3769
- cache: metadata.cache
3817
+ cache: metadata.cache,
3818
+ automergeHost: this._automergeHost
3770
3819
  });
3771
3820
  if (metadata.state !== import_services8.SpaceState.INACTIVE) {
3772
3821
  await dataSpace.open();
@@ -4052,6 +4101,7 @@ var ServiceContext = class ServiceContext2 {
4052
4101
  snapshotStore: this.snapshotStore
4053
4102
  });
4054
4103
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
4104
+ this.automergeHost = new import_echo_pipeline2.AutomergeHost(storage.createDirectory("automerge"));
4055
4105
  this.invitations = new InvitationsHandler(this.networkManager);
4056
4106
  this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
4057
4107
  }
@@ -4059,7 +4109,7 @@ var ServiceContext = class ServiceContext2 {
4059
4109
  await this._checkStorageVersion();
4060
4110
  (0, import_log13.log)("opening...", void 0, {
4061
4111
  F: __dxlog_file15,
4062
- L: 129,
4112
+ L: 133,
4063
4113
  S: this,
4064
4114
  C: (f, a) => f(...a)
4065
4115
  });
@@ -4067,7 +4117,7 @@ var ServiceContext = class ServiceContext2 {
4067
4117
  id: this._instanceId
4068
4118
  }), {
4069
4119
  F: __dxlog_file15,
4070
- L: 130,
4120
+ L: 134,
4071
4121
  S: this,
4072
4122
  C: (f, a) => f(...a)
4073
4123
  });
@@ -4083,13 +4133,13 @@ var ServiceContext = class ServiceContext2 {
4083
4133
  id: this._instanceId
4084
4134
  }), {
4085
4135
  F: __dxlog_file15,
4086
- L: 140,
4136
+ L: 144,
4087
4137
  S: this,
4088
4138
  C: (f, a) => f(...a)
4089
4139
  });
4090
4140
  (0, import_log13.log)("opened", void 0, {
4091
4141
  F: __dxlog_file15,
4092
- L: 141,
4142
+ L: 145,
4093
4143
  S: this,
4094
4144
  C: (f, a) => f(...a)
4095
4145
  });
@@ -4097,13 +4147,14 @@ var ServiceContext = class ServiceContext2 {
4097
4147
  async close() {
4098
4148
  (0, import_log13.log)("closing...", void 0, {
4099
4149
  F: __dxlog_file15,
4100
- L: 145,
4150
+ L: 149,
4101
4151
  S: this,
4102
4152
  C: (f, a) => f(...a)
4103
4153
  });
4104
4154
  if (this._deviceSpaceSync && this.identityManager.identity) {
4105
4155
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
4106
4156
  }
4157
+ await this.automergeHost.close();
4107
4158
  await this.dataSpaceManager?.close();
4108
4159
  await this.identityManager.close();
4109
4160
  await this.spaceManager.close();
@@ -4114,7 +4165,7 @@ var ServiceContext = class ServiceContext2 {
4114
4165
  await this.metadataStore.close();
4115
4166
  (0, import_log13.log)("closed", void 0, {
4116
4167
  F: __dxlog_file15,
4117
- L: 157,
4168
+ L: 162,
4118
4169
  S: this,
4119
4170
  C: (f, a) => f(...a)
4120
4171
  });
@@ -4128,7 +4179,7 @@ var ServiceContext = class ServiceContext2 {
4128
4179
  const factory = this._handlerFactories.get(invitation.kind);
4129
4180
  (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4130
4181
  F: __dxlog_file15,
4131
- L: 168,
4182
+ L: 173,
4132
4183
  S: this,
4133
4184
  A: [
4134
4185
  "factory",
@@ -4160,7 +4211,7 @@ var ServiceContext = class ServiceContext2 {
4160
4211
  async _initialize(ctx) {
4161
4212
  (0, import_log13.log)("initializing spaces...", void 0, {
4162
4213
  F: __dxlog_file15,
4163
- L: 199,
4214
+ L: 204,
4164
4215
  S: this,
4165
4216
  C: (f, a) => f(...a)
4166
4217
  });
@@ -4178,12 +4229,12 @@ var ServiceContext = class ServiceContext2 {
4178
4229
  });
4179
4230
  }
4180
4231
  };
4181
- this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
4232
+ this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
4182
4233
  await this.dataSpaceManager.open();
4183
4234
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4184
4235
  (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4185
4236
  F: __dxlog_file15,
4186
- L: 222,
4237
+ L: 228,
4187
4238
  S: this,
4188
4239
  A: [
4189
4240
  "this.dataSpaceManager",
@@ -4195,7 +4246,7 @@ var ServiceContext = class ServiceContext2 {
4195
4246
  this.initialized.wake();
4196
4247
  this._deviceSpaceSync = {
4197
4248
  processCredential: async (credential) => {
4198
- const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4249
+ const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4199
4250
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4200
4251
  return;
4201
4252
  }
@@ -4207,7 +4258,7 @@ var ServiceContext = class ServiceContext2 {
4207
4258
  details: assertion
4208
4259
  }, {
4209
4260
  F: __dxlog_file15,
4210
- L: 238,
4261
+ L: 244,
4211
4262
  S: this,
4212
4263
  C: (f, a) => f(...a)
4213
4264
  });
@@ -4218,7 +4269,7 @@ var ServiceContext = class ServiceContext2 {
4218
4269
  details: assertion
4219
4270
  }, {
4220
4271
  F: __dxlog_file15,
4221
- L: 242,
4272
+ L: 248,
4222
4273
  S: this,
4223
4274
  C: (f, a) => f(...a)
4224
4275
  });
@@ -4229,7 +4280,7 @@ var ServiceContext = class ServiceContext2 {
4229
4280
  details: assertion
4230
4281
  }, {
4231
4282
  F: __dxlog_file15,
4232
- L: 247,
4283
+ L: 253,
4233
4284
  S: this,
4234
4285
  C: (f, a) => f(...a)
4235
4286
  });
@@ -4240,7 +4291,7 @@ var ServiceContext = class ServiceContext2 {
4240
4291
  } catch (err) {
4241
4292
  import_log13.log.catch(err, void 0, {
4242
4293
  F: __dxlog_file15,
4243
- L: 253,
4294
+ L: 259,
4244
4295
  S: this,
4245
4296
  C: (f, a) => f(...a)
4246
4297
  });
@@ -4840,7 +4891,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4840
4891
  await this._serviceContext.initialized.wait();
4841
4892
  return this._serviceContext.dataSpaceManager;
4842
4893
  }),
4843
- DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4894
+ DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
4844
4895
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4845
4896
  LoggingService: this._loggingService,
4846
4897
  TracingService: this._tracingService,
@@ -4870,7 +4921,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4870
4921
  deviceKey
4871
4922
  }, {
4872
4923
  F: __dxlog_file17,
4873
- L: 317,
4924
+ L: 320,
4874
4925
  S: this,
4875
4926
  C: (f, a) => f(...a)
4876
4927
  });
@@ -4878,7 +4929,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4878
4929
  id: traceId
4879
4930
  }), {
4880
4931
  F: __dxlog_file17,
4881
- L: 318,
4932
+ L: 321,
4882
4933
  S: this,
4883
4934
  C: (f, a) => f(...a)
4884
4935
  });
@@ -4892,7 +4943,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4892
4943
  deviceKey
4893
4944
  }, {
4894
4945
  F: __dxlog_file17,
4895
- L: 329,
4946
+ L: 332,
4896
4947
  S: this,
4897
4948
  C: (f, a) => f(...a)
4898
4949
  });
@@ -4908,7 +4959,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4908
4959
  deviceKey
4909
4960
  }, {
4910
4961
  F: __dxlog_file17,
4911
- L: 336,
4962
+ L: 339,
4912
4963
  S: this,
4913
4964
  C: (f, a) => f(...a)
4914
4965
  });
@@ -4919,13 +4970,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4919
4970
  id: traceId
4920
4971
  }), {
4921
4972
  F: __dxlog_file17,
4922
- L: 341,
4973
+ L: 344,
4923
4974
  S: this,
4924
4975
  C: (f, a) => f(...a)
4925
4976
  });
4926
4977
  (0, import_log15.log)("resetting...", void 0, {
4927
4978
  F: __dxlog_file17,
4928
- L: 343,
4979
+ L: 346,
4929
4980
  S: this,
4930
4981
  C: (f, a) => f(...a)
4931
4982
  });
@@ -4933,7 +4984,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4933
4984
  await this._storage.reset();
4934
4985
  (0, import_log15.log)("reset", void 0, {
4935
4986
  F: __dxlog_file17,
4936
- L: 346,
4987
+ L: 349,
4937
4988
  S: this,
4938
4989
  C: (f, a) => f(...a)
4939
4990
  });
@@ -4941,7 +4992,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4941
4992
  id: traceId
4942
4993
  }), {
4943
4994
  F: __dxlog_file17,
4944
- L: 347,
4995
+ L: 350,
4945
4996
  S: this,
4946
4997
  C: (f, a) => f(...a)
4947
4998
  });
@@ -4951,7 +5002,9 @@ var ClientServicesHost = class ClientServicesHost2 {
4951
5002
  const identity = await this._serviceContext.createIdentity(params);
4952
5003
  await this._serviceContext.initialized.wait();
4953
5004
  const space = await this._serviceContext.dataSpaceManager.createSpace();
4954
- const obj = new import_client_protocol5.Properties();
5005
+ const obj = new import_client_protocol5.Properties(void 0, {
5006
+ useAutomergeBackend: false
5007
+ });
4955
5008
  obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
4956
5009
  await this._serviceRegistry.services.DataService.write({
4957
5010
  spaceKey: space.key,
@@ -5018,4 +5071,4 @@ ClientServicesHost = _ts_decorate8([
5018
5071
  subscribeToSpaces,
5019
5072
  subscribeToSwarmInfo
5020
5073
  });
5021
- //# sourceMappingURL=chunk-V5ZH44RD.cjs.map
5074
+ //# sourceMappingURL=chunk-OTXGXWD2.cjs.map