@livedesk/client 0.1.134 → 0.1.136

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,81 +1,81 @@
1
- # LiveDesk Client
2
-
3
- Run a direct LiveDesk remote client from a controlled computer.
4
-
5
- ```powershell
6
- npx -y --prefer-online livedesk@latest client
7
- npx -y --prefer-online livedesk@latest client 3
8
- ```
9
-
10
- `@livedesk/client` is the internal direct package and remains available for
11
- advanced diagnostics. The public command above keeps Hub and client versions
12
- aligned.
13
-
14
- The default flow opens Google sign-in, waits for the active LiveDesk Hub
15
- published by the same account, and connects locally. If the Hub is not
16
- ready yet, the client keeps checking every 5 seconds instead of exiting. If a
17
- connected Hub is replaced, the launcher also leaves the stale endpoint and
18
- discovers the newly published Hub without another Google login. Omit the number
19
- for first-available placement, or pass `1` to `999` to pin this machine to a
20
- screen wall slot.
21
-
22
- On Windows, check **Start with Windows** on the connection page to reconnect this
23
- client automatically after reboot. The startup entry reuses the saved Google
24
- session and only opens the connection page again if sign-in is needed.
25
-
26
- On the Hub computer, open the LiveDesk dashboard and sign in first. The
27
- dashboard keeps its local Hub address and private pair token refreshed in the
28
- LiveDesk Supabase registry for the signed-in account.
29
-
30
- Supabase Auth must allow the CLI callback URL:
31
-
32
- ```text
33
- http://127.0.0.1:5198/callback
34
- ```
35
-
36
- If you use a custom port, run `npx -y --prefer-online livedesk@latest client --auth-port 5200` and add
37
- the matching callback URL to Supabase Auth redirect URLs.
38
-
39
- The client registers the device, sends status heartbeats, can return
40
- Hub-requested thumbnails, can stream a focused view-only live screen, and
41
- can receive safe task-only instructions. The C# RemoteFast engine also supports
42
- keyboard/mouse control on Windows, macOS, and Linux/X11, file transfer, and
43
- Windows system-audio loopback playback. macOS control requires Accessibility
44
- permission for the terminal app that started LiveDesk; screen streaming and
45
- system-audio capture require Screen Recording permission. LiveDesk checks these
46
- permissions without opening repeated system dialogs and prints the matching
47
- System Settings path when access is missing; after granting access, restart the
48
- client. When file transfer is enabled by the Hub, received files are saved
49
- to `Desktop/LiveDeskFiles` unless the Hub sets another destination folder.
50
-
51
- By default, the launcher uses the packaged C# RemoteFast engine when supported.
52
- It falls back to the Node engine for AI assist or when a compatible RemoteFast
53
- runtime is unavailable. Windows, macOS, and Linux all try RemoteFast first so
54
- the Hub can request the Mode 3 hardware video path when it is available.
55
- The launcher also includes a prebuilt ffmpeg executable through
56
- `@ffmpeg-installer/ffmpeg` and passes it to RemoteFast automatically. Set
57
- `LIVEDESK_FFMPEG` to override that path. If you need LGPL-only distribution,
58
- point `LIVEDESK_FFMPEG` at a verified LGPL ffmpeg build before shipping.
59
-
60
- Useful flags:
61
-
62
- ```powershell
63
- npx -y --prefer-online livedesk@latest client 3
64
- npx -y --prefer-online livedesk@latest client --no-thumbnail
65
- npx -y --prefer-online livedesk@latest client --no-live
66
- npx -y --prefer-online livedesk@latest client --no-audio
67
- npx -y --prefer-online livedesk@latest client --files-dir "D:\LiveDeskFiles"
68
- npx -y --prefer-online livedesk@latest client --engine node
69
- npx -y --prefer-online livedesk@latest client --engine fast --trace-frames
70
- npx -y --prefer-online livedesk@latest client --auth-port 5200
71
- npx -y --prefer-online livedesk@latest client --logout
72
- ```
73
-
74
- Frame pipeline roadmap:
75
-
76
- - Mode 1: `mode1-jpeg` - current test path using screen capture, resize, and JPEG binary frames.
77
- - Mode 2: `mode2-lzo` - cross-platform wall path using independent RGB565LE frames capped at 320x180 and compressed as LZO1X blocks. The wall defaults to 8 fps. macOS and Linux keep one persistent local capture helper per client process. Legacy `mode2-lz4` settings migrate to this mode.
78
- - Mode 3: `mode3-h264-hw` - OS-specific hardware H.264 path. Windows tries Media Foundation/NVENC/QSV/AMF, macOS prefers ScreenCaptureKit plus VideoToolbox, and Linux tries NVENC/VAAPI/QSV. macOS emits one startup key frame and then an approximately one-second GOP. The launcher uses bundled ffmpeg for fallback paths unless `LIVEDESK_FFMPEG` points to a custom binary. On macOS, set `LIVEDESK_FFMPEG_AVFOUNDATION_INPUT` only when the ScreenCaptureKit helper is unavailable and the AVFoundation fallback input is not `1:none`.
79
-
80
- Legacy mode names such as `remote-fast` and `remote-quality` are treated as
81
- Mode 1 aliases.
1
+ # LiveDesk Client
2
+
3
+ Run a direct LiveDesk remote client from a controlled computer.
4
+
5
+ ```powershell
6
+ npx -y --prefer-online livedesk@latest client
7
+ npx -y --prefer-online livedesk@latest client 3
8
+ ```
9
+
10
+ `@livedesk/client` is the internal direct package and remains available for
11
+ advanced diagnostics. The public command above keeps Hub and client versions
12
+ aligned.
13
+
14
+ The default flow opens Google sign-in, waits for the active LiveDesk Hub
15
+ published by the same account, and connects locally. If the Hub is not
16
+ ready yet, the client keeps checking every 5 seconds instead of exiting. If a
17
+ connected Hub is replaced, the launcher also leaves the stale endpoint and
18
+ discovers the newly published Hub without another Google login. Omit the number
19
+ for first-available placement, or pass `1` to `999` to pin this machine to a
20
+ screen wall slot.
21
+
22
+ On Windows, check **Start with Windows** on the connection page to reconnect this
23
+ client automatically after reboot. The startup entry reuses the saved Google
24
+ session and only opens the connection page again if sign-in is needed.
25
+
26
+ On the Hub computer, open the LiveDesk dashboard and sign in first. The
27
+ dashboard keeps its local Hub address and private pair token refreshed in the
28
+ LiveDesk Supabase registry for the signed-in account.
29
+
30
+ Supabase Auth must allow the CLI callback URL:
31
+
32
+ ```text
33
+ http://127.0.0.1:5198/callback
34
+ ```
35
+
36
+ If you use a custom port, run `npx -y --prefer-online livedesk@latest client --auth-port 5200` and add
37
+ the matching callback URL to Supabase Auth redirect URLs.
38
+
39
+ The client registers the device, sends status heartbeats, can return
40
+ Hub-requested thumbnails, can stream a focused view-only live screen, and
41
+ can receive safe task-only instructions. The C# RemoteFast engine also supports
42
+ keyboard/mouse control on Windows, macOS, and Linux/X11, file transfer, and
43
+ Windows system-audio loopback playback. macOS control requires Accessibility
44
+ permission for the terminal app that started LiveDesk; screen streaming and
45
+ system-audio capture require Screen Recording permission. LiveDesk checks these
46
+ permissions without opening repeated system dialogs and prints the matching
47
+ System Settings path when access is missing; after granting access, restart the
48
+ client. When file transfer is enabled by the Hub, received files are saved
49
+ to `Desktop/LiveDeskFiles` unless the Hub sets another destination folder.
50
+
51
+ By default, the launcher uses the packaged C# RemoteFast engine when supported.
52
+ It falls back to the Node engine for AI assist or when a compatible RemoteFast
53
+ runtime is unavailable. Windows, macOS, and Linux all try RemoteFast first so
54
+ the Hub can request the Mode 3 hardware video path when it is available.
55
+ The launcher also includes a prebuilt ffmpeg executable through
56
+ `@ffmpeg-installer/ffmpeg` and passes it to RemoteFast automatically. Set
57
+ `LIVEDESK_FFMPEG` to override that path. If you need LGPL-only distribution,
58
+ point `LIVEDESK_FFMPEG` at a verified LGPL ffmpeg build before shipping.
59
+
60
+ Useful flags:
61
+
62
+ ```powershell
63
+ npx -y --prefer-online livedesk@latest client 3
64
+ npx -y --prefer-online livedesk@latest client --no-thumbnail
65
+ npx -y --prefer-online livedesk@latest client --no-live
66
+ npx -y --prefer-online livedesk@latest client --no-audio
67
+ npx -y --prefer-online livedesk@latest client --files-dir "D:\LiveDeskFiles"
68
+ npx -y --prefer-online livedesk@latest client --engine node
69
+ npx -y --prefer-online livedesk@latest client --engine fast --trace-frames
70
+ npx -y --prefer-online livedesk@latest client --auth-port 5200
71
+ npx -y --prefer-online livedesk@latest client --logout
72
+ ```
73
+
74
+ Frame pipeline roadmap:
75
+
76
+ - Mode 1: `mode1-jpeg` - current test path using screen capture, resize, and JPEG binary frames.
77
+ - Mode 2: `mode2-lzo` - cross-platform wall path using independent RGB565LE frames capped at 320x180 and compressed as LZO1X blocks. The wall defaults to 8 fps. macOS and Linux keep one persistent local capture helper per client process. Legacy `mode2-lz4` settings migrate to this mode.
78
+ - Mode 3: `mode3-h264-hw` - OS-specific hardware H.264 path. Windows tries Media Foundation/NVENC/QSV/AMF, macOS prefers ScreenCaptureKit plus VideoToolbox, and Linux tries NVENC/VAAPI/QSV. macOS emits one startup key frame and then an approximately one-second GOP. The launcher uses bundled ffmpeg for fallback paths unless `LIVEDESK_FFMPEG` points to a custom binary. On macOS, set `LIVEDESK_FFMPEG_AVFOUNDATION_INPUT` only when the ScreenCaptureKit helper is unavailable and the AVFoundation fallback input is not `1:none`.
79
+
80
+ Legacy mode names such as `remote-fast` and `remote-quality` are treated as
81
+ Mode 1 aliases.
@@ -3,15 +3,24 @@
3
3
  import net from 'net';
