@mcp-fe/mcp-worker 0.0.12 → 0.0.13

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.
package/README.md CHANGED
@@ -1,11 +1,62 @@
1
- # mcp-worker
1
+ # @mcp-fe/mcp-worker
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ This library provides a client adapter and ready-to-use worker scripts for working with MCP (Model Context Protocol).
4
4
 
5
- ## Building
5
+ Exports
6
6
 
7
- Run `nx build mcp-worker` to build the library.
7
+ - `index` the main client module (exports the `workerClient` singleton and related types). Import this in your client application.
8
+ - `mcp-service-worker.js` — Service Worker implementation intended to be registered via `navigator.serviceWorker.register(...)`.
9
+ - `mcp-shared-worker.js` — SharedWorker implementation intended to be started via `new SharedWorker(...)`.
8
10
 
9
- ## Running unit tests
11
+ Note: Worker script files (service/shared) must be available on your application's public path so the browser can fetch them (for example `/mcp-service-worker.js` and `/mcp-shared-worker.js`).
10
12
 
11
- Run `nx test mcp-worker` to execute the unit tests via [Vitest](https://vitest.dev/).
13
+ Quick start
14
+
15
+ 1) Make worker files available on your public path
16
+
17
+ - Copy the worker files (`mcp-service-worker.js`, `mcp-shared-worker.js`) into the folder your webserver serves as public (for example `public/` or `dist/`).
18
+ - Important: the URL used during registration must match the actual location of the files. The `WorkerClient` defaults to `/mcp-shared-worker.js` and `/mcp-service-worker.js`.
19
+ If you place them elsewhere, pass the correct URLs to `init`.
20
+
21
+ 3) Import and initialize in your client app
22
+
23
+ Example (TypeScript):
24
+
25
+ ```ts
26
+ import { workerClient } from '@mcp-fe/mcp-worker';
27
+
28
+ // Optionally provide custom worker URLs and backend WebSocket URL
29
+ await workerClient.init({
30
+ sharedWorkerUrl: '/mcp-shared-worker.js',
31
+ serviceWorkerUrl: '/mcp-service-worker.js',
32
+ backendWsUrl: 'wss://your-backend.example/ws'
33
+ });
34
+
35
+ // Set an auth token (if you use authentication)
36
+ workerClient.setAuthToken('Bearer ...');
37
+
38
+ // Send an event to the worker (fire-and-forget)
39
+ await workerClient.post('STORE_EVENT', { event: { /* ... */ } });
40
+
41
+ // Request events (request/response)
42
+ const res = await workerClient.request('GET_EVENTS');
43
+ if (res && (res as any).events) {
44
+ console.log('Events:', (res as any).events);
45
+ }
46
+ ```
47
+
48
+ Alternatively, register the Service Worker yourself and pass the registration to `init`:
49
+
50
+ ```ts
51
+ // register the service worker (e.g. in your app entry file)
52
+ const registration = await navigator.serviceWorker.register('/mcp-service-worker.js');
53
+ await workerClient.init(registration);
54
+ ```
55
+
56
+ Notes & best practices
57
+
58
+ - `WorkerClient` prefers `SharedWorker` (shared across windows/iframes on the same origin). If `SharedWorker` is not available, it will automatically fall back to `ServiceWorker`.
59
+ - If you need different worker URLs, pass `sharedWorkerUrl` and `serviceWorkerUrl` to `workerClient.init(...)`.
60
+ - Worker scripts must be served from the same origin as your app.
61
+ - Calling `workerClient.setAuthToken(...)` before initialization is allowed: the client will queue the token and send it when a worker becomes available.
62
+ - The default worker URLs are `/mcp-shared-worker.js` and `/mcp-service-worker.js`.
package/index.js CHANGED
@@ -1,5 +1,10 @@
1
1
  // libs/mcp-worker/src/lib/worker-client.ts
