livedesk 0.1.272 → 0.1.273

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/bin/livedesk.js CHANGED
@@ -578,6 +578,10 @@ async function runManager(args) {
578
578
  try {
579
579
  const request = JSON.parse(readFileSync(updateRequestPath, 'utf8'));
580
580
  rmSync(updateRequestPath, { force: true });
581
+ if (request?.continueClientUpdate === true) {
582
+ process.env.LIVEDESK_UPDATE_CONTINUE = '1';
583
+ process.env.LIVEDESK_UPDATE_CONTINUE_TARGET_VERSION = String(request.latestClientVersion || '');
584
+ }
581
585
  if (request?.pid && Number(request.pid) !== Number(activeChild?.pid || 0)) {
582
586
  restartRequested = true;
583
587
  console.log(`[LiveDesk Hub] Restart requested for update ${request.operationId || 'unknown'}.`);
package/hub/src/server.js CHANGED
@@ -285,6 +285,7 @@ function requestHubRestart(request = {}) {
285
285
  const temporaryPath = `${requestPath}.${process.pid}.tmp`;
286
286
  writeFileSync(temporaryPath, JSON.stringify({
287
287
  ...request,
288
+ continueClientUpdate: true,
288
289
  pid: process.pid,
289
290
  requestedAt: new Date().toISOString()
290
291
  }), 'utf8');
@@ -302,7 +303,45 @@ liveDeskUpdateManager = createLiveDeskUpdateManager({
302
303
  restartSupported: !!String(process.env.LIVEDESK_HUB_UPDATE_REQUEST_PATH || '').trim(),
303
304
  requestHubRestart
304
305
  });
305
- const agentMcpSessions = new Map();
306
+
307
+ if (process.env.LIVEDESK_UPDATE_CONTINUE === '1') {
308
+ let continueUpdateInFlight = false;
309
+ let continueUpdateAttempts = 0;
310
+ const continueUpdateTimer = setInterval(async () => {
311
+ if (continueUpdateInFlight || continueUpdateAttempts >= 90) {
312
+ if (continueUpdateAttempts >= 90) clearInterval(continueUpdateTimer);
313
+ return;
314
+ }
315
+ const connectedDevices = remoteHub.listDevices({ includeDataUrl: false })
316
+ .filter(device => device.connected === true && device.synthetic !== true);
317
+ if (connectedDevices.length === 0) return;
318
+ continueUpdateAttempts += 1;
319
+ continueUpdateInFlight = true;
320
+ try {
321
+ await liveDeskUpdateManager.checkLatest();
322
+ const updateStatus = liveDeskUpdateManager.getStatus();
323
+ if (!updateStatus.updateAvailable) {
324
+ clearInterval(continueUpdateTimer);
325
+ return;
326
+ }
327
+ if (updateStatus.outdatedClientCount <= 0 && !updateStatus.clientPackageUpdateAvailable) {
328
+ clearInterval(continueUpdateTimer);
329
+ return;
330
+ }
331
+ const result = await liveDeskUpdateManager.startUpdate();
332
+ if (result?.ok === false || ['waiting-for-clients', 'clients-updated', 'hub-restart-requested'].includes(String(result?.state || ''))) {
333
+ clearInterval(continueUpdateTimer);
334
+ }
335
+ } catch (error) {
336
+ console.warn(`[LiveDesk Hub] automatic client update continuation failed: ${error instanceof Error ? error.message : String(error)}`);
337
+ clearInterval(continueUpdateTimer);
338
+ } finally {
339
+ continueUpdateInFlight = false;
340
+ }
341
+ }, 1000);
342
+ continueUpdateTimer.unref?.();
343
+ }
344
+ const agentMcpSessions = new Map();
306
345
  const agentMcpRunBatches = new Map();
307
346
  const agentMcpRunCleanupTimers = new Map();
308
347
  const AGENT_MCP_RUN_TTL_MS = 60 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.272",
3
+ "version": "0.1.273",
4
4
  "description": "LiveDesk Hub and client launcher",
5
5
  "type": "module",
6
6
  "bin": {