shellpuppet 0.5.0 → 0.5.2

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.
@@ -30,9 +30,17 @@
30
30
  * Pure: no I/O.
31
31
  */
32
32
  /** What a terminal report says, as the audit log names it. */
33
- export type TerminalReportKind = 'focus-in' | 'focus-out' | 'cursor-position' | 'device-status' | 'device-attributes' | 'mode-report' | 'colour' | 'status-string';
33
+ export type TerminalReportKind = 'mouse' | 'multiple' | 'focus-in' | 'focus-out' | 'cursor-position' | 'device-status' | 'device-attributes' | 'mode-report' | 'colour' | 'status-string';
34
34
  /**
35
35
  * The kind of terminal report a viewer message is, or `null` when it is
36
36
  * input: a keystroke, a paste or anything else a person may have sent.
37
37
  */
38
38
  export declare function terminalReportKind(message: string): TerminalReportKind | null;
39
+ /** A whole input made only of complete reports; anything mixed is typing. */
40
+ export declare function terminalReportBatchKind(message: string): TerminalReportKind | null;
41
+ /** Classify and forward each viewer frame without waiting for another frame. */
42
+ export declare class TerminalReportStream {
43
+ private readonly deliver;
44
+ constructor(deliver: (data: string, kind: TerminalReportKind | null) => void);
45
+ push(data: string): void;
46
+ }
@@ -71,7 +71,18 @@ const REPORTS = [
71
71
  * filed as something nobody typed, so those stay input.
72
72
  */
73
73
  const MODIFIED_F3 = /^\x1b\[1;(?:[2-9]|1[0-6])R$/;
74
+ // CoreMouseService.eventCode uses two button/action bits, three modifier bits,
75
+ // and one of the move or wheel bits. The bundled browser emits wheel up/down.
76
+ const SGR_MOUSE = /^\x1b\[<(0|[1-9]\d{0,4});(0|[1-9]\d{0,4});(0|[1-9]\d{0,4})[Mm]$/;
74
77
  /* eslint-enable no-control-regex */
78
+ function mouseCodeValid(code) {
79
+ if (code > 95)
80
+ return false;
81
+ if ((code & 64) !== 0)
82
+ return (code & 3) <= 1;
83
+ // SGR names the released button, so button NONE is only valid for movement.
84
+ return (code & 32) !== 0 || (code & 3) !== 3;
85
+ }
75
86
  /**
76
87
  * The kind of terminal report a viewer message is, or `null` when it is
77
88
  * input: a keystroke, a paste or anything else a person may have sent.
@@ -79,6 +90,49 @@ const MODIFIED_F3 = /^\x1b\[1;(?:[2-9]|1[0-6])R$/;
79
90
  export function terminalReportKind(message) {
80
91
  if (MODIFIED_F3.test(message))
81
92
  return null;
93
+ const sgrMouse = SGR_MOUSE.exec(message);
94
+ if (sgrMouse !== null) {
95
+ const code = Number(sgrMouse[1]);
96
+ // The encoder uses lowercase m only for ordinary-button release.
97
+ return mouseCodeValid(code) && (message.endsWith('M') || code < 32) &&
98
+ Number(sgrMouse[2]) <= 10_000 && Number(sgrMouse[3]) <= 10_000
99
+ ? 'mouse' : null;
100
+ }
82
101
  return REPORTS.find(({ pattern }) => pattern.test(message))?.kind ?? null;
83
102
  }
103
+ const MAX_REPORT_BYTES = 128;
104
+ /** A whole input made only of complete reports; anything mixed is typing. */
105
+ export function terminalReportBatchKind(message) {
106
+ if (message.length === 0 || message.length > MAX_REPORT_BYTES)
107
+ return null;
108
+ const single = terminalReportKind(message);
109
+ if (single !== null)
110
+ return single;
111
+ let offset = 0;
112
+ let count = 0;
113
+ while (offset < message.length) {
114
+ if (message[offset] !== '\x1b')
115
+ return null;
116
+ let next = offset + 3;
117
+ for (; next <= message.length; next++) {
118
+ if (terminalReportKind(message.slice(offset, next)) !== null)
119
+ break;
120
+ }
121
+ if (next > message.length)
122
+ return null;
123
+ offset = next;
124
+ count++;
125
+ }
126
+ return count > 1 ? 'multiple' : null;
127
+ }
128
+ /** Classify and forward each viewer frame without waiting for another frame. */
129
+ export class TerminalReportStream {
130
+ deliver;
131
+ constructor(deliver) {
132
+ this.deliver = deliver;
133
+ }
134
+ push(data) {
135
+ this.deliver(data, terminalReportBatchKind(data));
136
+ }
137
+ }
84
138
  //# sourceMappingURL=terminalReports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terminalReports.js","sourceRoot":"","sources":["../../src/daemon/terminalReports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;QAC5C,IAAI,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC;QACtB,OAAO,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;YACtC,IAAI,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI;gBAAE,MAAM;QACtE,CAAC;QACD,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACvC,MAAM,GAAG,IAAI,CAAC;QACd,KAAK,EAAE,CAAC;IACV,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC;AAED,gFAAgF;AAChF,MAAM,OAAO,oBAAoB;IACF;IAA7B,YAA6B,OAAgE;QAAhE,YAAO,GAAP,OAAO,CAAyD;IAAG,CAAC;IAEjG,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -21,8 +21,11 @@ button.active { color: #9dd4ff; border-color: #4b9adc; background: #173249; }
21
21
  .messages-tools h2 { margin: 0; font-size: 16px; }
22
22
  #messages-content { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(260px, 2fr); gap: 10px; }
23
23
  #messages-list, #messages-detail { min-height: 0; overflow: auto; border: 1px solid #455366; border-radius: 4px; padding: 8px; }
24
+ #messages-content.unread-age { grid-template-columns: minmax(0, 1fr); }
25
+ #messages-detail[hidden] { display: none; }
24
26
  #messages-list { display: flex; flex-direction: column; gap: 5px; margin: 0; list-style: none; }
25
27
  .message-row { text-align: left; white-space: normal; overflow-wrap: anywhere; }
28
+ .unread-age-row { border-bottom: 1px solid #303b4a; padding: 6px 2px; overflow-wrap: anywhere; }
26
29
  .message-row[aria-current="true"] { border-color: #79b8f5; background: #173249; }
27
30
  #messages-detail { white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
28
31
  .pane-message-count[hidden] { display: none; }
@@ -37,7 +37,7 @@
37
37
  <main id="panes" aria-label="Sessions"></main>
38
38
  <div id="empty" class="hint">No sessions yet</div>
39
39
  <section id="messages-view" aria-label="Messages" hidden>
40
- <div class="messages-tools"><h2>Messages</h2><label>Filter by session or group <select id="messages-filter"><option value="">All</option></select></label></div>
40
+ <div class="messages-tools"><h2>Messages</h2><button id="messages-history" type="button" aria-pressed="true">History</button><button id="messages-unread-age" type="button" aria-pressed="false">Unread by age</button><label id="messages-filter-wrap">Filter by session or group <select id="messages-filter"><option value="">All</option></select></label></div>
41
41
  <p id="messages-off" hidden>Messaging is off. <a href="https://github.com/intermeld/shellpuppet/blob/main/docs/reference/configuration.md#messages-between-sessions">Switch it on in the configuration.</a></p>
42
42
  <p id="messages-empty" hidden>No messages yet.</p>
43
43
  <div id="messages-content"><ul id="messages-list" aria-label="Message history"></ul><div id="messages-detail" aria-live="polite"><p>Select a message to read it.</p></div></div>
@@ -12,6 +12,10 @@
12
12
  const messagesToggle = document.getElementById('messages-toggle');
13
13
  const messagesView = document.getElementById('messages-view');
14
14
  const messagesFilter = document.getElementById('messages-filter');
15
+ const messagesFilterWrap = document.getElementById('messages-filter-wrap');
16
+ const messagesHistory = document.getElementById('messages-history');
17
+ const messagesUnreadAge = document.getElementById('messages-unread-age');
18
+ const messagesContent = document.getElementById('messages-content');
15
19
  const messagesList = document.getElementById('messages-list');
16
20
  const messagesDetail = document.getElementById('messages-detail');
17
21
  const messagesOff = document.getElementById('messages-off');
@@ -39,6 +43,8 @@
39
43
  strip.id = 'strip';
40
44
  const panes = new Map();
41
45
  let messageEntries = [];
46
+ let unreadAgeEntries = [];
47
+ let messageMode = 'history';
42
48
  let unreadCounts = {};
43
49
  let messageGroups = [];
44
50
  let messagingEnabled = false;
@@ -46,6 +52,7 @@
46
52
  let messageFetching = false;
47
53
  let messageDirty = false;
48
54
  let messageTimer = null;
55
+ let ageRefreshTimer = null;
49
56
  let lastMessageFetch = 0;
50
57
  let messageRetryDelay = 0;
51
58
  let messageFilter = '';
@@ -56,7 +63,32 @@
56
63
  function unreadCount(id) {
57
64
  return unreadCounts[id] ?? 0;
58
65
  }
66
+ function renderUnreadAge() {
67
+ messagesFilterWrap.hidden = true;
68
+ messagesDetail.hidden = true;
69
+ messagesContent.classList.add('unread-age');
70
+ messagesList.setAttribute('aria-label', 'Unread messages by age');
71
+ messagesOff.hidden = true;
72
+ messagesEmpty.textContent = 'No unread messages.';
73
+ messagesEmpty.hidden = unreadAgeEntries.length > 0;
74
+ messagesContent.hidden = unreadAgeEntries.length === 0;
75
+ messagesList.replaceChildren();
76
+ for (const entry of unreadAgeEntries) {
77
+ const row = document.createElement('li');
78
+ row.className = 'unread-age-row';
79
+ const seconds = Math.floor(entry.ageMs / 1000);
80
+ const age = seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m`;
81
+ row.textContent = `${age} · ${entry.state} · ${entry.id} · ${entry.from.name} (${entry.from.id}) → ${entry.to.name} (${entry.to.id}) · sent ${new Date(entry.sentAt).toLocaleString()}`;
82
+ messagesList.append(row);
83
+ }
84
+ }
59
85
  function renderMessages() {
86
+ if (messageMode === 'unread') { renderUnreadAge(); return; }
87
+ messagesFilterWrap.hidden = false;
88
+ messagesDetail.hidden = false;
89
+ messagesContent.classList.remove('unread-age');
90
+ messagesList.setAttribute('aria-label', 'Message history');
91
+ messagesEmpty.textContent = 'No messages yet.';
60
92
  const participantLabel = (participant) => `${participant.name}${participant.kind === 'claim' || participant.id.startsWith('claim_') ? ' (outside claim)' : ''}`;
61
93
  const options = [{ value: '', label: 'All' }];
62
94
  const participants = new Map();
@@ -142,11 +174,14 @@
142
174
  }
143
175
  async function loadMessages() {
144
176
  messageTimer = null;
177
+ clearTimeout(ageRefreshTimer);
178
+ ageRefreshTimer = null;
145
179
  if (messageFetching || !messageDirty) return;
146
180
  messageDirty = false;
147
181
  messageFetching = true;
148
182
  lastMessageFetch = Date.now();
149
- const full = !messagesView.hidden;
183
+ const full = !messagesView.hidden && messageMode === 'history';
184
+ const unread = !messagesView.hidden && messageMode === 'unread';
150
185
  try {
151
186
  const response = await fetch(`/dashboard/messages${full ? '' : '?summary=1'}`, {
152
187
  headers: { 'x-shellpuppet-csrf': proof },
@@ -156,21 +191,40 @@
156
191
  messagingEnabled = result.enabled === true;
157
192
  unreadCounts = result.counts;
158
193
  for (const item of panes.values()) updateMessageBadge(item);
159
- if (full && !messagesView.hidden) {
194
+ if (full && !messagesView.hidden && messageMode === 'history') {
160
195
  messageEntries = result.messages;
161
196
  messageGroups = result.groups;
162
197
  renderMessages();
163
198
  }
164
- if (full !== !messagesView.hidden) messageDirty = true;
199
+ if (unread && !messagesView.hidden && messageMode === 'unread') {
200
+ const ageResponse = await fetch('/dashboard/messages/unread-age', {
201
+ headers: { 'x-shellpuppet-csrf': proof },
202
+ });
203
+ if (!ageResponse.ok) throw new Error('The unread message ages could not be read.');
204
+ const ageResult = await ageResponse.json();
205
+ unreadAgeEntries = ageResult.messages;
206
+ renderMessages();
207
+ }
208
+ if (full !== (!messagesView.hidden && messageMode === 'history') ||
209
+ unread !== (!messagesView.hidden && messageMode === 'unread')) messageDirty = true;
165
210
  messageRetryDelay = 0;
166
211
  } catch {
167
- showError('The message history could not be read.');
212
+ showError('The message view could not be read.');
168
213
  // Keep the update pending: the socket may stay open with no further
169
214
  // event, so retry rather than leave the badge stale.
170
215
  messageDirty = true;
171
216
  messageRetryDelay = Math.min(messageRetryDelay * 2 || 1000, 30_000);
172
217
  }
173
- finally { messageFetching = false; if (messageDirty) scheduleMessageRefresh(); }
218
+ finally {
219
+ messageFetching = false;
220
+ if (messageDirty) scheduleMessageRefresh();
221
+ else if (!messagesView.hidden && messageMode === 'unread') {
222
+ ageRefreshTimer = setTimeout(() => {
223
+ ageRefreshTimer = null;
224
+ scheduleMessageRefresh();
225
+ }, 60_000);
226
+ }
227
+ }
174
228
  }
175
229
  function scheduleMessageRefresh() {
176
230
  messageDirty = true;
@@ -178,7 +232,25 @@
178
232
  messageTimer = setTimeout(() => { void loadMessages(); },
179
233
  Math.max(messageRetryDelay, 250 - (Date.now() - lastMessageFetch)));
180
234
  }
235
+ function setMessageMode(mode) {
236
+ if (messageMode === mode) return;
237
+ messageMode = mode;
238
+ messageEntries = [];
239
+ unreadAgeEntries = [];
240
+ messageSelection = null;
241
+ messagesHistory.setAttribute('aria-pressed', String(mode === 'history'));
242
+ messagesUnreadAge.setAttribute('aria-pressed', String(mode === 'unread'));
243
+ clearTimeout(messageTimer);
244
+ messageTimer = null;
245
+ clearTimeout(ageRefreshTimer);
246
+ ageRefreshTimer = null;
247
+ renderMessages();
248
+ scheduleMessageRefresh();
249
+ }
181
250
  function openMessages(filter = '') {
251
+ messageMode = 'history';
252
+ messagesHistory.setAttribute('aria-pressed', 'true');
253
+ messagesUnreadAge.setAttribute('aria-pressed', 'false');
182
254
  messageFilter = filter;
183
255
  messagesView.hidden = false;
184
256
  root.hidden = true;
@@ -197,6 +269,9 @@
197
269
  messagesToggle.classList.remove('active');
198
270
  messagesToggle.focus();
199
271
  messageEntries = [];
272
+ unreadAgeEntries = [];
273
+ clearTimeout(ageRefreshTimer);
274
+ ageRefreshTimer = null;
200
275
  scheduleMessageRefresh();
201
276
  }
202
277
  const PREF = 'shellpuppet.dashboard';
@@ -1695,6 +1770,8 @@
1695
1770
  messagesToggle.addEventListener('click', () => {
1696
1771
  if (messagesView.hidden) openMessages(); else closeMessages();
1697
1772
  });
1773
+ messagesHistory.addEventListener('click', () => { setMessageMode('history'); });
1774
+ messagesUnreadAge.addEventListener('click', () => { setMessageMode('unread'); });
1698
1775
  messagesFilter.addEventListener('change', () => {
1699
1776
  messageFilter = messagesFilter.value;
1700
1777
  messageSelection = null;
@@ -1723,6 +1800,7 @@
1723
1800
  endActiveDivider?.();
1724
1801
  clearTimeout(retry);
1725
1802
  clearTimeout(messageTimer);
1803
+ clearTimeout(ageRefreshTimer);
1726
1804
  clearTimeout(autoFitTimer);
1727
1805
  window.cancelAnimationFrame(fontFitFrame);
1728
1806
  feed?.close();
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ShellPuppet pane: the terminal client for one session in one container.
3
3
  *
4
- * It owns frame handling, typing (with term.onData registered once), sizing,
4
+ * It owns frame handling, input (with term.onData and term.onBinary registered once), sizing,
5
5
  * reconnect and badges for one session. The page provides the container and
6
6
  * badge elements, and wires up its controls.
7
7
  *
@@ -9,13 +9,11 @@
9
9
  * live stream and the exit notice); TEXT frames are JSON control messages:
10
10
  * `identity`, `geometry`, `input-source`, `input-refused`, `exited`,
11
11
  * `prompt-stall`, `prompt-clear`, `session-stalled` and `session-stall-clear`.
12
- * What this pane sends is text: a JSON
13
- * resize message, or bytes for the program, which are either keystrokes or
14
- * the terminal's own answers to the program's queries. The daemon tells those
15
- * two apart.
12
+ * This pane sends text frames for JSON controls and onData input, and binary
13
+ * frames for onBinary input. The latter contains one byte per character.
16
14
  *
17
15
  * Three rules shape the pane:
18
- * - `term.onData` is registered exactly ONCE, never inside the connect path.
16
+ * - `term.onData` and `term.onBinary` are registered exactly ONCE, outside the connect path.
19
17
  * Registering per-connect would stack a listener per reconnect and send
20
18
  * every keystroke N times.
21
19
  * - The pane measures what grid this window would like, and asks
@@ -875,6 +873,12 @@ window.ShellPuppetPane = (() => {
875
873
  if (destroyed || sessionEnded || readOnly) return;
876
874
  if (ws && ws.readyState === 1) ws.send(data);
877
875
  });
876
+ term.onBinary((data) => {
877
+ if (destroyed || sessionEnded || readOnly || !ws || ws.readyState !== 1) return;
878
+ const bytes = new Uint8Array(data.length);
879
+ for (let i = 0; i < data.length; i++) bytes[i] = data.charCodeAt(i);
880
+ ws.send(bytes);
881
+ });
878
882
 
879
883
  function showReadOnly() {
880
884
  if (!elements.readonly) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shellpuppet",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Supervised terminal sessions for AI agents: an agent drives a real terminal while you watch, type and approve. Like Playwright, but for the terminal. An MCP server and CLI over a per-user daemon, with a live browser viewer on the same session.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Red Eagle Tech Ltd",