@livedesk/client 0.1.13 → 0.1.15

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
@@ -9,7 +9,7 @@ npx @livedesk/client 3
9
9
 
10
10
  The default flow opens Google sign-in, waits for the active LiveDesk manager
11
11
  published by the same account, and connects locally. If the manager is not
12
- ready yet, the client keeps checking every second instead of exiting. Omit the
12
+ ready yet, the client keeps checking every 5 seconds instead of exiting. Omit the
13
13
  number for first-available placement, or pass `1` to `999` to pin this machine
14
14
  to a screen wall slot.
15
15
 
@@ -4,7 +4,7 @@ import net from 'net';
4
4
  import os from 'os';
5
5
  import path from 'path';
6
6
  import crypto from 'crypto';
7
- import { promises as fs } from 'fs';
7
+ import { promises as fs, statfsSync } from 'fs';
8
8
 
9
9
  const AGENT_VERSION = '0.1.15-livedesk.1';
10
10
  const DEFAULT_MANAGER = '127.0.0.1:5197';
@@ -230,17 +230,60 @@ async function getDeviceId(explicitDeviceId = '') {
230
230
  return deviceId;
231
231
  }
232
232
 
233
+ function getRootDiskStatus() {
234
+ const root = path.parse(os.homedir()).root || '/';
235
+ try {
236
+ const stats = statfsSync(root);
237
+ const totalBytes = Number(stats.blocks) * Number(stats.bsize);
238
+ const freeBytes = Number(stats.bavail) * Number(stats.bsize);
239
+ return {
240
+ root,
241
+ totalBytes,
242
+ freeBytes,
243
+ usedRatio: totalBytes > 0 ? Number(((totalBytes - freeBytes) / totalBytes).toFixed(4)) : 0
244
+ };
245
+ } catch {
246
+ return { root, totalBytes: 0, freeBytes: 0, usedRatio: 0 };
247
+ }
248
+ }
249
+
233
250
  function getStatus(options = {}) {
234
251
  const totalMem = os.totalmem();
235
252
  const freeMem = os.freemem();
253
+ const cpus = os.cpus();
254
+ const loadavg = os.loadavg();
255
+ const cpuCores = Math.max(1, cpus.length || os.availableParallelism?.() || 1);
256
+ const cpuUsageRatio = loadavg[0] > 0
257
+ ? Number(Math.min(1, loadavg[0] / cpuCores).toFixed(4))
258
+ : 0;
259
+ const usedMemRatio = totalMem > 0 ? Number(((totalMem - freeMem) / totalMem).toFixed(4)) : 0;
236
260
  const status = {
237
261
  uptimeSec: Math.round(os.uptime()),
238
- loadavg: os.loadavg(),
262
+ loadavg,
239
263
  totalMem,
240
264
  freeMem,
241
- usedMemRatio: totalMem > 0 ? Number(((totalMem - freeMem) / totalMem).toFixed(4)) : 0,
265
+ usedMemRatio,
242
266
  platform: os.platform(),
243
267
  release: os.release(),
268
+ role: options.aiEnabled ? 'Agent worker' : options.taskEnabled ? 'Task worker' : 'Local machine',
269
+ cpu: {
270
+ cores: cpuCores,
271
+ model: cpus[0]?.model || '',
272
+ speedMHz: cpus[0]?.speed || 0,
273
+ usageRatio: cpuUsageRatio,
274
+ load1: loadavg[0] || 0
275
+ },
276
+ memory: {
277
+ totalBytes: totalMem,
278
+ freeBytes: freeMem,
279
+ usedRatio: usedMemRatio
280
+ },
281
+ disk: getRootDiskStatus(),
282
+ workload: {
283
+ role: options.aiEnabled ? 'Agent worker' : options.taskEnabled ? 'Task worker' : 'Local machine',
284
+ status: 'idle',
285
+ title: 'idle'
286
+ },
244
287
  timestamp: new Date().toISOString()
245
288
  };
246
289
  if (options.slotNumber) {
@@ -32,7 +32,7 @@ Usage:
32
32
  Default flow:
33
33
  Opens Google sign-in, waits for the signed-in manager, and connects locally.
34
34
  Omit the number for first-available placement, or pass 1-999 to pin a slot.
35
- If no manager is active yet, the client keeps checking every second.
35
+ If no manager is active yet, the client keeps checking every 5 seconds.
36
36
 
37
37
  Options:
38
38
  --slot <number> Screen wall slot number for this computer.
@@ -548,17 +548,18 @@ async function resolveManagerFromSupabase(supabase, options = {}) {
548
548
  }
549
549
 
550
550
  async function waitForManagerFromSupabase(supabase, options = {}) {
551
- const intervalMs = Math.max(250, Number(options.intervalMs || 1000));
551
+ const intervalMs = Math.max(1000, Number(options.intervalMs || 5000));
552
+ const intervalSeconds = Math.max(1, Math.round(intervalMs / 1000));
552
553
  let attempts = 0;
553
554
  let lastMessage = '';
554
- console.log('Waiting for a LiveDesk manager. This client will keep trying every 1s.');
555
+ console.log(`Waiting for a LiveDesk manager. This client will keep trying every ${intervalSeconds}s.`);
555
556
  while (true) {
556
557
  attempts += 1;
557
558
  try {
558
559
  return await resolveManagerFromSupabase(supabase, { requireReachable: true });
559
560
  } catch (err) {
560
561
  const message = err instanceof Error ? err.message : String(err);
561
- if (message !== lastMessage || attempts === 1 || attempts % 10 === 0) {
562
+ if (message !== lastMessage || attempts === 1 || attempts % 6 === 0) {
562
563
  const suffix = attempts === 1 ? '' : ` attempt ${attempts}`;
563
564
  console.log(`Still waiting for LiveDesk manager${suffix}: ${message}`);
564
565
  lastMessage = message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {