shellpuppet 0.0.1 → 0.1.0
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/LICENSE +202 -0
- package/NOTICE +31 -0
- package/README.md +340 -8
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +693 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/http.d.ts +82 -0
- package/dist/client/http.js +225 -0
- package/dist/client/http.js.map +1 -0
- package/dist/core/dialogs.d.ts +88 -0
- package/dist/core/dialogs.js +214 -0
- package/dist/core/dialogs.js.map +1 -0
- package/dist/core/echo.d.ts +71 -0
- package/dist/core/echo.js +249 -0
- package/dist/core/echo.js.map +1 -0
- package/dist/core/find.d.ts +34 -0
- package/dist/core/find.js +41 -0
- package/dist/core/find.js.map +1 -0
- package/dist/core/keys.d.ts +22 -0
- package/dist/core/keys.js +80 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/manager.d.ts +66 -0
- package/dist/core/manager.js +158 -0
- package/dist/core/manager.js.map +1 -0
- package/dist/core/nativePty.d.ts +69 -0
- package/dist/core/nativePty.js +156 -0
- package/dist/core/nativePty.js.map +1 -0
- package/dist/core/policy.d.ts +61 -0
- package/dist/core/policy.js +143 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/promptDetector.d.ts +75 -0
- package/dist/core/promptDetector.js +606 -0
- package/dist/core/promptDetector.js.map +1 -0
- package/dist/core/reasoning.d.ts +252 -0
- package/dist/core/reasoning.js +740 -0
- package/dist/core/reasoning.js.map +1 -0
- package/dist/core/regexBudget.d.ts +44 -0
- package/dist/core/regexBudget.js +79 -0
- package/dist/core/regexBudget.js.map +1 -0
- package/dist/core/renderer.d.ts +112 -0
- package/dist/core/renderer.js +225 -0
- package/dist/core/renderer.js.map +1 -0
- package/dist/core/session.d.ts +311 -0
- package/dist/core/session.js +966 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/types.d.ts +281 -0
- package/dist/core/types.js +47 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/waiter.d.ts +86 -0
- package/dist/core/waiter.js +317 -0
- package/dist/core/waiter.js.map +1 -0
- package/dist/core/windowsPtyStart.d.ts +90 -0
- package/dist/core/windowsPtyStart.js +129 -0
- package/dist/core/windowsPtyStart.js.map +1 -0
- package/dist/daemon/audit.d.ts +23 -0
- package/dist/daemon/audit.js +51 -0
- package/dist/daemon/audit.js.map +1 -0
- package/dist/daemon/auth.d.ts +127 -0
- package/dist/daemon/auth.js +241 -0
- package/dist/daemon/auth.js.map +1 -0
- package/dist/daemon/config.d.ts +76 -0
- package/dist/daemon/config.js +301 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/index.d.ts +7 -0
- package/dist/daemon/index.js +87 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/liveness.d.ts +36 -0
- package/dist/daemon/liveness.js +71 -0
- package/dist/daemon/liveness.js.map +1 -0
- package/dist/daemon/logger.d.ts +7 -0
- package/dist/daemon/logger.js +29 -0
- package/dist/daemon/logger.js.map +1 -0
- package/dist/daemon/meta.d.ts +9 -0
- package/dist/daemon/meta.js +24 -0
- package/dist/daemon/meta.js.map +1 -0
- package/dist/daemon/paths.d.ts +83 -0
- package/dist/daemon/paths.js +154 -0
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/screenshot.d.ts +87 -0
- package/dist/daemon/screenshot.js +256 -0
- package/dist/daemon/screenshot.js.map +1 -0
- package/dist/daemon/server.d.ts +244 -0
- package/dist/daemon/server.js +2187 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/terminalReports.d.ts +38 -0
- package/dist/daemon/terminalReports.js +84 -0
- package/dist/daemon/terminalReports.js.map +1 -0
- package/dist/daemon/viewerLauncher.d.ts +135 -0
- package/dist/daemon/viewerLauncher.js +280 -0
- package/dist/daemon/viewerLauncher.js.map +1 -0
- package/dist/daemon/viewerSync.d.ts +38 -0
- package/dist/daemon/viewerSync.js +83 -0
- package/dist/daemon/viewerSync.js.map +1 -0
- package/dist/mcp/config.d.ts +57 -0
- package/dist/mcp/config.js +106 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +10 -0
- package/dist/mcp/index.js +69 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +59 -0
- package/dist/mcp/tools.js +537 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/viewer/icon-16.png +0 -0
- package/dist/viewer/icon-180.png +0 -0
- package/dist/viewer/icon-32.png +0 -0
- package/dist/viewer/icon-512.png +0 -0
- package/dist/viewer/icon.svg +66 -0
- package/dist/viewer/index.html +56 -0
- package/dist/viewer/viewer.css +84 -0
- package/dist/viewer/viewer.js +661 -0
- package/package.json +66 -7
- package/index.js +0 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `~/.shellpuppet/` layout, permission hardening and the daemon state file
|
|
3
|
+
* (design §2.2, §2.3, §4.1).
|
|
4
|
+
*
|
|
5
|
+
* Everything honours `SHELLPUPPET_HOME` so tests (and unusual setups) can
|
|
6
|
+
* isolate themselves completely from the real per-user directory.
|
|
7
|
+
*/
|
|
8
|
+
/** Daemon discovery record: written atomically, read by every client. */
|
|
9
|
+
export interface DaemonState {
|
|
10
|
+
port: number;
|
|
11
|
+
token: string;
|
|
12
|
+
pid: number;
|
|
13
|
+
version: string;
|
|
14
|
+
startedAt: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function shellpuppetHome(env?: NodeJS.ProcessEnv): string;
|
|
17
|
+
export declare function daemonStatePath(home: string): string;
|
|
18
|
+
export declare function daemonLogPath(home: string): string;
|
|
19
|
+
export declare function configPath(home: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Create the home directory if absent and harden its permissions on first
|
|
22
|
+
* creation (design §4.1). `fs.chmod` is a near-no-op on Windows, so there we
|
|
23
|
+
* strip ACL inheritance and grant only the current user, with `(OI)(CI)` so
|
|
24
|
+
* files created inside inherit the restriction. POSIX gets a real 0700.
|
|
25
|
+
*
|
|
26
|
+
* Hardening failures are reported, not fatal: a working daemon with a warning
|
|
27
|
+
* beats a dead one, and the token file being unreadable to others is
|
|
28
|
+
* defence-in-depth on top of loopback binding + bearer auth.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ensureHome(home: string): Promise<{
|
|
31
|
+
created: boolean;
|
|
32
|
+
warning?: string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* What the state file holds: a daemon record; content that is not one (an
|
|
36
|
+
* emptied, truncated or hand-edited file), kept so that only that same content
|
|
37
|
+
* is ever removed; nothing; or a read that failed, which says nothing about
|
|
38
|
+
* the content and so is left alone.
|
|
39
|
+
*/
|
|
40
|
+
export type DaemonStateFile = {
|
|
41
|
+
kind: 'record';
|
|
42
|
+
state: DaemonState;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'not-a-record';
|
|
45
|
+
raw: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'missing';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'unreadable';
|
|
50
|
+
};
|
|
51
|
+
export declare function inspectDaemonState(home: string): DaemonStateFile;
|
|
52
|
+
export declare function readDaemonState(home: string): DaemonState | null;
|
|
53
|
+
export declare function removeDaemonState(home: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Remove the state file only while it still names `record`'s daemon, so that
|
|
56
|
+
* clearing a stale record cannot delete one that another daemon has just
|
|
57
|
+
* claimed in its place.
|
|
58
|
+
*/
|
|
59
|
+
export declare function removeDaemonStateIf(home: string, record: {
|
|
60
|
+
pid: number;
|
|
61
|
+
port: number;
|
|
62
|
+
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Remove a state file that holds no daemon record, only while it still holds
|
|
65
|
+
* exactly the content `raw` that was judged. A claim links a complete file
|
|
66
|
+
* into place, so a record claimed in the meantime stays; a writer outside
|
|
67
|
+
* ShellPuppet that rewrites the file in place can still lose its write.
|
|
68
|
+
*/
|
|
69
|
+
export declare function removeDaemonStateIfNotARecord(home: string, raw: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Atomically CLAIM the state file (design §2.2's crash-safe startup, extended
|
|
72
|
+
* for the auto-start race). Two daemons racing must not both believe they won:
|
|
73
|
+
*
|
|
74
|
+
* 1. content is written to a temp file in the same directory (never partial);
|
|
75
|
+
* 2. `fs.link(temp, daemon.json)` publishes it: link() fails with EEXIST if
|
|
76
|
+
* the file exists, so exactly one racer succeeds. (A plain rename() would
|
|
77
|
+
* overwrite and let the LAST writer win while both think they did.)
|
|
78
|
+
*
|
|
79
|
+
* Returns false when a file is already there. The caller then judges what it
|
|
80
|
+
* holds: it defers to a running daemon, or clears a record whose daemon has
|
|
81
|
+
* gone, or a file that holds no record, and retries.
|
|
82
|
+
*/
|
|
83
|
+
export declare function claimDaemonState(home: string, state: DaemonState): boolean;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `~/.shellpuppet/` layout, permission hardening and the daemon state file
|
|
3
|
+
* (design §2.2, §2.3, §4.1).
|
|
4
|
+
*
|
|
5
|
+
* Everything honours `SHELLPUPPET_HOME` so tests (and unusual setups) can
|
|
6
|
+
* isolate themselves completely from the real per-user directory.
|
|
7
|
+
*/
|
|
8
|
+
import { execFile } from 'node:child_process';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import { promisify } from 'node:util';
|
|
13
|
+
const execFileAsync = promisify(execFile);
|
|
14
|
+
export function shellpuppetHome(env = process.env) {
|
|
15
|
+
return env['SHELLPUPPET_HOME'] ?? path.join(os.homedir(), '.shellpuppet');
|
|
16
|
+
}
|
|
17
|
+
export function daemonStatePath(home) {
|
|
18
|
+
return path.join(home, 'daemon.json');
|
|
19
|
+
}
|
|
20
|
+
export function daemonLogPath(home) {
|
|
21
|
+
return path.join(home, 'daemon.log');
|
|
22
|
+
}
|
|
23
|
+
export function configPath(home) {
|
|
24
|
+
return path.join(home, 'config.json');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create the home directory if absent and harden its permissions on first
|
|
28
|
+
* creation (design §4.1). `fs.chmod` is a near-no-op on Windows, so there we
|
|
29
|
+
* strip ACL inheritance and grant only the current user, with `(OI)(CI)` so
|
|
30
|
+
* files created inside inherit the restriction. POSIX gets a real 0700.
|
|
31
|
+
*
|
|
32
|
+
* Hardening failures are reported, not fatal: a working daemon with a warning
|
|
33
|
+
* beats a dead one, and the token file being unreadable to others is
|
|
34
|
+
* defence-in-depth on top of loopback binding + bearer auth.
|
|
35
|
+
*/
|
|
36
|
+
export async function ensureHome(home) {
|
|
37
|
+
if (fs.existsSync(home))
|
|
38
|
+
return { created: false };
|
|
39
|
+
fs.mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
40
|
+
if (process.platform === 'win32') {
|
|
41
|
+
const user = process.env['USERNAME'];
|
|
42
|
+
if (user === undefined || user === '') {
|
|
43
|
+
return { created: true, warning: 'USERNAME not set: directory ACL not hardened' };
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await execFileAsync('icacls', [home, '/inheritance:r', '/grant:r', `${user}:(OI)(CI)F`], { windowsHide: true });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return { created: true, warning: `icacls hardening failed: ${String(error)}` };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
fs.chmodSync(home, 0o700);
|
|
54
|
+
}
|
|
55
|
+
return { created: true };
|
|
56
|
+
}
|
|
57
|
+
export function inspectDaemonState(home) {
|
|
58
|
+
let raw;
|
|
59
|
+
try {
|
|
60
|
+
raw = fs.readFileSync(daemonStatePath(home), 'utf8');
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return error.code === 'ENOENT'
|
|
64
|
+
? { kind: 'missing' }
|
|
65
|
+
: { kind: 'unreadable' };
|
|
66
|
+
}
|
|
67
|
+
const state = parseDaemonState(raw);
|
|
68
|
+
return state !== null ? { kind: 'record', state } : { kind: 'not-a-record', raw };
|
|
69
|
+
}
|
|
70
|
+
function parseDaemonState(raw) {
|
|
71
|
+
try {
|
|
72
|
+
const parsed = JSON.parse(raw);
|
|
73
|
+
if (typeof parsed === 'object' &&
|
|
74
|
+
parsed !== null &&
|
|
75
|
+
typeof parsed.port === 'number' &&
|
|
76
|
+
typeof parsed.token === 'string' &&
|
|
77
|
+
typeof parsed.pid === 'number') {
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function readDaemonState(home) {
|
|
87
|
+
const file = inspectDaemonState(home);
|
|
88
|
+
return file.kind === 'record' ? file.state : null;
|
|
89
|
+
}
|
|
90
|
+
export function removeDaemonState(home) {
|
|
91
|
+
try {
|
|
92
|
+
fs.unlinkSync(daemonStatePath(home));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Already gone, which is fine.
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Remove the state file only while it still names `record`'s daemon, so that
|
|
100
|
+
* clearing a stale record cannot delete one that another daemon has just
|
|
101
|
+
* claimed in its place.
|
|
102
|
+
*/
|
|
103
|
+
export function removeDaemonStateIf(home, record) {
|
|
104
|
+
const current = readDaemonState(home);
|
|
105
|
+
if (current !== null && current.pid === record.pid && current.port === record.port) {
|
|
106
|
+
removeDaemonState(home);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Remove a state file that holds no daemon record, only while it still holds
|
|
111
|
+
* exactly the content `raw` that was judged. A claim links a complete file
|
|
112
|
+
* into place, so a record claimed in the meantime stays; a writer outside
|
|
113
|
+
* ShellPuppet that rewrites the file in place can still lose its write.
|
|
114
|
+
*/
|
|
115
|
+
export function removeDaemonStateIfNotARecord(home, raw) {
|
|
116
|
+
const current = inspectDaemonState(home);
|
|
117
|
+
if (current.kind === 'not-a-record' && current.raw === raw) {
|
|
118
|
+
removeDaemonState(home);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Atomically CLAIM the state file (design §2.2's crash-safe startup, extended
|
|
123
|
+
* for the auto-start race). Two daemons racing must not both believe they won:
|
|
124
|
+
*
|
|
125
|
+
* 1. content is written to a temp file in the same directory (never partial);
|
|
126
|
+
* 2. `fs.link(temp, daemon.json)` publishes it: link() fails with EEXIST if
|
|
127
|
+
* the file exists, so exactly one racer succeeds. (A plain rename() would
|
|
128
|
+
* overwrite and let the LAST writer win while both think they did.)
|
|
129
|
+
*
|
|
130
|
+
* Returns false when a file is already there. The caller then judges what it
|
|
131
|
+
* holds: it defers to a running daemon, or clears a record whose daemon has
|
|
132
|
+
* gone, or a file that holds no record, and retries.
|
|
133
|
+
*/
|
|
134
|
+
export function claimDaemonState(home, state) {
|
|
135
|
+
const target = daemonStatePath(home);
|
|
136
|
+
const temp = path.join(home, `daemon.json.${String(state.pid)}.tmp`);
|
|
137
|
+
fs.writeFileSync(temp, JSON.stringify(state, null, 2), { mode: 0o600 });
|
|
138
|
+
try {
|
|
139
|
+
fs.linkSync(temp, target);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
try {
|
|
147
|
+
fs.unlinkSync(temp);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Best effort.
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/daemon/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO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AAC,IAAI,KAAK,cAAc,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;QAC3D,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAkB;IAC/D,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,IAAI,CAAC;QACH,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A picture of the viewer, as a browser draws it (design §5).
|
|
3
|
+
*
|
|
4
|
+
* The daemon's text snapshot is what the agent reads; the viewer is what the
|
|
5
|
+
* human sees, and the two can disagree: when the renderer is right and only
|
|
6
|
+
* the page is wrong, no text tool can tell. This module opens the real viewer
|
|
7
|
+
* page in the same Chromium the isolated viewer window uses, headless, drives
|
|
8
|
+
* it over the DevTools protocol and returns the pixels plus the text of each
|
|
9
|
+
* row xterm drew. It uses the WebSocket client the daemon already depends on,
|
|
10
|
+
* and no bundled browser (viewerLauncher.ts says why).
|
|
11
|
+
*
|
|
12
|
+
* The page is opened in capture mode (`capture=1`): chrome hidden, the grid
|
|
13
|
+
* held at the daemon's geometry, never a resize sent and a flag raised once
|
|
14
|
+
* the first snapshot has been drawn, which is what this waits on. A
|
|
15
|
+
* screenshot must not change what the program sees.
|
|
16
|
+
*
|
|
17
|
+
* Daemon-side only; logging through the injected logger.
|
|
18
|
+
*/
|
|
19
|
+
import WebSocket from 'ws';
|
|
20
|
+
import type { Logger } from '../core/types.js';
|
|
21
|
+
export interface CaptureOptions {
|
|
22
|
+
/** A Chromium-family binary, as `findBrowser()` reports it. */
|
|
23
|
+
browser: string;
|
|
24
|
+
/** The viewer URL, viewer grant included. Capture mode is added here. */
|
|
25
|
+
viewerUrl: string;
|
|
26
|
+
/** Browser window size in CSS pixels; the grid scales its font to fill it. */
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
/** Budget for the whole capture, browser start to screenshot. */
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Open the page as a viewer that may drive the grid, as a human's window
|
|
33
|
+
* does, rather than in capture mode. Readiness is then the probe below,
|
|
34
|
+
* which such a call should always give.
|
|
35
|
+
*/
|
|
36
|
+
drive?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* An expression evaluated in the page, whose value comes back as `probe`.
|
|
39
|
+
* The picture waits for it to be truthy: after the first paint in capture
|
|
40
|
+
* mode, as the whole of readiness when driving.
|
|
41
|
+
*/
|
|
42
|
+
probe?: string;
|
|
43
|
+
logger?: Logger;
|
|
44
|
+
}
|
|
45
|
+
export interface Capture {
|
|
46
|
+
png: Buffer;
|
|
47
|
+
/** The picture's dimensions, read from the PNG itself. */
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
/** What `probe` evaluated to, when one was given. */
|
|
51
|
+
probe?: unknown;
|
|
52
|
+
/**
|
|
53
|
+
* The text of each viewport row as xterm drew it: right-trimmed, trailing
|
|
54
|
+
* blank rows dropped. That is the same shape as the daemon snapshot's lines,
|
|
55
|
+
* so the two can be compared directly.
|
|
56
|
+
*/
|
|
57
|
+
rows: string[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Budget for a whole capture: starting the browser, connecting to DevTools,
|
|
61
|
+
* loading the page, waiting for its first snapshot and the screenshot
|
|
62
|
+
* itself. Cold starts dominate the figure and vary widely: a capture that
|
|
63
|
+
* worked took 20.8 s on a cold Windows CI runner. So the default is 45 s,
|
|
64
|
+
* about twice that.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DEFAULT_CAPTURE_TIMEOUT_MS = 45000;
|
|
67
|
+
/** The range a caller may ask for instead. */
|
|
68
|
+
export declare const MIN_CAPTURE_TIMEOUT_MS = 1000;
|
|
69
|
+
export declare const MAX_CAPTURE_TIMEOUT_MS = 120000;
|
|
70
|
+
/**
|
|
71
|
+
* The smallest DevTools client this needs: request ids in, results out.
|
|
72
|
+
* Exported for its unit test only.
|
|
73
|
+
*/
|
|
74
|
+
export declare class DevTools {
|
|
75
|
+
private readonly ws;
|
|
76
|
+
private readonly deadline;
|
|
77
|
+
private nextId;
|
|
78
|
+
private readonly pending;
|
|
79
|
+
constructor(ws: WebSocket, deadline: number);
|
|
80
|
+
send<T>(method: string, params?: Record<string, unknown>, sessionId?: string): Promise<T>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Open the viewer page headless, wait for its first snapshot to be drawn,
|
|
84
|
+
* and return the pixels and the rows. Throws when the browser will not start,
|
|
85
|
+
* DevTools will not answer or the page does not paint within the budget.
|
|
86
|
+
*/
|
|
87
|
+
export declare function captureViewer(options: CaptureOptions): Promise<Capture>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A picture of the viewer, as a browser draws it (design §5).
|
|
3
|
+
*
|
|
4
|
+
* The daemon's text snapshot is what the agent reads; the viewer is what the
|
|
5
|
+
* human sees, and the two can disagree: when the renderer is right and only
|
|
6
|
+
* the page is wrong, no text tool can tell. This module opens the real viewer
|
|
7
|
+
* page in the same Chromium the isolated viewer window uses, headless, drives
|
|
8
|
+
* it over the DevTools protocol and returns the pixels plus the text of each
|
|
9
|
+
* row xterm drew. It uses the WebSocket client the daemon already depends on,
|
|
10
|
+
* and no bundled browser (viewerLauncher.ts says why).
|
|
11
|
+
*
|
|
12
|
+
* The page is opened in capture mode (`capture=1`): chrome hidden, the grid
|
|
13
|
+
* held at the daemon's geometry, never a resize sent and a flag raised once
|
|
14
|
+
* the first snapshot has been drawn, which is what this waits on. A
|
|
15
|
+
* screenshot must not change what the program sees.
|
|
16
|
+
*
|
|
17
|
+
* Daemon-side only; logging through the injected logger.
|
|
18
|
+
*/
|
|
19
|
+
import { spawn } from 'node:child_process';
|
|
20
|
+
import * as fs from 'node:fs';
|
|
21
|
+
import * as os from 'node:os';
|
|
22
|
+
import * as path from 'node:path';
|
|
23
|
+
import WebSocket from 'ws';
|
|
24
|
+
import { NULL_LOGGER } from '../core/types.js';
|
|
25
|
+
/**
|
|
26
|
+
* Budget for a whole capture: starting the browser, connecting to DevTools,
|
|
27
|
+
* loading the page, waiting for its first snapshot and the screenshot
|
|
28
|
+
* itself. Cold starts dominate the figure and vary widely: a capture that
|
|
29
|
+
* worked took 20.8 s on a cold Windows CI runner. So the default is 45 s,
|
|
30
|
+
* about twice that.
|
|
31
|
+
*/
|
|
32
|
+
export const DEFAULT_CAPTURE_TIMEOUT_MS = 45_000;
|
|
33
|
+
/** The range a caller may ask for instead. */
|
|
34
|
+
export const MIN_CAPTURE_TIMEOUT_MS = 1_000;
|
|
35
|
+
export const MAX_CAPTURE_TIMEOUT_MS = 120_000;
|
|
36
|
+
const POLL_MS = 100;
|
|
37
|
+
/**
|
|
38
|
+
* The smallest DevTools client this needs: request ids in, results out.
|
|
39
|
+
* Exported for its unit test only.
|
|
40
|
+
*/
|
|
41
|
+
export class DevTools {
|
|
42
|
+
ws;
|
|
43
|
+
deadline;
|
|
44
|
+
nextId = 1;
|
|
45
|
+
pending = new Map();
|
|
46
|
+
constructor(ws, deadline) {
|
|
47
|
+
this.ws = ws;
|
|
48
|
+
this.deadline = deadline;
|
|
49
|
+
ws.on('message', (data) => {
|
|
50
|
+
let message;
|
|
51
|
+
try {
|
|
52
|
+
message = JSON.parse(String(data));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (typeof message.id !== 'number')
|
|
58
|
+
return; // an event; none are needed
|
|
59
|
+
const waiter = this.pending.get(message.id);
|
|
60
|
+
if (waiter === undefined)
|
|
61
|
+
return;
|
|
62
|
+
this.pending.delete(message.id);
|
|
63
|
+
if (message.error !== undefined) {
|
|
64
|
+
waiter.reject(new Error(message.error.message ?? 'DevTools error'));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
waiter.resolve(message.result);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
ws.on('close', () => {
|
|
71
|
+
for (const waiter of this.pending.values()) {
|
|
72
|
+
waiter.reject(new Error('DevTools connection closed'));
|
|
73
|
+
}
|
|
74
|
+
this.pending.clear();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
send(method, params = {}, sessionId) {
|
|
78
|
+
const id = this.nextId++;
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
// Every call shares the capture's deadline: a browser that accepts the
|
|
81
|
+
// connection and then never answers, as a wedged renderer does, fails
|
|
82
|
+
// the capture at the deadline rather than holding the agent's tool call
|
|
83
|
+
// open.
|
|
84
|
+
const timer = setTimeout(() => {
|
|
85
|
+
if (this.pending.delete(id)) {
|
|
86
|
+
reject(new Error(`DevTools did not answer ${method} in time.`));
|
|
87
|
+
}
|
|
88
|
+
}, Math.max(0, this.deadline - Date.now()));
|
|
89
|
+
this.pending.set(id, {
|
|
90
|
+
resolve: (result) => {
|
|
91
|
+
clearTimeout(timer);
|
|
92
|
+
resolve(result);
|
|
93
|
+
},
|
|
94
|
+
reject: (error) => {
|
|
95
|
+
clearTimeout(timer);
|
|
96
|
+
reject(error);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
this.ws.send(JSON.stringify({
|
|
100
|
+
id,
|
|
101
|
+
method,
|
|
102
|
+
params,
|
|
103
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function sleep(ms) {
|
|
109
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Chromium announces its DevTools endpoint by writing `DevToolsActivePort`
|
|
113
|
+
* into the profile directory: the port on line one, the browser target's
|
|
114
|
+
* path on line two. `--remote-debugging-port=0` leaves the port to the OS.
|
|
115
|
+
*/
|
|
116
|
+
async function waitForDevTools(profileDir, child, deadline) {
|
|
117
|
+
const file = path.join(profileDir, 'DevToolsActivePort');
|
|
118
|
+
while (Date.now() < deadline) {
|
|
119
|
+
if (child.exitCode !== null) {
|
|
120
|
+
throw new Error(`The browser exited before it was ready (code ${String(child.exitCode)}).`);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const [port, target] = fs.readFileSync(file, 'utf8').split(/\r?\n/);
|
|
124
|
+
if (port !== undefined && port !== '' && target !== undefined && target.startsWith('/')) {
|
|
125
|
+
return `ws://127.0.0.1:${port}${target}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Not written yet.
|
|
130
|
+
}
|
|
131
|
+
await sleep(POLL_MS);
|
|
132
|
+
}
|
|
133
|
+
throw new Error('The browser did not expose DevTools in time.');
|
|
134
|
+
}
|
|
135
|
+
function connect(endpoint, deadline) {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
const ws = new WebSocket(endpoint, { perMessageDeflate: false });
|
|
138
|
+
const timer = setTimeout(() => {
|
|
139
|
+
ws.terminate();
|
|
140
|
+
reject(new Error('DevTools did not accept the connection in time.'));
|
|
141
|
+
}, Math.max(0, deadline - Date.now()));
|
|
142
|
+
ws.on('open', () => {
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
resolve(ws);
|
|
145
|
+
});
|
|
146
|
+
ws.on('error', (error) => {
|
|
147
|
+
clearTimeout(timer);
|
|
148
|
+
reject(error);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/** Rows as the daemon snapshot shapes them: right-trimmed, blank tail dropped. */
|
|
153
|
+
function normaliseRows(value) {
|
|
154
|
+
const rows = Array.isArray(value)
|
|
155
|
+
? value.map((row) => String(row).split(String.fromCharCode(0xa0)).join(' ').replace(/\s+$/, ''))
|
|
156
|
+
: [];
|
|
157
|
+
while (rows.length > 0 && rows[rows.length - 1] === '')
|
|
158
|
+
rows.pop();
|
|
159
|
+
return rows;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Open the viewer page headless, wait for its first snapshot to be drawn,
|
|
163
|
+
* and return the pixels and the rows. Throws when the browser will not start,
|
|
164
|
+
* DevTools will not answer or the page does not paint within the budget.
|
|
165
|
+
*/
|
|
166
|
+
export async function captureViewer(options) {
|
|
167
|
+
const logger = options.logger ?? NULL_LOGGER;
|
|
168
|
+
const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_CAPTURE_TIMEOUT_MS);
|
|
169
|
+
const profileDir = fs.mkdtempSync(path.join(os.tmpdir(), 'shellpuppet-capture-'));
|
|
170
|
+
const child = spawn(options.browser, [
|
|
171
|
+
'--headless=new',
|
|
172
|
+
'--remote-debugging-port=0',
|
|
173
|
+
`--user-data-dir=${profileDir}`,
|
|
174
|
+
`--window-size=${String(options.width)},${String(options.height)}`,
|
|
175
|
+
'--no-first-run',
|
|
176
|
+
'--no-default-browser-check',
|
|
177
|
+
'--hide-scrollbars',
|
|
178
|
+
'about:blank',
|
|
179
|
+
], { stdio: 'ignore', windowsHide: true });
|
|
180
|
+
const exited = new Promise((resolve) => {
|
|
181
|
+
child.once('exit', () => resolve());
|
|
182
|
+
child.once('error', () => resolve());
|
|
183
|
+
});
|
|
184
|
+
let ws = null;
|
|
185
|
+
try {
|
|
186
|
+
const endpoint = await waitForDevTools(profileDir, child, deadline);
|
|
187
|
+
ws = await connect(endpoint, deadline);
|
|
188
|
+
const cdp = new DevTools(ws, deadline);
|
|
189
|
+
const { targetId } = await cdp.send('Target.createTarget', {
|
|
190
|
+
url: 'about:blank',
|
|
191
|
+
});
|
|
192
|
+
const { sessionId } = await cdp.send('Target.attachToTarget', {
|
|
193
|
+
targetId,
|
|
194
|
+
flatten: true,
|
|
195
|
+
});
|
|
196
|
+
await cdp.send('Page.enable', {}, sessionId);
|
|
197
|
+
// The window size is an OUTER size, and Chromium enforces a minimum of
|
|
198
|
+
// its own, so a window size alone gives a picture smaller than asked for
|
|
199
|
+
// or, below the minimum, a different shape altogether (200×200 asked,
|
|
200
|
+
// 504×104 drawn). The viewport is set directly instead, at one CSS pixel
|
|
201
|
+
// per device pixel.
|
|
202
|
+
await cdp.send('Emulation.setDeviceMetricsOverride', { width: options.width, height: options.height, deviceScaleFactor: 1, mobile: false }, sessionId);
|
|
203
|
+
const url = options.drive === true
|
|
204
|
+
? options.viewerUrl
|
|
205
|
+
: `${options.viewerUrl}${options.viewerUrl.includes('?') ? '&' : '?'}capture=1`;
|
|
206
|
+
await cdp.send('Page.navigate', { url }, sessionId);
|
|
207
|
+
const evaluate = async (expression) => {
|
|
208
|
+
const evaluated = await cdp.send('Runtime.evaluate', { expression, returnByValue: true }, sessionId);
|
|
209
|
+
return evaluated.result.value;
|
|
210
|
+
};
|
|
211
|
+
// The page raises the flag once the daemon's snapshot has been parsed and
|
|
212
|
+
// drawn. That, not the load event, is the picture being ready. A driving
|
|
213
|
+
// page never raises it (the flag exists for pictures), so there the probe
|
|
214
|
+
// is what says the page has settled.
|
|
215
|
+
let probed;
|
|
216
|
+
for (;;) {
|
|
217
|
+
const painted = options.drive === true ||
|
|
218
|
+
(await evaluate('window.__shellpuppetPainted === true')) === true;
|
|
219
|
+
probed = options.probe === undefined ? undefined : await evaluate(options.probe);
|
|
220
|
+
if (painted && (options.probe === undefined || Boolean(probed)))
|
|
221
|
+
break;
|
|
222
|
+
if (Date.now() >= deadline)
|
|
223
|
+
throw new Error('The viewer did not paint in time.');
|
|
224
|
+
await sleep(POLL_MS);
|
|
225
|
+
}
|
|
226
|
+
const rows = await cdp.send('Runtime.evaluate', {
|
|
227
|
+
expression: "Array.from(document.querySelectorAll('.xterm-rows > div')).map((row) => row.textContent || '')",
|
|
228
|
+
returnByValue: true,
|
|
229
|
+
}, sessionId);
|
|
230
|
+
const shot = await cdp.send('Page.captureScreenshot', { format: 'png' }, sessionId);
|
|
231
|
+
await cdp.send('Browser.close').catch(() => undefined);
|
|
232
|
+
const png = Buffer.from(shot.data, 'base64');
|
|
233
|
+
return {
|
|
234
|
+
png,
|
|
235
|
+
// IHDR is always the first chunk: width and height at bytes 16 and 20.
|
|
236
|
+
width: png.readUInt32BE(16),
|
|
237
|
+
height: png.readUInt32BE(20),
|
|
238
|
+
rows: normaliseRows(rows.result.value),
|
|
239
|
+
...(probed === undefined ? {} : { probe: probed }),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
ws?.close();
|
|
244
|
+
if (child.exitCode === null)
|
|
245
|
+
child.kill();
|
|
246
|
+
// The profile can be removed once the browser has let go of it.
|
|
247
|
+
await Promise.race([exited, sleep(3_000)]);
|
|
248
|
+
try {
|
|
249
|
+
fs.rmSync(profileDir, { recursive: true, force: true, maxRetries: 3 });
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
logger.warn('capture profile not removed', { profileDir, error: String(error) });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/daemon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