@waitcher/cli 0.2.33 → 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/README.md +1 -1
- package/dist/cli.mjs +1318 -716
- package/dist/model-client.mjs +73 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -5875,9 +5875,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
5875
5875
|
}
|
|
5876
5876
|
close(callback) {
|
|
5877
5877
|
if (callback === void 0) {
|
|
5878
|
-
return new Promise((
|
|
5878
|
+
return new Promise((resolve19, reject) => {
|
|
5879
5879
|
this.close((err, data) => {
|
|
5880
|
-
return err ? reject(err) :
|
|
5880
|
+
return err ? reject(err) : resolve19(data);
|
|
5881
5881
|
});
|
|
5882
5882
|
});
|
|
5883
5883
|
}
|
|
@@ -5915,9 +5915,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
5915
5915
|
err = null;
|
|
5916
5916
|
}
|
|
5917
5917
|
if (callback === void 0) {
|
|
5918
|
-
return new Promise((
|
|
5918
|
+
return new Promise((resolve19, reject) => {
|
|
5919
5919
|
this.destroy(err, (err2, data) => {
|
|
5920
|
-
return err2 ? reject(err2) :
|
|
5920
|
+
return err2 ? reject(err2) : resolve19(data);
|
|
5921
5921
|
});
|
|
5922
5922
|
});
|
|
5923
5923
|
}
|
|
@@ -11320,12 +11320,12 @@ upgrade: ${upgrade2}\r
|
|
|
11320
11320
|
cb();
|
|
11321
11321
|
}
|
|
11322
11322
|
}
|
|
11323
|
-
const waitForDrain = () => new Promise((
|
|
11323
|
+
const waitForDrain = () => new Promise((resolve19, reject) => {
|
|
11324
11324
|
assert2(callback === null);
|
|
11325
11325
|
if (socket[kError]) {
|
|
11326
11326
|
reject(socket[kError]);
|
|
11327
11327
|
} else {
|
|
11328
|
-
callback =
|
|
11328
|
+
callback = resolve19;
|
|
11329
11329
|
}
|
|
11330
11330
|
});
|
|
11331
11331
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -12835,12 +12835,12 @@ var require_client_h2 = __commonJS({
|
|
|
12835
12835
|
cb();
|
|
12836
12836
|
}
|
|
12837
12837
|
}
|
|
12838
|
-
const waitForDrain = () => new Promise((
|
|
12838
|
+
const waitForDrain = () => new Promise((resolve19, reject) => {
|
|
12839
12839
|
assert2(callback === null);
|
|
12840
12840
|
if (socket[kError]) {
|
|
12841
12841
|
reject(socket[kError]);
|
|
12842
12842
|
} else {
|
|
12843
|
-
callback =
|
|
12843
|
+
callback = resolve19;
|
|
12844
12844
|
}
|
|
12845
12845
|
});
|
|
12846
12846
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -13212,16 +13212,16 @@ var require_client = __commonJS({
|
|
|
13212
13212
|
return this[kNeedDrain] < 2;
|
|
13213
13213
|
}
|
|
13214
13214
|
[kClose]() {
|
|
13215
|
-
return new Promise((
|
|
13215
|
+
return new Promise((resolve19) => {
|
|
13216
13216
|
if (this[kSize]) {
|
|
13217
|
-
this[kClosedResolve] =
|
|
13217
|
+
this[kClosedResolve] = resolve19;
|
|
13218
13218
|
} else {
|
|
13219
|
-
|
|
13219
|
+
resolve19(null);
|
|
13220
13220
|
}
|
|
13221
13221
|
});
|
|
13222
13222
|
}
|
|
13223
13223
|
[kDestroy](err) {
|
|
13224
|
-
return new Promise((
|
|
13224
|
+
return new Promise((resolve19) => {
|
|
13225
13225
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
13226
13226
|
for (let i = 0; i < requests.length; i++) {
|
|
13227
13227
|
const request2 = requests[i];
|
|
@@ -13234,7 +13234,7 @@ var require_client = __commonJS({
|
|
|
13234
13234
|
this[kClosedResolve]();
|
|
13235
13235
|
this[kClosedResolve] = null;
|
|
13236
13236
|
}
|
|
13237
|
-
|
|
13237
|
+
resolve19(null);
|
|
13238
13238
|
};
|
|
13239
13239
|
if (this[kHTTPContext]) {
|
|
13240
13240
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -13711,8 +13711,8 @@ var require_pool_base = __commonJS({
|
|
|
13711
13711
|
if (this[kQueue].isEmpty()) {
|
|
13712
13712
|
return closeClients(this);
|
|
13713
13713
|
} else {
|
|
13714
|
-
return new Promise((
|
|
13715
|
-
this[kClosedResolve] =
|
|
13714
|
+
return new Promise((resolve19) => {
|
|
13715
|
+
this[kClosedResolve] = resolve19;
|
|
13716
13716
|
});
|
|
13717
13717
|
}
|
|
13718
13718
|
}
|
|
@@ -13781,8 +13781,8 @@ var require_pool_base = __commonJS({
|
|
|
13781
13781
|
}
|
|
13782
13782
|
let done = false;
|
|
13783
13783
|
let resolveClosed;
|
|
13784
|
-
const closed = new Promise((
|
|
13785
|
-
resolveClosed =
|
|
13784
|
+
const closed = new Promise((resolve19) => {
|
|
13785
|
+
resolveClosed = resolve19;
|
|
13786
13786
|
});
|
|
13787
13787
|
this[kRetiring].set(client, closed);
|
|
13788
13788
|
client.close(() => {
|
|
@@ -14948,8 +14948,8 @@ var require_socks5_client = __commonJS({
|
|
|
14948
14948
|
return;
|
|
14949
14949
|
}
|
|
14950
14950
|
if (reply !== REPLY_CODES.SUCCEEDED) {
|
|
14951
|
-
const
|
|
14952
|
-
throw new Socks5ProxyError(`SOCKS5 connection failed: ${
|
|
14951
|
+
const errorMessage2 = this.getReplyErrorMessage(reply);
|
|
14952
|
+
throw new Socks5ProxyError(`SOCKS5 connection failed: ${errorMessage2}`, `UND_ERR_SOCKS5_REPLY_${reply}`);
|
|
14953
14953
|
}
|
|
14954
14954
|
let boundAddress;
|
|
14955
14955
|
let offset = 4;
|
|
@@ -15568,10 +15568,10 @@ var require_proxy_agent = __commonJS({
|
|
|
15568
15568
|
headersPair[key] = value2;
|
|
15569
15569
|
continue;
|
|
15570
15570
|
}
|
|
15571
|
-
const
|
|
15571
|
+
const previous2 = headersPair[key];
|
|
15572
15572
|
const values = [];
|
|
15573
|
-
if (
|
|
15574
|
-
values.push(...Array.isArray(
|
|
15573
|
+
if (previous2 !== void 0) {
|
|
15574
|
+
values.push(...Array.isArray(previous2) ? previous2 : [previous2]);
|
|
15575
15575
|
}
|
|
15576
15576
|
if (value2 !== void 0) {
|
|
15577
15577
|
values.push(...Array.isArray(value2) ? value2 : [value2]);
|
|
@@ -16587,7 +16587,7 @@ var require_readable = __commonJS({
|
|
|
16587
16587
|
if (this._readableState.closeEmitted) {
|
|
16588
16588
|
return Promise.resolve(null);
|
|
16589
16589
|
}
|
|
16590
|
-
return new Promise((
|
|
16590
|
+
return new Promise((resolve19, reject) => {
|
|
16591
16591
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
16592
16592
|
this.destroy(new AbortError());
|
|
16593
16593
|
}
|
|
@@ -16601,11 +16601,11 @@ var require_readable = __commonJS({
|
|
|
16601
16601
|
if (signal.aborted) {
|
|
16602
16602
|
reject(signal.reason ?? new AbortError());
|
|
16603
16603
|
} else {
|
|
16604
|
-
|
|
16604
|
+
resolve19(null);
|
|
16605
16605
|
}
|
|
16606
16606
|
});
|
|
16607
16607
|
} else {
|
|
16608
|
-
this.on("close",
|
|
16608
|
+
this.on("close", resolve19);
|
|
16609
16609
|
}
|
|
16610
16610
|
this.on("error", noop).on("data", () => {
|
|
16611
16611
|
if (this[kBytesRead] > limit) {
|
|
@@ -16633,7 +16633,7 @@ var require_readable = __commonJS({
|
|
|
16633
16633
|
}
|
|
16634
16634
|
function consume(stream, type) {
|
|
16635
16635
|
assert2(!stream[kConsume]);
|
|
16636
|
-
return new Promise((
|
|
16636
|
+
return new Promise((resolve19, reject) => {
|
|
16637
16637
|
if (isUnusable(stream)) {
|
|
16638
16638
|
const rState = stream._readableState;
|
|
16639
16639
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -16648,7 +16648,7 @@ var require_readable = __commonJS({
|
|
|
16648
16648
|
stream[kConsume] = {
|
|
16649
16649
|
type,
|
|
16650
16650
|
stream,
|
|
16651
|
-
resolve:
|
|
16651
|
+
resolve: resolve19,
|
|
16652
16652
|
reject,
|
|
16653
16653
|
length: 0,
|
|
16654
16654
|
body: []
|
|
@@ -16726,18 +16726,18 @@ var require_readable = __commonJS({
|
|
|
16726
16726
|
return buffer;
|
|
16727
16727
|
}
|
|
16728
16728
|
function consumeEnd(consume2, encoding) {
|
|
16729
|
-
const { type, body: body2, resolve:
|
|
16729
|
+
const { type, body: body2, resolve: resolve19, stream, length } = consume2;
|
|
16730
16730
|
try {
|
|
16731
16731
|
if (type === "text") {
|
|
16732
|
-
|
|
16732
|
+
resolve19(chunksDecode(body2, length, encoding));
|
|
16733
16733
|
} else if (type === "json") {
|
|
16734
|
-
|
|
16734
|
+
resolve19(JSON.parse(chunksDecode(body2, length, encoding)));
|
|
16735
16735
|
} else if (type === "arrayBuffer") {
|
|
16736
|
-
|
|
16736
|
+
resolve19(chunksConcat(body2, length).buffer);
|
|
16737
16737
|
} else if (type === "blob") {
|
|
16738
|
-
|
|
16738
|
+
resolve19(new Blob(body2, { type: stream[kContentType] }));
|
|
16739
16739
|
} else if (type === "bytes") {
|
|
16740
|
-
|
|
16740
|
+
resolve19(chunksConcat(body2, length));
|
|
16741
16741
|
}
|
|
16742
16742
|
consumeFinish(consume2);
|
|
16743
16743
|
} catch (err) {
|
|
@@ -16956,9 +16956,9 @@ var require_api_request = __commonJS({
|
|
|
16956
16956
|
};
|
|
16957
16957
|
function request2(opts, callback) {
|
|
16958
16958
|
if (callback === void 0) {
|
|
16959
|
-
return new Promise((
|
|
16959
|
+
return new Promise((resolve19, reject) => {
|
|
16960
16960
|
request2.call(this, opts, (err, data) => {
|
|
16961
|
-
return err ? reject(err) :
|
|
16961
|
+
return err ? reject(err) : resolve19(data);
|
|
16962
16962
|
});
|
|
16963
16963
|
});
|
|
16964
16964
|
}
|
|
@@ -17219,9 +17219,9 @@ var require_api_stream = __commonJS({
|
|
|
17219
17219
|
};
|
|
17220
17220
|
function stream(opts, factory, callback) {
|
|
17221
17221
|
if (callback === void 0) {
|
|
17222
|
-
return new Promise((
|
|
17222
|
+
return new Promise((resolve19, reject) => {
|
|
17223
17223
|
stream.call(this, opts, factory, (err, data) => {
|
|
17224
|
-
return err ? reject(err) :
|
|
17224
|
+
return err ? reject(err) : resolve19(data);
|
|
17225
17225
|
});
|
|
17226
17226
|
});
|
|
17227
17227
|
}
|
|
@@ -17521,9 +17521,9 @@ var require_api_upgrade = __commonJS({
|
|
|
17521
17521
|
};
|
|
17522
17522
|
function upgrade2(opts, callback) {
|
|
17523
17523
|
if (callback === void 0) {
|
|
17524
|
-
return new Promise((
|
|
17524
|
+
return new Promise((resolve19, reject) => {
|
|
17525
17525
|
upgrade2.call(this, opts, (err, data) => {
|
|
17526
|
-
return err ? reject(err) :
|
|
17526
|
+
return err ? reject(err) : resolve19(data);
|
|
17527
17527
|
});
|
|
17528
17528
|
});
|
|
17529
17529
|
}
|
|
@@ -17617,9 +17617,9 @@ var require_api_connect = __commonJS({
|
|
|
17617
17617
|
};
|
|
17618
17618
|
function connect2(opts, callback) {
|
|
17619
17619
|
if (callback === void 0) {
|
|
17620
|
-
return new Promise((
|
|
17620
|
+
return new Promise((resolve19, reject) => {
|
|
17621
17621
|
connect2.call(this, opts, (err, data) => {
|
|
17622
|
-
return err ? reject(err) :
|
|
17622
|
+
return err ? reject(err) : resolve19(data);
|
|
17623
17623
|
});
|
|
17624
17624
|
});
|
|
17625
17625
|
}
|
|
@@ -19104,7 +19104,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19104
19104
|
"../../node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
19105
19105
|
"use strict";
|
|
19106
19106
|
var { writeFile: writeFile10, readFile: readFile13, mkdir: mkdir11 } = __require("node:fs/promises");
|
|
19107
|
-
var { dirname: dirname19, resolve:
|
|
19107
|
+
var { dirname: dirname19, resolve: resolve19 } = __require("node:path");
|
|
19108
19108
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
19109
19109
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
19110
19110
|
var { setHeader } = require_util();
|
|
@@ -19321,7 +19321,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19321
19321
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19322
19322
|
}
|
|
19323
19323
|
try {
|
|
19324
|
-
const data = await readFile13(
|
|
19324
|
+
const data = await readFile13(resolve19(path2), "utf8");
|
|
19325
19325
|
const parsed = JSON.parse(data);
|
|
19326
19326
|
if (Array.isArray(parsed)) {
|
|
19327
19327
|
this.#snapshots.clear();
|
|
@@ -19350,7 +19350,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19350
19350
|
if (!path2) {
|
|
19351
19351
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19352
19352
|
}
|
|
19353
|
-
const resolvedPath =
|
|
19353
|
+
const resolvedPath = resolve19(path2);
|
|
19354
19354
|
await mkdir11(dirname19(resolvedPath), { recursive: true });
|
|
19355
19355
|
const data = Array.from(this.#snapshots.entries()).map(([hash4, snapshot]) => ({
|
|
19356
19356
|
hash: hash4,
|
|
@@ -21358,14 +21358,14 @@ var require_cache = __commonJS({
|
|
|
21358
21358
|
var require_date = __commonJS({
|
|
21359
21359
|
"../../node_modules/undici/lib/util/date.js"(exports, module) {
|
|
21360
21360
|
"use strict";
|
|
21361
|
-
function parseHttpDate(
|
|
21362
|
-
switch (
|
|
21361
|
+
function parseHttpDate(date6) {
|
|
21362
|
+
switch (date6[3]) {
|
|
21363
21363
|
case ",":
|
|
21364
|
-
return parseImfDate(
|
|
21364
|
+
return parseImfDate(date6);
|
|
21365
21365
|
case " ":
|
|
21366
|
-
return parseAscTimeDate(
|
|
21366
|
+
return parseAscTimeDate(date6);
|
|
21367
21367
|
default:
|
|
21368
|
-
return parseRfc850Date(
|
|
21368
|
+
return parseRfc850Date(date6);
|
|
21369
21369
|
}
|
|
21370
21370
|
}
|
|
21371
21371
|
function makeDate(year, monthIdx, day, hour, minute, second, weekday) {
|
|
@@ -21375,66 +21375,66 @@ var require_date = __commonJS({
|
|
|
21375
21375
|
}
|
|
21376
21376
|
return result2.getUTCFullYear() === year && result2.getUTCMonth() === monthIdx && result2.getUTCDate() === day && result2.getUTCHours() === hour && result2.getUTCMinutes() === minute && result2.getUTCSeconds() === second && result2.getUTCDay() === weekday ? result2 : void 0;
|
|
21377
21377
|
}
|
|
21378
|
-
function parseImfDate(
|
|
21379
|
-
if (
|
|
21378
|
+
function parseImfDate(date6) {
|
|
21379
|
+
if (date6.length !== 29 || date6[4] !== " " || date6[7] !== " " || date6[11] !== " " || date6[16] !== " " || date6[19] !== ":" || date6[22] !== ":" || date6[25] !== " " || date6[26] !== "G" || date6[27] !== "M" || date6[28] !== "T") {
|
|
21380
21380
|
return void 0;
|
|
21381
21381
|
}
|
|
21382
21382
|
let weekday = -1;
|
|
21383
|
-
if (
|
|
21383
|
+
if (date6[0] === "S" && date6[1] === "u" && date6[2] === "n") {
|
|
21384
21384
|
weekday = 0;
|
|
21385
|
-
} else if (
|
|
21385
|
+
} else if (date6[0] === "M" && date6[1] === "o" && date6[2] === "n") {
|
|
21386
21386
|
weekday = 1;
|
|
21387
|
-
} else if (
|
|
21387
|
+
} else if (date6[0] === "T" && date6[1] === "u" && date6[2] === "e") {
|
|
21388
21388
|
weekday = 2;
|
|
21389
|
-
} else if (
|
|
21389
|
+
} else if (date6[0] === "W" && date6[1] === "e" && date6[2] === "d") {
|
|
21390
21390
|
weekday = 3;
|
|
21391
|
-
} else if (
|
|
21391
|
+
} else if (date6[0] === "T" && date6[1] === "h" && date6[2] === "u") {
|
|
21392
21392
|
weekday = 4;
|
|
21393
|
-
} else if (
|
|
21393
|
+
} else if (date6[0] === "F" && date6[1] === "r" && date6[2] === "i") {
|
|
21394
21394
|
weekday = 5;
|
|
21395
|
-
} else if (
|
|
21395
|
+
} else if (date6[0] === "S" && date6[1] === "a" && date6[2] === "t") {
|
|
21396
21396
|
weekday = 6;
|
|
21397
21397
|
} else {
|
|
21398
21398
|
return void 0;
|
|
21399
21399
|
}
|
|
21400
21400
|
let day = 0;
|
|
21401
|
-
if (
|
|
21402
|
-
const code =
|
|
21401
|
+
if (date6[5] === "0") {
|
|
21402
|
+
const code = date6.charCodeAt(6);
|
|
21403
21403
|
if (code < 49 || code > 57) {
|
|
21404
21404
|
return void 0;
|
|
21405
21405
|
}
|
|
21406
21406
|
day = code - 48;
|
|
21407
21407
|
} else {
|
|
21408
|
-
const code1 =
|
|
21408
|
+
const code1 = date6.charCodeAt(5);
|
|
21409
21409
|
if (code1 < 49 || code1 > 51) {
|
|
21410
21410
|
return void 0;
|
|
21411
21411
|
}
|
|
21412
|
-
const code2 =
|
|
21412
|
+
const code2 = date6.charCodeAt(6);
|
|
21413
21413
|
if (code2 < 48 || code2 > 57) {
|
|
21414
21414
|
return void 0;
|
|
21415
21415
|
}
|
|
21416
21416
|
day = (code1 - 48) * 10 + (code2 - 48);
|
|
21417
21417
|
}
|
|
21418
21418
|
let monthIdx = -1;
|
|
21419
|
-
if (
|
|
21419
|
+
if (date6[8] === "J" && date6[9] === "a" && date6[10] === "n") {
|
|
21420
21420
|
monthIdx = 0;
|
|
21421
|
-
} else if (
|
|
21421
|
+
} else if (date6[8] === "F" && date6[9] === "e" && date6[10] === "b") {
|
|
21422
21422
|
monthIdx = 1;
|
|
21423
|
-
} else if (
|
|
21424
|
-
if (
|
|
21423
|
+
} else if (date6[8] === "M" && date6[9] === "a") {
|
|
21424
|
+
if (date6[10] === "r") {
|
|
21425
21425
|
monthIdx = 2;
|
|
21426
|
-
} else if (
|
|
21426
|
+
} else if (date6[10] === "y") {
|
|
21427
21427
|
monthIdx = 4;
|
|
21428
21428
|
} else {
|
|
21429
21429
|
return void 0;
|
|
21430
21430
|
}
|
|
21431
|
-
} else if (
|
|
21432
|
-
if (
|
|
21431
|
+
} else if (date6[8] === "J") {
|
|
21432
|
+
if (date6[9] === "a" && date6[10] === "n") {
|
|
21433
21433
|
monthIdx = 0;
|
|
21434
|
-
} else if (
|
|
21435
|
-
if (
|
|
21434
|
+
} else if (date6[9] === "u") {
|
|
21435
|
+
if (date6[10] === "n") {
|
|
21436
21436
|
monthIdx = 5;
|
|
21437
|
-
} else if (
|
|
21437
|
+
} else if (date6[10] === "l") {
|
|
21438
21438
|
monthIdx = 6;
|
|
21439
21439
|
} else {
|
|
21440
21440
|
return void 0;
|
|
@@ -21442,55 +21442,55 @@ var require_date = __commonJS({
|
|
|
21442
21442
|
} else {
|
|
21443
21443
|
return void 0;
|
|
21444
21444
|
}
|
|
21445
|
-
} else if (
|
|
21446
|
-
if (
|
|
21445
|
+
} else if (date6[8] === "A") {
|
|
21446
|
+
if (date6[9] === "p" && date6[10] === "r") {
|
|
21447
21447
|
monthIdx = 3;
|
|
21448
|
-
} else if (
|
|
21448
|
+
} else if (date6[9] === "u" && date6[10] === "g") {
|
|
21449
21449
|
monthIdx = 7;
|
|
21450
21450
|
} else {
|
|
21451
21451
|
return void 0;
|
|
21452
21452
|
}
|
|
21453
|
-
} else if (
|
|
21453
|
+
} else if (date6[8] === "S" && date6[9] === "e" && date6[10] === "p") {
|
|
21454
21454
|
monthIdx = 8;
|
|
21455
|
-
} else if (
|
|
21455
|
+
} else if (date6[8] === "O" && date6[9] === "c" && date6[10] === "t") {
|
|
21456
21456
|
monthIdx = 9;
|
|
21457
|
-
} else if (
|
|
21457
|
+
} else if (date6[8] === "N" && date6[9] === "o" && date6[10] === "v") {
|
|
21458
21458
|
monthIdx = 10;
|
|
21459
|
-
} else if (
|
|
21459
|
+
} else if (date6[8] === "D" && date6[9] === "e" && date6[10] === "c") {
|
|
21460
21460
|
monthIdx = 11;
|
|
21461
21461
|
} else {
|
|
21462
21462
|
return void 0;
|
|
21463
21463
|
}
|
|
21464
|
-
const yearDigit1 =
|
|
21464
|
+
const yearDigit1 = date6.charCodeAt(12);
|
|
21465
21465
|
if (yearDigit1 < 48 || yearDigit1 > 57) {
|
|
21466
21466
|
return void 0;
|
|
21467
21467
|
}
|
|
21468
|
-
const yearDigit2 =
|
|
21468
|
+
const yearDigit2 = date6.charCodeAt(13);
|
|
21469
21469
|
if (yearDigit2 < 48 || yearDigit2 > 57) {
|
|
21470
21470
|
return void 0;
|
|
21471
21471
|
}
|
|
21472
|
-
const yearDigit3 =
|
|
21472
|
+
const yearDigit3 = date6.charCodeAt(14);
|
|
21473
21473
|
if (yearDigit3 < 48 || yearDigit3 > 57) {
|
|
21474
21474
|
return void 0;
|
|
21475
21475
|
}
|
|
21476
|
-
const yearDigit4 =
|
|
21476
|
+
const yearDigit4 = date6.charCodeAt(15);
|
|
21477
21477
|
if (yearDigit4 < 48 || yearDigit4 > 57) {
|
|
21478
21478
|
return void 0;
|
|
21479
21479
|
}
|
|
21480
21480
|
const year = (yearDigit1 - 48) * 1e3 + (yearDigit2 - 48) * 100 + (yearDigit3 - 48) * 10 + (yearDigit4 - 48);
|
|
21481
21481
|
let hour = 0;
|
|
21482
|
-
if (
|
|
21483
|
-
const code =
|
|
21482
|
+
if (date6[17] === "0") {
|
|
21483
|
+
const code = date6.charCodeAt(18);
|
|
21484
21484
|
if (code < 48 || code > 57) {
|
|
21485
21485
|
return void 0;
|
|
21486
21486
|
}
|
|
21487
21487
|
hour = code - 48;
|
|
21488
21488
|
} else {
|
|
21489
|
-
const code1 =
|
|
21489
|
+
const code1 = date6.charCodeAt(17);
|
|
21490
21490
|
if (code1 < 48 || code1 > 50) {
|
|
21491
21491
|
return void 0;
|
|
21492
21492
|
}
|
|
21493
|
-
const code2 =
|
|
21493
|
+
const code2 = date6.charCodeAt(18);
|
|
21494
21494
|
if (code2 < 48 || code2 > 57) {
|
|
21495
21495
|
return void 0;
|
|
21496
21496
|
}
|
|
@@ -21500,36 +21500,36 @@ var require_date = __commonJS({
|
|
|
21500
21500
|
hour = (code1 - 48) * 10 + (code2 - 48);
|
|
21501
21501
|
}
|
|
21502
21502
|
let minute = 0;
|
|
21503
|
-
if (
|
|
21504
|
-
const code =
|
|
21503
|
+
if (date6[20] === "0") {
|
|
21504
|
+
const code = date6.charCodeAt(21);
|
|
21505
21505
|
if (code < 48 || code > 57) {
|
|
21506
21506
|
return void 0;
|
|
21507
21507
|
}
|
|
21508
21508
|
minute = code - 48;
|
|
21509
21509
|
} else {
|
|
21510
|
-
const code1 =
|
|
21510
|
+
const code1 = date6.charCodeAt(20);
|
|
21511
21511
|
if (code1 < 48 || code1 > 53) {
|
|
21512
21512
|
return void 0;
|
|
21513
21513
|
}
|
|
21514
|
-
const code2 =
|
|
21514
|
+
const code2 = date6.charCodeAt(21);
|
|
21515
21515
|
if (code2 < 48 || code2 > 57) {
|
|
21516
21516
|
return void 0;
|
|
21517
21517
|
}
|
|
21518
21518
|
minute = (code1 - 48) * 10 + (code2 - 48);
|
|
21519
21519
|
}
|
|
21520
21520
|
let second = 0;
|
|
21521
|
-
if (
|
|
21522
|
-
const code =
|
|
21521
|
+
if (date6[23] === "0") {
|
|
21522
|
+
const code = date6.charCodeAt(24);
|
|
21523
21523
|
if (code < 48 || code > 57) {
|
|
21524
21524
|
return void 0;
|
|
21525
21525
|
}
|
|
21526
21526
|
second = code - 48;
|
|
21527
21527
|
} else {
|
|
21528
|
-
const code1 =
|
|
21528
|
+
const code1 = date6.charCodeAt(23);
|
|
21529
21529
|
if (code1 < 48 || code1 > 53) {
|
|
21530
21530
|
return void 0;
|
|
21531
21531
|
}
|
|
21532
|
-
const code2 =
|
|
21532
|
+
const code2 = date6.charCodeAt(24);
|
|
21533
21533
|
if (code2 < 48 || code2 > 57) {
|
|
21534
21534
|
return void 0;
|
|
21535
21535
|
}
|
|
@@ -21537,48 +21537,48 @@ var require_date = __commonJS({
|
|
|
21537
21537
|
}
|
|
21538
21538
|
return makeDate(year, monthIdx, day, hour, minute, second, weekday);
|
|
21539
21539
|
}
|
|
21540
|
-
function parseAscTimeDate(
|
|
21541
|
-
if (
|
|
21540
|
+
function parseAscTimeDate(date6) {
|
|
21541
|
+
if (date6.length !== 24 || date6[7] !== " " || date6[10] !== " " || date6[19] !== " ") {
|
|
21542
21542
|
return void 0;
|
|
21543
21543
|
}
|
|
21544
21544
|
let weekday = -1;
|
|
21545
|
-
if (
|
|
21545
|
+
if (date6[0] === "S" && date6[1] === "u" && date6[2] === "n") {
|
|
21546
21546
|
weekday = 0;
|
|
21547
|
-
} else if (
|
|
21547
|
+
} else if (date6[0] === "M" && date6[1] === "o" && date6[2] === "n") {
|
|
21548
21548
|
weekday = 1;
|
|
21549
|
-
} else if (
|
|
21549
|
+
} else if (date6[0] === "T" && date6[1] === "u" && date6[2] === "e") {
|
|
21550
21550
|
weekday = 2;
|
|
21551
|
-
} else if (
|
|
21551
|
+
} else if (date6[0] === "W" && date6[1] === "e" && date6[2] === "d") {
|
|
21552
21552
|
weekday = 3;
|
|
21553
|
-
} else if (
|
|
21553
|
+
} else if (date6[0] === "T" && date6[1] === "h" && date6[2] === "u") {
|
|
21554
21554
|
weekday = 4;
|
|
21555
|
-
} else if (
|
|
21555
|
+
} else if (date6[0] === "F" && date6[1] === "r" && date6[2] === "i") {
|
|
21556
21556
|
weekday = 5;
|
|
21557
|
-
} else if (
|
|
21557
|
+
} else if (date6[0] === "S" && date6[1] === "a" && date6[2] === "t") {
|
|
21558
21558
|
weekday = 6;
|
|
21559
21559
|
} else {
|
|
21560
21560
|
return void 0;
|
|
21561
21561
|
}
|
|
21562
21562
|
let monthIdx = -1;
|
|
21563
|
-
if (
|
|
21563
|
+
if (date6[4] === "J" && date6[5] === "a" && date6[6] === "n") {
|
|
21564
21564
|
monthIdx = 0;
|
|
21565
|
-
} else if (
|
|
21565
|
+
} else if (date6[4] === "F" && date6[5] === "e" && date6[6] === "b") {
|
|
21566
21566
|
monthIdx = 1;
|
|
21567
|
-
} else if (
|
|
21568
|
-
if (
|
|
21567
|
+
} else if (date6[4] === "M" && date6[5] === "a") {
|
|
21568
|
+
if (date6[6] === "r") {
|
|
21569
21569
|
monthIdx = 2;
|
|
21570
|
-
} else if (
|
|
21570
|
+
} else if (date6[6] === "y") {
|
|
21571
21571
|
monthIdx = 4;
|
|
21572
21572
|
} else {
|
|
21573
21573
|
return void 0;
|
|
21574
21574
|
}
|
|
21575
|
-
} else if (
|
|
21576
|
-
if (
|
|
21575
|
+
} else if (date6[4] === "J") {
|
|
21576
|
+
if (date6[5] === "a" && date6[6] === "n") {
|
|
21577
21577
|
monthIdx = 0;
|
|
21578
|
-
} else if (
|
|
21579
|
-
if (
|
|
21578
|
+
} else if (date6[5] === "u") {
|
|
21579
|
+
if (date6[6] === "n") {
|
|
21580
21580
|
monthIdx = 5;
|
|
21581
|
-
} else if (
|
|
21581
|
+
} else if (date6[6] === "l") {
|
|
21582
21582
|
monthIdx = 6;
|
|
21583
21583
|
} else {
|
|
21584
21584
|
return void 0;
|
|
@@ -21586,56 +21586,56 @@ var require_date = __commonJS({
|
|
|
21586
21586
|
} else {
|
|
21587
21587
|
return void 0;
|
|
21588
21588
|
}
|
|
21589
|
-
} else if (
|
|
21590
|
-
if (
|
|
21589
|
+
} else if (date6[4] === "A") {
|
|
21590
|
+
if (date6[5] === "p" && date6[6] === "r") {
|
|
21591
21591
|
monthIdx = 3;
|
|
21592
|
-
} else if (
|
|
21592
|
+
} else if (date6[5] === "u" && date6[6] === "g") {
|
|
21593
21593
|
monthIdx = 7;
|
|
21594
21594
|
} else {
|
|
21595
21595
|
return void 0;
|
|
21596
21596
|
}
|
|
21597
|
-
} else if (
|
|
21597
|
+
} else if (date6[4] === "S" && date6[5] === "e" && date6[6] === "p") {
|
|
21598
21598
|
monthIdx = 8;
|
|
21599
|
-
} else if (
|
|
21599
|
+
} else if (date6[4] === "O" && date6[5] === "c" && date6[6] === "t") {
|
|
21600
21600
|
monthIdx = 9;
|
|
21601
|
-
} else if (
|
|
21601
|
+
} else if (date6[4] === "N" && date6[5] === "o" && date6[6] === "v") {
|
|
21602
21602
|
monthIdx = 10;
|
|
21603
|
-
} else if (
|
|
21603
|
+
} else if (date6[4] === "D" && date6[5] === "e" && date6[6] === "c") {
|
|
21604
21604
|
monthIdx = 11;
|
|
21605
21605
|
} else {
|
|
21606
21606
|
return void 0;
|
|
21607
21607
|
}
|
|
21608
21608
|
let day = 0;
|
|
21609
|
-
if (
|
|
21610
|
-
const code =
|
|
21609
|
+
if (date6[8] === " ") {
|
|
21610
|
+
const code = date6.charCodeAt(9);
|
|
21611
21611
|
if (code < 49 || code > 57) {
|
|
21612
21612
|
return void 0;
|
|
21613
21613
|
}
|
|
21614
21614
|
day = code - 48;
|
|
21615
21615
|
} else {
|
|
21616
|
-
const code1 =
|
|
21616
|
+
const code1 = date6.charCodeAt(8);
|
|
21617
21617
|
if (code1 < 49 || code1 > 51) {
|
|
21618
21618
|
return void 0;
|
|
21619
21619
|
}
|
|
21620
|
-
const code2 =
|
|
21620
|
+
const code2 = date6.charCodeAt(9);
|
|
21621
21621
|
if (code2 < 48 || code2 > 57) {
|
|
21622
21622
|
return void 0;
|
|
21623
21623
|
}
|
|
21624
21624
|
day = (code1 - 48) * 10 + (code2 - 48);
|
|
21625
21625
|
}
|
|
21626
21626
|
let hour = 0;
|
|
21627
|
-
if (
|
|
21628
|
-
const code =
|
|
21627
|
+
if (date6[11] === "0") {
|
|
21628
|
+
const code = date6.charCodeAt(12);
|
|
21629
21629
|
if (code < 48 || code > 57) {
|
|
21630
21630
|
return void 0;
|
|
21631
21631
|
}
|
|
21632
21632
|
hour = code - 48;
|
|
21633
21633
|
} else {
|
|
21634
|
-
const code1 =
|
|
21634
|
+
const code1 = date6.charCodeAt(11);
|
|
21635
21635
|
if (code1 < 48 || code1 > 50) {
|
|
21636
21636
|
return void 0;
|
|
21637
21637
|
}
|
|
21638
|
-
const code2 =
|
|
21638
|
+
const code2 = date6.charCodeAt(12);
|
|
21639
21639
|
if (code2 < 48 || code2 > 57) {
|
|
21640
21640
|
return void 0;
|
|
21641
21641
|
}
|
|
@@ -21645,163 +21645,163 @@ var require_date = __commonJS({
|
|
|
21645
21645
|
hour = (code1 - 48) * 10 + (code2 - 48);
|
|
21646
21646
|
}
|
|
21647
21647
|
let minute = 0;
|
|
21648
|
-
if (
|
|
21649
|
-
const code =
|
|
21648
|
+
if (date6[14] === "0") {
|
|
21649
|
+
const code = date6.charCodeAt(15);
|
|
21650
21650
|
if (code < 48 || code > 57) {
|
|
21651
21651
|
return void 0;
|
|
21652
21652
|
}
|
|
21653
21653
|
minute = code - 48;
|
|
21654
21654
|
} else {
|
|
21655
|
-
const code1 =
|
|
21655
|
+
const code1 = date6.charCodeAt(14);
|
|
21656
21656
|
if (code1 < 48 || code1 > 53) {
|
|
21657
21657
|
return void 0;
|
|
21658
21658
|
}
|
|
21659
|
-
const code2 =
|
|
21659
|
+
const code2 = date6.charCodeAt(15);
|
|
21660
21660
|
if (code2 < 48 || code2 > 57) {
|
|
21661
21661
|
return void 0;
|
|
21662
21662
|
}
|
|
21663
21663
|
minute = (code1 - 48) * 10 + (code2 - 48);
|
|
21664
21664
|
}
|
|
21665
21665
|
let second = 0;
|
|
21666
|
-
if (
|
|
21667
|
-
const code =
|
|
21666
|
+
if (date6[17] === "0") {
|
|
21667
|
+
const code = date6.charCodeAt(18);
|
|
21668
21668
|
if (code < 48 || code > 57) {
|
|
21669
21669
|
return void 0;
|
|
21670
21670
|
}
|
|
21671
21671
|
second = code - 48;
|
|
21672
21672
|
} else {
|
|
21673
|
-
const code1 =
|
|
21673
|
+
const code1 = date6.charCodeAt(17);
|
|
21674
21674
|
if (code1 < 48 || code1 > 53) {
|
|
21675
21675
|
return void 0;
|
|
21676
21676
|
}
|
|
21677
|
-
const code2 =
|
|
21677
|
+
const code2 = date6.charCodeAt(18);
|
|
21678
21678
|
if (code2 < 48 || code2 > 57) {
|
|
21679
21679
|
return void 0;
|
|
21680
21680
|
}
|
|
21681
21681
|
second = (code1 - 48) * 10 + (code2 - 48);
|
|
21682
21682
|
}
|
|
21683
|
-
const yearDigit1 =
|
|
21683
|
+
const yearDigit1 = date6.charCodeAt(20);
|
|
21684
21684
|
if (yearDigit1 < 48 || yearDigit1 > 57) {
|
|
21685
21685
|
return void 0;
|
|
21686
21686
|
}
|
|
21687
|
-
const yearDigit2 =
|
|
21687
|
+
const yearDigit2 = date6.charCodeAt(21);
|
|
21688
21688
|
if (yearDigit2 < 48 || yearDigit2 > 57) {
|
|
21689
21689
|
return void 0;
|
|
21690
21690
|
}
|
|
21691
|
-
const yearDigit3 =
|
|
21691
|
+
const yearDigit3 = date6.charCodeAt(22);
|
|
21692
21692
|
if (yearDigit3 < 48 || yearDigit3 > 57) {
|
|
21693
21693
|
return void 0;
|
|
21694
21694
|
}
|
|
21695
|
-
const yearDigit4 =
|
|
21695
|
+
const yearDigit4 = date6.charCodeAt(23);
|
|
21696
21696
|
if (yearDigit4 < 48 || yearDigit4 > 57) {
|
|
21697
21697
|
return void 0;
|
|
21698
21698
|
}
|
|
21699
21699
|
const year = (yearDigit1 - 48) * 1e3 + (yearDigit2 - 48) * 100 + (yearDigit3 - 48) * 10 + (yearDigit4 - 48);
|
|
21700
21700
|
return makeDate(year, monthIdx, day, hour, minute, second, weekday);
|
|
21701
21701
|
}
|
|
21702
|
-
function parseRfc850Date(
|
|
21702
|
+
function parseRfc850Date(date6) {
|
|
21703
21703
|
let commaIndex = -1;
|
|
21704
21704
|
let weekday = -1;
|
|
21705
|
-
if (
|
|
21706
|
-
if (
|
|
21705
|
+
if (date6[0] === "S") {
|
|
21706
|
+
if (date6[1] === "u" && date6[2] === "n" && date6[3] === "d" && date6[4] === "a" && date6[5] === "y") {
|
|
21707
21707
|
weekday = 0;
|
|
21708
21708
|
commaIndex = 6;
|
|
21709
|
-
} else if (
|
|
21709
|
+
} else if (date6[1] === "a" && date6[2] === "t" && date6[3] === "u" && date6[4] === "r" && date6[5] === "d" && date6[6] === "a" && date6[7] === "y") {
|
|
21710
21710
|
weekday = 6;
|
|
21711
21711
|
commaIndex = 8;
|
|
21712
21712
|
}
|
|
21713
|
-
} else if (
|
|
21713
|
+
} else if (date6[0] === "M" && date6[1] === "o" && date6[2] === "n" && date6[3] === "d" && date6[4] === "a" && date6[5] === "y") {
|
|
21714
21714
|
weekday = 1;
|
|
21715
21715
|
commaIndex = 6;
|
|
21716
|
-
} else if (
|
|
21717
|
-
if (
|
|
21716
|
+
} else if (date6[0] === "T") {
|
|
21717
|
+
if (date6[1] === "u" && date6[2] === "e" && date6[3] === "s" && date6[4] === "d" && date6[5] === "a" && date6[6] === "y") {
|
|
21718
21718
|
weekday = 2;
|
|
21719
21719
|
commaIndex = 7;
|
|
21720
|
-
} else if (
|
|
21720
|
+
} else if (date6[1] === "h" && date6[2] === "u" && date6[3] === "r" && date6[4] === "s" && date6[5] === "d" && date6[6] === "a" && date6[7] === "y") {
|
|
21721
21721
|
weekday = 4;
|
|
21722
21722
|
commaIndex = 8;
|
|
21723
21723
|
}
|
|
21724
|
-
} else if (
|
|
21724
|
+
} else if (date6[0] === "W" && date6[1] === "e" && date6[2] === "d" && date6[3] === "n" && date6[4] === "e" && date6[5] === "s" && date6[6] === "d" && date6[7] === "a" && date6[8] === "y") {
|
|
21725
21725
|
weekday = 3;
|
|
21726
21726
|
commaIndex = 9;
|
|
21727
|
-
} else if (
|
|
21727
|
+
} else if (date6[0] === "F" && date6[1] === "r" && date6[2] === "i" && date6[3] === "d" && date6[4] === "a" && date6[5] === "y") {
|
|
21728
21728
|
weekday = 5;
|
|
21729
21729
|
commaIndex = 6;
|
|
21730
21730
|
} else {
|
|
21731
21731
|
return void 0;
|
|
21732
21732
|
}
|
|
21733
|
-
if (
|
|
21733
|
+
if (date6[commaIndex] !== "," || date6.length - commaIndex - 1 !== 23 || date6[commaIndex + 1] !== " " || date6[commaIndex + 4] !== "-" || date6[commaIndex + 8] !== "-" || date6[commaIndex + 11] !== " " || date6[commaIndex + 14] !== ":" || date6[commaIndex + 17] !== ":" || date6[commaIndex + 20] !== " " || date6[commaIndex + 21] !== "G" || date6[commaIndex + 22] !== "M" || date6[commaIndex + 23] !== "T") {
|
|
21734
21734
|
return void 0;
|
|
21735
21735
|
}
|
|
21736
21736
|
let day = 0;
|
|
21737
|
-
if (
|
|
21738
|
-
const code =
|
|
21737
|
+
if (date6[commaIndex + 2] === "0") {
|
|
21738
|
+
const code = date6.charCodeAt(commaIndex + 3);
|
|
21739
21739
|
if (code < 49 || code > 57) {
|
|
21740
21740
|
return void 0;
|
|
21741
21741
|
}
|
|
21742
21742
|
day = code - 48;
|
|
21743
21743
|
} else {
|
|
21744
|
-
const code1 =
|
|
21744
|
+
const code1 = date6.charCodeAt(commaIndex + 2);
|
|
21745
21745
|
if (code1 < 49 || code1 > 51) {
|
|
21746
21746
|
return void 0;
|
|
21747
21747
|
}
|
|
21748
|
-
const code2 =
|
|
21748
|
+
const code2 = date6.charCodeAt(commaIndex + 3);
|
|
21749
21749
|
if (code2 < 48 || code2 > 57) {
|
|
21750
21750
|
return void 0;
|
|
21751
21751
|
}
|
|
21752
21752
|
day = (code1 - 48) * 10 + (code2 - 48);
|
|
21753
21753
|
}
|
|
21754
21754
|
let monthIdx = -1;
|
|
21755
|
-
if (
|
|
21755
|
+
if (date6[commaIndex + 5] === "J" && date6[commaIndex + 6] === "a" && date6[commaIndex + 7] === "n") {
|
|
21756
21756
|
monthIdx = 0;
|
|
21757
|
-
} else if (
|
|
21757
|
+
} else if (date6[commaIndex + 5] === "F" && date6[commaIndex + 6] === "e" && date6[commaIndex + 7] === "b") {
|
|
21758
21758
|
monthIdx = 1;
|
|
21759
|
-
} else if (
|
|
21759
|
+
} else if (date6[commaIndex + 5] === "M" && date6[commaIndex + 6] === "a" && date6[commaIndex + 7] === "r") {
|
|
21760
21760
|
monthIdx = 2;
|
|
21761
|
-
} else if (
|
|
21761
|
+
} else if (date6[commaIndex + 5] === "A" && date6[commaIndex + 6] === "p" && date6[commaIndex + 7] === "r") {
|
|
21762
21762
|
monthIdx = 3;
|
|
21763
|
-
} else if (
|
|
21763
|
+
} else if (date6[commaIndex + 5] === "M" && date6[commaIndex + 6] === "a" && date6[commaIndex + 7] === "y") {
|
|
21764
21764
|
monthIdx = 4;
|
|
21765
|
-
} else if (
|
|
21765
|
+
} else if (date6[commaIndex + 5] === "J" && date6[commaIndex + 6] === "u" && date6[commaIndex + 7] === "n") {
|
|
21766
21766
|
monthIdx = 5;
|
|
21767
|
-
} else if (
|
|
21767
|
+
} else if (date6[commaIndex + 5] === "J" && date6[commaIndex + 6] === "u" && date6[commaIndex + 7] === "l") {
|
|
21768
21768
|
monthIdx = 6;
|
|
21769
|
-
} else if (
|
|
21769
|
+
} else if (date6[commaIndex + 5] === "A" && date6[commaIndex + 6] === "u" && date6[commaIndex + 7] === "g") {
|
|
21770
21770
|
monthIdx = 7;
|
|
21771
|
-
} else if (
|
|
21771
|
+
} else if (date6[commaIndex + 5] === "S" && date6[commaIndex + 6] === "e" && date6[commaIndex + 7] === "p") {
|
|
21772
21772
|
monthIdx = 8;
|
|
21773
|
-
} else if (
|
|
21773
|
+
} else if (date6[commaIndex + 5] === "O" && date6[commaIndex + 6] === "c" && date6[commaIndex + 7] === "t") {
|
|
21774
21774
|
monthIdx = 9;
|
|
21775
|
-
} else if (
|
|
21775
|
+
} else if (date6[commaIndex + 5] === "N" && date6[commaIndex + 6] === "o" && date6[commaIndex + 7] === "v") {
|
|
21776
21776
|
monthIdx = 10;
|
|
21777
|
-
} else if (
|
|
21777
|
+
} else if (date6[commaIndex + 5] === "D" && date6[commaIndex + 6] === "e" && date6[commaIndex + 7] === "c") {
|
|
21778
21778
|
monthIdx = 11;
|
|
21779
21779
|
} else {
|
|
21780
21780
|
return void 0;
|
|
21781
21781
|
}
|
|
21782
|
-
const yearDigit1 =
|
|
21782
|
+
const yearDigit1 = date6.charCodeAt(commaIndex + 9);
|
|
21783
21783
|
if (yearDigit1 < 48 || yearDigit1 > 57) {
|
|
21784
21784
|
return void 0;
|
|
21785
21785
|
}
|
|
21786
|
-
const yearDigit2 =
|
|
21786
|
+
const yearDigit2 = date6.charCodeAt(commaIndex + 10);
|
|
21787
21787
|
if (yearDigit2 < 48 || yearDigit2 > 57) {
|
|
21788
21788
|
return void 0;
|
|
21789
21789
|
}
|
|
21790
21790
|
let year = (yearDigit1 - 48) * 10 + (yearDigit2 - 48);
|
|
21791
21791
|
year += year < 70 ? 2e3 : 1900;
|
|
21792
21792
|
let hour = 0;
|
|
21793
|
-
if (
|
|
21794
|
-
const code =
|
|
21793
|
+
if (date6[commaIndex + 12] === "0") {
|
|
21794
|
+
const code = date6.charCodeAt(commaIndex + 13);
|
|
21795
21795
|
if (code < 48 || code > 57) {
|
|
21796
21796
|
return void 0;
|
|
21797
21797
|
}
|
|
21798
21798
|
hour = code - 48;
|
|
21799
21799
|
} else {
|
|
21800
|
-
const code1 =
|
|
21800
|
+
const code1 = date6.charCodeAt(commaIndex + 12);
|
|
21801
21801
|
if (code1 < 48 || code1 > 50) {
|
|
21802
21802
|
return void 0;
|
|
21803
21803
|
}
|
|
21804
|
-
const code2 =
|
|
21804
|
+
const code2 = date6.charCodeAt(commaIndex + 13);
|
|
21805
21805
|
if (code2 < 48 || code2 > 57) {
|
|
21806
21806
|
return void 0;
|
|
21807
21807
|
}
|
|
@@ -21811,36 +21811,36 @@ var require_date = __commonJS({
|
|
|
21811
21811
|
hour = (code1 - 48) * 10 + (code2 - 48);
|
|
21812
21812
|
}
|
|
21813
21813
|
let minute = 0;
|
|
21814
|
-
if (
|
|
21815
|
-
const code =
|
|
21814
|
+
if (date6[commaIndex + 15] === "0") {
|
|
21815
|
+
const code = date6.charCodeAt(commaIndex + 16);
|
|
21816
21816
|
if (code < 48 || code > 57) {
|
|
21817
21817
|
return void 0;
|
|
21818
21818
|
}
|
|
21819
21819
|
minute = code - 48;
|
|
21820
21820
|
} else {
|
|
21821
|
-
const code1 =
|
|
21821
|
+
const code1 = date6.charCodeAt(commaIndex + 15);
|
|
21822
21822
|
if (code1 < 48 || code1 > 53) {
|
|
21823
21823
|
return void 0;
|
|
21824
21824
|
}
|
|
21825
|
-
const code2 =
|
|
21825
|
+
const code2 = date6.charCodeAt(commaIndex + 16);
|
|
21826
21826
|
if (code2 < 48 || code2 > 57) {
|
|
21827
21827
|
return void 0;
|
|
21828
21828
|
}
|
|
21829
21829
|
minute = (code1 - 48) * 10 + (code2 - 48);
|
|
21830
21830
|
}
|
|
21831
21831
|
let second = 0;
|
|
21832
|
-
if (
|
|
21833
|
-
const code =
|
|
21832
|
+
if (date6[commaIndex + 18] === "0") {
|
|
21833
|
+
const code = date6.charCodeAt(commaIndex + 19);
|
|
21834
21834
|
if (code < 48 || code > 57) {
|
|
21835
21835
|
return void 0;
|
|
21836
21836
|
}
|
|
21837
21837
|
second = code - 48;
|
|
21838
21838
|
} else {
|
|
21839
|
-
const code1 =
|
|
21839
|
+
const code1 = date6.charCodeAt(commaIndex + 18);
|
|
21840
21840
|
if (code1 < 48 || code1 > 53) {
|
|
21841
21841
|
return void 0;
|
|
21842
21842
|
}
|
|
21843
|
-
const code2 =
|
|
21843
|
+
const code2 = date6.charCodeAt(commaIndex + 19);
|
|
21844
21844
|
if (code2 < 48 || code2 > 57) {
|
|
21845
21845
|
return void 0;
|
|
21846
21846
|
}
|
|
@@ -27657,7 +27657,7 @@ var require_fetch = __commonJS({
|
|
|
27657
27657
|
const hasTrailingQuestionMark = url3.search.length === 0 && url3.href[url3.href.length - url3.hash.length - 1] === "?";
|
|
27658
27658
|
return dispatchWithProtocolPreference(body2);
|
|
27659
27659
|
function dispatchWithProtocolPreference(body3, allowH2) {
|
|
27660
|
-
return new Promise((
|
|
27660
|
+
return new Promise((resolve19, reject) => agent.dispatch(
|
|
27661
27661
|
{
|
|
27662
27662
|
path: hasTrailingQuestionMark ? `${path2}?` : path2,
|
|
27663
27663
|
origin: url3.origin,
|
|
@@ -27744,7 +27744,7 @@ var require_fetch = __commonJS({
|
|
|
27744
27744
|
}
|
|
27745
27745
|
this.body = new Readable({ read: () => controller2.resume() });
|
|
27746
27746
|
const onError = (err) => this.onResponseError(controller2, err);
|
|
27747
|
-
|
|
27747
|
+
resolve19({
|
|
27748
27748
|
status: status2,
|
|
27749
27749
|
statusText,
|
|
27750
27750
|
headersList,
|
|
@@ -27777,7 +27777,7 @@ var require_fetch = __commonJS({
|
|
|
27777
27777
|
fetchParams.controller.off("terminated", this.abort);
|
|
27778
27778
|
}
|
|
27779
27779
|
if (request2.mode === "websocket" && allowH2 !== false && error62?.code === "UND_ERR_INFO" && error62?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
27780
|
-
|
|
27780
|
+
resolve19(dispatchWithProtocolPreference(body3, false));
|
|
27781
27781
|
return;
|
|
27782
27782
|
}
|
|
27783
27783
|
this.body?.destroy(error62);
|
|
@@ -27796,7 +27796,7 @@ var require_fetch = __commonJS({
|
|
|
27796
27796
|
const rawHeaders = controller2?.rawHeaders ?? [];
|
|
27797
27797
|
const headersList = new HeadersList();
|
|
27798
27798
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
27799
|
-
|
|
27799
|
+
resolve19({
|
|
27800
27800
|
status: status2,
|
|
27801
27801
|
statusText: STATUS_CODES[status2],
|
|
27802
27802
|
headersList,
|
|
@@ -28666,11 +28666,11 @@ var require_util4 = __commonJS({
|
|
|
28666
28666
|
"Dec"
|
|
28667
28667
|
];
|
|
28668
28668
|
var IMFPaddedNumbers = Array(61).fill(0).map((_, i) => i.toString().padStart(2, "0"));
|
|
28669
|
-
function toIMFDate(
|
|
28670
|
-
if (typeof
|
|
28671
|
-
|
|
28669
|
+
function toIMFDate(date6) {
|
|
28670
|
+
if (typeof date6 === "number") {
|
|
28671
|
+
date6 = new Date(date6);
|
|
28672
28672
|
}
|
|
28673
|
-
return `${IMFDays[
|
|
28673
|
+
return `${IMFDays[date6.getUTCDay()]}, ${IMFPaddedNumbers[date6.getUTCDate()]} ${IMFMonths[date6.getUTCMonth()]} ${date6.getUTCFullYear()} ${IMFPaddedNumbers[date6.getUTCHours()]}:${IMFPaddedNumbers[date6.getUTCMinutes()]}:${IMFPaddedNumbers[date6.getUTCSeconds()]} GMT`;
|
|
28674
28674
|
}
|
|
28675
28675
|
function validateCookieMaxAge(maxAge) {
|
|
28676
28676
|
if (maxAge < 0) {
|
|
@@ -37436,7 +37436,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
37436
37436
|
var NONE = 0;
|
|
37437
37437
|
var ASSUMED = 1;
|
|
37438
37438
|
var PROVEN = 2;
|
|
37439
|
-
function isRecursive(inst, stack,
|
|
37439
|
+
function isRecursive(inst, stack, resolve19) {
|
|
37440
37440
|
const cached2 = recursive.get(inst);
|
|
37441
37441
|
if (cached2 !== void 0)
|
|
37442
37442
|
return cached2 ? PROVEN : NONE;
|
|
@@ -37446,7 +37446,7 @@ function isRecursive(inst, stack, resolve18) {
|
|
|
37446
37446
|
let result2 = NONE;
|
|
37447
37447
|
const check2 = (child2) => {
|
|
37448
37448
|
if (result2 !== PROVEN && child2?._zod) {
|
|
37449
|
-
const answer = isRecursive(child2, stack,
|
|
37449
|
+
const answer = isRecursive(child2, stack, resolve19);
|
|
37450
37450
|
if (answer > result2)
|
|
37451
37451
|
result2 = answer;
|
|
37452
37452
|
}
|
|
@@ -37457,7 +37457,7 @@ function isRecursive(inst, stack, resolve18) {
|
|
|
37457
37457
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
37458
37458
|
if (spread && !desc.enumerable)
|
|
37459
37459
|
continue;
|
|
37460
|
-
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
37460
|
+
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve19) : NONE;
|
|
37461
37461
|
if (child2 > answer)
|
|
37462
37462
|
answer = child2;
|
|
37463
37463
|
}
|
|
@@ -37521,7 +37521,7 @@ function isRecursive(inst, stack, resolve18) {
|
|
|
37521
37521
|
break;
|
|
37522
37522
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
37523
37523
|
case "lazy": {
|
|
37524
|
-
const inner = def._cachedInner ?? (
|
|
37524
|
+
const inner = def._cachedInner ?? (resolve19 ? inst._zod.innerType : void 0);
|
|
37525
37525
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
37526
37526
|
break;
|
|
37527
37527
|
}
|
|
@@ -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
|
});
|
|
@@ -54577,6 +54579,16 @@ var AppError = class extends Error {
|
|
|
54577
54579
|
function asError(value2) {
|
|
54578
54580
|
return value2 instanceof Error ? value2 : new Error(String(value2));
|
|
54579
54581
|
}
|
|
54582
|
+
function errorMessage(value2) {
|
|
54583
|
+
const error62 = asError(value2);
|
|
54584
|
+
const cause = error62.cause;
|
|
54585
|
+
if (!(cause instanceof Error)) return error62.message;
|
|
54586
|
+
const first = cause.errors?.find((e) => e instanceof Error);
|
|
54587
|
+
let reason2 = cause.message || first?.message || "";
|
|
54588
|
+
if (cause.code && !reason2.includes(cause.code))
|
|
54589
|
+
reason2 = reason2 ? `${reason2} (${cause.code})` : cause.code;
|
|
54590
|
+
return reason2 && !error62.message.includes(reason2) ? `${error62.message}: ${reason2}` : error62.message;
|
|
54591
|
+
}
|
|
54580
54592
|
|
|
54581
54593
|
// src/client.ts
|
|
54582
54594
|
var defaultWorkspace;
|
|
@@ -54589,6 +54601,8 @@ var ServiceError = class extends Error {
|
|
|
54589
54601
|
exitCode;
|
|
54590
54602
|
fields;
|
|
54591
54603
|
requestId;
|
|
54604
|
+
/** Exact commands that move the agent forward, printed with the error. */
|
|
54605
|
+
next;
|
|
54592
54606
|
constructor(message, code = "SERVICE_ERROR", exitCode = 1) {
|
|
54593
54607
|
super(message);
|
|
54594
54608
|
this.code = code;
|
|
@@ -54668,7 +54682,7 @@ async function request(server, path2, {
|
|
|
54668
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}`;
|
|
54669
54683
|
const safe = [cookie, cookie?.split("=")[1], accessToken, ...secrets].filter(
|
|
54670
54684
|
(value2) => typeof value2 === "string" && value2.length > 0
|
|
54671
|
-
).reduce((
|
|
54685
|
+
).reduce((text5, secret) => text5.replaceAll(secret, "[redacted]"), message);
|
|
54672
54686
|
const failure3 = new ServiceError(
|
|
54673
54687
|
safe,
|
|
54674
54688
|
errorCode ?? (response.status === 401 ? "AUTH_REQUIRED" : response.status === 429 ? "RATE_LIMITED" : "SERVICE_ERROR"),
|
|
@@ -54678,7 +54692,7 @@ async function request(server, path2, {
|
|
|
54678
54692
|
const redacted = [cookie, cookie?.split("=")[1], accessToken, ...secrets].filter(
|
|
54679
54693
|
(value2) => typeof value2 === "string" && value2.length > 0
|
|
54680
54694
|
).reduce(
|
|
54681
|
-
(
|
|
54695
|
+
(text5, secret) => text5.replaceAll(secret, "[redacted]"),
|
|
54682
54696
|
JSON.stringify(detail.fields)
|
|
54683
54697
|
);
|
|
54684
54698
|
try {
|
|
@@ -54701,6 +54715,8 @@ var localRunMetadataSchema = external_exports.object({
|
|
|
54701
54715
|
provenance: external_exports.literal("local"),
|
|
54702
54716
|
runId: external_exports.uuid(),
|
|
54703
54717
|
status: external_exports.enum(["passed", "failed", "error"]),
|
|
54718
|
+
message: external_exports.string().max(8e3).optional(),
|
|
54719
|
+
code: external_exports.string().max(64).optional(),
|
|
54704
54720
|
files: external_exports.array(
|
|
54705
54721
|
external_exports.object({
|
|
54706
54722
|
path: external_exports.string().min(1).max(1024),
|
|
@@ -55474,6 +55490,14 @@ var runDiagnosisSchema = external_exports.object({
|
|
|
55474
55490
|
provenance: external_exports.enum(["hosted", "local"]),
|
|
55475
55491
|
runId: external_exports.uuid(),
|
|
55476
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(),
|
|
55477
55501
|
policy: external_exports.object({
|
|
55478
55502
|
availability: external_exports.enum(["available", "unavailable"]),
|
|
55479
55503
|
hash: hash2.nullable()
|
|
@@ -55688,6 +55712,125 @@ function scriptReproductionEligible(value2) {
|
|
|
55688
55712
|
// src/run-diagnosis.ts
|
|
55689
55713
|
init_limits();
|
|
55690
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
|
+
|
|
55691
55834
|
// src/manifest.ts
|
|
55692
55835
|
import { readFile, open as open4 } from "node:fs/promises";
|
|
55693
55836
|
import { dirname, resolve as resolve2 } from "node:path";
|
|
@@ -55830,10 +55973,22 @@ var visualExample = {
|
|
|
55830
55973
|
}
|
|
55831
55974
|
}
|
|
55832
55975
|
};
|
|
55833
|
-
async function writeText(path2,
|
|
55834
|
-
|
|
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
|
+
}
|
|
55835
55990
|
try {
|
|
55836
|
-
await file2.writeFile(
|
|
55991
|
+
await file2.writeFile(text5);
|
|
55837
55992
|
} finally {
|
|
55838
55993
|
await file2.close();
|
|
55839
55994
|
}
|
|
@@ -55842,11 +55997,11 @@ var writeJson = (path2, data) => writeText(path2, JSON.stringify(data, null, 2)
|
|
|
55842
55997
|
async function readManifest(path2, { enable = false } = {}) {
|
|
55843
55998
|
if (!path2) throw new Error("Provide --file PATH to a monitor JSON file.");
|
|
55844
55999
|
let value2;
|
|
55845
|
-
const
|
|
55846
|
-
if (Buffer.byteLength(
|
|
56000
|
+
const text5 = await readFile(path2, "utf8");
|
|
56001
|
+
if (Buffer.byteLength(text5) > 96e3)
|
|
55847
56002
|
throw new Error("Monitor configuration exceeds 96 KB.");
|
|
55848
56003
|
try {
|
|
55849
|
-
value2 = JSON.parse(
|
|
56004
|
+
value2 = JSON.parse(text5);
|
|
55850
56005
|
} catch {
|
|
55851
56006
|
throw new Error("Monitor configuration must be valid JSON.");
|
|
55852
56007
|
}
|
|
@@ -55987,7 +56142,8 @@ async function localRunDiagnosis(directory) {
|
|
|
55987
56142
|
artifact,
|
|
55988
56143
|
STORAGE_LIMITS.workBytes
|
|
55989
56144
|
);
|
|
55990
|
-
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")
|
|
55991
56147
|
verified.set(artifact.path, bytes2);
|
|
55992
56148
|
status2 = "available";
|
|
55993
56149
|
} catch (error62) {
|
|
@@ -56052,6 +56208,7 @@ async function localRunDiagnosis(directory) {
|
|
|
56052
56208
|
provenance: "local",
|
|
56053
56209
|
runId: recorded.runId,
|
|
56054
56210
|
runStatus: recorded.status,
|
|
56211
|
+
failure: localFailure(root, recorded, verified, definition),
|
|
56055
56212
|
policy: {
|
|
56056
56213
|
availability: policyHash ? "available" : "unavailable",
|
|
56057
56214
|
hash: policyHash
|
|
@@ -56083,6 +56240,32 @@ async function localRunDiagnosis(directory) {
|
|
|
56083
56240
|
}
|
|
56084
56241
|
});
|
|
56085
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
|
+
}
|
|
56086
56269
|
function formatRunDiagnosis(value2, agent) {
|
|
56087
56270
|
const report = parseRunDiagnosis(value2), scenarios = formatScenarioReport(report.scenarios).trimEnd().split("\n");
|
|
56088
56271
|
const lines = agent ? [
|
|
@@ -56090,6 +56273,14 @@ function formatRunDiagnosis(value2, agent) {
|
|
|
56090
56273
|
agent,
|
|
56091
56274
|
...scenarios.slice(1).filter((l) => !l.startsWith("No scenarios were recorded"))
|
|
56092
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
|
+
);
|
|
56093
56284
|
lines.push(`Verification policy: ${report.policy.hash ?? "unavailable"}`);
|
|
56094
56285
|
lines.push(
|
|
56095
56286
|
report.history.lastPassing ? `Last passing matching policy: ${report.history.lastPassing.runId}` : `Matching history: unavailable (${report.history.reason})`
|
|
@@ -56457,7 +56648,7 @@ async function readVerifiedJson(server, runId, expected, session, signal) {
|
|
|
56457
56648
|
}
|
|
56458
56649
|
|
|
56459
56650
|
// src/agent-report.ts
|
|
56460
|
-
var
|
|
56651
|
+
var text3 = (value2, max = 300) => typeof value2 === "string" ? value2.slice(0, max) : "";
|
|
56461
56652
|
var count = (value2) => typeof value2 === "number" && Number.isSafeInteger(value2) ? String(value2) : "unavailable";
|
|
56462
56653
|
function agentOutcome(outcome) {
|
|
56463
56654
|
if (outcome === "success") return "exited normally";
|
|
@@ -56475,13 +56666,13 @@ function formatAgentReport(summary2, gate, runStatus) {
|
|
|
56475
56666
|
(c) => Boolean(c) && typeof c.command === "string"
|
|
56476
56667
|
) : [];
|
|
56477
56668
|
const failed = commands2.filter((c) => c.failed === true);
|
|
56478
|
-
lines.push(` Agent: ${agentOutcome(
|
|
56669
|
+
lines.push(` Agent: ${agentOutcome(text3(summary2.outcome, 80))}`);
|
|
56479
56670
|
lines.push(
|
|
56480
56671
|
` Verifier: ${runStatus === "passed" ? "passed, the outcome is in the product" : runStatus === "failed" ? "failed, see the verifier's report" : runStatus}`
|
|
56481
56672
|
);
|
|
56482
|
-
lines.push(` Model: ${
|
|
56673
|
+
lines.push(` Model: ${text3(summary2.model, 120) || "unavailable"}`);
|
|
56483
56674
|
lines.push(
|
|
56484
|
-
` 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)}` : ""}`
|
|
56485
56676
|
);
|
|
56486
56677
|
const pages = Array.isArray(summary2.pages) ? summary2.pages.filter((p) => typeof p === "string").slice(0, 100) : [];
|
|
56487
56678
|
if (pages.length) {
|
|
@@ -56499,7 +56690,7 @@ function formatAgentReport(summary2, gate, runStatus) {
|
|
|
56499
56690
|
}
|
|
56500
56691
|
const denied = Array.isArray(gate?.denied) ? gate.denied.filter((d) => typeof d === "string").slice(0, 20) : [];
|
|
56501
56692
|
if (denied.length) lines.push(` Refused by the gateway: ${denied.join("; ")}`);
|
|
56502
|
-
const final =
|
|
56693
|
+
const final = text3(summary2.final, 2e3);
|
|
56503
56694
|
if (final) {
|
|
56504
56695
|
lines.push(" Final message (what the agent claims; the verifier decides):");
|
|
56505
56696
|
for (const line of final.split("\n")) lines.push(` ${line}`);
|
|
@@ -56560,8 +56751,8 @@ async function targetConfiguration(file2) {
|
|
|
56560
56751
|
await handle.close();
|
|
56561
56752
|
}
|
|
56562
56753
|
}
|
|
56563
|
-
function httpSecretInput(
|
|
56564
|
-
const value2 =
|
|
56754
|
+
function httpSecretInput(text5) {
|
|
56755
|
+
const value2 = text5.replace(/[\r\n]+$/, "");
|
|
56565
56756
|
if (!httpCredentialRotateSchema.shape.value.safeParse(value2).success)
|
|
56566
56757
|
throw new ServiceError(
|
|
56567
56758
|
"Use a single-line ASCII HTTP credential value of at most 4096 characters.",
|
|
@@ -57105,7 +57296,7 @@ function selectProductResponse(value2, pointers) {
|
|
|
57105
57296
|
return result2;
|
|
57106
57297
|
}
|
|
57107
57298
|
function abortRace(pending, signal) {
|
|
57108
|
-
return new Promise((
|
|
57299
|
+
return new Promise((resolve19, reject) => {
|
|
57109
57300
|
const abort = () => reject(failure2("PRODUCT_REQUEST_CANCELLED", 403));
|
|
57110
57301
|
if (signal.aborted) {
|
|
57111
57302
|
abort();
|
|
@@ -57114,7 +57305,7 @@ function abortRace(pending, signal) {
|
|
|
57114
57305
|
return;
|
|
57115
57306
|
}
|
|
57116
57307
|
signal.addEventListener("abort", abort, { once: true });
|
|
57117
|
-
pending.then(
|
|
57308
|
+
pending.then(resolve19, reject).finally(() => signal.removeEventListener("abort", abort)).catch(() => {
|
|
57118
57309
|
});
|
|
57119
57310
|
});
|
|
57120
57311
|
}
|
|
@@ -57477,11 +57668,11 @@ async function localProductRequestBroker(input2, options = {}) {
|
|
|
57477
57668
|
server.headersTimeout = 5e3;
|
|
57478
57669
|
server.requestTimeout = 1e4;
|
|
57479
57670
|
try {
|
|
57480
|
-
await new Promise((
|
|
57671
|
+
await new Promise((resolve19, reject) => {
|
|
57481
57672
|
server.once("error", reject);
|
|
57482
57673
|
server.listen(0, "127.0.0.1", () => {
|
|
57483
57674
|
server.removeListener("error", reject);
|
|
57484
|
-
|
|
57675
|
+
resolve19();
|
|
57485
57676
|
});
|
|
57486
57677
|
});
|
|
57487
57678
|
} catch (error62) {
|
|
@@ -57518,7 +57709,7 @@ async function localProductRequestBroker(input2, options = {}) {
|
|
|
57518
57709
|
closed = true;
|
|
57519
57710
|
stop.abort();
|
|
57520
57711
|
const done = new Promise(
|
|
57521
|
-
(
|
|
57712
|
+
(resolve19, reject) => server.close((e) => e ? reject(e) : resolve19())
|
|
57522
57713
|
);
|
|
57523
57714
|
server.closeAllConnections();
|
|
57524
57715
|
await Promise.allSettled([...pending]);
|
|
@@ -57590,12 +57781,12 @@ import { performance as performance7 } from "node:perf_hooks";
|
|
|
57590
57781
|
import {
|
|
57591
57782
|
mkdir as mkdir4,
|
|
57592
57783
|
lstat as lstat7,
|
|
57593
|
-
readFile as
|
|
57784
|
+
readFile as readFile5,
|
|
57594
57785
|
realpath,
|
|
57595
|
-
readdir,
|
|
57596
|
-
writeFile as
|
|
57786
|
+
readdir as readdir2,
|
|
57787
|
+
writeFile as writeFile5
|
|
57597
57788
|
} from "node:fs/promises";
|
|
57598
|
-
import { dirname as
|
|
57789
|
+
import { dirname as dirname9, join as join9, relative, resolve as resolve11, sep as sep2 } from "node:path";
|
|
57599
57790
|
|
|
57600
57791
|
// ../../src/checks/http-auth.ts
|
|
57601
57792
|
function httpCredentialHeaders(monitor, input2) {
|
|
@@ -57756,7 +57947,7 @@ HTTP ${response.status}
|
|
|
57756
57947
|
Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
57757
57948
|
};
|
|
57758
57949
|
}
|
|
57759
|
-
let
|
|
57950
|
+
let text5 = "", bytes2 = 0;
|
|
57760
57951
|
if (response.body) {
|
|
57761
57952
|
const reader = response.body.getReader();
|
|
57762
57953
|
const decoder = new TextDecoder();
|
|
@@ -57767,9 +57958,9 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57767
57958
|
bytes2 += value2.byteLength;
|
|
57768
57959
|
if (bytes2 > 256e3)
|
|
57769
57960
|
throw new Error("Response exceeds the 256 KB check limit");
|
|
57770
|
-
|
|
57961
|
+
text5 += decoder.decode(value2, { stream: true });
|
|
57771
57962
|
}
|
|
57772
|
-
|
|
57963
|
+
text5 += decoder.decode();
|
|
57773
57964
|
} finally {
|
|
57774
57965
|
await reader.cancel().catch(() => {
|
|
57775
57966
|
});
|
|
@@ -57782,9 +57973,9 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57782
57973
|
bytes: bytes2,
|
|
57783
57974
|
excerpt: omitted ? null : hidden.reduce(
|
|
57784
57975
|
(value2, secret) => value2.replaceAll(secret, "[redacted]"),
|
|
57785
|
-
|
|
57976
|
+
text5.slice(0, RUN_TRACE_LIMITS.bodyExcerpt)
|
|
57786
57977
|
),
|
|
57787
|
-
truncated: !omitted &&
|
|
57978
|
+
truncated: !omitted && text5.length > RUN_TRACE_LIMITS.bodyExcerpt,
|
|
57788
57979
|
omitted
|
|
57789
57980
|
};
|
|
57790
57981
|
const latency = Math.round(performance2.now() - start);
|
|
@@ -57793,11 +57984,11 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57793
57984
|
failures.push(
|
|
57794
57985
|
`Expected HTTP ${m.settings.expectedStatus}, received ${response.status}`
|
|
57795
57986
|
);
|
|
57796
|
-
if (m.settings.contains && !
|
|
57987
|
+
if (m.settings.contains && !text5.includes(m.settings.contains))
|
|
57797
57988
|
failures.push("Expected text missing from response");
|
|
57798
57989
|
if (m.settings.jsonPath) {
|
|
57799
57990
|
try {
|
|
57800
|
-
let value2 = JSON.parse(
|
|
57991
|
+
let value2 = JSON.parse(text5);
|
|
57801
57992
|
for (const part2 of m.settings.jsonPath.split("."))
|
|
57802
57993
|
value2 = value2?.[part2];
|
|
57803
57994
|
let expected;
|
|
@@ -57829,9 +58020,7 @@ ${failures.join("\n")}`
|
|
|
57829
58020
|
};
|
|
57830
58021
|
} catch (cause) {
|
|
57831
58022
|
if (exchange && !exchange.error) {
|
|
57832
|
-
|
|
57833
|
-
const code = error62.cause?.code;
|
|
57834
|
-
exchange.error = m.httpAuth ? "Request failed" : signal.aborted ? "Deadline reached before the response completed" : `${code ? `${code}: ` : ""}${error62.message}`.slice(
|
|
58023
|
+
exchange.error = m.httpAuth ? "Request failed" : signal.aborted ? "Deadline reached before the response completed" : errorMessage(cause).slice(
|
|
57835
58024
|
0,
|
|
57836
58025
|
RUN_TRACE_LIMITS.text
|
|
57837
58026
|
);
|
|
@@ -58041,23 +58230,23 @@ function evaluateAssertion(data, assertion, secrets = []) {
|
|
|
58041
58230
|
passed = matchesType(found.value, assertion.value);
|
|
58042
58231
|
break;
|
|
58043
58232
|
default: {
|
|
58044
|
-
const
|
|
58045
|
-
if (typeof
|
|
58233
|
+
const text5 = found.value;
|
|
58234
|
+
if (typeof text5 === "string") {
|
|
58046
58235
|
switch (assertion.operator) {
|
|
58047
58236
|
case "contains":
|
|
58048
|
-
passed =
|
|
58237
|
+
passed = text5.includes(assertion.value);
|
|
58049
58238
|
break;
|
|
58050
58239
|
case "not-contains":
|
|
58051
|
-
passed = !
|
|
58240
|
+
passed = !text5.includes(assertion.value);
|
|
58052
58241
|
break;
|
|
58053
58242
|
case "contains-any":
|
|
58054
58243
|
passed = assertion.value.some(
|
|
58055
|
-
(value2) =>
|
|
58244
|
+
(value2) => text5.includes(value2)
|
|
58056
58245
|
);
|
|
58057
58246
|
break;
|
|
58058
58247
|
case "contains-all":
|
|
58059
58248
|
passed = assertion.value.every(
|
|
58060
|
-
(value2) =>
|
|
58249
|
+
(value2) => text5.includes(value2)
|
|
58061
58250
|
);
|
|
58062
58251
|
break;
|
|
58063
58252
|
}
|
|
@@ -58498,10 +58687,10 @@ async function certificateCheck(monitor, parentSignal, io = transport, sink = {}
|
|
|
58498
58687
|
signal.throwIfAborted();
|
|
58499
58688
|
const url3 = certificateTarget(monitor.target), hostname4 = url3.hostname;
|
|
58500
58689
|
const lookupStarted = performance3.now();
|
|
58501
|
-
const addresses = await new Promise((
|
|
58690
|
+
const addresses = await new Promise((resolve19, reject) => {
|
|
58502
58691
|
const abort = () => reject(new Error("Certificate check cancelled or timed out"));
|
|
58503
58692
|
signal.addEventListener("abort", abort, { once: true });
|
|
58504
|
-
io.lookup(hostname4, { all: true, verbatim: true }).then(
|
|
58693
|
+
io.lookup(hostname4, { all: true, verbatim: true }).then(resolve19, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
58505
58694
|
if (signal.aborted) abort();
|
|
58506
58695
|
});
|
|
58507
58696
|
signal.throwIfAborted();
|
|
@@ -58518,7 +58707,7 @@ async function certificateCheck(monitor, parentSignal, io = transport, sink = {}
|
|
|
58518
58707
|
};
|
|
58519
58708
|
const connectStarted = performance3.now();
|
|
58520
58709
|
let tcpAt = null;
|
|
58521
|
-
return await new Promise((
|
|
58710
|
+
return await new Promise((resolve19) => {
|
|
58522
58711
|
let done = false;
|
|
58523
58712
|
const socket = io.connect({
|
|
58524
58713
|
host: addresses[0].address,
|
|
@@ -58543,7 +58732,7 @@ async function certificateCheck(monitor, parentSignal, io = transport, sink = {}
|
|
|
58543
58732
|
);
|
|
58544
58733
|
signal.removeEventListener("abort", abort);
|
|
58545
58734
|
socket.destroy();
|
|
58546
|
-
|
|
58735
|
+
resolve19(result2);
|
|
58547
58736
|
};
|
|
58548
58737
|
const abort = () => finish({
|
|
58549
58738
|
status: "error",
|
|
@@ -58612,7 +58801,7 @@ import { performance as performance4 } from "node:perf_hooks";
|
|
|
58612
58801
|
// package.json
|
|
58613
58802
|
var package_default = {
|
|
58614
58803
|
name: "@waitcher/cli",
|
|
58615
|
-
version: "0.2.
|
|
58804
|
+
version: "0.2.35",
|
|
58616
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.",
|
|
58617
58806
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
58618
58807
|
author: "S\u0142awomir Radzymi\u0144ski",
|
|
@@ -58721,7 +58910,7 @@ var MESSAGES = {
|
|
|
58721
58910
|
ASSERTION_FAILED: "The MCP tool result did not satisfy the checks"
|
|
58722
58911
|
};
|
|
58723
58912
|
var isObject2 = (value2) => value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
58724
|
-
var
|
|
58913
|
+
var text4 = (value2, secrets) => typeof value2 === "string" && value2.length <= 128 && /^[\x20-\x7e]*$/.test(value2) && !secrets.some((secret) => value2.includes(secret)) ? value2 : null;
|
|
58725
58914
|
async function readLimited(response, signal, onChunk) {
|
|
58726
58915
|
const length = response.headers.get("content-length");
|
|
58727
58916
|
if (length && /^\d+$/.test(length) && Number(length) > MCP_LIMITS.responseBytes) {
|
|
@@ -58925,11 +59114,11 @@ async function mcpCheck(monitor, parentSignal, options = {}) {
|
|
|
58925
59114
|
});
|
|
58926
59115
|
if (!isObject2(init)) throw new Stop("MALFORMED_RESPONSE");
|
|
58927
59116
|
const version2 = init.protocolVersion;
|
|
58928
|
-
report.server.protocolVersion =
|
|
59117
|
+
report.server.protocolVersion = text4(version2, secrets);
|
|
58929
59118
|
report.server.session = Boolean(session);
|
|
58930
59119
|
if (isObject2(init.serverInfo)) {
|
|
58931
|
-
report.server.name =
|
|
58932
|
-
report.server.version =
|
|
59120
|
+
report.server.name = text4(init.serverInfo.name, secrets);
|
|
59121
|
+
report.server.version = text4(init.serverInfo.version, secrets);
|
|
58933
59122
|
}
|
|
58934
59123
|
if (typeof version2 !== "string" || !MCP_PROTOCOL_VERSIONS.includes(version2))
|
|
58935
59124
|
throw new Stop("UNSUPPORTED_PROTOCOL");
|
|
@@ -58956,7 +59145,7 @@ async function mcpCheck(monitor, parentSignal, options = {}) {
|
|
|
58956
59145
|
report.tools.count = listed.size;
|
|
58957
59146
|
for (const name5 of listed) {
|
|
58958
59147
|
if (report.tools.names.length === MCP_LIMITS.reportedNames) break;
|
|
58959
|
-
const safe =
|
|
59148
|
+
const safe = text4(name5, secrets);
|
|
58960
59149
|
if (safe) report.tools.names.push(safe);
|
|
58961
59150
|
}
|
|
58962
59151
|
report.tools.missing = config2.expectTools.filter((name5) => !listed.has(name5));
|
|
@@ -59052,11 +59241,11 @@ var deadline = (monitor, parent) => AbortSignal.any([
|
|
|
59052
59241
|
...parent ? [parent] : []
|
|
59053
59242
|
]);
|
|
59054
59243
|
function race(work, signal, message) {
|
|
59055
|
-
return new Promise((
|
|
59244
|
+
return new Promise((resolve19, reject) => {
|
|
59056
59245
|
const abort = () => reject(new Error(message));
|
|
59057
59246
|
if (signal.aborted) return abort();
|
|
59058
59247
|
signal.addEventListener("abort", abort, { once: true });
|
|
59059
|
-
work.then(
|
|
59248
|
+
work.then(resolve19, reject).finally(
|
|
59060
59249
|
() => signal.removeEventListener("abort", abort)
|
|
59061
59250
|
);
|
|
59062
59251
|
});
|
|
@@ -59114,7 +59303,7 @@ async function tcpCheck(monitor, parent, io = tcpTransport, sink = {}) {
|
|
|
59114
59303
|
const address = addresses[0].address;
|
|
59115
59304
|
trace.address = address;
|
|
59116
59305
|
const connectStarted = performance5.now();
|
|
59117
|
-
return await new Promise((
|
|
59306
|
+
return await new Promise((resolve19) => {
|
|
59118
59307
|
let done = false;
|
|
59119
59308
|
const chunks = [];
|
|
59120
59309
|
let bytes2 = 0;
|
|
@@ -59127,7 +59316,7 @@ async function tcpCheck(monitor, parent, io = tcpTransport, sink = {}) {
|
|
|
59127
59316
|
socket.destroy();
|
|
59128
59317
|
if (bytes2)
|
|
59129
59318
|
trace.banner = short(Buffer.concat(chunks).toString("utf8").trim());
|
|
59130
|
-
|
|
59319
|
+
resolve19(result2);
|
|
59131
59320
|
};
|
|
59132
59321
|
const abort = () => finish(
|
|
59133
59322
|
connectedAt ? fail2(
|
|
@@ -59155,8 +59344,8 @@ async function tcpCheck(monitor, parent, io = tcpTransport, sink = {}) {
|
|
|
59155
59344
|
socket.on("data", (chunk) => {
|
|
59156
59345
|
chunks.push(chunk);
|
|
59157
59346
|
bytes2 += chunk.length;
|
|
59158
|
-
const
|
|
59159
|
-
if (
|
|
59347
|
+
const text5 = Buffer.concat(chunks).toString("utf8");
|
|
59348
|
+
if (text5.includes(expected)) {
|
|
59160
59349
|
trace.timings.banner = Math.round(performance5.now() - connectedAt);
|
|
59161
59350
|
finish({
|
|
59162
59351
|
status: "passed",
|
|
@@ -59654,9 +59843,9 @@ async function collectArtifacts(dir, base2 = dir, tokens2 = [], excluded = /* @_
|
|
|
59654
59843
|
"AI evidence exceeds its byte limit"
|
|
59655
59844
|
);
|
|
59656
59845
|
const original = await handle.readFile("utf8");
|
|
59657
|
-
const redactText = (
|
|
59846
|
+
const redactText = (text5) => tokens2.reduce(
|
|
59658
59847
|
(value2, token) => value2.replaceAll(token, "[redacted attempt credential]"),
|
|
59659
|
-
|
|
59848
|
+
text5
|
|
59660
59849
|
);
|
|
59661
59850
|
let clean = redactText(original);
|
|
59662
59851
|
if (entry2.name.endsWith(".json")) {
|
|
@@ -59718,7 +59907,7 @@ async function scriptCheckInternal(m, dir, signal, options = {}) {
|
|
|
59718
59907
|
throw Error(
|
|
59719
59908
|
"AI execution requires the exact frozen binding and a private attempt grant"
|
|
59720
59909
|
);
|
|
59721
|
-
await
|
|
59910
|
+
await linkNodeModules(root, dir);
|
|
59722
59911
|
await writeFile2(
|
|
59723
59912
|
join5(dir, "package.json"),
|
|
59724
59913
|
JSON.stringify({
|
|
@@ -59805,7 +59994,7 @@ const agents={default:{model:connect(${JSON.stringify(dispatch.model)}),${dispat
|
|
|
59805
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();"}` : "";
|
|
59806
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)});` : "" : "";
|
|
59807
59996
|
const envNames = m.settings.envNames ?? [];
|
|
59808
|
-
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]]:[]}));` : "";
|
|
59809
59998
|
const secrets = [
|
|
59810
59999
|
...envNames.length ? ["...checkSecrets"] : [],
|
|
59811
60000
|
...options.browserIdentityFile ? ["...identitySecrets"] : []
|
|
@@ -60019,8 +60208,21 @@ try {
|
|
|
60019
60208
|
const requestEvidence = await productRequestEvidence(dir);
|
|
60020
60209
|
const requestCoverageError = requestEvidence.summary.technicalError;
|
|
60021
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
|
+
};
|
|
60022
60224
|
const redact = (value2) => redactions.reduce(
|
|
60023
|
-
(
|
|
60225
|
+
(text5, token) => text5.replaceAll(token, "[redacted attempt credential]"),
|
|
60024
60226
|
value2
|
|
60025
60227
|
);
|
|
60026
60228
|
const artifacts = await collectArtifacts(
|
|
@@ -60035,7 +60237,7 @@ try {
|
|
|
60035
60237
|
return {
|
|
60036
60238
|
status: passed ? "passed" : requestCoverageError || scenarioCoverageError || dataCoverageError || executionCoverageError ? "error" : "failed",
|
|
60037
60239
|
message: redact(
|
|
60038
|
-
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."
|
|
60039
60241
|
),
|
|
60040
60242
|
logs: redact(p.logs),
|
|
60041
60243
|
artifacts
|
|
@@ -60063,6 +60265,19 @@ function identitySecretValues(identity) {
|
|
|
60063
60265
|
])
|
|
60064
60266
|
].filter((value2) => [...value2].length >= 6).flatMap((value2) => [value2, JSON.stringify(value2).slice(1, -1)]);
|
|
60065
60267
|
}
|
|
60268
|
+
async function linkNodeModules(root, dir, options = {}) {
|
|
60269
|
+
const platform = options.platform ?? process.platform, link2 = options.link ?? symlink;
|
|
60270
|
+
const target = resolve8(root, "node_modules");
|
|
60271
|
+
try {
|
|
60272
|
+
await link2(target, join5(dir, "node_modules"), platform === "win32" ? "junction" : "dir");
|
|
60273
|
+
} catch (cause) {
|
|
60274
|
+
const code = cause.code;
|
|
60275
|
+
throw new Error(
|
|
60276
|
+
`Could not link ${target} into the run folder (${code ?? "unknown error"}). ` + (platform === "win32" ? "Windows refused a directory junction; check that the run folder and the project are on local NTFS drives, or enable Developer Mode." : "Check that the project has node_modules (waitcher runtime install) and the run folder is writable."),
|
|
60277
|
+
{ cause }
|
|
60278
|
+
);
|
|
60279
|
+
}
|
|
60280
|
+
}
|
|
60066
60281
|
async function scriptCheck(m, dir, signal, options = {}) {
|
|
60067
60282
|
if (m.type === "visual") {
|
|
60068
60283
|
const { script, web } = visualTest(m.visual, m.timeout);
|
|
@@ -60223,7 +60438,7 @@ async function execute(monitor, runDir, {
|
|
|
60223
60438
|
const error62 = asError(cause);
|
|
60224
60439
|
result2 = {
|
|
60225
60440
|
status: "error",
|
|
60226
|
-
message: monitor.httpAuth ? "Authenticated endpoint execution could not be evaluated" : error62
|
|
60441
|
+
message: monitor.httpAuth ? "Authenticated endpoint execution could not be evaluated" : errorMessage(error62),
|
|
60227
60442
|
logs: monitor.httpAuth ? "HTTP credential dispatch or transport failed. No credentials or response body are recorded." : error62.stack ?? String(error62),
|
|
60228
60443
|
...cause instanceof StorageError ? { resourceReason: cause.code } : {},
|
|
60229
60444
|
...monitor.httpAuth && !(cause instanceof StorageError) ? { resourceReason: "HTTP_AUTH_EXECUTION_ERROR" } : {},
|
|
@@ -60252,10 +60467,10 @@ async function execute(monitor, runDir, {
|
|
|
60252
60467
|
}
|
|
60253
60468
|
async function withTrace(result2, runDir, trace) {
|
|
60254
60469
|
try {
|
|
60255
|
-
const
|
|
60256
|
-
if (Buffer.byteLength(
|
|
60470
|
+
const text5 = JSON.stringify(runTraceFileSchema.parse(trace));
|
|
60471
|
+
if (Buffer.byteLength(text5) > RUN_TRACE_LIMITS.fileBytes) return result2;
|
|
60257
60472
|
await mkdir3(join6(runDir, ".e2e"), { recursive: true, mode: 448 });
|
|
60258
|
-
await writeFile3(join6(runDir, RUN_TRACE_PATH),
|
|
60473
|
+
await writeFile3(join6(runDir, RUN_TRACE_PATH), text5, { mode: 384 });
|
|
60259
60474
|
return {
|
|
60260
60475
|
...result2,
|
|
60261
60476
|
artifacts: [...result2.artifacts ?? [], RUN_TRACE_PATH]
|
|
@@ -60572,9 +60787,77 @@ var entries = {
|
|
|
60572
60787
|
RUNTIME_INSTALL_FAILED: {
|
|
60573
60788
|
title: "Runtime install failed",
|
|
60574
60789
|
meaning: "npm install or the Chromium download of waitcher runtime install exited with an error.",
|
|
60575
|
-
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.",
|
|
60576
60791
|
exitCode: 1
|
|
60577
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
|
+
},
|
|
60578
60861
|
FILE_NOT_FOUND: {
|
|
60579
60862
|
title: "File not found",
|
|
60580
60863
|
meaning: "A referenced local file does not exist.",
|
|
@@ -60741,7 +61024,7 @@ var projectConfigSchema = external_exports.object({
|
|
|
60741
61024
|
monitors: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(CONFIG_LIMITS.monitors)
|
|
60742
61025
|
}).strict();
|
|
60743
61026
|
var pathOf = (parts) => parts.reduce(
|
|
60744
|
-
(
|
|
61027
|
+
(text5, part2) => typeof part2 === "number" ? `${text5}[${part2}]` : `${text5}${text5 ? "." : ""}${String(part2)}`,
|
|
60745
61028
|
""
|
|
60746
61029
|
);
|
|
60747
61030
|
var PLACEHOLDER_HTTP_AUTH = {
|
|
@@ -61080,8 +61363,8 @@ async function readConnectionConfiguration(file2) {
|
|
|
61080
61363
|
2
|
|
61081
61364
|
);
|
|
61082
61365
|
}
|
|
61083
|
-
function providerCredential(
|
|
61084
|
-
const parsed = connectionSecretSchema.safeParse(
|
|
61366
|
+
function providerCredential(text5) {
|
|
61367
|
+
const parsed = connectionSecretSchema.safeParse(text5.trim());
|
|
61085
61368
|
if (!parsed.success)
|
|
61086
61369
|
throw new ServiceError(
|
|
61087
61370
|
"Provide a private provider key through --credential-file or --credential-stdin.",
|
|
@@ -61339,8 +61622,8 @@ function modelTransport(authority, options = {}) {
|
|
|
61339
61622
|
"Model provider did not accept the request"
|
|
61340
61623
|
);
|
|
61341
61624
|
}
|
|
61342
|
-
const
|
|
61343
|
-
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)))
|
|
61344
61627
|
throw new AppError(
|
|
61345
61628
|
502,
|
|
61346
61629
|
"AI_RESPONSE_REJECTED",
|
|
@@ -61348,7 +61631,7 @@ function modelTransport(authority, options = {}) {
|
|
|
61348
61631
|
);
|
|
61349
61632
|
let result2;
|
|
61350
61633
|
try {
|
|
61351
|
-
result2 = modelResponseSchema.safeParse(JSON.parse(
|
|
61634
|
+
result2 = modelResponseSchema.safeParse(JSON.parse(text5));
|
|
61352
61635
|
} catch {
|
|
61353
61636
|
}
|
|
61354
61637
|
if (!result2?.success || result2.data.model !== body2.model)
|
|
@@ -61579,11 +61862,11 @@ async function localModelBroker(input2, options = {}) {
|
|
|
61579
61862
|
server.maxConnections = 8;
|
|
61580
61863
|
server.headersTimeout = 5e3;
|
|
61581
61864
|
server.requestTimeout = 35e3;
|
|
61582
|
-
await new Promise((
|
|
61865
|
+
await new Promise((resolve19, reject) => {
|
|
61583
61866
|
server.once("error", reject);
|
|
61584
61867
|
server.listen(0, "127.0.0.1", () => {
|
|
61585
61868
|
server.removeListener("error", reject);
|
|
61586
|
-
|
|
61869
|
+
resolve19();
|
|
61587
61870
|
});
|
|
61588
61871
|
});
|
|
61589
61872
|
const origin = `http://127.0.0.1:${server.address().port}`;
|
|
@@ -61619,7 +61902,7 @@ async function localModelBroker(input2, options = {}) {
|
|
|
61619
61902
|
finishing = (async () => {
|
|
61620
61903
|
revoked = true;
|
|
61621
61904
|
const closed = new Promise(
|
|
61622
|
-
(
|
|
61905
|
+
(resolve19, reject) => server.close((e) => e ? reject(e) : resolve19())
|
|
61623
61906
|
);
|
|
61624
61907
|
server.closeAllConnections();
|
|
61625
61908
|
await Promise.allSettled([...pending]);
|
|
@@ -61632,12 +61915,279 @@ async function localModelBroker(input2, options = {}) {
|
|
|
61632
61915
|
};
|
|
61633
61916
|
}
|
|
61634
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
|
+
|
|
61635
62184
|
// src/local.ts
|
|
62185
|
+
var PROJECT_FAILED = "e2e execution failed. Inspect the report and logs.";
|
|
61636
62186
|
var invalid2 = (message) => {
|
|
61637
62187
|
throw new ServiceError(message, "USAGE_ERROR", 2);
|
|
61638
62188
|
};
|
|
61639
62189
|
async function runtime(project, browser, ai = false) {
|
|
61640
|
-
const require2 = createRequire(
|
|
62190
|
+
const require2 = createRequire(join9(project, "package.json"));
|
|
61641
62191
|
async function locate(name5) {
|
|
61642
62192
|
let entry2;
|
|
61643
62193
|
try {
|
|
@@ -61647,9 +62197,9 @@ async function runtime(project, browser, ai = false) {
|
|
|
61647
62197
|
`Install ${name5} in ${project} before running locally (waitcher runtime install).`
|
|
61648
62198
|
);
|
|
61649
62199
|
}
|
|
61650
|
-
const root =
|
|
62200
|
+
const root = dirname9(dirname9(entry2));
|
|
61651
62201
|
const metadata2 = JSON.parse(
|
|
61652
|
-
await
|
|
62202
|
+
await readFile5(join9(root, "package.json"), "utf8")
|
|
61653
62203
|
);
|
|
61654
62204
|
if (metadata2.name !== name5)
|
|
61655
62205
|
invalid2(`${name5} in ${project} is not the ${name5} package.`);
|
|
@@ -61668,19 +62218,60 @@ async function runtime(project, browser, ai = false) {
|
|
|
61668
62218
|
if (model.version !== "7.0.177")
|
|
61669
62219
|
invalid2(`Local execution requires ai@7.0.177; found ${model.version}.`);
|
|
61670
62220
|
}
|
|
61671
|
-
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] };
|
|
61672
62263
|
}
|
|
61673
62264
|
async function inventory(root) {
|
|
61674
62265
|
const files = [];
|
|
61675
62266
|
async function walk(path2) {
|
|
61676
|
-
for (const item of await
|
|
61677
|
-
const full =
|
|
62267
|
+
for (const item of await readdir2(path2, { withFileTypes: true })) {
|
|
62268
|
+
const full = join9(path2, item.name);
|
|
61678
62269
|
if (item.isSymbolicLink() || item.name === "node_modules") continue;
|
|
61679
62270
|
if (item.isDirectory()) await walk(full);
|
|
61680
62271
|
else if (item.isFile()) {
|
|
61681
|
-
const bytes2 = await
|
|
62272
|
+
const bytes2 = await readFile5(full);
|
|
61682
62273
|
files.push({
|
|
61683
|
-
path: relative(root, full).split(
|
|
62274
|
+
path: relative(root, full).split(sep2).join("/"),
|
|
61684
62275
|
bytes: bytes2.length,
|
|
61685
62276
|
sha256: createHash8("sha256").update(bytes2).digest("hex")
|
|
61686
62277
|
});
|
|
@@ -61705,12 +62296,13 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61705
62296
|
options.httpCredentialsFile,
|
|
61706
62297
|
definition
|
|
61707
62298
|
);
|
|
61708
|
-
const parent =
|
|
62299
|
+
const parent = resolve11(options.output ?? join9(project, ".waitcher/runs"));
|
|
61709
62300
|
await mkdir4(parent, { recursive: true, mode: 448 });
|
|
62301
|
+
await ignoreRunFolder(parent, !options.output);
|
|
61710
62302
|
const info = await lstat7(parent);
|
|
61711
62303
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
61712
62304
|
invalid2("Output must be a regular directory, not a symbolic link.");
|
|
61713
|
-
const runId = randomUUID4(), directory =
|
|
62305
|
+
const runId = randomUUID4(), directory = join9(parent, runId), startedAt = Date.now(), start = performance7.now();
|
|
61714
62306
|
await mkdir4(directory, { mode: 448 });
|
|
61715
62307
|
const timeout = options.timeout ?? definition.timeout;
|
|
61716
62308
|
const signal = AbortSignal.any([
|
|
@@ -61761,8 +62353,8 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61761
62353
|
}
|
|
61762
62354
|
if (broker) {
|
|
61763
62355
|
modelUsage = await broker.finish();
|
|
61764
|
-
await
|
|
61765
|
-
|
|
62356
|
+
await writeFile5(
|
|
62357
|
+
join9(directory, "model-usage.json"),
|
|
61766
62358
|
JSON.stringify(modelUsage, null, 2) + "\n",
|
|
61767
62359
|
{ mode: 384, flag: "wx" }
|
|
61768
62360
|
);
|
|
@@ -61772,10 +62364,10 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61772
62364
|
check2.status = "error";
|
|
61773
62365
|
check2.message = "Local semantic grading could not verify model usage. Inspect model-usage.json and the endpoint report.";
|
|
61774
62366
|
}
|
|
61775
|
-
const report =
|
|
62367
|
+
const report = join9(
|
|
61776
62368
|
directory,
|
|
61777
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"
|
|
61778
|
-
), log =
|
|
62370
|
+
), log = join9(directory, "execution.log");
|
|
61779
62371
|
const reportText = ["ai", "mcp"].includes(definition.type) ? check2.logs : JSON.stringify({
|
|
61780
62372
|
schemaVersion: 1,
|
|
61781
62373
|
kind: ["tcp", "dns"].includes(definition.type) ? definition.type : "http",
|
|
@@ -61783,11 +62375,11 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61783
62375
|
message: check2.message,
|
|
61784
62376
|
duration: check2.duration
|
|
61785
62377
|
});
|
|
61786
|
-
await
|
|
61787
|
-
await
|
|
62378
|
+
await writeFile5(report, reportText + "\n", { mode: 384, flag: "wx" });
|
|
62379
|
+
await writeFile5(log, check2.logs + "\n", { mode: 384, flag: "wx" });
|
|
61788
62380
|
if (mcpToolResult !== void 0)
|
|
61789
|
-
await
|
|
61790
|
-
|
|
62381
|
+
await writeFile5(
|
|
62382
|
+
join9(directory, "mcp-tool-result.json"),
|
|
61791
62383
|
JSON.stringify(mcpToolResult, null, 2) + "\n",
|
|
61792
62384
|
{ mode: 384, flag: "wx" }
|
|
61793
62385
|
);
|
|
@@ -61806,10 +62398,15 @@ async function runLocalRequest(definition, options, project) {
|
|
|
61806
62398
|
summary: null,
|
|
61807
62399
|
log,
|
|
61808
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
|
+
},
|
|
61809
62406
|
files: await inventory(directory)
|
|
61810
62407
|
};
|
|
61811
|
-
await
|
|
61812
|
-
|
|
62408
|
+
await writeFile5(
|
|
62409
|
+
join9(directory, "local-run.json"),
|
|
61813
62410
|
JSON.stringify(result2, null, 2) + "\n",
|
|
61814
62411
|
{ mode: 384, flag: "wx" }
|
|
61815
62412
|
);
|
|
@@ -61828,7 +62425,7 @@ async function runLocal(options) {
|
|
|
61828
62425
|
"--runtime applies to --file only; projects use their installed E2E runtime."
|
|
61829
62426
|
);
|
|
61830
62427
|
const project = await realpath(
|
|
61831
|
-
|
|
62428
|
+
resolve11(options.project ?? options.runtime ?? process.cwd())
|
|
61832
62429
|
);
|
|
61833
62430
|
const definition = options.file ? await readManifest(options.file) : null;
|
|
61834
62431
|
if (!definition && options.browserIdentitiesFile)
|
|
@@ -61885,7 +62482,7 @@ async function runLocal(options) {
|
|
|
61885
62482
|
if (!definition) {
|
|
61886
62483
|
const config2 = await Promise.all(
|
|
61887
62484
|
["ts", "mts", "js", "mjs"].map(
|
|
61888
|
-
(extension) => lstat7(
|
|
62485
|
+
(extension) => lstat7(join9(project, `e2e.config.${extension}`)).then(
|
|
61889
62486
|
(s) => s.isFile(),
|
|
61890
62487
|
() => false
|
|
61891
62488
|
)
|
|
@@ -61896,33 +62493,40 @@ async function runLocal(options) {
|
|
|
61896
62493
|
"The project must contain an e2e.config.ts (or .mts/.js/.mjs). Run e2e init in that project first."
|
|
61897
62494
|
);
|
|
61898
62495
|
} else {
|
|
61899
|
-
if (!(await lstat7(
|
|
62496
|
+
if (!(await lstat7(join9(project, "node_modules")).catch(() => null))?.isDirectory())
|
|
61900
62497
|
invalid2(
|
|
61901
62498
|
"--runtime must contain node_modules for the pinned E2E dependencies."
|
|
61902
62499
|
);
|
|
61903
62500
|
}
|
|
61904
|
-
const parent =
|
|
61905
|
-
options.output ??
|
|
62501
|
+
const parent = resolve11(
|
|
62502
|
+
options.output ?? join9(options.project ? project : process.cwd(), ".waitcher/runs")
|
|
61906
62503
|
);
|
|
61907
62504
|
if (!definition) {
|
|
61908
62505
|
const path2 = relative(project, parent);
|
|
61909
|
-
if (!path2 || path2 === ".." || path2.startsWith(`..${
|
|
62506
|
+
if (!path2 || path2 === ".." || path2.startsWith(`..${sep2}`) || resolve11(project, path2) !== parent)
|
|
61910
62507
|
invalid2("Project output must be a subdirectory of the E2E project.");
|
|
61911
62508
|
}
|
|
61912
62509
|
await mkdir4(parent, { recursive: true, mode: 448 });
|
|
62510
|
+
await ignoreRunFolder(parent, !options.output);
|
|
61913
62511
|
const parentInfo = await lstat7(parent);
|
|
61914
62512
|
if (!parentInfo.isDirectory() || parentInfo.isSymbolicLink())
|
|
61915
62513
|
invalid2("Output must be a regular directory, not a symbolic link.");
|
|
61916
62514
|
if (!definition) {
|
|
61917
62515
|
const actual = relative(project, await realpath(parent));
|
|
61918
|
-
if (actual === ".." || actual.startsWith(`..${
|
|
62516
|
+
if (actual === ".." || actual.startsWith(`..${sep2}`))
|
|
61919
62517
|
invalid2("Project output cannot resolve outside the E2E project.");
|
|
61920
62518
|
}
|
|
61921
|
-
const runId = randomUUID4(), directory =
|
|
62519
|
+
const runId = randomUUID4(), directory = join9(parent, runId);
|
|
61922
62520
|
await mkdir4(directory, { mode: 448 });
|
|
61923
62521
|
const startedAt = Date.now(), start = performance7.now();
|
|
61924
62522
|
const timeout = options.timeout ?? definition?.timeout ?? 60;
|
|
61925
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
|
+
}
|
|
61926
62530
|
let status2 = "error", logs = "", message = "Local execution did not finish";
|
|
61927
62531
|
let requestUsage;
|
|
61928
62532
|
let modelUsage;
|
|
@@ -61932,19 +62536,19 @@ async function runLocal(options) {
|
|
|
61932
62536
|
let localRequests;
|
|
61933
62537
|
let localModel;
|
|
61934
62538
|
try {
|
|
61935
|
-
await
|
|
61936
|
-
|
|
62539
|
+
await writeFile5(
|
|
62540
|
+
join9(directory, "waitcher-scenario-runtime.mjs"),
|
|
61937
62541
|
scenarioSource,
|
|
61938
62542
|
{ mode: 384, flag: "wx" }
|
|
61939
62543
|
);
|
|
61940
62544
|
if (modelSource)
|
|
61941
|
-
await
|
|
61942
|
-
|
|
62545
|
+
await writeFile5(
|
|
62546
|
+
join9(directory, "waitcher-model-client.mjs"),
|
|
61943
62547
|
modelSource,
|
|
61944
62548
|
{ mode: 384, flag: "wx" }
|
|
61945
62549
|
);
|
|
61946
|
-
await
|
|
61947
|
-
|
|
62550
|
+
await writeFile5(
|
|
62551
|
+
join9(directory, "waitcher-request-runtime.mjs"),
|
|
61948
62552
|
requestSource,
|
|
61949
62553
|
{ mode: 384, flag: "wx" }
|
|
61950
62554
|
);
|
|
@@ -61977,18 +62581,19 @@ async function runLocal(options) {
|
|
|
61977
62581
|
// Baselines are approved in Waitcher; locally a stored
|
|
61978
62582
|
// screenshot is compared with a capture taken moments earlier.
|
|
61979
62583
|
localSnapshots: true,
|
|
61980
|
-
|
|
62584
|
+
causeAudience: "local",
|
|
62585
|
+
requestClientFile: join9(
|
|
61981
62586
|
directory,
|
|
61982
62587
|
"waitcher-request-runtime.mjs"
|
|
61983
62588
|
),
|
|
61984
62589
|
...localRequests ? { request: localRequests.dispatch } : {},
|
|
61985
|
-
scenarioClientFile:
|
|
62590
|
+
scenarioClientFile: join9(
|
|
61986
62591
|
directory,
|
|
61987
62592
|
"waitcher-scenario-runtime.mjs"
|
|
61988
62593
|
),
|
|
61989
62594
|
...definition.type === "browser" ? {
|
|
61990
62595
|
...browserIdentity ? { browserIdentity } : {},
|
|
61991
|
-
browserIdentityClientFile:
|
|
62596
|
+
browserIdentityClientFile: join9(
|
|
61992
62597
|
directory,
|
|
61993
62598
|
"waitcher-model-client.mjs"
|
|
61994
62599
|
)
|
|
@@ -61999,7 +62604,7 @@ async function runLocal(options) {
|
|
|
61999
62604
|
reporters: ["list", "markdown", "junit"],
|
|
62000
62605
|
...localModel ? {
|
|
62001
62606
|
model: localModel.dispatch,
|
|
62002
|
-
modelClientFile:
|
|
62607
|
+
modelClientFile: join9(
|
|
62003
62608
|
directory,
|
|
62004
62609
|
"waitcher-model-client.mjs"
|
|
62005
62610
|
)
|
|
@@ -62029,7 +62634,7 @@ async function runLocal(options) {
|
|
|
62029
62634
|
executable,
|
|
62030
62635
|
"run",
|
|
62031
62636
|
"--output",
|
|
62032
|
-
relative(project,
|
|
62637
|
+
relative(project, join9(directory, evidence)),
|
|
62033
62638
|
"--trace",
|
|
62034
62639
|
"on",
|
|
62035
62640
|
"--video",
|
|
@@ -62053,15 +62658,15 @@ async function runLocal(options) {
|
|
|
62053
62658
|
}
|
|
62054
62659
|
);
|
|
62055
62660
|
logs = result3.logs;
|
|
62056
|
-
const path2 =
|
|
62661
|
+
const path2 = join9(directory, evidence, "report.json");
|
|
62057
62662
|
if ((await lstat7(path2)).size > STORAGE_LIMITS.artifactFileBytes)
|
|
62058
62663
|
throw Error("Local E2E report exceeds its 8 MiB budget");
|
|
62059
|
-
const report = JSON.parse(await
|
|
62664
|
+
const report = JSON.parse(await readFile5(path2, "utf8"));
|
|
62060
62665
|
const passed = result3.code === 0 && report.run?.status === "passed" && report.run.results?.length > 0 && report.run.results.every(
|
|
62061
62666
|
(r) => r.status === "passed"
|
|
62062
62667
|
);
|
|
62063
62668
|
status2 = passed ? "passed" : result3.timedOut || ![0, 1].includes(result3.code ?? -1) ? "error" : "failed";
|
|
62064
|
-
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;
|
|
62065
62670
|
}
|
|
62066
62671
|
});
|
|
62067
62672
|
} catch (error62) {
|
|
@@ -62074,12 +62679,12 @@ async function runLocal(options) {
|
|
|
62074
62679
|
}
|
|
62075
62680
|
if (connection) connection.credential = "";
|
|
62076
62681
|
if (modelUsage)
|
|
62077
|
-
await
|
|
62078
|
-
|
|
62682
|
+
await writeFile5(
|
|
62683
|
+
join9(directory, "model-usage.json"),
|
|
62079
62684
|
JSON.stringify(modelUsage, null, 2) + "\n",
|
|
62080
62685
|
{ mode: 384, flag: "wx" }
|
|
62081
62686
|
);
|
|
62082
|
-
await
|
|
62687
|
+
await writeFile5(join9(directory, "execution.log"), logs, {
|
|
62083
62688
|
mode: 384,
|
|
62084
62689
|
flag: "wx"
|
|
62085
62690
|
});
|
|
@@ -62088,8 +62693,8 @@ async function runLocal(options) {
|
|
|
62088
62693
|
const { scanWork: scanWork2 } = await Promise.resolve().then(() => (init_work(), work_exports));
|
|
62089
62694
|
if (definition) await writeLocalFrozenDefinition(directory, definition);
|
|
62090
62695
|
if (requestUsage)
|
|
62091
|
-
await
|
|
62092
|
-
|
|
62696
|
+
await writeFile5(
|
|
62697
|
+
join9(directory, "request-usage.json"),
|
|
62093
62698
|
JSON.stringify(requestUsage, null, 2) + "\n",
|
|
62094
62699
|
{ mode: 384, flag: "wx" }
|
|
62095
62700
|
);
|
|
@@ -62100,6 +62705,9 @@ async function runLocal(options) {
|
|
|
62100
62705
|
message = "Local evidence exceeded its storage budget or could not be indexed; partial files remain in the output directory.";
|
|
62101
62706
|
}
|
|
62102
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;
|
|
62103
62711
|
const result2 = {
|
|
62104
62712
|
schemaVersion: 1,
|
|
62105
62713
|
event: "local_completed",
|
|
@@ -62107,25 +62715,32 @@ async function runLocal(options) {
|
|
|
62107
62715
|
runId,
|
|
62108
62716
|
status: finalStatus,
|
|
62109
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 } : {},
|
|
62110
62725
|
startedAt,
|
|
62111
62726
|
duration: Math.round(performance7.now() - start),
|
|
62112
62727
|
directory,
|
|
62113
|
-
report: files.some((f) => f.path === `${evidence}/report.json`) ?
|
|
62114
|
-
summary: files.some((f) => f.path === `${evidence}/summary.md`) ?
|
|
62115
|
-
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"),
|
|
62116
62731
|
videoRequested: Boolean(options.video),
|
|
62117
62732
|
...modelUsage ? {
|
|
62118
|
-
modelUsage:
|
|
62733
|
+
modelUsage: join9(directory, "model-usage.json"),
|
|
62119
62734
|
modelOutcome: modelUsage.outcome
|
|
62120
62735
|
} : {},
|
|
62121
62736
|
...requestUsage ? {
|
|
62122
|
-
requestUsage:
|
|
62737
|
+
requestUsage: join9(directory, "request-usage.json"),
|
|
62123
62738
|
requestOutcome: requestUsage.outcome
|
|
62124
62739
|
} : {},
|
|
62125
62740
|
files
|
|
62126
62741
|
};
|
|
62127
|
-
await
|
|
62128
|
-
|
|
62742
|
+
await writeFile5(
|
|
62743
|
+
join9(directory, "local-run.json"),
|
|
62129
62744
|
JSON.stringify(result2, null, 2) + "\n",
|
|
62130
62745
|
{ mode: 384, flag: "wx" }
|
|
62131
62746
|
);
|
|
@@ -62137,8 +62752,8 @@ async function runLocal(options) {
|
|
|
62137
62752
|
|
|
62138
62753
|
// src/calibration.ts
|
|
62139
62754
|
import { constants as constants12 } from "node:fs";
|
|
62140
|
-
import { open as open15, mkdir as mkdir5, lstat as lstat8, writeFile as
|
|
62141
|
-
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";
|
|
62142
62757
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
62143
62758
|
|
|
62144
62759
|
// ../../src/contracts/calibration.ts
|
|
@@ -62334,8 +62949,8 @@ async function runLocalCalibration(options) {
|
|
|
62334
62949
|
"Calibration inputs must not contain the private judge credential."
|
|
62335
62950
|
);
|
|
62336
62951
|
}
|
|
62337
|
-
const parent =
|
|
62338
|
-
options.output ??
|
|
62952
|
+
const parent = resolve12(
|
|
62953
|
+
options.output ?? join10(dirname10(resolve12(options.file)), ".waitcher/calibrations")
|
|
62339
62954
|
);
|
|
62340
62955
|
await mkdir5(parent, { recursive: true, mode: 448 });
|
|
62341
62956
|
const info = await lstat8(parent);
|
|
@@ -62343,7 +62958,7 @@ async function runLocalCalibration(options) {
|
|
|
62343
62958
|
return invalid3(
|
|
62344
62959
|
"Calibration output must be a regular directory, not a symbolic link."
|
|
62345
62960
|
);
|
|
62346
|
-
const calibrationId = randomUUID5(), directory =
|
|
62961
|
+
const calibrationId = randomUUID5(), directory = join10(parent, calibrationId), startedAt = Date.now();
|
|
62347
62962
|
await mkdir5(directory, { mode: 448 });
|
|
62348
62963
|
const signal = AbortSignal.any([
|
|
62349
62964
|
options.signal,
|
|
@@ -62385,12 +63000,12 @@ async function runLocalCalibration(options) {
|
|
|
62385
63000
|
connection.credential = "";
|
|
62386
63001
|
if (broker) usage3 = await broker.finish();
|
|
62387
63002
|
}
|
|
62388
|
-
const reportFile =
|
|
62389
|
-
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", {
|
|
62390
63005
|
mode: 384,
|
|
62391
63006
|
flag: "wx"
|
|
62392
63007
|
});
|
|
62393
|
-
await
|
|
63008
|
+
await writeFile6(usageFile, JSON.stringify(usage3, null, 2) + "\n", {
|
|
62394
63009
|
mode: 384,
|
|
62395
63010
|
flag: "wx"
|
|
62396
63011
|
});
|
|
@@ -62412,9 +63027,9 @@ async function runLocalCalibration(options) {
|
|
|
62412
63027
|
// src/bundle.ts
|
|
62413
63028
|
import { createRequire as createRequire2, isBuiltin } from "node:module";
|
|
62414
63029
|
import { createHash as createHash10 } from "node:crypto";
|
|
62415
|
-
import { readFile as
|
|
62416
|
-
import { basename, dirname as
|
|
62417
|
-
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";
|
|
62418
63033
|
var sha = (bytes2) => createHash10("sha256").update(bytes2).digest("hex");
|
|
62419
63034
|
function invalid4(message) {
|
|
62420
63035
|
throw new ServiceError(message, "VALIDATION_ERROR", 2);
|
|
@@ -62432,20 +63047,20 @@ async function bundleMonitor(options) {
|
|
|
62432
63047
|
invalid4(
|
|
62433
63048
|
"monitor build requires --file SOURCE.json and --output NEW_DIRECTORY."
|
|
62434
63049
|
);
|
|
62435
|
-
const sourceManifest = await realpath2(
|
|
63050
|
+
const sourceManifest = await realpath2(resolve13(options.file));
|
|
62436
63051
|
const project = await realpath2(
|
|
62437
|
-
|
|
63052
|
+
resolve13(options.project ?? dirname11(sourceManifest))
|
|
62438
63053
|
);
|
|
62439
63054
|
function projectPath(path2) {
|
|
62440
63055
|
const name5 = relative2(project, path2);
|
|
62441
|
-
if (name5 === ".." || name5.startsWith(`..${
|
|
63056
|
+
if (name5 === ".." || name5.startsWith(`..${sep3}`) || name5.startsWith(sep3))
|
|
62442
63057
|
invalid4(
|
|
62443
63058
|
"Build inputs must stay within --project, including resolved symlinks."
|
|
62444
63059
|
);
|
|
62445
|
-
return name5.split(
|
|
63060
|
+
return name5.split(sep3).join("/");
|
|
62446
63061
|
}
|
|
62447
63062
|
projectPath(sourceManifest);
|
|
62448
|
-
const manifestText = await
|
|
63063
|
+
const manifestText = await readFile6(sourceManifest, "utf8");
|
|
62449
63064
|
let definition;
|
|
62450
63065
|
try {
|
|
62451
63066
|
definition = await readManifest(sourceManifest);
|
|
@@ -62454,7 +63069,7 @@ async function bundleMonitor(options) {
|
|
|
62454
63069
|
error62 instanceof Error ? error62.message : "Invalid source manifest."
|
|
62455
63070
|
);
|
|
62456
63071
|
}
|
|
62457
|
-
if (manifestText !== await
|
|
63072
|
+
if (manifestText !== await readFile6(sourceManifest, "utf8"))
|
|
62458
63073
|
invalid4(
|
|
62459
63074
|
"The source manifest changed during the build. Retry with stable inputs."
|
|
62460
63075
|
);
|
|
@@ -62466,7 +63081,7 @@ async function bundleMonitor(options) {
|
|
|
62466
63081
|
"Use scriptFile in the source manifest so imports resolve from a real project file."
|
|
62467
63082
|
);
|
|
62468
63083
|
const entry2 = await realpath2(
|
|
62469
|
-
|
|
63084
|
+
resolve13(dirname11(sourceManifest), source.scriptFile)
|
|
62470
63085
|
);
|
|
62471
63086
|
const entryName = projectPath(entry2);
|
|
62472
63087
|
const { script, inputs, lock, builder } = await buildScript({
|
|
@@ -62498,20 +63113,20 @@ async function bundleMonitor(options) {
|
|
|
62498
63113
|
},
|
|
62499
63114
|
manifest: { path: "monitor.json", sha256: sha(manifest) }
|
|
62500
63115
|
};
|
|
62501
|
-
const output2 =
|
|
62502
|
-
await mkdir6(
|
|
63116
|
+
const output2 = resolve13(options.output);
|
|
63117
|
+
await mkdir6(dirname11(output2), { recursive: true, mode: 448 });
|
|
62503
63118
|
await mkdir6(output2, { mode: 448 });
|
|
62504
63119
|
try {
|
|
62505
|
-
await
|
|
63120
|
+
await writeFile7(join11(output2, "monitor.js"), script, {
|
|
62506
63121
|
flag: "wx",
|
|
62507
63122
|
mode: 384
|
|
62508
63123
|
});
|
|
62509
|
-
await
|
|
63124
|
+
await writeFile7(join11(output2, "monitor.json"), manifest, {
|
|
62510
63125
|
flag: "wx",
|
|
62511
63126
|
mode: 384
|
|
62512
63127
|
});
|
|
62513
|
-
await
|
|
62514
|
-
|
|
63128
|
+
await writeFile7(
|
|
63129
|
+
join11(output2, "build.json"),
|
|
62515
63130
|
JSON.stringify(provenance, null, 2) + "\n",
|
|
62516
63131
|
{ flag: "wx", mode: 384 }
|
|
62517
63132
|
);
|
|
@@ -62522,7 +63137,7 @@ async function bundleMonitor(options) {
|
|
|
62522
63137
|
return {
|
|
62523
63138
|
event: "monitor_built",
|
|
62524
63139
|
directory: output2,
|
|
62525
|
-
file:
|
|
63140
|
+
file: join11(output2, "monitor.json"),
|
|
62526
63141
|
...provenance
|
|
62527
63142
|
};
|
|
62528
63143
|
}
|
|
@@ -62533,16 +63148,16 @@ async function buildScript({
|
|
|
62533
63148
|
}) {
|
|
62534
63149
|
function projectPath(path2) {
|
|
62535
63150
|
const name5 = relative2(project, path2);
|
|
62536
|
-
if (name5 === ".." || name5.startsWith(`..${
|
|
63151
|
+
if (name5 === ".." || name5.startsWith(`..${sep3}`) || name5.startsWith(sep3))
|
|
62537
63152
|
invalid4(
|
|
62538
63153
|
"Build inputs must stay within --project, including resolved symlinks."
|
|
62539
63154
|
);
|
|
62540
|
-
return name5.split(
|
|
63155
|
+
return name5.split(sep3).join("/");
|
|
62541
63156
|
}
|
|
62542
63157
|
const entryName = projectPath(entry2);
|
|
62543
63158
|
if (!/\.(?:[cm]?[jt]s)$/.test(entry2))
|
|
62544
63159
|
invalid4("Use a TypeScript or JavaScript test entry, without JSX.");
|
|
62545
|
-
const require2 = createRequire2(
|
|
63160
|
+
const require2 = createRequire2(join11(project, "package.json"));
|
|
62546
63161
|
let tool;
|
|
62547
63162
|
try {
|
|
62548
63163
|
tool = require2.resolve("esbuild");
|
|
@@ -62552,20 +63167,20 @@ async function buildScript({
|
|
|
62552
63167
|
);
|
|
62553
63168
|
}
|
|
62554
63169
|
const toolMetadata = JSON.parse(
|
|
62555
|
-
await
|
|
63170
|
+
await readFile6(join11(dirname11(dirname11(tool)), "package.json"), "utf8")
|
|
62556
63171
|
);
|
|
62557
63172
|
if (toolMetadata.name !== "esbuild" || !supportedGenerations().some((g) => g.esbuild === toolMetadata.version))
|
|
62558
63173
|
invalid4(
|
|
62559
63174
|
`The portable build requires esbuild@${RUNTIME_PINS.esbuild} in the project (waitcher runtime install).`
|
|
62560
63175
|
);
|
|
62561
|
-
const { build } = await import(
|
|
63176
|
+
const { build } = await import(pathToFileURL3(tool).href);
|
|
62562
63177
|
const inputs = /* @__PURE__ */ new Map();
|
|
62563
63178
|
let inputBytes = 0;
|
|
62564
63179
|
async function load(path2) {
|
|
62565
63180
|
const actual = await realpath2(path2), name5 = projectPath(actual);
|
|
62566
63181
|
if (inputs.size >= 64 && !inputs.has(name5))
|
|
62567
63182
|
invalid4("A portable monitor may bundle at most 64 source files.");
|
|
62568
|
-
const contents = await
|
|
63183
|
+
const contents = await readFile6(actual);
|
|
62569
63184
|
inputBytes += contents.length;
|
|
62570
63185
|
if (contents.length > 512e3 || inputBytes > 1024e3)
|
|
62571
63186
|
invalid4("Build inputs exceed the 1 MB source budget.");
|
|
@@ -62588,8 +63203,8 @@ async function buildScript({
|
|
|
62588
63203
|
stdin: {
|
|
62589
63204
|
contents: entryText,
|
|
62590
63205
|
// esbuild prefixes resolveDir, so the bare name keeps the header path right.
|
|
62591
|
-
sourcefile:
|
|
62592
|
-
resolveDir:
|
|
63206
|
+
sourcefile: basename2(entry2),
|
|
63207
|
+
resolveDir: dirname11(entry2),
|
|
62593
63208
|
loader: /\.[cm]?ts$/.test(entry2) ? "ts" : "js"
|
|
62594
63209
|
},
|
|
62595
63210
|
bundle: true,
|
|
@@ -62677,7 +63292,7 @@ async function buildScript({
|
|
|
62677
63292
|
let lock = null;
|
|
62678
63293
|
for (const name5 of ["package-lock.json", "pnpm-lock.yaml", "yarn.lock"]) {
|
|
62679
63294
|
try {
|
|
62680
|
-
lock = { path: name5, sha256: sha(await
|
|
63295
|
+
lock = { path: name5, sha256: sha(await readFile6(join11(project, name5))) };
|
|
62681
63296
|
break;
|
|
62682
63297
|
} catch (error62) {
|
|
62683
63298
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -62702,208 +63317,8 @@ async function buildScript({
|
|
|
62702
63317
|
import { readFile as readFile7, realpath as realpath3, mkdir as mkdir7, writeFile as writeFile8, rm as rm5 } from "node:fs/promises";
|
|
62703
63318
|
import { execFile } from "node:child_process";
|
|
62704
63319
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
62705
|
-
import { dirname as dirname12, join as join12, resolve as
|
|
63320
|
+
import { dirname as dirname12, join as join12, resolve as resolve14 } from "node:path";
|
|
62706
63321
|
import { promisify } from "node:util";
|
|
62707
|
-
|
|
62708
|
-
// src/runtime.ts
|
|
62709
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
62710
|
-
import { access, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
62711
|
-
import { createRequire as createRequire3 } from "node:module";
|
|
62712
|
-
import { basename as basename2, dirname as dirname11, join as join11 } from "node:path";
|
|
62713
|
-
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
62714
|
-
var RUNTIME_IGNORES = ["node_modules/", ".waitcher/", ".e2e/"];
|
|
62715
|
-
async function installedPackage(project, name5) {
|
|
62716
|
-
try {
|
|
62717
|
-
let dir = dirname11(
|
|
62718
|
-
createRequire3(join11(project, "package.json")).resolve(name5)
|
|
62719
|
-
);
|
|
62720
|
-
for (let i = 0; i < 6; i++, dir = dirname11(dir)) {
|
|
62721
|
-
try {
|
|
62722
|
-
const meta3 = JSON.parse(await readFile6(join11(dir, "package.json"), "utf8"));
|
|
62723
|
-
if (meta3.name === name5) return { dir, version: meta3.version };
|
|
62724
|
-
} catch {
|
|
62725
|
-
}
|
|
62726
|
-
}
|
|
62727
|
-
} catch {
|
|
62728
|
-
}
|
|
62729
|
-
return null;
|
|
62730
|
-
}
|
|
62731
|
-
var installedVersion = async (project, name5) => (await installedPackage(project, name5))?.version ?? null;
|
|
62732
|
-
async function chromiumInstalled(project) {
|
|
62733
|
-
try {
|
|
62734
|
-
const web = await installedPackage(project, "@e2e-dev/web");
|
|
62735
|
-
if (!web) return false;
|
|
62736
|
-
const core = createRequire3(join11(web.dir, "package.json")).resolve("playwright-core");
|
|
62737
|
-
const playwright = await import(pathToFileURL3(core).href);
|
|
62738
|
-
await access((playwright.default ?? playwright).chromium.executablePath());
|
|
62739
|
-
return true;
|
|
62740
|
-
} catch {
|
|
62741
|
-
return false;
|
|
62742
|
-
}
|
|
62743
|
-
}
|
|
62744
|
-
function pinPackageJson(existing, project, pins = RUNTIME_PINS) {
|
|
62745
|
-
const json3 = existing ? structuredClone(existing) : {
|
|
62746
|
-
name: basename2(project).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "") || "waitcher-monitors",
|
|
62747
|
-
private: true
|
|
62748
|
-
};
|
|
62749
|
-
const changes = [];
|
|
62750
|
-
for (const [name5, to] of Object.entries(pins)) {
|
|
62751
|
-
const field = json3.dependencies?.[name5] !== void 0 ? "dependencies" : "devDependencies";
|
|
62752
|
-
const from = json3[field]?.[name5] ?? null;
|
|
62753
|
-
if (from === to) continue;
|
|
62754
|
-
json3[field] = { ...json3[field], [name5]: to };
|
|
62755
|
-
changes.push({ name: name5, from, to });
|
|
62756
|
-
}
|
|
62757
|
-
for (const [name5, nested] of Object.entries(RUNTIME_OVERRIDES))
|
|
62758
|
-
for (const [dep, to] of Object.entries(nested)) {
|
|
62759
|
-
const current = json3.overrides?.[name5];
|
|
62760
|
-
const from = typeof current === "object" ? current?.[dep] ?? null : null;
|
|
62761
|
-
if (from === to) continue;
|
|
62762
|
-
json3.overrides = {
|
|
62763
|
-
...json3.overrides,
|
|
62764
|
-
[name5]: { ...typeof current === "object" ? current : {}, [dep]: to }
|
|
62765
|
-
};
|
|
62766
|
-
changes.push({ name: `overrides.${name5}.${dep}`, from, to });
|
|
62767
|
-
}
|
|
62768
|
-
return { json: json3, changes };
|
|
62769
|
-
}
|
|
62770
|
-
var missingIgnores = (text4) => {
|
|
62771
|
-
const lines = new Set(
|
|
62772
|
-
text4.split(/\r?\n/).map((l) => l.trim().replace(/^\//, ""))
|
|
62773
|
-
);
|
|
62774
|
-
return RUNTIME_IGNORES.filter(
|
|
62775
|
-
(entry2) => !lines.has(entry2) && !lines.has(entry2.slice(0, -1))
|
|
62776
|
-
);
|
|
62777
|
-
};
|
|
62778
|
-
function run(command, args, cwd, signal) {
|
|
62779
|
-
return new Promise((resolve18, reject) => {
|
|
62780
|
-
const child2 = spawn2(command, args, {
|
|
62781
|
-
cwd,
|
|
62782
|
-
signal,
|
|
62783
|
-
stdio: ["ignore", process.stderr, process.stderr],
|
|
62784
|
-
shell: process.platform === "win32"
|
|
62785
|
-
});
|
|
62786
|
-
child2.on("error", reject);
|
|
62787
|
-
child2.on(
|
|
62788
|
-
"exit",
|
|
62789
|
-
(code) => code === 0 ? resolve18() : reject(
|
|
62790
|
-
new ServiceError(
|
|
62791
|
-
`${command} ${args.join(" ")} exited with ${code}; read its output above.`,
|
|
62792
|
-
"RUNTIME_INSTALL_FAILED",
|
|
62793
|
-
1
|
|
62794
|
-
)
|
|
62795
|
-
)
|
|
62796
|
-
);
|
|
62797
|
-
});
|
|
62798
|
-
}
|
|
62799
|
-
async function installRuntime(options) {
|
|
62800
|
-
const { project, browser, yes, signal } = options;
|
|
62801
|
-
const manifestPath = join11(project, "package.json");
|
|
62802
|
-
const text4 = await readFile6(manifestPath, "utf8").catch(() => null);
|
|
62803
|
-
let existing = null;
|
|
62804
|
-
if (text4 !== null)
|
|
62805
|
-
try {
|
|
62806
|
-
existing = JSON.parse(text4);
|
|
62807
|
-
} catch (cause) {
|
|
62808
|
-
throw new ServiceError(
|
|
62809
|
-
`${manifestPath} is not valid JSON: ${cause.message}`,
|
|
62810
|
-
"VALIDATION_ERROR",
|
|
62811
|
-
2
|
|
62812
|
-
);
|
|
62813
|
-
}
|
|
62814
|
-
const needed = runtimePackages(browser);
|
|
62815
|
-
const installed = {};
|
|
62816
|
-
for (const name5 of Object.keys(RUNTIME_PINS))
|
|
62817
|
-
installed[name5] = await installedVersion(project, name5);
|
|
62818
|
-
const generation = options.generation ?? installedGeneration(installed, browser) ?? RUNTIME_GENERATIONS[0];
|
|
62819
|
-
const pins = generationPins(generation);
|
|
62820
|
-
const { json: json3, changes } = pinPackageJson(existing, project, pins);
|
|
62821
|
-
const stale = Object.keys(pins).filter(
|
|
62822
|
-
(name5) => installed[name5] !== pins[name5]
|
|
62823
|
-
);
|
|
62824
|
-
const ignorePath = join11(project, ".gitignore");
|
|
62825
|
-
const ignoreText = await readFile6(ignorePath, "utf8").catch(() => "");
|
|
62826
|
-
const ignores = [];
|
|
62827
|
-
for (const entry2 of missingIgnores(ignoreText))
|
|
62828
|
-
if (!await gitIgnored(project, entry2)) ignores.push(entry2);
|
|
62829
|
-
const npmInstall = changes.length > 0 || stale.length > 0;
|
|
62830
|
-
const chromium = browser && (npmInstall || !await chromiumInstalled(project));
|
|
62831
|
-
const steps = [
|
|
62832
|
-
...changes.length ? [`${existing ? "update" : "create"} ${manifestPath}: ${changes.map((c) => `${c.name} ${c.from ?? "(none)"} -> ${c.to}`).join(", ")}`] : [],
|
|
62833
|
-
...ignores.length ? [`add ${ignores.join(" ")} to ${ignorePath}`] : [],
|
|
62834
|
-
...npmInstall ? [`npm install in ${project} (runs package install scripts)`] : [],
|
|
62835
|
-
...chromium ? ["npx --no-install e2e-web install chromium (downloads Chromium)"] : []
|
|
62836
|
-
];
|
|
62837
|
-
const base2 = {
|
|
62838
|
-
project,
|
|
62839
|
-
generation: generation.id,
|
|
62840
|
-
runtime: pins,
|
|
62841
|
-
packages: needed,
|
|
62842
|
-
browser,
|
|
62843
|
-
installed,
|
|
62844
|
-
changes,
|
|
62845
|
-
gitignore: ignores
|
|
62846
|
-
};
|
|
62847
|
-
if (!npmInstall && !ignores.length && !chromium)
|
|
62848
|
-
return { event: "runtime_current", ok: true, applied: false, ...base2, steps: [], next: [] };
|
|
62849
|
-
if (!yes)
|
|
62850
|
-
return {
|
|
62851
|
-
event: "runtime_planned",
|
|
62852
|
-
ok: true,
|
|
62853
|
-
applied: false,
|
|
62854
|
-
...base2,
|
|
62855
|
-
steps,
|
|
62856
|
-
next: [
|
|
62857
|
-
`Ask the user to agree to these steps, then run waitcher runtime install --file ${join11(project, "waitcher.json")} --yes`
|
|
62858
|
-
]
|
|
62859
|
-
};
|
|
62860
|
-
if (changes.length)
|
|
62861
|
-
await writeFile7(manifestPath, JSON.stringify(json3, null, 2) + "\n");
|
|
62862
|
-
if (ignores.length)
|
|
62863
|
-
await writeFile7(
|
|
62864
|
-
ignorePath,
|
|
62865
|
-
`${ignoreText}${ignoreText && !ignoreText.endsWith("\n") ? "\n" : ""}${ignores.join("\n")}
|
|
62866
|
-
`
|
|
62867
|
-
);
|
|
62868
|
-
if (npmInstall)
|
|
62869
|
-
await run("npm", ["install", "--no-audit", "--no-fund"], project, signal);
|
|
62870
|
-
if (chromium)
|
|
62871
|
-
await run("npx", ["--no-install", "e2e-web", "install", "chromium"], project, signal);
|
|
62872
|
-
for (const name5 of needed) {
|
|
62873
|
-
const found = await installedVersion(project, name5);
|
|
62874
|
-
if (found !== pins[name5])
|
|
62875
|
-
throw new ServiceError(
|
|
62876
|
-
`${name5}@${pins[name5]} is still not resolvable from ${project} (found ${found ?? "nothing"}). A parent workspace or lockfile may override it.`,
|
|
62877
|
-
"RUNTIME_VERSION_MISMATCH",
|
|
62878
|
-
2
|
|
62879
|
-
);
|
|
62880
|
-
}
|
|
62881
|
-
return {
|
|
62882
|
-
event: "runtime_installed",
|
|
62883
|
-
ok: true,
|
|
62884
|
-
applied: true,
|
|
62885
|
-
...base2,
|
|
62886
|
-
installed: Object.fromEntries(needed.map((n) => [n, pins[n]])),
|
|
62887
|
-
steps,
|
|
62888
|
-
next: [
|
|
62889
|
-
`waitcher config validate --file ${join11(project, "waitcher.json")}`,
|
|
62890
|
-
`waitcher deploy plan --file ${join11(project, "waitcher.json")} --env ENV --verify`,
|
|
62891
|
-
"Commit package.json, package-lock.json and .gitignore"
|
|
62892
|
-
]
|
|
62893
|
-
};
|
|
62894
|
-
}
|
|
62895
|
-
function gitIgnored(project, entry2) {
|
|
62896
|
-
return new Promise((done) => {
|
|
62897
|
-
const child2 = spawn2("git", ["check-ignore", "-q", "--no-index", entry2], {
|
|
62898
|
-
cwd: project,
|
|
62899
|
-
stdio: "ignore"
|
|
62900
|
-
});
|
|
62901
|
-
child2.once("error", () => done(false));
|
|
62902
|
-
child2.once("close", (code) => done(code === 0));
|
|
62903
|
-
});
|
|
62904
|
-
}
|
|
62905
|
-
|
|
62906
|
-
// src/config.ts
|
|
62907
63322
|
var configExample = (project, baseUrl) => ({
|
|
62908
63323
|
$schema: PROJECT_SCHEMA_URL,
|
|
62909
63324
|
schemaVersion: 1,
|
|
@@ -62960,7 +63375,7 @@ async function buildEntries(path2, config2) {
|
|
|
62960
63375
|
const at = `monitors[${index}].entry`;
|
|
62961
63376
|
try {
|
|
62962
63377
|
const built = await buildScript({
|
|
62963
|
-
entry: await realpath3(
|
|
63378
|
+
entry: await realpath3(resolve14(project, entry2)).catch(() => {
|
|
62964
63379
|
throw new Error(`${entry2} was not found next to waitcher.json`);
|
|
62965
63380
|
}),
|
|
62966
63381
|
project
|
|
@@ -63057,12 +63472,12 @@ async function verifyLocally(options) {
|
|
|
63057
63472
|
);
|
|
63058
63473
|
return { runs, issues: issues2 };
|
|
63059
63474
|
}
|
|
63060
|
-
var configPath = (file2) =>
|
|
63475
|
+
var configPath = (file2) => resolve14(file2 ?? CONFIG_FILE);
|
|
63061
63476
|
async function readProjectConfig(file2) {
|
|
63062
63477
|
const path2 = configPath(file2);
|
|
63063
|
-
let
|
|
63478
|
+
let text5;
|
|
63064
63479
|
try {
|
|
63065
|
-
|
|
63480
|
+
text5 = await readFile7(path2, "utf8");
|
|
63066
63481
|
} catch {
|
|
63067
63482
|
throw new ServiceError(
|
|
63068
63483
|
`${path2} was not found. Run waitcher config init or pass --file.`,
|
|
@@ -63070,14 +63485,14 @@ async function readProjectConfig(file2) {
|
|
|
63070
63485
|
2
|
|
63071
63486
|
);
|
|
63072
63487
|
}
|
|
63073
|
-
if (Buffer.byteLength(
|
|
63488
|
+
if (Buffer.byteLength(text5) > CONFIG_LIMITS.bytes)
|
|
63074
63489
|
throw new ServiceError(
|
|
63075
63490
|
`waitcher.json exceeds ${CONFIG_LIMITS.bytes} bytes.`,
|
|
63076
63491
|
"VALIDATION_ERROR",
|
|
63077
63492
|
2
|
|
63078
63493
|
);
|
|
63079
63494
|
try {
|
|
63080
|
-
return { path: path2, config: JSON.parse(
|
|
63495
|
+
return { path: path2, config: JSON.parse(text5) };
|
|
63081
63496
|
} catch (cause) {
|
|
63082
63497
|
throw new ServiceError(
|
|
63083
63498
|
`waitcher.json is not valid JSON: ${cause.message}`,
|
|
@@ -63152,7 +63567,7 @@ function deployNextSteps(result2, {
|
|
|
63152
63567
|
}
|
|
63153
63568
|
|
|
63154
63569
|
// src/upgrade.ts
|
|
63155
|
-
import { readdir as
|
|
63570
|
+
import { readdir as readdir3, readFile as readFile8, stat } from "node:fs/promises";
|
|
63156
63571
|
import { dirname as dirname13, join as join13, relative as relative3 } from "node:path";
|
|
63157
63572
|
var SCAN = { files: 2e3, bytes: 1024 * 1024, matches: 20 };
|
|
63158
63573
|
var SOURCE = /\.(m|c)?(j|t)sx?$/;
|
|
@@ -63160,7 +63575,7 @@ var SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".waitcher", ".e2e",
|
|
|
63160
63575
|
async function findChanges(project, changes) {
|
|
63161
63576
|
const files = [];
|
|
63162
63577
|
async function walk(dir) {
|
|
63163
|
-
for (const item of await
|
|
63578
|
+
for (const item of await readdir3(dir, { withFileTypes: true }).catch(() => [])) {
|
|
63164
63579
|
if (files.length >= SCAN.files) return;
|
|
63165
63580
|
if (SKIP.has(item.name)) continue;
|
|
63166
63581
|
const path2 = join13(dir, item.name);
|
|
@@ -63178,9 +63593,9 @@ async function findChanges(project, changes) {
|
|
|
63178
63593
|
if (change.find) {
|
|
63179
63594
|
const pattern = new RegExp(change.find);
|
|
63180
63595
|
for (const [file2, lines] of texts)
|
|
63181
|
-
lines.forEach((
|
|
63182
|
-
if (matches2.length < SCAN.matches && pattern.test(
|
|
63183
|
-
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) });
|
|
63184
63599
|
});
|
|
63185
63600
|
}
|
|
63186
63601
|
return { ...change, matches: matches2 };
|
|
@@ -63302,19 +63717,19 @@ async function upgrade(options) {
|
|
|
63302
63717
|
}
|
|
63303
63718
|
|
|
63304
63719
|
// ../../skills/waitcher/SKILL.md
|
|
63305
|
-
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
|
|
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";
|
|
63306
63721
|
|
|
63307
63722
|
// ../../skills/waitcher/references/authoring.md
|
|
63308
|
-
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';
|
|
63309
63724
|
|
|
63310
63725
|
// ../../skills/waitcher/references/ai-and-agents.md
|
|
63311
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";
|
|
63312
63727
|
|
|
63313
63728
|
// ../../skills/waitcher/references/deploy.md
|
|
63314
|
-
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\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
|
|
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';
|
|
63315
63730
|
|
|
63316
63731
|
// ../../skills/waitcher/references/diagnosis.md
|
|
63317
|
-
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';
|
|
63318
63733
|
|
|
63319
63734
|
// ../../skills/waitcher/references/optional-capabilities.md
|
|
63320
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';
|
|
@@ -63325,7 +63740,7 @@ var openai_default = 'interface:\n display_name: "Waitcher"\n short_descriptio
|
|
|
63325
63740
|
// src/skill.ts
|
|
63326
63741
|
import { lstat as lstat9, mkdir as mkdir8, readFile as readFile9, rm as rm6, writeFile as writeFile9 } from "node:fs/promises";
|
|
63327
63742
|
import { homedir } from "node:os";
|
|
63328
|
-
import { join as join14, resolve as
|
|
63743
|
+
import { join as join14, resolve as resolve15 } from "node:path";
|
|
63329
63744
|
var references = {
|
|
63330
63745
|
"authoring.md": authoring_default,
|
|
63331
63746
|
"ai-and-agents.md": ai_and_agents_default,
|
|
@@ -63337,46 +63752,63 @@ var bundledSkill = { name: "waitcher", content: SKILL_default, references };
|
|
|
63337
63752
|
var MARKER = ".waitcher-skill.json";
|
|
63338
63753
|
var SkillInstallError = class extends Error {
|
|
63339
63754
|
};
|
|
63340
|
-
|
|
63341
|
-
|
|
63342
|
-
|
|
63343
|
-
|
|
63344
|
-
|
|
63755
|
+
function skillParents(options) {
|
|
63756
|
+
if (options.path) return [resolve15(options.path)];
|
|
63757
|
+
if (options.global)
|
|
63758
|
+
return [
|
|
63759
|
+
join14(homedir(), ".claude", "skills"),
|
|
63760
|
+
join14(homedir(), ".agents", "skills")
|
|
63761
|
+
];
|
|
63762
|
+
return [
|
|
63763
|
+
join14(process.cwd(), ".claude", "skills"),
|
|
63764
|
+
join14(process.cwd(), ".agents", "skills")
|
|
63765
|
+
];
|
|
63766
|
+
}
|
|
63767
|
+
async function previous(directory) {
|
|
63345
63768
|
const existing = await lstat9(directory).catch(() => null);
|
|
63346
|
-
|
|
63347
|
-
|
|
63348
|
-
|
|
63349
|
-
|
|
63350
|
-
|
|
63351
|
-
|
|
63352
|
-
|
|
63353
|
-
|
|
63354
|
-
|
|
63355
|
-
|
|
63356
|
-
|
|
63357
|
-
|
|
63358
|
-
|
|
63359
|
-
|
|
63360
|
-
|
|
63361
|
-
|
|
63362
|
-
|
|
63363
|
-
|
|
63364
|
-
join14(directory,
|
|
63365
|
-
|
|
63366
|
-
|
|
63769
|
+
if (!existing) return null;
|
|
63770
|
+
const marker2 = existing.isDirectory() ? await readFile9(join14(directory, MARKER), "utf8").catch(() => null) : null;
|
|
63771
|
+
if (marker2 === null)
|
|
63772
|
+
throw new SkillInstallError(
|
|
63773
|
+
`${directory} exists and was not installed by waitcher. Remove it or choose another --path.`
|
|
63774
|
+
);
|
|
63775
|
+
return String(JSON.parse(marker2).version ?? "unknown");
|
|
63776
|
+
}
|
|
63777
|
+
async function installSkill(options) {
|
|
63778
|
+
const directories = skillParents(options).map((parent) => join14(parent, "waitcher"));
|
|
63779
|
+
const versions = [];
|
|
63780
|
+
for (const directory of directories) versions.push(await previous(directory));
|
|
63781
|
+
for (const [i, directory] of directories.entries()) {
|
|
63782
|
+
if (versions[i] !== null)
|
|
63783
|
+
for (const owned of ["SKILL.md", "references", "agents", MARKER])
|
|
63784
|
+
await rm6(join14(directory, owned), { recursive: true, force: true });
|
|
63785
|
+
await mkdir8(join14(directory, "references"), { recursive: true });
|
|
63786
|
+
await mkdir8(join14(directory, "agents"), { recursive: true });
|
|
63787
|
+
await writeFile9(join14(directory, "SKILL.md"), SKILL_default);
|
|
63788
|
+
for (const [name5, text5] of Object.entries(references))
|
|
63789
|
+
await writeFile9(join14(directory, "references", name5), text5);
|
|
63790
|
+
await writeFile9(join14(directory, "agents/openai.yaml"), openai_default);
|
|
63791
|
+
await writeFile9(
|
|
63792
|
+
join14(directory, MARKER),
|
|
63793
|
+
JSON.stringify({ name: "waitcher", version: options.version }) + "\n"
|
|
63794
|
+
);
|
|
63795
|
+
}
|
|
63796
|
+
const previousVersion = versions.find((version2) => version2 !== null);
|
|
63367
63797
|
return {
|
|
63368
|
-
event:
|
|
63798
|
+
event: versions.every((version2) => version2 !== null) ? "skill_updated" : "skill_installed",
|
|
63369
63799
|
name: "waitcher",
|
|
63370
63800
|
version: options.version,
|
|
63371
|
-
...previousVersion
|
|
63372
|
-
directory,
|
|
63801
|
+
...previousVersion ? { previousVersion } : {},
|
|
63802
|
+
// directory: the first, as before; directories: every one written.
|
|
63803
|
+
directory: directories[0],
|
|
63804
|
+
directories,
|
|
63373
63805
|
files: [
|
|
63374
63806
|
"SKILL.md",
|
|
63375
63807
|
...Object.keys(references).map((n) => `references/${n}`),
|
|
63376
63808
|
"agents/openai.yaml"
|
|
63377
63809
|
],
|
|
63378
63810
|
next: options.path || options.global ? ["Run waitcher skill install again after upgrading the CLI."] : [
|
|
63379
|
-
`Commit ${join14(".claude", "skills", "waitcher")} so every agent working in this repository finds
|
|
63811
|
+
`Commit ${join14(".claude", "skills", "waitcher")} (Claude Code, Copilot) and ${join14(".agents", "skills", "waitcher")} (Codex) so every agent working in this repository finds the skill.`,
|
|
63380
63812
|
"Run waitcher skill install again after upgrading the CLI."
|
|
63381
63813
|
]
|
|
63382
63814
|
};
|
|
@@ -63408,15 +63840,28 @@ async function doctor(options) {
|
|
|
63408
63840
|
);
|
|
63409
63841
|
add({ id: "cli", status: "ok", message: `waitcher ${options.version}` });
|
|
63410
63842
|
let config2, path2;
|
|
63843
|
+
let localOnly = false;
|
|
63411
63844
|
try {
|
|
63412
63845
|
({ config: config2, path: path2 } = await readProjectConfig(options.file));
|
|
63413
63846
|
} catch (cause) {
|
|
63414
|
-
|
|
63415
|
-
|
|
63416
|
-
|
|
63417
|
-
|
|
63418
|
-
|
|
63419
|
-
|
|
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
|
+
);
|
|
63420
63865
|
}
|
|
63421
63866
|
const environments = [];
|
|
63422
63867
|
let built;
|
|
@@ -63472,6 +63917,8 @@ async function doctor(options) {
|
|
|
63472
63917
|
join15(root, ".claude", "skills", "waitcher"),
|
|
63473
63918
|
join15(homedir2(), ".claude", "skills", "waitcher"),
|
|
63474
63919
|
join15(root, ".agents", "skills", "waitcher"),
|
|
63920
|
+
join15(homedir2(), ".agents", "skills", "waitcher"),
|
|
63921
|
+
// Older Codex releases read $CODEX_HOME/skills.
|
|
63475
63922
|
join15(process.env.CODEX_HOME ?? join15(homedir2(), ".codex"), "skills", "waitcher"),
|
|
63476
63923
|
...folders.slice(1).flatMap((dir) => [
|
|
63477
63924
|
join15(dir, ".claude", "skills", "waitcher"),
|
|
@@ -63482,32 +63929,49 @@ async function doctor(options) {
|
|
|
63482
63929
|
for (const home of skillHomes) {
|
|
63483
63930
|
if (!await exists(join15(home, "SKILL.md"))) continue;
|
|
63484
63931
|
installed.push(home);
|
|
63485
|
-
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);
|
|
63486
63933
|
if (marker2 && marker2.version !== options.version) stale.push(home);
|
|
63487
63934
|
}
|
|
63488
|
-
const install = root === process.cwd() ? "waitcher skill install" : `waitcher skill install --path ${join15(root,
|
|
63935
|
+
const install = root === process.cwd() ? ["waitcher skill install"] : [".claude", ".agents"].map((agent) => `waitcher skill install --path ${join15(root, agent, "skills")}`);
|
|
63489
63936
|
add(
|
|
63490
63937
|
!installed.length ? {
|
|
63491
63938
|
id: "skill",
|
|
63492
63939
|
status: "warning",
|
|
63493
63940
|
message: "The waitcher agent skill is not installed where common agents look",
|
|
63494
|
-
next:
|
|
63941
|
+
next: install
|
|
63495
63942
|
} : stale.length ? {
|
|
63496
63943
|
id: "skill",
|
|
63497
63944
|
status: "warning",
|
|
63498
63945
|
message: `Agent skill at ${stale.join(", ")} comes from another CLI version than ${options.version}`,
|
|
63499
|
-
next:
|
|
63500
|
-
|
|
63501
|
-
|
|
63946
|
+
next: [
|
|
63947
|
+
...new Set(
|
|
63948
|
+
stale.map(
|
|
63949
|
+
(home) => root === process.cwd() && (home === skillHomes[0] || home === skillHomes[2]) ? "waitcher skill install" : home === skillHomes[1] || home === skillHomes[3] ? "waitcher skill install --global" : `waitcher skill install --path ${dirname14(home)}`
|
|
63950
|
+
)
|
|
63951
|
+
)
|
|
63952
|
+
]
|
|
63502
63953
|
} : { id: "skill", status: "ok", message: `Agent skill at ${installed.join(", ")}` }
|
|
63503
63954
|
);
|
|
63504
|
-
|
|
63505
|
-
|
|
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") {
|
|
63506
63962
|
add({
|
|
63507
63963
|
id: "session",
|
|
63508
63964
|
status: "error",
|
|
63509
|
-
message:
|
|
63510
|
-
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)"]
|
|
63511
63975
|
});
|
|
63512
63976
|
} else {
|
|
63513
63977
|
const capabilities = await api("capabilities");
|
|
@@ -63605,7 +64069,7 @@ function olderVersion(a, b) {
|
|
|
63605
64069
|
// src/ci.ts
|
|
63606
64070
|
import { execFile as execFile2 } from "node:child_process";
|
|
63607
64071
|
import { mkdir as mkdir9 } from "node:fs/promises";
|
|
63608
|
-
import { dirname as dirname15, relative as relative4, resolve as
|
|
64072
|
+
import { dirname as dirname15, relative as relative4, resolve as resolve16 } from "node:path";
|
|
63609
64073
|
import { promisify as promisify2 } from "node:util";
|
|
63610
64074
|
async function defaultBranch(cwd) {
|
|
63611
64075
|
try {
|
|
@@ -63621,7 +64085,7 @@ async function defaultBranch(cwd) {
|
|
|
63621
64085
|
}
|
|
63622
64086
|
async function initWorkflow(options) {
|
|
63623
64087
|
const root = process.cwd();
|
|
63624
|
-
const output2 =
|
|
64088
|
+
const output2 = resolve16(options.output ?? ".github/workflows/waitcher.yml");
|
|
63625
64089
|
const config2 = relative4(root, options.config) || "waitcher.json";
|
|
63626
64090
|
if (config2.startsWith(".."))
|
|
63627
64091
|
throw new Error("Run ci init from the repository root that contains waitcher.json.");
|
|
@@ -63693,8 +64157,8 @@ jobs:
|
|
|
63693
64157
|
}
|
|
63694
64158
|
|
|
63695
64159
|
// src/main.ts
|
|
63696
|
-
import { readFile as readFile12, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
|
|
63697
|
-
import { basename as basename3, dirname as dirname18, join as join17, resolve as
|
|
64160
|
+
import { access as access3, readFile as readFile12, open as open18, lstat as lstat12, unlink as unlink5 } from "node:fs/promises";
|
|
64161
|
+
import { basename as basename3, dirname as dirname18, join as join17, resolve as resolve18 } from "node:path";
|
|
63698
64162
|
import { constants as constants13 } from "node:fs";
|
|
63699
64163
|
|
|
63700
64164
|
// ../../src/contracts/account-deletion.ts
|
|
@@ -63898,10 +64362,9 @@ var STATUS_PAGE_LIMITS = Object.freeze({
|
|
|
63898
64362
|
var plain = (max) => external_exports.string().trim().max(max).refine((v) => !/[\u0000-\u001f\u007f<>]/.test(v), {
|
|
63899
64363
|
message: "Use plain text without line breaks or angle brackets"
|
|
63900
64364
|
});
|
|
63901
|
-
var
|
|
63902
|
-
|
|
63903
|
-
|
|
63904
|
-
);
|
|
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);
|
|
63905
64368
|
var statusPageSchema = external_exports.object({
|
|
63906
64369
|
slug: statusSlugSchema,
|
|
63907
64370
|
title: plain(80).pipe(external_exports.string().min(1)),
|
|
@@ -63968,9 +64431,9 @@ var incidentEditSchema = external_exports.object({
|
|
|
63968
64431
|
|
|
63969
64432
|
// src/access.ts
|
|
63970
64433
|
import { lstat as lstat10, open as open16, unlink as unlink3 } from "node:fs/promises";
|
|
63971
|
-
import { dirname as dirname16, resolve as
|
|
63972
|
-
function accessTokenInput(
|
|
63973
|
-
let token =
|
|
64434
|
+
import { dirname as dirname16, resolve as resolve17 } from "node:path";
|
|
64435
|
+
function accessTokenInput(text5) {
|
|
64436
|
+
let token = text5.trim();
|
|
63974
64437
|
if (token.startsWith("{")) {
|
|
63975
64438
|
try {
|
|
63976
64439
|
token = JSON.parse(token).token;
|
|
@@ -63993,7 +64456,7 @@ async function issueToFile(path2, issue3) {
|
|
|
63993
64456
|
"VALIDATION_ERROR",
|
|
63994
64457
|
2
|
|
63995
64458
|
);
|
|
63996
|
-
const file2 =
|
|
64459
|
+
const file2 = resolve17(path2), directory = await lstat10(dirname16(file2));
|
|
63997
64460
|
if (!directory.isDirectory() || directory.isSymbolicLink() || process.platform !== "win32" && directory.mode & 63)
|
|
63998
64461
|
throw new ServiceError(
|
|
63999
64462
|
"Token output requires an existing private directory (chmod 700).",
|
|
@@ -64061,25 +64524,37 @@ function sessionPath(server) {
|
|
|
64061
64524
|
createHash11("sha256").update(server).digest("hex").slice(0, 24) + ".json"
|
|
64062
64525
|
);
|
|
64063
64526
|
}
|
|
64064
|
-
|
|
64065
|
-
|
|
64066
|
-
|
|
64067
|
-
|
|
64068
|
-
|
|
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.`
|
|
64069
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
|
+
}
|
|
64070
64545
|
if (!directory && info.size > 8192)
|
|
64071
64546
|
throw new Error("Credential file is too large.");
|
|
64072
64547
|
}
|
|
64073
|
-
async function readPrivate(path2) {
|
|
64074
|
-
await privatePath(path2);
|
|
64548
|
+
async function readPrivate(path2, session = false) {
|
|
64549
|
+
await privatePath(path2, false, session);
|
|
64075
64550
|
return readFile11(path2, "utf8");
|
|
64076
64551
|
}
|
|
64077
64552
|
async function loadSession(server) {
|
|
64078
64553
|
const path2 = sessionPath(server);
|
|
64079
|
-
let
|
|
64554
|
+
let text5;
|
|
64080
64555
|
try {
|
|
64081
64556
|
await privatePath(dirname17(path2), true);
|
|
64082
|
-
|
|
64557
|
+
text5 = await readPrivate(path2, true);
|
|
64083
64558
|
} catch (cause) {
|
|
64084
64559
|
const error62 = asError(cause);
|
|
64085
64560
|
if (error62.code === "ENOENT")
|
|
@@ -64090,7 +64565,7 @@ async function loadSession(server) {
|
|
|
64090
64565
|
}
|
|
64091
64566
|
let session;
|
|
64092
64567
|
try {
|
|
64093
|
-
session = JSON.parse(
|
|
64568
|
+
session = JSON.parse(text5);
|
|
64094
64569
|
} catch {
|
|
64095
64570
|
throw new Error("Saved session is unreadable. Run auth login again.");
|
|
64096
64571
|
}
|
|
@@ -64145,7 +64620,7 @@ async function writeSession(server, value2) {
|
|
|
64145
64620
|
await mkdir10(directory, { recursive: true, mode: 448 });
|
|
64146
64621
|
await privatePath(directory, true);
|
|
64147
64622
|
try {
|
|
64148
|
-
await privatePath(path2);
|
|
64623
|
+
await privatePath(path2, false, true);
|
|
64149
64624
|
} catch (cause) {
|
|
64150
64625
|
const error62 = asError(cause);
|
|
64151
64626
|
if (error62.code !== "ENOENT") throw error62;
|
|
@@ -64249,26 +64724,26 @@ async function post(config2, endpoint, fields, signal) {
|
|
|
64249
64724
|
);
|
|
64250
64725
|
return data;
|
|
64251
64726
|
}
|
|
64252
|
-
function tokenSession(config2, data,
|
|
64253
|
-
if (typeof data?.token_type !== "string" || data.token_type.toLowerCase() !== "bearer" || typeof data.access_token !== "string" || !data.access_token || typeof (data.refresh_token ??
|
|
64727
|
+
function tokenSession(config2, data, previous2) {
|
|
64728
|
+
if (typeof data?.token_type !== "string" || data.token_type.toLowerCase() !== "bearer" || typeof data.access_token !== "string" || !data.access_token || typeof (data.refresh_token ?? previous2) !== "string" || !(data.refresh_token ?? previous2) || typeof data.expires_in !== "number" || !Number.isFinite(data.expires_in) || data.expires_in <= 0 || data.expires_in > 172800)
|
|
64254
64729
|
throw fail("Clerk returned an invalid token response.");
|
|
64255
64730
|
return {
|
|
64256
64731
|
...config2,
|
|
64257
64732
|
accessToken: data.access_token,
|
|
64258
|
-
refreshToken: data.refresh_token ??
|
|
64733
|
+
refreshToken: data.refresh_token ?? previous2,
|
|
64259
64734
|
expiresAt: Date.now() + data.expires_in * 1e3
|
|
64260
64735
|
};
|
|
64261
64736
|
}
|
|
64262
64737
|
async function openBrowser(url3) {
|
|
64263
64738
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
|
|
64264
64739
|
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url3] : [url3];
|
|
64265
|
-
await new Promise((
|
|
64740
|
+
await new Promise((resolve19, reject) => {
|
|
64266
64741
|
const child2 = spawn3(command, args, { stdio: "ignore", shell: false });
|
|
64267
64742
|
child2.unref();
|
|
64268
64743
|
child2.once("error", reject);
|
|
64269
64744
|
child2.once(
|
|
64270
64745
|
"exit",
|
|
64271
|
-
(code) => code === 0 ?
|
|
64746
|
+
(code) => code === 0 ? resolve19() : reject(new Error("Browser unavailable"))
|
|
64272
64747
|
);
|
|
64273
64748
|
});
|
|
64274
64749
|
}
|
|
@@ -64286,8 +64761,8 @@ ${url3}
|
|
|
64286
64761
|
const verifier = randomBytes3(32).toString("base64url");
|
|
64287
64762
|
let redirect = "";
|
|
64288
64763
|
let finish;
|
|
64289
|
-
const callback = new Promise((
|
|
64290
|
-
finish = { resolve:
|
|
64764
|
+
const callback = new Promise((resolve19, reject) => {
|
|
64765
|
+
finish = { resolve: resolve19, reject };
|
|
64291
64766
|
});
|
|
64292
64767
|
callback.catch(() => {
|
|
64293
64768
|
});
|
|
@@ -64329,9 +64804,9 @@ ${url3}
|
|
|
64329
64804
|
let timer;
|
|
64330
64805
|
const cancel = () => finish.reject(fail("Sign-in was canceled."));
|
|
64331
64806
|
try {
|
|
64332
|
-
await new Promise((
|
|
64807
|
+
await new Promise((resolve19, reject) => {
|
|
64333
64808
|
listener.once("error", reject);
|
|
64334
|
-
listener.listen(0, "127.0.0.1",
|
|
64809
|
+
listener.listen(0, "127.0.0.1", resolve19);
|
|
64335
64810
|
});
|
|
64336
64811
|
redirect = `http://127.0.0.1:${listener.address().port}/callback`;
|
|
64337
64812
|
timer = setTimeout(
|
|
@@ -64376,7 +64851,7 @@ ${url3}
|
|
|
64376
64851
|
clearTimeout(timer);
|
|
64377
64852
|
signal?.removeEventListener("abort", cancel);
|
|
64378
64853
|
listener.closeAllConnections();
|
|
64379
|
-
await new Promise((
|
|
64854
|
+
await new Promise((resolve19) => listener.close(() => resolve19()));
|
|
64380
64855
|
}
|
|
64381
64856
|
}
|
|
64382
64857
|
async function refreshOAuth(server, session, signal) {
|
|
@@ -64415,7 +64890,7 @@ async function revokeOAuth(session, signal) {
|
|
|
64415
64890
|
var help = `Waitcher CLI
|
|
64416
64891
|
|
|
64417
64892
|
Usage: waitcher <group> <command> [options]
|
|
64418
|
-
Commands print JSON on stdout and errors as {error:{code,message}} on stderr;
|
|
64893
|
+
Commands print JSON on stdout and errors as {error:{code,message,next?}} on stderr;
|
|
64419
64894
|
run diagnose and run scenarios print a readable report unless --json. Help and version work offline.
|
|
64420
64895
|
waitcher help TOPIC (or waitcher GROUP --help) prints only matching sections, e.g. help deploy.
|
|
64421
64896
|
waitcher help all prints everything; waitcher --help prints an overview.
|
|
@@ -64423,9 +64898,10 @@ waitcher help all prints everything; waitcher --help prints an overview.
|
|
|
64423
64898
|
Agent skill
|
|
64424
64899
|
skill show Read the bundled skill and its references as JSON
|
|
64425
64900
|
skill install [--global | --path SKILLS_DIR]
|
|
64426
|
-
Install or update the skill in
|
|
64427
|
-
|
|
64428
|
-
|
|
64901
|
+
Install or update the skill for Claude Code and Codex in
|
|
64902
|
+
.claude/skills/waitcher and .agents/skills/waitcher (this
|
|
64903
|
+
project; --global: ~/.claude/skills and ~/.agents/skills;
|
|
64904
|
+
--path: only SKILLS_DIR). Rerun
|
|
64429
64905
|
after upgrading the CLI; never replaces a skill it did not write
|
|
64430
64906
|
|
|
64431
64907
|
Heartbeats
|
|
@@ -64532,6 +65008,9 @@ Capabilities
|
|
|
64532
65008
|
system capabilities Show account features, limits and contract versions
|
|
64533
65009
|
system diagnostics Operator resource, queue and storage diagnostics
|
|
64534
65010
|
system plans Administrator: plan profiles and accounts not on starter
|
|
65011
|
+
system accounts [--plan pilot] [--json]
|
|
65012
|
+
Administrator: every account's plan, monitors, runs and
|
|
65013
|
+
last activity; a table, or JSON with --json
|
|
64535
65014
|
system plan --owner clerk:USER_ID|team:ID --plan starter|pilot|pro|business|team
|
|
64536
65015
|
Administrator: assign a plan; takes effect immediately
|
|
64537
65016
|
system suspensions Administrator: accounts whose checks are suspended
|
|
@@ -64657,6 +65136,7 @@ Executions and reports
|
|
|
64657
65136
|
run local --project E2E_PROJECT [--output DIR] [--video] [--timeout 60]
|
|
64658
65137
|
Run trusted local tests without login or API access
|
|
64659
65138
|
Fresh output per run inside the project; video opt-in
|
|
65139
|
+
Not passing: code, message, trace and next. Browser: runtime install --browser first.
|
|
64660
65140
|
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60] [--update-baselines]
|
|
64661
65141
|
A finished run prints status, duration, message and a
|
|
64662
65142
|
report link (SERVER/app#run/RUN_ID) first;
|
|
@@ -64996,7 +65476,7 @@ var intro = `${title}
|
|
|
64996
65476
|
${usage}`;
|
|
64997
65477
|
var exitCodes = sections.find((s) => s.startsWith("Exit codes\n"));
|
|
64998
65478
|
var GROUPS = new Set(
|
|
64999
|
-
"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(
|
|
65000
65480
|
" "
|
|
65001
65481
|
)
|
|
65002
65482
|
);
|
|
@@ -65013,25 +65493,30 @@ var commands = (section) => {
|
|
|
65013
65493
|
([group, list2]) => list2.size ? `${group}: ${[...list2].join(", ")}` : group
|
|
65014
65494
|
);
|
|
65015
65495
|
};
|
|
65496
|
+
var HELP_TOPICS = [...GROUPS];
|
|
65016
65497
|
function helpTopic(topic) {
|
|
65017
|
-
const needle = topic.toLowerCase();
|
|
65498
|
+
const needle = topic.toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
65018
65499
|
if (needle === "all") return help;
|
|
65019
|
-
|
|
65500
|
+
if (!needle) return null;
|
|
65501
|
+
const word = new RegExp(`\\b${needle}\\b`);
|
|
65020
65502
|
const matches2 = sections.filter((section) => {
|
|
65021
65503
|
if (section === exitCodes) return false;
|
|
65022
65504
|
const [heading, ...lines] = section.split("\n");
|
|
65023
|
-
return word.test(heading.toLowerCase()) || lines.some(
|
|
65024
|
-
(
|
|
65025
|
-
|
|
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
|
+
});
|
|
65026
65510
|
});
|
|
65027
|
-
return matches2.length ? [intro, ...matches2, exitCodes].join("\n\n") + "\n" :
|
|
65028
|
-
|
|
65029
|
-
${overview()}`;
|
|
65511
|
+
return matches2.length ? [intro, ...matches2, exitCodes].join("\n\n") + "\n" : null;
|
|
65030
65512
|
}
|
|
65031
65513
|
function overview() {
|
|
65032
65514
|
const index = sections.map((section) => {
|
|
65033
65515
|
const list2 = commands(section);
|
|
65034
|
-
|
|
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}
|
|
65035
65520
|
${list2.join("\n ")}` : "";
|
|
65036
65521
|
}).filter(Boolean).join("\n");
|
|
65037
65522
|
return `${intro}
|
|
@@ -65055,14 +65540,50 @@ ${exitCodes}
|
|
|
65055
65540
|
`;
|
|
65056
65541
|
}
|
|
65057
65542
|
|
|
65543
|
+
// src/system-accounts.ts
|
|
65544
|
+
var date5 = (at) => at == null ? "-" : new Date(at).toISOString().slice(0, 10);
|
|
65545
|
+
var time3 = (at) => at == null ? "-" : new Date(at).toISOString().slice(0, 16).replace("T", " ");
|
|
65546
|
+
function formatSystemAccounts(result2) {
|
|
65547
|
+
const s = result2.summary;
|
|
65548
|
+
const head = [
|
|
65549
|
+
`Accounts ${s.accounts}, pilot ${s.pilot}, with an active monitor ${s.active}, script runs in 24 h ${s.scriptRuns24h}, still running after 30 days ${s.retained30d}`
|
|
65550
|
+
];
|
|
65551
|
+
if (!result2.accounts.length) return head.concat("No accounts match.", "").join("\n");
|
|
65552
|
+
const rows = [
|
|
65553
|
+
["OWNER", "PLAN", "FIRST SEEN", "MONITORS", "SCRIPTS 24H/7D", "OK 7D", "LAST RUN (UTC)", "DEPLOY", "OPEN", "TARGETS"],
|
|
65554
|
+
...result2.accounts.map((a) => [
|
|
65555
|
+
a.owner,
|
|
65556
|
+
`${a.plan} (${a.planSource})${a.suspended ? " SUSPENDED" : ""}`,
|
|
65557
|
+
date5(a.firstSeenAt),
|
|
65558
|
+
`${a.monitors.active} on / ${a.monitors.total}`,
|
|
65559
|
+
`${a.runs.scripts24h}/${a.runs.scripts7d}`,
|
|
65560
|
+
a.runs.successRate7d == null ? "-" : `${a.runs.successRate7d}%`,
|
|
65561
|
+
time3(a.runs.lastRunAt),
|
|
65562
|
+
date5(a.lastDeployAt),
|
|
65563
|
+
String(a.openIncidents),
|
|
65564
|
+
a.targets.length ? a.targets[0] + (a.targets.length > 1 ? ` +${a.targets.length - 1}` : "") : "-"
|
|
65565
|
+
])
|
|
65566
|
+
];
|
|
65567
|
+
const widths = rows[0].map((_, i) => Math.max(...rows.map((r) => r[i].length)));
|
|
65568
|
+
return head.concat(
|
|
65569
|
+
"",
|
|
65570
|
+
...rows.map(
|
|
65571
|
+
(r) => r.map((cell, i) => i === r.length - 1 ? cell : cell.padEnd(widths[i])).join(" ")
|
|
65572
|
+
),
|
|
65573
|
+
""
|
|
65574
|
+
).join("\n");
|
|
65575
|
+
}
|
|
65576
|
+
|
|
65058
65577
|
// src/main.ts
|
|
65059
|
-
var list = (
|
|
65578
|
+
var list = (text5) => (text5 ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
65060
65579
|
var issues = (all) => all.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n");
|
|
65061
65580
|
var controller = new AbortController();
|
|
65062
65581
|
process.once("SIGINT", () => controller.abort());
|
|
65063
65582
|
process.once("SIGTERM", () => controller.abort());
|
|
65064
|
-
function usage2(message) {
|
|
65065
|
-
|
|
65583
|
+
function usage2(message, next) {
|
|
65584
|
+
const error62 = new ServiceError(message, "USAGE_ERROR", 2);
|
|
65585
|
+
if (next) error62.next = next;
|
|
65586
|
+
throw error62;
|
|
65066
65587
|
}
|
|
65067
65588
|
function id3(value2) {
|
|
65068
65589
|
if (typeof value2 !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9-]{0,99}$/.test(value2))
|
|
@@ -65108,6 +65629,18 @@ async function deletionReceipt(file2, server) {
|
|
|
65108
65629
|
usage2("Use a deletion receipt for this exact server origin.");
|
|
65109
65630
|
return value2;
|
|
65110
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
|
+
};
|
|
65111
65644
|
async function authenticatedSession(server) {
|
|
65112
65645
|
try {
|
|
65113
65646
|
return await refreshOAuth(
|
|
@@ -65119,6 +65652,7 @@ async function authenticatedSession(server) {
|
|
|
65119
65652
|
const error62 = asError(cause);
|
|
65120
65653
|
if (["NETWORK_ERROR", "SERVICE_UNAVAILABLE"].includes(String(error62.code)))
|
|
65121
65654
|
throw cause;
|
|
65655
|
+
if (cause instanceof ConfigPermissionsError) throw configPermissions(cause);
|
|
65122
65656
|
throw new ServiceError(error62.message, "AUTH_REQUIRED", 3);
|
|
65123
65657
|
}
|
|
65124
65658
|
}
|
|
@@ -65127,16 +65661,16 @@ async function passwordFromStdin(maxBytes = 2048) {
|
|
|
65127
65661
|
usage2(
|
|
65128
65662
|
"Pipe the password to stdin, or use --password-file PATH. Passwords are not accepted as command arguments."
|
|
65129
65663
|
);
|
|
65130
|
-
let
|
|
65664
|
+
let text5 = "";
|
|
65131
65665
|
const cancel = () => process.stdin.destroy(new Error("Interrupted."));
|
|
65132
65666
|
controller.signal.addEventListener("abort", cancel, { once: true });
|
|
65133
65667
|
try {
|
|
65134
65668
|
for await (const chunk of process.stdin) {
|
|
65135
|
-
|
|
65136
|
-
if (Buffer.byteLength(
|
|
65669
|
+
text5 += chunk;
|
|
65670
|
+
if (Buffer.byteLength(text5) > maxBytes)
|
|
65137
65671
|
usage2("Password input is too long.");
|
|
65138
65672
|
}
|
|
65139
|
-
return
|
|
65673
|
+
return text5.replace(/[\r\n]+$/, "");
|
|
65140
65674
|
} finally {
|
|
65141
65675
|
controller.signal.removeEventListener("abort", cancel);
|
|
65142
65676
|
}
|
|
@@ -65257,7 +65791,13 @@ async function main() {
|
|
|
65257
65791
|
const { values: v, positionals: p } = parsed;
|
|
65258
65792
|
if (v.help || p[0] === "help" || !p.length && !v.version) {
|
|
65259
65793
|
const topic = p[0] === "help" ? p[1] : p[0];
|
|
65260
|
-
|
|
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);
|
|
65261
65801
|
return;
|
|
65262
65802
|
}
|
|
65263
65803
|
if (v.version) {
|
|
@@ -65443,6 +65983,7 @@ async function main() {
|
|
|
65443
65983
|
"system capabilities": [],
|
|
65444
65984
|
"system diagnostics": [],
|
|
65445
65985
|
"system plans": [],
|
|
65986
|
+
"system accounts": ["plan"],
|
|
65446
65987
|
"system plan": ["owner", "plan"],
|
|
65447
65988
|
"system suspensions": [],
|
|
65448
65989
|
"system suspend": ["owner", "reason"],
|
|
@@ -65593,10 +66134,16 @@ async function main() {
|
|
|
65593
66134
|
if (command === "config init") {
|
|
65594
66135
|
if (v.server) usage2("config init works locally; omit --server.");
|
|
65595
66136
|
if (v.target) {
|
|
65596
|
-
|
|
65597
|
-
|
|
65598
|
-
|
|
65599
|
-
usage2(
|
|
66137
|
+
const url3 = URL.parse(v.target);
|
|
66138
|
+
if (url3?.protocol !== "https:") {
|
|
66139
|
+
const local = url3 && (url3.protocol === "http:" || ["localhost", "127.0.0.1", "[::1]", "0.0.0.0"].includes(url3.hostname) || url3.hostname.endsWith(".localhost"));
|
|
66140
|
+
usage2(
|
|
66141
|
+
local ? "--target must be the HTTPS base URL of the production site. To try a local app first, write one monitor file and run it locally." : "--target must be the HTTPS base URL of the production site.",
|
|
66142
|
+
local ? [
|
|
66143
|
+
`waitcher monitor init --type http --file website.monitor.json --target ${url3.href}`,
|
|
66144
|
+
"waitcher run local --file website.monitor.json"
|
|
66145
|
+
] : void 0
|
|
66146
|
+
);
|
|
65600
66147
|
}
|
|
65601
66148
|
}
|
|
65602
66149
|
const file2 = configPath(v.file);
|
|
@@ -65623,18 +66170,42 @@ async function main() {
|
|
|
65623
66170
|
if (command === "runtime install") {
|
|
65624
66171
|
if (v.server) usage2("runtime install works locally; omit --server.");
|
|
65625
66172
|
const file2 = configPath(v.file);
|
|
65626
|
-
|
|
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;
|
|
65627
66193
|
try {
|
|
65628
66194
|
const { config: config2 } = await readProjectConfig(v.file);
|
|
66195
|
+
if (config2 && typeof config2 === "object" && "type" in config2 && !("monitors" in config2))
|
|
66196
|
+
await monitorFile();
|
|
65629
66197
|
browser ||= scriptEntries(config2).some((e) => e.type === "browser");
|
|
65630
66198
|
} catch (cause) {
|
|
65631
66199
|
if (cause.code !== "FILE_NOT_FOUND") throw cause;
|
|
66200
|
+
hasConfig = false;
|
|
65632
66201
|
}
|
|
65633
66202
|
const result3 = await installRuntime({
|
|
65634
66203
|
project: dirname18(file2),
|
|
65635
66204
|
browser,
|
|
65636
66205
|
yes: Boolean(v.yes),
|
|
65637
|
-
signal: controller.signal
|
|
66206
|
+
signal: controller.signal,
|
|
66207
|
+
hasConfig,
|
|
66208
|
+
command: `waitcher runtime install${v.file ? ` --file ${file2}` : ""}${v.browser ? " --browser" : ""}`
|
|
65638
66209
|
});
|
|
65639
66210
|
process.stdout.write(JSON.stringify(result3) + "\n");
|
|
65640
66211
|
return;
|
|
@@ -65937,22 +66508,33 @@ async function main() {
|
|
|
65937
66508
|
usage2("--target must be an HTTP(S) URL without embedded credentials.");
|
|
65938
66509
|
}
|
|
65939
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
|
+
};
|
|
65940
66522
|
if (!v.template && (v.type === "browser" || v.type === "api")) {
|
|
65941
66523
|
const scriptFile = basename3(v.file).replace(/(\.monitor)?\.json$/, "") + ".e2e.ts";
|
|
65942
66524
|
await writeText(
|
|
65943
66525
|
join17(dirname18(v.file), scriptFile),
|
|
65944
66526
|
v.type === "api" ? apiScriptExample : browserScriptExample
|
|
65945
|
-
);
|
|
66527
|
+
).catch(taken);
|
|
65946
66528
|
await writeJson(v.file, {
|
|
65947
66529
|
...v.type === "api" ? apiExample : browserExample,
|
|
65948
66530
|
scriptFile,
|
|
65949
66531
|
...v.target ? { target: v.target } : {}
|
|
65950
|
-
});
|
|
66532
|
+
}).catch(taken);
|
|
65951
66533
|
} else
|
|
65952
66534
|
await writeJson(v.file, {
|
|
65953
66535
|
...initial,
|
|
65954
66536
|
...v.target ? { target: v.target } : {}
|
|
65955
|
-
});
|
|
66537
|
+
}).catch(taken);
|
|
65956
66538
|
const type = v.template ? "api" : v.type ?? "http";
|
|
65957
66539
|
result2 = {
|
|
65958
66540
|
event: "initialized",
|
|
@@ -65961,9 +66543,12 @@ async function main() {
|
|
|
65961
66543
|
next: [
|
|
65962
66544
|
"Replace the example target, name and checks with the user's",
|
|
65963
66545
|
`waitcher monitor validate --file ${v.file}`,
|
|
65964
|
-
|
|
65965
|
-
|
|
65966
|
-
|
|
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}`],
|
|
65967
66552
|
`waitcher monitor apply --file ${v.file} --dry-run`
|
|
65968
66553
|
]
|
|
65969
66554
|
};
|
|
@@ -66438,7 +67023,7 @@ async function main() {
|
|
|
66438
67023
|
usage2(
|
|
66439
67024
|
"Provide --output with a new private receipt file before confirming deletion."
|
|
66440
67025
|
);
|
|
66441
|
-
const file2 =
|
|
67026
|
+
const file2 = resolve18(v.output), directory = await lstat12(dirname18(file2));
|
|
66442
67027
|
if (!directory.isDirectory() || directory.isSymbolicLink() || process.platform !== "win32" && directory.mode & 63)
|
|
66443
67028
|
usage2(
|
|
66444
67029
|
"Receipt output needs an existing private directory (chmod 700)."
|
|
@@ -66572,7 +67157,7 @@ async function main() {
|
|
|
66572
67157
|
else if (command === "account export") {
|
|
66573
67158
|
if (!v.file) usage2("Provide --file with a new private tar output path.");
|
|
66574
67159
|
const seconds = integer2(v.timeout ?? "90", "timeout", 1, 180);
|
|
66575
|
-
const destination =
|
|
67160
|
+
const destination = resolve18(v.file);
|
|
66576
67161
|
const directory = await lstat12(dirname18(destination));
|
|
66577
67162
|
if (!directory.isDirectory() || directory.isSymbolicLink() || process.platform !== "win32" && directory.mode & 63)
|
|
66578
67163
|
usage2(
|
|
@@ -67034,12 +67619,12 @@ async function main() {
|
|
|
67034
67619
|
usage2(
|
|
67035
67620
|
"Provide --file PATH with the complete configuration and expectedRevision for edits."
|
|
67036
67621
|
);
|
|
67037
|
-
const
|
|
67038
|
-
if (Buffer.byteLength(
|
|
67622
|
+
const text5 = await readFile12(v.file, "utf8");
|
|
67623
|
+
if (Buffer.byteLength(text5) > 16e3)
|
|
67039
67624
|
usage2("Project configuration exceeds 16 KB");
|
|
67040
67625
|
let body2;
|
|
67041
67626
|
try {
|
|
67042
|
-
body2 = JSON.parse(
|
|
67627
|
+
body2 = JSON.parse(text5);
|
|
67043
67628
|
} catch {
|
|
67044
67629
|
usage2("Configuration must be JSON");
|
|
67045
67630
|
}
|
|
@@ -67286,10 +67871,10 @@ async function main() {
|
|
|
67286
67871
|
if (!v.file) usage2("Provide --file PATH for the configuration.");
|
|
67287
67872
|
let input2;
|
|
67288
67873
|
try {
|
|
67289
|
-
const
|
|
67290
|
-
if (Buffer.byteLength(
|
|
67874
|
+
const text5 = await readFile12(v.file, "utf8");
|
|
67875
|
+
if (Buffer.byteLength(text5) > 96e3)
|
|
67291
67876
|
usage2("Configuration exceeds 96 KB.");
|
|
67292
|
-
input2 = JSON.parse(
|
|
67877
|
+
input2 = JSON.parse(text5);
|
|
67293
67878
|
} catch {
|
|
67294
67879
|
usage2("Could not read valid JSON configuration.");
|
|
67295
67880
|
}
|
|
@@ -67414,7 +67999,17 @@ async function main() {
|
|
|
67414
67999
|
} else if (command === "system diagnostics")
|
|
67415
68000
|
result2 = await api("system/diagnostics");
|
|
67416
68001
|
else if (command === "system plans") result2 = await api("system/plans");
|
|
67417
|
-
else if (command === "system
|
|
68002
|
+
else if (command === "system accounts") {
|
|
68003
|
+
const plan = v.plan === void 0 ? "" : String(v.plan);
|
|
68004
|
+
if (plan && !/^[a-z]{1,32}$/.test(plan)) usage2("--plan must be a plan name");
|
|
68005
|
+
result2 = await api(
|
|
68006
|
+
`system/accounts${plan ? `?plan=${encodeURIComponent(plan)}` : ""}`
|
|
68007
|
+
);
|
|
68008
|
+
if (!v.json) {
|
|
68009
|
+
process.stdout.write(formatSystemAccounts(result2));
|
|
68010
|
+
return;
|
|
68011
|
+
}
|
|
68012
|
+
} else if (command === "system suspensions")
|
|
67418
68013
|
result2 = await api("system/suspensions");
|
|
67419
68014
|
else if (command === "account billing") result2 = await api("billing");
|
|
67420
68015
|
else if (command === "account upgrade" || command === "account billing-portal") {
|
|
@@ -67795,10 +68390,10 @@ async function main() {
|
|
|
67795
68390
|
if (!v.file) usage2("Provide --file PATH for the status page.");
|
|
67796
68391
|
let input2;
|
|
67797
68392
|
try {
|
|
67798
|
-
const
|
|
67799
|
-
if (Buffer.byteLength(
|
|
68393
|
+
const text5 = await readFile12(v.file, "utf8");
|
|
68394
|
+
if (Buffer.byteLength(text5) > 96e3)
|
|
67800
68395
|
usage2("Configuration exceeds 96 KB.");
|
|
67801
|
-
input2 = JSON.parse(
|
|
68396
|
+
input2 = JSON.parse(text5);
|
|
67802
68397
|
} catch {
|
|
67803
68398
|
usage2("Could not read valid JSON configuration.");
|
|
67804
68399
|
}
|
|
@@ -67839,9 +68434,15 @@ async function main() {
|
|
|
67839
68434
|
process.stdout.write(JSON.stringify(result2) + "\n");
|
|
67840
68435
|
process.exitCode = exitCode;
|
|
67841
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
|
+
];
|
|
67842
68440
|
try {
|
|
67843
68441
|
await main();
|
|
67844
|
-
} 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;
|
|
67845
68446
|
const error62 = asError(cause);
|
|
67846
68447
|
const interrupted = controller.signal.aborted;
|
|
67847
68448
|
process.stderr.write(
|
|
@@ -67851,7 +68452,8 @@ try {
|
|
|
67851
68452
|
...error62.fields ? { fields: error62.fields } : {},
|
|
67852
68453
|
...error62.requestId ? { requestId: error62.requestId } : {},
|
|
67853
68454
|
code: interrupted ? "INTERRUPTED" : error62.code === "ENOENT" ? "FILE_NOT_FOUND" : error62 instanceof ServiceError ? error62.code : "LOCAL_ERROR",
|
|
67854
|
-
message: interrupted ? "Interrupted. Submitted work may still run on the server." : error62.message
|
|
68455
|
+
message: interrupted ? "Interrupted. Submitted work may still run on the server." : error62.message,
|
|
68456
|
+
...!interrupted && error62 instanceof ServiceError && error62.next ? { next: error62.next } : {}
|
|
67855
68457
|
}
|
|
67856
68458
|
}) + "\n"
|
|
67857
68459
|
);
|