@waitcher/cli 0.2.14 → 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/README.md +7 -1
- package/dist/cli.mjs +275 -57
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,6 +28,12 @@ waitcher runtime install --yes
|
|
|
28
28
|
waitcher deploy plan --env production --verify
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
To watch how a page looks, add a visual entry: Waitcher screenshots the page on a schedule and compares it with the capture you approved ([visual checks](https://waitcher.dev/docs/visual)).
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{ "key": "home-look", "type": "visual", "path": "/" }
|
|
35
|
+
```
|
|
36
|
+
|
|
31
37
|
## Coding agents
|
|
32
38
|
|
|
33
39
|
```sh
|
|
@@ -40,6 +46,6 @@ installs the Waitcher skill where Claude Code and other agents look for it. `wai
|
|
|
40
46
|
|
|
41
47
|
- Guide: https://waitcher.dev/docs/
|
|
42
48
|
- For agents: https://waitcher.dev/llms.txt
|
|
43
|
-
- Free accounts get
|
|
49
|
+
- Free accounts get 5 monitors every 30 minutes, one of them an API or browser test or a visual check every 2 hours.
|
|
44
50
|
|
|
45
51
|
Every command prints JSON. Help and `--version` work offline.
|
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({
|
|
@@ -53432,7 +53463,7 @@ var monitorSchema = external_exports.object({
|
|
|
53432
53463
|
if (!m.visual) issue3("Visual capture settings are required", "visual");
|
|
53433
53464
|
if (m.interval < 1800)
|
|
53434
53465
|
issue3(
|
|
53435
|
-
"Visual
|
|
53466
|
+
"Visual checks run at most once every 30 minutes",
|
|
53436
53467
|
"interval"
|
|
53437
53468
|
);
|
|
53438
53469
|
if (m.timeout > 60 || m.visual && m.timeout * 1e3 < m.visual.captureBudgetMs + 5e3)
|
|
@@ -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);
|
|
@@ -58552,8 +58722,8 @@ var entries = {
|
|
|
58552
58722
|
},
|
|
58553
58723
|
TYPE_NOT_SUPPORTED: {
|
|
58554
58724
|
title: "Monitor type cannot be deployed",
|
|
58555
|
-
meaning: "
|
|
58556
|
-
fix: "Deploys accept http, certificate, heartbeat, api and
|
|
58725
|
+
meaning: "AI monitors are not part of waitcher.json yet.",
|
|
58726
|
+
fix: "Deploys accept http, certificate, heartbeat, api, browser and visual monitors. Keep AI checks on monitor apply for now."
|
|
58557
58727
|
},
|
|
58558
58728
|
ENTRY_REQUIRED: {
|
|
58559
58729
|
title: "Script monitor without a test file",
|
|
@@ -58863,7 +59033,8 @@ var DEPLOY_TYPES = [
|
|
|
58863
59033
|
"http",
|
|
58864
59034
|
"certificate",
|
|
58865
59035
|
"heartbeat",
|
|
58866
|
-
...SCRIPT_TYPES
|
|
59036
|
+
...SCRIPT_TYPES,
|
|
59037
|
+
"visual"
|
|
58867
59038
|
];
|
|
58868
59039
|
var isScriptType = (type) => SCRIPT_TYPES.includes(type);
|
|
58869
59040
|
var MONITOR_KEY = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
@@ -59020,13 +59191,20 @@ function resolveProjectConfig(input2, environment, scripts) {
|
|
|
59020
59191
|
if (rest.type === "heartbeat") target = key;
|
|
59021
59192
|
else if (rest.type === "certificate" && baseUrl)
|
|
59022
59193
|
target = `${new URL(baseUrl).origin}/`;
|
|
59023
|
-
else if (script && baseUrl) target = baseUrl;
|
|
59194
|
+
else if ((script || rest.type === "visual") && baseUrl) target = baseUrl;
|
|
59024
59195
|
else
|
|
59025
59196
|
return fail2("TARGET_REQUIRED", "A target is required", `${at}.target`, key);
|
|
59026
59197
|
}
|
|
59027
59198
|
const definition = monitorDefinitionSchema.safeParse({
|
|
59028
59199
|
name: key,
|
|
59029
59200
|
...config2.defaults,
|
|
59201
|
+
// A capture runs at most every 30 minutes and needs time for its
|
|
59202
|
+
// budget; shorter project defaults do not apply to it.
|
|
59203
|
+
...rest.type === "visual" ? {
|
|
59204
|
+
interval: Math.max(1800, config2.defaults?.interval ?? 1800),
|
|
59205
|
+
timeout: 45,
|
|
59206
|
+
visual: {}
|
|
59207
|
+
} : {},
|
|
59030
59208
|
...rest,
|
|
59031
59209
|
target,
|
|
59032
59210
|
...script ? { script: scripts?.[key] ?? "// built at deploy" } : {},
|
|
@@ -59099,7 +59277,7 @@ function projectConfigJsonSchema() {
|
|
|
59099
59277
|
const { $schema: _, ...config2 } = external_exports.toJSONSchema(projectConfigSchema, io);
|
|
59100
59278
|
const monitor = external_exports.toJSONSchema(monitorDefinitionSchema, io);
|
|
59101
59279
|
const properties = { ...monitor.properties };
|
|
59102
|
-
for (const field of ["demo", "enabled", "script", "schemaVersion", "context", "
|
|
59280
|
+
for (const field of ["demo", "enabled", "script", "schemaVersion", "context", "ai", "aiEndpoint"])
|
|
59103
59281
|
delete properties[field];
|
|
59104
59282
|
Object.assign(properties, {
|
|
59105
59283
|
key: {
|
|
@@ -59144,7 +59322,7 @@ function projectConfigJsonSchema() {
|
|
|
59144
59322
|
|
|
59145
59323
|
// src/local-models.ts
|
|
59146
59324
|
import { constants as constants11 } from "node:fs";
|
|
59147
|
-
import { open as open14, readFile as
|
|
59325
|
+
import { open as open14, readFile as readFile3 } from "node:fs/promises";
|
|
59148
59326
|
import { dirname as dirname7, resolve as resolve9 } from "node:path";
|
|
59149
59327
|
|
|
59150
59328
|
// src/models.ts
|
|
@@ -59294,7 +59472,7 @@ async function readLocalModelConnection(file2, monitor, binding = monitor.ai) {
|
|
|
59294
59472
|
async function localModelClientSource() {
|
|
59295
59473
|
for (const relative4 of ["./model-client.mjs", "../dist/model-client.mjs"]) {
|
|
59296
59474
|
try {
|
|
59297
|
-
return await
|
|
59475
|
+
return await readFile3(new URL(relative4, import.meta.url), "utf8");
|
|
59298
59476
|
} catch {
|
|
59299
59477
|
}
|
|
59300
59478
|
}
|
|
@@ -59742,7 +59920,7 @@ async function runtime(project, browser, ai = false) {
|
|
|
59742
59920
|
}
|
|
59743
59921
|
const root2 = dirname8(dirname8(entry2));
|
|
59744
59922
|
const metadata2 = JSON.parse(
|
|
59745
|
-
await
|
|
59923
|
+
await readFile4(join8(root2, "package.json"), "utf8")
|
|
59746
59924
|
);
|
|
59747
59925
|
if (metadata2.name !== name5 || (name5 in RUNTIME_PINS ? runtimePinStatus(name5, metadata2.version) === "mismatch" : metadata2.version !== version2))
|
|
59748
59926
|
invalid2(
|
|
@@ -59763,7 +59941,7 @@ async function inventory(root) {
|
|
|
59763
59941
|
if (item.isSymbolicLink() || item.name === "node_modules") continue;
|
|
59764
59942
|
if (item.isDirectory()) await walk(full);
|
|
59765
59943
|
else if (item.isFile()) {
|
|
59766
|
-
const bytes2 = await
|
|
59944
|
+
const bytes2 = await readFile4(full);
|
|
59767
59945
|
files.push({
|
|
59768
59946
|
path: relative(root, full).split(sep).join("/"),
|
|
59769
59947
|
bytes: bytes2.length,
|
|
@@ -60051,6 +60229,9 @@ async function runLocal(options) {
|
|
|
60051
60229
|
signal,
|
|
60052
60230
|
{
|
|
60053
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,
|
|
60054
60235
|
requestClientFile: join8(
|
|
60055
60236
|
directory,
|
|
60056
60237
|
"waitcher-request-runtime.mjs"
|
|
@@ -60130,7 +60311,7 @@ async function runLocal(options) {
|
|
|
60130
60311
|
const path2 = join8(directory, evidence, "report.json");
|
|
60131
60312
|
if ((await lstat7(path2)).size > STORAGE_LIMITS.artifactFileBytes)
|
|
60132
60313
|
throw Error("Local E2E report exceeds its 8 MiB budget");
|
|
60133
|
-
const report = JSON.parse(await
|
|
60314
|
+
const report = JSON.parse(await readFile4(path2, "utf8"));
|
|
60134
60315
|
const passed = result3.code === 0 && report.run?.status === "passed" && report.run.results?.length > 0 && report.run.results.every(
|
|
60135
60316
|
(r) => r.status === "passed"
|
|
60136
60317
|
);
|
|
@@ -60486,7 +60667,7 @@ async function runLocalCalibration(options) {
|
|
|
60486
60667
|
// src/bundle.ts
|
|
60487
60668
|
import { createRequire as createRequire2, isBuiltin } from "node:module";
|
|
60488
60669
|
import { createHash as createHash10 } from "node:crypto";
|
|
60489
|
-
import { readFile as
|
|
60670
|
+
import { readFile as readFile5, realpath as realpath2, mkdir as mkdir6, writeFile as writeFile6, rm as rm4 } from "node:fs/promises";
|
|
60490
60671
|
import { basename, dirname as dirname10, join as join10, relative as relative2, resolve as resolve12, sep as sep2, extname } from "node:path";
|
|
60491
60672
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
60492
60673
|
var sha = (bytes2) => createHash10("sha256").update(bytes2).digest("hex");
|
|
@@ -60519,7 +60700,7 @@ async function bundleMonitor(options) {
|
|
|
60519
60700
|
return name5.split(sep2).join("/");
|
|
60520
60701
|
}
|
|
60521
60702
|
projectPath(sourceManifest);
|
|
60522
|
-
const manifestText = await
|
|
60703
|
+
const manifestText = await readFile5(sourceManifest, "utf8");
|
|
60523
60704
|
let definition;
|
|
60524
60705
|
try {
|
|
60525
60706
|
definition = await readManifest(sourceManifest);
|
|
@@ -60528,7 +60709,7 @@ async function bundleMonitor(options) {
|
|
|
60528
60709
|
error62 instanceof Error ? error62.message : "Invalid source manifest."
|
|
60529
60710
|
);
|
|
60530
60711
|
}
|
|
60531
|
-
if (manifestText !== await
|
|
60712
|
+
if (manifestText !== await readFile5(sourceManifest, "utf8"))
|
|
60532
60713
|
invalid4(
|
|
60533
60714
|
"The source manifest changed during the build. Retry with stable inputs."
|
|
60534
60715
|
);
|
|
@@ -60626,7 +60807,7 @@ async function buildScript({
|
|
|
60626
60807
|
);
|
|
60627
60808
|
}
|
|
60628
60809
|
const toolMetadata = JSON.parse(
|
|
60629
|
-
await
|
|
60810
|
+
await readFile5(join10(dirname10(dirname10(tool)), "package.json"), "utf8")
|
|
60630
60811
|
);
|
|
60631
60812
|
if (toolMetadata.name !== "esbuild" || runtimePinStatus("esbuild", toolMetadata.version) === "mismatch")
|
|
60632
60813
|
invalid4(
|
|
@@ -60639,7 +60820,7 @@ async function buildScript({
|
|
|
60639
60820
|
const actual = await realpath2(path2), name5 = projectPath(actual);
|
|
60640
60821
|
if (inputs.size >= 64 && !inputs.has(name5))
|
|
60641
60822
|
invalid4("A portable monitor may bundle at most 64 source files.");
|
|
60642
|
-
const contents = await
|
|
60823
|
+
const contents = await readFile5(actual);
|
|
60643
60824
|
inputBytes += contents.length;
|
|
60644
60825
|
if (contents.length > 512e3 || inputBytes > 1024e3)
|
|
60645
60826
|
invalid4("Build inputs exceed the 1 MB source budget.");
|
|
@@ -60751,7 +60932,7 @@ async function buildScript({
|
|
|
60751
60932
|
let lock = null;
|
|
60752
60933
|
for (const name5 of ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"]) {
|
|
60753
60934
|
try {
|
|
60754
|
-
lock = { path: name5, sha256: sha(await
|
|
60935
|
+
lock = { path: name5, sha256: sha(await readFile5(join10(project, name5))) };
|
|
60755
60936
|
break;
|
|
60756
60937
|
} catch (error62) {
|
|
60757
60938
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -60773,7 +60954,7 @@ async function buildScript({
|
|
|
60773
60954
|
}
|
|
60774
60955
|
|
|
60775
60956
|
// src/config.ts
|
|
60776
|
-
import { readFile as
|
|
60957
|
+
import { readFile as readFile7, realpath as realpath3, mkdir as mkdir7, writeFile as writeFile8, rm as rm5 } from "node:fs/promises";
|
|
60777
60958
|
import { execFile } from "node:child_process";
|
|
60778
60959
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
60779
60960
|
import { dirname as dirname12, join as join12, resolve as resolve13 } from "node:path";
|
|
@@ -60781,7 +60962,7 @@ import { promisify } from "node:util";
|
|
|
60781
60962
|
|
|
60782
60963
|
// src/runtime.ts
|
|
60783
60964
|
import { spawn as spawn2 } from "node:child_process";
|
|
60784
|
-
import { access, readFile as
|
|
60965
|
+
import { access, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
60785
60966
|
import { createRequire as createRequire3 } from "node:module";
|
|
60786
60967
|
import { basename as basename2, dirname as dirname11, join as join11 } from "node:path";
|
|
60787
60968
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
@@ -60793,7 +60974,7 @@ async function installedPackage(project, name5) {
|
|
|
60793
60974
|
);
|
|
60794
60975
|
for (let i = 0; i < 6; i++, dir = dirname11(dir)) {
|
|
60795
60976
|
try {
|
|
60796
|
-
const meta3 = JSON.parse(await
|
|
60977
|
+
const meta3 = JSON.parse(await readFile6(join11(dir, "package.json"), "utf8"));
|
|
60797
60978
|
if (meta3.name === name5) return { dir, version: meta3.version };
|
|
60798
60979
|
} catch {
|
|
60799
60980
|
}
|
|
@@ -60873,7 +61054,7 @@ function run(command, args, cwd, signal) {
|
|
|
60873
61054
|
async function installRuntime(options) {
|
|
60874
61055
|
const { project, browser, yes, signal } = options;
|
|
60875
61056
|
const manifestPath = join11(project, "package.json");
|
|
60876
|
-
const text2 = await
|
|
61057
|
+
const text2 = await readFile6(manifestPath, "utf8").catch(() => null);
|
|
60877
61058
|
let existing = null;
|
|
60878
61059
|
if (text2 !== null)
|
|
60879
61060
|
try {
|
|
@@ -60894,7 +61075,7 @@ async function installRuntime(options) {
|
|
|
60894
61075
|
(name5) => runtimePinStatus(name5, installed[name5], {}) !== "current"
|
|
60895
61076
|
);
|
|
60896
61077
|
const ignorePath = join11(project, ".gitignore");
|
|
60897
|
-
const ignoreText = await
|
|
61078
|
+
const ignoreText = await readFile6(ignorePath, "utf8").catch(() => "");
|
|
60898
61079
|
const ignores = [];
|
|
60899
61080
|
for (const entry2 of missingIgnores(ignoreText))
|
|
60900
61081
|
if (!await gitIgnored(project, entry2)) ignores.push(entry2);
|
|
@@ -61099,7 +61280,7 @@ async function verifyLocally(options) {
|
|
|
61099
61280
|
const summary2 = join12(result2.directory, ".e2e", "summary.md");
|
|
61100
61281
|
let failure3;
|
|
61101
61282
|
if (result2.status !== "passed") {
|
|
61102
|
-
const lines = (await
|
|
61283
|
+
const lines = (await readFile7(summary2, "utf8").catch(() => "")).split("\n");
|
|
61103
61284
|
const test = lines.map((l) => /^\*\*🔴 (.+)\*\*/.exec(l.trim())?.[1]).find(Boolean);
|
|
61104
61285
|
const error62 = lines.find((l) => l.startsWith("> "))?.slice(2).trim();
|
|
61105
61286
|
if (error62) failure3 = `${test ? `"${test}": ` : ""}${error62}`.slice(0, 300);
|
|
@@ -61132,7 +61313,7 @@ async function readProjectConfig(file2) {
|
|
|
61132
61313
|
const path2 = configPath(file2);
|
|
61133
61314
|
let text2;
|
|
61134
61315
|
try {
|
|
61135
|
-
text2 = await
|
|
61316
|
+
text2 = await readFile7(path2, "utf8");
|
|
61136
61317
|
} catch {
|
|
61137
61318
|
throw new ServiceError(
|
|
61138
61319
|
`${path2} was not found. Run waitcher config init or pass --file.`,
|
|
@@ -61209,6 +61390,10 @@ function deployNextSteps(result2, {
|
|
|
61209
61390
|
steps.push(
|
|
61210
61391
|
`waitcher heartbeat credential --id ${c.monitorId} --expected-revision 1 --output PRIVATE_FILE (install it in the job before resuming)`
|
|
61211
61392
|
);
|
|
61393
|
+
else if (c.action === "create" && c.type === "visual" && !smoked)
|
|
61394
|
+
steps.push(
|
|
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}`
|
|
61396
|
+
);
|
|
61212
61397
|
else if (c.action === "create" && !c.enabled)
|
|
61213
61398
|
steps.push(
|
|
61214
61399
|
smoked ? `waitcher monitor resume --id ${c.monitorId} when the user wants it scheduled` : `waitcher run start --id ${c.monitorId} --wait, then waitcher monitor resume --id ${c.monitorId} when the user wants it scheduled`
|
|
@@ -61218,10 +61403,10 @@ function deployNextSteps(result2, {
|
|
|
61218
61403
|
}
|
|
61219
61404
|
|
|
61220
61405
|
// ../../skills/waitcher/SKILL.md
|
|
61221
|
-
var SKILL_default = "---\nname: waitcher\ndescription: Set up and maintain Waitcher monitoring from a repository with the waitcher CLI. Use to turn a product's critical journeys into HTTP, certificate, heartbeat, API or
|
|
61406
|
+
var SKILL_default = "---\nname: waitcher\ndescription: Set up and maintain Waitcher monitoring from a repository with the waitcher CLI. Use to turn a product's critical journeys into HTTP, certificate, heartbeat, API, browser or visual monitors in waitcher.json, verify them locally, deploy them through a reviewed plan, and diagnose failures from real evidence.\n---\n\n# Waitcher\n\nYou operate the waitcher CLI for the user. The repository is the source of truth: `waitcher.json` declares the monitors of one project per environment, test files hold the scripts, and `waitcher deploy` reconciles one environment at a time. Commands print JSON on stdout (`run diagnose` and `run scenarios` need `--json` for it); failures print `{error:{code,message}}` on stderr. Read the exit code, every `issues` entry and every `next` step.\n\nThis skill says what to do and in which order. For exact syntax use the installed CLI, never memory: `waitcher help TOPIC` (for example `help deploy`, `help secret`, `help run`) prints only that part of the help for this CLI version, and `waitcher explain CODE` explains an issue or error code. The user guide at https://waitcher.dev/docs/ explains the same product for people; link the user to a page (CLI install and updates, alerts, access tokens, account) instead of retelling it.\n\n## Rules\n\n- Never put secrets in files, arguments or output. Pipe values to `--value-stdin`.\n- Keep new monitors paused. Pass `--activate-new`, `--prune`, `--adopt` or `--smoke` only when the user agreed to that effect.\n- Show the user the plan's `changes` before `deploy apply`, and apply with `--based-on` from that plan.\n- A local pass is not hosted permission. If capabilities or limits refuse something, report it; never switch accounts, raise limits or remove assertions to get a green result.\n- An agent's own success claim is not evidence. Verify outcomes through the product's state or real run evidence.\n- Do not turn a whole regression suite into monitors. Pick two to five journeys whose failure the user would act on.\n\n## Workflow\n\n1. **Check the setup.** Run `waitcher doctor` in the repository. Fix `error` checks first; its `next` lists exact commands. Without a session, ask the user to run `waitcher auth login` (CI uses a token).\n2. **Understand the product.** Read the repository: base URLs per environment, existing E2E tests, critical journeys, test accounts and jobs. Ask the user which failures should alert them.\n3. **Start the file.** `waitcher config init --project-name NAME --target https://BASE` when there is no `waitcher.json`. Give each monitor a stable lowercase `key`; changing a key later replaces the monitor and its history.\n4. **Choose types.** `http` for status and content, `certificate` for TLS expiry, `heartbeat` for jobs that report in, `api` for a multi-request invariant, `browser` for a user journey. `waitcher monitor init --type TYPE --file x.json` prints a complete example of any type. Script monitors name their test with `entry`; read [authoring](references/authoring.md) before writing one. They need the pinned runtime next to `waitcher.json`: run `waitcher runtime install`, show the user the steps it lists (npm install runs package install scripts; browser projects download Chromium), and after they agree rerun it with `--yes`. It writes exact pins into `package.json`, updates `.gitignore` and is safe to repeat. The same command upgrades the project after a CLI update (`RUNTIME_VERSION_OUTDATED`).\n5. **Validate offline.** `waitcher config validate` resolves every environment and builds every entry. Fix each issue at its `path`. Add `--env NAME --verify` (optionally `--key KEY`) to run the api/browser entries locally without an account; read the run directory it names when one fails.\n6. **Plan.** `waitcher deploy plan --env NAME --verify` runs script monitors locally against that environment, then asks the server. Resolve errors (`SECRET_MISSING`: ask the user for the value and run `waitcher secret set`; `ADOPTION_CANDIDATE`: ask whether the existing monitor is the same check).\n7. **Apply.** After the user accepts the plan: `waitcher deploy apply --env NAME --based-on BASED_ON`, where BASED_ON is the plan's `basedOn` or `none` when it is null (first deploy); the plan's `next` prints the exact command. Add `--smoke` for one hosted run per changed monitor. New monitors stay paused.\n8. **Report.** Give the user the monitor IDs, what each checks, local and hosted results, evidence paths and anything still pending (paused schedules, heartbeat credentials, secrets for other environments). If `waitcher alert policy list` shows no routing, failures will alert nobody: point the user to https://waitcher.dev/docs/alerts.\n\nFor CI, `waitcher ci init` writes a workflow that plans on pull requests and applies on the main branch. Details of secrets, adoption, rollback and CI are in [deploy](references/deploy.md).\n\n## When something fails\n\n- `waitcher --help` prints a short overview of topics; `waitcher help TOPIC` (or `waitcher GROUP --help`) prints one part with the exit codes; `waitcher help all` is long, avoid it.\n- Exit 2: fix the file or input; exit 3: sign in; exit 4: a check failed (inspect evidence); exit 6: quota, rate or queue limit; exit 7: not permitted; exit 8: conflict or managed by `waitcher.json`; exit 9: not found; exit 10: service unavailable.\n- For a failed run, read [diagnosis](references/diagnosis.md): `waitcher run diagnose --id RUN_ID`, then reproduce locally before changing the test.\n- Never retry a write automatically after an uncertain result; read the current state first.\n\n## References\n\n- [authoring](references/authoring.md): choosing a type, writing API and browser tests, local runs and evidence, single-monitor apply.\n- [deploy](references/deploy.md): waitcher.json details, secrets, adoption, rollback, CI.\n- [diagnosis](references/diagnosis.md): run diagnosis and reproduction.\n- [optional capabilities](references/optional-capabilities.md): visual baselines, browser identities, verified HTTP credentials, invocation budgets.\n- [AI and agents](references/ai-and-agents.md): agent outcome checks, scenario evidence, AI endpoints and suites, calibration, AI steps in scripts, protected requests.\n- Read the last two only when `waitcher system capabilities` reports the feature and the user needs it.\n";
|
|
61222
61407
|
|
|
61223
61408
|
// ../../skills/waitcher/references/authoring.md
|
|
61224
|
-
var authoring_default = '# Authoring and running monitors\n\nRead when writing or changing a test, choosing a monitor type, or running it locally. For exact syntax run `waitcher help monitor` or `waitcher help run`. AI endpoints, agent outcome checks and model steps are in [ai-and-agents](ai-and-agents.md).\n\n## Choose the type\n\n- `http`: status, body text, a JSON value or latency of one request. No script.\n- `certificate`: TLS expiry and chain. No script.\n- `heartbeat`: a job reports start and success; Waitcher alerts when it does not.\n- `api`: a script with several requests and an invariant between them.\n- `browser`: a script that walks a user journey in Chromium.\n\n`waitcher monitor init --type TYPE --file x.json` writes a paused example of every type; `api` and `browser` also write `x.e2e.ts`. Keep scripts focused on the requested behavior and use controlled test identities for actions that change state.\n\n## Scripts in waitcher.json\n\nIn a repository, a script monitor is an entry with `entry` pointing at its test file; one test serves every environment because it reads the base URL at run time.\n\n```json\n{ "key": "checkout", "type": "browser", "entry": "monitoring/checkout.e2e.ts", "timeout": 45 }\n```\n\nRun the entries of one environment locally, without an account:\n\n```sh\nwaitcher config validate --env production --verify\nwaitcher config validate --env production --verify --key checkout\n```\n\nExit 4 with `VERIFY_FAILED` names the failing assertion and the run directory to read. `run local --file` takes a single monitor manifest, not `waitcher.json`.\n\n## Browser journey\n\n```ts\nimport { test } from "@e2e-dev/web";\nimport { expect } from "e2e";\n\ntest("visitor can start a game", async ({ app, browser, screen }) => {\n await app.open("/games/klondike/");\n await expect(browser.locator("main h1")).toContainText("Solitaire");\n await expect(screen.getByRole("button", "New game")).toBeVisible();\n await app.screenshot("game");\n});\n```\n\n- `app.open(path)` resolves against the environment\'s base URL. Browser base URLs have no query or fragment; navigate to those URLs inside the script.\n- Find elements the way a visitor does with the `screen` fixture: `screen.getByRole("button", "New game")`, `screen.getByLabel("Email")`, `screen.getByText("Welcome")`, `screen.getByPlaceholder(...)`, `screen.getByTestId(...)`. Prefer these over CSS selectors.\n- The `browser` fixture navigates and offers CSS `browser.locator("main h1")` plus `expect(browser).toHaveURL(...)`; it has no `getBy*` methods.\n- Assertions come from `e2e`: `toBeVisible()`, `toContainText(...)`, `toHaveText(...)`.\n\n## API script\n\n```ts\nimport { test, expect } from "e2e";\n\ntest("orders API keeps totals consistent", async () => {\n const target = new URL(process.env.TARGET_URL!);\n const response = await fetch(new URL("/api/orders?limit=1", target));\n expect(response.status).toBe(200);\n});\n```\n\nAPI scripts import `test, expect` from `e2e` and read `process.env.TARGET_URL`. Secrets reach them only as `CHECK_*` names listed in `settings.envNames` (see [deploy](deploy.md)). The test runs as trusted local code, not in a sandbox.\n\n## Standalone manifest\n\nWithout `waitcher.json`, a monitor is one JSON file. `monitor init --type browser --file monitor.json` writes it with `scriptFile` next to the test:\n\n```json\n{\n "schemaVersion": 1,\n "name": "Product / key journey",\n "type": "browser",\n "target": "https://example.com/",\n "enabled": false,\n "interval": 1800,\n "timeout": 30,\n "scriptFile": "journey.e2e.ts"\n}\n```\n\n`scriptFile` resolves relative to the manifest; `monitor validate --file monitor.json` checks the actual contract. The platform receives one script per monitor, not the project directory. When the test imports shared helpers, run `monitor build --file monitors/checkout.json --project . --output build/checkout`: it needs installed `esbuild@0.28.2`, bundles code and JSON helpers, keeps only supported framework and Node imports, and writes `monitor.js`, `monitor.json` and `build.json` into a new directory. Unsupported dependencies and module-relative file access fail the build. Verify and apply the built `monitor.json`. The script limit is 50,000 characters and hosted dependencies are fixed.\n\n## Run locally and inspect evidence\n\nThe runtime project needs `e2e@0.21.1` and, for browser tests, `@e2e-dev/web@0.15.1` and Chromium. `waitcher runtime install --file DIR/waitcher.json [--browser]` lists the npm install and Chromium download; run it with `--yes` once the user agrees. Chromium goes to the Playwright browser cache (`PLAYWRIGHT_BROWSERS_PATH` when set), not the runtime directory.\n\n```sh\nwaitcher run local --file monitor.json --runtime /path/to/runtime\nwaitcher run local --file monitor.json --runtime /path/to/runtime --video\nwaitcher run local --project /path/to/e2e-project --timeout 60\n```\n\n- `--project` runs an existing E2E project with its own config and imports; its `--output` must stay inside that project.\n- Runs are serial, never retried or replayed, and get a fresh directory under `.waitcher/runs/` (`--output DIR` chooses the parent). Traces are always requested; video is opt-in, and tests can override recording, so inspect the returned files.\n- On failure read `.e2e/summary.md` and `.e2e/results/*/trace.md` in the run directory first, then `execution.log` and `report.json`. The `waitcher-*.mjs` files there are runtime support, not your test. Traces are Markdown, not Playwright ZIPs; there is no HAR option, and app logs hold selected console and request failures only.\n- Exit codes: 0 passed, 4 failed or error, 130 interrupted. After an interruption, inspect partial evidence before repeating a possibly completed action.\n- Fix test mistakes while preserving the user\'s assertions; never weaken an assertion just to get green.\n- Evidence can contain private content: keep `.waitcher/`, `.e2e/`, keys and reports out of Git. Local results are not uploaded and are not hosted health evidence.\n\n## Apply one monitor through the API\n\nWhen hosted scripts are allowed and applying configuration is in scope:\n\n```sh\nwaitcher monitor apply --file monitor.json --dry-run\nwaitcher monitor apply --file monitor.json\nwaitcher monitor get --id MONITOR_ID\n```\n\nKeep the monitor paused unless the user requested scheduled execution; applying does not run it. For an authorized single hosted run use `run start --id MONITOR_ID --wait`, then `run status`, `run trace --id RUN_ID` (steps, failed assertion, screenshots, fetch calls) and `artifact get` for evidence. Hosted scripts run under the server\'s execution policy and can differ from a local run.\n\nEdits are complete replacements: `monitor export`, change the file, then `monitor apply --file FILE --id ID --expected-revision N` with the revision from get or export. Use a stable `--request-key` to recover one uncertain create or run; never change the payload under that key or repeat a possibly executed action. Report the exact monitor and run IDs, local evidence path, observed outcome and any difference between local and hosted results.\n';
|
|
61409
|
+
var authoring_default = '# Authoring and running monitors\n\nRead when writing or changing a test, choosing a monitor type, or running it locally. For exact syntax run `waitcher help monitor` or `waitcher help run`. AI endpoints, agent outcome checks and model steps are in [ai-and-agents](ai-and-agents.md).\n\n## Choose the type\n\n- `http`: status, body text, a JSON value or latency of one request. No script.\n- `certificate`: TLS expiry and chain. No script.\n- `heartbeat`: a job reports start and success; Waitcher alerts when it does not.\n- `api`: a script with several requests and an invariant between them.\n- `browser`: a script that walks a user journey in Chromium.\n- `visual`: a screenshot of one public page or element compared with a baseline the user approved. No script; see [optional capabilities](optional-capabilities.md#optional-visual-checks).\n\n`waitcher monitor init --type TYPE --file x.json` writes a paused example of every type; `api` and `browser` also write `x.e2e.ts`. Keep scripts focused on the requested behavior and use controlled test identities for actions that change state.\n\n## Scripts in waitcher.json\n\nIn a repository, a script monitor is an entry with `entry` pointing at its test file; one test serves every environment because it reads the base URL at run time.\n\n```json\n{ "key": "checkout", "type": "browser", "entry": "monitoring/checkout.e2e.ts", "timeout": 45 }\n```\n\nRun the entries of one environment locally, without an account:\n\n```sh\nwaitcher config validate --env production --verify\nwaitcher config validate --env production --verify --key checkout\n```\n\nExit 4 with `VERIFY_FAILED` names the failing assertion and the run directory to read. `run local --file` takes a single monitor manifest, not `waitcher.json`.\n\n## Browser journey\n\n```ts\nimport { test } from "@e2e-dev/web";\nimport { expect } from "e2e";\n\ntest("visitor can start a game", async ({ app, browser, screen }) => {\n await app.open("/games/klondike/");\n await expect(browser.locator("main h1")).toContainText("Solitaire");\n await expect(screen.getByRole("button", "New game")).toBeVisible();\n await app.screenshot("game");\n});\n```\n\n- `app.open(path)` resolves against the environment\'s base URL. Browser base URLs have no query or fragment; navigate to those URLs inside the script.\n- Find elements the way a visitor does with the `screen` fixture: `screen.getByRole("button", "New game")`, `screen.getByLabel("Email")`, `screen.getByText("Welcome")`, `screen.getByPlaceholder(...)`, `screen.getByTestId(...)`. Prefer these over CSS selectors.\n- The `browser` fixture navigates and offers CSS `browser.locator("main h1")` plus `expect(browser).toHaveURL(...)`; it has no `getBy*` methods.\n- Assertions come from `e2e`: `toBeVisible()`, `toContainText(...)`, `toHaveText(...)`.\n\n## API script\n\n```ts\nimport { test, expect } from "e2e";\n\ntest("orders API keeps totals consistent", async () => {\n const target = new URL(process.env.TARGET_URL!);\n const response = await fetch(new URL("/api/orders?limit=1", target));\n expect(response.status).toBe(200);\n});\n```\n\nAPI scripts import `test, expect` from `e2e` and read `process.env.TARGET_URL`. Secrets reach them only as `CHECK_*` names listed in `settings.envNames` (see [deploy](deploy.md)). The test runs as trusted local code, not in a sandbox.\n\n## Standalone manifest\n\nWithout `waitcher.json`, a monitor is one JSON file. `monitor init --type browser --file monitor.json` writes it with `scriptFile` next to the test:\n\n```json\n{\n "schemaVersion": 1,\n "name": "Product / key journey",\n "type": "browser",\n "target": "https://example.com/",\n "enabled": false,\n "interval": 1800,\n "timeout": 30,\n "scriptFile": "journey.e2e.ts"\n}\n```\n\n`scriptFile` resolves relative to the manifest; `monitor validate --file monitor.json` checks the actual contract. The platform receives one script per monitor, not the project directory. When the test imports shared helpers, run `monitor build --file monitors/checkout.json --project . --output build/checkout`: it needs installed `esbuild@0.28.2`, bundles code and JSON helpers, keeps only supported framework and Node imports, and writes `monitor.js`, `monitor.json` and `build.json` into a new directory. Unsupported dependencies and module-relative file access fail the build. Verify and apply the built `monitor.json`. The script limit is 50,000 characters and hosted dependencies are fixed.\n\n## Run locally and inspect evidence\n\nThe runtime project needs `e2e@0.21.1` and, for browser tests, `@e2e-dev/web@0.15.1` and Chromium. `waitcher runtime install --file DIR/waitcher.json [--browser]` lists the npm install and Chromium download; run it with `--yes` once the user agrees. Chromium goes to the Playwright browser cache (`PLAYWRIGHT_BROWSERS_PATH` when set), not the runtime directory.\n\n```sh\nwaitcher run local --file monitor.json --runtime /path/to/runtime\nwaitcher run local --file monitor.json --runtime /path/to/runtime --video\nwaitcher run local --project /path/to/e2e-project --timeout 60\n```\n\n- `--project` runs an existing E2E project with its own config and imports; its `--output` must stay inside that project.\n- Runs are serial, never retried or replayed, and get a fresh directory under `.waitcher/runs/` (`--output DIR` chooses the parent). Traces are always requested; video is opt-in, and tests can override recording, so inspect the returned files.\n- On failure read `.e2e/summary.md` and `.e2e/results/*/trace.md` in the run directory first, then `execution.log` and `report.json`. The `waitcher-*.mjs` files there are runtime support, not your test. Traces are Markdown, not Playwright ZIPs; there is no HAR option, and app logs hold selected console and request failures only.\n- Exit codes: 0 passed, 4 failed or error, 130 interrupted. After an interruption, inspect partial evidence before repeating a possibly completed action.\n- Fix test mistakes while preserving the user\'s assertions; never weaken an assertion just to get green.\n- Evidence can contain private content: keep `.waitcher/`, `.e2e/`, keys and reports out of Git. Local results are not uploaded and are not hosted health evidence.\n\n## Apply one monitor through the API\n\nWhen hosted scripts are allowed and applying configuration is in scope:\n\n```sh\nwaitcher monitor apply --file monitor.json --dry-run\nwaitcher monitor apply --file monitor.json\nwaitcher monitor get --id MONITOR_ID\n```\n\nKeep the monitor paused unless the user requested scheduled execution; applying does not run it. For an authorized single hosted run use `run start --id MONITOR_ID --wait`, then `run status`, `run trace --id RUN_ID` (steps, failed assertion, screenshots, fetch calls) and `artifact get` for evidence. Hosted scripts run under the server\'s execution policy and can differ from a local run.\n\nEdits are complete replacements: `monitor export`, change the file, then `monitor apply --file FILE --id ID --expected-revision N` with the revision from get or export. Use a stable `--request-key` to recover one uncertain create or run; never change the payload under that key or repeat a possibly executed action. Report the exact monitor and run IDs, local evidence path, observed outcome and any difference between local and hosted results.\n';
|
|
61225
61410
|
|
|
61226
61411
|
// ../../skills/waitcher/references/ai-and-agents.md
|
|
61227
61412
|
var ai_and_agents_default = "# AI endpoints, agent outcomes and model steps\n\nRead only when `waitcher system capabilities` reports the feature and the user needs it. Deterministic HTTP, API and browser monitors need none of this; see [authoring](authoring.md).\n\n## Agent outcome checks\n\nFor hosted scripts using `#waitcher/scenario`, first confirm `features.scenarioEvidence` through `system capabilities`, alongside script admission. Older servers may not provide this helper. Do not silently remove required scenario checks to make an unsupported run pass. Capability discovery is separate from native security, capacity and production release acceptance.\n\nFor an agent that changes application state, start with `monitor init --template agent-outcome --file outcome.json --target https://product.example/api/`. It creates a paused ordinary API script, with no model binding or paid-provider requirement. Adapt its fixed `agent/tasks` submission and `notes/{runId}` resource paths, disposable test namespace and exact expected fields. It submits one action, ignores claims of success and response-provided URLs, then independently reads the known resource at most three times. A fresh per-run random `id` and `correlationId` must both match, alongside the expected result. Action transport errors are never automatically retried. Cleanup runs in `finally` only after an independent read proves the resource belongs to this run; cleanup failures fail the test. If ownership or the action result is uncertain, it records cleanup as unverified and leaves state untouched. Reconcile possible late actions before repeating a mutating test. This pattern verifies the chosen outcome, not the agent's overall quality or the correctness of its explanation.\n\nThe starter uses the optional `#waitcher/scenario` helper with required submit/action, observe, verify and cleanup phases. `createScenario({id, phases})` returns `phase(id, callback)`, `assert(boolean)` and `incomplete(reason)`. Call signals only inside an active phase. Every scenario needs a required verify phase, and an executed verify phase must call `scenario.assert` at least once; an empty verification cannot establish pass. `assert(false)` records a business failure even if caught; ordinary callback exceptions and `incomplete(\"CLEANUP_UNVERIFIED\")` record coverage errors. Inspect `.e2e/waitcher-scenarios.json` in the private evidence: required phases that never ran or remain in flight also prevent a pass. Coverage error takes precedence while retaining failed verification facts. A false agent claim can therefore produce a failed verify phase and an overall error when cleanup remains uncertain. The helper does not automatically classify arbitrary E2E assertions or infer agent/tool traces. Use stable non-secret scenario/phase IDs, avoid raw response values in assertions, and do not use report labels as secret storage.\n\nUse the unchanged file with `monitor validate`, account-free `run local --file outcome.json --runtime YOUR_PINNED_RUNTIME`, and the existing API-script editor or `monitor apply --file outcome.json --dry-run`. Keep it paused after applying. Project authors can extract the script into `scriptFile`, keep helper imports and use `monitor build` to create one portable script; `#waitcher/scenario` stays external and is supplied by the manifest runner. The complete CLI includes `scenario-runtime.mjs`; keep package companions together. Standalone `--project` needs its own helper integration. The starter's default is credential-free. Optional local/trusted-administrator bearer tokens use `CHECK_AGENT_ACTION_TOKEN`, `CHECK_RESOURCE_READ_TOKEN` and `CHECK_RESOURCE_CLEANUP_TOKEN`, explicitly listed in `settings.envNames` and supplied outside the manifest. Hosted personal scripts receive `CHECK_*` values only from their project environment's secrets (`waitcher secret set`), never from the server's environment; do not work around that boundary. Do not log credentials or response bodies, and do not promise complete trace masking for arbitrary custom environment values. Local success does not establish hosted admission or isolation.\n\n## Scenario evidence\n\nInspect readable scenario evidence with `waitcher run scenarios --id RUN_ID`, or use `waitcher run scenarios --directory PRIVATE_RUN_DIR` for account-free local inspection without a server/runtime. Add `--json` for the exact shared report DTO. Do not combine selectors or pass `--server` for local inspection. Inspection of failed/error runs succeeds; execution exit codes remain unchanged. Keep authoritative run status separate from evidence availability: empty valid reports verify no business outcome, and pending/not-recorded/expired/invalid reports cannot establish a pass. Local evidence is checked against its recorded inventory and checksum; never edit it to manufacture a successful outcome.\n\n## AI product endpoints\n\nFor a single AI product endpoint, prefer a declarative `type: \"ai\"` fixture over an E2E script. Run `monitor init --type ai --target https://product.example/ai --file ai.json`, replace the sample request and response checks with the product contract, then `monitor validate --file ai.json`. JSON-pointer assertions support exact equality, type, existence and literal case-sensitive contains/not-contains/contains-any/contains-all checks; an optional bounded response schema checks structure. `run local --file ai.json` uses the same one-POST adapter without an account, model connection, provider key or E2E runtime. It only reaches public HTTPS endpoints and supports optional verified `httpAuth` references as described below; arbitrary custom headers and account-session inheritance are forbidden. Inspect the structured per-assertion report and distinguish transport coverage errors from product assertion failures. Applying the same file to hosted monitoring requires `features.aiEndpoints`; personal admission also requires a currently verified `httpAuth` binding; keep it paused unless scheduling is authorized. This verifies a chosen fixture, not general agent quality or a calibrated semantic judge.\n\nFor a small set of representative prompts against the same endpoint, use `aiEndpoint.adapter: \"json-http-suite-v1\"` and `cases` with 1\u20135 objects containing a stable unique `id`, readable `name`, positive `revision` (default 1), literal JSON-object `fixture`, and assertions and/or response schema. The suite `invocationBudget` equals its case count and is filled in when omitted. Validate offline and run the unchanged manifest locally before applying it; hosted capability `features.aiEndpointSuites` must be available. Cases run serially under one total monitor timeout. Assertion failures permit later cases; a transport/deadline error stops them as `not-run`. Inspect every case and coverage summary, not only the overall status. The controller reserves the full case count before any hosted request, and partial/uncertain runs retain that conservative allowance. Reported attempted requests can therefore be fewer than charged units. Deterministic suites do not provide semantic grading; do not describe text matching as semantic correctness. Single fixtures and each suite case can opt into literal variables with variables:{name:\"string\"} and exact {{name}} placeholders inside fixture string values. Without variables, braces remain literal. Use at most 16 names, ASCII letter followed by letters/digits/underscores (64 characters); prototype-related names are refused. Each value fits 4 KiB UTF-8, maps and rendered fixtures 16 KiB and complete configurations 64 KiB. No expressions, environment lookup, key/URL/assertion/rubric interpolation, matrix expansion or recursive replacement is supported. Missing/malformed placeholders reject before requests. Use non-secret data. Validate locally and preview before applying: exports keep authored maps while enqueue freezes rendered literal requests. Release comparisons use effective rendered bodies, so a changed variable value can be a changed policy even with the same case revision.\n\nFor optional semantic endpoint grading, use `json-http-graded-suite-v1`, portable schemaVersion 2 and explicit context (even the default project/environment). Set the top-level `judge` connectionId/configurationRevision/model/budget and add a rubric to each selected case: stable id/revision, criteria, outputPath, threshold and optional reference examples. Keep target credentials separate from judge keys. Hosted use requires `features.endpointJudges`; local use accepts the same private `--connections-file` map without an account, UI or E2E runtime. Only the selected output and rubric criteria/examples reach the judge. Known echoed managed product keys are refused before grading. Inspect score, verdict, rubric hash and private model-usage.json: malformed/unavailable/unknown/over-budget grading is inconclusive coverage and cannot pass or recover a product incident. There are no retries or fallback models. Every report currently marks calibration unverified; labelled reference examples do not prove accuracy. Keep calibration, pricing and release acceptance distinct from a controlled protocol pass.\n\nTo measure a rubric against labelled examples, use `monitor calibrate --id ID --file REQUEST_JSON` for a saved hosted monitor, then `monitor calibrations --id ID` or `monitor calibration --id ID --calibration-id ID` to inspect retained measurements. The request contains `caseId`, `dataset` and optional `repeats`. For account-free local measurement, use `run calibrate --file MONITOR --case-id CASE --dataset DATASET --connections-file PRIVATE_MAP`; `--dataset` is the dataset object alone. Use 2\u20134 fictional labelled outputs and 1\u20133 repeats, within the saved judge call/token budget and a total 30-second ceiling. Calibration calls only the judge, not the product endpoint, and creates no health runs, incidents or recovery. Keep known keys out of dataset/rubric identifiers, object keys and content as well as prompts. Inspect agreement over valid evaluated decisions, disagreement, repeat instability and technical coverage errors separately. A valid expected inconclusive can agree; a provider error cannot. Inspect private model usage for actual reservations. Exit 4 means disagreement, instability or coverage failure; never erase those results to obtain a green check. A small successful sample applies only to its exact dataset/rubric/model identity and does not establish general accuracy or automatically change the monitor\u2019s unverified calibration label.\n\nFor release regressions, use `project compare --id PROJECT_ID --deployment-id DEPLOYMENT_ID` and follow the opaque `next` cursor with `--before`. AI rows include case-level comparisons from frozen queued definitions and retained structured reports. Inspect each case classification and compatibility reasons. A different fixture, assertion, rubric, judge model or policy identity cannot establish a product regression; do not compare numeric scores across changed policies. Missing/invalid reports and unexecuted cases are coverage gaps. Follow the owned run references for evidence. Last passing and first failure are useful only for the matching case policy; a pass from another case or rubric is not a reproduction baseline. Display-name changes and JSON object key order do not change the evaluation policy. Comparison is read-only and never schedules another paid request.\n\n## AI steps in browser and API scripts\n\nFor personal AI-assisted browser journeys, require both `features.ai` and `features.isolatedAi` alongside script admission. Keep the `ai` model connection binding optional; deterministic scripts need no model or provider key. Hosted personal runs always use server-owned isolated policy and an explicitly model-capable isolated worker. An older worker, withdrawn capability or missing connection is a coverage failure, never a reason to switch accounts or execute through a trusted lane. Use the same version-2 manifest locally with a private connection map before applying it paused. Only attempt-scoped broker authority enters the disposable runtime; upstream keys stay controller-side. Screenshots, page content and prompts used by AI steps reach the selected provider. Inspect native assertions plus authoritative model usage/error evidence; catching an SDK error does not make a run healthy. No browser login-state import or stored application credentials are supported by this capability. API scripts have no built-in screen observation engine: do not call screen-based agent.assert/waitFor/extract on API data. In manifest mode, import {assertGrade, grade} from \"#waitcher/ai\" and pass {data: selectedJsonOrText, rubric: criteria, threshold: 0.8}. The optional judgeModel grades the selected data, otherwise model is used. Keep expected facts in versioned fixtures; send no credentials or unnecessary response fields. Selected JSON is limited to 8 KiB and rubric to 2 KiB. grade returns {verdict,score}; assertGrade throws on non-pass. Any failure, valid inconclusive or technical grading error remains authoritative even when caught or ignored. Inspect private waitcher-data-grades.json alongside model usage and the native report. No retries/fallbacks occur. The alias survives monitor build and is supplied by run local --file and hosted script execution; standalone --project needs its own integration. Deterministic scripts need no binding; fixed endpoint fixtures can use the declarative graded adapter instead.\n\nFor an existing project's custom model setup, use `--project`. A schemaVersion 2 manifest with an `ai` binding can also run unchanged locally using `--connections-file /private/connections.json`, without login. The private map has schemaVersion 1 and a connections array; each record contains id, configurationRevision, provider openrouter, projectId, environmentId, allowed models and credentialFile. Credential paths resolve relative to the map. IDs/revisions/models and explicit manifest scope must match. Keep both map and key files private (chmod 600); inline keys, provider URLs and symlinks are refused. The selected runtime also needs ai@7.0.107. The complete CLI package ships model-client.mjs and notices; copying only cli.mjs is insufficient for bound AI execution.\n\nThe local manifest runner keeps the provider key in its parent and passes a temporary loopback grant to the test. It uses the hosted transport and per-run budget/outcome rules, but no hosted account/day ledger. Read model-usage.json as well as the native report: caught provider/budget failures may leave a native passed test while Waitcher correctly records error. Unknown usage stays reserved, SDK retries count separately, and local success does not verify hosted enablement or key freshness. Provider keys are not forwarded to the child, and literal temporary broker tokens are redacted from normal text evidence; trusted local code can read its filesystem and is not a sandbox. Traces default on, video stays opt-in.\n\nIn the project's `e2e.config.ts`, construct the chosen provider's AI SDK model under `agents.default.model`, following the installed framework's types. The provider reads its local key; a key alone does not configure a model. Never copy a user's provider key into a monitor manifest or use an operator's account key.\n\nMix exact assertions with selected `agent.act`, `agent.assert`, `agent.waitFor` and schema-bound `agent.extract` calls. AI operations may transmit screen content to the provider and incur cost; preserve the user's provider/call authorization. Step-level `maxModelCalls` is not a whole-run spending limit. Hosted connection/broker/budget support is separate and must be discovered from actual capabilities rather than assumed from a local run.\n\n## Protected product requests\n\nFor protected product operations, use monitor init --template protected-agent-outcome --request-policy-file POLICY.json --project-id UUID --environment-id UUID --file monitor.json. The public policy contains connections with id, canonical HTTPS origin and httpAuth references (targetId, credentialId, credentialRevision); operations with id, connection, method, path, optional static body, responsePointers and maxCalls; and budget.calls. Paths are fixed absolute paths with at most one whole {resourceId} UUID segment. Static JSON bodies may use only exact string leaves {{resourceId}}. Callers cannot choose URLs, methods, headers, bodies, query parameters or UUIDs. GET permits at most three calls, POST and DELETE one; DELETE requires the UUID path and POST must use the run identity. Limits are four connections, eight operations and eight total calls.\n\nThe protected starter requires submit POST, observe GET (three reads), cleanup DELETE, a five-call budget and response pointers /id, /correlationId, /title, /completed. Configure the static submission body to create a note with the parent-generated UUID in both id and correlationId, title Waitcher outcome check, and completed true. The optional #waitcher/requests SDK exposes requestOperation and requestResourceId. Responses contain status and a data map keyed by configured JSON pointers. The script never trusts the agent reply as proof of resulting state, never retries the action, and only cleans up independently proven run-owned state.\n\nLocal execution uses the existing --http-credentials-file private map: schemaVersion 1 and credentials entries with targetId, credentialId, credentialRevision, origin, header and credentialFile. Header is Authorization or X-Api-Key; its raw value stays in a separate private regular file. Map and key files require mode600 and exact reference/revision/origin matches. Keys stay in the CLI parent, never script, manifest, CLI arguments or custom environment. No account, app or AI provider is required locally. Keep request-runtime.mjs with the complete CLI package. For source projects use scriptFile, monitor build, then run local --file; standalone project mode does not inject the protected helper. Hosted use requires explicit capability and isolated execution even for administrators. Combined AI or browser-state bindings need their independent authority. Inspect request-usage.json, scenario and native reports. Caught budget errors, uncertain dispatch and unfinished calls cannot establish a healthy result; never replay mutations automatically.\n\nScenario request associations are optional recorded evidence. The request helper automatically records each issued request UUID on its originating phase. In a verify phase, call `scenario.referenceRequest(response.requestId)` for a request from an earlier completed observe phase in the same scenario; use the validated response envelope UUID, never an ID from response data. The protected starter references its last independent observation before asserting the business state. Read associations with `run scenarios`; `run diagnose` joins them to this run's request records and labels each ID `matched`, `not-found` or `unavailable`. These are script-reported phase associations. A matching controller row proves accounting correspondence, not the correctness of a phase or business outcome. Local matches remain local helper reports. Older evidence without association fields is not recorded, rather than an empty verified list. UNKNOWN requests remain charged and incomplete; no association authorizes mutation replay.\n";
|
|
@@ -61233,13 +61418,13 @@ var deploy_default = '# Repository deploys\n\nRead when the user keeps monitors
|
|
|
61233
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";
|
|
61234
61419
|
|
|
61235
61420
|
// ../../skills/waitcher/references/optional-capabilities.md
|
|
61236
|
-
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` identifies the default-off personal capture lane, independent of script/AI admission. Start with `monitor init --type visual --target https://product.example --file visual.json`, edit the fixed page/element checkpoint, viewport, readiness, masks and thresholds, 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. 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';
|
|
61237
61422
|
|
|
61238
61423
|
// ../../skills/waitcher/agents/openai.yaml
|
|
61239
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';
|
|
61240
61425
|
|
|
61241
61426
|
// src/skill.ts
|
|
61242
|
-
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";
|
|
61243
61428
|
import { homedir } from "node:os";
|
|
61244
61429
|
import { join as join13, resolve as resolve14 } from "node:path";
|
|
61245
61430
|
var references = {
|
|
@@ -61261,7 +61446,7 @@ async function installSkill(options) {
|
|
|
61261
61446
|
const existing = await lstat9(directory).catch(() => null);
|
|
61262
61447
|
let previousVersion = null;
|
|
61263
61448
|
if (existing) {
|
|
61264
|
-
const marker2 = existing.isDirectory() ? await
|
|
61449
|
+
const marker2 = existing.isDirectory() ? await readFile8(join13(directory, MARKER), "utf8").catch(() => null) : null;
|
|
61265
61450
|
if (marker2 === null)
|
|
61266
61451
|
throw new SkillInstallError(
|
|
61267
61452
|
`${directory} exists and was not installed by waitcher. Remove it or choose another --path.`
|
|
@@ -61299,7 +61484,7 @@ async function installSkill(options) {
|
|
|
61299
61484
|
}
|
|
61300
61485
|
|
|
61301
61486
|
// src/doctor.ts
|
|
61302
|
-
import { access as access2, readFile as
|
|
61487
|
+
import { access as access2, readFile as readFile9 } from "node:fs/promises";
|
|
61303
61488
|
import { homedir as homedir2 } from "node:os";
|
|
61304
61489
|
import { dirname as dirname13, join as join14 } from "node:path";
|
|
61305
61490
|
var exists = (path2) => access2(path2).then(
|
|
@@ -61398,7 +61583,7 @@ async function doctor(options) {
|
|
|
61398
61583
|
for (const home of skillHomes) {
|
|
61399
61584
|
if (!await exists(join14(home, "SKILL.md"))) continue;
|
|
61400
61585
|
installed.push(home);
|
|
61401
|
-
const marker2 = await
|
|
61586
|
+
const marker2 = await readFile9(join14(home, ".waitcher-skill.json"), "utf8").then((text2) => JSON.parse(text2)).catch(() => null);
|
|
61402
61587
|
if (marker2 && marker2.version !== options.version) stale.push(home);
|
|
61403
61588
|
}
|
|
61404
61589
|
const install = root === process.cwd() ? "waitcher skill install" : `waitcher skill install --path ${join14(root, ".claude", "skills")}`;
|
|
@@ -61595,7 +61780,7 @@ jobs:
|
|
|
61595
61780
|
}
|
|
61596
61781
|
|
|
61597
61782
|
// src/main.ts
|
|
61598
|
-
import { readFile as
|
|
61783
|
+
import { readFile as readFile11, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
|
|
61599
61784
|
import { basename as basename3, dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
|
|
61600
61785
|
import { constants as constants13 } from "node:fs";
|
|
61601
61786
|
|
|
@@ -61799,7 +61984,7 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
61799
61984
|
import { createHash as createHash11, randomUUID as randomUUID7 } from "node:crypto";
|
|
61800
61985
|
import { homedir as homedir3 } from "node:os";
|
|
61801
61986
|
import { dirname as dirname16, join as join15 } from "node:path";
|
|
61802
|
-
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";
|
|
61803
61988
|
function serverUrl(value2) {
|
|
61804
61989
|
let url3;
|
|
61805
61990
|
try {
|
|
@@ -61832,7 +62017,7 @@ async function privatePath(path2, directory = false) {
|
|
|
61832
62017
|
}
|
|
61833
62018
|
async function readPrivate(path2) {
|
|
61834
62019
|
await privatePath(path2);
|
|
61835
|
-
return
|
|
62020
|
+
return readFile10(path2, "utf8");
|
|
61836
62021
|
}
|
|
61837
62022
|
async function loadSession(server) {
|
|
61838
62023
|
const path2 = sessionPath(server);
|
|
@@ -62306,7 +62491,8 @@ Repository deploys (waitcher.json)
|
|
|
62306
62491
|
Keys identify monitors; renaming a key replaces the monitor and its history.
|
|
62307
62492
|
The repository owns definitions; the server owns pause and resume. New monitors start
|
|
62308
62493
|
paused unless --activate-new. Undeclared monitors are reported and deleted only with --prune.
|
|
62309
|
-
Deploys accept http, certificate, heartbeat, api
|
|
62494
|
+
Deploys accept http, certificate, heartbeat, api, browser and visual (first --smoke
|
|
62495
|
+
capture: baseline_review, see help visual). Script monitors name an
|
|
62310
62496
|
entry file; the CLI builds it like monitor build (project needs e2e@${RUNTIME_PINS.e2e},
|
|
62311
62497
|
@e2e-dev/web@${RUNTIME_PINS["@e2e-dev/web"]} for browser, esbuild@${RUNTIME_PINS.esbuild}). Plans and results list issues with
|
|
62312
62498
|
code, path, monitor key and hint; ok:false exits 2. --based-on refuses a stale plan.
|
|
@@ -62349,9 +62535,12 @@ Executions and reports
|
|
|
62349
62535
|
Run trusted local tests without login or API access
|
|
62350
62536
|
JSON/report/logs/traces; video opt-in, fresh output per run
|
|
62351
62537
|
Project output must stay inside the E2E project
|
|
62352
|
-
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60]
|
|
62538
|
+
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60] [--update-baselines]
|
|
62353
62539
|
A finished run prints status, duration and message first;
|
|
62354
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
|
|
62355
62544
|
artifact get --id RUN_ID --path PATH --file OUTPUT
|
|
62356
62545
|
Download checksum-verified evidence; no overwrite
|
|
62357
62546
|
run status --id RUN_ID
|
|
@@ -62362,7 +62551,11 @@ Executions and reports
|
|
|
62362
62551
|
report get [--days 1|7|14] [--demo]
|
|
62363
62552
|
incident list [--demo]
|
|
62364
62553
|
|
|
62365
|
-
Visual review (
|
|
62554
|
+
Visual checks and baseline review (features.visual, features.visualReview; decisions
|
|
62555
|
+
require write access). A visual monitor screenshots one page or element and compares it
|
|
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.
|
|
62366
62559
|
visual list [--monitor-id ID] [--head-id HEAD] [--before CURSOR]
|
|
62367
62560
|
visual get --id COMPARISON_ID
|
|
62368
62561
|
visual artifacts --id COMPARISON_ID
|
|
@@ -62664,8 +62857,8 @@ ${exitCodes}
|
|
|
62664
62857
|
// package.json
|
|
62665
62858
|
var package_default = {
|
|
62666
62859
|
name: "@waitcher/cli",
|
|
62667
|
-
version: "0.2.
|
|
62668
|
-
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API and
|
|
62860
|
+
version: "0.2.16",
|
|
62861
|
+
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
|
|
62669
62862
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
62670
62863
|
author: "S\u0142awomir Radzymi\u0144ski",
|
|
62671
62864
|
homepage: "https://waitcher.dev/docs/",
|
|
@@ -62867,6 +63060,7 @@ async function main() {
|
|
|
62867
63060
|
global: { type: "boolean" },
|
|
62868
63061
|
wait: { type: "boolean" },
|
|
62869
63062
|
brief: { type: "boolean" },
|
|
63063
|
+
"update-baselines": { type: "boolean" },
|
|
62870
63064
|
timeout: { type: "string" },
|
|
62871
63065
|
days: { type: "string" },
|
|
62872
63066
|
demo: { type: "boolean" },
|
|
@@ -63088,7 +63282,14 @@ async function main() {
|
|
|
63088
63282
|
"monitor pause": ["id"],
|
|
63089
63283
|
"monitor resume": ["id"],
|
|
63090
63284
|
"monitor delete": ["id", "yes"],
|
|
63091
|
-
"run start": [
|
|
63285
|
+
"run start": [
|
|
63286
|
+
"id",
|
|
63287
|
+
"wait",
|
|
63288
|
+
"timeout",
|
|
63289
|
+
"request-key",
|
|
63290
|
+
"brief",
|
|
63291
|
+
"update-baselines"
|
|
63292
|
+
],
|
|
63092
63293
|
"run local": [
|
|
63093
63294
|
"file",
|
|
63094
63295
|
"project",
|
|
@@ -64486,7 +64687,7 @@ async function main() {
|
|
|
64486
64687
|
usage2(
|
|
64487
64688
|
"Provide --file PATH with the complete configuration and expectedRevision for edits."
|
|
64488
64689
|
);
|
|
64489
|
-
const text2 = await
|
|
64690
|
+
const text2 = await readFile11(v.file, "utf8");
|
|
64490
64691
|
if (Buffer.byteLength(text2) > 16e3)
|
|
64491
64692
|
usage2("Project configuration exceeds 16 KB");
|
|
64492
64693
|
let body2;
|
|
@@ -64575,7 +64776,12 @@ async function main() {
|
|
|
64575
64776
|
if (!["create", "adopt", "update"].includes(c.action) || c.type === "heartbeat")
|
|
64576
64777
|
continue;
|
|
64577
64778
|
if (limited) {
|
|
64578
|
-
smoke.push({
|
|
64779
|
+
smoke.push({
|
|
64780
|
+
key: c.key,
|
|
64781
|
+
monitorId: c.monitorId,
|
|
64782
|
+
status: "skipped",
|
|
64783
|
+
message: limited
|
|
64784
|
+
});
|
|
64579
64785
|
continue;
|
|
64580
64786
|
}
|
|
64581
64787
|
try {
|
|
@@ -64588,16 +64794,19 @@ async function main() {
|
|
|
64588
64794
|
await delay(1e3, void 0, { signal });
|
|
64589
64795
|
run2 = await api(`runs/${id3(queued.id)}`);
|
|
64590
64796
|
}
|
|
64797
|
+
const review = c.type === "visual" && run2.visual?.reason === "missing_baseline";
|
|
64591
64798
|
smoke.push({
|
|
64592
64799
|
key: c.key,
|
|
64593
64800
|
monitorId: c.monitorId,
|
|
64594
64801
|
runId: queued.id,
|
|
64595
|
-
|
|
64802
|
+
...review ? { comparisonId: run2.visual.id } : {},
|
|
64803
|
+
status: ["queued", "running"].includes(run2.status) ? "timeout" : review ? "baseline_review" : run2.status,
|
|
64596
64804
|
message: run2.message ?? void 0
|
|
64597
64805
|
});
|
|
64598
64806
|
} catch (cause) {
|
|
64599
64807
|
const error62 = asError(cause);
|
|
64600
|
-
if (error62.code === "RATE_LIMITED")
|
|
64808
|
+
if (error62.code === "RATE_LIMITED")
|
|
64809
|
+
limited = `RATE_LIMITED: ${error62.message}`;
|
|
64601
64810
|
smoke.push({
|
|
64602
64811
|
key: c.key,
|
|
64603
64812
|
monitorId: c.monitorId,
|
|
@@ -64627,12 +64836,14 @@ async function main() {
|
|
|
64627
64836
|
adopt
|
|
64628
64837
|
}),
|
|
64629
64838
|
...smoke.filter((r) => r.status !== "passed").map(
|
|
64630
|
-
(r) => 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}`
|
|
64631
64840
|
)
|
|
64632
64841
|
]
|
|
64633
64842
|
};
|
|
64634
64843
|
if (!deployed.ok) exitCode = 2;
|
|
64635
|
-
else if (smoke.some(
|
|
64844
|
+
else if (smoke.some(
|
|
64845
|
+
(r) => !["passed", "skipped", "baseline_review"].includes(r.status)
|
|
64846
|
+
))
|
|
64636
64847
|
exitCode = 4;
|
|
64637
64848
|
} else if (command === "deploy rollback") {
|
|
64638
64849
|
if (v["based-on"] !== void 0 && v["based-on"] !== "none" && !/^[0-9a-f-]{36}$/.test(v["based-on"]))
|
|
@@ -64726,7 +64937,7 @@ async function main() {
|
|
|
64726
64937
|
if (!v.file) usage2("Provide --file PATH for the configuration.");
|
|
64727
64938
|
let input2;
|
|
64728
64939
|
try {
|
|
64729
|
-
const text2 = await
|
|
64940
|
+
const text2 = await readFile11(v.file, "utf8");
|
|
64730
64941
|
if (Buffer.byteLength(text2) > 96e3)
|
|
64731
64942
|
usage2("Configuration exceeds 96 KB.");
|
|
64732
64943
|
input2 = JSON.parse(text2);
|
|
@@ -65010,7 +65221,14 @@ async function main() {
|
|
|
65010
65221
|
if (v.timeout && command === "run start" && !v.wait)
|
|
65011
65222
|
usage2("--timeout requires --wait with run start.");
|
|
65012
65223
|
const seconds = integer2(v.timeout ?? "60", "timeout", 1, 900);
|
|
65013
|
-
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)) };
|
|
65014
65232
|
if (command === "run start" && !v.wait)
|
|
65015
65233
|
result2 = { event: "queued", ...queued };
|
|
65016
65234
|
else {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waitcher/cli",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API and
|
|
3
|
+
"version": "0.2.16",
|
|
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",
|
|
7
7
|
"homepage": "https://waitcher.dev/docs/",
|