@dxos/client-services 0.1.24 → 0.1.25-next.3c6b542

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 (70) hide show
  1. package/dist/lib/browser/{chunk-R2FEBB66.mjs → chunk-WF53R6F7.mjs} +325 -95
  2. package/dist/lib/browser/chunk-WF53R6F7.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +11 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +3 -3
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/index.cjs +350 -111
  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 +228 -110
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
  13. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -1
  15. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  16. package/dist/types/src/packlets/identity/identity.d.ts +2 -2
  17. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +1 -1
  19. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts +1 -1
  21. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
  23. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -1
  25. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  26. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  27. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  28. package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
  29. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  30. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +11 -4
  31. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  32. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +6 -1
  33. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  34. package/dist/types/src/packlets/vault/index.d.ts +2 -0
  35. package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
  36. package/dist/types/src/packlets/vault/services.d.ts +9 -1
  37. package/dist/types/src/packlets/vault/services.d.ts.map +1 -1
  38. package/dist/types/src/packlets/vault/shell-controller.d.ts +24 -0
  39. package/dist/types/src/packlets/vault/shell-controller.d.ts.map +1 -0
  40. package/dist/types/src/packlets/vault/shell-runtime.d.ts +45 -0
  41. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -0
  42. package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -1
  43. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  44. package/dist/types/src/packlets/vault/worker-session.d.ts +4 -1
  45. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  46. package/package.json +29 -28
  47. package/src/packlets/devtools/spaces.ts +1 -1
  48. package/src/packlets/identity/authenticator.ts +1 -1
  49. package/src/packlets/identity/identity-manager.test.ts +1 -1
  50. package/src/packlets/identity/identity-manager.ts +1 -1
  51. package/src/packlets/identity/identity.test.ts +1 -1
  52. package/src/packlets/identity/identity.ts +1 -1
  53. package/src/packlets/invitations/space-invitations-handler.test.ts +1 -1
  54. package/src/packlets/invitations/space-invitations-handler.ts +1 -1
  55. package/src/packlets/services/service-context.ts +2 -2
  56. package/src/packlets/services/service-host.ts +1 -1
  57. package/src/packlets/spaces/data-space-manager.test.ts +1 -1
  58. package/src/packlets/spaces/data-space-manager.ts +4 -4
  59. package/src/packlets/spaces/data-space.ts +3 -3
  60. package/src/packlets/spaces/spaces-service.ts +1 -1
  61. package/src/packlets/testing/test-builder.ts +3 -3
  62. package/src/packlets/vault/iframe-host-runtime.ts +26 -7
  63. package/src/packlets/vault/iframe-proxy-runtime.ts +16 -1
  64. package/src/packlets/vault/index.ts +2 -0
  65. package/src/packlets/vault/services.ts +17 -1
  66. package/src/packlets/vault/shell-controller.ts +78 -0
  67. package/src/packlets/vault/shell-runtime.ts +133 -0
  68. package/src/packlets/vault/worker-runtime.ts +3 -1
  69. package/src/packlets/vault/worker-session.ts +29 -19
  70. package/dist/lib/browser/chunk-R2FEBB66.mjs.map +0 -7
@@ -61,8 +61,8 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
61
61
 
62
62
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
63
63
  var import_credentials13 = require("@dxos/credentials");
64
- var import_echo_db6 = require("@dxos/echo-db");
65
- var import_testing = require("@dxos/echo-db/testing");
64
+ var import_echo_pipeline6 = require("@dxos/echo-pipeline");
65
+ var import_testing = require("@dxos/echo-pipeline/testing");
66
66
  var import_feed_store5 = require("@dxos/feed-store");
67
67
  var import_keyring2 = require("@dxos/keyring");
68
68
  var import_messaging3 = require("@dxos/messaging");
@@ -73,7 +73,7 @@ var import_random_access_storage2 = require("@dxos/random-access-storage");
73
73
  var import_async11 = require("@dxos/async");
74
74
  var import_credentials11 = require("@dxos/credentials");
75
75
  var import_debug3 = require("@dxos/debug");
76
- var import_echo_db3 = require("@dxos/echo-db");
76
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
77
77
  var import_feed_store3 = require("@dxos/feed-store");
78
78
  var import_keyring = require("@dxos/keyring");
79
79
  var import_log10 = require("@dxos/log");
@@ -1582,7 +1582,7 @@ var import_node_assert8 = __toESM(require("node:assert"));
1582
1582
  var import_async10 = require("@dxos/async");
1583
1583
  var import_context6 = require("@dxos/context");
1584
1584
  var import_credentials10 = require("@dxos/credentials");
1585
- var import_echo_db2 = require("@dxos/echo-db");
1585
+ var import_echo_pipeline2 = require("@dxos/echo-pipeline");
1586
1586
  var import_keys6 = require("@dxos/keys");
