@dxos/client-services 0.1.56-main.3d59582 → 0.1.56-main.48c2ad7

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 (44) hide show
  1. package/dist/lib/browser/{chunk-FD4L7N4K.mjs → chunk-RAFQP6TU.mjs} +438 -229
  2. package/dist/lib/browser/chunk-RAFQP6TU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +10 -8
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  7. package/dist/lib/node/index.cjs +562 -352
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +839 -631
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  13. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  14. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  15. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  16. package/dist/types/src/packlets/services/index.d.ts +1 -0
  17. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  19. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  20. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts +4 -2
  22. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  23. package/dist/types/src/packlets/services/util.d.ts +6 -0
  24. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  25. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  26. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  27. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  28. package/dist/types/src/version.d.ts +2 -0
  29. package/dist/types/src/version.d.ts.map +1 -0
  30. package/package.json +33 -33
  31. package/src/packlets/logging/logging-service.ts +17 -9
  32. package/src/packlets/services/diagnostics.ts +211 -0
  33. package/src/packlets/services/index.ts +1 -0
  34. package/src/packlets/services/platform.ts +48 -0
  35. package/src/packlets/services/service-context.ts +2 -3
  36. package/src/packlets/services/service-host.test.ts +5 -5
  37. package/src/packlets/services/service-host.ts +22 -18
  38. package/src/packlets/services/service-registry.test.ts +1 -0
  39. package/src/packlets/services/util.ts +33 -0
  40. package/src/packlets/system/system-service.test.ts +1 -0
  41. package/src/packlets/system/system-service.ts +34 -2
  42. package/src/packlets/vault/worker-session.ts +6 -1
  43. package/src/version.ts +1 -0
  44. package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
@@ -2385,6 +2385,172 @@ var ClientRpcServer = class {
2385
2385
  }
2386
2386
  };
2387
2387
 
2388
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2389
+ import { getFirstStreamValue } from "@dxos/codec-protobuf";
2390
+ import { credentialTypeFilter } from "@dxos/credentials";
2391
+ import { DocumentModel } from "@dxos/document-model";
2392
+ import { invariant as invariant9 } from "@dxos/invariant";
2393
+ import { log as log8 } from "@dxos/log";
2394
+ import { STORAGE_VERSION } from "@dxos/protocols";
2395
+ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2396
+
2397
+ // packages/sdk/client-services/src/version.ts
2398
+ var DXOS_VERSION = "0.1.56-main.48c2ad7";
2399
+
2400
+ // packages/sdk/client-services/src/packlets/services/platform.ts
2401
+ var getPlatform = () => {
2402
+ if (process.browser) {
2403
+ if (typeof window !== "undefined") {
2404
+ const { userAgent } = window.navigator;
2405
+ return {
2406
+ type: "browser",
2407
+ userAgent,
2408
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2409
+ };
2410
+ } else {
2411
+ return {
2412
+ type: "shared-worker",
2413
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2414
+ };
2415
+ }
2416
+ } else {
2417
+ const { platform, version, arch } = process;
2418
+ return {
2419
+ type: "node",
2420
+ platform: `${platform} ${version} ${arch}`,
2421
+ runtime: process.version,
2422
+ uptime: Math.floor(process.uptime()),
2423
+ memory: process.memoryUsage()
2424
+ };
2425
+ }
2426
+ };
2427
+
2428
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2429
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2430
+ var DEFAULT_TIMEOUT = 1e3;
2431
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
2432
+ var _a, _b, _c;
2433
+ const diagnostics = {
2434
+ created: new Date().toISOString(),
2435
+ platform: getPlatform(),
2436
+ client: {
2437
+ version: DXOS_VERSION,
2438
+ storage: {
2439
+ version: STORAGE_VERSION
2440
+ }
2441
+ }
2442
+ };
2443
+ {
2444
+ invariant9(clientServices.LoggingService, "SystemService is not available.", {
2445
+ F: __dxlog_file10,
2446
+ L: 87,
2447
+ S: void 0,
2448
+ A: [
2449
+ "clientServices.LoggingService",
2450
+ "'SystemService is not available.'"
2451
+ ]
2452
+ });
2453
+ diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
2454
+ timeout: DEFAULT_TIMEOUT
2455
+ }).catch(() => void 0);
2456
+ }
2457
+ const identity = serviceContext.identityManager.identity;
2458
+ if (identity) {
2459
+ diagnostics.identity = {
2460
+ identityKey: identity.identityKey,
2461
+ spaceKey: identity.space.key,
2462
+ profile: identity.profileDocument
2463
+ };
2464
+ const { devices } = (_a = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
2465
+ timeout: DEFAULT_TIMEOUT
2466
+ }).catch(() => void 0)) != null ? _a : {};
2467
+ diagnostics.devices = devices;
2468
+ if (serviceContext.dataSpaceManager) {
2469
+ diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
2470
+ }
2471
+ const { feeds = [] } = (_c = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2472
+ timeout: DEFAULT_TIMEOUT
2473
+ }).catch(() => void 0)) != null ? _c : {};
2474
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2475
+ feedKey,
2476
+ bytes,
2477
+ length
2478
+ }));
2479
+ }
2480
+ diagnostics.config = config.values;
2481
+ return diagnostics;
2482
+ };
2483
+ var getProperties = (space) => {
2484
+ let properties = {};
2485
+ try {
2486
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
2487
+ var _a, _b;
2488
+ return ((_a = item.modelMeta) == null ? void 0 : _a.type) === DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
2489
+ });
2490
+ const state = propertiesItem == null ? void 0 : propertiesItem.state;
2491
+ properties = state == null ? void 0 : state.data;
2492
+ } catch (err) {
2493
+ log8.warn(err.message, void 0, {
2494
+ F: __dxlog_file10,
2495
+ L: 144,
2496
+ S: void 0,
2497
+ C: (f, a) => f(...a)
2498
+ });
2499
+ }
2500
+ return properties;
2501
+ };
2502
+ var getSpaceStats = async (space) => {
2503
+ var _a, _b, _c, _d, _e, _f;
2504
+ const stats = {
2505
+ key: space.key,
2506
+ metrics: space.metrics,
2507
+ epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
2508
+ ...credential.subject.assertion,
2509
+ id: credential.id
2510
+ })),
2511
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2512
+ var _a2;
2513
+ return {
2514
+ identity: {
2515
+ identityKey: member.key,
2516
+ profile: {
2517
+ displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
2518
+ }
2519
+ },
2520
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
2521
+ };
2522
+ }),
2523
+ pipeline: {
2524
+ // TODO(burdon): Pick properties from credentials if needed.
2525
+ // currentEpoch: space.dataPipeline.currentEpoch,
2526
+ // appliedEpoch: space.dataPipeline.appliedEpoch,
2527
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2528
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2529
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2530
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
2531
+ // TODO(burdon): Empty?
2532
+ dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
2533
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
2534
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
2535
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
2536
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
2537
+ }
2538
+ };
2539
+ if (space.dataPipeline.itemManager) {
2540
+ Object.assign(stats, {
2541
+ properties: getProperties(space),
2542
+ db: {
2543
+ objects: space.dataPipeline.itemManager.entities.size
2544
+ }
2545
+ });
2546
+ }
2547
+ if (stats.metrics) {
2548
+ const { open, ready } = stats.metrics;
2549
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2550
+ }
2551
+ return stats;
2552
+ };
2553
+
2388
2554
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2389
2555
  import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
