@waitcher/cli 0.2.15 → 0.2.17

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.mjs +384 -47
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -40,7 +40,7 @@ To watch how a page looks, add a visual entry: Waitcher screenshots the page on
40
40
  waitcher skill install
41
41
  ```
42
42
 
43
- installs the Waitcher skill where Claude Code and other agents look for it. `waitcher doctor` checks the setup, `waitcher explain CODE` explains any issue code, and `waitcher help TOPIC` prints exact syntax for this version.
43
+ installs the Waitcher skill where Claude Code and other agents look for it. `waitcher doctor` checks the setup, `waitcher explain CODE` explains any issue code, and `waitcher help TOPIC` prints exact syntax for this version. The skill and example monitors are also public at https://github.com/waitcher/skills.
44
44
 
45
45
  ## More
46
46
 
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: readFile11, mkdir: mkdir11 } = __require("node:fs/promises");
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 readFile11(resolve18(path2), "utf8");
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({
@@ -55939,6 +55970,8 @@ var ACCOUNT_PLANS = Object.freeze({
55939
55970
  scriptDailyRuns: 12,
55940
55971
  // Agent checks (docs/AGENT-CHECKS.md), each a script monitor too.
55941
55972
  agentChecks: 0,
55973
+ // Public status pages (docs/STATUS-PAGES.md).
55974
+ statusPages: 1,
55942
55975
  // Days evidence files and run history are kept (docs/STORAGE.md).
55943
55976
  artifactDays: 7,
55944
55977
  historyDays: 14
@@ -55951,6 +55984,7 @@ var ACCOUNT_PLANS = Object.freeze({
55951
55984
  scriptMinInterval: 300,
55952
55985
  scriptDailyRuns: 480,
55953
55986
  agentChecks: 1,
55987
+ statusPages: 3,
55954
55988
  artifactDays: 30,
55955
55989
  historyDays: 30
55956
55990
  }),
@@ -55965,6 +55999,7 @@ var ACCOUNT_PLANS = Object.freeze({
55965
55999
  scriptMinInterval: 300,
55966
56000
  scriptDailyRuns: 480,
55967
56001
  agentChecks: 1,
56002
+ statusPages: 3,
55968
56003
  artifactDays: 30,
55969
56004
  historyDays: 30
55970
56005
  }),
@@ -55977,6 +56012,7 @@ var ACCOUNT_PLANS = Object.freeze({
55977
56012
  scriptMinInterval: 120,
55978
56013
  scriptDailyRuns: 2500,
55979
56014
  agentChecks: 5,
56015
+ statusPages: 10,
55980
56016
  artifactDays: 30,
55981
56017
  historyDays: 30
55982
56018
  })
@@ -56665,7 +56701,7 @@ import { performance as performance5 } from "node:perf_hooks";
56665
56701
  import {
56666
56702
  mkdir as mkdir4,
56667
56703
  lstat as lstat7,
56668
- readFile as readFile3,
56704
+ readFile as readFile4,
56669
56705
  realpath,
56670
56706
  readdir,
56671
56707
  writeFile as writeFile4
@@ -57795,6 +57831,8 @@ import {
57795
57831
  symlink,
57796
57832
  mkdtemp,
57797
57833
  rm as rm3,
57834
+ readFile as readFile2,
57835
+ copyFile,
57798
57836
  lstat as lstat5
57799
57837
  } from "node:fs/promises";
57800
57838
  import { constants as constants9 } from "node:fs";
@@ -57916,7 +57954,113 @@ function child(command, args, {
57916
57954
  );
57917
57955
  }
57918
57956
 
57957
+ // ../../src/visual/screenshot-outcome.ts
57958
+ var RESULTS = ".e2e/results/";
57959
+ var STORED = "tests/monitor.e2e.ts-snapshots/";
57960
+ function screenshotOutcome(report) {
57961
+ const run2 = report?.run ?? report;
57962
+ const results = run2?.results;
57963
+ if (!Array.isArray(results)) return null;
57964
+ for (const result2 of results) {
57965
+ for (const attempt of Array.isArray(result2?.attempts) ? result2.attempts : []) {
57966
+ const error62 = attempt?.error;
57967
+ const expected = error62?.details?.expected, observed = error62?.details?.observed;
57968
+ if (error62?.code !== "ASSERTION_FAILED" || typeof error62.message !== "string" || !error62.message.startsWith("expect.toHaveScreenshot failed") || typeof expected !== "string" || typeof observed !== "string" || !expected.startsWith(STORED))
57969
+ continue;
57970
+ const file2 = expected.slice(STORED.length);
57971
+ if (!SCRIPT_SCREENSHOT_FILE.test(file2)) return null;
57972
+ const paths = (Array.isArray(attempt.artifacts) ? attempt.artifacts : []).map((a) => a?.path).filter(
57973
+ (p) => typeof p === "string" && p.length < 900 && !p.includes("..")
57974
+ );
57975
+ const find = (suffix) => {
57976
+ const path2 = paths.find((p) => p.endsWith(suffix));
57977
+ return path2 ? RESULTS + path2 : void 0;
57978
+ };
57979
+ if (observed === "no stored screenshot") {
57980
+ const actual2 = find(`/snapshots/${expected}`);
57981
+ return actual2 ? { kind: "missing", file: file2, actual: actual2 } : null;
57982
+ }
57983
+ const actual = find("-actual.png"), stored = find("-expected.png");
57984
+ if (!actual || !stored) return null;
57985
+ const pixels = /^(\d{1,9}) pixels \(/.exec(observed);
57986
+ if (pixels) {
57987
+ const diff = find("-diff.png");
57988
+ return diff ? {
57989
+ kind: "pixels",
57990
+ file: file2,
57991
+ actual,
57992
+ expected: stored,
57993
+ diff,
57994
+ differentPixels: Number(pixels[1])
57995
+ } : null;
57996
+ }
57997
+ return /^a \d+x\d+ screenshot where /.test(observed) ? { kind: "size", file: file2, actual, expected: stored } : null;
57998
+ }
57999
+ }
58000
+ return null;
58001
+ }
58002
+
58003
+ // ../../src/visual/test-script.ts
58004
+ var CAPTURE_SUFFIX = "-capture";
58005
+ function visualTest(input2, timeoutSeconds) {
58006
+ const config2 = visualConfigSchema.parse(input2);
58007
+ const s = (value2) => JSON.stringify(value2);
58008
+ const name5 = config2.checkpoint.id;
58009
+ const subject = config2.checkpoint.kind === "element" ? `browser.locator(${s(config2.checkpoint.selector)})` : "screen";
58010
+ const budget = Math.max(
58011
+ 1e3,
58012
+ Math.min(config2.captureBudgetMs, timeoutSeconds * 1e3 - 5e3, 1e4)
58013
+ );
58014
+ const script = `import { test, expect } from 'e2e';
58015
+ test(${s(name5)}, async ({ app, browser, screen }) => {
58016
+ // Open the page twice. Each run starts with an empty cache, and a site
58017
+ // whose fonts use font-display: optional keeps the fallback font for the
58018
+ // whole visit when a font takes longer than about 100 ms. The first visit
58019
+ // fills the cache, so the captured second one renders like a returning
58020
+ // visitor's, every time.
58021
+ await app.open('');
58022
+ await browser.evaluate(() => document.fonts.ready.then(() => true));
58023
+ await app.open('');
58024
+ await expect(browser.locator(${s(config2.ready.selector)})).toBeVisible({ timeout: ${config2.ready.timeoutMs} });
58025
+ await browser.evaluate(() => document.fonts.ready.then(() => true));
58026
+ ${config2.masks.map(
58027
+ (mask) => ` await expect(browser.locator(${s(mask)})).not.toHaveCount(0, { timeout: ${config2.ready.timeoutMs} });`
58028
+ ).join("\n")}
58029
+ await expect(${subject}).toHaveScreenshot(${s(`${name5}.png`)}, {
58030
+ threshold: ${config2.thresholds.pixelThreshold},
58031
+ maxDiffPixelRatio: ${config2.thresholds.maxDiffRatio},
58032
+ mask: [${config2.masks.map((mask) => `browser.locator(${s(mask)})`).join(", ")}],
58033
+ maskColor: '#808080',
58034
+ timeout: ${budget},
58035
+ });
58036
+ // The framework keeps no image of a passing comparison. A second
58037
+ // screenshot under a name that has no baseline is written to the results
58038
+ // instead; its "missing" failure is expected and caught, and the server
58039
+ // measures this capture against the baseline for the run's record.
58040
+ try {
58041
+ await expect(${subject}).toHaveScreenshot(${s(`${name5}${CAPTURE_SUFFIX}.png`)}, {
58042
+ mask: [${config2.masks.map((mask) => `browser.locator(${s(mask)})`).join(", ")}],
58043
+ maskColor: '#808080',
58044
+ timeout: ${budget},
58045
+ });
58046
+ } catch {}
58047
+ });
58048
+ `;
58049
+ return {
58050
+ script,
58051
+ web: {
58052
+ viewport: VISUAL_VIEWPORTS[config2.viewport],
58053
+ locale: config2.locale,
58054
+ timezoneId: config2.timezone,
58055
+ colorScheme: "light",
58056
+ reducedMotion: "reduce"
58057
+ }
58058
+ };
58059
+ }
58060
+
57919
58061
  // ../../src/checks/e2e.ts
58062
+ var SNAPSHOT_DIRECTORY = "monitor.e2e.ts-snapshots";
58063
+ var SNAPSHOT_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,150}\.png$/;
57920
58064
  async function collectArtifacts(dir, base2 = dir, tokens2 = [], excluded = /* @__PURE__ */ new Set()) {
57921
58065
  const result2 = [];
57922
58066
  let entries2 = 0;
@@ -58065,6 +58209,15 @@ export const dataGradeSummary=grader.summary;
58065
58209
  );
58066
58210
  await mkdir2(join5(dir, "tests"));
58067
58211
  await writeFile2(join5(dir, "tests", "monitor.e2e.ts"), m.script);
58212
+ if (options.snapshots && Object.keys(options.snapshots).length) {
58213
+ const stored = join5(dir, "tests", SNAPSHOT_DIRECTORY);
58214
+ await mkdir2(stored, { mode: 448 });
58215
+ for (const [name5, bytes2] of Object.entries(options.snapshots)) {
58216
+ if (!SNAPSHOT_FILE.test(name5))
58217
+ throw Error("Invalid stored screenshot name");
58218
+ await writeFile2(join5(stored, name5), bytes2, { mode: 384, flag: "wx" });
58219
+ }
58220
+ }
58068
58221
  const config2 = {
58069
58222
  tests: ["tests/*.e2e.ts"],
58070
58223
  workers: 1,
@@ -58081,7 +58234,10 @@ export const dataGradeSummary=grader.summary;
58081
58234
  reporters: options.reporters ?? ["list"],
58082
58235
  targets: []
58083
58236
  };
58084
- 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)}}),viewport:{width:1280,height:800}})` : "browserOverride?web({browser:protectedBrowserProvider({chromium}),viewport:{width:1280,height:800}}):web({viewport:{width:1280,height:800}})"},app:{url:${JSON.stringify(m.target)}}}]` : `[{name:'api',platform:'api'}]`;
58237
+ const webOptions = JSON.stringify(
58238
+ options.web ?? { viewport: { width: 1280, height: 800 } }
58239
+ ).slice(1, -1);
58240
+ 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
58241
  const modelSource = dispatch ? `import {brokerModel} from ${JSON.stringify(pathToFileURL(options.modelClientFile ?? resolve8(root, "dist/model-client.mjs")).href)};
