@dxos/client-services 0.1.52-main.d3eb45f → 0.1.52-main.e73bc9f

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.
@@ -43,6 +43,7 @@ __export(src_exports, {
43
43
  IdentityServiceImpl: () => IdentityServiceImpl,
44
44
  InvitationsHandler: () => InvitationsHandler,
45
45
  InvitationsServiceImpl: () => InvitationsServiceImpl,
46
+ LocalClientServices: () => LocalClientServices,
46
47
  Lock: () => Lock,
47
48
  MemoryShellRuntime: () => MemoryShellRuntime,
48
49
  ServiceContext: () => ServiceContext,
@@ -2139,55 +2140,260 @@ var SpaceInvitationProtocol = class {
2139
2140
  }
2140
2141
  };
2141
2142
 
2142
- // packages/sdk/client-services/src/packlets/services/service-context.ts
2143
- var import_node_assert11 = __toESM(require("node:assert"));
2144
- var import_async14 = require("@dxos/async");
2145
- var import_credentials13 = require("@dxos/credentials");
2146
- var import_debug6 = require("@dxos/debug");
2147
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
2148
- var import_feed_store4 = require("@dxos/feed-store");
2149
- var import_keyring = require("@dxos/keyring");
2150
- var import_keys10 = require("@dxos/keys");
2151
- var import_log12 = require("@dxos/log");
2152
- var import_protocols8 = require("@dxos/protocols");
2153
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2154
- var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2143
+ // packages/sdk/client-services/src/packlets/services/service-host.ts
2144
+ var import_node_assert13 = __toESM(require("node:assert"));
2145
+ var import_async17 = require("@dxos/async");
2146
+ var import_client_protocol5 = require("@dxos/client-protocol");
2147
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
2148
+ var import_keys11 = require("@dxos/keys");
2149
+ var import_log15 = require("@dxos/log");
2150
+ var import_messaging = require("@dxos/messaging");
2151
+ var import_network_manager2 = require("@dxos/network-manager");
2152
+ var import_protocols9 = require("@dxos/protocols");
2153
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
2154
+
2155
+ // packages/sdk/client-services/src/packlets/devices/devices-service.ts
2156
+ var import_async10 = require("@dxos/async");
2157
+ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
2158
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2159
+ var DevicesServiceImpl = class {
2160
+ constructor(_identityManager) {
2161
+ this._identityManager = _identityManager;
2162
+ }
2163
+ updateDevice(request) {
2164
+ throw new Error("Method not implemented.");
2165
+ }
2166
+ queryDevices() {
2167
+ return new import_codec_protobuf9.Stream(({ next }) => {
2168
+ const update = () => {
2169
+ var _a;
2170
+ const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
2171
+ if (!deviceKeys) {
2172
+ next({
2173
+ devices: []
2174
+ });
2175
+ } else {
2176
+ next({
2177
+ devices: Array.from(deviceKeys.values()).map((key) => {
2178
+ var _a2;
2179
+ return {
2180
+ deviceKey: key,
2181
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services6.DeviceKind.CURRENT : import_services6.DeviceKind.TRUSTED
2182
+ };
2183
+ })
2184
+ });
2185
+ }
2186
+ };
2187
+ const subscriptions = new import_async10.EventSubscriptions();
2188
+ subscriptions.add(this._identityManager.stateUpdate.on(() => {
2189
+ update();
2190
+ if (this._identityManager.identity) {
2191
+ subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
2192
+ update();
2193
+ }));
2194
+ }
2195
+ }));
2196
+ update();
2197
+ return () => subscriptions.clear();
2198
+ });
2199
+ }
2200
+ };
2201
+
2202
+ // packages/sdk/client-services/src/packlets/locks/node.ts
2203
+ var import_node_assert9 = __toESM(require("node:assert"));
2204
+ var import_lock_file = require("@dxos/lock-file");
2205
+ var import_log8 = require("@dxos/log");
2206
+ var __decorate = function(decorators, target, key, desc) {
2207
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2208
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2209
+ r = Reflect.decorate(decorators, target, key, desc);
2210
+ else
2211
+ for (var i = decorators.length - 1; i >= 0; i--)
2212
+ if (d = decorators[i])
2213
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2214
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2215
+ };
2216
+ var Lock = class {
2217
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
2218
+ this._lockPath = lockPath;
2219
+ this._onAcquire = onAcquire;
2220
+ this._onRelease = onRelease;
2221
+ }
2222
+ get lockKey() {
2223
+ return this._lockPath;
2224
+ }
2225
+ async acquire() {
2226
+ var _a;
2227
+ (0, import_log8.log)("acquiring lock...", {}, {
2228
+ file: "node.ts",
2229
+ line: 32,
2230
+ scope: this,
2231
+ callSite: (f, a) => f(...a)
2232
+ });
2233
+ this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
2234
+ await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
2235
+ (0, import_log8.log)("acquired lock", {}, {
2236
+ file: "node.ts",
2237
+ line: 37,
2238
+ scope: this,
2239
+ callSite: (f, a) => f(...a)
2240
+ });
2241
+ }
2242
+ async release() {
2243
+ var _a;
2244
+ await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
2245
+ (0, import_node_assert9.default)(this._fileHandle, "Lock is not acquired");
2246
+ await import_lock_file.LockFile.release(this._fileHandle);
2247
+ }
2248
+ };
2249
+ __decorate([
2250
+ import_log8.logInfo
2251
+ ], Lock.prototype, "lockKey", null);
2252
+ var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
2253
+
2254
+ // packages/sdk/client-services/src/packlets/logging/logging-service.ts
2255
+ var import_async11 = require("@dxos/async");
2256
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2257
+ var import_log9 = require("@dxos/log");
2258
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2259
+ var import_util3 = require("@dxos/util");
2260
+ var LoggingServiceImpl = class {
2261
+ constructor() {
2262
+ this._logs = new import_async11.Event();
2263
+ this._logProcessor = (_config, entry2) => {
2264
+ this._logs.emit(entry2);
2265
+ };
2266
+ }
2267
+ async open() {
2268
+ import_log9.log.runtimeConfig.processors.push(this._logProcessor);
2269
+ }
2270
+ async close() {
2271
+ const index = import_log9.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
2272
+ import_log9.log.runtimeConfig.processors.splice(index, 1);
2273
+ }
2274
+ queryLogs(request) {
2275
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
2276
+ const handler = (entry2) => {
2277
+ var _a, _b, _c, _d, _e;
2278
+ if (LOG_PROCESSING > 0) {
2279
+ return;
2280
+ }
2281
+ 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"))) {
2282
+ return;
2283
+ }
2284
+ if (!shouldLog(entry2, request)) {
2285
+ return;
2286
+ }
2287
+ const record = {
2288
+ ...entry2,
2289
+ context: (0, import_util3.jsonify)((0, import_log9.getContextFromEntry)(entry2)),
2290
+ timestamp: new Date(),
2291
+ meta: {
2292
+ // TODO(dmaretskyi): Fix proto.
2293
+ file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
2294
+ line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
2295
+ }
2296
+ };
2297
+ try {
2298
+ LOG_PROCESSING++;
2299
+ next(record);
2300
+ } finally {
2301
+ LOG_PROCESSING--;
2302
+ }
2303
+ };
2304
+ this._logs.on(ctx, handler);
2305
+ });
2306
+ }
2307
+ };
2308
+ var matchFilter = (filter, level, path, options) => {
2309
+ switch (options) {
2310
+ case import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE:
2311
+ return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
2312
+ case import_services7.QueryLogsRequest.MatchingOptions.EXPLICIT:
2313
+ return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
2314
+ }
2315
+ };
2316
+ var shouldLog = (entry2, request) => {
2317
+ var _a;
2318
+ const options = (_a = request.options) != null ? _a : import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
2319
+ if (request.filters === void 0) {
2320
+ return options === import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
2321
+ } else {
2322
+ return request.filters.some((filter) => {
2323
+ var _a2, _b;
2324
+ return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
2325
+ });
2326
+ }
2327
+ };
2328
+ var LOG_PROCESSING = 0;
2329
+
2330
+ // packages/sdk/client-services/src/packlets/network/network-service.ts
2331
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
2332
+ var NetworkServiceImpl = class {
2333
+ constructor(networkManager, signalManager) {
2334
+ this.networkManager = networkManager;
2335
+ this.signalManager = signalManager;
2336
+ }
2337
+ queryStatus() {
2338
+ return new import_codec_protobuf11.Stream(({ next }) => {
2339
+ const update = () => {
2340
+ next({
2341
+ swarm: this.networkManager.connectionState,
2342
+ signaling: this.signalManager.getStatus().map(({ host, state }) => ({
2343
+ server: host,
2344
+ state
2345
+ }))
2346
+ });
2347
+ };
2348
+ const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
2349
+ const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
2350
+ update();
2351
+ return () => {
2352
+ unsubscribeSwarm();
2353
+ unsubscribeSignal();
2354
+ };
2355
+ });
2356
+ }
2357
+ async updateConfig(request) {
2358
+ await this.networkManager.setConnectionState(request.swarm);
2359
+ }
2360
+ };
2155
2361
 
