livedesk 0.1.299 → 0.1.300
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 {
|
|
@@ -685,10 +705,10 @@ async function runManager(args, resolvedRole = null) {
|
|
|
685
705
|
|
|
686
706
|
const startHubProcess = () => {
|
|
687
707
|
const stderrChunks = [];
|
|
688
|
-
|
|
689
|
-
env,
|
|
690
|
-
stdio: ['inherit', 'inherit', 'pipe'],
|
|
691
|
-
windowsHide:
|
|
708
|
+
const child = spawn(process.execPath, [hubEntry, ...options.forwarded], {
|
|
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,15 @@ 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_SKIP_BROWSER_OPEN: resolvedRole?.roleTransition === true || process.env.LIVEDESK_ROLE_TRANSITION === '1'
|
|
806
|
+
? '1'
|
|
807
|
+
: String(process.env.LIVEDESK_SKIP_BROWSER_OPEN || ''),
|
|
784
808
|
LIVEDESK_DEVICE_ID: String(resolvedRole?.deviceId || process.env.LIVEDESK_DEVICE_ID || ''),
|
|
785
809
|
LIVEDESK_ROLE_SOURCE: String(resolvedRole?.source || process.env.LIVEDESK_ROLE_SOURCE || '')
|
|
786
810
|
},
|
|
787
|
-
stdio: 'inherit',
|
|
788
|
-
windowsHide:
|
|
811
|
+
stdio: 'inherit',
|
|
812
|
+
windowsHide: true
|
|
789
813
|
});
|
|
790
814
|
child.once('error', error => {
|
|
791
815
|
console.error(`Failed to start LiveDesk client: ${error.message}`);
|
|
@@ -829,7 +853,7 @@ async function main() {
|
|
|
829
853
|
forcedRole: topLevel.forcedRole || process.env.LIVEDESK_FORCE_ROLE,
|
|
830
854
|
promptRole: topLevel.noRolePrompt ? undefined : promptForDeviceRole
|
|
831
855
|
});
|
|
832
|
-
|
|
856
|
+
if (!resolvedRole.role) {
|
|
833
857
|
if (resolvedRole.disabled) {
|
|
834
858
|
throw new Error(`LiveDesk device ${resolvedRole.deviceId} is disabled for this account.`);
|
|
835
859
|
}
|
|
@@ -837,6 +861,10 @@ async function main() {
|
|
|
837
861
|
}
|
|
838
862
|
}
|
|
839
863
|
|
|
864
|
+
if (process.env.LIVEDESK_ROLE_TRANSITION === '1') {
|
|
865
|
+
await waitForRoleTransitionParentExit(process.env.LIVEDESK_RESTART_WAIT_PID);
|
|
866
|
+
}
|
|
867
|
+
|
|
840
868
|
if (topLevel.noSingleInstance || process.env.LIVEDESK_DISABLE_SINGLE_INSTANCE === '1') {
|
|
841
869
|
console.warn('[LiveDesk] Single-instance lock disabled for this run.');
|
|
842
870
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livedesk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.300",
|
|
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.
|
|
35
|
+
"@livedesk/client": "0.1.153",
|
|
36
36
|
"@openai/codex-sdk": "0.144.5",
|
|
37
37
|
"cors": "^2.8.5",
|
|
38
38
|
"express": "^4.21.2",
|