58086
58242
  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
58243
  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 +58328,7 @@ try {
58172
58328
  const environment = options.environment ?? process.env;
58173
58329
  for (const name5 of envNames)
58174
58330
  if (environment[name5]) env[name5] = environment[name5];
58175
- const p = await (options.execute ?? child)(
58331
+ const launch = () => (options.execute ?? child)(
58176
58332
  process.execPath,
58177
58333
  [join5(dir, "waitcher-run.mjs")],
58178
58334
  {
@@ -58183,6 +58339,22 @@ try {
58183
58339
  interruptGraceMs: options.interruptGraceMs
58184
58340
  }
58185
58341
  );
58342
+ let p = await launch();
58343
+ for (let pass = 0; options.localSnapshots && !dispatch && !requestDispatch && pass < SCRIPT_SCREENSHOT_LIMITS.files && !signal?.aborted; pass++) {
58344
+ let outcome;
58345
+ try {
58346
+ outcome = screenshotOutcome(
58347
+ JSON.parse(await readFile2(join5(dir, ".e2e", "report.json"), "utf8"))
58348
+ );
58349
+ } catch {
58350
+ }
58351
+ if (outcome?.kind !== "missing") break;
58352
+ const stored = join5(dir, "tests", SNAPSHOT_DIRECTORY);
58353
+ await mkdir2(stored, { recursive: true, mode: 448 });
58354
+ await copyFile(join5(dir, outcome.actual), join5(stored, outcome.file));
58355
+ await rm3(join5(dir, ".e2e"), { recursive: true, force: true });
58356
+ p = await launch();
58357
+ }
58186
58358
  let report;
58187
58359
  try {
58188
58360
  const file2 = await open12(join5(dir, ".e2e", "report.json"), "r");
@@ -58335,6 +58507,16 @@ function identitySecretValues(identity) {
58335
58507
  ].filter((value2) => [...value2].length >= 6).flatMap((value2) => [value2, JSON.stringify(value2).slice(1, -1)]);
58336
58508
  }
58337
58509
  async function scriptCheck(m, dir, signal, options = {}) {
58510
+ if (m.type === "visual") {
58511
+ const { script, web } = visualTest(m.visual, m.timeout);
58512
+ const { visual: _, ...rest } = m;
58513
+ return scriptCheckInternal(
58514
+ { ...rest, type: "browser", script },
58515
+ dir,
58516
+ signal,
58517
+ { ...options, web }
58518
+ );
58519
+ }
58338
58520
  const identity = options.browserIdentity === void 0 ? void 0 : browserExecutionIdentitySchema.parse(options.browserIdentity);
58339
58521
  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
58522
  throw Error(
@@ -58400,7 +58582,8 @@ async function execute(monitor, runDir, {
58400
58582
  judgeComplete,
58401
58583
  httpFetch,
58402
58584
  httpCredential,
58403
- browserIdentity
58585
+ browserIdentity,
58586
+ snapshots
58404
58587
  } = {}) {
58405
58588
  const start = performance4.now();
58406
58589
  let result2;
@@ -58419,8 +58602,6 @@ async function execute(monitor, runDir, {
58419
58602
  "AI execution requires a private model grant; no script was started"
58420
58603
  );
58421
58604
  await mkdir3(runDir, { recursive: true });
58422
- if (monitor.type === "visual")
58423
- throw Error("Visual checks require the leased scheduler adapter");
58424
58605
  if (monitor.type === "ai")
58425
58606
  result2 = await aiEndpointCheck(monitor, signal, {
58426
58607
  fetch: aiEndpointFetch,
@@ -58466,7 +58647,8 @@ async function execute(monitor, runDir, {
58466
58647
  result2 = await scriptCheck(monitor, runDir, signal, {
58467
58648
  environment,
58468
58649
  model,
58469
- browserIdentity
58650
+ browserIdentity,
58651
+ ...snapshots ? { snapshots } : {}
58470
58652
  });
58471
58653
  } catch (cause) {
58472
58654
  const error62 = asError(cause);
@@ -59152,7 +59334,7 @@ function projectConfigJsonSchema() {
59152
59334
 
59153
59335
  // src/local-models.ts
59154
59336
  import { constants as constants11 } from "node:fs";
59155
- import { open as open14, readFile as readFile2 } from "node:fs/promises";
59337
+ import { open as open14, readFile as readFile3 } from "node:fs/promises";
59156
59338
  import { dirname as dirname7, resolve as resolve9 } from "node:path";
59157
59339
 
59158
59340
  // src/models.ts
@@ -59302,7 +59484,7 @@ async function readLocalModelConnection(file2, monitor, binding = monitor.ai) {
59302
59484
  async function localModelClientSource() {
59303
59485
  for (const relative4 of ["./model-client.mjs", "../dist/model-client.mjs"]) {
59304
59486
  try {
59305
- return await readFile2(new URL(relative4, import.meta.url), "utf8");
59487
+ return await readFile3(new URL(relative4, import.meta.url), "utf8");
59306
59488
  } catch {
59307
59489
  }
59308
59490
  }
@@ -59750,7 +59932,7 @@ async function runtime(project, browser, ai = false) {
59750
59932
  }
59751
59933
  const root2 = dirname8(dirname8(entry2));
59752
59934
  const metadata2 = JSON.parse(
59753
- await readFile3(join8(root2, "package.json"), "utf8")
59935
+ await readFile4(join8(root2, "package.json"), "utf8")
59754
59936
  );
59755
59937
  if (metadata2.name !== name5 || (name5 in RUNTIME_PINS ? runtimePinStatus(name5, metadata2.version) === "mismatch" : metadata2.version !== version2))
59756
59938
  invalid2(
@@ -59771,7 +59953,7 @@ async function inventory(root) {
59771
59953
  if (item.isSymbolicLink() || item.name === "node_modules") continue;
59772
59954
  if (item.isDirectory()) await walk(full);
59773
59955
  else if (item.isFile()) {
59774
- const bytes2 = await readFile3(full);
59956
+ const bytes2 = await readFile4(full);
59775
59957
  files.push({
59776
59958
  path: relative(root, full).split(sep).join("/"),
59777
59959
  bytes: bytes2.length,
@@ -60059,6 +60241,9 @@ async function runLocal(options) {
60059
60241
  signal,
60060
60242
  {
60061
60243
  runtimeRoot: project,
60244
+ // Baselines are approved in Waitcher; locally a stored
60245
+ // screenshot is compared with a capture taken moments earlier.
60246
+ localSnapshots: true,
60062
60247
  requestClientFile: join8(
60063
60248
  directory,
60064
60249
  "waitcher-request-runtime.mjs"
@@ -60138,7 +60323,7 @@ async function runLocal(options) {
60138
60323
  const path2 = join8(directory, evidence, "report.json");
60139
60324
  if ((await lstat7(path2)).size > STORAGE_LIMITS.artifactFileBytes)
60140
60325
  throw Error("Local E2E report exceeds its 8 MiB budget");
60141
- const report = JSON.parse(await readFile3(path2, "utf8"));
60326
+ const report = JSON.parse(await readFile4(path2, "utf8"));
60142
60327
  const passed = result3.code === 0 && report.run?.status === "passed" && report.run.results?.length > 0 && report.run.results.every(
60143
60328
  (r) => r.status === "passed"
60144
60329
  );
@@ -60494,7 +60679,7 @@ async function runLocalCalibration(options) {
60494
60679
  // src/bundle.ts
60495
60680
  import { createRequire as createRequire2, isBuiltin } from "node:module";
60496
60681
  import { createHash as createHash10 } from "node:crypto";
60497
- import { readFile as readFile4, realpath as realpath2, mkdir as mkdir6, writeFile as writeFile6, rm as rm4 } from "node:fs/promises";
60682
+ import { readFile as readFile5, realpath as realpath2, mkdir as mkdir6, writeFile as writeFile6, rm as rm4 } from "node:fs/promises";
60498
60683
  import { basename, dirname as dirname10, join as join10, relative as relative2, resolve as resolve12, sep as sep2, extname } from "node:path";
60499
60684
  import { pathToFileURL as pathToFileURL2 } from "node:url";
60500
60685
  var sha = (bytes2) => createHash10("sha256").update(bytes2).digest("hex");
@@ -60527,7 +60712,7 @@ async function bundleMonitor(options) {
60527
60712
  return name5.split(sep2).join("/");
60528
60713
  }
60529
60714
  projectPath(sourceManifest);
60530
- const manifestText = await readFile4(sourceManifest, "utf8");
60715
+ const manifestText = await readFile5(sourceManifest, "utf8");
60531
60716
  let definition;
60532
60717
  try {
60533
60718
  definition = await readManifest(sourceManifest);
@@ -60536,7 +60721,7 @@ async function bundleMonitor(options) {
60536
60721
  error62 instanceof Error ? error62.message : "Invalid source manifest."
60537
60722
  );
60538
60723
  }
60539
- if (manifestText !== await readFile4(sourceManifest, "utf8"))
60724
+ if (manifestText !== await readFile5(sourceManifest, "utf8"))
60540
60725
  invalid4(
60541
60726
  "The source manifest changed during the build. Retry with stable inputs."
60542
60727
  );
@@ -60634,7 +60819,7 @@ async function buildScript({
60634
60819
  );
60635
60820
  }
60636
60821
  const toolMetadata = JSON.parse(
60637
- await readFile4(join10(dirname10(dirname10(tool)), "package.json"), "utf8")
60822
+ await readFile5(join10(dirname10(dirname10(tool)), "package.json"), "utf8")
60638
60823
  );
60639
60824
  if (toolMetadata.name !== "esbuild" || runtimePinStatus("esbuild", toolMetadata.version) === "mismatch")
60640
60825
  invalid4(
@@ -60647,7 +60832,7 @@ async function buildScript({
60647
60832
  const actual = await realpath2(path2), name5 = projectPath(actual);
60648
60833
  if (inputs.size >= 64 && !inputs.has(name5))
60649
60834
  invalid4("A portable monitor may bundle at most 64 source files.");
60650
- const contents = await readFile4(actual);
60835
+ const contents = await readFile5(actual);
60651
60836
  inputBytes += contents.length;
60652
60837
  if (contents.length > 512e3 || inputBytes > 1024e3)
60653
60838
  invalid4("Build inputs exceed the 1 MB source budget.");
@@ -60759,7 +60944,7 @@ async function buildScript({
60759
60944
  let lock = null;
60760
60945
  for (const name5 of ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"]) {
60761
60946
  try {
60762
- lock = { path: name5, sha256: sha(await readFile4(join10(project, name5))) };
60947
+ lock = { path: name5, sha256: sha(await readFile5(join10(project, name5))) };
60763
60948
  break;
60764
60949
  } catch (error62) {
60765
60950
  if (error62.code !== "ENOENT") throw error62;
@@ -60781,7 +60966,7 @@ async function buildScript({
60781
60966
  }
60782
60967
 
60783
60968
  // src/config.ts
60784
- import { readFile as readFile6, realpath as realpath3, mkdir as mkdir7, writeFile as writeFile8, rm as rm5 } from "node:fs/promises";
60969
+ import { readFile as readFile7, realpath as realpath3, mkdir as mkdir7, writeFile as writeFile8, rm as rm5 } from "node:fs/promises";
60785
60970
  import { execFile } from "node:child_process";
60786
60971
  import { randomUUID as randomUUID6 } from "node:crypto";
60787
60972
  import { dirname as dirname12, join as join12, resolve as resolve13 } from "node:path";
@@ -60789,7 +60974,7 @@ import { promisify } from "node:util";
60789
60974
 
60790
60975
  // src/runtime.ts
60791
60976
  import { spawn as spawn2 } from "node:child_process";
60792
- import { access, readFile as readFile5, writeFile as writeFile7 } from "node:fs/promises";
60977
+ import { access, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
60793
60978
  import { createRequire as createRequire3 } from "node:module";
60794
60979
  import { basename as basename2, dirname as dirname11, join as join11 } from "node:path";
60795
60980
  import { pathToFileURL as pathToFileURL3 } from "node:url";
@@ -60801,7 +60986,7 @@ async function installedPackage(project, name5) {
60801
60986
  );
60802
60987
  for (let i = 0; i < 6; i++, dir = dirname11(dir)) {
60803
60988
  try {
60804
- const meta3 = JSON.parse(await readFile5(join11(dir, "package.json"), "utf8"));
60989
+ const meta3 = JSON.parse(await readFile6(join11(dir, "package.json"), "utf8"));
60805
60990
  if (meta3.name === name5) return { dir, version: meta3.version };
60806
60991
  } catch {
60807
60992
  }
@@ -60881,7 +61066,7 @@ function run(command, args, cwd, signal) {
60881
61066
  async function installRuntime(options) {
60882
61067
  const { project, browser, yes, signal } = options;
60883
61068
  const manifestPath = join11(project, "package.json");
60884
- const text2 = await readFile5(manifestPath, "utf8").catch(() => null);
61069
+ const text2 = await readFile6(manifestPath, "utf8").catch(() => null);
60885
61070
  let existing = null;
60886
61071
  if (text2 !== null)
60887
61072
  try {
@@ -60902,7 +61087,7 @@ async function installRuntime(options) {
60902
61087
  (name5) => runtimePinStatus(name5, installed[name5], {}) !== "current"
60903
61088
  );
60904
61089
  const ignorePath = join11(project, ".gitignore");
60905
- const ignoreText = await readFile5(ignorePath, "utf8").catch(() => "");
61090
+ const ignoreText = await readFile6(ignorePath, "utf8").catch(() => "");
60906
61091
  const ignores = [];
60907
61092
  for (const entry2 of missingIgnores(ignoreText))
60908
61093
  if (!await gitIgnored(project, entry2)) ignores.push(entry2);
@@ -61107,7 +61292,7 @@ async function verifyLocally(options) {
61107
61292
  const summary2 = join12(result2.directory, ".e2e", "summary.md");
61108
61293
  let failure3;
61109
61294
  if (result2.status !== "passed") {
61110
- const lines = (await readFile6(summary2, "utf8").catch(() => "")).split("\n");
61295
+ const lines = (await readFile7(summary2, "utf8").catch(() => "")).split("\n");
61111
61296
  const test = lines.map((l) => /^\*\*🔴 (.+)\*\*/.exec(l.trim())?.[1]).find(Boolean);
61112
61297
  const error62 = lines.find((l) => l.startsWith("> "))?.slice(2).trim();
61113
61298
  if (error62) failure3 = `${test ? `"${test}": ` : ""}${error62}`.slice(0, 300);
@@ -61140,7 +61325,7 @@ async function readProjectConfig(file2) {
61140
61325
  const path2 = configPath(file2);
61141
61326
  let text2;
61142
61327
  try {
61143
- text2 = await readFile6(path2, "utf8");
61328
+ text2 = await readFile7(path2, "utf8");
61144
61329
  } catch {
61145
61330
  throw new ServiceError(
61146
61331
  `${path2} was not found. Run waitcher config init or pass --file.`,
@@ -61219,7 +61404,7 @@ function deployNextSteps(result2, {
61219
61404
  );
61220
61405
  else if (c.action === "create" && c.type === "visual" && !smoked)
61221
61406
  steps.push(
61222
- `waitcher run start --id ${c.monitorId} --wait takes the first capture; approve it as the baseline (waitcher visual list --monitor-id ${c.monitorId}, then waitcher visual approve), then waitcher monitor resume --id ${c.monitorId}`
61407
+ `waitcher run start --id ${c.monitorId} --update-baselines --wait captures the first baseline; check it with waitcher visual list --monitor-id ${c.monitorId} and waitcher visual image, then waitcher monitor resume --id ${c.monitorId}`
61223
61408
  );
61224
61409
  else if (c.action === "create" && !c.enabled)
61225
61410
  steps.push(
@@ -61230,7 +61415,7 @@ function deployNextSteps(result2, {
61230
61415
  }
61231
61416
 
61232
61417
  // ../../skills/waitcher/SKILL.md
61233
- 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";
61418
+ 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, agent checks, public status pages.\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";
61234
61419
 
61235
61420
  // ../../skills/waitcher/references/authoring.md
61236
61421
  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';
@@ -61245,13 +61430,13 @@ var deploy_default = '# Repository deploys\n\nRead when the user keeps monitors
61245
61430
  var diagnosis_default = "# Diagnosing failures\n\nRead when a local, smoke or scheduled run failed or errored.\n\n## Diagnose and reproduce a retained run\n\nConfirm `features.runDiagnosis` for hosted support. Use `run diagnose --id RUN_ID` for a readable hosted packet, or add `--json` for the shared structured report. Use `run diagnose --directory PRIVATE_RUN_DIRECTORY` without an account to inspect indexed local evidence. Hosted request states come from the controller ledger; local helper observations are explicitly local and do not attest hosted accounting. A known response does not prove task success, and an unknown action may have taken effect. Do not automatically repeat a mutation because its result is unknown.\n\nA historical pass is useful only when the frozen verification policy matches. Changed scripts, targets, deadlines or protected-operation policies cannot supply a matching reference. History searches are bounded; unavailable or truncated history is not proof that the product never passed. Stored artifact checksums are metadata; inspect the actual artifact when needed. Scenario evidence is checked against its recorded checksum before display.\n\nFor a completed supported hosted script, `run reproduce --id RUN_ID --output NEW_DIRECTORY` prepares its frozen configuration in a new private folder. It never executes the test or retrieves the current edited monitor. Inspect `monitor.json` and `provenance.json`, then deliberately run `run local --file NEW_DIRECTORY/monitor.json --output FRESH_RUN_DIRECTORY` with the matching installed runtime, optionally `--runtime PROJECT`. Reproduction is a fresh run with separate provenance and does not replace the original evidence.\n\nManaged product credentials, AI keys and browser sessions are not exported. Supply existing private local mappings with `--http-credentials-file`, `--connections-file` and `--browser-identities-file` where required. Authored scripts and literal configuration can themselves be sensitive, so keep the reproduction private. Operator-injected headers, bodies or environment state make this initial portable preparation unavailable rather than silently changing the test. Older local runs without an indexed frozen manifest remain inspectable but cannot establish a captured reproduction policy.\n";
61246
61431
 
61247
61432
  // ../../skills/waitcher/references/optional-capabilities.md
61248
- var optional_capabilities_default = '# Optional capabilities\n\nRead only when capabilities report the feature and the user needs it: visual baselines, signed-in browser identities, verified HTTP credentials and invocation budgets. AI endpoints, agent outcome checks, model steps and protected requests are in [ai-and-agents](ai-and-agents.md).\n\n## Optional visual checks\n\nDiscover `features.visual` for authoring and `features.visualReview` for baseline inspection; `features.isolatedVisual` says personal captures run in the hosted runner. A visual monitor counts as one of the plan\'s script monitors and each capture as a script run; `limits.visual.minInterval` is the shortest interval (2 hours on the free plan, 30 minutes otherwise). In a repository, add a `waitcher.json` entry such as `{ "key": "home-look", "type": "visual", "path": "/" }` with an optional `visual` block (page/element checkpoint, viewport, readiness, masks, thresholds) and deploy it like any other monitor; with `--smoke` the first capture is reported as `baseline_review` with the commands that show and approve it. For one monitor outside a repository, start with `monitor init --type visual --target https://product.example --file visual.json`, then `monitor validate --file visual.json` and `monitor apply --file visual.json --dry-run`. Apply paused; an authorized `run start --id ID --wait` is a separate action. User guide: https://waitcher.dev/docs/visual.md. Visual monitors accept no script, model binding, session identity or custom request credential. Fixed visual baseline execution is not supported by `run local`; local API/browser script evidence does not establish a visual baseline.\n\nThe first capture needs baseline review; its `missing_baseline` result is missing coverage, not a product failure. Inspect `visual list`, `visual get --id COMPARISON_ID`, `visual heads --id MONITOR_ID`, `visual artifacts --id COMPARISON_ID` and `visual image --id COMPARISON_ID --role candidate|original|diff --file NEW_PRIVATE_PATH`. Review actual images and metrics before an authorized `visual approve --id COMPARISON_ID --expected-revision SELECTED_REVISION`; an initial selection uses 0. Restore only a reviewed retained baseline with `visual restore --id HEAD_ID --baseline-id BASELINE_ID --expected-revision CURRENT_HEAD_REVISION`. Stale decisions conflict: reload instead of retrying or changing revisions blindly. Approval preserves the historical result. Changed capture fingerprints need their own baseline. Foreign-owner/read-only refusals are boundaries, not reasons to switch credentials. Screenshots are private evidence; masks cover selected pixels only. Use actual `visual` and `run` help for current flags and capabilities.\n\n## Optional browser test-account identity\n\nFor a signed-in browser journey, discover hosted `features.browserIdentities` before configuring `identity create/rotate/enable/disable/delete`. Supply bounded cookies/localStorage through a private `--state-file`; metadata is scoped to one verified exact origin, project/environment and explicit expiry. State is write-only and cannot be exported. New identities default disabled; enable explicitly and bind the resulting current `{identityId, revision}` under `browserIdentity` in a version-2 browser manifest with explicit context. Rename, state replacement and enable/disable advance revisions; inspect current metadata and deliberately rebind rather than silently upgrading. After an uncertain write inspect metadata before retrying. No running Chrome profile is imported.\n\nRun the same manifest account-free with `run local --file MONITOR --runtime RUNTIME --browser-identities-file PRIVATE_MAP`. The map is `{schemaVersion:1,identities:[{identityId,revision,projectId,environmentId,origin,expiresAt,stateFile}]}`; state paths resolve relative to the map. Both map/state are private regular JSON files (chmod 600), no symlinks/hard links or inline state. Exact IDs/revision/scope/origin and bounded future expiry must match. Local mappings do not attest hosted target verification or revocation. The optional model map remains separate. Hosted identity-backed runs use the isolated lane for all owners; local code remains trusted. The selected script receives its own session and signed-in page content can reach private evidence or optional AI providers. Never promise pixel/encoded-secret masking. Use dedicated test accounts and inspect coverage errors after expiry/revocation before repeating a possibly completed action.\n\n## Verified HTTP credentials\n\nFor an authenticated HTTP or AI endpoint, use the user\'s owned verified HTTPS origin and an `httpAuth` reference (`targetId`, `credentialId`, `credentialRevision`). Check `features.httpTargets` before hosted configuration. Create/renew a target challenge with `target create` or `target challenge`, writing it to a new private `--output`; never print the token. The user publishes the supplied proof at `/.well-known/waitcher-verification.txt`, then `target verify` checks it without credentials. Verification expires after 24 hours and must be renewed. An origin excludes paths, query and fragments and is immutable.\n\nUse `target credential create/rotate` with non-secret metadata JSON plus `--credential-file` (mode 600) or `--credential-stdin`. Headers are limited to `Authorization` or `X-Api-Key`; values are complete single-line ASCII header values up to 4096 bytes. For Bearer auth, include the `Bearer ` prefix in the private value. Keys are write-only and encrypted on the server. The monitor and export retain references only. Rotation advances the credential revision; update the monitor binding explicitly. Disabled, expired, foreign or stale bindings fail without forwarding a request. Authenticated redirects are never followed.\n\nFor local execution without the app or account, pass `run local --file monitor.json --http-credentials-file private/http-map.json`. The private map is `{schemaVersion:1,credentials:[{targetId,credentialId,credentialRevision,origin,header,credentialFile}]}` and the referenced private file contains the raw header value. Paths resolve relative to the map. Never inline a key or reuse the CLI\'s own account cookie/token as a target credential. The local resolver requires exactly matching IDs, revision and canonical origin, and the shared runner enforces the single supported header and redirect policy. Local mapping does not prove that the hosted target is still verified or its key current. Keep the same manifest as the hosted monitor; only local key resolution differs. HTTP local checks need no E2E runtime. Use explicit user authorization for POST fixtures that change state.\n\n## Hosted endpoint invocation budgets\n\nBefore running dedicated AI endpoints or HTTP checks with `httpAuth`, read `account invocations` for the account/monitor UTC-day counters and limits. The manifest accepts `requestBudget: {dailyInvocations: N}` (default 50, maximum 1,000). Configure the owner cap with `account budget --daily-invocations N --expected-revision CURRENT_REVISION` only when authorized; personal accounts cap at 200, administrators at 5,000, and the controller also has a global 5,000 cap. Validate/apply/export do not charge calls.\n\n`INVOCATION_BUDGET_EXHAUSTED` is a coverage error: no request was dispatched and no product incident is created. Do not automatically retry or raise a limit to bypass it. Completed and uncertain dispatched calls consume budget, independent of product success or worker-reported usage. Local execution needs no account, preserves the setting and makes at most one endpoint call per fixture case, but does not enforce or consume the hosted daily ledger. After backup restore, `window.restoreHeld` blocks these checks until the next UTC reset because snapshot counters may be stale; do not bypass the hold by raising caps. These are request counts, separate from model-broker token/call caps and downstream provider spending. Inspect `account invocations` and the current `account` help for the hosted accounting contract.\n\n## Agent checks\n\nWhen `features.agentChecks` is true, an `api` entry may carry an `agent` block: Claude Code works on `task` in a sandbox, then the entry\'s script verifies the product\'s state ([guide](https://waitcher.dev/docs/agent-checks.md)). It needs a model connection in the entry\'s project environment (`connection create`, OpenRouter, the key from a private file) and fields `connectionId`, `configurationRevision`, `model`, `task`, optionally `seconds`, `turns`, `tokens`, `hosts` and `envNames` (a subset of `settings.envNames`). Read `limits.agentChecks` for the plan\'s count and bounds; the interval is at least 6 hours. Write the task as a user would say it and never put a secret in it. The verifier must reset the test account it checks. Ask before creating a connection: it stores the user\'s key and every run is billed to it.\n';
61433
+ 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\n## Status pages\n\nWhen `features.statusPages` is true, the account can publish public pages at `https://waitcher.dev/status/SLUG` ([guide](https://waitcher.dev/docs/status-pages.md)); `limits.statusPages` is the plan\'s count. `waitcher status-page save --file page.json` takes `slug`, `title` and `components` (`monitorId`, a public `name`, optional `group`); `waitcher help status` has the full shape. A page is private until `"published": true` and asks search engines not to index it unless `"indexable": true`. Write public names the user\'s customers would recognise, never a target URL or an internal monitor name; ask before publishing, because the address is public. During an incident, `waitcher incident update --id INCIDENT_ID --kind identified --message TEXT` posts a note to every page that shows the monitor; only post text the user wrote or approved.\n';
61249
61434
 
61250
61435
  // ../../skills/waitcher/agents/openai.yaml
61251
61436
  var openai_default = 'interface:\n display_name: "Waitcher"\n short_description: "Deploy monitoring from a repository and inspect evidence"\n default_prompt: "Use $waitcher to set up monitoring for this repository: pick the critical journeys, verify them locally and deploy them paused through a reviewed plan."\n';
61252
61437
 
61253
61438
  // src/skill.ts
61254
- import { lstat as lstat9, mkdir as mkdir8, readFile as readFile7, rm as rm6, writeFile as writeFile9 } from "node:fs/promises";
61439
+ import { lstat as lstat9, mkdir as mkdir8, readFile as readFile8, rm as rm6, writeFile as writeFile9 } from "node:fs/promises";
61255
61440
  import { homedir } from "node:os";
61256
61441
  import { join as join13, resolve as resolve14 } from "node:path";
61257
61442
  var references = {
@@ -61273,7 +61458,7 @@ async function installSkill(options) {
61273
61458
  const existing = await lstat9(directory).catch(() => null);
61274
61459
  let previousVersion = null;
61275
61460
  if (existing) {
61276
- const marker2 = existing.isDirectory() ? await readFile7(join13(directory, MARKER), "utf8").catch(() => null) : null;
61461
+ const marker2 = existing.isDirectory() ? await readFile8(join13(directory, MARKER), "utf8").catch(() => null) : null;
61277
61462
  if (marker2 === null)
61278
61463
  throw new SkillInstallError(
61279
61464
  `${directory} exists and was not installed by waitcher. Remove it or choose another --path.`
@@ -61311,7 +61496,7 @@ async function installSkill(options) {
61311
61496
  }
61312
61497
 
61313
61498
  // src/doctor.ts
61314
- import { access as access2, readFile as readFile8 } from "node:fs/promises";
61499
+ import { access as access2, readFile as readFile9 } from "node:fs/promises";
61315
61500
  import { homedir as homedir2 } from "node:os";
61316
61501
  import { dirname as dirname13, join as join14 } from "node:path";
61317
61502
  var exists = (path2) => access2(path2).then(
@@ -61410,7 +61595,7 @@ async function doctor(options) {
61410
61595
  for (const home of skillHomes) {
61411
61596
  if (!await exists(join14(home, "SKILL.md"))) continue;
61412
61597
  installed.push(home);
61413
- const marker2 = await readFile8(join14(home, ".waitcher-skill.json"), "utf8").then((text2) => JSON.parse(text2)).catch(() => null);
61598
+ const marker2 = await readFile9(join14(home, ".waitcher-skill.json"), "utf8").then((text2) => JSON.parse(text2)).catch(() => null);
61414
61599
  if (marker2 && marker2.version !== options.version) stale.push(home);
61415
61600
  }
61416
61601
  const install = root === process.cwd() ? "waitcher skill install" : `waitcher skill install --path ${join14(root, ".claude", "skills")}`;
@@ -61607,7 +61792,7 @@ jobs:
61607
61792
  }
61608
61793
 
61609
61794
  // src/main.ts
61610
- import { readFile as readFile10, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
61795
+ import { readFile as readFile11, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
61611
61796
  import { basename as basename3, dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
61612
61797
  import { constants as constants13 } from "node:fs";
61613
61798
 
@@ -61738,6 +61923,63 @@ var maintenanceSchema = external_exports.object({
61738
61923
  // src/main.ts
61739
61924
  import { parseArgs } from "node:util";
61740
61925
 
61926
+ // ../../src/contracts/status-pages.ts
61927
+ var STATUS_PAGE_LIMITS = Object.freeze({
61928
+ components: 25,
61929
+ // Incidents and daily bars are kept this long for monitors on a page,
61930
+ // whatever the plan's run history.
61931
+ historyDays: 90,
61932
+ adminPages: 10,
61933
+ updates: 20
61934
+ });
61935
+ var plain = (max) => external_exports.string().trim().max(max).refine((v) => !/[\u0000-\u001f\u007f<>]/.test(v), {
61936
+ message: "Use plain text without line breaks or angle brackets"
61937
+ });
61938
+ var statusSlugSchema = external_exports.string().regex(
61939
+ /^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])$/,
61940
+ "Use 3 to 40 lower-case letters, digits or hyphens, starting and ending with a letter or digit"
61941
+ );
61942
+ var statusPageSchema = external_exports.object({
61943
+ slug: statusSlugSchema,
61944
+ title: plain(80).pipe(external_exports.string().min(1)),
61945
+ website: external_exports.string().trim().max(200).url().refine((v) => v.startsWith("https://"), "Use an https:// address").nullable().default(null),
61946
+ historyDays: external_exports.union([external_exports.literal(30), external_exports.literal(90)]).default(90),
61947
+ published: external_exports.boolean().default(false),
61948
+ indexable: external_exports.boolean().default(false),
61949
+ showMaintenance: external_exports.boolean().default(true),
61950
+ components: external_exports.array(
61951
+ external_exports.object({
61952
+ monitorId: external_exports.string().min(1).max(100),
61953
+ name: plain(60).pipe(external_exports.string().min(1)),
61954
+ group: plain(40).default("")
61955
+ }).strict()
61956
+ ).max(STATUS_PAGE_LIMITS.components).default([]),
61957
+ expectedRevision: external_exports.number().int().nonnegative().default(0)
61958
+ }).strict().superRefine((v, ctx) => {
61959
+ const seen = /* @__PURE__ */ new Set();
61960
+ v.components.forEach((c, i) => {
61961
+ if (seen.has(c.monitorId))
61962
+ ctx.addIssue({
61963
+ code: "custom",
61964
+ path: ["components", i, "monitorId"],
61965
+ message: "Each monitor can appear once on a page"
61966
+ });
61967
+ seen.add(c.monitorId);
61968
+ });
61969
+ });
61970
+ var INCIDENT_UPDATE_KINDS = [
61971
+ "investigating",
61972
+ "identified",
61973
+ "monitoring",
61974
+ "update"
61975
+ ];
61976
+ var incidentUpdateSchema = external_exports.object({
61977
+ kind: external_exports.enum(INCIDENT_UPDATE_KINDS).default("update"),
61978
+ message: external_exports.string().trim().min(1).max(500).refine((v) => !/[\u0000-\u0009\u000b-\u001f\u007f]/.test(v), {
61979
+ message: "Use plain text"
61980
+ })
61981
+ }).strict();
61982
+
61741
61983
  // src/access.ts
61742
61984
  import { lstat as lstat10, open as open16, unlink as unlink3 } from "node:fs/promises";
61743
61985
  import { dirname as dirname15, resolve as resolve16 } from "node:path";
@@ -61811,7 +62053,7 @@ import { spawn as spawn3 } from "node:child_process";
61811
62053
  import { createHash as createHash11, randomUUID as randomUUID7 } from "node:crypto";
61812
62054
  import { homedir as homedir3 } from "node:os";
61813
62055
  import { dirname as dirname16, join as join15 } from "node:path";
61814
- import { mkdir as mkdir10, lstat as lstat11, open as open17, readFile as readFile9, rename, unlink as unlink4 } from "node:fs/promises";
62056
+ import { mkdir as mkdir10, lstat as lstat11, open as open17, readFile as readFile10, rename, unlink as unlink4 } from "node:fs/promises";
61815
62057
  function serverUrl(value2) {
61816
62058
  let url3;
61817
62059
  try {
@@ -61844,7 +62086,7 @@ async function privatePath(path2, directory = false) {
61844
62086
  }
61845
62087
  async function readPrivate(path2) {
61846
62088
  await privatePath(path2);
61847
- return readFile9(path2, "utf8");
62089
+ return readFile10(path2, "utf8");
61848
62090
  }
61849
62091
  async function loadSession(server) {
61850
62092
  const path2 = sessionPath(server);
@@ -62362,9 +62604,12 @@ Executions and reports
62362
62604
  Run trusted local tests without login or API access
62363
62605
  JSON/report/logs/traces; video opt-in, fresh output per run
62364
62606
  Project output must stay inside the E2E project
62365
- run start --id MONITOR_ID [--wait [--brief]] [--timeout 60]
62607
+ run start --id MONITOR_ID [--wait [--brief]] [--timeout 60] [--update-baselines]
62366
62608
  A finished run prints status, duration and message first;
62367
62609
  --brief leaves out the execution record
62610
+ --update-baselines (visual checks, browser tests; write
62611
+ access): the run adopts what it captures as the approved
62612
+ baseline, for a first reference or an intended change
62368
62613
  artifact get --id RUN_ID --path PATH --file OUTPUT
62369
62614
  Download checksum-verified evidence; no overwrite
62370
62615
  run status --id RUN_ID
@@ -62374,10 +62619,14 @@ Executions and reports
62374
62619
  run wait --id RUN_ID [--timeout 60] [--brief] Bounded wait (1 to 900 seconds)
62375
62620
  report get [--days 1|7|14] [--demo]
62376
62621
  incident list [--demo]
62622
+ incident update --id ID --message TEXT [--kind investigating|identified|monitoring|update]
62623
+ Posts a public note to every status page that shows the monitor
62377
62624
 
62378
62625
  Visual checks and baseline review (features.visual, features.visualReview; decisions
62379
62626
  require write access). A visual monitor screenshots one page or element and compares it
62380
- with the baseline you approved; it counts as a script monitor of the plan.
62627
+ with the baseline you approved; it counts as a script monitor of the plan. A browser test's
62628
+ expect(screen).toHaveScreenshot('name.png') is reviewed the same way: the first hosted run
62629
+ of each screenshot waits for visual approve, later runs compare. Commit no snapshot files.
62381
62630
  visual list [--monitor-id ID] [--head-id HEAD] [--before CURSOR]
62382
62631
  visual get --id COMPARISON_ID
62383
62632
  visual artifacts --id COMPARISON_ID
@@ -62480,6 +62729,18 @@ AI connections (when connection settings are enabled; AI execution is separate)
62480
62729
  Credential writes cannot be replayed. After an uncertain response, inspect
62481
62730
  connection list/get and revisions before submitting another write.
62482
62731
 
62732
+ Status pages
62733
+ status-page list
62734
+ status-page get --id ID
62735
+ status-page save --file PATH [--id ID]
62736
+ status-page delete --id ID --yes
62737
+ JSON: {"slug":"acme","title":"Acme","published":true,"components":
62738
+ [{"monitorId":"UUID","name":"Checkout","group":"Website"}]}
62739
+ Optional: "website":"https://...", "historyDays":30|90, "indexable":false,
62740
+ "showMaintenance":true. Updates add "expectedRevision":N (from list).
62741
+ The page lives at https://waitcher.dev/status/SLUG, with .json and .atom.
62742
+ It shows the names you give, never targets, scripts or error messages.
62743
+
62483
62744
  Alerts
62484
62745
  alert channel list
62485
62746
  alert channel save --file PATH [--id ID]
@@ -62679,7 +62940,7 @@ ${exitCodes}
62679
62940
  // package.json
62680
62941
  var package_default = {
62681
62942
  name: "@waitcher/cli",
62682
- version: "0.2.15",
62943
+ version: "0.2.17",
62683
62944
  description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
62684
62945
  license: "SEE LICENSE IN LICENSE.txt",
62685
62946
  author: "S\u0142awomir Radzymi\u0144ski",
@@ -62835,6 +63096,8 @@ async function main() {
62835
63096
  "calibration-id": { type: "string" },
62836
63097
  role: { type: "string" },
62837
63098
  note: { type: "string" },
63099
+ kind: { type: "string" },
63100
+ message: { type: "string" },
62838
63101
  "request-key": { type: "string" },
62839
63102
  "expected-revision": { type: "string" },
62840
63103
  "project-id": { type: "string" },
@@ -62882,6 +63145,7 @@ async function main() {
62882
63145
  global: { type: "boolean" },
62883
63146
  wait: { type: "boolean" },
62884
63147
  brief: { type: "boolean" },
63148
+ "update-baselines": { type: "boolean" },
62885
63149
  timeout: { type: "string" },
62886
63150
  days: { type: "string" },
62887
63151
  demo: { type: "boolean" },
@@ -63103,7 +63367,14 @@ async function main() {
63103
63367
  "monitor pause": ["id"],
63104
63368
  "monitor resume": ["id"],
63105
63369
  "monitor delete": ["id", "yes"],
63106
- "run start": ["id", "wait", "timeout", "request-key", "brief"],
63370
+ "run start": [
63371
+ "id",
63372
+ "wait",
63373
+ "timeout",
63374
+ "request-key",
63375
+ "brief",
63376
+ "update-baselines"
63377
+ ],
63107
63378
  "run local": [
63108
63379
  "file",
63109
63380
  "project",
@@ -63132,6 +63403,11 @@ async function main() {
63132
63403
  "run wait": ["id", "timeout", "brief"],
63133
63404
  "report get": ["days", "demo"],
63134
63405
  "incident list": ["demo"],
63406
+ "incident update": ["id", "kind", "message"],
63407
+ "status-page list": [],
63408
+ "status-page get": ["id"],
63409
+ "status-page save": ["file", "id"],
63410
+ "status-page delete": ["id", "yes"],
63135
63411
  "alert channel list": [],
63136
63412
  "alert channel save": [
63137
63413
  "file",
@@ -64501,7 +64777,7 @@ async function main() {
64501
64777
  usage2(
64502
64778
  "Provide --file PATH with the complete configuration and expectedRevision for edits."
64503
64779
  );
64504
- const text2 = await readFile10(v.file, "utf8");
64780
+ const text2 = await readFile11(v.file, "utf8");
64505
64781
  if (Buffer.byteLength(text2) > 16e3)
64506
64782
  usage2("Project configuration exceeds 16 KB");
64507
64783
  let body2;
@@ -64590,7 +64866,12 @@ async function main() {
64590
64866
  if (!["create", "adopt", "update"].includes(c.action) || c.type === "heartbeat")
64591
64867
  continue;
64592
64868
  if (limited) {
64593
- smoke.push({ key: c.key, monitorId: c.monitorId, status: "skipped", message: limited });
64869
+ smoke.push({
64870
+ key: c.key,
64871
+ monitorId: c.monitorId,
64872
+ status: "skipped",
64873
+ message: limited
64874
+ });
64594
64875
  continue;
64595
64876
  }
64596
64877
  try {
@@ -64614,7 +64895,8 @@ async function main() {
64614
64895
  });
64615
64896
  } catch (cause) {
64616
64897
  const error62 = asError(cause);
64617
- if (error62.code === "RATE_LIMITED") limited = `RATE_LIMITED: ${error62.message}`;
64898
+ if (error62.code === "RATE_LIMITED")
64899
+ limited = `RATE_LIMITED: ${error62.message}`;
64618
64900
  smoke.push({
64619
64901
  key: c.key,
64620
64902
  monitorId: c.monitorId,
@@ -64644,7 +64926,7 @@ async function main() {
64644
64926
  adopt
64645
64927
  }),
64646
64928
  ...smoke.filter((r) => r.status !== "passed").map(
64647
- (r) => r.comparisonId ? `waitcher visual image --id ${r.comparisonId} --role candidate --file ${r.key}.png shows the first capture of ${r.key}; waitcher visual approve --id ${r.comparisonId} --expected-revision 0 makes it the baseline` : r.runId ? `waitcher run diagnose --id ${r.runId} explains the hosted ${r.status} of ${r.key}` : r.status === "skipped" ? `Hosted smoke for ${r.key} was skipped (${r.message}); it runs on its schedule once enabled, or try waitcher run start --id ${r.monitorId} --wait later` : `Hosted smoke for ${r.key} did not start: ${r.message}`
64929
+ (r) => r.comparisonId ? `waitcher visual image --id ${r.comparisonId} --role candidate --file ${r.key}.png shows the first capture of ${r.key}; waitcher visual approve --id ${r.comparisonId} --expected-revision 0 makes it the baseline (or waitcher run start --id ${r.monitorId} --update-baselines --wait captures and approves a fresh one)` : r.runId ? `waitcher run diagnose --id ${r.runId} explains the hosted ${r.status} of ${r.key}` : r.status === "skipped" ? `Hosted smoke for ${r.key} was skipped (${r.message}); it runs on its schedule once enabled, or try waitcher run start --id ${r.monitorId} --wait later` : `Hosted smoke for ${r.key} did not start: ${r.message}`
64648
64930
  )
64649
64931
  ]
64650
64932
  };
@@ -64745,7 +65027,7 @@ async function main() {
64745
65027
  if (!v.file) usage2("Provide --file PATH for the configuration.");
64746
65028
  let input2;
64747
65029
  try {
64748
- const text2 = await readFile10(v.file, "utf8");
65030
+ const text2 = await readFile11(v.file, "utf8");
64749
65031
  if (Buffer.byteLength(text2) > 96e3)
64750
65032
  usage2("Configuration exceeds 96 KB.");
64751
65033
  input2 = JSON.parse(text2);
@@ -65029,7 +65311,14 @@ async function main() {
65029
65311
  if (v.timeout && command === "run start" && !v.wait)
65030
65312
  usage2("--timeout requires --wait with run start.");
65031
65313
  const seconds = integer2(v.timeout ?? "60", "timeout", 1, 900);
65032
- const queued = command === "run start" ? await api(`monitors/${id3(v.id)}/run`, { method: "POST", body: {} }) : { id: decodeURIComponent(id3(v.id)) };
65314
+ const queued = command === "run start" ? (
65315
+ // --update-baselines: the run adopts what it captures as the
65316
+ // approved baseline instead of comparing against it.
65317
+ await api(
65318
+ `monitors/${id3(v.id)}/${v["update-baselines"] ? "baselines" : "run"}`,
65319
+ { method: "POST", body: {} }
65320
+ )
65321
+ ) : { id: decodeURIComponent(id3(v.id)) };
65033
65322
  if (command === "run start" && !v.wait)
65034
65323
  result2 = { event: "queued", ...queued };
65035
65324
  else {
@@ -65086,6 +65375,54 @@ async function main() {
65086
65375
  const days = integer2(v.days ?? "1", "days", 1, 14);
65087
65376
  if (![1, 7, 14].includes(days)) usage2("days must be 1, 7 or 14.");
65088
65377
  result2 = await api(`reports?days=${days}&demo=${Boolean(v.demo)}`);
65378
+ } else if (command === "incident update") {
65379
+ if (!v.message)
65380
+ usage2("Provide --message TEXT, shown on your status pages.");
65381
+ const parsed2 = incidentUpdateSchema.safeParse({
65382
+ kind: v.kind ?? "update",
65383
+ message: v.message
65384
+ });
65385
+ if (!parsed2.success)
65386
+ usage2(
65387
+ parsed2.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`).join("\n")
65388
+ );
65389
+ result2 = await api(`incidents/${id3(v.id)}/updates`, {
65390
+ method: "POST",
65391
+ body: parsed2.data
65392
+ });
65393
+ } else if (command === "status-page list")
65394
+ result2 = await api("status-pages");
65395
+ else if (command === "status-page get")
65396
+ result2 = await api(`status-pages/${id3(v.id)}`);
65397
+ else if (command === "status-page save") {
65398
+ if (!v.file) usage2("Provide --file PATH for the status page.");
65399
+ let input2;
65400
+ try {
65401
+ const text2 = await readFile11(v.file, "utf8");
65402
+ if (Buffer.byteLength(text2) > 96e3)
65403
+ usage2("Configuration exceeds 96 KB.");
65404
+ input2 = JSON.parse(text2);
65405
+ } catch {
65406
+ usage2("Could not read valid JSON configuration.");
65407
+ }
65408
+ const parsed2 = statusPageSchema.safeParse(input2);
65409
+ if (!parsed2.success)
65410
+ usage2(
65411
+ parsed2.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`).join("\n")
65412
+ );
65413
+ result2 = await api(`status-pages${v.id ? "/" + id3(v.id) : ""}`, {
65414
+ method: v.id ? "PUT" : "POST",
65415
+ body: parsed2.data
65416
+ });
65417
+ } else if (command === "status-page delete") {
65418
+ if (!v.yes)
65419
+ usage2(
65420
+ "The page's address stops working within a minute. Pass --yes to confirm."
65421
+ );
65422
+ result2 = await api(`status-pages/${id3(v.id)}`, {
65423
+ method: "DELETE",
65424
+ body: {}
65425
+ });
65089
65426
  } else if (command === "incident list") {
65090
65427
  const monitors = (await api("monitors")).filter(
65091
65428
  (m) => Boolean(m.demo) === Boolean(v.demo)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waitcher/cli",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "description": "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Sławomir Radzymiński",