@waitcher/cli 0.2.24 → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1949 -428
- package/dist/model-client.mjs +75 -13
- package/dist/request-runtime.mjs +75 -13
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -2976,12 +2976,12 @@ var require_diagnostics = __commonJS({
|
|
|
2976
2976
|
diagnosticsChannel.subscribe(
|
|
2977
2977
|
"undici:websocket:close",
|
|
2978
2978
|
(evt) => {
|
|
2979
|
-
const { websocket, code, reason } = evt;
|
|
2979
|
+
const { websocket, code, reason: reason2 } = evt;
|
|
2980
2980
|
debugLog(
|
|
2981
2981
|
"closed connection to %s - %s %s",
|
|
2982
2982
|
websocket.url,
|
|
2983
2983
|
code,
|
|
2984
|
-
|
|
2984
|
+
reason2
|
|
2985
2985
|
);
|
|
2986
2986
|
}
|
|
2987
2987
|
);
|
|
@@ -4296,7 +4296,7 @@ var require_util2 = __commonJS({
|
|
|
4296
4296
|
var { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants2();
|
|
4297
4297
|
var { getGlobalOrigin } = require_global();
|
|
4298
4298
|
var { collectAnHTTPQuotedString, parseMIMEType } = require_data_url();
|
|
4299
|
-
var { performance:
|
|
4299
|
+
var { performance: performance8 } = __require("node:perf_hooks");
|
|
4300
4300
|
var { isValidHTTPToken, normalizedMethodRecordsBase } = require_util();
|
|
4301
4301
|
var assert2 = __require("node:assert");
|
|
4302
4302
|
var { isUint8Array } = __require("node:util/types");
|
|
@@ -4454,7 +4454,7 @@ var require_util2 = __commonJS({
|
|
|
4454
4454
|
};
|
|
4455
4455
|
}
|
|
4456
4456
|
function coarsenedSharedCurrentTime(crossOriginIsolatedCapability) {
|
|
4457
|
-
return coarsenTime(
|
|
4457
|
+
return coarsenTime(performance8.now(), crossOriginIsolatedCapability);
|
|
4458
4458
|
}
|
|
4459
4459
|
function createOpaqueTimingInfo(timingInfo) {
|
|
4460
4460
|
return {
|
|
@@ -5358,11 +5358,11 @@ var require_request = __commonJS({
|
|
|
5358
5358
|
this[kResume]?.();
|
|
5359
5359
|
}
|
|
5360
5360
|
}
|
|
5361
|
-
abort(
|
|
5361
|
+
abort(reason2) {
|
|
5362
5362
|
if (!this.#aborted) {
|
|
5363
5363
|
this.#aborted = true;
|
|
5364
|
-
this.#reason =
|
|
5365
|
-
this.#abort(
|
|
5364
|
+
this.#reason = reason2;
|
|
5365
|
+
this.#abort(reason2);
|
|
5366
5366
|
}
|
|
5367
5367
|
}
|
|
5368
5368
|
get aborted() {
|
|
@@ -9070,9 +9070,9 @@ var require_parser_h1 = __commonJS({
|
|
|
9070
9070
|
const errorCode = this.parserFields[this.milo.ParserFields.ERROR_CODE];
|
|
9071
9071
|
const errorName = this.milo.Errors[errorCode];
|
|
9072
9072
|
const errorDescription = errorName === "UNEXPECTED_EOF" ? "Invalid EOF state" : this.milo.getErrorDescription(this.parser);
|
|
9073
|
-
const
|
|
9073
|
+
const reason2 = errorName === "UNEXPECTED_EOF" ? errorDescription : errorDescription ? `[ERROR_${errorName}] ${errorDescription}` : `ERROR_${errorName}`;
|
|
9074
9074
|
return new HTTPParserError(
|
|
9075
|
-
`Response does not match the HTTP/1.1 protocol (${
|
|
9075
|
+
`Response does not match the HTTP/1.1 protocol (${reason2})`,
|
|
9076
9076
|
errorName,
|
|
9077
9077
|
data
|
|
9078
9078
|
);
|
|
@@ -9882,8 +9882,8 @@ var require_body = __commonJS({
|
|
|
9882
9882
|
}
|
|
9883
9883
|
}
|
|
9884
9884
|
},
|
|
9885
|
-
cancel(
|
|
9886
|
-
return action()[Symbol.asyncIterator]?.().return(
|
|
9885
|
+
cancel(reason2) {
|
|
9886
|
+
return action()[Symbol.asyncIterator]?.().return(reason2);
|
|
9887
9887
|
},
|
|
9888
9888
|
type: "bytes"
|
|
9889
9889
|
});
|
|
@@ -14399,7 +14399,7 @@ var require_dispatcher1_wrapper = __commonJS({
|
|
|
14399
14399
|
this.#handler = handler;
|
|
14400
14400
|
}
|
|
14401
14401
|
onRequestStart(controller2, context) {
|
|
14402
|
-
this.#handler.onConnect?.((
|
|
14402
|
+
this.#handler.onConnect?.((reason2) => controller2.abort(reason2), context);
|
|
14403
14403
|
}
|
|
14404
14404
|
onRequestUpgrade(controller2, statusCode, headers, socket) {
|
|
14405
14405
|
const rawHeaders = Array.isArray(controller2?.rawHeaders) ? controller2.rawHeaders : toRawHeaders(controller2?.rawHeaders ?? headers ?? {});
|
|
@@ -15769,9 +15769,9 @@ var require_retry_handler = __commonJS({
|
|
|
15769
15769
|
this.#paused = false;
|
|
15770
15770
|
this.#target?.resume();
|
|
15771
15771
|
}
|
|
15772
|
-
abort(
|
|
15773
|
-
this.#target?.abort(
|
|
15774
|
-
this.#onAbort(
|
|
15772
|
+
abort(reason2) {
|
|
15773
|
+
this.#target?.abort(reason2);
|
|
15774
|
+
this.#onAbort(reason2);
|
|
15775
15775
|
}
|
|
15776
15776
|
get paused() {
|
|
15777
15777
|
return this.#paused || (this.#target?.paused ?? false);
|
|
@@ -15855,7 +15855,7 @@ var require_retry_handler = __commonJS({
|
|
|
15855
15855
|
this.etag = null;
|
|
15856
15856
|
this.statusCode = null;
|
|
15857
15857
|
this.headers = null;
|
|
15858
|
-
this.controllerProxy = new RetryController((
|
|
15858
|
+
this.controllerProxy = new RetryController((reason2) => this.#onAbort(reason2));
|
|
15859
15859
|
this.retryPending = false;
|
|
15860
15860
|
this.retryTimer = null;
|
|
15861
15861
|
this.pendingResponseData = null;
|
|
@@ -16182,7 +16182,7 @@ var require_retry_handler = __commonJS({
|
|
|
16182
16182
|
shouldRetry.bind(this)
|
|
16183
16183
|
) ?? null;
|
|
16184
16184
|
}
|
|
16185
|
-
#onAbort(
|
|
16185
|
+
#onAbort(reason2) {
|
|
16186
16186
|
if (!this.retryPending) {
|
|
16187
16187
|
return;
|
|
16188
16188
|
}
|
|
@@ -16193,7 +16193,7 @@ var require_retry_handler = __commonJS({
|
|
|
16193
16193
|
this.pendingResponseData = null;
|
|
16194
16194
|
this.pendingResponseTrailers = null;
|
|
16195
16195
|
this.pendingResponseEnded = false;
|
|
16196
|
-
this.handler.onResponseError?.(this.controllerProxy,
|
|
16196
|
+
this.handler.onResponseError?.(this.controllerProxy, reason2 ?? new RequestAbortedError());
|
|
16197
16197
|
}
|
|
16198
16198
|
};
|
|
16199
16199
|
function isReplacedHeader(key, etag) {
|
|
@@ -16815,7 +16815,7 @@ var require_api_request = __commonJS({
|
|
|
16815
16815
|
}
|
|
16816
16816
|
assert2(this.callback);
|
|
16817
16817
|
this.controller = controller2;
|
|
16818
|
-
this.abort = (
|
|
16818
|
+
this.abort = (reason2) => controller2.abort(reason2);
|
|
16819
16819
|
this.context = context;
|
|
16820
16820
|
}
|
|
16821
16821
|
onResponseStart(controller2, statusCode, headers, statusText) {
|
|
@@ -16833,7 +16833,7 @@ var require_api_request = __commonJS({
|
|
|
16833
16833
|
const contentLength = parsedHeaders?.["content-length"];
|
|
16834
16834
|
const res = new Readable({
|
|
16835
16835
|
resume: () => controller2.resume(),
|
|
16836
|
-
abort: (
|
|
16836
|
+
abort: (reason2) => controller2.abort(reason2),
|
|
16837
16837
|
contentType,
|
|
16838
16838
|
contentLength: this.method !== "HEAD" && contentLength ? Number(contentLength) : null,
|
|
16839
16839
|
highWaterMark
|
|
@@ -17095,7 +17095,7 @@ var require_api_stream = __commonJS({
|
|
|
17095
17095
|
}
|
|
17096
17096
|
assert2(this.callback);
|
|
17097
17097
|
this.controller = controller2;
|
|
17098
|
-
this.abort = (
|
|
17098
|
+
this.abort = (reason2) => controller2.abort(reason2);
|
|
17099
17099
|
this.context = context;
|
|
17100
17100
|
}
|
|
17101
17101
|
onResponseStart(controller2, statusCode, headers, _statusMessage) {
|
|
@@ -17328,7 +17328,7 @@ var require_api_pipeline = __commonJS({
|
|
|
17328
17328
|
return;
|
|
17329
17329
|
}
|
|
17330
17330
|
assert2(!res, "pipeline cannot be retried");
|
|
17331
|
-
this.abort = (
|
|
17331
|
+
this.abort = (reason2) => controller2.abort(reason2);
|
|
17332
17332
|
this.context = context;
|
|
17333
17333
|
}
|
|
17334
17334
|
onResponseStart(controller2, statusCode, headers, _statusMessage) {
|
|
@@ -17445,7 +17445,7 @@ var require_api_upgrade = __commonJS({
|
|
|
17445
17445
|
return;
|
|
17446
17446
|
}
|
|
17447
17447
|
assert2(this.callback);
|
|
17448
|
-
this.abort = (
|
|
17448
|
+
this.abort = (reason2) => controller2.abort(reason2);
|
|
17449
17449
|
this.context = context;
|
|
17450
17450
|
}
|
|
17451
17451
|
onResponseStart() {
|
|
@@ -17543,7 +17543,7 @@ var require_api_connect = __commonJS({
|
|
|
17543
17543
|
return;
|
|
17544
17544
|
}
|
|
17545
17545
|
assert2(this.callback);
|
|
17546
|
-
this.abort = (
|
|
17546
|
+
this.abort = (reason2) => controller2.abort(reason2);
|
|
17547
17547
|
this.context = context;
|
|
17548
17548
|
}
|
|
17549
17549
|
onResponseStart() {
|
|
@@ -17967,7 +17967,7 @@ var require_mock_utils = __commonJS({
|
|
|
17967
17967
|
resume() {
|
|
17968
17968
|
this.paused = false;
|
|
17969
17969
|
},
|
|
17970
|
-
abort: (
|
|
17970
|
+
abort: (reason2) => {
|
|
17971
17971
|
if (aborted2) {
|
|
17972
17972
|
return;
|
|
17973
17973
|
}
|
|
@@ -17976,7 +17976,7 @@ var require_mock_utils = __commonJS({
|
|
|
17976
17976
|
clearTimeout(timer);
|
|
17977
17977
|
timer = null;
|
|
17978
17978
|
}
|
|
17979
|
-
handler.onResponseError?.(controller2,
|
|
17979
|
+
handler.onResponseError?.(controller2, reason2);
|
|
17980
17980
|
}
|
|
17981
17981
|
};
|
|
17982
17982
|
let replyOpts = opts;
|
|
@@ -18153,14 +18153,14 @@ var require_mock_utils = __commonJS({
|
|
|
18153
18153
|
mockDispatch.call(this, opts, handler);
|
|
18154
18154
|
} catch (error62) {
|
|
18155
18155
|
if (error62.code === "UND_MOCK_ERR_MOCK_NOT_MATCHED") {
|
|
18156
|
-
const
|
|
18156
|
+
const netConnect2 = agent[kGetNetConnect]();
|
|
18157
18157
|
const totalInterceptsCount = this[kDispatches][kTotalDispatchCount] || this[kDispatches].length;
|
|
18158
18158
|
const pendingInterceptsCount = this[kDispatches].filter(({ consumed }) => !consumed).length;
|
|
18159
18159
|
const interceptsMessage = `, ${pendingInterceptsCount} interceptor(s) remaining out of ${totalInterceptsCount} defined`;
|
|
18160
|
-
if (
|
|
18160
|
+
if (netConnect2 === false) {
|
|
18161
18161
|
throw new MockNotMatchedError(`${error62.message}: subsequent request to origin ${origin} was not allowed (net.connect disabled)${interceptsMessage}`);
|
|
18162
18162
|
}
|
|
18163
|
-
if (checkNetConnect(
|
|
18163
|
+
if (checkNetConnect(netConnect2, origin)) {
|
|
18164
18164
|
originalDispatch.call(this, "__mockAgentBodyForDispatch" in opts ? { ...opts, body: opts.__mockAgentBodyForDispatch } : opts, handler);
|
|
18165
18165
|
} else {
|
|
18166
18166
|
throw new MockNotMatchedError(`${error62.message}: subsequent request to origin ${origin} was not allowed (net.connect is not enabled for this origin)${interceptsMessage}`);
|
|
@@ -18174,11 +18174,11 @@ var require_mock_utils = __commonJS({
|
|
|
18174
18174
|
}
|
|
18175
18175
|
};
|
|
18176
18176
|
}
|
|
18177
|
-
function checkNetConnect(
|
|
18177
|
+
function checkNetConnect(netConnect2, origin) {
|
|
18178
18178
|
const url3 = new URL(origin);
|
|
18179
|
-
if (
|
|
18179
|
+
if (netConnect2 === true) {
|
|
18180
18180
|
return true;
|
|
18181
|
-
} else if (Array.isArray(
|
|
18181
|
+
} else if (Array.isArray(netConnect2) && netConnect2.some((matcher) => matchValue(matcher, url3.host))) {
|
|
18182
18182
|
return true;
|
|
18183
18183
|
}
|
|
18184
18184
|
return false;
|
|
@@ -19605,9 +19605,9 @@ var require_snapshot_agent = __commonJS({
|
|
|
19605
19605
|
},
|
|
19606
19606
|
resume() {
|
|
19607
19607
|
},
|
|
19608
|
-
abort(
|
|
19608
|
+
abort(reason2) {
|
|
19609
19609
|
this.aborted = true;
|
|
19610
|
-
this.reason =
|
|
19610
|
+
this.reason = reason2;
|
|
19611
19611
|
},
|
|
19612
19612
|
aborted: false,
|
|
19613
19613
|
paused: false
|
|
@@ -20234,9 +20234,9 @@ var require_dump = __commonJS({
|
|
|
20234
20234
|
super(handler);
|
|
20235
20235
|
this.#maxSize = maxSize ?? this.#maxSize;
|
|
20236
20236
|
}
|
|
20237
|
-
#abort(
|
|
20237
|
+
#abort(reason2) {
|
|
20238
20238
|
this.aborted = true;
|
|
20239
|
-
this.reason =
|
|
20239
|
+
this.reason = reason2;
|
|
20240
20240
|
}
|
|
20241
20241
|
onRequestStart(controller2, context) {
|
|
20242
20242
|
controller2.abort = this.#abort.bind(this);
|
|
@@ -20296,7 +20296,7 @@ var require_dump = __commonJS({
|
|
|
20296
20296
|
var require_dns = __commonJS({
|
|
20297
20297
|
"../../node_modules/undici/lib/interceptor/dns.js"(exports, module) {
|
|
20298
20298
|
"use strict";
|
|
20299
|
-
var { isIP:
|
|
20299
|
+
var { isIP: isIP3 } = __require("node:net");
|
|
20300
20300
|
var { lookup: lookup3 } = __require("node:dns");
|
|
20301
20301
|
var DecoratorHandler = require_decorator_handler();
|
|
20302
20302
|
var { InvalidArgumentError, InformationalError } = require_errors();
|
|
@@ -20713,7 +20713,7 @@ var require_dns = __commonJS({
|
|
|
20713
20713
|
return dispatch(origDispatchOpts, handler);
|
|
20714
20714
|
}
|
|
20715
20715
|
const origin = origDispatchOpts.origin.constructor === URL ? origDispatchOpts.origin : new URL(origDispatchOpts.origin);
|
|
20716
|
-
if (
|
|
20716
|
+
if (isIP3(origin.hostname) !== 0) {
|
|
20717
20717
|
return dispatch(origDispatchOpts, handler);
|
|
20718
20718
|
}
|
|
20719
20719
|
instance.runLookup(origin, origDispatchOpts, (err, newOrigin) => {
|
|
@@ -21835,8 +21835,8 @@ var require_cache_handler = __commonJS({
|
|
|
21835
21835
|
this.target.resume();
|
|
21836
21836
|
}
|
|
21837
21837
|
}
|
|
21838
|
-
abort(
|
|
21839
|
-
this.target.abort(
|
|
21838
|
+
abort(reason2) {
|
|
21839
|
+
this.target.abort(reason2);
|
|
21840
21840
|
}
|
|
21841
21841
|
get paused() {
|
|
21842
21842
|
return this.#downstreamPaused;
|
|
@@ -22955,9 +22955,9 @@ var require_cache2 = __commonJS({
|
|
|
22955
22955
|
resume() {
|
|
22956
22956
|
this.paused = false;
|
|
22957
22957
|
},
|
|
22958
|
-
abort: (
|
|
22958
|
+
abort: (reason2) => {
|
|
22959
22959
|
aborted2 = true;
|
|
22960
|
-
handler.onResponseError?.(controller2,
|
|
22960
|
+
handler.onResponseError?.(controller2, reason2 ?? new AbortError());
|
|
22961
22961
|
}
|
|
22962
22962
|
};
|
|
22963
22963
|
try {
|
|
@@ -23003,12 +23003,12 @@ var require_cache2 = __commonJS({
|
|
|
23003
23003
|
get reason() {
|
|
23004
23004
|
return abortReason;
|
|
23005
23005
|
},
|
|
23006
|
-
abort(
|
|
23006
|
+
abort(reason2) {
|
|
23007
23007
|
if (aborted2) {
|
|
23008
23008
|
return;
|
|
23009
23009
|
}
|
|
23010
23010
|
aborted2 = true;
|
|
23011
|
-
abortReason =
|
|
23011
|
+
abortReason = reason2 ?? new AbortError();
|
|
23012
23012
|
stream.destroy(abortReason);
|
|
23013
23013
|
}
|
|
23014
23014
|
};
|
|
@@ -23274,9 +23274,9 @@ var require_decompress = __commonJS({
|
|
|
23274
23274
|
this.#paused = false;
|
|
23275
23275
|
this.#onResume();
|
|
23276
23276
|
}
|
|
23277
|
-
abort(
|
|
23278
|
-
this.target?.abort(
|
|
23279
|
-
this.#onAbort(
|
|
23277
|
+
abort(reason2) {
|
|
23278
|
+
this.target?.abort(reason2);
|
|
23279
|
+
this.#onAbort(reason2);
|
|
23280
23280
|
}
|
|
23281
23281
|
get paused() {
|
|
23282
23282
|
return this.#paused;
|
|
@@ -23380,9 +23380,9 @@ var require_decompress = __commonJS({
|
|
|
23380
23380
|
this.#controller = new DecompressController(
|
|
23381
23381
|
() => this.#onDownstreamPause(),
|
|
23382
23382
|
() => this.#onDownstreamResume(),
|
|
23383
|
-
(
|
|
23383
|
+
(reason2) => {
|
|
23384
23384
|
if (this.#inputEnded && !this.#terminated) {
|
|
23385
|
-
this.onResponseError(this.#controller,
|
|
23385
|
+
this.onResponseError(this.#controller, reason2);
|
|
23386
23386
|
}
|
|
23387
23387
|
}
|
|
23388
23388
|
);
|
|
@@ -24038,12 +24038,12 @@ var require_deduplication_handler = __commonJS({
|
|
|
24038
24038
|
get reason() {
|
|
24039
24039
|
return state.reason;
|
|
24040
24040
|
},
|
|
24041
|
-
abort: (
|
|
24041
|
+
abort: (reason2) => {
|
|
24042
24042
|
if (state.aborted) {
|
|
24043
24043
|
return;
|
|
24044
24044
|
}
|
|
24045
24045
|
state.aborted = true;
|
|
24046
|
-
state.reason =
|
|
24046
|
+
state.reason = reason2 ?? null;
|
|
24047
24047
|
waitingHandler.done = true;
|
|
24048
24048
|
waitingHandler.pendingTrailers = null;
|
|
24049
24049
|
waitingHandler.bufferedChunks = [];
|
|
@@ -24574,17 +24574,17 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24574
24574
|
if (now >= value2.deleteAt && !canBeExpired) {
|
|
24575
24575
|
continue;
|
|
24576
24576
|
}
|
|
24577
|
-
let
|
|
24577
|
+
let matches2 = true;
|
|
24578
24578
|
if (value2.vary) {
|
|
24579
24579
|
const vary = JSON.parse(value2.vary);
|
|
24580
24580
|
for (const header in vary) {
|
|
24581
24581
|
if (!headerValueEquals(headers[header], vary[header])) {
|
|
24582
|
-
|
|
24582
|
+
matches2 = false;
|
|
24583
24583
|
break;
|
|
24584
24584
|
}
|
|
24585
24585
|
}
|
|
24586
24586
|
}
|
|
24587
|
-
if (
|
|
24587
|
+
if (matches2) {
|
|
24588
24588
|
return value2;
|
|
24589
24589
|
}
|
|
24590
24590
|
}
|
|
@@ -25329,13 +25329,13 @@ var require_response = __commonJS({
|
|
|
25329
25329
|
urlList: init?.urlList ? [...init.urlList] : []
|
|
25330
25330
|
};
|
|
25331
25331
|
}
|
|
25332
|
-
function makeNetworkError(
|
|
25333
|
-
const isError = isErrorLike(
|
|
25332
|
+
function makeNetworkError(reason2) {
|
|
25333
|
+
const isError = isErrorLike(reason2);
|
|
25334
25334
|
return makeResponse({
|
|
25335
25335
|
type: "error",
|
|
25336
25336
|
status: 0,
|
|
25337
|
-
error: isError ?
|
|
25338
|
-
aborted:
|
|
25337
|
+
error: isError ? reason2 : new Error(reason2 ? String(reason2) : reason2),
|
|
25338
|
+
aborted: reason2 && reason2.name === "AbortError"
|
|
25339
25339
|
});
|
|
25340
25340
|
}
|
|
25341
25341
|
function isNetworkError(response) {
|
|
@@ -26490,13 +26490,13 @@ var require_fetch = __commonJS({
|
|
|
26490
26490
|
this.dump = false;
|
|
26491
26491
|
this.state = "ongoing";
|
|
26492
26492
|
}
|
|
26493
|
-
terminate(
|
|
26493
|
+
terminate(reason2) {
|
|
26494
26494
|
if (this.state !== "ongoing") {
|
|
26495
26495
|
return;
|
|
26496
26496
|
}
|
|
26497
26497
|
this.state = "terminated";
|
|
26498
|
-
this.connection?.destroy(
|
|
26499
|
-
this.emit("terminated",
|
|
26498
|
+
this.connection?.destroy(reason2);
|
|
26499
|
+
this.emit("terminated", reason2);
|
|
26500
26500
|
}
|
|
26501
26501
|
// https://fetch.spec.whatwg.org/#fetch-controller-abort
|
|
26502
26502
|
abort(error62) {
|
|
@@ -26785,7 +26785,7 @@ var require_fetch = __commonJS({
|
|
|
26785
26785
|
fetchParams.controller.dump = true;
|
|
26786
26786
|
}
|
|
26787
26787
|
if (request2.integrity) {
|
|
26788
|
-
const processBodyError = (
|
|
26788
|
+
const processBodyError = (reason2) => fetchFinale(fetchParams, makeNetworkError(reason2));
|
|
26789
26789
|
if (request2.responseTainting === "opaque" || response.body == null) {
|
|
26790
26790
|
processBodyError(response.error);
|
|
26791
26791
|
return;
|
|
@@ -27305,9 +27305,9 @@ var require_fetch = __commonJS({
|
|
|
27305
27305
|
const pullAlgorithm = () => {
|
|
27306
27306
|
return fetchParams.controller.resume();
|
|
27307
27307
|
};
|
|
27308
|
-
const cancelAlgorithm = (
|
|
27308
|
+
const cancelAlgorithm = (reason2) => {
|
|
27309
27309
|
if (!isCancelled(fetchParams)) {
|
|
27310
|
-
fetchParams.controller.abort(
|
|
27310
|
+
fetchParams.controller.abort(reason2);
|
|
27311
27311
|
}
|
|
27312
27312
|
};
|
|
27313
27313
|
const stream = new ReadableStream(
|
|
@@ -27365,7 +27365,7 @@ var require_fetch = __commonJS({
|
|
|
27365
27365
|
}
|
|
27366
27366
|
}
|
|
27367
27367
|
};
|
|
27368
|
-
function onAborted(
|
|
27368
|
+
function onAborted(reason2) {
|
|
27369
27369
|
if (isAborted(fetchParams)) {
|
|
27370
27370
|
response.aborted = true;
|
|
27371
27371
|
if (isReadable(stream)) {
|
|
@@ -27376,7 +27376,7 @@ var require_fetch = __commonJS({
|
|
|
27376
27376
|
} else {
|
|
27377
27377
|
if (isReadable(stream)) {
|
|
27378
27378
|
fetchParams.controller.controller.error(new TypeError("terminated", {
|
|
27379
|
-
cause: isErrorLike(
|
|
27379
|
+
cause: isErrorLike(reason2) ? reason2 : void 0
|
|
27380
27380
|
}));
|
|
27381
27381
|
}
|
|
27382
27382
|
}
|
|
@@ -27409,7 +27409,7 @@ var require_fetch = __commonJS({
|
|
|
27409
27409
|
onRequestStart(controller2) {
|
|
27410
27410
|
const { connection } = fetchParams.controller;
|
|
27411
27411
|
timingInfo.finalConnectionTimingInfo = clampAndCoarsenConnectionTimingInfo(void 0, timingInfo.postRedirectStartTime, fetchParams.crossOriginIsolatedCapability);
|
|
27412
|
-
const abort = (
|
|
27412
|
+
const abort = (reason2) => controller2.abort(reason2);
|
|
27413
27413
|
if (connection.destroyed) {
|
|
27414
27414
|
abort(new DOMException("The operation was aborted.", "AbortError"));
|
|
27415
27415
|
} else {
|
|
@@ -29228,14 +29228,14 @@ var require_util5 = __commonJS({
|
|
|
29228
29228
|
}
|
|
29229
29229
|
return urlRecord;
|
|
29230
29230
|
}
|
|
29231
|
-
function validateCloseCodeAndReason(code,
|
|
29231
|
+
function validateCloseCodeAndReason(code, reason2) {
|
|
29232
29232
|
if (code !== null) {
|
|
29233
29233
|
if (code !== 1e3 && (code < 3e3 || code > 4999)) {
|
|
29234
29234
|
throw new DOMException("invalid code", "InvalidAccessError");
|
|
29235
29235
|
}
|
|
29236
29236
|
}
|
|
29237
|
-
if (
|
|
29238
|
-
const reasonBytesLength = Buffer.byteLength(
|
|
29237
|
+
if (reason2 !== null) {
|
|
29238
|
+
const reasonBytesLength = Buffer.byteLength(reason2);
|
|
29239
29239
|
if (reasonBytesLength > 123) {
|
|
29240
29240
|
throw new DOMException(`Reason must be less than 123 bytes; received ${reasonBytesLength}`, "SyntaxError");
|
|
29241
29241
|
}
|
|
@@ -29485,29 +29485,29 @@ var require_connection = __commonJS({
|
|
|
29485
29485
|
});
|
|
29486
29486
|
return controller2;
|
|
29487
29487
|
}
|
|
29488
|
-
function closeWebSocketConnection(object2, code,
|
|
29488
|
+
function closeWebSocketConnection(object2, code, reason2, validate2 = false) {
|
|
29489
29489
|
code ??= null;
|
|
29490
|
-
|
|
29491
|
-
if (validate2) validateCloseCodeAndReason(code,
|
|
29490
|
+
reason2 ??= "";
|
|
29491
|
+
if (validate2) validateCloseCodeAndReason(code, reason2);
|
|
29492
29492
|
if (isClosed(object2.readyState) || isClosing(object2.readyState)) {
|
|
29493
29493
|
} else if (!isEstablished(object2.readyState)) {
|
|
29494
29494
|
failWebsocketConnection(object2);
|
|
29495
29495
|
object2.readyState = states.CLOSING;
|
|
29496
29496
|
} else if (!object2.closeState.has(sentCloseFrameState.SENT) && !object2.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
29497
29497
|
const frame = new WebsocketFrameSend();
|
|
29498
|
-
if (
|
|
29498
|
+
if (reason2.length !== 0 && code === null) {
|
|
29499
29499
|
code = 1e3;
|
|
29500
29500
|
}
|
|
29501
29501
|
assert2(code === null || Number.isInteger(code));
|
|
29502
|
-
if (code === null &&
|
|
29502
|
+
if (code === null && reason2.length === 0) {
|
|
29503
29503
|
frame.frameData = emptyBuffer;
|
|
29504
|
-
} else if (code !== null &&
|
|
29504
|
+
} else if (code !== null && reason2 === null) {
|
|
29505
29505
|
frame.frameData = Buffer.allocUnsafe(2);
|
|
29506
29506
|
frame.frameData.writeUInt16BE(code, 0);
|
|
29507
|
-
} else if (code !== null &&
|
|
29508
|
-
frame.frameData = Buffer.allocUnsafe(2 + Buffer.byteLength(
|
|
29507
|
+
} else if (code !== null && reason2 !== null) {
|
|
29508
|
+
frame.frameData = Buffer.allocUnsafe(2 + Buffer.byteLength(reason2));
|
|
29509
29509
|
frame.frameData.writeUInt16BE(code, 0);
|
|
29510
|
-
frame.frameData.write(
|
|
29510
|
+
frame.frameData.write(reason2, 2, "utf-8");
|
|
29511
29511
|
} else {
|
|
29512
29512
|
frame.frameData = emptyBuffer;
|
|
29513
29513
|
}
|
|
@@ -29518,15 +29518,15 @@ var require_connection = __commonJS({
|
|
|
29518
29518
|
object2.readyState = states.CLOSING;
|
|
29519
29519
|
}
|
|
29520
29520
|
}
|
|
29521
|
-
function failHandshake(handler, response, code,
|
|
29521
|
+
function failHandshake(handler, response, code, reason2, cause) {
|
|
29522
29522
|
if (response.socket?.session != null && !response.socket.destroyed) {
|
|
29523
29523
|
response.socket.destroy();
|
|
29524
29524
|
}
|
|
29525
|
-
failWebsocketConnection(handler, code,
|
|
29525
|
+
failWebsocketConnection(handler, code, reason2, cause);
|
|
29526
29526
|
}
|
|
29527
|
-
function failWebsocketConnection(handler, code,
|
|
29527
|
+
function failWebsocketConnection(handler, code, reason2, cause) {
|
|
29528
29528
|
if (isEstablished(handler.readyState)) {
|
|
29529
|
-
closeWebSocketConnection(handler, code,
|
|
29529
|
+
closeWebSocketConnection(handler, code, reason2, false);
|
|
29530
29530
|
}
|
|
29531
29531
|
handler.controller.abort();
|
|
29532
29532
|
if (isConnecting(handler.readyState)) {
|
|
@@ -29936,16 +29936,16 @@ var require_receiver = __commonJS({
|
|
|
29936
29936
|
if (code !== void 0 && !isValidStatusCode(code)) {
|
|
29937
29937
|
return { code: 1002, reason: "Invalid status code", error: true };
|
|
29938
29938
|
}
|
|
29939
|
-
let
|
|
29940
|
-
if (
|
|
29941
|
-
|
|
29939
|
+
let reason2 = data.subarray(2);
|
|
29940
|
+
if (reason2[0] === 239 && reason2[1] === 187 && reason2[2] === 191) {
|
|
29941
|
+
reason2 = reason2.subarray(3);
|
|
29942
29942
|
}
|
|
29943
29943
|
try {
|
|
29944
|
-
|
|
29944
|
+
reason2 = utf8Decode(reason2);
|
|
29945
29945
|
} catch {
|
|
29946
29946
|
return { code: 1007, reason: "Invalid UTF-8", error: true };
|
|
29947
29947
|
}
|
|
29948
|
-
return { code, reason, error: false };
|
|
29948
|
+
return { code, reason: reason2, error: false };
|
|
29949
29949
|
}
|
|
29950
29950
|
/**
|
|
29951
29951
|
* Parses control frames.
|
|
@@ -29960,8 +29960,8 @@ var require_receiver = __commonJS({
|
|
|
29960
29960
|
}
|
|
29961
29961
|
this.#info.closeInfo = this.parseCloseBody(body2);
|
|
29962
29962
|
if (this.#info.closeInfo.error) {
|
|
29963
|
-
const { code, reason } = this.#info.closeInfo;
|
|
29964
|
-
failWebsocketConnection(this.#handler, code,
|
|
29963
|
+
const { code, reason: reason2 } = this.#info.closeInfo;
|
|
29964
|
+
failWebsocketConnection(this.#handler, code, reason2);
|
|
29965
29965
|
return false;
|
|
29966
29966
|
}
|
|
29967
29967
|
if (!this.#handler.closeState.has(sentCloseFrameState.SENT) && !this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
@@ -30233,18 +30233,18 @@ var require_websocket = __commonJS({
|
|
|
30233
30233
|
* @param {number|undefined} code
|
|
30234
30234
|
* @param {string|undefined} reason
|
|
30235
30235
|
*/
|
|
30236
|
-
close(code = void 0,
|
|
30236
|
+
close(code = void 0, reason2 = void 0) {
|
|
30237
30237
|
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
30238
30238
|
const prefix = "WebSocket.close";
|
|
30239
30239
|
if (code !== void 0) {
|
|
30240
30240
|
code = webidl.converters["unsigned short"](code, prefix, "code", webidl.attributes.Clamp);
|
|
30241
30241
|
}
|
|
30242
|
-
if (
|
|
30243
|
-
|
|
30242
|
+
if (reason2 !== void 0) {
|
|
30243
|
+
reason2 = webidl.converters.USVString(reason2);
|
|
30244
30244
|
}
|
|
30245
30245
|
code ??= null;
|
|
30246
|
-
|
|
30247
|
-
closeWebSocketConnection(this.#handler, code,
|
|
30246
|
+
reason2 ??= "";
|
|
30247
|
+
closeWebSocketConnection(this.#handler, code, reason2, true);
|
|
30248
30248
|
}
|
|
30249
30249
|
/**
|
|
30250
30250
|
* @see https://websockets.spec.whatwg.org/#dom-websocket-send
|
|
@@ -30461,29 +30461,29 @@ var require_websocket = __commonJS({
|
|
|
30461
30461
|
#onSocketClose() {
|
|
30462
30462
|
const wasClean = this.#handler.closeState.has(sentCloseFrameState.SENT) && this.#handler.closeState.has(sentCloseFrameState.RECEIVED);
|
|
30463
30463
|
let code = 1005;
|
|
30464
|
-
let
|
|
30464
|
+
let reason2 = "";
|
|
30465
30465
|
const result2 = this.#parser?.closingInfo;
|
|
30466
30466
|
if (result2 && !result2.error) {
|
|
30467
30467
|
code = result2.code ?? 1005;
|
|
30468
|
-
|
|
30468
|
+
reason2 = result2.reason;
|
|
30469
30469
|
}
|
|
30470
30470
|
this.#handler.readyState = states.CLOSED;
|
|
30471
30471
|
if (!this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
30472
30472
|
code = 1006;
|
|
30473
30473
|
fireEvent("error", this, (type, init) => new ErrorEvent(type, init), {
|
|
30474
|
-
error: new TypeError(
|
|
30474
|
+
error: new TypeError(reason2)
|
|
30475
30475
|
});
|
|
30476
30476
|
}
|
|
30477
30477
|
fireEvent("close", this, (type, init) => new CloseEvent(type, init), {
|
|
30478
30478
|
wasClean,
|
|
30479
30479
|
code,
|
|
30480
|
-
reason
|
|
30480
|
+
reason: reason2
|
|
30481
30481
|
});
|
|
30482
30482
|
if (channels.close.hasSubscribers) {
|
|
30483
30483
|
channels.close.publish({
|
|
30484
30484
|
websocket: this,
|
|
30485
30485
|
code,
|
|
30486
|
-
reason
|
|
30486
|
+
reason: reason2
|
|
30487
30487
|
});
|
|
30488
30488
|
}
|
|
30489
30489
|
}
|
|
@@ -30628,13 +30628,13 @@ var require_websocketerror = __commonJS({
|
|
|
30628
30628
|
init = webidl.converters.WebSocketCloseInfo(init);
|
|
30629
30629
|
}
|
|
30630
30630
|
let code = init.closeCode ?? null;
|
|
30631
|
-
const
|
|
30632
|
-
validateCloseCodeAndReason(code,
|
|
30633
|
-
if (
|
|
30631
|
+
const reason2 = init.reason ?? "";
|
|
30632
|
+
validateCloseCodeAndReason(code, reason2);
|
|
30633
|
+
if (reason2.length !== 0 && code === null) {
|
|
30634
30634
|
code = 1e3;
|
|
30635
30635
|
}
|
|
30636
30636
|
this.#closeCode = code;
|
|
30637
|
-
this.#reason =
|
|
30637
|
+
this.#reason = reason2;
|
|
30638
30638
|
}
|
|
30639
30639
|
get closeCode() {
|
|
30640
30640
|
return this.#closeCode;
|
|
@@ -30643,10 +30643,10 @@ var require_websocketerror = __commonJS({
|
|
|
30643
30643
|
return this.#reason;
|
|
30644
30644
|
}
|
|
30645
30645
|
static {
|
|
30646
|
-
createUnvalidatedWebSocketError = (message, code,
|
|
30646
|
+
createUnvalidatedWebSocketError = (message, code, reason2) => {
|
|
30647
30647
|
const error62 = new _WebSocketError(message, kConstruct);
|
|
30648
30648
|
error62.#closeCode = code;
|
|
30649
|
-
error62.#reason =
|
|
30649
|
+
error62.#reason = reason2;
|
|
30650
30650
|
return error62;
|
|
30651
30651
|
};
|
|
30652
30652
|
webidl.is.WebSocketError = (arg) => {
|
|
@@ -30807,8 +30807,8 @@ var require_websocketstream = __commonJS({
|
|
|
30807
30807
|
closeInfo = webidl.converters.WebSocketCloseInfo(closeInfo);
|
|
30808
30808
|
}
|
|
30809
30809
|
const code = closeInfo.closeCode ?? null;
|
|
30810
|
-
const
|
|
30811
|
-
closeWebSocketConnection(this.#handler, code,
|
|
30810
|
+
const reason2 = closeInfo.reason;
|
|
30811
|
+
closeWebSocketConnection(this.#handler, code, reason2, true);
|
|
30812
30812
|
}
|
|
30813
30813
|
#write(chunk) {
|
|
30814
30814
|
chunk = webidl.converters.WebSocketStreamWrite(chunk);
|
|
@@ -30859,7 +30859,7 @@ var require_websocketstream = __commonJS({
|
|
|
30859
30859
|
this.#readableStreamController = controller2;
|
|
30860
30860
|
},
|
|
30861
30861
|
pull: () => this.#pull(),
|
|
30862
|
-
cancel: (
|
|
30862
|
+
cancel: (reason2) => this.#cancel(reason2)
|
|
30863
30863
|
});
|
|
30864
30864
|
const writable = new WritableStream({
|
|
30865
30865
|
start: (controller2) => {
|
|
@@ -30867,7 +30867,7 @@ var require_websocketstream = __commonJS({
|
|
|
30867
30867
|
},
|
|
30868
30868
|
write: (chunk) => this.#write(chunk),
|
|
30869
30869
|
close: () => closeWebSocketConnection(this.#handler, null, null),
|
|
30870
|
-
abort: (
|
|
30870
|
+
abort: (reason2) => this.#closeUsingReason(reason2)
|
|
30871
30871
|
});
|
|
30872
30872
|
this.#readableStream = readable;
|
|
30873
30873
|
this.#openedPromise.resolve({
|
|
@@ -30913,27 +30913,27 @@ var require_websocketstream = __commonJS({
|
|
|
30913
30913
|
if (!this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
30914
30914
|
code = 1006;
|
|
30915
30915
|
}
|
|
30916
|
-
const
|
|
30916
|
+
const reason2 = result2?.reason == null ? "" : utf8DecodeBytes(Buffer.from(result2.reason));
|
|
30917
30917
|
if (wasClean) {
|
|
30918
30918
|
readableStreamClose(this.#readableStreamController);
|
|
30919
30919
|
this.#writableStreamController.error(new DOMException("A closed WebSocketStream cannot be written to", "InvalidStateError"));
|
|
30920
30920
|
this.#closedPromise.resolve({
|
|
30921
30921
|
closeCode: code,
|
|
30922
|
-
reason
|
|
30922
|
+
reason: reason2
|
|
30923
30923
|
});
|
|
30924
30924
|
} else {
|
|
30925
|
-
const error62 = createUnvalidatedWebSocketError("unclean close", code,
|
|
30925
|
+
const error62 = createUnvalidatedWebSocketError("unclean close", code, reason2);
|
|
30926
30926
|
this.#readableStreamController?.error(error62);
|
|
30927
30927
|
this.#writableStreamController?.error(error62);
|
|
30928
30928
|
this.#closedPromise.reject(error62);
|
|
30929
30929
|
}
|
|
30930
30930
|
}
|
|
30931
|
-
#closeUsingReason(
|
|
30931
|
+
#closeUsingReason(reason2) {
|
|
30932
30932
|
let code = null;
|
|
30933
30933
|
let reasonString = "";
|
|
30934
|
-
if (webidl.is.WebSocketError(
|
|
30935
|
-
code =
|
|
30936
|
-
reasonString =
|
|
30934
|
+
if (webidl.is.WebSocketError(reason2)) {
|
|
30935
|
+
code = reason2.closeCode;
|
|
30936
|
+
reasonString = reason2.reason;
|
|
30937
30937
|
}
|
|
30938
30938
|
closeWebSocketConnection(this.#handler, code, reasonString);
|
|
30939
30939
|
}
|
|
@@ -30942,8 +30942,8 @@ var require_websocketstream = __commonJS({
|
|
|
30942
30942
|
this.#handler.socket.resume();
|
|
30943
30943
|
}
|
|
30944
30944
|
// To cancel a WebSocketStream stream given reason , close using reason giving stream and reason .
|
|
30945
|
-
#cancel(
|
|
30946
|
-
this.#closeUsingReason(
|
|
30945
|
+
#cancel(reason2) {
|
|
30946
|
+
this.#closeUsingReason(reason2);
|
|
30947
30947
|
}
|
|
30948
30948
|
};
|
|
30949
30949
|
Object.defineProperties(WebSocketStream.prototype, {
|
|
@@ -35664,7 +35664,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
35664
35664
|
}
|
|
35665
35665
|
return propValues;
|
|
35666
35666
|
});
|
|
35667
|
-
const
|
|
35667
|
+
const isObject3 = isObject;
|
|
35668
35668
|
const catchall = def.catchall;
|
|
35669
35669
|
let value2;
|
|
35670
35670
|
const memo2 = globalConfig.memoizer;
|
|
@@ -35672,7 +35672,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
35672
35672
|
inst._zod.parse = (payload, ctx) => {
|
|
35673
35673
|
value2 ?? (value2 = _normalized.value);
|
|
35674
35674
|
const input2 = payload.value;
|
|
35675
|
-
if (!
|
|
35675
|
+
if (!isObject3(input2)) {
|
|
35676
35676
|
payload.issues.push({
|
|
35677
35677
|
expected: "object",
|
|
35678
35678
|
code: "invalid_type",
|
|
@@ -35808,7 +35808,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
35808
35808
|
return doc.compile();
|
|
35809
35809
|
};
|
|
35810
35810
|
let fastpass;
|
|
35811
|
-
const
|
|
35811
|
+
const isObject3 = isObject;
|
|
35812
35812
|
const jit = !globalConfig.jitless;
|
|
35813
35813
|
const allowsEval2 = allowsEval;
|
|
35814
35814
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -35817,7 +35817,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
35817
35817
|
inst._zod.parse = (payload, ctx) => {
|
|
35818
35818
|
value2 ?? (value2 = _normalized.value);
|
|
35819
35819
|
const input2 = payload.value;
|
|
35820
|
-
if (!
|
|
35820
|
+
if (!isObject3(input2)) {
|
|
35821
35821
|
payload.issues.push({
|
|
35822
35822
|
expected: "object",
|
|
35823
35823
|
code: "invalid_type",
|
|
@@ -35903,16 +35903,16 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
35903
35903
|
};
|
|
35904
35904
|
});
|
|
35905
35905
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
35906
|
-
const
|
|
35906
|
+
const matches2 = [];
|
|
35907
35907
|
for (let i = 0; i < results.length; i++) {
|
|
35908
35908
|
if (results[i].issues.length === 0)
|
|
35909
|
-
|
|
35909
|
+
matches2.push(i);
|
|
35910
35910
|
}
|
|
35911
|
-
if (
|
|
35912
|
-
final.value = results[
|
|
35911
|
+
if (matches2.length === 1) {
|
|
35912
|
+
final.value = results[matches2[0]].value;
|
|
35913
35913
|
return final;
|
|
35914
35914
|
}
|
|
35915
|
-
if (
|
|
35915
|
+
if (matches2.length === 0) {
|
|
35916
35916
|
final.issues.push({
|
|
35917
35917
|
code: "invalid_union",
|
|
35918
35918
|
input: final.value,
|
|
@@ -35926,7 +35926,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
35926
35926
|
inst,
|
|
35927
35927
|
errors: [],
|
|
35928
35928
|
inclusive: false,
|
|
35929
|
-
matches
|
|
35929
|
+
matches: matches2
|
|
35930
35930
|
});
|
|
35931
35931
|
}
|
|
35932
35932
|
return final;
|
|
@@ -41452,8 +41452,8 @@ function ko_default() {
|
|
|
41452
41452
|
}
|
|
41453
41453
|
|
|
41454
41454
|
// ../../node_modules/zod/v4/locales/lt.js
|
|
41455
|
-
var capitalizeFirstCharacter = (
|
|
41456
|
-
return
|
|
41455
|
+
var capitalizeFirstCharacter = (text4) => {
|
|
41456
|
+
return text4.charAt(0).toUpperCase() + text4.slice(1);
|
|
41457
41457
|
};
|
|
41458
41458
|
function getUnitTypeFromNumber(number4) {
|
|
41459
41459
|
const abs = Math.abs(number4);
|
|
@@ -45323,9 +45323,9 @@ function codePointLengthVar(doc, ctx, accessor, inDoubt) {
|
|
|
45323
45323
|
doc.write(`const ${v} = typeof ${accessor} === "string" && ${inDoubt} ? ${cpLen}(${accessor}) : ${accessor}.length;`);
|
|
45324
45324
|
return v;
|
|
45325
45325
|
}
|
|
45326
|
-
function numericOperand(value2,
|
|
45326
|
+
function numericOperand(value2, label2) {
|
|
45327
45327
|
if (typeof value2 !== "number" || !Number.isFinite(value2)) {
|
|
45328
|
-
throw new ZodCompileUnsupportedError(`${
|
|
45328
|
+
throw new ZodCompileUnsupportedError(`${label2} bound of type ${typeof value2}`);
|
|
45329
45329
|
}
|
|
45330
45330
|
return `${value2}`;
|
|
45331
45331
|
}
|
|
@@ -51135,20 +51135,20 @@ function checkArrayGuards(arraySchema, guards) {
|
|
|
51135
51135
|
if (guards.containsSchema) {
|
|
51136
51136
|
const minContains = guards.minContains ?? 1;
|
|
51137
51137
|
const ceiling = guards.maxContains !== void 0 ? guards.maxContains + 1 : Number.POSITIVE_INFINITY;
|
|
51138
|
-
let
|
|
51138
|
+
let matches2 = 0;
|
|
51139
51139
|
for (const item of items) {
|
|
51140
|
-
if (guards.containsSchema.safeParse(item).success && ++
|
|
51140
|
+
if (guards.containsSchema.safeParse(item).success && ++matches2 >= ceiling)
|
|
51141
51141
|
break;
|
|
51142
51142
|
}
|
|
51143
|
-
if (
|
|
51143
|
+
if (matches2 < minContains) {
|
|
51144
51144
|
payload.issues.push({
|
|
51145
51145
|
code: "custom",
|
|
51146
|
-
message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${
|
|
51146
|
+
message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${matches2}`,
|
|
51147
51147
|
input: items,
|
|
51148
51148
|
continue: true
|
|
51149
51149
|
});
|
|
51150
51150
|
}
|
|
51151
|
-
if (guards.maxContains !== void 0 &&
|
|
51151
|
+
if (guards.maxContains !== void 0 && matches2 > guards.maxContains) {
|
|
51152
51152
|
payload.issues.push({
|
|
51153
51153
|
code: "custom",
|
|
51154
51154
|
message: `Array must contain at most ${guards.maxContains} matching ${plural(guards.maxContains)}`,
|
|
@@ -51846,19 +51846,78 @@ var httpTargetOriginSchema = external_exports.string().trim().min(1).max(2e3).re
|
|
|
51846
51846
|
}, "Use a public HTTPS hostname origin on port 443 without a path, query, credentials or fragment").transform((value2) => new URL(value2).origin);
|
|
51847
51847
|
var httpTargetCreateSchema = external_exports.object({ name, origin: httpTargetOriginSchema }).strict();
|
|
51848
51848
|
var httpTargetRevisionSchema = external_exports.object({ expectedRevision: external_exports.number().int().positive() }).strict();
|
|
51849
|
+
var FORBIDDEN_CREDENTIAL_HEADERS = /* @__PURE__ */ new Set([
|
|
51850
|
+
"accept",
|
|
51851
|
+
"accept-encoding",
|
|
51852
|
+
"connection",
|
|
51853
|
+
"content-length",
|
|
51854
|
+
"content-type",
|
|
51855
|
+
"cookie",
|
|
51856
|
+
"expect",
|
|
51857
|
+
"host",
|
|
51858
|
+
"keep-alive",
|
|
51859
|
+
"mcp-protocol-version",
|
|
51860
|
+
"mcp-session-id",
|
|
51861
|
+
"origin",
|
|
51862
|
+
"range",
|
|
51863
|
+
"referer",
|
|
51864
|
+
"set-cookie",
|
|
51865
|
+
"te",
|
|
51866
|
+
"trailer",
|
|
51867
|
+
"transfer-encoding",
|
|
51868
|
+
"upgrade",
|
|
51869
|
+
"user-agent",
|
|
51870
|
+
"via"
|
|
51871
|
+
]);
|
|
51872
|
+
var httpCredentialHeaderSchema = external_exports.string().min(1).max(64).regex(/^[A-Za-z0-9-]+$/, "Use letters, digits and hyphens in the header name").refine((value2) => {
|
|
51873
|
+
const key = value2.toLowerCase();
|
|
51874
|
+
return !(FORBIDDEN_CREDENTIAL_HEADERS.has(key) || /^(proxy-|sec-|x-forwarded-|cf-|if-)/.test(key));
|
|
51875
|
+
}, "This header is set by Waitcher or the transport and cannot carry a credential");
|
|
51849
51876
|
var httpCredentialValueSchema = external_exports.string().min(1).max(HTTP_TARGET_LIMITS.credentialBytes).regex(
|
|
51850
51877
|
/^[\x20-\x7e]+$/,
|
|
51851
51878
|
"Use a printable ASCII credential without line breaks"
|
|
51852
51879
|
);
|
|
51853
|
-
var
|
|
51854
|
-
|
|
51855
|
-
|
|
51856
|
-
|
|
51857
|
-
|
|
51880
|
+
var OAUTH_GRANTS = ["client_credentials", "refresh_token"];
|
|
51881
|
+
var oauthTokenUrlSchema = external_exports.string().trim().min(1).max(2e3).refine((value2) => {
|
|
51882
|
+
try {
|
|
51883
|
+
const url3 = new URL(value2), host = url3.hostname;
|
|
51884
|
+
return url3.protocol === "https:" && (!url3.port || url3.port === "443") && !url3.username && !url3.password && !url3.hash && host.includes(".") && !host.startsWith("[") && !host.endsWith(".") && !/^[0-9.]+$/.test(host) && !/\.(localhost|local|internal|test|invalid)$/.test(host);
|
|
51885
|
+
} catch {
|
|
51886
|
+
return false;
|
|
51887
|
+
}
|
|
51888
|
+
}, "Use a public HTTPS token endpoint on port 443 without credentials or a fragment");
|
|
51889
|
+
var oauthText = (max) => external_exports.string().min(1).max(max).regex(/^[\x20-\x7e]+$/);
|
|
51890
|
+
var oauthSettingsSchema = external_exports.object({
|
|
51891
|
+
grant: external_exports.enum(OAUTH_GRANTS),
|
|
51892
|
+
tokenUrl: oauthTokenUrlSchema,
|
|
51893
|
+
clientId: oauthText(256),
|
|
51894
|
+
scope: oauthText(512).optional(),
|
|
51895
|
+
clientAuth: external_exports.enum(["post", "basic"]).default("post")
|
|
51896
|
+
}).strict();
|
|
51897
|
+
var oauthSecretSchema = external_exports.object({
|
|
51898
|
+
clientSecret: oauthText(2048).optional(),
|
|
51899
|
+
refreshToken: oauthText(2048).optional()
|
|
51858
51900
|
}).strict();
|
|
51901
|
+
var oauthValueSchema = external_exports.string().min(1).max(5e3).regex(/^[\x20-\x7e]+$/, "Use a printable ASCII credential without line breaks");
|
|
51902
|
+
var httpCredentialCreateSchema = external_exports.union([
|
|
51903
|
+
external_exports.object({
|
|
51904
|
+
targetId: external_exports.uuid(),
|
|
51905
|
+
name,
|
|
51906
|
+
header: httpCredentialHeaderSchema,
|
|
51907
|
+
value: httpCredentialValueSchema
|
|
51908
|
+
}).strict(),
|
|
51909
|
+
external_exports.object({
|
|
51910
|
+
targetId: external_exports.uuid(),
|
|
51911
|
+
name,
|
|
51912
|
+
kind: external_exports.literal("oauth2"),
|
|
51913
|
+
oauth: oauthSettingsSchema,
|
|
51914
|
+
value: oauthValueSchema
|
|
51915
|
+
}).strict()
|
|
51916
|
+
]);
|
|
51859
51917
|
var httpCredentialRotateSchema = external_exports.object({
|
|
51860
51918
|
expectedRevision: external_exports.number().int().positive(),
|
|
51861
|
-
value
|
|
51919
|
+
// A static header value is limited to 4096 bytes by the service.
|
|
51920
|
+
value: oauthValueSchema
|
|
51862
51921
|
}).strict();
|
|
51863
51922
|
var httpAuthSchema = external_exports.object({
|
|
51864
51923
|
targetId: external_exports.uuid(),
|
|
@@ -51881,7 +51940,13 @@ var httpCredentialResourceSchema = external_exports.object({
|
|
|
51881
51940
|
id: external_exports.uuid(),
|
|
51882
51941
|
targetId: external_exports.uuid(),
|
|
51883
51942
|
name,
|
|
51884
|
-
header:
|
|
51943
|
+
header: httpCredentialHeaderSchema,
|
|
51944
|
+
kind: external_exports.enum(["header", "oauth2"]),
|
|
51945
|
+
// Non-secret token settings and the last refresh outcome, for oauth2.
|
|
51946
|
+
oauth: oauthSettingsSchema.extend({
|
|
51947
|
+
lastRefreshAt: external_exports.number().int().nonnegative().nullable(),
|
|
51948
|
+
lastError: external_exports.string().max(200).nullable()
|
|
51949
|
+
}).strict().optional(),
|
|
51885
51950
|
revision: external_exports.number().int().positive(),
|
|
51886
51951
|
enabled: external_exports.boolean(),
|
|
51887
51952
|
hasCredential: external_exports.boolean()
|
|
@@ -51897,12 +51962,9 @@ var httpTargetChallengeResponseSchema = external_exports.object({
|
|
|
51897
51962
|
}).strict();
|
|
51898
51963
|
var httpExecutionCredentialSchema = httpAuthSchema.extend({
|
|
51899
51964
|
origin: httpTargetOriginSchema,
|
|
51900
|
-
headers: external_exports.
|
|
51901
|
-
|
|
51902
|
-
"
|
|
51903
|
-
}).strict().refine(
|
|
51904
|
-
(value2) => Object.keys(value2).length === 1 && Object.values(value2).every((value3) => typeof value3 === "string"),
|
|
51905
|
-
"Use exactly one supported credential header"
|
|
51965
|
+
headers: external_exports.record(httpCredentialHeaderSchema, httpCredentialValueSchema).refine(
|
|
51966
|
+
(value2) => Object.keys(value2).length === 1,
|
|
51967
|
+
"Use exactly one credential header"
|
|
51906
51968
|
)
|
|
51907
51969
|
}).strict();
|
|
51908
51970
|
|
|
@@ -52274,6 +52336,11 @@ var VISUAL_POLICY = Object.freeze({
|
|
|
52274
52336
|
reviewLogPerHead: 200,
|
|
52275
52337
|
reviewLogGlobal: 1e4,
|
|
52276
52338
|
historyDays: 30,
|
|
52339
|
+
// A visual check's run evidence (capture, diff, report) is kept for the
|
|
52340
|
+
// latest passing run and the latest failed runs of each head; older ones
|
|
52341
|
+
// expire at once instead of after the plan's evidence days.
|
|
52342
|
+
passedEvidencePerHead: 1,
|
|
52343
|
+
failedEvidencePerHead: 10,
|
|
52277
52344
|
pageSize: 50
|
|
52278
52345
|
});
|
|
52279
52346
|
var SCRIPT_SCREENSHOT_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,150}\.png$/;
|
|
@@ -52638,21 +52705,21 @@ function validateAiVariables(input2) {
|
|
|
52638
52705
|
return invalid();
|
|
52639
52706
|
return value2;
|
|
52640
52707
|
}
|
|
52641
|
-
function renderText(
|
|
52708
|
+
function renderText(text4, variables) {
|
|
52642
52709
|
let cursor = 0, result2 = "";
|
|
52643
52710
|
for (; ; ) {
|
|
52644
|
-
const open19 =
|
|
52711
|
+
const open19 = text4.indexOf("{{", cursor), close = text4.indexOf("}}", cursor);
|
|
52645
52712
|
if (close >= 0 && (open19 < 0 || close < open19)) return invalid();
|
|
52646
52713
|
if (open19 < 0) {
|
|
52647
|
-
result2 +=
|
|
52714
|
+
result2 += text4.slice(cursor);
|
|
52648
52715
|
break;
|
|
52649
52716
|
}
|
|
52650
|
-
const end =
|
|
52717
|
+
const end = text4.indexOf("}}", open19 + 2);
|
|
52651
52718
|
if (end < 0) return invalid();
|
|
52652
|
-
const key =
|
|
52719
|
+
const key = text4.slice(open19 + 2, end);
|
|
52653
52720
|
if (!name2.test(key)) return invalid();
|
|
52654
52721
|
if (!Object.hasOwn(variables, key)) throw new AiTemplateError(key);
|
|
52655
|
-
result2 +=
|
|
52722
|
+
result2 += text4.slice(cursor, open19) + variables[key];
|
|
52656
52723
|
if (result2.length > AI_TEMPLATE_LIMITS.fixtureBytes) return invalid();
|
|
52657
52724
|
cursor = end + 2;
|
|
52658
52725
|
}
|
|
@@ -53134,6 +53201,117 @@ var heartbeatEventSchema = external_exports.object({
|
|
|
53134
53201
|
sentAt: external_exports.number().int().positive()
|
|
53135
53202
|
}).strict();
|
|
53136
53203
|
|
|
53204
|
+
// ../../src/contracts/mcp.ts
|
|
53205
|
+
var MCP_LIMITS = {
|
|
53206
|
+
expectTools: 50,
|
|
53207
|
+
toolNameLength: 128,
|
|
53208
|
+
argumentsBytes: 8 * 1024,
|
|
53209
|
+
assertions: 20,
|
|
53210
|
+
responseBytes: 256 * 1024,
|
|
53211
|
+
responseDepth: 64,
|
|
53212
|
+
responseNodes: 32768,
|
|
53213
|
+
listPages: 5,
|
|
53214
|
+
tools: 500,
|
|
53215
|
+
// Tool names the report keeps so a user can pick expectTools.
|
|
53216
|
+
reportedNames: 100,
|
|
53217
|
+
maxTimeoutSeconds: 30
|
|
53218
|
+
};
|
|
53219
|
+
var MCP_CLIENT_PROTOCOL = "2025-11-25";
|
|
53220
|
+
var MCP_PROTOCOL_VERSIONS = [
|
|
53221
|
+
"2025-11-25",
|
|
53222
|
+
"2025-06-18",
|
|
53223
|
+
"2025-03-26",
|
|
53224
|
+
"2024-11-05"
|
|
53225
|
+
];
|
|
53226
|
+
var toolName = external_exports.string().min(1).max(MCP_LIMITS.toolNameLength).regex(
|
|
53227
|
+
/^[A-Za-z0-9_.\/-]+$/,
|
|
53228
|
+
"Use a tool name of letters, digits, _ . / or -"
|
|
53229
|
+
);
|
|
53230
|
+
var mcpToolCallSchema = external_exports.object({
|
|
53231
|
+
name: toolName,
|
|
53232
|
+
arguments: external_exports.record(external_exports.string(), external_exports.unknown()).default({}).refine(
|
|
53233
|
+
(value2) => isBoundedJson(value2, {
|
|
53234
|
+
bytes: MCP_LIMITS.argumentsBytes,
|
|
53235
|
+
depth: 16,
|
|
53236
|
+
nodes: 4096
|
|
53237
|
+
}),
|
|
53238
|
+
`Use a JSON object of arguments up to ${MCP_LIMITS.argumentsBytes / 1024} KiB`
|
|
53239
|
+
),
|
|
53240
|
+
assertions: external_exports.array(aiEndpointAssertionSchema).max(MCP_LIMITS.assertions).default([])
|
|
53241
|
+
}).strict();
|
|
53242
|
+
var mcpConfigSchema = external_exports.object({
|
|
53243
|
+
expectTools: external_exports.array(toolName).max(MCP_LIMITS.expectTools).default([]).refine(
|
|
53244
|
+
(names) => new Set(names).size === names.length,
|
|
53245
|
+
"List each expected tool once"
|
|
53246
|
+
),
|
|
53247
|
+
toolCall: mcpToolCallSchema.optional()
|
|
53248
|
+
}).strict();
|
|
53249
|
+
var reason = external_exports.enum([
|
|
53250
|
+
"INVALID_CONFIGURATION",
|
|
53251
|
+
"INVALID_TARGET",
|
|
53252
|
+
"TRANSPORT_ERROR",
|
|
53253
|
+
"TIMEOUT",
|
|
53254
|
+
"REDIRECT_REFUSED",
|
|
53255
|
+
"RESPONSE_TOO_LARGE",
|
|
53256
|
+
"MALFORMED_RESPONSE",
|
|
53257
|
+
"HTTP_ERROR",
|
|
53258
|
+
"AUTH_REJECTED",
|
|
53259
|
+
"JSONRPC_ERROR",
|
|
53260
|
+
"UNSUPPORTED_PROTOCOL",
|
|
53261
|
+
"NO_TOOLS_CAPABILITY",
|
|
53262
|
+
"MALFORMED_TOOLS",
|
|
53263
|
+
"MISSING_TOOLS",
|
|
53264
|
+
"TOOL_NOT_LISTED",
|
|
53265
|
+
"TOOL_ERROR",
|
|
53266
|
+
"ASSERTION_FAILED"
|
|
53267
|
+
]);
|
|
53268
|
+
var label = external_exports.string().max(128).nullable();
|
|
53269
|
+
var mcpReportSchema = external_exports.object({
|
|
53270
|
+
schemaVersion: external_exports.literal(1),
|
|
53271
|
+
kind: external_exports.literal("mcp"),
|
|
53272
|
+
status: external_exports.enum(["passed", "failed", "error"]),
|
|
53273
|
+
reason: reason.nullable(),
|
|
53274
|
+
server: external_exports.object({
|
|
53275
|
+
name: label,
|
|
53276
|
+
version: label,
|
|
53277
|
+
protocolVersion: label,
|
|
53278
|
+
session: external_exports.boolean()
|
|
53279
|
+
}).strict(),
|
|
53280
|
+
steps: external_exports.array(
|
|
53281
|
+
external_exports.object({
|
|
53282
|
+
method: external_exports.enum([
|
|
53283
|
+
"initialize",
|
|
53284
|
+
"notifications/initialized",
|
|
53285
|
+
"tools/list",
|
|
53286
|
+
"tools/call"
|
|
53287
|
+
]),
|
|
53288
|
+
httpStatus: external_exports.number().int().nullable(),
|
|
53289
|
+
durationMs: external_exports.number().int().nonnegative(),
|
|
53290
|
+
ok: external_exports.boolean(),
|
|
53291
|
+
jsonRpcCode: external_exports.number().int().nullable()
|
|
53292
|
+
}).strict()
|
|
53293
|
+
).max(MCP_LIMITS.listPages + 3),
|
|
53294
|
+
tools: external_exports.object({
|
|
53295
|
+
count: external_exports.number().int().nonnegative().nullable(),
|
|
53296
|
+
truncated: external_exports.boolean(),
|
|
53297
|
+
expected: external_exports.number().int().nonnegative(),
|
|
53298
|
+
missing: external_exports.array(external_exports.string().max(MCP_LIMITS.toolNameLength)),
|
|
53299
|
+
names: external_exports.array(external_exports.string().max(MCP_LIMITS.toolNameLength)).max(MCP_LIMITS.reportedNames)
|
|
53300
|
+
}).strict(),
|
|
53301
|
+
toolCall: external_exports.object({
|
|
53302
|
+
name: external_exports.string().max(MCP_LIMITS.toolNameLength),
|
|
53303
|
+
isError: external_exports.boolean().nullable(),
|
|
53304
|
+
assertions: external_exports.array(
|
|
53305
|
+
external_exports.object({
|
|
53306
|
+
path: external_exports.string().max(260),
|
|
53307
|
+
operator: external_exports.string().max(32),
|
|
53308
|
+
passed: external_exports.boolean(),
|
|
53309
|
+
reason: external_exports.enum(["MISSING_PATH", "TYPE_MISMATCH", "VALUE_MISMATCH"]).nullable()
|
|
53310
|
+
}).strict()
|
|
53311
|
+
)
|
|
53312
|
+
}).strict().nullable()
|
|
53313
|
+
}).strict();
|
|
53314
|
+
|
|
53137
53315
|
// ../../src/contracts/browser-identities.ts
|
|
53138
53316
|
var BROWSER_IDENTITY_LIMITS = {
|
|
53139
53317
|
ownerIdentities: 10,
|
|
@@ -53306,6 +53484,62 @@ var agentKeySchema = external_exports.object({
|
|
|
53306
53484
|
model: modelNameSchema
|
|
53307
53485
|
}).strict();
|
|
53308
53486
|
|
|
53487
|
+
// ../../src/contracts/network.ts
|
|
53488
|
+
var NETWORK_LIMITS = Object.freeze({
|
|
53489
|
+
maxTimeoutSeconds: 15,
|
|
53490
|
+
bannerChars: 200,
|
|
53491
|
+
bannerBytes: 1024,
|
|
53492
|
+
expectedValues: 20,
|
|
53493
|
+
valueChars: 255,
|
|
53494
|
+
answers: 32
|
|
53495
|
+
});
|
|
53496
|
+
var DNS_RECORD_TYPES = ["A", "AAAA", "CNAME", "MX", "TXT"];
|
|
53497
|
+
var tcpConfigSchema = external_exports.object({
|
|
53498
|
+
// Text the server must send first, such as "SSH-2.0" or "220 ". Empty
|
|
53499
|
+
// means a completed connection passes.
|
|
53500
|
+
banner: external_exports.string().max(NETWORK_LIMITS.bannerChars).default("")
|
|
53501
|
+
}).strict();
|
|
53502
|
+
var dnsConfigSchema = external_exports.object({
|
|
53503
|
+
recordType: external_exports.enum(DNS_RECORD_TYPES),
|
|
53504
|
+
// Values the answer must hold. Empty means any answer passes.
|
|
53505
|
+
expected: external_exports.array(external_exports.string().trim().min(1).max(NETWORK_LIMITS.valueChars)).max(NETWORK_LIMITS.expectedValues).default([]),
|
|
53506
|
+
// includes: every expected value is in the answer; exact: the answer is
|
|
53507
|
+
// exactly the expected set.
|
|
53508
|
+
match: external_exports.enum(["includes", "exact"]).default("includes")
|
|
53509
|
+
}).strict();
|
|
53510
|
+
var RESERVED = /(^|\.)(localhost|local|internal|test|invalid|example|home\.arpa|lan|corp)\.?$/i;
|
|
53511
|
+
var LABELS = /^(?=.{1,253}$)(?:[A-Za-z0-9_](?:[A-Za-z0-9_-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z][A-Za-z0-9-]{0,61}[A-Za-z0-9]\.?$/;
|
|
53512
|
+
var IPV4 = /^(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/;
|
|
53513
|
+
function publicDnsName(name5) {
|
|
53514
|
+
return LABELS.test(name5) && !RESERVED.test(name5);
|
|
53515
|
+
}
|
|
53516
|
+
function parseTcpTarget(target) {
|
|
53517
|
+
const match = /^\[([0-9A-Fa-f:.]{2,45})\]:(\d{1,5})$/.exec(target) ?? /^([A-Za-z0-9._-]{1,253}):(\d{1,5})$/.exec(target);
|
|
53518
|
+
if (!match) return null;
|
|
53519
|
+
const host = match[1], port = Number(match[2]);
|
|
53520
|
+
if (port < 1 || port > 65535) return null;
|
|
53521
|
+
if (target.startsWith("[") || IPV4.test(host)) return { host, port };
|
|
53522
|
+
return publicDnsName(host) ? { host: host.replace(/\.$/, ""), port } : null;
|
|
53523
|
+
}
|
|
53524
|
+
var networkTraceSchema = external_exports.object({
|
|
53525
|
+
protocol: external_exports.enum(["tcp", "dns"]),
|
|
53526
|
+
host: external_exports.string().max(253),
|
|
53527
|
+
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
53528
|
+
recordType: external_exports.enum(DNS_RECORD_TYPES).nullable(),
|
|
53529
|
+
// The resolver a DNS check asked; TCP uses the host's resolver.
|
|
53530
|
+
resolver: external_exports.string().max(100).nullable(),
|
|
53531
|
+
// The address a TCP check connected to.
|
|
53532
|
+
address: external_exports.string().max(64).nullable(),
|
|
53533
|
+
answers: external_exports.array(external_exports.string().max(300)).max(NETWORK_LIMITS.answers),
|
|
53534
|
+
banner: external_exports.string().max(300).nullable(),
|
|
53535
|
+
timings: external_exports.object({
|
|
53536
|
+
dns: external_exports.number().int().min(0).nullable(),
|
|
53537
|
+
connect: external_exports.number().int().min(0).nullable(),
|
|
53538
|
+
banner: external_exports.number().int().min(0).nullable()
|
|
53539
|
+
}).strict(),
|
|
53540
|
+
error: external_exports.string().max(300).nullable()
|
|
53541
|
+
}).strict();
|
|
53542
|
+
|
|
53309
53543
|
// ../../src/contracts/monitor.ts
|
|
53310
53544
|
var url2 = external_exports.string().max(2e3).url().refine((value2) => {
|
|
53311
53545
|
try {
|
|
@@ -53326,7 +53560,10 @@ var monitorSchema = external_exports.object({
|
|
|
53326
53560
|
"certificate",
|
|
53327
53561
|
"visual",
|
|
53328
53562
|
"heartbeat",
|
|
53329
|
-
"ai"
|
|
53563
|
+
"ai",
|
|
53564
|
+
"mcp",
|
|
53565
|
+
"tcp",
|
|
53566
|
+
"dns"
|
|
53330
53567
|
]),
|
|
53331
53568
|
target: external_exports.string().trim().min(1).max(2e3),
|
|
53332
53569
|
interval: external_exports.number().int().min(60).max(86400).default(300),
|
|
@@ -53338,11 +53575,17 @@ var monitorSchema = external_exports.object({
|
|
|
53338
53575
|
ai: modelGrantSchema.optional(),
|
|
53339
53576
|
heartbeat: heartbeatConfigSchema.optional(),
|
|
53340
53577
|
aiEndpoint: aiEndpointConfigSchema.optional(),
|
|
53578
|
+
mcp: mcpConfigSchema.optional(),
|
|
53579
|
+
tcp: tcpConfigSchema.optional(),
|
|
53580
|
+
dns: dnsConfigSchema.optional(),
|
|
53341
53581
|
httpAuth: httpAuthSchema.optional(),
|
|
53342
53582
|
protectedRequests: productRequestsPolicySchema.optional(),
|
|
53343
53583
|
browserIdentity: browserIdentityBindingSchema.optional(),
|
|
53344
53584
|
agent: agentBindingSchema.optional(),
|
|
53345
53585
|
requestBudget: requestBudgetSchema.optional(),
|
|
53586
|
+
// false opts an HTTP or certificate check out of second-region
|
|
53587
|
+
// confirmation (docs/design/second-region.md); absent means on.
|
|
53588
|
+
secondRegion: external_exports.boolean().optional(),
|
|
53346
53589
|
settings: external_exports.object({
|
|
53347
53590
|
certificateMinDays: external_exports.number().int().min(1).max(90).optional(),
|
|
53348
53591
|
method: external_exports.enum(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]).default("GET"),
|
|
@@ -53357,9 +53600,9 @@ var monitorSchema = external_exports.object({
|
|
|
53357
53600
|
}).prefault({})
|
|
53358
53601
|
}).superRefine((m, ctx) => {
|
|
53359
53602
|
const issue3 = (message, path2) => ctx.addIssue({ code: "custom", message, path: [path2] });
|
|
53360
|
-
if (m.requestBudget && !(m.type === "ai" || m.httpAuth || m.protectedRequests))
|
|
53603
|
+
if (m.requestBudget && !(m.type === "ai" || m.type === "mcp" || m.httpAuth || m.protectedRequests))
|
|
53361
53604
|
issue3(
|
|
53362
|
-
"Daily invocation budgets require an AI endpoint, authenticated HTTP check or protected request script",
|
|
53605
|
+
"Daily invocation budgets require an AI endpoint, MCP, authenticated HTTP check or protected request script",
|
|
53363
53606
|
"requestBudget"
|
|
53364
53607
|
);
|
|
53365
53608
|
if (m.protectedRequests) {
|
|
@@ -53385,9 +53628,9 @@ var monitorSchema = external_exports.object({
|
|
|
53385
53628
|
}
|
|
53386
53629
|
}
|
|
53387
53630
|
if (m.httpAuth) {
|
|
53388
|
-
if (!["http", "ai"].includes(m.type) || m.script || m.ai || m.demo || m.settings.envNames.length || Object.keys(m.settings.headers).length)
|
|
53631
|
+
if (!["http", "ai", "mcp"].includes(m.type) || m.script || m.ai || m.demo || m.settings.envNames.length || Object.keys(m.settings.headers).length)
|
|
53389
53632
|
issue3(
|
|
53390
|
-
"HTTP credentials require a live fixed HTTP
|
|
53633
|
+
"HTTP credentials require a live fixed HTTP, AI endpoint or MCP check without scripts or custom headers",
|
|
53391
53634
|
"httpAuth"
|
|
53392
53635
|
);
|
|
53393
53636
|
if (!["GET", "HEAD", "POST"].includes(m.settings.method) || new TextEncoder().encode(m.settings.body).byteLength > 16384)
|
|
@@ -53418,6 +53661,11 @@ var monitorSchema = external_exports.object({
|
|
|
53418
53661
|
issue3("Use a public HTTPS endpoint", "target");
|
|
53419
53662
|
}
|
|
53420
53663
|
}
|
|
53664
|
+
if (m.secondRegion !== void 0 && !["http", "certificate"].includes(m.type))
|
|
53665
|
+
issue3(
|
|
53666
|
+
"Second-region confirmation applies to HTTP and certificate checks",
|
|
53667
|
+
"secondRegion"
|
|
53668
|
+
);
|
|
53421
53669
|
if (m.type !== "ai" && m.aiEndpoint !== void 0)
|
|
53422
53670
|
issue3(
|
|
53423
53671
|
"AI endpoint settings require an AI endpoint monitor",
|
|
@@ -53452,6 +53700,59 @@ var monitorSchema = external_exports.object({
|
|
|
53452
53700
|
"settings"
|
|
53453
53701
|
);
|
|
53454
53702
|
}
|
|
53703
|
+
if (m.type !== "mcp" && m.mcp !== void 0)
|
|
53704
|
+
issue3("MCP settings require an MCP monitor", "mcp");
|
|
53705
|
+
if (m.type === "mcp") {
|
|
53706
|
+
if (!m.mcp) issue3("MCP settings are required", "mcp");
|
|
53707
|
+
if (m.timeout > MCP_LIMITS.maxTimeoutSeconds)
|
|
53708
|
+
issue3(
|
|
53709
|
+
`MCP checks have a maximum timeout of ${MCP_LIMITS.maxTimeoutSeconds} seconds`,
|
|
53710
|
+
"timeout"
|
|
53711
|
+
);
|
|
53712
|
+
try {
|
|
53713
|
+
const target = new URL(m.target);
|
|
53714
|
+
if (target.protocol !== "https:" || target.port && target.port !== "443" || target.username || target.password || target.hash)
|
|
53715
|
+
issue3(
|
|
53716
|
+
"Use a public HTTPS MCP endpoint on port 443 without credentials or a fragment",
|
|
53717
|
+
"target"
|
|
53718
|
+
);
|
|
53719
|
+
} catch {
|
|
53720
|
+
issue3("Use a public HTTPS MCP endpoint", "target");
|
|
53721
|
+
}
|
|
53722
|
+
if (m.demo || m.script || m.ai || m.visual || m.heartbeat || m.aiEndpoint || Object.keys(m.settings.headers).length || m.settings.body || m.settings.envNames.length || m.settings.method !== "GET" || m.settings.contains || m.settings.jsonPath || m.settings.jsonValue || m.settings.maxLatency || m.settings.expectedStatus !== 200 || m.settings.certificateMinDays !== void 0)
|
|
53723
|
+
issue3(
|
|
53724
|
+
"MCP monitors use expected tools and an optional tool call; scripts, custom headers and HTTP assertions are not supported",
|
|
53725
|
+
"settings"
|
|
53726
|
+
);
|
|
53727
|
+
}
|
|
53728
|
+
if (m.type !== "tcp" && m.tcp !== void 0)
|
|
53729
|
+
issue3("TCP settings require a TCP monitor", "tcp");
|
|
53730
|
+
if (m.type !== "dns" && m.dns !== void 0)
|
|
53731
|
+
issue3("DNS settings require a DNS monitor", "dns");
|
|
53732
|
+
if (m.type === "tcp" || m.type === "dns") {
|
|
53733
|
+
if (m.type === "dns" && !m.dns)
|
|
53734
|
+
issue3("Choose a DNS record type", "dns");
|
|
53735
|
+
if (m.type === "tcp" && !parseTcpTarget(m.target))
|
|
53736
|
+
issue3(
|
|
53737
|
+
"Enter HOST:PORT with a public hostname or IP address, such as db.example.com:5432",
|
|
53738
|
+
"target"
|
|
53739
|
+
);
|
|
53740
|
+
if (m.type === "dns" && !publicDnsName(m.target))
|
|
53741
|
+
issue3(
|
|
53742
|
+
"Enter a public DNS name such as example.com, without a scheme or path",
|
|
53743
|
+
"target"
|
|
53744
|
+
);
|
|
53745
|
+
if (m.timeout > NETWORK_LIMITS.maxTimeoutSeconds)
|
|
53746
|
+
issue3(
|
|
53747
|
+
`TCP and DNS checks have a maximum timeout of ${NETWORK_LIMITS.maxTimeoutSeconds} seconds`,
|
|
53748
|
+
"timeout"
|
|
53749
|
+
);
|
|
53750
|
+
if (m.demo || m.script || m.ai || m.visual || m.heartbeat || m.aiEndpoint || m.mcp || m.httpAuth || m.requestBudget || Object.keys(m.settings.headers).length || m.settings.body || m.settings.envNames.length || m.settings.method !== "GET" || m.settings.contains || m.settings.jsonPath || m.settings.jsonValue || m.settings.maxLatency || m.settings.expectedStatus !== 200 || m.settings.certificateMinDays !== void 0)
|
|
53751
|
+
issue3(
|
|
53752
|
+
m.type === "tcp" ? "TCP checks accept a host, port and optional banner only; scripts and HTTP assertions are not supported" : "DNS checks accept a name, record type and expected values only; scripts and HTTP assertions are not supported",
|
|
53753
|
+
"settings"
|
|
53754
|
+
);
|
|
53755
|
+
}
|
|
53455
53756
|
if (m.type !== "heartbeat" && m.heartbeat !== void 0)
|
|
53456
53757
|
issue3("Heartbeat settings require a heartbeat monitor", "heartbeat");
|
|
53457
53758
|
if (m.type === "heartbeat") {
|
|
@@ -53516,7 +53817,7 @@ var monitorSchema = external_exports.object({
|
|
|
53516
53817
|
"Enter a hostname or IP address, without a URL or flags",
|
|
53517
53818
|
"target"
|
|
53518
53819
|
);
|
|
53519
|
-
} else if (
|
|
53820
|
+
} else if (!["heartbeat", "tcp", "dns"].includes(m.type)) {
|
|
53520
53821
|
if (!url2.safeParse(m.target).success)
|
|
53521
53822
|
issue3("Enter an HTTP(S) URL without embedded credentials", "target");
|
|
53522
53823
|
if (m.type === "browser") {
|
|
@@ -53943,7 +54244,7 @@ async function boundedText(response, maxBytes = 8 * 1024 * 1024) {
|
|
|
53943
54244
|
const reader = response.body?.getReader();
|
|
53944
54245
|
if (!reader) return "";
|
|
53945
54246
|
const decoder = new TextDecoder();
|
|
53946
|
-
let total = 0,
|
|
54247
|
+
let total = 0, text4 = "";
|
|
53947
54248
|
try {
|
|
53948
54249
|
while (true) {
|
|
53949
54250
|
const part2 = await reader.read();
|
|
@@ -53951,9 +54252,9 @@ async function boundedText(response, maxBytes = 8 * 1024 * 1024) {
|
|
|
53951
54252
|
total += part2.value.byteLength;
|
|
53952
54253
|
if (total > maxBytes)
|
|
53953
54254
|
throw new Error("Response exceeds the 8 MiB text limit");
|
|
53954
|
-
|
|
54255
|
+
text4 += decoder.decode(part2.value, { stream: true });
|
|
53955
54256
|
}
|
|
53956
|
-
return
|
|
54257
|
+
return text4 + decoder.decode();
|
|
53957
54258
|
} finally {
|
|
53958
54259
|
await reader.cancel().catch(() => {
|
|
53959
54260
|
});
|
|
@@ -54010,6 +54311,10 @@ function asError(value2) {
|
|
|
54010
54311
|
}
|
|
54011
54312
|
|
|
54012
54313
|
// src/client.ts
|
|
54314
|
+
var defaultWorkspace;
|
|
54315
|
+
function useWorkspace(id4) {
|
|
54316
|
+
defaultWorkspace = id4;
|
|
54317
|
+
}
|
|
54013
54318
|
var ServiceError = class extends Error {
|
|
54014
54319
|
idempotencyKey;
|
|
54015
54320
|
code;
|
|
@@ -54031,7 +54336,8 @@ async function request(server, path2, {
|
|
|
54031
54336
|
body: body2,
|
|
54032
54337
|
signal,
|
|
54033
54338
|
secrets = [],
|
|
54034
|
-
version: version2 = "v1"
|
|
54339
|
+
version: version2 = "v1",
|
|
54340
|
+
workspace = defaultWorkspace
|
|
54035
54341
|
} = {}) {
|
|
54036
54342
|
if (idempotencyKey !== void 0 && (!requestKeyPattern.test(idempotencyKey) || !keyedOperation(path2, method)))
|
|
54037
54343
|
throw new ServiceError(
|
|
@@ -54061,7 +54367,8 @@ async function request(server, path2, {
|
|
|
54061
54367
|
"Content-Type": "application/json",
|
|
54062
54368
|
...key ? { "Idempotency-Key": key } : {},
|
|
54063
54369
|
...cookie ? { Cookie: cookie } : {},
|
|
54064
|
-
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
54370
|
+
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
|
|
54371
|
+
...workspace ? { "Waitcher-Workspace": workspace } : {}
|
|
54065
54372
|
},
|
|
54066
54373
|
...body2 !== void 0 ? { body: JSON.stringify(body2) } : {},
|
|
54067
54374
|
signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(15e3)]) : AbortSignal.timeout(15e3)
|
|
@@ -54093,7 +54400,7 @@ async function request(server, path2, {
|
|
|
54093
54400
|
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}`;
|
|
54094
54401
|
const safe = [cookie, cookie?.split("=")[1], accessToken, ...secrets].filter(
|
|
54095
54402
|
(value2) => typeof value2 === "string" && value2.length > 0
|
|
54096
|
-
).reduce((
|
|
54403
|
+
).reduce((text4, secret) => text4.replaceAll(secret, "[redacted]"), message);
|
|
54097
54404
|
const failure3 = new ServiceError(
|
|
54098
54405
|
safe,
|
|
54099
54406
|
errorCode ?? (response.status === 401 ? "AUTH_REQUIRED" : response.status === 429 ? "RATE_LIMITED" : "SERVICE_ERROR"),
|
|
@@ -54103,7 +54410,7 @@ async function request(server, path2, {
|
|
|
54103
54410
|
const redacted = [cookie, cookie?.split("=")[1], accessToken, ...secrets].filter(
|
|
54104
54411
|
(value2) => typeof value2 === "string" && value2.length > 0
|
|
54105
54412
|
).reduce(
|
|
54106
|
-
(
|
|
54413
|
+
(text4, secret) => text4.replaceAll(secret, "[redacted]"),
|
|
54107
54414
|
JSON.stringify(detail.fields)
|
|
54108
54415
|
);
|
|
54109
54416
|
try {
|
|
@@ -54318,6 +54625,136 @@ function formatScenarioReport(input2) {
|
|
|
54318
54625
|
return lines.join("\n") + "\n";
|
|
54319
54626
|
}
|
|
54320
54627
|
|
|
54628
|
+
// ../../src/contracts/evidence.ts
|
|
54629
|
+
var safeEvidencePath = (path2) => path2.length <= 512 && !path2.includes("\\") && path2.split("/").every(
|
|
54630
|
+
(p) => p !== "" && p !== "." && p !== ".." && !/[\x00-\x1f\x7f]/.test(p)
|
|
54631
|
+
);
|
|
54632
|
+
|
|
54633
|
+
// ../../src/cloud/contract.ts
|
|
54634
|
+
var cloudAttemptSchema = external_exports.object({
|
|
54635
|
+
attemptId: external_exports.uuid(),
|
|
54636
|
+
deadlineAt: external_exports.number().int().positive(),
|
|
54637
|
+
monitor: monitorDefinitionSchema,
|
|
54638
|
+
environment: external_exports.record(external_exports.string().regex(/^CHECK_[A-Z0-9_]+$/), external_exports.string().max(16e3)).default({}),
|
|
54639
|
+
// Approved baselines of the test's toHaveScreenshot calls, base64 by the
|
|
54640
|
+
// file name the framework looks for.
|
|
54641
|
+
snapshots: external_exports.record(
|
|
54642
|
+
external_exports.string().regex(SCRIPT_SCREENSHOT_FILE),
|
|
54643
|
+
external_exports.string().max(Math.ceil(SCRIPT_SCREENSHOT_LIMITS.totalBytes / 3) * 4)
|
|
54644
|
+
).refine(
|
|
54645
|
+
(files) => Object.keys(files).length <= SCRIPT_SCREENSHOT_LIMITS.files && Object.values(files).reduce((n, data) => n + data.length, 0) <= Math.ceil(SCRIPT_SCREENSHOT_LIMITS.totalBytes / 3) * 4,
|
|
54646
|
+
"Stored screenshots exceed their budget"
|
|
54647
|
+
).optional()
|
|
54648
|
+
}).strict().superRefine((value2, ctx) => {
|
|
54649
|
+
const m = value2.monitor, target = new URL(m.target);
|
|
54650
|
+
if (!["api", "browser", "visual"].includes(m.type) || value2.snapshots && m.type === "api" || (m.type === "visual" ? !m.visual || Boolean(m.script) || Object.keys(value2.environment).length > 0 : !m.script?.trim()) || m.ai || m.httpAuth || m.protectedRequests || m.browserIdentity || m.demo || target.protocol !== "https:" || target.port && target.port !== "443" || Object.keys(value2.environment).some(
|
|
54651
|
+
(name5) => !m.settings.envNames.includes(name5)
|
|
54652
|
+
))
|
|
54653
|
+
ctx.addIssue({
|
|
54654
|
+
code: "custom",
|
|
54655
|
+
message: "Cloud attempts accept deterministic public HTTPS API/browser scripts, visual checks and only listed CHECK_* values"
|
|
54656
|
+
});
|
|
54657
|
+
});
|
|
54658
|
+
var cloudAgentSchema = external_exports.object({
|
|
54659
|
+
attemptId: external_exports.uuid(),
|
|
54660
|
+
deadlineAt: external_exports.number().int().positive(),
|
|
54661
|
+
agent: external_exports.object({
|
|
54662
|
+
runner: external_exports.literal("claude-code"),
|
|
54663
|
+
task: external_exports.string().min(1).max(8e3),
|
|
54664
|
+
model: external_exports.string().min(1).max(120),
|
|
54665
|
+
turns: external_exports.number().int().min(1).max(100),
|
|
54666
|
+
placeholder: external_exports.string().regex(/^wa_[a-f0-9]{48}$/)
|
|
54667
|
+
}).strict(),
|
|
54668
|
+
environment: external_exports.record(external_exports.string().regex(/^CHECK_[A-Z0-9_]+$/), external_exports.string().max(16e3)).default({})
|
|
54669
|
+
}).strict();
|
|
54670
|
+
function egressAllowed(url3) {
|
|
54671
|
+
const host = url3.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
54672
|
+
return url3.protocol === "https:" && (url3.port === "" || url3.port === "443") && !url3.username && !url3.password && !/^[\d.]+$/.test(host) && !host.includes(":") && host.includes(".") && !/(^|\.)(localhost|local|internal|home|lan|arpa)$/.test(host);
|
|
54673
|
+
}
|
|
54674
|
+
var CLOUD_EVIDENCE = Object.freeze({
|
|
54675
|
+
files: 32,
|
|
54676
|
+
fileBytes: 8 * 1024 * 1024,
|
|
54677
|
+
totalBytes: 16 * 1024 * 1024
|
|
54678
|
+
});
|
|
54679
|
+
|
|
54680
|
+
// ../../src/contracts/second-region.ts
|
|
54681
|
+
var SECOND_REGIONS = [
|
|
54682
|
+
"enam",
|
|
54683
|
+
"wnam",
|
|
54684
|
+
"apac",
|
|
54685
|
+
"apac-ne",
|
|
54686
|
+
"apac-se",
|
|
54687
|
+
"oc"
|
|
54688
|
+
];
|
|
54689
|
+
var PRIMARY_REGION = "Europe";
|
|
54690
|
+
var SECOND_REGION_LIMITS = Object.freeze({
|
|
54691
|
+
redirects: 3,
|
|
54692
|
+
bodyBytes: 256e3,
|
|
54693
|
+
// Added to an eligible attempt's absolute deadline, beyond its timeout.
|
|
54694
|
+
allowanceSeconds: 10,
|
|
54695
|
+
// Seconds beyond the monitor timeout the control plane waits for the Worker.
|
|
54696
|
+
requestSlackSeconds: 5,
|
|
54697
|
+
message: 300
|
|
54698
|
+
});
|
|
54699
|
+
var recheckRequestSchema = external_exports.object({
|
|
54700
|
+
schemaVersion: external_exports.literal(1),
|
|
54701
|
+
region: external_exports.enum(SECOND_REGIONS),
|
|
54702
|
+
// "http": the monitor's own assertions; "tls": any HTTP answer means the
|
|
54703
|
+
// TLS handshake verified from there.
|
|
54704
|
+
kind: external_exports.enum(["http", "tls"]),
|
|
54705
|
+
method: external_exports.enum(["GET", "HEAD"]),
|
|
54706
|
+
url: external_exports.string().max(2e3).refine((value2) => {
|
|
54707
|
+
try {
|
|
54708
|
+
return egressAllowed(new URL(value2));
|
|
54709
|
+
} catch {
|
|
54710
|
+
return false;
|
|
54711
|
+
}
|
|
54712
|
+
}, "Public HTTPS names on port 443 only"),
|
|
54713
|
+
expectedStatus: external_exports.number().int().min(100).max(599),
|
|
54714
|
+
contains: external_exports.string().max(2e3).default(""),
|
|
54715
|
+
jsonPath: external_exports.string().max(200).default(""),
|
|
54716
|
+
jsonValue: external_exports.string().max(2e3).default(""),
|
|
54717
|
+
timeoutMs: external_exports.number().int().min(1e3).max(18e4)
|
|
54718
|
+
}).strict();
|
|
54719
|
+
var ms = external_exports.number().int().min(0).max(6e5);
|
|
54720
|
+
var recheckResponseSchema = external_exports.object({
|
|
54721
|
+
schemaVersion: external_exports.literal(1),
|
|
54722
|
+
region: external_exports.enum(SECOND_REGIONS),
|
|
54723
|
+
// IATA code of the data center the object ran in, null if unknown.
|
|
54724
|
+
colo: external_exports.string().regex(/^[A-Z]{3}$/).nullable(),
|
|
54725
|
+
verdict: external_exports.enum(["passed", "failed", "error"]),
|
|
54726
|
+
status: external_exports.number().int().min(100).max(599).nullable(),
|
|
54727
|
+
message: external_exports.string().max(SECOND_REGION_LIMITS.message),
|
|
54728
|
+
durationMs: ms,
|
|
54729
|
+
hops: external_exports.array(
|
|
54730
|
+
external_exports.object({
|
|
54731
|
+
url: external_exports.string().max(2048),
|
|
54732
|
+
status: external_exports.number().int().min(100).max(599).nullable(),
|
|
54733
|
+
firstByteMs: ms.nullable(),
|
|
54734
|
+
totalMs: ms.nullable(),
|
|
54735
|
+
error: external_exports.string().max(SECOND_REGION_LIMITS.message).nullable()
|
|
54736
|
+
}).strict()
|
|
54737
|
+
).max(SECOND_REGION_LIMITS.redirects + 1)
|
|
54738
|
+
}).strict();
|
|
54739
|
+
var confirmationOutcomes = [
|
|
54740
|
+
"confirmed",
|
|
54741
|
+
"not_confirmed",
|
|
54742
|
+
"recheck_error",
|
|
54743
|
+
"skipped"
|
|
54744
|
+
];
|
|
54745
|
+
var runConfirmationSchema = external_exports.object({
|
|
54746
|
+
outcome: external_exports.enum(confirmationOutcomes),
|
|
54747
|
+
primary: external_exports.literal(PRIMARY_REGION),
|
|
54748
|
+
region: external_exports.enum(SECOND_REGIONS).nullable(),
|
|
54749
|
+
colo: external_exports.string().max(8).nullable(),
|
|
54750
|
+
status: external_exports.number().int().min(100).max(599).nullable(),
|
|
54751
|
+
durationMs: ms.nullable(),
|
|
54752
|
+
message: external_exports.string().max(SECOND_REGION_LIMITS.message),
|
|
54753
|
+
hops: recheckResponseSchema.shape.hops,
|
|
54754
|
+
at: external_exports.number().int().min(0),
|
|
54755
|
+
incidentId: external_exports.string().max(64).nullable()
|
|
54756
|
+
}).strict();
|
|
54757
|
+
|
|
54321
54758
|
// ../../src/contracts/run-trace.ts
|
|
54322
54759
|
var RUN_TRACE_PATH = ".e2e/waitcher-trace.json";
|
|
54323
54760
|
var FETCH_TRACE_PATH = ".e2e/waitcher-fetch.json";
|
|
@@ -54336,8 +54773,8 @@ var RUN_TRACE_LIMITS = Object.freeze({
|
|
|
54336
54773
|
fileBytes: 65536
|
|
54337
54774
|
});
|
|
54338
54775
|
var text = (max = RUN_TRACE_LIMITS.text) => external_exports.string().max(max);
|
|
54339
|
-
var
|
|
54340
|
-
var nullableMs =
|
|
54776
|
+
var ms2 = external_exports.number().int().min(0).max(864e5);
|
|
54777
|
+
var nullableMs = ms2.nullable();
|
|
54341
54778
|
var TRACE_HEADERS = [
|
|
54342
54779
|
"content-type",
|
|
54343
54780
|
"content-length",
|
|
@@ -54412,13 +54849,18 @@ var runTraceFileSchema = external_exports.discriminatedUnion("kind", [
|
|
|
54412
54849
|
schemaVersion: external_exports.literal(1),
|
|
54413
54850
|
kind: external_exports.literal("certificate"),
|
|
54414
54851
|
certificate: certificateTraceSchema
|
|
54852
|
+
}).strict(),
|
|
54853
|
+
external_exports.object({
|
|
54854
|
+
schemaVersion: external_exports.literal(1),
|
|
54855
|
+
kind: external_exports.literal("network"),
|
|
54856
|
+
network: networkTraceSchema
|
|
54415
54857
|
}).strict()
|
|
54416
54858
|
]);
|
|
54417
54859
|
var fetchRecordSchema = external_exports.object({
|
|
54418
54860
|
method: external_exports.string().min(1).max(16),
|
|
54419
54861
|
url: text(2048),
|
|
54420
54862
|
status: external_exports.number().int().min(0).max(599).nullable(),
|
|
54421
|
-
durationMs:
|
|
54863
|
+
durationMs: ms2,
|
|
54422
54864
|
error: text().nullable()
|
|
54423
54865
|
}).strict();
|
|
54424
54866
|
var fetchTraceFileSchema = external_exports.object({
|
|
@@ -54458,7 +54900,7 @@ var traceTestSchema = external_exports.object({
|
|
|
54458
54900
|
api: text(64),
|
|
54459
54901
|
label: text(),
|
|
54460
54902
|
status: stepStatus,
|
|
54461
|
-
durationMs:
|
|
54903
|
+
durationMs: ms2,
|
|
54462
54904
|
line: external_exports.number().int().min(1).nullable(),
|
|
54463
54905
|
error: text(RUN_TRACE_LIMITS.message).nullable()
|
|
54464
54906
|
}).strict()
|
|
@@ -54492,11 +54934,15 @@ var runTraceSchema = external_exports.object({
|
|
|
54492
54934
|
exchanges: external_exports.array(httpExchangeSchema).max(RUN_TRACE_LIMITS.exchanges)
|
|
54493
54935
|
}).strict().nullable(),
|
|
54494
54936
|
certificate: certificateTraceSchema.nullable(),
|
|
54937
|
+
// TCP and DNS checks; absent for other types, so older CLIs still parse.
|
|
54938
|
+
network: networkTraceSchema.optional(),
|
|
54495
54939
|
tests: external_exports.array(traceTestSchema).max(RUN_TRACE_LIMITS.tests).nullable(),
|
|
54496
54940
|
requests: external_exports.object({
|
|
54497
54941
|
items: external_exports.array(fetchRecordSchema).max(RUN_TRACE_LIMITS.requests),
|
|
54498
54942
|
dropped: external_exports.number().int().min(0)
|
|
54499
54943
|
}).strict().nullable(),
|
|
54944
|
+
// The second-region recheck before an incident (docs/design/second-region.md).
|
|
54945
|
+
secondRegion: runConfirmationSchema.nullable().optional(),
|
|
54500
54946
|
// A finished run's captured test output; empty means the runner printed nothing.
|
|
54501
54947
|
output: external_exports.object({ bytes: external_exports.number().int().min(0), empty: external_exports.boolean() }).strict()
|
|
54502
54948
|
}).strict();
|
|
@@ -54688,11 +55134,6 @@ import { createHash as createHash3 } from "node:crypto";
|
|
|
54688
55134
|
import { mkdir, lstat as lstat2, rm } from "node:fs/promises";
|
|
54689
55135
|
import { dirname as dirname2, join as join2, resolve as resolve3 } from "node:path";
|
|
54690
55136
|
|
|
54691
|
-
// ../../src/contracts/evidence.ts
|
|
54692
|
-
var safeEvidencePath = (path2) => path2.length <= 512 && !path2.includes("\\") && path2.split("/").every(
|
|
54693
|
-
(p) => p !== "" && p !== "." && p !== ".." && !/[\x00-\x1f\x7f]/.test(p)
|
|
54694
|
-
);
|
|
54695
|
-
|
|
54696
55137
|
// ../../src/contracts/run-diagnosis.ts
|
|
54697
55138
|
var DIAGNOSIS_LIMITS = {
|
|
54698
55139
|
history: 200,
|
|
@@ -55047,6 +55488,39 @@ var aiEndpointExample = {
|
|
|
55047
55488
|
invocationBudget: 1
|
|
55048
55489
|
}
|
|
55049
55490
|
};
|
|
55491
|
+
var mcpExample = {
|
|
55492
|
+
schemaVersion: 1,
|
|
55493
|
+
name: "MCP server",
|
|
55494
|
+
type: "mcp",
|
|
55495
|
+
target: "https://example.com/mcp",
|
|
55496
|
+
enabled: false,
|
|
55497
|
+
interval: 1800,
|
|
55498
|
+
timeout: 15,
|
|
55499
|
+
failureThreshold: 2,
|
|
55500
|
+
mcp: { expectTools: ["search"] }
|
|
55501
|
+
};
|
|
55502
|
+
var tcpExample = {
|
|
55503
|
+
schemaVersion: 1,
|
|
55504
|
+
name: "Database port",
|
|
55505
|
+
type: "tcp",
|
|
55506
|
+
target: "db.example.com:5432",
|
|
55507
|
+
enabled: false,
|
|
55508
|
+
interval: 1800,
|
|
55509
|
+
timeout: 10,
|
|
55510
|
+
failureThreshold: 2,
|
|
55511
|
+
tcp: { banner: "" }
|
|
55512
|
+
};
|
|
55513
|
+
var dnsExample = {
|
|
55514
|
+
schemaVersion: 1,
|
|
55515
|
+
name: "Mail records",
|
|
55516
|
+
type: "dns",
|
|
55517
|
+
target: "example.com",
|
|
55518
|
+
enabled: false,
|
|
55519
|
+
interval: 1800,
|
|
55520
|
+
timeout: 10,
|
|
55521
|
+
failureThreshold: 2,
|
|
55522
|
+
dns: { recordType: "MX", expected: ["mail.example.com"], match: "includes" }
|
|
55523
|
+
};
|
|
55050
55524
|
var visualExample = {
|
|
55051
55525
|
schemaVersion: 1,
|
|
55052
55526
|
name: "Production / homepage appearance",
|
|
@@ -55072,10 +55546,10 @@ var visualExample = {
|
|
|
55072
55546
|
}
|
|
55073
55547
|
}
|
|
55074
55548
|
};
|
|
55075
|
-
async function writeText(path2,
|
|
55549
|
+
async function writeText(path2, text4) {
|
|
55076
55550
|
const file2 = await open4(path2, "wx", 384);
|
|
55077
55551
|
try {
|
|
55078
|
-
await file2.writeFile(
|
|
55552
|
+
await file2.writeFile(text4);
|
|
55079
55553
|
} finally {
|
|
55080
55554
|
await file2.close();
|
|
55081
55555
|
}
|
|
@@ -55084,11 +55558,11 @@ var writeJson = (path2, data) => writeText(path2, JSON.stringify(data, null, 2)
|
|
|
55084
55558
|
async function readManifest(path2, { enable = false } = {}) {
|
|
55085
55559
|
if (!path2) throw new Error("Provide --file PATH to a monitor JSON file.");
|
|
55086
55560
|
let value2;
|
|
55087
|
-
const
|
|
55088
|
-
if (Buffer.byteLength(
|
|
55561
|
+
const text4 = await readFile(path2, "utf8");
|
|
55562
|
+
if (Buffer.byteLength(text4) > 96e3)
|
|
55089
55563
|
throw new Error("Monitor configuration exceeds 96 KB.");
|
|
55090
55564
|
try {
|
|
55091
|
-
value2 = JSON.parse(
|
|
55565
|
+
value2 = JSON.parse(text4);
|
|
55092
55566
|
} catch {
|
|
55093
55567
|
throw new Error("Monitor configuration must be valid JSON.");
|
|
55094
55568
|
}
|
|
@@ -55104,6 +55578,14 @@ async function readManifest(path2, { enable = false } = {}) {
|
|
|
55104
55578
|
throw new Error(
|
|
55105
55579
|
"AI endpoint monitors do not accept scriptFile; use fixture and assertions."
|
|
55106
55580
|
);
|
|
55581
|
+
if (definition.type === "mcp")
|
|
55582
|
+
throw new Error(
|
|
55583
|
+
"MCP monitors do not accept scriptFile; use expectTools and toolCall."
|
|
55584
|
+
);
|
|
55585
|
+
if (definition.type === "tcp" || definition.type === "dns")
|
|
55586
|
+
throw new Error(
|
|
55587
|
+
"TCP and DNS monitors do not accept scriptFile; use tcp or dns settings."
|
|
55588
|
+
);
|
|
55107
55589
|
if (definition.type === "visual")
|
|
55108
55590
|
throw new Error(
|
|
55109
55591
|
"Visual monitors do not accept scriptFile; use capture settings."
|
|
@@ -55794,8 +56276,8 @@ async function targetConfiguration(file2) {
|
|
|
55794
56276
|
await handle.close();
|
|
55795
56277
|
}
|
|
55796
56278
|
}
|
|
55797
|
-
function httpSecretInput(
|
|
55798
|
-
const value2 =
|
|
56279
|
+
function httpSecretInput(text4) {
|
|
56280
|
+
const value2 = text4.replace(/[\r\n]+$/, "");
|
|
55799
56281
|
if (!httpCredentialRotateSchema.shape.value.safeParse(value2).success)
|
|
55800
56282
|
throw new ServiceError(
|
|
55801
56283
|
"Use a single-line ASCII HTTP credential value of at most 4096 characters.",
|
|
@@ -55893,7 +56375,7 @@ async function targetChallengeToFile(path2, server, issue3) {
|
|
|
55893
56375
|
// src/http-local.ts
|
|
55894
56376
|
var entrySchema = httpAuthSchema.extend({
|
|
55895
56377
|
origin: external_exports.string().url(),
|
|
55896
|
-
header:
|
|
56378
|
+
header: httpCredentialHeaderSchema,
|
|
55897
56379
|
credentialFile: external_exports.string().min(1).max(2e3)
|
|
55898
56380
|
}).strict();
|
|
55899
56381
|
var mapSchema = external_exports.object({
|
|
@@ -55955,11 +56437,11 @@ async function localHttpCredential(file2, definition) {
|
|
|
55955
56437
|
"VALIDATION_ERROR",
|
|
55956
56438
|
2
|
|
55957
56439
|
);
|
|
55958
|
-
const
|
|
56440
|
+
const matches2 = parsed.data.credentials.filter(
|
|
55959
56441
|
(entry2) => entry2.targetId === definition.httpAuth.targetId && entry2.credentialId === definition.httpAuth.credentialId
|
|
55960
56442
|
);
|
|
55961
|
-
const value2 =
|
|
55962
|
-
if (
|
|
56443
|
+
const value2 = matches2[0], origin = new URL(definition.target).origin;
|
|
56444
|
+
if (matches2.length !== 1 || !value2 || value2.credentialRevision !== definition.httpAuth.credentialRevision || value2.origin !== origin || new URL(value2.origin).origin !== value2.origin)
|
|
55963
56445
|
throw new ServiceError(
|
|
55964
56446
|
"Local HTTP credential ID, revision and canonical origin must match the monitor exactly.",
|
|
55965
56447
|
"VALIDATION_ERROR",
|
|
@@ -56059,7 +56541,7 @@ var import_ipaddr2 = __toESM(require_ipaddr(), 1);
|
|
|
56059
56541
|
var ACCOUNT_PLANS = Object.freeze({
|
|
56060
56542
|
starter: Object.freeze({
|
|
56061
56543
|
monitors: 5,
|
|
56062
|
-
// HTTP, certificate and
|
|
56544
|
+
// HTTP, certificate, heartbeat, MCP, TCP and DNS checks.
|
|
56063
56545
|
checkMinInterval: 1800,
|
|
56064
56546
|
scriptMonitors: 1,
|
|
56065
56547
|
scriptMinInterval: 7200,
|
|
@@ -56070,7 +56552,10 @@ var ACCOUNT_PLANS = Object.freeze({
|
|
|
56070
56552
|
statusPages: 1,
|
|
56071
56553
|
// Days evidence files and run history are kept (docs/STORAGE.md).
|
|
56072
56554
|
artifactDays: 7,
|
|
56073
|
-
historyDays: 14
|
|
56555
|
+
historyDays: 14,
|
|
56556
|
+
// People in a team workspace on this plan (docs/design/teams.md); a
|
|
56557
|
+
// personal workspace always has one.
|
|
56558
|
+
members: 3
|
|
56074
56559
|
}),
|
|
56075
56560
|
// Design partners, assigned by the administrator: the pro limits, unpaid.
|
|
56076
56561
|
pilot: Object.freeze({
|
|
@@ -56082,7 +56567,8 @@ var ACCOUNT_PLANS = Object.freeze({
|
|
|
56082
56567
|
agentChecks: 1,
|
|
56083
56568
|
statusPages: 3,
|
|
56084
56569
|
artifactDays: 30,
|
|
56085
|
-
historyDays: 30
|
|
56570
|
+
historyDays: 30,
|
|
56571
|
+
members: 5
|
|
56086
56572
|
}),
|
|
56087
56573
|
// Paid plan (docs/PRICING.md): more monitors checked every 5 minutes and a
|
|
56088
56574
|
// month of evidence. Scripts may run every 5 minutes; what bounds our cost
|
|
@@ -56097,7 +56583,8 @@ var ACCOUNT_PLANS = Object.freeze({
|
|
|
56097
56583
|
agentChecks: 1,
|
|
56098
56584
|
statusPages: 3,
|
|
56099
56585
|
artifactDays: 30,
|
|
56100
|
-
historyDays: 30
|
|
56586
|
+
historyDays: 30,
|
|
56587
|
+
members: 5
|
|
56101
56588
|
}),
|
|
56102
56589
|
// Volume for one account (docs/PRICING.md): 1 minute checks and 2,500
|
|
56103
56590
|
// script runs a day, about 18 USD of runner cost a month when fully used.
|
|
@@ -56110,7 +56597,23 @@ var ACCOUNT_PLANS = Object.freeze({
|
|
|
56110
56597
|
agentChecks: 5,
|
|
56111
56598
|
statusPages: 10,
|
|
56112
56599
|
artifactDays: 30,
|
|
56113
|
-
historyDays: 30
|
|
56600
|
+
historyDays: 30,
|
|
56601
|
+
members: 10
|
|
56602
|
+
}),
|
|
56603
|
+
// Team workspaces (docs/design/teams.md): business volume shared by up to
|
|
56604
|
+
// 25 people. Sold only to team workspaces, priced per workspace
|
|
56605
|
+
// (docs/PRICING.md).
|
|
56606
|
+
team: Object.freeze({
|
|
56607
|
+
monitors: 100,
|
|
56608
|
+
checkMinInterval: 60,
|
|
56609
|
+
scriptMonitors: 25,
|
|
56610
|
+
scriptMinInterval: 120,
|
|
56611
|
+
scriptDailyRuns: 2500,
|
|
56612
|
+
agentChecks: 5,
|
|
56613
|
+
statusPages: 10,
|
|
56614
|
+
artifactDays: 30,
|
|
56615
|
+
historyDays: 30,
|
|
56616
|
+
members: 25
|
|
56114
56617
|
})
|
|
56115
56618
|
});
|
|
56116
56619
|
var SCRIPT_MIN_INTERVAL = Math.min(
|
|
@@ -56118,7 +56621,8 @@ var SCRIPT_MIN_INTERVAL = Math.min(
|
|
|
56118
56621
|
);
|
|
56119
56622
|
var PRO_PRICES_USD = Object.freeze({ month: 12, year: 120 });
|
|
56120
56623
|
var BUSINESS_PRICES_USD = Object.freeze({ month: 49, year: 490 });
|
|
56121
|
-
var
|
|
56624
|
+
var TEAM_PRICES_USD = Object.freeze({ month: 79, year: 790 });
|
|
56625
|
+
var PAID_PLANS = ["pro", "business", "team"];
|
|
56122
56626
|
var billingCheckoutSchema = external_exports.object({
|
|
56123
56627
|
// Checkout defaults to monthly; a running subscription keeps its own
|
|
56124
56628
|
// interval unless one is given.
|
|
@@ -56130,7 +56634,10 @@ var accountPlanSchema = external_exports.enum(
|
|
|
56130
56634
|
Object.keys(ACCOUNT_PLANS)
|
|
56131
56635
|
);
|
|
56132
56636
|
var accountPlanWriteSchema = external_exports.object({ plan: accountPlanSchema }).strict();
|
|
56133
|
-
var accountOwnerSchema = external_exports.string().regex(
|
|
56637
|
+
var accountOwnerSchema = external_exports.string().regex(
|
|
56638
|
+
/^(clerk:user_[A-Za-z0-9]{8,64}|team:[a-f0-9]{24})$/,
|
|
56639
|
+
"Use an owner like clerk:user_ID or team:ID"
|
|
56640
|
+
);
|
|
56134
56641
|
var accountSuspensionWriteSchema = external_exports.object({ reason: external_exports.string().trim().min(3).max(200) }).strict();
|
|
56135
56642
|
|
|
56136
56643
|
// ../../src/public-http.ts
|
|
@@ -56702,13 +57209,13 @@ async function localProductRequestBroker(input2, options = {}) {
|
|
|
56702
57209
|
resourceId
|
|
56703
57210
|
};
|
|
56704
57211
|
const snapshot = () => {
|
|
56705
|
-
const unknown2 = calls.filter((c) => c.state === "unknown").length, pendingCall = calls.some((c) => c.state === "pending"),
|
|
57212
|
+
const unknown2 = calls.filter((c) => c.state === "unknown").length, pendingCall = calls.some((c) => c.state === "pending"), reason2 = failure3 ?? (input2.signal.aborted || now() >= input2.deadlineAt ? "PRODUCT_REQUEST_NOT_AUTHORIZED" : pendingCall || unknown2 ? "PRODUCT_REQUEST_UNKNOWN" : null);
|
|
56706
57213
|
return {
|
|
56707
57214
|
provenance: "local",
|
|
56708
57215
|
resourceId,
|
|
56709
57216
|
outcome: {
|
|
56710
|
-
ok:
|
|
56711
|
-
reason,
|
|
57217
|
+
ok: reason2 === null,
|
|
57218
|
+
reason: reason2,
|
|
56712
57219
|
calls: calls.filter((c) => c.state !== "released").length,
|
|
56713
57220
|
unknown: unknown2
|
|
56714
57221
|
},
|
|
@@ -56793,7 +57300,7 @@ async function localScenarioRuntimeSource() {
|
|
|
56793
57300
|
// src/local.ts
|
|
56794
57301
|
import { createRequire } from "node:module";
|
|
56795
57302
|
import { randomUUID as randomUUID4, createHash as createHash8 } from "node:crypto";
|
|
56796
|
-
import { performance as
|
|
57303
|
+
import { performance as performance7 } from "node:perf_hooks";
|
|
56797
57304
|
import {
|
|
56798
57305
|
mkdir as mkdir4,
|
|
56799
57306
|
lstat as lstat7,
|
|
@@ -56963,7 +57470,7 @@ HTTP ${response.status}
|
|
|
56963
57470
|
Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
56964
57471
|
};
|
|
56965
57472
|
}
|
|
56966
|
-
let
|
|
57473
|
+
let text4 = "", bytes2 = 0;
|
|
56967
57474
|
if (response.body) {
|
|
56968
57475
|
const reader = response.body.getReader();
|
|
56969
57476
|
const decoder = new TextDecoder();
|
|
@@ -56974,9 +57481,9 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
56974
57481
|
bytes2 += value2.byteLength;
|
|
56975
57482
|
if (bytes2 > 256e3)
|
|
56976
57483
|
throw new Error("Response exceeds the 256 KB check limit");
|
|
56977
|
-
|
|
57484
|
+
text4 += decoder.decode(value2, { stream: true });
|
|
56978
57485
|
}
|
|
56979
|
-
|
|
57486
|
+
text4 += decoder.decode();
|
|
56980
57487
|
} finally {
|
|
56981
57488
|
await reader.cancel().catch(() => {
|
|
56982
57489
|
});
|
|
@@ -56989,9 +57496,9 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
56989
57496
|
bytes: bytes2,
|
|
56990
57497
|
excerpt: omitted ? null : hidden.reduce(
|
|
56991
57498
|
(value2, secret) => value2.replaceAll(secret, "[redacted]"),
|
|
56992
|
-
|
|
57499
|
+
text4.slice(0, RUN_TRACE_LIMITS.bodyExcerpt)
|
|
56993
57500
|
),
|
|
56994
|
-
truncated: !omitted &&
|
|
57501
|
+
truncated: !omitted && text4.length > RUN_TRACE_LIMITS.bodyExcerpt,
|
|
56995
57502
|
omitted
|
|
56996
57503
|
};
|
|
56997
57504
|
const latency = Math.round(performance2.now() - start);
|
|
@@ -57000,11 +57507,11 @@ Cloudflare challenge blocked the probe. No challenge was bypassed.`
|
|
|
57000
57507
|
failures.push(
|
|
57001
57508
|
`Expected HTTP ${m.settings.expectedStatus}, received ${response.status}`
|
|
57002
57509
|
);
|
|
57003
|
-
if (m.settings.contains && !
|
|
57510
|
+
if (m.settings.contains && !text4.includes(m.settings.contains))
|
|
57004
57511
|
failures.push("Expected text missing from response");
|
|
57005
57512
|
if (m.settings.jsonPath) {
|
|
57006
57513
|
try {
|
|
57007
|
-
let value2 = JSON.parse(
|
|
57514
|
+
let value2 = JSON.parse(text4);
|
|
57008
57515
|
for (const part2 of m.settings.jsonPath.split("."))
|
|
57009
57516
|
value2 = value2?.[part2];
|
|
57010
57517
|
let expected;
|
|
@@ -57079,9 +57586,9 @@ function semanticGradingIdentity(rubric, judge) {
|
|
|
57079
57586
|
}
|
|
57080
57587
|
async function semanticGrade(input2) {
|
|
57081
57588
|
const report = semanticGradingIdentity(input2.rubric, input2.judge);
|
|
57082
|
-
const fail2 = (
|
|
57589
|
+
const fail2 = (reason2) => ({
|
|
57083
57590
|
...report,
|
|
57084
|
-
reason
|
|
57591
|
+
reason: reason2
|
|
57085
57592
|
});
|
|
57086
57593
|
if (input2.signal.aborted) return fail2("CANCELLED");
|
|
57087
57594
|
if (!input2.selected.found) return fail2("MISSING_OUTPUT");
|
|
@@ -57233,6 +57740,57 @@ function matchesSchema(value2, schema) {
|
|
|
57233
57740
|
return false;
|
|
57234
57741
|
return true;
|
|
57235
57742
|
}
|
|
57743
|
+
function evaluateAssertion(data, assertion, secrets = []) {
|
|
57744
|
+
const found = pointer3(data, assertion.path);
|
|
57745
|
+
let passed = false;
|
|
57746
|
+
if (found.found) {
|
|
57747
|
+
switch (assertion.operator) {
|
|
57748
|
+
case "exists":
|
|
57749
|
+
passed = true;
|
|
57750
|
+
break;
|
|
57751
|
+
case "equals":
|
|
57752
|
+
passed = equals(found.value, assertion.value);
|
|
57753
|
+
break;
|
|
57754
|
+
case "type":
|
|
57755
|
+
passed = matchesType(found.value, assertion.value);
|
|
57756
|
+
break;
|
|
57757
|
+
default: {
|
|
57758
|
+
const text4 = found.value;
|
|
57759
|
+
if (typeof text4 === "string") {
|
|
57760
|
+
switch (assertion.operator) {
|
|
57761
|
+
case "contains":
|
|
57762
|
+
passed = text4.includes(assertion.value);
|
|
57763
|
+
break;
|
|
57764
|
+
case "not-contains":
|
|
57765
|
+
passed = !text4.includes(assertion.value);
|
|
57766
|
+
break;
|
|
57767
|
+
case "contains-any":
|
|
57768
|
+
passed = assertion.value.some(
|
|
57769
|
+
(value2) => text4.includes(value2)
|
|
57770
|
+
);
|
|
57771
|
+
break;
|
|
57772
|
+
case "contains-all":
|
|
57773
|
+
passed = assertion.value.every(
|
|
57774
|
+
(value2) => text4.includes(value2)
|
|
57775
|
+
);
|
|
57776
|
+
break;
|
|
57777
|
+
}
|
|
57778
|
+
}
|
|
57779
|
+
}
|
|
57780
|
+
}
|
|
57781
|
+
}
|
|
57782
|
+
return {
|
|
57783
|
+
path: secrets.some((secret) => assertion.path.includes(secret)) ? "/[redacted]" : assertion.path,
|
|
57784
|
+
operator: assertion.operator,
|
|
57785
|
+
passed,
|
|
57786
|
+
reason: passed ? null : !found.found ? "MISSING_PATH" : assertion.operator === "type" || [
|
|
57787
|
+
"contains",
|
|
57788
|
+
"not-contains",
|
|
57789
|
+
"contains-any",
|
|
57790
|
+
"contains-all"
|
|
57791
|
+
].includes(assertion.operator) && typeof found.value !== "string" ? "TYPE_MISMATCH" : "VALUE_MISMATCH"
|
|
57792
|
+
};
|
|
57793
|
+
}
|
|
57236
57794
|
function initialReport(config2) {
|
|
57237
57795
|
return {
|
|
57238
57796
|
schemaVersion: 1,
|
|
@@ -57295,12 +57853,12 @@ async function singleCheck(monitor, parentSignal, options = {}) {
|
|
|
57295
57853
|
"AI_ENDPOINT_CONFIGURATION_ERROR"
|
|
57296
57854
|
);
|
|
57297
57855
|
}
|
|
57298
|
-
const config2 = parsed.data, report = initialReport(config2),
|
|
57856
|
+
const config2 = parsed.data, report = initialReport(config2), deadline2 = AbortSignal.timeout(
|
|
57299
57857
|
Math.max(1, Math.ceil(monitor.timeout * 1e3))
|
|
57300
|
-
), signal = parentSignal ? AbortSignal.any([parentSignal,
|
|
57301
|
-
const fail2 = (
|
|
57858
|
+
), signal = parentSignal ? AbortSignal.any([parentSignal, deadline2]) : deadline2;
|
|
57859
|
+
const fail2 = (reason2) => {
|
|
57302
57860
|
report.transport.status = "error";
|
|
57303
|
-
report.transport.reason =
|
|
57861
|
+
report.transport.reason = reason2;
|
|
57304
57862
|
return result(
|
|
57305
57863
|
report,
|
|
57306
57864
|
"error",
|
|
@@ -57396,57 +57954,9 @@ async function singleCheck(monitor, parentSignal, options = {}) {
|
|
|
57396
57954
|
options.onResponse?.(data);
|
|
57397
57955
|
report.transport.status = "passed";
|
|
57398
57956
|
metadata(report, data, secrets);
|
|
57399
|
-
report.assertions = config2.assertions.map(
|
|
57400
|
-
|
|
57401
|
-
|
|
57402
|
-
if (found.found) {
|
|
57403
|
-
switch (assertion.operator) {
|
|
57404
|
-
case "exists":
|
|
57405
|
-
passed2 = true;
|
|
57406
|
-
break;
|
|
57407
|
-
case "equals":
|
|
57408
|
-
passed2 = equals(found.value, assertion.value);
|
|
57409
|
-
break;
|
|
57410
|
-
case "type":
|
|
57411
|
-
passed2 = matchesType(found.value, assertion.value);
|
|
57412
|
-
break;
|
|
57413
|
-
default: {
|
|
57414
|
-
const text3 = found.value;
|
|
57415
|
-
if (typeof text3 === "string") {
|
|
57416
|
-
switch (assertion.operator) {
|
|
57417
|
-
case "contains":
|
|
57418
|
-
passed2 = text3.includes(assertion.value);
|
|
57419
|
-
break;
|
|
57420
|
-
case "not-contains":
|
|
57421
|
-
passed2 = !text3.includes(assertion.value);
|
|
57422
|
-
break;
|
|
57423
|
-
case "contains-any":
|
|
57424
|
-
passed2 = assertion.value.some(
|
|
57425
|
-
(value2) => text3.includes(value2)
|
|
57426
|
-
);
|
|
57427
|
-
break;
|
|
57428
|
-
case "contains-all":
|
|
57429
|
-
passed2 = assertion.value.every(
|
|
57430
|
-
(value2) => text3.includes(value2)
|
|
57431
|
-
);
|
|
57432
|
-
break;
|
|
57433
|
-
}
|
|
57434
|
-
}
|
|
57435
|
-
}
|
|
57436
|
-
}
|
|
57437
|
-
}
|
|
57438
|
-
return {
|
|
57439
|
-
path: secrets.some((secret) => assertion.path.includes(secret)) ? "/[redacted]" : assertion.path,
|
|
57440
|
-
operator: assertion.operator,
|
|
57441
|
-
passed: passed2,
|
|
57442
|
-
reason: passed2 ? null : !found.found ? "MISSING_PATH" : assertion.operator === "type" || [
|
|
57443
|
-
"contains",
|
|
57444
|
-
"not-contains",
|
|
57445
|
-
"contains-any",
|
|
57446
|
-
"contains-all"
|
|
57447
|
-
].includes(assertion.operator) && typeof found.value !== "string" ? "TYPE_MISMATCH" : "VALUE_MISMATCH"
|
|
57448
|
-
};
|
|
57449
|
-
});
|
|
57957
|
+
report.assertions = config2.assertions.map(
|
|
57958
|
+
(assertion) => evaluateAssertion(data, assertion, secrets)
|
|
57959
|
+
);
|
|
57450
57960
|
if (config2.responseSchema)
|
|
57451
57961
|
report.responseSchema.passed = matchesSchema(data, config2.responseSchema);
|
|
57452
57962
|
const passed = report.assertions.every((check2) => check2.passed) && report.responseSchema.passed !== false;
|
|
@@ -57459,7 +57969,7 @@ async function singleCheck(monitor, parentSignal, options = {}) {
|
|
|
57459
57969
|
await response?.body?.cancel().catch(() => {
|
|
57460
57970
|
});
|
|
57461
57971
|
return fail2(
|
|
57462
|
-
parentSignal?.aborted ? "CANCELLED" :
|
|
57972
|
+
parentSignal?.aborted ? "CANCELLED" : deadline2.aborted ? "TIMEOUT" : "REQUEST_FAILED"
|
|
57463
57973
|
);
|
|
57464
57974
|
}
|
|
57465
57975
|
}
|
|
@@ -57477,10 +57987,10 @@ async function aiEndpointCheck(monitor, parentSignal, options = {}) {
|
|
|
57477
57987
|
}
|
|
57478
57988
|
async function suiteCheck(monitor, config2, parentSignal, options) {
|
|
57479
57989
|
const end = performance.now() + monitor.timeout * 1e3;
|
|
57480
|
-
const
|
|
57990
|
+
const deadline2 = AbortSignal.timeout(
|
|
57481
57991
|
Math.max(1, Math.ceil(monitor.timeout * 1e3))
|
|
57482
57992
|
);
|
|
57483
|
-
const signal = parentSignal ? AbortSignal.any([parentSignal,
|
|
57993
|
+
const signal = parentSignal ? AbortSignal.any([parentSignal, deadline2]) : deadline2;
|
|
57484
57994
|
const secrets = httpCredentialRedactions(options.httpCredential);
|
|
57485
57995
|
const graded = config2.adapter === "json-http-graded-suite-v1";
|
|
57486
57996
|
const report = {
|
|
@@ -57555,7 +58065,7 @@ async function suiteCheck(monitor, config2, parentSignal, options) {
|
|
|
57555
58065
|
diagnostic.transport.status = "error";
|
|
57556
58066
|
diagnostic.transport.reason = parentSignal?.aborted ? "CANCELLED" : "TIMEOUT";
|
|
57557
58067
|
}
|
|
57558
|
-
if (outcome.status === "error" && !parentSignal?.aborted &&
|
|
58068
|
+
if (outcome.status === "error" && !parentSignal?.aborted && deadline2.aborted && diagnostic.transport.reason === "CANCELLED")
|
|
57559
58069
|
diagnostic.transport.reason = "TIMEOUT";
|
|
57560
58070
|
if (graded && "rubric" in item && item.rubric) {
|
|
57561
58071
|
const grading = outcome.status === "failed" ? {
|
|
@@ -57810,11 +58320,656 @@ async function certificateCheck(monitor, parentSignal, io = transport, sink = {}
|
|
|
57810
58320
|
}
|
|
57811
58321
|
}
|
|
57812
58322
|
|
|
58323
|
+
// ../../src/checks/mcp.ts
|
|
58324
|
+
import { performance as performance4 } from "node:perf_hooks";
|
|
58325
|
+
|
|
58326
|
+
// package.json
|
|
58327
|
+
var package_default = {
|
|
58328
|
+
name: "@waitcher/cli",
|
|
58329
|
+
version: "0.2.26",
|
|
58330
|
+
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
|
|
58331
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
58332
|
+
author: "S\u0142awomir Radzymi\u0144ski",
|
|
58333
|
+
homepage: "https://waitcher.dev/docs/",
|
|
58334
|
+
repository: {
|
|
58335
|
+
type: "git",
|
|
58336
|
+
url: "git+https://github.com/slawekradzyminski/synthetic-watch.git",
|
|
58337
|
+
directory: "packages/cli"
|
|
58338
|
+
},
|
|
58339
|
+
keywords: [
|
|
58340
|
+
"monitoring",
|
|
58341
|
+
"synthetic-monitoring",
|
|
58342
|
+
"uptime",
|
|
58343
|
+
"e2e",
|
|
58344
|
+
"ci",
|
|
58345
|
+
"cli"
|
|
58346
|
+
],
|
|
58347
|
+
type: "module",
|
|
58348
|
+
bin: {
|
|
58349
|
+
waitcher: "dist/cli.mjs"
|
|
58350
|
+
},
|
|
58351
|
+
files: [
|
|
58352
|
+
"dist/cli.mjs",
|
|
58353
|
+
"dist/model-client.mjs",
|
|
58354
|
+
"dist/scenario-runtime.mjs",
|
|
58355
|
+
"dist/request-runtime.mjs",
|
|
58356
|
+
"dist/MODEL_CLIENT_NOTICES.txt",
|
|
58357
|
+
"README.md",
|
|
58358
|
+
"THIRD_PARTY_NOTICES.txt",
|
|
58359
|
+
"LICENSE.txt"
|
|
58360
|
+
],
|
|
58361
|
+
engines: {
|
|
58362
|
+
node: ">=24.15.0"
|
|
58363
|
+
},
|
|
58364
|
+
publishConfig: {
|
|
58365
|
+
access: "public"
|
|
58366
|
+
},
|
|
58367
|
+
scripts: {
|
|
58368
|
+
build: "node build.mjs",
|
|
58369
|
+
prepack: "npm run build"
|
|
58370
|
+
}
|
|
58371
|
+
};
|
|
58372
|
+
|
|
58373
|
+
// ../../src/checks/mcp.ts
|
|
58374
|
+
var COVERAGE = /* @__PURE__ */ new Set([
|
|
58375
|
+
"INVALID_CONFIGURATION",
|
|
58376
|
+
"INVALID_TARGET",
|
|
58377
|
+
"TRANSPORT_ERROR",
|
|
58378
|
+
"TIMEOUT",
|
|
58379
|
+
"REDIRECT_REFUSED",
|
|
58380
|
+
"RESPONSE_TOO_LARGE"
|
|
58381
|
+
]);
|
|
58382
|
+
var Stop = class extends Error {
|
|
58383
|
+
constructor(reason2, hint = "") {
|
|
58384
|
+
super(reason2);
|
|
58385
|
+
this.reason = reason2;
|
|
58386
|
+
this.hint = hint;
|
|
58387
|
+
}
|
|
58388
|
+
reason;
|
|
58389
|
+
hint;
|
|
58390
|
+
};
|
|
58391
|
+
function authHint(response, hasCredential) {
|
|
58392
|
+
if (response.status !== 401) return "";
|
|
58393
|
+
const challenge = response.headers.get("www-authenticate") ?? "";
|
|
58394
|
+
if (/resource_metadata\s*=/i.test(challenge))
|
|
58395
|
+
return "; the server advertises MCP OAuth, whose interactive flow Waitcher cannot run; if it accepts a token you can obtain without a browser, store it as an HTTP target credential (a static header, or an OAuth 2 token credential)";
|
|
58396
|
+
return hasCredential ? "; check that the stored credential is still valid" : "; add an HTTP target credential for this origin and bind it as httpAuth";
|
|
58397
|
+
}
|
|
58398
|
+
var MESSAGES = {
|
|
58399
|
+
INVALID_CONFIGURATION: "MCP check configuration is invalid",
|
|
58400
|
+
INVALID_TARGET: "Use a public HTTPS MCP endpoint on port 443",
|
|
58401
|
+
TRANSPORT_ERROR: "The MCP server could not be reached",
|
|
58402
|
+
TIMEOUT: "The MCP check did not finish within its timeout",
|
|
58403
|
+
REDIRECT_REFUSED: "The MCP endpoint redirected; use the final URL",
|
|
58404
|
+
RESPONSE_TOO_LARGE: "An MCP response exceeded 256 KiB",
|
|
58405
|
+
MALFORMED_RESPONSE: "The MCP server did not answer with JSON-RPC",
|
|
58406
|
+
HTTP_ERROR: "The MCP server answered with an HTTP error",
|
|
58407
|
+
AUTH_REJECTED: "The MCP server rejected the request as unauthorized",
|
|
58408
|
+
JSONRPC_ERROR: "The MCP server answered with a JSON-RPC error",
|
|
58409
|
+
UNSUPPORTED_PROTOCOL: "The MCP server negotiated an unknown protocol version",
|
|
58410
|
+
NO_TOOLS_CAPABILITY: "The MCP server does not advertise tools",
|
|
58411
|
+
MALFORMED_TOOLS: "The MCP server listed a tool without a name or input schema",
|
|
58412
|
+
MISSING_TOOLS: "Expected MCP tools are missing",
|
|
58413
|
+
TOOL_NOT_LISTED: "The tool to call is not listed by the server",
|
|
58414
|
+
TOOL_ERROR: "The MCP tool call returned an error",
|
|
58415
|
+
ASSERTION_FAILED: "The MCP tool result did not satisfy the checks"
|
|
58416
|
+
};
|
|
58417
|
+
var isObject2 = (value2) => value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
58418
|
+
var text3 = (value2, secrets) => typeof value2 === "string" && value2.length <= 128 && /^[\x20-\x7e]*$/.test(value2) && !secrets.some((secret) => value2.includes(secret)) ? value2 : null;
|
|
58419
|
+
async function readLimited(response, signal, onChunk) {
|
|
58420
|
+
const length = response.headers.get("content-length");
|
|
58421
|
+
if (length && /^\d+$/.test(length) && Number(length) > MCP_LIMITS.responseBytes) {
|
|
58422
|
+
await response.body?.cancel();
|
|
58423
|
+
throw new Stop("RESPONSE_TOO_LARGE");
|
|
58424
|
+
}
|
|
58425
|
+
const reader = response.body?.getReader();
|
|
58426
|
+
if (!reader) return "";
|
|
58427
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
58428
|
+
const abort = () => void reader.cancel().catch(() => {
|
|
58429
|
+
});
|
|
58430
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
58431
|
+
let size = 0, out = "";
|
|
58432
|
+
try {
|
|
58433
|
+
for (; ; ) {
|
|
58434
|
+
signal.throwIfAborted();
|
|
58435
|
+
const { done, value: value2 } = await reader.read();
|
|
58436
|
+
signal.throwIfAborted();
|
|
58437
|
+
if (done) break;
|
|
58438
|
+
size += value2.length;
|
|
58439
|
+
if (size > MCP_LIMITS.responseBytes) throw new Stop("RESPONSE_TOO_LARGE");
|
|
58440
|
+
try {
|
|
58441
|
+
out += decoder.decode(value2, { stream: true });
|
|
58442
|
+
} catch {
|
|
58443
|
+
throw new Stop("MALFORMED_RESPONSE");
|
|
58444
|
+
}
|
|
58445
|
+
if (onChunk?.(out)) break;
|
|
58446
|
+
}
|
|
58447
|
+
return out;
|
|
58448
|
+
} finally {
|
|
58449
|
+
signal.removeEventListener("abort", abort);
|
|
58450
|
+
await reader.cancel().catch(() => {
|
|
58451
|
+
});
|
|
58452
|
+
reader.releaseLock();
|
|
58453
|
+
}
|
|
58454
|
+
}
|
|
58455
|
+
function parseJson(raw) {
|
|
58456
|
+
let data;
|
|
58457
|
+
try {
|
|
58458
|
+
data = JSON.parse(raw);
|
|
58459
|
+
} catch {
|
|
58460
|
+
throw new Stop("MALFORMED_RESPONSE");
|
|
58461
|
+
}
|
|
58462
|
+
if (!isBoundedJson(data, {
|
|
58463
|
+
bytes: MCP_LIMITS.responseBytes,
|
|
58464
|
+
depth: MCP_LIMITS.responseDepth,
|
|
58465
|
+
nodes: MCP_LIMITS.responseNodes
|
|
58466
|
+
}))
|
|
58467
|
+
throw new Stop("MALFORMED_RESPONSE");
|
|
58468
|
+
return data;
|
|
58469
|
+
}
|
|
58470
|
+
function fromEvents(raw, id4, final) {
|
|
58471
|
+
const blocks = raw.split(/\r?\n\r?\n/);
|
|
58472
|
+
if (!final) blocks.pop();
|
|
58473
|
+
for (const block of blocks) {
|
|
58474
|
+
const data = block.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(line.startsWith("data: ") ? 6 : 5)).join("\n");
|
|
58475
|
+
if (!data) continue;
|
|
58476
|
+
const message = parseJson(data);
|
|
58477
|
+
if (isObject2(message) && message.id === id4) return message;
|
|
58478
|
+
}
|
|
58479
|
+
return null;
|
|
58480
|
+
}
|
|
58481
|
+
async function mcpCheck(monitor, parentSignal, options = {}) {
|
|
58482
|
+
const report = {
|
|
58483
|
+
schemaVersion: 1,
|
|
58484
|
+
kind: "mcp",
|
|
58485
|
+
status: "error",
|
|
58486
|
+
reason: null,
|
|
58487
|
+
server: { name: null, version: null, protocolVersion: null, session: false },
|
|
58488
|
+
steps: [],
|
|
58489
|
+
tools: { count: null, truncated: false, expected: 0, missing: [], names: [] },
|
|
58490
|
+
toolCall: null
|
|
58491
|
+
};
|
|
58492
|
+
const finish = (status2, reason2, message) => {
|
|
58493
|
+
report.status = status2;
|
|
58494
|
+
report.reason = reason2;
|
|
58495
|
+
return {
|
|
58496
|
+
status: status2,
|
|
58497
|
+
message,
|
|
58498
|
+
logs: JSON.stringify(report),
|
|
58499
|
+
...status2 === "error" && reason2 ? { resourceReason: `MCP_${reason2}` } : {}
|
|
58500
|
+
};
|
|
58501
|
+
};
|
|
58502
|
+
const parsed = mcpConfigSchema.safeParse(monitor.mcp);
|
|
58503
|
+
if (!parsed.success || !Number.isFinite(monitor.timeout) || monitor.timeout <= 0 || monitor.timeout > MCP_LIMITS.maxTimeoutSeconds)
|
|
58504
|
+
return finish("error", "INVALID_CONFIGURATION", MESSAGES.INVALID_CONFIGURATION);
|
|
58505
|
+
const config2 = parsed.data;
|
|
58506
|
+
report.tools.expected = config2.expectTools.length;
|
|
58507
|
+
if (!options.fetch) {
|
|
58508
|
+
try {
|
|
58509
|
+
publicTarget(monitor.target);
|
|
58510
|
+
} catch {
|
|
58511
|
+
return finish("error", "INVALID_TARGET", MESSAGES.INVALID_TARGET);
|
|
58512
|
+
}
|
|
58513
|
+
}
|
|
58514
|
+
const deadline2 = AbortSignal.timeout(Math.ceil(monitor.timeout * 1e3));
|
|
58515
|
+
const signal = parentSignal ? AbortSignal.any([parentSignal, deadline2]) : deadline2;
|
|
58516
|
+
const secrets = httpCredentialRedactions(options.httpCredential);
|
|
58517
|
+
const fetcher = options.fetch ?? ((url3, init) => publicFetch(url3, init));
|
|
58518
|
+
let session = null, protocol = null, nextId = 1;
|
|
58519
|
+
async function send(method, params, notification = false) {
|
|
58520
|
+
const id4 = nextId++;
|
|
58521
|
+
const step = {
|
|
58522
|
+
method,
|
|
58523
|
+
httpStatus: null,
|
|
58524
|
+
durationMs: 0,
|
|
58525
|
+
ok: false,
|
|
58526
|
+
jsonRpcCode: null
|
|
58527
|
+
};
|
|
58528
|
+
report.steps.push(step);
|
|
58529
|
+
const started = performance4.now();
|
|
58530
|
+
try {
|
|
58531
|
+
const headers = {
|
|
58532
|
+
"content-type": "application/json",
|
|
58533
|
+
accept: "application/json, text/event-stream",
|
|
58534
|
+
"user-agent": `waitcher-mcp-check/${package_default.version}`,
|
|
58535
|
+
...httpCredentialHeaders(monitor, options.httpCredential)
|
|
58536
|
+
};
|
|
58537
|
+
if (session) headers["mcp-session-id"] = session;
|
|
58538
|
+
if (protocol) headers["mcp-protocol-version"] = protocol;
|
|
58539
|
+
let response;
|
|
58540
|
+
try {
|
|
58541
|
+
response = await fetcher(monitor.target, {
|
|
58542
|
+
method: "POST",
|
|
58543
|
+
redirect: "manual",
|
|
58544
|
+
headers,
|
|
58545
|
+
body: JSON.stringify({
|
|
58546
|
+
jsonrpc: "2.0",
|
|
58547
|
+
...notification ? {} : { id: id4 },
|
|
58548
|
+
method,
|
|
58549
|
+
...params ? { params } : {}
|
|
58550
|
+
}),
|
|
58551
|
+
signal
|
|
58552
|
+
});
|
|
58553
|
+
} catch (cause) {
|
|
58554
|
+
if (cause instanceof Stop) throw cause;
|
|
58555
|
+
throw new Stop(deadline2.aborted ? "TIMEOUT" : "TRANSPORT_ERROR");
|
|
58556
|
+
}
|
|
58557
|
+
step.httpStatus = response.status;
|
|
58558
|
+
if (response.status >= 300 && response.status < 400) {
|
|
58559
|
+
await response.body?.cancel();
|
|
58560
|
+
throw new Stop("REDIRECT_REFUSED");
|
|
58561
|
+
}
|
|
58562
|
+
if (response.status === 401 || response.status === 403) {
|
|
58563
|
+
await response.body?.cancel();
|
|
58564
|
+
throw new Stop("AUTH_REJECTED", authHint(response, Boolean(monitor.httpAuth)));
|
|
58565
|
+
}
|
|
58566
|
+
if (response.status < 200 || response.status >= 300) {
|
|
58567
|
+
await response.body?.cancel();
|
|
58568
|
+
throw new Stop("HTTP_ERROR");
|
|
58569
|
+
}
|
|
58570
|
+
if (method === "initialize") {
|
|
58571
|
+
const value2 = response.headers.get("mcp-session-id");
|
|
58572
|
+
if (value2 && /^[\x21-\x7e]{1,1024}$/.test(value2)) session = value2;
|
|
58573
|
+
}
|
|
58574
|
+
if (notification) {
|
|
58575
|
+
await response.body?.cancel();
|
|
58576
|
+
step.ok = true;
|
|
58577
|
+
return void 0;
|
|
58578
|
+
}
|
|
58579
|
+
const type = (response.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
|
|
58580
|
+
let message;
|
|
58581
|
+
if (type === "text/event-stream") {
|
|
58582
|
+
let found = null;
|
|
58583
|
+
const raw = await readLimited(response, signal, (sofar) => {
|
|
58584
|
+
found = fromEvents(sofar, id4, false);
|
|
58585
|
+
return found !== null;
|
|
58586
|
+
});
|
|
58587
|
+
message = found ?? fromEvents(raw, id4, true);
|
|
58588
|
+
} else if (type === "application/json") {
|
|
58589
|
+
const data = parseJson(await readLimited(response, signal));
|
|
58590
|
+
message = Array.isArray(data) ? data.find((item) => isObject2(item) && item.id === id4) ?? null : data;
|
|
58591
|
+
} else {
|
|
58592
|
+
await response.body?.cancel();
|
|
58593
|
+
throw new Stop("MALFORMED_RESPONSE");
|
|
58594
|
+
}
|
|
58595
|
+
if (!isObject2(message) || message.jsonrpc !== "2.0" || message.id !== id4)
|
|
58596
|
+
throw new Stop("MALFORMED_RESPONSE");
|
|
58597
|
+
if (isObject2(message.error)) {
|
|
58598
|
+
const code = message.error.code;
|
|
58599
|
+
step.jsonRpcCode = Number.isSafeInteger(code) ? code : null;
|
|
58600
|
+
throw new Stop("JSONRPC_ERROR");
|
|
58601
|
+
}
|
|
58602
|
+
if (!isObject2(message.result)) throw new Stop("MALFORMED_RESPONSE");
|
|
58603
|
+
step.ok = true;
|
|
58604
|
+
return message.result;
|
|
58605
|
+
} catch (cause) {
|
|
58606
|
+
if (cause instanceof Stop) throw cause;
|
|
58607
|
+
throw new Stop(
|
|
58608
|
+
deadline2.aborted ? "TIMEOUT" : cause instanceof Error && cause.name === "AbortError" ? "TIMEOUT" : "TRANSPORT_ERROR"
|
|
58609
|
+
);
|
|
58610
|
+
} finally {
|
|
58611
|
+
step.durationMs = Math.max(0, Math.round(performance4.now() - started));
|
|
58612
|
+
}
|
|
58613
|
+
}
|
|
58614
|
+
try {
|
|
58615
|
+
const init = await send("initialize", {
|
|
58616
|
+
protocolVersion: MCP_CLIENT_PROTOCOL,
|
|
58617
|
+
capabilities: {},
|
|
58618
|
+
clientInfo: { name: "waitcher", version: package_default.version }
|
|
58619
|
+
});
|
|
58620
|
+
if (!isObject2(init)) throw new Stop("MALFORMED_RESPONSE");
|
|
58621
|
+
const version2 = init.protocolVersion;
|
|
58622
|
+
report.server.protocolVersion = text3(version2, secrets);
|
|
58623
|
+
report.server.session = Boolean(session);
|
|
58624
|
+
if (isObject2(init.serverInfo)) {
|
|
58625
|
+
report.server.name = text3(init.serverInfo.name, secrets);
|
|
58626
|
+
report.server.version = text3(init.serverInfo.version, secrets);
|
|
58627
|
+
}
|
|
58628
|
+
if (typeof version2 !== "string" || !MCP_PROTOCOL_VERSIONS.includes(version2))
|
|
58629
|
+
throw new Stop("UNSUPPORTED_PROTOCOL");
|
|
58630
|
+
protocol = version2;
|
|
58631
|
+
if (!isObject2(init.capabilities) || !isObject2(init.capabilities.tools))
|
|
58632
|
+
throw new Stop("NO_TOOLS_CAPABILITY");
|
|
58633
|
+
await send("notifications/initialized", void 0, true);
|
|
58634
|
+
const listed = /* @__PURE__ */ new Set();
|
|
58635
|
+
let cursor;
|
|
58636
|
+
for (let page = 0; page < MCP_LIMITS.listPages; page++) {
|
|
58637
|
+
const result2 = await send("tools/list", cursor ? { cursor } : void 0);
|
|
58638
|
+
if (!isObject2(result2) || !Array.isArray(result2.tools))
|
|
58639
|
+
throw new Stop("MALFORMED_TOOLS");
|
|
58640
|
+
for (const tool of result2.tools) {
|
|
58641
|
+
if (!isObject2(tool) || typeof tool.name !== "string" || !tool.name || !isObject2(tool.inputSchema))
|
|
58642
|
+
throw new Stop("MALFORMED_TOOLS");
|
|
58643
|
+
if (listed.size < MCP_LIMITS.tools) listed.add(tool.name);
|
|
58644
|
+
else report.tools.truncated = true;
|
|
58645
|
+
}
|
|
58646
|
+
cursor = typeof result2.nextCursor === "string" && result2.nextCursor ? result2.nextCursor : void 0;
|
|
58647
|
+
if (!cursor) break;
|
|
58648
|
+
if (page === MCP_LIMITS.listPages - 1) report.tools.truncated = true;
|
|
58649
|
+
}
|
|
58650
|
+
report.tools.count = listed.size;
|
|
58651
|
+
for (const name5 of listed) {
|
|
58652
|
+
if (report.tools.names.length === MCP_LIMITS.reportedNames) break;
|
|
58653
|
+
const safe = text3(name5, secrets);
|
|
58654
|
+
if (safe) report.tools.names.push(safe);
|
|
58655
|
+
}
|
|
58656
|
+
report.tools.missing = config2.expectTools.filter((name5) => !listed.has(name5));
|
|
58657
|
+
if (report.tools.missing.length) throw new Stop("MISSING_TOOLS");
|
|
58658
|
+
const call = config2.toolCall;
|
|
58659
|
+
if (call) {
|
|
58660
|
+
report.toolCall = { name: call.name, isError: null, assertions: [] };
|
|
58661
|
+
if (!listed.has(call.name) && !report.tools.truncated)
|
|
58662
|
+
throw new Stop("TOOL_NOT_LISTED");
|
|
58663
|
+
options.onInvocation?.();
|
|
58664
|
+
const result2 = await send("tools/call", {
|
|
58665
|
+
name: call.name,
|
|
58666
|
+
arguments: call.arguments
|
|
58667
|
+
});
|
|
58668
|
+
if (!isObject2(result2)) throw new Stop("MALFORMED_RESPONSE");
|
|
58669
|
+
options.onToolResult?.(result2);
|
|
58670
|
+
report.toolCall.isError = result2.isError === true;
|
|
58671
|
+
if (result2.isError === true) throw new Stop("TOOL_ERROR");
|
|
58672
|
+
report.toolCall.assertions = call.assertions.map(
|
|
58673
|
+
(assertion) => evaluateAssertion(result2, assertion, secrets)
|
|
58674
|
+
);
|
|
58675
|
+
if (report.toolCall.assertions.some((check2) => !check2.passed))
|
|
58676
|
+
throw new Stop("ASSERTION_FAILED");
|
|
58677
|
+
}
|
|
58678
|
+
const listing = `MCP server listed ${listed.size} tool${listed.size === 1 ? "" : "s"}`;
|
|
58679
|
+
return finish(
|
|
58680
|
+
"passed",
|
|
58681
|
+
null,
|
|
58682
|
+
call ? `${listing}; ${call.name} answered as expected` : listing
|
|
58683
|
+
);
|
|
58684
|
+
} catch (cause) {
|
|
58685
|
+
const reason2 = cause instanceof Stop ? cause.reason : "TRANSPORT_ERROR";
|
|
58686
|
+
let message = MESSAGES[reason2] + (cause instanceof Stop ? cause.hint : "");
|
|
58687
|
+
if (reason2 === "MISSING_TOOLS")
|
|
58688
|
+
message += `: ${report.tools.missing.join(", ")}`.slice(0, 400);
|
|
58689
|
+
return finish(COVERAGE.has(reason2) ? "error" : "failed", reason2, message);
|
|
58690
|
+
} finally {
|
|
58691
|
+
if (session && !signal.aborted) {
|
|
58692
|
+
const headers = { "mcp-session-id": session };
|
|
58693
|
+
if (protocol) headers["mcp-protocol-version"] = protocol;
|
|
58694
|
+
try {
|
|
58695
|
+
Object.assign(headers, httpCredentialHeaders(monitor, options.httpCredential));
|
|
58696
|
+
const response = await fetcher(monitor.target, {
|
|
58697
|
+
method: "DELETE",
|
|
58698
|
+
redirect: "manual",
|
|
58699
|
+
headers,
|
|
58700
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(2e3)])
|
|
58701
|
+
});
|
|
58702
|
+
await response.body?.cancel();
|
|
58703
|
+
} catch {
|
|
58704
|
+
}
|
|
58705
|
+
}
|
|
58706
|
+
}
|
|
58707
|
+
}
|
|
58708
|
+
|
|
58709
|
+
// ../../src/checks/network.ts
|
|
58710
|
+
import { lookup as systemLookup } from "node:dns/promises";
|
|
58711
|
+
import { Resolver } from "node:dns/promises";
|
|
58712
|
+
import { connect as netConnect, isIP as isIP2 } from "node:net";
|
|
58713
|
+
import { performance as performance5 } from "node:perf_hooks";
|
|
58714
|
+
var configuredResolvers = () => (process.env.WAITCHER_DNS_SERVERS ?? "1.1.1.1,8.8.8.8").split(",").map((s) => s.trim()).filter(Boolean);
|
|
58715
|
+
var tcpTransport = {
|
|
58716
|
+
lookup: (host, options) => systemLookup(host, options),
|
|
58717
|
+
connect: (options) => netConnect(options)
|
|
58718
|
+
};
|
|
58719
|
+
var publicDns = (servers = configuredResolvers()) => ({
|
|
58720
|
+
servers,
|
|
58721
|
+
async resolve(name5, type, signal) {
|
|
58722
|
+
const resolver = new Resolver({ timeout: 4e3, tries: 2 });
|
|
58723
|
+
resolver.setServers(servers);
|
|
58724
|
+
const cancel = () => resolver.cancel();
|
|
58725
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
58726
|
+
try {
|
|
58727
|
+
if (type === "MX")
|
|
58728
|
+
return (await resolver.resolveMx(name5)).map(
|
|
58729
|
+
(r) => `${r.priority} ${r.exchange}`
|
|
58730
|
+
);
|
|
58731
|
+
if (type === "TXT")
|
|
58732
|
+
return (await resolver.resolveTxt(name5)).map((chunks) => chunks.join(""));
|
|
58733
|
+
if (type === "CNAME") return await resolver.resolveCname(name5);
|
|
58734
|
+
if (type === "AAAA") return await resolver.resolve6(name5);
|
|
58735
|
+
return await resolver.resolve4(name5);
|
|
58736
|
+
} finally {
|
|
58737
|
+
signal.removeEventListener("abort", cancel);
|
|
58738
|
+
}
|
|
58739
|
+
}
|
|
58740
|
+
});
|
|
58741
|
+
var short = (value2, max = 300) => value2.replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "\xB7").slice(0, max);
|
|
58742
|
+
var deadline = (monitor, parent) => AbortSignal.any([
|
|
58743
|
+
AbortSignal.timeout(
|
|
58744
|
+
Math.min(monitor.timeout, NETWORK_LIMITS.maxTimeoutSeconds) * 1e3
|
|
58745
|
+
),
|
|
58746
|
+
...parent ? [parent] : []
|
|
58747
|
+
]);
|
|
58748
|
+
function race(work, signal, message) {
|
|
58749
|
+
return new Promise((resolve18, reject) => {
|
|
58750
|
+
const abort = () => reject(new Error(message));
|
|
58751
|
+
if (signal.aborted) return abort();
|
|
58752
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
58753
|
+
work.then(resolve18, reject).finally(
|
|
58754
|
+
() => signal.removeEventListener("abort", abort)
|
|
58755
|
+
);
|
|
58756
|
+
});
|
|
58757
|
+
}
|
|
58758
|
+
async function tcpCheck(monitor, parent, io = tcpTransport, sink = {}) {
|
|
58759
|
+
const signal = deadline(monitor, parent);
|
|
58760
|
+
const target = parseTcpTarget(monitor.target);
|
|
58761
|
+
const expected = monitor.tcp?.banner ?? "";
|
|
58762
|
+
const trace = {
|
|
58763
|
+
protocol: "tcp",
|
|
58764
|
+
host: short(target?.host ?? monitor.target, 253),
|
|
58765
|
+
port: target?.port ?? null,
|
|
58766
|
+
recordType: null,
|
|
58767
|
+
resolver: null,
|
|
58768
|
+
address: null,
|
|
58769
|
+
answers: [],
|
|
58770
|
+
banner: null,
|
|
58771
|
+
timings: { dns: null, connect: null, banner: null },
|
|
58772
|
+
error: null
|
|
58773
|
+
};
|
|
58774
|
+
sink.trace = trace;
|
|
58775
|
+
const fail2 = (status2, message, logs) => {
|
|
58776
|
+
trace.error = short(message);
|
|
58777
|
+
return { status: status2, message, logs };
|
|
58778
|
+
};
|
|
58779
|
+
if (!target)
|
|
58780
|
+
return fail2("error", "TCP target is invalid", "Use HOST:PORT.");
|
|
58781
|
+
let addresses;
|
|
58782
|
+
const started = performance5.now();
|
|
58783
|
+
if (isIP2(target.host)) addresses = [{ address: target.host, family: isIP2(target.host) }];
|
|
58784
|
+
else {
|
|
58785
|
+
try {
|
|
58786
|
+
addresses = await race(
|
|
58787
|
+
io.lookup(target.host, { all: true, verbatim: true }),
|
|
58788
|
+
signal,
|
|
58789
|
+
"TCP check cancelled or timed out"
|
|
58790
|
+
);
|
|
58791
|
+
} catch (cause) {
|
|
58792
|
+
const code = cause.code;
|
|
58793
|
+
return fail2(
|
|
58794
|
+
signal.aborted ? "error" : "failed",
|
|
58795
|
+
signal.aborted ? "TCP check timed out while resolving the host" : `Host ${target.host} did not resolve${code ? ` (${code})` : ""}`,
|
|
58796
|
+
"No connection was attempted."
|
|
58797
|
+
);
|
|
58798
|
+
}
|
|
58799
|
+
trace.timings.dns = Math.round(performance5.now() - started);
|
|
58800
|
+
}
|
|
58801
|
+
trace.answers = addresses.slice(0, NETWORK_LIMITS.answers).map((a) => a.address);
|
|
58802
|
+
if (!addresses.length || addresses.length > NETWORK_LIMITS.answers || addresses.some((a) => !isPublicAddress(a.address)))
|
|
58803
|
+
return fail2(
|
|
58804
|
+
"error",
|
|
58805
|
+
"TCP destination is blocked",
|
|
58806
|
+
"All resolved addresses must be public; private, loopback, link-local and reserved destinations are blocked."
|
|
58807
|
+
);
|
|
58808
|
+
const address = addresses[0].address;
|
|
58809
|
+
trace.address = address;
|
|
58810
|
+
const connectStarted = performance5.now();
|
|
58811
|
+
return await new Promise((resolve18) => {
|
|
58812
|
+
let done = false;
|
|
58813
|
+
const chunks = [];
|
|
58814
|
+
let bytes2 = 0;
|
|
58815
|
+
let connectedAt = 0;
|
|
58816
|
+
const socket = io.connect({ host: address, port: target.port });
|
|
58817
|
+
const finish = (result2) => {
|
|
58818
|
+
if (done) return;
|
|
58819
|
+
done = true;
|
|
58820
|
+
signal.removeEventListener("abort", abort);
|
|
58821
|
+
socket.destroy();
|
|
58822
|
+
if (bytes2)
|
|
58823
|
+
trace.banner = short(Buffer.concat(chunks).toString("utf8").trim());
|
|
58824
|
+
resolve18(result2);
|
|
58825
|
+
};
|
|
58826
|
+
const abort = () => finish(
|
|
58827
|
+
connectedAt ? fail2(
|
|
58828
|
+
"failed",
|
|
58829
|
+
`Connected, but the server did not send "${short(expected, 80)}" in time`,
|
|
58830
|
+
`Connected to ${address}:${target.port}; ${bytes2} bytes received before the deadline.`
|
|
58831
|
+
) : fail2(
|
|
58832
|
+
"failed",
|
|
58833
|
+
`Connection to ${target.host}:${target.port} timed out`,
|
|
58834
|
+
`No TCP handshake with ${address}:${target.port} before the deadline.`
|
|
58835
|
+
)
|
|
58836
|
+
);
|
|
58837
|
+
if (signal.aborted) return abort();
|
|
58838
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
58839
|
+
socket.once("connect", () => {
|
|
58840
|
+
connectedAt = performance5.now();
|
|
58841
|
+
trace.timings.connect = Math.round(connectedAt - connectStarted);
|
|
58842
|
+
if (!expected)
|
|
58843
|
+
finish({
|
|
58844
|
+
status: "passed",
|
|
58845
|
+
message: `Connected to ${target.host}:${target.port}`,
|
|
58846
|
+
logs: `TCP handshake with ${address}:${target.port} in ${trace.timings.connect} ms. No data was sent.`
|
|
58847
|
+
});
|
|
58848
|
+
});
|
|
58849
|
+
socket.on("data", (chunk) => {
|
|
58850
|
+
chunks.push(chunk);
|
|
58851
|
+
bytes2 += chunk.length;
|
|
58852
|
+
const text4 = Buffer.concat(chunks).toString("utf8");
|
|
58853
|
+
if (text4.includes(expected)) {
|
|
58854
|
+
trace.timings.banner = Math.round(performance5.now() - connectedAt);
|
|
58855
|
+
finish({
|
|
58856
|
+
status: "passed",
|
|
58857
|
+
message: `Connected to ${target.host}:${target.port}; banner matched`,
|
|
58858
|
+
logs: `TCP handshake with ${address}:${target.port}; the server sent the expected banner. No data was sent.`
|
|
58859
|
+
});
|
|
58860
|
+
} else if (bytes2 >= NETWORK_LIMITS.bannerBytes)
|
|
58861
|
+
finish(
|
|
58862
|
+
fail2(
|
|
58863
|
+
"failed",
|
|
58864
|
+
`Banner does not contain "${short(expected, 80)}"`,
|
|
58865
|
+
`Read ${bytes2} bytes from ${address}:${target.port} without the expected text.`
|
|
58866
|
+
)
|
|
58867
|
+
);
|
|
58868
|
+
});
|
|
58869
|
+
socket.once(
|
|
58870
|
+
"end",
|
|
58871
|
+
() => finish(
|
|
58872
|
+
fail2(
|
|
58873
|
+
"failed",
|
|
58874
|
+
`Server closed the connection without sending "${short(expected, 80)}"`,
|
|
58875
|
+
`Connected to ${address}:${target.port}; ${bytes2} bytes received before close.`
|
|
58876
|
+
)
|
|
58877
|
+
)
|
|
58878
|
+
);
|
|
58879
|
+
socket.once(
|
|
58880
|
+
"error",
|
|
58881
|
+
(error62) => finish(
|
|
58882
|
+
fail2(
|
|
58883
|
+
"failed",
|
|
58884
|
+
error62.code === "ECONNREFUSED" ? `Connection to ${target.host}:${target.port} was refused` : `Connection to ${target.host}:${target.port} failed${error62.code ? ` (${error62.code})` : ""}`,
|
|
58885
|
+
`TCP connect to ${address}:${target.port} failed.`
|
|
58886
|
+
)
|
|
58887
|
+
)
|
|
58888
|
+
);
|
|
58889
|
+
});
|
|
58890
|
+
}
|
|
58891
|
+
var normal = (type, value2) => {
|
|
58892
|
+
const v = value2.trim();
|
|
58893
|
+
if (type === "TXT") return v;
|
|
58894
|
+
if (type === "AAAA" && isIP2(v) === 6)
|
|
58895
|
+
return v.toLowerCase().replace(/(^|:)0+(?=[0-9a-f])/g, "$1");
|
|
58896
|
+
return v.toLowerCase().replace(/\.$/, "").replace(/\s+/g, " ");
|
|
58897
|
+
};
|
|
58898
|
+
var matches = (type, answer, expected) => answer === expected || type === "MX" && answer.split(" ").slice(1).join(" ") === expected;
|
|
58899
|
+
async function dnsCheck(monitor, parent, io = publicDns(), sink = {}) {
|
|
58900
|
+
const signal = deadline(monitor, parent);
|
|
58901
|
+
const config2 = monitor.dns;
|
|
58902
|
+
const name5 = monitor.target.replace(/\.$/, "");
|
|
58903
|
+
const type = config2?.recordType ?? "A";
|
|
58904
|
+
const trace = {
|
|
58905
|
+
protocol: "dns",
|
|
58906
|
+
host: short(name5, 253),
|
|
58907
|
+
port: null,
|
|
58908
|
+
recordType: type,
|
|
58909
|
+
resolver: short(io.servers.join(", "), 100) || null,
|
|
58910
|
+
address: null,
|
|
58911
|
+
answers: [],
|
|
58912
|
+
banner: null,
|
|
58913
|
+
timings: { dns: null, connect: null, banner: null },
|
|
58914
|
+
error: null
|
|
58915
|
+
};
|
|
58916
|
+
sink.trace = trace;
|
|
58917
|
+
const result2 = (status2, message, logs2) => {
|
|
58918
|
+
if (status2 !== "passed") trace.error = short(message);
|
|
58919
|
+
return { status: status2, message, logs: logs2 };
|
|
58920
|
+
};
|
|
58921
|
+
if (!config2 || !publicDnsName(name5))
|
|
58922
|
+
return result2("error", "DNS target is invalid", "Use a public DNS name.");
|
|
58923
|
+
const started = performance5.now();
|
|
58924
|
+
let answers;
|
|
58925
|
+
try {
|
|
58926
|
+
answers = await race(
|
|
58927
|
+
io.resolve(name5, type, signal),
|
|
58928
|
+
signal,
|
|
58929
|
+
"DNS check cancelled or timed out"
|
|
58930
|
+
);
|
|
58931
|
+
} catch (cause) {
|
|
58932
|
+
trace.timings.dns = Math.round(performance5.now() - started);
|
|
58933
|
+
const code = cause.code ?? "";
|
|
58934
|
+
if (code === "ENOTFOUND" || code === "ENODATA")
|
|
58935
|
+
return result2(
|
|
58936
|
+
"failed",
|
|
58937
|
+
code === "ENOTFOUND" ? `${name5} does not exist (NXDOMAIN)` : `${name5} has no ${type} record`,
|
|
58938
|
+
`Asked ${trace.resolver} for ${type} ${name5}.`
|
|
58939
|
+
);
|
|
58940
|
+
return result2(
|
|
58941
|
+
"error",
|
|
58942
|
+
signal.aborted ? "DNS check cancelled or timed out" : `DNS resolution failed${code ? ` (${code})` : ""}`,
|
|
58943
|
+
`Asked ${trace.resolver} for ${type} ${name5}; no answer was evaluated.`
|
|
58944
|
+
);
|
|
58945
|
+
}
|
|
58946
|
+
trace.timings.dns = Math.round(performance5.now() - started);
|
|
58947
|
+
const got = answers.map((a) => normal(type, a));
|
|
58948
|
+
trace.answers = answers.slice(0, NETWORK_LIMITS.answers).map((a) => short(a));
|
|
58949
|
+
const want = config2.expected.map((e) => normal(type, e));
|
|
58950
|
+
const logs = `Asked ${trace.resolver} for ${type} ${name5}.
|
|
58951
|
+
Answer: ${trace.answers.join(" | ") || "(none)"}`;
|
|
58952
|
+
if (!got.length) return result2("failed", `${name5} has no ${type} record`, logs);
|
|
58953
|
+
const missing = want.filter((w) => !got.some((g) => matches(type, g, w)));
|
|
58954
|
+
const extra = config2.match === "exact" ? got.filter((g) => !want.some((w) => matches(type, g, w))) : [];
|
|
58955
|
+
if (missing.length || extra.length)
|
|
58956
|
+
return result2(
|
|
58957
|
+
"failed",
|
|
58958
|
+
missing.length ? `${type} ${name5} is missing ${missing.map((m) => short(m, 80)).join(", ")}` : `${type} ${name5} has unexpected ${extra.map((m) => short(m, 80)).join(", ")}`,
|
|
58959
|
+
logs
|
|
58960
|
+
);
|
|
58961
|
+
return result2(
|
|
58962
|
+
"passed",
|
|
58963
|
+
want.length ? `${type} ${name5} holds the expected value${want.length === 1 ? "" : "s"}` : `${type} ${name5} resolved to ${answers.length} record${answers.length === 1 ? "" : "s"}`,
|
|
58964
|
+
logs
|
|
58965
|
+
);
|
|
58966
|
+
}
|
|
58967
|
+
|
|
57813
58968
|
// ../../src/runner.ts
|
|
57814
58969
|
init_limits();
|
|
57815
58970
|
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
57816
58971
|
import { join as join6 } from "node:path";
|
|
57817
|
-
import { performance as
|
|
58972
|
+
import { performance as performance6 } from "node:perf_hooks";
|
|
57818
58973
|
|
|
57819
58974
|
// ../../src/checks/product-evidence.ts
|
|
57820
58975
|
import { constants as constants8 } from "node:fs";
|
|
@@ -58193,9 +59348,9 @@ async function collectArtifacts(dir, base2 = dir, tokens2 = [], excluded = /* @_
|
|
|
58193
59348
|
"AI evidence exceeds its byte limit"
|
|
58194
59349
|
);
|
|
58195
59350
|
const original = await handle.readFile("utf8");
|
|
58196
|
-
const redactText = (
|
|
59351
|
+
const redactText = (text4) => tokens2.reduce(
|
|
58197
59352
|
(value2, token) => value2.replaceAll(token, "[redacted attempt credential]"),
|
|
58198
|
-
|
|
59353
|
+
text4
|
|
58199
59354
|
);
|
|
58200
59355
|
let clean = redactText(original);
|
|
58201
59356
|
if (entry2.name.endsWith(".json")) {
|
|
@@ -58559,7 +59714,7 @@ try {
|
|
|
58559
59714
|
const requestCoverageError = requestEvidence.summary.technicalError;
|
|
58560
59715
|
const passed = !requestCoverageError && !dataCoverageError && !dataFailed && !scenarioCoverageError && !scenarioFailed && p.code === 0 && run2?.status === "passed" && results.length > 0 && results.every((r) => r.status === "passed");
|
|
58561
59716
|
const redact = (value2) => redactions.reduce(
|
|
58562
|
-
(
|
|
59717
|
+
(text4, token) => text4.replaceAll(token, "[redacted attempt credential]"),
|
|
58563
59718
|
value2
|
|
58564
59719
|
);
|
|
58565
59720
|
const artifacts = await collectArtifacts(
|
|
@@ -58634,13 +59789,13 @@ async function scriptCheck(m, dir, signal, options = {}) {
|
|
|
58634
59789
|
mode: 384,
|
|
58635
59790
|
flag: "wx"
|
|
58636
59791
|
});
|
|
58637
|
-
const
|
|
59792
|
+
const deadline2 = Math.min(
|
|
58638
59793
|
identity.expiresAt,
|
|
58639
59794
|
...identity.storageState.cookies.filter((cookie) => cookie.expires > 0).map((cookie) => cookie.expires * 1e3)
|
|
58640
59795
|
);
|
|
58641
59796
|
const identitySignal = AbortSignal.any([
|
|
58642
59797
|
...signal ? [signal] : [],
|
|
58643
|
-
AbortSignal.timeout(Math.max(1, Math.ceil(
|
|
59798
|
+
AbortSignal.timeout(Math.max(1, Math.ceil(deadline2 - Date.now())))
|
|
58644
59799
|
]);
|
|
58645
59800
|
const result2 = await scriptCheckInternal(m, dir, identitySignal, {
|
|
58646
59801
|
...options,
|
|
@@ -58679,19 +59834,21 @@ async function execute(monitor, runDir, {
|
|
|
58679
59834
|
httpFetch,
|
|
58680
59835
|
httpCredential,
|
|
58681
59836
|
browserIdentity,
|
|
58682
|
-
snapshots
|
|
59837
|
+
snapshots,
|
|
59838
|
+
onMcpToolResult
|
|
58683
59839
|
} = {}) {
|
|
58684
|
-
const start =
|
|
59840
|
+
const start = performance6.now();
|
|
58685
59841
|
let result2;
|
|
58686
59842
|
const exchanges = [];
|
|
58687
59843
|
const certificate = {};
|
|
59844
|
+
const network = {};
|
|
58688
59845
|
try {
|
|
58689
59846
|
signal?.throwIfAborted();
|
|
58690
59847
|
if (Boolean(monitor.browserIdentity) !== Boolean(browserIdentity) || browserIdentity && monitor.type !== "browser")
|
|
58691
59848
|
throw Error("Unexpected or missing browser identity authority");
|
|
58692
59849
|
if (httpCredential && !monitor.httpAuth)
|
|
58693
59850
|
throw Error("Unexpected HTTP credential authority");
|
|
58694
|
-
if (monitor.httpAuth && (!["http", "ai"].includes(monitor.type) || monitor.script || monitor.ai || monitor.settings.envNames.length || Object.keys(monitor.settings.headers).length || !["GET", "HEAD", "POST"].includes(monitor.settings.method) || new TextEncoder().encode(monitor.settings.body).byteLength > 16384 || ["GET", "HEAD"].includes(monitor.settings.method) && monitor.settings.body))
|
|
59851
|
+
if (monitor.httpAuth && (!["http", "ai", "mcp"].includes(monitor.type) || monitor.script || monitor.ai || monitor.settings.envNames.length || Object.keys(monitor.settings.headers).length || !["GET", "HEAD", "POST"].includes(monitor.settings.method) || new TextEncoder().encode(monitor.settings.body).byteLength > 16384 || ["GET", "HEAD"].includes(monitor.settings.method) && monitor.settings.body))
|
|
58695
59852
|
throw Error("Invalid authenticated HTTP execution configuration");
|
|
58696
59853
|
if (monitor.ai && (!["api", "browser"].includes(monitor.type) || !model))
|
|
58697
59854
|
throw Error(
|
|
@@ -58704,6 +59861,12 @@ async function execute(monitor, runDir, {
|
|
|
58704
59861
|
judgeComplete,
|
|
58705
59862
|
httpCredential
|
|
58706
59863
|
});
|
|
59864
|
+
else if (monitor.type === "mcp")
|
|
59865
|
+
result2 = await mcpCheck(monitor, signal, {
|
|
59866
|
+
fetch: httpFetch,
|
|
59867
|
+
httpCredential,
|
|
59868
|
+
onToolResult: onMcpToolResult
|
|
59869
|
+
});
|
|
58707
59870
|
else if (monitor.type === "heartbeat")
|
|
58708
59871
|
throw Error(
|
|
58709
59872
|
"Heartbeats receive external events and cannot execute a script"
|
|
@@ -58716,6 +59879,10 @@ async function execute(monitor, runDir, {
|
|
|
58716
59879
|
});
|
|
58717
59880
|
else if (monitor.type === "certificate")
|
|
58718
59881
|
result2 = await certificateCheck(monitor, signal, void 0, certificate);
|
|
59882
|
+
else if (monitor.type === "tcp")
|
|
59883
|
+
result2 = await tcpCheck(monitor, signal, void 0, network);
|
|
59884
|
+
else if (monitor.type === "dns")
|
|
59885
|
+
result2 = await dnsCheck(monitor, signal, void 0, network);
|
|
58719
59886
|
else if (monitor.type === "ping") {
|
|
58720
59887
|
const p = await child(
|
|
58721
59888
|
"ping",
|
|
@@ -58757,7 +59924,7 @@ async function execute(monitor, runDir, {
|
|
|
58757
59924
|
...monitor.ai && !(cause instanceof StorageError) ? { resourceReason: "AI_EXECUTION_ERROR" } : {}
|
|
58758
59925
|
};
|
|
58759
59926
|
}
|
|
58760
|
-
if (monitor.httpAuth && monitor.type
|
|
59927
|
+
if (monitor.httpAuth && !["ai", "mcp"].includes(monitor.type)) {
|
|
58761
59928
|
for (const secret of httpCredentialRedactions(httpCredential)) {
|
|
58762
59929
|
result2.logs = result2.logs.replaceAll(
|
|
58763
59930
|
secret,
|
|
@@ -58773,16 +59940,16 @@ async function execute(monitor, runDir, {
|
|
|
58773
59940
|
schemaVersion: 1,
|
|
58774
59941
|
kind: "certificate",
|
|
58775
59942
|
certificate: certificate.trace
|
|
58776
|
-
} : null;
|
|
59943
|
+
} : network.trace ? { schemaVersion: 1, kind: "network", network: network.trace } : null;
|
|
58777
59944
|
if (trace) result2 = await withTrace(result2, runDir, trace);
|
|
58778
|
-
return { ...result2, duration: Math.round(
|
|
59945
|
+
return { ...result2, duration: Math.round(performance6.now() - start) };
|
|
58779
59946
|
}
|
|
58780
59947
|
async function withTrace(result2, runDir, trace) {
|
|
58781
59948
|
try {
|
|
58782
|
-
const
|
|
58783
|
-
if (Buffer.byteLength(
|
|
59949
|
+
const text4 = JSON.stringify(runTraceFileSchema.parse(trace));
|
|
59950
|
+
if (Buffer.byteLength(text4) > RUN_TRACE_LIMITS.fileBytes) return result2;
|
|
58784
59951
|
await mkdir3(join6(runDir, ".e2e"), { recursive: true, mode: 448 });
|
|
58785
|
-
await writeFile3(join6(runDir, RUN_TRACE_PATH),
|
|
59952
|
+
await writeFile3(join6(runDir, RUN_TRACE_PATH), text4, { mode: 384 });
|
|
58786
59953
|
return {
|
|
58787
59954
|
...result2,
|
|
58788
59955
|
artifacts: [...result2.artifacts ?? [], RUN_TRACE_PATH]
|
|
@@ -58831,7 +59998,7 @@ var entries = {
|
|
|
58831
59998
|
TYPE_NOT_SUPPORTED: {
|
|
58832
59999
|
title: "Monitor type cannot be deployed",
|
|
58833
60000
|
meaning: "AI monitors are not part of waitcher.json yet.",
|
|
58834
|
-
fix: "Deploys accept http, certificate, heartbeat, api, browser and
|
|
60001
|
+
fix: "Deploys accept http, certificate, heartbeat, api, browser, visual, mcp, tcp and dns monitors. Keep AI checks on monitor apply for now."
|
|
58835
60002
|
},
|
|
58836
60003
|
ENTRY_REQUIRED: {
|
|
58837
60004
|
title: "Script monitor without a test file",
|
|
@@ -58878,6 +60045,21 @@ var entries = {
|
|
|
58878
60045
|
meaning: "A script lists a CHECK_* name in settings.envNames that has no value in the environment.",
|
|
58879
60046
|
fix: "Set it once per environment: waitcher secret set --env NAME --name CHECK_NAME --value-stdin. Values are write-only and never part of waitcher.json."
|
|
58880
60047
|
},
|
|
60048
|
+
HTTP_CREDENTIAL_REFERENCE: {
|
|
60049
|
+
title: "Malformed credential reference",
|
|
60050
|
+
meaning: "httpAuth.credential is not a credential name, or a name per environment that includes this environment.",
|
|
60051
|
+
fix: 'Write httpAuth as {"credential": "Product key"} or {"credential": {"production": "Prod key", "staging": "Staging key"}}.'
|
|
60052
|
+
},
|
|
60053
|
+
HTTP_CREDENTIAL_NOT_FOUND: {
|
|
60054
|
+
title: "No credential with this name",
|
|
60055
|
+
meaning: "The account has no HTTP target credential with the name httpAuth.credential gives.",
|
|
60056
|
+
fix: "Create it first: waitcher target credential create --file credential.json --credential-file ./private/key (the name is in its JSON), or fix the name."
|
|
60057
|
+
},
|
|
60058
|
+
HTTP_CREDENTIAL_AMBIGUOUS: {
|
|
60059
|
+
title: "Credential name is not unique",
|
|
60060
|
+
meaning: "Two HTTP target credentials share the name, so the reference cannot choose one.",
|
|
60061
|
+
fix: "Give each credential a distinct name, or use the target, credential and revision IDs in httpAuth."
|
|
60062
|
+
},
|
|
58881
60063
|
ADOPTION_CANDIDATE: {
|
|
58882
60064
|
title: "An existing monitor looks like this entry",
|
|
58883
60065
|
meaning: "Applying would create a second monitor next to an unmanaged one with the same name or target.",
|
|
@@ -59142,7 +60324,10 @@ var DEPLOY_TYPES = [
|
|
|
59142
60324
|
"certificate",
|
|
59143
60325
|
"heartbeat",
|
|
59144
60326
|
...SCRIPT_TYPES,
|
|
59145
|
-
"visual"
|
|
60327
|
+
"visual",
|
|
60328
|
+
"mcp",
|
|
60329
|
+
"tcp",
|
|
60330
|
+
"dns"
|
|
59146
60331
|
];
|
|
59147
60332
|
var isScriptType = (type) => SCRIPT_TYPES.includes(type);
|
|
59148
60333
|
var MONITOR_KEY = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
@@ -59176,10 +60361,15 @@ var projectConfigSchema = external_exports.object({
|
|
|
59176
60361
|
monitors: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(CONFIG_LIMITS.monitors)
|
|
59177
60362
|
}).strict();
|
|
59178
60363
|
var pathOf = (parts) => parts.reduce(
|
|
59179
|
-
(
|
|
60364
|
+
(text4, part2) => typeof part2 === "number" ? `${text4}[${part2}]` : `${text4}${text4 ? "." : ""}${String(part2)}`,
|
|
59180
60365
|
""
|
|
59181
60366
|
);
|
|
59182
|
-
|
|
60367
|
+
var PLACEHOLDER_HTTP_AUTH = {
|
|
60368
|
+
targetId: "00000000-0000-4000-8000-000000000000",
|
|
60369
|
+
credentialId: "00000000-0000-4000-8000-000000000000",
|
|
60370
|
+
credentialRevision: 1
|
|
60371
|
+
};
|
|
60372
|
+
function resolveProjectConfig(input2, environment, scripts, httpAuth) {
|
|
59183
60373
|
const result2 = {
|
|
59184
60374
|
environments: [],
|
|
59185
60375
|
declared: [],
|
|
@@ -59282,6 +60472,32 @@ function resolveProjectConfig(input2, environment, scripts) {
|
|
|
59282
60472
|
`${at}.entry`,
|
|
59283
60473
|
key
|
|
59284
60474
|
);
|
|
60475
|
+
const ref = rest.httpAuth;
|
|
60476
|
+
if (ref && typeof ref === "object" && !Array.isArray(ref) && Object.hasOwn(ref, "credential")) {
|
|
60477
|
+
const named = ref.credential;
|
|
60478
|
+
const name5 = typeof named === "string" ? named : named && typeof named === "object" && !Array.isArray(named) ? Object.entries(named).find(
|
|
60479
|
+
([k]) => lookup3(k) === env
|
|
60480
|
+
)?.[1] : void 0;
|
|
60481
|
+
if (Object.keys(ref).length !== 1 || typeof name5 !== "string" || !name5)
|
|
60482
|
+
return fail2(
|
|
60483
|
+
"HTTP_CREDENTIAL_REFERENCE",
|
|
60484
|
+
`httpAuth.credential is a credential name, or a name per environment including "${env}"`,
|
|
60485
|
+
`${at}.httpAuth`,
|
|
60486
|
+
key
|
|
60487
|
+
);
|
|
60488
|
+
if (!httpAuth) rest.httpAuth = PLACEHOLDER_HTTP_AUTH;
|
|
60489
|
+
else {
|
|
60490
|
+
const bound = httpAuth(name5);
|
|
60491
|
+
if (bound === "missing" || bound === "ambiguous")
|
|
60492
|
+
return fail2(
|
|
60493
|
+
bound === "missing" ? "HTTP_CREDENTIAL_NOT_FOUND" : "HTTP_CREDENTIAL_AMBIGUOUS",
|
|
60494
|
+
bound === "missing" ? `No HTTP credential is named "${name5}"` : `More than one HTTP credential is named "${name5}"; rename one`,
|
|
60495
|
+
`${at}.httpAuth`,
|
|
60496
|
+
key
|
|
60497
|
+
);
|
|
60498
|
+
rest.httpAuth = bound;
|
|
60499
|
+
}
|
|
60500
|
+
}
|
|
59285
60501
|
let target = rest.target;
|
|
59286
60502
|
if (path2 !== void 0) {
|
|
59287
60503
|
if (target !== void 0)
|
|
@@ -59299,6 +60515,7 @@ function resolveProjectConfig(input2, environment, scripts) {
|
|
|
59299
60515
|
if (rest.type === "heartbeat") target = key;
|
|
59300
60516
|
else if (rest.type === "certificate" && baseUrl)
|
|
59301
60517
|
target = `${new URL(baseUrl).origin}/`;
|
|
60518
|
+
else if (rest.type === "dns" && baseUrl) target = new URL(baseUrl).hostname;
|
|
59302
60519
|
else if ((script || rest.type === "visual") && baseUrl) target = baseUrl;
|
|
59303
60520
|
else
|
|
59304
60521
|
return fail2("TARGET_REQUIRED", "A target is required", `${at}.target`, key);
|
|
@@ -59385,6 +60602,25 @@ function projectConfigJsonSchema() {
|
|
|
59385
60602
|
const { $schema: _, ...config2 } = external_exports.toJSONSchema(projectConfigSchema, io);
|
|
59386
60603
|
const monitor = external_exports.toJSONSchema(monitorDefinitionSchema, io);
|
|
59387
60604
|
const properties = { ...monitor.properties };
|
|
60605
|
+
properties.httpAuth = {
|
|
60606
|
+
description: "Stored header credential: account IDs, or a credential name (one per environment as an object)",
|
|
60607
|
+
anyOf: [
|
|
60608
|
+
properties.httpAuth,
|
|
60609
|
+
{
|
|
60610
|
+
type: "object",
|
|
60611
|
+
additionalProperties: false,
|
|
60612
|
+
required: ["credential"],
|
|
60613
|
+
properties: {
|
|
60614
|
+
credential: {
|
|
60615
|
+
anyOf: [
|
|
60616
|
+
{ type: "string", minLength: 1 },
|
|
60617
|
+
{ type: "object", additionalProperties: { type: "string", minLength: 1 } }
|
|
60618
|
+
]
|
|
60619
|
+
}
|
|
60620
|
+
}
|
|
60621
|
+
}
|
|
60622
|
+
]
|
|
60623
|
+
};
|
|
59388
60624
|
for (const field of ["demo", "enabled", "script", "schemaVersion", "context", "ai", "aiEndpoint"])
|
|
59389
60625
|
delete properties[field];
|
|
59390
60626
|
Object.assign(properties, {
|
|
@@ -59461,8 +60697,8 @@ async function readConnectionConfiguration(file2) {
|
|
|
59461
60697
|
2
|
|
59462
60698
|
);
|
|
59463
60699
|
}
|
|
59464
|
-
function providerCredential(
|
|
59465
|
-
const parsed = connectionSecretSchema.safeParse(
|
|
60700
|
+
function providerCredential(text4) {
|
|
60701
|
+
const parsed = connectionSecretSchema.safeParse(text4.trim());
|
|
59466
60702
|
if (!parsed.success)
|
|
59467
60703
|
throw new ServiceError(
|
|
59468
60704
|
"Provide a private provider key through --credential-file or --credential-stdin.",
|
|
@@ -59629,8 +60865,8 @@ function modelAllowance(body2, models, maxOutput) {
|
|
|
59629
60865
|
return { outputTokens, reservedTokens };
|
|
59630
60866
|
}
|
|
59631
60867
|
function modelOutcome(input2) {
|
|
59632
|
-
const
|
|
59633
|
-
return { ok:
|
|
60868
|
+
const reason2 = !input2.authorized ? "AI_NOT_AUTHORIZED" : input2.failure ?? (input2.pending || input2.lastState && input2.lastState !== "known" ? "AI_USAGE_UNKNOWN" : null);
|
|
60869
|
+
return { ok: reason2 === null, reason: reason2 };
|
|
59634
60870
|
}
|
|
59635
60871
|
function modelTransport(authority, options = {}) {
|
|
59636
60872
|
const providerFetch = options.fetchImpl ?? fetch, now = options.now ?? Date.now, requestMs = options.requestMs ?? MODEL_LIMITS.requestMs;
|
|
@@ -59720,8 +60956,8 @@ function modelTransport(authority, options = {}) {
|
|
|
59720
60956
|
"Model provider did not accept the request"
|
|
59721
60957
|
);
|
|
59722
60958
|
}
|
|
59723
|
-
const
|
|
59724
|
-
if (
|
|
60959
|
+
const text4 = await boundedText(response2, MODEL_LIMITS.responseBytes);
|
|
60960
|
+
if (text4.includes(call.secret) || text4.includes(JSON.stringify(call.secret).slice(1, -1)))
|
|
59725
60961
|
throw new AppError(
|
|
59726
60962
|
502,
|
|
59727
60963
|
"AI_RESPONSE_REJECTED",
|
|
@@ -59729,7 +60965,7 @@ function modelTransport(authority, options = {}) {
|
|
|
59729
60965
|
);
|
|
59730
60966
|
let result2;
|
|
59731
60967
|
try {
|
|
59732
|
-
result2 = modelResponseSchema.safeParse(JSON.parse(
|
|
60968
|
+
result2 = modelResponseSchema.safeParse(JSON.parse(text4));
|
|
59733
60969
|
} catch {
|
|
59734
60970
|
}
|
|
59735
60971
|
if (!result2?.success || result2.data.model !== body2.model)
|
|
@@ -60083,7 +61319,7 @@ async function runLocalRequest(definition, options, project) {
|
|
|
60083
61319
|
const info = await lstat7(parent);
|
|
60084
61320
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
60085
61321
|
invalid2("Output must be a regular directory, not a symbolic link.");
|
|
60086
|
-
const runId = randomUUID4(), directory = join8(parent, runId), startedAt = Date.now(), start =
|
|
61322
|
+
const runId = randomUUID4(), directory = join8(parent, runId), startedAt = Date.now(), start = performance7.now();
|
|
60087
61323
|
await mkdir4(directory, { mode: 448 });
|
|
60088
61324
|
const timeout = options.timeout ?? definition.timeout;
|
|
60089
61325
|
const signal = AbortSignal.any([
|
|
@@ -60093,6 +61329,7 @@ async function runLocalRequest(definition, options, project) {
|
|
|
60093
61329
|
let broker;
|
|
60094
61330
|
let modelUsage;
|
|
60095
61331
|
let check2;
|
|
61332
|
+
let mcpToolResult;
|
|
60096
61333
|
try {
|
|
60097
61334
|
if (binding && connection) {
|
|
60098
61335
|
broker = await localModelBroker(
|
|
@@ -60111,6 +61348,7 @@ async function runLocalRequest(definition, options, project) {
|
|
|
60111
61348
|
aiEndpointFetch: options.aiEndpointFetch,
|
|
60112
61349
|
httpFetch: options.httpFetch,
|
|
60113
61350
|
httpCredential: credential,
|
|
61351
|
+
onMcpToolResult: (result3) => mcpToolResult = result3,
|
|
60114
61352
|
...broker ? {
|
|
60115
61353
|
judgeComplete: async (body2, signal2) => {
|
|
60116
61354
|
const response = await broker.complete(
|
|
@@ -60145,17 +61383,23 @@ async function runLocalRequest(definition, options, project) {
|
|
|
60145
61383
|
}
|
|
60146
61384
|
const report = join8(
|
|
60147
61385
|
directory,
|
|
60148
|
-
definition.type === "ai" ? "ai-endpoint-report.json" : "http-report.json"
|
|
61386
|
+
definition.type === "ai" ? "ai-endpoint-report.json" : definition.type === "mcp" ? "mcp-report.json" : ["tcp", "dns"].includes(definition.type) ? "network-report.json" : "http-report.json"
|
|
60149
61387
|
), log = join8(directory, "execution.log");
|
|
60150
|
-
const reportText = definition.type
|
|
61388
|
+
const reportText = ["ai", "mcp"].includes(definition.type) ? check2.logs : JSON.stringify({
|
|
60151
61389
|
schemaVersion: 1,
|
|
60152
|
-
kind: "http",
|
|
61390
|
+
kind: ["tcp", "dns"].includes(definition.type) ? definition.type : "http",
|
|
60153
61391
|
status: check2.status,
|
|
60154
61392
|
message: check2.message,
|
|
60155
61393
|
duration: check2.duration
|
|
60156
61394
|
});
|
|
60157
61395
|
await writeFile4(report, reportText + "\n", { mode: 384, flag: "wx" });
|
|
60158
61396
|
await writeFile4(log, check2.logs + "\n", { mode: 384, flag: "wx" });
|
|
61397
|
+
if (mcpToolResult !== void 0)
|
|
61398
|
+
await writeFile4(
|
|
61399
|
+
join8(directory, "mcp-tool-result.json"),
|
|
61400
|
+
JSON.stringify(mcpToolResult, null, 2) + "\n",
|
|
61401
|
+
{ mode: 384, flag: "wx" }
|
|
61402
|
+
);
|
|
60159
61403
|
await writeLocalFrozenDefinition(directory, definition);
|
|
60160
61404
|
const result2 = {
|
|
60161
61405
|
schemaVersion: 1,
|
|
@@ -60165,7 +61409,7 @@ async function runLocalRequest(definition, options, project) {
|
|
|
60165
61409
|
status: check2.status,
|
|
60166
61410
|
message: check2.message,
|
|
60167
61411
|
startedAt,
|
|
60168
|
-
duration: Math.round(
|
|
61412
|
+
duration: Math.round(performance7.now() - start),
|
|
60169
61413
|
directory,
|
|
60170
61414
|
report,
|
|
60171
61415
|
summary: null,
|
|
@@ -60201,14 +61445,14 @@ async function runLocal(options) {
|
|
|
60201
61445
|
"--browser-identities-file applies only to a bound browser manifest."
|
|
60202
61446
|
);
|
|
60203
61447
|
const browserIdentity = definition ? await localBrowserIdentity(options.browserIdentitiesFile, definition) : void 0;
|
|
60204
|
-
if (definition && ["ai", "http"].includes(definition.type)) {
|
|
60205
|
-
if (definition.type
|
|
61448
|
+
if (definition && ["ai", "http", "mcp", "tcp", "dns"].includes(definition.type)) {
|
|
61449
|
+
if (["ai", "mcp"].includes(definition.type) && options.timeout !== void 0 && (!Number.isSafeInteger(options.timeout) || options.timeout < 3 || options.timeout > AI_ENDPOINT_LIMITS.maxTimeoutSeconds))
|
|
60206
61450
|
invalid2(
|
|
60207
|
-
`AI endpoint
|
|
61451
|
+
`AI endpoint and MCP timeouts must be an integer from 3 to ${AI_ENDPOINT_LIMITS.maxTimeoutSeconds} seconds.`
|
|
60208
61452
|
);
|
|
60209
61453
|
if (options.runtime || options.video)
|
|
60210
61454
|
invalid2(
|
|
60211
|
-
"HTTP
|
|
61455
|
+
"HTTP, AI endpoint, MCP, TCP and DNS checks need no E2E runtime or video; omit those options."
|
|
60212
61456
|
);
|
|
60213
61457
|
if (options.connectionsFile && !endpointJudgeBinding(definition.aiEndpoint))
|
|
60214
61458
|
invalid2(
|
|
@@ -60285,7 +61529,7 @@ async function runLocal(options) {
|
|
|
60285
61529
|
}
|
|
60286
61530
|
const runId = randomUUID4(), directory = join8(parent, runId);
|
|
60287
61531
|
await mkdir4(directory, { mode: 448 });
|
|
60288
|
-
const startedAt = Date.now(), start =
|
|
61532
|
+
const startedAt = Date.now(), start = performance7.now();
|
|
60289
61533
|
const timeout = options.timeout ?? definition?.timeout ?? 60;
|
|
60290
61534
|
const evidence = definition ? ".e2e" : "evidence";
|
|
60291
61535
|
let status2 = "error", logs = "", message = "Local execution did not finish";
|
|
@@ -60473,7 +61717,7 @@ async function runLocal(options) {
|
|
|
60473
61717
|
status: finalStatus,
|
|
60474
61718
|
message,
|
|
60475
61719
|
startedAt,
|
|
60476
|
-
duration: Math.round(
|
|
61720
|
+
duration: Math.round(performance7.now() - start),
|
|
60477
61721
|
directory,
|
|
60478
61722
|
report: files.some((f) => f.path === `${evidence}/report.json`) ? join8(directory, evidence, "report.json") : null,
|
|
60479
61723
|
summary: files.some((f) => f.path === `${evidence}/summary.md`) ? join8(directory, evidence, "summary.md") : null,
|
|
@@ -61132,9 +62376,9 @@ function pinPackageJson(existing, project) {
|
|
|
61132
62376
|
}
|
|
61133
62377
|
return { json: json3, changes };
|
|
61134
62378
|
}
|
|
61135
|
-
var missingIgnores = (
|
|
62379
|
+
var missingIgnores = (text4) => {
|
|
61136
62380
|
const lines = new Set(
|
|
61137
|
-
|
|
62381
|
+
text4.split(/\r?\n/).map((l) => l.trim().replace(/^\//, ""))
|
|
61138
62382
|
);
|
|
61139
62383
|
return RUNTIME_IGNORES.filter(
|
|
61140
62384
|
(entry2) => !lines.has(entry2) && !lines.has(entry2.slice(0, -1))
|
|
@@ -61164,11 +62408,11 @@ function run(command, args, cwd, signal) {
|
|
|
61164
62408
|
async function installRuntime(options) {
|
|
61165
62409
|
const { project, browser, yes, signal } = options;
|
|
61166
62410
|
const manifestPath = join11(project, "package.json");
|
|
61167
|
-
const
|
|
62411
|
+
const text4 = await readFile6(manifestPath, "utf8").catch(() => null);
|
|
61168
62412
|
let existing = null;
|
|
61169
|
-
if (
|
|
62413
|
+
if (text4 !== null)
|
|
61170
62414
|
try {
|
|
61171
|
-
existing = JSON.parse(
|
|
62415
|
+
existing = JSON.parse(text4);
|
|
61172
62416
|
} catch (cause) {
|
|
61173
62417
|
throw new ServiceError(
|
|
61174
62418
|
`${manifestPath} is not valid JSON: ${cause.message}`,
|
|
@@ -61421,9 +62665,9 @@ async function verifyLocally(options) {
|
|
|
61421
62665
|
var configPath = (file2) => resolve13(file2 ?? CONFIG_FILE);
|
|
61422
62666
|
async function readProjectConfig(file2) {
|
|
61423
62667
|
const path2 = configPath(file2);
|
|
61424
|
-
let
|
|
62668
|
+
let text4;
|
|
61425
62669
|
try {
|
|
61426
|
-
|
|
62670
|
+
text4 = await readFile7(path2, "utf8");
|
|
61427
62671
|
} catch {
|
|
61428
62672
|
throw new ServiceError(
|
|
61429
62673
|
`${path2} was not found. Run waitcher config init or pass --file.`,
|
|
@@ -61431,14 +62675,14 @@ async function readProjectConfig(file2) {
|
|
|
61431
62675
|
2
|
|
61432
62676
|
);
|
|
61433
62677
|
}
|
|
61434
|
-
if (Buffer.byteLength(
|
|
62678
|
+
if (Buffer.byteLength(text4) > CONFIG_LIMITS.bytes)
|
|
61435
62679
|
throw new ServiceError(
|
|
61436
62680
|
`waitcher.json exceeds ${CONFIG_LIMITS.bytes} bytes.`,
|
|
61437
62681
|
"VALIDATION_ERROR",
|
|
61438
62682
|
2
|
|
61439
62683
|
);
|
|
61440
62684
|
try {
|
|
61441
|
-
return { path: path2, config: JSON.parse(
|
|
62685
|
+
return { path: path2, config: JSON.parse(text4) };
|
|
61442
62686
|
} catch (cause) {
|
|
61443
62687
|
throw new ServiceError(
|
|
61444
62688
|
`waitcher.json is not valid JSON: ${cause.message}`,
|
|
@@ -61513,22 +62757,22 @@ function deployNextSteps(result2, {
|
|
|
61513
62757
|
}
|
|
61514
62758
|
|
|
61515
62759
|
// ../../skills/waitcher/SKILL.md
|
|
61516
|
-
var SKILL_default = "---\nname: waitcher\ndescription: Set up and maintain Waitcher monitoring from a repository with the waitcher CLI. Use to turn a product's critical journeys into HTTP, certificate, heartbeat, API, browser or
|
|
62760
|
+
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. 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).\n2. **Understand the product.** Read the repository: base URLs per environment, existing E2E tests, critical journeys, test accounts and jobs. Ask the user which failures should alert them.\n3. **Start the file.** `waitcher config init --project-name NAME --target https://BASE` when there is no `waitcher.json`. Give each monitor a stable lowercase `key`; changing a key later replaces the monitor and its history.\n4. **Choose types.** `http` for status and content, `certificate` for TLS expiry, `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. The same command upgrades the project after a CLI update (`RUNTIME_VERSION_OUTDATED`).\n5. **Validate offline.** `waitcher config validate` resolves every environment and builds every entry. Fix each issue at its `path`. Add `--env NAME --verify` (optionally `--key KEY`) to run the api/browser entries locally without an account; read the run directory it names when one fails.\n6. **Plan.** `waitcher deploy plan --env NAME --verify` runs script monitors locally against that environment, then asks the server. Resolve errors (`SECRET_MISSING`: ask the user for the value and run `waitcher secret set`; `ADOPTION_CANDIDATE`: ask whether the existing monitor is the same check).\n7. **Apply.** After the user accepts the plan: `waitcher deploy apply --env NAME --based-on BASED_ON`, where BASED_ON is the plan's `basedOn` or `none` when it is null (first deploy); the plan's `next` prints the exact command. Add `--smoke` for one hosted run per changed monitor. New monitors stay paused.\n8. **Report.** Give the user the monitor IDs, what each checks, local and hosted results, evidence paths and anything still pending (paused schedules, heartbeat credentials, secrets for other environments). If `waitcher alert policy list` shows no routing, failures will alert nobody: point the user to https://waitcher.dev/docs/alerts.\n\nFor CI, `waitcher ci init` writes a workflow that plans on pull requests and applies on the main branch. Details of secrets, adoption, rollback and CI are in [deploy](references/deploy.md).\n\n## When something fails\n\n- `waitcher --help` prints a short overview of topics; `waitcher help TOPIC` (or `waitcher GROUP --help`) prints one part with the exit codes; `waitcher help all` is long, avoid it.\n- Exit 2: fix the file or input; exit 3: sign in; exit 4: a check failed (inspect evidence); exit 6: quota, rate or queue limit; exit 7: not permitted; exit 8: conflict or managed by `waitcher.json`; exit 9: not found; exit 10: service unavailable.\n- For a failed run, read [diagnosis](references/diagnosis.md): `waitcher run diagnose --id RUN_ID`, then reproduce locally before changing the test.\n- Never retry a write automatically after an uncertain result; read the current state first.\n\n## References\n\n- [authoring](references/authoring.md): choosing a type, writing API and browser tests, local runs and evidence, single-monitor apply.\n- [deploy](references/deploy.md): waitcher.json details, secrets, adoption, rollback, CI.\n- [diagnosis](references/diagnosis.md): run diagnosis and reproduction.\n- [optional capabilities](references/optional-capabilities.md): visual baselines, browser identities, verified HTTP credentials, invocation budgets, agent checks, public status pages, 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";
|
|
61517
62761
|
|
|
61518
62762
|
// ../../skills/waitcher/references/authoring.md
|
|
61519
|
-
var authoring_default = '# Authoring and running monitors\n\nRead when writing or changing a test, choosing a monitor type, or running it locally. For exact syntax run `waitcher help monitor` or `waitcher help run`. AI endpoints, agent outcome checks and model steps are in [ai-and-agents](ai-and-agents.md).\n\n## Choose the type\n\n- `http`: status, body text, a JSON value or latency of one request. No script.\n- `certificate`: TLS expiry and chain. No script.\n- `heartbeat`: a job reports start and success; Waitcher alerts when it does not.\n- `api`: a script with several requests and an invariant between them.\n- `browser`: a script that walks a user journey in Chromium.\n- `visual`: a screenshot of one public page or element compared with a baseline the user approved. No script; see [optional capabilities](optional-capabilities.md#optional-visual-checks).\n\n`waitcher monitor init --type TYPE --file x.json` writes a paused example of every type; `api` and `browser` also write `x.e2e.ts`. Keep scripts focused on the requested behavior and use controlled test identities for actions that change state.\n\n## Scripts in waitcher.json\n\nIn a repository, a script monitor is an entry with `entry` pointing at its test file; one test serves every environment because it reads the base URL at run time.\n\n```json\n{ "key": "checkout", "type": "browser", "entry": "monitoring/checkout.e2e.ts", "timeout": 45 }\n```\n\nRun the entries of one environment locally, without an account:\n\n```sh\nwaitcher config validate --env production --verify\nwaitcher config validate --env production --verify --key checkout\n```\n\nExit 4 with `VERIFY_FAILED` names the failing assertion and the run directory to read. `run local --file` takes a single monitor manifest, not `waitcher.json`.\n\n## Browser journey\n\n```ts\nimport { test } from "@e2e-dev/web";\nimport { expect } from "e2e";\n\ntest("visitor can start a game", async ({ app, browser, screen }) => {\n await app.open("/games/klondike/");\n await expect(browser.locator("main h1")).toContainText("Solitaire");\n await expect(screen.getByRole("button", "New game")).toBeVisible();\n await app.screenshot("game");\n});\n```\n\n- `app.open(path)` resolves against the environment\'s base URL. Browser base URLs have no query or fragment; navigate to those URLs inside the script.\n- Find elements the way a visitor does with the `screen` fixture: `screen.getByRole("button", "New game")`, `screen.getByLabel("Email")`, `screen.getByText("Welcome")`, `screen.getByPlaceholder(...)`, `screen.getByTestId(...)`. Prefer these over CSS selectors.\n- The `browser` fixture navigates and offers CSS `browser.locator("main h1")` plus `expect(browser).toHaveURL(...)`; it has no `getBy*` methods.\n- Assertions come from `e2e`: `toBeVisible()`, `toContainText(...)`, `toHaveText(...)`.\n\n## API script\n\n```ts\nimport { test, expect } from "e2e";\n\ntest("orders API keeps totals consistent", async () => {\n const target = new URL(process.env.TARGET_URL!);\n const response = await fetch(new URL("/api/orders?limit=1", target));\n expect(response.status).toBe(200);\n});\n```\n\nAPI scripts import `test, expect` from `e2e` and read `process.env.TARGET_URL`. Secrets reach them only as `CHECK_*` names listed in `settings.envNames` (see [deploy](deploy.md)). The test runs as trusted local code, not in a sandbox.\n\n## Standalone manifest\n\nWithout `waitcher.json`, a monitor is one JSON file. `monitor init --type browser --file monitor.json` writes it with `scriptFile` next to the test:\n\n```json\n{\n "schemaVersion": 1,\n "name": "Product / key journey",\n "type": "browser",\n "target": "https://example.com/",\n "enabled": false,\n "interval": 1800,\n "timeout": 30,\n "scriptFile": "journey.e2e.ts"\n}\n```\n\n`scriptFile` resolves relative to the manifest; `monitor validate --file monitor.json` checks the actual contract. The platform receives one script per monitor, not the project directory. When the test imports shared helpers, run `monitor build --file monitors/checkout.json --project . --output build/checkout`: it needs installed `esbuild@0.28.2`, bundles code and JSON helpers, keeps only supported framework and Node imports, and writes `monitor.js`, `monitor.json` and `build.json` into a new directory. Unsupported dependencies and module-relative file access fail the build. Verify and apply the built `monitor.json`. The script limit is 50,000 characters and hosted dependencies are fixed.\n\n## Run locally and inspect evidence\n\nThe runtime project needs `e2e@0.21.1` and, for browser tests, `@e2e-dev/web@0.15.1` and Chromium. `waitcher runtime install --file DIR/waitcher.json [--browser]` lists the npm install and Chromium download; run it with `--yes` once the user agrees. Chromium goes to the Playwright browser cache (`PLAYWRIGHT_BROWSERS_PATH` when set), not the runtime directory.\n\n```sh\nwaitcher run local --file monitor.json --runtime /path/to/runtime\nwaitcher run local --file monitor.json --runtime /path/to/runtime --video\nwaitcher run local --project /path/to/e2e-project --timeout 60\n```\n\n- `--project` runs an existing E2E project with its own config and imports; its `--output` must stay inside that project.\n- Runs are serial, never retried or replayed, and get a fresh directory under `.waitcher/runs/` (`--output DIR` chooses the parent). Traces are always requested; video is opt-in, and tests can override recording, so inspect the returned files.\n- On failure read `.e2e/summary.md` and `.e2e/results/*/trace.md` in the run directory first, then `execution.log` and `report.json`. The `waitcher-*.mjs` files there are runtime support, not your test. Traces are Markdown, not Playwright ZIPs; there is no HAR option, and app logs hold selected console and request failures only.\n- Exit codes: 0 passed, 4 failed or error, 130 interrupted. After an interruption, inspect partial evidence before repeating a possibly completed action.\n- Fix test mistakes while preserving the user\'s assertions; never weaken an assertion just to get green.\n- Evidence can contain private content: keep `.waitcher/`, `.e2e/`, keys and reports out of Git. Local results are not uploaded and are not hosted health evidence.\n\n## Apply one monitor through the API\n\nWhen hosted scripts are allowed and applying configuration is in scope:\n\n```sh\nwaitcher monitor apply --file monitor.json --dry-run\nwaitcher monitor apply --file monitor.json\nwaitcher monitor get --id MONITOR_ID\n```\n\nKeep the monitor paused unless the user requested scheduled execution; applying does not run it. For an authorized single hosted run use `run start --id MONITOR_ID --wait`, then `run status`, `run trace --id RUN_ID` (steps, failed assertion, screenshots, fetch calls) and `artifact get` for evidence. Hosted scripts run under the server\'s execution policy and can differ from a local run.\n\nEdits are complete replacements: `monitor export`, change the file, then `monitor apply --file FILE --id ID --expected-revision N` with the revision from get or export. Use a stable `--request-key` to recover one uncertain create or run; never change the payload under that key or repeat a possibly executed action. Report the exact monitor and run IDs, local evidence path, observed outcome and any difference between local and hosted results.\n';
|
|
62763
|
+
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@0.28.2`, bundles code and JSON helpers, keeps only supported framework and Node imports, and writes `monitor.js`, `monitor.json` and `build.json` into a new directory. Unsupported dependencies and module-relative file access fail the build. Verify and apply the built `monitor.json`. The script limit is 50,000 characters and hosted dependencies are fixed.\n\n## Run locally and inspect evidence\n\nThe runtime project needs `e2e@0.21.1` and, for browser tests, `@e2e-dev/web@0.15.1` and Chromium. `waitcher runtime install --file DIR/waitcher.json [--browser]` lists the npm install and Chromium download; run it with `--yes` once the user agrees. Chromium goes to the Playwright browser cache (`PLAYWRIGHT_BROWSERS_PATH` when set), not the runtime directory.\n\n```sh\nwaitcher run local --file monitor.json --runtime /path/to/runtime\nwaitcher run local --file monitor.json --runtime /path/to/runtime --video\nwaitcher run local --project /path/to/e2e-project --timeout 60\n```\n\n- `--project` runs an existing E2E project with its own config and imports; its `--output` must stay inside that project.\n- Runs are serial, never retried or replayed, and get a fresh directory under `.waitcher/runs/` (`--output DIR` chooses the parent). Traces are always requested; video is opt-in, and tests can override recording, so inspect the returned files.\n- On failure read `.e2e/summary.md` and `.e2e/results/*/trace.md` in the run directory first, then `execution.log` and `report.json`. The `waitcher-*.mjs` files there are runtime support, not your test. Traces are Markdown, not Playwright ZIPs; there is no HAR option, and app logs hold selected console and request failures only.\n- Exit codes: 0 passed, 4 failed or error, 130 interrupted. After an interruption, inspect partial evidence before repeating a possibly completed action.\n- Fix test mistakes while preserving the user\'s assertions; never weaken an assertion just to get green.\n- Evidence can contain private content: keep `.waitcher/`, `.e2e/`, keys and reports out of Git. Local results are not uploaded and are not hosted health evidence.\n\n## Apply one monitor through the API\n\nWhen hosted scripts are allowed and applying configuration is in scope:\n\n```sh\nwaitcher monitor apply --file monitor.json --dry-run\nwaitcher monitor apply --file monitor.json\nwaitcher monitor get --id MONITOR_ID\n```\n\nKeep the monitor paused unless the user requested scheduled execution; applying does not run it. For an authorized single hosted run use `run start --id MONITOR_ID --wait`, then `run status`, `run trace --id RUN_ID` (steps, failed assertion, screenshots, fetch calls) and `artifact get` for evidence. Hosted scripts run under the server\'s execution policy and can differ from a local run.\n\nEdits are complete replacements: `monitor export`, change the file, then `monitor apply --file FILE --id ID --expected-revision N` with the revision from get or export. Use a stable `--request-key` to recover one uncertain create or run; never change the payload under that key or repeat a possibly executed action. Report the exact monitor and run IDs, local evidence path, observed outcome and any difference between local and hosted results.\n';
|
|
61520
62764
|
|
|
61521
62765
|
// ../../skills/waitcher/references/ai-and-agents.md
|
|
61522
|
-
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.107. The complete CLI package ships model-client.mjs and notices; copying only cli.mjs is insufficient for bound AI execution.\n\nThe local manifest runner keeps the provider key in its parent and passes a temporary loopback grant to the test. It uses the hosted transport and per-run budget/outcome rules, but no hosted account/day ledger. Read model-usage.json as well as the native report: caught provider/budget failures may leave a native passed test while Waitcher correctly records error. Unknown usage stays reserved, SDK retries count separately, and local success does not verify hosted enablement or key freshness. Provider keys are not forwarded to the child, and literal temporary broker tokens are redacted from normal text evidence; trusted local code can read its filesystem and is not a sandbox. Traces default on, video stays opt-in.\n\nIn the project's `e2e.config.ts`, construct the chosen provider's AI SDK model under `agents.default.model`, following the installed framework's types. The provider reads its local key; a key alone does not configure a model. Never copy a user's provider key into a monitor manifest or use an operator's account key.\n\nMix exact assertions with selected `agent.act`, `agent.assert`, `agent.waitFor` and schema-bound `agent.extract` calls. AI operations may transmit screen content to the provider and incur cost; preserve the user's provider/call authorization. Step-level `maxModelCalls` is not a whole-run spending limit. Hosted connection/broker/budget support is separate and must be discovered from actual capabilities rather than assumed from a local run.\n\n## Protected product requests\n\nFor protected product operations, use monitor init --template protected-agent-outcome --request-policy-file POLICY.json --project-id UUID --environment-id UUID --file monitor.json. The public policy contains connections with id, canonical HTTPS origin and httpAuth references (targetId, credentialId, credentialRevision); operations with id, connection, method, path, optional static body, responsePointers and maxCalls; and budget.calls. Paths are fixed absolute paths with at most one whole {resourceId} UUID segment. Static JSON bodies may use only exact string leaves {{resourceId}}. Callers cannot choose URLs, methods, headers, bodies, query parameters or UUIDs. GET permits at most three calls, POST and DELETE one; DELETE requires the UUID path and POST must use the run identity. Limits are four connections, eight operations and eight total calls.\n\nThe protected starter requires submit POST, observe GET (three reads), cleanup DELETE, a five-call budget and response pointers /id, /correlationId, /title, /completed. Configure the static submission body to create a note with the parent-generated UUID in both id and correlationId, title Waitcher outcome check, and completed true. The optional #waitcher/requests SDK exposes requestOperation and requestResourceId. Responses contain status and a data map keyed by configured JSON pointers. The script never trusts the agent reply as proof of resulting state, never retries the action, and only cleans up independently proven run-owned state.\n\nLocal execution uses the existing --http-credentials-file private map: schemaVersion 1 and credentials entries with targetId, credentialId, credentialRevision, origin, header and credentialFile. Header is Authorization or X-Api-Key; its raw value stays in a separate private regular file. Map and key files require mode600 and exact reference/revision/origin matches. Keys stay in the CLI parent, never script, manifest, CLI arguments or custom environment. No account, app or AI provider is required locally. Keep request-runtime.mjs with the complete CLI package. For source projects use scriptFile, monitor build, then run local --file; standalone project mode does not inject the protected helper. Hosted use requires explicit capability and isolated execution even for administrators. Combined AI or browser-state bindings need their independent authority. Inspect request-usage.json, scenario and native reports. Caught budget errors, uncertain dispatch and unfinished calls cannot establish a healthy result; never replay mutations automatically.\n\nScenario request associations are optional recorded evidence. The request helper automatically records each issued request UUID on its originating phase. In a verify phase, call `scenario.referenceRequest(response.requestId)` for a request from an earlier completed observe phase in the same scenario; use the validated response envelope UUID, never an ID from response data. The protected starter references its last independent observation before asserting the business state. Read associations with `run scenarios`; `run diagnose` joins them to this run's request records and labels each ID `matched`, `not-found` or `unavailable`. These are script-reported phase associations. A matching controller row proves accounting correspondence, not the correctness of a phase or business outcome. Local matches remain local helper reports. Older evidence without association fields is not recorded, rather than an empty verified list. UNKNOWN requests remain charged and incomplete; no association authorizes mutation replay.\n";
|
|
62766
|
+
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.107. The complete CLI package ships model-client.mjs and notices; copying only cli.mjs is insufficient for bound AI execution.\n\nThe local manifest runner keeps the provider key in its parent and passes a temporary loopback grant to the test. It uses the hosted transport and per-run budget/outcome rules, but no hosted account/day ledger. Read model-usage.json as well as the native report: caught provider/budget failures may leave a native passed test while Waitcher correctly records error. Unknown usage stays reserved, SDK retries count separately, and local success does not verify hosted enablement or key freshness. Provider keys are not forwarded to the child, and literal temporary broker tokens are redacted from normal text evidence; trusted local code can read its filesystem and is not a sandbox. Traces default on, video stays opt-in.\n\nIn the project's `e2e.config.ts`, construct the chosen provider's AI SDK model under `agents.default.model`, following the installed framework's types. The provider reads its local key; a key alone does not configure a model. Never copy a user's provider key into a monitor manifest or use an operator's account key.\n\nMix exact assertions with selected `agent.act`, `agent.assert`, `agent.waitFor` and schema-bound `agent.extract` calls. AI operations may transmit screen content to the provider and incur cost; preserve the user's provider/call authorization. Step-level `maxModelCalls` is not a whole-run spending limit. Hosted connection/broker/budget support is separate and must be discovered from actual capabilities rather than assumed from a local run.\n\n## Protected product requests\n\nFor protected product operations, use monitor init --template protected-agent-outcome --request-policy-file POLICY.json --project-id UUID --environment-id UUID --file monitor.json. The public policy contains connections with id, canonical HTTPS origin and httpAuth references (targetId, credentialId, credentialRevision); operations with id, connection, method, path, optional static body, responsePointers and maxCalls; and budget.calls. Paths are fixed absolute paths with at most one whole {resourceId} UUID segment. Static JSON bodies may use only exact string leaves {{resourceId}}. Callers cannot choose URLs, methods, headers, bodies, query parameters or UUIDs. GET permits at most three calls, POST and DELETE one; DELETE requires the UUID path and POST must use the run identity. Limits are four connections, eight operations and eight total calls.\n\nThe protected starter requires submit POST, observe GET (three reads), cleanup DELETE, a five-call budget and response pointers /id, /correlationId, /title, /completed. Configure the static submission body to create a note with the parent-generated UUID in both id and correlationId, title Waitcher outcome check, and completed true. The optional #waitcher/requests SDK exposes requestOperation and requestResourceId. Responses contain status and a data map keyed by configured JSON pointers. The script never trusts the agent reply as proof of resulting state, never retries the action, and only cleans up independently proven run-owned state.\n\nLocal execution uses the existing --http-credentials-file private map: schemaVersion 1 and credentials entries with targetId, credentialId, credentialRevision, origin, header and credentialFile. Header is 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";
|
|
61523
62767
|
|
|
61524
62768
|
// ../../skills/waitcher/references/deploy.md
|
|
61525
62769
|
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@0.21.1`, `@e2e-dev/web@0.15.1` (browser) and `esbuild@0.28.2` installed exactly; `waitcher runtime install` sets them up and later upgrades them (ask before `--yes`). 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 export the same `CHECK_*` variables locally (never in files) or skip `--verify` for that monitor and rely on `--smoke`.\n\nListed values of at least 6 characters appear as `<secret:CHECK_NAME>` in reports, traces and logs; screenshots, video and transformed values are not masked. For a password or token typed into a page, prefer `fill(secrets.get("CHECK_NAME"))` (`import { secrets } from "e2e"`) over `process.env`: the value stays out of the test code and the run refuses `app.screenshot()` after that fill, so take screenshots before it or drop them. Read `process.env.CHECK_NAME` for values the script sends itself, such as API headers. Never log a value or assert on it.\n\n## Adopting existing monitors\n\nWhen a plan warns `ADOPTION_CANDIDATE`, an existing unmanaged monitor looks like the entry. Show it to the user (`waitcher monitor get --id ID`). If it is the same check, plan and apply with `--adopt KEY=MONITOR_ID`: it keeps its ID, history and pause state and takes the file\'s definition. Otherwise ignore the warning; apply creates a separate monitor.\n\n## Rollback\n\n`waitcher deploy list --project-id ID` shows deploys; `restorable:true` marks the latest 10 per environment. `waitcher deploy rollback --id DEPLOY_ID --dry-run` shows the plan, then run it with `--based-on`. Secrets are not rolled back. Tell the user to revert the repository too, or the next apply reintroduces the change.\n\n## CI\n\n`waitcher ci init [--env production] [--file waitcher.json]` writes `.github/workflows/waitcher.yml`: plan on pull requests, apply on pushes to the main branch. It installs the CLI from the server with a checksum and signs in with the `WAITCHER_TOKEN` repository secret. Create that token with read and write permissions (add run for `--smoke`) and `"projectId"` set to the project\'s ID (from `deploy plan`\'s `project.id`) using `waitcher token create`, so CI cannot touch other projects, and let the user store it with `gh secret set WAITCHER_TOKEN`. Signed in with a project token, read `authorization.projectName` from `waitcher auth status` and use it as `waitcher.json`\'s `project` (`config init --project-name NAME`); such a token changes monitors only through `deploy apply`, so do not try `monitor apply`. Set the `WAITCHER_SERVER` repository variable for a non-default server.\n';
|
|
61526
62770
|
|
|
61527
62771
|
// ../../skills/waitcher/references/diagnosis.md
|
|
61528
|
-
var diagnosis_default =
|
|
62772
|
+
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';
|
|
61529
62773
|
|
|
61530
62774
|
// ../../skills/waitcher/references/optional-capabilities.md
|
|
61531
|
-
var optional_capabilities_default = '# Optional capabilities\n\nRead only when capabilities report the feature and the user needs it: visual baselines, signed-in browser identities, verified HTTP credentials and invocation budgets. AI endpoints, agent outcome checks, model steps and protected requests are in [ai-and-agents](ai-and-agents.md).\n\n## Optional visual checks\n\nDiscover `features.visual` for authoring and `features.visualReview` for baseline inspection; `features.isolatedVisual` says personal captures run in the hosted runner. A visual monitor counts as one of the plan\'s script monitors and each capture as a script run; `limits.visual.minInterval` is the shortest interval (2 hours on the free plan, 30 minutes otherwise). In a repository, add a `waitcher.json` entry such as `{ "key": "home-look", "type": "visual", "path": "/" }` with an optional `visual` block (page/element checkpoint, viewport, readiness, masks, thresholds) and deploy it like any other monitor; with `--smoke` the first capture is reported as `baseline_review` with the commands that show and approve it. For one monitor outside a repository, start with `monitor init --type visual --target https://product.example --file visual.json`, then `monitor validate --file visual.json` and `monitor apply --file visual.json --dry-run`. Apply paused; an authorized `run start --id ID --wait` is a separate action. User guide: https://waitcher.dev/docs/visual.md.\n\nFor a screen behind a sign-in or a few clicks, assert it inside a `browser` test instead: `await expect(screen).toHaveScreenshot(\'dashboard.png\')` (options `threshold`, `maxDiffPixels`, `maxDiffPixelRatio`, `mask`). Do not commit snapshot PNGs or pass `--update-snapshots`: Waitcher keeps the baselines. The first hosted run of each screenshot ends as `error` "First capture of NAME: approve it as the baseline"; inspect it with `visual list --monitor-id ID` and `visual image`, then `visual approve --id COMPARISON_ID --expected-revision 0`, one screenshot per run. Later runs fail with a comparison when a screenshot differs. Local runs (`run local`, `--verify`) compare against a capture from the same run, so a local pass says nothing about the look. Visual monitors accept no script, model binding, session identity or custom request credential. Fixed visual baseline execution is not supported by `run local`; local API/browser script evidence does not establish a visual baseline.\n\nA scheduled run never creates a baseline. Set the first one, or accept an intended change, with one run: `run start --id MONITOR_ID --update-baselines --wait` captures and approves it (write access); then inspect it with `visual list` and `visual image`. The alternative is to run normally and approve the capture. Until a baseline exists a run ends as `error` "First capture of NAME"; that is missing coverage, not a product failure. Every later run of a visual monitor keeps its comparison, passing runs included. Inspect `visual list`, `visual get --id COMPARISON_ID`, `visual heads --id MONITOR_ID`, `visual artifacts --id COMPARISON_ID` and `visual image --id COMPARISON_ID --role candidate|original|diff --file NEW_PRIVATE_PATH`. Review actual images and metrics before an authorized `visual approve --id COMPARISON_ID --expected-revision SELECTED_REVISION`; an initial selection uses 0. Restore only a reviewed retained baseline with `visual restore --id HEAD_ID --baseline-id BASELINE_ID --expected-revision CURRENT_HEAD_REVISION`. Stale decisions conflict: reload instead of retrying or changing revisions blindly. Approval preserves the historical result. Changed capture fingerprints need their own baseline. Foreign-owner/read-only refusals are boundaries, not reasons to switch credentials. Screenshots are private evidence; masks cover selected pixels only. Use actual `visual` and `run` help for current flags and capabilities.\n\n## Optional browser test-account identity\n\nFor a signed-in browser journey, discover hosted `features.browserIdentities` before configuring `identity create/rotate/enable/disable/delete`. Supply bounded cookies/localStorage through a private `--state-file`; metadata is scoped to one verified exact origin, project/environment and explicit expiry. State is write-only and cannot be exported. New identities default disabled; enable explicitly and bind the resulting current `{identityId, revision}` under `browserIdentity` in a version-2 browser manifest with explicit context. Rename, state replacement and enable/disable advance revisions; inspect current metadata and deliberately rebind rather than silently upgrading. After an uncertain write inspect metadata before retrying. No running Chrome profile is imported.\n\nRun the same manifest account-free with `run local --file MONITOR --runtime RUNTIME --browser-identities-file PRIVATE_MAP`. The map is `{schemaVersion:1,identities:[{identityId,revision,projectId,environmentId,origin,expiresAt,stateFile}]}`; state paths resolve relative to the map. Both map/state are private regular JSON files (chmod 600), no symlinks/hard links or inline state. Exact IDs/revision/scope/origin and bounded future expiry must match. Local mappings do not attest hosted target verification or revocation. The optional model map remains separate. Hosted identity-backed runs use the isolated lane for all owners; local code remains trusted. The selected script receives its own session and signed-in page content can reach private evidence or optional AI providers. Never promise pixel/encoded-secret masking. Use dedicated test accounts and inspect coverage errors after expiry/revocation before repeating a possibly completed action.\n\n## Verified HTTP credentials\n\nFor an authenticated HTTP or AI endpoint, use the user\'s owned verified HTTPS origin and an `httpAuth` reference (`targetId`, `credentialId`, `credentialRevision`). Check `features.httpTargets` before hosted configuration. Create/renew a target challenge with `target create` or `target challenge`, writing it to a new private `--output`; never print the token. The user publishes the supplied proof at `/.well-known/waitcher-verification.txt`, then `target verify` checks it without credentials. Verification expires after 24 hours and must be renewed. An origin excludes paths, query and fragments and is immutable.\n\nUse `target credential create/rotate` with non-secret metadata JSON plus `--credential-file` (mode 600) or `--credential-stdin`. Headers are limited to `Authorization` or `X-Api-Key`; values are complete single-line ASCII header values up to 4096 bytes. For Bearer auth, include the `Bearer ` prefix in the private value. Keys are write-only and encrypted on the server. The monitor and export retain references only. Rotation advances the credential revision; update the monitor binding explicitly. Disabled, expired, foreign or stale bindings fail without forwarding a request. Authenticated redirects are never followed.\n\nFor local execution without the app or account, pass `run local --file monitor.json --http-credentials-file private/http-map.json`. The private map is `{schemaVersion:1,credentials:[{targetId,credentialId,credentialRevision,origin,header,credentialFile}]}` and the referenced private file contains the raw header value. Paths resolve relative to the map. Never inline a key or reuse the CLI\'s own account cookie/token as a target credential. The local resolver requires exactly matching IDs, revision and canonical origin, and the shared runner enforces the single supported header and redirect policy. Local mapping does not prove that the hosted target is still verified or its key current. Keep the same manifest as the hosted monitor; only local key resolution differs. HTTP local checks need no E2E runtime. Use explicit user authorization for POST fixtures that change state.\n\n## Hosted endpoint invocation budgets\n\nBefore running dedicated AI endpoints or HTTP checks with `httpAuth`, read `account invocations` for the account/monitor UTC-day counters and limits. The manifest accepts `requestBudget: {dailyInvocations: N}` (default 50, maximum 1,000). Configure the owner cap with `account budget --daily-invocations N --expected-revision CURRENT_REVISION` only when authorized; personal accounts cap at 200, administrators at 5,000, and the controller also has a global 5,000 cap. Validate/apply/export do not charge calls.\n\n`INVOCATION_BUDGET_EXHAUSTED` is a coverage error: no request was dispatched and no product incident is created. Do not automatically retry or raise a limit to bypass it. Completed and uncertain dispatched calls consume budget, independent of product success or worker-reported usage. Local execution needs no account, preserves the setting and makes at most one endpoint call per fixture case, but does not enforce or consume the hosted daily ledger. After backup restore, `window.restoreHeld` blocks these checks until the next UTC reset because snapshot counters may be stale; do not bypass the hold by raising caps. These are request counts, separate from model-broker token/call caps and downstream provider spending. Inspect `account invocations` and the current `account` help for the hosted accounting contract.\n\n## Agent checks\n\nWhen `features.agentChecks` is true, an `api` entry may carry an `agent` block: Claude Code works on `task` in a sandbox, then the entry\'s script verifies the product\'s state ([guide](https://waitcher.dev/docs/agent-checks.md)). It needs 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## 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';
|
|
62775
|
+
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';
|
|
61532
62776
|
|
|
61533
62777
|
// ../../skills/waitcher/agents/openai.yaml
|
|
61534
62778
|
var openai_default = 'interface:\n display_name: "Waitcher"\n short_description: "Deploy monitoring from a repository and inspect evidence"\n default_prompt: "Use $waitcher to set up monitoring for this repository: pick the critical journeys, verify them locally and deploy them paused through a reviewed plan."\n';
|
|
@@ -61568,8 +62812,8 @@ async function installSkill(options) {
|
|
|
61568
62812
|
await mkdir8(join13(directory, "references"), { recursive: true });
|
|
61569
62813
|
await mkdir8(join13(directory, "agents"), { recursive: true });
|
|
61570
62814
|
await writeFile9(join13(directory, "SKILL.md"), SKILL_default);
|
|
61571
|
-
for (const [name5,
|
|
61572
|
-
await writeFile9(join13(directory, "references", name5),
|
|
62815
|
+
for (const [name5, text4] of Object.entries(references))
|
|
62816
|
+
await writeFile9(join13(directory, "references", name5), text4);
|
|
61573
62817
|
await writeFile9(join13(directory, "agents/openai.yaml"), openai_default);
|
|
61574
62818
|
await writeFile9(
|
|
61575
62819
|
join13(directory, MARKER),
|
|
@@ -61693,7 +62937,7 @@ async function doctor(options) {
|
|
|
61693
62937
|
for (const home of skillHomes) {
|
|
61694
62938
|
if (!await exists(join14(home, "SKILL.md"))) continue;
|
|
61695
62939
|
installed.push(home);
|
|
61696
|
-
const marker2 = await readFile9(join14(home, ".waitcher-skill.json"), "utf8").then((
|
|
62940
|
+
const marker2 = await readFile9(join14(home, ".waitcher-skill.json"), "utf8").then((text4) => JSON.parse(text4)).catch(() => null);
|
|
61697
62941
|
if (marker2 && marker2.version !== options.version) stale.push(home);
|
|
61698
62942
|
}
|
|
61699
62943
|
const install = root === process.cwd() ? "waitcher skill install" : `waitcher skill install --path ${join14(root, ".claude", "skills")}`;
|
|
@@ -61955,12 +63199,31 @@ var accountActivityQuerySchema = external_exports.object({
|
|
|
61955
63199
|
}).strict();
|
|
61956
63200
|
|
|
61957
63201
|
// ../../src/contracts/alerts.ts
|
|
63202
|
+
var channelKinds = [
|
|
63203
|
+
"account-email",
|
|
63204
|
+
"slack",
|
|
63205
|
+
"webhook",
|
|
63206
|
+
"email",
|
|
63207
|
+
"pagerduty",
|
|
63208
|
+
"discord",
|
|
63209
|
+
"teams",
|
|
63210
|
+
"telegram",
|
|
63211
|
+
"ntfy"
|
|
63212
|
+
];
|
|
63213
|
+
var regionalKinds = ["pagerduty"];
|
|
63214
|
+
var TELEGRAM_CHAT_ID = /^(-?\d{1,20}|@[A-Za-z][A-Za-z0-9_]{4,31})$/;
|
|
61958
63215
|
var channelSchema = external_exports.object({
|
|
61959
63216
|
name: external_exports.string().trim().min(1).max(100),
|
|
61960
|
-
kind: external_exports.enum(
|
|
63217
|
+
kind: external_exports.enum(channelKinds),
|
|
61961
63218
|
credential: external_exports.string().trim().min(1).max(8192).optional(),
|
|
61962
63219
|
from: external_exports.string().trim().max(254).default(""),
|
|
61963
63220
|
to: external_exports.string().trim().max(254).default(""),
|
|
63221
|
+
region: external_exports.enum(["us", "eu"]).optional(),
|
|
63222
|
+
// Telegram only: where the bot posts.
|
|
63223
|
+
chatId: external_exports.string().trim().max(40).optional(),
|
|
63224
|
+
// ntfy only, write-only like the credential: a bearer access token
|
|
63225
|
+
// (tk_...) for a protected topic.
|
|
63226
|
+
accessToken: external_exports.string().trim().min(1).max(200).optional(),
|
|
61964
63227
|
enabled: external_exports.boolean().default(false),
|
|
61965
63228
|
expectedRevision: external_exports.number().int().positive().optional()
|
|
61966
63229
|
}).strict().superRefine((value2, ctx) => {
|
|
@@ -61979,6 +63242,39 @@ var channelSchema = external_exports.object({
|
|
|
61979
63242
|
path: ["kind"],
|
|
61980
63243
|
message: value2.kind === "account-email" ? "Account email always goes to your verified sign-in address" : "Email addresses apply only to email channels"
|
|
61981
63244
|
});
|
|
63245
|
+
if (value2.region && !regionalKinds.includes(value2.kind))
|
|
63246
|
+
ctx.addIssue({
|
|
63247
|
+
code: "custom",
|
|
63248
|
+
path: ["region"],
|
|
63249
|
+
message: "A region applies only to PagerDuty channels"
|
|
63250
|
+
});
|
|
63251
|
+
if (value2.kind === "telegram") {
|
|
63252
|
+
if (value2.chatId !== void 0 && !TELEGRAM_CHAT_ID.test(value2.chatId))
|
|
63253
|
+
ctx.addIssue({
|
|
63254
|
+
code: "custom",
|
|
63255
|
+
path: ["chatId"],
|
|
63256
|
+
message: "Use a numeric chat id such as -1001234567890 or a public channel such as @team_alerts"
|
|
63257
|
+
});
|
|
63258
|
+
} else if (value2.chatId !== void 0)
|
|
63259
|
+
ctx.addIssue({
|
|
63260
|
+
code: "custom",
|
|
63261
|
+
path: ["chatId"],
|
|
63262
|
+
message: "A chat id applies only to Telegram channels"
|
|
63263
|
+
});
|
|
63264
|
+
if (value2.accessToken !== void 0) {
|
|
63265
|
+
if (value2.kind !== "ntfy")
|
|
63266
|
+
ctx.addIssue({
|
|
63267
|
+
code: "custom",
|
|
63268
|
+
path: ["accessToken"],
|
|
63269
|
+
message: "An access token applies only to ntfy channels"
|
|
63270
|
+
});
|
|
63271
|
+
else if (!/^tk_[A-Za-z0-9]{20,64}$/.test(value2.accessToken))
|
|
63272
|
+
ctx.addIssue({
|
|
63273
|
+
code: "custom",
|
|
63274
|
+
path: ["accessToken"],
|
|
63275
|
+
message: "Use an ntfy access token (tk_...)"
|
|
63276
|
+
});
|
|
63277
|
+
}
|
|
61982
63278
|
if (value2.kind === "account-email" && value2.credential)
|
|
61983
63279
|
ctx.addIssue({
|
|
61984
63280
|
code: "custom",
|
|
@@ -62114,8 +63410,8 @@ var incidentEditSchema = external_exports.object({
|
|
|
62114
63410
|
// src/access.ts
|
|
62115
63411
|
import { lstat as lstat10, open as open16, unlink as unlink3 } from "node:fs/promises";
|
|
62116
63412
|
import { dirname as dirname15, resolve as resolve16 } from "node:path";
|
|
62117
|
-
function accessTokenInput(
|
|
62118
|
-
let token =
|
|
63413
|
+
function accessTokenInput(text4) {
|
|
63414
|
+
let token = text4.trim();
|
|
62119
63415
|
if (token.startsWith("{")) {
|
|
62120
63416
|
try {
|
|
62121
63417
|
token = JSON.parse(token).token;
|
|
@@ -62221,10 +63517,10 @@ async function readPrivate(path2) {
|
|
|
62221
63517
|
}
|
|
62222
63518
|
async function loadSession(server) {
|
|
62223
63519
|
const path2 = sessionPath(server);
|
|
62224
|
-
let
|
|
63520
|
+
let text4;
|
|
62225
63521
|
try {
|
|
62226
63522
|
await privatePath(dirname16(path2), true);
|
|
62227
|
-
|
|
63523
|
+
text4 = await readPrivate(path2);
|
|
62228
63524
|
} catch (cause) {
|
|
62229
63525
|
const error62 = asError(cause);
|
|
62230
63526
|
if (error62.code === "ENOENT")
|
|
@@ -62235,7 +63531,7 @@ async function loadSession(server) {
|
|
|
62235
63531
|
}
|
|
62236
63532
|
let session;
|
|
62237
63533
|
try {
|
|
62238
|
-
session = JSON.parse(
|
|
63534
|
+
session = JSON.parse(text4);
|
|
62239
63535
|
} catch {
|
|
62240
63536
|
throw new Error("Saved session is unreadable. Run auth login again.");
|
|
62241
63537
|
}
|
|
@@ -62322,6 +63618,41 @@ async function forgetSession(server) {
|
|
|
62322
63618
|
if (error62.code !== "ENOENT") throw error62;
|
|
62323
63619
|
}
|
|
62324
63620
|
}
|
|
63621
|
+
var workspacePath = (server) => sessionPath(server).replace(/\.json$/, ".workspace.json");
|
|
63622
|
+
async function loadWorkspace(server) {
|
|
63623
|
+
try {
|
|
63624
|
+
const value2 = JSON.parse(await readPrivate(workspacePath(server)));
|
|
63625
|
+
return value2?.server === server && typeof value2.workspace === "string" && /^team:[a-f0-9]{24}$/.test(value2.workspace) ? value2.workspace : null;
|
|
63626
|
+
} catch {
|
|
63627
|
+
return null;
|
|
63628
|
+
}
|
|
63629
|
+
}
|
|
63630
|
+
async function saveWorkspace(server, workspace) {
|
|
63631
|
+
const path2 = workspacePath(server);
|
|
63632
|
+
if (!workspace) {
|
|
63633
|
+
await unlink4(path2).catch((error62) => {
|
|
63634
|
+
if (error62.code !== "ENOENT") throw error62;
|
|
63635
|
+
});
|
|
63636
|
+
return;
|
|
63637
|
+
}
|
|
63638
|
+
const directory = dirname16(path2);
|
|
63639
|
+
await mkdir10(directory, { recursive: true, mode: 448 });
|
|
63640
|
+
await privatePath(directory, true);
|
|
63641
|
+
const temp = join15(directory, `.workspace-${randomUUID7()}.tmp`);
|
|
63642
|
+
try {
|
|
63643
|
+
const file2 = await open17(temp, "wx", 384);
|
|
63644
|
+
try {
|
|
63645
|
+
await file2.writeFile(JSON.stringify({ server, workspace }));
|
|
63646
|
+
} finally {
|
|
63647
|
+
await file2.close();
|
|
63648
|
+
}
|
|
63649
|
+
await rename(temp, path2);
|
|
63650
|
+
} finally {
|
|
63651
|
+
await unlink4(temp).catch((error62) => {
|
|
63652
|
+
if (error62.code !== "ENOENT") throw error62;
|
|
63653
|
+
});
|
|
63654
|
+
}
|
|
63655
|
+
}
|
|
62325
63656
|
|
|
62326
63657
|
// src/oauth.ts
|
|
62327
63658
|
var fail = (message) => new ServiceError(message, "AUTH_REQUIRED", 3);
|
|
@@ -62574,13 +63905,35 @@ Authentication
|
|
|
62574
63905
|
|
|
62575
63906
|
Plans and billing
|
|
62576
63907
|
account billing Plan, limits and subscription status
|
|
62577
|
-
account upgrade [--plan pro|business] [--yearly] [--trial]
|
|
62578
|
-
Stripe Checkout URL for a paid plan (default pro
|
|
62579
|
-
14 days, once, no card); a
|
|
63908
|
+
account upgrade [--plan pro|business|team] [--yearly] [--trial]
|
|
63909
|
+
Stripe Checkout URL for a paid plan (default pro, or team in a
|
|
63910
|
+
team workspace; --trial: pro, 14 days, once, no card); a
|
|
63911
|
+
subscribed account moves in place
|
|
62580
63912
|
account billing-portal Stripe portal URL to change payment or cancel
|
|
62581
63913
|
The plan changes only when Stripe confirms the payment, never on the return page.
|
|
62582
63914
|
Billing appears when the server reports features.billing.
|
|
62583
63915
|
|
|
63916
|
+
Teams (when the server reports features.teams)
|
|
63917
|
+
workspace list Your personal workspace, your teams with your role, and
|
|
63918
|
+
invitations to your verified email
|
|
63919
|
+
workspace create --name NAME Create a team you own (at most 3); it starts on starter
|
|
63920
|
+
workspace use --id TEAM_ID|personal Act in that team from now on, on this server
|
|
63921
|
+
workspace join --id INVITE_ID Accept an invitation (signed in with the invited email)
|
|
63922
|
+
workspace decline --id INVITE_ID Decline an invitation
|
|
63923
|
+
workspace rename --name NAME --expected-revision N
|
|
63924
|
+
workspace leave --yes Leave the active team; the last owner cannot
|
|
63925
|
+
member list Members, roles and pending invitations of the active team
|
|
63926
|
+
member invite --email ADDRESS [--role member|admin|owner]
|
|
63927
|
+
Owners and admins; the email expires in 7 days
|
|
63928
|
+
member cancel-invite --id INVITE_ID
|
|
63929
|
+
member role --member MEMBER_ID --role owner|admin|member Owners only
|
|
63930
|
+
member remove --member MEMBER_ID --yes Revokes the tokens they created in the team
|
|
63931
|
+
--workspace TEAM_ID|personal on any command acts there once. Monitors, projects,
|
|
63932
|
+
alerts, status pages, tokens, plan, export and deletion all follow the active
|
|
63933
|
+
workspace; account deletion with a team active deletes the team (owners only).
|
|
63934
|
+
Members cannot change credentials, settings, billing or members. A token is bound
|
|
63935
|
+
to the workspace it was created in and stops when its creator leaves.
|
|
63936
|
+
|
|
62584
63937
|
Account data
|
|
62585
63938
|
account deletion Review current deletion revision and impact
|
|
62586
63939
|
account deletion-prepare --expected-revision N --output NEW_PRIVATE_RECEIPT
|
|
@@ -62620,10 +63973,10 @@ Capabilities
|
|
|
62620
63973
|
system capabilities Show account features, limits and contract versions
|
|
62621
63974
|
system diagnostics Operator resource, queue and storage diagnostics
|
|
62622
63975
|
system plans Administrator: plan profiles and accounts not on starter
|
|
62623
|
-
system plan --owner clerk:USER_ID --plan starter|pilot
|
|
63976
|
+
system plan --owner clerk:USER_ID|team:ID --plan starter|pilot|pro|business|team
|
|
62624
63977
|
Administrator: assign a plan; takes effect immediately
|
|
62625
63978
|
system suspensions Administrator: accounts whose checks are suspended
|
|
62626
|
-
system suspend --owner clerk:USER_ID --reason TEXT
|
|
63979
|
+
system suspend --owner clerk:USER_ID|team:ID --reason TEXT
|
|
62627
63980
|
Administrator: stop every check of one account; data stays
|
|
62628
63981
|
system unsuspend --owner clerk:USER_ID Administrator: lift a suspension
|
|
62629
63982
|
|
|
@@ -62692,14 +64045,14 @@ Repository deploys (waitcher.json)
|
|
|
62692
64045
|
Keys identify monitors; renaming a key replaces the monitor and its history.
|
|
62693
64046
|
The repository owns definitions; the server owns pause and resume. New monitors start
|
|
62694
64047
|
paused unless --activate-new. Undeclared monitors are reported and deleted only with --prune.
|
|
62695
|
-
Deploys accept http, certificate, heartbeat, api, browser and
|
|
64048
|
+
Deploys accept http, certificate, heartbeat, api, browser, visual, mcp, tcp and dns (first --smoke
|
|
62696
64049
|
capture: baseline_review, see help visual). Script monitors name an
|
|
62697
64050
|
entry file; the CLI builds it like monitor build (project needs e2e@${RUNTIME_PINS.e2e},
|
|
62698
64051
|
@e2e-dev/web@${RUNTIME_PINS["@e2e-dev/web"]} for browser, esbuild@${RUNTIME_PINS.esbuild}). Plans and results list issues with
|
|
62699
64052
|
code, path, monitor key and hint; ok:false exits 2. --based-on refuses a stale plan.
|
|
62700
64053
|
|
|
62701
64054
|
Monitor configuration
|
|
62702
|
-
monitor init --file PATH [--type http|certificate|api|browser|visual|heartbeat|ai] [--target URL]
|
|
64055
|
+
monitor init --file PATH [--type http|certificate|api|browser|visual|heartbeat|ai|mcp|tcp|dns] [--target URL]
|
|
62703
64056
|
Write a paused example; never overwrite
|
|
62704
64057
|
api and browser also write PATH.e2e.ts next to it
|
|
62705
64058
|
monitor init --template agent-outcome --file PATH [--target API_BASE]
|
|
@@ -62726,6 +64079,11 @@ Monitor configuration
|
|
|
62726
64079
|
monitor pause --id ID Disable scheduled executions
|
|
62727
64080
|
monitor resume --id ID Enable scheduled executions
|
|
62728
64081
|
monitor delete --id ID --yes Permanently remove monitor and history
|
|
64082
|
+
Second region (features.secondRegion): before a failing HTTP or certificate check
|
|
64083
|
+
opens an incident, Waitcher repeats it once from North America or Asia-Pacific; a pass
|
|
64084
|
+
there means no incident. "secondRegion": false in a definition or waitcher.json entry
|
|
64085
|
+
opts a monitor out. Checks with httpAuth, custom headers, a body or a write method are
|
|
64086
|
+
not repeated (https://waitcher.dev/docs/results.md#second-region).
|
|
62729
64087
|
|
|
62730
64088
|
Executions and reports
|
|
62731
64089
|
run scenarios --id RUN_ID [--json]
|
|
@@ -62737,8 +64095,7 @@ Executions and reports
|
|
|
62737
64095
|
[--connections-file PRIVATE_JSON] Scoped local AI keys; no login
|
|
62738
64096
|
run local --project E2E_PROJECT [--output DIR] [--video] [--timeout 60]
|
|
62739
64097
|
Run trusted local tests without login or API access
|
|
62740
|
-
|
|
62741
|
-
Project output must stay inside the E2E project
|
|
64098
|
+
Fresh output per run inside the project; video opt-in
|
|
62742
64099
|
run start --id MONITOR_ID [--wait [--brief]] [--timeout 60] [--update-baselines]
|
|
62743
64100
|
A finished run prints status, duration, message and a
|
|
62744
64101
|
report link (SERVER/app#run/RUN_ID) first;
|
|
@@ -62749,11 +64106,14 @@ Executions and reports
|
|
|
62749
64106
|
artifact get --id RUN_ID --path PATH --file OUTPUT
|
|
62750
64107
|
Download checksum-verified evidence; no overwrite
|
|
62751
64108
|
run status --id RUN_ID
|
|
62752
|
-
run trace --id RUN_ID What the run did: HTTP hops
|
|
62753
|
-
|
|
62754
|
-
|
|
64109
|
+
run trace --id RUN_ID What the run did: HTTP hops, certificate,
|
|
64110
|
+
TCP/DNS, e2e steps, logs, screenshots,
|
|
64111
|
+
fetch calls, secondRegion
|
|
62755
64112
|
run wait --id RUN_ID [--timeout 60] [--brief] Bounded wait (1 to 900 seconds)
|
|
62756
64113
|
report get [--days 1|7|14] [--demo]
|
|
64114
|
+
report history [--file PATH] 13 months of daily availability, p50, p95;
|
|
64115
|
+
--file writes a new CSV
|
|
64116
|
+
monitor history --id ID One monitor's 13 months
|
|
62757
64117
|
incident list [--demo]
|
|
62758
64118
|
|
|
62759
64119
|
Visual checks and baseline review (features.visual, features.visualReview; decisions
|
|
@@ -62807,17 +64167,50 @@ Verified HTTP targets and write-only request credentials (features.httpTargets)
|
|
|
62807
64167
|
target credential disable --id ID --expected-revision N
|
|
62808
64168
|
target credential delete --id ID --expected-revision N --yes
|
|
62809
64169
|
Target JSON: {"name":"Product","origin":"https://product.example"}.
|
|
62810
|
-
Credential JSON: {"targetId":"UUID","name":"API key","header":"X-Api-Key"}.
|
|
62811
|
-
|
|
64170
|
+
Credential JSON: {"targetId":"UUID","name":"API key","header":"X-Api-Key"}; header is any name your API reads (X-Api-Key, Authorization, X-Auth-Token, ...), not Host, Cookie or transport headers.
|
|
64171
|
+
Basic auth: header Authorization, private value "Basic " + base64(user:password).
|
|
64172
|
+
OAuth 2: {"targetId":"UUID","name":"Product OAuth","kind":"oauth2","oauth":{"grant":"client_credentials","tokenUrl":"https://auth.example.com/oauth/token","clientId":"ID","scope":"read","clientAuth":"post"}}.
|
|
64173
|
+
The private value is the client secret; for grant refresh_token it is one JSON line {"refreshToken":"...","clientSecret":"..."} (clientSecret optional).
|
|
64174
|
+
Waitcher mints, caches and refreshes the Bearer token. Hosted runs only.
|
|
64175
|
+
Challenge output needs a new file in a private directory (700); token not printed.
|
|
62812
64176
|
Publish its proof at /.well-known/waitcher-verification.txt, then verify explicitly.
|
|
62813
64177
|
Proof expires after 15 minutes; verification lasts 24 hours. Redirects are refused.
|
|
62814
|
-
Keys
|
|
64178
|
+
Keys: one ASCII line up to 4096 characters, private file (600) or stdin.
|
|
62815
64179
|
Monitor httpAuth contains reference IDs/revision only; keys never appear in export.
|
|
62816
|
-
run local --file
|
|
64180
|
+
run local --file HTTP_AI_OR_MCP.json --http-credentials-file PRIVATE_MAP
|
|
62817
64181
|
Local map resolves reference IDs/revision/origin/header to private credentialFile.
|
|
62818
64182
|
Map schemaVersion 1, credentials:[{targetId,credentialId,credentialRevision,
|
|
62819
64183
|
origin,header,credentialFile}]. Paths resolve relative to map; no inline keys.
|
|
62820
64184
|
|
|
64185
|
+
MCP server monitoring (remote Streamable HTTP servers)
|
|
64186
|
+
monitor init --type mcp --target https://product.example/mcp --file mcp.json
|
|
64187
|
+
Locally without an account: waitcher run local --file mcp.json [--timeout 3..30]
|
|
64188
|
+
Each run: initialize, tools/list, optional tools/call, then the session is closed.
|
|
64189
|
+
monitor apply --file mcp.json Save paused; then monitor resume --id ID
|
|
64190
|
+
"mcp": {"expectTools":["search"],"toolCall":{"name":"search","arguments":{},
|
|
64191
|
+
"assertions":[{"path":"/content/0/type","operator":"equals","value":"text"}]}}
|
|
64192
|
+
Missing tools, JSON-RPC errors, isError results and failed assertions fail the check.
|
|
64193
|
+
Personal accounts: listing tools needs nothing extra; a toolCall needs verified
|
|
64194
|
+
httpAuth, an interval of at least 30 minutes and counts one daily invocation.
|
|
64195
|
+
Reports record steps, server name/version and tool names, never arguments or tool output.
|
|
64196
|
+
stdio servers, OAuth flows, resources and prompts are not checked
|
|
64197
|
+
(https://waitcher.dev/docs/mcp.md).
|
|
64198
|
+
|
|
64199
|
+
TCP and DNS monitoring (every account, at the plan's HTTP interval)
|
|
64200
|
+
monitor init --type tcp --file db.json Then set "target":"db.example.com:5432"
|
|
64201
|
+
monitor init --type dns --file mx.json Then set "target":"example.com"
|
|
64202
|
+
Locally without an account: waitcher run local --file db.json
|
|
64203
|
+
"tcp": {"banner":"SSH-2.0"} Optional text the server must send first (1 KB read);
|
|
64204
|
+
empty passes once the connection opens. Waitcher sends nothing.
|
|
64205
|
+
"dns": {"recordType":"A|AAAA|CNAME|MX|TXT","expected":["203.0.113.10"],
|
|
64206
|
+
"match":"includes|exact"} No expected values passes on any answer; MX may
|
|
64207
|
+
name the exchange alone or "10 mail.example.com". Asked of public resolvers.
|
|
64208
|
+
Targets must be public: a TCP host resolves once, every address must be public
|
|
64209
|
+
and the connection goes to the checked address. Timeout at most 15 seconds.
|
|
64210
|
+
NXDOMAIN, a missing record, a refused or timed out connection fail; a resolver
|
|
64211
|
+
that does not answer is an error. In waitcher.json a dns entry without a
|
|
64212
|
+
target checks the environment's baseUrl host (https://waitcher.dev/docs/network.md).
|
|
64213
|
+
|
|
62821
64214
|
AI product endpoint monitoring (administrator pilot; requires features.aiEndpoints)
|
|
62822
64215
|
monitor init --type ai --target https://product.example/ai --file ai.json
|
|
62823
64216
|
monitor validate --file ai.json Offline JSON fixture/assertion/schema validation
|
|
@@ -62899,10 +64292,14 @@ Alerts
|
|
|
62899
64292
|
alert channel list
|
|
62900
64293
|
alert channel save --file PATH [--id ID]
|
|
62901
64294
|
[--credential-file PATH | --credential-stdin]
|
|
64295
|
+
[--access-token-file PATH]
|
|
62902
64296
|
Kinds: account-email (no credential; Waitcher emails your
|
|
62903
64297
|
verified sign-in address, up to 50 per day; sign in with
|
|
62904
|
-
this CLI version first), slack,
|
|
62905
|
-
|
|
64298
|
+
this CLI version first), slack, discord, teams (a Teams
|
|
64299
|
+
Workflows URL), pagerduty (Events API v2 integration key),
|
|
64300
|
+
telegram (bot token; JSON "chatId"), ntfy (topic URL;
|
|
64301
|
+
--access-token-file for a protected topic), webhook,
|
|
64302
|
+
email (your own Resend key)
|
|
62906
64303
|
alert channel delete --id ID --yes
|
|
62907
64304
|
alert channel test --id ID --yes Sends a real notification; no monitor runs
|
|
62908
64305
|
alert maintenance list
|
|
@@ -62913,9 +64310,14 @@ Alerts
|
|
|
62913
64310
|
alert policy delete (--id ID | --project-id ID) --yes Use '*' for default routing
|
|
62914
64311
|
alert deliveries
|
|
62915
64312
|
alert attempts --id DELIVERY_ID
|
|
62916
|
-
Channel JSON: {"name":"Ops","kind":"slack","enabled":true}; email adds "from" and "to"
|
|
62917
|
-
|
|
62918
|
-
|
|
64313
|
+
Channel JSON: {"name":"Ops","kind":"slack","enabled":true}; email adds "from" and "to";
|
|
64314
|
+
pagerduty takes "region":"us"|"eu" (default us); telegram needs "chatId"
|
|
64315
|
+
(-100... or @channel).
|
|
64316
|
+
enabled defaults to false and test refuses a disabled channel. The webhook URL,
|
|
64317
|
+
integration key or Resend key is the credential: private file or stdin, never JSON.
|
|
64318
|
+
PagerDuty opens one alert per incident and resolves it on recovery; its test
|
|
64319
|
+
is a change event that pages nobody. Grafana IRM: use a webhook channel
|
|
64320
|
+
(https://waitcher.dev/docs/alerts.md#grafana-irm). Updates add
|
|
62919
64321
|
"expectedRevision":N (from channel list); omit the credential to keep it.
|
|
62920
64322
|
Policy JSON: {"monitorId":"*","channelIds":["CHANNEL_ID"],"events":["incident","recovered"],
|
|
62921
64323
|
"cooldownSeconds":0,"enabled":true,"expectedRevision":0}. Scope: "*" (account default),
|
|
@@ -62928,6 +64330,7 @@ Alerts
|
|
|
62928
64330
|
Shared options
|
|
62929
64331
|
--server URL HTTPS origin, or loopback HTTP for development
|
|
62930
64332
|
Default: WAITCHER_SERVER or https://waitcher.dev
|
|
64333
|
+
--workspace ID Act in a team (team:...) or personal, for this command only
|
|
62931
64334
|
--request-key KEY Recover a create, run start or channel test (16 to 100 characters)
|
|
62932
64335
|
Same account, operation and payload; retained for 24 hours
|
|
62933
64336
|
--json Structured JSON for run diagnose and run scenarios (others default to JSON)
|
|
@@ -63053,14 +64456,14 @@ function helpTopic(topic) {
|
|
|
63053
64456
|
const needle = topic.toLowerCase();
|
|
63054
64457
|
if (needle === "all") return help;
|
|
63055
64458
|
const word = new RegExp(`\\b${needle.replace(/[^a-z0-9-]/g, "")}\\b`);
|
|
63056
|
-
const
|
|
64459
|
+
const matches2 = sections.filter((section) => {
|
|
63057
64460
|
if (section === exitCodes) return false;
|
|
63058
64461
|
const [heading, ...lines] = section.split("\n");
|
|
63059
64462
|
return word.test(heading.toLowerCase()) || lines.some(
|
|
63060
64463
|
(line) => /^ {2}[a-z]/.test(line) && line.trimStart().startsWith(`${needle} `)
|
|
63061
64464
|
);
|
|
63062
64465
|
});
|
|
63063
|
-
return
|
|
64466
|
+
return matches2.length ? [intro, ...matches2, exitCodes].join("\n\n") + "\n" : `No help section matches "${topic}".
|
|
63064
64467
|
|
|
63065
64468
|
${overview()}`;
|
|
63066
64469
|
}
|
|
@@ -63091,55 +64494,8 @@ ${exitCodes}
|
|
|
63091
64494
|
`;
|
|
63092
64495
|
}
|
|
63093
64496
|
|
|
63094
|
-
// package.json
|
|
63095
|
-
var package_default = {
|
|
63096
|
-
name: "@waitcher/cli",
|
|
63097
|
-
version: "0.2.24",
|
|
63098
|
-
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
|
|
63099
|
-
license: "SEE LICENSE IN LICENSE.txt",
|
|
63100
|
-
author: "S\u0142awomir Radzymi\u0144ski",
|
|
63101
|
-
homepage: "https://waitcher.dev/docs/",
|
|
63102
|
-
repository: {
|
|
63103
|
-
type: "git",
|
|
63104
|
-
url: "git+https://github.com/slawekradzyminski/synthetic-watch.git",
|
|
63105
|
-
directory: "packages/cli"
|
|
63106
|
-
},
|
|
63107
|
-
keywords: [
|
|
63108
|
-
"monitoring",
|
|
63109
|
-
"synthetic-monitoring",
|
|
63110
|
-
"uptime",
|
|
63111
|
-
"e2e",
|
|
63112
|
-
"ci",
|
|
63113
|
-
"cli"
|
|
63114
|
-
],
|
|
63115
|
-
type: "module",
|
|
63116
|
-
bin: {
|
|
63117
|
-
waitcher: "dist/cli.mjs"
|
|
63118
|
-
},
|
|
63119
|
-
files: [
|
|
63120
|
-
"dist/cli.mjs",
|
|
63121
|
-
"dist/model-client.mjs",
|
|
63122
|
-
"dist/scenario-runtime.mjs",
|
|
63123
|
-
"dist/request-runtime.mjs",
|
|
63124
|
-
"dist/MODEL_CLIENT_NOTICES.txt",
|
|
63125
|
-
"README.md",
|
|
63126
|
-
"THIRD_PARTY_NOTICES.txt",
|
|
63127
|
-
"LICENSE.txt"
|
|
63128
|
-
],
|
|
63129
|
-
engines: {
|
|
63130
|
-
node: ">=24.15.0"
|
|
63131
|
-
},
|
|
63132
|
-
publishConfig: {
|
|
63133
|
-
access: "public"
|
|
63134
|
-
},
|
|
63135
|
-
scripts: {
|
|
63136
|
-
build: "node build.mjs",
|
|
63137
|
-
prepack: "npm run build"
|
|
63138
|
-
}
|
|
63139
|
-
};
|
|
63140
|
-
|
|
63141
64497
|
// src/main.ts
|
|
63142
|
-
var list = (
|
|
64498
|
+
var list = (text4) => (text4 ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
63143
64499
|
var issues = (all) => all.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n");
|
|
63144
64500
|
var controller = new AbortController();
|
|
63145
64501
|
process.once("SIGINT", () => controller.abort());
|
|
@@ -63152,9 +64508,9 @@ function id3(value2) {
|
|
|
63152
64508
|
usage2("Provide --id with the exact monitor or execution ID.");
|
|
63153
64509
|
return encodeURIComponent(value2);
|
|
63154
64510
|
}
|
|
63155
|
-
function integer2(value2,
|
|
64511
|
+
function integer2(value2, label2, min, max) {
|
|
63156
64512
|
if (!/^\d+$/.test(value2 ?? "") || !Number.isSafeInteger(Number(value2)) || Number(value2) < min || Number(value2) > max)
|
|
63157
|
-
usage2(`${
|
|
64513
|
+
usage2(`${label2} must be an integer from ${min} to ${max}.`);
|
|
63158
64514
|
return Number(value2);
|
|
63159
64515
|
}
|
|
63160
64516
|
function summary(m) {
|
|
@@ -63210,16 +64566,16 @@ async function passwordFromStdin(maxBytes = 2048) {
|
|
|
63210
64566
|
usage2(
|
|
63211
64567
|
"Pipe the password to stdin, or use --password-file PATH. Passwords are not accepted as command arguments."
|
|
63212
64568
|
);
|
|
63213
|
-
let
|
|
64569
|
+
let text4 = "";
|
|
63214
64570
|
const cancel = () => process.stdin.destroy(new Error("Interrupted."));
|
|
63215
64571
|
controller.signal.addEventListener("abort", cancel, { once: true });
|
|
63216
64572
|
try {
|
|
63217
64573
|
for await (const chunk of process.stdin) {
|
|
63218
|
-
|
|
63219
|
-
if (Buffer.byteLength(
|
|
64574
|
+
text4 += chunk;
|
|
64575
|
+
if (Buffer.byteLength(text4) > maxBytes)
|
|
63220
64576
|
usage2("Password input is too long.");
|
|
63221
64577
|
}
|
|
63222
|
-
return
|
|
64578
|
+
return text4.replace(/[\r\n]+$/, "");
|
|
63223
64579
|
} finally {
|
|
63224
64580
|
controller.signal.removeEventListener("abort", cancel);
|
|
63225
64581
|
}
|
|
@@ -63297,6 +64653,9 @@ async function main() {
|
|
|
63297
64653
|
"environment-id": { type: "string" },
|
|
63298
64654
|
before: { type: "string" },
|
|
63299
64655
|
server: { type: "string" },
|
|
64656
|
+
workspace: { type: "string" },
|
|
64657
|
+
member: { type: "string" },
|
|
64658
|
+
email: { type: "string" },
|
|
63300
64659
|
id: { type: "string" },
|
|
63301
64660
|
file: { type: "string" },
|
|
63302
64661
|
template: { type: "string" },
|
|
@@ -63306,6 +64665,7 @@ async function main() {
|
|
|
63306
64665
|
"token-file": { type: "string" },
|
|
63307
64666
|
"token-stdin": { type: "boolean" },
|
|
63308
64667
|
"credential-file": { type: "string" },
|
|
64668
|
+
"access-token-file": { type: "string" },
|
|
63309
64669
|
"connections-file": { type: "string" },
|
|
63310
64670
|
"credential-stdin": { type: "boolean" },
|
|
63311
64671
|
enable: { type: "boolean" },
|
|
@@ -63368,6 +64728,18 @@ async function main() {
|
|
|
63368
64728
|
);
|
|
63369
64729
|
const command = p.join(" ");
|
|
63370
64730
|
const commands2 = {
|
|
64731
|
+
"workspace list": [],
|
|
64732
|
+
"workspace use": ["id"],
|
|
64733
|
+
"workspace create": ["name"],
|
|
64734
|
+
"workspace rename": ["name", "expected-revision"],
|
|
64735
|
+
"workspace join": ["id"],
|
|
64736
|
+
"workspace decline": ["id"],
|
|
64737
|
+
"workspace leave": ["yes"],
|
|
64738
|
+
"member list": [],
|
|
64739
|
+
"member invite": ["email", "role"],
|
|
64740
|
+
"member cancel-invite": ["id"],
|
|
64741
|
+
"member role": ["member", "role"],
|
|
64742
|
+
"member remove": ["member", "yes"],
|
|
63371
64743
|
"identity list": [],
|
|
63372
64744
|
"identity get": ["id"],
|
|
63373
64745
|
"identity create": ["file", "state-file"],
|
|
@@ -63574,6 +64946,8 @@ async function main() {
|
|
|
63574
64946
|
"run trace": ["id"],
|
|
63575
64947
|
"run wait": ["id", "timeout", "brief"],
|
|
63576
64948
|
"report get": ["days", "demo"],
|
|
64949
|
+
"report history": ["file"],
|
|
64950
|
+
"monitor history": ["id"],
|
|
63577
64951
|
"incident list": ["demo"],
|
|
63578
64952
|
"incident update": ["id", "kind", "message"],
|
|
63579
64953
|
"incident open": [
|
|
@@ -63607,6 +64981,7 @@ async function main() {
|
|
|
63607
64981
|
"id",
|
|
63608
64982
|
"credential-file",
|
|
63609
64983
|
"credential-stdin",
|
|
64984
|
+
"access-token-file",
|
|
63610
64985
|
"request-key"
|
|
63611
64986
|
],
|
|
63612
64987
|
"alert channel delete": ["id", "yes"],
|
|
@@ -63622,7 +64997,7 @@ async function main() {
|
|
|
63622
64997
|
};
|
|
63623
64998
|
if (!commands2[command]) usage2("Unknown command. Run waitcher --help.");
|
|
63624
64999
|
for (const option of Object.keys(v))
|
|
63625
|
-
if (!["server", "json"].includes(option) && !commands2[command].includes(option))
|
|
65000
|
+
if (!["server", "json", "workspace"].includes(option) && !commands2[command].includes(option))
|
|
63626
65001
|
usage2(`--${option} does not apply to ${command}.`);
|
|
63627
65002
|
if (v["request-key"] && (v.id && [
|
|
63628
65003
|
"monitor apply",
|
|
@@ -63947,10 +65322,13 @@ async function main() {
|
|
|
63947
65322
|
"browser",
|
|
63948
65323
|
"visual",
|
|
63949
65324
|
"heartbeat",
|
|
63950
|
-
"ai"
|
|
65325
|
+
"ai",
|
|
65326
|
+
"mcp",
|
|
65327
|
+
"tcp",
|
|
65328
|
+
"dns"
|
|
63951
65329
|
].includes(v.type))
|
|
63952
65330
|
usage2(
|
|
63953
|
-
"monitor init supports --type http, certificate, api, browser, visual, heartbeat or
|
|
65331
|
+
"monitor init supports --type http, certificate, api, browser, visual, heartbeat, ai, mcp, tcp or dns."
|
|
63954
65332
|
);
|
|
63955
65333
|
let protectedInitial;
|
|
63956
65334
|
if (v.template === "protected-agent-outcome") {
|
|
@@ -63974,7 +65352,7 @@ async function main() {
|
|
|
63974
65352
|
usage2(
|
|
63975
65353
|
"These request policy/context options require --template protected-agent-outcome."
|
|
63976
65354
|
);
|
|
63977
|
-
const initial = protectedInitial ?? (v.template === "agent-outcome" ? agentOutcomeExample : v.type === "ai" ? aiEndpointExample : v.type === "heartbeat" ? {
|
|
65355
|
+
const initial = protectedInitial ?? (v.template === "agent-outcome" ? agentOutcomeExample : v.type === "ai" ? aiEndpointExample : v.type === "mcp" ? mcpExample : v.type === "tcp" ? tcpExample : v.type === "dns" ? dnsExample : v.type === "heartbeat" ? {
|
|
63978
65356
|
schemaVersion: 1,
|
|
63979
65357
|
name: "Scheduled job",
|
|
63980
65358
|
type: "heartbeat",
|
|
@@ -63984,7 +65362,7 @@ async function main() {
|
|
|
63984
65362
|
failureThreshold: 2,
|
|
63985
65363
|
heartbeat: { graceSeconds: 60, completionSeconds: 300 }
|
|
63986
65364
|
} : v.type === "visual" ? visualExample : v.type === "certificate" ? certificateExample : example);
|
|
63987
|
-
if (v.target && v.type
|
|
65365
|
+
if (v.target && !["heartbeat", "tcp", "dns"].includes(v.type ?? "")) {
|
|
63988
65366
|
try {
|
|
63989
65367
|
const target = new URL(v.target);
|
|
63990
65368
|
if (!["https:", "http:"].includes(target.protocol) || target.username || target.password)
|
|
@@ -64211,6 +65589,12 @@ async function main() {
|
|
|
64211
65589
|
};
|
|
64212
65590
|
} else {
|
|
64213
65591
|
const session = await authenticatedSession(server);
|
|
65592
|
+
const teamId = /^team:[a-f0-9]{24}$/;
|
|
65593
|
+
if (v.workspace !== void 0 && v.workspace !== "personal" && !teamId.test(v.workspace))
|
|
65594
|
+
usage2("--workspace takes a team ID (team:...) or personal.");
|
|
65595
|
+
useWorkspace(
|
|
65596
|
+
v.workspace === "personal" ? void 0 : v.workspace ?? (session.kind === "automation" || command === "workspace use" ? void 0 : await loadWorkspace(server) ?? void 0)
|
|
65597
|
+
);
|
|
64214
65598
|
const api = async (path2, options = {}) => (await request(server, path2, {
|
|
64215
65599
|
cookie: session.cookie,
|
|
64216
65600
|
accessToken: session.accessToken,
|
|
@@ -64218,7 +65602,120 @@ async function main() {
|
|
|
64218
65602
|
...options,
|
|
64219
65603
|
...options.method === "POST" ? { idempotencyKey: v["request-key"] } : {}
|
|
64220
65604
|
})).data;
|
|
64221
|
-
if (command.startsWith("
|
|
65605
|
+
if (command.startsWith("workspace ") || command.startsWith("member ")) {
|
|
65606
|
+
const member = (value2) => {
|
|
65607
|
+
if (typeof value2 !== "string" || !/^(admin|clerk:user_[A-Za-z0-9]{8,64})$/.test(value2))
|
|
65608
|
+
usage2("Provide --member with a member ID from member list.");
|
|
65609
|
+
return encodeURIComponent(value2);
|
|
65610
|
+
};
|
|
65611
|
+
const role = () => {
|
|
65612
|
+
if (v.role !== void 0 && !["owner", "admin", "member"].includes(v.role))
|
|
65613
|
+
usage2("--role must be owner, admin or member.");
|
|
65614
|
+
return v.role;
|
|
65615
|
+
};
|
|
65616
|
+
if (command === "workspace list") {
|
|
65617
|
+
const data = await api("workspaces");
|
|
65618
|
+
const saved = await loadWorkspace(server);
|
|
65619
|
+
result2 = {
|
|
65620
|
+
...data,
|
|
65621
|
+
selected: saved ?? data.workspaces[0]?.id ?? null
|
|
65622
|
+
};
|
|
65623
|
+
} else if (command === "workspace use") {
|
|
65624
|
+
if (typeof v.id !== "string")
|
|
65625
|
+
usage2("Provide --id with a team ID from workspace list, or personal.");
|
|
65626
|
+
if (v.id === "personal") {
|
|
65627
|
+
await saveWorkspace(server, null);
|
|
65628
|
+
result2 = { event: "workspace_selected", workspace: "personal" };
|
|
65629
|
+
} else {
|
|
65630
|
+
if (!teamId.test(v.id))
|
|
65631
|
+
usage2("Provide --id with a team ID from workspace list, or personal.");
|
|
65632
|
+
if (session.kind === "automation")
|
|
65633
|
+
usage2("An automation token is bound to its own workspace.");
|
|
65634
|
+
const data = await api("workspaces");
|
|
65635
|
+
const found = data.workspaces.find(
|
|
65636
|
+
(w) => w.id === v.id
|
|
65637
|
+
);
|
|
65638
|
+
if (!found)
|
|
65639
|
+
throw new ServiceError(
|
|
65640
|
+
"You are not a member of that workspace.",
|
|
65641
|
+
"WORKSPACE_NOT_FOUND",
|
|
65642
|
+
4
|
|
65643
|
+
);
|
|
65644
|
+
await saveWorkspace(server, v.id);
|
|
65645
|
+
result2 = { event: "workspace_selected", workspace: found };
|
|
65646
|
+
}
|
|
65647
|
+
} else if (command === "workspace create") {
|
|
65648
|
+
if (!v.name) usage2("Provide --name for the team.");
|
|
65649
|
+
const created = await api("workspaces", {
|
|
65650
|
+
method: "POST",
|
|
65651
|
+
body: { name: v.name }
|
|
65652
|
+
});
|
|
65653
|
+
result2 = {
|
|
65654
|
+
event: "workspace_created",
|
|
65655
|
+
workspace: created,
|
|
65656
|
+
next: [`waitcher workspace use --id ${created.id}`]
|
|
65657
|
+
};
|
|
65658
|
+
} else if (command === "workspace rename") {
|
|
65659
|
+
if (!v.name) usage2("Provide --name for the team.");
|
|
65660
|
+
result2 = await api("workspaces/current", {
|
|
65661
|
+
method: "PUT",
|
|
65662
|
+
body: {
|
|
65663
|
+
name: v.name,
|
|
65664
|
+
expectedRevision: integer2(
|
|
65665
|
+
v["expected-revision"],
|
|
65666
|
+
"expected-revision",
|
|
65667
|
+
1,
|
|
65668
|
+
Number.MAX_SAFE_INTEGER
|
|
65669
|
+
)
|
|
65670
|
+
}
|
|
65671
|
+
});
|
|
65672
|
+
} else if (command === "workspace join" || command === "workspace decline") {
|
|
65673
|
+
if (typeof v.id !== "string" || !/^[a-f0-9-]{36}$/.test(v.id))
|
|
65674
|
+
usage2("Provide --id with an invitation ID from workspace list.");
|
|
65675
|
+
result2 = await api(
|
|
65676
|
+
`workspaces/invites/${v.id}/${command === "workspace join" ? "accept" : "decline"}`,
|
|
65677
|
+
{ method: "POST", body: {} }
|
|
65678
|
+
);
|
|
65679
|
+
if (command === "workspace join")
|
|
65680
|
+
result2 = {
|
|
65681
|
+
event: "workspace_joined",
|
|
65682
|
+
workspace: result2,
|
|
65683
|
+
next: [`waitcher workspace use --id ${result2.id}`]
|
|
65684
|
+
};
|
|
65685
|
+
} else if (command === "workspace leave") {
|
|
65686
|
+
if (!v.yes) usage2("Pass --yes to leave the active team.");
|
|
65687
|
+
const me = (await api("workspaces")).workspaces[0].id;
|
|
65688
|
+
result2 = await api(`workspaces/current/members/${member(me)}`, {
|
|
65689
|
+
method: "DELETE"
|
|
65690
|
+
});
|
|
65691
|
+
await saveWorkspace(server, null);
|
|
65692
|
+
} else if (command === "member list")
|
|
65693
|
+
result2 = await api("workspaces/current/members");
|
|
65694
|
+
else if (command === "member invite") {
|
|
65695
|
+
if (!v.email) usage2("Provide --email of the person to invite.");
|
|
65696
|
+
result2 = await api("workspaces/current/invites", {
|
|
65697
|
+
method: "POST",
|
|
65698
|
+
body: { email: v.email, ...role() ? { role: role() } : {} }
|
|
65699
|
+
});
|
|
65700
|
+
} else if (command === "member cancel-invite") {
|
|
65701
|
+
if (typeof v.id !== "string" || !/^[a-f0-9-]{36}$/.test(v.id))
|
|
65702
|
+
usage2("Provide --id with an invitation ID from member list.");
|
|
65703
|
+
result2 = await api(`workspaces/current/invites/${v.id}`, {
|
|
65704
|
+
method: "DELETE"
|
|
65705
|
+
});
|
|
65706
|
+
} else if (command === "member role") {
|
|
65707
|
+
if (!role()) usage2("Provide --role owner, admin or member.");
|
|
65708
|
+
result2 = await api(`workspaces/current/members/${member(v.member)}`, {
|
|
65709
|
+
method: "PUT",
|
|
65710
|
+
body: { role: role() }
|
|
65711
|
+
});
|
|
65712
|
+
} else {
|
|
65713
|
+
if (!v.yes) usage2("Pass --yes to remove this member.");
|
|
65714
|
+
result2 = await api(`workspaces/current/members/${member(v.member)}`, {
|
|
65715
|
+
method: "DELETE"
|
|
65716
|
+
});
|
|
65717
|
+
}
|
|
65718
|
+
} else if (command.startsWith("identity ")) {
|
|
64222
65719
|
const action = p[1];
|
|
64223
65720
|
const revision = () => {
|
|
64224
65721
|
const n = Number(v["expected-revision"]);
|
|
@@ -64329,7 +65826,7 @@ async function main() {
|
|
|
64329
65826
|
});
|
|
64330
65827
|
if (!parsed2.success)
|
|
64331
65828
|
usage2(
|
|
64332
|
-
"Credential JSON must contain targetId, name and header
|
|
65829
|
+
"Credential JSON must contain targetId, name and either a valid header name or kind oauth2 with an oauth block (grant, tokenUrl, clientId). See: waitcher help target."
|
|
64333
65830
|
);
|
|
64334
65831
|
result2 = await api("http-targets/credentials", {
|
|
64335
65832
|
method: "POST",
|
|
@@ -64971,12 +66468,12 @@ async function main() {
|
|
|
64971
66468
|
usage2(
|
|
64972
66469
|
"Provide --file PATH with the complete configuration and expectedRevision for edits."
|
|
64973
66470
|
);
|
|
64974
|
-
const
|
|
64975
|
-
if (Buffer.byteLength(
|
|
66471
|
+
const text4 = await readFile11(v.file, "utf8");
|
|
66472
|
+
if (Buffer.byteLength(text4) > 16e3)
|
|
64976
66473
|
usage2("Project configuration exceeds 16 KB");
|
|
64977
66474
|
let body2;
|
|
64978
66475
|
try {
|
|
64979
|
-
body2 = JSON.parse(
|
|
66476
|
+
body2 = JSON.parse(text4);
|
|
64980
66477
|
} catch {
|
|
64981
66478
|
usage2("Configuration must be JSON");
|
|
64982
66479
|
}
|
|
@@ -65221,10 +66718,10 @@ async function main() {
|
|
|
65221
66718
|
if (!v.file) usage2("Provide --file PATH for the configuration.");
|
|
65222
66719
|
let input2;
|
|
65223
66720
|
try {
|
|
65224
|
-
const
|
|
65225
|
-
if (Buffer.byteLength(
|
|
66721
|
+
const text4 = await readFile11(v.file, "utf8");
|
|
66722
|
+
if (Buffer.byteLength(text4) > 96e3)
|
|
65226
66723
|
usage2("Configuration exceeds 96 KB.");
|
|
65227
|
-
input2 = JSON.parse(
|
|
66724
|
+
input2 = JSON.parse(text4);
|
|
65228
66725
|
} catch {
|
|
65229
66726
|
usage2("Could not read valid JSON configuration.");
|
|
65230
66727
|
}
|
|
@@ -65239,6 +66736,15 @@ async function main() {
|
|
|
65239
66736
|
if (v["credential-file"] && v["credential-stdin"])
|
|
65240
66737
|
usage2("Choose one credential input method.");
|
|
65241
66738
|
credential = v["credential-file"] ? (await readPrivate(v["credential-file"])).trim() : v["credential-stdin"] ? (await passwordFromStdin(8192)).trim() : void 0;
|
|
66739
|
+
if (Object.hasOwn(input2, "accessToken"))
|
|
66740
|
+
usage2(
|
|
66741
|
+
"Keep the ntfy access token out of configuration. Use --access-token-file."
|
|
66742
|
+
);
|
|
66743
|
+
if (v["access-token-file"]) {
|
|
66744
|
+
if (input2.kind !== "ntfy")
|
|
66745
|
+
usage2("--access-token-file applies only to ntfy channels.");
|
|
66746
|
+
input2.accessToken = (await readPrivate(v["access-token-file"])).trim();
|
|
66747
|
+
}
|
|
65242
66748
|
if (input2.kind === "account-email" && credential)
|
|
65243
66749
|
usage2(
|
|
65244
66750
|
"Account email needs no credential; Waitcher sends to your verified sign-in address."
|
|
@@ -65345,8 +66851,8 @@ async function main() {
|
|
|
65345
66851
|
else if (command === "account billing") result2 = await api("billing");
|
|
65346
66852
|
else if (command === "account upgrade" || command === "account billing-portal") {
|
|
65347
66853
|
const plan = v.plan === void 0 ? void 0 : String(v.plan);
|
|
65348
|
-
if (command === "account upgrade" && plan && !["pro", "business"].includes(plan))
|
|
65349
|
-
usage2("--plan must be pro or
|
|
66854
|
+
if (command === "account upgrade" && plan && !["pro", "business", "team"].includes(plan))
|
|
66855
|
+
usage2("--plan must be pro, business or team");
|
|
65350
66856
|
const { url: url3, changed } = await api(
|
|
65351
66857
|
command === "account upgrade" ? "billing/checkout" : "billing/portal",
|
|
65352
66858
|
{
|
|
@@ -65372,8 +66878,8 @@ async function main() {
|
|
|
65372
66878
|
};
|
|
65373
66879
|
} else if (command === "system plan") {
|
|
65374
66880
|
const owner = String(v.owner ?? ""), plan = String(v.plan ?? "");
|
|
65375
|
-
if (!/^clerk:user_[A-Za-z0-9]{8,64}$/.test(owner))
|
|
65376
|
-
usage2("--owner must be an account owner like clerk:user_ID");
|
|
66881
|
+
if (!/^(clerk:user_[A-Za-z0-9]{8,64}|team:[a-f0-9]{24})$/.test(owner))
|
|
66882
|
+
usage2("--owner must be an account owner like clerk:user_ID or team:ID");
|
|
65377
66883
|
if (!/^[a-z]{1,32}$/.test(plan)) usage2("--plan must be a plan name");
|
|
65378
66884
|
result2 = await api(`system/plans/${encodeURIComponent(owner)}`, {
|
|
65379
66885
|
method: "PUT",
|
|
@@ -65381,8 +66887,8 @@ async function main() {
|
|
|
65381
66887
|
});
|
|
65382
66888
|
} else if (command === "system suspend" || command === "system unsuspend") {
|
|
65383
66889
|
const owner = String(v.owner ?? "");
|
|
65384
|
-
if (!/^clerk:user_[A-Za-z0-9]{8,64}$/.test(owner))
|
|
65385
|
-
usage2("--owner must be an account owner like clerk:user_ID");
|
|
66890
|
+
if (!/^(clerk:user_[A-Za-z0-9]{8,64}|team:[a-f0-9]{24})$/.test(owner))
|
|
66891
|
+
usage2("--owner must be an account owner like clerk:user_ID or team:ID");
|
|
65386
66892
|
const suspend = command === "system suspend";
|
|
65387
66893
|
if (suspend && String(v.reason ?? "").trim().length < 3)
|
|
65388
66894
|
usage2("--reason must say why, in 3 to 200 characters");
|
|
@@ -65399,6 +66905,7 @@ async function main() {
|
|
|
65399
66905
|
mode: session.kind === "automation" ? "automation" : session.kind === "oauth" ? "oauth" : "admin_password",
|
|
65400
66906
|
authorization: data.authorization,
|
|
65401
66907
|
account: data.account,
|
|
66908
|
+
...data.workspace ? { workspace: data.workspace } : {},
|
|
65402
66909
|
...data.owner ? {
|
|
65403
66910
|
owner: data.owner,
|
|
65404
66911
|
plan: data.limits?.plan,
|
|
@@ -65585,6 +67092,20 @@ async function main() {
|
|
|
65585
67092
|
);
|
|
65586
67093
|
}
|
|
65587
67094
|
}
|
|
67095
|
+
} else if (command === "monitor history") {
|
|
67096
|
+
result2 = await api(`monitors/${id3(v.id)}/history`);
|
|
67097
|
+
} else if (command === "report history") {
|
|
67098
|
+
if (v.file) {
|
|
67099
|
+
const csv = await api("reports/history.csv", { responseType: "text" });
|
|
67100
|
+
const file2 = await open18(v.file, "wx", 384);
|
|
67101
|
+
try {
|
|
67102
|
+
await file2.writeFile(csv);
|
|
67103
|
+
await file2.sync();
|
|
67104
|
+
} finally {
|
|
67105
|
+
await file2.close();
|
|
67106
|
+
}
|
|
67107
|
+
result2 = { event: "exported", file: v.file };
|
|
67108
|
+
} else result2 = await api("reports/history");
|
|
65588
67109
|
} else if (command === "report get") {
|
|
65589
67110
|
const days = integer2(v.days ?? "1", "days", 1, 14);
|
|
65590
67111
|
if (![1, 7, 14].includes(days)) usage2("days must be 1, 7 or 14.");
|
|
@@ -65676,10 +67197,10 @@ async function main() {
|
|
|
65676
67197
|
if (!v.file) usage2("Provide --file PATH for the status page.");
|
|
65677
67198
|
let input2;
|
|
65678
67199
|
try {
|
|
65679
|
-
const
|
|
65680
|
-
if (Buffer.byteLength(
|
|
67200
|
+
const text4 = await readFile11(v.file, "utf8");
|
|
67201
|
+
if (Buffer.byteLength(text4) > 96e3)
|
|
65681
67202
|
usage2("Configuration exceeds 96 KB.");
|
|
65682
|
-
input2 = JSON.parse(
|
|
67203
|
+
input2 = JSON.parse(text4);
|
|
65683
67204
|
} catch {
|
|
65684
67205
|
usage2("Could not read valid JSON configuration.");
|
|
65685
67206
|
}
|