4
4
  import os from 'os';
5
5
  import path from 'path';
6
- import crypto from 'crypto';
7
- import { promises as fs, statfsSync } from 'fs';
8
- import { spawn } from 'child_process';
9
-
10
- const AGENT_VERSION = '0.1.24-livedesk.1';
6
+ import crypto from 'crypto';
7
+ import { promises as fs, statfsSync } from 'fs';
8
+ import { spawn } from 'child_process';
9
+ import { createRequire } from 'node:module';
10
+
11
+ const require = createRequire(import.meta.url);
12
+ const AGENT_VERSION = (() => {
13
+ try {
14
+ return String(require('../package.json').version || '0.0.0');
15
+ } catch {
16
+ return '0.0.0';
17
+ }
18
+ })();
11
19
  const DEFAULT_MANAGER = '127.0.0.1:5197';
12
20
  const DEFAULT_HEARTBEAT_MS = 5000;
13
21
  const DEFAULT_RECONNECT_MS = 5000;
14
- const EXIT_INVALID_PAIR_TOKEN = 23;
22
+ const EXIT_INVALID_PAIR_TOKEN = 23;
23
+ const EXIT_CLIENT_UPDATE = 42;
15
24
  const DEFAULT_AI_MODEL = 'gpt-5.4-mini';
