@dxos/client-services 0.6.13 → 0.6.14-main.2b6a0f3

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 (138) hide show
  1. package/dist/lib/browser/{chunk-CRXXOI45.mjs → chunk-BBLK6AUB.mjs} +6301 -5383
  2. package/dist/lib/browser/chunk-BBLK6AUB.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +320 -45
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +12 -7
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-PZ3JJJ3K.cjs → chunk-SJEDBF7U.cjs} +6286 -5378
  9. package/dist/lib/node/chunk-SJEDBF7U.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +369 -94
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +18 -13
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/chunk-A6GS6OOD.mjs +8634 -0
  16. package/dist/lib/node-esm/chunk-A6GS6OOD.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +691 -0
  18. package/dist/lib/node-esm/index.mjs.map +7 -0
  19. package/dist/lib/node-esm/meta.json +1 -0
  20. package/dist/lib/node-esm/testing/index.mjs +424 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/index.d.ts +1 -0
  23. package/dist/types/src/index.d.ts.map +1 -1
  24. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +35 -0
  25. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -0
  26. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +10 -0
  27. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -0
  28. package/dist/types/src/packlets/agents/index.d.ts +3 -0
  29. package/dist/types/src/packlets/agents/index.d.ts.map +1 -0
  30. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
  31. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  32. package/dist/types/src/packlets/identity/authenticator.node.test.d.ts +2 -0
  33. package/dist/types/src/packlets/identity/authenticator.node.test.d.ts.map +1 -0
  34. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  35. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  36. package/dist/types/src/packlets/identity/identity-manager.d.ts +28 -9
  37. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  38. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +18 -0
  39. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -0
  40. package/dist/types/src/packlets/identity/identity-service.d.ts +7 -2
  41. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  42. package/dist/types/src/packlets/identity/identity.d.ts +12 -3
  43. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  44. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  45. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +30 -0
  46. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -0
  47. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +2 -1
  48. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  49. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts +2 -1
  50. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  51. package/dist/types/src/packlets/invitations/invitation-state.d.ts +19 -0
  52. package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -0
  53. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -8
  54. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  55. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  56. package/dist/types/src/packlets/services/service-context.d.ts +14 -9
  57. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  58. package/dist/types/src/packlets/services/service-host.d.ts +2 -0
  59. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  60. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +7 -3
  61. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  62. package/dist/types/src/packlets/spaces/data-space.d.ts +5 -3
  63. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  64. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +3 -0
  65. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  66. package/dist/types/src/packlets/spaces/edge-feed-replicator.test.d.ts +2 -0
  67. package/dist/types/src/packlets/spaces/edge-feed-replicator.test.d.ts.map +1 -0
  68. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +1 -1
  69. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  70. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +35 -6
  71. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  72. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  73. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  74. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  75. package/dist/types/src/packlets/testing/test-builder.d.ts +1 -2
  76. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  77. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  78. package/dist/types/src/testing/setup.d.ts +3 -0
  79. package/dist/types/src/testing/setup.d.ts.map +1 -0
  80. package/dist/types/src/version.d.ts +1 -1
  81. package/dist/types/src/version.d.ts.map +1 -1
  82. package/package.json +44 -39
  83. package/src/index.ts +1 -0
  84. package/src/packlets/agents/edge-agent-manager.ts +163 -0
  85. package/src/packlets/agents/edge-agent-service.ts +42 -0
  86. package/src/packlets/agents/index.ts +6 -0
  87. package/src/packlets/devices/devices-service.test.ts +4 -5
  88. package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -0
  89. package/src/packlets/identity/{authenticator.test.ts → authenticator.node.test.ts} +2 -3
  90. package/src/packlets/identity/authenticator.ts +5 -2
  91. package/src/packlets/identity/contacts-service.ts +1 -1
  92. package/src/packlets/identity/identity-manager.test.ts +31 -16
  93. package/src/packlets/identity/identity-manager.ts +76 -32
  94. package/src/packlets/identity/identity-recovery-manager.ts +95 -0
  95. package/src/packlets/identity/identity-service.test.ts +5 -8
  96. package/src/packlets/identity/identity-service.ts +11 -5
  97. package/src/packlets/identity/identity.test.ts +130 -239
  98. package/src/packlets/identity/identity.ts +60 -17
  99. package/src/packlets/invitations/device-invitation-protocol.test.ts +7 -4
  100. package/src/packlets/invitations/device-invitation-protocol.ts +5 -1
  101. package/src/packlets/invitations/edge-invitation-handler.ts +185 -0
  102. package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -4
  103. package/src/packlets/invitations/invitation-host-extension.ts +8 -7
  104. package/src/packlets/invitations/invitation-state.ts +111 -0
  105. package/src/packlets/invitations/invitations-handler.test.ts +16 -9
  106. package/src/packlets/invitations/invitations-handler.ts +23 -93
  107. package/src/packlets/invitations/space-invitation-protocol.test.ts +4 -3
  108. package/src/packlets/invitations/space-invitation-protocol.ts +4 -0
  109. package/src/packlets/logging/logging.test.ts +1 -2
  110. package/src/packlets/network/network-service.test.ts +2 -3
  111. package/src/packlets/services/service-context.test.ts +3 -1
  112. package/src/packlets/services/service-context.ts +113 -35
  113. package/src/packlets/services/service-host.test.ts +8 -12
  114. package/src/packlets/services/service-host.ts +25 -7
  115. package/src/packlets/services/service-registry.test.ts +1 -2
  116. package/src/packlets/spaces/data-space-manager.test.ts +2 -2
  117. package/src/packlets/spaces/data-space-manager.ts +44 -7
  118. package/src/packlets/spaces/data-space.ts +37 -6
  119. package/src/packlets/spaces/edge-feed-replicator.test.ts +252 -0
  120. package/src/packlets/spaces/edge-feed-replicator.ts +80 -22
  121. package/src/packlets/spaces/epoch-migrations.ts +2 -2
  122. package/src/packlets/spaces/notarization-plugin.test.ts +10 -7
  123. package/src/packlets/spaces/notarization-plugin.ts +196 -29
  124. package/src/packlets/spaces/spaces-service.test.ts +5 -9
  125. package/src/packlets/spaces/spaces-service.ts +6 -1
  126. package/src/packlets/storage/storage.ts +0 -1
  127. package/src/packlets/system/system-service.test.ts +1 -2
  128. package/src/packlets/testing/test-builder.ts +7 -4
  129. package/src/packlets/worker/worker-runtime.ts +2 -2
  130. package/src/testing/setup.ts +11 -0
  131. package/src/version.ts +1 -5
  132. package/dist/lib/browser/chunk-CRXXOI45.mjs.map +0 -7
  133. package/dist/lib/node/chunk-PZ3JJJ3K.cjs.map +0 -7
  134. package/dist/types/src/packlets/identity/authenticator.test.d.ts +0 -2
  135. package/dist/types/src/packlets/identity/authenticator.test.d.ts.map +0 -1
  136. package/dist/types/src/packlets/services/automerge-host.test.d.ts +0 -2
  137. package/dist/types/src/packlets/services/automerge-host.test.d.ts.map +0 -1
  138. package/src/packlets/services/automerge-host.test.ts +0 -60
