herdr-remote 0.2.18 → 0.2.20
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/bin/herdr-remote.js +3 -225
- package/dist/agent-status.js +130 -0
- package/dist/binary-plist.js +157 -0
- package/dist/cli.js +255 -0
- package/dist/config.js +270 -0
- package/dist/connector/agent-watch.js +110 -0
- package/dist/connector/font-server.js +165 -0
- package/dist/connector/host-connector.js +430 -0
- package/dist/connector/lock.js +66 -0
- package/dist/connector/main.js +18 -0
- package/dist/connector/sessions.js +366 -0
- package/dist/connector/update-report.js +67 -0
- package/dist/connector/wire.js +42 -0
- package/{src → dist}/exit-codes.js +1 -4
- package/dist/font-subset.js +110 -0
- package/dist/herdr-api.js +246 -0
- package/dist/herdr-command.js +223 -0
- package/dist/herdr-plugin.js +116 -0
- package/dist/herdr-server.js +189 -0
- package/dist/i18n/en.js +223 -0
- package/dist/i18n/index.js +48 -0
- package/dist/i18n/zh.js +222 -0
- package/dist/keepalive/detached.js +78 -0
- package/dist/keepalive/environment.js +44 -0
- package/dist/keepalive/index.js +110 -0
- package/dist/keepalive/launchd.js +117 -0
- package/dist/keepalive/systemd.js +108 -0
- package/dist/keepalive/types.js +1 -0
- package/dist/lib/process.js +12 -0
- package/dist/lifecycle.js +59 -0
- package/dist/net-interfaces.js +73 -0
- package/dist/pasted-files.js +115 -0
- package/dist/paths.js +62 -0
- package/dist/pty-session.js +96 -0
- package/dist/relay-client.js +106 -0
- package/dist/relay-urls.js +99 -0
- package/dist/runtime.js +106 -0
- package/dist/service.js +260 -0
- package/dist/settings-model.js +298 -0
- package/dist/socket-discovery.js +48 -0
- package/dist/supervisor.js +319 -0
- package/dist/terminal-font/deps.js +73 -0
- package/dist/terminal-font/files.js +354 -0
- package/dist/terminal-font/formats.js +335 -0
- package/dist/terminal-font/index.js +187 -0
- package/dist/terminal-font/readers.js +316 -0
- package/dist/terminal-font/terminals.js +128 -0
- package/dist/terminal-palette.js +339 -0
- package/dist/tui/App.js +195 -0
- package/dist/tui/api.js +79 -0
- package/dist/tui/components/TextField.js +50 -0
- package/dist/tui/components/common.js +80 -0
- package/dist/tui/index.js +36 -0
- package/dist/tui/mouse/index.js +164 -0
- package/dist/tui/mouse/protocol.js +96 -0
- package/dist/tui/mouse/source.js +74 -0
- package/dist/tui/screens/About.js +166 -0
- package/dist/tui/screens/Herdr.js +74 -0
- package/dist/tui/screens/Keepalive.js +84 -0
- package/dist/tui/screens/Overview.js +36 -0
- package/dist/tui/screens/Pair.js +74 -0
- package/dist/tui/screens/Relay.js +242 -0
- package/dist/tui/screens/Services.js +63 -0
- package/dist/tui/screens/Wizard.js +235 -0
- package/dist/tui/terminal.js +39 -0
- package/dist/tui/theme.js +33 -0
- package/dist/updater.js +382 -0
- package/herdr-plugin.toml +1 -1
- package/package.json +8 -8
- package/dist/tui.mjs +0 -5775
- package/src/agent-status.js +0 -139
- package/src/binary-plist.js +0 -146
- package/src/config.js +0 -454
- package/src/font-subset.js +0 -110
- package/src/herdr-api.js +0 -244
- package/src/herdr-command.js +0 -231
- package/src/herdr-plugin.js +0 -130
- package/src/herdr-server.js +0 -201
- package/src/host-connector.js +0 -1069
- package/src/i18n/en.js +0 -240
- package/src/i18n/index.js +0 -56
- package/src/i18n/zh.js +0 -239
- package/src/keepalive.js +0 -460
- package/src/lifecycle.js +0 -62
- package/src/net-interfaces.js +0 -76
- package/src/pasted-files.js +0 -176
- package/src/pty-session.js +0 -92
- package/src/service.js +0 -530
- package/src/settings-model.js +0 -323
- package/src/socket-discovery.js +0 -60
- package/src/state.js +0 -47
- package/src/supervisor.js +0 -250
- package/src/terminal-font.js +0 -1204
- package/src/terminal-palette.js +0 -325
- package/src/updater.js +0 -394
package/src/agent-status.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* What the agents on this workstation are doing, small enough to put in a
|
|
5
|
-
* status bar.
|
|
6
|
-
*
|
|
7
|
-
* The question a phone actually has is "does anything need me?", and the
|
|
8
|
-
* terminal is a poor way to ask it: finding a blocked agent means navigating
|
|
9
|
-
* Herdr's sidebar through a viewport the width of a hand. Herdr already knows
|
|
10
|
-
* the answer — it classifies every pane as idle, working, blocked, done or
|
|
11
|
-
* unknown — so this turns a session snapshot into the two-line version.
|
|
12
|
-
*
|
|
13
|
-
* Deliberately a pure function over a snapshot. The socket, the debounce and
|
|
14
|
-
* the retry live in the host connector; what counts as "needs me" lives here,
|
|
15
|
-
* where it can be tested without either.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/** Herdr's own vocabulary, in the order a person cares about them. */
|
|
19
|
-
const AGENT_STATUSES = ['blocked', 'done', 'working', 'idle', 'unknown'];
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* How many agents travel with the summary.
|
|
23
|
-
*
|
|
24
|
-
* The counts are always exact; this caps only the named list, which exists so a
|
|
25
|
-
* future screen can say *which* agent is blocked. A workstation with more than
|
|
26
|
-
* this many live agents is not going to be read off a phone anyway.
|
|
27
|
-
*/
|
|
28
|
-
const MAX_LISTED_AGENTS = 16;
|
|
29
|
-
|
|
30
|
-
/** Titles come from a remote program; keep them short and printable. */
|
|
31
|
-
const MAX_TITLE_LENGTH = 48;
|
|
32
|
-
|
|
33
|
-
function cleanText(value, limit = MAX_TITLE_LENGTH) {
|
|
34
|
-
if (typeof value !== 'string') return null;
|
|
35
|
-
// eslint-disable-next-line no-control-regex
|
|
36
|
-
const collapsed = value.replace(/[\u0000-\u001F\u007F-\u009F]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
37
|
-
if (!collapsed) return null;
|
|
38
|
-
return collapsed.length > limit ? collapsed.slice(0, limit) : collapsed;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function normalizeStatus(value) {
|
|
42
|
-
return AGENT_STATUSES.includes(value) ? value : 'unknown';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function emptyCounts() {
|
|
46
|
-
return Object.fromEntries(AGENT_STATUSES.map((status) => [status, 0]));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Turn `session.snapshot` into the summary the browser receives.
|
|
51
|
-
*
|
|
52
|
-
* Sorted by how much each status wants attention, so the capped list keeps the
|
|
53
|
-
* agents worth naming rather than the first ones Herdr happened to report.
|
|
54
|
-
* `focusedPaneId` and `focusedAgent` also track the live pane selection,
|
|
55
|
-
* including shells and panes Herdr has not added to its agent summary.
|
|
56
|
-
*/
|
|
57
|
-
function summarizeAgents(snapshot) {
|
|
58
|
-
const entries = Array.isArray(snapshot?.agents) ? snapshot.agents : [];
|
|
59
|
-
const panes = Array.isArray(snapshot?.panes) ? snapshot.panes : [];
|
|
60
|
-
const reportedFocusId = typeof snapshot?.focused_pane_id === 'string' && snapshot.focused_pane_id
|
|
61
|
-
? snapshot.focused_pane_id
|
|
62
|
-
: null;
|
|
63
|
-
// `focused_pane_id` is the primary signal in Herdr snapshots. The focused
|
|
64
|
-
// flags are a fallback for snapshots where that top-level field is absent.
|
|
65
|
-
const focusedPane = (reportedFocusId
|
|
66
|
-
? panes.find((pane) => pane?.pane_id === reportedFocusId)
|
|
67
|
-
: panes.find((pane) => pane?.focused === true)) || null;
|
|
68
|
-
const focusedAgentEntry = (reportedFocusId
|
|
69
|
-
? entries.find((entry) => entry?.pane_id === reportedFocusId)
|
|
70
|
-
: entries.find((entry) => entry?.focused === true)) || null;
|
|
71
|
-
const focusedPaneId = reportedFocusId
|
|
72
|
-
|| (typeof focusedPane?.pane_id === 'string' ? focusedPane.pane_id : null)
|
|
73
|
-
|| (typeof focusedAgentEntry?.pane_id === 'string' ? focusedAgentEntry.pane_id : null);
|
|
74
|
-
const focusedAgent = typeof focusedPane?.agent === 'string'
|
|
75
|
-
? focusedPane.agent
|
|
76
|
-
: typeof focusedAgentEntry?.agent === 'string'
|
|
77
|
-
? focusedAgentEntry.agent
|
|
78
|
-
: null;
|
|
79
|
-
const counts = emptyCounts();
|
|
80
|
-
const ranked = [];
|
|
81
|
-
|
|
82
|
-
for (const entry of entries) {
|
|
83
|
-
if (!entry || typeof entry.pane_id !== 'string') continue;
|
|
84
|
-
const status = normalizeStatus(entry.agent_status);
|
|
85
|
-
counts[status] += 1;
|
|
86
|
-
ranked.push({
|
|
87
|
-
paneId: entry.pane_id,
|
|
88
|
-
workspaceId: typeof entry.workspace_id === 'string' ? entry.workspace_id : null,
|
|
89
|
-
agent: cleanText(entry.display_agent || entry.agent, 24),
|
|
90
|
-
title: cleanText(entry.terminal_title_stripped || entry.terminal_title),
|
|
91
|
-
status,
|
|
92
|
-
focused: entry.focused === true,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
ranked.sort((left, right) => AGENT_STATUSES.indexOf(left.status) - AGENT_STATUSES.indexOf(right.status));
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
focusedPaneId,
|
|
100
|
-
focusedAgent,
|
|
101
|
-
counts,
|
|
102
|
-
// Total rather than a sum the browser has to compute, and the one number a
|
|
103
|
-
// collapsed chip can show on its own.
|
|
104
|
-
total: ranked.length,
|
|
105
|
-
agents: ranked.slice(0, MAX_LISTED_AGENTS),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Whether two summaries say the same thing, so an unchanged one is not sent. */
|
|
110
|
-
function sameSummary(left, right) {
|
|
111
|
-
if (!left || !right) return left === right;
|
|
112
|
-
if (left.focusedPaneId !== right.focusedPaneId || left.focusedAgent !== right.focusedAgent) return false;
|
|
113
|
-
if (left.total !== right.total) return false;
|
|
114
|
-
for (const status of AGENT_STATUSES) {
|
|
115
|
-
if ((left.counts?.[status] || 0) !== (right.counts?.[status] || 0)) return false;
|
|
116
|
-
}
|
|
117
|
-
if (left.agents.length !== right.agents.length) return false;
|
|
118
|
-
return left.agents.every((agent, index) => {
|
|
119
|
-
const other = right.agents[index];
|
|
120
|
-
return other
|
|
121
|
-
&& agent.paneId === other.paneId
|
|
122
|
-
&& agent.status === other.status
|
|
123
|
-
&& agent.agent === other.agent
|
|
124
|
-
&& agent.title === other.title;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** The summary of a workstation with nothing to report, or nothing to ask. */
|
|
129
|
-
function emptySummary() {
|
|
130
|
-
return { focusedPaneId: null, focusedAgent: null, counts: emptyCounts(), total: 0, agents: [] };
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = {
|
|
134
|
-
AGENT_STATUSES,
|
|
135
|
-
MAX_LISTED_AGENTS,
|
|
136
|
-
emptySummary,
|
|
137
|
-
sameSummary,
|
|
138
|
-
summarizeAgents,
|
|
139
|
-
};
|
package/src/binary-plist.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Reads Apple binary property lists (`bplist00`), the format macOS writes its
|
|
5
|
-
* preference files in, and the NSKeyedArchiver graphs stored inside them.
|
|
6
|
-
*
|
|
7
|
-
* Terminal.app keeps each profile's font as an archived NSFont — a binary
|
|
8
|
-
* plist nested in a binary plist — and there is no command-line tool that
|
|
9
|
-
* turns that into something readable without asking Terminal itself (an
|
|
10
|
-
* AppleScript that prompts for Automation access). A reader this small is
|
|
11
|
-
* less intrusive than any of those.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** A reference to another object in a keyed archive (`CF$UID`). */
|
|
15
|
-
class Uid {
|
|
16
|
-
constructor(value) {
|
|
17
|
-
this.value = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function readSizedInt(buffer, offset, size) {
|
|
22
|
-
let value = 0;
|
|
23
|
-
for (let i = 0; i < size; i += 1) value = value * 256 + buffer[offset + i];
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parses a whole `bplist00` buffer into plain values: objects, arrays,
|
|
29
|
-
* strings, numbers, booleans, Buffers (data), Dates and `Uid`s. Throws on
|
|
30
|
-
* anything malformed; callers treat that as "no answer".
|
|
31
|
-
*/
|
|
32
|
-
function parseBinaryPlist(buffer) {
|
|
33
|
-
if (!Buffer.isBuffer(buffer) || buffer.length < 40 || buffer.toString('latin1', 0, 8) !== 'bplist00') {
|
|
34
|
-
throw new Error('not a binary plist');
|
|
35
|
-
}
|
|
36
|
-
const trailer = buffer.length - 32;
|
|
37
|
-
const offsetSize = buffer[trailer + 6];
|
|
38
|
-
const refSize = buffer[trailer + 7];
|
|
39
|
-
const count = readSizedInt(buffer, trailer + 8, 8);
|
|
40
|
-
const top = readSizedInt(buffer, trailer + 16, 8);
|
|
41
|
-
const tableOffset = readSizedInt(buffer, trailer + 24, 8);
|
|
42
|
-
if (!offsetSize || !refSize || count > 1_000_000 || tableOffset + count * offsetSize > trailer) {
|
|
43
|
-
throw new Error('corrupt binary plist trailer');
|
|
44
|
-
}
|
|
45
|
-
const offsets = [];
|
|
46
|
-
for (let i = 0; i < count; i += 1) offsets.push(readSizedInt(buffer, tableOffset + i * offsetSize, offsetSize));
|
|
47
|
-
|
|
48
|
-
const parsing = new Set();
|
|
49
|
-
const parse = (index) => {
|
|
50
|
-
if (index >= count || parsing.has(index)) throw new Error('corrupt binary plist reference');
|
|
51
|
-
parsing.add(index);
|
|
52
|
-
try {
|
|
53
|
-
return parseObject(offsets[index]);
|
|
54
|
-
} finally {
|
|
55
|
-
parsing.delete(index);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// A length stored in the marker's low nibble, or as the int object after it.
|
|
60
|
-
const lengthAt = (offset) => {
|
|
61
|
-
const low = buffer[offset] & 0x0f;
|
|
62
|
-
if (low !== 0x0f) return { length: low, start: offset + 1 };
|
|
63
|
-
const marker = buffer[offset + 1];
|
|
64
|
-
if ((marker & 0xf0) !== 0x10) throw new Error('corrupt binary plist length');
|
|
65
|
-
const size = 1 << (marker & 0x0f);
|
|
66
|
-
return { length: readSizedInt(buffer, offset + 2, size), start: offset + 2 + size };
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const parseObject = (offset) => {
|
|
70
|
-
const marker = buffer[offset];
|
|
71
|
-
const type = marker >> 4;
|
|
72
|
-
const low = marker & 0x0f;
|
|
73
|
-
switch (type) {
|
|
74
|
-
case 0x0:
|
|
75
|
-
if (marker === 0x08) return false;
|
|
76
|
-
if (marker === 0x09) return true;
|
|
77
|
-
return null;
|
|
78
|
-
case 0x1: {
|
|
79
|
-
const size = 1 << low;
|
|
80
|
-
if (size === 8) return Number(buffer.readBigInt64BE(offset + 1));
|
|
81
|
-
return readSizedInt(buffer, offset + 1, size);
|
|
82
|
-
}
|
|
83
|
-
case 0x2:
|
|
84
|
-
return low === 2 ? buffer.readFloatBE(offset + 1) : buffer.readDoubleBE(offset + 1);
|
|
85
|
-
case 0x3:
|
|
86
|
-
return new Date(Date.UTC(2001, 0, 1) + buffer.readDoubleBE(offset + 1) * 1000);
|
|
87
|
-
case 0x4: {
|
|
88
|
-
const { length, start } = lengthAt(offset);
|
|
89
|
-
return buffer.subarray(start, start + length);
|
|
90
|
-
}
|
|
91
|
-
case 0x5: {
|
|
92
|
-
const { length, start } = lengthAt(offset);
|
|
93
|
-
return buffer.toString('latin1', start, start + length);
|
|
94
|
-
}
|
|
95
|
-
case 0x6: {
|
|
96
|
-
const { length, start } = lengthAt(offset);
|
|
97
|
-
return Buffer.from(buffer.subarray(start, start + length * 2)).swap16().toString('utf16le');
|
|
98
|
-
}
|
|
99
|
-
case 0x8:
|
|
100
|
-
return new Uid(readSizedInt(buffer, offset + 1, low + 1));
|
|
101
|
-
case 0xa:
|
|
102
|
-
case 0xc: {
|
|
103
|
-
const { length, start } = lengthAt(offset);
|
|
104
|
-
const items = [];
|
|
105
|
-
for (let i = 0; i < length; i += 1) items.push(parse(readSizedInt(buffer, start + i * refSize, refSize)));
|
|
106
|
-
return items;
|
|
107
|
-
}
|
|
108
|
-
case 0xd: {
|
|
109
|
-
const { length, start } = lengthAt(offset);
|
|
110
|
-
const result = {};
|
|
111
|
-
for (let i = 0; i < length; i += 1) {
|
|
112
|
-
const key = parse(readSizedInt(buffer, start + i * refSize, refSize));
|
|
113
|
-
result[String(key)] = parse(readSizedInt(buffer, start + (length + i) * refSize, refSize));
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
default:
|
|
118
|
-
throw new Error(`unsupported binary plist object 0x${marker.toString(16)}`);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return parse(top);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* The root object of an NSKeyedArchiver plist, with every `Uid` replaced by
|
|
127
|
-
* the object it points at (to a bounded depth; archives may be cyclic).
|
|
128
|
-
*/
|
|
129
|
-
function unarchiveKeyed(archive, depth = 6) {
|
|
130
|
-
const objects = archive?.$objects;
|
|
131
|
-
const rootRef = archive?.$top?.root;
|
|
132
|
-
if (!Array.isArray(objects) || !(rootRef instanceof Uid)) throw new Error('not a keyed archive');
|
|
133
|
-
const resolve = (value, level) => {
|
|
134
|
-
if (value instanceof Uid) return level > depth ? null : resolve(objects[value.value], level + 1);
|
|
135
|
-
if (Array.isArray(value)) return value.map((item) => resolve(item, level));
|
|
136
|
-
if (value && typeof value === 'object' && !Buffer.isBuffer(value) && !(value instanceof Date)) {
|
|
137
|
-
const result = {};
|
|
138
|
-
for (const [key, item] of Object.entries(value)) result[key] = resolve(item, level);
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
return value === '$null' ? null : value;
|
|
142
|
-
};
|
|
143
|
-
return resolve(rootRef, 0);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
module.exports = { Uid, parseBinaryPlist, unarchiveKeyed };
|