2390
2556
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
@@ -2393,7 +2559,7 @@ import { timed } from "@dxos/debug";
2393
2559
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2394
2560
  import { CancelledError, SystemError } from "@dxos/errors";
2395
2561
  import { PublicKey as PublicKey7 } from "@dxos/keys";
2396
- import { log as log9 } from "@dxos/log";
2562
+ import { log as log10 } from "@dxos/log";
2397
2563
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
2398
2564
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2399
2565
  import { Timeframe } from "@dxos/timeframe";
@@ -2402,13 +2568,13 @@ import { ComplexSet as ComplexSet2 } from "@dxos/util";
2402
2568
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2403
2569
  import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
2404
2570
  import { Context as Context5, rejectOnDispose } from "@dxos/context";
2405
- import { invariant as invariant9 } from "@dxos/invariant";
2571
+ import { invariant as invariant10 } from "@dxos/invariant";
2406
2572
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2407
- import { log as log8 } from "@dxos/log";
2573
+ import { log as log9 } from "@dxos/log";
2408
2574
  import { schema as schema3 } from "@dxos/protocols";
2409
2575
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
2410
2576
  import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
2411
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2577
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2412
2578
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2413
2579
  var DEFAULT_SUCCESS_DELAY = 1e3;
2414
2580
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -2433,16 +2599,16 @@ var NotarizationPlugin = class {
2433
2599
  * Request credentials to be notarized.
2434
2600
  */
2435
2601
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2436
- log8("notarize", {
2602
+ log9("notarize", {
2437
2603
  credentials
2438
2604
  }, {
2439
- F: __dxlog_file10,
2605
+ F: __dxlog_file11,
2440
2606
  L: 90,
2441
2607
  S: this,
2442
2608
  C: (f, a) => f(...a)
2443
2609
  });
2444
- invariant9(credentials.every((credential) => credential.id), "Credentials must have an id", {
2445
- F: __dxlog_file10,
2610
+ invariant10(credentials.every((credential) => credential.id), "Credentials must have an id", {
2611
+ F: __dxlog_file11,
2446
2612
  L: 91,
2447
2613
  S: this,
2448
2614
  A: [
@@ -2453,10 +2619,10 @@ var NotarizationPlugin = class {
2453
2619
  const errors = new Trigger4();
2454
2620
  const ctx = this._ctx.derive({
2455
2621
  onError: (err) => {
2456
- log8.warn("Notarization error", {
2622
+ log9.warn("Notarization error", {
2457
2623
  err
2458
2624
  }, {
2459
- F: __dxlog_file10,
2625
+ F: __dxlog_file11,
2460
2626
  L: 99,
2461
2627
  S: this,
2462
2628
  C: (f, a) => f(...a)
@@ -2468,11 +2634,11 @@ var NotarizationPlugin = class {
2468
2634
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2469
2635
  if (timeout !== 0) {
2470
2636
  scheduleTask3(ctx, () => {
2471
- log8.warn("Notarization timeout", {
2637
+ log9.warn("Notarization timeout", {
2472
2638
  timeout,
2473
2639
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2474
2640
  }, {
2475
- F: __dxlog_file10,
2641
+ F: __dxlog_file11,
2476
2642
  L: 111,
2477
2643
  S: this,
2478
2644
  C: (f, a) => f(...a)
@@ -2492,10 +2658,10 @@ var NotarizationPlugin = class {
2492
2658
  ...this._extensions
2493
2659
  ].find((peer2) => !peersTried.has(peer2));
2494
2660
  if (!peer) {
2495
- log8.warn("Exhausted all peers to notarize with", {
2661
+ log9.warn("Exhausted all peers to notarize with", {
2496
2662
  retryIn: retryTimeout
2497
2663
  }, {
2498
- F: __dxlog_file10,
2664
+ F: __dxlog_file11,
2499
2665
  L: 136,
2500
2666
  S: this,
2501
2667
  C: (f, a) => f(...a)
@@ -2505,11 +2671,11 @@ var NotarizationPlugin = class {
2505
2671
  return;
2506
2672
  }
2507
2673
  peersTried.add(peer);
2508
- log8("try notarizing", {
2674
+ log9("try notarizing", {
2509
2675
  peer: peer.localPeerId,
2510
2676
  credentialId: credentials.map((credential) => credential.id)
2511
2677
  }, {
2512
- F: __dxlog_file10,
2678
+ F: __dxlog_file11,
2513
2679
  L: 143,
2514
2680
  S: this,
2515
2681
  C: (f, a) => f(...a)
@@ -2517,8 +2683,8 @@ var NotarizationPlugin = class {
2517
2683
  await peer.rpc.NotarizationService.notarize({
2518
2684
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2519
2685
  });
2520
- log8("success", void 0, {
2521
- F: __dxlog_file10,
2686
+ log9("success", void 0, {
2687
+ F: __dxlog_file11,
2522
2688
  L: 147,
2523
2689
  S: this,
2524
2690
  C: (f, a) => f(...a)
@@ -2526,8 +2692,8 @@ var NotarizationPlugin = class {
2526
2692
  await sleep(successDelay);
2527
2693
  } catch (err) {
2528
2694
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2529
- log8.warn("error notarizing (recoverable)", err, {
2530
- F: __dxlog_file10,
2695
+ log9.warn("error notarizing (recoverable)", err, {
2696
+ F: __dxlog_file11,
2531
2697
  L: 151,
2532
2698
  S: this,
2533
2699
  C: (f, a) => f(...a)
@@ -2544,8 +2710,8 @@ var NotarizationPlugin = class {
2544
2710
  allNotarized,
2545
2711
  errors.wait()
2546
2712
  ]);
2547
- log8("done", void 0, {
2548
- F: __dxlog_file10,
2713
+ log9("done", void 0, {
2714
+ F: __dxlog_file11,
2549
2715
  L: 162,
2550
2716
  S: this,
2551
2717
  C: (f, a) => f(...a)
@@ -2567,8 +2733,8 @@ var NotarizationPlugin = class {
2567
2733
  this._processCredentialsTriggers.delete(credential.id);
2568
2734
  }
2569
2735
  setWriter(writer) {
2570
- invariant9(!this._writer, "Writer already set.", {
2571
- F: __dxlog_file10,
2736
+ invariant10(!this._writer, "Writer already set.", {
2737
+ F: __dxlog_file11,
2572
2738
  L: 181,
2573
2739
  S: this,
2574
2740
  A: [
@@ -2593,8 +2759,8 @@ var NotarizationPlugin = class {
2593
2759
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2594
2760
  }
2595
2761
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2596
- invariant9(credential.id, "Credential must have an id", {
2597
- F: __dxlog_file10,
2762
+ invariant10(credential.id, "Credential must have an id", {
2763
+ F: __dxlog_file11,
2598
2764
  L: 200,
2599
2765
  S: this,
2600
2766
  A: [
@@ -2611,10 +2777,10 @@ var NotarizationPlugin = class {
2611
2777
  createExtension() {
2612
2778
  const extension = new NotarizationTeleportExtension({
2613
2779
  onOpen: async () => {
2614
- log8("extension opened", {
2780
+ log9("extension opened", {
2615
2781
  peer: extension.localPeerId
2616
2782
  }, {
2617
- F: __dxlog_file10,
2783
+ F: __dxlog_file11,
2618
2784
  L: 211,
2619
2785
  S: this,
2620
2786
  C: (f, a) => f(...a)
@@ -2623,10 +2789,10 @@ var NotarizationPlugin = class {
2623
2789
  this._extensionOpened.emit();
2624
2790
  },
2625
2791
  onClose: async () => {
2626
- log8("extension closed", {
2792
+ log9("extension closed", {
2627
2793
  peer: extension.localPeerId
2628
2794
  }, {
2629
- F: __dxlog_file10,
2795
+ F: __dxlog_file11,
2630
2796
  L: 216,
2631
2797
  S: this,
2632
2798
  C: (f, a) => f(...a)
@@ -2680,7 +2846,7 @@ function _ts_decorate(decorators, target, key, desc) {
2680
2846
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2681
2847
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2682
2848
  }
2683
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2849
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2684
2850
  var DataSpace = class DataSpace2 {
2685
2851
  constructor(params) {
2686
2852
  this._ctx = new Context6();
@@ -2778,16 +2944,16 @@ var DataSpace = class DataSpace2 {
2778
2944
  await this.initializeDataPipeline();
2779
2945
  } catch (err) {
2780
2946
  if (err instanceof CancelledError) {
2781
- log9("data pipeline initialization cancelled", err, {
2782
- F: __dxlog_file11,
2947
+ log10("data pipeline initialization cancelled", err, {
2948
+ F: __dxlog_file12,
2783
2949
  L: 193,
2784
2950
  S: this,
2785
2951
  C: (f, a) => f(...a)
2786
2952
  });
2787
2953
  return;
2788
2954
  }
2789
- log9.error("Error initializing data pipeline", err, {
2790
- F: __dxlog_file11,
2955
+ log10.error("Error initializing data pipeline", err, {
2956
+ F: __dxlog_file12,
2791
2957
  L: 197,
2792
2958
  S: this,
2793
2959
  C: (f, a) => f(...a)
@@ -2812,8 +2978,8 @@ var DataSpace = class DataSpace2 {
2812
2978
  });
2813
2979
  this.metrics.controlPipelineReady = new Date();
2814
2980
  await this._createWritableFeeds();
2815
- log9("writable feeds created", void 0, {
2816
- F: __dxlog_file11,
2981
+ log10("writable feeds created", void 0, {
2982
+ F: __dxlog_file12,
2817
2983
  L: 221,
2818
2984
  S: this,
2819
2985
  C: (f, a) => f(...a)
@@ -2829,8 +2995,8 @@ var DataSpace = class DataSpace2 {
2829
2995
  await this._inner.initializeDataPipeline();
2830
2996
  this.metrics.dataPipelineOpen = new Date();
2831
2997
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2832
- log9("waiting for data pipeline to reach target timeframe", void 0, {
2833
- F: __dxlog_file11,
2998
+ log10("waiting for data pipeline to reach target timeframe", void 0, {
2999
+ F: __dxlog_file12,
2834
3000
  L: 242,
2835
3001
  S: this,
2836
3002
  C: (f, a) => f(...a)
@@ -2840,8 +3006,8 @@ var DataSpace = class DataSpace2 {
2840
3006
  breakOnStall: false
2841
3007
  });
2842
3008
  this.metrics.dataPipelineReady = new Date();
2843
- log9("data pipeline ready", void 0, {
2844
- F: __dxlog_file11,
3009
+ log10("data pipeline ready", void 0, {
3010
+ F: __dxlog_file12,
2845
3011
  L: 251,
2846
3012
  S: this,
2847
3013
  C: (f, a) => f(...a)
@@ -2963,9 +3129,9 @@ DataSpace = _ts_decorate([
2963
3129
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
2964
3130
  import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
2965
3131
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
2966
- import { invariant as invariant10 } from "@dxos/invariant";
3132
+ import { invariant as invariant11 } from "@dxos/invariant";
2967
3133
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2968
- import { log as log10 } from "@dxos/log";
3134
+ import { log as log11 } from "@dxos/log";
2969
3135
  import { trace as trace4 } from "@dxos/protocols";
2970
3136
  import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
2971
3137
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
@@ -2974,7 +3140,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
2974
3140
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
2975
3141
  import { createCredential } from "@dxos/credentials";
2976
3142
  import { failUndefined as failUndefined2 } from "@dxos/debug";
2977
- import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
3143
+ import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
2978
3144
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2979
3145
  var spaceGenesis = async (keyring, signingContext, space) => {
2980
3146
  var _a, _b, _c, _d;
@@ -2995,7 +3161,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2995
3161
  assertion: {
2996
3162
  "@type": "dxos.halo.credentials.SpaceMember",
2997
3163
  spaceKey: space.key,
2998
- role: SpaceMember.Role.ADMIN,
3164
+ role: SpaceMember2.Role.ADMIN,
2999
3165
  profile: signingContext.profile,
3000
3166
  genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : failUndefined2()
3001
3167
  }
@@ -3052,7 +3218,7 @@ function _ts_decorate2(decorators, target, key, desc) {
3052
3218
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3053
3219
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3054
3220
  }
3055
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3221
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3056
3222
  var DataSpaceManager = class DataSpaceManager2 {
3057
3223
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
3058
3224
  this._spaceManager = _spaceManager;
@@ -3072,35 +3238,35 @@ var DataSpaceManager = class DataSpaceManager2 {
3072
3238
  return this._spaces;
3073
3239
  }
3074
3240
  async open() {
3075
- log10("open", void 0, {
3076
- F: __dxlog_file12,
3241
+ log11("open", void 0, {
3242
+ F: __dxlog_file13,
3077
3243
  L: 79,
3078
3244
  S: this,
3079
3245
  C: (f, a) => f(...a)
3080
3246
  });
3081
- log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
3247
+ log11.trace("dxos.echo.data-space-manager.open", trace4.begin({
3082
3248
  id: this._instanceId
3083
3249
  }), {
3084
- F: __dxlog_file12,
3250
+ F: __dxlog_file13,
3085
3251
  L: 80,
3086
3252
  S: this,
3087
3253
  C: (f, a) => f(...a)
3088
3254
  });
3089
3255
  await this._metadataStore.load();
3090
- log10("metadata loaded", {
3256
+ log11("metadata loaded", {
3091
3257
  spaces: this._metadataStore.spaces.length
3092
3258
  }, {
3093
- F: __dxlog_file12,
3259
+ F: __dxlog_file13,
3094
3260
  L: 82,
3095
3261
  S: this,
3096
3262
  C: (f, a) => f(...a)
3097
3263
  });
3098
3264
  for (const spaceMetadata of this._metadataStore.spaces) {
3099
3265
  try {
3100
- log10("load space", {
3266
+ log11("load space", {
3101
3267
  spaceMetadata
3102
3268
  }, {
3103
- F: __dxlog_file12,
3269
+ F: __dxlog_file13,
3104
3270
  L: 86,
3105
3271
  S: this,
3106
3272
  C: (f, a) => f(...a)
@@ -3110,11 +3276,11 @@ var DataSpaceManager = class DataSpaceManager2 {
3110
3276
  space.initializeDataPipelineAsync();
3111
3277
  }
3112
3278
  } catch (err) {
3113
- log10.error("Error loading space", {
3279
+ log11.error("Error loading space", {
3114
3280
  spaceMetadata,
3115
3281
  err
3116
3282
  }, {
3117
- F: __dxlog_file12,
3283
+ F: __dxlog_file13,
3118
3284
  L: 92,
3119
3285
  S: this,
3120
3286
  C: (f, a) => f(...a)
@@ -3123,18 +3289,18 @@ var DataSpaceManager = class DataSpaceManager2 {
3123
3289
  }
3124
3290
  this._isOpen = true;
3125
3291
  this.updated.emit();
3126
- log10.trace("dxos.echo.data-space-manager.open", trace4.end({
3292
+ log11.trace("dxos.echo.data-space-manager.open", trace4.end({
3127
3293
  id: this._instanceId
3128
3294
  }), {
3129
- F: __dxlog_file12,
3295
+ F: __dxlog_file13,
3130
3296
  L: 98,
3131
3297
  S: this,
3132
3298
  C: (f, a) => f(...a)
3133
3299
  });
3134
3300
  }
3135
3301
  async close() {
3136
- log10("close", void 0, {
3137
- F: __dxlog_file12,
3302
+ log11("close", void 0, {
3303
+ F: __dxlog_file13,
3138
3304
  L: 103,
3139
3305
  S: this,
3140
3306
  C: (f, a) => f(...a)
@@ -3149,8 +3315,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3149
3315
  * Creates a new space writing the genesis credentials to the control feed.
3150
3316
  */
3151
3317
  async createSpace() {
3152
- invariant10(this._isOpen, "Not open.", {
3153
- F: __dxlog_file12,
3318
+ invariant11(this._isOpen, "Not open.", {
3319
+ F: __dxlog_file13,
3154
3320
  L: 116,
3155
3321
  S: this,
3156
3322
  A: [
@@ -3168,10 +3334,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3168
3334
  dataFeedKey,
3169
3335
  state: SpaceState2.ACTIVE
3170
3336
  };
3171
- log10("creating space...", {
3337
+ log11("creating space...", {
3172
3338
  spaceKey
3173
3339
  }, {
3174
- F: __dxlog_file12,
3340
+ F: __dxlog_file13,
3175
3341
  L: 128,
3176
3342
  S: this,
3177
3343
  C: (f, a) => f(...a)
@@ -3180,8 +3346,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3180
3346
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
3181
3347
  await this._metadataStore.addSpace(metadata);
3182
3348
  const memberCredential = credentials[1];
3183
- invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3184
- F: __dxlog_file12,
3349
+ invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3350
+ F: __dxlog_file13,
3185
3351
  L: 135,
3186
3352
  S: this,
3187
3353
  A: [
@@ -3196,16 +3362,16 @@ var DataSpaceManager = class DataSpaceManager2 {
3196
3362
  }
3197
3363
  // TODO(burdon): Rename join space.
3198
3364
  async acceptSpace(opts) {
3199
- log10("accept space", {
3365
+ log11("accept space", {
3200
3366
  opts
3201
3367
  }, {
3202
- F: __dxlog_file12,
3368
+ F: __dxlog_file13,
3203
3369
  L: 147,
3204
3370
  S: this,
3205
3371
  C: (f, a) => f(...a)
3206
3372
  });
3207
- invariant10(this._isOpen, "Not open.", {
3208
- F: __dxlog_file12,
3373
+ invariant11(this._isOpen, "Not open.", {
3374
+ F: __dxlog_file13,
3209
3375
  L: 148,
3210
3376
  S: this,
3211
3377
  A: [
@@ -3213,8 +3379,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3213
3379
  "'Not open.'"
3214
3380
  ]
3215
3381
  });
3216
- invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3217
- F: __dxlog_file12,
3382
+ invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3383
+ F: __dxlog_file13,
3218
3384
  L: 149,
3219
3385
  S: this,
3220
3386
  A: [
@@ -3246,10 +3412,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3246
3412
  }));
3247
3413
  }
3248
3414
  async _constructSpace(metadata) {
3249
- log10("construct space", {
3415
+ log11("construct space", {
3250
3416
  metadata
3251
3417
  }, {
3252
- F: __dxlog_file12,
3418
+ F: __dxlog_file13,
3253
3419
  L: 182,
3254
3420
  S: this,
3255
3421
  C: (f, a) => f(...a)
@@ -3284,8 +3450,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3284
3450
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3285
3451
  },
3286
3452
  onAuthFailure: () => {
3287
- log10.warn("auth failure", void 0, {
3288
- F: __dxlog_file12,
3453
+ log11.warn("auth failure", void 0, {
3454
+ F: __dxlog_file13,
3289
3455
  L: 213,
3290
3456
  S: this,
3291
3457
  C: (f, a) => f(...a)
@@ -3306,10 +3472,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3306
3472
  signingContext: this._signingContext,
3307
3473
  callbacks: {
3308
3474
  beforeReady: async () => {
3309
- log10("before space ready", {
3475
+ log11("before space ready", {
3310
3476
  space: space.key
3311
3477
  }, {
3312
- F: __dxlog_file12,
3478
+ F: __dxlog_file13,
3313
3479
  L: 231,
3314
3480
  S: this,
3315
3481
  C: (f, a) => f(...a)
@@ -3317,11 +3483,11 @@ var DataSpaceManager = class DataSpaceManager2 {
3317
3483
  await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3318
3484
  },
3319
3485
  afterReady: async () => {
3320
- log10("after space ready", {
3486
+ log11("after space ready", {
3321
3487
  space: space.key,
3322
3488
  open: this._isOpen
3323
3489
  }, {
3324
- F: __dxlog_file12,
3490
+ F: __dxlog_file13,
3325
3491
  L: 238,
3326
3492
  S: this,
3327
3493
  C: (f, a) => f(...a)
@@ -3331,10 +3497,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3331
3497
  }
3332
3498
  },
3333
3499
  beforeClose: async () => {
3334
- log10("before space close", {
3500
+ log11("before space close", {
3335
3501
  space: space.key
3336
3502
  }, {
3337
- F: __dxlog_file12,
3503
+ F: __dxlog_file13,
3338
3504
  L: 244,
3339
3505
  S: this,
3340
3506
  C: (f, a) => f(...a)
@@ -3379,11 +3545,11 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
3379
3545
  import { raise as raise2 } from "@dxos/debug";
3380
3546
  import { SpaceNotFoundError } from "@dxos/echo-pipeline";
3381
3547
  import { ApiError } from "@dxos/errors";
3382
- import { log as log11 } from "@dxos/log";
3548
+ import { log as log12 } from "@dxos/log";
3383
3549
  import { encodeError } from "@dxos/protocols";
3384
- import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3550
+ import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3385
3551
  import { humanize } from "@dxos/util";
3386
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3552
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3387
3553
  var SpacesServiceImpl = class {
3388
3554
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3389
3555
  this._identityManager = _identityManager;
@@ -3421,10 +3587,10 @@ var SpacesServiceImpl = class {
3421
3587
  const scheduler = new UpdateScheduler(ctx, async () => {
3422
3588
  const dataSpaceManager = await this._getDataSpaceManager();
3423
3589
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
3424
- log11("update", {
3590
+ log12("update", {
3425
3591
  spaces
3426
3592
  }, {
3427
- F: __dxlog_file13,
3593
+ F: __dxlog_file14,
3428
3594
  L: 78,
3429
3595
  S: this,
3430
3596
  C: (f, a) => f(...a)
@@ -3547,7 +3713,7 @@ var SpacesServiceImpl = class {
3547
3713
  displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : humanize(member.key)
3548
3714
  }
3549
3715
  },
3550
- presence: isMe || peers.length > 0 ? SpaceMember2.PresenceState.ONLINE : SpaceMember2.PresenceState.OFFLINE,
3716
+ presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
3551
3717
  peerStates: peers
3552
3718
  };
3553
3719
  }),
@@ -3565,14 +3731,14 @@ import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credent
3565
3731
  import { failUndefined as failUndefined3 } from "@dxos/debug";
3566
3732
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
3567
3733
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
3568
- import { invariant as invariant11 } from "@dxos/invariant";
3734
+ import { invariant as invariant12 } from "@dxos/invariant";
3569
3735
  import { Keyring } from "@dxos/keyring";
3570
3736
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3571
- import { log as log12 } from "@dxos/log";
3572
- import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
3737
+ import { log as log13 } from "@dxos/log";
3738
+ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace5 } from "@dxos/protocols";
3573
3739
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3574
3740
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
3575
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3741
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3576
3742
  var ServiceContext = class {
3577
3743
  // prettier-ignore
3578
3744
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3613,18 +3779,18 @@ var ServiceContext = class {
3613
3779
  }, this._acceptIdentity.bind(this)));
3614
3780
  }
3615
3781
  async open() {
3616
- log12.trace("dxos.sdk.service-context.open", trace5.begin({
3617
- id: this._instanceId
3618
- }), {
3619
- F: __dxlog_file14,
3620
- L: 125,
3782
+ await this._checkStorageVersion();
3783
+ log13("opening...", void 0, {
3784
+ F: __dxlog_file15,
3785
+ L: 127,
3621
3786
  S: this,
3622
3787
  C: (f, a) => f(...a)
3623
3788
  });
3624
- await this._checkStorageVersion();
3625
- log12("opening...", void 0, {
3626
- F: __dxlog_file14,
3627
- L: 129,
3789
+ log13.trace("dxos.sdk.service-context.open", trace5.begin({
3790
+ id: this._instanceId
3791
+ }), {
3792
+ F: __dxlog_file15,
3793
+ L: 128,
3628
3794
  S: this,
3629
3795
  C: (f, a) => f(...a)
3630
3796
  });
@@ -3635,26 +3801,26 @@ var ServiceContext = class {
3635
3801
  if (this.identityManager.identity) {
3636
3802
  await this._initialize();
3637
3803
  }
3638
- log12("opened", void 0, {
3639
- F: __dxlog_file14,
3640
- L: 137,
3804
+ log13.trace("dxos.sdk.service-context.open", trace5.end({
3805
+ id: this._instanceId
3806
+ }), {
3807
+ F: __dxlog_file15,
3808
+ L: 136,
3641
3809
  S: this,
3642
3810
  C: (f, a) => f(...a)
3643
3811
  });
3644
- log12.trace("dxos.sdk.service-context.open", trace5.end({
3645
- id: this._instanceId
3646
- }), {
3647
- F: __dxlog_file14,
3648
- L: 138,
3812
+ log13("opened", void 0, {
3813
+ F: __dxlog_file15,
3814
+ L: 137,
3649
3815
  S: this,
3650
3816
  C: (f, a) => f(...a)
3651
3817
  });
3652
3818
  }
3653
3819
  async close() {
3654
3820
  var _a;
3655
- log12("closing...", void 0, {
3656
- F: __dxlog_file14,
3657
- L: 142,
3821
+ log13("closing...", void 0, {
3822
+ F: __dxlog_file15,
3823
+ L: 141,
3658
3824
  S: this,
3659
3825
  C: (f, a) => f(...a)
3660
3826
  });
@@ -3668,9 +3834,9 @@ var ServiceContext = class {
3668
3834
  await this.networkManager.close();
3669
3835
  await this.signalManager.close();
3670
3836
  this.dataServiceSubscriptions.clear();
3671
- log12("closed", void 0, {
3672
- F: __dxlog_file14,
3673
- L: 153,
3837
+ log13("closed", void 0, {
3838
+ F: __dxlog_file15,
3839
+ L: 152,
3674
3840
  S: this,
3675
3841
  C: (f, a) => f(...a)
3676
3842
  });
@@ -3682,9 +3848,9 @@ var ServiceContext = class {
3682
3848
  }
3683
3849
  getInvitationHandler(invitation) {
3684
3850
  const factory = this._handlerFactories.get(invitation.kind);
3685
- invariant11(factory, `Unknown invitation kind: ${invitation.kind}`, {
3686
- F: __dxlog_file14,
3687
- L: 165,
3851
+ invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
3852
+ F: __dxlog_file15,
3853
+ L: 164,
3688
3854
  S: this,
3689
3855
  A: [
3690
3856
  "factory",
@@ -3700,16 +3866,16 @@ var ServiceContext = class {
3700
3866
  }
3701
3867
  async _checkStorageVersion() {
3702
3868
  await this.metadataStore.load();
3703
- if (this.metadataStore.version !== STORAGE_VERSION) {
3704
- throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION}`);
3869
+ if (this.metadataStore.version !== STORAGE_VERSION2) {
3870
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION2}`);
3705
3871
  }
3706
3872
  }
3707
3873
  // Called when identity is created.
3708
3874
  async _initialize() {
3709
3875
  var _a;
3710
- log12("initializing spaces...", void 0, {
3711
- F: __dxlog_file14,
3712
- L: 186,
3876
+ log13("initializing spaces...", void 0, {
3877
+ F: __dxlog_file15,
3878
+ L: 185,
3713
3879
  S: this,
3714
3880
  C: (f, a) => f(...a)
3715
3881
  });
@@ -3730,9 +3896,9 @@ var ServiceContext = class {
3730
3896
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3731
3897
  await this.dataSpaceManager.open();
3732
3898
  this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
3733
- invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3734
- F: __dxlog_file14,
3735
- L: 209,
3899
+ invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3900
+ F: __dxlog_file15,
3901
+ L: 208,
3736
3902
  S: this,
3737
3903
  A: [
3738
3904
  "this.dataSpaceManager",
@@ -3752,33 +3918,33 @@ var ServiceContext = class {
3752
3918
  return;
3753
3919
  }
3754
3920
  if (!this.dataSpaceManager) {
3755
- log12("dataSpaceManager not initialized yet, ignoring space admission", {
3921
+ log13("dataSpaceManager not initialized yet, ignoring space admission", {
3756
3922
  details: assertion
3757
3923
  }, {
3758
- F: __dxlog_file14,
3759
- L: 225,
3924
+ F: __dxlog_file15,
3925
+ L: 224,
3760
3926
  S: this,
3761
3927
  C: (f, a) => f(...a)
3762
3928
  });
3763
3929
  return;
3764
3930
  }
3765
3931
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3766
- log12("space already exists, ignoring space admission", {
3932
+ log13("space already exists, ignoring space admission", {
3767
3933
  details: assertion
3768
3934
  }, {
3769
- F: __dxlog_file14,
3770
- L: 229,
3935
+ F: __dxlog_file15,
3936
+ L: 228,
3771
3937
  S: this,
3772
3938
  C: (f, a) => f(...a)
3773
3939
  });
3774
3940
  return;
3775
3941
  }
3776
3942
  try {
3777
- log12("accepting space recorded in halo", {
3943
+ log13("accepting space recorded in halo", {
3778
3944
  details: assertion
3779
3945
  }, {
3780
- F: __dxlog_file14,
3781
- L: 234,
3946
+ F: __dxlog_file15,
3947
+ L: 233,
3782
3948
  S: this,
3783
3949
  C: (f, a) => f(...a)
3784
3950
  });
@@ -3787,9 +3953,9 @@ var ServiceContext = class {
3787
3953
  genesisFeedKey: assertion.genesisFeedKey
3788
3954
  });
3789
3955
  } catch (err) {
3790
- log12.catch(err, void 0, {
3791
- F: __dxlog_file14,
3792
- L: 240,
3956
+ log13.catch(err, void 0, {
3957
+ F: __dxlog_file15,
3958
+ L: 239,
3793
3959
  S: this,
3794
3960
  C: (f, a) => f(...a)
3795
3961
  });
@@ -3803,7 +3969,7 @@ var ServiceContext = class {
3803
3969
  // packages/sdk/client-services/src/packlets/locks/browser.ts
3804
3970
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3805
3971
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3806
- import { log as log13, logInfo } from "@dxos/log";
3972
+ import { log as log14, logInfo } from "@dxos/log";
3807
3973
  function _ts_decorate3(decorators, target, key, desc) {
3808
3974
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3809
3975
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3814,7 +3980,7 @@ function _ts_decorate3(decorators, target, key, desc) {
3814
3980
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3815
3981
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3816
3982
  }
3817
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
3983
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
3818
3984
  var Message;
3819
3985
  (function(Message2) {
3820
3986
  Message2["ACQUIRING"] = "acquiring";
@@ -3836,29 +4002,29 @@ var Lock = class {
3836
4002
  message: Message.ACQUIRING
3837
4003
  });
3838
4004
  try {
3839
- log13("aquiring lock...", void 0, {
3840
- F: __dxlog_file15,
4005
+ log14("aquiring lock...", void 0, {
4006
+ F: __dxlog_file16,
3841
4007
  L: 42,
3842
4008
  S: this,
3843
4009
  C: (f, a) => f(...a)
3844
4010
  });
3845
4011
  await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
3846
- log13("acquired lock", void 0, {
3847
- F: __dxlog_file15,
4012
+ log14("acquired lock", void 0, {
4013
+ F: __dxlog_file16,
3848
4014
  L: 44,
3849
4015
  S: this,
3850
4016
  C: (f, a) => f(...a)
3851
4017
  });
3852
4018
  } catch (e) {
3853
- log13("stealing lock...", void 0, {
3854
- F: __dxlog_file15,
4019
+ log14("stealing lock...", void 0, {
4020
+ F: __dxlog_file16,
3855
4021
  L: 46,
3856
4022
  S: this,
3857
4023
  C: (f, a) => f(...a)
3858
4024
  });
3859
4025
  await this._requestLock(true);
3860
- log13("stolen lock", void 0, {
3861
- F: __dxlog_file15,
4026
+ log14("stolen lock", void 0, {
4027
+ F: __dxlog_file16,
3862
4028
  L: 48,
3863
4029
  S: this,
3864
4030
  C: (f, a) => f(...a)
@@ -3874,10 +4040,10 @@ var Lock = class {
3874
4040
  }
3875
4041
  }
3876
4042
  async _requestLock(steal = false) {
3877
- log13("requesting lock...", {
4043
+ log14("requesting lock...", {
3878
4044
  steal
3879
4045
  }, {
3880
- F: __dxlog_file15,
4046
+ F: __dxlog_file16,
3881
4047
  L: 63,
3882
4048
  S: this,
3883
4049
  C: (f, a) => f(...a)
@@ -3891,15 +4057,15 @@ var Lock = class {
3891
4057
  acquired.wake();
3892
4058
  this._releaseTrigger = new Trigger6();
3893
4059
  await this._releaseTrigger.wait();
3894
- log13("releasing lock...", void 0, {
3895
- F: __dxlog_file15,
4060
+ log14("releasing lock...", void 0, {
4061
+ F: __dxlog_file16,
3896
4062
  L: 72,
3897
4063
  S: this,
3898
4064
  C: (f, a) => f(...a)
3899
4065
  });
3900
4066
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3901
- log13("released lock", void 0, {
3902
- F: __dxlog_file15,
4067
+ log14("released lock", void 0, {
4068
+ F: __dxlog_file16,
3903
4069
  L: 74,
3904
4070
  S: this,
3905
4071
  C: (f, a) => f(...a)
@@ -3909,10 +4075,10 @@ var Lock = class {
3909
4075
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3910
4076
  });
3911
4077
  await acquired.wait();
3912
- log13("recieved lock", {
4078
+ log14("recieved lock", {
3913
4079
  steal
3914
4080
  }, {
3915
- F: __dxlog_file15,
4081
+ F: __dxlog_file16,
3916
4082
  L: 81,
3917
4083
  S: this,
3918
4084
  C: (f, a) => f(...a)
@@ -4002,11 +4168,11 @@ var ServiceRegistry = class {
4002
4168
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4003
4169
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
4004
4170
  import { clientServiceBundle } from "@dxos/client-protocol";
4005
- import { DocumentModel } from "@dxos/document-model";
4171
+ import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4006
4172
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4007
- import { invariant as invariant12 } from "@dxos/invariant";
4173
+ import { invariant as invariant13 } from "@dxos/invariant";
4008
4174
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4009
- import { log as log15 } from "@dxos/log";
4175
+ import { log as log16 } from "@dxos/log";
4010
4176
  import { WebsocketSignalManager } from "@dxos/messaging";
4011
4177
  import { ModelFactory } from "@dxos/model-factory";
4012
4178
  import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
@@ -4064,22 +4230,23 @@ var DevicesServiceImpl = class {
4064
4230
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
4065
4231
  import { Event as Event7 } from "@dxos/async";
4066
4232
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
4067
- import { getContextFromEntry, log as log14 } from "@dxos/log";
4233
+ import { getContextFromEntry, log as log15 } from "@dxos/log";
4068
4234
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
4069
4235
  import { jsonify, numericalValues, tracer } from "@dxos/util";
4070
4236
  var LoggingServiceImpl = class {
4071
4237
  constructor() {
4072
4238
  this._logs = new Event7();
4239
+ this._started = new Date();
4073
4240
  this._logProcessor = (_config, entry2) => {
4074
4241
  this._logs.emit(entry2);
4075
4242
  };
4076
4243
  }
4077
4244
  async open() {
4078
- log14.runtimeConfig.processors.push(this._logProcessor);
4245
+ log15.runtimeConfig.processors.push(this._logProcessor);
4079
4246
  }
4080
4247
  async close() {
4081
- const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4082
- log14.runtimeConfig.processors.splice(index, 1);
4248
+ const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4249
+ log15.runtimeConfig.processors.splice(index, 1);
4083
4250
  }
4084
4251
  async controlMetrics({ reset, record }) {
4085
4252
  if (reset) {
@@ -4094,13 +4261,16 @@ var LoggingServiceImpl = class {
4094
4261
  recording: tracer.recording
4095
4262
  };
4096
4263
  }
4097
- queryMetrics({ interval }) {
4098
- const createNumericalValues = (key) => {
4264
+ /**
4265
+ * @deprecated (Move to diagnostics).
4266
+ */
4267
+ queryMetrics({ interval = 5e3 }) {
4268
+ const getNumericalValues = (key) => {
4099
4269
  var _a;
4100
- const consume = (_a = tracer.get(key)) != null ? _a : [];
4270
+ const events = (_a = tracer.get(key)) != null ? _a : [];
4101
4271
  return {
4102
4272
  key,
4103
- stats: numericalValues(consume, "duration")
4273
+ stats: numericalValues(events, "duration")
4104
4274
  };
4105
4275
  };
4106
4276
  return new Stream12(({ next }) => {
@@ -4108,14 +4278,17 @@ var LoggingServiceImpl = class {
4108
4278
  const metrics = {
4109
4279
  timestamp: new Date(),
4110
4280
  values: [
4111
- createNumericalValues("dxos.echo.pipeline.control"),
4112
- createNumericalValues("dxos.echo.pipeline.data")
4113
- ]
4281
+ getNumericalValues("dxos.echo.pipeline.control"),
4282
+ getNumericalValues("dxos.echo.pipeline.data")
4283
+ ].filter(Boolean)
4114
4284
  };
4115
- next(metrics);
4285
+ next({
4286
+ timestamp: new Date(),
4287
+ metrics
4288
+ });
4116
4289
  };
4117
4290
  update();
4118
- const i = setInterval(update, interval);
4291
+ const i = setInterval(update, Math.max(interval, 1e3));
4119
4292
  return () => {
4120
4293
  clearInterval(i);
4121
4294
  };
@@ -4211,11 +4384,14 @@ var NetworkServiceImpl = class {
4211
4384
 
4212
4385
  // packages/sdk/client-services/src/packlets/system/system-service.ts
4213
4386
  import { Stream as Stream14 } from "@dxos/codec-protobuf";
4387
+ import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
4388
+ import { jsonKeyReplacer } from "@dxos/util";
4214
4389
  var SystemServiceImpl = class {
4215
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
4390
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
4216
4391
  this._config = config;
4217
4392
  this._statusUpdate = statusUpdate;
4218
4393
  this._getCurrentStatus = getCurrentStatus;
4394
+ this._getDiagnostics = getDiagnostics;
4219
4395
  this._onUpdateStatus = onUpdateStatus;
4220
4396
  this._onReset = onReset;
4221
4397
  }
@@ -4223,6 +4399,19 @@ var SystemServiceImpl = class {
4223
4399
  var _a, _b;
4224
4400
  return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
4225
4401
  }
4402
+ /**
4403
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
4404
+ */
4405
+ async getDiagnostics({ keys } = {}) {
4406
+ const diagnostics = await this._getDiagnostics();
4407
+ return {
4408
+ timestamp: new Date(),
4409
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
4410
+ truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4411
+ humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4412
+ })))
4413
+ };
4414
+ }
4226
4415
  async updateStatus({ status }) {
4227
4416
  await this._onUpdateStatus(status);
4228
4417
  }
@@ -4259,18 +4448,16 @@ function _ts_decorate4(decorators, target, key, desc) {
4259
4448
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4260
4449
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4261
4450
  }
4262
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4451
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4263
4452
  var createDefaultModelFactory = () => {
4264
- return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
4453
+ return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
4265
4454
  };
4266
4455
  var ClientServicesHost = class {
4267
4456
  constructor({
4268
4457
  config,
4269
4458
  modelFactory = createDefaultModelFactory(),
4270
- // TODO(burdon): Create ApolloLink abstraction (see Client).
4271
4459
  transportFactory,
4272
4460
  signalManager,
4273
- connectionLog,
4274
4461
  storage,
4275
4462
  // TODO(wittjosiah): Turn this on by default.
4276
4463
  lockKey,
@@ -4304,6 +4491,9 @@ var ClientServicesHost = class {
4304
4491
  config: this._config,
4305
4492
  statusUpdate: this._statusUpdate,
4306
4493
  getCurrentStatus: () => this.isOpen ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
4494
+ getDiagnostics: () => {
4495
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4496
+ },
4307
4497
  onUpdateStatus: async (status) => {
4308
4498
  var _a, _b;
4309
4499
  if (!this.isOpen && status === SystemStatus.ACTIVE) {
@@ -4324,6 +4514,12 @@ var ClientServicesHost = class {
4324
4514
  get isOpen() {
4325
4515
  return this._open;
4326
4516
  }
4517
+ get config() {
4518
+ return this._config;
4519
+ }
4520
+ get context() {
4521
+ return this._serviceContext;
4522
+ }
4327
4523
  get serviceRegistry() {
4328
4524
  return this._serviceRegistry;
4329
4525
  }
@@ -4340,19 +4536,25 @@ var ClientServicesHost = class {
4340
4536
  */
4341
4537
  initialize({ config, ...options }) {
4342
4538
  var _a, _b, _c;
4343
- invariant12(!this._open, "service host is open", {
4344
- F: __dxlog_file16,
4345
- L: 167,
4539
+ invariant13(!this._open, "service host is open", {
4540
+ F: __dxlog_file17,
4541
+ L: 172,
4346
4542
  S: this,
4347
4543
  A: [
4348
4544
  "!this._open",
4349
4545
  "'service host is open'"
4350
4546
  ]
4351
4547
  });
4548
+ log16.info("initializing...", void 0, {
4549
+ F: __dxlog_file17,
4550
+ L: 173,
4551
+ S: this,
4552
+ C: (f, a) => f(...a)
4553
+ });
4352
4554
  if (config) {
4353
- invariant12(!this._config, "config already set", {
4354
- F: __dxlog_file16,
4355
- L: 170,
4555
+ invariant13(!this._config, "config already set", {
4556
+ F: __dxlog_file17,
4557
+ L: 176,
4356
4558
  S: this,
4357
4559
  A: [
4358
4560
  "!this._config",
@@ -4368,9 +4570,9 @@ var ClientServicesHost = class {
4368
4570
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4369
4571
  }), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4370
4572
  this._signalManager = signalManager;
4371
- invariant12(!this._networkManager, "network manager already set", {
4372
- F: __dxlog_file16,
4373
- L: 187,
4573
+ invariant13(!this._networkManager, "network manager already set", {
4574
+ F: __dxlog_file17,
4575
+ L: 192,
4374
4576
  S: this,
4375
4577
  A: [
4376
4578
  "!this._networkManager",
@@ -4382,6 +4584,12 @@ var ClientServicesHost = class {
4382
4584
  transportFactory,
4383
4585
  signalManager
4384
4586
  });
4587
+ log16.info("initialized", void 0, {
4588
+ F: __dxlog_file17,
4589
+ L: 199,
4590
+ S: this,
4591
+ C: (f, a) => f(...a)
4592
+ });
4385
4593
  }
4386
4594
  async open() {
4387
4595
  var _a, _b, _c;
@@ -4389,44 +4597,44 @@ var ClientServicesHost = class {
4389
4597
  return;
4390
4598
  }
4391
4599
  const traceId = PublicKey10.random().toHex();
4392
- log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
4600
+ log16.trace("dxos.client-services.host.open", trace6.begin({
4393
4601
  id: traceId
4394
4602
  }), {
4395
- F: __dxlog_file16,
4396
- L: 202,
4603
+ F: __dxlog_file17,
4604
+ L: 209,
4397
4605
  S: this,
4398
4606
  C: (f, a) => f(...a)
4399
4607
  });
4400
- invariant12(this._config, "config not set", {
4401
- F: __dxlog_file16,
4402
- L: 204,
4608
+ invariant13(this._config, "config not set", {
4609
+ F: __dxlog_file17,
4610
+ L: 211,
4403
4611
  S: this,
4404
4612
  A: [
4405
4613
  "this._config",
4406
4614
  "'config not set'"
4407
4615
  ]
4408
4616
  });
4409
- invariant12(this._storage, "storage not set", {
4410
- F: __dxlog_file16,
4411
- L: 205,
4617
+ invariant13(this._storage, "storage not set", {
4618
+ F: __dxlog_file17,
4619
+ L: 212,
4412
4620
  S: this,
4413
4621
  A: [
4414
4622
  "this._storage",
4415
4623
  "'storage not set'"
4416
4624
  ]
4417
4625
  });
4418
- invariant12(this._signalManager, "signal manager not set", {
4419
- F: __dxlog_file16,
4420
- L: 206,
4626
+ invariant13(this._signalManager, "signal manager not set", {
4627
+ F: __dxlog_file17,
4628
+ L: 213,
4421
4629
  S: this,
4422
4630
  A: [
4423
4631
  "this._signalManager",
4424
4632
  "'signal manager not set'"
4425
4633
  ]
4426
4634
  });
4427
- invariant12(this._networkManager, "network manager not set", {
4428
- F: __dxlog_file16,
4429
- L: 207,
4635
+ invariant13(this._networkManager, "network manager not set", {
4636
+ F: __dxlog_file17,
4637
+ L: 214,
4430
4638
  S: this,
4431
4639
  A: [
4432
4640
  "this._networkManager",
@@ -4434,11 +4642,11 @@ var ClientServicesHost = class {
4434
4642
  ]
4435
4643
  });
4436
4644
  this._opening = true;
4437
- log15("opening...", {
4645
+ log16.info("opening...", {
4438
4646
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4439
4647
  }, {
4440
- F: __dxlog_file16,
4441
- L: 210,
4648
+ F: __dxlog_file17,
4649
+ L: 217,
4442
4650
  S: this,
4443
4651
  C: (f, a) => f(...a)
4444
4652
  });
@@ -4469,19 +4677,19 @@ var ClientServicesHost = class {
4469
4677
  this._open = true;
4470
4678
  this._statusUpdate.emit();
4471
4679
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4472
- log15("opened", {
4680
+ log16.info("opened", {
4473
4681
  deviceKey
4474
4682
  }, {
4475
- F: __dxlog_file16,
4476
- L: 265,
4683
+ F: __dxlog_file17,
4684
+ L: 269,
4477
4685
  S: this,
4478
4686
  C: (f, a) => f(...a)
4479
4687
  });
4480
- log15.trace("dxos.sdk.client-services-host.open", trace6.end({
4688
+ log16.trace("dxos.client-services.host.open", trace6.end({
4481
4689
  id: traceId
4482
4690
  }), {
4483
- F: __dxlog_file16,
4484
- L: 266,
4691
+ F: __dxlog_file17,
4692
+ L: 270,
4485
4693
  S: this,
4486
4694
  C: (f, a) => f(...a)
4487
4695
  });
@@ -4492,11 +4700,11 @@ var ClientServicesHost = class {
4492
4700
  return;
4493
4701
  }
4494
4702
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4495
- log15("closing...", {
4703
+ log16.info("closing...", {
4496
4704
  deviceKey
4497
4705
  }, {
4498
- F: __dxlog_file16,
4499
- L: 276,
4706
+ F: __dxlog_file17,
4707
+ L: 280,
4500
4708
  S: this,
4501
4709
  C: (f, a) => f(...a)
4502
4710
  });
@@ -4507,11 +4715,11 @@ var ClientServicesHost = class {
4507
4715
  await this._serviceContext.close();
4508
4716
  this._open = false;
4509
4717
  this._statusUpdate.emit();
4510
- log15("closed", {
4718
+ log16.info("closed", {
4511
4719
  deviceKey
4512
4720
  }, {
4513
- F: __dxlog_file16,
4514
- L: 282,
4721
+ F: __dxlog_file17,
4722
+ L: 286,
4515
4723
  S: this,
4516
4724
  C: (f, a) => f(...a)
4517
4725
  });
@@ -4519,33 +4727,33 @@ var ClientServicesHost = class {
4519
4727
  async reset() {
4520
4728
  var _a, _b, _c;
4521
4729
  const traceId = PublicKey10.random().toHex();
4522
- log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4730
+ log16.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4523
4731
  id: traceId
4524
4732
  }), {
4525
- F: __dxlog_file16,
4526
- L: 287,
4733
+ F: __dxlog_file17,
4734
+ L: 291,
4527
4735
  S: this,
4528
4736
  C: (f, a) => f(...a)
4529
4737
  });
4530
- log15("resetting...", void 0, {
4531
- F: __dxlog_file16,
4532
- L: 289,
4738
+ log16("resetting...", void 0, {
4739
+ F: __dxlog_file17,
4740
+ L: 293,
4533
4741
  S: this,
4534
4742
  C: (f, a) => f(...a)
4535
4743
  });
4536
4744
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4537
4745
  await this._storage.reset();
4538
- log15("reset", void 0, {
4539
- F: __dxlog_file16,
4540
- L: 292,
4746
+ log16("reset", void 0, {
4747
+ F: __dxlog_file17,
4748
+ L: 296,
4541
4749
  S: this,
4542
4750
  C: (f, a) => f(...a)
4543
4751
  });
4544
- log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
4752
+ log16.trace("dxos.sdk.client-services-host.reset", trace6.end({
4545
4753
  id: traceId
4546
4754
  }), {
4547
- F: __dxlog_file16,
4548
- L: 293,
4755
+ F: __dxlog_file17,
4756
+ L: 297,
4549
4757
  S: this,
4550
4758
  C: (f, a) => f(...a)
4551
4759
  });
@@ -4580,6 +4788,7 @@ export {
4580
4788
  InvitationsServiceImpl,
4581
4789
  SpaceInvitationProtocol,
4582
4790
  ClientRpcServer,
4791
+ createDiagnostics,
4583
4792
  DataSpace,
4584
4793
  DataSpaceManager,
4585
4794
  SpacesServiceImpl,
@@ -4591,4 +4800,4 @@ export {
4591
4800
  createDefaultModelFactory,
4592
4801
  ClientServicesHost
4593
4802
  };
4594
- //# sourceMappingURL=chunk-FD4L7N4K.mjs.map
4803
+ //# sourceMappingURL=chunk-RAFQP6TU.mjs.map