@@ -18,78 +18,351 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
- ClientRpcServer: () => import_chunk_PZ3JJJ3K.ClientRpcServer,
22
- ClientServicesHost: () => import_chunk_PZ3JJJ3K.ClientServicesHost,
23
- DataSpace: () => import_chunk_PZ3JJJ3K.DataSpace,
24
- DataSpaceManager: () => import_chunk_PZ3JJJ3K.DataSpaceManager,
25
- DeviceInvitationProtocol: () => import_chunk_PZ3JJJ3K.DeviceInvitationProtocol,
26
- DevtoolsHostEvents: () => import_chunk_PZ3JJJ3K.DevtoolsHostEvents,
27
- DevtoolsServiceImpl: () => import_chunk_PZ3JJJ3K.DevtoolsServiceImpl,
28
- DiagnosticsCollector: () => import_chunk_PZ3JJJ3K.DiagnosticsCollector,
29
- EdgeFeedReplicator: () => import_chunk_PZ3JJJ3K.EdgeFeedReplicator,
30
- Identity: () => import_chunk_PZ3JJJ3K.Identity,
31
- IdentityManager: () => import_chunk_PZ3JJJ3K.IdentityManager,
32
- IdentityServiceImpl: () => import_chunk_PZ3JJJ3K.IdentityServiceImpl,
33
- InvitationsHandler: () => import_chunk_PZ3JJJ3K.InvitationsHandler,
34
- InvitationsManager: () => import_chunk_PZ3JJJ3K.InvitationsManager,
35
- InvitationsServiceImpl: () => import_chunk_PZ3JJJ3K.InvitationsServiceImpl,
36
- Lock: () => import_chunk_PZ3JJJ3K.Lock,
37
- ServiceContext: () => import_chunk_PZ3JJJ3K.ServiceContext,
38
- ServiceRegistry: () => import_chunk_PZ3JJJ3K.ServiceRegistry,
39
- SpaceInvitationProtocol: () => import_chunk_PZ3JJJ3K.SpaceInvitationProtocol,
40
- SpacesServiceImpl: () => import_chunk_PZ3JJJ3K.SpacesServiceImpl,
41
- TrustedKeySetAuthVerifier: () => import_chunk_PZ3JJJ3K.TrustedKeySetAuthVerifier,
21
+ ClientRpcServer: () => ClientRpcServer,
22
+ ClientServicesHost: () => import_chunk_SJEDBF7U.ClientServicesHost,
23
+ DataSpace: () => import_chunk_SJEDBF7U.DataSpace,
24
+ DataSpaceManager: () => import_chunk_SJEDBF7U.DataSpaceManager,
25
+ DeviceInvitationProtocol: () => import_chunk_SJEDBF7U.DeviceInvitationProtocol,
26
+ DevtoolsHostEvents: () => import_chunk_SJEDBF7U.DevtoolsHostEvents,
27
+ DevtoolsServiceImpl: () => import_chunk_SJEDBF7U.DevtoolsServiceImpl,
28
+ DiagnosticsCollector: () => DiagnosticsCollector,
29
+ EdgeAgentManager: () => import_chunk_SJEDBF7U.EdgeAgentManager,
30
+ EdgeAgentServiceImpl: () => import_chunk_SJEDBF7U.EdgeAgentServiceImpl,
31
+ EdgeFeedReplicator: () => import_chunk_SJEDBF7U.EdgeFeedReplicator,
32
+ Identity: () => import_chunk_SJEDBF7U.Identity,
33
+ IdentityManager: () => import_chunk_SJEDBF7U.IdentityManager,
34
+ IdentityServiceImpl: () => import_chunk_SJEDBF7U.IdentityServiceImpl,
35
+ InvitationsHandler: () => import_chunk_SJEDBF7U.InvitationsHandler,
36
+ InvitationsManager: () => import_chunk_SJEDBF7U.InvitationsManager,
37
+ InvitationsServiceImpl: () => import_chunk_SJEDBF7U.InvitationsServiceImpl,
38
+ Lock: () => import_chunk_SJEDBF7U.Lock,
39
+ ServiceContext: () => import_chunk_SJEDBF7U.ServiceContext,
40
+ ServiceRegistry: () => import_chunk_SJEDBF7U.ServiceRegistry,
41
+ SpaceInvitationProtocol: () => import_chunk_SJEDBF7U.SpaceInvitationProtocol,
42
+ SpacesServiceImpl: () => import_chunk_SJEDBF7U.SpacesServiceImpl,
43
+ TrustedKeySetAuthVerifier: () => import_chunk_SJEDBF7U.TrustedKeySetAuthVerifier,
42
44
  WorkerRuntime: () => WorkerRuntime,
