pw-repl 0.12.2 → 0.12.4
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 +3 -3
- package/lib/help.js +2 -1
- package/lib/launch.js +6 -2
- package/lib/record.js +2 -3
- package/lib/util.js +16 -1
- package/package.json +1 -1
- package/skill/SKILL.md +2 -1
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ in one it starts itself. You type commands at a `pw>` prompt. Agents send the sa
|
|
|
8
8
|
with `pw-repl send`. Every command shows in the REPL, whoever sent it, so you always see what an agent
|
|
9
9
|
is doing in your browser, and the agent can see what you did.
|
|
10
10
|
|
|
11
|
-
[](https://github.com/user-attachments/assets/c4114933-8ef2-455e-bc9e-1dd6f1fe9c07)
|
|
12
12
|
|
|
13
|
-
A 90-second demo
|
|
14
|
-
|
|
13
|
+
A 90-second demo, recorded by pw-repl itself from one script of commands. The command panel on the
|
|
14
|
+
right is part of the demo page, showing what the agent sends.
|
|
15
15
|
|
|
16
16
|
```text
|
|
17
17
|
pw> tab new http://localhost:3000/cart
|
package/lib/help.js
CHANGED
|
@@ -573,7 +573,8 @@ A (page) line marks each new page, loaded or routed to by a single-page app. It
|
|
|
573
573
|
video.
|
|
574
574
|
|
|
575
575
|
ffmpeg: $PW_FFMPEG, and only it when it is set (the REPL's, not send's); otherwise Playwright's own (npx
|
|
576
|
-
playwright-core install ffmpeg, in $PLAYWRIGHT_BROWSERS_PATH or ~/.cache/ms-playwright
|
|
576
|
+
playwright-core install ffmpeg, in $PLAYWRIGHT_BROWSERS_PATH, or ~/.cache/ms-playwright on Linux and
|
|
577
|
+
~/Library/Caches/ms-playwright on macOS), then one on the
|
|
577
578
|
PATH. Playwright's writes only WebM; an MP4 needs a system ffmpeg with H.264. Without one that can write
|
|
578
579
|
the format, record on fails at once, recording nothing. WebM plays in browsers, GitHub, GitLab and Slack;
|
|
579
580
|
MP4 everywhere. About 15 MB a minute.`,
|
package/lib/launch.js
CHANGED
|
@@ -6,6 +6,7 @@ const { spawn } = require('child_process');
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const os = require('os');
|
|
8
8
|
const path = require('path');
|
|
9
|
+
const { playwrightBrowsersDir } = require('./util');
|
|
9
10
|
|
|
10
11
|
const START_TIMEOUT = 20000;
|
|
11
12
|
// Stopping: a moment to connect and ask it to close, a few seconds to close, as long again after SIGTERM,
|
|
@@ -31,11 +32,14 @@ function findChrome() {
|
|
|
31
32
|
if (fs.existsSync(bundled)) return bundled;
|
|
32
33
|
} catch {}
|
|
33
34
|
// Any Chromium works over CDP, so a revision other than this Playwright's is fine.
|
|
34
|
-
const dir =
|
|
35
|
+
const dir = playwrightBrowsersDir();
|
|
35
36
|
let names = [];
|
|
36
37
|
try { names = fs.readdirSync(dir).filter(n => /^chromium-\d+$/.test(n)).sort().reverse(); } catch {}
|
|
37
38
|
for (const name of names) {
|
|
38
|
-
for (const sub of ['chrome-linux64/chrome', 'chrome-linux/chrome', 'chrome-
|
|
39
|
+
for (const sub of ['chrome-linux64/chrome', 'chrome-linux-arm64/chrome', 'chrome-linux/chrome', 'chrome-win64/chrome.exe',
|
|
40
|
+
'chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
|
|
41
|
+
'chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
|
|
42
|
+
'chrome-mac/Chromium.app/Contents/MacOS/Chromium']) {
|
|
39
43
|
const candidate = path.join(dir, name, sub);
|
|
40
44
|
if (fs.existsSync(candidate)) return candidate;
|
|
41
45
|
}
|
package/lib/record.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// Recording a tab's page to a video, from Chrome's screencast of it through ffmpeg.
|
|
2
2
|
const { spawn, execFileSync } = require('child_process');
|
|
3
3
|
const fs = require('fs');
|
|
4
|
-
const os = require('os');
|
|
5
4
|
const path = require('path');
|
|
6
5
|
const { state, onShutdown } = require('./state');
|
|
7
6
|
const out = require('./output');
|
|
8
7
|
const { tabState } = require('./tabstate');
|
|
9
|
-
const { clock, NO_TAB, STOPPED_RECORDING, ENDED_UNSEEN } = require('./util');
|
|
8
|
+
const { clock, NO_TAB, STOPPED_RECORDING, ENDED_UNSEEN, playwrightBrowsersDir } = require('./util');
|
|
10
9
|
const { shellWords, splitSelector } = require('./syntax');
|
|
11
10
|
const { reapplyMetrics } = require('./emulation');
|
|
12
11
|
|
|
@@ -38,7 +37,7 @@ const FORMAT_NAMES = { webm: 'WebM (VP8)', mp4: 'MP4 (H.264)' };
|
|
|
38
37
|
// Playwright's own (wherever PLAYWRIGHT_BROWSERS_PATH puts it), then one on the PATH.
|
|
39
38
|
function ffmpegCandidates() {
|
|
40
39
|
const found = [];
|
|
41
|
-
const dir =
|
|
40
|
+
const dir = playwrightBrowsersDir();
|
|
42
41
|
let names = [];
|
|
43
42
|
try { names = fs.readdirSync(dir).filter(n => /^ffmpeg-\d+$/.test(n)).sort().reverse(); } catch {}
|
|
44
43
|
for (const name of names) {
|
package/lib/util.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Small helpers the commands share: output hints, clipping, times, patterns and number arguments.
|
|
2
2
|
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
3
6
|
const COMMAND_TIMEOUT = 15000;
|
|
4
7
|
|
|
5
8
|
const MAX_EVENT_TEXT = 4000;
|
|
@@ -51,4 +54,16 @@ function clock(t) {
|
|
|
51
54
|
const STOPPED_RECORDING = 'The REPL stopped, which ended a recording';
|
|
52
55
|
const ENDED_UNSEEN = 'A recording ended before the REPL stopped, unseen since';
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
// Where Playwright installs its browsers and ffmpeg, worked out as playwright-core does it: a cache of
|
|
58
|
+
// each platform's own (~/Library/Caches on macOS), unless PLAYWRIGHT_BROWSERS_PATH says otherwise.
|
|
59
|
+
function playwrightBrowsersDir() {
|
|
60
|
+
const given = process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
61
|
+
if (given === '0') return path.join(path.dirname(require.resolve('playwright-core/package.json')), '.local-browsers');
|
|
62
|
+
if (given) return path.resolve(process.env.INIT_CWD || process.cwd(), given);
|
|
63
|
+
const cache = process.platform === 'darwin' ? path.join(os.homedir(), 'Library', 'Caches')
|
|
64
|
+
: process.platform === 'win32' ? process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local')
|
|
65
|
+
: process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache');
|
|
66
|
+
return path.join(cache, 'ms-playwright');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = { STOPPED_RECORDING, ENDED_UNSEEN, COMMAND_TIMEOUT, MAX_EVENT_TEXT, NO_TAB, hints, clipText, numbers, regexOf, patternText, clock, playwrightBrowsersDir };
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -249,7 +249,8 @@ pw-repl send -c <name> close # your modes off; tab close
|
|
|
249
249
|
- `PW_FFMPEG` — the ffmpeg `record` uses, and no other, read by the REPL, not by `send` (default:
|
|
250
250
|
Playwright's own, then one on the `PATH`).
|
|
251
251
|
- Playwright's own Chromium and ffmpeg are found where Playwright installs them:
|
|
252
|
-
`PLAYWRIGHT_BROWSERS_PATH`, or `~/.cache/ms-playwright
|
|
252
|
+
`PLAYWRIGHT_BROWSERS_PATH`, or `~/.cache/ms-playwright` on Linux and `~/Library/Caches/ms-playwright`
|
|
253
|
+
on macOS.
|
|
253
254
|
- `PW_CDP_URL` — CDP endpoint (default `http://localhost:9222`).
|
|
254
255
|
- `PW_SCREENSHOT_DIR` — where the REPL saves screenshots (a folder that exists), read when it starts,
|
|
255
256
|
not by `send`. Without it, a REPL on a socket of its own saves them next to its socket, and any other
|