herdr-remote-relay 0.3.18 → 0.3.19

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.
@@ -9,13 +9,18 @@ export declare const CAPABILITY: {
9
9
  readonly idleHeartbeat: "idle_heartbeat";
10
10
  /** The host routes output by 16-bit stream index (v2 frames). */
11
11
  readonly binaryFrameV2: "binary_frame_v2";
12
+ /** The host can route elevated Windows PTYs through its local broker. */
13
+ readonly adminSessions: "admin_sessions";
12
14
  };
13
15
  export type ClientRole = 'controller' | 'viewer';
16
+ export type HostShellProfile = 'posix' | 'cmd' | 'powershell' | 'git-bash';
14
17
  export interface ClientHelloMessage {
15
18
  type: 'hello';
16
19
  protocol: 1;
17
20
  token?: string;
18
21
  pairCode?: string;
22
+ /** Open this window's PTY through the host's pre-authorized admin broker. */
23
+ adminTerminal?: boolean;
19
24
  clientId: string;
20
25
  cols: number;
21
26
  rows: number;
@@ -73,6 +78,10 @@ export interface ServerReadyMessage {
73
78
  controllerId?: string | null;
74
79
  hostId?: string;
75
80
  hostname?: string;
81
+ platform?: string;
82
+ shellProfile?: HostShellProfile;
83
+ /** The relay and Windows host both understand administrator-terminal requests. */
84
+ adminTerminalSupported?: boolean;
76
85
  clientId?: string;
77
86
  terminalPalette?: HostTerminalPalette | null;
78
87
  terminalFont?: HostTerminalFont | null;
@@ -110,6 +119,9 @@ export interface ServerSessionRestartedMessage {
110
119
  cols?: number;
111
120
  rows?: number;
112
121
  hostname?: string;
122
+ platform?: string;
123
+ shellProfile?: HostShellProfile;
124
+ adminTerminalSupported?: boolean;
113
125
  terminalPalette?: HostTerminalPalette | null;
114
126
  terminalFont?: HostTerminalFont | null;
115
127
  }
@@ -210,6 +222,7 @@ export interface HostHelloMessage {
210
222
  password?: string | null;
211
223
  hostname?: string;
212
224
  platform?: string;
225
+ shellProfile?: HostShellProfile;
213
226
  arch?: string;
214
227
  terminalPalette?: HostTerminalPalette | null;
215
228
  terminalFont?: HostTerminalFont | null;
@@ -278,6 +291,7 @@ export interface RelaySessionStartMessage extends StreamAddressed {
278
291
  cols: number;
279
292
  rows: number;
280
293
  role: ClientRole;
294
+ adminTerminal?: boolean;
281
295
  /** Present when the host negotiated v2 frames and an index was free. */
282
296
  streamIndex?: number;
283
297
  }
@@ -15,4 +15,6 @@ export const CAPABILITY = {
15
15
  idleHeartbeat: 'idle_heartbeat',
16
16
  /** The host routes output by 16-bit stream index (v2 frames). */
17
17
  binaryFrameV2: 'binary_frame_v2',
18
+ /** The host can route elevated Windows PTYs through its local broker. */
19
+ adminSessions: 'admin_sessions',
18
20
  };
@@ -86,6 +86,7 @@ export function handleClientConnection(relay, ws, req) {
86
86
  // Stable per browser profile; used to recognise a reconnect from the
87
87
  // same browser rather than a genuinely separate viewer.
88
88
  browserClientId: typeof message.clientId === 'string' ? message.clientId.slice(0, 128) : null,
89
+ adminTerminal: message.adminTerminal === true,
89
90
  handoffCapable: Array.isArray(message.capabilities) &&
90
91
  message.capabilities.includes(CAPABILITY.hostHandoff),
91
92
  session: null,
@@ -136,6 +137,9 @@ export function handleClientConnection(relay, ws, req) {
136
137
  controllerId: null,
137
138
  hostId: host.id,
138
139
  hostname: host.hostname,
140
+ platform: host.platform,
141
+ ...(host.shellProfile ? { shellProfile: host.shellProfile } : {}),
142
+ adminTerminalSupported: host.adminSessionsAvailable,
139
143
  clientId: client.id,
140
144
  // Delivered with `ready`, before the first PTY byte, so the terminal
141
145
  // is painted in the host's colors from its very first frame.
@@ -15,6 +15,8 @@ function createHostRecord(message, ws, pending, clients = new Set()) {
15
15
  ws,
16
16
  hostname: typeof message.hostname === 'string' ? message.hostname.slice(0, 128) : os.hostname(),
17
17
  platform: typeof message.platform === 'string' ? message.platform.slice(0, 32) : process.platform,
18
+ ...(message.shellProfile === 'git-bash' ? { shellProfile: message.shellProfile } : {}),
19
+ adminSessionsAvailable: capabilities.includes(CAPABILITY.adminSessions),
18
20
  arch: typeof message.arch === 'string' ? message.arch.slice(0, 32) : process.arch,
19
21
  connectedAt: new Date(pending.connectedAt).toISOString(),
20
22
  connectedAtMs: pending.connectedAt,
@@ -34,6 +34,14 @@ export function releaseSession(relay, host, client) {
34
34
  export function startSession(relay, host, client, { restarted = false } = {}) {
35
35
  if (!client || !isOpen(host.ws))
36
36
  return;
37
+ if (client.adminTerminal && !host.adminSessionsAvailable) {
38
+ jsonSend(client.ws, {
39
+ type: 'error',
40
+ code: 'admin_terminal_unsupported',
41
+ message: 'Update the host connector to support administrator terminals.',
42
+ });
43
+ return;
44
+ }
37
45
  const streamId = randomId('session');
38
46
  let streamIndex = null;
39
47
  if (host.binaryFrameV2) {
@@ -57,6 +65,7 @@ export function startSession(relay, host, client, { restarted = false } = {}) {
57
65
  cols: Math.max(MIN_SESSION_COLS, client.cols),
58
66
  rows: Math.max(MIN_SESSION_ROWS, client.rows),
59
67
  role: 'controller',
68
+ ...(client.adminTerminal ? { adminTerminal: true } : {}),
60
69
  ...(streamIndex !== null ? { streamIndex } : {}),
61
70
  });
62
71
  if (restarted) {
@@ -66,6 +75,9 @@ export function startSession(relay, host, client, { restarted = false } = {}) {
66
75
  cols: client.cols,
67
76
  rows: client.rows,
68
77
  hostname: host.hostname,
78
+ platform: host.platform,
79
+ ...(host.shellProfile ? { shellProfile: host.shellProfile } : {}),
80
+ adminTerminalSupported: host.adminSessionsAvailable,
69
81
  terminalPalette: host.terminalPalette || null,
70
82
  terminalFont: host.terminalFont || null,
71
83
  });
@@ -1,7 +1,7 @@
1
1
  import type { WebSocket } from 'ws';
2
2
  import type { AuthStore } from '../auth-store.js';
3
3
  import type { RelayMetrics } from '../metrics.js';
4
- import type { ClientRole, HostPtySummary, ServerAgentStatusMessage, ServerUpdateStatusMessage } from '../protocol/messages.js';
4
+ import type { ClientRole, HostPtySummary, ServerAgentStatusMessage, ServerUpdateStatusMessage, HostShellProfile } from '../protocol/messages.js';
5
5
  import type { HostTerminalFont, HostTerminalPalette } from '../protocol/terminal.js';
6
6
  import type { RelayConfig } from '../relay-config.js';
7
7
  /** A WebSocket plus the liveness flag the heartbeat keeps on it. */
@@ -23,6 +23,8 @@ export interface RelayHost {
23
23
  ws: RelaySocket | null;
24
24
  hostname: string;
25
25
  platform: string;
26
+ shellProfile?: HostShellProfile;
27
+ adminSessionsAvailable: boolean;
26
28
  arch: string;
27
29
  connectedAt: string;
28
30
  connectedAtMs: number;
@@ -57,6 +59,7 @@ export interface RelayClient {
57
59
  deviceId: string;
58
60
  /** Stable per browser profile, supplied by the browser itself. */
59
61
  browserClientId: string | null;
62
+ adminTerminal: boolean;
60
63
  handoffCapable: boolean;
61
64
  session: ClientSession | null;
62
65
  role: ClientRole;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-remote-relay",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "description": "Standalone relay server and web terminal for Herdr Remote",
5
5
  "license": "MIT",
6
6
  "type": "module",