2156
2362
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2157
- var import_node_assert10 = __toESM(require("node:assert"));
2158
- var import_async12 = require("@dxos/async");
2363
+ var import_node_assert11 = __toESM(require("node:assert"));
2364
+ var import_async14 = require("@dxos/async");
2159
2365
  var import_context7 = require("@dxos/context");
2160
2366
  var import_credentials12 = require("@dxos/credentials");
2161
2367
  var import_keys9 = require("@dxos/keys");
2162
- var import_log10 = require("@dxos/log");
2368
+ var import_log12 = require("@dxos/log");
2163
2369
  var import_protocols6 = require("@dxos/protocols");
2164
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2370
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2165
2371
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2166
- var import_util5 = require("@dxos/util");
2372
+ var import_util6 = require("@dxos/util");
2167
2373
 
2168
2374
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2169
- var import_async11 = require("@dxos/async");
2375
+ var import_async13 = require("@dxos/async");
2170
2376
  var import_client_protocol3 = require("@dxos/client-protocol");
2171
2377
  var import_context6 = require("@dxos/context");
2172
2378
  var import_debug3 = require("@dxos/debug");
2173
2379
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2174
2380
  var import_errors3 = require("@dxos/errors");
2175
2381
  var import_keys8 = require("@dxos/keys");
2176
- var import_log9 = require("@dxos/log");
2177
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2382
+ var import_log11 = require("@dxos/log");
2383
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2178
2384
  var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
2179
2385
  var import_timeframe = require("@dxos/timeframe");
2180
- var import_util4 = require("@dxos/util");
2386
+ var import_util5 = require("@dxos/util");
2181
2387
 
2182
2388
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2183
- var import_node_assert9 = __toESM(require("node:assert"));
2184
- var import_async10 = require("@dxos/async");
2389
+ var import_node_assert10 = __toESM(require("node:assert"));
2390
+ var import_async12 = require("@dxos/async");
2185
2391
  var import_context5 = require("@dxos/context");
2186
2392
  var import_keys7 = require("@dxos/keys");
2187
- var import_log8 = require("@dxos/log");
2393
+ var import_log10 = require("@dxos/log");
2188
2394
  var import_protocols5 = require("@dxos/protocols");
2189
2395
  var import_teleport2 = require("@dxos/teleport");
2190
- var import_util3 = require("@dxos/util");
2396
+ var import_util4 = require("@dxos/util");
2191
2397
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2192
2398
  var DEFAULT_SUCCESS_DELAY = 1e3;
