herdr-remote-relay 0.3.21 → 0.3.23

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.
@@ -65,6 +65,10 @@ export interface HostInfo {
65
65
  connectedDeviceCount?: number;
66
66
  /** Devices holding a valid pairing token for this host, online or not. */
67
67
  pairedDeviceCount?: number;
68
+ /** The herdr-remote release the host runs; null when it is too old to say. */
69
+ version?: string | null;
70
+ /** A newer release the host found on npm, if it found one. */
71
+ latestVersion?: string | null;
68
72
  }
69
73
  export interface PtyInfo {
70
74
  id: string;
@@ -92,6 +92,8 @@ export interface ServerReadyMessage {
92
92
  terminalFont?: HostTerminalFont | null;
93
93
  /** How many windows share this terminal, this one included. */
94
94
  clientCount?: number;
95
+ /** The workstation's herdr-remote release; null when it is too old to say. */
96
+ hostVersion?: string | null;
95
97
  }
96
98
  export interface ServerPairedMessage {
97
99
  type: 'paired';
@@ -129,6 +131,8 @@ export interface ServerSessionRestartedMessage {
129
131
  adminTerminalSupported?: boolean;
130
132
  terminalPalette?: HostTerminalPalette | null;
131
133
  terminalFont?: HostTerminalFont | null;
134
+ /** As in `ready`: the host may have come back on another release. */
135
+ hostVersion?: string | null;
132
136
  }
133
137
  export interface ServerExitMessage {
134
138
  type: 'exit';
@@ -231,6 +235,8 @@ export interface HostHelloMessage {
231
235
  platform?: string;
232
236
  shellProfile?: HostShellProfile;
233
237
  arch?: string;
238
+ /** The herdr-remote release the host runs. Connectors before 0.2.31 leave it out. */
239
+ version?: string;
234
240
  terminalPalette?: HostTerminalPalette | null;
235
241
  terminalFont?: HostTerminalFont | null;
236
242
  capabilities?: string[];
@@ -147,6 +147,7 @@ export function handleClientConnection(relay, ws, req) {
147
147
  terminalPalette: host.terminalPalette || null,
148
148
  terminalFont: host.terminalFont || null,
149
149
  clientCount: host.clients.size,
150
+ hostVersion: host.version,
150
151
  });
151
152
  if (host.agentStatus)
152
153
  jsonSend(ws, host.agentStatus);
@@ -4,6 +4,8 @@ import type { RelayContext, RelayHost } from './types.js';
4
4
  type Unchecked<T> = {
5
5
  [K in keyof T]?: unknown;
6
6
  };
7
+ /** `value` if it is a release version, else null: it ends up as text in browsers. */
8
+ export declare function releaseVersion(value: unknown): string | null;
7
9
  /**
8
10
  * Pass on what the workstation's agents are doing.
9
11
  *
@@ -6,6 +6,10 @@ import { text } from './sockets.js';
6
6
  import { broadcastToClients } from './transport.js';
7
7
  /** A release version as npm writes it; anything else is not forwarded. */
8
8
  const RELEASE_VERSION = /^\d{1,6}\.\d{1,6}\.\d{1,6}(?:-[0-9A-Za-z.-]{1,32})?$/;
9
+ /** `value` if it is a release version, else null: it ends up as text in browsers. */
10
+ export function releaseVersion(value) {
11
+ return typeof value === 'string' && RELEASE_VERSION.test(value) ? value : null;
12
+ }
9
13
  /** Matches the host's own cap; the relay re-applies it rather than trusting it. */
10
14
  const MAX_AGENT_STATUS_ENTRIES = 16;
11
15
  /**
@@ -55,15 +59,14 @@ export function broadcastAgentStatus(relay, host, message) {
55
59
  * browser, and the host is not the relay's to trust.
56
60
  */
57
61
  export function broadcastUpdateStatus(relay, host, message) {
58
- const version = (value) => typeof value === 'string' && RELEASE_VERSION.test(value) ? value : null;
59
- const current = version(message.current);
60
- const latest = version(message.latest);
62
+ const current = releaseVersion(message.current);
63
+ const latest = releaseVersion(message.latest);
61
64
  if (!current || !latest)
62
65
  return;
63
66
  const payload = {
64
67
  type: 'update_status',
65
68
  current,
66
- installed: version(message.installed) || current,
69
+ installed: releaseVersion(message.installed) || current,
67
70
  latest,
68
71
  updateAvailable: message.updateAvailable === true,
69
72
  restartPending: message.restartPending === true,
@@ -3,7 +3,7 @@
3
3
  import os from 'node:os';
4
4
  import { CAPABILITY, PROTOCOL_VERSION, sanitizeTerminalFont, sanitizeTerminalPalette, unpackStreamFrame, } from '../protocol/index.js';
5
5
  import { forwardFontChunk, forwardFontSubset, settleFontChunk, settleFontSubset, } from './font-proxy.js';
6
- import { broadcastAgentStatus, broadcastTerminalFont, broadcastUpdateStatus, } from './host-broadcasts.js';
6
+ import { broadcastAgentStatus, broadcastTerminalFont, broadcastUpdateStatus, releaseVersion, } from './host-broadcasts.js';
7
7
  import { allowHostHandshake } from './requests.js';
8
8
  import { beginHostReconnect, canHandoffHost, detachClient, detachHost, releaseSession, startSession, } from './sessions.js';
9
9
  import { closeSocket, isOpen, jsonSend, parseJson, randomId, rejectHandshake } from './sockets.js';
@@ -27,6 +27,7 @@ function createHostRecord(message, ws, pending, clients = new Set()) {
27
27
  agentStatus: null,
28
28
  /** Whether the workstation's herdr-remote is behind; replayed the same way. */
29
29
  updateStatus: null,
30
+ version: releaseVersion(message.version),
30
31
  lastSeenAt: Date.now(),
31
32
  clients,
32
33
  controllerId: null,
@@ -71,6 +71,7 @@ export function startSession(relay, host, client, { restarted = false } = {}) {
71
71
  adminTerminalSupported: host.adminTabsAvailable,
72
72
  terminalPalette: host.terminalPalette || null,
73
73
  terminalFont: host.terminalFont || null,
74
+ hostVersion: host.version,
74
75
  });
75
76
  }
76
77
  }
@@ -43,6 +43,10 @@ export function statusSnapshot(relay, { sample = true, includeDevices = false, s
43
43
  .map((id) => relay.clients.get(id))
44
44
  .filter((client) => Boolean(client))),
45
45
  pairedDeviceCount: pairedPerHost.get(host.id) || 0,
46
+ // A connector too old to name itself in its hello may still have said
47
+ // which release it runs when it checked npm.
48
+ version: host.version ?? host.updateStatus?.current ?? null,
49
+ latestVersion: host.updateStatus?.updateAvailable ? host.updateStatus.latest : null,
46
50
  load: host.load,
47
51
  }));
48
52
  // The workstation counts one PTY per stream and cannot know how many
@@ -35,6 +35,8 @@ export interface RelayHost {
35
35
  agentStatus: ServerAgentStatusMessage | null;
36
36
  /** Whether the workstation's herdr-remote is behind; replayed the same way. */
37
37
  updateStatus: ServerUpdateStatusMessage | null;
38
+ /** The herdr-remote release the host runs; null when its hello did not say. */
39
+ version: string | null;
38
40
  lastSeenAt: number;
39
41
  /** Ids of the windows attached to this host. */
40
42
  clients: Set<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-remote-relay",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "Standalone relay server and web terminal for Herdr Remote",
5
5
  "license": "MIT",
6
6
  "type": "module",