clearcote 0.55.1 → 0.57.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/README.md CHANGED
@@ -137,6 +137,7 @@ In code: `serveMultiplex({ port: 9222, idleTimeoutSec: 300, dataDir: "./profiles
137
137
  ```bash
138
138
  npx clearcote install [--version 152] [--channel preview]
139
139
  npx clearcote info [--quick] [--json] [--proxy <url>] # alias: doctor
140
+ npx clearcote bench [--concurrency 3] [--url <url>] [--proxy <url>] [--duration 30] [--json]
140
141
  npx clearcote login [key] # validates the key, saves it to ~/.clearcote/license.key
141
142
  npx clearcote logout
142
143
  npx clearcote clear-cache
@@ -144,7 +145,9 @@ npx clearcote serve [--port 9222] ...
144
145
  npx clearcote cloud run|sessions|stop|events|recording|profile sync|webhooks ... # the hosted API, see Local or cloud
145
146
  ```
146
147
 
147
- `info` never downloads: it reports the SDK, the cached builds, which engine features the binary supports, a launch test (skipped with `--quick`), licence seats, fonts and missing system libraries.
148
+ `info` never downloads: it reports the SDK, this machine (CPU, RAM, VM or not, and whether there is a GPU Chromium can draw with), the cached builds, which engine features the binary supports, a launch test (skipped with `--quick`), licence seats, fonts and missing system libraries.
149
+
150
+ `bench` answers "why is my CPU at 100 %" and "how many browsers can I run": it starts `--concurrency` browsers (headless, temporary profiles, deleted afterwards), loads `--url` in each for `--duration` seconds, through `--proxy` if you give one, and prints what each browser costs in CPU threads and RAM on this machine, page timings (DOMContentLoaded, load, network idle), errors, about how many browsers the machine runs at once, and what to change. It runs fewer browsers than asked when free RAM looks too small (`--force` runs them all). Each browser holds a licence seat while it runs. Paste the output into a support request; proxy credentials are never printed.
148
151
 
149
152
  Windows: when a cached build cannot start from the cache (`spawn UNKNOWN`, "the side-by-side configuration is incorrect"; this happens when the SDK runs inside an MSIX-packaged app, whose writes to `%LOCALAPPDATA%` Windows redirects), launches use one copy of that build in `~/.clearcote/recovered/` instead, made once and reused by every later launch from Python or Node. `clear-cache` removes those copies too.
150
153
 
@@ -358,6 +361,39 @@ await ctx.close();
358
361
  - Cloud launches (`cloud: true`) are unchanged: hosted browsers load Widevine on the server.
359
362
  - Software-secure (L3) playback. Hardware-secure (L1) paths are out of scope.
360
363
 
364
+ ### Certificate revocation (`crlset`, opt-in)
365
+
366
+ Real Chrome receives Google's **CRLSet** — the list of revoked and distrusted certificate keys — in the
367
+ background, which is how a CA compromise reaches browsers within hours. A Clearcote engine never downloads
368
+ it, so on its own it keeps trusting certificates that Chrome already blocks. `crlset: true` closes that gap
369
+ for every engine the SDK launches, old builds included:
370
+
371
+ - The SDK fetches the current CRLSet **from Google** (`update.googleapis.com`, the same service as the
372
+ Widevine CDM), checks its SHA-256 and caches it under `~/.clearcote/crlset` (`CLEARCOTE_CRLSET_DIR`
373
+ overrides; the cache is shared with the Python and .NET SDKs). A cache older than 6 hours is refreshed in
374
+ the background; the launch uses the cached copy.
375
+ - It places the CRLSet in the profile and lets the engine's component updater load it (it makes no network
376
+ request of its own). The launch then **waits until the CRLSet is live**, usually a few seconds, so the
377
+ first page you open is already protected.
378
+ - `crlset: "nowait"` skips the wait: the CRLSet goes live once the first tab has been idle for a moment.
379
+ `crlset: "<path>"` seeds that file instead. `crlsetTimeout` bounds the wait (default 15 s).
380
+ - Fail-soft: if the first download fails or the CRLSet is not confirmed in time, the launch goes on and
381
+ prints one warning (`quiet: true` or `CLEARCOTE_NO_WARN=1` silences it).
382
+ - `CLEARCOTE_CRLSET=1` turns it on for every launch. It needs a profile: `launch()` (which uses a temporary
383
+ one) and `launchPersistentContext()`; an incognito launch (`ephemeralProfile: false`) prints a warning
384
+ and goes on without it.
385
+
386
+ ```ts
387
+ import { launch } from "clearcote";
388
+
389
+ const browser = await launch({ crlset: true });
390
+ const page = await browser.newPage();
391
+ await page.goto("https://dv-g3b-emudhra.we-have-a-problem.com/"); // net::ERR_CERT_REVOKED, as in Chrome
392
+ ```
393
+
394
+ - Fetch it ahead of time with `fetchCrlset()`, or point `CLEARCOTE_CRLSET_URL` at your own mirror of the raw
395
+ `crl-set` file.
396
+
361
397
  ### AI agent (OpenRouter)
362
398
 
363
399
  Drive a page with an **in-browser AI agent** — it perceives the live page, asks an LLM what to do,
@@ -0,0 +1,138 @@
1
+ import type { BrowserContext } from "playwright-core";
2
+ export interface HostReport {
3
+ cpu: {
4
+ model: string;
5
+ threads: number;
6
+ };
7
+ memory: {
8
+ totalMB: number;
9
+ freeMB: number;
10
+ };
11
+ os: string;
12
+ /** "virtual machine (VMware, Inc. VMware7,1)", "container", or null on a physical machine. */
13
+ virtual: string | null;
14
+ /** Windows: this is a Remote Desktop session (no GPU acceleration by default). */
15
+ remoteSession: boolean;
16
+ /** The display adapters the OS reports; `software` when none of them can draw 3D. */
17
+ gpu: {
18
+ adapters: string[];
19
+ software: boolean;
20
+ };
21
+ }
22
+ export declare const WINDOWS_DISPLAY_CLASS = "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}";
23
+ /** "Windows 11 Pro (10.0.26200)": ProductName still says "Windows 10" on Windows 11, whose builds start at 22000. */
24
+ export declare function windowsName(product: string, major: string, minor: string, build: string): string;
25
+ /** The machine: CPU, RAM, OS, VM or not, and whether there is a GPU Chromium can draw with. Local only. */
26
+ export declare function hostInfo(): HostReport;
27
+ /** The Host lines of `clearcote info` (and the top of `clearcote bench`). */
28
+ export declare function hostLines(h: HostReport): string[];
29
+ export interface Proc {
30
+ pid: number;
31
+ ppid: number;
32
+ cmd: string;
33
+ cpuMs: number;
34
+ memMB: number;
35
+ }
36
+ /** Every process of the browser executable (Windows) or every process (elsewhere): pid, parent, command
37
+ * line, CPU time used so far, and private memory (Windows commit, Linux PSS, macOS RSS). */
38
+ export declare function processTable(exeName?: string): Proc[];
39
+ /** The pids of the browser started on `profileDir` and of every process below it. */
40
+ export declare function browserTree(table: Proc[], profileDir: string): Set<number>;
41
+ export interface BenchOptions {
42
+ concurrency: number;
43
+ url: string;
44
+ durationSec: number;
45
+ headless: boolean;
46
+ proxy?: {
47
+ server: string;
48
+ username?: string;
49
+ password?: string;
50
+ };
51
+ /** Run more browsers than free RAM looks able to hold. */
52
+ force?: boolean;
53
+ }
54
+ /** What one browser did: every navigation, what it cost. */
55
+ export interface BrowserRun {
56
+ launchMs?: number;
57
+ launchError?: string;
58
+ dclMs: number[];
59
+ loadMs: number[];
60
+ loadTimeouts: number;
61
+ idleReached: number;
62
+ idleMissed: number;
63
+ errors: string[];
64
+ cpuMs: number;
65
+ peakMemMB: number;
66
+ }
67
+ /** Everything bench measured, before any summary: also what the tests feed summarizeBench(). */
68
+ export interface BenchRaw {
69
+ host: HostReport;
70
+ url: string;
71
+ proxy: string | null;
72
+ headless: boolean;
73
+ requested: number;
74
+ concurrency: number;
75
+ durationSec: number;
76
+ /** Wall time the browsers were measured over. */
77
+ measuredSec: number;
78
+ browsers: BrowserRun[];
79
+ /** Whole-machine CPU busy % in the 3 s before launching and during the measured window (null where
80
+ * the platform does not say). */
81
+ machineBefore: number | null;
82
+ machineDuring: number | null;
83
+ }
84
+ /** The browsers free RAM looks able to hold before anything is measured (450 MB each, 15 % kept back). */
85
+ export declare function ramSafeCount(freeMB: number): number;
86
+ /** Strip credentials: `http://host:8080`. */
87
+ export declare function proxyLabel(server: string): string;
88
+ export declare function runBench(o: BenchOptions, launchFn: (dir: string, opts: Record<string, unknown>) => Promise<BrowserContext>, exeName?: string, progress?: (line: string) => void): Promise<BenchRaw>;
89
+ export interface BenchReport {
90
+ host: HostReport;
91
+ url: string;
92
+ proxy: string | null;
93
+ headless: boolean;
94
+ requested: number;
95
+ concurrency: number;
96
+ durationSec: number;
97
+ launch: {
98
+ started: number;
99
+ medianMs: number | null;
100
+ errors: string[];
101
+ };
102
+ pages: {
103
+ loads: number;
104
+ dclMedianMs: number | null;
105
+ dclP95Ms: number | null;
106
+ loadMedianMs: number | null;
107
+ loadP95Ms: number | null;
108
+ loadTimeouts: number;
109
+ idleReached: number;
110
+ idleMissed: number;
111
+ errors: Array<{
112
+ count: number;
113
+ error: string;
114
+ }>;
115
+ };
116
+ perBrowser: {
117
+ cpuThreads: number;
118
+ cpuPercentOfMachine: number;
119
+ memMB: number;
120
+ } | null;
121
+ machine: {
122
+ cpuBefore: number | null;
123
+ cpuDuring: number | null;
124
+ saturated: boolean;
125
+ };
126
+ capacity: {
127
+ browsers: number;
128
+ limit: "cpu" | "ram";
129
+ byCpu: number;
130
+ byRam: number;
131
+ } | null;
132
+ advice: string[];
133
+ }
134
+ /** The figures and advice of a bench run. Pure: the same raw run gives the same report in both SDKs. */
135
+ export declare function summarizeBench(raw: BenchRaw): BenchReport;
136
+ /** What `clearcote bench` prints. */
137
+ export declare function benchLines(r: BenchReport): string[];
138
+ //# sourceMappingURL=bench.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bench.d.ts","sourceRoot":"","sources":["../src/bench.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,8FAA8F;IAC9F,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,kFAAkF;IAClF,aAAa,EAAE,OAAO,CAAC;IACvB,qFAAqF;IACrF,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;CAChD;AA4BD,eAAO,MAAM,qBAAqB,4FAA4F,CAAC;AAE/H,qHAAqH;AACrH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAA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