@waitcher/cli 0.2.15 → 0.2.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/dist/cli.mjs +245 -46
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -19057,7 +19057,7 @@ var require_snapshot_utils = __commonJS({
|
|
|
19057
19057
|
var require_snapshot_recorder = __commonJS({
|
|
19058
19058
|
"../../node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
19059
19059
|
"use strict";
|
|
19060
|
-
var { writeFile: writeFile10, readFile:
|
|
19060
|
+
var { writeFile: writeFile10, readFile: readFile12, mkdir: mkdir11 } = __require("node:fs/promises");
|
|
19061
19061
|
var { dirname: dirname18, resolve: resolve18 } = __require("node:path");
|
|
19062
19062
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
19063
19063
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
@@ -19275,7 +19275,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19275
19275
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19276
19276
|
}
|
|
19277
19277
|
try {
|
|
19278
|
-
const data = await
|
|
19278
|
+
const data = await readFile12(resolve18(path2), "utf8");
|
|
19279
19279
|
const parsed = JSON.parse(data);
|
|
19280
19280
|
if (Array.isArray(parsed)) {
|
|
19281
19281
|
this.#snapshots.clear();
|
|
@@ -52276,6 +52276,37 @@ var VISUAL_POLICY = Object.freeze({
|
|
|
52276
52276
|
historyDays: 30,
|
|
52277
52277
|
pageSize: 50
|
|
52278
52278
|
});
|
|
52279
|
+
var SCRIPT_SCREENSHOT_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,150}\.png$/;
|
|
52280
|
+
var SCRIPT_SCREENSHOT_LIMITS = Object.freeze({
|
|
52281
|
+
// Baselines sent with one run.
|
|
52282
|
+
files: 10,
|
|
52283
|
+
totalBytes: 12 * 1024 * 1024
|
|
52284
|
+
});
|
|
52285
|
+
var scriptCaptureEvidenceSchema = external_exports.object({
|
|
52286
|
+
schemaVersion: external_exports.literal(1),
|
|
52287
|
+
kind: external_exports.literal("script"),
|
|
52288
|
+
fingerprint: visualDigestSchema,
|
|
52289
|
+
file: external_exports.string().regex(SCRIPT_SCREENSHOT_FILE),
|
|
52290
|
+
width: external_exports.number().int().min(1).max(VISUAL_LIMITS.maxDimension),
|
|
52291
|
+
height: external_exports.number().int().min(1).max(VISUAL_LIMITS.maxDimension),
|
|
52292
|
+
sha256: visualDigestSchema,
|
|
52293
|
+
candidatePath: external_exports.string().max(1e3)
|
|
52294
|
+
}).strict();
|
|
52295
|
+
var scriptMetricsSchema = external_exports.object({
|
|
52296
|
+
schemaVersion: external_exports.literal(1),
|
|
52297
|
+
// "e2e": the framework's own numbers for a failed assertion. "measured":
|
|
52298
|
+
// a passing run's capture compared with the baseline by the server.
|
|
52299
|
+
source: external_exports.enum(["e2e", "measured"]),
|
|
52300
|
+
status: external_exports.enum(["passed", "failed"]),
|
|
52301
|
+
reason: external_exports.enum(["within_tolerance", "visual_change", "dimension_mismatch"]),
|
|
52302
|
+
thresholds: visualThresholdSchema.optional(),
|
|
52303
|
+
baseline: visualShape.nullable(),
|
|
52304
|
+
candidate: visualShape,
|
|
52305
|
+
differentPixels: external_exports.number().int().min(0).nullable(),
|
|
52306
|
+
totalPixels: external_exports.number().int().min(1),
|
|
52307
|
+
diffRatio: external_exports.number().min(0).max(1).nullable(),
|
|
52308
|
+
hasDiff: external_exports.boolean()
|
|
52309
|
+
}).strict();
|
|
52279
52310
|
var visualImageRoleSchema = external_exports.enum(["candidate", "original", "diff"]);
|
|
52280
52311
|
var visualHeadIdSchema = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
52281
52312
|
var visualListQuerySchema = external_exports.object({
|
|
@@ -56665,7 +56696,7 @@ import { performance as performance5 } from "node:perf_hooks";
|
|
|
56665
56696
|
import {
|
|
56666
56697
|
mkdir as mkdir4,
|
|
56667
56698
|
lstat as lstat7,
|
|
56668
|
-
readFile as
|
|
56699
|
+
readFile as readFile4,
|
|
56669
56700
|
realpath,
|
|
56670
56701
|
readdir,
|
|
56671
56702
|
writeFile as writeFile4
|
|
@@ -57795,6 +57826,8 @@ import {
|
|
|
57795
57826
|
symlink,
|
|
57796
57827
|
mkdtemp,
|
|
57797
57828
|
rm as rm3,
|
|
57829
|
+
readFile as readFile2,
|
|
57830
|
+
copyFile,
|
|
57798
57831
|
lstat as lstat5
|
|
57799
57832
|
} from "node:fs/promises";
|
|
57800
57833
|
import { constants as constants9 } from "node:fs";
|
|
@@ -57916,7 +57949,106 @@ function child(command, args, {
|
|
|
57916
57949
|
);
|
|
57917
57950
|
}
|
|
57918
57951
|
|
|
57952
|
+
// ../../src/visual/screenshot-outcome.ts
|
|
57953
|
+
var RESULTS = ".e2e/results/";
|
|
57954
|
+
var STORED = "tests/monitor.e2e.ts-snapshots/";
|
|
57955
|
+
function screenshotOutcome(report) {
|
|
57956
|
+
const run2 = report?.run ?? report;
|
|
57957
|
+
const results = run2?.results;
|
|
57958
|
+
if (!Array.isArray(results)) return null;
|
|
57959
|
+
for (const result2 of results) {
|
|
57960
|
+
for (const attempt of Array.isArray(result2?.attempts) ? result2.attempts : []) {
|
|
57961
|
+
const error62 = attempt?.error;
|
|
57962
|
+
const expected = error62?.details?.expected, observed = error62?.details?.observed;
|
|
57963
|
+
if (error62?.code !== "ASSERTION_FAILED" || typeof error62.message !== "string" || !error62.message.startsWith("expect.toHaveScreenshot failed") || typeof expected !== "string" || typeof observed !== "string" || !expected.startsWith(STORED))
|
|
57964
|
+
continue;
|
|
57965
|
+
const file2 = expected.slice(STORED.length);
|
|
57966
|
+
if (!SCRIPT_SCREENSHOT_FILE.test(file2)) return null;
|
|
57967
|
+
const paths = (Array.isArray(attempt.artifacts) ? attempt.artifacts : []).map((a) => a?.path).filter(
|
|
57968
|
+
(p) => typeof p === "string" && p.length < 900 && !p.includes("..")
|
|
57969
|
+
);
|
|
57970
|
+
const find = (suffix) => {
|
|
57971
|
+
const path2 = paths.find((p) => p.endsWith(suffix));
|
|
57972
|
+
return path2 ? RESULTS + path2 : void 0;
|
|
57973
|
+
};
|
|
57974
|
+
if (observed === "no stored screenshot") {
|
|
57975
|
+
const actual2 = find(`/snapshots/${expected}`);
|
|
57976
|
+
return actual2 ? { kind: "missing", file: file2, actual: actual2 } : null;
|
|
57977
|
+
}
|
|
57978
|
+
const actual = find("-actual.png"), stored = find("-expected.png");
|
|
57979
|
+
if (!actual || !stored) return null;
|
|
57980
|
+
const pixels = /^(\d{1,9}) pixels \(/.exec(observed);
|
|
57981
|
+
if (pixels) {
|
|
57982
|
+
const diff = find("-diff.png");
|
|
57983
|
+
return diff ? {
|
|
57984
|
+
kind: "pixels",
|
|
57985
|
+
file: file2,
|
|
57986
|
+
actual,
|
|
57987
|
+
expected: stored,
|
|
57988
|
+
diff,
|
|
57989
|
+
differentPixels: Number(pixels[1])
|
|
57990
|
+
} : null;
|
|
57991
|
+
}
|
|
57992
|
+
return /^a \d+x\d+ screenshot where /.test(observed) ? { kind: "size", file: file2, actual, expected: stored } : null;
|
|
57993
|
+
}
|
|
57994
|
+
}
|
|
57995
|
+
return null;
|
|
57996
|
+
}
|
|
57997
|
+
|
|
57998
|
+
// ../../src/visual/test-script.ts
|
|
57999
|
+
var CAPTURE_SUFFIX = "-capture";
|
|
58000
|
+
function visualTest(input2, timeoutSeconds) {
|
|
58001
|
+
const config2 = visualConfigSchema.parse(input2);
|
|
58002
|
+
const s = (value2) => JSON.stringify(value2);
|
|
58003
|
+
const name5 = config2.checkpoint.id;
|
|
58004
|
+
const subject = config2.checkpoint.kind === "element" ? `browser.locator(${s(config2.checkpoint.selector)})` : "screen";
|
|
58005
|
+
const budget = Math.max(
|
|
58006
|
+
1e3,
|
|
58007
|
+
Math.min(config2.captureBudgetMs, timeoutSeconds * 1e3 - 5e3, 1e4)
|
|
58008
|
+
);
|
|
58009
|
+
const script = `import { test, expect } from 'e2e';
|
|
58010
|
+
test(${s(name5)}, async ({ app, browser, screen }) => {
|
|
58011
|
+
await app.open('');
|
|
58012
|
+
await expect(browser.locator(${s(config2.ready.selector)})).toBeVisible({ timeout: ${config2.ready.timeoutMs} });
|
|
58013
|
+
await browser.evaluate(() => document.fonts.ready.then(() => true));
|
|
58014
|
+
${config2.masks.map(
|
|
58015
|
+
(mask) => ` await expect(browser.locator(${s(mask)})).not.toHaveCount(0, { timeout: ${config2.ready.timeoutMs} });`
|
|
58016
|
+
).join("\n")}
|
|
58017
|
+
await expect(${subject}).toHaveScreenshot(${s(`${name5}.png`)}, {
|
|
58018
|
+
threshold: ${config2.thresholds.pixelThreshold},
|
|
58019
|
+
maxDiffPixelRatio: ${config2.thresholds.maxDiffRatio},
|
|
58020
|
+
mask: [${config2.masks.map((mask) => `browser.locator(${s(mask)})`).join(", ")}],
|
|
58021
|
+
maskColor: '#808080',
|
|
58022
|
+
timeout: ${budget},
|
|
58023
|
+
});
|
|
58024
|
+
// The framework keeps no image of a passing comparison. A second
|
|
58025
|
+
// screenshot under a name that has no baseline is written to the results
|
|
58026
|
+
// instead; its "missing" failure is expected and caught, and the server
|
|
58027
|
+
// measures this capture against the baseline for the run's record.
|
|
58028
|
+
try {
|
|
58029
|
+
await expect(${subject}).toHaveScreenshot(${s(`${name5}${CAPTURE_SUFFIX}.png`)}, {
|
|
58030
|
+
mask: [${config2.masks.map((mask) => `browser.locator(${s(mask)})`).join(", ")}],
|
|
58031
|
+
maskColor: '#808080',
|
|
58032
|
+
timeout: ${budget},
|
|
58033
|
+
});
|
|
58034
|
+
} catch {}
|
|
58035
|
+
});
|
|
58036
|
+
`;
|
|
58037
|
+
return {
|
|
58038
|
+
script,
|
|
58039
|
+
web: {
|
|
58040
|
+
viewport: VISUAL_VIEWPORTS[config2.viewport],
|
|
58041
|
+
locale: config2.locale,
|
|
58042
|
+
timezoneId: config2.timezone,
|
|
58043
|
+
colorScheme: "light",
|
|
58044
|
+
reducedMotion: "reduce"
|
|
58045
|
+
}
|
|
58046
|
+
};
|
|
58047
|
+
}
|
|
58048
|
+
|
|
57919
58049
|
// ../../src/checks/e2e.ts
|
|
58050
|
+
var SNAPSHOT_DIRECTORY = "monitor.e2e.ts-snapshots";
|
|
58051
|
+
var SNAPSHOT_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,150}\.png$/;
|
|
57920
58052
|
async function collectArtifacts(dir, base2 = dir, tokens2 = [], excluded = /* @__PURE__ */ new Set()) {
|
|
57921
58053
|
const result2 = [];
|
|
57922
58054
|
let entries2 = 0;
|
|
@@ -58065,6 +58197,15 @@ export const dataGradeSummary=grader.summary;
|
|
|
58065
58197
|
);
|
|
58066
58198
|
await mkdir2(join5(dir, "tests"));
|
|
58067
58199
|
await writeFile2(join5(dir, "tests", "monitor.e2e.ts"), m.script);
|
|
58200
|
+
if (options.snapshots && Object.keys(options.snapshots).length) {
|
|
58201
|
+
const stored = join5(dir, "tests", SNAPSHOT_DIRECTORY);
|
|
58202
|
+
await mkdir2(stored, { mode: 448 });
|
|
58203
|
+
for (const [name5, bytes2] of Object.entries(options.snapshots)) {
|
|
58204
|
+
if (!SNAPSHOT_FILE.test(name5))
|
|
58205
|
+
throw Error("Invalid stored screenshot name");
|
|
58206
|
+
await writeFile2(join5(stored, name5), bytes2, { mode: 384, flag: "wx" });
|
|
58207
|
+
}
|
|
58208
|
+
}
|
|
58068
58209
|
const config2 = {
|
|
58069
58210
|
tests: ["tests/*.e2e.ts"],
|
|
58070
58211
|
workers: 1,
|
|
@@ -58081,7 +58222,10 @@ export const dataGradeSummary=grader.summary;
|
|
|
58081
58222
|
reporters: options.reporters ?? ["list"],
|
|
58082
58223
|
targets: []
|
|
58083
58224
|
};
|
|
58084
|
-
const
|
|
58225
|
+
const webOptions = JSON.stringify(
|
|
58226
|
+
options.web ?? { viewport: { width: 1280, height: 800 } }
|
|
58227
|
+
).slice(1, -1);
|
|
58228
|
+
const targets = m.type === "browser" ? `[{engine:${network ? `isolatedWeb(proxyFromEnvironment(),undefined,${JSON.stringify(options.browserIdentityFile) ?? "undefined"})` : options.browserIdentityFile ? `web({browser:protectedBrowserProvider({chromium,identityFile:${JSON.stringify(options.browserIdentityFile)}}),${webOptions}})` : `browserOverride?web({browser:protectedBrowserProvider({chromium}),${webOptions}}):web({${webOptions}})`},app:{url:${JSON.stringify(m.target)}}}]` : `[{name:'api',platform:'api'}]`;
|
|
58085
58229
|
const modelSource = dispatch ? `import {brokerModel} from ${JSON.stringify(pathToFileURL(options.modelClientFile ?? resolve8(root, "dist/model-client.mjs")).href)};
|
|
58086
58230
|
const connect=(model)=>brokerModel({origin:process.env.WAITCHER_MODEL_ORIGIN,token:process.env.WAITCHER_MODEL_TOKEN,model,outputTokens:${dispatch.outputTokens}${"transport" in dispatch ? ",transport:'gateway'" : ""}});
|
|
58087
58231
|
const agents={default:{model:connect(${JSON.stringify(dispatch.model)}),${dispatch.judgeModel ? `judge:connect(${JSON.stringify(dispatch.judgeModel)}),` : ""}maxSteps:5,maxModelCalls:${m.ai.budget.calls},judgmentTimeout:${Math.min(3e4, m.timeout * 1e3)},maxObservationBytes:131072}};` : "";
|
|
@@ -58172,7 +58316,7 @@ try {
|
|
|
58172
58316
|
const environment = options.environment ?? process.env;
|
|
58173
58317
|
for (const name5 of envNames)
|
|
58174
58318
|
if (environment[name5]) env[name5] = environment[name5];
|
|
58175
|
-
const
|
|
58319
|
+
const launch = () => (options.execute ?? child)(
|
|
58176
58320
|
process.execPath,
|
|
58177
58321
|
[join5(dir, "waitcher-run.mjs")],
|
|
58178
58322
|
{
|
|
@@ -58183,6 +58327,22 @@ try {
|
|
|
58183
58327
|
interruptGraceMs: options.interruptGraceMs
|
|
58184
58328
|
}
|
|
58185
58329
|
);
|
|
58330
|
+
let p = await launch();
|
|
58331
|
+
for (let pass = 0; options.localSnapshots && !dispatch && !requestDispatch && pass < SCRIPT_SCREENSHOT_LIMITS.files && !signal?.aborted; pass++) {
|
|
58332
|
+
let outcome;
|
|
58333
|
+
try {
|
|
58334
|
+
outcome = screenshotOutcome(
|
|
58335
|
+
JSON.parse(await readFile2(join5(dir, ".e2e", "report.json"), "utf8"))
|
|
58336
|
+
);
|
|
58337
|
+
} catch {
|
|
58338
|
+
}
|
|
58339
|
+
if (outcome?.kind !== "missing") break;
|
|
58340
|
+
const stored = join5(dir, "tests", SNAPSHOT_DIRECTORY);
|
|
58341
|
+
await mkdir2(stored, { recursive: true, mode: 448 });
|
|
58342
|
+
await copyFile(join5(dir, outcome.actual), join5(stored, outcome.file));
|
|
58343
|
+
await rm3(join5(dir, ".e2e"), { recursive: true, force: true });
|
|
58344
|
+
p = await launch();
|
|
58345
|
+
}
|
|
58186
58346
|
let report;
|
|
58187
58347
|
try {
|
|
58188
58348
|
const file2 = await open12(join5(dir, ".e2e", "report.json"), "r");
|
|
@@ -58335,6 +58495,16 @@ function identitySecretValues(identity) {
|
|
|
58335
58495
|
].filter((value2) => [...value2].length >= 6).flatMap((value2) => [value2, JSON.stringify(value2).slice(1, -1)]);
|
|
58336
58496
|
}
|
|
58337
58497
|
async function scriptCheck(m, dir, signal, options = {}) {
|
|
58498
|
+
if (m.type === "visual") {
|
|
58499
|
+
const { script, web } = visualTest(m.visual, m.timeout);
|
|
58500
|
+
const { visual: _, ...rest } = m;
|
|
58501
|
+
return scriptCheckInternal(
|
|
58502
|
+
{ ...rest, type: "browser", script },
|
|
58503
|
+
dir,
|
|
58504
|
+
signal,
|
|
58505
|
+
{ ...options, web }
|
|
58506
|
+
);
|
|
58507
|
+
}
|
|
58338
58508
|
const identity = options.browserIdentity === void 0 ? void 0 : browserExecutionIdentitySchema.parse(options.browserIdentity);
|
|
58339
58509
|
if (Boolean(m.browserIdentity) !== Boolean(identity) || identity && (m.type !== "browser" || m.browserIdentity?.identityId !== identity.identityId || m.browserIdentity.revision !== identity.revision || new URL(m.target).origin !== identity.origin || m.context?.projectId !== identity.projectId || m.context?.environmentId !== identity.environmentId))
|
|
58340
58510
|
throw Error(
|
|
@@ -58400,7 +58570,8 @@ async function execute(monitor, runDir, {
|
|
|
58400
58570
|
judgeComplete,
|
|
58401
58571
|
httpFetch,
|
|
58402
58572
|
httpCredential,
|
|
58403
|
-
browserIdentity
|
|
58573
|
+
browserIdentity,
|
|
58574
|
+
snapshots
|
|
58404
58575
|
} = {}) {
|
|
58405
58576
|
const start = performance4.now();
|
|
58406
58577
|
let result2;
|
|
@@ -58419,8 +58590,6 @@ async function execute(monitor, runDir, {
|
|
|
58419
58590
|
"AI execution requires a private model grant; no script was started"
|
|
58420
58591
|
);
|
|
58421
58592
|
await mkdir3(runDir, { recursive: true });
|
|
58422
|
-
if (monitor.type === "visual")
|
|
58423
|
-
throw Error("Visual checks require the leased scheduler adapter");
|
|
58424
58593
|
if (monitor.type === "ai")
|
|
58425
58594
|
result2 = await aiEndpointCheck(monitor, signal, {
|
|
58426
58595
|
fetch: aiEndpointFetch,
|
|
@@ -58466,7 +58635,8 @@ async function execute(monitor, runDir, {
|
|
|
58466
58635
|
result2 = await scriptCheck(monitor, runDir, signal, {
|
|
58467
58636
|
environment,
|
|
58468
58637
|
model,
|
|
58469
|
-
browserIdentity
|
|
58638
|
+
browserIdentity,
|
|
58639
|
+
...snapshots ? { snapshots } : {}
|
|
58470
58640
|
});
|
|
58471
58641
|
} catch (cause) {
|
|
58472
58642
|
const error62 = asError(cause);
|
|
@@ -59152,7 +59322,7 @@ function projectConfigJsonSchema() {
|
|
|
59152
59322
|
|
|
59153
59323
|
// src/local-models.ts
|
|
59154
59324
|
import { constants as constants11 } from "node:fs";
|
|
59155
|
-
import { open as open14, readFile as
|
|
59325
|
+
import { open as open14, readFile as readFile3 } from "node:fs/promises";
|
|
59156
59326
|
import { dirname as dirname7, resolve as resolve9 } from "node:path";
|
|
59157
59327
|
|
|
59158
59328
|
// src/models.ts
|
|
@@ -59302,7 +59472,7 @@ async function readLocalModelConnection(file2, monitor, binding = monitor.ai) {
|
|
|
59302
59472
|
async function localModelClientSource() {
|
|
59303
59473
|
for (const relative4 of ["./model-client.mjs", "../dist/model-client.mjs"]) {
|
|
59304
59474
|
try {
|
|
59305
|
-
return await
|
|
59475
|
+
return await readFile3(new URL(relative4, import.meta.url), "utf8");
|
|
59306
59476
|
} catch {
|
|
59307
59477
|
}
|
|
59308
59478
|
}
|
|
@@ -59750,7 +59920,7 @@ async function runtime(project, browser, ai = false) {
|
|
|
59750
59920
|
}
|
|
59751
59921
|
const root2 = dirname8(dirname8(entry2));
|
|
59752
59922
|
const metadata2 = JSON.parse(
|
|
59753
|
-
await
|
|
59923
|
+
await readFile4(join8(root2, "package.json"), "utf8")
|
|
59754
59924
|
);
|
|
59755
59925
|
if (metadata2.name !== name5 || (name5 in RUNTIME_PINS ? runtimePinStatus(name5, metadata2.version) === "mismatch" : metadata2.version !== version2))
|
|
59756
59926
|
invalid2(
|
|
@@ -59771,7 +59941,7 @@ async function inventory(root) {
|
|
|
59771
59941
|
if (item.isSymbolicLink() || item.name === "node_modules") continue;
|
|
59772
59942
|
if (item.isDirectory()) await walk(full);
|
|
59773
59943
|
else if (item.isFile()) {
|
|
59774
|
-
const bytes2 = await
|
|
59944
|
+
const bytes2 = await readFile4(full);
|
|
59775
59945
|
files.push({
|
|
59776
59946
|
path: relative(root, full).split(sep).join("/"),
|
|
59777
59947
|
bytes: bytes2.length,
|
|
@@ -60059,6 +60229,9 @@ async function runLocal(options) {
|
|
|
60059
60229
|
signal,
|
|
60060
60230
|
{
|
|
60061
60231
|
runtimeRoot: project,
|
|
60232
|
+
// Baselines are approved in Waitcher; locally a stored
|
|
60233
|
+
// screenshot is compared with a capture taken moments earlier.
|
|
60234
|
+
localSnapshots: true,
|
|
60062
60235
|
requestClientFile: join8(
|
|
60063
60236
|
directory,
|
|
60064
60237
|
"waitcher-request-runtime.mjs"
|
|
@@ -60138,7 +60311,7 @@ async function runLocal(options) {
|
|
|
60138
60311
|
const path2 = join8(directory, evidence, "report.json");
|
|
60139
60312
|
if ((await lstat7(path2)).size > STORAGE_LIMITS.artifactFileBytes)
|
|
60140
60313
|
throw Error("Local E2E report exceeds its 8 MiB budget");
|
|
60141
|
-
const report = JSON.parse(await
|
|
60314
|
+
const report = JSON.parse(await readFile4(path2, "utf8"));
|
|
60142
60315
|
const passed = result3.code === 0 && report.run?.status === "passed" && report.run.results?.length > 0 && report.run.results.every(
|
|
60143
60316
|
(r) => r.status === "passed"
|
|
60144
60317
|
);
|
|
@@ -60494,7 +60667,7 @@ async function runLocalCalibration(options) {
|
|
|
60494
60667
|
// src/bundle.ts
|
|
60495
60668
|
import { createRequire as createRequire2, isBuiltin } from "node:module";
|
|
60496
60669
|
import { createHash as createHash10 } from "node:crypto";
|
|
60497
|
-
import { readFile as
|
|
60670
|
+
import { readFile as readFile5, realpath as realpath2, mkdir as mkdir6, writeFile as writeFile6, rm as rm4 } from "node:fs/promises";
|
|
60498
60671
|
import { basename, dirname as dirname10, join as join10, relative as relative2, resolve as resolve12, sep as sep2, extname } from "node:path";
|
|
60499
60672
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
60500
60673
|
var sha = (bytes2) => createHash10("sha256").update(bytes2).digest("hex");
|
|
@@ -60527,7 +60700,7 @@ async function bundleMonitor(options) {
|
|
|
60527
60700
|
return name5.split(sep2).join("/");
|
|
60528
60701
|
}
|
|
60529
60702
|
projectPath(sourceManifest);
|
|
60530
|
-
const manifestText = await
|
|
60703
|
+
const manifestText = await readFile5(sourceManifest, "utf8");
|
|
60531
60704
|
let definition;
|
|
60532
60705
|
try {
|
|
60533
60706
|
definition = await readManifest(sourceManifest);
|
|
@@ -60536,7 +60709,7 @@ async function bundleMonitor(options) {
|
|
|
60536
60709
|
error62 instanceof Error ? error62.message : "Invalid source manifest."
|
|
60537
60710
|
);
|
|
60538
60711
|
}
|
|
60539
|
-
if (manifestText !== await
|
|
60712
|
+
if (manifestText !== await readFile5(sourceManifest, "utf8"))
|
|
60540
60713
|
invalid4(
|
|
60541
60714
|
"The source manifest changed during the build. Retry with stable inputs."
|
|
60542
60715
|
);
|
|
@@ -60634,7 +60807,7 @@ async function buildScript({
|
|
|
60634
60807
|
);
|
|
60635
60808
|
}
|
|
60636
60809
|
const toolMetadata = JSON.parse(
|
|
60637
|
-
await
|
|
60810
|
+
await readFile5(join10(dirname10(dirname10(tool)), "package.json"), "utf8")
|
|
60638
60811
|
);
|
|
60639
60812
|
if (toolMetadata.name !== "esbuild" || runtimePinStatus("esbuild", toolMetadata.version) === "mismatch")
|
|
60640
60813
|
invalid4(
|
|
@@ -60647,7 +60820,7 @@ async function buildScript({
|
|
|
60647
60820
|
const actual = await realpath2(path2), name5 = projectPath(actual);
|
|
60648
60821
|
if (inputs.size >= 64 && !inputs.has(name5))
|
|
60649
60822
|
invalid4("A portable monitor may bundle at most 64 source files.");
|
|
60650
|
-
const contents = await
|
|
60823
|
+
const contents = await readFile5(actual);
|
|
60651
60824
|
inputBytes += contents.length;
|
|
60652
60825
|
if (contents.length > 512e3 || inputBytes > 1024e3)
|
|
60653
60826
|
invalid4("Build inputs exceed the 1 MB source budget.");
|
|
@@ -60759,7 +60932,7 @@ async function buildScript({
|
|
|
60759
60932
|
let lock = null;
|
|
60760
60933
|
for (const name5 of ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"]) {
|
|
60761
60934
|
try {
|
|
60762
|
-
lock = { path: name5, sha256: sha(await
|
|
60935
|
+
lock = { path: name5, sha256: sha(await readFile5(join10(project, name5))) };
|
|
60763
60936
|
break;
|
|
60764
60937
|
} catch (error62) {
|
|
60765
60938
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -60781,7 +60954,7 @@ async function buildScript({
|
|
|
60781
60954
|
}
|
|
60782
60955
|
|
|
60783
60956
|
// src/config.ts
|
|
60784
|
-
import { readFile as
|
|
60957
|
+
import { readFile as readFile7, realpath as realpath3, mkdir as mkdir7, writeFile as writeFile8, rm as rm5 } from "node:fs/promises";
|
|
60785
60958
|
import { execFile } from "node:child_process";
|
|
60786
60959
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
60787
60960
|
import { dirname as dirname12, join as join12, resolve as resolve13 } from "node:path";
|
|
@@ -60789,7 +60962,7 @@ import { promisify } from "node:util";
|
|
|
60789
60962
|
|
|
60790
60963
|
// src/runtime.ts
|
|
60791
60964
|
import { spawn as spawn2 } from "node:child_process";
|
|
60792
|
-
import { access, readFile as
|
|
60965
|
+
import { access, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
60793
60966
|
import { createRequire as createRequire3 } from "node:module";
|
|
60794
60967
|
import { basename as basename2, dirname as dirname11, join as join11 } from "node:path";
|
|
60795
60968
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
@@ -60801,7 +60974,7 @@ async function installedPackage(project, name5) {
|
|
|
60801
60974
|
);
|
|
60802
60975
|
for (let i = 0; i < 6; i++, dir = dirname11(dir)) {
|
|
60803
60976
|
try {
|
|
60804
|
-
const meta3 = JSON.parse(await
|
|
60977
|
+
const meta3 = JSON.parse(await readFile6(join11(dir, "package.json"), "utf8"));
|
|
60805
60978
|
if (meta3.name === name5) return { dir, version: meta3.version };
|
|
60806
60979
|
} catch {
|
|
60807
60980
|
}
|
|
@@ -60881,7 +61054,7 @@ function run(command, args, cwd, signal) {
|
|
|
60881
61054
|
async function installRuntime(options) {
|
|
60882
61055
|
const { project, browser, yes, signal } = options;
|
|
60883
61056
|
const manifestPath = join11(project, "package.json");
|
|
60884
|
-
const text2 = await
|
|
61057
|
+
const text2 = await readFile6(manifestPath, "utf8").catch(() => null);
|
|
60885
61058
|
let existing = null;
|
|
60886
61059
|
if (text2 !== null)
|
|
60887
61060
|
try {
|
|
@@ -60902,7 +61075,7 @@ async function installRuntime(options) {
|
|
|
60902
61075
|
(name5) => runtimePinStatus(name5, installed[name5], {}) !== "current"
|
|
60903
61076
|
);
|
|
60904
61077
|
const ignorePath = join11(project, ".gitignore");
|
|
60905
|
-
const ignoreText = await
|
|
61078
|
+
const ignoreText = await readFile6(ignorePath, "utf8").catch(() => "");
|
|
60906
61079
|
const ignores = [];
|
|
60907
61080
|
for (const entry2 of missingIgnores(ignoreText))
|
|
60908
61081
|
if (!await gitIgnored(project, entry2)) ignores.push(entry2);
|
|
@@ -61107,7 +61280,7 @@ async function verifyLocally(options) {
|
|
|
61107
61280
|
const summary2 = join12(result2.directory, ".e2e", "summary.md");
|
|
61108
61281
|
let failure3;
|
|
61109
61282
|
if (result2.status !== "passed") {
|
|
61110
|
-
const lines = (await
|
|
61283
|
+
const lines = (await readFile7(summary2, "utf8").catch(() => "")).split("\n");
|
|
61111
61284
|
const test = lines.map((l) => /^\*\*🔴 (.+)\*\*/.exec(l.trim())?.[1]).find(Boolean);
|
|
61112
61285
|
const error62 = lines.find((l) => l.startsWith("> "))?.slice(2).trim();
|
|
61113
61286
|
if (error62) failure3 = `${test ? `"${test}": ` : ""}${error62}`.slice(0, 300);
|
|
@@ -61140,7 +61313,7 @@ async function readProjectConfig(file2) {
|
|
|
61140
61313
|
const path2 = configPath(file2);
|
|
61141
61314
|
let text2;
|
|
61142
61315
|
try {
|
|
61143
|
-
text2 = await
|
|
61316
|
+
text2 = await readFile7(path2, "utf8");
|
|
61144
61317
|
} catch {
|
|
61145
61318
|
throw new ServiceError(
|
|
61146
61319
|
`${path2} was not found. Run waitcher config init or pass --file.`,
|
|
@@ -61219,7 +61392,7 @@ function deployNextSteps(result2, {
|
|
|
61219
61392
|
);
|
|
61220
61393
|
else if (c.action === "create" && c.type === "visual" && !smoked)
|
|
61221
61394
|
steps.push(
|
|
61222
|
-
`waitcher run start --id ${c.monitorId} --wait
|
|
61395
|
+
`waitcher run start --id ${c.monitorId} --update-baselines --wait captures the first baseline; check it with waitcher visual list --monitor-id ${c.monitorId} and waitcher visual image, then waitcher monitor resume --id ${c.monitorId}`
|
|
61223
61396
|
);
|
|
61224
61397
|
else if (c.action === "create" && !c.enabled)
|
|
61225
61398
|
steps.push(
|
|
@@ -61245,13 +61418,13 @@ var deploy_default = '# Repository deploys\n\nRead when the user keeps monitors
|
|
|
61245
61418
|
var diagnosis_default = "# Diagnosing failures\n\nRead when a local, smoke or scheduled run failed or errored.\n\n## Diagnose and reproduce a retained run\n\nConfirm `features.runDiagnosis` for hosted support. Use `run diagnose --id RUN_ID` for a readable hosted packet, or add `--json` for the shared structured report. Use `run diagnose --directory PRIVATE_RUN_DIRECTORY` without an account to inspect indexed local evidence. Hosted request states come from the controller ledger; local helper observations are explicitly local and do not attest hosted accounting. A known response does not prove task success, and an unknown action may have taken effect. Do not automatically repeat a mutation because its result is unknown.\n\nA historical pass is useful only when the frozen verification policy matches. Changed scripts, targets, deadlines or protected-operation policies cannot supply a matching reference. History searches are bounded; unavailable or truncated history is not proof that the product never passed. Stored artifact checksums are metadata; inspect the actual artifact when needed. Scenario evidence is checked against its recorded checksum before display.\n\nFor a completed supported hosted script, `run reproduce --id RUN_ID --output NEW_DIRECTORY` prepares its frozen configuration in a new private folder. It never executes the test or retrieves the current edited monitor. Inspect `monitor.json` and `provenance.json`, then deliberately run `run local --file NEW_DIRECTORY/monitor.json --output FRESH_RUN_DIRECTORY` with the matching installed runtime, optionally `--runtime PROJECT`. Reproduction is a fresh run with separate provenance and does not replace the original evidence.\n\nManaged product credentials, AI keys and browser sessions are not exported. Supply existing private local mappings with `--http-credentials-file`, `--connections-file` and `--browser-identities-file` where required. Authored scripts and literal configuration can themselves be sensitive, so keep the reproduction private. Operator-injected headers, bodies or environment state make this initial portable preparation unavailable rather than silently changing the test. Older local runs without an indexed frozen manifest remain inspectable but cannot establish a captured reproduction policy.\n";
|
|
61246
61419
|
|
|
61247
61420
|
// ../../skills/waitcher/references/optional-capabilities.md
|
|
61248
|
-
var optional_capabilities_default = '# Optional capabilities\n\nRead only when capabilities report the feature and the user needs it: visual baselines, signed-in browser identities, verified HTTP credentials and invocation budgets. AI endpoints, agent outcome checks, model steps and protected requests are in [ai-and-agents](ai-and-agents.md).\n\n## Optional visual checks\n\nDiscover `features.visual` for authoring and `features.visualReview` for baseline inspection; `features.isolatedVisual` says personal captures run in the hosted runner. A visual monitor counts as one of the plan\'s script monitors and each capture as a script run; `limits.visual.minInterval` is the shortest interval (2 hours on the free plan, 30 minutes otherwise). In a repository, add a `waitcher.json` entry such as `{ "key": "home-look", "type": "visual", "path": "/" }` with an optional `visual` block (page/element checkpoint, viewport, readiness, masks, thresholds) and deploy it like any other monitor; with `--smoke` the first capture is reported as `baseline_review` with the commands that show and approve it. For one monitor outside a repository, start with `monitor init --type visual --target https://product.example --file visual.json`, then `monitor validate --file visual.json` and `monitor apply --file visual.json --dry-run`. Apply paused; an authorized `run start --id ID --wait` is a separate action. User guide: https://waitcher.dev/docs/visual.md. Visual monitors accept no script, model binding, session identity or custom request credential. Fixed visual baseline execution is not supported by `run local`; local API/browser script evidence does not establish a visual baseline.\n\nThe first capture needs baseline review; its `missing_baseline` result is missing coverage, not a product failure. Inspect `visual list`, `visual get --id COMPARISON_ID`, `visual heads --id MONITOR_ID`, `visual artifacts --id COMPARISON_ID` and `visual image --id COMPARISON_ID --role candidate|original|diff --file NEW_PRIVATE_PATH`. Review actual images and metrics before an authorized `visual approve --id COMPARISON_ID --expected-revision SELECTED_REVISION`; an initial selection uses 0. Restore only a reviewed retained baseline with `visual restore --id HEAD_ID --baseline-id BASELINE_ID --expected-revision CURRENT_HEAD_REVISION`. Stale decisions conflict: reload instead of retrying or changing revisions blindly. Approval preserves the historical result. Changed capture fingerprints need their own baseline. Foreign-owner/read-only refusals are boundaries, not reasons to switch credentials. Screenshots are private evidence; masks cover selected pixels only. Use actual `visual` and `run` help for current flags and capabilities.\n\n## Optional browser test-account identity\n\nFor a signed-in browser journey, discover hosted `features.browserIdentities` before configuring `identity create/rotate/enable/disable/delete`. Supply bounded cookies/localStorage through a private `--state-file`; metadata is scoped to one verified exact origin, project/environment and explicit expiry. State is write-only and cannot be exported. New identities default disabled; enable explicitly and bind the resulting current `{identityId, revision}` under `browserIdentity` in a version-2 browser manifest with explicit context. Rename, state replacement and enable/disable advance revisions; inspect current metadata and deliberately rebind rather than silently upgrading. After an uncertain write inspect metadata before retrying. No running Chrome profile is imported.\n\nRun the same manifest account-free with `run local --file MONITOR --runtime RUNTIME --browser-identities-file PRIVATE_MAP`. The map is `{schemaVersion:1,identities:[{identityId,revision,projectId,environmentId,origin,expiresAt,stateFile}]}`; state paths resolve relative to the map. Both map/state are private regular JSON files (chmod 600), no symlinks/hard links or inline state. Exact IDs/revision/scope/origin and bounded future expiry must match. Local mappings do not attest hosted target verification or revocation. The optional model map remains separate. Hosted identity-backed runs use the isolated lane for all owners; local code remains trusted. The selected script receives its own session and signed-in page content can reach private evidence or optional AI providers. Never promise pixel/encoded-secret masking. Use dedicated test accounts and inspect coverage errors after expiry/revocation before repeating a possibly completed action.\n\n## Verified HTTP credentials\n\nFor an authenticated HTTP or AI endpoint, use the user\'s owned verified HTTPS origin and an `httpAuth` reference (`targetId`, `credentialId`, `credentialRevision`). Check `features.httpTargets` before hosted configuration. Create/renew a target challenge with `target create` or `target challenge`, writing it to a new private `--output`; never print the token. The user publishes the supplied proof at `/.well-known/waitcher-verification.txt`, then `target verify` checks it without credentials. Verification expires after 24 hours and must be renewed. An origin excludes paths, query and fragments and is immutable.\n\nUse `target credential create/rotate` with non-secret metadata JSON plus `--credential-file` (mode 600) or `--credential-stdin`. Headers are limited to `Authorization` or `X-Api-Key`; values are complete single-line ASCII header values up to 4096 bytes. For Bearer auth, include the `Bearer ` prefix in the private value. Keys are write-only and encrypted on the server. The monitor and export retain references only. Rotation advances the credential revision; update the monitor binding explicitly. Disabled, expired, foreign or stale bindings fail without forwarding a request. Authenticated redirects are never followed.\n\nFor local execution without the app or account, pass `run local --file monitor.json --http-credentials-file private/http-map.json`. The private map is `{schemaVersion:1,credentials:[{targetId,credentialId,credentialRevision,origin,header,credentialFile}]}` and the referenced private file contains the raw header value. Paths resolve relative to the map. Never inline a key or reuse the CLI\'s own account cookie/token as a target credential. The local resolver requires exactly matching IDs, revision and canonical origin, and the shared runner enforces the single supported header and redirect policy. Local mapping does not prove that the hosted target is still verified or its key current. Keep the same manifest as the hosted monitor; only local key resolution differs. HTTP local checks need no E2E runtime. Use explicit user authorization for POST fixtures that change state.\n\n## Hosted endpoint invocation budgets\n\nBefore running dedicated AI endpoints or HTTP checks with `httpAuth`, read `account invocations` for the account/monitor UTC-day counters and limits. The manifest accepts `requestBudget: {dailyInvocations: N}` (default 50, maximum 1,000). Configure the owner cap with `account budget --daily-invocations N --expected-revision CURRENT_REVISION` only when authorized; personal accounts cap at 200, administrators at 5,000, and the controller also has a global 5,000 cap. Validate/apply/export do not charge calls.\n\n`INVOCATION_BUDGET_EXHAUSTED` is a coverage error: no request was dispatched and no product incident is created. Do not automatically retry or raise a limit to bypass it. Completed and uncertain dispatched calls consume budget, independent of product success or worker-reported usage. Local execution needs no account, preserves the setting and makes at most one endpoint call per fixture case, but does not enforce or consume the hosted daily ledger. After backup restore, `window.restoreHeld` blocks these checks until the next UTC reset because snapshot counters may be stale; do not bypass the hold by raising caps. These are request counts, separate from model-broker token/call caps and downstream provider spending. Inspect `account invocations` and the current `account` help for the hosted accounting contract.\n\n## Agent checks\n\nWhen `features.agentChecks` is true, an `api` entry may carry an `agent` block: Claude Code works on `task` in a sandbox, then the entry\'s script verifies the product\'s state ([guide](https://waitcher.dev/docs/agent-checks.md)). It needs a model connection in the entry\'s project environment (`connection create`, OpenRouter, the key from a private file) and fields `connectionId`, `configurationRevision`, `model`, `task`, optionally `seconds`, `turns`, `tokens`, `hosts` and `envNames` (a subset of `settings.envNames`). Read `limits.agentChecks` for the plan\'s count and bounds; the interval is at least 6 hours. Write the task as a user would say it and never put a secret in it. The verifier must reset the test account it checks. Ask before creating a connection: it stores the user\'s key and every run is billed to it.\n';
|
|
61421
|
+
var optional_capabilities_default = '# Optional capabilities\n\nRead only when capabilities report the feature and the user needs it: visual baselines, signed-in browser identities, verified HTTP credentials and invocation budgets. AI endpoints, agent outcome checks, model steps and protected requests are in [ai-and-agents](ai-and-agents.md).\n\n## Optional visual checks\n\nDiscover `features.visual` for authoring and `features.visualReview` for baseline inspection; `features.isolatedVisual` says personal captures run in the hosted runner. A visual monitor counts as one of the plan\'s script monitors and each capture as a script run; `limits.visual.minInterval` is the shortest interval (2 hours on the free plan, 30 minutes otherwise). In a repository, add a `waitcher.json` entry such as `{ "key": "home-look", "type": "visual", "path": "/" }` with an optional `visual` block (page/element checkpoint, viewport, readiness, masks, thresholds) and deploy it like any other monitor; with `--smoke` the first capture is reported as `baseline_review` with the commands that show and approve it. For one monitor outside a repository, start with `monitor init --type visual --target https://product.example --file visual.json`, then `monitor validate --file visual.json` and `monitor apply --file visual.json --dry-run`. Apply paused; an authorized `run start --id ID --wait` is a separate action. User guide: https://waitcher.dev/docs/visual.md.\n\nFor a screen behind a sign-in or a few clicks, assert it inside a `browser` test instead: `await expect(screen).toHaveScreenshot(\'dashboard.png\')` (options `threshold`, `maxDiffPixels`, `maxDiffPixelRatio`, `mask`). Do not commit snapshot PNGs or pass `--update-snapshots`: Waitcher keeps the baselines. The first hosted run of each screenshot ends as `error` "First capture of NAME: approve it as the baseline"; inspect it with `visual list --monitor-id ID` and `visual image`, then `visual approve --id COMPARISON_ID --expected-revision 0`, one screenshot per run. Later runs fail with a comparison when a screenshot differs. Local runs (`run local`, `--verify`) compare against a capture from the same run, so a local pass says nothing about the look. Visual monitors accept no script, model binding, session identity or custom request credential. Fixed visual baseline execution is not supported by `run local`; local API/browser script evidence does not establish a visual baseline.\n\nA scheduled run never creates a baseline. Set the first one, or accept an intended change, with one run: `run start --id MONITOR_ID --update-baselines --wait` captures and approves it (write access); then inspect it with `visual list` and `visual image`. The alternative is to run normally and approve the capture. Until a baseline exists a run ends as `error` "First capture of NAME"; that is missing coverage, not a product failure. Every later run of a visual monitor keeps its comparison, passing runs included. Inspect `visual list`, `visual get --id COMPARISON_ID`, `visual heads --id MONITOR_ID`, `visual artifacts --id COMPARISON_ID` and `visual image --id COMPARISON_ID --role candidate|original|diff --file NEW_PRIVATE_PATH`. Review actual images and metrics before an authorized `visual approve --id COMPARISON_ID --expected-revision SELECTED_REVISION`; an initial selection uses 0. Restore only a reviewed retained baseline with `visual restore --id HEAD_ID --baseline-id BASELINE_ID --expected-revision CURRENT_HEAD_REVISION`. Stale decisions conflict: reload instead of retrying or changing revisions blindly. Approval preserves the historical result. Changed capture fingerprints need their own baseline. Foreign-owner/read-only refusals are boundaries, not reasons to switch credentials. Screenshots are private evidence; masks cover selected pixels only. Use actual `visual` and `run` help for current flags and capabilities.\n\n## Optional browser test-account identity\n\nFor a signed-in browser journey, discover hosted `features.browserIdentities` before configuring `identity create/rotate/enable/disable/delete`. Supply bounded cookies/localStorage through a private `--state-file`; metadata is scoped to one verified exact origin, project/environment and explicit expiry. State is write-only and cannot be exported. New identities default disabled; enable explicitly and bind the resulting current `{identityId, revision}` under `browserIdentity` in a version-2 browser manifest with explicit context. Rename, state replacement and enable/disable advance revisions; inspect current metadata and deliberately rebind rather than silently upgrading. After an uncertain write inspect metadata before retrying. No running Chrome profile is imported.\n\nRun the same manifest account-free with `run local --file MONITOR --runtime RUNTIME --browser-identities-file PRIVATE_MAP`. The map is `{schemaVersion:1,identities:[{identityId,revision,projectId,environmentId,origin,expiresAt,stateFile}]}`; state paths resolve relative to the map. Both map/state are private regular JSON files (chmod 600), no symlinks/hard links or inline state. Exact IDs/revision/scope/origin and bounded future expiry must match. Local mappings do not attest hosted target verification or revocation. The optional model map remains separate. Hosted identity-backed runs use the isolated lane for all owners; local code remains trusted. The selected script receives its own session and signed-in page content can reach private evidence or optional AI providers. Never promise pixel/encoded-secret masking. Use dedicated test accounts and inspect coverage errors after expiry/revocation before repeating a possibly completed action.\n\n## Verified HTTP credentials\n\nFor an authenticated HTTP or AI endpoint, use the user\'s owned verified HTTPS origin and an `httpAuth` reference (`targetId`, `credentialId`, `credentialRevision`). Check `features.httpTargets` before hosted configuration. Create/renew a target challenge with `target create` or `target challenge`, writing it to a new private `--output`; never print the token. The user publishes the supplied proof at `/.well-known/waitcher-verification.txt`, then `target verify` checks it without credentials. Verification expires after 24 hours and must be renewed. An origin excludes paths, query and fragments and is immutable.\n\nUse `target credential create/rotate` with non-secret metadata JSON plus `--credential-file` (mode 600) or `--credential-stdin`. Headers are limited to `Authorization` or `X-Api-Key`; values are complete single-line ASCII header values up to 4096 bytes. For Bearer auth, include the `Bearer ` prefix in the private value. Keys are write-only and encrypted on the server. The monitor and export retain references only. Rotation advances the credential revision; update the monitor binding explicitly. Disabled, expired, foreign or stale bindings fail without forwarding a request. Authenticated redirects are never followed.\n\nFor local execution without the app or account, pass `run local --file monitor.json --http-credentials-file private/http-map.json`. The private map is `{schemaVersion:1,credentials:[{targetId,credentialId,credentialRevision,origin,header,credentialFile}]}` and the referenced private file contains the raw header value. Paths resolve relative to the map. Never inline a key or reuse the CLI\'s own account cookie/token as a target credential. The local resolver requires exactly matching IDs, revision and canonical origin, and the shared runner enforces the single supported header and redirect policy. Local mapping does not prove that the hosted target is still verified or its key current. Keep the same manifest as the hosted monitor; only local key resolution differs. HTTP local checks need no E2E runtime. Use explicit user authorization for POST fixtures that change state.\n\n## Hosted endpoint invocation budgets\n\nBefore running dedicated AI endpoints or HTTP checks with `httpAuth`, read `account invocations` for the account/monitor UTC-day counters and limits. The manifest accepts `requestBudget: {dailyInvocations: N}` (default 50, maximum 1,000). Configure the owner cap with `account budget --daily-invocations N --expected-revision CURRENT_REVISION` only when authorized; personal accounts cap at 200, administrators at 5,000, and the controller also has a global 5,000 cap. Validate/apply/export do not charge calls.\n\n`INVOCATION_BUDGET_EXHAUSTED` is a coverage error: no request was dispatched and no product incident is created. Do not automatically retry or raise a limit to bypass it. Completed and uncertain dispatched calls consume budget, independent of product success or worker-reported usage. Local execution needs no account, preserves the setting and makes at most one endpoint call per fixture case, but does not enforce or consume the hosted daily ledger. After backup restore, `window.restoreHeld` blocks these checks until the next UTC reset because snapshot counters may be stale; do not bypass the hold by raising caps. These are request counts, separate from model-broker token/call caps and downstream provider spending. Inspect `account invocations` and the current `account` help for the hosted accounting contract.\n\n## Agent checks\n\nWhen `features.agentChecks` is true, an `api` entry may carry an `agent` block: Claude Code works on `task` in a sandbox, then the entry\'s script verifies the product\'s state ([guide](https://waitcher.dev/docs/agent-checks.md)). It needs a model connection in the entry\'s project environment (`connection create`, OpenRouter, the key from a private file) and fields `connectionId`, `configurationRevision`, `model`, `task`, optionally `seconds`, `turns`, `tokens`, `hosts` and `envNames` (a subset of `settings.envNames`). Read `limits.agentChecks` for the plan\'s count and bounds; the interval is at least 6 hours. Write the task as a user would say it and never put a secret in it. The verifier must reset the test account it checks. Ask before creating a connection: it stores the user\'s key and every run is billed to it.\n';
|
|
61249
61422
|
|
|
61250
61423
|
// ../../skills/waitcher/agents/openai.yaml
|
|
61251
61424
|
var openai_default = 'interface:\n display_name: "Waitcher"\n short_description: "Deploy monitoring from a repository and inspect evidence"\n default_prompt: "Use $waitcher to set up monitoring for this repository: pick the critical journeys, verify them locally and deploy them paused through a reviewed plan."\n';
|
|
61252
61425
|
|
|
61253
61426
|
// src/skill.ts
|
|
61254
|
-
import { lstat as lstat9, mkdir as mkdir8, readFile as
|
|
61427
|
+
import { lstat as lstat9, mkdir as mkdir8, readFile as readFile8, rm as rm6, writeFile as writeFile9 } from "node:fs/promises";
|
|
61255
61428
|
import { homedir } from "node:os";
|
|
61256
61429
|
import { join as join13, resolve as resolve14 } from "node:path";
|
|
61257
61430
|
var references = {
|
|
@@ -61273,7 +61446,7 @@ async function installSkill(options) {
|
|
|
61273
61446
|
const existing = await lstat9(directory).catch(() => null);
|
|
61274
61447
|
let previousVersion = null;
|
|
61275
61448
|
if (existing) {
|
|
61276
|
-
const marker2 = existing.isDirectory() ? await
|
|
61449
|
+
const marker2 = existing.isDirectory() ? await readFile8(join13(directory, MARKER), "utf8").catch(() => null) : null;
|
|
61277
61450
|
if (marker2 === null)
|
|
61278
61451
|
throw new SkillInstallError(
|
|
61279
61452
|
`${directory} exists and was not installed by waitcher. Remove it or choose another --path.`
|
|
@@ -61311,7 +61484,7 @@ async function installSkill(options) {
|
|
|
61311
61484
|
}
|
|
61312
61485
|
|
|
61313
61486
|
// src/doctor.ts
|
|
61314
|
-
import { access as access2, readFile as
|
|
61487
|
+
import { access as access2, readFile as readFile9 } from "node:fs/promises";
|
|
61315
61488
|
import { homedir as homedir2 } from "node:os";
|
|
61316
61489
|
import { dirname as dirname13, join as join14 } from "node:path";
|
|
61317
61490
|
var exists = (path2) => access2(path2).then(
|
|
@@ -61410,7 +61583,7 @@ async function doctor(options) {
|
|
|
61410
61583
|
for (const home of skillHomes) {
|
|
61411
61584
|
if (!await exists(join14(home, "SKILL.md"))) continue;
|
|
61412
61585
|
installed.push(home);
|
|
61413
|
-
const marker2 = await
|
|
61586
|
+
const marker2 = await readFile9(join14(home, ".waitcher-skill.json"), "utf8").then((text2) => JSON.parse(text2)).catch(() => null);
|
|
61414
61587
|
if (marker2 && marker2.version !== options.version) stale.push(home);
|
|
61415
61588
|
}
|
|
61416
61589
|
const install = root === process.cwd() ? "waitcher skill install" : `waitcher skill install --path ${join14(root, ".claude", "skills")}`;
|
|
@@ -61607,7 +61780,7 @@ jobs:
|
|
|
61607
61780
|
}
|
|
61608
61781
|
|
|
61609
61782
|
// src/main.ts
|
|
61610
|
-
import { readFile as
|
|
61783
|
+
import { readFile as readFile11, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
|
|
61611
61784
|
import { basename as basename3, dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
|
|
61612
61785
|
import { constants as constants13 } from "node:fs";
|
|
61613
61786
|
|
|
@@ -61811,7 +61984,7 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
61811
61984
|
import { createHash as createHash11, randomUUID as randomUUID7 } from "node:crypto";
|
|
61812
61985
|
import { homedir as homedir3 } from "node:os";
|
|
61813
61986
|
import { dirname as dirname16, join as join15 } from "node:path";
|
|
61814
|
-
import { mkdir as mkdir10, lstat as lstat11, open as open17, readFile as
|
|
61987
|
+
import { mkdir as mkdir10, lstat as lstat11, open as open17, readFile as readFile10, rename, unlink as unlink4 } from "node:fs/promises";
|
|
61815
61988
|
function serverUrl(value2) {
|
|
61816
61989
|
let url3;
|
|
61817
61990
|
try {
|
|
@@ -61844,7 +62017,7 @@ async function privatePath(path2, directory = false) {
|
|
|
61844
62017
|
}
|
|
61845
62018
|
async function readPrivate(path2) {
|
|
61846
62019
|
await privatePath(path2);
|
|
61847
|
-
return
|
|
62020
|
+
return readFile10(path2, "utf8");
|
|
61848
62021
|
}
|
|
61849
62022
|
async function loadSession(server) {
|
|
61850
62023
|
const path2 = sessionPath(server);
|
|
@@ -62362,9 +62535,12 @@ Executions and reports
|
|
|
62362
62535
|
Run trusted local tests without login or API access
|
|
62363
62536
|
JSON/report/logs/traces; video opt-in, fresh output per run
|
|
62364
62537
|
Project output must stay inside the E2E project
|
|
62365
|
-
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60]
|
|
62538
|
+
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60] [--update-baselines]
|
|
62366
62539
|
A finished run prints status, duration and message first;
|
|
62367
62540
|
--brief leaves out the execution record
|
|
62541
|
+
--update-baselines (visual checks, browser tests; write
|
|
62542
|
+
access): the run adopts what it captures as the approved
|
|
62543
|
+
baseline, for a first reference or an intended change
|
|
62368
62544
|
artifact get --id RUN_ID --path PATH --file OUTPUT
|
|
62369
62545
|
Download checksum-verified evidence; no overwrite
|
|
62370
62546
|
run status --id RUN_ID
|
|
@@ -62377,7 +62553,9 @@ Executions and reports
|
|
|
62377
62553
|
|
|
62378
62554
|
Visual checks and baseline review (features.visual, features.visualReview; decisions
|
|
62379
62555
|
require write access). A visual monitor screenshots one page or element and compares it
|
|
62380
|
-
with the baseline you approved; it counts as a script monitor of the plan.
|
|
62556
|
+
with the baseline you approved; it counts as a script monitor of the plan. A browser test's
|
|
62557
|
+
expect(screen).toHaveScreenshot('name.png') is reviewed the same way: the first hosted run
|
|
62558
|
+
of each screenshot waits for visual approve, later runs compare. Commit no snapshot files.
|
|
62381
62559
|
visual list [--monitor-id ID] [--head-id HEAD] [--before CURSOR]
|
|
62382
62560
|
visual get --id COMPARISON_ID
|
|
62383
62561
|
visual artifacts --id COMPARISON_ID
|
|
@@ -62679,7 +62857,7 @@ ${exitCodes}
|
|
|
62679
62857
|
// package.json
|
|
62680
62858
|
var package_default = {
|
|
62681
62859
|
name: "@waitcher/cli",
|
|
62682
|
-
version: "0.2.
|
|
62860
|
+
version: "0.2.16",
|
|
62683
62861
|
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
|
|
62684
62862
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
62685
62863
|
author: "S\u0142awomir Radzymi\u0144ski",
|
|
@@ -62882,6 +63060,7 @@ async function main() {
|
|
|
62882
63060
|
global: { type: "boolean" },
|
|
62883
63061
|
wait: { type: "boolean" },
|
|
62884
63062
|
brief: { type: "boolean" },
|
|
63063
|
+
"update-baselines": { type: "boolean" },
|
|
62885
63064
|
timeout: { type: "string" },
|
|
62886
63065
|
days: { type: "string" },
|
|
62887
63066
|
demo: { type: "boolean" },
|
|
@@ -63103,7 +63282,14 @@ async function main() {
|
|
|
63103
63282
|
"monitor pause": ["id"],
|
|
63104
63283
|
"monitor resume": ["id"],
|
|
63105
63284
|
"monitor delete": ["id", "yes"],
|
|
63106
|
-
"run start": [
|
|
63285
|
+
"run start": [
|
|
63286
|
+
"id",
|
|
63287
|
+
"wait",
|
|
63288
|
+
"timeout",
|
|
63289
|
+
"request-key",
|
|
63290
|
+
"brief",
|
|
63291
|
+
"update-baselines"
|
|
63292
|
+
],
|
|
63107
63293
|
"run local": [
|
|
63108
63294
|
"file",
|
|
63109
63295
|
"project",
|
|
@@ -64501,7 +64687,7 @@ async function main() {
|
|
|
64501
64687
|
usage2(
|
|
64502
64688
|
"Provide --file PATH with the complete configuration and expectedRevision for edits."
|
|
64503
64689
|
);
|
|
64504
|
-
const text2 = await
|
|
64690
|
+
const text2 = await readFile11(v.file, "utf8");
|
|
64505
64691
|
if (Buffer.byteLength(text2) > 16e3)
|
|
64506
64692
|
usage2("Project configuration exceeds 16 KB");
|
|
64507
64693
|
let body2;
|
|
@@ -64590,7 +64776,12 @@ async function main() {
|
|
|
64590
64776
|
if (!["create", "adopt", "update"].includes(c.action) || c.type === "heartbeat")
|
|
64591
64777
|
continue;
|
|
64592
64778
|
if (limited) {
|
|
64593
|
-
smoke.push({
|
|
64779
|
+
smoke.push({
|
|
64780
|
+
key: c.key,
|
|
64781
|
+
monitorId: c.monitorId,
|
|
64782
|
+
status: "skipped",
|
|
64783
|
+
message: limited
|
|
64784
|
+
});
|
|
64594
64785
|
continue;
|
|
64595
64786
|
}
|
|
64596
64787
|
try {
|
|
@@ -64614,7 +64805,8 @@ async function main() {
|
|
|
64614
64805
|
});
|
|
64615
64806
|
} catch (cause) {
|
|
64616
64807
|
const error62 = asError(cause);
|
|
64617
|
-
if (error62.code === "RATE_LIMITED")
|
|
64808
|
+
if (error62.code === "RATE_LIMITED")
|
|
64809
|
+
limited = `RATE_LIMITED: ${error62.message}`;
|
|
64618
64810
|
smoke.push({
|
|
64619
64811
|
key: c.key,
|
|
64620
64812
|
monitorId: c.monitorId,
|
|
@@ -64644,7 +64836,7 @@ async function main() {
|
|
|
64644
64836
|
adopt
|
|
64645
64837
|
}),
|
|
64646
64838
|
...smoke.filter((r) => r.status !== "passed").map(
|
|
64647
|
-
(r) => r.comparisonId ? `waitcher visual image --id ${r.comparisonId} --role candidate --file ${r.key}.png shows the first capture of ${r.key}; waitcher visual approve --id ${r.comparisonId} --expected-revision 0 makes it the baseline` : r.runId ? `waitcher run diagnose --id ${r.runId} explains the hosted ${r.status} of ${r.key}` : r.status === "skipped" ? `Hosted smoke for ${r.key} was skipped (${r.message}); it runs on its schedule once enabled, or try waitcher run start --id ${r.monitorId} --wait later` : `Hosted smoke for ${r.key} did not start: ${r.message}`
|
|
64839
|
+
(r) => r.comparisonId ? `waitcher visual image --id ${r.comparisonId} --role candidate --file ${r.key}.png shows the first capture of ${r.key}; waitcher visual approve --id ${r.comparisonId} --expected-revision 0 makes it the baseline (or waitcher run start --id ${r.monitorId} --update-baselines --wait captures and approves a fresh one)` : r.runId ? `waitcher run diagnose --id ${r.runId} explains the hosted ${r.status} of ${r.key}` : r.status === "skipped" ? `Hosted smoke for ${r.key} was skipped (${r.message}); it runs on its schedule once enabled, or try waitcher run start --id ${r.monitorId} --wait later` : `Hosted smoke for ${r.key} did not start: ${r.message}`
|
|
64648
64840
|
)
|
|
64649
64841
|
]
|
|
64650
64842
|
};
|
|
@@ -64745,7 +64937,7 @@ async function main() {
|
|
|
64745
64937
|
if (!v.file) usage2("Provide --file PATH for the configuration.");
|
|
64746
64938
|
let input2;
|
|
64747
64939
|
try {
|
|
64748
|
-
const text2 = await
|
|
64940
|
+
const text2 = await readFile11(v.file, "utf8");
|
|
64749
64941
|
if (Buffer.byteLength(text2) > 96e3)
|
|
64750
64942
|
usage2("Configuration exceeds 96 KB.");
|
|
64751
64943
|
input2 = JSON.parse(text2);
|
|
@@ -65029,7 +65221,14 @@ async function main() {
|
|
|
65029
65221
|
if (v.timeout && command === "run start" && !v.wait)
|
|
65030
65222
|
usage2("--timeout requires --wait with run start.");
|
|
65031
65223
|
const seconds = integer2(v.timeout ?? "60", "timeout", 1, 900);
|
|
65032
|
-
const queued = command === "run start" ?
|
|
65224
|
+
const queued = command === "run start" ? (
|
|
65225
|
+
// --update-baselines: the run adopts what it captures as the
|
|
65226
|
+
// approved baseline instead of comparing against it.
|
|
65227
|
+
await api(
|
|
65228
|
+
`monitors/${id3(v.id)}/${v["update-baselines"] ? "baselines" : "run"}`,
|
|
65229
|
+
{ method: "POST", body: {} }
|
|
65230
|
+
)
|
|
65231
|
+
) : { id: decodeURIComponent(id3(v.id)) };
|
|
65033
65232
|
if (command === "run start" && !v.wait)
|
|
65034
65233
|
result2 = { event: "queued", ...queued };
|
|
65035
65234
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waitcher/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Sławomir Radzymiński",
|