2
2
  var WorkerClient = class {
3
+ // Configurable worker script URLs (defaults kept for backward compatibility)
4
+ sharedWorkerUrl = "/mcp-shared-worker.js";
5
+ serviceWorkerUrl = "/mcp-service-worker.js";
6
+ // Backend websocket URL to pass into the worker(s)
7
+ backendWsUrl = "ws://localhost:3001";
3
8
  serviceWorkerRegistration = null;
4
9
  sharedWorker = null;
5
10
  sharedWorkerPort = null;
@@ -7,143 +12,113 @@ var WorkerClient = class {
7
12
  pendingAuthToken = null;
8
13
  // connection status subscribers
9
14
  connectionStatusCallbacks = /* @__PURE__ */ new Set();
10
- serviceWorkerMessageHandler = null;
11
15
  // Mutex/promise to prevent concurrent init runs
12
16
  initPromise = null;
13
17
  // Initialize and choose worker implementation (prefer SharedWorker)
14
- async init(registration) {
18
+ // Accept either a ServiceWorkerRegistration OR WorkerInitOptions to configure URLs
19
+ async init(registrationOrOptions) {
20
+ let explicitRegistration;
21
+ const maybeReg = registrationOrOptions;
22
+ if (maybeReg && typeof maybeReg.scope === "string") {
23
+ explicitRegistration = registrationOrOptions;
24
+ } else if (registrationOrOptions) {
25
+ const opts = registrationOrOptions;
26
+ if (opts.sharedWorkerUrl)
27
+ this.sharedWorkerUrl = opts.sharedWorkerUrl;
28
+ if (opts.serviceWorkerUrl)
29
+ this.serviceWorkerUrl = opts.serviceWorkerUrl;
30
+ if (opts.backendWsUrl)
31
+ this.backendWsUrl = opts.backendWsUrl;
32
+ }
15
33
  if (this.initPromise) {
16
34
  return this.initPromise.then(async () => {
17
- if (registration && this.workerType !== "service") {
18
- await this.init(registration);
35
+ if (explicitRegistration && this.workerType !== "service") {
36
+ await this.init(explicitRegistration);
19
37
  }
20
38
  });
21
39
  }
22
40
  this.initPromise = (async () => {
23
41
  try {
24
- if (registration) {
25
- this.serviceWorkerRegistration = registration;
42
+ if (explicitRegistration) {
43
+ this.serviceWorkerRegistration = explicitRegistration;
26
44
  this.workerType = "service";
27
- console.log("[WorkerClient] Using ServiceWorker (explicit registration)");
28
- if (this.pendingAuthToken) {
29
- this.sendAuthTokenToServiceWorker(this.pendingAuthToken);
30
- this.pendingAuthToken = null;
31
- }
32
- return;
33
- }
34
- if (typeof SharedWorker !== "undefined") {
45
+ console.log(
46
+ "[WorkerClient] Using ServiceWorker (explicit registration)"
47
+ );
35
48
  try {
36
- this.sharedWorker = new SharedWorker("/mcp-shared-worker.js", { type: "module" });
37
- this.sharedWorkerPort = this.sharedWorker.port;
38
- this.sharedWorkerPort.start();
39
- if (this.pendingAuthToken && this.sharedWorkerPort) {
40
- try {
41
- this.sharedWorkerPort.postMessage({ type: "SET_AUTH_TOKEN", token: this.pendingAuthToken });
42
- } catch (err) {
43
- console.warn("[WorkerClient] Immediate postMessage to SharedWorker failed (will retry after init):", err);
44
- }
45
- }
46
- this.sharedWorker.onerror = (event) => {
47
- console.error("[WorkerClient] SharedWorker error:", event.message || event.error || event);
48
- if (this.workerType !== "shared") {
49
- this.initServiceWorkerFallback().catch((err) => {
50
- console.error("[WorkerClient] Failed to initialize ServiceWorker fallback:", err);
51
- });
52
- }
53
- };
54
- await new Promise((resolve, reject) => {
55
- let resolved = false;
56
- const timeout = setTimeout(() => {
57
- if (!resolved) {
58
- const p2 = this.sharedWorkerPort;
59
- if (p2)
60
- p2.onmessage = null;
61
- reject(new Error("SharedWorker initialization timeout"));
62
- }
63
- }, 2e3);
64
- const p = this.sharedWorkerPort;
65
- if (!p) {
66
- clearTimeout(timeout);
67
- return reject(new Error("SharedWorker port not available"));
68
- }
69
- p.onmessage = (ev) => {
70
- try {
71
- const data = ev.data;
72
- if (data && data.type === "CONNECTION_STATUS") {
73
- clearTimeout(timeout);
74
- resolved = true;
75
- this.workerType = "shared";
76
- p.onmessage = null;
77
- resolve();
78
- }
79
- } catch {
80
- }
81
- };
82
- });
83
- const portAfterInit = this.sharedWorkerPort;
84
- if (this.pendingAuthToken && portAfterInit) {
85
- try {
86
- portAfterInit.postMessage({ type: "SET_AUTH_TOKEN", token: this.pendingAuthToken });
87
- this.pendingAuthToken = null;
88
- } catch (e) {
89
- console.error("[WorkerClient] Failed to send pending auth token to SharedWorker:", e);
90
- }
91
- }
92
- if (portAfterInit) {
93
- portAfterInit.onmessage = (ev) => {
94
- try {
95
- const data = ev.data;
96
- if (data && data.type === "CONNECTION_STATUS") {
97
- const connected = !!data.connected;
98
- this.connectionStatusCallbacks.forEach((cb) => {
99
- try {
100
- cb(connected);
101
- } catch (e) {
102
- }
103
- });
104
- }
105
- } catch {
106
- }
107
- };
49
+ const initMsg = { type: "INIT", backendUrl: this.backendWsUrl };
50
+ if (this.pendingAuthToken)
51
+ initMsg["token"] = this.pendingAuthToken;
52
+ if (this.serviceWorkerRegistration.active) {
53
+ this.serviceWorkerRegistration.active.postMessage(initMsg);
54
+ } else if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
55
+ navigator.serviceWorker.controller.postMessage(initMsg);
108
56
  }
109
- console.log("[WorkerClient] Using SharedWorker");
110
- return;
111
- } catch (error) {
112
- console.warn("[WorkerClient] SharedWorker not available, falling back to ServiceWorker:", error);
57
+ } catch {
113
58
  }
59
+ return;
114
60
  }
115
- console.log("this should not be called");
61
+ const sharedOk = await this.initSharedWorker();
62
+ if (sharedOk)
63
+ return;
116
64
  await this.initServiceWorkerFallback();
117
- if (this.pendingAuthToken && this.workerType === "service") {
118
- this.sendAuthTokenToServiceWorker(this.pendingAuthToken);
119
- this.pendingAuthToken = null;
120
- }
121
65
  } finally {
122
66
  this.initPromise = null;
123
67
  }
124
68
  })();
125
69
  return this.initPromise;
126
70
  }
127
- async initServiceWorkerFallback() {
128
- console.log("initServiceWorkerFallback called");
129
- if ("serviceWorker" in navigator) {
130
- try {
131
- const existingRegistration = await navigator.serviceWorker.getRegistration();
132
- if (existingRegistration) {
133
- this.serviceWorkerRegistration = existingRegistration;
134
- this.workerType = "service";
135
- console.log("[WorkerClient] Using existing ServiceWorker registration");
136
- return;
71
+ async initSharedWorker() {
72
+ if (typeof SharedWorker === "undefined") {
73
+ return false;
74
+ }
75
+ try {
76
+ this.sharedWorker = new SharedWorker(this.sharedWorkerUrl, {
77
+ type: "module"
78
+ });
79
+ this.sharedWorkerPort = this.sharedWorker.port;
80
+ this.sharedWorkerPort.start();
81
+ await new Promise((resolve, reject) => {
82
+ let resolved = false;
83
+ const timeout = setTimeout(() => {
84
+ if (!resolved) {
85
+ const p2 = this.sharedWorkerPort;
86
+ if (p2)
87
+ p2.onmessage = null;
88
+ reject(new Error("SharedWorker initialization timeout"));
89
+ }
90
+ }, 2e3);
91
+ const p = this.sharedWorkerPort;
92
+ if (!p) {
93
+ clearTimeout(timeout);
94
+ return reject(new Error("SharedWorker port not available"));
137
95
  }
138
- const reg = await navigator.serviceWorker.register("/mcp-service-worker.js");
139
- this.serviceWorkerRegistration = reg;
140
- this.workerType = "service";
141
- console.log("[WorkerClient] Using ServiceWorker (fallback)");
142
- if (this.serviceWorkerMessageHandler) {
143
- navigator.serviceWorker.removeEventListener("message", this.serviceWorkerMessageHandler);
144
- this.serviceWorkerMessageHandler = null;
96
+ p.onmessage = (ev) => {
97
+ try {
98
+ const data = ev.data;
99
+ if (data && data.type === "CONNECTION_STATUS") {
100
+ clearTimeout(timeout);
101
+ resolved = true;
102
+ this.workerType = "shared";
103
+ p.onmessage = null;
104
+ resolve();
105
+ }
106
+ } catch {
107
+ }
108
+ };
109
+ });
110
+ const portAfterInit = this.sharedWorkerPort;
111
+ if (portAfterInit) {
112
+ try {
113
+ const initMsg = { type: "INIT", backendUrl: this.backendWsUrl };
114
+ if (this.pendingAuthToken)
115
+ initMsg["token"] = this.pendingAuthToken;
116
+ portAfterInit.postMessage(initMsg);
117
+ this.pendingAuthToken = null;
118
+ } catch (e) {
119
+ console.warn("[WorkerClient] Failed to send INIT to SharedWorker port:", e);
145
120
  }
146
- this.serviceWorkerMessageHandler = (ev) => {
121
+ portAfterInit.onmessage = (ev) => {
147
122
  try {
148
123
  const data = ev.data;
149
124
  if (data && data.type === "CONNECTION_STATUS") {
@@ -151,16 +126,58 @@ var WorkerClient = class {
151
126
  this.connectionStatusCallbacks.forEach((cb) => {
152
127
  try {
153
128
  cb(connected);
154
- } catch (e) {
129
+ } catch {
155
130
  }
156
131
  });
157
132
  }
158
133
  } catch {
159
134
  }
160
135
  };
161
- navigator.serviceWorker.addEventListener("message", this.serviceWorkerMessageHandler);
136
+ }
137
+ console.log("[WorkerClient] Using SharedWorker");
138
+ return true;
139
+ } catch (error) {
140
+ console.warn(
141
+ "[WorkerClient] SharedWorker not available, falling back to ServiceWorker:",
142
+ error
143
+ );
144
+ return false;
145
+ }
146
+ }
147
+ async initServiceWorkerFallback() {
148
+ if ("serviceWorker" in navigator) {
149
+ try {
150
+ const existingRegistration = await navigator.serviceWorker.getRegistration();
151
+ if (existingRegistration) {
152
+ this.serviceWorkerRegistration = existingRegistration;
153
+ this.workerType = "service";
154
+ console.log(
155
+ "[WorkerClient] Using existing ServiceWorker registration"
156
+ );
157
+ return;
158
+ }
159
+ this.serviceWorkerRegistration = await navigator.serviceWorker.register(
160
+ this.serviceWorkerUrl
161
+ );
162
+ this.workerType = "service";
163
+ console.log("[WorkerClient] Using MCP ServiceWorker (fallback)");
164
+ try {
165
+ const initMsg = { type: "INIT", backendUrl: this.backendWsUrl };
166
+ if (this.pendingAuthToken)
167
+ initMsg["token"] = this.pendingAuthToken;
168
+ if (this.serviceWorkerRegistration.active) {
169
+ this.serviceWorkerRegistration.active.postMessage(initMsg);
170
+ } else if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
171
+ navigator.serviceWorker.controller.postMessage(initMsg);
172
+ }
173
+ this.pendingAuthToken = null;
174
+ } catch {
175
+ }
162
176
  } catch (error) {
163
- console.error("[WorkerClient] Failed to register ServiceWorker:", error);
177
+ console.error(
178
+ "[WorkerClient] Failed to register ServiceWorker:",
179
+ error
180
+ );
164
181
  throw error;
165
182
  }
166
183
  } else {
@@ -229,7 +246,9 @@ var WorkerClient = class {
229
246
  const active = reg.active;
230
247
  if (!active) {
231
248
  clearTimeout(timer);
232
- return reject(new Error("Service worker active instance not available"));
249
+ return reject(
250
+ new Error("Service worker active instance not available")
251
+ );
233
252
  }
234
253
  active.postMessage({ type, ...payload || {} }, [mc.port2]);
235
254
  } catch (e) {
@@ -252,17 +271,29 @@ var WorkerClient = class {
252
271
  }
253
272
  if (this.workerType === "service" && this.serviceWorkerRegistration?.active) {
254
273
  try {
255
- this.serviceWorkerRegistration.active.postMessage({ type, ...payload || {} });
274
+ this.serviceWorkerRegistration.active.postMessage({
275
+ type,
276
+ ...payload || {}
277
+ });
256
278
  } catch (e) {
257
- console.error("[WorkerClient] Failed to post to ServiceWorker (active):", e);
279
+ console.error(
280
+ "[WorkerClient] Failed to post to ServiceWorker (active):",
281
+ e
282
+ );
258
283
  }
259
284
  return;
260
285
  }
261
286
  if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
262
287
  try {
263
- navigator.serviceWorker.controller.postMessage({ type, ...payload || {} });
288
+ navigator.serviceWorker.controller.postMessage({
289
+ type,
290
+ ...payload || {}
291
+ });
264
292
  } catch (e) {
265
- console.error("[WorkerClient] Failed to post to ServiceWorker.controller:", e);
293
+ console.error(
294
+ "[WorkerClient] Failed to post to ServiceWorker.controller:",
295
+ e
296
+ );
266
297
  }
267
298
  return;
268
299
  }
@@ -275,15 +306,27 @@ var WorkerClient = class {
275
306
  sendAuthTokenToServiceWorker(token) {
276
307
  if (this.serviceWorkerRegistration?.active) {
277
308
  try {
278
- this.serviceWorkerRegistration.active.postMessage({ type: "SET_AUTH_TOKEN", token });
309
+ this.serviceWorkerRegistration.active.postMessage({
310
+ type: "SET_AUTH_TOKEN",
311
+ token
312
+ });
279
313
  } catch (e) {
280
- console.error("[WorkerClient] Failed to send auth token to ServiceWorker:", e);
314
+ console.error(
315
+ "[WorkerClient] Failed to send auth token to ServiceWorker:",
316
+ e
317
+ );
281
318
  }
282
319
  } else if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
283
320
  try {
284
- navigator.serviceWorker.controller.postMessage({ type: "SET_AUTH_TOKEN", token });
321
+ navigator.serviceWorker.controller.postMessage({
322
+ type: "SET_AUTH_TOKEN",
323
+ token
324
+ });
285
325
  } catch (e) {
286
- console.error("[WorkerClient] Failed to send auth token to ServiceWorker.controller:", e);
326
+ console.error(
327
+ "[WorkerClient] Failed to send auth token to ServiceWorker.controller:",
328
+ e
329
+ );
287
330
  }
288
331
  } else {
289
332
  this.pendingAuthToken = token;
@@ -298,10 +341,14 @@ var WorkerClient = class {
298
341
  }
299
342
  async getConnectionStatus() {
300
343
  try {
301
- const res = await this.request("GET_CONNECTION_STATUS", void 0, 2e3);
344
+ const res = await this.request(
345
+ "GET_CONNECTION_STATUS",
346
+ void 0,
347
+ 2e3
348
+ );
302
349
  if (res && typeof res === "object" && "connected" in res)
303
350
  return !!res.connected;
304
- return !!res.connected;
351
+ return !!res?.connected;
305
352
  } catch {
306
353
  return false;
307
354
  }
@@ -313,7 +360,10 @@ var WorkerClient = class {
313
360
  this.sharedWorkerPort.postMessage({ type: "SET_AUTH_TOKEN", token });
314
361
  this.pendingAuthToken = null;
315
362
  } catch (e) {
316
- console.error("[WorkerClient] Failed to set auth token on SharedWorker:", e);
363
+ console.error(
364
+ "[WorkerClient] Failed to set auth token on SharedWorker:",
365
+ e
366
+ );
317
367
  }
318
368
  } else if (this.workerType === "service") {
319
369
  this.sendAuthTokenToServiceWorker(token);
@@ -373,7 +423,10 @@ async function queryEvents(filters) {
373
423
  request.onerror = () => reject(request.error);
374
424
  });
375
425
  }
426
+
427
+ // libs/mcp-worker/src/index.ts
428
+ var workerClient = new WorkerClient();
376
429
  export {
377
- WorkerClient,
378
- queryEvents
430
+ queryEvents,
431
+ workerClient
379
432
  };
@@ -27831,9 +27831,9 @@ var WebSocketTransport = class {
27831
27831
  // libs/mcp-worker/src/lib/mcp-controller.ts
27832
27832
  var MAX_RECONNECT_DELAY = 3e4;
27833
27833
  var INITIAL_RECONNECT_DELAY = 1e3;
27834
- var MCPController = class {
27835
- constructor(backendUrl, broadcastFn, requireAuth = true) {
27836
- this.backendUrl = backendUrl;
27834
+ var MCPController = class _MCPController {
27835
+ constructor(backendUrl2, broadcastFn, requireAuth = true) {
27836
+ this.backendUrl = backendUrl2;
27837
27837
  this.broadcastFn = broadcastFn;
27838
27838
  this.requireAuth = requireAuth;
27839
27839
  }
@@ -27979,61 +27979,133 @@ var MCPController = class {
27979
27979
  this.socket = null;
27980
27980
  }
27981
27981
  }
27982
+ /**
27983
+ * Factory helper to create an MCPController instance. Use this instead of
27984
+ * replicating controller creation logic in callers.
27985
+ */
27986
+ static create(backendUrl2, broadcastFn, requireAuth = true) {
27987
+ return new _MCPController(backendUrl2, broadcastFn, requireAuth);
27988
+ }
27982
27989
  };
27983
27990
 
27984
27991
  // libs/mcp-worker/src/mcp-service-worker.ts
27985
- var BACKEND_WS_URL = "ws://localhost:3001";
27986
- var controller = new MCPController(BACKEND_WS_URL, (message) => {
27987
- self.clients.matchAll().then((clients) => {
27988
- clients.forEach((client) => {
27989
- try {
27990
- client.postMessage(message);
27991
- } catch (e) {
27992
- console.error("[ServiceWorker] Failed to post message to client:", e);
27993
- }
27992
+ var controller = null;
27993
+ var backendUrl = null;
27994
+ var pendingToken = null;
27995
+ var getController = () => {
27996
+ if (!controller)
27997
+ throw new Error("Worker not initialized (no backendUrl)");
27998
+ return controller;
27999
+ };
28000
+ var setBackendUrl = (url2) => {
28001
+ backendUrl = url2;
28002
+ controller = null;
28003
+ controller = MCPController.create(url2, (message) => {
28004
+ self.clients.matchAll().then((clients) => {
28005
+ clients.forEach((client) => {
28006
+ try {
28007
+ client.postMessage(message);
28008
+ } catch (e) {
28009
+ console.error("[ServiceWorker] Failed to post message to client:", e);
28010
+ }
28011
+ });
28012
+ }).catch((err) => {
28013
+ console.error("[ServiceWorker] Failed to match clients for broadcast:", err);
27994
28014
  });
27995
- }).catch((err) => {
27996
- console.error("[ServiceWorker] Failed to match clients for broadcast:", err);
27997
28015
  });
27998
- });
28016
+ return controller;
28017
+ };
27999
28018
  self.addEventListener("message", async (event) => {
28000
28019
  if (!event.data)
28001
28020
  return;
28002
- if (event.data.type === "SET_AUTH_TOKEN") {
28003
- controller.setAuthToken(event.data.token);
28021
+ const msg = event.data;
28022
+ if (msg["type"] === "INIT") {
28023
+ const url2 = msg["backendUrl"];
28024
+ if (!url2) {
28025
+ console.error("[ServiceWorker] INIT missing backendUrl");
28026
+ return;
28027
+ }
28028
+ try {
28029
+ setBackendUrl(url2);
28030
+ const token = msg["token"];
28031
+ if (token) {
28032
+ getController().setAuthToken(token);
28033
+ } else if (pendingToken) {
28034
+ getController().setAuthToken(pendingToken);
28035
+ pendingToken = null;
28036
+ }
28037
+ } catch (e) {
28038
+ console.error("[ServiceWorker] Failed to apply INIT:", e);
28039
+ }
28040
+ return;
28041
+ }
28042
+ if (msg["type"] === "SET_AUTH_TOKEN") {
28043
+ const token = msg["token"];
28044
+ if (!token)
28045
+ return;
28046
+ try {
28047
+ if (controller) {
28048
+ getController().setAuthToken(token);
28049
+ } else {
28050
+ pendingToken = token;
28051
+ }
28052
+ } catch (e) {
28053
+ console.error("[ServiceWorker] Failed to set auth token:", e);
28054
+ }
28004
28055
  return;
28005
28056
  }
28006
- if (event.data.type === "STORE_EVENT") {
28057
+ if (msg["type"] === "STORE_EVENT") {
28007
28058
  event.waitUntil((async () => {
28008
28059
  try {
28060
+ if (!backendUrl || !controller) {
28061
+ if (event.ports && event.ports[0]) {
28062
+ event.ports[0].postMessage({ success: false, error: "Worker not initialized" });
28063
+ }
28064
+ return;
28065
+ }
28009
28066
  const userEvent = event.data.event;
28010
- await controller.handleStoreEvent(userEvent);
28067
+ await getController().handleStoreEvent(userEvent);
28011
28068
  if (event.ports && event.ports[0]) {
28012
28069
  event.ports[0].postMessage({ success: true });
28013
28070
  }
28014
28071
  } catch (error48) {
28015
28072
  if (event.ports && event.ports[0]) {
28016
- event.ports[0].postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Unknown error" });
28073
+ event.ports[0].postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Worker not initialized" });
28017
28074
  }
28018
28075
  }
28019
28076
  })());
28020
- } else if (event.data.type === "GET_EVENTS") {
28077
+ return;
28078
+ }
28079
+ if (msg["type"] === "GET_EVENTS") {
28021
28080
  event.waitUntil((async () => {
28022
28081
  try {
28023
- const events = await controller.handleGetEvents();
28082
+ if (!backendUrl || !controller) {
28083
+ if (event.ports && event.ports[0]) {
28084
+ event.ports[0].postMessage({ success: false, error: "Worker not initialized" });
28085
+ }
28086
+ return;
28087
+ }
28088
+ const events = await getController().handleGetEvents();
28024
28089
  if (event.ports && event.ports[0]) {
28025
28090
  event.ports[0].postMessage({ success: true, events });
28026
28091
  }
28027
28092
  } catch (error48) {
28028
28093
  if (event.ports && event.ports[0]) {
28029
- event.ports[0].postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Unknown error" });
28094
+ event.ports[0].postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Worker not initialized" });
28030
28095
  }
28031
28096
  }
28032
28097
  })());
28033
- } else if (event.data.type === "GET_CONNECTION_STATUS") {
28098
+ return;
28099
+ }
28100
+ if (msg["type"] === "GET_CONNECTION_STATUS") {
28034
28101
  if (event.ports && event.ports[0]) {
28035
- event.ports[0].postMessage({ success: true, connected: controller.getConnectionStatus() });
28102
+ if (!backendUrl || !controller) {
28103
+ event.ports[0].postMessage({ success: false, error: "Worker not initialized" });
28104
+ } else {
28105
+ event.ports[0].postMessage({ success: true, connected: getController().getConnectionStatus() });
28106
+ }
28036
28107
  }
28108
+ return;
28037
28109
  }
28038
28110
  });
28039
28111
  self.addEventListener("install", (event) => {
@@ -27831,9 +27831,9 @@ var WebSocketTransport = class {
27831
27831
  // libs/mcp-worker/src/lib/mcp-controller.ts
27832
27832
  var MAX_RECONNECT_DELAY = 3e4;
27833
27833
  var INITIAL_RECONNECT_DELAY = 1e3;
27834
- var MCPController = class {
27835
- constructor(backendUrl, broadcastFn, requireAuth = true) {
27836
- this.backendUrl = backendUrl;
27834
+ var MCPController = class _MCPController {
27835
+ constructor(backendUrl2, broadcastFn, requireAuth = true) {
27836
+ this.backendUrl = backendUrl2;
27837
27837
  this.broadcastFn = broadcastFn;
27838
27838
  this.requireAuth = requireAuth;
27839
27839
  }
@@ -27979,27 +27979,48 @@ var MCPController = class {
27979
27979
  this.socket = null;
27980
27980
  }
27981
27981
  }
27982
+ /**
27983
+ * Factory helper to create an MCPController instance. Use this instead of
27984
+ * replicating controller creation logic in callers.
27985
+ */
27986
+ static create(backendUrl2, broadcastFn, requireAuth = true) {
27987
+ return new _MCPController(backendUrl2, broadcastFn, requireAuth);
27988
+ }
27982
27989
  };
27983
27990
 
27984
27991
  // libs/mcp-worker/src/mcp-shared-worker.ts
27985
- var BACKEND_WS_URL = "ws://localhost:3001";
27986
27992
  var connectedPorts = [];
27987
- var controller = new MCPController(BACKEND_WS_URL, (message) => {
27988
- connectedPorts.forEach((port) => {
27989
- try {
27990
- port.postMessage(message);
27991
- } catch (error48) {
27992
- const idx = connectedPorts.indexOf(port);
27993
- if (idx > -1)
27994
- connectedPorts.splice(idx, 1);
27995
- }
27993
+ var controller = null;
27994
+ var backendUrl = null;
27995
+ var pendingToken = null;
27996
+ var getController = () => {
27997
+ if (!controller)
27998
+ throw new Error("Worker not initialized (no backendUrl)");
27999
+ return controller;
28000
+ };
28001
+ var setBackendUrl = (url2) => {
28002
+ backendUrl = url2;
28003
+ controller = null;
28004
+ controller = MCPController.create(url2, (message) => {
28005
+ connectedPorts.forEach((port) => {
28006
+ try {
28007
+ port.postMessage(message);
28008
+ } catch (error48) {
28009
+ const idx = connectedPorts.indexOf(port);
28010
+ if (idx > -1)
28011
+ connectedPorts.splice(idx, 1);
28012
+ console.debug("[SharedWorker] Failed to broadcast to a port (removed):", error48);
28013
+ }
28014
+ });
27996
28015
  });
27997
- });
28016
+ return controller;
28017
+ };
27998
28018
  self.onconnect = (event) => {
27999
28019
  const port = event.ports[0];
28000
28020
  connectedPorts.push(port);
28001
28021
  try {
28002
- port.postMessage({ type: "CONNECTION_STATUS", connected: controller.getConnectionStatus() });
28022
+ const connected = controller ? getController().getConnectionStatus() : false;
28023
+ port.postMessage({ type: "CONNECTION_STATUS", connected });
28003
28024
  } catch (err) {
28004
28025
  console.error("[SharedWorker] Failed to post initial status to port:", err);
28005
28026
  }
@@ -28007,23 +28028,93 @@ self.onconnect = (event) => {
28007
28028
  if (!ev.data)
28008
28029
  return;
28009
28030
  const messageData = ev.data;
28031
+ if (messageData.type === "INIT") {
28032
+ const url2 = messageData["backendUrl"];
28033
+ if (!url2) {
28034
+ try {
28035
+ port.postMessage({ success: false, error: "INIT missing backendUrl" });
28036
+ } catch (e) {
28037
+ console.debug("[SharedWorker] Failed to reply to INIT with missing backendUrl:", e);
28038
+ }
28039
+ return;
28040
+ }
28041
+ try {
28042
+ setBackendUrl(url2);
28043
+ const token = messageData["token"];
28044
+ if (token) {
28045
+ getController().setAuthToken(token);
28046
+ } else if (pendingToken) {
28047
+ getController().setAuthToken(pendingToken);
28048
+ pendingToken = null;
28049
+ }
28050
+ try {
28051
+ port.postMessage({ success: true });
28052
+ } catch (e) {
28053
+ console.debug("[SharedWorker] Failed to post INIT success to port:", e);
28054
+ }
28055
+ } catch (e) {
28056
+ try {
28057
+ port.postMessage({ success: false, error: String(e) });
28058
+ } catch (er) {
28059
+ console.debug("[SharedWorker] Failed to post INIT failure to port:", er);
28060
+ }
28061
+ }
28062
+ return;
28063
+ }
28010
28064
  if (messageData.type === "SET_AUTH_TOKEN") {
28011
- const newToken = messageData.token;
28012
- controller.setAuthToken(newToken);
28065
+ const newToken = messageData["token"];
28066
+ if (!newToken)
28067
+ return;
28068
+ if (controller) {
28069
+ try {
28070
+ getController().setAuthToken(newToken);
28071
+ } catch (e) {
28072
+ console.error("[SharedWorker] Failed to set auth token:", e);
28073
+ }
28074
+ } else {
28075
+ pendingToken = newToken;
28076
+ }
28077
+ return;
28078
+ }
28079
+ if (messageData.type === "SET_BACKEND_URL") {
28080
+ const url2 = messageData["url"];
28081
+ if (!url2)
28082
+ return;
28083
+ try {
28084
+ setBackendUrl(url2);
28085
+ if (pendingToken) {
28086
+ try {
28087
+ getController().setAuthToken(pendingToken);
28088
+ pendingToken = null;
28089
+ } catch (e) {
28090
+ console.error("[SharedWorker] Failed to set pending auth token after SET_BACKEND_URL:", e);
28091
+ }
28092
+ }
28093
+ } catch (e) {
28094
+ console.error("[SharedWorker] Failed to set backend URL:", e);
28095
+ }
28013
28096
  return;
28014
28097
  }
28015
28098
  if (messageData.type === "STORE_EVENT") {
28016
28099
  try {
28100
+ if (!backendUrl || !controller) {
28101
+ try {
28102
+ port.postMessage({ success: false, error: "Worker not initialized" });
28103
+ } catch (e) {
28104
+ console.debug("[SharedWorker] Failed to post uninitialized error for STORE_EVENT:", e);
28105
+ }
28106
+ return;
28107
+ }
28017
28108
  const userEvent = messageData.event;
28018
- await controller.handleStoreEvent(userEvent);
28109
+ await getController().handleStoreEvent(userEvent);
28019
28110
  try {
28020
28111
  port.postMessage({ success: true });
28021
- } catch (error48) {
28022
- console.error("[SharedWorker] Failed to post success to port:", error48);
28112
+ } catch (e) {
28113
+ console.debug("[SharedWorker] Failed to post STORE_EVENT success to port:", e);
28023
28114
  }
28024
28115
  } catch (error48) {
28025
28116
  try {
28026
- port.postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Unknown error" });
28117
+ port.postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Worker not initialized" });
28027
28118
  } catch (e) {
28028
28119
  console.error("[SharedWorker] Failed to post failure to port:", e);
28029
28120
  }
@@ -28032,7 +28123,15 @@ self.onconnect = (event) => {
28032
28123
  }
28033
28124
  if (messageData.type === "GET_EVENTS") {
28034
28125
  try {
28035
- const events = await controller.handleGetEvents();
28126
+ if (!backendUrl || !controller) {
28127
+ try {
28128
+ port.postMessage({ success: false, error: "Worker not initialized" });
28129
+ } catch (e) {
28130
+ console.debug("[SharedWorker] Failed to post uninitialized error for GET_EVENTS:", e);
28131
+ }
28132
+ return;
28133
+ }
28134
+ const events = await getController().handleGetEvents();
28036
28135
  try {
28037
28136
  port.postMessage({ success: true, events });
28038
28137
  } catch (error48) {
@@ -28040,7 +28139,7 @@ self.onconnect = (event) => {
28040
28139
  }
28041
28140
  } catch (error48) {
28042
28141
  try {
28043
- port.postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Unknown error" });
28142
+ port.postMessage({ success: false, error: error48 instanceof Error ? error48.message : "Worker not initialized" });
28044
28143
  } catch (e) {
28045
28144
  console.error("[SharedWorker] Failed to post failure to port:", e);
28046
28145
  }
@@ -28049,9 +28148,22 @@ self.onconnect = (event) => {
28049
28148
  }
28050
28149
  if (messageData.type === "GET_CONNECTION_STATUS") {
28051
28150
  try {
28052
- port.postMessage({ success: true, connected: controller.getConnectionStatus() });
28151
+ if (!backendUrl || !controller) {
28152
+ try {
28153
+ port.postMessage({ success: false, error: "Worker not initialized" });
28154
+ } catch (e) {
28155
+ console.debug("[SharedWorker] Failed to post uninitialized error for GET_CONNECTION_STATUS:", e);
28156
+ }
28157
+ return;
28158
+ }
28159
+ port.postMessage({ success: true, connected: getController().getConnectionStatus() });
28053
28160
  } catch (error48) {
28054
- console.error("[SharedWorker] Failed to post connection status to port:", error48);
28161
+ console.debug("[SharedWorker] GET_CONNECTION_STATUS failed:", error48);
28162
+ try {
28163
+ port.postMessage({ success: false, error: "Worker not initialized" });
28164
+ } catch (e) {
28165
+ console.debug("[SharedWorker] Failed to post GET_CONNECTION_STATUS failure:", e);
28166
+ }
28055
28167
  }
28056
28168
  return;
28057
28169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-fe/mcp-worker",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export * from './lib/worker-client';
1
+ import { WorkerClient } from './lib/worker-client';
2
+ export { type WorkerClientInitOptions } from './lib/worker-client';
2
3
  export { queryEvents, type UserEvent } from './lib/database';
4
+ export declare const workerClient: WorkerClient;
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/mcp-worker/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/mcp-worker/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAO,qBAAqB,CAAC;AAElD,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG7D,eAAO,MAAM,YAAY,cAAqB,CAAC"}
@@ -24,5 +24,10 @@ export declare class MCPController {
24
24
  handleGetEvents(): Promise<ReturnType<typeof queryEvents>>;
25
25
  getConnectionStatus(): boolean;
26
26
  dispose(): void;
27
+ /**
28
+ * Factory helper to create an MCPController instance. Use this instead of
29
+ * replicating controller creation logic in callers.
30
+ */
31
+ static create(backendUrl: string, broadcastFn: BroadcastFn, requireAuth?: boolean): MCPController;
27
32
  }
28
33
  //# sourceMappingURL=mcp-controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-controller.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/lib/mcp-controller.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAAc,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOhE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAErD,qBAAa,aAAa;IAQZ,OAAO,CAAC,UAAU;IAAU,OAAO,CAAC,WAAW;IAP3D,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,iBAAiB,CAA+C;IACxE,OAAO,CAAC,WAAW,CAAU;gBAET,UAAU,EAAE,MAAM,EAAU,WAAW,EAAE,WAAW,EAAE,WAAW,UAAO;IAI5F,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,aAAa;IAOR,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAyGvC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAkBlC,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IAIhE,mBAAmB,IAAI,OAAO;IAI9B,OAAO,IAAI,IAAI;CAWvB"}
1
+ {"version":3,"file":"mcp-controller.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/lib/mcp-controller.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAAc,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOhE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAErD,qBAAa,aAAa;IAQZ,OAAO,CAAC,UAAU;IAAU,OAAO,CAAC,WAAW;IAP3D,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,iBAAiB,CAA+C;IACxE,OAAO,CAAC,WAAW,CAAU;gBAET,UAAU,EAAE,MAAM,EAAU,WAAW,EAAE,WAAW,EAAE,WAAW,UAAO;IAI5F,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,aAAa;IAOR,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAyGvC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAkBlC,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IAIhE,mBAAmB,IAAI,OAAO;IAI9B,OAAO,IAAI,IAAI;IAYtB;;;OAGG;WACW,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,UAAO,GAAG,aAAa;CAGtG"}
@@ -1,15 +1,64 @@
1
+ /**
2
+ * WorkerClient — adapter for communicating with a worker process.
3
+ *
4
+ * Responsibilities
5
+ * - Chooses the transport: prefers a SharedWorker and falls back to a ServiceWorker.
6
+ * - Provides a request/response API (MessageChannel) and a fire-and-forget post API.
7
+ * - Tracks connection status and exposes a subscription API for CONNECTION_STATUS updates.
8
+ * - Buffers an auth token (SET_AUTH_TOKEN) when no worker is available and sends it when a
9
+ * worker becomes active.
10
+ *
11
+ * Public API
12
+ * - async init(registration?: ServiceWorkerRegistration): Promise<void>
13
+ * Initializes the client. If a ServiceWorkerRegistration is provided, it will be used directly.
14
+ *
15
+ * - async request<T = any>(type: string, payload?: Record<string, unknown>, timeoutMs = 5000): Promise<T>
16
+ * Sends a request expecting a reply via MessageChannel. Rejects on timeout, missing worker,
17
+ * or a worker-reported error.
18
+ *
19
+ * - async post(type: string, payload?: Record<string, unknown>): Promise<void>
20
+ * Fire-and-forget message. If type === 'SET_AUTH_TOKEN' and no worker is available, the token
21
+ * is queued and sent after initialization.
22
+ *
23
+ * - getConnectionStatus(): Promise<boolean>
24
+ * Attempts to obtain the current connection status (uses GET_CONNECTION_STATUS request with a
25
+ * short timeout) and returns a boolean.
26
+ *
27
+ * - onConnectionStatus(cb: (connected: boolean) => void): void
28
+ * - offConnectionStatus(cb: (connected: boolean) => void): void
29
+ * Subscribe/unsubscribe to connection status updates.
30
+ *
31
+ * Error model and edge cases
32
+ * - init may throw if neither SharedWorker nor ServiceWorker is supported or registration fails.
33
+ * - request may reject due to timeout, no worker registered, missing active ServiceWorker, or a
34
+ * worker-reported error payload.
35
+ * - post does not throw for transient postMessage failures; SET_AUTH_TOKEN is queued instead.
36
+ * - Concurrent init calls are serialized via an internal mutex (initPromise).
37
+ *
38
+ */
39
+ export type WorkerClientInitOptions = {
40
+ /** URL to the SharedWorker script (optional) */
41
+ sharedWorkerUrl?: string;
42
+ /** URL to the ServiceWorker script (optional) */
43
+ serviceWorkerUrl?: string;
44
+ /** Backend WebSocket URL to configure inside the worker (optional) */
45
+ backendWsUrl?: string;
46
+ };
1
47
  export declare class WorkerClient {
48
+ private sharedWorkerUrl;
49
+ private serviceWorkerUrl;
50
+ private backendWsUrl;
2
51
  private serviceWorkerRegistration;
3
52
  private sharedWorker;
4
53
  private sharedWorkerPort;
5
54
  private workerType;
6
55
  private pendingAuthToken;
7
56
  private connectionStatusCallbacks;
8
- private serviceWorkerMessageHandler;
9
57
  private initPromise;
10
- init(registration?: ServiceWorkerRegistration): Promise<void>;
58
+ init(registrationOrOptions?: ServiceWorkerRegistration | WorkerClientInitOptions): Promise<void>;
59
+ private initSharedWorker;
11
60
  private initServiceWorkerFallback;
12
- request<T = any>(type: string, payload?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
61
+ request<T = unknown>(type: string, payload?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
13
62
  post(type: string, payload?: Record<string, unknown>): Promise<void>;
14
63
  private sendAuthTokenToServiceWorker;
15
64
  onConnectionStatus(cb: (connected: boolean) => void): void;
@@ -1 +1 @@
1
- {"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/lib/worker-client.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,OAAO,CAAC,yBAAyB,CAA0C;IAC3E,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,gBAAgB,CAAuB;IAE/C,OAAO,CAAC,yBAAyB,CAAgD;IACjF,OAAO,CAAC,2BAA2B,CAA6C;IAGhF,OAAO,CAAC,WAAW,CAA8B;IAGpC,IAAI,CAAC,YAAY,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;YAsI5D,yBAAyB;IA4C1B,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAoF/F,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCjF,OAAO,CAAC,4BAA4B;IAoB7B,kBAAkB,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAI1D,mBAAmB,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAIrD,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAU7C,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAiBzC"}
1
+ {"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/lib/worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH,MAAM,MAAM,uBAAuB,GAAG;IACpC,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,YAAY;IAEvB,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,YAAY,CAAwC;IAE5D,OAAO,CAAC,yBAAyB,CAA0C;IAC3E,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,gBAAgB,CAAuB;IAE/C,OAAO,CAAC,yBAAyB,CACrB;IAGZ,OAAO,CAAC,WAAW,CAA8B;IAIpC,IAAI,CACf,qBAAqB,CAAC,EAAE,yBAAyB,GAAG,uBAAuB,GAC1E,OAAO,CAAC,IAAI,CAAC;YAkEF,gBAAgB;YAwFhB,yBAAyB;IA8C1B,OAAO,CAAC,CAAC,GAAG,OAAO,EAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,SAAO,GACf,OAAO,CAAC,CAAC,CAAC;IAsFA,IAAI,CACf,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC;IAkDhB,OAAO,CAAC,4BAA4B;IAmC7B,kBAAkB,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAI1D,mBAAmB,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAIrD,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAe7C,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAoBzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-shared-worker.d.ts","sourceRoot":"","sources":["../../../../libs/mcp-worker/src/mcp-shared-worker.ts"],"names":[],"mappings":"AACA;;;;;;GAMG"}
1
+ {"version":3,"file":"mcp-shared-worker.d.ts","sourceRoot":"","sources":["../../../../libs/mcp-worker/src/mcp-shared-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}