herdr-remote 0.2.32 → 0.2.33
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/dist/connector/agent-watch.js +16 -3
- package/dist/connector/herdr-prefix-keys.js +28 -0
- package/dist/connector/host-connector.js +6 -20
- package/dist/connector/host-hello.js +32 -0
- package/dist/herdr-api.js +7 -1
- package/dist/herdr-command.js +7 -2
- package/dist/i18n/en.js +1 -1
- package/dist/i18n/zh.js +1 -1
- package/dist/pty-session.js +27 -2
- package/dist/socket-discovery.js +16 -6
- package/dist/terminal-font/formats.js +26 -6
- package/dist/terminal-font/terminals.js +19 -3
- package/herdr-plugin.toml +2 -2
- package/package.json +1 -1
|
@@ -19,7 +19,10 @@ const AGENT_STATUS_SUBSCRIPTIONS = [
|
|
|
19
19
|
*
|
|
20
20
|
* A long-lived subscription provides fast refreshes on pane and workspace
|
|
21
21
|
* focus changes; the five-second poll still repairs missed events and a
|
|
22
|
-
* restarted Herdr server. Both paths only read the side-channel snapshot
|
|
22
|
+
* restarted Herdr server. Both paths only read the side-channel snapshot, and
|
|
23
|
+
* events only invalidate it: Herdr's snapshots and events share no sequence,
|
|
24
|
+
* so each (re)started subscription and each event mid-read asks for a fresh
|
|
25
|
+
* read rather than patching the last one.
|
|
23
26
|
*/
|
|
24
27
|
export class AgentWatch {
|
|
25
28
|
socketPath;
|
|
@@ -30,6 +33,7 @@ export class AgentWatch {
|
|
|
30
33
|
debounceTimer = null;
|
|
31
34
|
subscription = null;
|
|
32
35
|
pending = false;
|
|
36
|
+
stale = false;
|
|
33
37
|
lastSummary = null;
|
|
34
38
|
constructor(options, send) {
|
|
35
39
|
this.socketPath = options.socketPath;
|
|
@@ -43,7 +47,7 @@ export class AgentWatch {
|
|
|
43
47
|
this.pollTimer = setInterval(() => this.read(), AGENT_STATUS_POLL_MS);
|
|
44
48
|
this.pollTimer.unref?.();
|
|
45
49
|
try {
|
|
46
|
-
this.subscription = this.subscribe(this.socketPath, AGENT_STATUS_SUBSCRIPTIONS, () => this.scheduleRead());
|
|
50
|
+
this.subscription = this.subscribe(this.socketPath, AGENT_STATUS_SUBSCRIPTIONS, () => this.scheduleRead(), { onStarted: () => this.scheduleRead() });
|
|
47
51
|
}
|
|
48
52
|
catch {
|
|
49
53
|
// A missing or restarting Herdr server leaves the regular poll in place.
|
|
@@ -63,6 +67,7 @@ export class AgentWatch {
|
|
|
63
67
|
this.subscription.close();
|
|
64
68
|
this.subscription = null;
|
|
65
69
|
}
|
|
70
|
+
this.stale = false;
|
|
66
71
|
this.lastSummary = null;
|
|
67
72
|
}
|
|
68
73
|
scheduleRead() {
|
|
@@ -84,9 +89,14 @@ export class AgentWatch {
|
|
|
84
89
|
* Herdr's server not running is an ordinary state, not news.
|
|
85
90
|
*/
|
|
86
91
|
async read() {
|
|
87
|
-
if (
|
|
92
|
+
if (!this.pollTimer)
|
|
93
|
+
return;
|
|
94
|
+
if (this.pending) {
|
|
95
|
+
this.stale = true;
|
|
88
96
|
return;
|
|
97
|
+
}
|
|
89
98
|
this.pending = true;
|
|
99
|
+
this.stale = false;
|
|
90
100
|
let snapshot;
|
|
91
101
|
try {
|
|
92
102
|
const result = await this.request(this.socketPath, 'session.snapshot', {});
|
|
@@ -97,6 +107,9 @@ export class AgentWatch {
|
|
|
97
107
|
}
|
|
98
108
|
finally {
|
|
99
109
|
this.pending = false;
|
|
110
|
+
// Something changed while this answer was in flight; it may predate it.
|
|
111
|
+
if (this.stale)
|
|
112
|
+
this.scheduleRead();
|
|
100
113
|
}
|
|
101
114
|
// Stopped while the answer was in flight; the browser it was for is gone.
|
|
102
115
|
if (!this.pollTimer)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The keys that put this workstation's Herdr into prefix mode. A browser has
|
|
2
|
+
// to tell a Herdr command from typed text, and only Herdr's own config file
|
|
3
|
+
// says which key starts one, so the host reads it and reports it in its hello.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { sanitizeHerdrPrefixKeys } from 'herdr-remote-relay/protocol';
|
|
6
|
+
import { herdrConfigPath } from '../socket-discovery.js';
|
|
7
|
+
import { parseTomlSubset } from '../terminal-font/formats.js';
|
|
8
|
+
/** What Herdr uses when `keys.prefix` is absent or names nothing it can read. */
|
|
9
|
+
const DEFAULT_PREFIX_KEYS = ['ctrl+b'];
|
|
10
|
+
/**
|
|
11
|
+
* `keys.prefix` from the Herdr config the connector's Herdr reads: one key or
|
|
12
|
+
* a list, each a combo like `ctrl+space`. Always at least one key, because
|
|
13
|
+
* Herdr itself falls back to `ctrl+b` when the file, the key or every entry
|
|
14
|
+
* is unusable.
|
|
15
|
+
*/
|
|
16
|
+
export function readHerdrPrefixKeys(env = process.env, platform = process.platform) {
|
|
17
|
+
let text;
|
|
18
|
+
try {
|
|
19
|
+
text = fs.readFileSync(herdrConfigPath(env, platform), 'utf8');
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// No readable config file means Herdr runs on its defaults.
|
|
23
|
+
return [...DEFAULT_PREFIX_KEYS];
|
|
24
|
+
}
|
|
25
|
+
const configured = parseTomlSubset(text)['keys.prefix'];
|
|
26
|
+
const entries = typeof configured === 'string' ? [configured] : configured;
|
|
27
|
+
return sanitizeHerdrPrefixKeys(entries) ?? [...DEFAULT_PREFIX_KEYS];
|
|
28
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// message to the part of the connector that owns it.
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import {
|
|
6
|
+
import { unpackStreamFrame } from 'herdr-remote-relay/protocol';
|
|
7
7
|
import { WebSocket } from 'ws';
|
|
8
8
|
import { loadConfig } from '../config.js';
|
|
9
9
|
import { EXIT_AUTH_FAILED, EXIT_REPLACED } from '../exit-codes.js';
|
|
@@ -16,6 +16,7 @@ import { randomToken } from 'herdr-remote-relay/state';
|
|
|
16
16
|
import { openAdminTabFor } from './admin-tab.js';
|
|
17
17
|
import { AgentWatch } from './agent-watch.js';
|
|
18
18
|
import { FontServer } from './font-server.js';
|
|
19
|
+
import { hostHello } from './host-hello.js';
|
|
19
20
|
import { acquireHostLock, releaseHostLock } from './lock.js';
|
|
20
21
|
import { Sessions } from './sessions.js';
|
|
21
22
|
import { UpdateReport } from './update-report.js';
|
|
@@ -178,29 +179,14 @@ export class HostConnector {
|
|
|
178
179
|
}
|
|
179
180
|
ws.isAlive = true;
|
|
180
181
|
this.authFailure = false;
|
|
181
|
-
sendJson(ws, {
|
|
182
|
-
type: 'host_hello',
|
|
183
|
-
protocol: PROTOCOL_VERSION,
|
|
182
|
+
sendJson(ws, hostHello({
|
|
184
183
|
hostId: this.hostId,
|
|
185
184
|
token: this.hostToken,
|
|
186
|
-
password: this.relayPassword
|
|
187
|
-
hostname: os.hostname(),
|
|
188
|
-
platform: process.platform,
|
|
189
|
-
...(process.platform === 'win32' &&
|
|
190
|
-
(process.env.MSYSTEM || /(?:^|[\\/])(?:bash|sh)(?:\.exe)?$/i.test(process.env.SHELL || ''))
|
|
191
|
-
? { shellProfile: 'git-bash' }
|
|
192
|
-
: {}),
|
|
193
|
-
arch: process.arch,
|
|
185
|
+
password: this.relayPassword,
|
|
194
186
|
version: this.updates.runningVersion,
|
|
195
|
-
terminalPalette: this.terminalPalette
|
|
187
|
+
terminalPalette: this.terminalPalette,
|
|
196
188
|
terminalFont: this.font.publicFont(),
|
|
197
|
-
|
|
198
|
-
CAPABILITY.hostHandoff,
|
|
199
|
-
CAPABILITY.idleHeartbeat,
|
|
200
|
-
CAPABILITY.binaryFrameV2,
|
|
201
|
-
...(process.platform === 'win32' ? [CAPABILITY.adminTabs] : []),
|
|
202
|
-
],
|
|
203
|
-
});
|
|
189
|
+
}));
|
|
204
190
|
// The relay sends host_ready with the current browser count. No business
|
|
205
191
|
// heartbeat is started until that message says somebody is watching.
|
|
206
192
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The first message a workstation sends the relay: who it is, what it runs,
|
|
2
|
+
// and the facts about its terminal and Herdr that a browser cannot learn itself.
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import { CAPABILITY, PROTOCOL_VERSION } from 'herdr-remote-relay/protocol';
|
|
5
|
+
import { readHerdrPrefixKeys } from './herdr-prefix-keys.js';
|
|
6
|
+
/** Built afresh for each connection, so a reconnect reports the config as it is now. */
|
|
7
|
+
export function hostHello(identity) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'host_hello',
|
|
10
|
+
protocol: PROTOCOL_VERSION,
|
|
11
|
+
hostId: identity.hostId,
|
|
12
|
+
token: identity.token,
|
|
13
|
+
password: identity.password || null,
|
|
14
|
+
hostname: os.hostname(),
|
|
15
|
+
platform: process.platform,
|
|
16
|
+
...(process.platform === 'win32' &&
|
|
17
|
+
(process.env.MSYSTEM || /(?:^|[\\/])(?:bash|sh)(?:\.exe)?$/i.test(process.env.SHELL || ''))
|
|
18
|
+
? { shellProfile: 'git-bash' }
|
|
19
|
+
: {}),
|
|
20
|
+
arch: process.arch,
|
|
21
|
+
version: identity.version,
|
|
22
|
+
terminalPalette: identity.terminalPalette || null,
|
|
23
|
+
terminalFont: identity.terminalFont,
|
|
24
|
+
herdrPrefixKeys: readHerdrPrefixKeys(),
|
|
25
|
+
capabilities: [
|
|
26
|
+
CAPABILITY.hostHandoff,
|
|
27
|
+
CAPABILITY.idleHeartbeat,
|
|
28
|
+
CAPABILITY.binaryFrameV2,
|
|
29
|
+
...(process.platform === 'win32' ? [CAPABILITY.adminTabs] : []),
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
package/dist/herdr-api.js
CHANGED
|
@@ -122,9 +122,14 @@ function requestHerdr(socketPath, method, params = {}, options = {}) {
|
|
|
122
122
|
* They share a socket, but are separate NDJSON messages. A subscription never
|
|
123
123
|
* starts or writes to a terminal, so an unavailable socket is only a reason to
|
|
124
124
|
* retry this side channel.
|
|
125
|
+
*
|
|
126
|
+
* Events are not replayed across connections, and from Herdr 0.9.2 a reader
|
|
127
|
+
* that falls behind gets an `events_lost` error carrying the request id and a
|
|
128
|
+
* closed socket. Both end in a reconnect, and `onStarted` fires on every
|
|
129
|
+
* acknowledgement so the caller can re-read what it may have missed.
|
|
125
130
|
*/
|
|
126
131
|
function subscribeHerdr(socketPath, subscriptions, onEvent, options = {}) {
|
|
127
|
-
const { connect = net.connect, retryBaseMs = SUBSCRIBE_RETRY_BASE_MS, retryMaxMs = SUBSCRIBE_RETRY_MAX_MS, } = options;
|
|
132
|
+
const { connect = net.connect, retryBaseMs = SUBSCRIBE_RETRY_BASE_MS, retryMaxMs = SUBSCRIBE_RETRY_MAX_MS, onStarted, } = options;
|
|
128
133
|
let socket = null;
|
|
129
134
|
let reconnectTimer = null;
|
|
130
135
|
let handshakeTimer = null;
|
|
@@ -203,6 +208,7 @@ function subscribeHerdr(socketPath, subscriptions, onEvent, options = {}) {
|
|
|
203
208
|
}
|
|
204
209
|
acknowledged = true;
|
|
205
210
|
retryCount = 0;
|
|
211
|
+
onStarted?.();
|
|
206
212
|
}
|
|
207
213
|
else if (acknowledged &&
|
|
208
214
|
typeof message?.event === 'string' &&
|
package/dist/herdr-command.js
CHANGED
|
@@ -29,8 +29,13 @@ const COMMAND_NAME = 'herdr';
|
|
|
29
29
|
* machine in the background stops resizing somebody else's focused pane, and a
|
|
30
30
|
* large paste no longer disconnects the client — and pasting is how an image
|
|
31
31
|
* reaches an agent from a phone.
|
|
32
|
+
*
|
|
33
|
+
* 0.9.3 because a browser types through escape sequences: 0.9.2 stopped a tap
|
|
34
|
+
* on a pane from sending a stray Escape to a working agent and stopped mouse
|
|
35
|
+
* reports split across reads from leaking into the shell, and it also broke
|
|
36
|
+
* Escape followed by a key — Alt+B, Alt+F, Alt+Backspace — which 0.9.3 mends.
|
|
32
37
|
*/
|
|
33
|
-
const MIN_HERDR_VERSION = '0.9.
|
|
38
|
+
const MIN_HERDR_VERSION = '0.9.3';
|
|
34
39
|
/** Where a user-level install lands, in the order we trust it. */
|
|
35
40
|
const FALLBACK_DIRECTORIES = [
|
|
36
41
|
'~/.local/bin',
|
|
@@ -224,7 +229,7 @@ function herdrVersion({ command, timeout = 10_000, ...lookup } = {}) {
|
|
|
224
229
|
/** The one line that tells a user why an older Herdr is a problem here. */
|
|
225
230
|
function herdrOutdatedMessage(version) {
|
|
226
231
|
return (`Herdr ${version} is older than ${MIN_HERDR_VERSION}, which herdr-remote is written against. ` +
|
|
227
|
-
'Run "herdr update" — window titles,
|
|
232
|
+
'Run "herdr update" — window titles, large pastes, taps on a pane and Alt shortcuts all ' +
|
|
228
233
|
'misbehave in browser windows before that release.');
|
|
229
234
|
}
|
|
230
235
|
/** The one message a user needs to fix a missing install themselves. */
|
package/dist/i18n/en.js
CHANGED
|
@@ -163,7 +163,7 @@ const en = {
|
|
|
163
163
|
'herdr.autoStartHint': 'Off: Herdr starts only when you run it, or when you confirm it from a browser. On: herdr-remote also starts it every time it starts, at boot included. Takes effect the next time herdr-remote starts.',
|
|
164
164
|
'herdr.cliMissing': 'Command herdr not found. Set HERDR_BIN_PATH to its full path.',
|
|
165
165
|
'herdr.version': 'Herdr version',
|
|
166
|
-
'herdr.versionOutdated': 'Herdr {version} is older than {minimum}. Run "herdr update": window titles,
|
|
166
|
+
'herdr.versionOutdated': 'Herdr {version} is older than {minimum}. Run "herdr update": window titles, large pastes, taps on a pane and Alt shortcuts misbehave in browser windows before that release.',
|
|
167
167
|
'about.title': 'Language & about',
|
|
168
168
|
'about.language': 'Interface language',
|
|
169
169
|
'about.languageAuto': 'Follow system ({detected})',
|
package/dist/i18n/zh.js
CHANGED
|
@@ -162,7 +162,7 @@ const zh = {
|
|
|
162
162
|
'herdr.autoStartHint': '关:Herdr 只在你手动运行,或在浏览器里确认后才启动。开:herdr-remote 每次启动(包括开机)时一并启动 Herdr。下次 herdr-remote 启动时生效。',
|
|
163
163
|
'herdr.cliMissing': '未找到 herdr 命令,可将 HERDR_BIN_PATH 设为其完整路径。',
|
|
164
164
|
'herdr.version': 'Herdr 版本',
|
|
165
|
-
'herdr.versionOutdated': 'Herdr {version} 低于 {minimum},请运行 “herdr update
|
|
165
|
+
'herdr.versionOutdated': 'Herdr {version} 低于 {minimum},请运行 “herdr update”:在该版本之前,浏览器窗口的标题、大段粘贴、点按窗格与 Alt 快捷键都会出问题。',
|
|
166
166
|
'about.title': '语言与关于',
|
|
167
167
|
'about.language': '界面语言',
|
|
168
168
|
'about.languageAuto': '跟随系统({detected})',
|
package/dist/pty-session.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import { nodePty } from './node-pty-loader.js';
|
|
3
|
+
/**
|
|
4
|
+
* Variables that name the terminal this process was started from. The Herdr
|
|
5
|
+
* client's outer terminal is the browser's xterm.js, and from Herdr 0.9.2 the
|
|
6
|
+
* client reads these to pick image transports: one that believes it runs in
|
|
7
|
+
* Ghostty, kitty or WezTerm hands images over as local file paths no browser
|
|
8
|
+
* can open. Herdr strips the same list from its own panes.
|
|
9
|
+
*/
|
|
10
|
+
const OUTER_TERMINAL_ENV = [
|
|
11
|
+
'TERM_PROGRAM',
|
|
12
|
+
'TERM_PROGRAM_VERSION',
|
|
13
|
+
'ITERM_SESSION_ID',
|
|
14
|
+
'LC_TERMINAL',
|
|
15
|
+
'LC_TERMINAL_VERSION',
|
|
16
|
+
'WEZTERM_PANE',
|
|
17
|
+
'KITTY_WINDOW_ID',
|
|
18
|
+
'WT_SESSION',
|
|
19
|
+
'TMUX',
|
|
20
|
+
'TMUX_PANE',
|
|
21
|
+
'STY',
|
|
22
|
+
'ZELLIJ',
|
|
23
|
+
'ZELLIJ_SESSION_NAME',
|
|
24
|
+
'ZELLIJ_PANE_ID',
|
|
25
|
+
];
|
|
3
26
|
class PtySession {
|
|
4
27
|
static DEFAULT_COLS = 100;
|
|
5
28
|
static DEFAULT_ROWS = 30;
|
|
@@ -29,12 +52,14 @@ class PtySession {
|
|
|
29
52
|
this.terminal = null;
|
|
30
53
|
this.startedAt = null;
|
|
31
54
|
}
|
|
32
|
-
static childEnv(socketPath) {
|
|
33
|
-
const env = { ...
|
|
55
|
+
static childEnv(socketPath, source = process.env) {
|
|
56
|
+
const env = { ...source };
|
|
34
57
|
for (const key of Object.keys(env)) {
|
|
35
58
|
if (key.startsWith('HERDR_'))
|
|
36
59
|
delete env[key];
|
|
37
60
|
}
|
|
61
|
+
for (const key of OUTER_TERMINAL_ENV)
|
|
62
|
+
delete env[key];
|
|
38
63
|
if (socketPath)
|
|
39
64
|
env.HERDR_SOCKET_PATH = socketPath;
|
|
40
65
|
env.TERM = 'xterm-256color';
|
package/dist/socket-discovery.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Herdr's own config directory, resolved as Herdr does (`XDG_CONFIG_HOME`
|
|
6
|
+
* first on every platform, then the platform's home for it), so the socket
|
|
7
|
+
* and `config.toml` are found wherever Herdr put them.
|
|
8
|
+
*/
|
|
9
|
+
function herdrConfigDir(env = process.env, platform = process.platform) {
|
|
7
10
|
if (platform === 'win32') {
|
|
8
11
|
const configHome = env.XDG_CONFIG_HOME ||
|
|
9
12
|
env.APPDATA ||
|
|
10
13
|
(env.USERPROFILE && path.join(env.USERPROFILE, 'AppData', 'Roaming')) ||
|
|
11
14
|
path.join(os.homedir(), 'AppData', 'Roaming');
|
|
12
|
-
return path.join(configHome, 'herdr'
|
|
15
|
+
return path.join(configHome, 'herdr');
|
|
13
16
|
}
|
|
14
17
|
const configHome = env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
|
|
15
|
-
return path.join(configHome, 'herdr'
|
|
18
|
+
return path.join(configHome, 'herdr');
|
|
19
|
+
}
|
|
20
|
+
function defaultSocketPath(env = process.env, platform = process.platform) {
|
|
21
|
+
return env.HERDR_SOCKET_PATH || path.join(herdrConfigDir(env, platform), 'herdr.sock');
|
|
22
|
+
}
|
|
23
|
+
/** The `config.toml` Herdr reads; `HERDR_CONFIG_PATH` names it outright. */
|
|
24
|
+
function herdrConfigPath(env = process.env, platform = process.platform) {
|
|
25
|
+
return env.HERDR_CONFIG_PATH || path.join(herdrConfigDir(env, platform), 'config.toml');
|
|
16
26
|
}
|
|
17
27
|
/**
|
|
18
28
|
* On Windows, Herdr uses this path itself as the GenericNamespaced pipe name;
|
|
@@ -57,4 +67,4 @@ function inspectSocket(socketPath, options = {}) {
|
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
|
-
export { defaultSocketPath, herdrEndpoint, resolveSocketPath, inspectSocket };
|
|
70
|
+
export { defaultSocketPath, herdrConfigPath, herdrEndpoint, resolveSocketPath, inspectSocket };
|
|
@@ -193,10 +193,28 @@ export function parseJsonc(text) {
|
|
|
193
193
|
return null;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
+
/** `line` up to a `#` that starts a comment, not one inside a string. */
|
|
197
|
+
function withoutTomlComment(line) {
|
|
198
|
+
let quote = '';
|
|
199
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
200
|
+
const char = line[i];
|
|
201
|
+
if (quote) {
|
|
202
|
+
if (char === '\\' && quote === '"')
|
|
203
|
+
i += 1;
|
|
204
|
+
else if (char === quote)
|
|
205
|
+
quote = '';
|
|
206
|
+
}
|
|
207
|
+
else if (char === '"' || char === "'")
|
|
208
|
+
quote = char;
|
|
209
|
+
else if (char === '#')
|
|
210
|
+
return line.slice(0, i);
|
|
211
|
+
}
|
|
212
|
+
return line;
|
|
213
|
+
}
|
|
196
214
|
/**
|
|
197
|
-
* Just enough TOML for Alacritty's font keys
|
|
198
|
-
* numbers, inline tables and (possibly
|
|
199
|
-
* flat `dotted.key → value` map.
|
|
215
|
+
* Just enough TOML for Alacritty's font keys and Herdr's `keys.prefix`:
|
|
216
|
+
* tables, dotted keys, strings, numbers, inline tables and (possibly
|
|
217
|
+
* multi-line) string arrays. Returns a flat `dotted.key → value` map.
|
|
200
218
|
*/
|
|
201
219
|
export function parseTomlSubset(text) {
|
|
202
220
|
const values = {};
|
|
@@ -253,11 +271,13 @@ export function parseTomlSubset(text) {
|
|
|
253
271
|
if (equals === -1)
|
|
254
272
|
continue;
|
|
255
273
|
let rawValue = line.slice(equals + 1);
|
|
256
|
-
|
|
257
|
-
|
|
274
|
+
if (rawValue.trim().startsWith('[')) {
|
|
275
|
+
// A comment inside an array may hold quotes or a `]` of its own.
|
|
276
|
+
rawValue = withoutTomlComment(rawValue);
|
|
277
|
+
// An array may span lines; gather it before assigning.
|
|
258
278
|
while (index + 1 < lines.length && !rawValue.includes(']')) {
|
|
259
279
|
index += 1;
|
|
260
|
-
rawValue += ` ${lines[index].trim()}`;
|
|
280
|
+
rawValue += ` ${withoutTomlComment(lines[index]).trim()}`;
|
|
261
281
|
}
|
|
262
282
|
}
|
|
263
283
|
assign(table, line.slice(0, equals), rawValue);
|
|
@@ -19,6 +19,15 @@ const TERMINAL_PROCESSES = [
|
|
|
19
19
|
[/^xterm$/, 'xterm'],
|
|
20
20
|
[/^(urxvt|urxvtd|rxvt)$/, 'urxvt'],
|
|
21
21
|
];
|
|
22
|
+
/** macOS app bundle ids, which every process an app starts inherits. */
|
|
23
|
+
const BUNDLE_TERMINALS = {
|
|
24
|
+
'com.apple.Terminal': 'apple-terminal',
|
|
25
|
+
'com.googlecode.iterm2': 'iterm2',
|
|
26
|
+
'com.microsoft.VSCode': 'vscode',
|
|
27
|
+
'com.mitchellh.ghostty': 'ghostty',
|
|
28
|
+
'com.github.wez.wezterm': 'wezterm',
|
|
29
|
+
'net.kovidgoyal.kitty': 'kitty',
|
|
30
|
+
};
|
|
22
31
|
/**
|
|
23
32
|
* The emulator a process runs under, from its own ancestry first.
|
|
24
33
|
*
|
|
@@ -37,10 +46,15 @@ export function identifyTerminal({ env = process.env, ancestry = [], } = {}) {
|
|
|
37
46
|
return id;
|
|
38
47
|
}
|
|
39
48
|
}
|
|
49
|
+
// From Herdr 0.9.2 a pane says TERM_PROGRAM=herdr and loses the terminal's
|
|
50
|
+
// session markers, so a start from inside Herdr falls through to markers
|
|
51
|
+
// Herdr leaves alone: macOS's app bundle id, ITERM_PROFILE, KITTY_PID,
|
|
52
|
+
// WT_PROFILE_ID.
|
|
40
53
|
const program = env.TERM_PROGRAM || '';
|
|
54
|
+
const bundle = env.__CFBundleIdentifier || '';
|
|
41
55
|
if (program === 'vscode')
|
|
42
56
|
return 'vscode';
|
|
43
|
-
if (program === 'iTerm.app' || env.ITERM_SESSION_ID)
|
|
57
|
+
if (program === 'iTerm.app' || env.ITERM_SESSION_ID || env.ITERM_PROFILE)
|
|
44
58
|
return 'iterm2';
|
|
45
59
|
if (program === 'Apple_Terminal')
|
|
46
60
|
return 'apple-terminal';
|
|
@@ -48,7 +62,7 @@ export function identifyTerminal({ env = process.env, ancestry = [], } = {}) {
|
|
|
48
62
|
return 'wezterm';
|
|
49
63
|
if (program === 'ghostty' || env.GHOSTTY_RESOURCES_DIR)
|
|
50
64
|
return 'ghostty';
|
|
51
|
-
if (env.KITTY_WINDOW_ID || env.TERM === 'xterm-kitty')
|
|
65
|
+
if (env.KITTY_WINDOW_ID || env.KITTY_PID || env.TERM === 'xterm-kitty')
|
|
52
66
|
return 'kitty';
|
|
53
67
|
if (env.ALACRITTY_SOCKET || env.ALACRITTY_WINDOW_ID || env.ALACRITTY_LOG)
|
|
54
68
|
return 'alacritty';
|
|
@@ -64,8 +78,10 @@ export function identifyTerminal({ env = process.env, ancestry = [], } = {}) {
|
|
|
64
78
|
return 'gnome-terminal';
|
|
65
79
|
if (/^rxvt-unicode/.test(env.TERM || ''))
|
|
66
80
|
return 'urxvt';
|
|
81
|
+
if (Object.hasOwn(BUNDLE_TERMINALS, bundle))
|
|
82
|
+
return BUNDLE_TERMINALS[bundle];
|
|
67
83
|
// WT_SESSION is inherited by nested terminals, so specific terminal markers win first.
|
|
68
|
-
if (env.WT_SESSION)
|
|
84
|
+
if (env.WT_SESSION || env.WT_PROFILE_ID)
|
|
69
85
|
return 'windows-terminal';
|
|
70
86
|
// Last: a terminal started from xterm inherits this too.
|
|
71
87
|
if (env.XTERM_VERSION)
|
package/herdr-plugin.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
id = "herdr.remote.web"
|
|
2
2
|
name = "Herdr Remote Web"
|
|
3
|
-
version = "0.2.
|
|
4
|
-
min_herdr_version = "0.9.
|
|
3
|
+
version = "0.2.33"
|
|
4
|
+
min_herdr_version = "0.9.3"
|
|
5
5
|
description = "Browser access to Herdr workspaces via local or self-hosted relay"
|
|
6
6
|
platforms = ["linux", "macos", "windows"]
|
|
7
7
|
|