2193
2399
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -2195,10 +2401,10 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2195
2401
  var NotarizationPlugin = class {
2196
2402
  constructor() {
2197
2403
  this._ctx = new import_context5.Context();
2198
- this._extensionOpened = new import_async10.Event();
2404
+ this._extensionOpened = new import_async12.Event();
2199
2405
  this._extensions = /* @__PURE__ */ new Set();
2200
- this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
2201
- this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
2406
+ this._processedCredentials = new import_util4.ComplexSet(import_keys7.PublicKey.hash);
2407
+ this._processCredentialsTriggers = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
2202
2408
  }
2203
2409
  async open() {
2204
2410
  }
@@ -2209,7 +2415,7 @@ var NotarizationPlugin = class {
2209
2415
  * Request credentials to be notarized.
2210
2416
  */
2211
2417
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2212
- (0, import_log8.log)("notarize", {
2418
+ (0, import_log10.log)("notarize", {
2213
2419
  credentials
2214
2420
  }, {
2215
2421
  file: "notarization-plugin.ts",
@@ -2217,11 +2423,11 @@ var NotarizationPlugin = class {
2217
2423
  scope: this,
2218
2424
  callSite: (f, a) => f(...a)
2219
2425
  });
2220
- (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2221
- const errors = new import_async10.Trigger();
2426
+ (0, import_node_assert10.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2427
+ const errors = new import_async12.Trigger();
2222
2428
  const ctx = this._ctx.derive({
2223
2429
  onError: (err) => {
2224
- import_log8.log.warn("Notarization error", {
2430
+ import_log10.log.warn("Notarization error", {
2225
2431
  err
2226
2432
  }, {
2227
2433
  file: "notarization-plugin.ts",
@@ -2235,8 +2441,8 @@ var NotarizationPlugin = class {
2235
2441
  });
2236
2442
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2237
2443
  if (timeout !== 0) {
2238
- (0, import_async10.scheduleTask)(ctx, () => {
2239
- import_log8.log.warn("Notarization timeout", {
2444
+ (0, import_async12.scheduleTask)(ctx, () => {
2445
+ import_log10.log.warn("Notarization timeout", {
2240
2446
  timeout,
2241
2447
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2242
2448
  }, {
@@ -2246,12 +2452,12 @@ var NotarizationPlugin = class {
2246
2452
  callSite: (f, a) => f(...a)
2247
2453
  });
2248
2454
  void ctx.dispose();
2249
- errors.throw(new import_async10.TimeoutError(timeout, "Notarization timed out"));
2455
+ errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
2250
2456
  }, timeout);
2251
2457
  }
2252
2458
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
2253
2459
  const peersTried = /* @__PURE__ */ new Set();
2254
- const notarizeTask = new import_async10.DeferredTask(ctx, async () => {
2460
+ const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
2255
2461
  try {
2256
2462
  if (this._extensions.size === 0) {
2257
2463
  return;
@@ -2260,7 +2466,7 @@ var NotarizationPlugin = class {
2260
2466
  ...this._extensions
2261
2467
  ].find((peer2) => !peersTried.has(peer2));
2262
2468
  if (!peer) {
2263
- import_log8.log.warn("Exhausted all peers to notarize with", {
2469
+ import_log10.log.warn("Exhausted all peers to notarize with", {
2264
2470
  retryIn: retryTimeout
2265
2471
  }, {
2266
2472
  file: "notarization-plugin.ts",
@@ -2269,11 +2475,11 @@ var NotarizationPlugin = class {
2269
2475
  callSite: (f, a) => f(...a)
2270
2476
  });
2271
2477
  peersTried.clear();
2272
- (0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
2478
+ (0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
2273
2479
  return;
2274
2480
  }
2275
2481
  peersTried.add(peer);
2276
- (0, import_log8.log)("try notarizing", {
2482
+ (0, import_log10.log)("try notarizing", {
2277
2483
  peer: peer.localPeerId,
2278
2484
  credentialId: credentials.map((credential) => credential.id)
2279
2485
  }, {
@@ -2285,16 +2491,16 @@ var NotarizationPlugin = class {
2285
2491
  await peer.rpc.NotarizationService.notarize({
2286
2492
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2287
2493
  });
2288
- (0, import_log8.log)("success", {}, {
2494
+ (0, import_log10.log)("success", {}, {
2289
2495
  file: "notarization-plugin.ts",
2290
2496
  line: 144,
2291
2497
  scope: this,
2292
2498
  callSite: (f, a) => f(...a)
2293
2499
  });
2294
- await (0, import_async10.sleep)(successDelay);
2500
+ await (0, import_async12.sleep)(successDelay);
2295
2501
  } catch (err) {
2296
2502
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2297
- import_log8.log.warn("error notarizing (recoverable)", err, {
2503
+ import_log10.log.warn("error notarizing (recoverable)", err, {
2298
2504
  file: "notarization-plugin.ts",
2299
2505
  line: 148,
2300
2506
  scope: this,
@@ -2312,7 +2518,7 @@ var NotarizationPlugin = class {
2312
2518
  allNotarized,
2313
2519
  errors.wait()
2314
2520
  ]);
2315
- (0, import_log8.log)("done", {}, {
2521
+ (0, import_log10.log)("done", {}, {
2316
2522
  file: "notarization-plugin.ts",
2317
2523
  line: 159,
2318
2524
  scope: this,
@@ -2335,14 +2541,14 @@ var NotarizationPlugin = class {
2335
2541
  this._processCredentialsTriggers.delete(credential.id);
2336
2542
  }
2337
2543
  setWriter(writer) {
2338
- (0, import_node_assert9.default)(!this._writer, "Writer already set.");
2544
+ (0, import_node_assert10.default)(!this._writer, "Writer already set.");
2339
2545
  this._writer = writer;
2340
2546
  }
2341
2547
  async _waitUntilProcessed(id) {
2342
2548
  if (this._processedCredentials.has(id)) {
2343
2549
  return;
2344
2550
  }
2345
- await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async10.Trigger()).value.wait();
2551
+ await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
2346
2552
  }
2347
2553
  /**
2348
2554
  * Requests from other peers to notarize credentials.
@@ -2353,7 +2559,7 @@ var NotarizationPlugin = class {
2353
2559
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2354
2560
  }
2355
2561
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2356
- (0, import_node_assert9.default)(credential.id, "Credential must have an id");
2562
+ (0, import_node_assert10.default)(credential.id, "Credential must have an id");
2357
2563
  if (this._processedCredentials.has(credential.id)) {
2358
2564
  continue;
2359
2565
  }
@@ -2363,7 +2569,7 @@ var NotarizationPlugin = class {
2363
2569
  createExtension() {
2364
2570
  const extension = new NotarizationTeleportExtension({
2365
2571
  onOpen: async () => {
2366
- (0, import_log8.log)("extension opened", {
2572
+ (0, import_log10.log)("extension opened", {
2367
2573
  peer: extension.localPeerId
2368
2574
  }, {
2369
2575
  file: "notarization-plugin.ts",
@@ -2375,7 +2581,7 @@ var NotarizationPlugin = class {
2375
2581
  this._extensionOpened.emit();
2376
2582
  },
2377
2583
  onClose: async () => {
2378
- (0, import_log8.log)("extension closed", {
2584
+ (0, import_log10.log)("extension closed", {
2379
2585
  peer: extension.localPeerId
2380
2586
  }, {
2381
2587
  file: "notarization-plugin.ts",
@@ -2422,7 +2628,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2422
2628
  };
2423
2629
 
2424
2630
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2425
- var __decorate = function(decorators, target, key, desc) {
2631
+ var __decorate2 = function(decorators, target, key, desc) {
2426
2632
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2427
2633
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2428
2634
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2435,12 +2641,12 @@ var __decorate = function(decorators, target, key, desc) {
2435
2641
  var DataSpace = class DataSpace2 {
2436
2642
  constructor(params) {
2437
2643
  this._ctx = new import_context6.Context();
2438
- this._state = import_services6.SpaceState.CLOSED;
2644
+ this._state = import_services8.SpaceState.CLOSED;
2439
2645
  /**
2440
2646
  * Error for _state === SpaceState.ERROR.
2441
2647
  */
2442
2648
  this.error = void 0;
2443
- this.stateUpdate = new import_async11.Event();
2649
+ this.stateUpdate = new import_async13.Event();
2444
2650
  this.metrics = {};
2445
2651
  var _a;
2446
2652
  this._inner = params.inner;
@@ -2453,7 +2659,7 @@ var DataSpace = class DataSpace2 {
2453
2659
  this._signingContext = params.signingContext;
2454
2660
  this._callbacks = (_a = params.callbacks) != null ? _a : {};
2455
2661
  this.authVerifier = new TrustedKeySetAuthVerifier({
2456
- trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
2662
+ trustedKeysProvider: () => new import_util5.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
2457
2663
  update: this._inner.stateUpdate,
2458
2664
  authTimeout: import_client_protocol3.AUTH_TIMEOUT
2459
2665
  });
@@ -2489,11 +2695,11 @@ var DataSpace = class DataSpace2 {
2489
2695
  await this.notarizationPlugin.open();
2490
2696
  await this._notarizationPluginConsumer.open();
2491
2697
  await this._inner.open();
2492
- this._state = import_services6.SpaceState.INACTIVE;
2698
+ this._state = import_services8.SpaceState.INACTIVE;
2493
2699
  this.metrics.open = new Date();
2494
2700
  }
2495
2701
  async close() {
2496
- this._state = import_services6.SpaceState.CLOSED;
2702
+ this._state = import_services8.SpaceState.CLOSED;
2497
2703
  await this._ctx.dispose();
2498
2704
  await this.authVerifier.close();
2499
2705
  await this._inner.close();
@@ -2511,13 +2717,13 @@ var DataSpace = class DataSpace2 {
2511
2717
  * Initialize the data pipeline in a separate task.
2512
2718
  */
2513
2719
  initializeDataPipelineAsync() {
2514
- (0, import_async11.scheduleTask)(this._ctx, async () => {
2720
+ (0, import_async13.scheduleTask)(this._ctx, async () => {
2515
2721
  try {
2516
2722
  this.metrics.pipelineInitBegin = new Date();
2517
2723
  await this.initializeDataPipeline();
2518
2724
  } catch (err) {
2519
2725
  if (err instanceof import_errors3.CancelledError) {
2520
- (0, import_log9.log)("Data pipeline initialization cancelled", err, {
2726
+ (0, import_log11.log)("Data pipeline initialization cancelled", err, {
2521
2727
  file: "data-space.ts",
2522
2728
  line: 173,
2523
2729
  scope: this,
@@ -2525,13 +2731,13 @@ var DataSpace = class DataSpace2 {
2525
2731
  });
2526
2732
  return;
2527
2733
  }
2528
- import_log9.log.error("Error initializing data pipeline", err, {
2734
+ import_log11.log.error("Error initializing data pipeline", err, {
2529
2735
  file: "data-space.ts",
2530
2736
  line: 177,
2531
2737
  scope: this,
2532
2738
  callSite: (f, a) => f(...a)
2533
2739
  });
2534
- this._state = import_services6.SpaceState.ERROR;
2740
+ this._state = import_services8.SpaceState.ERROR;
2535
2741
  this.error = err;
2536
2742
  this.stateUpdate.emit();
2537
2743
  } finally {
@@ -2541,17 +2747,17 @@ var DataSpace = class DataSpace2 {
2541
2747
  }
2542
2748
  async initializeDataPipeline() {
2543
2749
  var _a, _b, _c, _d;
2544
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2750
+ if (this._state !== import_services8.SpaceState.INACTIVE) {
2545
2751
  throw new import_errors3.SystemError("Invalid operation");
2546
2752
  }
2547
- this._state = import_services6.SpaceState.INITIALIZING;
2753
+ this._state = import_services8.SpaceState.INITIALIZING;
2548
2754
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2549
2755
  ctx: this._ctx,
2550
2756
  breakOnStall: false
2551
2757
  });
2552
2758
  this.metrics.controlPipelineReady = new Date();
2553
2759
  await this._createWritableFeeds();
2554
- (0, import_log9.log)("Writable feeds created", {}, {
2760
+ (0, import_log11.log)("Writable feeds created", {}, {
2555
2761
  file: "data-space.ts",
2556
2762
  line: 201,
2557
2763
  scope: this,
@@ -2566,7 +2772,7 @@ var DataSpace = class DataSpace2 {
2566
2772
  await this._inner.initializeDataPipeline();
2567
2773
  this.metrics.dataPipelineOpen = new Date();
2568
2774
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2569
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", {}, {
2775
+ (0, import_log11.log)("waiting for data pipeline to reach target timeframe", {}, {
2570
2776
  file: "data-space.ts",
2571
2777
  line: 220,
2572
2778
  scope: this,
@@ -2577,14 +2783,14 @@ var DataSpace = class DataSpace2 {
2577
2783
  breakOnStall: false
2578
2784
  });
2579
2785
  this.metrics.dataPipelineReady = new Date();
2580
- (0, import_log9.log)("data pipeline ready", {}, {
2786
+ (0, import_log11.log)("data pipeline ready", {}, {
2581
2787
  file: "data-space.ts",
2582
2788
  line: 229,
2583
2789
  scope: this,
2584
2790
  callSite: (f, a) => f(...a)
2585
2791
  });
2586
2792
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2587
- this._state = import_services6.SpaceState.READY;
2793
+ this._state = import_services8.SpaceState.READY;
2588
2794
  this.stateUpdate.emit();
2589
2795
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2590
2796
  }
@@ -2660,11 +2866,11 @@ var DataSpace = class DataSpace2 {
2660
2866
  }
2661
2867
  }
2662
2868
  };
2663
- __decorate([
2869
+ __decorate2([
2664
2870
  (0, import_debug3.timed)(1e4)
2665
2871
  ], DataSpace.prototype, "_createWritableFeeds", null);
2666
- DataSpace = __decorate([
2667
- (0, import_async11.trackLeaks)("open", "close")
2872
+ DataSpace = __decorate2([
2873
+ (0, import_async13.trackLeaks)("open", "close")
2668
2874
  ], DataSpace);
2669
2875
 
2670
2876
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
@@ -2738,7 +2944,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2738
2944
  };
2739
2945
 
2740
2946
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2741
- var __decorate2 = function(decorators, target, key, desc) {
2947
+ var __decorate3 = function(decorators, target, key, desc) {
2742
2948
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2743
2949
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2744
2950
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2757,8 +2963,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2757
2963
  this._signingContext = _signingContext;
2758
2964
  this._feedStore = _feedStore;
2759
2965
  this._ctx = new import_context7.Context();
2760
- this.updated = new import_async12.Event();
2761
- this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
2966
+ this.updated = new import_async14.Event();
2967
+ this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
2762
2968
  this._isOpen = false;
2763
2969
  this._instanceId = import_keys9.PublicKey.random().toHex();
2764
2970
  }
@@ -2767,13 +2973,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2767
2973
  return this._spaces;
2768
2974
  }
2769
2975
  async open() {
2770
- (0, import_log10.log)("open", {}, {
2976
+ (0, import_log12.log)("open", {}, {
2771
2977
  file: "data-space-manager.ts",
2772
2978
  line: 80,
2773
2979
  scope: this,
2774
2980
  callSite: (f, a) => f(...a)
2775
2981
  });
2776
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2982
+ import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2777
2983
  id: this._instanceId
2778
2984
  }), {
2779
2985
  file: "data-space-manager.ts",
@@ -2782,7 +2988,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2782
2988
  callSite: (f, a) => f(...a)
2783
2989
  });
2784
2990
  await this._metadataStore.load();
2785
- (0, import_log10.log)("metadata loaded", {
2991
+ (0, import_log12.log)("metadata loaded", {
2786
2992
  spaces: this._metadataStore.spaces.length
2787
2993
  }, {
2788
2994
  file: "data-space-manager.ts",
@@ -2792,7 +2998,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2792
2998
  });
2793
2999
  for (const spaceMetadata of this._metadataStore.spaces) {
2794
3000
  try {
2795
- (0, import_log10.log)("load space", {
3001
+ (0, import_log12.log)("load space", {
2796
3002
  spaceMetadata
2797
3003
  }, {
2798
3004
  file: "data-space-manager.ts",
@@ -2803,7 +3009,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2803
3009
  const space = await this._constructSpace(spaceMetadata);
2804
3010
  space.initializeDataPipelineAsync();
2805
3011
  } catch (err) {
2806
- import_log10.log.error("Error loading space", {
3012
+ import_log12.log.error("Error loading space", {
2807
3013
  spaceMetadata,
2808
3014
  err
2809
3015
  }, {
@@ -2816,7 +3022,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2816
3022
  }
2817
3023
  this._isOpen = true;
2818
3024
  this.updated.emit();
2819
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
3025
+ import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2820
3026
  id: this._instanceId
2821
3027
  }), {
2822
3028
  file: "data-space-manager.ts",
@@ -2826,7 +3032,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2826
3032
  });
2827
3033
  }
2828
3034
  async close() {
2829
- (0, import_log10.log)("close", {}, {
3035
+ (0, import_log12.log)("close", {}, {
2830
3036
  file: "data-space-manager.ts",
2831
3037
  line: 102,
2832
3038
  scope: this,
@@ -2842,7 +3048,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2842
3048
  * Creates a new space writing the genesis credentials to the control feed.
2843
3049
  */
2844
3050
  async createSpace() {
2845
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
3051
+ (0, import_node_assert11.default)(this._isOpen, "Not open.");
2846
3052
  const spaceKey = await this._keyring.createKey();
2847
3053
  const controlFeedKey = await this._keyring.createKey();
2848
3054
  const dataFeedKey = await this._keyring.createKey();
@@ -2852,7 +3058,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2852
3058
  controlFeedKey,
2853
3059
  dataFeedKey
2854
3060
  };
2855
- (0, import_log10.log)("creating space...", {
3061
+ (0, import_log12.log)("creating space...", {
2856
3062
  spaceKey
2857
3063
  }, {
2858
3064
  file: "data-space-manager.ts",
@@ -2864,7 +3070,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2864
3070
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2865
3071
  await this._metadataStore.addSpace(metadata);
2866
3072
  const memberCredential = credentials[1];
2867
- (0, import_node_assert10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
3073
+ (0, import_node_assert11.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2868
3074
  await this._signingContext.recordCredential(memberCredential);
2869
3075
  await space.initializeDataPipeline();
2870
3076
  this.updated.emit();
@@ -2872,7 +3078,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2872
3078
  }
2873
3079
  // TODO(burdon): Rename join space.
2874
3080
  async acceptSpace(opts) {
2875
- (0, import_log10.log)("accept space", {
3081
+ (0, import_log12.log)("accept space", {
2876
3082
  opts
2877
3083
  }, {
2878
3084
  file: "data-space-manager.ts",
@@ -2880,8 +3086,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2880
3086
  scope: this,
2881
3087
  callSite: (f, a) => f(...a)
2882
3088
  });
2883
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2884
- (0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
3089
+ (0, import_node_assert11.default)(this._isOpen, "Not open.");
3090
+ (0, import_node_assert11.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2885
3091
  const metadata = {
2886
3092
  key: opts.spaceKey,
2887
3093
  genesisFeedKey: opts.genesisFeedKey,
@@ -2902,11 +3108,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2902
3108
  async waitUntilSpaceReady(spaceKey) {
2903
3109
  await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
2904
3110
  const space = this._spaces.get(spaceKey);
2905
- return !!space && space.state === import_services7.SpaceState.READY;
3111
+ return !!space && space.state === import_services9.SpaceState.READY;
2906
3112
  }));
2907
3113
  }
2908
3114
  async _constructSpace(metadata) {
2909
- (0, import_log10.log)("construct space", {
3115
+ (0, import_log12.log)("construct space", {
2910
3116
  metadata
2911
3117
  }, {
2912
3118
  file: "data-space-manager.ts",
@@ -2935,7 +3141,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2935
3141
  swarmIdentity: {
2936
3142
  peerKey: this._signingContext.deviceKey,
2937
3143
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
2938
- credentialAuthenticator: (0, import_util5.deferFunction)(() => dataSpace.authVerifier.verifier)
3144
+ credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
2939
3145
  },
2940
3146
  onNetworkConnection: (session) => {
2941
3147
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
@@ -2944,7 +3150,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2944
3150
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2945
3151
  },
2946
3152
  onAuthFailure: () => {
2947
- import_log10.log.warn("auth failure", {}, {
3153
+ import_log12.log.warn("auth failure", {}, {
2948
3154
  file: "data-space-manager.ts",
2949
3155
  line: 212,
2950
3156
  scope: this,
@@ -2965,7 +3171,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2965
3171
  signingContext: this._signingContext,
2966
3172
  callbacks: {
2967
3173
  beforeReady: async () => {
2968
- (0, import_log10.log)("before space ready", {
3174
+ (0, import_log12.log)("before space ready", {
2969
3175
  space: space.key
2970
3176
  }, {
2971
3177
  file: "data-space-manager.ts",
@@ -2976,7 +3182,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2976
3182
  this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2977
3183
  },
2978
3184
  afterReady: async () => {
2979
- (0, import_log10.log)("after space ready", {
3185
+ (0, import_log12.log)("after space ready", {
2980
3186
  space: space.key,
2981
3187
  open: this._isOpen
2982
3188
  }, {
@@ -3003,31 +3209,31 @@ var DataSpaceManager = class DataSpaceManager2 {
3003
3209
  return dataSpace;
3004
3210
  }
3005
3211
  };
3006
- __decorate2([
3007
- import_async12.synchronized
3212
+ __decorate3([
3213
+ import_async14.synchronized
3008
3214
  ], DataSpaceManager.prototype, "open", null);
3009
- __decorate2([
3010
- import_async12.synchronized
3215
+ __decorate3([
3216
+ import_async14.synchronized
3011
3217
  ], DataSpaceManager.prototype, "close", null);
3012
- __decorate2([
3013
- import_async12.synchronized
3218
+ __decorate3([
3219
+ import_async14.synchronized
3014
3220
  ], DataSpaceManager.prototype, "createSpace", null);
3015
- __decorate2([
3016
- import_async12.synchronized
3221
+ __decorate3([
3222
+ import_async14.synchronized
3017
3223
  ], DataSpaceManager.prototype, "acceptSpace", null);
3018
- DataSpaceManager = __decorate2([
3019
- (0, import_async12.trackLeaks)("open", "close")
3224
+ DataSpaceManager = __decorate3([
3225
+ (0, import_async14.trackLeaks)("open", "close")
3020
3226
  ], DataSpaceManager);
3021
3227
 
3022
3228
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3023
- var import_async13 = require("@dxos/async");
3024
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3025
- var import_debug5 = require("@dxos/debug");
3229
+ var import_async15 = require("@dxos/async");
3230
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3231
+ var import_debug5 = require("@dxos/debug");
3026
3232
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3027
- var import_log11 = require("@dxos/log");
3233
+ var import_log13 = require("@dxos/log");
3028
3234
  var import_protocols7 = require("@dxos/protocols");
3029
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3030
- var import_util6 = require("@dxos/util");
3235
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3236
+ var import_util7 = require("@dxos/util");
3031
3237
  var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
3032
3238
  var SpacesServiceImpl = class {
3033
3239
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
@@ -3048,11 +3254,11 @@ var SpacesServiceImpl = class {
3048
3254
  (0, import_debug5.todo)();
3049
3255
  }
3050
3256
  querySpaces() {
3051
- return new import_codec_protobuf9.Stream(({ next, ctx }) => {
3257
+ return new import_codec_protobuf12.Stream(({ next, ctx }) => {
3052
3258
  const onUpdate = async () => {
3053
3259
  const dataSpaceManager = await this._getDataSpaceManager();
3054
3260
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
3055
- (0, import_log11.log)("update", {
3261
+ (0, import_log13.log)("update", {
3056
3262
  spaces
3057
3263
  }, {
3058
3264
  file: "spaces-service.ts",
@@ -3064,9 +3270,9 @@ var SpacesServiceImpl = class {
3064
3270
  spaces
3065
3271
  });
3066
3272
  };
3067
- (0, import_async13.scheduleTask)(ctx, async () => {
3273
+ (0, import_async15.scheduleTask)(ctx, async () => {
3068
3274
  const dataSpaceManager = await this._getDataSpaceManager();
3069
- const subscriptions = new import_async13.EventSubscriptions();
3275
+ const subscriptions = new import_async15.EventSubscriptions();
3070
3276
  ctx.onDispose(() => subscriptions.clear());
3071
3277
  const subscribeSpaces = () => {
3072
3278
  subscriptions.clear();
@@ -3101,8 +3307,8 @@ var SpacesServiceImpl = class {
3101
3307
  await space.postMessage(getChannelId(channel), message);
3102
3308
  }
3103
3309
  subscribeMessages({ spaceKey, channel }) {
3104
- return new import_codec_protobuf9.Stream(({ ctx, next }) => {
3105
- (0, import_async13.scheduleTask)(ctx, async () => {
3310
+ return new import_codec_protobuf12.Stream(({ ctx, next }) => {
3311
+ (0, import_async15.scheduleTask)(ctx, async () => {
3106
3312
  var _a;
3107
3313
  const dataSpaceManager = await this._getDataSpaceManager();
3108
3314
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
@@ -3114,7 +3320,7 @@ var SpacesServiceImpl = class {
3114
3320
  });
3115
3321
  }
3116
3322
  queryCredentials({ spaceKey }) {
3117
- return new import_codec_protobuf9.Stream(({ ctx, next }) => {
3323
+ return new import_codec_protobuf12.Stream(({ ctx, next }) => {
3118
3324
  var _a;
3119
3325
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3120
3326
  const processor = space.spaceState.registerProcessor({
@@ -3123,7 +3329,7 @@ var SpacesServiceImpl = class {
3123
3329
  }
3124
3330
  });
3125
3331
  ctx.onDispose(() => processor.close());
3126
- (0, import_async13.scheduleTask)(ctx, () => processor.open());
3332
+ (0, import_async15.scheduleTask)(ctx, () => processor.open());
3127
3333
  });
3128
3334
  }
3129
3335
  async writeCredentials({ spaceKey, credentials }) {
@@ -3168,10 +3374,10 @@ var SpacesServiceImpl = class {
3168
3374
  identity: {
3169
3375
  identityKey: member.key,
3170
3376
  profile: {
3171
- displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
3377
+ displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util7.humanize)(member.key)
3172
3378
  }
3173
3379
  },
3174
- presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE
3380
+ presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE
3175
3381
  };
3176
3382
  }),
3177
3383
  creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
@@ -3182,7 +3388,106 @@ var SpacesServiceImpl = class {
3182
3388
  };
3183
3389
  var getChannelId = (channel) => `user-channel/${channel}`;
3184
3390
 
3391
+ // packages/sdk/client-services/src/packlets/storage/storage.ts
3392
+ var import_client_protocol4 = require("@dxos/client-protocol");
3393
+ var import_errors4 = require("@dxos/errors");
3394
+ var import_config = require("@dxos/protocols/proto/dxos/config");
3395
+ var import_random_access_storage = require("@dxos/random-access-storage");
3396
+ var import_util8 = require("@dxos/util");
3397
+ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
3398
+ var createStorageObjects = (config) => {
3399
+ const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
3400
+ if (persistent && storageType === StorageDriver.RAM) {
3401
+ throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3402
+ }
3403
+ if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
3404
+ throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3405
+ }
3406
+ if (persistent && keyStorage === StorageDriver.RAM) {
3407
+ throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3408
+ }
3409
+ if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
3410
+ throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3411
+ }
3412
+ return {
3413
+ storage: (0, import_random_access_storage.createStorage)({
3414
+ type: persistent ? toStorageType(storageType) : import_random_access_storage.StorageType.RAM,
3415
+ root: `${path}/`
3416
+ })
3417
+ };
3418
+ };
3419
+ var toStorageType = (type) => {
3420
+ switch (type) {
3421
+ case void 0:
3422
+ return void 0;
3423
+ case StorageDriver.RAM:
3424
+ return import_random_access_storage.StorageType.RAM;
3425
+ case StorageDriver.CHROME:
3426
+ return import_random_access_storage.StorageType.CHROME;
3427
+ case StorageDriver.FIREFOX:
3428
+ return import_random_access_storage.StorageType.FIREFOX;
3429
+ case StorageDriver.IDB:
3430
+ return import_random_access_storage.StorageType.IDB;
3431
+ case StorageDriver.NODE:
3432
+ return import_random_access_storage.StorageType.NODE;
3433
+ case StorageDriver.WEBFS:
3434
+ return import_random_access_storage.StorageType.WEBFS;
3435
+ default:
3436
+ throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
3437
+ }
3438
+ };
3439
+
3440
+ // packages/sdk/client-services/src/packlets/system/system-service.ts
3441
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3442
+ var SystemServiceImpl = class {
3443
+ constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3444
+ this._config = config;
3445
+ this._statusUpdate = statusUpdate;
3446
+ this._getCurrentStatus = getCurrentStatus;
3447
+ this._onUpdateStatus = onUpdateStatus;
3448
+ this._onReset = onReset;
3449
+ }
3450
+ async getConfig() {
3451
+ var _a, _b;
3452
+ return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
3453
+ }
3454
+ async updateStatus({ status }) {
3455
+ await this._onUpdateStatus(status);
3456
+ }
3457
+ queryStatus() {
3458
+ return new import_codec_protobuf13.Stream(({ next }) => {
3459
+ const update = () => {
3460
+ next({
3461
+ status: this._getCurrentStatus()
3462
+ });
3463
+ };
3464
+ update();
3465
+ const unsubscribe = this._statusUpdate.on(() => update());
3466
+ const interval = setInterval(update, 3e3);
3467
+ return () => {
3468
+ clearInterval(interval);
3469
+ unsubscribe();
3470
+ };
3471
+ });
3472
+ }
3473
+ async reset() {
3474
+ await this._onReset();
3475
+ }
3476
+ };
3477
+
3185
3478
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3479
+ var import_node_assert12 = __toESM(require("node:assert"));
3480
+ var import_async16 = require("@dxos/async");
3481
+ var import_credentials13 = require("@dxos/credentials");
3482
+ var import_debug6 = require("@dxos/debug");
3483
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
3484
+ var import_feed_store4 = require("@dxos/feed-store");
3485
+ var import_keyring = require("@dxos/keyring");
3486
+ var import_keys10 = require("@dxos/keys");
3487
+ var import_log14 = require("@dxos/log");
3488
+ var import_protocols8 = require("@dxos/protocols");
3489
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3490
+ var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
3186
3491
  var ServiceContext = class {
3187
3492
  // prettier-ignore
3188
3493
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3190,7 +3495,7 @@ var ServiceContext = class {
3190
3495
  this.networkManager = networkManager;
3191
3496
  this.signalManager = signalManager;
3192
3497
  this.modelFactory = modelFactory;
3193
- this.initialized = new import_async14.Trigger();
3498
+ this.initialized = new import_async16.Trigger();
3194
3499
  this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
3195
3500
  this._handlerFactories = /* @__PURE__ */ new Map();
3196
3501
  this._instanceId = import_keys10.PublicKey.random().toHex();
@@ -3217,13 +3522,13 @@ var ServiceContext = class {
3217
3522
  });
3218
3523
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3219
3524
  this.invitations = new InvitationsHandler(this.networkManager);
3220
- this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3525
+ this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3221
3526
  var _a;
3222
3527
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3223
3528
  }, this._acceptIdentity.bind(this)));
3224
3529
  }
3225
3530
  async open() {
3226
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3531
+ import_log14.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3227
3532
  id: this._instanceId
3228
3533
  }), {
3229
3534
  file: "service-context.ts",
@@ -3232,7 +3537,7 @@ var ServiceContext = class {
3232
3537
  callSite: (f, a) => f(...a)
3233
3538
  });
3234
3539
  await this._checkStorageVersion();
3235
- (0, import_log12.log)("opening...", {}, {
3540
+ (0, import_log14.log)("opening...", {}, {
3236
3541
  file: "service-context.ts",
3237
3542
  line: 130,
3238
3543
  scope: this,
@@ -3245,13 +3550,13 @@ var ServiceContext = class {
3245
3550
  if (this.identityManager.identity) {
3246
3551
  await this._initialize();
3247
3552
  }
3248
- (0, import_log12.log)("opened", {}, {
3553
+ (0, import_log14.log)("opened", {}, {
3249
3554
  file: "service-context.ts",
3250
3555
  line: 138,
3251
3556
  scope: this,
3252
3557
  callSite: (f, a) => f(...a)
3253
3558
  });
3254
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3559
+ import_log14.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3255
3560
  id: this._instanceId
3256
3561
  }), {
3257
3562
  file: "service-context.ts",
@@ -3262,7 +3567,7 @@ var ServiceContext = class {
3262
3567
  }
3263
3568
  async close() {
3264
3569
  var _a, _b;
3265
- (0, import_log12.log)("closing...", {}, {
3570
+ (0, import_log14.log)("closing...", {}, {
3266
3571
  file: "service-context.ts",
3267
3572
  line: 143,
3268
3573
  scope: this,
@@ -3276,7 +3581,7 @@ var ServiceContext = class {
3276
3581
  await this.networkManager.close();
3277
3582
  await this.signalManager.close();
3278
3583
  this.dataServiceSubscriptions.clear();
3279
- (0, import_log12.log)("closed", {}, {
3584
+ (0, import_log14.log)("closed", {}, {
3280
3585
  file: "service-context.ts",
3281
3586
  line: 152,
3282
3587
  scope: this,
@@ -3290,7 +3595,7 @@ var ServiceContext = class {
3290
3595
  }
3291
3596
  getInvitationHandler(invitation) {
3292
3597
  const factory = this._handlerFactories.get(invitation.kind);
3293
- (0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3598
+ (0, import_node_assert12.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3294
3599
  return factory(invitation);
3295
3600
  }
3296
3601
  async _acceptIdentity(params) {
@@ -3307,7 +3612,7 @@ var ServiceContext = class {
3307
3612
  // Called when identity is created.
3308
3613
  async _initialize() {
3309
3614
  var _a;
3310
- (0, import_log12.log)("initializing spaces...", {}, {
3615
+ (0, import_log14.log)("initializing spaces...", {}, {
3311
3616
  file: "service-context.ts",
3312
3617
  line: 185,
3313
3618
  scope: this,
@@ -3329,8 +3634,8 @@ var ServiceContext = class {
3329
3634
  };
3330
3635
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3331
3636
  await this.dataSpaceManager.open();
3332
- this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3333
- (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3637
+ this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
3638
+ (0, import_node_assert12.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3334
3639
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3335
3640
  });
3336
3641
  this.initialized.wake();
@@ -3344,7 +3649,7 @@ var ServiceContext = class {
3344
3649
  return;
3345
3650
  }
3346
3651
  if (!this.dataSpaceManager) {
3347
- (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3652
+ (0, import_log14.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3348
3653
  details: assertion
3349
3654
  }, {
3350
3655
  file: "service-context.ts",
@@ -3355,7 +3660,7 @@ var ServiceContext = class {
3355
3660
  return;
3356
3661
  }
3357
3662
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3358
- (0, import_log12.log)("space already exists, ignoring space admission", {
3663
+ (0, import_log14.log)("space already exists, ignoring space admission", {
3359
3664
  details: assertion
3360
3665
  }, {
3361
3666
  file: "service-context.ts",
@@ -3366,7 +3671,7 @@ var ServiceContext = class {
3366
3671
  return;
3367
3672
  }
3368
3673
  try {
3369
- (0, import_log12.log)("accepting space recorded in halo", {
3674
+ (0, import_log14.log)("accepting space recorded in halo", {
3370
3675
  details: assertion
3371
3676
  }, {
3372
3677
  file: "service-context.ts",
@@ -3379,7 +3684,7 @@ var ServiceContext = class {
3379
3684
  genesisFeedKey: assertion.genesisFeedKey
3380
3685
  });
3381
3686
  } catch (err) {
3382
- import_log12.log.catch(err, {}, {
3687
+ import_log14.log.catch(err, {}, {
3383
3688
  file: "service-context.ts",
3384
3689
  line: 239,
3385
3690
  scope: this,
@@ -3392,312 +3697,6 @@ var ServiceContext = class {
3392
3697
  }
3393
3698
  };
3394
3699
 
3395
- // packages/sdk/client-services/src/packlets/services/service-host.ts
3396
- var import_node_assert13 = __toESM(require("node:assert"));
3397
- var import_async17 = require("@dxos/async");
3398
- var import_client_protocol5 = require("@dxos/client-protocol");
3399
- var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3400
- var import_keys11 = require("@dxos/keys");
3401
- var import_log15 = require("@dxos/log");
3402
- var import_messaging = require("@dxos/messaging");
3403
- var import_network_manager2 = require("@dxos/network-manager");
3404
- var import_protocols9 = require("@dxos/protocols");
3405
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3406
-
3407
- // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3408
- var import_async15 = require("@dxos/async");
3409
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3410
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3411
- var DevicesServiceImpl = class {
3412
- constructor(_identityManager) {
3413
- this._identityManager = _identityManager;
3414
- }
3415
- updateDevice(request) {
3416
- throw new Error("Method not implemented.");
3417
- }
3418
- queryDevices() {
3419
- return new import_codec_protobuf10.Stream(({ next }) => {
3420
- const update = () => {
3421
- var _a;
3422
- const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
3423
- if (!deviceKeys) {
3424
- next({
3425
- devices: []
3426
- });
3427
- } else {
3428
- next({
3429
- devices: Array.from(deviceKeys.values()).map((key) => {
3430
- var _a2;
3431
- return {
3432
- deviceKey: key,
3433
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
3434
- };
3435
- })
3436
- });
3437
- }
3438
- };
3439
- const subscriptions = new import_async15.EventSubscriptions();
3440
- subscriptions.add(this._identityManager.stateUpdate.on(() => {
3441
- update();
3442
- if (this._identityManager.identity) {
3443
- subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
3444
- update();
3445
- }));
3446
- }
3447
- }));
3448
- update();
3449
- return () => subscriptions.clear();
3450
- });
3451
- }
3452
- };
3453
-
3454
- // packages/sdk/client-services/src/packlets/locks/node.ts
3455
- var import_node_assert12 = __toESM(require("node:assert"));
3456
- var import_lock_file = require("@dxos/lock-file");
3457
- var import_log13 = require("@dxos/log");
3458
- var __decorate3 = function(decorators, target, key, desc) {
3459
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3460
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3461
- r = Reflect.decorate(decorators, target, key, desc);
3462
- else
3463
- for (var i = decorators.length - 1; i >= 0; i--)
3464
- if (d = decorators[i])
3465
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3466
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3467
- };
3468
- var Lock = class {
3469
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3470
- this._lockPath = lockPath;
3471
- this._onAcquire = onAcquire;
3472
- this._onRelease = onRelease;
3473
- }
3474
- get lockKey() {
3475
- return this._lockPath;
3476
- }
3477
- async acquire() {
3478
- var _a;
3479
- (0, import_log13.log)("acquiring lock...", {}, {
3480
- file: "node.ts",
3481
- line: 32,
3482
- scope: this,
3483
- callSite: (f, a) => f(...a)
3484
- });
3485
- this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3486
- await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3487
- (0, import_log13.log)("acquired lock", {}, {
3488
- file: "node.ts",
3489
- line: 37,
3490
- scope: this,
3491
- callSite: (f, a) => f(...a)
3492
- });
3493
- }
3494
- async release() {
3495
- var _a;
3496
- await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3497
- (0, import_node_assert12.default)(this._fileHandle, "Lock is not acquired");
3498
- await import_lock_file.LockFile.release(this._fileHandle);
3499
- }
3500
- };
3501
- __decorate3([
3502
- import_log13.logInfo
3503
- ], Lock.prototype, "lockKey", null);
3504
- var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
3505
-
3506
- // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3507
- var import_async16 = require("@dxos/async");
3508
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3509
- var import_log14 = require("@dxos/log");
3510
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3511
- var import_util7 = require("@dxos/util");
3512
- var LoggingServiceImpl = class {
3513
- constructor() {
3514
- this._logs = new import_async16.Event();
3515
- this._logProcessor = (_config, entry2) => {
3516
- this._logs.emit(entry2);
3517
- };
3518
- }
3519
- async open() {
3520
- import_log14.log.runtimeConfig.processors.push(this._logProcessor);
3521
- }
3522
- async close() {
3523
- const index = import_log14.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3524
- import_log14.log.runtimeConfig.processors.splice(index, 1);
3525
- }
3526
- queryLogs(request) {
3527
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3528
- const handler = (entry2) => {
3529
- var _a, _b, _c, _d, _e;
3530
- if (LOG_PROCESSING > 0) {
3531
- return;
3532
- }
3533
- 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"))) {
3534
- return;
3535
- }
3536
- if (!shouldLog(entry2, request)) {
3537
- return;
3538
- }
3539
- const record = {
3540
- ...entry2,
3541
- context: (0, import_util7.jsonify)((0, import_log14.getContextFromEntry)(entry2)),
3542
- timestamp: new Date(),
3543
- meta: {
3544
- // TODO(dmaretskyi): Fix proto.
3545
- file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
3546
- line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
3547
- }
3548
- };
3549
- try {
3550
- LOG_PROCESSING++;
3551
- next(record);
3552
- } finally {
3553
- LOG_PROCESSING--;
3554
- }
3555
- };
3556
- this._logs.on(ctx, handler);
3557
- });
3558
- }
3559
- };
3560
- var matchFilter = (filter, level, path, options) => {
3561
- switch (options) {
3562
- case import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE:
3563
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
3564
- case import_services11.QueryLogsRequest.MatchingOptions.EXPLICIT:
3565
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
3566
- }
3567
- };
3568
- var shouldLog = (entry2, request) => {
3569
- var _a;
3570
- const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
3571
- if (request.filters === void 0) {
3572
- return options === import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
3573
- } else {
3574
- return request.filters.some((filter) => {
3575
- var _a2, _b;
3576
- return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
3577
- });
3578
- }
3579
- };
3580
- var LOG_PROCESSING = 0;
3581
-
3582
- // packages/sdk/client-services/src/packlets/network/network-service.ts
3583
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3584
- var NetworkServiceImpl = class {
3585
- constructor(networkManager, signalManager) {
3586
- this.networkManager = networkManager;
3587
- this.signalManager = signalManager;
3588
- }
3589
- queryStatus() {
3590
- return new import_codec_protobuf12.Stream(({ next }) => {
3591
- const update = () => {
3592
- next({
3593
- swarm: this.networkManager.connectionState,
3594
- signaling: this.signalManager.getStatus().map(({ host, state }) => ({
3595
- server: host,
3596
- state
3597
- }))
3598
- });
3599
- };
3600
- const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
3601
- const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
3602
- update();
3603
- return () => {
3604
- unsubscribeSwarm();
3605
- unsubscribeSignal();
3606
- };
3607
- });
3608
- }
3609
- async updateConfig(request) {
3610
- await this.networkManager.setConnectionState(request.swarm);
3611
- }
3612
- };
3613
-
3614
- // packages/sdk/client-services/src/packlets/storage/storage.ts
3615
- var import_client_protocol4 = require("@dxos/client-protocol");
3616
- var import_errors4 = require("@dxos/errors");
3617
- var import_config = require("@dxos/protocols/proto/dxos/config");
3618
- var import_random_access_storage = require("@dxos/random-access-storage");
3619
- var import_util8 = require("@dxos/util");
3620
- var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
3621
- var createStorageObjects = (config) => {
3622
- const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
3623
- if (persistent && storageType === StorageDriver.RAM) {
3624
- throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3625
- }
3626
- if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
3627
- throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3628
- }
3629
- if (persistent && keyStorage === StorageDriver.RAM) {
3630
- throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3631
- }
3632
- if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
3633
- throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3634
- }
3635
- return {
3636
- storage: (0, import_random_access_storage.createStorage)({
3637
- type: persistent ? toStorageType(storageType) : import_random_access_storage.StorageType.RAM,
3638
- root: `${path}/`
3639
- })
3640
- };
3641
- };
3642
- var toStorageType = (type) => {
3643
- switch (type) {
3644
- case void 0:
3645
- return void 0;
3646
- case StorageDriver.RAM:
3647
- return import_random_access_storage.StorageType.RAM;
3648
- case StorageDriver.CHROME:
3649
- return import_random_access_storage.StorageType.CHROME;
3650
- case StorageDriver.FIREFOX:
3651
- return import_random_access_storage.StorageType.FIREFOX;
3652
- case StorageDriver.IDB:
3653
- return import_random_access_storage.StorageType.IDB;
3654
- case StorageDriver.NODE:
3655
- return import_random_access_storage.StorageType.NODE;
3656
- case StorageDriver.WEBFS:
3657
- return import_random_access_storage.StorageType.WEBFS;
3658
- default:
3659
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
3660
- }
3661
- };
3662
-
3663
- // packages/sdk/client-services/src/packlets/system/system-service.ts
3664
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3665
- var SystemServiceImpl = class {
3666
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3667
- this._config = config;
3668
- this._statusUpdate = statusUpdate;
3669
- this._getCurrentStatus = getCurrentStatus;
3670
- this._onUpdateStatus = onUpdateStatus;
3671
- this._onReset = onReset;
3672
- }
3673
- async getConfig() {
3674
- var _a, _b;
3675
- return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
3676
- }
3677
- async updateStatus({ status }) {
3678
- await this._onUpdateStatus(status);
3679
- }
3680
- queryStatus() {
3681
- return new import_codec_protobuf13.Stream(({ next }) => {
3682
- const update = () => {
3683
- next({
3684
- status: this._getCurrentStatus()
3685
- });
3686
- };
3687
- update();
3688
- const unsubscribe = this._statusUpdate.on(() => update());
3689
- const interval = setInterval(update, 3e3);
3690
- return () => {
3691
- clearInterval(interval);
3692
- unsubscribe();
3693
- };
3694
- });
3695
- }
3696
- async reset() {
3697
- await this._onReset();
3698
- }
3699
- };
3700
-
3701
3700
  // packages/sdk/client-services/src/packlets/services/service-registry.ts
3702
3701
  var ServiceRegistry = class {
3703
3702
  // prettier-ignore
@@ -3954,6 +3953,28 @@ var ClientServicesHost = class {
3954
3953
  }
3955
3954
  };
3956
3955
 
3956
+ // packages/sdk/client-services/src/packlets/services/local-client-services.ts
3957
+ var LocalClientServices = class {
3958
+ constructor(params) {
3959
+ this._host = new ClientServicesHost(params);
3960
+ }
3961
+ get descriptors() {
3962
+ return this._host.descriptors;
3963
+ }
3964
+ get services() {
3965
+ return this._host.services;
3966
+ }
3967
+ get host() {
3968
+ return this._host;
3969
+ }
3970
+ async open() {
3971
+ await this._host.open();
3972
+ }
3973
+ async close() {
3974
+ await this._host.close();
3975
+ }
3976
+ };
3977
+
3957
3978
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3958
3979
  var import_async19 = require("@dxos/async");
3959
3980
  var import_client_protocol7 = require("@dxos/client-protocol");
@@ -4147,7 +4168,7 @@ var IFrameHostRuntime = class {
4147
4168
  iceServers: this._config.get("runtime.services.ice")
4148
4169
  });
4149
4170
  const signals = this._config.get("runtime.services.signaling");
4150
- this._clientServices = new ClientServicesHost({
4171
+ this._clientServices = new LocalClientServices({
4151
4172
  lockKey: LOCK_KEY,
4152
4173
  config: this._config,
4153
4174
  signalManager: signals ? new import_messaging2.WebsocketSignalManager(signals) : new import_messaging2.MemorySignalManager(new import_messaging2.MemorySignalManagerContext()),
@@ -4174,7 +4195,7 @@ var IFrameHostRuntime = class {
4174
4195
  }
4175
4196
  };
4176
4197
  this._clientRpc = new ClientRpcServer({
4177
- serviceRegistry: this._clientServices.serviceRegistry,
4198
+ serviceRegistry: this._clientServices.host.serviceRegistry,
4178
4199
  port: this._appPort,
4179
4200
  ...middleware
4180
4201
  });
@@ -4564,6 +4585,7 @@ var WorkerRuntime = class {
4564
4585
  IdentityServiceImpl,
4565
4586
  InvitationsHandler,
4566
4587
  InvitationsServiceImpl,
4588
+ LocalClientServices,
4567
4589
  Lock,
4568
4590
  MemoryShellRuntime,
4569
4591
  ServiceContext,