43
45
  WorkerSession: () => WorkerSession,
44
- createAdmissionKeypair: () => import_chunk_PZ3JJJ3K.createAdmissionKeypair,
45
- createAuthProvider: () => import_chunk_PZ3JJJ3K.createAuthProvider,
46
- createCollectDiagnosticsBroadcastHandler: () => import_chunk_PZ3JJJ3K.createCollectDiagnosticsBroadcastHandler,
47
- createCollectDiagnosticsBroadcastSender: () => import_chunk_PZ3JJJ3K.createCollectDiagnosticsBroadcastSender,
48
- createDiagnostics: () => import_chunk_PZ3JJJ3K.createDiagnostics,
49
- createLevel: () => import_chunk_PZ3JJJ3K.createLevel,
50
- createStorageObjects: () => import_chunk_PZ3JJJ3K.createStorageObjects,
51
- decodeProfileArchive: () => import_chunk_PZ3JJJ3K.decodeProfileArchive,
52
- encodeProfileArchive: () => import_chunk_PZ3JJJ3K.encodeProfileArchive,
53
- exportProfileData: () => import_chunk_PZ3JJJ3K.exportProfileData,
54
- getNetworkPeers: () => import_chunk_PZ3JJJ3K.getNetworkPeers,
55
- importProfileData: () => import_chunk_PZ3JJJ3K.importProfileData,
56
- isLocked: () => import_chunk_PZ3JJJ3K.isLocked,
57
- subscribeToFeedBlocks: () => import_chunk_PZ3JJJ3K.subscribeToFeedBlocks,
58
- subscribeToFeeds: () => import_chunk_PZ3JJJ3K.subscribeToFeeds,
59
- subscribeToNetworkStatus: () => import_chunk_PZ3JJJ3K.subscribeToNetworkStatus,
60
- subscribeToNetworkTopics: () => import_chunk_PZ3JJJ3K.subscribeToNetworkTopics,
61
- subscribeToSignal: () => import_chunk_PZ3JJJ3K.subscribeToSignal,
62
- subscribeToSpaces: () => import_chunk_PZ3JJJ3K.subscribeToSpaces,
63
- subscribeToSwarmInfo: () => import_chunk_PZ3JJJ3K.subscribeToSwarmInfo
46
+ createAdmissionKeypair: () => import_chunk_SJEDBF7U.createAdmissionKeypair,
47
+ createAuthProvider: () => import_chunk_SJEDBF7U.createAuthProvider,
48
+ createCollectDiagnosticsBroadcastHandler: () => import_chunk_SJEDBF7U.createCollectDiagnosticsBroadcastHandler,
49
+ createCollectDiagnosticsBroadcastSender: () => import_chunk_SJEDBF7U.createCollectDiagnosticsBroadcastSender,
50
+ createDiagnostics: () => import_chunk_SJEDBF7U.createDiagnostics,
51
+ createLevel: () => import_chunk_SJEDBF7U.createLevel,
52
+ createStorageObjects: () => import_chunk_SJEDBF7U.createStorageObjects,
53
+ decodeProfileArchive: () => decodeProfileArchive,
54
+ encodeProfileArchive: () => encodeProfileArchive,
55
+ exportProfileData: () => exportProfileData,
56
+ getNetworkPeers: () => import_chunk_SJEDBF7U.getNetworkPeers,
57
+ importProfileData: () => importProfileData,
58
+ isLocked: () => import_chunk_SJEDBF7U.isLocked,
59
+ subscribeToFeedBlocks: () => import_chunk_SJEDBF7U.subscribeToFeedBlocks,
60
+ subscribeToFeeds: () => import_chunk_SJEDBF7U.subscribeToFeeds,
61
+ subscribeToNetworkStatus: () => import_chunk_SJEDBF7U.subscribeToNetworkStatus,
62
+ subscribeToNetworkTopics: () => import_chunk_SJEDBF7U.subscribeToNetworkTopics,
63
+ subscribeToSignal: () => import_chunk_SJEDBF7U.subscribeToSignal,
64
+ subscribeToSpaces: () => import_chunk_SJEDBF7U.subscribeToSpaces,
65
+ subscribeToSwarmInfo: () => import_chunk_SJEDBF7U.subscribeToSwarmInfo
64
66
  });
65
67
  module.exports = __toCommonJS(node_exports);
66
- var import_chunk_PZ3JJJ3K = require("./chunk-PZ3JJJ3K.cjs");
67
- var import_async = require("@dxos/async");
68
+ var import_chunk_SJEDBF7U = require("./chunk-SJEDBF7U.cjs");
68
69
  var import_client_protocol = require("@dxos/client-protocol");
69
- var import_context = require("@dxos/context");
70
+ var import_config = require("@dxos/config");
71
+ var import_services = require("@dxos/protocols/proto/dxos/client/services");
72
+ var import_tracing = require("@dxos/tracing");
73
+ var import_util = require("@dxos/util");
74
+ var import_codec_protobuf = require("@dxos/codec-protobuf");
75
+ var import_debug = require("@dxos/debug");
76
+ var import_rpc = require("@dxos/rpc");
77
+ var import_tracing2 = require("@dxos/tracing");
78
+ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
70
79
  var import_invariant = require("@dxos/invariant");
71
80
  var import_log = require("@dxos/log");
72
- var import_messaging = require("@dxos/messaging");
73
- var import_network_manager = require("@dxos/network-manager");
74
- var import_async2 = require("@dxos/async");
81
+ var import_protocols = require("@dxos/protocols");
82
+ var import_util2 = require("@dxos/util");
83
+ var import_async = require("@dxos/async");
75
84
  var import_client_protocol2 = require("@dxos/client-protocol");
85
+ var import_context = require("@dxos/context");
76
86
  var import_invariant2 = require("@dxos/invariant");
77
87
  var import_log2 = require("@dxos/log");
78
- var import_rpc = require("@dxos/rpc");
79
- var import_util = require("@dxos/util");
88
+ var import_messaging = require("@dxos/messaging");
89
+ var import_network_manager = require("@dxos/network-manager");
90
+ var import_async2 = require("@dxos/async");
91
+ var import_client_protocol3 = require("@dxos/client-protocol");
92
+ var import_invariant3 = require("@dxos/invariant");
93
+ var import_log3 = require("@dxos/log");
94
+ var import_rpc2 = require("@dxos/rpc");
95
+ var import_util3 = require("@dxos/util");
96
+ var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
97
+ var DiagnosticsCollector = class {
98
+ static {
99
+ this.broadcastSender = (0, import_chunk_SJEDBF7U.createCollectDiagnosticsBroadcastSender)();
100
+ }
101
+ static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
102
+ const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
103
+ keys: options.humanize ? import_services.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
104
+ }, {
105
+ timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
106
+ });
107
+ const clientDiagnostics = {
108
+ config,
109
+ trace: import_tracing.TRACE_PROCESSOR.getDiagnostics()
110
+ };
111
+ const diagnostics = serviceDiagnostics != null ? {
112
+ client: clientDiagnostics,
113
+ services: serviceDiagnostics
114
+ } : {
115
+ client: clientDiagnostics,
116
+ broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
117
+ };
118
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util.jsonKeyReplacer)(options)));
119
+ }
120
+ };
121
+ var findSystemServiceProvider = () => {
122
+ const serviceProviders = import_tracing.TRACE_PROCESSOR.findResourcesByAnnotation(import_client_protocol.ClientServicesProviderResource);
123
+ const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
124
+ return providerResource?.instance?.deref() ?? null;
125
+ };
126
+ var findConfigs = () => {
127
+ const configs = import_tracing.TRACE_PROCESSOR.findResourcesByAnnotation(import_config.ConfigResource);
128
+ return configs.map((r) => r.instance.deref()).filter(import_util.nonNullable);
129
+ };
80
130
  function _ts_decorate(decorators, target, key, desc) {
81
131
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
82
132
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
83
133
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
84
134
  return c > 3 && r && Object.defineProperty(target, key, r), r;
85
135
  }
