thuthi-plugin 0.0.0-stage → 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/.claude-plugin/marketplace.json +55 -0
- package/README.md +13 -2
- package/bin/parallel-browser.js +109 -0
- package/extension/background.js +1329 -0
- package/extension/config.json +1 -0
- package/extension/guard.js +44 -0
- package/extension/manifest.json +10 -0
- package/extension/overlay.js +104 -0
- package/extension/popup.html +34 -0
- package/extension/popup.js +39 -0
- package/extension-reloader/manifest.json +13 -0
- package/extension-reloader/sw.js +17 -0
- package/package.json +13 -4
- package/plugins/thuthi/.claude-plugin/plugin.json +8 -0
- package/plugins/thuthi/context.md +3 -0
- package/plugins/thuthi/hooks/hooks.json +15 -0
- package/plugins/thuthi/skills/setup/SKILL.md +55 -0
- package/plugins/thuthi/skills/setup/scripts/doctor.py +249 -0
- package/plugins/thuthi/skills/setup/scripts/selftest.py +188 -0
- package/plugins/thuthi/tools/claude-switch/claude_switch.py +8 -0
- package/plugins/thuthi/tools/legacy_launcher.py +65 -0
- package/plugins/thuthi/tools/statusline/statusline.py +8 -0
- package/plugins/thuthi-accounts/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-accounts/bin/claude-switch +5 -0
- package/plugins/thuthi-accounts/bin/claude-switch.cmd +4 -0
- package/plugins/thuthi-accounts/hooks/hooks.json +15 -0
- package/plugins/thuthi-accounts/lib/tls.py +68 -0
- package/plugins/thuthi-accounts/lib/usage_store.py +150 -0
- package/plugins/thuthi-accounts/setup_check.py +21 -0
- package/plugins/thuthi-accounts/skills/claude-switch/SKILL.md +48 -0
- package/plugins/thuthi-accounts/tools/claude-switch/claude-switch-tui.py +397 -0
- package/plugins/thuthi-accounts/tools/claude-switch/claude_switch.py +1204 -0
- package/plugins/thuthi-accounts/tools/claude-switch/credstore.py +417 -0
- package/plugins/thuthi-accounts/tools/claude-switch/install.py +301 -0
- package/plugins/thuthi-accounts/tools/claude-switch/tests/selftest.py +491 -0
- package/plugins/thuthi-accounts/tools/statusline/statusline.py +212 -0
- package/plugins/thuthi-agenda-picker/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-agenda-picker/context.md +3 -0
- package/plugins/thuthi-agenda-picker/hooks/hooks.json +15 -0
- package/plugins/thuthi-agenda-picker/lib/pbpage.py +397 -0
- package/plugins/thuthi-agenda-picker/setup_check.py +18 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/SKILL.md +280 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/design-rules.md +110 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/diagram/base.css +33 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/agenda.json +146 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/A-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/A-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/B-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/B-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/C-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/C-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/base.css +33 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/name-B.html +15 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/now-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/now-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/picker.py +1286 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/selftest.py +771 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/shot.py +117 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/template.html +1029 -0
- package/plugins/thuthi-arch-diagram/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-arch-diagram/lib/pbpage.py +397 -0
- package/plugins/thuthi-arch-diagram/lib/tls.py +68 -0
- package/plugins/thuthi-arch-diagram/setup_check.py +10 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/SKILL.md +125 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/references/design-rules.md +110 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/references/example-shop.py +167 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/check.py +194 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/diagramkit.py +682 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/interact_test.py +115 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/render.py +113 -0
- package/plugins/thuthi-browser/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-browser/context.md +3 -0
- package/plugins/thuthi-browser/hooks/hooks.json +15 -0
- package/plugins/thuthi-browser/lib/pbpage.py +397 -0
- package/plugins/thuthi-browser/setup_check.py +93 -0
- package/plugins/thuthi-browser/skills/parallel-browser/SKILL.md +271 -0
- package/plugins/thuthi-browser/skills/parallel-browser/references/api.md +243 -0
- package/plugins/thuthi-browser/skills/parallel-browser/references/install.md +106 -0
- package/plugins/thuthi-demo-video/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-demo-video/lib/pbpage.py +397 -0
- package/plugins/thuthi-demo-video/setup_check.py +14 -0
- package/plugins/thuthi-demo-video/skills/demo-video/SKILL.md +261 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/caption.html +16 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/cursor.js +132 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/demo_video.py +2416 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/example_scenario.py +97 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/frame.html +95 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/overlay.js +129 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/title.html +30 -0
- package/plugins/thuthi-no-more-slop/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-no-more-slop/setup_check.py +10 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/LICENSE +21 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/SKILL.md +235 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/SOURCE.txt +1 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/agents/openai.yaml +6 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/examples.md +289 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/tokens.md +46 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/unslop-fallback.md +36 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/scripts/count_tells.py +426 -0
- package/plugins/thuthi-orca/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-orca/context.md +5 -0
- package/plugins/thuthi-orca/hooks/hooks.json +18 -0
- package/plugins/thuthi-orca/hooks/orca-team-grid.ts +21 -0
- package/plugins/thuthi-orca/setup_check.py +12 -0
- package/plugins/thuthi-orca/skills/orca-new-work/SKILL.md +492 -0
- package/plugins/thuthi-orca/tools/orca-team-grid/bin/tmux +338 -0
- package/plugins/thuthi-orca/tools/orca-team-grid/tests/selftest.py +299 -0
- package/runtime/client.js +69 -0
- package/runtime/daemon.js +503 -0
- package/runtime/focus-monitor.js +53 -0
- package/runtime/keys.js +86 -0
- package/runtime/owner.js +64 -0
- package/runtime/recorder.js +267 -0
- package/runtime/relay.js +95 -0
- package/runtime/session.js +1599 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""thuthi-browser 점검 · 고치기 (thuthi:setup 의 doctor.py 가 부른다). d = doctor 모듈 (run · version · market_root · 기호).
|
|
2
|
+
|
|
3
|
+
parallel-browser 런타임 · 확장은 플러그인 캐시에 없다 (플러그인은 plugins/thuthi-browser 만 가져간다). 마켓플레이스가 받아 둔
|
|
4
|
+
레포에서 npm install + npm link 하고, 확장은 그 레포의 extension/ 을 사람이 한 번 올린다.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
G = "parallel-browser"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def pb_link_target(d) -> str:
|
|
17
|
+
"""전역 parallel-browser 명령이 가리키는 레포."""
|
|
18
|
+
code, prefix = d.run(["npm", "prefix", "-g"]) if shutil.which("npm") else (1, "")
|
|
19
|
+
if code:
|
|
20
|
+
return ""
|
|
21
|
+
# macOS · Linux 는 <prefix>/lib/node_modules, Windows 는 <prefix>\\node_modules
|
|
22
|
+
for p in (Path(prefix.strip()) / "lib" / "node_modules" / "parallel-browser",
|
|
23
|
+
Path(prefix.strip()) / "node_modules" / "parallel-browser"):
|
|
24
|
+
if p.exists():
|
|
25
|
+
return str(p.resolve())
|
|
26
|
+
return ""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def check(d) -> list:
|
|
30
|
+
rows = []
|
|
31
|
+
add = lambda mark, item, note="": rows.append((G, mark, item, note))
|
|
32
|
+
node = d.version(["node", "--version"])
|
|
33
|
+
root = d.market_root()
|
|
34
|
+
add(d.OK if node and node >= (22, 0) else d.BAD, f"node {'.'.join(map(str, node)) if node else '없음'}",
|
|
35
|
+
"" if node and node >= (22, 0) else "brew install node (22 이상)")
|
|
36
|
+
st = {}
|
|
37
|
+
if shutil.which("parallel-browser"):
|
|
38
|
+
_, out = d.run(["parallel-browser", "status"], timeout=20)
|
|
39
|
+
try:
|
|
40
|
+
st = json.loads(out[out.index("{"):]).get("daemon", {})
|
|
41
|
+
except ValueError:
|
|
42
|
+
st = {}
|
|
43
|
+
target = pb_link_target(d)
|
|
44
|
+
want = str(root.resolve()) if root else ""
|
|
45
|
+
if not shutil.which("parallel-browser"):
|
|
46
|
+
add(d.BAD, "parallel-browser 명령", "doctor.py fix pb-runtime")
|
|
47
|
+
else:
|
|
48
|
+
same = bool(target) and target == want
|
|
49
|
+
add(d.OK if same or not want else d.OPT, "parallel-browser 명령",
|
|
50
|
+
f"→ {target or '알 수 없음'}" + ("" if same or not want else f" (마켓플레이스 레포가 아니다. doctor.py fix pb-runtime 으로 {want} 에 다시 건다)"))
|
|
51
|
+
if root:
|
|
52
|
+
has_ws = (root / "node_modules" / "ws").is_dir()
|
|
53
|
+
add(d.OK if has_ws else d.BAD, "런타임 의존성 (node_modules/ws)",
|
|
54
|
+
"" if has_ws else "doctor.py fix pb-runtime (마켓플레이스 업데이트가 레포를 새로 받으면 다시 해야 한다)")
|
|
55
|
+
if shutil.which("parallel-browser"):
|
|
56
|
+
pb = bool(st.get("connected"))
|
|
57
|
+
ext = f"{root / 'extension'}" if root else "레포의 extension/"
|
|
58
|
+
add(d.OK if pb else d.BAD, "브라우저 확장 연결 (스크린샷 · 검사 · 녹화가 모두 이것을 쓴다)",
|
|
59
|
+
(st.get("userAgent", "")[-40:] if pb else
|
|
60
|
+
f"Chrome · Edge 확장 화면에서 개발자 모드 → 압축 해제된 확장 로드 → {ext}"))
|
|
61
|
+
ex = st.get("extension")
|
|
62
|
+
if pb and ex is not None: # 자동 반영을 아는 데몬 (thuthi-browser 0.16 부터)
|
|
63
|
+
reloader = f"{root / 'extension-reloader'}" if root else "레포의 extension-reloader/"
|
|
64
|
+
edge = "Edg/" in st.get("userAgent", "")
|
|
65
|
+
if ex.get("upToDate"):
|
|
66
|
+
add(d.OK, "확장 자동 반영", "디스크의 확장과 같은 판이 돌고 있다. 업데이트는 데몬이 쉴 때 저절로 들어간다"
|
|
67
|
+
+ ("" if edge else f" (Chrome 은 도우미 확장 {reloader} 를 한 번 올려 두어야 저절로 들어간다)"))
|
|
68
|
+
else:
|
|
69
|
+
add(d.OPT, "확장 자동 반영", ex.get("note") or "새 판이 디스크에 있다. 이 PC 의 에이전트가 브라우저를 안 쓰는 때 데몬이 확장을 다시 불러온다"
|
|
70
|
+
+ ("" if edge else f" · Chrome 은 도우미 확장 {reloader} 를 한 번 올리면 다음부터 저절로 된다"))
|
|
71
|
+
return rows
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def fix(what: str, d):
|
|
75
|
+
if what != "pb-runtime":
|
|
76
|
+
return None
|
|
77
|
+
root = d.market_root()
|
|
78
|
+
if not root:
|
|
79
|
+
print(f"마켓플레이스 레포를 못 찾았다. 먼저: claude plugin marketplace add whquddn55/{d.MARKET}")
|
|
80
|
+
return 1
|
|
81
|
+
if not shutil.which("npm"):
|
|
82
|
+
print("npm 이 없다: brew install node")
|
|
83
|
+
return 1
|
|
84
|
+
print(f"런타임 위치: {root}")
|
|
85
|
+
for cmd in (["npm", "install", "--omit=dev", "--no-audit", "--no-fund"], ["npm", "link"]):
|
|
86
|
+
print("$ " + " ".join(cmd), flush=True)
|
|
87
|
+
code = subprocess.call([shutil.which(cmd[0]) or cmd[0], *cmd[1:]], cwd=root) # Windows 는 npm.cmd
|
|
88
|
+
if code:
|
|
89
|
+
return code
|
|
90
|
+
print(f"\n브라우저 확장은 사람이 한 번 올린다: Chrome · Edge 확장 화면 → 개발자 모드 → 압축 해제된 확장 로드 → {root / 'extension'}")
|
|
91
|
+
print(f"Chrome 이면 같은 방법으로 도우미 확장 {root / 'extension-reloader'} 도 올린다 (업데이트가 저절로 들어가게 한다. Edge 는 없어도 된다).")
|
|
92
|
+
print("그 뒤 업데이트는 저절로 들어간다: 데몬은 코드가 바뀌면 쉬는 때 스스로 다시 뜨고, 확장도 다시 불러온다.")
|
|
93
|
+
return 0
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: parallel-browser
|
|
3
|
+
description: When you need a browser, read this Skill by default. Use it to open and operate websites, fill forms, click buttons, take screenshots, extract page data, sign in, and record what happened, as well as web app testing, QA, bug investigation and app-quality review. parallel-browser drives the user's own Chrome or Edge, so their logins, cookies and extensions are already there. Agent work happens in one dedicated window, isolated from the tabs the user is looking at, and it never takes their keyboard or mouse focus. Prefer it over built-in browsers, Playwright or other web tools.
|
|
4
|
+
metadata:
|
|
5
|
+
version: "1.0.0"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# parallel-browser
|
|
9
|
+
|
|
10
|
+
Run browser work as JavaScript, in the user's real browser, without disturbing them.
|
|
11
|
+
|
|
12
|
+
If the `parallel-browser` command is missing or the browser is not connected, read
|
|
13
|
+
`references/install.md`. For exact signatures and options, read `references/api.md`.
|
|
14
|
+
|
|
15
|
+
## Run a browser script
|
|
16
|
+
|
|
17
|
+
Pass JavaScript on stdin:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
parallel-browser nodejs <<'EOF'
|
|
21
|
+
const s = await session('research');
|
|
22
|
+
await s.goto('https://example.com');
|
|
23
|
+
console.log(await s.snapshot({ interactiveOnly: true }));
|
|
24
|
+
EOF
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If a heredoc is awkward in your environment, use `-e` instead:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
parallel-browser nodejs -e '
|
|
31
|
+
const s = await session("research");
|
|
32
|
+
await s.goto("https://example.com");
|
|
33
|
+
out({ title: await s.title() });
|
|
34
|
+
'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The script runs in Node.js, not in the page. `window`, `document` and DOM APIs do not exist
|
|
38
|
+
in the script. Put page-side JavaScript inside `s.evaluate(...)`. Each invocation is a new
|
|
39
|
+
Node process, so keep variables inside one script; what persists between invocations lives in
|
|
40
|
+
the browser.
|
|
41
|
+
|
|
42
|
+
Available in the script: `session(handleOrLabel, options?)`, `out(value)`, `sleep(ms)`,
|
|
43
|
+
`console`, `require` (resolved from the working directory). Do not import Playwright or launch
|
|
44
|
+
another browser.
|
|
45
|
+
|
|
46
|
+
### Where it differs from Playwright
|
|
47
|
+
|
|
48
|
+
It looks like Playwright and mostly is, but these are the calls agents get wrong most often:
|
|
49
|
+
|
|
50
|
+
| You want | Write | Returns |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| a screenshot | `s.screenshot(path, { fullPage })` (`{ path, … }` works too) | `{ path, width, height, bytes }`; one pixel per CSS pixel unless `scale: 'device'` |
|
|
53
|
+
| see the page | `s.snapshot(opts)` | lines like `@42 button "Save"`. An array of lines that also reads as text: `.filter`, `.find`, `.split('\n')`, `.includes('Save')`, `` `${snap}` `` all work; `console.log(snap)` prints every line |
|
|
54
|
+
| a screen size | `s.setViewport(1440, 900)` (not `s.cdp('Emulation.setDeviceMetricsOverride', …)`) | `{ width, height, scale, tabArea }`; kept for new tabs |
|
|
55
|
+
| text of an element | `s.text(selector)` | string |
|
|
56
|
+
| run in the page | `s.evaluate(fnOrString, arg)` | the value (JSON-able) |
|
|
57
|
+
| current address | `await s.url()`, `await s.title()` | string (they are calls, not properties) |
|
|
58
|
+
| pick one of many | `'text=Save >> nth=0'` | — a selector matching several elements is an error, not the first one |
|
|
59
|
+
|
|
60
|
+
## Sessions
|
|
61
|
+
|
|
62
|
+
A session is one colored tab group inside the dedicated agent window.
|
|
63
|
+
|
|
64
|
+
- **Use one session for the whole user goal**, and address it by its handle.
|
|
65
|
+
`session('invoice-check')` always creates a **new** session and prints a handle like
|
|
66
|
+
`pb-3f9a21c7-6b1d…`; the string you pass is only a label for the user to read. To continue that
|
|
67
|
+
session in a later invocation, pass the **handle back**: `session('pb-3f9a21c7-6b1d…')`. Record
|
|
68
|
+
it as soon as you create a session — it is printed once, to you, and listed nowhere.
|
|
69
|
+
- **Sessions are private to the agent that created them.** Other agents work in the same browser,
|
|
70
|
+
but you cannot list theirs, read them, drive them or close them — there is no enumeration at
|
|
71
|
+
all, and every command carries the handle's secret. Yours are equally out of their reach. If the
|
|
72
|
+
user wants another agent to continue your session, give them the handle and let them pass it on.
|
|
73
|
+
If you lose a handle, the session is no longer yours to reach: make a new one and tell the user,
|
|
74
|
+
who can close the old one from the extension dashboard.
|
|
75
|
+
- **Close the session when the task is done.** `await s.close()` closes every tab it opened (the
|
|
76
|
+
user asked that each task cleans up the tabs it started). Leave it open only when the user asked
|
|
77
|
+
to look at the result in the browser, when you stopped because something blocked you (so they can
|
|
78
|
+
see the state you saw), or after `handOff` while you wait for them — leaving it open means simply
|
|
79
|
+
not closing it: it stays for as long as you are running. Scripts that drive the browser for a
|
|
80
|
+
skill close it in a `finally`, so an error does not leave tabs behind.
|
|
81
|
+
- **A session closes by itself when its owner exits.** The owner is the process that ran your
|
|
82
|
+
script — you, the agent (Claude Code: `CLAUDE_PID`; other agents: the parent of the shell). Within
|
|
83
|
+
seconds of that process going (finished, killed or crashed) the daemon closes the session,
|
|
84
|
+
so a forgotten `close()` does not leave tabs behind. This is a safety net, not a replacement:
|
|
85
|
+
still close when you are done. Nothing outlives its owner: there is no way to keep a session
|
|
86
|
+
after you exit, and a paused one (`handOff`, or the user pressed "내가 하기") closes the same way.
|
|
87
|
+
Handing a handle to another agent adds it as an owner; the session stays until every owner is
|
|
88
|
+
gone. To pick the owner yourself: `session('x', { owner: pid })`, or `PB_OWNER_PID=<pid>` in the
|
|
89
|
+
environment (a script that spawns the CLI passes its own pid).
|
|
90
|
+
- **Keep the user informed** with `await s.status('reading invoice 3 of 12')`. The text shows
|
|
91
|
+
on the tab group and on the page overlay, and it is the only progress the user sees while the
|
|
92
|
+
window is in the background.
|
|
93
|
+
- **A session owns a small number of tabs** (3 by default; pass `budget` to change it). Reuse a
|
|
94
|
+
tab with `goto()` instead of opening a new one. Popups the page opens are captured into the
|
|
95
|
+
session automatically as inactive tabs.
|
|
96
|
+
- **The user working in the page does not interrupt you.** They can click, type and scroll in your
|
|
97
|
+
tabs and the session stays yours — nothing is taken by accident, and you will not find your
|
|
98
|
+
input fighting theirs. Control changes hands in exactly two ways: they press **"내가 하기"** on
|
|
99
|
+
the page overlay (or pause from the dashboard), or you hand over yourself.
|
|
100
|
+
- **When they take it, stop.** `s.paused` turns true, a `takeover` event fires, and **anything
|
|
101
|
+
that would change the page throws `SessionPausedError`** — clicks, typing, navigation, uploads.
|
|
102
|
+
Reading still works, so you can still look and describe. Say what you had done and what you were
|
|
103
|
+
about to do, and leave the tabs alone. Do not call `s.resume()`; they hand it back with the same
|
|
104
|
+
button.
|
|
105
|
+
- **When you need the user, ask for them.** `await s.handOff('로그인이 필요합니다')` pauses the
|
|
106
|
+
session the same way but records it as *you* handing over, so the overlay says so instead of
|
|
107
|
+
making them wonder who grabbed it. Use it for logins, captchas and confirmations you must not
|
|
108
|
+
make yourself. End your turn after calling it and explain what they should do; continue with
|
|
109
|
+
`s.resume()` only after they say they are done.
|
|
110
|
+
|
|
111
|
+
## Never steal focus
|
|
112
|
+
|
|
113
|
+
The whole point of this tool is that the user keeps working while you browse. The runtime
|
|
114
|
+
already refuses `Page.bringToFront` and `Target.activateTarget`, and reroutes page popups into
|
|
115
|
+
background tabs. Do not try to work around this, do not activate windows or tabs, and do not
|
|
116
|
+
ask the user to bring the browser forward. Everything works while the window is behind theirs,
|
|
117
|
+
minimized or fully covered, including screenshots and recording.
|
|
118
|
+
|
|
119
|
+
## Finding things on the page
|
|
120
|
+
|
|
121
|
+
`await s.snapshot()` is the cheap way to see a page: one line per meaningful element, with a
|
|
122
|
+
`@N` ref you can act on. It includes iframe content, marked with an `--- iframe` header.
|
|
123
|
+
Use `{ interactiveOnly: true }` when you only need controls.
|
|
124
|
+
|
|
125
|
+
Selectors accepted by every action:
|
|
126
|
+
|
|
127
|
+
| Form | Example | Notes |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| snapshot ref | `@42` | from `snapshot()`; short-lived, re-snapshot after the page changes |
|
|
130
|
+
| text | `text=Sign in` | visible text; resolves to the innermost match, then its control |
|
|
131
|
+
| role | `role=button[name="Save"]` | accessible role and name |
|
|
132
|
+
| label | `label=Email` | form control by its label, aria-label or placeholder |
|
|
133
|
+
| CSS | `#email` or `css=.row > input` | plain CSS is the default when no prefix is given |
|
|
134
|
+
| XPath | `xpath=//table//tr[2]/td[1]` | |
|
|
135
|
+
| in one iframe | `frame=#checkout >> text=Pay` | pins the search to that iframe |
|
|
136
|
+
| through shadow DOM | `css=my-app >>> .row button` | open shadow roots are pierced anyway; `>>>` is for stepping through hosts |
|
|
137
|
+
| pick one of several | `text=Save >> nth=1` | 0-based; `-1` is the last |
|
|
138
|
+
|
|
139
|
+
Selectors search every frame, same-origin and cross-origin alike, and pierce open shadow roots.
|
|
140
|
+
|
|
141
|
+
**Matching is strict.** If a selector matches more than one element you get an error listing the
|
|
142
|
+
candidates, not a silent guess at the first one. Narrow the selector, or say which one you mean
|
|
143
|
+
with `>> nth=N`. Read the candidate list before choosing: it tells you what else is on the page.
|
|
144
|
+
|
|
145
|
+
Observation discipline: read the cheapest thing that answers the question. `title()`, `url()`
|
|
146
|
+
and `text(selector)` before `snapshot()`, and `snapshot()` before `screenshot()`. On a long page
|
|
147
|
+
prefer `snapshot({ scope: 'viewport' })`, and once you know where you are working,
|
|
148
|
+
`snapshot({ scope: 'subtree', root: '#checkout' })` — both cost a fraction of the full page.
|
|
149
|
+
|
|
150
|
+
Take a screenshot when layout or visual state actually matters, or when the user asked to see it.
|
|
151
|
+
Screenshots are saved at CSS size (a retina screen does not double them), which is also what
|
|
152
|
+
it costs to look at one.
|
|
153
|
+
|
|
154
|
+
## Screen size
|
|
155
|
+
|
|
156
|
+
The agent window is about 1200×800, so the page sees roughly 1000×670 — narrower than most
|
|
157
|
+
desktop layouts. `await s.setViewport(1440, 900)` makes the page lay out at that size, and
|
|
158
|
+
re-applies itself to tabs opened later. The window is not touched: screenshots and recordings
|
|
159
|
+
capture the whole emulated size even when the window is far smaller. `s.clearViewport()` goes
|
|
160
|
+
back.
|
|
161
|
+
|
|
162
|
+
That holds while the session's tab is behind: the browser records the window's front tab at the
|
|
163
|
+
window's real size, cropped. So the agent window keeps a blank tab in front and session tabs
|
|
164
|
+
behind it. If the user clicks a session tab while working in the agent window, recordings of that
|
|
165
|
+
tab come out at the tab area until they leave the window; the blank tab goes back in front then and
|
|
166
|
+
the emulated size is set again by itself. Nothing to do on your side — do not activate tabs.
|
|
167
|
+
|
|
168
|
+
## Acting
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
parallel-browser nodejs <<'EOF'
|
|
172
|
+
const s = await session('signup');
|
|
173
|
+
await s.goto('https://example.com/signup');
|
|
174
|
+
await s.fill('label=Email', 'a@example.com');
|
|
175
|
+
await s.fill('label=Password', 'hunter2');
|
|
176
|
+
await s.check('#terms');
|
|
177
|
+
await s.click('role=button[name="Create account"]');
|
|
178
|
+
await s.waitForURL('/welcome');
|
|
179
|
+
out({ url: await s.url() });
|
|
180
|
+
EOF
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
- `click` scrolls the element into view, checks it is really hittable, and fails with the
|
|
184
|
+
reason if something covers it or it is disabled. It retries while the failure is transient.
|
|
185
|
+
- `fill` replaces the value and fires real input events, so framework-bound forms update.
|
|
186
|
+
- `press('ControlOrMeta+a')`, `press('#search', 'Enter')` (focuses first), `focus(selector)`,
|
|
187
|
+
`select('#country', 'Korea')`, `check`/`uncheck`, `hover`, `scroll`,
|
|
188
|
+
`dragAndDrop(source, target)`, `dropFiles(target, paths)`.
|
|
189
|
+
- When an action needs finer control than the helpers give: `keyboard.down('Shift')` /
|
|
190
|
+
`keyboard.up('Shift')` to hold a modifier, `keyboard.insertText`, `keyboard.paste(text)` for a
|
|
191
|
+
real paste event, and `mouse.move/down/up/click/wheel` in viewport coordinates (the pointer
|
|
192
|
+
keeps its position between calls).
|
|
193
|
+
- After an action, verify the result you actually care about (`waitForURL`, `waitFor`,
|
|
194
|
+
`text(...)`) rather than assuming it worked. Stop as soon as the page shows the result; do not
|
|
195
|
+
re-confirm what you already saw.
|
|
196
|
+
|
|
197
|
+
## Waiting
|
|
198
|
+
|
|
199
|
+
Never `sleep` to wait for the page. Use `waitFor(selector, { state })`, `waitForURL`,
|
|
200
|
+
`waitForFunction`, `waitForNetworkIdle` or `waitForLoad`. `goto` already waits for load;
|
|
201
|
+
pass `{ waitUntil: 'networkidle' }` for pages that fill in afterwards. A script that sleeps more
|
|
202
|
+
than 5 seconds in total gets a `hint:` line on stderr saying so.
|
|
203
|
+
|
|
204
|
+
## Dialogs, uploads, logins
|
|
205
|
+
|
|
206
|
+
- `alert`/`confirm`/`prompt` are answered automatically (dismissed; `beforeunload` accepted) and
|
|
207
|
+
recorded in `s.dialogs`. Override with `s.onDialog(async (d) => ({ accept: true, promptText: 'x' }))`.
|
|
208
|
+
- File pickers: call `s.expectUpload(['/abs/path.pdf'])` before the click that opens the picker,
|
|
209
|
+
or set the input directly with `s.setInputFiles('#file', ['/abs/path.pdf'])`.
|
|
210
|
+
- HTTP basic auth: `s.setHttpCredentials({ username, password })` before navigating.
|
|
211
|
+
- Site logins: the user's cookies are already there, so try the page first. If a login is
|
|
212
|
+
required, say so and let the user sign in on that tab; do not type credentials you were not
|
|
213
|
+
given, and never put secrets in your output.
|
|
214
|
+
- Popups: when *you* trigger `window.open` (a "로그인" / "Sign in with …" button), the popup opens as
|
|
215
|
+
an inactive tab in your session and the page gets a stand-in window, so sign-in popups work
|
|
216
|
+
without taking focus: the provider's `window.opener.postMessage`, same-origin callbacks and
|
|
217
|
+
`window.close()` are relayed to the page, and `popup.location` reads once it is back on the
|
|
218
|
+
page's origin. If the provider needs input (pick an account, consent), find the popup tab with
|
|
219
|
+
`s.tabs()`, `s.use(tabId)` to act in it, then `s.use()` back. It closes itself when done. Passwords
|
|
220
|
+
are still the user's: `handOff()` for those. When the *user* clicks in your tab, popups and new
|
|
221
|
+
tabs open normally, outside your session.
|
|
222
|
+
|
|
223
|
+
## Recording
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
await s.setViewport(1920, 1080); // film at 1080p
|
|
227
|
+
await s.startRecording('/Users/<you>/scratch/<project>/<branch>/run-work'); // a working folder
|
|
228
|
+
// ... drive the page ...
|
|
229
|
+
const r = await s.stopRecording('/Users/<you>/scratch/<project>/<branch>/run.mp4');
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Keep recordings under `~/scratch`, not `/tmp` (`<project>` is the main repo folder name even in a
|
|
233
|
+
worktree, `<branch>` is the current branch with `/` turned into `-`); pass absolute paths, `~` is
|
|
234
|
+
not expanded. Recording survives across invocations because the daemon owns it, and it works while
|
|
235
|
+
the window is hidden. Record when the user wants to see what happened, not by default.
|
|
236
|
+
|
|
237
|
+
- **The video is encoded while it is filmed.** Nothing piles up on disk however long it runs — the
|
|
238
|
+
working folder holds the video being written and `stopRecording` removes it. Stopping takes a
|
|
239
|
+
moment whatever the length. Measured: three minutes at 1920×1080 is a 40 MB video.
|
|
240
|
+
- **Film at 1920×1080** unless the user asked for another size (a phone screen, say): the video is
|
|
241
|
+
the page's own size, so call `setViewport(1920, 1080)` first — or `setViewport(390, 844)` and
|
|
242
|
+
`startRecording(dir, { width: 390, height: 844 })` when they did. Frames are 1920×1080 at most by
|
|
243
|
+
default; pass `width` / `height` for anything larger or to cap it lower.
|
|
244
|
+
- The page is filmed only while it changes, at 30 frames a second at most. A page that sits still
|
|
245
|
+
costs nothing and is still in the video for as long as it sat there.
|
|
246
|
+
- **A long run with a spinner on screen:** the page sends frames all the time, and every kept
|
|
247
|
+
frame costs CPU (measured at 1920×1080: 37% of a core at 30 a second, 9% at 5, 1.5% at 1). Call
|
|
248
|
+
`await s.setRecordingFps(2)` while only waiting and `setRecordingFps(30)` before showing
|
|
249
|
+
something. A page that really sits still needs none of this.
|
|
250
|
+
- **`await s.pauseRecording()` / `await s.resumeRecording()`** leave the time in between out of
|
|
251
|
+
the video altogether (the picture jumps from before to after) and nothing runs meanwhile. Use
|
|
252
|
+
it for stretches nobody needs to see; `stopRecording` works while paused.
|
|
253
|
+
- `stopRecording` returns `{ frames, seconds, fps, width, height, mp4, bytes, t0, tEnd, events }`
|
|
254
|
+
(`events`: address changes and frame-size changes, with their times).
|
|
255
|
+
- `await s.recordingFrame('/…/now.jpg')` saves what the video shows right now, without stopping.
|
|
256
|
+
- If the session is closed or its owner exits while recording, what was filmed is saved next to
|
|
257
|
+
the working folder as `<folder>-unfinished.mp4`.
|
|
258
|
+
- For an edited video to show people (captions, arrows, zoom, fast-forward), use the demo-video
|
|
259
|
+
skill; it records through this.
|
|
260
|
+
|
|
261
|
+
## Reporting back
|
|
262
|
+
|
|
263
|
+
Print the answer with `out(...)` or `console.log`. Report what the page actually showed. If you
|
|
264
|
+
could not complete the task, say where you stopped and what blocked you; leave the tabs open
|
|
265
|
+
(do not call `close()`) so the user can look at the same state you saw while you wait.
|
|
266
|
+
|
|
267
|
+
## References
|
|
268
|
+
|
|
269
|
+
- [Install and connect](references/install.md) — read when `parallel-browser` is missing or the
|
|
270
|
+
browser is not connected.
|
|
271
|
+
- [API reference](references/api.md) — every method, with options.
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Session API reference
|
|
2
|
+
|
|
3
|
+
_Generated from `runtime/session.js` by `npm run generate:api-docs`. Do not edit by hand._
|
|
4
|
+
|
|
5
|
+
Every method lives on a `Session`, obtained with `await session(name)` inside
|
|
6
|
+
`parallel-browser nodejs`. All time values are milliseconds. All coordinates are CSS pixels
|
|
7
|
+
in the top-level viewport, including elements inside iframes.
|
|
8
|
+
|
|
9
|
+
## lifecycle
|
|
10
|
+
|
|
11
|
+
### `Session.create(relay, { name, color, bounds, budget, placement = 'shared', windowId } = {})`
|
|
12
|
+
|
|
13
|
+
placement: 'shared' (tab group in the ONE dedicated agent window, default) | 'window' | 'group'
|
|
14
|
+
|
|
15
|
+
### `Session.open(relay, handleOrName, opts = {})`
|
|
16
|
+
|
|
17
|
+
The one way agents address a session. A full handle (`pb-xxxxxxxx-<key>`) resumes exactly that session; anything else is a display label and always creates a NEW one. Neither a name nor a bare id is a handle: two agents sharing this browser must not be able to reach each other's tabs, by accident or on purpose. /
|
|
18
|
+
|
|
19
|
+
### `Session.attach(relay, handle)`
|
|
20
|
+
|
|
21
|
+
Resume a session from the handle its creator was given.
|
|
22
|
+
|
|
23
|
+
### `call(method, params = {}, opts)`
|
|
24
|
+
|
|
25
|
+
Every session-scoped call proves ownership; the extension rejects it otherwise.
|
|
26
|
+
|
|
27
|
+
### `cdp(method, params = {}, { tabId = this.tabId, targetId, timeout = 30000 } = {})`
|
|
28
|
+
|
|
29
|
+
### `status(text)`
|
|
30
|
+
|
|
31
|
+
### `handOff(message)`
|
|
32
|
+
|
|
33
|
+
Ask the user to take the wheel — a login, a captcha, a confirmation the agent must not make on its own. The session pauses exactly as if they had taken it, so every page-changing command throws, but the overlay says the agent handed it over rather than that someone grabbed it. Say what you need in `message`; it is what the user reads. /
|
|
34
|
+
|
|
35
|
+
### `resume()`
|
|
36
|
+
|
|
37
|
+
### `setOwner(owner)`
|
|
38
|
+
|
|
39
|
+
Add a process whose exit closes this session. session() sets one already (the agent that ran the script; see the `owner` option), so call this only to add another: a session stays until every owner is gone, then closes within seconds — paused or not. Needs the daemon (the CLI). /
|
|
40
|
+
|
|
41
|
+
### `close()`
|
|
42
|
+
|
|
43
|
+
## events
|
|
44
|
+
|
|
45
|
+
### `onDialog(fn)`
|
|
46
|
+
|
|
47
|
+
JS dialogs block the page until answered. Default: beforeunload accepted, everything else dismissed.
|
|
48
|
+
|
|
49
|
+
### `expectUpload(files)`
|
|
50
|
+
|
|
51
|
+
Files to hand to the next file chooser the page opens (e.g. after clicking "Upload").
|
|
52
|
+
|
|
53
|
+
### `setHttpCredentials(credentials)`
|
|
54
|
+
|
|
55
|
+
HTTP basic/digest auth: answered from these credentials; without them the browser would show a blocking prompt.
|
|
56
|
+
|
|
57
|
+
### `clearHttpCredentials()`
|
|
58
|
+
|
|
59
|
+
## tabs
|
|
60
|
+
|
|
61
|
+
### `tabs()`
|
|
62
|
+
|
|
63
|
+
### `use(tabId)`
|
|
64
|
+
|
|
65
|
+
Point subsequent calls at another tab of this session (no focus change, purely internal).
|
|
66
|
+
|
|
67
|
+
### `newTab(url)`
|
|
68
|
+
|
|
69
|
+
### `closeTab(tabId = this.tabId)`
|
|
70
|
+
|
|
71
|
+
## navigation
|
|
72
|
+
|
|
73
|
+
### `goto(url, { timeout = 30000, waitUntil = 'load' } = {})`
|
|
74
|
+
|
|
75
|
+
### `reload()`
|
|
76
|
+
|
|
77
|
+
### `back()`
|
|
78
|
+
|
|
79
|
+
### `forward()`
|
|
80
|
+
|
|
81
|
+
### `url()`
|
|
82
|
+
|
|
83
|
+
### `title()`
|
|
84
|
+
|
|
85
|
+
## observation
|
|
86
|
+
|
|
87
|
+
### `evaluate(expression, arg)`
|
|
88
|
+
|
|
89
|
+
### `snapshot({ interactiveOnly = false, max = 400, frames = true, scope = 'page', root = null } = {})`
|
|
90
|
+
|
|
91
|
+
Compact accessibility snapshot. Refs (@N) are backend node ids usable as targets. scope: 'page' (everything, default) | 'viewport' (only what is on screen) | 'subtree' (below `root`, which is a ref or selector). Viewport scope is the cheap one to reach for on a long page: it is what the user would see, at a fraction of the tokens. Returns a Snapshot: an array of lines (`.filter`, `.find`, `.length` count lines) that also acts as their text (`.split('\n')`, `.includes('Save')`, `.match(re)`, `.text`, `${snap}`). console.log(snap) and out(snap) print every line. /
|
|
92
|
+
|
|
93
|
+
### `evaluateInFrame(iframeSelector, expression)`
|
|
94
|
+
|
|
95
|
+
Evaluate inside one iframe, picked by a CSS selector on its <iframe> element. Usually the frame's own script world; a frame that was already there when this script started is reached through a separate world that sees its DOM, location and fetch but not the page's variables. /
|
|
96
|
+
|
|
97
|
+
### `frameList()`
|
|
98
|
+
|
|
99
|
+
Frames of the current tab, as the runtime sees them.
|
|
100
|
+
|
|
101
|
+
### `text(target)`
|
|
102
|
+
|
|
103
|
+
### `content()`
|
|
104
|
+
|
|
105
|
+
### `screenshot(path, { timeout = 10000, fullPage = false, format, quality, scale = 'css' } = {})`
|
|
106
|
+
|
|
107
|
+
screenshot(path, opts) or screenshot({ path, ...opts }) (the Playwright form works too). scale: 'css' (default) saves one image pixel per CSS pixel, so a retina screen does not double the file and the tokens it costs to look at; 'device' keeps every device pixel. format: 'png' (default) | 'jpeg' (with quality, 0-100). Returns { path, width, height, bytes, ms }. /
|
|
108
|
+
|
|
109
|
+
### `cookies()`
|
|
110
|
+
|
|
111
|
+
### `fetch(url, init = {})`
|
|
112
|
+
|
|
113
|
+
fetch() inside the page, so the site's cookies and origin apply.
|
|
114
|
+
|
|
115
|
+
## frames
|
|
116
|
+
|
|
117
|
+
### `refreshFrames()`
|
|
118
|
+
|
|
119
|
+
Frame inventory for the current tab, to any depth. Frames that share a process with their parent are reached through an execution context of the same debuggee; cross-origin ones (out-of-process) are separate targets the extension attaches to, and may themselves contain further frames. Offsets accumulate so every frame knows where it sits in the top-level viewport. /
|
|
120
|
+
|
|
121
|
+
## actions
|
|
122
|
+
|
|
123
|
+
### `click(target, { button = 'left', clickCount = 1, modifiers = 0, timeout = 10000 } = {})`
|
|
124
|
+
|
|
125
|
+
### `dblclick(target, opts = {})`
|
|
126
|
+
|
|
127
|
+
### `clickAt(x, y)`
|
|
128
|
+
|
|
129
|
+
### `hover(target, { timeout = 10000 } = {})`
|
|
130
|
+
|
|
131
|
+
### `setViewport(width, height, { dpr = 1, fitWindow = false, shrink = false } = {})`
|
|
132
|
+
|
|
133
|
+
Make the page see a width × height screen (CSS px), like Playwright's viewport. The window is left alone: the page is laid out at that size whatever the window, and screenshots and recordings capture all of it (2026-10-29, Edge 155: a 669×407 tab area recorded 1792×848 whole, 2× on retina) — while the tab is behind: the window's front tab is recorded at the window's real size, cropped, which is why the agent window keeps a blank tab in front. Applies to every tab of this session, including ones opened later. `fitWindow: true` also grows the agent window to hold it; `shrink: true` draws it scaled into the tab area and scales input to match. Neither is needed for screenshots or recordings. Returns { width, height, dpr, scale, tabArea: [w, h] }. /
|
|
134
|
+
|
|
135
|
+
### `clearViewport()`
|
|
136
|
+
|
|
137
|
+
Back to the real tab area: no emulated screen size, input unscaled.
|
|
138
|
+
|
|
139
|
+
### `fitWindow(width, height)`
|
|
140
|
+
|
|
141
|
+
Grow (never shrink) the window this session draws in until its tab area is at least width × height CSS px, as far as the screen allows. It is resized in place: no focus, no raising. Returns the tab area it ended with. Sessions placed in the user's own window (placement 'group') leave that window alone. /
|
|
142
|
+
|
|
143
|
+
### `setInputScale(scale = 1)`
|
|
144
|
+
|
|
145
|
+
화면 크기 흉내에 scale 을 걸었을 때 그 값을 준다. 클릭 · 이동 · 휠 · 끌기 좌표가 CSS 좌표 그대로 맞는다.
|
|
146
|
+
|
|
147
|
+
### `fill(target, text, { timeout = 10000 } = {})`
|
|
148
|
+
|
|
149
|
+
Replace the element's value with text, firing real input events (works with React/Vue).
|
|
150
|
+
|
|
151
|
+
### `type(text, { delay = 0 } = {})`
|
|
152
|
+
|
|
153
|
+
Type into whatever is focused (call click/fill first).
|
|
154
|
+
|
|
155
|
+
### `press(comboOrTarget, maybeCombo)`
|
|
156
|
+
|
|
157
|
+
press('Enter') on whatever is focused, or press('#search', 'Enter') to focus it first.
|
|
158
|
+
|
|
159
|
+
### `focus(target, { timeout = 10000 } = {})`
|
|
160
|
+
|
|
161
|
+
Move focus to an element without clicking it.
|
|
162
|
+
|
|
163
|
+
### `select(target, values)`
|
|
164
|
+
|
|
165
|
+
select('#color', 'b') or select('#color', ['a','b']) — matches option value, then label.
|
|
166
|
+
|
|
167
|
+
### `check(target)`
|
|
168
|
+
|
|
169
|
+
### `uncheck(target)`
|
|
170
|
+
|
|
171
|
+
### `scroll(targetOrDelta, { x = 0, y = 400 } = {})`
|
|
172
|
+
|
|
173
|
+
### `setInputFiles(target, files)`
|
|
174
|
+
|
|
175
|
+
setInputFiles('#file', ['/abs/path.pdf']) — for a visible <input type=file>.
|
|
176
|
+
|
|
177
|
+
## drag and drop
|
|
178
|
+
|
|
179
|
+
### `dragAndDrop(source, target, { steps = 10, hold = 80, settle = 120, intercept = false, timeout = 10000, sourceOffset, targetOffset } = {})`
|
|
180
|
+
|
|
181
|
+
Real mouse-driven drag. Chrome's own drag controller runs, so HTML5 dataTransfer, sortable lists and pointer-event libraries all see what they expect. `intercept: true` additionally captures the drag payload and replays it as explicit drag events, which is what you want when the drop target inspects dataTransfer. /
|
|
182
|
+
|
|
183
|
+
### `dropFiles(target, files, { timeout = 10000 } = {})`
|
|
184
|
+
|
|
185
|
+
Drop files from disk onto an element, the way a user dragging from Finder would.
|
|
186
|
+
|
|
187
|
+
### `dragAndDropSynthetic(source, target, { types = { 'text/plain': '' } } = {})`
|
|
188
|
+
|
|
189
|
+
Last-resort fallback: synthesize HTML5 drag events in the page (no real mouse involved).
|
|
190
|
+
|
|
191
|
+
## waits
|
|
192
|
+
|
|
193
|
+
### `waitFor(target, { state = 'visible', timeout = 15000 } = {})`
|
|
194
|
+
|
|
195
|
+
waitFor('#late') | waitFor('text=Done', { state: 'hidden' }) — states: visible (default), attached, hidden, detached
|
|
196
|
+
|
|
197
|
+
### `waitForFunction(expression, { timeout = 15000, interval = 100 } = {})`
|
|
198
|
+
|
|
199
|
+
### `waitForURL(pattern, { timeout = 15000 } = {})`
|
|
200
|
+
|
|
201
|
+
### `waitForLoad({ timeout = 30000 } = {})`
|
|
202
|
+
|
|
203
|
+
### `waitForNetworkIdle({ idle = 500, timeout = 30000 } = {})`
|
|
204
|
+
|
|
205
|
+
### `waitForDialog({ timeout = 15000 } = {})`
|
|
206
|
+
|
|
207
|
+
## recording
|
|
208
|
+
|
|
209
|
+
### `startRecording(dir, { width, height, fps, crf } = {})`
|
|
210
|
+
|
|
211
|
+
Start filming this tab. `dir` is a working folder (it holds the video while it is being written, and is removed by stopRecording). The video is encoded as it is filmed, so nothing piles up on disk however long it runs. Frames are at most `width` × `height` (default 1920×1080; the page's own size when that is smaller — `setViewport(1920, 1080)` first for a full-size video, or a phone size for a mobile one), at most `fps` a second (default 30), and only while the page changes. The daemon owns the recording, so a later invocation can stop it. /
|
|
212
|
+
|
|
213
|
+
### `stopRecording(outMp4, { wait = 100000 } = {})`
|
|
214
|
+
|
|
215
|
+
Stop filming and write the video to `outMp4` (absolute path). Returns { frames, received, dropped, seconds, fps, width, height, t0, tEnd, pauses, visibility, events, mp4, bytes }: `t0` and `tEnd` are when second 0 and the end of the video were (epoch seconds), `events` the address changes and frame-size changes on the way. Quick, whatever the length. On a very slow disk it returns after `wait` ms with `encoding: true`; `waitForRecording(outMp4)` then waits for the file. /
|
|
216
|
+
|
|
217
|
+
### `setRecordingFps(fps)`
|
|
218
|
+
|
|
219
|
+
Keep at most `fps` frames a second from now on (1–60). A page with a spinner sends frames all the time and costs CPU for each one kept: drop to 1–5 while only waiting, back to 30 to show something. /
|
|
220
|
+
|
|
221
|
+
### `pauseRecording()`
|
|
222
|
+
|
|
223
|
+
Stop filming until resumeRecording(). The time in between is left out of the video; nothing runs meanwhile.
|
|
224
|
+
|
|
225
|
+
### `resumeRecording()`
|
|
226
|
+
|
|
227
|
+
Film again after pauseRecording().
|
|
228
|
+
|
|
229
|
+
### `recordingFrame(path)`
|
|
230
|
+
|
|
231
|
+
Save what the recording shows right now (its latest frame) as a JPEG at `path`. Returns { path, width, height }.
|
|
232
|
+
|
|
233
|
+
### `recordingStatus(outMp4)`
|
|
234
|
+
|
|
235
|
+
Whether the video of `stopRecording(outMp4)` is written: the same result, `encoding: true` while it is not.
|
|
236
|
+
|
|
237
|
+
### `waitForRecording(outMp4, { timeout = 30 * 60 * 1000 } = {})`
|
|
238
|
+
|
|
239
|
+
Wait until that video is finished, up to `timeout` ms (default 30 minutes). Throws if the encoding failed.
|
|
240
|
+
|
|
241
|
+
### `setWindowState(state, { allowFocus = false } = {})`
|
|
242
|
+
|
|
243
|
+
Minimizing is free; un-minimizing takes the user's focus, so it needs `allowFocus`.
|