@waitcher/cli 0.2.34 → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +933 -433
- package/dist/model-client.mjs +73 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -41719,8 +41719,8 @@ function ko_default() {
|
|
|
41719
41719
|
}
|
|
41720
41720
|
|
|
41721
41721
|
// ../../node_modules/zod/v4/locales/lt.js
|
|
41722
|
-
var capitalizeFirstCharacter = (
|
|
41723
|
-
return
|
|
41722
|
+
var capitalizeFirstCharacter = (text5) => {
|
|
41723
|
+
return text5.charAt(0).toUpperCase() + text5.slice(1);
|
|
41724
41724
|
};
|
|
41725
41725
|
function getUnitTypeFromNumber(number4) {
|
|
41726
41726
|
const abs = Math.abs(number4);
|
|
@@ -52453,15 +52453,17 @@ var visualThresholdSchema = external_exports.object({
|
|
|
52453
52453
|
maxDiffRatio: external_exports.number().min(0).max(0.1).default(1e-3),
|
|
52454
52454
|
includeAntialiasing: external_exports.boolean().default(false)
|
|
52455
52455
|
}).strict().prefault({});
|
|
52456
|
+
var VISUAL_CHECKPOINT_ID = /^[a-z][a-z0-9-]{0,39}$/;
|
|
52457
|
+
var VISUAL_CHECKPOINT_RULE = "Use up to 40 lower-case letters, digits or hyphens, starting with a letter";
|
|
52456
52458
|
var visualConfigSchema = external_exports.object({
|
|
52457
52459
|
schemaVersion: external_exports.literal(1).default(1),
|
|
52458
52460
|
checkpoint: external_exports.discriminatedUnion("kind", [
|
|
52459
52461
|
external_exports.object({
|
|
52460
|
-
id: external_exports.string().regex(
|
|
52462
|
+
id: external_exports.string().regex(VISUAL_CHECKPOINT_ID, VISUAL_CHECKPOINT_RULE).default("main"),
|
|
52461
52463
|
kind: external_exports.literal("page")
|
|
52462
52464
|
}).strict(),
|
|
52463
52465
|
external_exports.object({
|
|
52464
|
-
id: external_exports.string().regex(
|
|
52466
|
+
id: external_exports.string().regex(VISUAL_CHECKPOINT_ID, VISUAL_CHECKPOINT_RULE).default("main"),
|
|
52465
52467
|
kind: external_exports.literal("element"),
|
|
52466
52468
|
selector
|
|
52467
52469
|
}).strict()
|
|
@@ -52972,21 +52974,21 @@ function validateAiVariables(input2) {
|
|
|
52972
52974
|
return invalid();
|
|
52973
52975
|
return value2;
|
|
52974
52976
|
}
|
|
52975
|
-
function renderText(
|
|
52977
|
+
function renderText(text5, variables) {
|
|
52976
52978
|
let cursor = 0, result2 = "";
|
|
52977
52979
|
for (; ; ) {
|
|
52978
|
-
const open19 =
|
|
52980
|
+
const open19 = text5.indexOf("{{", cursor), close = text5.indexOf("}}", cursor);
|
|
52979
52981
|
if (close >= 0 && (open19 < 0 || close < open19)) return invalid();
|
|
52980
52982
|
if (open19 < 0) {
|
|
52981
|
-
result2 +=
|
|
52983
|
+
result2 += text5.slice(cursor);
|
|
52982
52984
|
break;
|
|
52983
52985
|
}
|
|
52984
|
-
const end =
|
|
52986
|
+
const end = text5.indexOf("}}", open19 + 2);
|
|
52985
52987
|
if (end < 0) return invalid();
|
|
52986
|
-
const key =
|
|
52988
|
+
const key = text5.slice(open19 + 2, end);
|
|
52987
52989
|
if (!name2.test(key)) return invalid();
|
|
52988
52990
|
if (!Object.hasOwn(variables, key)) throw new AiTemplateError(key);
|
|
52989
|
-
result2 +=
|
|
52991
|
+
result2 += text5.slice(cursor, open19) + variables[key];
|
|
52990
52992
|
if (result2.length > AI_TEMPLATE_LIMITS.fixtureBytes) return invalid();
|
|
52991
52993
|
cursor = end + 2;
|
|
52992
52994
|
}
|
|
@@ -54511,7 +54513,7 @@ async function boundedText(response, maxBytes = 8 * 1024 * 1024) {
|
|
|
54511
54513
|
const reader = response.body?.getReader();
|
|
54512
54514
|
if (!reader) return "";
|
|
54513
54515
|
const decoder = new TextDecoder();
|
|
54514
|
-
let total = 0,
|
|
54516
|
+
let total = 0, text5 = "";
|
|
54515
54517
|
try {
|
|
54516
54518
|
while (true) {
|
|
54517
54519
|
const part2 = await reader.read();
|
|
@@ -54519,9 +54521,9 @@ async function boundedText(response, maxBytes = 8 * 1024 * 1024) {
|
|
|
54519
54521
|
total += part2.value.byteLength;
|
|
54520
54522
|
if (total > maxBytes)
|
|
54521
54523
|
throw new Error("Response exceeds the 8 MiB text limit");
|
|
54522
|
-
|
|
54524
|
+
text5 += decoder.decode(part2.value, { stream: true });
|
|
54523
54525
|
}
|
|
54524
|
-
return
|
|
54526
|
+
return text5 + decoder.decode();
|
|
54525
54527
|
} finally {
|
|
54526
54528
|
await reader.cancel().catch(() => {
|
|
54527
54529
|
});
|
|
@@ -54680,7 +54682,7 @@ async function request(server, path2, {
|
|
|
54680
54682
|
const message = typeof (detail.message ?? data.error) === "string" ? (detail.message ?? data.error).replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, " ").slice(0, 1e3) : `HTTP ${response.status}`;
|
|
54681
54683
|
const safe = [cookie, cookie?.split("=")[1], accessToken, ...secrets].filter(
|
|
54682
54684
|
(value2) => typeof value2 === "string" && value2.length > 0
|
|
54683
|
-
).reduce((
|
|
54685
|
+
).reduce((text5, secret) => text5.replaceAll(secret, "[redacted]"), message);
|
|
54684
54686
|
const failure3 = new ServiceError(
|
|
54685
54687
|
safe,
|
|
54686
54688
|
errorCode ?? (response.status === 401 ? "AUTH_REQUIRED" : response.status === 429 ? "RATE_LIMITED" : "SERVICE_ERROR"),
|
|
@@ -54690,7 +54692,7 @@ async function request(server, path2, {
|
|
|
54690
54692
|
const redacted = [cookie, cookie?.split("=")[1], accessToken, ...secrets].filter(
|
|
54691
54693
|
(value2) => typeof value2 === "string" && value2.length > 0
|
|
54692
54694
|
).reduce(
|
|
54693
|
-
(
|
|
54695
|
+
(text5, secret) => text5.replaceAll(secret, "[redacted]"),
|
|
54694
54696
|
JSON.stringify(detail.fields)
|
|
54695
54697
|
);
|
|
54696
54698
|
try {
|
|
@@ -54713,6 +54715,8 @@ var localRunMetadataSchema = external_exports.object({
|
|
|
54713
54715
|
provenance: external_exports.literal("local"),
|
|
54714
54716
|
runId: external_exports.uuid(),
|
|
54715
54717
|
status: external_exports.enum(["passed", "failed", "error"]),
|
|
54718
|
+
message: external_exports.string().max(8e3).optional(),
|
|
54719
|
+
code: external_exports.string().max(64).optional(),
|
|
54716
54720
|
files: external_exports.array(
|
|
54717
54721
|
external_exports.object({
|
|
54718
54722
|
path: external_exports.string().min(1).max(1024),
|
|
@@ -55486,6 +55490,14 @@ var runDiagnosisSchema = external_exports.object({
|
|
|
55486
55490
|
provenance: external_exports.enum(["hosted", "local"]),
|
|
55487
55491
|
runId: external_exports.uuid(),
|
|
55488
55492
|
runStatus: status,
|
|
55493
|
+
// Why the run did not pass, as the test framework classified it, in
|
|
55494
|
+
// Waitcher terms; absent for a passed run or one without a classified cause.
|
|
55495
|
+
failure: external_exports.object({
|
|
55496
|
+
code: external_exports.string().regex(/^[A-Z][A-Z0-9_]{1,63}$/),
|
|
55497
|
+
message: external_exports.string().max(4e3),
|
|
55498
|
+
test: external_exports.string().max(300).nullable(),
|
|
55499
|
+
trace: external_exports.string().max(4096).nullable()
|
|
55500
|
+
}).strict().nullable().optional(),
|
|
55489
55501
|
policy: external_exports.object({
|
|
55490
55502
|
availability: external_exports.enum(["available", "unavailable"]),
|
|
55491
55503
|
hash: hash2.nullable()
|
|
@@ -55700,6 +55712,125 @@ function scriptReproductionEligible(value2) {
|
|
|
55700
55712
|
// src/run-diagnosis.ts
|
|
55701
55713
|
init_limits();
|
|
55702
55714
|
|
|
55715
|
+
// ../../src/checks/e2e-causes.ts
|
|
55716
|
+
var MIN_SECRET_CHARACTERS = 6;
|
|
55717
|
+
var text2 = (value2, max = 2e3) => typeof value2 === "string" ? value2.slice(0, max) : "";
|
|
55718
|
+
var codeOf = (value2) => typeof value2 === "string" && /^[A-Z][A-Z0-9_]{1,63}$/.test(value2) ? value2 : null;
|
|
55719
|
+
function e2eCause(report) {
|
|
55720
|
+
const run2 = report?.run;
|
|
55721
|
+
if (!run2 || typeof run2 !== "object") return null;
|
|
55722
|
+
const errors = Array.isArray(run2.errors) ? run2.errors : [];
|
|
55723
|
+
for (const error62 of errors) {
|
|
55724
|
+
const code = codeOf(error62?.code);
|
|
55725
|
+
if (code)
|
|
55726
|
+
return { code, detail: text2(error62.message), test: null, trace: null };
|
|
55727
|
+
}
|
|
55728
|
+
const results = Array.isArray(run2.results) ? run2.results : [];
|
|
55729
|
+
for (const result2 of results) {
|
|
55730
|
+
if (result2?.status === "passed" || result2?.status === "skipped") continue;
|
|
55731
|
+
const attempt = Array.isArray(result2?.attempts) ? result2.attempts.at(-1) : void 0;
|
|
55732
|
+
const code = codeOf(attempt?.error?.code);
|
|
55733
|
+
if (!code) continue;
|
|
55734
|
+
const titles = Array.isArray(result2.titlePath) ? result2.titlePath : [];
|
|
55735
|
+
const folder = (attempt?.artifacts ?? []).map((a) => text2(a?.path, 512).split("/")[0]).find((part2) => part2 && /^[A-Za-z0-9._-]+$/.test(part2) && part2 !== "..");
|
|
55736
|
+
return {
|
|
55737
|
+
code,
|
|
55738
|
+
detail: text2(attempt?.error?.message),
|
|
55739
|
+
test: text2(titles.at(-1), 300) || null,
|
|
55740
|
+
trace: folder ? `results/${folder}/trace.md` : null
|
|
55741
|
+
};
|
|
55742
|
+
}
|
|
55743
|
+
return null;
|
|
55744
|
+
}
|
|
55745
|
+
function explainCause(cause, context) {
|
|
55746
|
+
const local = context.where === "local";
|
|
55747
|
+
switch (cause.code) {
|
|
55748
|
+
case "SECRET_UNAVAILABLE": {
|
|
55749
|
+
const name5 = /secret "([^"]{1,128})"/.exec(cause.detail)?.[1] ?? null;
|
|
55750
|
+
const value2 = name5 ? context.environment[name5] : void 0;
|
|
55751
|
+
if (name5 && value2 && [...value2].length < MIN_SECRET_CHARACTERS)
|
|
55752
|
+
return {
|
|
55753
|
+
message: `${name5} is set but has ${[...value2].length} characters; secrets.get("${name5}") needs at least ${MIN_SECRET_CHARACTERS}, because masking a shorter value would also mask unrelated text. Read process.env.${name5} in the script instead (it stays unmasked in evidence), or use a longer value.`,
|
|
55754
|
+
next: [
|
|
55755
|
+
`Change the script to read process.env.${name5}, or ${local ? `export a value of at least ${MIN_SECRET_CHARACTERS} characters` : `set a value of at least ${MIN_SECRET_CHARACTERS} characters with waitcher secret set`}, then rerun`
|
|
55756
|
+
]
|
|
55757
|
+
};
|
|
55758
|
+
if (name5 && !context.envNames.includes(name5))
|
|
55759
|
+
return {
|
|
55760
|
+
message: `The script reads secret ${name5}, which the monitor does not list. Add "${name5}" to settings.envNames (names start with CHECK_), give it a value, then rerun.`,
|
|
55761
|
+
next: [
|
|
55762
|
+
`Add "${name5}" to settings.envNames in the monitor definition`,
|
|
55763
|
+
local ? `The user exports ${name5} in the shell that runs waitcher (never in a file committed to Git), then rerun this command` : `waitcher secret set --env ENV --name ${name5} --value-stdin, or set it on the Monitors page`
|
|
55764
|
+
]
|
|
55765
|
+
};
|
|
55766
|
+
const subject = name5 ?? "A CHECK_* value the script reads";
|
|
55767
|
+
return local ? {
|
|
55768
|
+
message: `${subject} is not set in this shell. Export it before waitcher run local (export ${name5 ?? "CHECK_NAME"}=...); hosted runs use the value saved with waitcher secret set instead.`,
|
|
55769
|
+
next: [
|
|
55770
|
+
`The user exports ${name5 ?? "CHECK_NAME"} in the shell that runs waitcher (never in a file committed to Git), then rerun this command`
|
|
55771
|
+
]
|
|
55772
|
+
} : {
|
|
55773
|
+
message: `${subject} has no value for this monitor. Save it with waitcher secret set --env ENV --name ${name5 ?? "CHECK_NAME"} --value-stdin, or on the Monitors page.`,
|
|
55774
|
+
next: [
|
|
55775
|
+
`waitcher secret set --env ENV --name ${name5 ?? "CHECK_NAME"} --value-stdin`
|
|
55776
|
+
]
|
|
55777
|
+
};
|
|
55778
|
+
}
|
|
55779
|
+
case "APP_UNREACHABLE": {
|
|
55780
|
+
const reason2 = /\((ERR_[A-Z_]+|E[A-Z]+)\)/.exec(cause.detail)?.[1];
|
|
55781
|
+
return local ? {
|
|
55782
|
+
message: `Nothing answered at ${context.target}${reason2 ? ` (${reason2})` : ""}. Start the app at the monitor's target, or change "target" in the monitor file to where it runs, then rerun.`,
|
|
55783
|
+
next: [
|
|
55784
|
+
`Start the app so it answers at ${context.target} (or change the monitor's target), then rerun this command`
|
|
55785
|
+
]
|
|
55786
|
+
} : {
|
|
55787
|
+
message: `Nothing answered at ${context.target}${reason2 ? ` (${reason2})` : ""}. Hosted checks reach only public addresses: check that the site is up and the target is right.`,
|
|
55788
|
+
next: [
|
|
55789
|
+
"Check that the target answers from the internet, then run the monitor again"
|
|
55790
|
+
]
|
|
55791
|
+
};
|
|
55792
|
+
}
|
|
55793
|
+
case "BROWSER_INSTALL_FAILED":
|
|
55794
|
+
return {
|
|
55795
|
+
message: local ? `Chromium could not be installed for this run: ${cause.detail}` : `The browser could not start on the worker: ${cause.detail}`,
|
|
55796
|
+
next: local ? [
|
|
55797
|
+
"waitcher runtime install --browser --yes (after the user agrees; it downloads Chromium), then rerun this command"
|
|
55798
|
+
] : ["Run the monitor again; report the run ID if it repeats"]
|
|
55799
|
+
};
|
|
55800
|
+
case "ENGINE_NOT_INSTALLED":
|
|
55801
|
+
case "RUNNER_NOT_INSTALLED":
|
|
55802
|
+
case "WORKER_ENTRY_MISSING":
|
|
55803
|
+
return {
|
|
55804
|
+
message: `The test runtime is incomplete: ${cause.detail}`,
|
|
55805
|
+
next: [
|
|
55806
|
+
local ? "waitcher runtime install (lists the steps; --yes after the user agrees), then rerun this command" : "Run the monitor again; report the run ID if it repeats"
|
|
55807
|
+
]
|
|
55808
|
+
};
|
|
55809
|
+
case "COLLECTION_ERROR":
|
|
55810
|
+
case "CONFIG_LOAD_FAILED":
|
|
55811
|
+
case "NO_TESTS":
|
|
55812
|
+
case "INVALID_CONFIG":
|
|
55813
|
+
return {
|
|
55814
|
+
message: `The test file did not load: ${cause.detail}`,
|
|
55815
|
+
next: [
|
|
55816
|
+
"Fix the test file (it declares test(...) from @e2e-dev/web for browser checks or e2e for API checks), then rerun"
|
|
55817
|
+
]
|
|
55818
|
+
};
|
|
55819
|
+
case "MODEL_UNAVAILABLE":
|
|
55820
|
+
return {
|
|
55821
|
+
message: `The script uses an AI step without a model: ${cause.detail}`,
|
|
55822
|
+
next: [
|
|
55823
|
+
local ? "Pass --connections-file with the monitor's AI connection, or remove the AI step" : "Bind an AI connection to the monitor, or remove the AI step"
|
|
55824
|
+
]
|
|
55825
|
+
};
|
|
55826
|
+
default:
|
|
55827
|
+
return {
|
|
55828
|
+
message: cause.detail || cause.code,
|
|
55829
|
+
next: [`waitcher explain ${cause.code}`]
|
|
55830
|
+
};
|
|
55831
|
+
}
|
|
55832
|
+
}
|
|
55833
|
+
|
|
55703
55834
|
// src/manifest.ts
|
|
55704
55835
|
import { readFile, open as open4 } from "node:fs/promises";
|
|
55705
55836
|
import { dirname, resolve as resolve2 } from "node:path";
|
|
@@ -55842,10 +55973,22 @@ var visualExample = {
|
|
|
55842
55973
|
}
|
|
55843
55974
|
}
|
|
55844
55975
|
};
|
|
55845
|
-
async function writeText(path2,
|
|
55846
|
-
|
|
55976
|
+
async function writeText(path2, text5) {
|
|
55977
|
+
let file2;
|
|
55978
|
+
try {
|
|
55979
|
+
file2 = await open4(path2, "wx", 384);
|
|
55980
|
+
} catch (cause) {
|
|
55981
|
+
if (cause.code !== "EEXIST") throw cause;
|
|
55982
|
+
const error62 = new ServiceError(
|
|
55983
|
+
`${path2} already exists. Waitcher never overwrites a file: choose another path, or edit that file.`,
|
|
55984
|
+
"FILE_EXISTS",
|
|
55985
|
+
2
|
|
55986
|
+
);
|
|
55987
|
+
error62.next = [`Rerun with another --file path, or open ${path2} and edit it`];
|
|
55988
|
+
throw error62;
|
|
55989
|
+
}
|
|
55847
55990
|
try {
|
|
55848
|
-
await file2.writeFile(
|
|
55991
|
+
await file2.writeFile(text5);
|
|
55849
55992
|
} finally {
|
|
55850
55993
|
await file2.close();
|
|
55851
55994
|
}
|
|
@@ -55854,11 +55997,11 @@ var writeJson = (path2, data) => writeText(path2, JSON.stringify(data, null, 2)
|
|
|
55854
55997
|
async function readManifest(path2, { enable = false } = {}) {
|
|
55855
55998
|
if (!path2) throw new Error("Provide --file PATH to a monitor JSON file.");
|
|
55856
55999
|
let value2;
|
|
55857
|
-
const
|
|
55858
|
-
if (Buffer.byteLength(
|
|
56000
|
+
const text5 = await readFile(path2, "utf8");
|
|
56001
|
+
if (Buffer.byteLength(text5) > 96e3)
|
|
55859
56002
|
throw new Error("Monitor configuration exceeds 96 KB.");
|
|
55860
56003
|
try {
|
|
55861
|
-
value2 = JSON.parse(
|
|
56004
|
+
value2 = JSON.parse(text5);
|
|
55862
56005
|
} catch {
|
|
55863
56006
|
throw new Error("Monitor configuration must be valid JSON.");
|
|
55864
56007
|
}
|
|
@@ -55999,7 +56142,8 @@ async function localRunDiagnosis(directory) {
|
|
|
55999
56142
|
artifact,
|
|
56000
56143
|
STORAGE_LIMITS.workBytes
|
|
56001
56144
|
);
|
|
56002
|
-
if ([LOCAL_FROZEN_MONITOR, "request-usage.json"].includes(artifact.path) && bytes2.length <= DIAGNOSIS_LIMITS.definitionBytes
|
|
56145
|
+
if ([LOCAL_FROZEN_MONITOR, "request-usage.json"].includes(artifact.path) && bytes2.length <= DIAGNOSIS_LIMITS.definitionBytes || // The framework's report, read once for the classified failure.
|
|
56146
|
+
REPORTS.includes(artifact.path) && recorded.status !== "passed")
|
|
56003
56147
|
verified.set(artifact.path, bytes2);
|
|
56004
56148
|
status2 = "available";
|
|
56005
56149
|
} catch (error62) {
|
|
@@ -56064,6 +56208,7 @@ async function localRunDiagnosis(directory) {
|
|
|
56064
56208
|
provenance: "local",
|
|
56065
56209
|
runId: recorded.runId,
|
|
56066
56210
|
runStatus: recorded.status,
|
|
56211
|
+
failure: localFailure(root, recorded, verified, definition),
|
|
56067
56212
|
policy: {
|
|
56068
56213
|
availability: policyHash ? "available" : "unavailable",
|
|
56069
56214
|
hash: policyHash
|
|
@@ -56095,6 +56240,32 @@ async function localRunDiagnosis(directory) {
|
|
|
56095
56240
|
}
|
|
56096
56241
|
});
|
|
56097
56242
|
}
|
|
56243
|
+
var REPORTS = [".e2e/report.json", "evidence/report.json"];
|
|
56244
|
+
function localFailure(root, recorded, verified, definition) {
|
|
56245
|
+
if (recorded.status === "passed") return null;
|
|
56246
|
+
const path2 = REPORTS.find((p) => verified.has(p));
|
|
56247
|
+
if (!path2) return null;
|
|
56248
|
+
let cause;
|
|
56249
|
+
try {
|
|
56250
|
+
cause = e2eCause(decodeLocalJson(verified.get(path2)));
|
|
56251
|
+
} catch {
|
|
56252
|
+
return null;
|
|
56253
|
+
}
|
|
56254
|
+
if (!cause) return null;
|
|
56255
|
+
const envNames = definition?.settings?.envNames ?? [];
|
|
56256
|
+
const message = recorded.code === cause.code && recorded.message ? recorded.message : definition && path2 === ".e2e/report.json" ? explainCause(cause, {
|
|
56257
|
+
where: "local",
|
|
56258
|
+
target: definition.target,
|
|
56259
|
+
envNames,
|
|
56260
|
+
environment: Object.fromEntries(envNames.map((n) => [n, process.env[n]]))
|
|
56261
|
+
}).message : cause.detail || cause.code;
|
|
56262
|
+
return {
|
|
56263
|
+
code: cause.code,
|
|
56264
|
+
message: message.slice(0, 4e3),
|
|
56265
|
+
test: cause.test,
|
|
56266
|
+
trace: cause.trace ? join2(root, dirname2(path2), cause.trace) : null
|
|
56267
|
+
};
|
|
56268
|
+
}
|
|
56098
56269
|
function formatRunDiagnosis(value2, agent) {
|
|
56099
56270
|
const report = parseRunDiagnosis(value2), scenarios = formatScenarioReport(report.scenarios).trimEnd().split("\n");
|
|
56100
56271
|
const lines = agent ? [
|
|
@@ -56102,6 +56273,14 @@ function formatRunDiagnosis(value2, agent) {
|
|
|
56102
56273
|
agent,
|
|
56103
56274
|
...scenarios.slice(1).filter((l) => !l.startsWith("No scenarios were recorded"))
|
|
56104
56275
|
] : [scenarios.join("\n")];
|
|
56276
|
+
if (report.failure)
|
|
56277
|
+
lines.unshift(
|
|
56278
|
+
`Failed${report.failure.test ? `: ${report.failure.test}` : ""}`,
|
|
56279
|
+
` ${report.failure.code}: ${report.failure.message}`,
|
|
56280
|
+
...report.failure.trace ? [` Trace: ${report.failure.trace}`] : [],
|
|
56281
|
+
` waitcher explain ${report.failure.code}`,
|
|
56282
|
+
""
|
|
56283
|
+
);
|
|
56105
56284
|
lines.push(`Verification policy: ${report.policy.hash ?? "unavailable"}`);
|
|
56106
56285
|
lines.push(
|
|
56107
56286
|
report.history.lastPassing ? `Last passing matching policy: ${report.history.lastPassing.runId}` : `Matching history: unavailable (${report.history.reason})`
|
|
@@ -56469,7 +56648,7 @@ async function readVerifiedJson(server, runId, expected, session, signal) {
|
|
|
56469
56648
|
}
|
|
56470
56649
|
|
|
56471
56650
|
// src/agent-report.ts
|
|
56472
|
-
var
|
|
56651
|
+
var text3 = (value2, max = 300) => typeof value2 === "string" ? value2.slice(0, max) : "";
|
|
56473
56652
|
var count = (value2) => typeof value2 === "number" && Number.isSafeInteger(value2) ? String(value2) : "unavailable";
|
|
56474
56653
|
function agentOutcome(outcome) {
|
|
56475
56654
|
if (outcome === "success") return "exited normally";
|
|
@@ -56487,13 +56666,13 @@ function formatAgentReport(summary2, gate, runStatus) {
|
|
|
56487
56666
|
(c) => Boolean(c) && typeof c.command === "string"
|
|
56488
56667
|
) : [];
|
|
56489
56668
|
const failed = commands2.filter((c) => c.failed === true);
|
|
56490
|
-
lines.push(` Agent: ${agentOutcome(
|
|
56669
|
+
lines.push(` Agent: ${agentOutcome(text3(summary2.outcome, 80))}`);
|
|
56491
56670
|
lines.push(
|
|
56492
56671
|
` Verifier: ${runStatus === "passed" ? "passed, the outcome is in the product" : runStatus === "failed" ? "failed, see the verifier's report" : runStatus}`
|
|
56493
56672
|
);
|
|
56494
|
-
lines.push(` Model: ${
|
|
56673
|
+
lines.push(` Model: ${text3(summary2.model, 120) || "unavailable"}`);
|
|
56495
56674
|
lines.push(
|
|
56496
|
-
` Steps: ${count(summary2.steps)}${failed.length ? ` (${failed.length} failed)` : ""}; model requests: ${count(gate?.turns)}; tokens: ${count(gate?.tokens)}${
|
|
56675
|
+
` Steps: ${count(summary2.steps)}${failed.length ? ` (${failed.length} failed)` : ""}; model requests: ${count(gate?.turns)}; tokens: ${count(gate?.tokens)}${text3(gate?.stopped, 80) ? `; stopped at its ${text3(gate?.stopped, 80)}` : ""}`
|
|
56497
56676
|
);
|
|
56498
56677
|
const pages = Array.isArray(summary2.pages) ? summary2.pages.filter((p) => typeof p === "string").slice(0, 100) : [];
|
|
56499
56678
|
if (pages.length) {
|
|
@@ -56511,7 +56690,7 @@ function formatAgentReport(summary2, gate, runStatus) {
|
|
|
56511
56690
|
}
|
|
56512
56691
|
const denied = Array.isArray(gate?.denied) ? gate.denied.filter((d) => typeof d === "string").slice(0, 20) : [];
|
|
56513
56692
|
if (denied.length) lines.push(` Refused by the gateway: ${denied.join("; ")}`);
|
|
56514
|
-
const final =
|
|
56693
|
+
const final = text3(summary2.final, 2e3);
|
|
56515
56694
|
if (final) {
|
|
56516
56695
|
lines.push(" Final message (what the agent claims; the verifier decides):");
|
|
56517
56696
|
for (const line of final.split("\n")) lines.push(` ${line}`);
|
|
@@ -56572,8 +56751,8 @@ async function targetConfiguration(file2) {
|
|
|
56572
56751
|
await handle.close();
|
|
56573
56752
|
}
|
|
56574
56753
|
}
|
|
56575
|
-
function httpSecretInput(
|
|
56576
|
-
const value2 =
|
|
56754
|
+
function httpSecretInput(text5) {
|
|
56755
|
+
const value2 = text5.replace(/[\r\n]+$/, "");
|
|
56577
56756
|
if (!httpCredentialRotateSchema.shape.value.safeParse(value2).success)
|
|
56578
56757
|
throw new ServiceError(
|
|
56579
56758
|
"Use a single-line ASCII HTTP credential value of at most 4096 characters.",
|
|
@@ -57602,12 +57781,12 @@ import { performance as performance7 } from "node:perf_hooks";
|
|
|
57602
57781
|
import {
|
|
57603
57782
|
mkdir as mkdir4,
|
|
57604
57783
|
lstat as lstat7,
|
|
57605
|
-
readFile as
|
|
57784
|
+
readFile as readFile5,
|
|
57606
57785
|
realpath,
|
|
57607
|
-
readdir,
|
|
57608
|
-
writeFile as
|
|
57786
|
+
readdir as readdir2,
|
|
57787
|
+
writeFile as writeFile5
|
|
57609
57788
|
} from "node:fs/promises";
|
|
57610
|
-
import { dirname as
|
|
57789
|
+
import { dirname as dirname9, join as join9, relative, resolve as resolve11, sep as sep2 } from "node:path";
|
|
57611
57790
|
|
|
57612
57791
|
// ../../src/checks/http-auth.ts
|
|
57613
57792
|
function httpCredentialHeaders(monitor, input2) {
|
|
@@ -57768,7 +57947,7 @@ HTTP ${response.status}
|
|
|
57768
57947
|
Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
57769
57948
|
};
|
|
57770
57949
|
}
|
|
57771
|
-
let
|
|
57950
|
+
let text5 = "", bytes2 = 0;
|
|
57772
57951
|
if (response.body) {
|
|
57773
57952
|
const reader = response.body.getReader();
|
|
57774
57953
|
const decoder = new TextDecoder();
|
|
@@ -57779,9 +57958,9 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57779
57958
|
bytes2 += value2.byteLength;
|
|
57780
57959
|
if (bytes2 > 256e3)
|
|
57781
57960
|
throw new Error("Response exceeds the 256 KB check limit");
|
|
57782
|
-
|
|
57961
|
+
text5 += decoder.decode(value2, { stream: true });
|
|
57783
57962
|
}
|
|
57784
|
-
|
|
57963
|
+
text5 += decoder.decode();
|
|
57785
57964
|
} finally {
|
|
57786
57965
|
await reader.cancel().catch(() => {
|
|
57787
57966
|
});
|
|
@@ -57794,9 +57973,9 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57794
57973
|
bytes: bytes2,
|
|
57795
57974
|
excerpt: omitted ? null : hidden.reduce(
|
|
57796
57975
|
(value2, secret) => value2.replaceAll(secret, "[redacted]"),
|
|
57797
|
-
|
|
57976
|
+
text5.slice(0, RUN_TRACE_LIMITS.bodyExcerpt)
|
|
57798
57977
|
),
|
|
57799
|
-
truncated: !omitted &&
|
|
57978
|
+
truncated: !omitted && text5.length > RUN_TRACE_LIMITS.bodyExcerpt,
|
|
57800
57979
|
omitted
|
|
57801
57980
|
};
|
|
57802
57981
|
const latency = Math.round(performance2.now() - start);
|
|
@@ -57805,11 +57984,11 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57805
57984
|
failures.push(
|
|
57806
57985
|
`Expected HTTP ${m.settings.expectedStatus}, received ${response.status}`
|
|
57807
57986
|
);
|
|
57808
|
-
if (m.settings.contains && !
|
|
57987
|
+
if (m.settings.contains && !text5.includes(m.settings.contains))
|
|
57809
57988
|
failures.push("Expected text missing from response");
|
|
57810
57989
|
if (m.settings.jsonPath) {
|
|
57811
57990
|
try {
|
|
57812
|
-
let value2 = JSON.parse(
|
|
57991
|
+
let value2 = JSON.parse(text5);
|
|
57813
57992
|
for (const part2 of m.settings.jsonPath.split("."))
|
|
57814
57993
|
value2 = value2?.[part2];
|
|
57815
57994
|
let expected;
|
|
@@ -58051,23 +58230,23 @@ function evaluateAssertion(data, assertion, secrets = []) {
|
|
|
58051
58230
|
passed = matchesType(found.value, assertion.value);
|
|
58052
58231
|
break;
|
|
58053
58232
|
default: {
|
|
58054
|
-
const
|
|
58055
|
-
if (typeof
|
|
58233
|
+
const text5 = found.value;
|
|
58234
|
+
if (typeof text5 === "string") {
|
|
58056
58235
|
switch (assertion.operator) {
|
|
58057
58236
|
case "contains":
|
|
58058
|
-
passed =
|
|
58237
|
+
passed = text5.includes(assertion.value);
|
|
58059
58238
|
break;
|
|
58060
58239
|
case "not-contains":
|
|
58061
|
-
passed = !
|
|
58240
|
+
passed = !text5.includes(assertion.value);
|
|
58062
58241
|
break;
|
|
58063
58242
|
case "contains-any":
|
|
58064
58243
|
passed = assertion.value.some(
|
|
58065
|
-
(value2) =>
|
|
58244
|
+
(value2) => text5.includes(value2)
|
|
58066
58245
|
);
|
|
58067
58246
|
break;
|
|
58068
58247
|
case "contains-all":
|
|
58069
58248
|
passed = assertion.value.every(
|
|
58070
|
-
(value2) =>
|
|
58249
|
+
(value2) => text5.includes(value2)
|
|
58071
58250
|
);
|
|
58072
58251
|
break;
|
|
58073
58252
|
}
|
|
@@ -58622,7 +58801,7 @@ import { performance as performance4 } from "node:perf_hooks";
|
|
|
58622
58801
|
// package.json
|
|
58623
58802
|
var package_default = {
|
|
58624
58803
|
name: "@waitcher/cli",
|
|
58625
|
-
version: "0.2.
|
|
58804
|
+
version: "0.2.35",
|
|
58626
58805
|
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, TCP, DNS, heartbeat, API, browser, visual, MCP server and coding agent checks from waitcher.json, with AI checks and status pages.",
|
|
58627
58806
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
58628
58807
|
author: "S\u0142awomir Radzymi\u0144ski",
|
|
@@ -58731,7 +58910,7 @@ var MESSAGES = {
|
|
|
58731
58910
|
ASSERTION_FAILED: "The MCP tool result did not satisfy the checks"
|
|
58732
58911
|
};
|
|
58733
58912
|
var isObject2 = (value2) => value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
58734
|
-
var
|
|
58913
|
+
var text4 = (value2, secrets) => typeof value2 === "string" && value2.length <= 128 && /^[\x20-\x7e]*$/.test(value2) && !secrets.some((secret) => value2.includes(secret)) ? value2 : null;
|
|
58735
58914
|
async function readLimited(response, signal, onChunk) {
|
|
58736
58915
|
const length = response.headers.get("content-length");
|
|
58737
58916
|
if (length && /^\d+$/.test(length) && Number(length) > MCP_LIMITS.responseBytes) {
|
|
@@ -58935,11 +59114,11 @@ async function mcpCheck(monitor, parentSignal, options = {}) {
|
|
|
58935
59114
|
});
|
|
58936
59115
|
if (!isObject2(init)) throw new Stop("MALFORMED_RESPONSE");
|
|
58937
59116
|
const version2 = init.protocolVersion;
|
|
58938
|
-
report.server.protocolVersion =
|
|
59117
|
+
report.server.protocolVersion = text4(version2, secrets);
|
|
58939
59118
|
report.server.session = Boolean(session);
|
|
58940
59119
|
if (isObject2(init.serverInfo)) {
|
|
58941
|
-
report.server.name =
|
|
58942
|
-
report.server.version =
|
|
59120
|
+
report.server.name = text4(init.serverInfo.name, secrets);
|
|
59121
|
+
report.server.version = text4(init.serverInfo.version, secrets);
|
|
58943
59122
|
}
|
|
58944
59123
|
if (typeof version2 !== "string" || !MCP_PROTOCOL_VERSIONS.includes(version2))
|
|
58945
59124
|
throw new Stop("UNSUPPORTED_PROTOCOL");
|
|
@@ -58966,7 +59145,7 @@ async function mcpCheck(monitor, parentSignal, options = {}) {
|
|
|
58966
59145
|
report.tools.count = listed.size;
|
|
58967
59146
|
for (const name5 of listed) {
|
|
58968
59147
|
if (report.tools.names.length === MCP_LIMITS.reportedNames) break;
|
|
58969
|
-
const safe =
|
|
59148
|
+
const safe = text4(name5, secrets);
|
|
58970
59149
|
if (safe) report.tools.names.push(safe);
|
|
58971
59150
|
}
|
|
58972
59151
|
report.tools.missing = config2.expectTools.filter((name5) => !listed.has(name5));
|
|
@@ -59165,8 +59344,8 @@ async function tcpCheck(monitor, parent, io = tcpTransport, sink = {}) {
|
|
|
59165
59344
|
socket.on("data", (chunk) => {
|
|
59166
59345
|
chunks.push(chunk);
|
|
59167
59346
|
bytes2 += chunk.length;
|
|
59168
|
-
const
|
|
59169
|
-
if (
|
|
59347
|
+
const text5 = Buffer.concat(chunks).toString("utf8");
|
|
59348
|
+
if (text5.includes(expected)) {
|
|
59170
59349
|
trace.timings.banner = Math.round(performance5.now() - connectedAt);
|
|
59171
59350
|
finish({
|
|
59172
59351
|
status: "passed",
|
|
@@ -59664,9 +59843,9 @@ async function collectArtifacts(dir, base2 = dir, tokens2 = [], excluded = /* @_
|
|
|
59664
59843
|
"AI evidence exceeds its byte limit"
|
|
59665
59844
|
);
|
|
59666
59845
|
const original = await handle.readFile("utf8");
|
|
59667
|
-
const redactText = (
|
|
59846
|
+
const redactText = (text5) => tokens2.reduce(
|
|
59668
59847
|
(value2, token) => value2.replaceAll(token, "[redacted attempt credential]"),
|
|
59669
|
-
|
|
59848
|
+
text5
|
|
59670
59849
|
);
|
|
59671
59850
|
let clean = redactText(original);
|
|
59672
59851
|
if (entry2.name.endsWith(".json")) {
|
|
@@ -59815,7 +59994,7 @@ const agents={default:{model:connect(${JSON.stringify(dispatch.model)}),${dispat
|
|
|
59815
59994
|
const browserImports = m.type === "browser" && !network ? `import{protectedBrowserProvider,${options.browserIdentityFile ? "browserIdentitySecrets" : "browserExecutable"}}from ${JSON.stringify(browserClient)};import{chromium}from'playwright-core';${options.browserIdentityFile ? `const identitySecrets=await browserIdentitySecrets(${JSON.stringify(options.browserIdentityFile)});` : "const browserOverride=await browserExecutable();"}` : "";
|
|
59816
59995
|
const identityImports = options.browserIdentityFile ? network ? `import {browserIdentitySecrets} from ${JSON.stringify(pathToFileURL(options.isolationWebFile ?? resolve8(root, "dist/isolated-web.mjs")).href)};const identitySecrets=await browserIdentitySecrets(${JSON.stringify(options.browserIdentityFile)});` : "" : "";
|
|
59817
59996
|
const envNames = m.settings.envNames ?? [];
|
|
59818
|
-
const checkSecrets = envNames.length ? `const checkSecrets=Object.fromEntries(${JSON.stringify(envNames)}.flatMap(n=>{const v=process.env[n];return v&&[...v].length
|
|
59997
|
+
const checkSecrets = envNames.length ? `const checkSecrets=Object.fromEntries(${JSON.stringify(envNames)}.flatMap(n=>{const v=process.env[n];return v&&[...v].length>=${MIN_SECRET_CHARACTERS}?[[n,v]]:[]}));` : "";
|
|
59819
59998
|
const secrets = [
|
|
59820
59999
|
...envNames.length ? ["...checkSecrets"] : [],
|
|
59821
60000
|
...options.browserIdentityFile ? ["...identitySecrets"] : []
|
|
@@ -60029,8 +60208,21 @@ try {
|
|
|
60029
60208
|
const requestEvidence = await productRequestEvidence(dir);
|
|
60030
60209
|
const requestCoverageError = requestEvidence.summary.technicalError;
|
|
60031
60210
|
const passed = !requestCoverageError && !dataCoverageError && !dataFailed && !scenarioCoverageError && !scenarioFailed && p.code === 0 && run2?.status === "passed" && results.length > 0 && results.every((r) => r.status === "passed");
|
|
60211
|
+
const incompleteMessage = () => {
|
|
60212
|
+
const cause = e2eCause(report);
|
|
60213
|
+
if (!cause) return "E2E execution did not produce a complete result";
|
|
60214
|
+
const { message } = explainCause(cause, {
|
|
60215
|
+
where: options.causeAudience ?? "hosted",
|
|
60216
|
+
target: m.target,
|
|
60217
|
+
envNames,
|
|
60218
|
+
environment: Object.fromEntries(
|
|
60219
|
+
envNames.map((name5) => [name5, environment[name5]])
|
|
60220
|
+
)
|
|
60221
|
+
});
|
|
60222
|
+
return `${cause.code}: ${message}`.slice(0, 2e3);
|
|
60223
|
+
};
|
|
60032
60224
|
const redact = (value2) => redactions.reduce(
|
|
60033
|
-
(
|
|
60225
|
+
(text5, token) => text5.replaceAll(token, "[redacted attempt credential]"),
|
|
60034
60226
|
value2
|
|
60035
60227
|
);
|
|
60036
60228
|
const artifacts = await collectArtifacts(
|
|
@@ -60045,7 +60237,7 @@ try {
|
|
|
60045
60237
|
return {
|
|
60046
60238
|
status: passed ? "passed" : requestCoverageError || scenarioCoverageError || dataCoverageError || executionCoverageError ? "error" : "failed",
|
|
60047
60239
|
message: redact(
|
|
60048
|
-
requestCoverageError ? "Protected product request coverage was incomplete or invalid" : scenarioCoverageError ? "Required scenario coverage was incomplete or invalid" : dataCoverageError ? "API-data grading did not establish a conclusive result" : p.timedOut ? "Execution exceeded its wall-clock deadline" : executionCoverageError ?
|
|
60240
|
+
requestCoverageError ? "Protected product request coverage was incomplete or invalid" : scenarioCoverageError ? "Required scenario coverage was incomplete or invalid" : dataCoverageError ? "API-data grading did not establish a conclusive result" : p.timedOut ? "Execution exceeded its wall-clock deadline" : executionCoverageError ? incompleteMessage() : scenarioFailed ? "Scenario business assertions failed" : dataFailed ? "API-data grading failed its rubric" : passed ? `${results.length} e2e test${results.length === 1 ? "" : "s"} passed` : run2?.errors?.[0]?.message || firstTestError(results) || "e2e execution failed. Open the execution trace for details."
|
|
60049
60241
|
),
|
|
60050
60242
|
logs: redact(p.logs),
|
|
60051
60243
|
artifacts
|
|
@@ -60275,10 +60467,10 @@ async function execute(monitor, runDir, {
|
|
|
60275
60467
|
}
|
|
60276
60468
|
async function withTrace(result2, runDir, trace) {
|
|
60277
60469
|
try {
|
|
60278
|
-
const
|
|
60279
|
-
if (Buffer.byteLength(
|
|
60470
|
+
const text5 = JSON.stringify(runTraceFileSchema.parse(trace));
|
|
60471
|
+
if (Buffer.byteLength(text5) > RUN_TRACE_LIMITS.fileBytes) return result2;
|
|
60280
60472
|
await mkdir3(join6(runDir, ".e2e"), { recursive: true, mode: 448 });
|
|
60281
|
-
await writeFile3(join6(runDir, RUN_TRACE_PATH),
|
|
60473
|
+
await writeFile3(join6(runDir, RUN_TRACE_PATH), text5, { mode: 384 });
|
|
60282
60474
|
return {
|
|
60283
60475
|
...result2,
|
|
60284
60476
|
artifacts: [...result2.artifacts ?? [], RUN_TRACE_PATH]
|
|
@@ -60595,9 +60787,77 @@ var entries = {
|
|
|
60595
60787
|
RUNTIME_INSTALL_FAILED: {
|
|
60596
60788
|
title: "Runtime install failed",
|
|
60597
60789
|
meaning: "npm install or the Chromium download of waitcher runtime install exited with an error.",
|
|
60598
|
-
fix: "Read the npm or e2e-web output on stderr (network, registry or permissions), fix it and rerun waitcher runtime install --yes; it is safe to repeat.",
|
|
60790
|
+
fix: "Read the npm or e2e-web output on stderr (network, registry or permissions), fix it and rerun waitcher runtime install --yes; it is safe to repeat. npm 11 EALLOWSCRIPTS (--allow-scripts is not allowed in project-scoped installs): npm got allow-scripts from the command line or an npm_config_allow_scripts variable; unset it and approve with npm install-scripts approve esbuild or allow-scripts=esbuild in .npmrc.",
|
|
60599
60791
|
exitCode: 1
|
|
60600
60792
|
},
|
|
60793
|
+
FILE_EXISTS: {
|
|
60794
|
+
title: "File already exists",
|
|
60795
|
+
meaning: "init, export and other writers never overwrite a file.",
|
|
60796
|
+
fix: "Choose another --file path, or edit the existing file.",
|
|
60797
|
+
exitCode: 2
|
|
60798
|
+
},
|
|
60799
|
+
CONFIG_DIR_PERMISSIONS: {
|
|
60800
|
+
title: "Config directory is not private",
|
|
60801
|
+
meaning: "The folder that keeps sessions (~/.config/waitcher or WAITCHER_CONFIG_DIR), or a session file in it, is readable by other users or is a link, so the CLI neither reads nor saves a session there.",
|
|
60802
|
+
fix: "macOS and Linux: chmod 700 the folder (chmod 600 a session file), or point WAITCHER_CONFIG_DIR at a new private folder. Windows checks no mode bits; point WAITCHER_CONFIG_DIR at a regular folder that is not a link.",
|
|
60803
|
+
exitCode: 2
|
|
60804
|
+
},
|
|
60805
|
+
// Causes the test framework names when a script run stops (run local,
|
|
60806
|
+
// config validate --verify, hosted runs). The run exits 4.
|
|
60807
|
+
SECRET_UNAVAILABLE: {
|
|
60808
|
+
title: "A CHECK_* value is missing or too short",
|
|
60809
|
+
meaning: "The script reads a secret with secrets.get(NAME) that this run has no value for, or whose value is shorter than 6 characters (masking a shorter value would rewrite unrelated text, so it is not registered as a secret).",
|
|
60810
|
+
fix: "List the name in settings.envNames. run local: the user exports it in the shell. Hosted: waitcher secret set --env ENV --name NAME --value-stdin, or the Monitors page. For a value under 6 characters, read process.env.NAME in the script instead (unmasked in evidence).",
|
|
60811
|
+
exitCode: 4
|
|
60812
|
+
},
|
|
60813
|
+
APP_UNREACHABLE: {
|
|
60814
|
+
title: "Nothing answered at the target",
|
|
60815
|
+
meaning: "The browser could not reach the monitor's target (connection refused, DNS or TLS failure).",
|
|
60816
|
+
fix: "run local: start the app at the monitor's target, or change target to where it runs. Hosted: the target must answer from the public internet.",
|
|
60817
|
+
exitCode: 4
|
|
60818
|
+
},
|
|
60819
|
+
BROWSER_INSTALL_FAILED: {
|
|
60820
|
+
title: "Chromium could not be installed",
|
|
60821
|
+
meaning: "The run found no Chromium for its runtime and the download failed.",
|
|
60822
|
+
fix: "Run waitcher runtime install --browser --yes after the user agrees (on Linux add system libraries with npx e2e-web install chromium --with-deps), then rerun.",
|
|
60823
|
+
exitCode: 4
|
|
60824
|
+
},
|
|
60825
|
+
ENGINE_NOT_INSTALLED: {
|
|
60826
|
+
title: "Test runtime incomplete",
|
|
60827
|
+
meaning: "A package the script needs (@e2e-dev/web for browser checks) is not installed in the runtime folder.",
|
|
60828
|
+
fix: "Run waitcher runtime install (with --browser for browser checks) in the folder with package.json, then rerun.",
|
|
60829
|
+
exitCode: 4
|
|
60830
|
+
},
|
|
60831
|
+
COLLECTION_ERROR: {
|
|
60832
|
+
title: "Test file did not load",
|
|
60833
|
+
meaning: "The script failed to import or compile, so no test ran.",
|
|
60834
|
+
fix: "Fix the error in the message; scripts import test from @e2e-dev/web (browser) or e2e (API) and declare at least one test.",
|
|
60835
|
+
exitCode: 4
|
|
60836
|
+
},
|
|
60837
|
+
NO_TESTS: {
|
|
60838
|
+
title: "No test in the script",
|
|
60839
|
+
meaning: "The script declares no test(...), so the run has nothing to check.",
|
|
60840
|
+
fix: "Declare one test(...) in the script, then rerun.",
|
|
60841
|
+
exitCode: 4
|
|
60842
|
+
},
|
|
60843
|
+
TEST_SETUP_FAILED: {
|
|
60844
|
+
title: "Test setup failed",
|
|
60845
|
+
meaning: "A fixture or beforeAll/beforeEach step failed before the test body ran.",
|
|
60846
|
+
fix: "Read the message and the trace (run diagnose), fix the setup step, then rerun.",
|
|
60847
|
+
exitCode: 4
|
|
60848
|
+
},
|
|
60849
|
+
LAUNCH_TIMEOUT: {
|
|
60850
|
+
title: "Browser did not start in time",
|
|
60851
|
+
meaning: "Chromium did not launch within the framework's limit, usually on an overloaded machine or with missing system libraries.",
|
|
60852
|
+
fix: "Rerun; on Linux install system libraries with npx e2e-web install chromium --with-deps.",
|
|
60853
|
+
exitCode: 4
|
|
60854
|
+
},
|
|
60855
|
+
MODEL_UNAVAILABLE: {
|
|
60856
|
+
title: "AI step without a model",
|
|
60857
|
+
meaning: "The script uses an AI step but the run has no model connection.",
|
|
60858
|
+
fix: "run local: pass --connections-file with the monitor's AI connection. Hosted: bind an AI connection, or remove the AI step.",
|
|
60859
|
+
exitCode: 4
|
|
60860
|
+
},
|
|
60601
60861
|
FILE_NOT_FOUND: {
|
|
60602
60862
|
title: "File not found",
|
|
60603
60863
|
meaning: "A referenced local file does not exist.",
|
|
@@ -60764,7 +61024,7 @@ var projectConfigSchema = external_exports.object({
|
|
|
60764
61024
|
monitors: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(CONFIG_LIMITS.monitors)
|
|
60765
61025
|
}).strict();
|
|
60766
61026
|
var pathOf = (parts) => parts.reduce(
|
|
60767
|
-
(
|
|
61027
|
+
(text5, part2) => typeof part2 === "number" ? `${text5}[${part2}]` : `${text5}${text5 ? "." : ""}${String(part2)}`,
|
|
60768
61028
|
""
|
|
60769
61029
|
);
|
|
60770
61030
|
var PLACEHOLDER_HTTP_AUTH = {
|
|
@@ -61103,8 +61363,8 @@ async function readConnectionConfiguration(file2) {
|
|
|
61103
61363
|
2
|
|
61104
61364
|
);
|
|
61105
61365
|
}
|
|
61106
|
-
function providerCredential(
|
|
61107
|
-
const parsed = connectionSecretSchema.safeParse(
|
|
61366
|
+
function providerCredential(text5) {
|
|
61367
|
+
const parsed = connectionSecretSchema.safeParse(text5.trim());
|
|
61108
61368
|
if (!parsed.success)
|
|
61109
61369
|
throw new ServiceError(
|
|
61110
61370
|
"Provide a private provider key through --credential-file or --credential-stdin.",
|
|
@@ -61362,8 +61622,8 @@ function modelTransport(authority, options = {}) {
|
|
|
61362
61622
|
"Model provider did not accept the request"
|
|
61363
61623
|
);
|
|
61364
61624
|
}
|
|
61365
|
-
const
|
|
61366
|
-
if (
|
|
61625
|
+
const text5 = await boundedText(response2, MODEL_LIMITS.responseBytes);
|
|
61626
|
+
if (text5.includes(call.secret) || text5.includes(JSON.stringify(call.secret).slice(1, -1)))
|
|
61367
61627
|
throw new AppError(
|
|
61368
61628
|
502,
|
|
61369
61629
|
"AI_RESPONSE_REJECTED",
|
|
@@ -61371,7 +61631,7 @@ function modelTransport(authority, options = {}) {
|
|
|
61371
61631
|
);
|
|
61372
61632
|
let result2;
|
|
61373
61633
|
try {
|
|
61374
|
-
result2 = modelResponseSchema.safeParse(JSON.parse(
|
|
61634
|
+
result2 = modelResponseSchema.safeParse(JSON.parse(text5));
|
|
61375
61635
|
} catch {
|
|
61376
61636
|
}
|
|
61377
61637
|
if (!result2?.success || result2.data.model !== body2.model)
|
|
@@ -61655,12 +61915,279 @@ async function localModelBroker(input2, options = {}) {
|
|
|
61655
61915
|
};
|
|
61656
61916
|
}
|
|
61657
61917
|
|
|
61918
|
+
// src/runtime.ts
|
|
61919
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
61920
|
+
import { access, readdir, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
|
|
61921
|
+
import { basename, dirname as dirname8, join as join8, resolve as resolve10, sep } from "node:path";
|
|
61922
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
61923
|
+
var RUNTIME_IGNORES = ["node_modules/", ".waitcher/", ".e2e/"];
|
|
61924
|
+
async function installedPackage(from, name5) {
|
|
61925
|
+
for (let dir = resolve10(from); ; ) {
|
|
61926
|
+
const folder = join8(dir, "node_modules", ...name5.split("/"));
|
|
61927
|
+
try {
|
|
61928
|
+
const meta3 = JSON.parse(await readFile4(join8(folder, "package.json"), "utf8"));
|
|
61929
|
+
if (meta3.name === name5)
|
|
61930
|
+
return { dir: folder, version: meta3.version, main: meta3.main };
|
|
61931
|
+
} catch {
|
|
61932
|
+
}
|
|
61933
|
+
const parent = dirname8(dir);
|
|
61934
|
+
if (parent === dir) return null;
|
|
61935
|
+
dir = parent;
|
|
61936
|
+
}
|
|
61937
|
+
}
|
|
61938
|
+
var installedVersion = async (project, name5) => (await installedPackage(project, name5))?.version ?? null;
|
|
61939
|
+
async function chromiumInstalled(project) {
|
|
61940
|
+
try {
|
|
61941
|
+
const web = await installedPackage(project, "@e2e-dev/web");
|
|
61942
|
+
if (!web) return false;
|
|
61943
|
+
const core = await installedPackage(web.dir, "playwright-core");
|
|
61944
|
+
if (!core) return false;
|
|
61945
|
+
const playwright = await import(pathToFileURL2(join8(core.dir, core.main ?? "index.js")).href);
|
|
61946
|
+
await access((playwright.default ?? playwright).chromium.executablePath());
|
|
61947
|
+
return true;
|
|
61948
|
+
} catch {
|
|
61949
|
+
return false;
|
|
61950
|
+
}
|
|
61951
|
+
}
|
|
61952
|
+
async function headlessShellInstalled(project) {
|
|
61953
|
+
try {
|
|
61954
|
+
const web = await installedPackage(project, "@e2e-dev/web");
|
|
61955
|
+
if (!web) return false;
|
|
61956
|
+
const core = await installedPackage(web.dir, "playwright-core");
|
|
61957
|
+
if (!core) return false;
|
|
61958
|
+
const playwright = await import(pathToFileURL2(join8(core.dir, core.main ?? "index.js")).href);
|
|
61959
|
+
const executable = (playwright.default ?? playwright).chromium.executablePath();
|
|
61960
|
+
const marker2 = `${sep}chromium-`;
|
|
61961
|
+
const at = executable.lastIndexOf(marker2);
|
|
61962
|
+
if (at === -1) return false;
|
|
61963
|
+
const revision = executable.slice(at + marker2.length).split(sep)[0];
|
|
61964
|
+
await access(
|
|
61965
|
+
join8(executable.slice(0, at), `chromium_headless_shell-${revision}`, "INSTALLATION_COMPLETE")
|
|
61966
|
+
);
|
|
61967
|
+
return true;
|
|
61968
|
+
} catch {
|
|
61969
|
+
return false;
|
|
61970
|
+
}
|
|
61971
|
+
}
|
|
61972
|
+
async function monitorFiles(root) {
|
|
61973
|
+
const found = [];
|
|
61974
|
+
const skip = /* @__PURE__ */ new Set(["node_modules", ".git", ".waitcher", ".e2e"]);
|
|
61975
|
+
const scan = async (dir, depth) => {
|
|
61976
|
+
let items;
|
|
61977
|
+
try {
|
|
61978
|
+
items = await readdir(dir, { withFileTypes: true });
|
|
61979
|
+
} catch {
|
|
61980
|
+
return;
|
|
61981
|
+
}
|
|
61982
|
+
for (const item of items.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
61983
|
+
if (found.length >= 20) return;
|
|
61984
|
+
const path2 = join8(dir, item.name);
|
|
61985
|
+
if (item.isDirectory() && depth < 1 && !skip.has(item.name)) await scan(path2, depth + 1);
|
|
61986
|
+
else if (item.isFile() && item.name.endsWith(".monitor.json")) {
|
|
61987
|
+
let type = null;
|
|
61988
|
+
try {
|
|
61989
|
+
const value2 = JSON.parse(await readFile4(path2, "utf8"));
|
|
61990
|
+
type = typeof value2?.type === "string" ? value2.type : null;
|
|
61991
|
+
} catch {
|
|
61992
|
+
}
|
|
61993
|
+
found.push({ file: path2, type });
|
|
61994
|
+
}
|
|
61995
|
+
}
|
|
61996
|
+
};
|
|
61997
|
+
await scan(root, 0);
|
|
61998
|
+
return found;
|
|
61999
|
+
}
|
|
62000
|
+
function pinPackageJson(existing, project, pins = RUNTIME_PINS) {
|
|
62001
|
+
const json3 = existing ? structuredClone(existing) : {
|
|
62002
|
+
name: basename(project).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "") || "waitcher-monitors",
|
|
62003
|
+
private: true
|
|
62004
|
+
};
|
|
62005
|
+
const changes = [];
|
|
62006
|
+
for (const [name5, to] of Object.entries(pins)) {
|
|
62007
|
+
const field = json3.dependencies?.[name5] !== void 0 ? "dependencies" : "devDependencies";
|
|
62008
|
+
const from = json3[field]?.[name5] ?? null;
|
|
62009
|
+
if (from === to) continue;
|
|
62010
|
+
json3[field] = { ...json3[field], [name5]: to };
|
|
62011
|
+
changes.push({ name: name5, from, to });
|
|
62012
|
+
}
|
|
62013
|
+
for (const [name5, nested] of Object.entries(RUNTIME_OVERRIDES))
|
|
62014
|
+
for (const [dep, to] of Object.entries(nested)) {
|
|
62015
|
+
const current = json3.overrides?.[name5];
|
|
62016
|
+
const from = typeof current === "object" ? current?.[dep] ?? null : null;
|
|
62017
|
+
if (from === to) continue;
|
|
62018
|
+
json3.overrides = {
|
|
62019
|
+
...json3.overrides,
|
|
62020
|
+
[name5]: { ...typeof current === "object" ? current : {}, [dep]: to }
|
|
62021
|
+
};
|
|
62022
|
+
changes.push({ name: `overrides.${name5}.${dep}`, from, to });
|
|
62023
|
+
}
|
|
62024
|
+
return { json: json3, changes };
|
|
62025
|
+
}
|
|
62026
|
+
var missingIgnores = (text5) => {
|
|
62027
|
+
const lines = new Set(
|
|
62028
|
+
text5.split(/\r?\n/).map((l) => l.trim().replace(/^\//, ""))
|
|
62029
|
+
);
|
|
62030
|
+
return RUNTIME_IGNORES.filter(
|
|
62031
|
+
(entry2) => !lines.has(entry2) && !lines.has(entry2.slice(0, -1))
|
|
62032
|
+
);
|
|
62033
|
+
};
|
|
62034
|
+
function run(command, args, cwd, signal) {
|
|
62035
|
+
return new Promise((resolve19, reject) => {
|
|
62036
|
+
const child2 = spawn2(command, args, {
|
|
62037
|
+
cwd,
|
|
62038
|
+
signal,
|
|
62039
|
+
stdio: ["ignore", process.stderr, process.stderr],
|
|
62040
|
+
shell: process.platform === "win32"
|
|
62041
|
+
});
|
|
62042
|
+
child2.on("error", reject);
|
|
62043
|
+
child2.on(
|
|
62044
|
+
"exit",
|
|
62045
|
+
(code) => code === 0 ? resolve19() : reject(
|
|
62046
|
+
new ServiceError(
|
|
62047
|
+
`${command} ${args.join(" ")} exited with ${code}; read its output above.`,
|
|
62048
|
+
"RUNTIME_INSTALL_FAILED",
|
|
62049
|
+
1
|
|
62050
|
+
)
|
|
62051
|
+
)
|
|
62052
|
+
);
|
|
62053
|
+
});
|
|
62054
|
+
}
|
|
62055
|
+
async function installRuntime(options) {
|
|
62056
|
+
const { project, yes, signal } = options;
|
|
62057
|
+
const manifestPath = join8(project, "package.json");
|
|
62058
|
+
const text5 = await readFile4(manifestPath, "utf8").catch(() => null);
|
|
62059
|
+
let existing = null;
|
|
62060
|
+
if (text5 !== null)
|
|
62061
|
+
try {
|
|
62062
|
+
existing = JSON.parse(text5);
|
|
62063
|
+
} catch (cause) {
|
|
62064
|
+
throw new ServiceError(
|
|
62065
|
+
`${manifestPath} is not valid JSON: ${cause.message}`,
|
|
62066
|
+
"VALIDATION_ERROR",
|
|
62067
|
+
2
|
|
62068
|
+
);
|
|
62069
|
+
}
|
|
62070
|
+
const installed = {};
|
|
62071
|
+
for (const name5 of Object.keys(RUNTIME_PINS))
|
|
62072
|
+
installed[name5] = await installedVersion(project, name5);
|
|
62073
|
+
const monitors = options.hasConfig === false ? await monitorFiles(project) : [];
|
|
62074
|
+
const browser = options.browser || Boolean(installed["@e2e-dev/web"]) || existing?.dependencies?.["@e2e-dev/web"] !== void 0 || existing?.devDependencies?.["@e2e-dev/web"] !== void 0 || monitors.some((m) => m.type === "browser");
|
|
62075
|
+
const needed = runtimePackages(browser);
|
|
62076
|
+
const generation = options.generation ?? installedGeneration(installed, browser) ?? RUNTIME_GENERATIONS[0];
|
|
62077
|
+
const pins = generationPins(generation);
|
|
62078
|
+
const { json: json3, changes } = pinPackageJson(existing, project, pins);
|
|
62079
|
+
const stale = Object.keys(pins).filter(
|
|
62080
|
+
(name5) => installed[name5] !== pins[name5]
|
|
62081
|
+
);
|
|
62082
|
+
const ignorePath = join8(project, ".gitignore");
|
|
62083
|
+
const ignoreText = await readFile4(ignorePath, "utf8").catch(() => "");
|
|
62084
|
+
const ignores = [];
|
|
62085
|
+
for (const entry2 of missingIgnores(ignoreText))
|
|
62086
|
+
if (!await gitIgnored(project, entry2)) ignores.push(entry2);
|
|
62087
|
+
const npmInstall = changes.length > 0 || stale.length > 0;
|
|
62088
|
+
const chromium = browser && (npmInstall || !await chromiumInstalled(project) || !await headlessShellInstalled(project));
|
|
62089
|
+
const steps = [
|
|
62090
|
+
...changes.length ? [`${existing ? "update" : "create"} ${manifestPath}: ${changes.map((c) => `${c.name} ${c.from ?? "(none)"} -> ${c.to}`).join(", ")}`] : [],
|
|
62091
|
+
...ignores.length ? [`add ${ignores.join(" ")} to ${ignorePath}`] : [],
|
|
62092
|
+
...npmInstall ? [`npm install in ${project} (runs package install scripts)`] : [],
|
|
62093
|
+
...chromium ? ["npx --no-install e2e-web install chromium (downloads Chromium)"] : []
|
|
62094
|
+
];
|
|
62095
|
+
const base2 = {
|
|
62096
|
+
project,
|
|
62097
|
+
generation: generation.id,
|
|
62098
|
+
runtime: pins,
|
|
62099
|
+
packages: needed,
|
|
62100
|
+
browser,
|
|
62101
|
+
installed,
|
|
62102
|
+
changes,
|
|
62103
|
+
gitignore: ignores
|
|
62104
|
+
};
|
|
62105
|
+
if (!npmInstall && !ignores.length && !chromium)
|
|
62106
|
+
return {
|
|
62107
|
+
event: "runtime_current",
|
|
62108
|
+
ok: true,
|
|
62109
|
+
applied: false,
|
|
62110
|
+
...base2,
|
|
62111
|
+
steps: [],
|
|
62112
|
+
// Without waitcher.json the useful next step is a local run.
|
|
62113
|
+
next: options.hasConfig === false ? afterInstall(project, false, monitors).slice(0, -1) : []
|
|
62114
|
+
};
|
|
62115
|
+
if (!yes)
|
|
62116
|
+
return {
|
|
62117
|
+
event: "runtime_planned",
|
|
62118
|
+
ok: true,
|
|
62119
|
+
applied: false,
|
|
62120
|
+
...base2,
|
|
62121
|
+
steps,
|
|
62122
|
+
next: [
|
|
62123
|
+
`Ask the user to agree to these steps, then run ${options.command ?? `waitcher runtime install --file ${join8(project, "waitcher.json")}`} --yes`
|
|
62124
|
+
]
|
|
62125
|
+
};
|
|
62126
|
+
if (changes.length)
|
|
62127
|
+
await writeFile4(manifestPath, JSON.stringify(json3, null, 2) + "\n");
|
|
62128
|
+
if (ignores.length)
|
|
62129
|
+
await writeFile4(
|
|
62130
|
+
ignorePath,
|
|
62131
|
+
`${ignoreText}${ignoreText && !ignoreText.endsWith("\n") ? "\n" : ""}${ignores.join("\n")}
|
|
62132
|
+
`
|
|
62133
|
+
);
|
|
62134
|
+
if (npmInstall)
|
|
62135
|
+
await run("npm", ["install", "--no-audit", "--no-fund"], project, signal);
|
|
62136
|
+
if (chromium)
|
|
62137
|
+
await run("npx", ["--no-install", "e2e-web", "install", "chromium"], project, signal);
|
|
62138
|
+
for (const name5 of needed) {
|
|
62139
|
+
const found = await installedVersion(project, name5);
|
|
62140
|
+
if (found !== pins[name5])
|
|
62141
|
+
throw new ServiceError(
|
|
62142
|
+
`${name5}@${pins[name5]} is still not resolvable from ${project} (found ${found ?? "nothing"}). A parent workspace or lockfile may override it.`,
|
|
62143
|
+
"RUNTIME_VERSION_MISMATCH",
|
|
62144
|
+
2
|
|
62145
|
+
);
|
|
62146
|
+
}
|
|
62147
|
+
return {
|
|
62148
|
+
event: "runtime_installed",
|
|
62149
|
+
ok: true,
|
|
62150
|
+
applied: true,
|
|
62151
|
+
...base2,
|
|
62152
|
+
installed: Object.fromEntries(needed.map((n) => [n, pins[n]])),
|
|
62153
|
+
steps,
|
|
62154
|
+
next: afterInstall(project, options.hasConfig ?? true, monitors)
|
|
62155
|
+
};
|
|
62156
|
+
}
|
|
62157
|
+
function afterInstall(project, hasConfig, monitors) {
|
|
62158
|
+
const commit = "Commit package.json, package-lock.json and .gitignore";
|
|
62159
|
+
if (hasConfig)
|
|
62160
|
+
return [
|
|
62161
|
+
`waitcher config validate --file ${join8(project, "waitcher.json")}`,
|
|
62162
|
+
`waitcher deploy plan --file ${join8(project, "waitcher.json")} --env ENV --verify`,
|
|
62163
|
+
commit
|
|
62164
|
+
];
|
|
62165
|
+
const runtime2 = resolve10(process.cwd()) === project ? "" : ` --runtime ${project}`;
|
|
62166
|
+
return [
|
|
62167
|
+
...monitors.length ? monitors.slice(0, 5).map((m) => `waitcher run local --file ${m.file}${runtime2}`) : [
|
|
62168
|
+
`waitcher monitor init --type browser --file ${join8(project, "home.monitor.json")} --target http://localhost:3000/ (or --type api or http), then waitcher run local --file that file${runtime2}`
|
|
62169
|
+
],
|
|
62170
|
+
commit
|
|
62171
|
+
];
|
|
62172
|
+
}
|
|
62173
|
+
function gitIgnored(project, entry2) {
|
|
62174
|
+
return new Promise((done) => {
|
|
62175
|
+
const child2 = spawn2("git", ["check-ignore", "-q", "--no-index", entry2], {
|
|
62176
|
+
cwd: project,
|
|
62177
|
+
stdio: "ignore"
|
|
62178
|
+
});
|
|
62179
|
+
child2.once("error", () => done(false));
|
|
62180
|
+
child2.once("close", (code) => done(code === 0));
|
|
62181
|
+
});
|
|
62182
|
+
}
|
|
62183
|
+
|
|
61658
62184
|
// src/local.ts
|
|
62185
|
+
var PROJECT_FAILED = "e2e execution failed. Inspect the report and logs.";
|
|
61659
62186
|
var invalid2 = (message) => {
|
|
61660
62187
|
throw new ServiceError(message, "USAGE_ERROR", 2);
|
|
61661
62188
|
};
|
|
61662
62189
|
async function runtime(project, browser, ai = false) {
|
|
61663
|
-
const require2 = createRequire(
|
|
62190
|
+
const require2 = createRequire(join9(project, "package.json"));
|
|
61664
62191
|
async function locate(name5) {
|
|
61665
62192
|
let entry2;
|
|
61666
62193
|
try {
|
|
@@ -61670,9 +62197,9 @@ async function runtime(project, browser, ai = false) {
|
|
|
61670
62197
|
`Install ${name5} in ${project} before running locally (waitcher runtime install).`
|
|
61671
62198
|
);
|
|
61672
62199
|
}
|
|
61673
|
-
const root =
|
|
62200
|
+
const root = dirname9(dirname9(entry2));
|
|
61674
62201
|
const metadata2 = JSON.parse(
|
|
61675
|
-
await
|
|
62202
|
+
await readFile5(join9(root, "package.json"), "utf8")
|
|
61676
62203
|
);
|
|
61677
62204
|
if (metadata2.name !== name5)
|
|
61678
62205
|
invalid2(`${name5} in ${project} is not the ${name5} package.`);
|
|
@@ -61691,19 +62218,60 @@ async function runtime(project, browser, ai = false) {
|
|
|
61691
62218
|
if (model.version !== "7.0.177")
|
|
61692
62219
|
invalid2(`Local execution requires ai@7.0.177; found ${model.version}.`);
|
|
61693
62220
|
}
|
|
61694
|
-
return
|
|
62221
|
+
return join9(e2e.root, "dist/cli/bin.js");
|
|
62222
|
+
}
|
|
62223
|
+
async function ignoreRunFolder(parent, isDefault) {
|
|
62224
|
+
if (!isDefault) return;
|
|
62225
|
+
await writeFile5(join9(dirname9(parent), ".gitignore"), "*\n", {
|
|
62226
|
+
mode: 384,
|
|
62227
|
+
flag: "wx"
|
|
62228
|
+
}).catch((error62) => {
|
|
62229
|
+
if (error62.code !== "EEXIST") throw error62;
|
|
62230
|
+
});
|
|
62231
|
+
}
|
|
62232
|
+
async function classifiedFailure(directory, evidence, definition) {
|
|
62233
|
+
let report;
|
|
62234
|
+
try {
|
|
62235
|
+
const path2 = join9(directory, evidence, "report.json");
|
|
62236
|
+
if ((await lstat7(path2)).size > STORAGE_LIMITS.artifactFileBytes) return null;
|
|
62237
|
+
report = JSON.parse(await readFile5(path2, "utf8"));
|
|
62238
|
+
} catch {
|
|
62239
|
+
return null;
|
|
62240
|
+
}
|
|
62241
|
+
const cause = e2eCause(report);
|
|
62242
|
+
if (!cause) return null;
|
|
62243
|
+
const diagnose = `waitcher run diagnose --directory ${directory}`;
|
|
62244
|
+
const trace = cause.trace ? join9(directory, evidence, cause.trace) : null;
|
|
62245
|
+
if (!definition)
|
|
62246
|
+
return {
|
|
62247
|
+
code: cause.code,
|
|
62248
|
+
message: cause.detail || cause.code,
|
|
62249
|
+
test: cause.test,
|
|
62250
|
+
trace,
|
|
62251
|
+
next: [`waitcher explain ${cause.code}`, diagnose]
|
|
62252
|
+
};
|
|
62253
|
+
const envNames = definition.settings?.envNames ?? [];
|
|
62254
|
+
const explained = explainCause(cause, {
|
|
62255
|
+
where: "local",
|
|
62256
|
+
target: definition.target,
|
|
62257
|
+
envNames,
|
|
62258
|
+
environment: Object.fromEntries(
|
|
62259
|
+
envNames.map((name5) => [name5, process.env[name5]])
|
|
62260
|
+
)
|
|
62261
|
+
});
|
|
62262
|
+
return { code: cause.code, test: cause.test, trace, ...explained, next: [...explained.next, diagnose] };
|
|
61695
62263
|
}
|
|
61696
62264
|
async function inventory(root) {
|
|
61697
62265
|
const files = [];
|
|
61698
62266
|
async function walk(path2) {
|
|
61699
|
-
for (const item of await
|
|
61700
|
-
const full =
|
|
62267
|
+
for (const item of await readdir2(path2, { withFileTypes: true })) {
|
|
62268
|
+
const full = join9(path2, item.name);
|
|
61701
62269
|
if (item.isSymbolicLink() || item.name === "node_modules") continue;
|
|
61702
62270
|
if (item.isDirectory()) await walk(full);
|
|
61703
62271
|
else if (item.isFile()) {
|
|
61704
|
-
const bytes2 = await
|
|
62272
|
+
const bytes2 = await readFile5(full);
|
|
61705
62273
|
files.push({
|
|
61706
|
-
path: relative(root, full).split(
|
|
62274
|
+
path: relative(root, full).split(sep2).join("/"),
|
|
61707
62275
|
bytes: bytes2.length,
|
|
61708
62276
|
sha256: createHash8("sha256").update(bytes2).digest("hex")
|
|
61709
62277
|
});
|
|
@@ -61728,12 +62296,13 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61728
62296
|
options.httpCredentialsFile,
|
|
61729
62297
|
definition
|
|
61730
62298
|
);
|
|
61731
|
-
const parent =
|
|
62299
|
+
const parent = resolve11(options.output ?? join9(project, ".waitcher/runs"));
|
|
61732
62300
|
await mkdir4(parent, { recursive: true, mode: 448 });
|
|
62301
|
+
await ignoreRunFolder(parent, !options.output);
|
|
61733
62302
|
const info = await lstat7(parent);
|
|
61734
62303
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
61735
62304
|
invalid2("Output must be a regular directory, not a symbolic link.");
|
|
61736
|
-
const runId = randomUUID4(), directory =
|
|
62305
|
+
const runId = randomUUID4(), directory = join9(parent, runId), startedAt = Date.now(), start = performance7.now();
|
|
61737
62306
|
await mkdir4(directory, { mode: 448 });
|
|
61738
62307
|
const timeout = options.timeout ?? definition.timeout;
|
|
61739
62308
|
const signal = AbortSignal.any([
|
|
@@ -61784,8 +62353,8 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61784
62353
|
}
|
|
61785
62354
|
if (broker) {
|
|
61786
62355
|
modelUsage = await broker.finish();
|
|
61787
|
-
await
|
|
61788
|
-
|
|
62356
|
+
await writeFile5(
|
|
62357
|
+
join9(directory, "model-usage.json"),
|
|
61789
62358
|
JSON.stringify(modelUsage, null, 2) + "\n",
|
|
61790
62359
|
{ mode: 384, flag: "wx" }
|
|
61791
62360
|
);
|
|
@@ -61795,10 +62364,10 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61795
62364
|
check2.status = "error";
|
|
61796
62365
|
check2.message = "Local semantic grading could not verify model usage. Inspect model-usage.json and the endpoint report.";
|
|
61797
62366
|
}
|
|
61798
|
-
const report =
|
|
62367
|
+
const report = join9(
|
|
61799
62368
|
directory,
|
|
61800
62369
|
definition.type === "ai" ? "ai-endpoint-report.json" : definition.type === "mcp" ? "mcp-report.json" : ["tcp", "dns"].includes(definition.type) ? "network-report.json" : "http-report.json"
|
|
61801
|
-
), log =
|
|
62370
|
+
), log = join9(directory, "execution.log");
|
|
61802
62371
|
const reportText = ["ai", "mcp"].includes(definition.type) ? check2.logs : JSON.stringify({
|
|
61803
62372
|
schemaVersion: 1,
|
|
61804
62373
|
kind: ["tcp", "dns"].includes(definition.type) ? definition.type : "http",
|
|
@@ -61806,11 +62375,11 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61806
62375
|
message: check2.message,
|
|
61807
62376
|
duration: check2.duration
|
|
61808
62377
|
});
|
|
61809
|
-
await
|
|
61810
|
-
await
|
|
62378
|
+
await writeFile5(report, reportText + "\n", { mode: 384, flag: "wx" });
|
|
62379
|
+
await writeFile5(log, check2.logs + "\n", { mode: 384, flag: "wx" });
|
|
61811
62380
|
if (mcpToolResult !== void 0)
|
|
61812
|
-
await
|
|
61813
|
-
|
|
62381
|
+
await writeFile5(
|
|
62382
|
+
join9(directory, "mcp-tool-result.json"),
|
|
61814
62383
|
JSON.stringify(mcpToolResult, null, 2) + "\n",
|
|
61815
62384
|
{ mode: 384, flag: "wx" }
|
|
61816
62385
|
);
|
|
@@ -61829,10 +62398,15 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61829
62398
|
summary: null,
|
|
61830
62399
|
log,
|
|
61831
62400
|
videoRequested: false,
|
|
62401
|
+
...check2.status === "passed" ? {} : {
|
|
62402
|
+
next: [
|
|
62403
|
+
check2.status === "error" ? `Check that something answers at ${definition.target} (for a local app, start it there), then rerun this command` : `Compare the response with the monitor's assertions in ${options.file ?? "the monitor file"}, then rerun this command`
|
|
62404
|
+
]
|
|
62405
|
+
},
|
|
61832
62406
|
files: await inventory(directory)
|
|
61833
62407
|
};
|
|
61834
|
-
await
|
|
61835
|
-
|
|
62408
|
+
await writeFile5(
|
|
62409
|
+
join9(directory, "local-run.json"),
|
|
61836
62410
|
JSON.stringify(result2, null, 2) + "\n",
|
|
61837
62411
|
{ mode: 384, flag: "wx" }
|
|
61838
62412
|
);
|
|
@@ -61851,7 +62425,7 @@ async function runLocal(options) {
|
|
|
61851
62425
|
"--runtime applies to --file only; projects use their installed E2E runtime."
|
|
61852
62426
|
);
|
|
61853
62427
|
const project = await realpath(
|
|
61854
|
-
|
|
62428
|
+
resolve11(options.project ?? options.runtime ?? process.cwd())
|
|
61855
62429
|
);
|
|
61856
62430
|
const definition = options.file ? await readManifest(options.file) : null;
|
|
61857
62431
|
if (!definition && options.browserIdentitiesFile)
|
|
@@ -61908,7 +62482,7 @@ async function runLocal(options) {
|
|
|
61908
62482
|
if (!definition) {
|
|
61909
62483
|
const config2 = await Promise.all(
|
|
61910
62484
|
["ts", "mts", "js", "mjs"].map(
|
|
61911
|
-
(extension) => lstat7(
|
|
62485
|
+
(extension) => lstat7(join9(project, `e2e.config.${extension}`)).then(
|
|
61912
62486
|
(s) => s.isFile(),
|
|
61913
62487
|
() => false
|
|
61914
62488
|
)
|
|
@@ -61919,33 +62493,40 @@ async function runLocal(options) {
|
|
|
61919
62493
|
"The project must contain an e2e.config.ts (or .mts/.js/.mjs). Run e2e init in that project first."
|
|
61920
62494
|
);
|
|
61921
62495
|
} else {
|
|
61922
|
-
if (!(await lstat7(
|
|
62496
|
+
if (!(await lstat7(join9(project, "node_modules")).catch(() => null))?.isDirectory())
|
|
61923
62497
|
invalid2(
|
|
61924
62498
|
"--runtime must contain node_modules for the pinned E2E dependencies."
|
|
61925
62499
|
);
|
|
61926
62500
|
}
|
|
61927
|
-
const parent =
|
|
61928
|
-
options.output ??
|
|
62501
|
+
const parent = resolve11(
|
|
62502
|
+
options.output ?? join9(options.project ? project : process.cwd(), ".waitcher/runs")
|
|
61929
62503
|
);
|
|
61930
62504
|
if (!definition) {
|
|
61931
62505
|
const path2 = relative(project, parent);
|
|
61932
|
-
if (!path2 || path2 === ".." || path2.startsWith(`..${
|
|
62506
|
+
if (!path2 || path2 === ".." || path2.startsWith(`..${sep2}`) || resolve11(project, path2) !== parent)
|
|
61933
62507
|
invalid2("Project output must be a subdirectory of the E2E project.");
|
|
61934
62508
|
}
|
|
61935
62509
|
await mkdir4(parent, { recursive: true, mode: 448 });
|
|
62510
|
+
await ignoreRunFolder(parent, !options.output);
|
|
61936
62511
|
const parentInfo = await lstat7(parent);
|
|
61937
62512
|
if (!parentInfo.isDirectory() || parentInfo.isSymbolicLink())
|
|
61938
62513
|
invalid2("Output must be a regular directory, not a symbolic link.");
|
|
61939
62514
|
if (!definition) {
|
|
61940
62515
|
const actual = relative(project, await realpath(parent));
|
|
61941
|
-
if (actual === ".." || actual.startsWith(`..${
|
|
62516
|
+
if (actual === ".." || actual.startsWith(`..${sep2}`))
|
|
61942
62517
|
invalid2("Project output cannot resolve outside the E2E project.");
|
|
61943
62518
|
}
|
|
61944
|
-
const runId = randomUUID4(), directory =
|
|
62519
|
+
const runId = randomUUID4(), directory = join9(parent, runId);
|
|
61945
62520
|
await mkdir4(directory, { mode: 448 });
|
|
61946
62521
|
const startedAt = Date.now(), start = performance7.now();
|
|
61947
62522
|
const timeout = options.timeout ?? definition?.timeout ?? 60;
|
|
61948
62523
|
const evidence = definition ? ".e2e" : "evidence";
|
|
62524
|
+
const notes = [];
|
|
62525
|
+
if (definition?.type === "browser" && !await headlessShellInstalled(project)) {
|
|
62526
|
+
const note = `Chromium for the runtime in ${project} is not installed; this run downloads it first (about 100 to 200 MB, once). waitcher runtime install --browser --yes installs it ahead.`;
|
|
62527
|
+
notes.push(note);
|
|
62528
|
+
process.stderr.write(note + "\n");
|
|
62529
|
+
}
|
|
61949
62530
|
let status2 = "error", logs = "", message = "Local execution did not finish";
|
|
61950
62531
|
let requestUsage;
|
|
61951
62532
|
let modelUsage;
|
|
@@ -61955,19 +62536,19 @@ async function runLocal(options) {
|
|
|
61955
62536
|
let localRequests;
|
|
61956
62537
|
let localModel;
|
|
61957
62538
|
try {
|
|
61958
|
-
await
|
|
61959
|
-
|
|
62539
|
+
await writeFile5(
|
|
62540
|
+
join9(directory, "waitcher-scenario-runtime.mjs"),
|
|
61960
62541
|
scenarioSource,
|
|
61961
62542
|
{ mode: 384, flag: "wx" }
|
|
61962
62543
|
);
|
|
61963
62544
|
if (modelSource)
|
|
61964
|
-
await
|
|
61965
|
-
|
|
62545
|
+
await writeFile5(
|
|
62546
|
+
join9(directory, "waitcher-model-client.mjs"),
|
|
61966
62547
|
modelSource,
|
|
61967
62548
|
{ mode: 384, flag: "wx" }
|
|
61968
62549
|
);
|
|
61969
|
-
await
|
|
61970
|
-
|
|
62550
|
+
await writeFile5(
|
|
62551
|
+
join9(directory, "waitcher-request-runtime.mjs"),
|
|
61971
62552
|
requestSource,
|
|
61972
62553
|
{ mode: 384, flag: "wx" }
|
|
61973
62554
|
);
|
|
@@ -62000,18 +62581,19 @@ async function runLocal(options) {
|
|
|
62000
62581
|
// Baselines are approved in Waitcher; locally a stored
|
|
62001
62582
|
// screenshot is compared with a capture taken moments earlier.
|
|
62002
62583
|
localSnapshots: true,
|
|
62003
|
-
|
|
62584
|
+
causeAudience: "local",
|
|
62585
|
+
requestClientFile: join9(
|
|
62004
62586
|
directory,
|
|
62005
62587
|
"waitcher-request-runtime.mjs"
|
|
62006
62588
|
),
|
|
62007
62589
|
...localRequests ? { request: localRequests.dispatch } : {},
|
|
62008
|
-
scenarioClientFile:
|
|
62590
|
+
scenarioClientFile: join9(
|
|
62009
62591
|
directory,
|
|
62010
62592
|
"waitcher-scenario-runtime.mjs"
|
|
62011
62593
|
),
|
|
62012
62594
|
...definition.type === "browser" ? {
|
|
62013
62595
|
...browserIdentity ? { browserIdentity } : {},
|
|
62014
|
-
browserIdentityClientFile:
|
|
62596
|
+
browserIdentityClientFile: join9(
|
|
62015
62597
|
directory,
|
|
62016
62598
|
"waitcher-model-client.mjs"
|
|
62017
62599
|
)
|
|
@@ -62022,7 +62604,7 @@ async function runLocal(options) {
|
|
|
62022
62604
|
reporters: ["list", "markdown", "junit"],
|
|
62023
62605
|
...localModel ? {
|
|
62024
62606
|
model: localModel.dispatch,
|
|
62025
|
-
modelClientFile:
|
|
62607
|
+
modelClientFile: join9(
|
|
62026
62608
|
directory,
|
|
62027
62609
|
"waitcher-model-client.mjs"
|
|
62028
62610
|
)
|
|
@@ -62052,7 +62634,7 @@ async function runLocal(options) {
|
|
|
62052
62634
|
executable,
|
|
62053
62635
|
"run",
|
|
62054
62636
|
"--output",
|
|
62055
|
-
relative(project,
|
|
62637
|
+
relative(project, join9(directory, evidence)),
|
|
62056
62638
|
"--trace",
|
|
62057
62639
|
"on",
|
|
62058
62640
|
"--video",
|
|
@@ -62076,15 +62658,15 @@ async function runLocal(options) {
|
|
|
62076
62658
|
}
|
|
62077
62659
|
);
|
|
62078
62660
|
logs = result3.logs;
|
|
62079
|
-
const path2 =
|
|
62661
|
+
const path2 = join9(directory, evidence, "report.json");
|
|
62080
62662
|
if ((await lstat7(path2)).size > STORAGE_LIMITS.artifactFileBytes)
|
|
62081
62663
|
throw Error("Local E2E report exceeds its 8 MiB budget");
|
|
62082
|
-
const report = JSON.parse(await
|
|
62664
|
+
const report = JSON.parse(await readFile5(path2, "utf8"));
|
|
62083
62665
|
const passed = result3.code === 0 && report.run?.status === "passed" && report.run.results?.length > 0 && report.run.results.every(
|
|
62084
62666
|
(r) => r.status === "passed"
|
|
62085
62667
|
);
|
|
62086
62668
|
status2 = passed ? "passed" : result3.timedOut || ![0, 1].includes(result3.code ?? -1) ? "error" : "failed";
|
|
62087
|
-
message = result3.timedOut ? "Execution exceeded its wall-clock deadline" : passed ? `${report.run.results.length} e2e tests passed` :
|
|
62669
|
+
message = result3.timedOut ? "Execution exceeded its wall-clock deadline" : passed ? `${report.run.results.length} e2e tests passed` : PROJECT_FAILED;
|
|
62088
62670
|
}
|
|
62089
62671
|
});
|
|
62090
62672
|
} catch (error62) {
|
|
@@ -62097,12 +62679,12 @@ async function runLocal(options) {
|
|
|
62097
62679
|
}
|
|
62098
62680
|
if (connection) connection.credential = "";
|
|
62099
62681
|
if (modelUsage)
|
|
62100
|
-
await
|
|
62101
|
-
|
|
62682
|
+
await writeFile5(
|
|
62683
|
+
join9(directory, "model-usage.json"),
|
|
62102
62684
|
JSON.stringify(modelUsage, null, 2) + "\n",
|
|
62103
62685
|
{ mode: 384, flag: "wx" }
|
|
62104
62686
|
);
|
|
62105
|
-
await
|
|
62687
|
+
await writeFile5(join9(directory, "execution.log"), logs, {
|
|
62106
62688
|
mode: 384,
|
|
62107
62689
|
flag: "wx"
|
|
62108
62690
|
});
|
|
@@ -62111,8 +62693,8 @@ async function runLocal(options) {
|
|
|
62111
62693
|
const { scanWork: scanWork2 } = await Promise.resolve().then(() => (init_work(), work_exports));
|
|
62112
62694
|
if (definition) await writeLocalFrozenDefinition(directory, definition);
|
|
62113
62695
|
if (requestUsage)
|
|
62114
|
-
await
|
|
62115
|
-
|
|
62696
|
+
await writeFile5(
|
|
62697
|
+
join9(directory, "request-usage.json"),
|
|
62116
62698
|
JSON.stringify(requestUsage, null, 2) + "\n",
|
|
62117
62699
|
{ mode: 384, flag: "wx" }
|
|
62118
62700
|
);
|
|
@@ -62123,6 +62705,9 @@ async function runLocal(options) {
|
|
|
62123
62705
|
message = "Local evidence exceeded its storage budget or could not be indexed; partial files remain in the output directory.";
|
|
62124
62706
|
}
|
|
62125
62707
|
const finalStatus = status2;
|
|
62708
|
+
const failure3 = finalStatus === "passed" || options.signal.aborted ? null : await classifiedFailure(directory, evidence, definition);
|
|
62709
|
+
if (failure3 && (message.startsWith(`${failure3.code}: `) || message === PROJECT_FAILED))
|
|
62710
|
+
message = failure3.message;
|
|
62126
62711
|
const result2 = {
|
|
62127
62712
|
schemaVersion: 1,
|
|
62128
62713
|
event: "local_completed",
|
|
@@ -62130,25 +62715,32 @@ async function runLocal(options) {
|
|
|
62130
62715
|
runId,
|
|
62131
62716
|
status: finalStatus,
|
|
62132
62717
|
message,
|
|
62718
|
+
...failure3 ? {
|
|
62719
|
+
code: failure3.code,
|
|
62720
|
+
test: failure3.test,
|
|
62721
|
+
trace: failure3.trace,
|
|
62722
|
+
next: failure3.next
|
|
62723
|
+
} : finalStatus === "passed" || options.signal.aborted ? {} : { next: [`waitcher run diagnose --directory ${directory}`] },
|
|
62724
|
+
...notes.length ? { notes } : {},
|
|
62133
62725
|
startedAt,
|
|
62134
62726
|
duration: Math.round(performance7.now() - start),
|
|
62135
62727
|
directory,
|
|
62136
|
-
report: files.some((f) => f.path === `${evidence}/report.json`) ?
|
|
62137
|
-
summary: files.some((f) => f.path === `${evidence}/summary.md`) ?
|
|
62138
|
-
log:
|
|
62728
|
+
report: files.some((f) => f.path === `${evidence}/report.json`) ? join9(directory, evidence, "report.json") : null,
|
|
62729
|
+
summary: files.some((f) => f.path === `${evidence}/summary.md`) ? join9(directory, evidence, "summary.md") : null,
|
|
62730
|
+
log: join9(directory, "execution.log"),
|
|
62139
62731
|
videoRequested: Boolean(options.video),
|
|
62140
62732
|
...modelUsage ? {
|
|
62141
|
-
modelUsage:
|
|
62733
|
+
modelUsage: join9(directory, "model-usage.json"),
|
|
62142
62734
|
modelOutcome: modelUsage.outcome
|
|
62143
62735
|
} : {},
|
|
62144
62736
|
...requestUsage ? {
|
|
62145
|
-
requestUsage:
|
|
62737
|
+
requestUsage: join9(directory, "request-usage.json"),
|
|
62146
62738
|
requestOutcome: requestUsage.outcome
|
|
62147
62739
|
} : {},
|
|
62148
62740
|
files
|
|
62149
62741
|
};
|
|
62150
|
-
await
|
|
62151
|
-
|
|
62742
|
+
await writeFile5(
|
|
62743
|
+
join9(directory, "local-run.json"),
|
|
62152
62744
|
JSON.stringify(result2, null, 2) + "\n",
|
|
62153
62745
|
{ mode: 384, flag: "wx" }
|
|
62154
62746
|
);
|
|
@@ -62160,8 +62752,8 @@ async function runLocal(options) {
|
|
|
62160
62752
|
|
|
62161
62753
|
// src/calibration.ts
|
|
62162
62754
|
import { constants as constants12 } from "node:fs";
|
|
62163
|
-
import { open as open15, mkdir as mkdir5, lstat as lstat8, writeFile as
|
|
62164
|
-
import { dirname as
|
|
62755
|
+
import { open as open15, mkdir as mkdir5, lstat as lstat8, writeFile as writeFile6 } from "node:fs/promises";
|
|
62756
|
+
import { dirname as dirname10, join as join10, resolve as resolve12 } from "node:path";
|
|
62165
62757
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
62166
62758
|
|
|
62167
62759
|
// ../../src/contracts/calibration.ts
|
|
@@ -62357,8 +62949,8 @@ async function runLocalCalibration(options) {
|
|
|
62357
62949
|
"Calibration inputs must not contain the private judge credential."
|
|
62358
62950
|
);
|
|
62359
62951
|
}
|
|
62360
|
-
const parent =
|
|
62361
|
-
options.output ??
|
|
62952
|
+
const parent = resolve12(
|
|
62953
|
+
options.output ?? join10(dirname10(resolve12(options.file)), ".waitcher/calibrations")
|
|
62362
62954
|
);
|
|
62363
62955
|
await mkdir5(parent, { recursive: true, mode: 448 });
|
|
62364
62956
|
const info = await lstat8(parent);
|
|
@@ -62366,7 +62958,7 @@ async function runLocalCalibration(options) {
|
|
|
62366
62958
|
return invalid3(
|
|
62367
62959
|
"Calibration output must be a regular directory, not a symbolic link."
|
|
62368
62960
|
);
|
|
62369
|
-
const calibrationId = randomUUID5(), directory =
|
|
62961
|
+
const calibrationId = randomUUID5(), directory = join10(parent, calibrationId), startedAt = Date.now();
|
|
62370
62962
|
await mkdir5(directory, { mode: 448 });
|
|
62371
62963
|
const signal = AbortSignal.any([
|
|
62372
62964
|
options.signal,
|
|
@@ -62408,12 +63000,12 @@ async function runLocalCalibration(options) {
|
|
|
62408
63000
|
connection.credential = "";
|
|
62409
63001
|
if (broker) usage3 = await broker.finish();
|
|
62410
63002
|
}
|
|
62411
|
-
const reportFile =
|
|
62412
|
-
await
|
|
63003
|
+
const reportFile = join10(directory, "calibration-report.json"), usageFile = join10(directory, "model-usage.json");
|
|
63004
|
+
await writeFile6(reportFile, JSON.stringify(report, null, 2) + "\n", {
|
|
62413
63005
|
mode: 384,
|
|
62414
63006
|
flag: "wx"
|
|
62415
63007
|
});
|
|
62416
|
-
await
|
|
63008
|
+
await writeFile6(usageFile, JSON.stringify(usage3, null, 2) + "\n", {
|
|
62417
63009
|
mode: 384,
|
|
62418
63010
|
flag: "wx"
|
|
62419
63011
|
});
|
|
@@ -62435,9 +63027,9 @@ async function runLocalCalibration(options) {
|
|
|
62435
63027
|
// src/bundle.ts
|
|
62436
63028
|
import { createRequire as createRequire2, isBuiltin } from "node:module";
|
|
62437
63029
|
import { createHash as createHash10 } from "node:crypto";
|
|
62438
|
-
import { readFile as
|
|
62439
|
-
import { basename, dirname as
|
|
62440
|
-
import { pathToFileURL as
|
|
63030
|
+
import { readFile as readFile6, realpath as realpath2, mkdir as mkdir6, writeFile as writeFile7, rm as rm4 } from "node:fs/promises";
|
|
63031
|
+
import { basename as basename2, dirname as dirname11, join as join11, relative as relative2, resolve as resolve13, sep as sep3, extname } from "node:path";
|
|
63032
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
62441
63033
|
var sha = (bytes2) => createHash10("sha256").update(bytes2).digest("hex");
|
|
62442
63034
|
function invalid4(message) {
|
|
62443
63035
|
throw new ServiceError(message, "VALIDATION_ERROR", 2);
|
|
@@ -62455,20 +63047,20 @@ async function bundleMonitor(options) {
|
|
|
62455
63047
|
invalid4(
|
|
62456
63048
|
"monitor build requires --file SOURCE.json and --output NEW_DIRECTORY."
|
|
62457
63049
|
);
|
|
62458
|
-
const sourceManifest = await realpath2(
|
|
63050
|
+
const sourceManifest = await realpath2(resolve13(options.file));
|
|
62459
63051
|
const project = await realpath2(
|
|
62460
|
-
|
|
63052
|
+
resolve13(options.project ?? dirname11(sourceManifest))
|
|
62461
63053
|
);
|
|
62462
63054
|
function projectPath(path2) {
|
|
62463
63055
|
const name5 = relative2(project, path2);
|
|
62464
|
-
if (name5 === ".." || name5.startsWith(`..${
|
|
63056
|
+
if (name5 === ".." || name5.startsWith(`..${sep3}`) || name5.startsWith(sep3))
|
|
62465
63057
|
invalid4(
|
|
62466
63058
|
"Build inputs must stay within --project, including resolved symlinks."
|
|
62467
63059
|
);
|
|
62468
|
-
return name5.split(
|
|
63060
|
+
return name5.split(sep3).join("/");
|
|
62469
63061
|
}
|
|
62470
63062
|
projectPath(sourceManifest);
|
|
62471
|
-
const manifestText = await
|
|
63063
|
+
const manifestText = await readFile6(sourceManifest, "utf8");
|
|
62472
63064
|
let definition;
|
|
62473
63065
|
try {
|
|
62474
63066
|
definition = await readManifest(sourceManifest);
|
|
@@ -62477,7 +63069,7 @@ async function bundleMonitor(options) {
|
|
|
62477
63069
|
error62 instanceof Error ? error62.message : "Invalid source manifest."
|
|
62478
63070
|
);
|
|
62479
63071
|
}
|
|
62480
|
-
if (manifestText !== await
|
|
63072
|
+
if (manifestText !== await readFile6(sourceManifest, "utf8"))
|
|
62481
63073
|
invalid4(
|
|
62482
63074
|
"The source manifest changed during the build. Retry with stable inputs."
|
|
62483
63075
|
);
|
|
@@ -62489,7 +63081,7 @@ async function bundleMonitor(options) {
|
|
|
62489
63081
|
"Use scriptFile in the source manifest so imports resolve from a real project file."
|
|
62490
63082
|
);
|
|
62491
63083
|
const entry2 = await realpath2(
|
|
62492
|
-
|
|
63084
|
+
resolve13(dirname11(sourceManifest), source.scriptFile)
|
|
62493
63085
|
);
|
|
62494
63086
|
const entryName = projectPath(entry2);
|
|
62495
63087
|
const { script, inputs, lock, builder } = await buildScript({
|
|
@@ -62521,20 +63113,20 @@ async function bundleMonitor(options) {
|
|
|
62521
63113
|
},
|
|
62522
63114
|
manifest: { path: "monitor.json", sha256: sha(manifest) }
|
|
62523
63115
|
};
|
|
62524
|
-
const output2 =
|
|
62525
|
-
await mkdir6(
|
|
63116
|
+
const output2 = resolve13(options.output);
|
|
63117
|
+
await mkdir6(dirname11(output2), { recursive: true, mode: 448 });
|
|
62526
63118
|
await mkdir6(output2, { mode: 448 });
|
|
62527
63119
|
try {
|
|
62528
|
-
await
|
|
63120
|
+
await writeFile7(join11(output2, "monitor.js"), script, {
|
|
62529
63121
|
flag: "wx",
|
|
62530
63122
|
mode: 384
|
|
62531
63123
|
});
|
|
62532
|
-
await
|
|
63124
|
+
await writeFile7(join11(output2, "monitor.json"), manifest, {
|
|
62533
63125
|
flag: "wx",
|
|
62534
63126
|
mode: 384
|
|
62535
63127
|
});
|
|
62536
|
-
await
|
|
62537
|
-
|
|
63128
|
+
await writeFile7(
|
|
63129
|
+
join11(output2, "build.json"),
|
|
62538
63130
|
JSON.stringify(provenance, null, 2) + "\n",
|
|
62539
63131
|
{ flag: "wx", mode: 384 }
|
|
62540
63132
|
);
|
|
@@ -62545,7 +63137,7 @@ async function bundleMonitor(options) {
|
|
|
62545
63137
|
return {
|
|
62546
63138
|
event: "monitor_built",
|
|
62547
63139
|
directory: output2,
|
|
62548
|
-
file:
|
|
63140
|
+
file: join11(output2, "monitor.json"),
|
|
62549
63141
|
...provenance
|
|
62550
63142
|
};
|
|
62551
63143
|
}
|
|
@@ -62556,16 +63148,16 @@ async function buildScript({
|
|
|
62556
63148
|
}) {
|
|
62557
63149
|
function projectPath(path2) {
|
|
62558
63150
|
const name5 = relative2(project, path2);
|
|
62559
|
-
if (name5 === ".." || name5.startsWith(`..${
|
|
63151
|
+
if (name5 === ".." || name5.startsWith(`..${sep3}`) || name5.startsWith(sep3))
|
|
62560
63152
|
invalid4(
|
|
62561
63153
|
"Build inputs must stay within --project, including resolved symlinks."
|
|
62562
63154
|
);
|
|
62563
|
-
return name5.split(
|
|
63155
|
+
return name5.split(sep3).join("/");
|
|
62564
63156
|
}
|
|
62565
63157
|
const entryName = projectPath(entry2);
|
|
62566
63158
|
if (!/\.(?:[cm]?[jt]s)$/.test(entry2))
|
|
62567
63159
|
invalid4("Use a TypeScript or JavaScript test entry, without JSX.");
|
|
62568
|
-
const require2 = createRequire2(
|
|
63160
|
+
const require2 = createRequire2(join11(project, "package.json"));
|
|
62569
63161
|
let tool;
|
|
62570
63162
|
try {
|
|
62571
63163
|
tool = require2.resolve("esbuild");
|
|
@@ -62575,20 +63167,20 @@ async function buildScript({
|
|
|
62575
63167
|
);
|
|
62576
63168
|
}
|
|
62577
63169
|
const toolMetadata = JSON.parse(
|
|
62578
|
-
await
|
|
63170
|
+
await readFile6(join11(dirname11(dirname11(tool)), "package.json"), "utf8")
|
|
62579
63171
|
);
|
|
62580
63172
|
if (toolMetadata.name !== "esbuild" || !supportedGenerations().some((g) => g.esbuild === toolMetadata.version))
|
|
62581
63173
|
invalid4(
|
|
62582
63174
|
`The portable build requires esbuild@${RUNTIME_PINS.esbuild} in the project (waitcher runtime install).`
|
|
62583
63175
|
);
|
|
62584
|
-
const { build } = await import(
|
|
63176
|
+
const { build } = await import(pathToFileURL3(tool).href);
|
|
62585
63177
|
const inputs = /* @__PURE__ */ new Map();
|
|
62586
63178
|
let inputBytes = 0;
|
|
62587
63179
|
async function load(path2) {
|
|
62588
63180
|
const actual = await realpath2(path2), name5 = projectPath(actual);
|
|
62589
63181
|
if (inputs.size >= 64 && !inputs.has(name5))
|
|
62590
63182
|
invalid4("A portable monitor may bundle at most 64 source files.");
|
|
62591
|
-
const contents = await
|
|
63183
|
+
const contents = await readFile6(actual);
|
|
62592
63184
|
inputBytes += contents.length;
|
|
62593
63185
|
if (contents.length > 512e3 || inputBytes > 1024e3)
|
|
62594
63186
|
invalid4("Build inputs exceed the 1 MB source budget.");
|
|
@@ -62611,8 +63203,8 @@ async function buildScript({
|
|
|
62611
63203
|
stdin: {
|
|
62612
63204
|
contents: entryText,
|
|
62613
63205
|
// esbuild prefixes resolveDir, so the bare name keeps the header path right.
|
|
62614
|
-
sourcefile:
|
|
62615
|
-
resolveDir:
|
|
63206
|
+
sourcefile: basename2(entry2),
|
|
63207
|
+
resolveDir: dirname11(entry2),
|
|
62616
63208
|
loader: /\.[cm]?ts$/.test(entry2) ? "ts" : "js"
|
|
62617
63209
|
},
|
|
62618
63210
|
bundle: true,
|
|
@@ -62700,7 +63292,7 @@ async function buildScript({
|
|
|
62700
63292
|
let lock = null;
|
|
62701
63293
|
for (const name5 of ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"]) {
|
|
62702
63294
|
try {
|
|
62703
|
-
lock = { path: name5, sha256: sha(await
|
|
63295
|
+
lock = { path: name5, sha256: sha(await readFile6(join11(project, name5))) };
|
|
62704
63296
|
break;
|
|
62705
63297
|
} catch (error62) {
|
|
62706
63298
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -62727,204 +63319,6 @@ import { execFile } from "node:child_process";
|
|
|
62727
63319
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
62728
63320
|
import { dirname as dirname12, join as join12, resolve as resolve14 } from "node:path";
|
|
62729
63321
|
import { promisify } from "node:util";
|
|
62730
|
-
|
|
62731
|
-
// src/runtime.ts
|
|
62732
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
62733
|
-
import { access, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
62734
|
-
import { basename as basename2, dirname as dirname11, join as join11, resolve as resolve13 } from "node:path";
|
|
62735
|
-
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
62736
|
-
var RUNTIME_IGNORES = ["node_modules/", ".waitcher/", ".e2e/"];
|
|
62737
|
-
async function installedPackage(from, name5) {
|
|
62738
|
-
for (let dir = resolve13(from); ; ) {
|
|
62739
|
-
const folder = join11(dir, "node_modules", ...name5.split("/"));
|
|
62740
|
-
try {
|
|
62741
|
-
const meta3 = JSON.parse(await readFile6(join11(folder, "package.json"), "utf8"));
|
|
62742
|
-
if (meta3.name === name5)
|
|
62743
|
-
return { dir: folder, version: meta3.version, main: meta3.main };
|
|
62744
|
-
} catch {
|
|
62745
|
-
}
|
|
62746
|
-
const parent = dirname11(dir);
|
|
62747
|
-
if (parent === dir) return null;
|
|
62748
|
-
dir = parent;
|
|
62749
|
-
}
|
|
62750
|
-
}
|
|
62751
|
-
var installedVersion = async (project, name5) => (await installedPackage(project, name5))?.version ?? null;
|
|
62752
|
-
async function chromiumInstalled(project) {
|
|
62753
|
-
try {
|
|
62754
|
-
const web = await installedPackage(project, "@e2e-dev/web");
|
|
62755
|
-
if (!web) return false;
|
|
62756
|
-
const core = await installedPackage(web.dir, "playwright-core");
|
|
62757
|
-
if (!core) return false;
|
|
62758
|
-
const playwright = await import(pathToFileURL3(join11(core.dir, core.main ?? "index.js")).href);
|
|
62759
|
-
await access((playwright.default ?? playwright).chromium.executablePath());
|
|
62760
|
-
return true;
|
|
62761
|
-
} catch {
|
|
62762
|
-
return false;
|
|
62763
|
-
}
|
|
62764
|
-
}
|
|
62765
|
-
function pinPackageJson(existing, project, pins = RUNTIME_PINS) {
|
|
62766
|
-
const json3 = existing ? structuredClone(existing) : {
|
|
62767
|
-
name: basename2(project).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "") || "waitcher-monitors",
|
|
62768
|
-
private: true
|
|
62769
|
-
};
|
|
62770
|
-
const changes = [];
|
|
62771
|
-
for (const [name5, to] of Object.entries(pins)) {
|
|
62772
|
-
const field = json3.dependencies?.[name5] !== void 0 ? "dependencies" : "devDependencies";
|
|
62773
|
-
const from = json3[field]?.[name5] ?? null;
|
|
62774
|
-
if (from === to) continue;
|
|
62775
|
-
json3[field] = { ...json3[field], [name5]: to };
|
|
62776
|
-
changes.push({ name: name5, from, to });
|
|
62777
|
-
}
|
|
62778
|
-
for (const [name5, nested] of Object.entries(RUNTIME_OVERRIDES))
|
|
62779
|
-
for (const [dep, to] of Object.entries(nested)) {
|
|
62780
|
-
const current = json3.overrides?.[name5];
|
|
62781
|
-
const from = typeof current === "object" ? current?.[dep] ?? null : null;
|
|
62782
|
-
if (from === to) continue;
|
|
62783
|
-
json3.overrides = {
|
|
62784
|
-
...json3.overrides,
|
|
62785
|
-
[name5]: { ...typeof current === "object" ? current : {}, [dep]: to }
|
|
62786
|
-
};
|
|
62787
|
-
changes.push({ name: `overrides.${name5}.${dep}`, from, to });
|
|
62788
|
-
}
|
|
62789
|
-
return { json: json3, changes };
|
|
62790
|
-
}
|
|
62791
|
-
var missingIgnores = (text4) => {
|
|
62792
|
-
const lines = new Set(
|
|
62793
|
-
text4.split(/\r?\n/).map((l) => l.trim().replace(/^\//, ""))
|
|
62794
|
-
);
|
|
62795
|
-
return RUNTIME_IGNORES.filter(
|
|
62796
|
-
(entry2) => !lines.has(entry2) && !lines.has(entry2.slice(0, -1))
|
|
62797
|
-
);
|
|
62798
|
-
};
|
|
62799
|
-
function run(command, args, cwd, signal) {
|
|
62800
|
-
return new Promise((resolve19, reject) => {
|
|
62801
|
-
const child2 = spawn2(command, args, {
|
|
62802
|
-
cwd,
|
|
62803
|
-
signal,
|
|
62804
|
-
stdio: ["ignore", process.stderr, process.stderr],
|
|
62805
|
-
shell: process.platform === "win32"
|
|
62806
|
-
});
|
|
62807
|
-
child2.on("error", reject);
|
|
62808
|
-
child2.on(
|
|
62809
|
-
"exit",
|
|
62810
|
-
(code) => code === 0 ? resolve19() : reject(
|
|
62811
|
-
new ServiceError(
|
|
62812
|
-
`${command} ${args.join(" ")} exited with ${code}; read its output above.`,
|
|
62813
|
-
"RUNTIME_INSTALL_FAILED",
|
|
62814
|
-
1
|
|
62815
|
-
)
|
|
62816
|
-
)
|
|
62817
|
-
);
|
|
62818
|
-
});
|
|
62819
|
-
}
|
|
62820
|
-
async function installRuntime(options) {
|
|
62821
|
-
const { project, browser, yes, signal } = options;
|
|
62822
|
-
const manifestPath = join11(project, "package.json");
|
|
62823
|
-
const text4 = await readFile6(manifestPath, "utf8").catch(() => null);
|
|
62824
|
-
let existing = null;
|
|
62825
|
-
if (text4 !== null)
|
|
62826
|
-
try {
|
|
62827
|
-
existing = JSON.parse(text4);
|
|
62828
|
-
} catch (cause) {
|
|
62829
|
-
throw new ServiceError(
|
|
62830
|
-
`${manifestPath} is not valid JSON: ${cause.message}`,
|
|
62831
|
-
"VALIDATION_ERROR",
|
|
62832
|
-
2
|
|
62833
|
-
);
|
|
62834
|
-
}
|
|
62835
|
-
const needed = runtimePackages(browser);
|
|
62836
|
-
const installed = {};
|
|
62837
|
-
for (const name5 of Object.keys(RUNTIME_PINS))
|
|
62838
|
-
installed[name5] = await installedVersion(project, name5);
|
|
62839
|
-
const generation = options.generation ?? installedGeneration(installed, browser) ?? RUNTIME_GENERATIONS[0];
|
|
62840
|
-
const pins = generationPins(generation);
|
|
62841
|
-
const { json: json3, changes } = pinPackageJson(existing, project, pins);
|
|
62842
|
-
const stale = Object.keys(pins).filter(
|
|
62843
|
-
(name5) => installed[name5] !== pins[name5]
|
|
62844
|
-
);
|
|
62845
|
-
const ignorePath = join11(project, ".gitignore");
|
|
62846
|
-
const ignoreText = await readFile6(ignorePath, "utf8").catch(() => "");
|
|
62847
|
-
const ignores = [];
|
|
62848
|
-
for (const entry2 of missingIgnores(ignoreText))
|
|
62849
|
-
if (!await gitIgnored(project, entry2)) ignores.push(entry2);
|
|
62850
|
-
const npmInstall = changes.length > 0 || stale.length > 0;
|
|
62851
|
-
const chromium = browser && (npmInstall || !await chromiumInstalled(project));
|
|
62852
|
-
const steps = [
|
|
62853
|
-
...changes.length ? [`${existing ? "update" : "create"} ${manifestPath}: ${changes.map((c) => `${c.name} ${c.from ?? "(none)"} -> ${c.to}`).join(", ")}`] : [],
|
|
62854
|
-
...ignores.length ? [`add ${ignores.join(" ")} to ${ignorePath}`] : [],
|
|
62855
|
-
...npmInstall ? [`npm install in ${project} (runs package install scripts)`] : [],
|
|
62856
|
-
...chromium ? ["npx --no-install e2e-web install chromium (downloads Chromium)"] : []
|
|
62857
|
-
];
|
|
62858
|
-
const base2 = {
|
|
62859
|
-
project,
|
|
62860
|
-
generation: generation.id,
|
|
62861
|
-
runtime: pins,
|
|
62862
|
-
packages: needed,
|
|
62863
|
-
browser,
|
|
62864
|
-
installed,
|
|
62865
|
-
changes,
|
|
62866
|
-
gitignore: ignores
|
|
62867
|
-
};
|
|
62868
|
-
if (!npmInstall && !ignores.length && !chromium)
|
|
62869
|
-
return { event: "runtime_current", ok: true, applied: false, ...base2, steps: [], next: [] };
|
|
62870
|
-
if (!yes)
|
|
62871
|
-
return {
|
|
62872
|
-
event: "runtime_planned",
|
|
62873
|
-
ok: true,
|
|
62874
|
-
applied: false,
|
|
62875
|
-
...base2,
|
|
62876
|
-
steps,
|
|
62877
|
-
next: [
|
|
62878
|
-
`Ask the user to agree to these steps, then run waitcher runtime install --file ${join11(project, "waitcher.json")} --yes`
|
|
62879
|
-
]
|
|
62880
|
-
};
|
|
62881
|
-
if (changes.length)
|
|
62882
|
-
await writeFile7(manifestPath, JSON.stringify(json3, null, 2) + "\n");
|
|
62883
|
-
if (ignores.length)
|
|
62884
|
-
await writeFile7(
|
|
62885
|
-
ignorePath,
|
|
62886
|
-
`${ignoreText}${ignoreText && !ignoreText.endsWith("\n") ? "\n" : ""}${ignores.join("\n")}
|
|
62887
|
-
`
|
|
62888
|
-
);
|
|
62889
|
-
if (npmInstall)
|
|
62890
|
-
await run("npm", ["install", "--no-audit", "--no-fund"], project, signal);
|
|
62891
|
-
if (chromium)
|
|
62892
|
-
await run("npx", ["--no-install", "e2e-web", "install", "chromium"], project, signal);
|
|
62893
|
-
for (const name5 of needed) {
|
|
62894
|
-
const found = await installedVersion(project, name5);
|
|
62895
|
-
if (found !== pins[name5])
|
|
62896
|
-
throw new ServiceError(
|
|
62897
|
-
`${name5}@${pins[name5]} is still not resolvable from ${project} (found ${found ?? "nothing"}). A parent workspace or lockfile may override it.`,
|
|
62898
|
-
"RUNTIME_VERSION_MISMATCH",
|
|
62899
|
-
2
|
|
62900
|
-
);
|
|
62901
|
-
}
|
|
62902
|
-
return {
|
|
62903
|
-
event: "runtime_installed",
|
|
62904
|
-
ok: true,
|
|
62905
|
-
applied: true,
|
|
62906
|
-
...base2,
|
|
62907
|
-
installed: Object.fromEntries(needed.map((n) => [n, pins[n]])),
|
|
62908
|
-
steps,
|
|
62909
|
-
next: [
|
|
62910
|
-
`waitcher config validate --file ${join11(project, "waitcher.json")}`,
|
|
62911
|
-
`waitcher deploy plan --file ${join11(project, "waitcher.json")} --env ENV --verify`,
|
|
62912
|
-
"Commit package.json, package-lock.json and .gitignore"
|
|
62913
|
-
]
|
|
62914
|
-
};
|
|
62915
|
-
}
|
|
62916
|
-
function gitIgnored(project, entry2) {
|
|
62917
|
-
return new Promise((done) => {
|
|
62918
|
-
const child2 = spawn2("git", ["check-ignore", "-q", "--no-index", entry2], {
|
|
62919
|
-
cwd: project,
|
|
62920
|
-
stdio: "ignore"
|
|
62921
|
-
});
|
|
62922
|
-
child2.once("error", () => done(false));
|
|
62923
|
-
child2.once("close", (code) => done(code === 0));
|
|
62924
|
-
});
|
|
62925
|
-
}
|
|
62926
|
-
|
|
62927
|
-
// src/config.ts
|
|
62928
63322
|
var configExample = (project, baseUrl) => ({
|
|
62929
63323
|
$schema: PROJECT_SCHEMA_URL,
|
|
62930
63324
|
schemaVersion: 1,
|
|
@@ -63081,9 +63475,9 @@ async function verifyLocally(options) {
|
|
|
63081
63475
|
var configPath = (file2) => resolve14(file2 ?? CONFIG_FILE);
|
|
63082
63476
|
async function readProjectConfig(file2) {
|
|
63083
63477
|
const path2 = configPath(file2);
|
|
63084
|
-
let
|
|
63478
|
+
let text5;
|
|
63085
63479
|
try {
|
|
63086
|
-
|
|
63480
|
+
text5 = await readFile7(path2, "utf8");
|
|
63087
63481
|
} catch {
|
|
63088
63482
|
throw new ServiceError(
|
|
63089
63483
|
`${path2} was not found. Run waitcher config init or pass --file.`,
|
|
@@ -63091,14 +63485,14 @@ async function readProjectConfig(file2) {
|
|
|
63091
63485
|
2
|
|
63092
63486
|
);
|
|
63093
63487
|
}
|
|
63094
|
-
if (Buffer.byteLength(
|
|
63488
|
+
if (Buffer.byteLength(text5) > CONFIG_LIMITS.bytes)
|
|
63095
63489
|
throw new ServiceError(
|
|
63096
63490
|
`waitcher.json exceeds ${CONFIG_LIMITS.bytes} bytes.`,
|
|
63097
63491
|
"VALIDATION_ERROR",
|
|
63098
63492
|
2
|
|
63099
63493
|
);
|
|
63100
63494
|
try {
|
|
63101
|
-
return { path: path2, config: JSON.parse(
|
|
63495
|
+
return { path: path2, config: JSON.parse(text5) };
|
|
63102
63496
|
} catch (cause) {
|
|
63103
63497
|
throw new ServiceError(
|
|
63104
63498
|
`waitcher.json is not valid JSON: ${cause.message}`,
|
|
@@ -63173,7 +63567,7 @@ function deployNextSteps(result2, {
|
|
|
63173
63567
|
}
|
|
63174
63568
|
|
|
63175
63569
|
// src/upgrade.ts
|
|
63176
|
-
import { readdir as
|
|
63570
|
+
import { readdir as readdir3, readFile as readFile8, stat } from "node:fs/promises";
|
|
63177
63571
|
import { dirname as dirname13, join as join13, relative as relative3 } from "node:path";
|
|
63178
63572
|
var SCAN = { files: 2e3, bytes: 1024 * 1024, matches: 20 };
|
|
63179
63573
|
var SOURCE = /\.(m|c)?(j|t)sx?$/;
|
|
@@ -63181,7 +63575,7 @@ var SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".waitcher", ".e2e",
|
|
|
63181
63575
|
async function findChanges(project, changes) {
|
|
63182
63576
|
const files = [];
|
|
63183
63577
|
async function walk(dir) {
|
|
63184
|
-
for (const item of await
|
|
63578
|
+
for (const item of await readdir3(dir, { withFileTypes: true }).catch(() => [])) {
|
|
63185
63579
|
if (files.length >= SCAN.files) return;
|
|
63186
63580
|
if (SKIP.has(item.name)) continue;
|
|
63187
63581
|
const path2 = join13(dir, item.name);
|
|
@@ -63199,9 +63593,9 @@ async function findChanges(project, changes) {
|
|
|
63199
63593
|
if (change.find) {
|
|
63200
63594
|
const pattern = new RegExp(change.find);
|
|
63201
63595
|
for (const [file2, lines] of texts)
|
|
63202
|
-
lines.forEach((
|
|
63203
|
-
if (matches2.length < SCAN.matches && pattern.test(
|
|
63204
|
-
matches2.push({ file: relative3(project, file2), line: index + 1, text:
|
|
63596
|
+
lines.forEach((text5, index) => {
|
|
63597
|
+
if (matches2.length < SCAN.matches && pattern.test(text5))
|
|
63598
|
+
matches2.push({ file: relative3(project, file2), line: index + 1, text: text5.trim().slice(0, 200) });
|
|
63205
63599
|
});
|
|
63206
63600
|
}
|
|
63207
63601
|
return { ...change, matches: matches2 };
|
|
@@ -63323,19 +63717,19 @@ async function upgrade(options) {
|
|
|
63323
63717
|
}
|
|
63324
63718
|
|
|
63325
63719
|
// ../../skills/waitcher/SKILL.md
|
|
63326
|
-
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, TCP, DNS, heartbeat, API, browser, visual or MCP 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, some with `next`. 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 or workspaces, raise limits or remove assertions to get a green result.\n- Work in the workspace the user chose. `waitcher auth status` names the active one (personal or a team) and your role; ask before `workspace use`, `--workspace` or any `member` command.\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)
|
|
63720
|
+
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, TCP, DNS, heartbeat, API, browser, visual or MCP 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, some with `next`. 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 or workspaces, raise limits or remove assertions to get a green result.\n- Work in the workspace the user chose. `waitcher auth status` names the active one (personal or a team) and your role; ask before `workspace use`, `--workspace` or any `member` command.\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); every `AUTH_REQUIRED` error says so in `next`. `CONFIG_DIR_PERMISSIONS` means the session folder is readable by others: show the user the `chmod` in `next`.\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`; the target is the deployed HTTPS site. To try an app that only runs locally first, write one monitor file instead (`waitcher monitor init --type http --file website.monitor.json --target http://localhost:PORT`, then `waitcher run local --file website.monitor.json`; a browser monitor needs `waitcher runtime install --browser` first). Until a deploy, no `waitcher.json` is needed and doctor only warns about it. 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, `tcp` for a database, mail or SSH port, `dns` for records that must keep their values, `heartbeat` for jobs that report in, `api` for a multi-request invariant, `browser` for a user journey, `mcp` when the product ships a remote MCP server. `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.\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\n## Runtime upgrades\n\nChecks run on the runtime generation the project pins; nothing moves them but a deploy. When the user asks to upgrade Waitcher or its runtime, doctor names a newer generation, or you see `RUNTIME_VERSION_ENDING` or `RUNTIME_VERSION_MISMATCH`: run `waitcher runtime upgrade` in the repository and repeat it until `stage` is `current` (`--to ID` targets another supported generation). Each call reports one stage with its `steps`; do them in order. In the `upgrade` stage, `changes[]` names what changed, the lines of this project it may affect (`matches`) and a `fix`, and `previews[]` shows how each hosted check did when Waitcher ran it on the target. Before `--yes` (it installs packages and Chromium) show the user `install.steps` and wait for agreement. Then fix the scripts, run `config validate --env NAME --verify`, show the diff for a commit, and in the `deploy` stage plan and apply each environment it lists. Checks made in the web app (no `waitcher.json`) move with `waitcher runtime move --id MONITOR_ID` once their preview passed. After a generation ends its checks that did not pass their preview are paused (`RUNTIME_ENDED`, `hosted[].paused` in the upgrade output) until the project upgrades and deploys. Never upgrade unasked: a supported generation is the user's choice.\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, team workspaces.\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";
|
|
63327
63721
|
|
|
63328
63722
|
// ../../skills/waitcher/references/authoring.md
|
|
63329
|
-
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- `tcp`: a public `HOST:PORT` accepts connections (database, mail, SSH); optional `tcp.banner` the server must send first. No script.\n- `dns`: a name\'s `A`, `AAAA`, `CNAME`, `MX` or `TXT` records hold `dns.expected` (`match`: `includes` or `exact`), asked of public resolvers. In `waitcher.json` a `dns` entry without `target` checks the `baseUrl` host. Details: https://waitcher.dev/docs/network.md.\n- `mcp`: a remote MCP server (Streamable HTTP). Lists tools and checks `mcp.expectTools`; an optional `mcp.toolCall` calls one side-effect-free tool with fixed arguments and JSON-pointer `assertions` on its result. No script. `run local --file mcp.json` runs it without an account; its `mcp-report.json` lists the tool names and `mcp-tool-result.json` holds the called tool\'s answer, so read both before writing `expectTools` and assertions. Personal tool calls need verified `httpAuth` and a 30-minute interval; listing tools needs neither. Never pick a tool that writes data. Details: https://waitcher.dev/docs/mcp.md.\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`, 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` and, for browser tests, `@e2e-dev/web` and Chromium, at the exact versions `waitcher runtime install` prints. `waitcher runtime install --file DIR/waitcher.json
|
|
63723
|
+
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- `tcp`: a public `HOST:PORT` accepts connections (database, mail, SSH); optional `tcp.banner` the server must send first. No script.\n- `dns`: a name\'s `A`, `AAAA`, `CNAME`, `MX` or `TXT` records hold `dns.expected` (`match`: `includes` or `exact`), asked of public resolvers. In `waitcher.json` a `dns` entry without `target` checks the `baseUrl` host. Details: https://waitcher.dev/docs/network.md.\n- `mcp`: a remote MCP server (Streamable HTTP). Lists tools and checks `mcp.expectTools`; an optional `mcp.toolCall` calls one side-effect-free tool with fixed arguments and JSON-pointer `assertions` on its result. No script. `run local --file mcp.json` runs it without an account; its `mcp-report.json` lists the tool names and `mcp-tool-result.json` holds the called tool\'s answer, so read both before writing `expectTools` and assertions. Personal tool calls need verified `httpAuth` and a 30-minute interval; listing tools needs neither. Never pick a tool that writes data. Details: https://waitcher.dev/docs/mcp.md.\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`, 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` and, for browser tests, `@e2e-dev/web` and Chromium, at the exact versions `waitcher runtime install` prints. Run `waitcher runtime install [--browser]` in the folder that holds `package.json` (or pass `--file DIR/waitcher.json`; the file need not exist, and a monitor file is refused): it lists the npm install and Chromium download; rerun it with `--yes` once the user agrees. A project that already has `@e2e-dev/web` or a browser monitor file keeps the browser packages without `--browser`. Without `waitcher.json` its `next` is the `run local` command of each monitor file it finds. Chromium goes to the Playwright browser cache (`PLAYWRIGHT_BROWSERS_PATH` when set), not the runtime directory; a browser run without it downloads it first and says so in `notes`.\n\n```sh\nwaitcher run local --file monitor.json # runtime: the current folder\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- A run that did not pass prints `code`, `message`, `test`, `trace` and `next` at the top level; do what `next` says ([diagnosis](diagnosis.md#local-runs)). Then read the `trace` file and `.e2e/summary.md`, then `execution.log` and `report.json`, or `waitcher run diagnose --directory RUN_DIR`. 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- `APP_UNREACHABLE`, or an HTTP check\'s `fetch failed: connect ECONNREFUSED 127.0.0.1:3000`, means nothing answered at the target: start the app (or fix the URL) before changing the monitor.\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. The default `.waitcher/` folder carries its own `.gitignore`. 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';
|
|
63330
63724
|
|
|
63331
63725
|
// ../../skills/waitcher/references/ai-and-agents.md
|
|
63332
63726
|
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 (the only provider for AI scripts; anthropic connections serve hosted agent checks only), 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.177. 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 the credential header name (for example 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";
|
|
63333
63727
|
|
|
63334
63728
|
// ../../skills/waitcher/references/deploy.md
|
|
63335
|
-
var deploy_default = '# Repository deploys\n\nRead when the user keeps monitors in a repository with `waitcher.json`. The core workflow is in SKILL.md; this file holds the details. `waitcher doctor` confirms that the server supports deploys.\n\n## The file\n\n```json\n{\n "schemaVersion": 1,\n "project": "Shop",\n "environments": {\n "production": { "baseUrl": "https://shop.example" },\n "staging": { "baseUrl": "https://staging.shop.example" }\n },\n "defaults": { "interval": 1800, "timeout": 15 },\n "monitors": [\n { "key": "home", "type": "http", "path": "/", "settings": { "contains": "Shop" } },\n { "key": "tls", "type": "certificate" },\n { "key": "checkout", "type": "browser", "entry": "monitoring/checkout.e2e.ts", "timeout": 45 },\n { "key": "orders-api", "type": "api", "entry": "monitoring/orders.e2e.ts",\n "settings": { "envNames": ["CHECK_ORDERS_TOKEN"] } },\n { "key": "nightly-export", "type": "heartbeat", "environments": ["production"],\n "heartbeat": { "graceSeconds": 300, "completionSeconds": 900 } }\n ]\n}\n```\n\n- `config init` starts with two example monitors (`home`: HTTP 200 on `/`; `tls`: certificate expiry). Keep, change or remove them.\n- Environment names match case-insensitively: `production` in the file is the project\'s default `Production` environment.\n- HTTP `settings`: `method`, `expectedStatus`, `contains`, `jsonPath` with `jsonValue`, `maxLatency` (ms), `headers`, `body`; certificates: `certificateMinDays` (default 14). `waitcher monitor init --type TYPE --file x.json` writes a complete example of any type.\n- A 30-minute interval suits HTTP, certificate and browser checks alike; certificates rarely need more often. Personal accounts follow their plan: checks every 30 minutes on starter, 5 on pro and 1 on business at the shortest; script monitors have a count, a shortest interval and runs a day that the running schedules must fit together (starter: one, every 2 hours or slower). Read `limits.minInterval` and `limits.isolatedScripts` in `system capabilities` before planning.\n- Entries are ordinary monitor definitions plus `key`, optional `environments` and optional `path` (resolved against `baseUrl`). Script and certificate targets default to `baseUrl`; heartbeats use the key as their label.\n- Never set `enabled`, `script`, `scriptFile`, `schemaVersion`, `context` or `demo` in entries.\n- Script tests read `process.env.TARGET_URL` (API) or call `app.open("/")` (browser), so one test serves every environment.\n- The directory holding `waitcher.json` must have `e2e`, `@e2e-dev/web` (browser) and `esbuild` installed at the exact versions `waitcher runtime install` prints; `waitcher runtime install` sets them up and keeps the project\'s generation (ask before `--yes`); `waitcher runtime upgrade` moves the project and, through its deploys, its checks to another generation (see Runtime upgrades in the skill, [runtime updates](https://waitcher.dev/docs/runtime)). Do not let dependency bots move these three packages. Tests may import project files and JSON; other packages fail with `BUILD_FAILED` naming the import. Replace them with project code, `fetch` or JSON data; do not vendor a dependency to get past the limit. A built script must fit 50,000 characters.\n\n## Plan and apply\n\n- `config validate --env NAME --verify [--key KEY]` runs that environment\'s script entries locally without an account. `deploy plan --env NAME [--verify]` changes nothing. `changes` lists `create`, `adopt`, `update` (with `fields`), `unchanged`, `delete`, `orphaned` and `invalid` per key.\n- `deploy apply --env NAME --based-on BASED_ON` applies the whole environment or nothing. `ok:false` exits 2 and writes nothing. A stale `--based-on` is `CONFLICT`: plan again and show the new plan.\n- The repository owns definitions; the server owns pause and resume. Managed monitors refuse edits through `monitor apply` or the web (`MANAGED_BY_CONFIG`); change the file instead.\n- Undeclared monitors stay as `orphaned` warnings. `--prune` deletes them and their history; use it only with the user\'s consent.\n- Deploy versions come from the Git commit (`-dirty` when `waitcher.json` has uncommitted changes). A configuration deploy is not a product release: runs show `context.deployment` only for markers recorded with `waitcher deployment record`.\n- `--smoke` runs each created, adopted or updated monitor once on the server after apply. A failed smoke leaves the deploy applied and exits 4; follow `next` to `run diagnose`. On a personal account only the first monitor\'s smoke starts (one manual run per 10 minutes); the rest are `skipped`, which is not a failure.\n\n## Secrets\n\nScripts list `CHECK_*` names in `settings.envNames`. Values live per project environment on the server:\n\n```sh\nprintf %s "$VALUE" | waitcher secret set --env staging --name CHECK_ORDERS_TOKEN --value-stdin\nwaitcher secret list --env staging\n```\n\nIn Windows PowerShell pipe the same way: `$env:VALUE | waitcher secret set --env staging --name CHECK_ORDERS_TOKEN --value-stdin` (the trailing newline is dropped).\n\nAsk the user for each value, or tell them the command to run themselves. Never echo, log or commit it. A plan reports `SECRET_MISSING` with the missing names. `--verify` runs with your local environment, so set the same `CHECK_*` variables in the shell (bash: `export CHECK_NAME=...`, PowerShell: `$env:CHECK_NAME = "..."`, CMD: `set CHECK_NAME=...`; never in files) or skip `--verify` for that monitor and rely on `--smoke`.\n\nListed values of at least 6 characters appear as `<secret:CHECK_NAME>` in reports, traces and logs; screenshots, video and transformed values are not masked. For a password or token typed into a page, prefer `fill(secrets.get("CHECK_NAME"))` (`import { secrets } from "e2e"`) over `process.env`: the value stays out of the test code and the run refuses `app.screenshot()` after that fill, so take screenshots before it or drop them. Read `process.env.CHECK_NAME` for values the script sends itself, such as API headers. Never log a value or assert on it.\n\n## Adopting existing monitors\n\nWhen a plan warns `ADOPTION_CANDIDATE`, an existing unmanaged monitor looks like the entry. Show it to the user (`waitcher monitor get --id ID`). If it is the same check, plan and apply with `--adopt KEY=MONITOR_ID`: it keeps its ID, history and pause state and takes the file\'s definition. Otherwise ignore the warning; apply creates a separate monitor.\n\n## Rollback\n\n`waitcher deploy list --project-id ID` shows deploys; `restorable:true` marks the latest 10 per environment. `waitcher deploy rollback --id DEPLOY_ID --dry-run` shows the plan, then run it with `--based-on`. Secrets are not rolled back. Tell the user to revert the repository too, or the next apply reintroduces the change.\n\n## CI\n\n`waitcher ci init [--env production] [--file waitcher.json]` writes `.github/workflows/waitcher.yml`: plan on pull requests, apply on pushes to the main branch. It installs the CLI from the server with a checksum and signs in with the `WAITCHER_TOKEN` repository secret. Create that token with read and write permissions (add run for `--smoke`) and `"projectId"` set to the project\'s ID (from `deploy plan`\'s `project.id`) using `waitcher token create`, so CI cannot touch other projects, and let the user store it with `gh secret set WAITCHER_TOKEN`. Signed in with a project token, read `authorization.projectName` from `waitcher auth status` and use it as `waitcher.json`\'s `project` (`config init --project-name NAME`); such a token changes monitors only through `deploy apply`, so do not try `monitor apply`. Set the `WAITCHER_SERVER` repository variable for a non-default server.\n';
|
|
63729
|
+
var deploy_default = '# Repository deploys\n\nRead when the user keeps monitors in a repository with `waitcher.json`. The core workflow is in SKILL.md; this file holds the details. `waitcher doctor` confirms that the server supports deploys.\n\n## The file\n\n```json\n{\n "schemaVersion": 1,\n "project": "Shop",\n "environments": {\n "production": { "baseUrl": "https://shop.example" },\n "staging": { "baseUrl": "https://staging.shop.example" }\n },\n "defaults": { "interval": 1800, "timeout": 15 },\n "monitors": [\n { "key": "home", "type": "http", "path": "/", "settings": { "contains": "Shop" } },\n { "key": "tls", "type": "certificate" },\n { "key": "checkout", "type": "browser", "entry": "monitoring/checkout.e2e.ts", "timeout": 45 },\n { "key": "orders-api", "type": "api", "entry": "monitoring/orders.e2e.ts",\n "settings": { "envNames": ["CHECK_ORDERS_TOKEN"] } },\n { "key": "nightly-export", "type": "heartbeat", "environments": ["production"],\n "heartbeat": { "graceSeconds": 300, "completionSeconds": 900 } }\n ]\n}\n```\n\n- `config init` starts with two example monitors (`home`: HTTP 200 on `/`; `tls`: certificate expiry). Keep, change or remove them.\n- Environment names match case-insensitively: `production` in the file is the project\'s default `Production` environment.\n- HTTP `settings`: `method`, `expectedStatus`, `contains`, `jsonPath` with `jsonValue`, `maxLatency` (ms), `headers`, `body`; certificates: `certificateMinDays` (default 14). `waitcher monitor init --type TYPE --file x.json` writes a complete example of any type.\n- A 30-minute interval suits HTTP, certificate and browser checks alike; certificates rarely need more often. Personal accounts follow their plan: checks every 30 minutes on starter, 5 on pro and 1 on business at the shortest; script monitors have a count, a shortest interval and runs a day that the running schedules must fit together (starter: one, every 2 hours or slower). Read `limits.minInterval` and `limits.isolatedScripts` in `system capabilities` before planning.\n- Entries are ordinary monitor definitions plus `key`, optional `environments` and optional `path` (resolved against `baseUrl`). Script and certificate targets default to `baseUrl`; heartbeats use the key as their label.\n- Never set `enabled`, `script`, `scriptFile`, `schemaVersion`, `context` or `demo` in entries.\n- Script tests read `process.env.TARGET_URL` (API) or call `app.open("/")` (browser), so one test serves every environment.\n- The directory holding `waitcher.json` must have `e2e`, `@e2e-dev/web` (browser) and `esbuild` installed at the exact versions `waitcher runtime install` prints; `waitcher runtime install` sets them up and keeps the project\'s generation (ask before `--yes`); `waitcher runtime upgrade` moves the project and, through its deploys, its checks to another generation (see Runtime upgrades in the skill, [runtime updates](https://waitcher.dev/docs/runtime)). Do not let dependency bots move these three packages. Tests may import project files and JSON; other packages fail with `BUILD_FAILED` naming the import. Replace them with project code, `fetch` or JSON data; do not vendor a dependency to get past the limit. A built script must fit 50,000 characters.\n\n## Plan and apply\n\n- `config validate --env NAME --verify [--key KEY]` runs that environment\'s script entries locally without an account. `deploy plan --env NAME [--verify]` changes nothing. `changes` lists `create`, `adopt`, `update` (with `fields`), `unchanged`, `delete`, `orphaned` and `invalid` per key.\n- `deploy apply --env NAME --based-on BASED_ON` applies the whole environment or nothing. `ok:false` exits 2 and writes nothing. A stale `--based-on` is `CONFLICT`: plan again and show the new plan.\n- The repository owns definitions; the server owns pause and resume. Managed monitors refuse edits through `monitor apply` or the web (`MANAGED_BY_CONFIG`); change the file instead.\n- Undeclared monitors stay as `orphaned` warnings. `--prune` deletes them and their history; use it only with the user\'s consent.\n- Deploy versions come from the Git commit (`-dirty` when `waitcher.json` has uncommitted changes). A configuration deploy is not a product release: runs show `context.deployment` only for markers recorded with `waitcher deployment record`.\n- `--smoke` runs each created, adopted or updated monitor once on the server after apply. A failed smoke leaves the deploy applied and exits 4; follow `next` to `run diagnose`. On a personal account only the first monitor\'s smoke starts (one manual run per 10 minutes); the rest are `skipped`, which is not a failure.\n\n## Secrets\n\nScripts list `CHECK_*` names in `settings.envNames`. Values live per project environment on the server:\n\n```sh\nprintf %s "$VALUE" | waitcher secret set --env staging --name CHECK_ORDERS_TOKEN --value-stdin\nwaitcher secret list --env staging\n```\n\nIn Windows PowerShell pipe the same way: `$env:VALUE | waitcher secret set --env staging --name CHECK_ORDERS_TOKEN --value-stdin` (the trailing newline is dropped).\n\nAsk the user for each value, or tell them the command to run themselves. Never echo, log or commit it. A plan reports `SECRET_MISSING` with the missing names. `--verify` runs with your local environment, so set the same `CHECK_*` variables in the shell (bash: `export CHECK_NAME=...`, PowerShell: `$env:CHECK_NAME = "..."`, CMD: `set CHECK_NAME=...`; never in files) or skip `--verify` for that monitor and rely on `--smoke`.\n\nListed values of at least 6 characters appear as `<secret:CHECK_NAME>` in reports, traces and logs; screenshots, video and transformed values are not masked. For a password or token typed into a page, prefer `fill(secrets.get("CHECK_NAME"))` (`import { secrets } from "e2e"`) over `process.env`: the value stays out of the test code and the run refuses `app.screenshot()` after that fill, so take screenshots before it or drop them. Read `process.env.CHECK_NAME` for values the script sends itself, such as API headers, and for any value shorter than 6 characters: the framework does not register those as secrets, so `secrets.get` of one stops the run with `SECRET_UNAVAILABLE` naming the short value, and evidence shows it unmasked. Never log a value or assert on it.\n\n## Adopting existing monitors\n\nWhen a plan warns `ADOPTION_CANDIDATE`, an existing unmanaged monitor looks like the entry. Show it to the user (`waitcher monitor get --id ID`). If it is the same check, plan and apply with `--adopt KEY=MONITOR_ID`: it keeps its ID, history and pause state and takes the file\'s definition. Otherwise ignore the warning; apply creates a separate monitor.\n\n## Rollback\n\n`waitcher deploy list --project-id ID` shows deploys; `restorable:true` marks the latest 10 per environment. `waitcher deploy rollback --id DEPLOY_ID --dry-run` shows the plan, then run it with `--based-on`. Secrets are not rolled back. Tell the user to revert the repository too, or the next apply reintroduces the change.\n\n## CI\n\n`waitcher ci init [--env production] [--file waitcher.json]` writes `.github/workflows/waitcher.yml`: plan on pull requests, apply on pushes to the main branch. It installs the CLI from the server with a checksum and signs in with the `WAITCHER_TOKEN` repository secret. Create that token with read and write permissions (add run for `--smoke`) and `"projectId"` set to the project\'s ID (from `deploy plan`\'s `project.id`) using `waitcher token create`, so CI cannot touch other projects, and let the user store it with `gh secret set WAITCHER_TOKEN`. Signed in with a project token, read `authorization.projectName` from `waitcher auth status` and use it as `waitcher.json`\'s `project` (`config init --project-name NAME`); such a token changes monitors only through `deploy apply`, so do not try `monitor apply`. Set the `WAITCHER_SERVER` repository variable for a non-default server.\n';
|
|
63336
63730
|
|
|
63337
63731
|
// ../../skills/waitcher/references/diagnosis.md
|
|
63338
|
-
var diagnosis_default = '# Diagnosing failures\n\nRead when a local, smoke or scheduled run failed or errored.\n\nFor "since when" or "how often" questions, `waitcher monitor history --id ID` gives 13 months of daily runs, failures, availability and p50/p95 for one monitor, and `waitcher report history` sums the account by month and monitor; individual runs and evidence only go back as far as the plan keeps them.\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';
|
|
63732
|
+
var diagnosis_default = '# Diagnosing failures\n\nRead when a local, smoke or scheduled run failed or errored.\n\n## Local runs\n\n`run local` (and `config validate --verify`) prints why a run did not pass at the top level: `code`, a `message` in Waitcher terms, the failing `test`, its `trace` and `next`. Do what `next` says; `waitcher explain CODE` has the meaning and fix offline. Hosted run messages start with the same code.\n\n- `APP_UNREACHABLE`: nothing answered at the monitor\'s target. Start the app there (ask the user how, or use the project\'s start script), or correct `target`. Hosted runs reach only public addresses.\n- `SECRET_UNAVAILABLE`: the script calls `secrets.get(NAME)` without a value. Locally the user exports `NAME` in the shell that runs waitcher; hosted, `waitcher secret set`. The name must be in `settings.envNames`. A value under 6 characters is never registered as a secret: read it with `process.env.NAME` instead.\n- `BROWSER_INSTALL_FAILED`: run `waitcher runtime install --browser`, and with `--yes` after the user agrees. A browser run without Chromium downloads it first and says so in `notes`.\n- `COLLECTION_ERROR`, `NO_TESTS`: the test file did not load; fix it.\n- `ASSERTION_FAILED` and other test codes: the app or the test is wrong; read the trace before changing the test.\n- `RUNTIME_INSTALL_FAILED` with npm `EALLOWSCRIPTS` (npm 11): npm got `allow-scripts` from the command line or an `npm_config_allow_scripts` variable. Unset it for the install and record approvals with `npm install-scripts approve esbuild` or `allow-scripts=esbuild` in `.npmrc`. A warning that esbuild\'s install script was skipped is harmless.\n- `CONFIG_DIR_PERMISSIONS`: the session folder is readable by others; the user runs the `chmod` in `next`.\n\nFor "since when" or "how often" questions, `waitcher monitor history --id ID` gives 13 months of daily runs, failures, availability and p50/p95 for one monitor, and `waitcher report history` sums the account by month and monitor; individual runs and evidence only go back as far as the plan keeps them.\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; it starts with the failing test, its code and message and the trace path. 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';
|
|
63339
63733
|
|
|
63340
63734
|
// ../../skills/waitcher/references/optional-capabilities.md
|
|
63341
63735
|
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`; in `waitcher.json` write `{"credential": "NAME"}` or `{"credential": {"production": "NAME", "staging": "NAME"}}` and the deploy binds it). 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`. The header is any valid name (not Host, Cookie or transport headers); basic auth is `Authorization` with `Basic ` plus base64(user:password); values are complete single-line ASCII header values up to 4096 bytes. For Bearer auth, include the `Bearer ` prefix in the private value. For OAuth 2 (a token endpoint, client credentials or a refresh token) create the credential with `"kind":"oauth2"` and an `oauth` block (`grant`, `tokenUrl`, `clientId`, optional `scope`, `clientAuth`); the private value is the client secret, or for `refresh_token` one JSON line `{"refreshToken":"...","clientSecret":"..."}`. Waitcher mints, caches and refreshes the Bearer token; `run local` cannot use it. 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 an Anthropic connection in the entry\'s project environment (`connection create` with `"provider":"anthropic"`, the user\'s own Anthropic API key from a private file; models `haiku`, `sonnet`, `opus` or `fable` follow the latest model of that family, resolved at each run, or exact IDs like `claude-sonnet-5-5` stay fixed); an OpenRouter connection is refused for agent checks and serves only AI scripts and AI checks 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; a project token lets it list that project\'s monitors, and monitors it finds there that a deploy created are removed by a deploy with `--prune`, not `monitor delete`. Read a run with `run diagnose --id RUN_ID`, which leads with the agent\'s outcome, model, pages read, failed steps, gateway refusals and final message, apart from the verifier\'s verdict. Ask before creating a connection: it stores the user\'s key and every run is billed to it.\n\n## Second-region confirmation\n\nWhen `features.secondRegion` is true, a failing HTTP or certificate check that would open an incident is first repeated once from a Cloudflare region outside Europe ([guide](https://waitcher.dev/docs/results.md#second-region)). A pass there marks the run "Not confirmed" and opens no incident; a failure there marks the incident "Confirmed from 2 regions"; a recheck that cannot answer alerts as usual. `run trace`, `run status` and `incident list` carry it as `secondRegion` (outcome, region, data center, status, time, hops). Checks with `httpAuth`, custom headers, a body or a method other than GET or HEAD are never repeated, and the trace says so; do not remove credentials or headers just to get a recheck. `"secondRegion": false` on a definition or `waitcher.json` entry opts a monitor out; suggest it only when the user wants alerts from the first region alone. A "Not confirmed" run is still a real failure from Europe: mention it when diagnosing, but it is not an outage of the site.\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 it. People can also open an incident no monitor has seen (`incident open --page-id ID --title TEXT --message TEXT [--impact down|degraded|none] [--services "A,B"]`), and change any incident with `incident edit` (title, impact, open or resolved, hidden; `--expected-revision` from `status-page incidents --id PAGE_ID`). On a monitor\'s incident those values win over the monitor until reset (`--state auto`). A page with `"automaticIncidents": false` shows only incidents people open. Visitors can subscribe to email updates unless `"subscriptions": false`; opening, updating, resolving or reopening an incident emails them, so treat every such command as a message to the user\'s customers. Everything on these pages is public: only post, open, resolve or hide what the user wrote or approved.\n\n## Team workspaces\n\nWhen `features.teams` is true, the user may belong to team workspaces ([guide](https://waitcher.dev/docs/teams.md)). Monitors, projects, alerts, status pages, tokens, plan, export and deletion belong to the active workspace; `waitcher auth status` shows it (`workspace.id`, `workspace.role`). `waitcher workspace list` lists the user\'s workspaces and invitations; `workspace use --id team:ID` switches for later commands and `--workspace team:ID|personal` acts once. Deploy a repository into the workspace the user names, and never move work between workspaces to get around a limit. A member can change monitors, projects, deploys, alert routing and status pages; a `FORBIDDEN` refusal for credentials, settings, export, billing or members means an owner or admin must do it, so report it. A project token is bound to the team it was created in. `member invite`, `member remove`, `member role`, `workspace leave` and account deletion with a team active affect other people: run them only when the user asked for that exact change.\n';
|
|
@@ -63391,8 +63785,8 @@ async function installSkill(options) {
|
|
|
63391
63785
|
await mkdir8(join14(directory, "references"), { recursive: true });
|
|
63392
63786
|
await mkdir8(join14(directory, "agents"), { recursive: true });
|
|
63393
63787
|
await writeFile9(join14(directory, "SKILL.md"), SKILL_default);
|
|
63394
|
-
for (const [name5,
|
|
63395
|
-
await writeFile9(join14(directory, "references", name5),
|
|
63788
|
+
for (const [name5, text5] of Object.entries(references))
|
|
63789
|
+
await writeFile9(join14(directory, "references", name5), text5);
|
|
63396
63790
|
await writeFile9(join14(directory, "agents/openai.yaml"), openai_default);
|
|
63397
63791
|
await writeFile9(
|
|
63398
63792
|
join14(directory, MARKER),
|
|
@@ -63446,15 +63840,28 @@ async function doctor(options) {
|
|
|
63446
63840
|
);
|
|
63447
63841
|
add({ id: "cli", status: "ok", message: `waitcher ${options.version}` });
|
|
63448
63842
|
let config2, path2;
|
|
63843
|
+
let localOnly = false;
|
|
63449
63844
|
try {
|
|
63450
63845
|
({ config: config2, path: path2 } = await readProjectConfig(options.file));
|
|
63451
63846
|
} catch (cause) {
|
|
63452
|
-
|
|
63453
|
-
|
|
63454
|
-
|
|
63455
|
-
|
|
63456
|
-
|
|
63457
|
-
|
|
63847
|
+
const monitors = cause.code === "FILE_NOT_FOUND" ? await monitorFiles(options.file ? dirname14(options.file) : process.cwd()) : [];
|
|
63848
|
+
localOnly = monitors.length > 0;
|
|
63849
|
+
add(
|
|
63850
|
+
localOnly ? {
|
|
63851
|
+
id: "config",
|
|
63852
|
+
status: "warning",
|
|
63853
|
+
message: `No waitcher.json; ${monitors.length} monitor file${monitors.length === 1 ? "" : "s"} (${monitors.map((m) => m.file).join(", ")}) run locally without one. waitcher.json is needed only to deploy.`,
|
|
63854
|
+
next: [
|
|
63855
|
+
...monitors.slice(0, 3).map((m) => `waitcher run local --file ${m.file}`),
|
|
63856
|
+
"To deploy later: waitcher config init --project-name NAME --target https://PRODUCTION_URL"
|
|
63857
|
+
]
|
|
63858
|
+
} : {
|
|
63859
|
+
id: "config",
|
|
63860
|
+
status: "error",
|
|
63861
|
+
message: cause.message,
|
|
63862
|
+
next: ["waitcher config init --project-name NAME --target https://BASE_URL"]
|
|
63863
|
+
}
|
|
63864
|
+
);
|
|
63458
63865
|
}
|
|
63459
63866
|
const environments = [];
|
|
63460
63867
|
let built;
|
|
@@ -63522,7 +63929,7 @@ async function doctor(options) {
|
|
|
63522
63929
|
for (const home of skillHomes) {
|
|
63523
63930
|
if (!await exists(join15(home, "SKILL.md"))) continue;
|
|
63524
63931
|
installed.push(home);
|
|
63525
|
-
const marker2 = await readFile10(join15(home, ".waitcher-skill.json"), "utf8").then((
|
|
63932
|
+
const marker2 = await readFile10(join15(home, ".waitcher-skill.json"), "utf8").then((text5) => JSON.parse(text5)).catch(() => null);
|
|
63526
63933
|
if (marker2 && marker2.version !== options.version) stale.push(home);
|
|
63527
63934
|
}
|
|
63528
63935
|
const install = root === process.cwd() ? ["waitcher skill install"] : [".claude", ".agents"].map((agent) => `waitcher skill install --path ${join15(root, agent, "skills")}`);
|
|
@@ -63545,13 +63952,26 @@ async function doctor(options) {
|
|
|
63545
63952
|
]
|
|
63546
63953
|
} : { id: "skill", status: "ok", message: `Agent skill at ${installed.join(", ")}` }
|
|
63547
63954
|
);
|
|
63548
|
-
|
|
63549
|
-
|
|
63955
|
+
let sessionError = null;
|
|
63956
|
+
const api = await options.session().catch((cause) => {
|
|
63957
|
+
sessionError = cause;
|
|
63958
|
+
return null;
|
|
63959
|
+
});
|
|
63960
|
+
const refused = sessionError;
|
|
63961
|
+
if (refused?.code === "CONFIG_DIR_PERMISSIONS") {
|
|
63550
63962
|
add({
|
|
63551
63963
|
id: "session",
|
|
63552
63964
|
status: "error",
|
|
63553
|
-
message:
|
|
63554
|
-
next:
|
|
63965
|
+
message: `${refused.message} Sessions cannot be read or saved until it is.`,
|
|
63966
|
+
next: refused.next ?? []
|
|
63967
|
+
});
|
|
63968
|
+
} else if (!api) {
|
|
63969
|
+
add({
|
|
63970
|
+
id: "session",
|
|
63971
|
+
// Trying monitors locally needs no account.
|
|
63972
|
+
status: localOnly ? "warning" : "error",
|
|
63973
|
+
message: localOnly ? "Not signed in; local runs need no account, deploys and hosted checks do" : "Not signed in to the server; hosted checks were skipped",
|
|
63974
|
+
next: ["The user runs `waitcher auth login` (browser sign-in), then rerun this command (CI: waitcher auth login --token-stdin)"]
|
|
63555
63975
|
});
|
|
63556
63976
|
} else {
|
|
63557
63977
|
const capabilities = await api("capabilities");
|
|
@@ -63737,7 +64157,7 @@ jobs:
|
|
|
63737
64157
|
}
|
|
63738
64158
|
|
|
63739
64159
|
// src/main.ts
|
|
63740
|
-
import { readFile as readFile12, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
|
|
64160
|
+
import { access as access3, readFile as readFile12, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
|
|
63741
64161
|
import { basename as basename3, dirname as dirname18, join as join17, resolve as resolve18 } from "node:path";
|
|
63742
64162
|
import { constants as constants13 } from "node:fs";
|
|
63743
64163
|
|
|
@@ -63942,10 +64362,9 @@ var STATUS_PAGE_LIMITS = Object.freeze({
|
|
|
63942
64362
|
var plain = (max) => external_exports.string().trim().max(max).refine((v) => !/[\u0000-\u001f\u007f<>]/.test(v), {
|
|
63943
64363
|
message: "Use plain text without line breaks or angle brackets"
|
|
63944
64364
|
});
|
|
63945
|
-
var
|
|
63946
|
-
|
|
63947
|
-
|
|
63948
|
-
);
|
|
64365
|
+
var STATUS_SLUG = /^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])$/;
|
|
64366
|
+
var STATUS_SLUG_RULE = "Use 3 to 40 lower-case letters, digits or hyphens, starting and ending with a letter or digit";
|
|
64367
|
+
var statusSlugSchema = external_exports.string().regex(STATUS_SLUG, STATUS_SLUG_RULE);
|
|
63949
64368
|
var statusPageSchema = external_exports.object({
|
|
63950
64369
|
slug: statusSlugSchema,
|
|
63951
64370
|
title: plain(80).pipe(external_exports.string().min(1)),
|
|
@@ -64013,8 +64432,8 @@ var incidentEditSchema = external_exports.object({
|
|
|
64013
64432
|
// src/access.ts
|
|
64014
64433
|
import { lstat as lstat10, open as open16, unlink as unlink3 } from "node:fs/promises";
|
|
64015
64434
|
import { dirname as dirname16, resolve as resolve17 } from "node:path";
|
|
64016
|
-
function accessTokenInput(
|
|
64017
|
-
let token =
|
|
64435
|
+
function accessTokenInput(text5) {
|
|
64436
|
+
let token = text5.trim();
|
|
64018
64437
|
if (token.startsWith("{")) {
|
|
64019
64438
|
try {
|
|
64020
64439
|
token = JSON.parse(token).token;
|
|
@@ -64105,25 +64524,37 @@ function sessionPath(server) {
|
|
|
64105
64524
|
createHash11("sha256").update(server).digest("hex").slice(0, 24) + ".json"
|
|
64106
64525
|
);
|
|
64107
64526
|
}
|
|
64108
|
-
|
|
64109
|
-
|
|
64110
|
-
|
|
64111
|
-
|
|
64112
|
-
|
|
64527
|
+
var ConfigPermissionsError = class extends Error {
|
|
64528
|
+
code = "CONFIG_DIR_PERMISSIONS";
|
|
64529
|
+
path;
|
|
64530
|
+
directory;
|
|
64531
|
+
constructor(path2, directory) {
|
|
64532
|
+
super(
|
|
64533
|
+
`${directory ? "The Waitcher config directory" : "The session file"} ${path2} must be ${directory ? "a private directory (mode 700)" : "a private regular file (mode 600)"}, not a link and not readable by other users.`
|
|
64113
64534
|
);
|
|
64535
|
+
this.path = path2;
|
|
64536
|
+
this.directory = directory;
|
|
64537
|
+
}
|
|
64538
|
+
};
|
|
64539
|
+
async function privatePath(path2, directory = false, session = false) {
|
|
64540
|
+
const info = await lstat11(path2);
|
|
64541
|
+
if (info.isSymbolicLink() || (directory ? !info.isDirectory() : !info.isFile()) || process.platform !== "win32" && info.mode & 63) {
|
|
64542
|
+
if (directory || session) throw new ConfigPermissionsError(path2, directory);
|
|
64543
|
+
throw new Error("Credential file must be a private regular file (chmod 600).");
|
|
64544
|
+
}
|
|
64114
64545
|
if (!directory && info.size > 8192)
|
|
64115
64546
|
throw new Error("Credential file is too large.");
|
|
64116
64547
|
}
|
|
64117
|
-
async function readPrivate(path2) {
|
|
64118
|
-
await privatePath(path2);
|
|
64548
|
+
async function readPrivate(path2, session = false) {
|
|
64549
|
+
await privatePath(path2, false, session);
|
|
64119
64550
|
return readFile11(path2, "utf8");
|
|
64120
64551
|
}
|
|
64121
64552
|
async function loadSession(server) {
|
|
64122
64553
|
const path2 = sessionPath(server);
|
|
64123
|
-
let
|
|
64554
|
+
let text5;
|
|
64124
64555
|
try {
|
|
64125
64556
|
await privatePath(dirname17(path2), true);
|
|
64126
|
-
|
|
64557
|
+
text5 = await readPrivate(path2, true);
|
|
64127
64558
|
} catch (cause) {
|
|
64128
64559
|
const error62 = asError(cause);
|
|
64129
64560
|
if (error62.code === "ENOENT")
|
|
@@ -64134,7 +64565,7 @@ async function loadSession(server) {
|
|
|
64134
64565
|
}
|
|
64135
64566
|
let session;
|
|
64136
64567
|
try {
|
|
64137
|
-
session = JSON.parse(
|
|
64568
|
+
session = JSON.parse(text5);
|
|
64138
64569
|
} catch {
|
|
64139
64570
|
throw new Error("Saved session is unreadable. Run auth login again.");
|
|
64140
64571
|
}
|
|
@@ -64189,7 +64620,7 @@ async function writeSession(server, value2) {
|
|
|
64189
64620
|
await mkdir10(directory, { recursive: true, mode: 448 });
|
|
64190
64621
|
await privatePath(directory, true);
|
|
64191
64622
|
try {
|
|
64192
|
-
await privatePath(path2);
|
|
64623
|
+
await privatePath(path2, false, true);
|
|
64193
64624
|
} catch (cause) {
|
|
64194
64625
|
const error62 = asError(cause);
|
|
64195
64626
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -64705,6 +65136,7 @@ Executions and reports
|
|
|
64705
65136
|
run local --project E2E_PROJECT [--output DIR] [--video] [--timeout 60]
|
|
64706
65137
|
Run trusted local tests without login or API access
|
|
64707
65138
|
Fresh output per run inside the project; video opt-in
|
|
65139
|
+
Not passing: code, message, trace and next. Browser: runtime install --browser first.
|
|
64708
65140
|
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60] [--update-baselines]
|
|
64709
65141
|
A finished run prints status, duration, message and a
|
|
64710
65142
|
report link (SERVER/app#run/RUN_ID) first;
|
|
@@ -65044,7 +65476,7 @@ var intro = `${title}
|
|
|
65044
65476
|
${usage}`;
|
|
65045
65477
|
var exitCodes = sections.find((s) => s.startsWith("Exit codes\n"));
|
|
65046
65478
|
var GROUPS = new Set(
|
|
65047
|
-
"skill heartbeat auth token account system project environment deployment doctor explain ci config runtime deploy secret monitor run artifact report incident visual identity target connection alert".split(
|
|
65479
|
+
"skill heartbeat auth token account workspace member system project environment deployment doctor explain ci config runtime deploy secret monitor run artifact report incident visual identity target connection alert".split(
|
|
65048
65480
|
" "
|
|
65049
65481
|
)
|
|
65050
65482
|
);
|
|
@@ -65061,25 +65493,30 @@ var commands = (section) => {
|
|
|
65061
65493
|
([group, list2]) => list2.size ? `${group}: ${[...list2].join(", ")}` : group
|
|
65062
65494
|
);
|
|
65063
65495
|
};
|
|
65496
|
+
var HELP_TOPICS = [...GROUPS];
|
|
65064
65497
|
function helpTopic(topic) {
|
|
65065
|
-
const needle = topic.toLowerCase();
|
|
65498
|
+
const needle = topic.toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
65066
65499
|
if (needle === "all") return help;
|
|
65067
|
-
|
|
65500
|
+
if (!needle) return null;
|
|
65501
|
+
const word = new RegExp(`\\b${needle}\\b`);
|
|
65068
65502
|
const matches2 = sections.filter((section) => {
|
|
65069
65503
|
if (section === exitCodes) return false;
|
|
65070
65504
|
const [heading, ...lines] = section.split("\n");
|
|
65071
|
-
return word.test(heading.toLowerCase()) || lines.some(
|
|
65072
|
-
(
|
|
65073
|
-
|
|
65505
|
+
return word.test(heading.toLowerCase()) || lines.some((line) => {
|
|
65506
|
+
if (!/^ {2}[a-z]/.test(line)) return false;
|
|
65507
|
+
const [group, action] = line.trimStart().split(" ");
|
|
65508
|
+
return group === needle || GROUPS.has(group) && action === needle;
|
|
65509
|
+
});
|
|
65074
65510
|
});
|
|
65075
|
-
return matches2.length ? [intro, ...matches2, exitCodes].join("\n\n") + "\n" :
|
|
65076
|
-
|
|
65077
|
-
${overview()}`;
|
|
65511
|
+
return matches2.length ? [intro, ...matches2, exitCodes].join("\n\n") + "\n" : null;
|
|
65078
65512
|
}
|
|
65079
65513
|
function overview() {
|
|
65080
65514
|
const index = sections.map((section) => {
|
|
65081
65515
|
const list2 = commands(section);
|
|
65082
|
-
|
|
65516
|
+
let heading = section.split("\n")[0];
|
|
65517
|
+
if (heading.includes("(") && !heading.includes(")"))
|
|
65518
|
+
heading = heading.slice(0, heading.indexOf(" ("));
|
|
65519
|
+
return list2.length ? `${heading}
|
|
65083
65520
|
${list2.join("\n ")}` : "";
|
|
65084
65521
|
}).filter(Boolean).join("\n");
|
|
65085
65522
|
return `${intro}
|
|
@@ -65138,7 +65575,7 @@ function formatSystemAccounts(result2) {
|
|
|
65138
65575
|
}
|
|
65139
65576
|
|
|
65140
65577
|
// src/main.ts
|
|
65141
|
-
var list = (
|
|
65578
|
+
var list = (text5) => (text5 ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
65142
65579
|
var issues = (all) => all.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n");
|
|
65143
65580
|
var controller = new AbortController();
|
|
65144
65581
|
process.once("SIGINT", () => controller.abort());
|
|
@@ -65192,6 +65629,18 @@ async function deletionReceipt(file2, server) {
|
|
|
65192
65629
|
usage2("Use a deletion receipt for this exact server origin.");
|
|
65193
65630
|
return value2;
|
|
65194
65631
|
}
|
|
65632
|
+
function configPermissionsNext(error62) {
|
|
65633
|
+
return process.platform === "win32" ? [
|
|
65634
|
+
`Point WAITCHER_CONFIG_DIR at a regular folder that is not a link (now ${error62.path}), or unset it to use the default, then rerun this command`
|
|
65635
|
+
] : [
|
|
65636
|
+
error62.directory ? `chmod 700 ${error62.path} (or point WAITCHER_CONFIG_DIR at a new private folder; a link is refused), then rerun this command` : `chmod 600 ${error62.path}, then rerun this command`
|
|
65637
|
+
];
|
|
65638
|
+
}
|
|
65639
|
+
var configPermissions = (error62) => {
|
|
65640
|
+
const service = new ServiceError(error62.message, "CONFIG_DIR_PERMISSIONS", 2);
|
|
65641
|
+
service.next = configPermissionsNext(error62);
|
|
65642
|
+
return service;
|
|
65643
|
+
};
|
|
65195
65644
|
async function authenticatedSession(server) {
|
|
65196
65645
|
try {
|
|
65197
65646
|
return await refreshOAuth(
|
|
@@ -65203,6 +65652,7 @@ async function authenticatedSession(server) {
|
|
|
65203
65652
|
const error62 = asError(cause);
|
|
65204
65653
|
if (["NETWORK_ERROR", "SERVICE_UNAVAILABLE"].includes(String(error62.code)))
|
|
65205
65654
|
throw cause;
|
|
65655
|
+
if (cause instanceof ConfigPermissionsError) throw configPermissions(cause);
|
|
65206
65656
|
throw new ServiceError(error62.message, "AUTH_REQUIRED", 3);
|
|
65207
65657
|
}
|
|
65208
65658
|
}
|
|
@@ -65211,16 +65661,16 @@ async function passwordFromStdin(maxBytes = 2048) {
|
|
|
65211
65661
|
usage2(
|
|
65212
65662
|
"Pipe the password to stdin, or use --password-file PATH. Passwords are not accepted as command arguments."
|
|
65213
65663
|
);
|
|
65214
|
-
let
|
|
65664
|
+
let text5 = "";
|
|
65215
65665
|
const cancel = () => process.stdin.destroy(new Error("Interrupted."));
|
|
65216
65666
|
controller.signal.addEventListener("abort", cancel, { once: true });
|
|
65217
65667
|
try {
|
|
65218
65668
|
for await (const chunk of process.stdin) {
|
|
65219
|
-
|
|
65220
|
-
if (Buffer.byteLength(
|
|
65669
|
+
text5 += chunk;
|
|
65670
|
+
if (Buffer.byteLength(text5) > maxBytes)
|
|
65221
65671
|
usage2("Password input is too long.");
|
|
65222
65672
|
}
|
|
65223
|
-
return
|
|
65673
|
+
return text5.replace(/[\r\n]+$/, "");
|
|
65224
65674
|
} finally {
|
|
65225
65675
|
controller.signal.removeEventListener("abort", cancel);
|
|
65226
65676
|
}
|
|
@@ -65341,7 +65791,13 @@ async function main() {
|
|
|
65341
65791
|
const { values: v, positionals: p } = parsed;
|
|
65342
65792
|
if (v.help || p[0] === "help" || !p.length && !v.version) {
|
|
65343
65793
|
const topic = p[0] === "help" ? p[1] : p[0];
|
|
65344
|
-
|
|
65794
|
+
const text5 = topic ? helpTopic(topic) : overview();
|
|
65795
|
+
if (text5 === null)
|
|
65796
|
+
usage2(
|
|
65797
|
+
`No help section matches "${topic}". Topics: ${HELP_TOPICS.join(", ")}; a word from a section heading or a command action (help local) works too, and waitcher help all prints everything.`,
|
|
65798
|
+
["waitcher --help"]
|
|
65799
|
+
);
|
|
65800
|
+
process.stdout.write(text5);
|
|
65345
65801
|
return;
|
|
65346
65802
|
}
|
|
65347
65803
|
if (v.version) {
|
|
@@ -65714,18 +66170,42 @@ async function main() {
|
|
|
65714
66170
|
if (command === "runtime install") {
|
|
65715
66171
|
if (v.server) usage2("runtime install works locally; omit --server.");
|
|
65716
66172
|
const file2 = configPath(v.file);
|
|
65717
|
-
|
|
66173
|
+
const monitorFile = async () => {
|
|
66174
|
+
let project = dirname18(file2);
|
|
66175
|
+
for (let dir = project; ; ) {
|
|
66176
|
+
if (await access3(join17(dir, "package.json")).then(() => true, () => false)) {
|
|
66177
|
+
project = dir;
|
|
66178
|
+
break;
|
|
66179
|
+
}
|
|
66180
|
+
const parent = dirname18(dir);
|
|
66181
|
+
if (parent === dir) break;
|
|
66182
|
+
dir = parent;
|
|
66183
|
+
}
|
|
66184
|
+
return usage2(
|
|
66185
|
+
`${file2} is a monitor file, not waitcher.json. runtime install sets up the folder that holds package.json: run it there without --file, or pass --file FOLDER/waitcher.json (the file need not exist yet).`,
|
|
66186
|
+
[
|
|
66187
|
+
`waitcher runtime install --file ${join17(project, "waitcher.json")}${v.browser ? " --browser" : ""} (lists the steps; --yes after the user agrees)`
|
|
66188
|
+
]
|
|
66189
|
+
);
|
|
66190
|
+
};
|
|
66191
|
+
if (basename3(file2).endsWith(".monitor.json")) await monitorFile();
|
|
66192
|
+
let browser = Boolean(v.browser), hasConfig = true;
|
|
65718
66193
|
try {
|
|
65719
66194
|
const { config: config2 } = await readProjectConfig(v.file);
|
|
66195
|
+
if (config2 && typeof config2 === "object" && "type" in config2 && !("monitors" in config2))
|
|
66196
|
+
await monitorFile();
|
|
65720
66197
|
browser ||= scriptEntries(config2).some((e) => e.type === "browser");
|
|
65721
66198
|
} catch (cause) {
|
|
65722
66199
|
if (cause.code !== "FILE_NOT_FOUND") throw cause;
|
|
66200
|
+
hasConfig = false;
|
|
65723
66201
|
}
|
|
65724
66202
|
const result3 = await installRuntime({
|
|
65725
66203
|
project: dirname18(file2),
|
|
65726
66204
|
browser,
|
|
65727
66205
|
yes: Boolean(v.yes),
|
|
65728
|
-
signal: controller.signal
|
|
66206
|
+
signal: controller.signal,
|
|
66207
|
+
hasConfig,
|
|
66208
|
+
command: `waitcher runtime install${v.file ? ` --file ${file2}` : ""}${v.browser ? " --browser" : ""}`
|
|
65729
66209
|
});
|
|
65730
66210
|
process.stdout.write(JSON.stringify(result3) + "\n");
|
|
65731
66211
|
return;
|
|
@@ -66028,22 +66508,33 @@ async function main() {
|
|
|
66028
66508
|
usage2("--target must be an HTTP(S) URL without embedded credentials.");
|
|
66029
66509
|
}
|
|
66030
66510
|
}
|
|
66511
|
+
const taken = (cause) => {
|
|
66512
|
+
if (cause instanceof ServiceError && cause.code === "FILE_EXISTS") {
|
|
66513
|
+
const stem = basename3(v.file).replace(/(\.monitor)?\.json$/, "");
|
|
66514
|
+
const free = join17(dirname18(v.file), `${stem}-2.monitor.json`);
|
|
66515
|
+
cause.next = [
|
|
66516
|
+
`waitcher monitor init${v.type ? ` --type ${v.type}` : ""}${v.template ? ` --template ${v.template}` : ""} --file ${free}${v.target ? ` --target ${v.target}` : ""}`,
|
|
66517
|
+
"Or edit the existing file; init never overwrites"
|
|
66518
|
+
];
|
|
66519
|
+
}
|
|
66520
|
+
throw cause;
|
|
66521
|
+
};
|
|
66031
66522
|
if (!v.template && (v.type === "browser" || v.type === "api")) {
|
|
66032
66523
|
const scriptFile = basename3(v.file).replace(/(\.monitor)?\.json$/, "") + ".e2e.ts";
|
|
66033
66524
|
await writeText(
|
|
66034
66525
|
join17(dirname18(v.file), scriptFile),
|
|
66035
66526
|
v.type === "api" ? apiScriptExample : browserScriptExample
|
|
66036
|
-
);
|
|
66527
|
+
).catch(taken);
|
|
66037
66528
|
await writeJson(v.file, {
|
|
66038
66529
|
...v.type === "api" ? apiExample : browserExample,
|
|
66039
66530
|
scriptFile,
|
|
66040
66531
|
...v.target ? { target: v.target } : {}
|
|
66041
|
-
});
|
|
66532
|
+
}).catch(taken);
|
|
66042
66533
|
} else
|
|
66043
66534
|
await writeJson(v.file, {
|
|
66044
66535
|
...initial,
|
|
66045
66536
|
...v.target ? { target: v.target } : {}
|
|
66046
|
-
});
|
|
66537
|
+
}).catch(taken);
|
|
66047
66538
|
const type = v.template ? "api" : v.type ?? "http";
|
|
66048
66539
|
result2 = {
|
|
66049
66540
|
event: "initialized",
|
|
@@ -66052,9 +66543,12 @@ async function main() {
|
|
|
66052
66543
|
next: [
|
|
66053
66544
|
"Replace the example target, name and checks with the user's",
|
|
66054
66545
|
`waitcher monitor validate --file ${v.file}`,
|
|
66055
|
-
|
|
66056
|
-
|
|
66057
|
-
|
|
66546
|
+
// A script check runs on the project's pinned runtime; install it
|
|
66547
|
+
// in the folder that holds package.json first.
|
|
66548
|
+
...type === "api" || type === "browser" ? [
|
|
66549
|
+
`waitcher runtime install${type === "browser" ? " --browser" : ""} (from the folder with package.json; lists the steps, --yes after the user agrees)`
|
|
66550
|
+
] : [],
|
|
66551
|
+
...["visual", "heartbeat", "certificate"].includes(type) ? [] : [`waitcher run local --file ${v.file}`],
|
|
66058
66552
|
`waitcher monitor apply --file ${v.file} --dry-run`
|
|
66059
66553
|
]
|
|
66060
66554
|
};
|
|
@@ -67125,12 +67619,12 @@ async function main() {
|
|
|
67125
67619
|
usage2(
|
|
67126
67620
|
"Provide --file PATH with the complete configuration and expectedRevision for edits."
|
|
67127
67621
|
);
|
|
67128
|
-
const
|
|
67129
|
-
if (Buffer.byteLength(
|
|
67622
|
+
const text5 = await readFile12(v.file, "utf8");
|
|
67623
|
+
if (Buffer.byteLength(text5) > 16e3)
|
|
67130
67624
|
usage2("Project configuration exceeds 16 KB");
|
|
67131
67625
|
let body2;
|
|
67132
67626
|
try {
|
|
67133
|
-
body2 = JSON.parse(
|
|
67627
|
+
body2 = JSON.parse(text5);
|
|
67134
67628
|
} catch {
|
|
67135
67629
|
usage2("Configuration must be JSON");
|
|
67136
67630
|
}
|
|
@@ -67377,10 +67871,10 @@ async function main() {
|
|
|
67377
67871
|
if (!v.file) usage2("Provide --file PATH for the configuration.");
|
|
67378
67872
|
let input2;
|
|
67379
67873
|
try {
|
|
67380
|
-
const
|
|
67381
|
-
if (Buffer.byteLength(
|
|
67874
|
+
const text5 = await readFile12(v.file, "utf8");
|
|
67875
|
+
if (Buffer.byteLength(text5) > 96e3)
|
|
67382
67876
|
usage2("Configuration exceeds 96 KB.");
|
|
67383
|
-
input2 = JSON.parse(
|
|
67877
|
+
input2 = JSON.parse(text5);
|
|
67384
67878
|
} catch {
|
|
67385
67879
|
usage2("Could not read valid JSON configuration.");
|
|
67386
67880
|
}
|
|
@@ -67896,10 +68390,10 @@ async function main() {
|
|
|
67896
68390
|
if (!v.file) usage2("Provide --file PATH for the status page.");
|
|
67897
68391
|
let input2;
|
|
67898
68392
|
try {
|
|
67899
|
-
const
|
|
67900
|
-
if (Buffer.byteLength(
|
|
68393
|
+
const text5 = await readFile12(v.file, "utf8");
|
|
68394
|
+
if (Buffer.byteLength(text5) > 96e3)
|
|
67901
68395
|
usage2("Configuration exceeds 96 KB.");
|
|
67902
|
-
input2 = JSON.parse(
|
|
68396
|
+
input2 = JSON.parse(text5);
|
|
67903
68397
|
} catch {
|
|
67904
68398
|
usage2("Could not read valid JSON configuration.");
|
|
67905
68399
|
}
|
|
@@ -67940,9 +68434,15 @@ async function main() {
|
|
|
67940
68434
|
process.stdout.write(JSON.stringify(result2) + "\n");
|
|
67941
68435
|
process.exitCode = exitCode;
|
|
67942
68436
|
}
|
|
68437
|
+
var SIGN_IN_NEXT = [
|
|
68438
|
+
"The user runs `waitcher auth login` (browser sign-in), then rerun this command (CI: waitcher auth login --token-stdin)"
|
|
68439
|
+
];
|
|
67943
68440
|
try {
|
|
67944
68441
|
await main();
|
|
67945
|
-
} catch (
|
|
68442
|
+
} catch (raw) {
|
|
68443
|
+
const cause = raw instanceof ConfigPermissionsError ? configPermissions(raw) : raw;
|
|
68444
|
+
if (cause instanceof ServiceError && cause.code === "AUTH_REQUIRED" && !cause.next)
|
|
68445
|
+
cause.next = SIGN_IN_NEXT;
|
|
67946
68446
|
const error62 = asError(cause);
|
|
67947
68447
|
const interrupted = controller.signal.aborted;
|
|
67948
68448
|
process.stderr.write(
|