blastproof 0.27.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cli.js +495 -190
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -207,7 +207,7 @@ function formatInitGuidance(result) {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// src/commands/plan.ts
|
|
210
|
-
import
|
|
210
|
+
import path11 from "path";
|
|
211
211
|
|
|
212
212
|
// src/auth.ts
|
|
213
213
|
import { readFile, writeFile as writeFile2, mkdir as mkdir3 } from "fs/promises";
|
|
@@ -363,12 +363,13 @@ var RunBudget = class {
|
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
365
|
};
|
|
366
|
-
function estimateMaxModelCalls(tests, maxIterationsPerStep, maxRetriesPerStep) {
|
|
366
|
+
function estimateMaxModelCalls(tests, maxIterationsPerStep, maxRetriesPerStep, judgeCalls = 1) {
|
|
367
367
|
const totalSteps = tests.reduce(
|
|
368
368
|
(sum, test) => sum + (test.setup?.length ?? 0) + test.steps.length,
|
|
369
369
|
0
|
|
370
370
|
);
|
|
371
|
-
|
|
371
|
+
const bundled = (2 * judgeCalls - 1) * Math.min(maxIterationsPerStep, maxRetriesPerStep);
|
|
372
|
+
return totalSteps * (maxIterationsPerStep + maxRetriesPerStep + bundled);
|
|
372
373
|
}
|
|
373
374
|
|
|
374
375
|
// src/runner/env.ts
|
|
@@ -1249,6 +1250,25 @@ async function executeTest(page, test, options) {
|
|
|
1249
1250
|
};
|
|
1250
1251
|
}
|
|
1251
1252
|
|
|
1253
|
+
// src/runner/device.ts
|
|
1254
|
+
import { devices } from "playwright";
|
|
1255
|
+
function isDevice(name) {
|
|
1256
|
+
return Object.hasOwn(devices, name);
|
|
1257
|
+
}
|
|
1258
|
+
function unknownDeviceMessage(name) {
|
|
1259
|
+
const words = name.toLowerCase().split(/\s+/).filter(Boolean);
|
|
1260
|
+
const same = Object.keys(devices).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
1261
|
+
if (same) return `"${name}" is not a device Playwright knows; did you mean "${same}"? Names are case-sensitive`;
|
|
1262
|
+
const close = Object.keys(devices).filter((candidate) => !candidate.endsWith(" landscape")).filter((candidate) => words.length > 0 && words.every((word) => candidate.toLowerCase().includes(word))).slice(-3);
|
|
1263
|
+
const hint = close.length ? `did you mean ${close.map((c) => `"${c}"`).join(", ")}?` : "see the device names in Playwright's registry: https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json";
|
|
1264
|
+
return `"${name}" is not a device Playwright knows; ${hint}`;
|
|
1265
|
+
}
|
|
1266
|
+
function deviceOptions(name) {
|
|
1267
|
+
if (!name) return {};
|
|
1268
|
+
const { defaultBrowserType: _browser, ...options } = devices[name];
|
|
1269
|
+
return options;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1252
1272
|
// src/auth.ts
|
|
1253
1273
|
var AUTH_STATE_RELATIVE_PATH = path3.join(".blastproof", ".auth-state.json");
|
|
1254
1274
|
var AuthError = class extends Error {
|
|
@@ -1327,7 +1347,7 @@ async function fromSteps(options) {
|
|
|
1327
1347
|
const { auth, baseUrl, browser, brain, maxRetries, snapshot, timeoutMs, maxSnapshotLines, onEvent, mask } = options;
|
|
1328
1348
|
const steps = auth.steps;
|
|
1329
1349
|
const takeSnapshot = snapshot ?? ((page) => defaultSnapshot(page, maxSnapshotLines));
|
|
1330
|
-
const context = await browser.newContext();
|
|
1350
|
+
const context = await browser.newContext(deviceOptions(options.device));
|
|
1331
1351
|
try {
|
|
1332
1352
|
const page = await context.newPage();
|
|
1333
1353
|
const result = await runJourney(
|
|
@@ -1406,9 +1426,10 @@ async function authenticate(options) {
|
|
|
1406
1426
|
if (auth.cache) await writeCached(cwd, session);
|
|
1407
1427
|
return session;
|
|
1408
1428
|
}
|
|
1409
|
-
function contextOptions(session) {
|
|
1410
|
-
if (!session) return
|
|
1429
|
+
function contextOptions(session, device) {
|
|
1430
|
+
if (!session) return deviceOptions(device);
|
|
1411
1431
|
return {
|
|
1432
|
+
...deviceOptions(device),
|
|
1412
1433
|
...session.storageState ? { storageState: session.storageState } : {},
|
|
1413
1434
|
...session.extraHTTPHeaders ? { extraHTTPHeaders: session.extraHTTPHeaders } : {}
|
|
1414
1435
|
};
|
|
@@ -1449,6 +1470,9 @@ var llmSchema = z.object({
|
|
|
1449
1470
|
});
|
|
1450
1471
|
}
|
|
1451
1472
|
});
|
|
1473
|
+
var deviceSchema = z.string().superRefine((name, ctx) => {
|
|
1474
|
+
if (!isDevice(name)) ctx.addIssue({ code: "custom", message: unknownDeviceMessage(name) });
|
|
1475
|
+
});
|
|
1452
1476
|
var browserSchema = z.object({
|
|
1453
1477
|
headless: z.boolean().default(true),
|
|
1454
1478
|
/**
|
|
@@ -1463,7 +1487,13 @@ var browserSchema = z.object({
|
|
|
1463
1487
|
* undefined lets `runner/snapshot.ts`'s own default (200) apply, so a config
|
|
1464
1488
|
* that never mentions this behaves exactly as before it existed.
|
|
1465
1489
|
*/
|
|
1466
|
-
max_snapshot_lines: z.number().int().positive().optional()
|
|
1490
|
+
max_snapshot_lines: z.number().int().positive().optional(),
|
|
1491
|
+
/**
|
|
1492
|
+
* The device every test runs as unless its file names its own (spec
|
|
1493
|
+
* device-emulation). Optional: undefined is Playwright's desktop default, so a
|
|
1494
|
+
* config that never mentions it behaves exactly as before it existed.
|
|
1495
|
+
*/
|
|
1496
|
+
device: deviceSchema.optional()
|
|
1467
1497
|
});
|
|
1468
1498
|
var budgetSchema = z.object({
|
|
1469
1499
|
max_llm_calls: z.coerce.number().int().positive().optional(),
|
|
@@ -1471,6 +1501,11 @@ var budgetSchema = z.object({
|
|
|
1471
1501
|
/** Seconds, not milliseconds, to match how a human would set a deadline. */
|
|
1472
1502
|
max_duration_s: z.coerce.number().positive().optional()
|
|
1473
1503
|
});
|
|
1504
|
+
var firstJudgeSchema = z.object({
|
|
1505
|
+
model: z.string().min(1),
|
|
1506
|
+
api_key_env: z.string().min(1).default("OPENROUTER_API_KEY"),
|
|
1507
|
+
threshold: z.coerce.number().gt(0, "must be a probability above 0").lt(1, "must be a probability below 1").default(0.7)
|
|
1508
|
+
});
|
|
1474
1509
|
var cookieSchema = z.object({
|
|
1475
1510
|
name: z.string().min(1),
|
|
1476
1511
|
value: z.string(),
|
|
@@ -1550,7 +1585,8 @@ var configSchema = z.object({
|
|
|
1550
1585
|
* those tests, not of the runner. Opted into by the person who knows.
|
|
1551
1586
|
*/
|
|
1552
1587
|
concurrency: z.number().int().min(1, "concurrency must be at least 1").default(1),
|
|
1553
|
-
budget: budgetSchema.optional()
|
|
1588
|
+
budget: budgetSchema.optional(),
|
|
1589
|
+
first_judge: firstJudgeSchema.optional()
|
|
1554
1590
|
});
|
|
1555
1591
|
var ENV_OVERRIDES = {
|
|
1556
1592
|
BLASTPROOF_BASE_URL: ["base_url"],
|
|
@@ -1561,7 +1597,10 @@ var ENV_OVERRIDES = {
|
|
|
1561
1597
|
BLASTPROOF_LLM_TIMEOUT_S: ["llm", "timeout_s"],
|
|
1562
1598
|
BLASTPROOF_MAX_LLM_CALLS: ["budget", "max_llm_calls"],
|
|
1563
1599
|
BLASTPROOF_MAX_TOKENS: ["budget", "max_tokens"],
|
|
1564
|
-
BLASTPROOF_MAX_DURATION_S: ["budget", "max_duration_s"]
|
|
1600
|
+
BLASTPROOF_MAX_DURATION_S: ["budget", "max_duration_s"],
|
|
1601
|
+
BLASTPROOF_FIRST_JUDGE_MODEL: ["first_judge", "model"],
|
|
1602
|
+
BLASTPROOF_FIRST_JUDGE_THRESHOLD: ["first_judge", "threshold"],
|
|
1603
|
+
BLASTPROOF_BROWSER_DEVICE: ["browser", "device"]
|
|
1565
1604
|
};
|
|
1566
1605
|
function applyEnvOverrides(data, env = process.env) {
|
|
1567
1606
|
const merged = data && typeof data === "object" ? { ...data } : {};
|
|
@@ -1607,13 +1646,13 @@ function unwrapToObjectSchema(schema) {
|
|
|
1607
1646
|
}
|
|
1608
1647
|
return current instanceof z.ZodObject ? current : void 0;
|
|
1609
1648
|
}
|
|
1610
|
-
function findUnknownConfigKeys(data, schema = configSchema,
|
|
1649
|
+
function findUnknownConfigKeys(data, schema = configSchema, path12 = []) {
|
|
1611
1650
|
const object = unwrapToObjectSchema(schema);
|
|
1612
1651
|
if (!object || data === null || typeof data !== "object" || Array.isArray(data)) return [];
|
|
1613
1652
|
const shape = object.shape;
|
|
1614
1653
|
const warnings = [];
|
|
1615
1654
|
for (const key of Object.keys(data)) {
|
|
1616
|
-
const fieldPath = [...
|
|
1655
|
+
const fieldPath = [...path12, key];
|
|
1617
1656
|
const fieldSchema = shape[key];
|
|
1618
1657
|
if (!fieldSchema) {
|
|
1619
1658
|
warnings.push(fieldPath.join("."));
|
|
@@ -1743,27 +1782,42 @@ function mapImpact(changedFiles, routes, ignore = []) {
|
|
|
1743
1782
|
};
|
|
1744
1783
|
}
|
|
1745
1784
|
|
|
1785
|
+
// src/report/warnings.ts
|
|
1786
|
+
function emitWarning(warning, into) {
|
|
1787
|
+
if (!warning) return;
|
|
1788
|
+
console.error(`${warning.spaced ? "\n" : ""}${warning.title}`);
|
|
1789
|
+
for (const line of warning.lines) console.error(line);
|
|
1790
|
+
into?.push(warning);
|
|
1791
|
+
}
|
|
1792
|
+
function warningText(warning) {
|
|
1793
|
+
return [warning.title, ...warning.lines].join("\n");
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1746
1796
|
// src/report/uncommitted.ts
|
|
1747
|
-
function printUncommitted(uncommitted, changedFiles, config, baseRef) {
|
|
1797
|
+
function printUncommitted(uncommitted, changedFiles, config, baseRef, into) {
|
|
1798
|
+
emitWarning(uncommittedWarning(uncommitted, changedFiles, config, baseRef), into);
|
|
1799
|
+
}
|
|
1800
|
+
function uncommittedWarning(uncommitted, changedFiles, config, baseRef) {
|
|
1748
1801
|
const inDiff = new Set(changedFiles.map((file) => file.replace(/\\/g, "/")));
|
|
1749
1802
|
const routes = config.routes ?? {};
|
|
1750
1803
|
const ignore = config.ignore ?? [];
|
|
1751
1804
|
const findings = uncommitted.filter((file) => !inDiff.has(file)).map((file) => ({ file, impact: mapImpact([file], routes, ignore) })).filter(({ impact }) => impact.ignoredFiles.length === 0);
|
|
1752
|
-
if (findings.length === 0) return;
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
warning: ${findings.length} file(s) changed in the working tree are not in the diff against '${baseRef}'
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1805
|
+
if (findings.length === 0) return void 0;
|
|
1806
|
+
return {
|
|
1807
|
+
kind: "uncommitted",
|
|
1808
|
+
title: `warning: ${findings.length} file(s) changed in the working tree are not in the diff against '${baseRef}':`,
|
|
1809
|
+
lines: [
|
|
1810
|
+
...findings.map(
|
|
1811
|
+
({ file, impact }) => impact.affectedRoutes.length > 0 ? ` ${file} -> ${impact.affectedRoutes.join(", ")}` : ` ${file} (matched by no routes: or ignore: glob)`
|
|
1812
|
+
),
|
|
1813
|
+
"Nothing above was considered. Commit or stash them to include them."
|
|
1814
|
+
],
|
|
1815
|
+
spaced: true
|
|
1816
|
+
};
|
|
1763
1817
|
}
|
|
1764
1818
|
|
|
1765
1819
|
// src/llm/brain.ts
|
|
1766
|
-
import { APICallError, generateObject, NoObjectGeneratedError, RetryError } from "ai";
|
|
1820
|
+
import { APICallError as APICallError2, generateObject, NoObjectGeneratedError, RetryError } from "ai";
|
|
1767
1821
|
|
|
1768
1822
|
// src/llm/prompts.ts
|
|
1769
1823
|
function agentSystemPrompt() {
|
|
@@ -1848,6 +1902,16 @@ function assertUserPrompt(step, expectation, snapshot, stepHistory) {
|
|
|
1848
1902
|
);
|
|
1849
1903
|
return parts.join("\n");
|
|
1850
1904
|
}
|
|
1905
|
+
function firstJudgeQuestion() {
|
|
1906
|
+
const system = assertSystemPrompt();
|
|
1907
|
+
return {
|
|
1908
|
+
instructions: system.slice(0, system.indexOf("Answer with pass=true/false")).trim(),
|
|
1909
|
+
criteria: {
|
|
1910
|
+
true: "The snapshot shows the state the step asks for. Every value the step names appears where the step places it, committed (not only typed into an open, unsubmitted field). An outcome that is an absence is shown by the thing being absent.",
|
|
1911
|
+
false: "Some part of the outcome the step asks for is not shown, or cannot be assessed from this snapshot: a value is missing or different, appears only somewhere else on the page, or only inside an unsubmitted control, or the claim is true of something other than what the step asks."
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1851
1915
|
function plannerSystemPrompt() {
|
|
1852
1916
|
return `You are a QA engineer writing one end-to-end test for a web page, in plain English.
|
|
1853
1917
|
|
|
@@ -1879,6 +1943,223 @@ function plannerUserPrompt(input) {
|
|
|
1879
1943
|
return parts.join("\n");
|
|
1880
1944
|
}
|
|
1881
1945
|
|
|
1946
|
+
// src/llm/decision.ts
|
|
1947
|
+
import { appendFileSync, mkdirSync } from "fs";
|
|
1948
|
+
import path5 from "path";
|
|
1949
|
+
import { APICallError } from "ai";
|
|
1950
|
+
|
|
1951
|
+
// src/llm/provider.ts
|
|
1952
|
+
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
1953
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
1954
|
+
var DEFAULT_MODELS = {
|
|
1955
|
+
anthropic: "claude-haiku-4-5",
|
|
1956
|
+
openai: "gpt-6-luna",
|
|
1957
|
+
ollama: "gpt-oss:20b"
|
|
1958
|
+
};
|
|
1959
|
+
var DEFAULT_API_KEY_ENVS = {
|
|
1960
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
1961
|
+
openai: "OPENAI_API_KEY"
|
|
1962
|
+
};
|
|
1963
|
+
var DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434/v1";
|
|
1964
|
+
var DEFAULT_TIMEOUT_SECONDS = {
|
|
1965
|
+
anthropic: 300,
|
|
1966
|
+
openai: 300,
|
|
1967
|
+
ollama: 900
|
|
1968
|
+
};
|
|
1969
|
+
function timeoutSeconds(llm) {
|
|
1970
|
+
return llm.timeout_s ?? DEFAULT_TIMEOUT_SECONDS[llm.provider];
|
|
1971
|
+
}
|
|
1972
|
+
function withExtraBody(extra, base = fetch) {
|
|
1973
|
+
return (input, init) => {
|
|
1974
|
+
if (typeof init?.body !== "string") return base(input, init);
|
|
1975
|
+
let body;
|
|
1976
|
+
try {
|
|
1977
|
+
body = JSON.parse(init.body);
|
|
1978
|
+
} catch {
|
|
1979
|
+
return base(input, init);
|
|
1980
|
+
}
|
|
1981
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) return base(input, init);
|
|
1982
|
+
return base(input, { ...init, body: JSON.stringify({ ...extra, ...body }) });
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
var MissingApiKeyError = class extends Error {
|
|
1986
|
+
constructor(variable, provider) {
|
|
1987
|
+
super(
|
|
1988
|
+
`Missing API key: environment variable ${variable} is not set (required for provider "${provider}"). Export it before running, e.g. \`export ${variable}=...\`, or change llm.provider / llm.api_key_env in .blastproof/config.yaml.`
|
|
1989
|
+
);
|
|
1990
|
+
this.name = "MissingApiKeyError";
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
function createModel(llm, env = process.env) {
|
|
1994
|
+
const modelId = llm.model ?? DEFAULT_MODELS[llm.provider];
|
|
1995
|
+
switch (llm.provider) {
|
|
1996
|
+
case "anthropic":
|
|
1997
|
+
case "openai": {
|
|
1998
|
+
const keyEnv = llm.api_key_env ?? DEFAULT_API_KEY_ENVS[llm.provider];
|
|
1999
|
+
const apiKey = env[keyEnv];
|
|
2000
|
+
if (!apiKey) {
|
|
2001
|
+
throw new MissingApiKeyError(keyEnv, llm.provider);
|
|
2002
|
+
}
|
|
2003
|
+
const baseURL = llm.base_url ? { baseURL: llm.base_url } : {};
|
|
2004
|
+
const extra = llm.extra_body ? { fetch: withExtraBody(llm.extra_body) } : {};
|
|
2005
|
+
const model = llm.provider === "anthropic" ? (
|
|
2006
|
+
// A configured endpoint applies to whichever provider is selected —
|
|
2007
|
+
// dropping it here routed corporate-proxy configs to the public API
|
|
2008
|
+
// with no error (design D2).
|
|
2009
|
+
createAnthropic({ apiKey, ...baseURL })(modelId)
|
|
2010
|
+
) : (
|
|
2011
|
+
// `.chat` = Chat Completions: works with official OpenAI and any
|
|
2012
|
+
// OpenAI-compatible endpoint (OpenRouter, LiteLLM, vLLM) via base_url.
|
|
2013
|
+
createOpenAI({ apiKey, ...baseURL, ...extra }).chat(modelId)
|
|
2014
|
+
);
|
|
2015
|
+
return { model, provider: llm.provider, modelId };
|
|
2016
|
+
}
|
|
2017
|
+
case "ollama": {
|
|
2018
|
+
const baseURL = llm.base_url ?? DEFAULT_OLLAMA_BASE_URL;
|
|
2019
|
+
const extra = llm.extra_body ? { fetch: withExtraBody(llm.extra_body) } : {};
|
|
2020
|
+
const model = createOpenAI({ baseURL, apiKey: "ollama", ...extra }).chat(modelId);
|
|
2021
|
+
return { model, provider: "ollama", modelId };
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
// src/llm/decision.ts
|
|
2027
|
+
var DECISIONS_ENDPOINT = "https://openrouter.ai/api/alpha/decisions";
|
|
2028
|
+
var MAX_DECISION_CHARS = 6e4;
|
|
2029
|
+
var RETRY_DELAYS_MS = [2e3, 4e3];
|
|
2030
|
+
var sleep = (ms, signal) => new Promise((resolve2, reject) => {
|
|
2031
|
+
if (signal?.aborted) return reject(signal.reason);
|
|
2032
|
+
const timer = setTimeout(resolve2, ms);
|
|
2033
|
+
signal?.addEventListener(
|
|
2034
|
+
"abort",
|
|
2035
|
+
() => {
|
|
2036
|
+
clearTimeout(timer);
|
|
2037
|
+
reject(signal.reason);
|
|
2038
|
+
},
|
|
2039
|
+
{ once: true }
|
|
2040
|
+
);
|
|
2041
|
+
});
|
|
2042
|
+
function retryable(status) {
|
|
2043
|
+
return status === 408 || status === 409 || status === 429 || status >= 500;
|
|
2044
|
+
}
|
|
2045
|
+
function readAnswer(text) {
|
|
2046
|
+
let body;
|
|
2047
|
+
try {
|
|
2048
|
+
body = JSON.parse(text);
|
|
2049
|
+
} catch {
|
|
2050
|
+
return { p: void 0 };
|
|
2051
|
+
}
|
|
2052
|
+
const root = body ?? {};
|
|
2053
|
+
const raw = root.answers?.pass?.noul;
|
|
2054
|
+
const p = typeof raw === "number" && raw >= 0 && raw <= 1 ? raw : void 0;
|
|
2055
|
+
const input = root.usage?.input_tokens;
|
|
2056
|
+
const output = root.usage?.output_tokens;
|
|
2057
|
+
const totalTokens = typeof input === "number" ? input + (typeof output === "number" ? output : 0) : void 0;
|
|
2058
|
+
return { p, usage: { totalTokens } };
|
|
2059
|
+
}
|
|
2060
|
+
function createDecisionClient(options) {
|
|
2061
|
+
const doFetch = options.fetch ?? fetch;
|
|
2062
|
+
const wait = options.sleep ?? sleep;
|
|
2063
|
+
const url = options.endpoint ?? DECISIONS_ENDPOINT;
|
|
2064
|
+
return async (question, state, signal) => {
|
|
2065
|
+
const requestBodyValues = {
|
|
2066
|
+
model: options.model,
|
|
2067
|
+
state,
|
|
2068
|
+
questions: { pass: { type: "noul", ...question } }
|
|
2069
|
+
};
|
|
2070
|
+
for (let attempt = 0; ; attempt++) {
|
|
2071
|
+
let response;
|
|
2072
|
+
try {
|
|
2073
|
+
response = await doFetch(url, {
|
|
2074
|
+
method: "POST",
|
|
2075
|
+
headers: { Authorization: `Bearer ${options.apiKey}`, "Content-Type": "application/json" },
|
|
2076
|
+
body: JSON.stringify(requestBodyValues),
|
|
2077
|
+
signal
|
|
2078
|
+
});
|
|
2079
|
+
} catch (error) {
|
|
2080
|
+
if (signal?.aborted) throw error;
|
|
2081
|
+
if (attempt < RETRY_DELAYS_MS.length) {
|
|
2082
|
+
await wait(RETRY_DELAYS_MS[attempt], signal);
|
|
2083
|
+
continue;
|
|
2084
|
+
}
|
|
2085
|
+
throw new APICallError({
|
|
2086
|
+
message: `first judge ${options.model}: ${error instanceof Error ? error.message : String(error)}`,
|
|
2087
|
+
url,
|
|
2088
|
+
requestBodyValues,
|
|
2089
|
+
cause: error
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
const text = await response.text();
|
|
2093
|
+
if (response.ok) return readAnswer(text);
|
|
2094
|
+
if (retryable(response.status) && attempt < RETRY_DELAYS_MS.length) {
|
|
2095
|
+
await wait(RETRY_DELAYS_MS[attempt], signal);
|
|
2096
|
+
continue;
|
|
2097
|
+
}
|
|
2098
|
+
throw new APICallError({
|
|
2099
|
+
message: `first judge ${options.model}`,
|
|
2100
|
+
url,
|
|
2101
|
+
requestBodyValues,
|
|
2102
|
+
statusCode: response.status,
|
|
2103
|
+
responseBody: text
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
}
|
|
2108
|
+
var MissingFirstJudgeKeyError = class extends MissingApiKeyError {
|
|
2109
|
+
constructor(variable, model) {
|
|
2110
|
+
super(variable, model);
|
|
2111
|
+
this.message = `Missing API key: environment variable ${variable} is not set (required for the first judge "${model}"). Export it before running, e.g. \`export ${variable}=...\`, or remove first_judge from .blastproof/config.yaml (and unset BLASTPROOF_FIRST_JUDGE_MODEL).`;
|
|
2112
|
+
}
|
|
2113
|
+
};
|
|
2114
|
+
var FirstJudgeLog = class {
|
|
2115
|
+
constructor(model, threshold, file) {
|
|
2116
|
+
this.model = model;
|
|
2117
|
+
this.threshold = threshold;
|
|
2118
|
+
this.file = file;
|
|
2119
|
+
}
|
|
2120
|
+
model;
|
|
2121
|
+
threshold;
|
|
2122
|
+
file;
|
|
2123
|
+
passed = 0;
|
|
2124
|
+
failedByLabelCheck = 0;
|
|
2125
|
+
toLlm = 0;
|
|
2126
|
+
dirReady = false;
|
|
2127
|
+
record(test, entry) {
|
|
2128
|
+
if (entry.outcome === "passed") this.passed++;
|
|
2129
|
+
else if (entry.outcome === "label-check") this.failedByLabelCheck++;
|
|
2130
|
+
else this.toLlm++;
|
|
2131
|
+
if (entry.outcome === "too-large" || !this.file) return;
|
|
2132
|
+
if (!this.dirReady) {
|
|
2133
|
+
mkdirSync(path5.dirname(this.file), { recursive: true });
|
|
2134
|
+
this.dirReady = true;
|
|
2135
|
+
}
|
|
2136
|
+
const line = {
|
|
2137
|
+
test,
|
|
2138
|
+
step: entry.step,
|
|
2139
|
+
claim: entry.claim,
|
|
2140
|
+
model: this.model,
|
|
2141
|
+
p: entry.p ?? null,
|
|
2142
|
+
threshold: this.threshold,
|
|
2143
|
+
outcome: entry.outcome,
|
|
2144
|
+
snapshot: entry.snapshot
|
|
2145
|
+
};
|
|
2146
|
+
appendFileSync(this.file, `${JSON.stringify(line)}
|
|
2147
|
+
`, "utf8");
|
|
2148
|
+
}
|
|
2149
|
+
summaryLine() {
|
|
2150
|
+
const labelCheck = this.failedByLabelCheck > 0 ? `, ${this.failedByLabelCheck} failed by the label check` : "";
|
|
2151
|
+
return `First judge (experimental, ${this.model} at ${this.threshold}): ${this.passed} passed${labelCheck}, ${this.toLlm} to the LLM judge`;
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
function firstJudgeLogPath(sessionDir) {
|
|
2155
|
+
return path5.join(sessionDir, "first-judge.jsonl");
|
|
2156
|
+
}
|
|
2157
|
+
function createFirstJudgeClient(config, env = process.env, fetchImpl) {
|
|
2158
|
+
const apiKey = env[config.api_key_env];
|
|
2159
|
+
if (!apiKey) throw new MissingFirstJudgeKeyError(config.api_key_env, config.model);
|
|
2160
|
+
return createDecisionClient({ model: config.model, apiKey, fetch: fetchImpl });
|
|
2161
|
+
}
|
|
2162
|
+
|
|
1882
2163
|
// src/llm/schemas.ts
|
|
1883
2164
|
import { z as z2 } from "zod";
|
|
1884
2165
|
function absentAsNull(schema) {
|
|
@@ -1964,7 +2245,7 @@ function withProviderDetail(error) {
|
|
|
1964
2245
|
}
|
|
1965
2246
|
function asProviderRefusal(error) {
|
|
1966
2247
|
const cause = RetryError.isInstance(error) ? error.lastError : error;
|
|
1967
|
-
if (!
|
|
2248
|
+
if (!APICallError2.isInstance(cause)) return error;
|
|
1968
2249
|
if (cause.statusCode !== void 0 && cause.statusCode < 400) return error;
|
|
1969
2250
|
withProviderDetail(cause);
|
|
1970
2251
|
return new ProviderRefusedError(cause.statusCode, cause.message);
|
|
@@ -1986,12 +2267,12 @@ function spentAndExplained(error, budget) {
|
|
|
1986
2267
|
`the answer reached the ${MAX_OUTPUT_TOKENS}-token output limit before its JSON was complete`
|
|
1987
2268
|
);
|
|
1988
2269
|
}
|
|
1989
|
-
async function
|
|
2270
|
+
async function counted(budget, call) {
|
|
1990
2271
|
budget.check();
|
|
1991
2272
|
const abort = callAbort(budget);
|
|
1992
2273
|
let result;
|
|
1993
2274
|
try {
|
|
1994
|
-
result = await
|
|
2275
|
+
result = await call(abort?.signal);
|
|
1995
2276
|
} catch (error) {
|
|
1996
2277
|
if (abort?.signal.aborted) {
|
|
1997
2278
|
if (abort.byDeadline) throw budget.deadlineReached();
|
|
@@ -2004,7 +2285,29 @@ async function countedGenerate(generate, budget, options) {
|
|
|
2004
2285
|
budget.record(result.usage);
|
|
2005
2286
|
return result;
|
|
2006
2287
|
}
|
|
2007
|
-
function
|
|
2288
|
+
function countedGenerate(generate, budget, options) {
|
|
2289
|
+
return counted(budget, (abortSignal) => generate({ ...options, maxOutputTokens: MAX_OUTPUT_TOKENS, abortSignal }));
|
|
2290
|
+
}
|
|
2291
|
+
async function firstJudgment(firstJudge, budget, judged, label) {
|
|
2292
|
+
const question = firstJudgeQuestion();
|
|
2293
|
+
const entry = { step: judged.step, claim: judged.claim, snapshot: judged.snapshot };
|
|
2294
|
+
if (judged.prompt.length + question.instructions.length > MAX_DECISION_CHARS) {
|
|
2295
|
+
firstJudge.record({ ...entry, p: void 0, outcome: "too-large" });
|
|
2296
|
+
return void 0;
|
|
2297
|
+
}
|
|
2298
|
+
const { p } = await counted(budget, (signal) => firstJudge.decide(question, judged.prompt, signal));
|
|
2299
|
+
if (p === void 0 || p < firstJudge.threshold) {
|
|
2300
|
+
firstJudge.record({ ...entry, p, outcome: "to-llm" });
|
|
2301
|
+
return void 0;
|
|
2302
|
+
}
|
|
2303
|
+
const judgment = label({
|
|
2304
|
+
pass: true,
|
|
2305
|
+
reason: `passed by the first judge, ${firstJudge.model}, at p(yes) ${p.toFixed(2)} (threshold ${firstJudge.threshold}); a decision model gives no reason`
|
|
2306
|
+
});
|
|
2307
|
+
firstJudge.record({ ...entry, p, outcome: judgment.pass ? "passed" : "label-check" });
|
|
2308
|
+
return judgment;
|
|
2309
|
+
}
|
|
2310
|
+
function createBrain(model, generate = generateObject, budget, firstJudge) {
|
|
2008
2311
|
return {
|
|
2009
2312
|
async nextAction(input) {
|
|
2010
2313
|
const result = await countedGenerate(generate, budget, {
|
|
@@ -2026,16 +2329,19 @@ function createBrain(model, generate = generateObject, budget) {
|
|
|
2026
2329
|
action: placeholdersAsLabels(entry.action),
|
|
2027
2330
|
result: placeholdersAsLabels(entry.result)
|
|
2028
2331
|
}));
|
|
2332
|
+
const judgedStep = placeholdersAsLabels(step);
|
|
2333
|
+
const claim = placeholdersAsLabels(expectation);
|
|
2334
|
+
const prompt = assertUserPrompt(judgedStep, claim, snapshot, asJudged);
|
|
2335
|
+
const label = (judgment) => secretMismatch(judgedStep, snapshot, asJudged, usedEarlier ?? [], judgment);
|
|
2336
|
+
if (firstJudge) {
|
|
2337
|
+
const decided = await firstJudgment(firstJudge, budget, { step: judgedStep, claim, snapshot, prompt }, label);
|
|
2338
|
+
if (decided) return decided;
|
|
2339
|
+
}
|
|
2029
2340
|
const result = await countedGenerate(generate, budget, {
|
|
2030
2341
|
model,
|
|
2031
2342
|
schema: assertJudgmentSchema,
|
|
2032
2343
|
system: assertSystemPrompt(),
|
|
2033
|
-
prompt
|
|
2034
|
-
placeholdersAsLabels(step),
|
|
2035
|
-
placeholdersAsLabels(expectation),
|
|
2036
|
-
snapshot,
|
|
2037
|
-
asJudged
|
|
2038
|
-
),
|
|
2344
|
+
prompt,
|
|
2039
2345
|
temperature: 0
|
|
2040
2346
|
});
|
|
2041
2347
|
const parsed = assertJudgmentSchema.safeParse(result.object);
|
|
@@ -2044,7 +2350,7 @@ function createBrain(model, generate = generateObject, budget) {
|
|
|
2044
2350
|
`Model returned an invalid assert judgment: ${parsed.error.issues[0]?.message ?? "unknown"}`
|
|
2045
2351
|
);
|
|
2046
2352
|
}
|
|
2047
|
-
return
|
|
2353
|
+
return label(parsed.data);
|
|
2048
2354
|
}
|
|
2049
2355
|
};
|
|
2050
2356
|
}
|
|
@@ -2087,92 +2393,17 @@ function createPlanner(model, generate = generateObject, budget) {
|
|
|
2087
2393
|
};
|
|
2088
2394
|
}
|
|
2089
2395
|
|
|
2090
|
-
// src/llm/provider.ts
|
|
2091
|
-
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2092
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
2093
|
-
var DEFAULT_MODELS = {
|
|
2094
|
-
anthropic: "claude-haiku-4-5",
|
|
2095
|
-
openai: "gpt-6-luna",
|
|
2096
|
-
ollama: "gpt-oss:20b"
|
|
2097
|
-
};
|
|
2098
|
-
var DEFAULT_API_KEY_ENVS = {
|
|
2099
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
2100
|
-
openai: "OPENAI_API_KEY"
|
|
2101
|
-
};
|
|
2102
|
-
var DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434/v1";
|
|
2103
|
-
var DEFAULT_TIMEOUT_SECONDS = {
|
|
2104
|
-
anthropic: 300,
|
|
2105
|
-
openai: 300,
|
|
2106
|
-
ollama: 900
|
|
2107
|
-
};
|
|
2108
|
-
function timeoutSeconds(llm) {
|
|
2109
|
-
return llm.timeout_s ?? DEFAULT_TIMEOUT_SECONDS[llm.provider];
|
|
2110
|
-
}
|
|
2111
|
-
function withExtraBody(extra, base = fetch) {
|
|
2112
|
-
return (input, init) => {
|
|
2113
|
-
if (typeof init?.body !== "string") return base(input, init);
|
|
2114
|
-
let body;
|
|
2115
|
-
try {
|
|
2116
|
-
body = JSON.parse(init.body);
|
|
2117
|
-
} catch {
|
|
2118
|
-
return base(input, init);
|
|
2119
|
-
}
|
|
2120
|
-
if (body === null || typeof body !== "object" || Array.isArray(body)) return base(input, init);
|
|
2121
|
-
return base(input, { ...init, body: JSON.stringify({ ...extra, ...body }) });
|
|
2122
|
-
};
|
|
2123
|
-
}
|
|
2124
|
-
var MissingApiKeyError = class extends Error {
|
|
2125
|
-
constructor(variable, provider) {
|
|
2126
|
-
super(
|
|
2127
|
-
`Missing API key: environment variable ${variable} is not set (required for provider "${provider}"). Export it before running, e.g. \`export ${variable}=...\`, or change llm.provider / llm.api_key_env in .blastproof/config.yaml.`
|
|
2128
|
-
);
|
|
2129
|
-
this.name = "MissingApiKeyError";
|
|
2130
|
-
}
|
|
2131
|
-
};
|
|
2132
|
-
function createModel(llm, env = process.env) {
|
|
2133
|
-
const modelId = llm.model ?? DEFAULT_MODELS[llm.provider];
|
|
2134
|
-
switch (llm.provider) {
|
|
2135
|
-
case "anthropic":
|
|
2136
|
-
case "openai": {
|
|
2137
|
-
const keyEnv = llm.api_key_env ?? DEFAULT_API_KEY_ENVS[llm.provider];
|
|
2138
|
-
const apiKey = env[keyEnv];
|
|
2139
|
-
if (!apiKey) {
|
|
2140
|
-
throw new MissingApiKeyError(keyEnv, llm.provider);
|
|
2141
|
-
}
|
|
2142
|
-
const baseURL = llm.base_url ? { baseURL: llm.base_url } : {};
|
|
2143
|
-
const extra = llm.extra_body ? { fetch: withExtraBody(llm.extra_body) } : {};
|
|
2144
|
-
const model = llm.provider === "anthropic" ? (
|
|
2145
|
-
// A configured endpoint applies to whichever provider is selected —
|
|
2146
|
-
// dropping it here routed corporate-proxy configs to the public API
|
|
2147
|
-
// with no error (design D2).
|
|
2148
|
-
createAnthropic({ apiKey, ...baseURL })(modelId)
|
|
2149
|
-
) : (
|
|
2150
|
-
// `.chat` = Chat Completions: works with official OpenAI and any
|
|
2151
|
-
// OpenAI-compatible endpoint (OpenRouter, LiteLLM, vLLM) via base_url.
|
|
2152
|
-
createOpenAI({ apiKey, ...baseURL, ...extra }).chat(modelId)
|
|
2153
|
-
);
|
|
2154
|
-
return { model, provider: llm.provider, modelId };
|
|
2155
|
-
}
|
|
2156
|
-
case "ollama": {
|
|
2157
|
-
const baseURL = llm.base_url ?? DEFAULT_OLLAMA_BASE_URL;
|
|
2158
|
-
const extra = llm.extra_body ? { fetch: withExtraBody(llm.extra_body) } : {};
|
|
2159
|
-
const model = createOpenAI({ baseURL, apiKey: "ollama", ...extra }).chat(modelId);
|
|
2160
|
-
return { model, provider: "ollama", modelId };
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
2396
|
// src/planner.ts
|
|
2166
2397
|
import { mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
|
|
2167
|
-
import
|
|
2398
|
+
import path7 from "path";
|
|
2168
2399
|
import { stringify } from "yaml";
|
|
2169
2400
|
|
|
2170
2401
|
// src/runner/testfile.ts
|
|
2171
2402
|
import { readFile as readFile3, readdir } from "fs/promises";
|
|
2172
|
-
import
|
|
2403
|
+
import path6 from "path";
|
|
2173
2404
|
import { parse as parseYaml2 } from "yaml";
|
|
2174
2405
|
import { z as z3 } from "zod";
|
|
2175
|
-
var TESTS_RELATIVE_DIR =
|
|
2406
|
+
var TESTS_RELATIVE_DIR = path6.join(".blastproof", "tests");
|
|
2176
2407
|
var prioritySchema = z3.enum(["P0", "P1", "P2"]);
|
|
2177
2408
|
var testFileSchema = z3.object({
|
|
2178
2409
|
summary: z3.string().min(1),
|
|
@@ -2181,7 +2412,8 @@ var testFileSchema = z3.object({
|
|
|
2181
2412
|
tags: z3.array(z3.string()).default([]),
|
|
2182
2413
|
setup: z3.array(z3.string().min(1)).optional(),
|
|
2183
2414
|
routes: z3.array(z3.string()).default([]),
|
|
2184
|
-
auth: z3.boolean().default(true)
|
|
2415
|
+
auth: z3.boolean().default(true),
|
|
2416
|
+
device: deviceSchema.optional()
|
|
2185
2417
|
});
|
|
2186
2418
|
var TestFileError = class extends Error {
|
|
2187
2419
|
constructor(message) {
|
|
@@ -2219,7 +2451,7 @@ async function discoverTestFiles(root) {
|
|
|
2219
2451
|
async function walk(dir) {
|
|
2220
2452
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
2221
2453
|
for (const entry of entries) {
|
|
2222
|
-
const full =
|
|
2454
|
+
const full = path6.join(dir, entry.name);
|
|
2223
2455
|
if (entry.isDirectory()) {
|
|
2224
2456
|
await walk(full);
|
|
2225
2457
|
} else if (/\.ya?ml$/i.test(entry.name)) {
|
|
@@ -2306,8 +2538,8 @@ async function generateForRoute(page, options) {
|
|
|
2306
2538
|
};
|
|
2307
2539
|
}
|
|
2308
2540
|
async function writeDraft(cwd, draft, meta) {
|
|
2309
|
-
const dir =
|
|
2310
|
-
const file =
|
|
2541
|
+
const dir = path7.join(cwd, TESTS_RELATIVE_DIR);
|
|
2542
|
+
const file = path7.join(dir, `${routeToSlug(meta.route)}.yaml`);
|
|
2311
2543
|
try {
|
|
2312
2544
|
await mkdir4(dir, { recursive: true });
|
|
2313
2545
|
await writeFile3(file, renderTestYaml(draft, meta), { flag: "wx" });
|
|
@@ -2315,11 +2547,11 @@ async function writeDraft(cwd, draft, meta) {
|
|
|
2315
2547
|
const err = error;
|
|
2316
2548
|
if (err.code === "EEXIST" && err.syscall !== "mkdir") {
|
|
2317
2549
|
throw new PlannerError(
|
|
2318
|
-
`Refusing to overwrite ${
|
|
2550
|
+
`Refusing to overwrite ${path7.relative(cwd, file)} (route ${meta.route}). Delete or rename it to regenerate.`
|
|
2319
2551
|
);
|
|
2320
2552
|
}
|
|
2321
2553
|
throw new PlannerError(
|
|
2322
|
-
`Cannot write draft to ${file}: ${fsReason(error)}. Check that ${
|
|
2554
|
+
`Cannot write draft to ${file}: ${fsReason(error)}. Check that ${path7.dirname(file)} is a directory you can write to, not a file.`
|
|
2323
2555
|
);
|
|
2324
2556
|
}
|
|
2325
2557
|
return file;
|
|
@@ -2482,11 +2714,11 @@ function formatSpendLine(spend) {
|
|
|
2482
2714
|
}
|
|
2483
2715
|
|
|
2484
2716
|
// src/commands/run.ts
|
|
2485
|
-
import
|
|
2717
|
+
import path10 from "path";
|
|
2486
2718
|
|
|
2487
2719
|
// src/report/html.ts
|
|
2488
2720
|
import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
2489
|
-
import
|
|
2721
|
+
import path8 from "path";
|
|
2490
2722
|
var ESCAPES = {
|
|
2491
2723
|
"&": "&",
|
|
2492
2724
|
"<": "<",
|
|
@@ -2507,10 +2739,10 @@ async function embedScreenshot(file) {
|
|
|
2507
2739
|
}
|
|
2508
2740
|
var STYLES = `
|
|
2509
2741
|
:root { color-scheme: light dark; --bg:#fff; --fg:#111; --muted:#666; --line:#e3e3e3;
|
|
2510
|
-
--pass:#137333; --fail:#c5221f; --card:#fafafa; }
|
|
2742
|
+
--pass:#137333; --fail:#c5221f; --warn:#b06000; --card:#fafafa; }
|
|
2511
2743
|
@media (prefers-color-scheme: dark) {
|
|
2512
2744
|
:root { --bg:#15171a; --fg:#e8e8e8; --muted:#9aa0a6; --line:#2c2f34;
|
|
2513
|
-
--pass:#5bb974; --fail:#f28b82; --card:#1c1f23; }
|
|
2745
|
+
--pass:#5bb974; --fail:#f28b82; --warn:#fdd663; --card:#1c1f23; }
|
|
2514
2746
|
}
|
|
2515
2747
|
* { box-sizing: border-box; }
|
|
2516
2748
|
body { margin:0; padding:2rem 1.25rem; background:var(--bg); color:var(--fg);
|
|
@@ -2525,6 +2757,11 @@ h1 { font-size:1.35rem; margin:0 0 .25rem; }
|
|
|
2525
2757
|
.verdict { font-weight:600; }
|
|
2526
2758
|
.verdict.pass { color:var(--pass); } .verdict.fail { color:var(--fail); }
|
|
2527
2759
|
.counts { color:var(--muted); font-size:.9rem; }
|
|
2760
|
+
.warnings { padding:1rem 1.25rem; border:1px solid var(--warn); border-radius:10px;
|
|
2761
|
+
background:color-mix(in srgb, var(--warn) 8%, transparent); margin-bottom:1.5rem; }
|
|
2762
|
+
.warnings h2 { font-size:1rem; margin:0 0 .5rem; color:var(--warn); }
|
|
2763
|
+
.warnings h3 { font-size:.9rem; margin:.75rem 0 .25rem; }
|
|
2764
|
+
.warnings pre { margin:0; white-space:pre-wrap; font-size:.82rem; }
|
|
2528
2765
|
.incomplete { padding:1rem 1.25rem; border:1px solid var(--fail); border-radius:10px;
|
|
2529
2766
|
background:color-mix(in srgb, var(--fail) 10%, transparent); margin-bottom:1.5rem; font-weight:600; }
|
|
2530
2767
|
table { width:100%; border-collapse:collapse; margin-bottom:1.5rem; }
|
|
@@ -2562,7 +2799,7 @@ function renderSteps(steps) {
|
|
|
2562
2799
|
</ol>`;
|
|
2563
2800
|
}
|
|
2564
2801
|
function withheldScreenshot(file, reportDir) {
|
|
2565
|
-
const href =
|
|
2802
|
+
const href = path8.relative(reportDir, file).split(path8.sep).join("/");
|
|
2566
2803
|
return ` <p class="note">Screenshot withheld: this run handled secrets ({{env.*}}), and a screenshot cannot be masked. <a href="${escapeHtml(href)}">${escapeHtml(href)}</a></p>`;
|
|
2567
2804
|
}
|
|
2568
2805
|
async function renderTest(result, screenshots, cwd) {
|
|
@@ -2570,10 +2807,11 @@ async function renderTest(result, screenshots, cwd) {
|
|
|
2570
2807
|
const notRun = result.status === "not-run";
|
|
2571
2808
|
const tagClass = failed ? "fail" : notRun ? "skip" : "pass";
|
|
2572
2809
|
const label = failed ? "FAIL" : notRun ? "NOT RUN" : "PASS";
|
|
2573
|
-
const file = cwd ?
|
|
2810
|
+
const file = cwd ? path8.relative(cwd, result.file) : result.file;
|
|
2811
|
+
const device = result.device ? ` \xB7 ${escapeHtml(result.device)}` : "";
|
|
2574
2812
|
const parts = [
|
|
2575
2813
|
` <details${failed || notRun ? " open" : ""}>`,
|
|
2576
|
-
` <summary><span class="tag ${tagClass}">${label}</span> ${escapeHtml(result.summary)} <span class="note">${escapeHtml(result.priority)} \xB7 ${escapeHtml(file)}</span></summary>`
|
|
2814
|
+
` <summary><span class="tag ${tagClass}">${label}</span> ${escapeHtml(result.summary)} <span class="note">${escapeHtml(result.priority)}${device} \xB7 ${escapeHtml(file)}</span></summary>`
|
|
2577
2815
|
];
|
|
2578
2816
|
if (failed) {
|
|
2579
2817
|
if (result.failedStep) {
|
|
@@ -2609,15 +2847,22 @@ async function renderHtml(results, skipped, meta) {
|
|
|
2609
2847
|
const banner = meta.incomplete === void 0 ? "" : ` <section class="incomplete">Run stopped: ${escapeHtml(meta.incomplete)}</section>
|
|
2610
2848
|
|
|
2611
2849
|
`;
|
|
2850
|
+
const warnings = meta.warnings ?? [];
|
|
2851
|
+
const warningsSection = warnings.length === 0 ? "" : ` <section class="warnings">
|
|
2852
|
+
<h2>Warnings (${warnings.length})</h2>
|
|
2853
|
+
` + warnings.map(
|
|
2854
|
+
(w) => ` <h3>${escapeHtml(w.title)}</h3>` + (w.lines.length > 0 ? `
|
|
2855
|
+
<pre>${escapeHtml(w.lines.join("\n"))}</pre>` : "")
|
|
2856
|
+
).join("\n") + "\n </section>\n\n";
|
|
2612
2857
|
const rows = results.map((r) => {
|
|
2613
|
-
const file = meta.cwd ?
|
|
2858
|
+
const file = meta.cwd ? path8.relative(meta.cwd, r.file) : r.file;
|
|
2614
2859
|
const tagClass = r.status === "failed" ? "fail" : r.status === "not-run" ? "skip" : "pass";
|
|
2615
2860
|
const label = r.status === "failed" ? "FAIL" : r.status === "not-run" ? "NOT RUN" : "PASS";
|
|
2616
2861
|
const time = r.status === "not-run" ? "\u2014" : seconds(r.durationMs);
|
|
2617
2862
|
return ` <tr><td><span class="tag ${tagClass}">${label}</span></td><td>${escapeHtml(r.priority)}</td><td>${escapeHtml(r.summary)}</td><td>${escapeHtml(file)}</td><td class="num">${time}</td></tr>`;
|
|
2618
2863
|
}).join("\n");
|
|
2619
2864
|
const skippedRows = skipped.map((s) => {
|
|
2620
|
-
const file = meta.cwd ?
|
|
2865
|
+
const file = meta.cwd ? path8.relative(meta.cwd, s.path) : s.path;
|
|
2621
2866
|
return ` <tr><td><span class="tag skip">SKIP</span></td><td>\u2014</td><td>${escapeHtml(s.summary)}</td><td>${escapeHtml(file)}</td><td class="num">\u2014</td></tr>`;
|
|
2622
2867
|
}).join("\n");
|
|
2623
2868
|
return `<!doctype html>
|
|
@@ -2639,7 +2884,7 @@ ${banner} <section class="score">
|
|
|
2639
2884
|
<span class="counts">${passed} passed \xB7 ${failures.length} failed${notRun.length > 0 ? ` \xB7 ${notRun.length} not run` : ""}${skipped.length > 0 ? ` \xB7 ${skipped.length} skipped` : ""}</span>
|
|
2640
2885
|
</section>
|
|
2641
2886
|
|
|
2642
|
-
<table>
|
|
2887
|
+
${warningsSection} <table>
|
|
2643
2888
|
<thead><tr><th>Status</th><th>Priority</th><th>Test</th><th>File</th><th class="num">Time</th></tr></thead>
|
|
2644
2889
|
<tbody>
|
|
2645
2890
|
${rows}${rows && skippedRows ? "\n" : ""}${skippedRows}
|
|
@@ -2656,7 +2901,7 @@ ${detail}
|
|
|
2656
2901
|
}
|
|
2657
2902
|
async function writeHtml(file, html) {
|
|
2658
2903
|
try {
|
|
2659
|
-
await mkdir5(
|
|
2904
|
+
await mkdir5(path8.dirname(file), { recursive: true });
|
|
2660
2905
|
await writeFile4(file, html, "utf8");
|
|
2661
2906
|
return file;
|
|
2662
2907
|
} catch (error) {
|
|
@@ -2668,7 +2913,7 @@ async function writeHtml(file, html) {
|
|
|
2668
2913
|
|
|
2669
2914
|
// src/report/junit.ts
|
|
2670
2915
|
import { mkdir as mkdir6, writeFile as writeFile5 } from "fs/promises";
|
|
2671
|
-
import
|
|
2916
|
+
import path9 from "path";
|
|
2672
2917
|
var ESCAPES2 = {
|
|
2673
2918
|
"&": "&",
|
|
2674
2919
|
"<": "<",
|
|
@@ -2683,7 +2928,8 @@ function seconds2(ms) {
|
|
|
2683
2928
|
return (ms / 1e3).toFixed(3);
|
|
2684
2929
|
}
|
|
2685
2930
|
function renderJUnit(results, skipped, meta) {
|
|
2686
|
-
const relative = (file) => meta.cwd ?
|
|
2931
|
+
const relative = (file) => meta.cwd ? path9.relative(meta.cwd, file) : file;
|
|
2932
|
+
const warnings = meta.warnings ?? [];
|
|
2687
2933
|
const failures = results.filter((result) => result.status === "failed").length;
|
|
2688
2934
|
const notRun = results.filter((result) => result.status === "not-run");
|
|
2689
2935
|
const lines = [
|
|
@@ -2703,6 +2949,9 @@ function renderJUnit(results, skipped, meta) {
|
|
|
2703
2949
|
' <property name="incomplete" value="true"/>',
|
|
2704
2950
|
` <property name="incomplete_reason" value="${escapeXml(meta.incomplete)}"/>`
|
|
2705
2951
|
] : [],
|
|
2952
|
+
// Emitted as 0 too (design D2): unlike a token count nobody reported, 0 is
|
|
2953
|
+
// a true claim here, that the run printed no warning.
|
|
2954
|
+
` <property name="warnings" value="${warnings.length}"/>`,
|
|
2706
2955
|
" </properties>"
|
|
2707
2956
|
];
|
|
2708
2957
|
for (const result of results) {
|
|
@@ -2733,12 +2982,15 @@ ${reason}` : reason;
|
|
|
2733
2982
|
" </testcase>"
|
|
2734
2983
|
);
|
|
2735
2984
|
}
|
|
2985
|
+
if (warnings.length > 0) {
|
|
2986
|
+
lines.push(` <system-err>${escapeXml(warnings.map(warningText).join("\n\n"))}</system-err>`);
|
|
2987
|
+
}
|
|
2736
2988
|
lines.push("</testsuite>", "");
|
|
2737
2989
|
return lines.join("\n");
|
|
2738
2990
|
}
|
|
2739
2991
|
async function writeJUnit(file, xml) {
|
|
2740
2992
|
try {
|
|
2741
|
-
await mkdir6(
|
|
2993
|
+
await mkdir6(path9.dirname(file), { recursive: true });
|
|
2742
2994
|
await writeFile5(file, xml, "utf8");
|
|
2743
2995
|
return file;
|
|
2744
2996
|
} catch (error) {
|
|
@@ -2926,8 +3178,12 @@ ${notRun.length} test(s) not run (run stopped: ${notRun[0].reason}):`);
|
|
|
2926
3178
|
for (const r of notRun) console.log(` - ${r.summary} (${r.file})`);
|
|
2927
3179
|
}
|
|
2928
3180
|
}
|
|
2929
|
-
|
|
2930
|
-
const
|
|
3181
|
+
function deviceTag(test, config) {
|
|
3182
|
+
const device = test.device ?? config.browser.device;
|
|
3183
|
+
return device ? ` [${device}]` : "";
|
|
3184
|
+
}
|
|
3185
|
+
async function runOne(browser, test, config, sessionDir, session, runMask, budget, write, firstJudge) {
|
|
3186
|
+
const brain = createBrain(createModel(config.llm).model, void 0, budget, firstJudge);
|
|
2931
3187
|
let resolved;
|
|
2932
3188
|
const mask = runMask;
|
|
2933
3189
|
try {
|
|
@@ -2947,11 +3203,12 @@ async function runOne(browser, test, config, sessionDir, session, runMask, budge
|
|
|
2947
3203
|
}
|
|
2948
3204
|
throw error;
|
|
2949
3205
|
}
|
|
2950
|
-
const
|
|
3206
|
+
const device = test.device ?? config.browser.device;
|
|
3207
|
+
const context = await browser.newContext(contextOptions(test.auth ? session : void 0, device));
|
|
2951
3208
|
try {
|
|
2952
3209
|
const page = await context.newPage();
|
|
2953
3210
|
page.setDefaultTimeout(config.browser.timeout_ms);
|
|
2954
|
-
|
|
3211
|
+
const result = await executeTest(page, resolved, {
|
|
2955
3212
|
brain,
|
|
2956
3213
|
sessionDir,
|
|
2957
3214
|
baseUrl: config.base_url,
|
|
@@ -2963,6 +3220,7 @@ async function runOne(browser, test, config, sessionDir, session, runMask, budge
|
|
|
2963
3220
|
mask: (text) => mask.mask(text),
|
|
2964
3221
|
onEvent: (event) => printEvent(event, write)
|
|
2965
3222
|
});
|
|
3223
|
+
return device ? { ...result, device } : result;
|
|
2966
3224
|
} finally {
|
|
2967
3225
|
await context.close();
|
|
2968
3226
|
}
|
|
@@ -2983,7 +3241,7 @@ function printImpactReport(impact, selection, cwd) {
|
|
|
2983
3241
|
if (selection.unroutedSkipped.length > 0) {
|
|
2984
3242
|
console.log("Unrouted tests (skipped):");
|
|
2985
3243
|
for (const test of selection.unroutedSkipped) {
|
|
2986
|
-
console.log(` ${test.summary} (${
|
|
3244
|
+
console.log(` ${test.summary} (${path10.relative(cwd, test.path)})`);
|
|
2987
3245
|
}
|
|
2988
3246
|
}
|
|
2989
3247
|
if (selection.uncoveredRoutes.length > 0) {
|
|
@@ -2992,35 +3250,42 @@ function printImpactReport(impact, selection, cwd) {
|
|
|
2992
3250
|
}
|
|
2993
3251
|
console.log("---------------------------------------------------------------");
|
|
2994
3252
|
}
|
|
2995
|
-
function reportNearMissedSecrets(variables) {
|
|
3253
|
+
function reportNearMissedSecrets(variables, warnings) {
|
|
2996
3254
|
for (const variable of variables) {
|
|
2997
|
-
|
|
2998
|
-
|
|
3255
|
+
emitWarning(
|
|
3256
|
+
{
|
|
3257
|
+
kind: "reformatted-secret",
|
|
3258
|
+
title: `warning: the application returned ${variable} in a different form than the value supplied (case or spacing). It was redacted, but a form this tool cannot recognise \u2014 an encoding, a hash \u2014 would not have been. Check what that page does with the value.`,
|
|
3259
|
+
lines: []
|
|
3260
|
+
},
|
|
3261
|
+
warnings
|
|
2999
3262
|
);
|
|
3000
3263
|
}
|
|
3001
3264
|
}
|
|
3002
|
-
async function finalize(results, skipped, options, sessionDir, secretsHeld, nearMissedSecrets, durationMs, impact, incomplete, spend) {
|
|
3265
|
+
async function finalize(results, skipped, options, sessionDir, secretsHeld, nearMissedSecrets, warnings, durationMs, impact, incomplete, spend, firstJudgeLog) {
|
|
3003
3266
|
if (results.length > 0) printSummary(results);
|
|
3004
|
-
reportNearMissedSecrets(nearMissedSecrets);
|
|
3267
|
+
reportNearMissedSecrets(nearMissedSecrets, warnings);
|
|
3005
3268
|
if (spend) console.log(formatSpendLine(spend));
|
|
3269
|
+
if (firstJudgeLog) console.log(firstJudgeLog.summaryLine());
|
|
3006
3270
|
const score = scoreOf(results, incomplete !== void 0);
|
|
3007
3271
|
console.log(
|
|
3008
3272
|
incomplete ? formatIncompleteLine(score, incomplete.message) : formatScoreLine(computeScore(results), results, options.minScore)
|
|
3009
3273
|
);
|
|
3010
3274
|
if (options.junit) {
|
|
3011
|
-
const target = typeof options.junit === "string" ?
|
|
3275
|
+
const target = typeof options.junit === "string" ? path10.resolve(options.cwd, options.junit) : path10.join(sessionDir, "junit.xml");
|
|
3012
3276
|
const xml = renderJUnit(results, skipped, {
|
|
3013
3277
|
score,
|
|
3014
3278
|
durationMs,
|
|
3015
3279
|
cwd: options.cwd,
|
|
3016
3280
|
incomplete: incomplete?.message,
|
|
3017
|
-
spend
|
|
3281
|
+
spend,
|
|
3282
|
+
warnings
|
|
3018
3283
|
});
|
|
3019
3284
|
await writeJUnit(target, xml);
|
|
3020
|
-
console.log(`JUnit report: ${
|
|
3285
|
+
console.log(`JUnit report: ${path10.relative(options.cwd, target)}`);
|
|
3021
3286
|
}
|
|
3022
3287
|
if (options.html) {
|
|
3023
|
-
const target = typeof options.html === "string" ?
|
|
3288
|
+
const target = typeof options.html === "string" ? path10.resolve(options.cwd, options.html) : path10.join(sessionDir, "report.html");
|
|
3024
3289
|
const html = await renderHtml(results, skipped, {
|
|
3025
3290
|
score,
|
|
3026
3291
|
durationMs,
|
|
@@ -3028,15 +3293,16 @@ async function finalize(results, skipped, options, sessionDir, secretsHeld, near
|
|
|
3028
3293
|
cwd: options.cwd,
|
|
3029
3294
|
incomplete: incomplete?.message,
|
|
3030
3295
|
spend,
|
|
3296
|
+
warnings,
|
|
3031
3297
|
// A screenshot cannot be masked, so a run that held any `{{env.*}}` value
|
|
3032
3298
|
// links to it instead of carrying it (design
|
|
3033
3299
|
// withhold-a-screenshot-that-saw-a-secret, D1): the run's mask, not the
|
|
3034
3300
|
// failed test's own placeholders, because a login credential is echoed by
|
|
3035
3301
|
// the pages of every test that comes after it.
|
|
3036
|
-
screenshots: secretsHeld ? { withheldRelativeTo:
|
|
3302
|
+
screenshots: secretsHeld ? { withheldRelativeTo: path10.dirname(target) } : "embed"
|
|
3037
3303
|
});
|
|
3038
3304
|
await writeHtml(target, html);
|
|
3039
|
-
console.log(`HTML report: ${
|
|
3305
|
+
console.log(`HTML report: ${path10.relative(options.cwd, target)}`);
|
|
3040
3306
|
}
|
|
3041
3307
|
if (incomplete) return EXIT_FAILED;
|
|
3042
3308
|
if (reportUnclassified(options, impact)) return EXIT_FAILED;
|
|
@@ -3061,35 +3327,42 @@ function declaredConfigRoutes(config) {
|
|
|
3061
3327
|
const routes = config.routes ? Object.values(config.routes) : [];
|
|
3062
3328
|
return [...new Set(routes.flat())].sort();
|
|
3063
3329
|
}
|
|
3064
|
-
function
|
|
3065
|
-
if (drift.drifted.length === 0) return;
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3330
|
+
function routeDriftWarning(drift, cwd) {
|
|
3331
|
+
if (drift.drifted.length === 0) return void 0;
|
|
3332
|
+
return {
|
|
3333
|
+
kind: "route-drift",
|
|
3334
|
+
title: "Route drift (test routes declared by no routes: mapping \u2014 contribute nothing to --impacted selection):",
|
|
3335
|
+
lines: [
|
|
3336
|
+
...drift.drifted.map(({ test, routes }) => ` ${test.summary} (${path10.relative(cwd, test.path)}): ${routes.join(", ")}`),
|
|
3337
|
+
"Fix the route typo, or add the route to a routes: mapping in .blastproof/config.yaml."
|
|
3338
|
+
]
|
|
3339
|
+
};
|
|
3073
3340
|
}
|
|
3074
|
-
function
|
|
3075
|
-
if (result.findings.length === 0) return;
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3341
|
+
function authoringWarning(result, cwd) {
|
|
3342
|
+
if (result.findings.length === 0) return void 0;
|
|
3343
|
+
return {
|
|
3344
|
+
kind: "authoring",
|
|
3345
|
+
title: "Authoring (a step enters a value but names none):",
|
|
3346
|
+
lines: [
|
|
3347
|
+
...result.findings.flatMap(({ test, origin, index, step }) => {
|
|
3348
|
+
const where = origin === "setup" ? `setup step ${index}` : `step ${index}`;
|
|
3349
|
+
return [
|
|
3350
|
+
` ${test.summary} (${path10.relative(cwd, test.path)}) ${where}:`,
|
|
3351
|
+
` ${step}`,
|
|
3352
|
+
` \u2192 ${suggestValueClause(step)}`
|
|
3353
|
+
];
|
|
3354
|
+
}),
|
|
3355
|
+
"The runner is forbidden from inventing values and enforces it: one it cannot trace to the step, the page or an {{env.*}} placeholder is refused, so a step supplying none fails at run time. Naming the value here is what makes it run.",
|
|
3356
|
+
"Steps are inspected in English only; steps in other languages are not checked."
|
|
3357
|
+
],
|
|
3358
|
+
spaced: true
|
|
3359
|
+
};
|
|
3087
3360
|
}
|
|
3088
3361
|
function printDryRun(selected, config, cwd) {
|
|
3089
3362
|
console.log(`
|
|
3090
3363
|
Dry run: ${selected.length} test(s) selected, base_url=${config.base_url}`);
|
|
3091
3364
|
for (const test of selected) {
|
|
3092
|
-
console.log(` ${test.summary} [${test.priority}] (${
|
|
3365
|
+
console.log(` ${test.summary} [${test.priority}]${deviceTag(test, config)} (${path10.relative(cwd, test.path)})`);
|
|
3093
3366
|
}
|
|
3094
3367
|
const needsLogin = selected.some((test) => test.auth);
|
|
3095
3368
|
const authSteps = needsLogin ? config.auth?.steps ?? [] : [];
|
|
@@ -3097,7 +3370,10 @@ Dry run: ${selected.length} test(s) selected, base_url=${config.base_url}`);
|
|
|
3097
3370
|
const ceiling = estimateMaxModelCalls(
|
|
3098
3371
|
withAuth,
|
|
3099
3372
|
DEFAULT_MAX_ITERATIONS_PER_STEP,
|
|
3100
|
-
config.max_retries_per_step
|
|
3373
|
+
config.max_retries_per_step,
|
|
3374
|
+
// A judgment the first judge does not pass makes two calls (design
|
|
3375
|
+
// a-decision-model-judges-first, D8).
|
|
3376
|
+
config.first_judge ? 2 : 1
|
|
3101
3377
|
);
|
|
3102
3378
|
const authNote = authSteps.length > 0 ? ", including the login journey" : "";
|
|
3103
3379
|
console.log(
|
|
@@ -3116,6 +3392,7 @@ async function runCommand(options) {
|
|
|
3116
3392
|
}
|
|
3117
3393
|
throw error;
|
|
3118
3394
|
}
|
|
3395
|
+
const warnings = [];
|
|
3119
3396
|
const impacted = options.impacted ?? false;
|
|
3120
3397
|
const base = options.base ?? "main";
|
|
3121
3398
|
if (options.failOnUnmapped && !impacted) {
|
|
@@ -3137,9 +3414,9 @@ async function runCommand(options) {
|
|
|
3137
3414
|
throw error;
|
|
3138
3415
|
}
|
|
3139
3416
|
impact = mapImpact(changedFiles, config.routes ?? {}, config.ignore ?? []);
|
|
3140
|
-
printUncommitted(await getUncommittedFiles(options.cwd), changedFiles, config, base);
|
|
3417
|
+
printUncommitted(await getUncommittedFiles(options.cwd), changedFiles, config, base, warnings);
|
|
3141
3418
|
}
|
|
3142
|
-
const testsDir =
|
|
3419
|
+
const testsDir = path10.join(options.cwd, TESTS_RELATIVE_DIR);
|
|
3143
3420
|
let files;
|
|
3144
3421
|
try {
|
|
3145
3422
|
files = await discoverTestFiles(testsDir);
|
|
@@ -3155,8 +3432,8 @@ async function runCommand(options) {
|
|
|
3155
3432
|
} catch (error) {
|
|
3156
3433
|
if (error instanceof TestFileError) {
|
|
3157
3434
|
results.push({
|
|
3158
|
-
file:
|
|
3159
|
-
summary:
|
|
3435
|
+
file: path10.relative(options.cwd, file),
|
|
3436
|
+
summary: path10.basename(file),
|
|
3160
3437
|
priority: "P1",
|
|
3161
3438
|
tags: [],
|
|
3162
3439
|
status: "failed",
|
|
@@ -3170,9 +3447,9 @@ async function runCommand(options) {
|
|
|
3170
3447
|
}
|
|
3171
3448
|
}
|
|
3172
3449
|
const drift = detectRouteDrift(parsed, declaredConfigRoutes(config));
|
|
3173
|
-
|
|
3450
|
+
emitWarning(routeDriftWarning(drift, options.cwd), warnings);
|
|
3174
3451
|
const authoring = detectMissingValues(parsed);
|
|
3175
|
-
|
|
3452
|
+
emitWarning(authoringWarning(authoring, options.cwd), warnings);
|
|
3176
3453
|
if (options.failOnAuthoring && authoring.findings.length > 0) {
|
|
3177
3454
|
console.error(
|
|
3178
3455
|
`error: --fail-on-authoring: ${authoring.findings.length} step(s) enter a value but name none.`
|
|
@@ -3198,16 +3475,18 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3198
3475
|
}
|
|
3199
3476
|
return reportUnclassified(options, impact) ? EXIT_FAILED : EXIT_OK;
|
|
3200
3477
|
}
|
|
3201
|
-
const sessionDir =
|
|
3478
|
+
const sessionDir = path10.join(options.cwd, ".blastproof", "reports", sessionId());
|
|
3202
3479
|
const startedAt = Date.now();
|
|
3203
3480
|
if (selected.length === 0) {
|
|
3204
3481
|
console.log(
|
|
3205
3482
|
impact ? "No impacted tests to run." : "No tests matched the given filters."
|
|
3206
3483
|
);
|
|
3207
|
-
return finalize(results, selection.unroutedSkipped, options, sessionDir, false, [], Date.now() - startedAt, impact);
|
|
3484
|
+
return finalize(results, selection.unroutedSkipped, options, sessionDir, false, [], warnings, Date.now() - startedAt, impact);
|
|
3208
3485
|
}
|
|
3486
|
+
let decide;
|
|
3209
3487
|
try {
|
|
3210
3488
|
createModel(config.llm);
|
|
3489
|
+
if (config.first_judge) decide = createFirstJudgeClient(config.first_judge);
|
|
3211
3490
|
} catch (error) {
|
|
3212
3491
|
if (error instanceof MissingApiKeyError) {
|
|
3213
3492
|
console.error(`error: ${error.message}`);
|
|
@@ -3219,6 +3498,18 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3219
3498
|
console.log(
|
|
3220
3499
|
`blastproof run: ${selected.length} test(s), provider=${provider} model=${modelId}, base_url=${config.base_url}`
|
|
3221
3500
|
);
|
|
3501
|
+
const firstJudgeLog = config.first_judge && decide ? new FirstJudgeLog(config.first_judge.model, config.first_judge.threshold, firstJudgeLogPath(sessionDir)) : void 0;
|
|
3502
|
+
const firstJudgeFor = (test) => firstJudgeLog && decide ? {
|
|
3503
|
+
model: firstJudgeLog.model,
|
|
3504
|
+
threshold: firstJudgeLog.threshold,
|
|
3505
|
+
decide,
|
|
3506
|
+
record: (entry) => firstJudgeLog.record(test, entry)
|
|
3507
|
+
} : void 0;
|
|
3508
|
+
if (firstJudgeLog) {
|
|
3509
|
+
console.log(
|
|
3510
|
+
`First judge (experimental): ${firstJudgeLog.model}, passing at p(yes) >= ${firstJudgeLog.threshold}; its decisions are kept in ${path10.relative(options.cwd, firstJudgeLogPath(sessionDir))}`
|
|
3511
|
+
);
|
|
3512
|
+
}
|
|
3222
3513
|
const runMask = buildRunMask(config, parsed);
|
|
3223
3514
|
const budget = options.budget ?? new RunBudget(resolveBudgetOptions(config, options));
|
|
3224
3515
|
const preflight = await runPreflight({ browser: true, model: true, baseUrl: true }, config);
|
|
@@ -3239,10 +3530,11 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3239
3530
|
baseUrl: config.base_url,
|
|
3240
3531
|
allowedOrigins: config.allowed_origins,
|
|
3241
3532
|
browser,
|
|
3242
|
-
brain: createBrain(createModel(config.llm).model, void 0, budget),
|
|
3533
|
+
brain: createBrain(createModel(config.llm).model, void 0, budget, firstJudgeFor("(login)")),
|
|
3243
3534
|
maxRetries: config.max_retries_per_step,
|
|
3244
3535
|
timeoutMs: config.browser.timeout_ms,
|
|
3245
3536
|
maxSnapshotLines: config.browser.max_snapshot_lines,
|
|
3537
|
+
device: config.browser.device,
|
|
3246
3538
|
mask: runMask,
|
|
3247
3539
|
onEvent: printEvent
|
|
3248
3540
|
});
|
|
@@ -3267,13 +3559,23 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3267
3559
|
if (stoppedBy) return { index, stopped: stoppedBy };
|
|
3268
3560
|
const lines = [];
|
|
3269
3561
|
const header = `
|
|
3270
|
-
> ${test.summary} [${test.priority}] (${
|
|
3562
|
+
> ${test.summary} [${test.priority}]${deviceTag(test, config)} (${path10.relative(options.cwd, test.path)})`;
|
|
3271
3563
|
const write = streaming ? console.log : (line) => lines.push(line);
|
|
3272
3564
|
if (streaming) console.log(header);
|
|
3273
3565
|
else lines.push(header);
|
|
3274
3566
|
try {
|
|
3275
3567
|
budget.check();
|
|
3276
|
-
const result = await runOne(
|
|
3568
|
+
const result = await runOne(
|
|
3569
|
+
browser,
|
|
3570
|
+
test,
|
|
3571
|
+
config,
|
|
3572
|
+
sessionDir,
|
|
3573
|
+
session,
|
|
3574
|
+
runMask,
|
|
3575
|
+
budget,
|
|
3576
|
+
write,
|
|
3577
|
+
firstJudgeFor(path10.relative(options.cwd, test.path))
|
|
3578
|
+
);
|
|
3277
3579
|
if (!streaming) for (const line of lines) console.log(line);
|
|
3278
3580
|
return { index, result };
|
|
3279
3581
|
} catch (error) {
|
|
@@ -3304,6 +3606,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3304
3606
|
sessionDir,
|
|
3305
3607
|
!runMask.isEmpty(),
|
|
3306
3608
|
runMask.nearMissedVariables(),
|
|
3609
|
+
warnings,
|
|
3307
3610
|
Date.now() - startedAt,
|
|
3308
3611
|
impact,
|
|
3309
3612
|
incomplete,
|
|
@@ -3312,7 +3615,8 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3312
3615
|
// phases deliberately, so reporting at the point of use rather than the
|
|
3313
3616
|
// point of ownership would print the running total twice for a single
|
|
3314
3617
|
// allowance, the second line silently including the first.
|
|
3315
|
-
options.budget === void 0 ? budget.spend() : void 0
|
|
3618
|
+
options.budget === void 0 ? budget.spend() : void 0,
|
|
3619
|
+
firstJudgeLog
|
|
3316
3620
|
);
|
|
3317
3621
|
}
|
|
3318
3622
|
|
|
@@ -3327,7 +3631,7 @@ function printAuthEvent(event) {
|
|
|
3327
3631
|
}
|
|
3328
3632
|
}
|
|
3329
3633
|
async function loadSuite(cwd) {
|
|
3330
|
-
const testsDir =
|
|
3634
|
+
const testsDir = path11.join(cwd, TESTS_RELATIVE_DIR);
|
|
3331
3635
|
let files;
|
|
3332
3636
|
try {
|
|
3333
3637
|
files = await discoverTestFiles(testsDir);
|
|
@@ -3457,6 +3761,7 @@ async function planCommand(options) {
|
|
|
3457
3761
|
maxRetries: config.max_retries_per_step,
|
|
3458
3762
|
timeoutMs: config.browser.timeout_ms,
|
|
3459
3763
|
maxSnapshotLines: config.browser.max_snapshot_lines,
|
|
3764
|
+
device: config.browser.device,
|
|
3460
3765
|
mask,
|
|
3461
3766
|
onEvent: printAuthEvent
|
|
3462
3767
|
});
|
|
@@ -3475,7 +3780,7 @@ async function planCommand(options) {
|
|
|
3475
3780
|
console.log(`
|
|
3476
3781
|
> ${route}`);
|
|
3477
3782
|
let draft;
|
|
3478
|
-
const context = await browser.newContext(contextOptions(session));
|
|
3783
|
+
const context = await browser.newContext(contextOptions(session, config.browser.device));
|
|
3479
3784
|
try {
|
|
3480
3785
|
const page = await context.newPage();
|
|
3481
3786
|
page.setDefaultTimeout(config.browser.timeout_ms);
|
|
@@ -3509,8 +3814,8 @@ async function planCommand(options) {
|
|
|
3509
3814
|
if (options.write) {
|
|
3510
3815
|
try {
|
|
3511
3816
|
const file = await writeDraft(options.cwd, draft, { route, base });
|
|
3512
|
-
written.push(
|
|
3513
|
-
console.log(` wrote ${
|
|
3817
|
+
written.push(path11.relative(options.cwd, file));
|
|
3818
|
+
console.log(` wrote ${path11.relative(options.cwd, file)}`);
|
|
3514
3819
|
} catch (error) {
|
|
3515
3820
|
generated.pop();
|
|
3516
3821
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -3637,7 +3942,7 @@ function parsePositiveNumber(flag) {
|
|
|
3637
3942
|
};
|
|
3638
3943
|
}
|
|
3639
3944
|
var program = new Command();
|
|
3640
|
-
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.
|
|
3945
|
+
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.29.1");
|
|
3641
3946
|
program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
|
|
3642
3947
|
try {
|
|
3643
3948
|
const result = await initProject(process.cwd());
|