browser-pilot 0.0.15 → 0.0.16
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 +16 -3
- package/dist/actions.cjs +60 -45
- package/dist/actions.d.cts +2 -2
- package/dist/actions.d.ts +2 -2
- package/dist/actions.mjs +1 -1
- package/dist/{browser-MEWT75IB.mjs → browser-ZCR6AA4D.mjs} +2 -2
- package/dist/browser.cjs +455 -67
- package/dist/browser.d.cts +3 -3
- package/dist/browser.d.ts +3 -3
- package/dist/browser.mjs +3 -3
- package/dist/{chunk-USYSHCI3.mjs → chunk-6GBYX7C2.mjs} +87 -62
- package/dist/chunk-EZNZ72VA.mjs +563 -0
- package/dist/{chunk-ZAXQ5OTV.mjs → chunk-NNEHWWHL.mjs} +23 -9
- package/dist/{chunk-WPNW23CE.mjs → chunk-TJ5B56NV.mjs} +345 -7
- package/dist/{chunk-7YVCOL2W.mjs → chunk-V3VLBQAM.mjs} +60 -45
- package/dist/cli.mjs +530 -381
- package/dist/index.cjs +419 -55
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +19 -7
- package/dist/{page-XPS6IC6V.mjs → page-IUUTJ3SW.mjs} +1 -1
- package/dist/providers.cjs +637 -2
- package/dist/providers.d.cts +2 -2
- package/dist/providers.d.ts +2 -2
- package/dist/providers.mjs +17 -3
- package/dist/{types-C9ySEdOX.d.cts → types-BflRmiDz.d.cts} +1 -1
- package/dist/{types-Cvvf0oGu.d.ts → types-BzM-IfsL.d.ts} +1 -1
- package/dist/types-DeVSWhXj.d.cts +142 -0
- package/dist/types-DeVSWhXj.d.ts +142 -0
- package/package.json +1 -1
- package/dist/chunk-BRAFQUMG.mjs +0 -229
- package/dist/types--wXNHUwt.d.cts +0 -56
- package/dist/types--wXNHUwt.d.ts +0 -56
package/README.md
CHANGED
|
@@ -26,7 +26,20 @@ bun add browser-pilot
|
|
|
26
26
|
npm install browser-pilot
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
For local Chrome
|
|
29
|
+
For local Chrome on Chrome 144+:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 1. Start Chrome normally
|
|
33
|
+
# 2. Open chrome://inspect/#remote-debugging
|
|
34
|
+
# 3. Enable remote debugging, then run:
|
|
35
|
+
bp connect
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Tip: try plain `bp connect` first. Only add `--channel` or `--user-data-dir` if auto-discovery finds more than one eligible profile.
|
|
39
|
+
|
|
40
|
+
Use `bp connect --channel beta` or `bp connect --user-data-dir <path>` when more than one Chrome profile is eligible.
|
|
41
|
+
|
|
42
|
+
Legacy/manual fallback still works with a separate debug profile:
|
|
30
43
|
|
|
31
44
|
```bash
|
|
32
45
|
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
|
|
@@ -48,7 +61,7 @@ For local Chrome:
|
|
|
48
61
|
## Golden path 1: automate a page
|
|
49
62
|
|
|
50
63
|
```bash
|
|
51
|
-
bp connect --
|
|
64
|
+
bp connect --name dev
|
|
52
65
|
bp snapshot -i -s dev
|
|
53
66
|
bp exec -s dev '[
|
|
54
67
|
{"action":"fill","selector":"ref:e5","value":"user@example.com"},
|
|
@@ -74,7 +87,7 @@ Do not start by opening the raw artifact. Use `record summary`, `record inspect`
|
|
|
74
87
|
## Golden path 3: debug a realtime or voice session
|
|
75
88
|
|
|
76
89
|
```bash
|
|
77
|
-
bp connect --
|
|
90
|
+
bp connect --name realtime
|
|
78
91
|
bp trace start -s realtime --timeout 20000
|
|
79
92
|
# reproduce the issue in the app
|
|
80
93
|
bp trace summary -s realtime --view ws
|
package/dist/actions.cjs
CHANGED
|
@@ -582,7 +582,9 @@ function buildTraceSummaries(events) {
|
|
|
582
582
|
};
|
|
583
583
|
}
|
|
584
584
|
function summarizeWs(events) {
|
|
585
|
-
const relevant = events.filter(
|
|
585
|
+
const relevant = events.filter(
|
|
586
|
+
(event) => event.channel === "ws" || event.event.startsWith("ws.")
|
|
587
|
+
);
|
|
586
588
|
const connections = /* @__PURE__ */ new Map();
|
|
587
589
|
for (const event of relevant) {
|
|
588
590
|
const id = event.connectionId ?? event.requestId ?? event.traceId;
|
|
@@ -612,7 +614,7 @@ function summarizeWs(events) {
|
|
|
612
614
|
}
|
|
613
615
|
const values = [...connections.values()];
|
|
614
616
|
const reconnects = values.reduce((count, connection) => {
|
|
615
|
-
return connection.closedAt && !connection.createdAt ? count : count;
|
|
617
|
+
return connection.closedAt && !connection.createdAt ? count + 1 : count;
|
|
616
618
|
}, 0);
|
|
617
619
|
return {
|
|
618
620
|
view: "ws",
|
|
@@ -865,6 +867,31 @@ function frameToStep(frame) {
|
|
|
865
867
|
}
|
|
866
868
|
}
|
|
867
869
|
|
|
870
|
+
// src/trace/model.ts
|
|
871
|
+
function createTraceId(prefix = "evt") {
|
|
872
|
+
const random = Math.random().toString(36).slice(2, 10);
|
|
873
|
+
return `${prefix}-${Date.now().toString(36)}-${random}`;
|
|
874
|
+
}
|
|
875
|
+
function normalizeTraceEvent(event) {
|
|
876
|
+
return {
|
|
877
|
+
traceId: event.traceId ?? createTraceId(event.channel),
|
|
878
|
+
ts: event.ts ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
879
|
+
elapsedMs: event.elapsedMs ?? 0,
|
|
880
|
+
severity: event.severity ?? inferSeverity(event.event),
|
|
881
|
+
data: event.data ?? {},
|
|
882
|
+
...event
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function inferSeverity(eventName) {
|
|
886
|
+
if (eventName.includes(".failed") || eventName.includes(".error") || eventName.includes("exception") || eventName.includes("notReady")) {
|
|
887
|
+
return "error";
|
|
888
|
+
}
|
|
889
|
+
if (eventName.includes(".closed") || eventName.includes(".warn") || eventName.includes(".changed")) {
|
|
890
|
+
return "warn";
|
|
891
|
+
}
|
|
892
|
+
return "info";
|
|
893
|
+
}
|
|
894
|
+
|
|
868
895
|
// src/trace/script.ts
|
|
869
896
|
var TRACE_BINDING_NAME = "__bpTraceBinding";
|
|
870
897
|
var TRACE_SCRIPT = `
|
|
@@ -1144,31 +1171,6 @@ var TRACE_SCRIPT = `
|
|
|
1144
1171
|
})();
|
|
1145
1172
|
`;
|
|
1146
1173
|
|
|
1147
|
-
// src/trace/model.ts
|
|
1148
|
-
function createTraceId(prefix = "evt") {
|
|
1149
|
-
const random = Math.random().toString(36).slice(2, 10);
|
|
1150
|
-
return `${prefix}-${Date.now().toString(36)}-${random}`;
|
|
1151
|
-
}
|
|
1152
|
-
function normalizeTraceEvent(event) {
|
|
1153
|
-
return {
|
|
1154
|
-
traceId: event.traceId ?? createTraceId(event.channel),
|
|
1155
|
-
ts: event.ts ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1156
|
-
elapsedMs: event.elapsedMs ?? 0,
|
|
1157
|
-
severity: event.severity ?? inferSeverity(event.event),
|
|
1158
|
-
data: event.data ?? {},
|
|
1159
|
-
...event
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
function inferSeverity(eventName) {
|
|
1163
|
-
if (eventName.includes(".failed") || eventName.includes(".error") || eventName.includes("exception") || eventName.includes("notReady")) {
|
|
1164
|
-
return "error";
|
|
1165
|
-
}
|
|
1166
|
-
if (eventName.includes(".closed") || eventName.includes(".warn") || eventName.includes(".changed")) {
|
|
1167
|
-
return "warn";
|
|
1168
|
-
}
|
|
1169
|
-
return "info";
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
1174
|
// src/trace/live.ts
|
|
1173
1175
|
function globToRegex(pattern) {
|
|
1174
1176
|
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
@@ -1185,6 +1187,15 @@ var DEFAULT_RECORDING_SKIP_ACTIONS = [
|
|
|
1185
1187
|
"text",
|
|
1186
1188
|
"screenshot"
|
|
1187
1189
|
];
|
|
1190
|
+
function readString(value) {
|
|
1191
|
+
return typeof value === "string" ? value : void 0;
|
|
1192
|
+
}
|
|
1193
|
+
function readStringOr(value, fallback = "") {
|
|
1194
|
+
return readString(value) ?? fallback;
|
|
1195
|
+
}
|
|
1196
|
+
function formatConsoleArg(entry) {
|
|
1197
|
+
return readString(entry["value"]) ?? readString(entry["description"]) ?? "";
|
|
1198
|
+
}
|
|
1188
1199
|
function loadExistingRecording(manifestPath) {
|
|
1189
1200
|
try {
|
|
1190
1201
|
const raw = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
@@ -1985,8 +1996,13 @@ Valid actions: ${valid}`);
|
|
|
1985
1996
|
await this.page.cdpClient.send("Runtime.addBinding", { name: TRACE_BINDING_NAME });
|
|
1986
1997
|
} catch {
|
|
1987
1998
|
}
|
|
1988
|
-
await this.page.cdpClient.send("Page.addScriptToEvaluateOnNewDocument", {
|
|
1989
|
-
|
|
1999
|
+
await this.page.cdpClient.send("Page.addScriptToEvaluateOnNewDocument", {
|
|
2000
|
+
source: TRACE_SCRIPT
|
|
2001
|
+
});
|
|
2002
|
+
await this.page.cdpClient.send("Runtime.evaluate", {
|
|
2003
|
+
expression: TRACE_SCRIPT,
|
|
2004
|
+
awaitPromise: false
|
|
2005
|
+
});
|
|
1990
2006
|
}
|
|
1991
2007
|
async waitForWsMessage(match, where, timeout) {
|
|
1992
2008
|
await this.ensureTraceHooks();
|
|
@@ -2004,12 +2020,12 @@ Valid actions: ${valid}`);
|
|
|
2004
2020
|
clearTimeout(timer);
|
|
2005
2021
|
};
|
|
2006
2022
|
const onCreated = (params) => {
|
|
2007
|
-
wsUrls.set(
|
|
2023
|
+
wsUrls.set(readStringOr(params["requestId"]), readStringOr(params["url"]));
|
|
2008
2024
|
};
|
|
2009
2025
|
const onFrame = (params) => {
|
|
2010
|
-
const requestId =
|
|
2026
|
+
const requestId = readStringOr(params["requestId"]);
|
|
2011
2027
|
const response = params["response"] ?? {};
|
|
2012
|
-
const payload =
|
|
2028
|
+
const payload = response.payloadData ?? "";
|
|
2013
2029
|
const url = wsUrls.get(requestId) ?? "";
|
|
2014
2030
|
if (!regex.test(url) && !regex.test(payload)) {
|
|
2015
2031
|
return;
|
|
@@ -2025,13 +2041,13 @@ Valid actions: ${valid}`);
|
|
|
2025
2041
|
return;
|
|
2026
2042
|
}
|
|
2027
2043
|
try {
|
|
2028
|
-
const parsed = JSON.parse(
|
|
2044
|
+
const parsed = JSON.parse(readStringOr(params["payload"]));
|
|
2029
2045
|
if (parsed.event !== "ws.frame.received") {
|
|
2030
2046
|
return;
|
|
2031
2047
|
}
|
|
2032
2048
|
const data = parsed.data ?? {};
|
|
2033
|
-
const payload =
|
|
2034
|
-
const url =
|
|
2049
|
+
const payload = readStringOr(data["payload"]);
|
|
2050
|
+
const url = readStringOr(data["url"]);
|
|
2035
2051
|
if (!regex.test(url) && !regex.test(payload)) {
|
|
2036
2052
|
return;
|
|
2037
2053
|
}
|
|
@@ -2040,7 +2056,7 @@ Valid actions: ${valid}`);
|
|
|
2040
2056
|
}
|
|
2041
2057
|
cleanup();
|
|
2042
2058
|
resolve({
|
|
2043
|
-
requestId:
|
|
2059
|
+
requestId: readStringOr(data["connectionId"]),
|
|
2044
2060
|
url,
|
|
2045
2061
|
payload
|
|
2046
2062
|
});
|
|
@@ -2084,13 +2100,14 @@ Valid actions: ${valid}`);
|
|
|
2084
2100
|
if (!entry || typeof entry !== "object") {
|
|
2085
2101
|
continue;
|
|
2086
2102
|
}
|
|
2087
|
-
const
|
|
2103
|
+
const record = entry;
|
|
2104
|
+
const event = readStringOr(record["event"]);
|
|
2088
2105
|
if (event !== "ws.frame.received") {
|
|
2089
2106
|
continue;
|
|
2090
2107
|
}
|
|
2091
|
-
const data =
|
|
2092
|
-
const payload =
|
|
2093
|
-
const url =
|
|
2108
|
+
const data = record["data"] ?? {};
|
|
2109
|
+
const payload = readStringOr(data["payload"]);
|
|
2110
|
+
const url = readStringOr(data["url"]);
|
|
2094
2111
|
if (!regex.test(url) && !regex.test(payload)) {
|
|
2095
2112
|
continue;
|
|
2096
2113
|
}
|
|
@@ -2098,7 +2115,7 @@ Valid actions: ${valid}`);
|
|
|
2098
2115
|
continue;
|
|
2099
2116
|
}
|
|
2100
2117
|
return {
|
|
2101
|
-
requestId:
|
|
2118
|
+
requestId: readStringOr(data["connectionId"]),
|
|
2102
2119
|
url,
|
|
2103
2120
|
payload
|
|
2104
2121
|
};
|
|
@@ -2119,13 +2136,11 @@ Valid actions: ${valid}`);
|
|
|
2119
2136
|
return;
|
|
2120
2137
|
}
|
|
2121
2138
|
const args = Array.isArray(params["args"]) ? params["args"] : [];
|
|
2122
|
-
errors.push(
|
|
2123
|
-
args.map((entry) => String(entry["value"] ?? entry["description"] ?? "")).filter(Boolean).join(" ")
|
|
2124
|
-
);
|
|
2139
|
+
errors.push(args.map(formatConsoleArg).filter(Boolean).join(" "));
|
|
2125
2140
|
};
|
|
2126
2141
|
const onException = (params) => {
|
|
2127
2142
|
const details = params["exceptionDetails"] ?? {};
|
|
2128
|
-
errors.push(
|
|
2143
|
+
errors.push(readString(details["text"]) ?? "Runtime exception");
|
|
2129
2144
|
};
|
|
2130
2145
|
const timer = setTimeout(() => {
|
|
2131
2146
|
cleanup();
|
package/dist/actions.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-
|
|
2
|
-
export { A as ActionType, aj as FailureReason, c as RecordOptions, d as StepResult } from './types-
|
|
1
|
+
import { J as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-BflRmiDz.cjs';
|
|
2
|
+
export { A as ActionType, aj as FailureReason, c as RecordOptions, d as StepResult } from './types-BflRmiDz.cjs';
|
|
3
3
|
import './client-B5QBRgIy.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-
|
|
2
|
-
export { A as ActionType, aj as FailureReason, c as RecordOptions, d as StepResult } from './types-
|
|
1
|
+
import { J as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-BzM-IfsL.js';
|
|
2
|
+
export { A as ActionType, aj as FailureReason, c as RecordOptions, d as StepResult } from './types-BzM-IfsL.js';
|
|
3
3
|
import './client-B5QBRgIy.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/actions.mjs
CHANGED