blastproof 0.30.0 → 0.32.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 +3 -2
- package/dist/chunk-O6UTUPT6.js +387 -0
- package/dist/chunk-O6UTUPT6.js.map +1 -0
- package/dist/cli.js +80 -205
- package/dist/cli.js.map +1 -1
- package/dist/{snapshot-JISKGGMN.js → snapshot-ECNLGVUG.js} +4 -2
- package/package.json +1 -1
- package/dist/chunk-DO4WZKLT.js +0 -124
- package/dist/chunk-DO4WZKLT.js.map +0 -1
- /package/dist/{snapshot-JISKGGMN.js.map → snapshot-ECNLGVUG.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
allowedOriginsFor,
|
|
4
|
+
bindTarget,
|
|
5
|
+
describeBoundary,
|
|
3
6
|
indexRefs,
|
|
7
|
+
isOriginAllowed,
|
|
8
|
+
performAction,
|
|
4
9
|
snapshotCutAt,
|
|
5
10
|
withoutRefs
|
|
6
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-O6UTUPT6.js";
|
|
7
12
|
|
|
8
13
|
// src/cli.ts
|
|
9
14
|
import { Command, InvalidArgumentError } from "commander";
|
|
@@ -494,189 +499,6 @@ var SecretsMask = class {
|
|
|
494
499
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
495
500
|
import path2 from "path";
|
|
496
501
|
|
|
497
|
-
// src/runner/actions.ts
|
|
498
|
-
var ActionError = class extends Error {
|
|
499
|
-
constructor(message) {
|
|
500
|
-
super(message);
|
|
501
|
-
this.name = "ActionError";
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
var BLANK_PAGE = "about:blank";
|
|
505
|
-
function allowedOriginsFor(baseUrl, allowedOrigins) {
|
|
506
|
-
const allowed = /* @__PURE__ */ new Set([new URL(baseUrl).origin]);
|
|
507
|
-
for (const origin of allowedOrigins ?? []) {
|
|
508
|
-
allowed.add(new URL(origin).origin);
|
|
509
|
-
}
|
|
510
|
-
return allowed;
|
|
511
|
-
}
|
|
512
|
-
function isOriginAllowed(url, allowed) {
|
|
513
|
-
if (url === BLANK_PAGE) return true;
|
|
514
|
-
let origin;
|
|
515
|
-
try {
|
|
516
|
-
origin = new URL(url).origin;
|
|
517
|
-
} catch {
|
|
518
|
-
return false;
|
|
519
|
-
}
|
|
520
|
-
if (origin === "null") return false;
|
|
521
|
-
return allowed.has(origin);
|
|
522
|
-
}
|
|
523
|
-
function describeBoundary(allowed) {
|
|
524
|
-
return [...allowed].join(" or ");
|
|
525
|
-
}
|
|
526
|
-
function assertAllowedOrigin(url, ctx) {
|
|
527
|
-
const allowed = allowedOriginsFor(ctx.baseUrl, ctx.allowedOrigins);
|
|
528
|
-
if (!isOriginAllowed(url.toString(), allowed)) {
|
|
529
|
-
throw new ActionError(
|
|
530
|
-
`Refusing to navigate outside the application: ${url.origin} is not ${describeBoundary(allowed)}. Add it to allowed_origins in .blastproof/config.yaml if the app legitimately spans hosts.`
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
function describeTarget(target) {
|
|
535
|
-
const parts = [];
|
|
536
|
-
if (target.role) parts.push(`role=${target.role}`);
|
|
537
|
-
if (target.name) parts.push(`name="${target.name}"`);
|
|
538
|
-
return parts.join(" ") || "(no target)";
|
|
539
|
-
}
|
|
540
|
-
function normaliseName(text) {
|
|
541
|
-
return (text ?? "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
542
|
-
}
|
|
543
|
-
function bareRef(ref) {
|
|
544
|
-
return ref.trim().replace(/^\[/, "").replace(/^ref=/, "").replace(/\]$/, "");
|
|
545
|
-
}
|
|
546
|
-
function describeElement(element) {
|
|
547
|
-
const name = element.name ?? element.text;
|
|
548
|
-
return name === void 0 ? element.role : `${element.role} "${name}"`;
|
|
549
|
-
}
|
|
550
|
-
function bindTarget(action, refs) {
|
|
551
|
-
const target = action.target;
|
|
552
|
-
if (!target || !target.ref && !target.role && !target.name) return { ...action, target: void 0 };
|
|
553
|
-
const fix = "Use the [ref=\u2026] on the line of the element you mean in the current snapshot.";
|
|
554
|
-
if (!target.ref) {
|
|
555
|
-
throw new ActionError(`refused: the target names no ref, so nothing was done. ${fix}`);
|
|
556
|
-
}
|
|
557
|
-
const ref = bareRef(target.ref);
|
|
558
|
-
const element = refs.get(ref);
|
|
559
|
-
if (!element) {
|
|
560
|
-
throw new ActionError(`refused: no element in the current snapshot has ref "${ref}". ${fix}`);
|
|
561
|
-
}
|
|
562
|
-
const shown = element.name ?? element.text;
|
|
563
|
-
const sameRole = normaliseName(target.role) === normaliseName(element.role);
|
|
564
|
-
const sameName = normaliseName(target.name) === normaliseName(shown);
|
|
565
|
-
if (!sameRole || !sameName) {
|
|
566
|
-
const said = [target.role ?? "(no role)", target.name === void 0 ? "" : `"${target.name}"`].filter(Boolean).join(" ");
|
|
567
|
-
throw new ActionError(
|
|
568
|
-
`refused: ref ${ref} is ${describeElement(element)}, not ${said}, so nothing was done. ${fix}`
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
return { ...action, target: { ref, role: element.role, name: shown } };
|
|
572
|
-
}
|
|
573
|
-
async function resolveTarget(page, target, resolveTimeoutMs = 2e3) {
|
|
574
|
-
if (!target.ref) throw new ActionError(`Element not found: ${describeTarget(target)} has no ref`);
|
|
575
|
-
const ref = bareRef(target.ref);
|
|
576
|
-
const locator = page.locator(`aria-ref=${ref}`);
|
|
577
|
-
let count2;
|
|
578
|
-
try {
|
|
579
|
-
count2 = await locator.count();
|
|
580
|
-
} catch {
|
|
581
|
-
count2 = 0;
|
|
582
|
-
}
|
|
583
|
-
if (count2 === 0) {
|
|
584
|
-
throw new ActionError(
|
|
585
|
-
`Element not found: ${describeTarget(target)} (ref ${ref}) is no longer on the page; it changed since the snapshot. Choose the element again from the fresh snapshot.`
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
try {
|
|
589
|
-
await locator.waitFor({ state: "visible", timeout: resolveTimeoutMs });
|
|
590
|
-
} catch {
|
|
591
|
-
throw new ActionError(
|
|
592
|
-
`Element not found: ${describeTarget(target)} (ref ${ref}) is on the page but did not become visible within ${resolveTimeoutMs}ms.`
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
return locator;
|
|
596
|
-
}
|
|
597
|
-
function requireTarget(action) {
|
|
598
|
-
if (!action.target?.ref) {
|
|
599
|
-
throw new ActionError(`Action "${action.action}" requires a target (its ref in the snapshot)`);
|
|
600
|
-
}
|
|
601
|
-
return action.target;
|
|
602
|
-
}
|
|
603
|
-
function resolve(value, ctx) {
|
|
604
|
-
return ctx.resolveValue ? ctx.resolveValue(value) : value;
|
|
605
|
-
}
|
|
606
|
-
function requireValue(action) {
|
|
607
|
-
if (action.value === void 0 || action.value === "") {
|
|
608
|
-
throw new ActionError(`Action "${action.action}" requires a value`);
|
|
609
|
-
}
|
|
610
|
-
return action.value;
|
|
611
|
-
}
|
|
612
|
-
var INTERCEPTS_POINTER = /(<[^>\n]{1,400}>)[^\n]{0,400}?intercepts pointer events/;
|
|
613
|
-
var MAX_BLOCKER_LENGTH = 80;
|
|
614
|
-
function truncateBlocker(tag) {
|
|
615
|
-
return tag.length <= MAX_BLOCKER_LENGTH ? tag : `${tag.slice(0, MAX_BLOCKER_LENGTH)}\u2026>`;
|
|
616
|
-
}
|
|
617
|
-
function obstructionFor(error, action) {
|
|
618
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
619
|
-
const match = INTERCEPTS_POINTER.exec(message);
|
|
620
|
-
if (!match) return void 0;
|
|
621
|
-
const where = action.target ? ` on ${describeTarget(action.target)}` : "";
|
|
622
|
-
return new ActionError(
|
|
623
|
-
`blocked: the ${action.action}${where} was NOT performed. The target was found and is visible, enabled and stable \u2014 nothing about it is wrong. ${truncateBlocker(match[1])} is on top of it and received the pointer event instead. Something is covering the page: find it in the snapshot \u2014 a dialog, a cookie banner, an onboarding overlay \u2014 and dismiss it first, using its own close or accept control, or by pressing Escape with no target. Then act on this target again. Choosing a different name for the same target cannot help.`
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
async function performAction(page, action, ctx) {
|
|
627
|
-
try {
|
|
628
|
-
return await performResolvedAction(page, action, ctx);
|
|
629
|
-
} catch (error) {
|
|
630
|
-
throw obstructionFor(error, action) ?? error;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
async function performResolvedAction(page, action, ctx) {
|
|
634
|
-
switch (action.action) {
|
|
635
|
-
case "navigate": {
|
|
636
|
-
const value = resolve(requireValue(action), ctx);
|
|
637
|
-
const url = new URL(value, ctx.baseUrl);
|
|
638
|
-
assertAllowedOrigin(url, ctx);
|
|
639
|
-
await page.goto(url.toString(), { timeout: ctx.resolveTimeoutMs ?? 3e4 });
|
|
640
|
-
const landed = page.url();
|
|
641
|
-
return landed === url.toString() ? `ok: navigated to ${url.toString()}` : `ok: navigated to ${url.toString()}, which redirected to ${landed}`;
|
|
642
|
-
}
|
|
643
|
-
case "click": {
|
|
644
|
-
const target = requireTarget(action);
|
|
645
|
-
const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);
|
|
646
|
-
await locator.click();
|
|
647
|
-
return `ok: clicked ${describeTarget(target)}`;
|
|
648
|
-
}
|
|
649
|
-
case "fill": {
|
|
650
|
-
const target = requireTarget(action);
|
|
651
|
-
const value = resolve(requireValue(action), ctx);
|
|
652
|
-
const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);
|
|
653
|
-
await locator.fill(value);
|
|
654
|
-
return `ok: filled ${describeTarget(target)}`;
|
|
655
|
-
}
|
|
656
|
-
case "press": {
|
|
657
|
-
const key = action.value ? resolve(action.value, ctx) : "Enter";
|
|
658
|
-
if (action.target?.ref) {
|
|
659
|
-
const locator = await resolveTarget(page, action.target, ctx.resolveTimeoutMs);
|
|
660
|
-
await locator.press(key);
|
|
661
|
-
return `ok: pressed ${key} on ${describeTarget(action.target)}`;
|
|
662
|
-
}
|
|
663
|
-
await page.keyboard.press(key);
|
|
664
|
-
return `ok: pressed ${key}`;
|
|
665
|
-
}
|
|
666
|
-
case "select": {
|
|
667
|
-
const target = requireTarget(action);
|
|
668
|
-
const value = resolve(requireValue(action), ctx);
|
|
669
|
-
const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);
|
|
670
|
-
await locator.selectOption({ label: value });
|
|
671
|
-
return `ok: selected "${value}" in ${describeTarget(target)}`;
|
|
672
|
-
}
|
|
673
|
-
case "assert":
|
|
674
|
-
case "done":
|
|
675
|
-
case "fail":
|
|
676
|
-
throw new ActionError(`Action "${action.action}" is handled by the executor, not the page`);
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
502
|
// src/runner/authoring.ts
|
|
681
503
|
var VALUE_VERBS = ["fill", "enter", "type", "input", "set"];
|
|
682
504
|
var LEADING_VALUE_VERB = new RegExp(`^\\s*(?:${VALUE_VERBS.join("|")})\\b`, "i");
|
|
@@ -964,9 +786,9 @@ async function waitForSettled(page) {
|
|
|
964
786
|
});
|
|
965
787
|
}
|
|
966
788
|
}
|
|
967
|
-
async function defaultSnapshot(page, maxLines) {
|
|
968
|
-
const { captureSnapshot } = await import("./snapshot-
|
|
969
|
-
return captureSnapshot(page, { maxLines });
|
|
789
|
+
async function defaultSnapshot(page, maxLines, frames) {
|
|
790
|
+
const { captureSnapshot } = await import("./snapshot-ECNLGVUG.js");
|
|
791
|
+
return captureSnapshot(page, { maxLines, frames });
|
|
970
792
|
}
|
|
971
793
|
function slugify(text) {
|
|
972
794
|
const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
@@ -980,13 +802,26 @@ var StepFailure = class extends Error {
|
|
|
980
802
|
async function pageChangedWithin(page, takeSnapshot, view, seen, withinMs) {
|
|
981
803
|
const deadline = Date.now() + withinMs;
|
|
982
804
|
while (Date.now() < deadline) {
|
|
983
|
-
await new Promise((
|
|
805
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(RENDER_POLL_MS, Math.max(0, deadline - Date.now()))));
|
|
984
806
|
const raw = await takeSnapshot(page);
|
|
985
807
|
const current = view(raw);
|
|
986
808
|
if (current !== seen) return { raw, page: current };
|
|
987
809
|
}
|
|
988
810
|
return void 0;
|
|
989
811
|
}
|
|
812
|
+
var NOTE_MAX_LINES = 4;
|
|
813
|
+
function pageChangeNote(before, after) {
|
|
814
|
+
const beforeLines = before.split("\n");
|
|
815
|
+
const afterLines = after.split("\n");
|
|
816
|
+
const kept = { before: new Set(beforeLines), after: new Set(afterLines) };
|
|
817
|
+
const removed = beforeLines.filter((line) => !kept.after.has(line));
|
|
818
|
+
const added = afterLines.filter((line) => !kept.before.has(line));
|
|
819
|
+
const changed = removed.length + added.length;
|
|
820
|
+
if (changed === 0) return " (after it, the page did not change at all)";
|
|
821
|
+
if (changed > NOTE_MAX_LINES) return void 0;
|
|
822
|
+
const lines = [...removed.map((line) => `- ${line.trim()}`), ...added.map((line) => `+ ${line.trim()}`)];
|
|
823
|
+
return ` (after it, the only change on the page: ${lines.join("; ")})`;
|
|
824
|
+
}
|
|
990
825
|
async function executeTest(page, test, options) {
|
|
991
826
|
const {
|
|
992
827
|
brain,
|
|
@@ -1002,9 +837,11 @@ async function executeTest(page, test, options) {
|
|
|
1002
837
|
maxSnapshotLines,
|
|
1003
838
|
renderWatchMs = RENDER_WATCH_MS,
|
|
1004
839
|
onEvent = () => {
|
|
1005
|
-
}
|
|
840
|
+
},
|
|
841
|
+
onHiddenFrame
|
|
1006
842
|
} = options;
|
|
1007
|
-
const
|
|
843
|
+
const boundary = allowedOriginsFor(baseUrl, allowedOrigins);
|
|
844
|
+
const takeSnapshot = snapshot ?? ((page2) => defaultSnapshot(page2, maxSnapshotLines, { allowed: boundary, onHidden: onHiddenFrame }));
|
|
1008
845
|
const startedAt = Date.now();
|
|
1009
846
|
const stepResults = [];
|
|
1010
847
|
const allSteps = [
|
|
@@ -1021,7 +858,6 @@ async function executeTest(page, test, options) {
|
|
|
1021
858
|
onEvent({ type: "action", index, action: maskedAction, result: mask(result) });
|
|
1022
859
|
};
|
|
1023
860
|
let failure;
|
|
1024
|
-
const boundary = allowedOriginsFor(baseUrl, allowedOrigins);
|
|
1025
861
|
await page.goto(new URL(baseUrl).toString());
|
|
1026
862
|
const usedEarlier = /* @__PURE__ */ new Set();
|
|
1027
863
|
for (let index = 0; index < allSteps.length; index++) {
|
|
@@ -1035,6 +871,8 @@ async function executeTest(page, test, options) {
|
|
|
1035
871
|
let lastSnapshot;
|
|
1036
872
|
let lookedAgain = false;
|
|
1037
873
|
const recovery = new StepRecovery(step);
|
|
874
|
+
const agentRecord = [];
|
|
875
|
+
let pageActedOn;
|
|
1038
876
|
try {
|
|
1039
877
|
while (true) {
|
|
1040
878
|
if (iterations >= maxIterationsPerStep) {
|
|
@@ -1052,6 +890,15 @@ async function executeTest(page, test, options) {
|
|
|
1052
890
|
const refs = indexRefs(maskedSnap);
|
|
1053
891
|
const pageSnap = withoutRefs(maskedSnap);
|
|
1054
892
|
recovery.observe(pageSnap);
|
|
893
|
+
if (pageActedOn !== void 0) {
|
|
894
|
+
const note = pageChangeNote(pageActedOn, pageSnap);
|
|
895
|
+
const acted = agentRecord[agentRecord.length - 1];
|
|
896
|
+
if (note !== void 0 && acted !== void 0 && lastResult !== void 0) {
|
|
897
|
+
acted.result += note;
|
|
898
|
+
lastResult += note;
|
|
899
|
+
}
|
|
900
|
+
pageActedOn = void 0;
|
|
901
|
+
}
|
|
1055
902
|
let action;
|
|
1056
903
|
try {
|
|
1057
904
|
action = await brain.nextAction({
|
|
@@ -1061,7 +908,7 @@ async function executeTest(page, test, options) {
|
|
|
1061
908
|
lastResult: lastResult === void 0 ? void 0 : mask(lastResult),
|
|
1062
909
|
// Already masked when recorded, on the same boundary as everything
|
|
1063
910
|
// else crossing into a prompt (design contained-recovery, D2).
|
|
1064
|
-
stepHistory:
|
|
911
|
+
stepHistory: agentRecord.map((entry) => ({ ...entry })),
|
|
1065
912
|
retriesLeft: maxRetries - failedAttempts,
|
|
1066
913
|
iterationsLeft: maxIterationsPerStep - iterations
|
|
1067
914
|
});
|
|
@@ -1145,6 +992,9 @@ async function executeTest(page, test, options) {
|
|
|
1145
992
|
continue;
|
|
1146
993
|
}
|
|
1147
994
|
const result = judgment.pass ? `ok: assertion passed: ${judgment.reason}` : `assertion failed: ${judgment.reason}`;
|
|
995
|
+
if (!judgment.pass) {
|
|
996
|
+
agentRecord.push({ action: `assert "${mask(expectation)}"`, result: mask(result) });
|
|
997
|
+
}
|
|
1148
998
|
emitAction(index, shown(), result);
|
|
1149
999
|
if (judgment.pass) {
|
|
1150
1000
|
lastResult = result;
|
|
@@ -1187,6 +1037,8 @@ async function executeTest(page, test, options) {
|
|
|
1187
1037
|
});
|
|
1188
1038
|
lastResult = result;
|
|
1189
1039
|
recovery.record(action, mask(describeAction(action)), mask(result));
|
|
1040
|
+
agentRecord.push({ action: mask(describeAction(action)), result: mask(result) });
|
|
1041
|
+
pageActedOn = pageSnap;
|
|
1190
1042
|
emitAction(index, action, result);
|
|
1191
1043
|
} catch (error) {
|
|
1192
1044
|
failedAttempts++;
|
|
@@ -1273,8 +1125,8 @@ function deviceOptions(name) {
|
|
|
1273
1125
|
var SESSION_SEEDED_MARKER = "blastproof:session-seeded";
|
|
1274
1126
|
async function readFalsyRecords() {
|
|
1275
1127
|
const g = globalThis;
|
|
1276
|
-
const done = (request) => new Promise((
|
|
1277
|
-
request.onsuccess = () =>
|
|
1128
|
+
const done = (request) => new Promise((resolve, reject) => {
|
|
1129
|
+
request.onsuccess = () => resolve(request.result);
|
|
1278
1130
|
request.onerror = () => reject(request.error);
|
|
1279
1131
|
});
|
|
1280
1132
|
const encode = (value) => {
|
|
@@ -1482,7 +1334,8 @@ async function verifyJudgment(brain, verify, snapshot, maskText, maxRetries = 3)
|
|
|
1482
1334
|
async function fromSteps(options) {
|
|
1483
1335
|
const { auth, baseUrl, browser, brain, maxRetries, snapshot, timeoutMs, maxSnapshotLines, onEvent, mask } = options;
|
|
1484
1336
|
const steps = auth.steps;
|
|
1485
|
-
const
|
|
1337
|
+
const frames = { allowed: allowedOriginsFor(baseUrl, options.allowedOrigins), onHidden: options.onHiddenFrame };
|
|
1338
|
+
const takeSnapshot = snapshot ?? ((page) => defaultSnapshot(page, maxSnapshotLines, frames));
|
|
1486
1339
|
const context = await browser.newContext(deviceOptions(options.device));
|
|
1487
1340
|
try {
|
|
1488
1341
|
const page = await context.newPage();
|
|
@@ -1980,6 +1833,13 @@ function emitWarning(warning, into) {
|
|
|
1980
1833
|
function warningText(warning) {
|
|
1981
1834
|
return [warning.title, ...warning.lines].join("\n");
|
|
1982
1835
|
}
|
|
1836
|
+
function hiddenFrameWarning(origin) {
|
|
1837
|
+
return {
|
|
1838
|
+
kind: "hidden-frame",
|
|
1839
|
+
title: `warning: content from ${origin} was not shown to the agent: it is in a frame on a page under test, and not in allowed_origins.`,
|
|
1840
|
+
lines: [`Add it to allowed_origins in .blastproof/config.yaml if the agent should read and act on it.`]
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1983
1843
|
|
|
1984
1844
|
// src/report/uncommitted.ts
|
|
1985
1845
|
function printUncommitted(uncommitted, changedFiles, config, baseRef, into) {
|
|
@@ -2019,7 +1879,7 @@ Rules:
|
|
|
2019
1879
|
- Return exactly ONE action per response. Never batch actions.
|
|
2020
1880
|
- Placeholders like {{env.SOME_NAME}} are secrets that are filled in after you answer. Pass them through in your action exactly as written, never expanded, never guessed at.
|
|
2021
1881
|
- Pick target elements exclusively from the current snapshot. Every element there carries a ref, like \`[ref=f1e25]\`: name your target by that ref, and give its role and name exactly as that same line shows them (the text after the colon when it has no quoted name). The ref decides which element is acted on, so copy it from the line of the element you mean; a role or name that does not match that line is refused. Refs change when the page changes, so always take them from the current snapshot. Never invent CSS selectors or guess elements not in the snapshot.
|
|
2022
|
-
- Use "navigate" only with a URL or path as value. Use "fill" to type into textboxes/inputs. Use "press" for keyboard keys (value e.g. "Enter"). Use "select" for dropdowns (value = option label).
|
|
1882
|
+
- Use "navigate" only with a URL or path as value. Use "fill" to type into textboxes/inputs. Use "press" for keyboard keys (value e.g. "Enter"). Use "select" for dropdowns (value = option label). Use "hover" to point at an element without clicking it, when a menu, tooltip or control appears only on hover.
|
|
2023
1883
|
- Use "assert" with an expectation to verify page state (visible text, counts, URLs). Assertions never modify the page.
|
|
2024
1884
|
- A step that begins with "verify", "check", "confirm", "ensure", "assert", "expect", "validate", "make sure" or "see that" only looks. Never click or press in it: making the page show what the step checks would hide the very thing it checks. Assert what the page shows, navigate if what it names is on another page, or fail. It closes on a passing assertion, never on "done". This is enforced: a click, a press or "done" in such a step is refused.
|
|
2025
1885
|
- Return "done" when the current step's outcome holds \u2014 including when it already held before you acted, or was achieved by your previous action. "Already true" is done, never failure. Do not return "done" for work belonging to later steps.
|
|
@@ -2215,9 +2075,9 @@ function createModel(llm, env = process.env) {
|
|
|
2215
2075
|
var DECISIONS_ENDPOINT = "https://openrouter.ai/api/alpha/decisions";
|
|
2216
2076
|
var MAX_DECISION_CHARS = 6e4;
|
|
2217
2077
|
var RETRY_DELAYS_MS = [2e3, 4e3];
|
|
2218
|
-
var sleep = (ms, signal) => new Promise((
|
|
2078
|
+
var sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
2219
2079
|
if (signal?.aborted) return reject(signal.reason);
|
|
2220
|
-
const timer = setTimeout(
|
|
2080
|
+
const timer = setTimeout(resolve, ms);
|
|
2221
2081
|
signal?.addEventListener(
|
|
2222
2082
|
"abort",
|
|
2223
2083
|
() => {
|
|
@@ -2353,7 +2213,7 @@ import { z as z2 } from "zod";
|
|
|
2353
2213
|
function absentAsNull(schema) {
|
|
2354
2214
|
return schema.nullable().transform((value) => value ?? void 0);
|
|
2355
2215
|
}
|
|
2356
|
-
var ACTION_NAMES = ["navigate", "click", "fill", "press", "select", "assert", "done", "fail"];
|
|
2216
|
+
var ACTION_NAMES = ["navigate", "click", "fill", "press", "select", "hover", "assert", "done", "fail"];
|
|
2357
2217
|
var agentActionSchema = z2.object({
|
|
2358
2218
|
action: z2.enum(ACTION_NAMES).describe("The next browser action to perform for the current step."),
|
|
2359
2219
|
target: absentAsNull(
|
|
@@ -2698,7 +2558,8 @@ function renderTestYaml(draft, meta) {
|
|
|
2698
2558
|
}
|
|
2699
2559
|
async function generateForRoute(page, options) {
|
|
2700
2560
|
const { route, baseUrl, changedFiles, brain, mask, snapshot, maxSnapshotLines, timeoutMs } = options;
|
|
2701
|
-
const
|
|
2561
|
+
const frames = { allowed: allowedOriginsFor(baseUrl, options.allowedOrigins), onHidden: options.onHiddenFrame };
|
|
2562
|
+
const takeSnapshot = snapshot ?? ((p) => defaultSnapshot(p, maxSnapshotLines, frames));
|
|
2702
2563
|
const url = new URL(route, baseUrl).toString();
|
|
2703
2564
|
try {
|
|
2704
2565
|
await page.goto(url, { timeout: timeoutMs });
|
|
@@ -3370,7 +3231,7 @@ function deviceTag(test, config) {
|
|
|
3370
3231
|
const device = test.device ?? config.browser.device;
|
|
3371
3232
|
return device ? ` [${device}]` : "";
|
|
3372
3233
|
}
|
|
3373
|
-
async function runOne(browser, test, config, sessionDir, session, runMask, budget, write, firstJudge) {
|
|
3234
|
+
async function runOne(browser, test, config, sessionDir, session, runMask, budget, write, onHiddenFrame, firstJudge) {
|
|
3374
3235
|
const brain = createBrain(createModel(config.llm).model, void 0, budget, firstJudge);
|
|
3375
3236
|
let resolved;
|
|
3376
3237
|
const mask = runMask;
|
|
@@ -3407,7 +3268,8 @@ async function runOne(browser, test, config, sessionDir, session, runMask, budge
|
|
|
3407
3268
|
timeoutMs: config.browser.timeout_ms,
|
|
3408
3269
|
maxSnapshotLines: config.browser.max_snapshot_lines,
|
|
3409
3270
|
mask: (text) => mask.mask(text),
|
|
3410
|
-
onEvent: (event) => printEvent(event, write)
|
|
3271
|
+
onEvent: (event) => printEvent(event, write),
|
|
3272
|
+
onHiddenFrame
|
|
3411
3273
|
});
|
|
3412
3274
|
return device ? { ...result, device } : result;
|
|
3413
3275
|
} finally {
|
|
@@ -3596,6 +3458,8 @@ async function runCommand(options) {
|
|
|
3596
3458
|
throw error;
|
|
3597
3459
|
}
|
|
3598
3460
|
const warnings = [];
|
|
3461
|
+
const hiddenFrames = /* @__PURE__ */ new Set();
|
|
3462
|
+
const onHiddenFrame = (origin) => hiddenFrames.add(origin);
|
|
3599
3463
|
const impacted = options.impacted ?? false;
|
|
3600
3464
|
const base = options.base ?? "main";
|
|
3601
3465
|
if (options.failOnUnmapped && !impacted) {
|
|
@@ -3741,13 +3605,15 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3741
3605
|
maxSnapshotLines: config.browser.max_snapshot_lines,
|
|
3742
3606
|
device: config.browser.device,
|
|
3743
3607
|
mask: runMask,
|
|
3744
|
-
onEvent: printEvent
|
|
3608
|
+
onEvent: printEvent,
|
|
3609
|
+
onHiddenFrame
|
|
3745
3610
|
});
|
|
3746
3611
|
} catch (error) {
|
|
3747
3612
|
if (error instanceof RunStoppedError) {
|
|
3748
3613
|
incomplete = error;
|
|
3749
3614
|
} else if (error instanceof AuthError) {
|
|
3750
3615
|
console.error(`error: ${error.message}`);
|
|
3616
|
+
for (const origin of hiddenFrames) emitWarning(hiddenFrameWarning(origin), warnings);
|
|
3751
3617
|
return EXIT_USAGE;
|
|
3752
3618
|
} else {
|
|
3753
3619
|
throw error;
|
|
@@ -3779,6 +3645,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3779
3645
|
runMask,
|
|
3780
3646
|
budget,
|
|
3781
3647
|
write,
|
|
3648
|
+
onHiddenFrame,
|
|
3782
3649
|
firstJudgeFor(path10.relative(options.cwd, test.path))
|
|
3783
3650
|
);
|
|
3784
3651
|
if (!streaming) for (const line of lines) console.log(line);
|
|
@@ -3804,6 +3671,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3804
3671
|
} finally {
|
|
3805
3672
|
await browser.close();
|
|
3806
3673
|
}
|
|
3674
|
+
for (const origin of hiddenFrames) emitWarning(hiddenFrameWarning(origin), warnings);
|
|
3807
3675
|
return finalize(
|
|
3808
3676
|
results,
|
|
3809
3677
|
selection.unroutedSkipped,
|
|
@@ -3951,6 +3819,8 @@ async function planCommand(options) {
|
|
|
3951
3819
|
return EXIT_USAGE;
|
|
3952
3820
|
}
|
|
3953
3821
|
const browser = preflight.browser;
|
|
3822
|
+
const hiddenFrames = /* @__PURE__ */ new Set();
|
|
3823
|
+
const onHiddenFrame = (origin) => hiddenFrames.add(origin);
|
|
3954
3824
|
try {
|
|
3955
3825
|
let session;
|
|
3956
3826
|
if (config.auth) {
|
|
@@ -3968,13 +3838,15 @@ async function planCommand(options) {
|
|
|
3968
3838
|
maxSnapshotLines: config.browser.max_snapshot_lines,
|
|
3969
3839
|
device: config.browser.device,
|
|
3970
3840
|
mask,
|
|
3971
|
-
onEvent: printAuthEvent
|
|
3841
|
+
onEvent: printAuthEvent,
|
|
3842
|
+
onHiddenFrame
|
|
3972
3843
|
});
|
|
3973
3844
|
} catch (error) {
|
|
3974
3845
|
if (error instanceof RunStoppedError) {
|
|
3975
3846
|
incomplete = error;
|
|
3976
3847
|
} else if (error instanceof AuthError) {
|
|
3977
3848
|
console.error(`error: ${error.message}`);
|
|
3849
|
+
for (const origin of hiddenFrames) emitWarning(hiddenFrameWarning(origin));
|
|
3978
3850
|
return EXIT_USAGE;
|
|
3979
3851
|
} else {
|
|
3980
3852
|
throw error;
|
|
@@ -3995,6 +3867,8 @@ async function planCommand(options) {
|
|
|
3995
3867
|
baseUrl: config.base_url,
|
|
3996
3868
|
changedFiles,
|
|
3997
3869
|
brain,
|
|
3870
|
+
allowedOrigins: config.allowed_origins,
|
|
3871
|
+
onHiddenFrame,
|
|
3998
3872
|
mask: (text) => mask.mask(text),
|
|
3999
3873
|
maxSnapshotLines: config.browser.max_snapshot_lines,
|
|
4000
3874
|
timeoutMs: config.browser.timeout_ms
|
|
@@ -4037,6 +3911,7 @@ ${renderTestYaml(draft, { route, base })}`);
|
|
|
4037
3911
|
} finally {
|
|
4038
3912
|
await browser.close();
|
|
4039
3913
|
}
|
|
3914
|
+
for (const origin of hiddenFrames) emitWarning(hiddenFrameWarning(origin));
|
|
4040
3915
|
const notAttempted = incomplete ? work.map((item) => item.route).filter((route) => !generated.includes(route) && !failed.some((f) => f.route === route)) : [];
|
|
4041
3916
|
console.log("\n--- Plan -------------------------------------------------------");
|
|
4042
3917
|
console.log(`Generated: ${generated.length > 0 ? generated.join(", ") : "none"}`);
|
|
@@ -4148,7 +4023,7 @@ function parsePositiveNumber(flag) {
|
|
|
4148
4023
|
};
|
|
4149
4024
|
}
|
|
4150
4025
|
var program = new Command();
|
|
4151
|
-
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.
|
|
4026
|
+
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.32.0");
|
|
4152
4027
|
program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
|
|
4153
4028
|
try {
|
|
4154
4029
|
const result = await initProject(process.cwd());
|