shellpuppet 0.5.0 → 0.5.1
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/README.md +1 -1
- package/dist/agents/claude/nudge.js +1 -1
- package/dist/agents/claude/nudge.js.map +1 -1
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.js +7 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/core/session.d.ts +26 -2
- package/dist/core/session.js +118 -18
- package/dist/core/session.js.map +1 -1
- package/dist/daemon/launchProfiles.d.ts +3 -2
- package/dist/daemon/launchProfiles.js +6 -4
- package/dist/daemon/launchProfiles.js.map +1 -1
- package/dist/daemon/screenshot.d.ts +2 -0
- package/dist/daemon/screenshot.js +21 -3
- package/dist/daemon/screenshot.js.map +1 -1
- package/dist/daemon/server.d.ts +4 -1
- package/dist/daemon/server.js +348 -253
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/terminalReports.d.ts +9 -1
- package/dist/daemon/terminalReports.js +54 -0
- package/dist/daemon/terminalReports.js.map +1 -1
- package/dist/viewer/pane.js +10 -6
- package/package.json +1 -1
|
@@ -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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B,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,MAAM,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"}
|
package/dist/viewer/pane.js
CHANGED
|
@@ -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,
|
|
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
|
-
*
|
|
13
|
-
*
|
|
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`
|
|
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.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|