1587
1587
  var import_log9 = require("@dxos/log");
1588
1588
  var import_teleport_extension_presence = require("@dxos/teleport-extension-presence");
@@ -1592,7 +1592,7 @@ var import_util4 = require("@dxos/util");
1592
1592
  var import_async9 = require("@dxos/async");
1593
1593
  var import_context5 = require("@dxos/context");
1594
1594
  var import_debug2 = require("@dxos/debug");
1595
- var import_echo_db = require("@dxos/echo-db");
1595
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
1596
1596
  var import_keys5 = require("@dxos/keys");
1597
1597
  var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
1598
1598
  var import_util3 = require("@dxos/util");
@@ -1855,7 +1855,7 @@ var DataSpace = class DataSpace2 {
1855
1855
  this._feedStore = params.feedStore;
1856
1856
  this._metadataStore = params.metadataStore;
1857
1857
  this._signingContext = params.signingContext;
1858
- this._dataPipelineController = new import_echo_db.DataPipelineControllerImpl({
1858
+ this._dataPipelineController = new import_echo_pipeline.DataPipelineControllerImpl({
1859
1859
  modelFactory: params.modelFactory,
1860
1860
  metadataStore: params.metadataStore,
1861
1861
  snapshotManager: params.snapshotManager,
@@ -1911,7 +1911,7 @@ var DataSpace = class DataSpace2 {
1911
1911
  timeout: CONTROL_PIPELINE_READY_TIMEFRAME
1912
1912
  });
1913
1913
  await this._createWritableFeeds();
1914
- this.notarizationPlugin.setWriter((0, import_echo_db.createMappedFeedWriter)((credential) => ({
1914
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
1915
1915
  credential: {
1916
1916
  credential
1917
1917
  }
@@ -2061,7 +2061,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2061
2061
  callSite: (f, a) => f(...a)
2062
2062
  });
2063
2063
  const space = await this._constructSpace(metadata);
2064
- const credentials = await (0, import_echo_db2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
2064
+ const credentials = await (0, import_echo_pipeline2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
2065
2065
  await this._metadataStore.addSpace(metadata);
2066
2066
  const memberCredential = credentials[1];
2067
2067
  (0, import_node_assert8.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
@@ -2092,7 +2092,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2092
2092
  offlineTimeout: 3e4,
2093
2093
  identityKey: this._signingContext.identityKey
2094
2094
  });
2095
- const snapshotManager = new import_echo_db2.SnapshotManager(this._snapshotStore);
2095
+ const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
2096
2096
  const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
2097
2097
  writable: true
2098
2098
  });
@@ -2157,20 +2157,20 @@ var ServiceContext = class {
2157
2157
  this.networkManager = networkManager;
2158
2158
  this.modelFactory = modelFactory;
2159
2159
  this.initialized = new import_async11.Trigger();
2160
- this.dataServiceSubscriptions = new import_echo_db3.DataServiceSubscriptions();
2161
- this.metadataStore = new import_echo_db3.MetadataStore(storage.createDirectory("metadata"));
2162
- this.snapshotStore = new import_echo_db3.SnapshotStore(storage.createDirectory("snapshots"));
2160
+ this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
2161
+ this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
2162
+ this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
2163
2163
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
2164
2164
  this.feedStore = new import_feed_store3.FeedStore({
2165
2165
  factory: new import_feed_store3.FeedFactory({
2166
2166
  root: storage.createDirectory("feeds"),
2167
2167
  signer: this.keyring,
2168
2168
  hypercore: {
2169
- valueEncoding: import_echo_db3.valueEncoding
2169
+ valueEncoding: import_echo_pipeline3.valueEncoding
2170
2170
  }
2171
2171
  })
2172
2172
  });
2173
- this.spaceManager = new import_echo_db3.SpaceManager({
2173
+ this.spaceManager = new import_echo_pipeline3.SpaceManager({
2174
2174
  feedStore: this.feedStore,
2175
2175
  networkManager: this.networkManager
2176
2176
  });
@@ -2359,8 +2359,8 @@ var clientServiceBundle = (0, import_rpc.createServiceBundle)({
2359
2359
  // packages/sdk/client-services/src/packlets/services/service-host.ts
2360
2360
  var import_debug7 = require("@dxos/debug");
2361
2361
  var import_document_model = require("@dxos/document-model");
2362
- var import_echo_db5 = require("@dxos/echo-db");
2363
- var import_log16 = require("@dxos/log");
2362
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
2363
+ var import_log17 = require("@dxos/log");
2364
2364
  var import_model_factory = require("@dxos/model-factory");
2365
2365
  var import_client2 = require("@dxos/protocols/proto/dxos/client");
2366
2366
  var import_text_model = require("@dxos/text-model");
@@ -2914,7 +2914,7 @@ var NetworkServiceImpl = class {
2914
2914
  var import_async15 = require("@dxos/async");
2915
2915
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
2916
2916
  var import_debug6 = require("@dxos/debug");
2917
- var import_echo_db4 = require("@dxos/echo-db");
2917
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
2918
2918
  var SpacesServiceImpl = class {
2919
2919
  constructor(_spaceManager) {
2920
2920
  this._spaceManager = _spaceManager;
@@ -2931,7 +2931,7 @@ var SpacesServiceImpl = class {
2931
2931
  queryCredentials({ spaceKey }) {
2932
2932
  return new import_codec_protobuf11.Stream(({ ctx, next }) => {
2933
2933
  var _a;
2934
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_db4.SpaceNotFoundError(spaceKey));
2934
+ const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline4.SpaceNotFoundError(spaceKey));
2935
2935
  const processor = space.spaceState.registerProcessor({
2936
2936
  process: async (credential) => {
2937
2937
  next(credential);
@@ -2943,7 +2943,7 @@ var SpacesServiceImpl = class {
2943
2943
  }
2944
2944
  async writeCredentials({ spaceKey, credentials }) {
2945
2945
  var _a;
2946
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_db4.SpaceNotFoundError(spaceKey));
2946
+ const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline4.SpaceNotFoundError(spaceKey));
2947
2947
  for (const credential of credentials != null ? credentials : []) {
2948
2948
  await space.controlPipeline.writer.write({
2949
2949
  credential: {
@@ -3000,11 +3000,100 @@ var toStorageType = (type) => {
3000
3000
  };
3001
3001
 
3002
3002
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3003
- var import_async16 = require("@dxos/async");
3003
+ var import_async17 = require("@dxos/async");
3004
3004
  var import_log12 = require("@dxos/log");
3005
3005
  var import_messaging = require("@dxos/messaging");
3006
3006
  var import_network_manager3 = require("@dxos/network-manager");
3007
+ var import_rpc3 = require("@dxos/rpc");
3008
+ var import_util7 = require("@dxos/util");
3009
+
3010
+ // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3011
+ var import_node_assert11 = __toESM(require("node:assert"));
3012
+ var import_async16 = require("@dxos/async");
3013
+ var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
3007
3014
  var import_rpc2 = require("@dxos/rpc");
3015
+
3016
+ // packages/sdk/client-services/src/packlets/vault/services.ts
3017
+ var import_protocols7 = require("@dxos/protocols");
3018
+ var iframeServiceBundle = {
3019
+ IframeService: import_protocols7.schema.getService("dxos.iframe.IframeService"),
3020
+ BridgeService: import_protocols7.schema.getService("dxos.mesh.bridge.BridgeService")
3021
+ };
3022
+ var workerServiceBundle = {
3023
+ WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
3024
+ };
3025
+ var appServiceBundle = {
3026
+ AppService: import_protocols7.schema.getService("dxos.iframe.AppService")
3027
+ };
3028
+ var shellServiceBundle = {
3029
+ ShellService: import_protocols7.schema.getService("dxos.iframe.ShellService")
3030
+ };
3031
+
3032
+ // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3033
+ var ShellRuntimeImpl = class {
3034
+ constructor(_port) {
3035
+ this._port = _port;
3036
+ this.layoutUpdate = new import_async16.Event();
3037
+ this._layout = import_iframe.ShellLayout.DEFAULT;
3038
+ }
3039
+ get layout() {
3040
+ return this._layout;
3041
+ }
3042
+ get invitationCode() {
3043
+ return this._invitationCode;
3044
+ }
3045
+ get spaceKey() {
3046
+ return this._spaceKey;
3047
+ }
3048
+ setLayout(layout, options = {}) {
3049
+ this._layout = layout;
3050
+ this._invitationCode = options.invitationCode;
3051
+ this._spaceKey = options.spaceKey;
3052
+ this.layoutUpdate.emit({
3053
+ layout,
3054
+ ...options
3055
+ });
3056
+ }
3057
+ async setAppContext(context) {
3058
+ (0, import_node_assert11.default)(this._appRpc, "runtime not open");
3059
+ if (context.spaceKey) {
3060
+ this._spaceKey = context.spaceKey;
3061
+ }
3062
+ if (context.invitationCode) {
3063
+ this._invitationCode = context.invitationCode;
3064
+ }
3065
+ await this._appRpc.rpc.AppService.setContext({
3066
+ ...context,
3067
+ spaceKey: this._spaceKey,
3068
+ invitationCode: this._invitationCode
3069
+ });
3070
+ }
3071
+ async open() {
3072
+ this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
3073
+ requested: appServiceBundle,
3074
+ exposed: shellServiceBundle,
3075
+ handlers: {
3076
+ ShellService: {
3077
+ setLayout: async (request) => {
3078
+ this._layout = request.layout;
3079
+ this._invitationCode = request.invitationCode;
3080
+ this._spaceKey = request.spaceKey;
3081
+ this.layoutUpdate.emit(request);
3082
+ }
3083
+ }
3084
+ },
3085
+ port: this._port
3086
+ });
3087
+ await this._appRpc.open();
3088
+ }
3089
+ async close() {
3090
+ var _a;
3091
+ await ((_a = this._appRpc) == null ? void 0 : _a.close());
3092
+ this._appRpc = void 0;
3093
+ }
3094
+ };
3095
+
3096
+ // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3008
3097
  var __decorate3 = function(decorators, target, key, desc) {
3009
3098
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3010
3099
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3017,11 +3106,12 @@ var __decorate3 = function(decorators, target, key, desc) {
3017
3106
  };
3018
3107
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
3019
3108
  var IFrameHostRuntime = class {
3020
- constructor({ configProvider, appPort }) {
3109
+ constructor({ configProvider, appPort, shellPort }) {
3021
3110
  this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)();
3022
- this._ready = new import_async16.Trigger();
3111
+ this._ready = new import_async17.Trigger();
3023
3112
  this._configProvider = configProvider;
3024
3113
  this._appPort = appPort;
3114
+ this._shellPort = shellPort;
3025
3115
  this._getService = async (find) => {
3026
3116
  const error = await this._ready.wait();
3027
3117
  if (error) {
@@ -3033,16 +3123,26 @@ var IFrameHostRuntime = class {
3033
3123
  }
3034
3124
  return service;
3035
3125
  };
3126
+ if (this._shellPort) {
3127
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3128
+ }
3129
+ }
3130
+ get services() {
3131
+ return this._clientServices;
3132
+ }
3133
+ get shell() {
3134
+ return this._shellRuntime;
3036
3135
  }
3037
3136
  async start() {
3137
+ var _a;
3038
3138
  (0, import_log12.log)("starting...", {}, {
3039
3139
  file: "iframe-host-runtime.ts",
3040
- line: 63,
3140
+ line: 81,
3041
3141
  scope: this,
3042
3142
  callSite: (f, a) => f(...a)
3043
3143
  });
3044
3144
  try {
3045
- this._config = await this._configProvider();
3145
+ this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
3046
3146
  const signalServer = this._config.get("runtime.services.signal.server");
3047
3147
  this._clientServices = new ClientServicesHost({
3048
3148
  lockKey: LOCK_KEY,
@@ -3055,7 +3155,7 @@ var IFrameHostRuntime = class {
3055
3155
  transportFactory: this._transportFactory
3056
3156
  })
3057
3157
  });
3058
- this._clientRpc = (0, import_rpc2.createProtoRpcPeer)({
3158
+ this._clientRpc = (0, import_rpc3.createProtoRpcPeer)({
3059
3159
  exposed: clientServiceBundle,
3060
3160
  handlers: {
3061
3161
  DataService: async () => await this._getService((services) => services.DataService),
@@ -3074,12 +3174,13 @@ var IFrameHostRuntime = class {
3074
3174
  });
3075
3175
  await Promise.all([
3076
3176
  this._clientServices.open(),
3077
- this._clientRpc.open()
3177
+ this._clientRpc.open(),
3178
+ (_a = this._shellRuntime) == null ? void 0 : _a.open()
3078
3179
  ]);
3079
3180
  this._ready.wake(void 0);
3080
3181
  (0, import_log12.log)("started", {}, {
3081
3182
  file: "iframe-host-runtime.ts",
3082
- line: 99,
3183
+ line: 117,
3083
3184
  scope: this,
3084
3185
  callSite: (f, a) => f(...a)
3085
3186
  });
@@ -3087,24 +3188,26 @@ var IFrameHostRuntime = class {
3087
3188
  this._ready.wake(err);
3088
3189
  import_log12.log.catch(err, {}, {
3089
3190
  file: "iframe-host-runtime.ts",
3090
- line: 102,
3191
+ line: 120,
3091
3192
  scope: this,
3092
3193
  callSite: (f, a) => f(...a)
3093
3194
  });
3094
3195
  }
3095
3196
  }
3096
3197
  async stop() {
3198
+ var _a;
3097
3199
  (0, import_log12.log)("stopping...", {}, {
3098
3200
  file: "iframe-host-runtime.ts",
3099
- line: 107,
3201
+ line: 125,
3100
3202
  scope: this,
3101
3203
  callSite: (f, a) => f(...a)
3102
3204
  });
3103
3205
  await this._clientRpc.close();
3104
3206
  await this._clientServices.close();
3207
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3105
3208
  (0, import_log12.log)("stopped", {}, {
3106
3209
  file: "iframe-host-runtime.ts",
3107
- line: 110,
3210
+ line: 129,
3108
3211
  scope: this,
3109
3212
  callSite: (f, a) => f(...a)
3110
3213
  });
@@ -3116,21 +3219,17 @@ __decorate3([
3116
3219
 
3117
3220
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3118
3221
  var import_network_manager4 = require("@dxos/network-manager");
3119
- var import_rpc3 = require("@dxos/rpc");
3222
+ var import_rpc4 = require("@dxos/rpc");
3120
3223
 
3121
- // packages/sdk/client-services/src/packlets/vault/services.ts
3122
- var import_protocols7 = require("@dxos/protocols");
3123
- var iframeServiceBundle = {
3124
- IframeService: import_protocols7.schema.getService("dxos.iframe.IframeService"),
3125
- BridgeService: import_protocols7.schema.getService("dxos.mesh.bridge.BridgeService")
3126
- };
3127
- var workerServiceBundle = {
3128
- WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
3129
- };
3224
+ // packages/sdk/client-services/src/packlets/vault/shell-controller.ts
3225
+ var import_async18 = require("@dxos/async");
3226
+ var import_log13 = require("@dxos/log");
3227
+ var import_iframe2 = require("@dxos/protocols/proto/dxos/iframe");
3228
+ var import_rpc5 = require("@dxos/rpc");
3130
3229
 
3131
3230
  // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3132
- var import_async17 = require("@dxos/async");
3133
- var import_log13 = require("@dxos/log");
3231
+ var import_async19 = require("@dxos/async");
3232
+ var import_log14 = require("@dxos/log");
3134
3233
  var Message;
3135
3234
  (function(Message2) {
3136
3235
  Message2["ACQUIRING"] = "acquiring";
@@ -3138,7 +3237,7 @@ var Message;
3138
3237
  var VaultResourceLock = class {
3139
3238
  constructor({ lockKey, onAcquire, onRelease }) {
3140
3239
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
3141
- this._releaseTrigger = new import_async17.Trigger();
3240
+ this._releaseTrigger = new import_async19.Trigger();
3142
3241
  this._lockKey = lockKey;
3143
3242
  this._onAcquire = onAcquire;
3144
3243
  this._onRelease = onRelease;
@@ -3149,7 +3248,7 @@ var VaultResourceLock = class {
3149
3248
  message: Message.ACQUIRING
3150
3249
  });
3151
3250
  try {
3152
- await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
3251
+ await (0, import_async19.asyncTimeout)(this._requestLock(), 3e3);
3153
3252
  } catch (e) {
3154
3253
  await this._requestLock(true);
3155
3254
  }
@@ -3163,7 +3262,7 @@ var VaultResourceLock = class {
3163
3262
  }
3164
3263
  }
3165
3264
  async _requestLock(steal = false) {
3166
- (0, import_log13.log)("requesting lock...", {
3265
+ (0, import_log14.log)("requesting lock...", {
3167
3266
  steal
3168
3267
  }, {
3169
3268
  file: "vault-resource-lock.ts",
@@ -3171,23 +3270,23 @@ var VaultResourceLock = class {
3171
3270
  scope: this,
3172
3271
  callSite: (f, a) => f(...a)
3173
3272
  });
3174
- const acquired = new import_async17.Trigger();
3273
+ const acquired = new import_async19.Trigger();
3175
3274
  void navigator.locks.request(this._lockKey, {
3176
3275
  steal
3177
3276
  }, async () => {
3178
3277
  var _a, _b;
3179
3278
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3180
3279
  acquired.wake();
3181
- this._releaseTrigger = new import_async17.Trigger();
3280
+ this._releaseTrigger = new import_async19.Trigger();
3182
3281
  await this._releaseTrigger.wait();
3183
- (0, import_log13.log)("releasing lock...", {}, {
3282
+ (0, import_log14.log)("releasing lock...", {}, {
3184
3283
  file: "vault-resource-lock.ts",
3185
3284
  line: 65,
3186
3285
  scope: this,
3187
3286
  callSite: (f, a) => f(...a)
3188
3287
  });
3189
3288
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3190
- (0, import_log13.log)("released lock", {}, {
3289
+ (0, import_log14.log)("released lock", {}, {
3191
3290
  file: "vault-resource-lock.ts",
3192
3291
  line: 67,
3193
3292
  scope: this,
@@ -3198,7 +3297,7 @@ var VaultResourceLock = class {
3198
3297
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3199
3298
  });
3200
3299
  await acquired.wait();
3201
- (0, import_log13.log)("recieved lock", {
3300
+ (0, import_log14.log)("recieved lock", {
3202
3301
  steal
3203
3302
  }, {
3204
3303
  file: "vault-resource-lock.ts",
@@ -3210,17 +3309,17 @@ var VaultResourceLock = class {
3210
3309
  };
3211
3310
 
3212
3311
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3213
- var import_async19 = require("@dxos/async");
3214
- var import_log15 = require("@dxos/log");
3312
+ var import_async21 = require("@dxos/async");
3313
+ var import_log16 = require("@dxos/log");
3215
3314
  var import_messaging2 = require("@dxos/messaging");
3216
3315
  var import_network_manager5 = require("@dxos/network-manager");
3217
3316
 
3218
3317
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3219
- var import_node_assert11 = __toESM(require("node:assert"));
3220
- var import_async18 = require("@dxos/async");
3221
- var import_log14 = require("@dxos/log");
3222
- var import_rpc4 = require("@dxos/rpc");
3223
- var import_util7 = require("@dxos/util");
3318
+ var import_node_assert12 = __toESM(require("node:assert"));
3319
+ var import_async20 = require("@dxos/async");
3320
+ var import_log15 = require("@dxos/log");
3321
+ var import_rpc6 = require("@dxos/rpc");
3322
+ var import_util8 = require("@dxos/util");
3224
3323
  var __decorate4 = function(decorators, target, key, desc) {
3225
3324
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3226
3325
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3232,33 +3331,39 @@ var __decorate4 = function(decorators, target, key, desc) {
3232
3331
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3233
3332
  };
3234
3333
  var WorkerSession = class {
3235
- constructor({ getService, systemPort, appPort, options = {
3334
+ constructor({ getService, systemPort, appPort, shellPort, options = {
3236
3335
  heartbeatInterval: 1e3
3237
3336
  } }) {
3238
- this._startTrigger = new import_async18.Trigger();
3239
- this.onClose = new import_util7.Callback();
3240
- (0, import_node_assert11.default)(options);
3241
- (0, import_node_assert11.default)(getService);
3337
+ this._startTrigger = new import_async20.Trigger();
3338
+ this.onClose = new import_util8.Callback();
3339
+ (0, import_node_assert12.default)(options);
3340
+ (0, import_node_assert12.default)(getService);
3242
3341
  this._options = options;
3243
3342
  this._getService = getService;
3244
- this._clientRpc = (0, import_rpc4.createProtoRpcPeer)({
3343
+ const handlers = {
3344
+ DataService: async () => await this._getService((services) => services.DataService),
3345
+ DevicesService: async () => await this._getService((services) => services.DevicesService),
3346
+ DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3347
+ HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3348
+ NetworkService: async () => await this._getService((services) => services.NetworkService),
3349
+ ProfileService: async () => await this._getService((services) => services.ProfileService),
3350
+ SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3351
+ SpaceService: async () => await this._getService((services) => services.SpaceService),
3352
+ SpacesService: async () => await this._getService((services) => services.SpacesService),
3353
+ SystemService: async () => await this._getService((services) => services.SystemService),
3354
+ TracingService: async () => await this._getService((services) => services.TracingService)
3355
+ };
3356
+ this._clientRpc = (0, import_rpc6.createProtoRpcPeer)({
3245
3357
  exposed: clientServiceBundle,
3246
- handlers: {
3247
- DataService: async () => await this._getService((services) => services.DataService),
3248
- DevicesService: async () => await this._getService((services) => services.DevicesService),
3249
- DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3250
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3251
- NetworkService: async () => await this._getService((services) => services.NetworkService),
3252
- ProfileService: async () => await this._getService((services) => services.ProfileService),
3253
- SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3254
- SpaceService: async () => await this._getService((services) => services.SpaceService),
3255
- SpacesService: async () => await this._getService((services) => services.SpacesService),
3256
- SystemService: async () => await this._getService((services) => services.SystemService),
3257
- TracingService: async () => await this._getService((services) => services.TracingService)
3258
- },
3358
+ handlers,
3259
3359
  port: appPort
3260
3360
  });
3261
- this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
3361
+ this._shellClientRpc = (0, import_rpc6.createProtoRpcPeer)({
3362
+ exposed: clientServiceBundle,
3363
+ handlers,
3364
+ port: shellPort
3365
+ });
3366
+ this._iframeRpc = (0, import_rpc6.createProtoRpcPeer)({
3262
3367
  requested: iframeServiceBundle,
3263
3368
  exposed: workerServiceBundle,
3264
3369
  handlers: {
@@ -3272,9 +3377,9 @@ var WorkerSession = class {
3272
3377
  try {
3273
3378
  await this.close();
3274
3379
  } catch (err) {
3275
- import_log14.log.catch(err, {}, {
3380
+ import_log15.log.catch(err, {}, {
3276
3381
  file: "worker-session.ts",
3277
- line: 90,
3382
+ line: 92,
3278
3383
  scope: this,
3279
3384
  callSite: (f, a) => f(...a)
3280
3385
  });
@@ -3290,15 +3395,16 @@ var WorkerSession = class {
3290
3395
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
3291
3396
  }
3292
3397
  async open() {
3293
- import_log14.log.info("opening..", {}, {
3398
+ import_log15.log.info("opening..", {}, {
3294
3399
  file: "worker-session.ts",
3295
- line: 104,
3400
+ line: 106,
3296
3401
  scope: this,
3297
3402
  callSite: (f, a) => f(...a)
3298
3403
  });
3299
3404
  await Promise.all([
3300
3405
  this._clientRpc.open(),
3301
- this._iframeRpc.open()
3406
+ this._iframeRpc.open(),
3407
+ this._maybeOpenShell()
3302
3408
  ]);
3303
3409
  await this._startTrigger.wait({
3304
3410
  timeout: 3e3
@@ -3307,20 +3413,20 @@ var WorkerSession = class {
3307
3413
  try {
3308
3414
  await this._iframeRpc.rpc.IframeService.heartbeat();
3309
3415
  } catch (err1) {
3310
- import_log14.log.warn("Heartbeat failed", {
3416
+ import_log15.log.warn("Heartbeat failed", {
3311
3417
  err: err1
3312
3418
  }, {
3313
3419
  file: "worker-session.ts",
3314
- line: 116,
3420
+ line: 118,
3315
3421
  scope: this,
3316
3422
  callSite: (f, a) => f(...a)
3317
3423
  });
3318
3424
  try {
3319
3425
  await this.close();
3320
3426
  } catch (err) {
3321
- import_log14.log.catch(err, {}, {
3427
+ import_log15.log.catch(err, {}, {
3322
3428
  file: "worker-session.ts",
3323
- line: 120,
3429
+ line: 122,
3324
3430
  scope: this,
3325
3431
  callSite: (f, a) => f(...a)
3326
3432
  });
@@ -3329,18 +3435,18 @@ var WorkerSession = class {
3329
3435
  }, this._options.heartbeatInterval);
3330
3436
  }
3331
3437
  async close() {
3332
- import_log14.log.info("closing..", {}, {
3438
+ import_log15.log.info("closing..", {}, {
3333
3439
  file: "worker-session.ts",
3334
- line: 127,
3440
+ line: 129,
3335
3441
  scope: this,
3336
3442
  callSite: (f, a) => f(...a)
3337
3443
  });
3338
3444
  try {
3339
3445
  await this.onClose.callIfSet();
3340
3446
  } catch (err) {
3341
- import_log14.log.catch(err, {}, {
3447
+ import_log15.log.catch(err, {}, {
3342
3448
  file: "worker-session.ts",
3343
- line: 131,
3449
+ line: 133,
3344
3450
  scope: this,
3345
3451
  callSite: (f, a) => f(...a)
3346
3452
  });
@@ -3353,9 +3459,21 @@ var WorkerSession = class {
3353
3459
  this._iframeRpc.close()
3354
3460
  ]);
3355
3461
  }
3462
+ async _maybeOpenShell() {
3463
+ try {
3464
+ await (0, import_async20.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3465
+ } catch (e) {
3466
+ import_log15.log.info("No shell connected.", {}, {
3467
+ file: "worker-session.ts",
3468
+ line: 147,
3469
+ scope: this,
3470
+ callSite: (f, a) => f(...a)
3471
+ });
3472
+ }
3473
+ }
3356
3474
  };
3357
3475
  __decorate4([
3358
- import_log14.logInfo
3476
+ import_log15.logInfo
3359
3477
  ], WorkerSession.prototype, "origin", void 0);
3360
3478
 
3361
3479
  // packages/sdk/client-services/src/packlets/services/service-registry.ts
@@ -3438,7 +3556,7 @@ var ClientServicesHost = class {
3438
3556
  if (this._open) {
3439
3557
  return;
3440
3558
  }
3441
- (0, import_log16.log)("opening...", {}, {
3559
+ (0, import_log17.log)("opening...", {}, {
3442
3560
  file: "service-host.ts",
3443
3561
  line: 125,
3444
3562
  scope: this,
@@ -3458,7 +3576,7 @@ var ClientServicesHost = class {
3458
3576
  return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
3459
3577
  }),
3460
3578
  SpacesService: new SpacesServiceImpl(this._serviceContext.spaceManager),
3461
- DataService: new import_echo_db5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
3579
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
3462
3580
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
3463
3581
  // TODO(burdon): Move to new protobuf definitions.
3464
3582
  ProfileService: new ProfileServiceImpl(this._serviceContext),
@@ -3474,7 +3592,7 @@ var ClientServicesHost = class {
3474
3592
  await this._serviceContext.open();
3475
3593
  this._open = true;
3476
3594
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3477
- (0, import_log16.log)("opened", {
3595
+ (0, import_log17.log)("opened", {
3478
3596
  deviceKey
3479
3597
  }, {
3480
3598
  file: "service-host.ts",
@@ -3489,7 +3607,7 @@ var ClientServicesHost = class {
3489
3607
  return;
3490
3608
  }
3491
3609
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3492
- (0, import_log16.log)("closing...", {
3610
+ (0, import_log17.log)("closing...", {
3493
3611
  deviceKey
3494
3612
  }, {
3495
3613
  file: "service-host.ts",
@@ -3502,7 +3620,7 @@ var ClientServicesHost = class {
3502
3620
  });
3503
3621
  await this._serviceContext.close();
3504
3622
  this._open = false;
3505
- (0, import_log16.log)("closed", {
3623
+ (0, import_log17.log)("closed", {
3506
3624
  deviceKey
3507
3625
  }, {
3508
3626
  file: "service-host.ts",
@@ -3514,9 +3632,9 @@ var ClientServicesHost = class {
3514
3632
  };
3515
3633
 
3516
3634
  // packages/sdk/client-services/src/packlets/services/service-proxy.ts
3517
- var import_async20 = require("@dxos/async");
3635
+ var import_async22 = require("@dxos/async");
3518
3636
  var import_errors2 = require("@dxos/errors");
3519
- var import_rpc5 = require("@dxos/rpc");
3637
+ var import_rpc7 = require("@dxos/rpc");
3520
3638
 
3521
3639
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
3522
3640
  var createServiceHost = (config, signalManagerContext) => {
@@ -3587,18 +3705,18 @@ var TestPeer = class {
3587
3705
  root: this.storage.createDirectory("feeds"),
3588
3706
  signer: this.keyring,
3589
3707
  hypercore: {
3590
- valueEncoding: import_echo_db6.valueEncoding
3708
+ valueEncoding: import_echo_pipeline6.valueEncoding
3591
3709
  }
3592
3710
  })
3593
3711
  });
3594
3712
  }
3595
3713
  get metadataStore() {
3596
3714
  var _a, _b;
3597
- return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_db6.MetadataStore(this.storage.createDirectory("metadata"));
3715
+ return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline6.MetadataStore(this.storage.createDirectory("metadata"));
3598
3716
  }
3599
3717
  get snapshotStore() {
3600
3718
  var _a, _b;
3601
- return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_db6.SnapshotStore(this.storage.createDirectory("snapshots"));
3719
+ return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline6.SnapshotStore(this.storage.createDirectory("snapshots"));
3602
3720
  }
3603
3721
  get networkManager() {
3604
3722
  var _a, _b;
@@ -3609,7 +3727,7 @@ var TestPeer = class {
3609
3727
  }
3610
3728
  get spaceManager() {
3611
3729
  var _a, _b;
3612
- return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_db6.SpaceManager({
3730
+ return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_pipeline6.SpaceManager({
3613
3731
  feedStore: this.feedStore,
3614
3732
  networkManager: this.networkManager
3615
3733
  });
@@ -3631,24 +3749,24 @@ var createSigningContext = async (keyring) => {
3631
3749
  };
3632
3750
 
3633
3751
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
3634
- var import_node_assert12 = __toESM(require("node:assert"));
3635
- var import_async21 = require("@dxos/async");
3752
+ var import_node_assert13 = __toESM(require("node:assert"));
3753
+ var import_async23 = require("@dxos/async");
3636
3754
  var import_debug8 = require("@dxos/debug");
3637
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3755
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
3638
3756
  var performInvitation = async (host, guest, context) => {
3639
- const done1 = new import_async21.Trigger();
3640
- const done2 = new import_async21.Trigger();
3757
+ const done1 = new import_async23.Trigger();
3758
+ const done2 = new import_async23.Trigger();
3641
3759
  const observable1 = await host.createInvitation(context, {
3642
- type: import_services12.Invitation.Type.INTERACTIVE_TESTING
3760
+ type: import_services14.Invitation.Type.INTERACTIVE_TESTING
3643
3761
  });
3644
3762
  observable1.subscribe({
3645
3763
  onConnecting: async (invitation1) => {
3646
3764
  const observable2 = await guest.acceptInvitation(invitation1, {
3647
- type: import_services12.Invitation.Type.INTERACTIVE_TESTING
3765
+ type: import_services14.Invitation.Type.INTERACTIVE_TESTING
3648
3766
  });
3649
3767
  observable2.subscribe({
3650
3768
  onConnecting: async (invitation2) => {
3651
- (0, import_node_assert12.default)(invitation1.swarmKey.equals(invitation2.swarmKey));
3769
+ (0, import_node_assert13.default)(invitation1.swarmKey.equals(invitation2.swarmKey));
3652
3770
  },
3653
3771
  onConnected: async (invitation2) => {
3654
3772
  },