16
25
  const DEFAULT_LIVE_FPS = 30;
17
26
  const MAX_LIVE_FPS = 30;
@@ -1292,6 +1301,8 @@ function remotePolicyAllows(options, command) {
1292
1301
  ? ['allowFileTransfer']
1293
1302
  : command === 'audio.start'
1294
1303
  ? ['allowRemoteAudio']
1304
+ : command === 'livedesk.client-update'
1305
+ ? []
1295
1306
  : command === 'agent.task' || NODE_AGENT_OPERATIONS.has(command)
1296
1307
  ? ['allowAgent']
1297
1308
  : [];
@@ -1299,6 +1310,42 @@ function remotePolicyAllows(options, command) {
1299
1310
  return denied ? { ok: false, error: `${denied}-blocked-by-settings` } : { ok: true };
1300
1311
  }
1301
1312
 
1313
+ function scheduleClientUpdate(options, payload = {}) {
1314
+ const parentPid = Number(process.env.LIVEDESK_CLIENT_PARENT_PID || process.ppid);
1315
+ if (!Number.isInteger(parentPid) || parentPid <= 1) {
1316
+ throw new Error('LiveDesk client launcher process id is unavailable.');
1317
+ }
1318
+ const command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1319
+ const child = spawn(command, [
1320
+ '-y',
1321
+ '--prefer-online',
1322
+ 'livedesk@latest',
1323
+ 'client',
1324
+ '--no-login',
1325
+ '--update-wait-pid',
1326
+ String(parentPid)
1327
+ ], {
1328
+ env: {
1329
+ ...process.env,
1330
+ LIVEDESK_CLIENT_UPDATE_TARGET_VERSION: String(payload.targetVersion || process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION || '')
1331
+ },
1332
+ detached: true,
1333
+ stdio: 'ignore',
1334
+ windowsHide: true
1335
+ });
1336
+ child.once('error', error => {
1337
+ console.error(`LiveDesk client updater failed to start: ${error.message}`);
1338
+ });
1339
+ child.unref();
1340
+ return {
1341
+ ok: true,
1342
+ status: 'update-scheduled',
1343
+ targetVersion: String(payload.targetVersion || ''),
1344
+ parentPid,
1345
+ restartAfterMs: 500
1346
+ };
1347
+ }
1348
+
1302
1349
  async function handleRemoteCommand(socket, options, message, nextFrameSeq, activeStreams) {
1303
1350
  const command = String(message.command || '');
1304
1351
  if (command === 'ping') {
@@ -1323,6 +1370,26 @@ async function handleRemoteCommand(socket, options, message, nextFrameSeq, activ
1323
1370
  });
1324
1371
  return;
1325
1372
  }
1373
+
1374
+ if (command === 'livedesk.client-update') {
1375
+ try {
1376
+ const result = scheduleClientUpdate(options, message.payload || {});
1377
+ writeJsonLine(socket, {
1378
+ type: 'command.result',
1379
+ commandId: message.commandId,
1380
+ result
1381
+ });
1382
+ setTimeout(() => process.exit(EXIT_CLIENT_UPDATE), 500);
1383
+ } catch (error) {
1384
+ writeJsonLine(socket, {
1385
+ type: 'command.result',
1386
+ commandId: message.commandId,
1387
+ error: error?.message || String(error),
1388
+ result: { ok: false, status: 'failed', error: error?.message || String(error) }
1389
+ });
1390
+ }
1391
+ return;
1392
+ }
1326
1393
 
1327
1394
  if (NODE_AGENT_OPERATIONS.has(command)) {
1328
1395
  if (!options.taskEnabled) {
@@ -1657,7 +1724,8 @@ function connectOnce(options, deviceId) {
1657
1724
  remoteFiles: true,
1658
1725
  fileTransferMaxBytes: MAX_FILE_TRANSFER_BYTES,
1659
1726
  computerAgent: options.taskEnabled,
1660
- taskDispatch: options.taskEnabled,
1727
+ taskDispatch: options.taskEnabled,
1728
+ clientUpdate: true,
1661
1729
  agentApproval: options.taskEnabled,
1662
1730
  agentAudit: options.taskEnabled,
1663
1731
  agentTools: [...NODE_AGENT_OPERATIONS],