livedesk 0.1.299 → 0.1.301

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
@@ -238,7 +238,7 @@ function getStablePairToken() {
238
238
  return pairToken;
239
239
  }
240
240
 
241
- function openBrowser(url) {
241
+ function openBrowser(url) {
242
242
  if (!url) {
243
243
  return;
244
244
  }
@@ -251,8 +251,28 @@ function openBrowser(url) {
251
251
  return;
252
252
  }
253
253
  const command = os.platform() === 'darwin' ? 'open' : 'xdg-open';
254
- spawn(command, [url], { detached: true, stdio: 'ignore' }).unref();
255
- }
254
+ spawn(command, [url], { detached: true, stdio: 'ignore' }).unref();
255
+ }
256
+
257
+ async function waitForRoleTransitionParentExit(pid, timeoutMs = 120_000) {
258
+ const processId = Number(pid);
259
+ if (!Number.isInteger(processId) || processId <= 1 || processId === process.pid) {
260
+ return;
261
+ }
262
+ const deadline = Date.now() + timeoutMs;
263
+ while (Date.now() < deadline) {
264
+ let alive = false;
265
+ try {
266
+ process.kill(processId, 0);
267
+ alive = true;
268
+ } catch (error) {
269
+ alive = error?.code === 'EPERM';
270
+ }
271
+ if (!alive) return;
272
+ await new Promise(resolve => setTimeout(resolve, 250));
273
+ }
274
+ throw new Error(`Previous LiveDesk runtime ${processId} did not exit before the role transition deadline.`);
275
+ }
256
276
 
257
277
  async function isManagerAlreadyRunning(url = DEFAULT_MANAGER_URL) {
258
278
  try {
@@ -684,11 +704,11 @@ async function runManager(args, resolvedRole = null) {
684
704
  };
685
705
 
686
706
  const startHubProcess = () => {
687
- const stderrChunks = [];
707
+ const stderrChunks = [];
688
708
  const child = spawn(process.execPath, [hubEntry, ...options.forwarded], {
689
- env,
690
- stdio: ['inherit', 'inherit', 'pipe'],
691
- windowsHide: false
709
+ env,
710
+ stdio: ['inherit', 'inherit', 'pipe'],
711
+ windowsHide: true
692
712
  });
693
713
  activeChild = child;
694
714
 
@@ -729,7 +749,7 @@ async function runManager(args, resolvedRole = null) {
729
749
  isOfflineFallback: false
730
750
  });
731
751
  console.log('[LiveDesk Hub] Role transition accepted. Starting the Client runtime.');
732
- runClient([], { ...resolvedRole, role: 'client', source: 'local-cache' });
752
+ runClient([], { ...resolvedRole, role: 'client', source: 'local-cache', roleTransition: true });
733
753
  return;
734
754
  }
735
755
  if (!signal
@@ -781,11 +801,18 @@ function runClient(args, resolvedRole = null) {
781
801
  LIVEDESK_NPM_LAUNCHER_NAME: 'livedesk',
782
802
  LIVEDESK_NPM_LAUNCHER_VERSION: readVersion(),
783
803
  LIVEDESK_RUNTIME_ROLE: 'client',
804
+ LIVEDESK_UNIFIED_LAUNCHER_ENTRY: String(process.argv[1] || ''),
805
+ LIVEDESK_ROLE_TRANSITION: resolvedRole?.roleTransition === true || process.env.LIVEDESK_ROLE_TRANSITION === '1'
806
+ ? '1'
807
+ : String(process.env.LIVEDESK_ROLE_TRANSITION || ''),
808
+ LIVEDESK_SKIP_BROWSER_OPEN: resolvedRole?.roleTransition === true || process.env.LIVEDESK_ROLE_TRANSITION === '1'
809
+ ? '1'
810
+ : String(process.env.LIVEDESK_SKIP_BROWSER_OPEN || ''),
784
811
  LIVEDESK_DEVICE_ID: String(resolvedRole?.deviceId || process.env.LIVEDESK_DEVICE_ID || ''),
785
812
  LIVEDESK_ROLE_SOURCE: String(resolvedRole?.source || process.env.LIVEDESK_ROLE_SOURCE || '')
786
813
  },
787
- stdio: 'inherit',
788
- windowsHide: false
814
+ stdio: 'inherit',
815
+ windowsHide: true
789
816
  });
790
817
  child.once('error', error => {
791
818
  console.error(`Failed to start LiveDesk client: ${error.message}`);
@@ -837,6 +864,10 @@ async function main() {
837
864
  }
838
865
  }
839
866
 
867
+ if (process.env.LIVEDESK_ROLE_TRANSITION === '1') {
868
+ await waitForRoleTransitionParentExit(process.env.LIVEDESK_RESTART_WAIT_PID);
869
+ }
870
+
840
871
  if (topLevel.noSingleInstance || process.env.LIVEDESK_DISABLE_SINGLE_INSTANCE === '1') {
841
872
  console.warn('[LiveDesk] Single-instance lock disabled for this run.');
842
873
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.299",
3
+ "version": "0.1.301",
4
4
  "description": "LiveDesk Hub and client launcher",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@ffmpeg-installer/ffmpeg": "^1.1.0",
35
- "@livedesk/client": "0.1.152",
35
+ "@livedesk/client": "0.1.154",
36
36
  "@openai/codex-sdk": "0.144.5",
37
37
  "cors": "^2.8.5",
38
38
  "express": "^4.21.2",