86
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
136
+ var ClientRpcServer = class {
137
+ constructor(params) {
138
+ this._handlerCache = /* @__PURE__ */ new Map();
139
+ this._callMetrics = new import_tracing2.MapCounter();
140
+ const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
141
+ this._handleCall = handleCall;
142
+ this._handleStream = handleStream;
143
+ this._serviceRegistry = serviceRegistry;
144
+ this._rpcPeer = new import_rpc.RpcPeer({
145
+ ...rpcOptions,
146
+ callHandler: (method, params2) => {
147
+ const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
148
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
149
+ this._callMetrics.inc(`${serviceName}.${methodName} request`);
150
+ if (this._handleCall) {
151
+ return this._handleCall(methodName, params2, handler);
152
+ } else {
153
+ return handler(methodName, params2);
154
+ }
155
+ },
156
+ streamHandler: (method, params2) => {
157
+ const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
158
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
159
+ this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
160
+ if (this._handleStream) {
161
+ return import_codec_protobuf.Stream.map(import_codec_protobuf.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
162
+ this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
163
+ return data;
164
+ });
165
+ } else {
166
+ return handler(methodName, params2);
167
+ }
168
+ }
169
+ });
170
+ }
171
+ get _services() {
172
+ return Object.keys(this._serviceRegistry.services);
173
+ }
174
+ async open() {
175
+ await this._rpcPeer.open();
176
+ }
177
+ async close() {
178
+ await this._rpcPeer.close();
179
+ }
180
+ _getServiceHandler(serviceName) {
181
+ if (!this._handlerCache.has(serviceName)) {
182
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug.raise)(new Error(`Service not available: ${serviceName}`));
183
+ const service = this._serviceRegistry.services[key];
184
+ if (!service) {
185
+ throw new Error(`Service not available: ${serviceName}`);
186
+ }
187
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
188
+ }
189
+ return this._handlerCache.get(serviceName);
190
+ }
191
+ };
192
+ _ts_decorate([
193
+ import_tracing2.trace.metricsCounter()
194
+ ], ClientRpcServer.prototype, "_callMetrics", void 0);
195
+ _ts_decorate([
196
+ import_tracing2.trace.info()
197
+ ], ClientRpcServer.prototype, "_services", null);
198
+ ClientRpcServer = _ts_decorate([
199
+ import_tracing2.trace.resource()
200
+ ], ClientRpcServer);
201
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
202
+ var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
203
+ var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
204
+ var exportProfileData = async ({ storage, level }) => {
205
+ const archive = {
206
+ storage: [],
207
+ meta: {
208
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
209
+ }
210
+ };
211
+ {
212
+ const directory = await storage.createDirectory();
213
+ const files = await directory.list();
214
+ import_log.log.info("begin exporting files", {
215
+ count: files.length
216
+ }, {
217
+ F: __dxlog_file,
218
+ L: 30,
219
+ S: void 0,
220
+ C: (f, a) => f(...a)
221
+ });
222
+ for (const filename of files) {
223
+ const file = await directory.getOrCreateFile(filename);
224
+ const { size } = await file.stat();
225
+ const data = await file.read(0, size);
226
+ archive.storage.push({
227
+ type: import_protocols.ProfileArchiveEntryType.FILE,
228
+ key: filename,
229
+ value: data
230
+ });
231
+ }
232
+ import_log.log.info("done exporting files", {
233
+ count: files.length
234
+ }, {
235
+ F: __dxlog_file,
236
+ L: 41,
237
+ S: void 0,
238
+ C: (f, a) => f(...a)
239
+ });
240
+ }
241
+ {
242
+ import_log.log.info("begin exporting kv pairs", void 0, {
243
+ F: __dxlog_file,
244
+ L: 45,
245
+ S: void 0,
246
+ C: (f, a) => f(...a)
247
+ });
248
+ const iter = await level.iterator({
249
+ keyEncoding: "binary",
250
+ valueEncoding: "binary"
251
+ });
252
+ let count = 0;
253
+ for await (const [key, value] of iter) {
254
+ archive.storage.push({
255
+ type: import_protocols.ProfileArchiveEntryType.KEY_VALUE,
256
+ key,
257
+ value
258
+ });
259
+ count++;
260
+ }
261
+ import_log.log.info("done exporting kv pairs", {
262
+ count
263
+ }, {
264
+ F: __dxlog_file,
265
+ L: 56,
266
+ S: void 0,
267
+ C: (f, a) => f(...a)
268
+ });
269
+ }
270
+ return archive;
271
+ };
272
+ var importProfileData = async ({ storage, level }, archive) => {
273
+ let batch = level.batch();
274
+ let count = 0;
275
+ for (const entry of archive.storage) {
276
+ switch (entry.type) {
277
+ case import_protocols.ProfileArchiveEntryType.FILE: {
278
+ const directory = await storage.createDirectory();
279
+ (0, import_invariant.invariant)(typeof entry.key === "string", "Invalid key type", {
280
+ F: __dxlog_file,
281
+ L: 79,
282
+ S: void 0,
283
+ A: [
284
+ "typeof entry.key === 'string'",
285
+ "'Invalid key type'"
286
+ ]
287
+ });
288
+ const file = await directory.getOrCreateFile(entry.key);
289
+ (0, import_invariant.invariant)(entry.value instanceof Uint8Array, "Invalid value type", {
290
+ F: __dxlog_file,
291
+ L: 81,
292
+ S: void 0,
293
+ A: [
294
+ "entry.value instanceof Uint8Array",
295
+ "'Invalid value type'"
296
+ ]
297
+ });
298
+ await file.write(0, (0, import_util2.arrayToBuffer)(entry.value));
299
+ await file.close();
300
+ break;
301
+ }
302
+ case import_protocols.ProfileArchiveEntryType.KEY_VALUE: {
303
+ (0, import_invariant.invariant)(entry.key instanceof Uint8Array, "Invalid key type", {
304
+ F: __dxlog_file,
305
+ L: 87,
306
+ S: void 0,
307
+ A: [
308
+ "entry.key instanceof Uint8Array",
309
+ "'Invalid key type'"
310
+ ]
311
+ });
312
+ (0, import_invariant.invariant)(entry.value instanceof Uint8Array, "Invalid value type", {
313
+ F: __dxlog_file,
314
+ L: 88,
315
+ S: void 0,
316
+ A: [
317
+ "entry.value instanceof Uint8Array",
318
+ "'Invalid value type'"
319
+ ]
320
+ });
321
+ batch.put(entry.key, entry.value, {
322
+ keyEncoding: "binary",
323
+ valueEncoding: "binary"
324
+ });
325
+ break;
326
+ }
327
+ default:
328
+ throw new Error(`Invalid entry type: ${entry.type}`);
329
+ }
330
+ if (++count % 1e3 === 0) {
331
+ await batch.write();
332
+ batch = level.batch();
333
+ import_log.log.info("importing", {
334
+ count,
335
+ total: archive.storage.length,
336
+ progress: `${(count / archive.storage.length * 100).toFixed()}%`
337
+ }, {
338
+ F: __dxlog_file,
339
+ L: 101,
340
+ S: void 0,
341
+ C: (f, a) => f(...a)
342
+ });
343
+ }
344
+ }
345
+ import_log.log.info("committing changes..", void 0, {
346
+ F: __dxlog_file,
347
+ L: 109,
348
+ S: void 0,
349
+ C: (f, a) => f(...a)
350
+ });
351
+ await batch.write();
352
+ };
353
+ function _ts_decorate2(decorators, target, key, desc) {
354
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
355
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
356
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
357
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
358
+ }
359
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
87
360
  var WorkerSession = class {
88
361
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
89
362
  this._startTrigger = new import_async2.Trigger();
90
- this.onClose = new import_util.Callback();
91
- (0, import_invariant2.invariant)(serviceHost, void 0, {
92
- F: __dxlog_file,
363
+ this.onClose = new import_util3.Callback();
364
+ (0, import_invariant3.invariant)(serviceHost, void 0, {
365
+ F: __dxlog_file2,
93
366
  L: 54,
94
367
  S: this,
95
368
  A: [
@@ -101,7 +374,7 @@ var WorkerSession = class {
101
374
  const middleware = {
102
375
  handleCall: async (method, params, handler) => {
103
376
  const error = await readySignal.wait({
104
- timeout: import_client_protocol2.PROXY_CONNECTION_TIMEOUT
377
+ timeout: import_client_protocol3.PROXY_CONNECTION_TIMEOUT
105
378
  });
106
379
  if (error) {
107
380
  throw error;
@@ -110,7 +383,7 @@ var WorkerSession = class {
110
383
  },
111
384
  handleStream: async (method, params, handler) => {
112
385
  const error = await readySignal.wait({
113
- timeout: import_client_protocol2.PROXY_CONNECTION_TIMEOUT
386
+ timeout: import_client_protocol3.PROXY_CONNECTION_TIMEOUT
114
387
  });
115
388
  if (error) {
116
389
  throw error;
@@ -118,19 +391,19 @@ var WorkerSession = class {
118
391
  return handler(method, params);
119
392
  }
120
393
  };
121
- this._clientRpc = new import_chunk_PZ3JJJ3K.ClientRpcServer({
394
+ this._clientRpc = new ClientRpcServer({
122
395
  serviceRegistry: this._serviceHost.serviceRegistry,
123
396
  port: appPort,
124
397
  ...middleware
125
398
  });
126
- this._shellClientRpc = shellPort ? new import_chunk_PZ3JJJ3K.ClientRpcServer({
399
+ this._shellClientRpc = shellPort ? new ClientRpcServer({
127
400
  serviceRegistry: this._serviceHost.serviceRegistry,
128
401
  port: shellPort,
129
402
  ...middleware
130
403
  }) : void 0;
131
- this._iframeRpc = (0, import_rpc.createProtoRpcPeer)({
132
- requested: import_client_protocol2.iframeServiceBundle,
133
- exposed: import_client_protocol2.workerServiceBundle,
404
+ this._iframeRpc = (0, import_rpc2.createProtoRpcPeer)({
405
+ requested: import_client_protocol3.iframeServiceBundle,
406
+ exposed: import_client_protocol3.workerServiceBundle,
134
407
  handlers: {
135
408
  WorkerService: {
136
409
  start: async (request) => {
@@ -145,8 +418,8 @@ var WorkerSession = class {
145
418
  try {
146
419
  await this.close();
147
420
  } catch (err) {
148
- import_log2.log.catch(err, void 0, {
149
- F: __dxlog_file,
421
+ import_log3.log.catch(err, void 0, {
422
+ F: __dxlog_file2,
150
423
  L: 108,
151
424
  S: this,
152
425
  C: (f, a) => f(...a)
@@ -162,8 +435,8 @@ var WorkerSession = class {
162
435
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
163
436
  }
164
437
  async open() {
165
- import_log2.log.info("opening...", void 0, {
166
- F: __dxlog_file,
438
+ import_log3.log.info("opening...", void 0, {
439
+ F: __dxlog_file2,
167
440
  L: 122,
168
441
  S: this,
169
442
  C: (f, a) => f(...a)
@@ -174,21 +447,21 @@ var WorkerSession = class {
174
447
  this._maybeOpenShell()
175
448
  ]);
176
449
  await this._startTrigger.wait({
177
- timeout: import_client_protocol2.PROXY_CONNECTION_TIMEOUT
450
+ timeout: import_client_protocol3.PROXY_CONNECTION_TIMEOUT
178
451
  });
179
452
  if (this.lockKey) {
180
453
  void this._afterLockReleases(this.lockKey, () => this.close());
181
454
  }
182
- import_log2.log.info("opened", void 0, {
183
- F: __dxlog_file,
455
+ import_log3.log.info("opened", void 0, {
456
+ F: __dxlog_file2,
184
457
  L: 133,
185
458
  S: this,
186
459
  C: (f, a) => f(...a)
187
460
  });
188
461
  }
189
462
  async close() {
190
- import_log2.log.info("closing...", void 0, {
191
- F: __dxlog_file,
463
+ import_log3.log.info("closing...", void 0, {
464
+ F: __dxlog_file2,
192
465
  L: 137,
193
466
  S: this,
194
467
  C: (f, a) => f(...a)
@@ -196,8 +469,8 @@ var WorkerSession = class {
196
469
  try {
197
470
  await this.onClose.callIfSet();
198
471
  } catch (err) {
199
- import_log2.log.catch(err, void 0, {
200
- F: __dxlog_file,
472
+ import_log3.log.catch(err, void 0, {
473
+ F: __dxlog_file2,
201
474
  L: 141,
202
475
  S: this,
203
476
  C: (f, a) => f(...a)
@@ -207,8 +480,8 @@ var WorkerSession = class {
207
480
  this._clientRpc.close(),
208
481
  this._iframeRpc.close()
209
482
  ]);
210
- import_log2.log.info("closed", void 0, {
211
- F: __dxlog_file,
483
+ import_log3.log.info("closed", void 0, {
484
+ F: __dxlog_file2,
212
485
  L: 145,
213
486
  S: this,
214
487
  C: (f, a) => f(...a)
@@ -218,8 +491,8 @@ var WorkerSession = class {
218
491
  try {
219
492
  this._shellClientRpc && await (0, import_async2.asyncTimeout)(this._shellClientRpc.open(), 1e3);
220
493
  } catch {
221
- import_log2.log.info("No shell connected.", void 0, {
222
- F: __dxlog_file,
494
+ import_log3.log.info("No shell connected.", void 0, {
495
+ F: __dxlog_file2,
223
496
  L: 152,
224
497
  S: this,
225
498
  C: (f, a) => f(...a)
@@ -231,16 +504,16 @@ var WorkerSession = class {
231
504
  }).then(callback);
232
505
  }
233
506
  };
234
- _ts_decorate([
235
- import_log2.logInfo
507
+ _ts_decorate2([
508
+ import_log3.logInfo
236
509
  ], WorkerSession.prototype, "origin", void 0);
237
- _ts_decorate([
238
- import_log2.logInfo
510
+ _ts_decorate2([
511
+ import_log3.logInfo
239
512
  ], WorkerSession.prototype, "lockKey", void 0);
240
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
513
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
241
514
  var WorkerRuntime = class {
242
- constructor({ channel = import_client_protocol.DEFAULT_WORKER_BROADCAST_CHANNEL, configProvider, acquireLock, releaseLock, onStop }) {
243
- this._transportFactory = new import_network_manager.SimplePeerTransportProxyFactory();
515
+ constructor({ channel = import_client_protocol2.DEFAULT_WORKER_BROADCAST_CHANNEL, configProvider, acquireLock, releaseLock, onStop }) {
516
+ this._transportFactory = new import_network_manager.RtcTransportProxyFactory();
244
517
  this._ready = new import_async.Trigger();
245
518
  this._sessions = /* @__PURE__ */ new Set();
246
519
  this._signalMetadataTags = {
@@ -252,7 +525,7 @@ var WorkerRuntime = class {
252
525
  this._releaseLock = releaseLock;
253
526
  this._onStop = onStop;
254
527
  this._channel = channel;
255
- this._clientServices = new import_chunk_PZ3JJJ3K.ClientServicesHost({
528
+ this._clientServices = new import_chunk_SJEDBF7U.ClientServicesHost({
256
529
  callbacks: {
257
530
  onReset: async () => this.stop()
258
531
  }
@@ -262,8 +535,8 @@ var WorkerRuntime = class {
262
535
  return this._clientServices;
263
536
  }
264
537
  async start() {
265
- (0, import_log.log)("starting...", void 0, {
266
- F: __dxlog_file2,
538
+ (0, import_log2.log)("starting...", void 0, {
539
+ F: __dxlog_file3,
267
540
  L: 84,
268
541
  S: this,
269
542
  C: (f, a) => f(...a)
@@ -287,12 +560,12 @@ var WorkerRuntime = class {
287
560
  transportFactory: this._transportFactory
288
561
  });
289
562
  await this._clientServices.open(new import_context.Context(void 0, {
290
- F: __dxlog_file2,
563
+ F: __dxlog_file3,
291
564
  L: 107
292
565
  }));
293
566
  this._ready.wake(void 0);
294
- (0, import_log.log)("started", void 0, {
295
- F: __dxlog_file2,
567
+ (0, import_log2.log)("started", void 0, {
568
+ F: __dxlog_file3,
296
569
  L: 109,
297
570
  S: this,
298
571
  C: (f, a) => f(...a)
@@ -306,8 +579,8 @@ var WorkerRuntime = class {
306
579
  });
307
580
  } catch (err) {
308
581
  this._ready.wake(err);
309
- import_log.log.error("starting", err, {
310
- F: __dxlog_file2,
582
+ import_log2.log.error("starting", err, {
583
+ F: __dxlog_file3,
311
584
  L: 119,
312
585
  S: this,
313
586
  C: (f, a) => f(...a)
@@ -341,8 +614,8 @@ var WorkerRuntime = class {
341
614
  }
342
615
  });
343
616
  await session.open();
344
- (0, import_invariant.invariant)(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
345
- F: __dxlog_file2,
617
+ (0, import_invariant2.invariant)(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
618
+ F: __dxlog_file3,
346
619
  L: 157,
347
620
  S: this,
348
621
  A: [
@@ -362,8 +635,8 @@ var WorkerRuntime = class {
362
635
  * Selects one of the existing session for WebRTC networking.
363
636
  */
364
637
  _reconnectWebrtc() {
365
- (0, import_log.log)("reconnecting webrtc...", void 0, {
366
- F: __dxlog_file2,
638
+ (0, import_log2.log)("reconnecting webrtc...", void 0, {
639
+ F: __dxlog_file3,
367
640
  L: 175,
368
641
  S: this,
369
642
  C: (f, a) => f(...a)
@@ -394,6 +667,8 @@ var WorkerRuntime = class {
394
667
  DevtoolsHostEvents,
395
668
  DevtoolsServiceImpl,
396
669
  DiagnosticsCollector,
670
+ EdgeAgentManager,
671
+ EdgeAgentServiceImpl,
397
672
  EdgeFeedReplicator,
398
673
  Identity,
399
674
  IdentityManager,