@waitcher/cli 0.2.26 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/MODEL_CLIENT_NOTICES.txt +6 -51
- package/dist/cli.mjs +458 -189
- package/dist/model-client.mjs +10762 -12545
- package/dist/request-runtime.mjs +446 -179
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -8688,7 +8688,7 @@ var require_parser_h1 = __commonJS({
|
|
|
8688
8688
|
var EVENT_RANGE_SIZE = 9;
|
|
8689
8689
|
var EVENT_HEADERS_SIZE = 19;
|
|
8690
8690
|
var miloPackage;
|
|
8691
|
-
var useWasmSIMD = process.arch !== "ppc64";
|
|
8691
|
+
var useWasmSIMD = process.arch !== "riscv64" && process.arch !== "ppc64";
|
|
8692
8692
|
if (process.env.UNDICI_NO_WASM_SIMD === "1") {
|
|
8693
8693
|
useWasmSIMD = false;
|
|
8694
8694
|
} else if (process.env.UNDICI_NO_WASM_SIMD === "0") {
|
|
@@ -9966,14 +9966,35 @@ Content-Type: ${value2.type || "application/octet-stream"}\r
|
|
|
9966
9966
|
"Response body object should not be disturbed or locked"
|
|
9967
9967
|
);
|
|
9968
9968
|
}
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9969
|
+
if (webidl.is.ReadableStream(object2)) {
|
|
9970
|
+
stream = object2;
|
|
9971
|
+
} else {
|
|
9972
|
+
const reader = ReadableStream.from(object2).getReader();
|
|
9973
|
+
let cancelled = false;
|
|
9974
|
+
stream = new ReadableStream({
|
|
9975
|
+
async pull(controller2) {
|
|
9976
|
+
while (true) {
|
|
9977
|
+
const { done, value: value2 } = await reader.read();
|
|
9978
|
+
if (cancelled) {
|
|
9979
|
+
return;
|
|
9980
|
+
}
|
|
9981
|
+
if (done) {
|
|
9982
|
+
controller2.close();
|
|
9983
|
+
return;
|
|
9984
|
+
}
|
|
9985
|
+
const bytes2 = isUint8Array(value2) ? value2 : Buffer.from(value2);
|
|
9986
|
+
if (bytes2.byteLength) {
|
|
9987
|
+
controller2.enqueue(bytes2);
|
|
9988
|
+
return;
|
|
9989
|
+
}
|
|
9990
|
+
}
|
|
9991
|
+
},
|
|
9992
|
+
cancel(reason2) {
|
|
9993
|
+
cancelled = true;
|
|
9994
|
+
return reader.cancel(reason2);
|
|
9974
9995
|
}
|
|
9975
|
-
}
|
|
9976
|
-
}
|
|
9996
|
+
}, { highWaterMark: 0 });
|
|
9997
|
+
}
|
|
9977
9998
|
}
|
|
9978
9999
|
if (typeof source === "string" || isUint8Array(source)) {
|
|
9979
10000
|
action = () => source;
|
|
@@ -10205,7 +10226,9 @@ var require_client_h1 = __commonJS({
|
|
|
10205
10226
|
const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
|
|
10206
10227
|
let mod;
|
|
10207
10228
|
let useWasmSIMD = true;
|
|
10208
|
-
if (process.arch === "
|
|
10229
|
+
if (process.arch === "riscv64") {
|
|
10230
|
+
useWasmSIMD = false;
|
|
10231
|
+
} else if (process.arch === "ppc64") {
|
|
10209
10232
|
const [major, minor] = process.versions.node.split(".").map((n) => parseInt(n, 10));
|
|
10210
10233
|
if (major < 24 || major === 24 && minor < 12) {
|
|
10211
10234
|
useWasmSIMD = false;
|
|
@@ -11526,7 +11549,6 @@ var require_client_h2 = __commonJS({
|
|
|
11526
11549
|
} = require_symbols();
|
|
11527
11550
|
var { channels } = require_diagnostics();
|
|
11528
11551
|
var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
|
|
11529
|
-
var kRequestStreamId = /* @__PURE__ */ Symbol("request stream id");
|
|
11530
11552
|
var kRequestStream = /* @__PURE__ */ Symbol("request stream");
|
|
11531
11553
|
var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
|
|
11532
11554
|
var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
|
|
@@ -11534,6 +11556,7 @@ var require_client_h2 = __commonJS({
|
|
|
11534
11556
|
var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
|
|
11535
11557
|
var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
|
|
11536
11558
|
var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
|
|
11559
|
+
var HTTP2_FRAME_TYPE_HEADERS = 1;
|
|
11537
11560
|
var MIN_PROBE_TIMEOUT = 1e3;
|
|
11538
11561
|
var extractBody;
|
|
11539
11562
|
var http2;
|
|
@@ -11585,14 +11608,14 @@ var require_client_h2 = __commonJS({
|
|
|
11585
11608
|
if (request2 == null) {
|
|
11586
11609
|
continue;
|
|
11587
11610
|
}
|
|
11588
|
-
|
|
11611
|
+
const streamId = request2[kRequestStream]?.id;
|
|
11612
|
+
if (typeof streamId !== "number" || streamId > maxAcceptedStreamID) {
|
|
11589
11613
|
return i;
|
|
11590
11614
|
}
|
|
11591
11615
|
}
|
|
11592
11616
|
return client[kPendingIdx];
|
|
11593
11617
|
}
|
|
11594
11618
|
function detachRequestFromStream(request2) {
|
|
11595
|
-
request2[kRequestStreamId] = null;
|
|
11596
11619
|
request2[kRequestStream] = null;
|
|
11597
11620
|
request2[kRequestStreamCleanup] = null;
|
|
11598
11621
|
}
|
|
@@ -11601,7 +11624,6 @@ var require_client_h2 = __commonJS({
|
|
|
11601
11624
|
const previousStream = request2[kRequestStream];
|
|
11602
11625
|
detachRequestFromStream(request2);
|
|
11603
11626
|
previousCleanup?.(previousStream);
|
|
11604
|
-
request2[kRequestStreamId] = stream.id;
|
|
11605
11627
|
request2[kRequestStream] = stream;
|
|
11606
11628
|
request2[kRequestStreamCleanup] = cleanup;
|
|
11607
11629
|
}
|
|
@@ -11670,7 +11692,8 @@ var require_client_h2 = __commonJS({
|
|
|
11670
11692
|
closeStreamSession(stream);
|
|
11671
11693
|
}
|
|
11672
11694
|
if (!stream.destroyed && !stream.closed) {
|
|
11673
|
-
stream.
|
|
11695
|
+
stream.off("error", noop);
|
|
11696
|
+
stream.on("error", noop);
|
|
11674
11697
|
}
|
|
11675
11698
|
}
|
|
11676
11699
|
function connectH2(client, socket) {
|
|
@@ -12005,14 +12028,12 @@ var require_client_h2 = __commonJS({
|
|
|
12005
12028
|
}
|
|
12006
12029
|
}
|
|
12007
12030
|
}
|
|
12008
|
-
for (let i = 0; i < streamsToClose.length; i++) {
|
|
12009
|
-
closeStream(streamsToClose[i]);
|
|
12010
|
-
}
|
|
12011
12031
|
if (pendingIdx !== previousPendingIdx) {
|
|
12012
12032
|
const remainingPendingRequests = client[kQueue].slice(previousPendingIdx);
|
|
12013
12033
|
client[kQueue].length = pendingIdx;
|
|
12014
12034
|
client[kQueue].push(...retriableRequests, ...remainingPendingRequests);
|
|
12015
12035
|
}
|
|
12036
|
+
client[kPendingIdx] = pendingIdx;
|
|
12016
12037
|
if (client[kHTTP2Session] === this) {
|
|
12017
12038
|
client[kSocket] = null;
|
|
12018
12039
|
client[kHTTPContext] = null;
|
|
@@ -12024,10 +12045,12 @@ var require_client_h2 = __commonJS({
|
|
|
12024
12045
|
clearHttp2IdleTimeout(this);
|
|
12025
12046
|
clearNoStreamsTimeout(this);
|
|
12026
12047
|
clearHttp2ProbeTimeout(this);
|
|
12048
|
+
for (let i = 0; i < streamsToClose.length; i++) {
|
|
12049
|
+
closeStream(streamsToClose[i]);
|
|
12050
|
+
}
|
|
12027
12051
|
if (!this.closed && !this.destroyed) {
|
|
12028
12052
|
this.close();
|
|
12029
12053
|
}
|
|
12030
|
-
client[kPendingIdx] = pendingIdx;
|
|
12031
12054
|
client.emit("disconnect", client[kUrl], [client], err);
|
|
12032
12055
|
client[kResume]();
|
|
12033
12056
|
}
|
|
@@ -12103,7 +12126,6 @@ var require_client_h2 = __commonJS({
|
|
|
12103
12126
|
}
|
|
12104
12127
|
}
|
|
12105
12128
|
function onUpgradeStreamClose() {
|
|
12106
|
-
this.off("error", noop);
|
|
12107
12129
|
const state = this[kRequestStreamState];
|
|
12108
12130
|
this[kRequestStreamState] = null;
|
|
12109
12131
|
failUpgradeStream(state, new InformationalError("HTTP/2: stream closed before response headers"));
|
|
@@ -12176,7 +12198,7 @@ var require_client_h2 = __commonJS({
|
|
|
12176
12198
|
}
|
|
12177
12199
|
removeUpgradeStreamListeners(stream);
|
|
12178
12200
|
if (!stream.destroyed && !stream.closed) {
|
|
12179
|
-
stream.
|
|
12201
|
+
stream.on("error", noop);
|
|
12180
12202
|
}
|
|
12181
12203
|
}
|
|
12182
12204
|
function failUpgradeStream(state, err) {
|
|
@@ -12470,7 +12492,7 @@ var require_client_h2 = __commonJS({
|
|
|
12470
12492
|
}
|
|
12471
12493
|
if (!stream.destroyed && !stream.closed) {
|
|
12472
12494
|
removeRequestStreamListeners(stream);
|
|
12473
|
-
stream.
|
|
12495
|
+
stream.on("error", noop);
|
|
12474
12496
|
}
|
|
12475
12497
|
}
|
|
12476
12498
|
function onData(chunk) {
|
|
@@ -12583,13 +12605,25 @@ var require_client_h2 = __commonJS({
|
|
|
12583
12605
|
return false;
|
|
12584
12606
|
}
|
|
12585
12607
|
request2[kRefusedStreamRetry] = true;
|
|
12608
|
+
requeueStreamRequest(client, state);
|
|
12609
|
+
return true;
|
|
12610
|
+
}
|
|
12611
|
+
function retryUnsentStream(state) {
|
|
12612
|
+
const { client, request: request2, session } = state;
|
|
12613
|
+
if (!session[kReceivedGoAway] || state.responseReceived || request2.aborted || request2.completed || !canReplayRequest(request2) || !registerGoAwayRefusal(request2)) {
|
|
12614
|
+
return false;
|
|
12615
|
+
}
|
|
12616
|
+
requeueStreamRequest(client, state);
|
|
12617
|
+
return true;
|
|
12618
|
+
}
|
|
12619
|
+
function requeueStreamRequest(client, state) {
|
|
12620
|
+
const { request: request2 } = state;
|
|
12586
12621
|
detachRequestStreamForClose(request2);
|
|
12587
12622
|
state.stream = null;
|
|
12588
12623
|
state.requestFinalized = true;
|
|
12589
12624
|
completeRequest(client, request2);
|
|
12590
12625
|
client[kQueue].splice(client[kPendingIdx], 0, request2);
|
|
12591
12626
|
client[kResume]();
|
|
12592
|
-
return true;
|
|
12593
12627
|
}
|
|
12594
12628
|
function onError(err) {
|
|
12595
12629
|
const stream = this;
|
|
@@ -12598,6 +12632,7 @@ var require_client_h2 = __commonJS({
|
|
|
12598
12632
|
return;
|
|
12599
12633
|
}
|
|
12600
12634
|
stream.off("error", onError);
|
|
12635
|
+
stream.on("error", noop);
|
|
12601
12636
|
if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
|
|
12602
12637
|
err = new ResponseContentLengthMismatchError();
|
|
12603
12638
|
}
|
|
@@ -12616,6 +12651,9 @@ var require_client_h2 = __commonJS({
|
|
|
12616
12651
|
return;
|
|
12617
12652
|
}
|
|
12618
12653
|
stream.off("frameError", onFrameError);
|
|
12654
|
+
if (type === HTTP2_FRAME_TYPE_HEADERS && retryUnsentStream(state)) {
|
|
12655
|
+
return;
|
|
12656
|
+
}
|
|
12619
12657
|
state.abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
|
|
12620
12658
|
}
|
|
12621
12659
|
function onAborted() {
|
|
@@ -17868,13 +17906,18 @@ var require_mock_utils = __commonJS({
|
|
|
17868
17906
|
if (typeof path2 !== "string") {
|
|
17869
17907
|
return path2;
|
|
17870
17908
|
}
|
|
17909
|
+
const queryIndex = path2.indexOf("?");
|
|
17910
|
+
const search = queryIndex === -1 ? "" : path2.slice(queryIndex);
|
|
17911
|
+
if (queryIndex !== -1) {
|
|
17912
|
+
path2 = path2.slice(0, queryIndex);
|
|
17913
|
+
}
|
|
17871
17914
|
while (path2.endsWith("/")) {
|
|
17872
17915
|
path2 = path2.slice(0, -1);
|
|
17873
17916
|
}
|
|
17874
17917
|
if (path2.length === 0) {
|
|
17875
17918
|
path2 = "/";
|
|
17876
17919
|
}
|
|
17877
|
-
return path2;
|
|
17920
|
+
return path2 + search;
|
|
17878
17921
|
}
|
|
17879
17922
|
function buildKey(opts) {
|
|
17880
17923
|
const { path: path2, method, body: body2, headers, query } = opts;
|
|
@@ -17961,6 +18004,9 @@ var require_mock_utils = __commonJS({
|
|
|
17961
18004
|
paused: false,
|
|
17962
18005
|
rawHeaders: null,
|
|
17963
18006
|
rawTrailers: null,
|
|
18007
|
+
get aborted() {
|
|
18008
|
+
return aborted2;
|
|
18009
|
+
},
|
|
17964
18010
|
pause() {
|
|
17965
18011
|
this.paused = true;
|
|
17966
18012
|
},
|
|
@@ -19842,8 +19888,11 @@ var require_decorator_handler = __commonJS({
|
|
|
19842
19888
|
onResponseStart(...args) {
|
|
19843
19889
|
assert2(!this.#onCompleteCalled);
|
|
19844
19890
|
assert2(!this.#onErrorCalled);
|
|
19845
|
-
|
|
19846
|
-
|
|
19891
|
+
const statusCode = args[1];
|
|
19892
|
+
if (statusCode >= 200) {
|
|
19893
|
+
assert2(!this.#onResponseStartCalled);
|
|
19894
|
+
this.#onResponseStartCalled = true;
|
|
19895
|
+
}
|
|
19847
19896
|
return this.#handler.onResponseStart?.(...args);
|
|
19848
19897
|
}
|
|
19849
19898
|
onResponseData(...args) {
|
|
@@ -19963,7 +20012,11 @@ var require_redirect_handler = __commonJS({
|
|
|
19963
20012
|
this.handler.onResponseStart?.(controller2, statusCode, headers, statusMessage);
|
|
19964
20013
|
return;
|
|
19965
20014
|
}
|
|
19966
|
-
this.history[kRedirectCacheControl].push(
|
|
20015
|
+
this.history[kRedirectCacheControl].push({
|
|
20016
|
+
statusCode,
|
|
20017
|
+
headers: { ...headers },
|
|
20018
|
+
receivedAt: Date.now()
|
|
20019
|
+
});
|
|
19967
20020
|
const baseUrl = requestOrigin ? new URL(this.opts.path, requestOrigin) : void 0;
|
|
19968
20021
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, baseUrl));
|
|
19969
20022
|
const path2 = search ? `${pathname}${search}` : pathname;
|
|
@@ -20031,9 +20084,17 @@ var require_redirect_handler = __commonJS({
|
|
|
20031
20084
|
function cleanRequestHeaders(headers, removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin) {
|
|
20032
20085
|
const ret = [];
|
|
20033
20086
|
if (Array.isArray(headers)) {
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20087
|
+
if (headers.length > 0 && Array.isArray(headers[0])) {
|
|
20088
|
+
for (const [key, value2] of headers) {
|
|
20089
|
+
if (!shouldRemoveHeader(key, removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
|
|
20090
|
+
ret.push(key, value2);
|
|
20091
|
+
}
|
|
20092
|
+
}
|
|
20093
|
+
} else {
|
|
20094
|
+
for (let i = 0; i < headers.length; i += 2) {
|
|
20095
|
+
if (!shouldRemoveHeader(headers[i], removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
|
|
20096
|
+
ret.push(headers[i], headers[i + 1]);
|
|
20097
|
+
}
|
|
20037
20098
|
}
|
|
20038
20099
|
}
|
|
20039
20100
|
} else if (headers && typeof headers === "object") {
|
|
@@ -21897,6 +21958,15 @@ var require_cache_handler = __commonJS({
|
|
|
21897
21958
|
}
|
|
21898
21959
|
return false;
|
|
21899
21960
|
}
|
|
21961
|
+
function appendVaryValues(target, varyValue) {
|
|
21962
|
+
if (Array.isArray(varyValue)) {
|
|
21963
|
+
for (let i = 0; i < varyValue.length; i++) {
|
|
21964
|
+
target.push(varyValue[i]);
|
|
21965
|
+
}
|
|
21966
|
+
} else if (varyValue != null) {
|
|
21967
|
+
target.push(varyValue);
|
|
21968
|
+
}
|
|
21969
|
+
}
|
|
21900
21970
|
function appendConnectionHeaderTokens(headersToRemove, connectionHeader) {
|
|
21901
21971
|
const values = Array.isArray(connectionHeader) ? connectionHeader : [connectionHeader];
|
|
21902
21972
|
for (let i = 0; i < values.length; i++) {
|
|
@@ -21958,6 +22028,9 @@ var require_cache_handler = __commonJS({
|
|
|
21958
22028
|
deleteLocationTargets(store, cacheKey, resHeaders.location);
|
|
21959
22029
|
deleteLocationTargets(store, cacheKey, resHeaders["content-location"]);
|
|
21960
22030
|
}
|
|
22031
|
+
function requestCarriesCredentials(headers) {
|
|
22032
|
+
return headers != null && (Object.hasOwn(headers, "authorization") || Object.hasOwn(headers, "cookie") || Object.hasOwn(headers, "proxy-authorization"));
|
|
22033
|
+
}
|
|
21961
22034
|
var CacheHandler = class {
|
|
21962
22035
|
/**
|
|
21963
22036
|
* @type {import('../../types/cache-interceptor.d.ts').default.CacheKey}
|
|
@@ -21990,7 +22063,7 @@ var require_cache_handler = __commonJS({
|
|
|
21990
22063
|
/**
|
|
21991
22064
|
* The URLs visited while following redirects, shared by reference from the
|
|
21992
22065
|
* redirect handler through the request context. Carries the suppressed hops'
|
|
21993
|
-
*
|
|
22066
|
+
* status/headers under {@link kRedirectCacheControl}.
|
|
21994
22067
|
* @type {URL[] | undefined}
|
|
21995
22068
|
*/
|
|
21996
22069
|
#history;
|
|
@@ -22040,21 +22113,29 @@ var require_cache_handler = __commonJS({
|
|
|
22040
22113
|
invalidateUnsafeRequest(this.#store, this.#cacheKey, resHeaders);
|
|
22041
22114
|
return downstreamOnHeaders();
|
|
22042
22115
|
}
|
|
22043
|
-
if (this.#history && this.#history.length >
|
|
22044
|
-
|
|
22045
|
-
if (!sameOrigin(finalUrl.origin, this.#cacheKey.origin)) {
|
|
22046
|
-
return downstreamOnHeaders();
|
|
22047
|
-
}
|
|
22116
|
+
if (this.#history && this.#history.length > 1 && requestCarriesCredentials(this.#cacheKey.headers)) {
|
|
22117
|
+
return downstreamOnHeaders();
|
|
22048
22118
|
}
|
|
22049
|
-
|
|
22050
|
-
|
|
22051
|
-
|
|
22052
|
-
const hopDirectives = hopCacheControl ? parseCacheControlHeader(hopCacheControl) : {};
|
|
22053
|
-
if (hopDirectives["no-store"] === true || this.#cacheType === "shared" && hopDirectives.private === true) {
|
|
22119
|
+
if (this.#history && this.#history.length > 0) {
|
|
22120
|
+
for (const hopUrl of this.#history) {
|
|
22121
|
+
if (!sameOrigin(hopUrl.origin, this.#cacheKey.origin)) {
|
|
22054
22122
|
return downstreamOnHeaders();
|
|
22055
22123
|
}
|
|
22056
22124
|
}
|
|
22057
22125
|
}
|
|
22126
|
+
const now = Date.now();
|
|
22127
|
+
const redirectHopInfo = this.#history?.[kRedirectCacheControl];
|
|
22128
|
+
const redirectPolicy = redirectHopInfo?.length > 0 ? getRedirectPolicy(
|
|
22129
|
+
this.#cacheType,
|
|
22130
|
+
this.#cacheKey.method,
|
|
22131
|
+
redirectHopInfo,
|
|
22132
|
+
this.#cacheKey.headers,
|
|
22133
|
+
this.#cacheByDefault,
|
|
22134
|
+
now
|
|
22135
|
+
) : void 0;
|
|
22136
|
+
if (redirectHopInfo?.length > 0 && redirectPolicy === void 0) {
|
|
22137
|
+
return downstreamOnHeaders();
|
|
22138
|
+
}
|
|
22058
22139
|
const cacheControlHeader = resHeaders["cache-control"];
|
|
22059
22140
|
const cacheControlDirectives = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
|
|
22060
22141
|
if (revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives)) {
|
|
@@ -22074,7 +22155,6 @@ var require_cache_handler = __commonJS({
|
|
|
22074
22155
|
}
|
|
22075
22156
|
return downstreamOnHeaders();
|
|
22076
22157
|
}
|
|
22077
|
-
const now = Date.now();
|
|
22078
22158
|
const resAge = Object.hasOwn(resHeaders, "age") ? getAge(resHeaders.age) : void 0;
|
|
22079
22159
|
if (resAge !== void 0 && resAge >= MAX_RESPONSE_AGE) {
|
|
22080
22160
|
deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
|
|
@@ -22097,27 +22177,53 @@ var require_cache_handler = __commonJS({
|
|
|
22097
22177
|
return downstreamOnHeaders();
|
|
22098
22178
|
}
|
|
22099
22179
|
const baseTime = now - currentAge;
|
|
22100
|
-
|
|
22180
|
+
let absoluteStaleAt = staleAt + baseTime;
|
|
22181
|
+
if (redirectPolicy !== void 0) {
|
|
22182
|
+
absoluteStaleAt = Math.min(absoluteStaleAt, redirectPolicy.staleAt);
|
|
22183
|
+
}
|
|
22101
22184
|
if (now >= absoluteStaleAt && !revalidationOnly) {
|
|
22102
22185
|
deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
|
|
22103
22186
|
return downstreamOnHeaders();
|
|
22104
22187
|
}
|
|
22105
22188
|
let varyDirectives;
|
|
22106
|
-
|
|
22107
|
-
|
|
22108
|
-
|
|
22109
|
-
|
|
22189
|
+
const combinedVary = [];
|
|
22190
|
+
if (redirectHopInfo) {
|
|
22191
|
+
for (const hop of redirectHopInfo) {
|
|
22192
|
+
appendVaryValues(combinedVary, hop?.headers?.vary);
|
|
22193
|
+
}
|
|
22194
|
+
}
|
|
22195
|
+
appendVaryValues(combinedVary, resHeaders.vary);
|
|
22196
|
+
if (combinedVary.length > 0) {
|
|
22197
|
+
for (const varyHeader of combinedVary) {
|
|
22198
|
+
if (hasVaryStar(varyHeader)) {
|
|
22199
|
+
return downstreamOnHeaders();
|
|
22200
|
+
}
|
|
22201
|
+
}
|
|
22202
|
+
if (this.#cacheKey.headers) {
|
|
22203
|
+
varyDirectives = parseVaryHeader(combinedVary, this.#cacheKey.headers);
|
|
22204
|
+
if (!varyDirectives) {
|
|
22205
|
+
return downstreamOnHeaders();
|
|
22206
|
+
}
|
|
22207
|
+
}
|
|
22208
|
+
}
|
|
22209
|
+
let effectiveCacheControlDirectives = cacheControlDirectives;
|
|
22210
|
+
if (redirectPolicy !== void 0) {
|
|
22211
|
+
effectiveCacheControlDirectives = { ...cacheControlDirectives };
|
|
22212
|
+
delete effectiveCacheControlDirectives["stale-while-revalidate"];
|
|
22213
|
+
delete effectiveCacheControlDirectives["stale-if-error"];
|
|
22214
|
+
if (redirectPolicy.requiresRevalidation === true) {
|
|
22215
|
+
effectiveCacheControlDirectives["proxy-revalidate"] = true;
|
|
22110
22216
|
}
|
|
22111
22217
|
}
|
|
22112
22218
|
const cachedAt = baseTime;
|
|
22113
|
-
const deleteAt = determineDeleteAt(baseTime, now,
|
|
22219
|
+
const deleteAt = determineDeleteAt(baseTime, now, effectiveCacheControlDirectives, absoluteStaleAt);
|
|
22114
22220
|
const strippedHeaders = stripNecessaryHeaders(resHeaders, cacheControlDirectives);
|
|
22115
22221
|
const value2 = {
|
|
22116
22222
|
statusCode,
|
|
22117
22223
|
statusMessage,
|
|
22118
22224
|
headers: strippedHeaders,
|
|
22119
22225
|
vary: varyDirectives,
|
|
22120
|
-
cacheControlDirectives,
|
|
22226
|
+
cacheControlDirectives: effectiveCacheControlDirectives,
|
|
22121
22227
|
cachedAt,
|
|
22122
22228
|
staleAt: absoluteStaleAt,
|
|
22123
22229
|
deleteAt
|
|
@@ -22131,6 +22237,13 @@ var require_cache_handler = __commonJS({
|
|
|
22131
22237
|
done = true;
|
|
22132
22238
|
this.#downstreamController.release();
|
|
22133
22239
|
};
|
|
22240
|
+
const failReplay = (err) => {
|
|
22241
|
+
if (done) {
|
|
22242
|
+
return;
|
|
22243
|
+
}
|
|
22244
|
+
done = true;
|
|
22245
|
+
controller2.abort(err);
|
|
22246
|
+
};
|
|
22134
22247
|
const handle304 = (cachedValue) => {
|
|
22135
22248
|
if (!cachedValue) {
|
|
22136
22249
|
downstreamOnHeaders();
|
|
@@ -22154,14 +22267,18 @@ var require_cache_handler = __commonJS({
|
|
|
22154
22267
|
if (done) {
|
|
22155
22268
|
return;
|
|
22156
22269
|
}
|
|
22157
|
-
|
|
22158
|
-
const
|
|
22159
|
-
|
|
22160
|
-
|
|
22161
|
-
|
|
22270
|
+
try {
|
|
22271
|
+
for (const chunk of bodyIterator) {
|
|
22272
|
+
const full = this.#writeStream?.write(chunk) === false;
|
|
22273
|
+
this.#handler.onResponseData?.(this.#downstreamController, chunk);
|
|
22274
|
+
if (full) {
|
|
22275
|
+
return;
|
|
22276
|
+
}
|
|
22162
22277
|
}
|
|
22278
|
+
finish304();
|
|
22279
|
+
} catch (err) {
|
|
22280
|
+
failReplay(err);
|
|
22163
22281
|
}
|
|
22164
|
-
finish304();
|
|
22165
22282
|
};
|
|
22166
22283
|
this.#writeStream.on("error", function() {
|
|
22167
22284
|
handler.#writeStream = void 0;
|
|
@@ -22178,8 +22295,13 @@ var require_cache_handler = __commonJS({
|
|
|
22178
22295
|
streamCachedBody();
|
|
22179
22296
|
} else if (typeof cachedValue.body.on === "function") {
|
|
22180
22297
|
cachedValue.body.on("data", (chunk) => {
|
|
22181
|
-
|
|
22182
|
-
|
|
22298
|
+
try {
|
|
22299
|
+
this.#writeStream?.write(chunk);
|
|
22300
|
+
this.#handler.onResponseData?.(this.#downstreamController, chunk);
|
|
22301
|
+
} catch (err) {
|
|
22302
|
+
cachedValue.body.destroy();
|
|
22303
|
+
failReplay(err);
|
|
22304
|
+
}
|
|
22183
22305
|
}).on("end", () => {
|
|
22184
22306
|
this.#writeStream?.end();
|
|
22185
22307
|
finish304();
|
|
@@ -22296,6 +22418,74 @@ var require_cache_handler = __commonJS({
|
|
|
22296
22418
|
}
|
|
22297
22419
|
return true;
|
|
22298
22420
|
}
|
|
22421
|
+
function getRedirectPolicy(cacheType, method, redirectHops, reqHeaders, cacheByDefault, now) {
|
|
22422
|
+
let staleAt = Infinity;
|
|
22423
|
+
let requiresRevalidation = false;
|
|
22424
|
+
for (const hop of redirectHops) {
|
|
22425
|
+
const hopPolicy = getRedirectHopPolicy(cacheType, method, hop, reqHeaders, cacheByDefault);
|
|
22426
|
+
if (hopPolicy === void 0 || hopPolicy.staleAt <= now) {
|
|
22427
|
+
return void 0;
|
|
22428
|
+
}
|
|
22429
|
+
staleAt = Math.min(staleAt, hopPolicy.staleAt);
|
|
22430
|
+
requiresRevalidation ||= hopPolicy.requiresRevalidation;
|
|
22431
|
+
}
|
|
22432
|
+
return { staleAt, requiresRevalidation };
|
|
22433
|
+
}
|
|
22434
|
+
function getRedirectHopPolicy(cacheType, method, hop, reqHeaders, cacheByDefault) {
|
|
22435
|
+
if (!Number.isInteger(hop?.statusCode) || !Number.isFinite(hop?.receivedAt)) {
|
|
22436
|
+
return void 0;
|
|
22437
|
+
}
|
|
22438
|
+
const hopHeaders = hop.headers ?? {};
|
|
22439
|
+
const cacheControlHeader = hopHeaders["cache-control"];
|
|
22440
|
+
const hopCacheControl = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
|
|
22441
|
+
if (hopHeaders.vary && hasVaryStar(hopHeaders.vary)) {
|
|
22442
|
+
return void 0;
|
|
22443
|
+
}
|
|
22444
|
+
if (hopCacheControl["no-store"] === true) {
|
|
22445
|
+
return void 0;
|
|
22446
|
+
}
|
|
22447
|
+
if (cacheType === "shared" && Object.hasOwn(hopCacheControl, "private")) {
|
|
22448
|
+
return void 0;
|
|
22449
|
+
}
|
|
22450
|
+
if (Object.hasOwn(hopCacheControl, "no-cache") || hopCacheControl["must-revalidate"] === true || cacheType === "shared" && hopCacheControl["proxy-revalidate"] === true) {
|
|
22451
|
+
return void 0;
|
|
22452
|
+
}
|
|
22453
|
+
const heuristicallyCacheable = hopHeaders["last-modified"] && arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, hop.statusCode);
|
|
22454
|
+
if (!cacheControlHeader && !hopHeaders.expires && !heuristicallyCacheable && !cacheByDefault) {
|
|
22455
|
+
return void 0;
|
|
22456
|
+
}
|
|
22457
|
+
if (!canCacheResponse(cacheType, method, hop.statusCode, hopHeaders, hopCacheControl, reqHeaders)) {
|
|
22458
|
+
return void 0;
|
|
22459
|
+
}
|
|
22460
|
+
const age = Object.hasOwn(hopHeaders, "age") ? getAge(hopHeaders.age) : void 0;
|
|
22461
|
+
if (age !== void 0 && age >= MAX_RESPONSE_AGE) {
|
|
22462
|
+
return void 0;
|
|
22463
|
+
}
|
|
22464
|
+
const responseDate = Object.hasOwn(hopHeaders, "date") ? getDate(hopHeaders.date) : void 0;
|
|
22465
|
+
if (responseDate === null) {
|
|
22466
|
+
return void 0;
|
|
22467
|
+
}
|
|
22468
|
+
const apparentAge = responseDate ? Math.max(0, hop.receivedAt - responseDate.getTime()) : 0;
|
|
22469
|
+
const currentAge = Math.max(apparentAge, age ?? 0);
|
|
22470
|
+
const hasValidator = typeof hopHeaders.etag === "string" && isEtagUsable(hopHeaders.etag) || typeof hopHeaders["last-modified"] === "string";
|
|
22471
|
+
const freshnessLifetime = determineStaleAt(
|
|
22472
|
+
cacheType,
|
|
22473
|
+
hop.receivedAt,
|
|
22474
|
+
age,
|
|
22475
|
+
hopHeaders,
|
|
22476
|
+
responseDate,
|
|
22477
|
+
hopCacheControl,
|
|
22478
|
+
hasValidator
|
|
22479
|
+
) ?? cacheByDefault;
|
|
22480
|
+
if (freshnessLifetime === void 0) {
|
|
22481
|
+
return void 0;
|
|
22482
|
+
}
|
|
22483
|
+
return {
|
|
22484
|
+
staleAt: hop.receivedAt - currentAge + freshnessLifetime,
|
|
22485
|
+
// RFC 9111 §5.2.2.10: s-maxage implies proxy-revalidate for shared caches.
|
|
22486
|
+
requiresRevalidation: cacheType === "shared" && Object.hasOwn(hopCacheControl, "s-maxage")
|
|
22487
|
+
};
|
|
22488
|
+
}
|
|
22299
22489
|
function getDate(dateHeader) {
|
|
22300
22490
|
let dateValue = dateHeader;
|
|
22301
22491
|
if (Array.isArray(dateValue)) {
|
|
@@ -22797,7 +22987,8 @@ var require_cache2 = __commonJS({
|
|
|
22797
22987
|
normalizeHeaders,
|
|
22798
22988
|
parseCacheControlHeader,
|
|
22799
22989
|
isInvalidOrWildcardVaryHeader,
|
|
22800
|
-
parseVaryHeader
|
|
22990
|
+
parseVaryHeader,
|
|
22991
|
+
isEtagUsable
|
|
22801
22992
|
} = require_cache();
|
|
22802
22993
|
var { AbortError } = require_errors();
|
|
22803
22994
|
var { parseHttpDate } = require_date();
|
|
@@ -22917,6 +23108,34 @@ var require_cache2 = __commonJS({
|
|
|
22917
23108
|
}
|
|
22918
23109
|
return headers;
|
|
22919
23110
|
}
|
|
23111
|
+
function revalidationTargetMatchesCacheKey(cacheKey, context) {
|
|
23112
|
+
const history = context?.history;
|
|
23113
|
+
if (!Array.isArray(history) || history.length === 0) {
|
|
23114
|
+
return true;
|
|
23115
|
+
}
|
|
23116
|
+
try {
|
|
23117
|
+
const cachedUrl = new URL(cacheKey.path, cacheKey.origin);
|
|
23118
|
+
const responseUrl = history[history.length - 1];
|
|
23119
|
+
return responseUrl.origin === cachedUrl.origin && responseUrl.pathname === cachedUrl.pathname && responseUrl.search === cachedUrl.search;
|
|
23120
|
+
} catch {
|
|
23121
|
+
return false;
|
|
23122
|
+
}
|
|
23123
|
+
}
|
|
23124
|
+
function revalidationEtagMatchesCachedValue(result2, headers) {
|
|
23125
|
+
if (!Object.hasOwn(headers, "etag")) {
|
|
23126
|
+
return true;
|
|
23127
|
+
}
|
|
23128
|
+
const responseEtag = headers.etag;
|
|
23129
|
+
const cachedEtag = result2.etag;
|
|
23130
|
+
if (typeof responseEtag !== "string" || typeof cachedEtag !== "string" || !isEtagUsable(responseEtag) || !isEtagUsable(cachedEtag)) {
|
|
23131
|
+
return false;
|
|
23132
|
+
}
|
|
23133
|
+
if (!responseEtag.startsWith("W/")) {
|
|
23134
|
+
return responseEtag === cachedEtag;
|
|
23135
|
+
}
|
|
23136
|
+
const cachedOpaqueTag = cachedEtag.startsWith("W/") ? cachedEtag.slice(2) : cachedEtag;
|
|
23137
|
+
return responseEtag.slice(2) === cachedOpaqueTag;
|
|
23138
|
+
}
|
|
22920
23139
|
function isStale(result2, cacheControlDirectives, cacheType) {
|
|
22921
23140
|
const now = Date.now();
|
|
22922
23141
|
if (now > result2.staleAt || result2.staleAt <= result2.cachedAt) {
|
|
@@ -23014,18 +23233,23 @@ var require_cache2 = __commonJS({
|
|
|
23014
23233
|
};
|
|
23015
23234
|
stream.on("error", function(err) {
|
|
23016
23235
|
if (!this.readableEnded) {
|
|
23017
|
-
|
|
23018
|
-
handler.onResponseError(controller2, err);
|
|
23019
|
-
} else {
|
|
23020
|
-
throw err;
|
|
23021
|
-
}
|
|
23236
|
+
handler.onResponseError?.(controller2, err);
|
|
23022
23237
|
}
|
|
23023
23238
|
}).on("close", function() {
|
|
23024
23239
|
if (!this.errored) {
|
|
23025
|
-
|
|
23240
|
+
try {
|
|
23241
|
+
handler.onResponseEnd?.(controller2, {});
|
|
23242
|
+
} catch (err) {
|
|
23243
|
+
handler.onResponseError?.(controller2, err);
|
|
23244
|
+
}
|
|
23026
23245
|
}
|
|
23027
23246
|
});
|
|
23028
|
-
|
|
23247
|
+
try {
|
|
23248
|
+
handler.onRequestStart?.(controller2, context);
|
|
23249
|
+
} catch (err) {
|
|
23250
|
+
stream.destroy(err);
|
|
23251
|
+
return;
|
|
23252
|
+
}
|
|
23029
23253
|
if (stream.destroyed) {
|
|
23030
23254
|
return;
|
|
23031
23255
|
}
|
|
@@ -23034,12 +23258,21 @@ var require_cache2 = __commonJS({
|
|
|
23034
23258
|
headers.warning = '110 - "response is stale"';
|
|
23035
23259
|
}
|
|
23036
23260
|
controller2.rawHeaders = util.toRawHeaders(headers);
|
|
23037
|
-
|
|
23261
|
+
try {
|
|
23262
|
+
handler.onResponseStart?.(controller2, result2.statusCode, headers, result2.statusMessage);
|
|
23263
|
+
} catch (err) {
|
|
23264
|
+
stream.destroy(err);
|
|
23265
|
+
return;
|
|
23266
|
+
}
|
|
23038
23267
|
if (opts.method === "HEAD") {
|
|
23039
23268
|
stream.destroy();
|
|
23040
23269
|
} else {
|
|
23041
23270
|
stream.on("data", function(chunk) {
|
|
23042
|
-
|
|
23271
|
+
try {
|
|
23272
|
+
handler.onResponseData?.(controller2, chunk);
|
|
23273
|
+
} catch (err) {
|
|
23274
|
+
stream.destroy(err);
|
|
23275
|
+
}
|
|
23043
23276
|
});
|
|
23044
23277
|
}
|
|
23045
23278
|
}
|
|
@@ -23102,6 +23335,13 @@ var require_cache2 = __commonJS({
|
|
|
23102
23335
|
}
|
|
23103
23336
|
}
|
|
23104
23337
|
const headers = makeRevalidationHeaders(opts, result2);
|
|
23338
|
+
const refetch = () => {
|
|
23339
|
+
if (util.isStream(result2.body)) {
|
|
23340
|
+
result2.body.on("error", nop).destroy();
|
|
23341
|
+
}
|
|
23342
|
+
deleteCachedValue(globalOpts.store, cacheKey);
|
|
23343
|
+
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
23344
|
+
};
|
|
23105
23345
|
return dispatch(
|
|
23106
23346
|
{
|
|
23107
23347
|
...opts,
|
|
@@ -23111,21 +23351,13 @@ var require_cache2 = __commonJS({
|
|
|
23111
23351
|
(success2, context, statusCode, headers2) => {
|
|
23112
23352
|
if (success2) {
|
|
23113
23353
|
if (statusCode === 304) {
|
|
23114
|
-
if (revalidationResponseDisallowsCachedReuse(globalOpts.type, headers2)) {
|
|
23115
|
-
|
|
23116
|
-
result2.body.on("error", nop).destroy();
|
|
23117
|
-
}
|
|
23118
|
-
deleteCachedValue(globalOpts.store, cacheKey);
|
|
23119
|
-
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
23354
|
+
if (!revalidationTargetMatchesCacheKey(cacheKey, context) || !revalidationEtagMatchesCachedValue(result2, headers2) || revalidationResponseDisallowsCachedReuse(globalOpts.type, headers2)) {
|
|
23355
|
+
return refetch();
|
|
23120
23356
|
}
|
|
23121
23357
|
if (revalidationResponseUpdatesCacheControl(headers2)) {
|
|
23122
23358
|
deleteCachedValue(globalOpts.store, cacheKey);
|
|
23123
23359
|
} else if (revalidationResponseAddsVary(result2, headers2.vary ? parseVaryHeader(headers2.vary, opts.headers) : void 0)) {
|
|
23124
|
-
|
|
23125
|
-
result2.body.on("error", nop).destroy();
|
|
23126
|
-
}
|
|
23127
|
-
deleteCachedValue(globalOpts.store, cacheKey);
|
|
23128
|
-
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
23360
|
+
return refetch();
|
|
23129
23361
|
}
|
|
23130
23362
|
}
|
|
23131
23363
|
sendCachedValue(handler, opts, result2, age, context, stale);
|
|
@@ -23223,7 +23455,31 @@ var require_cache2 = __commonJS({
|
|
|
23223
23455
|
opts2,
|
|
23224
23456
|
reqCacheControl,
|
|
23225
23457
|
result3
|
|
23226
|
-
))
|
|
23458
|
+
)).catch((err) => {
|
|
23459
|
+
if (typeof handler.onResponseError === "function") {
|
|
23460
|
+
handler.onResponseError({
|
|
23461
|
+
rawHeaders: [],
|
|
23462
|
+
rawTrailers: [],
|
|
23463
|
+
pause() {
|
|
23464
|
+
},
|
|
23465
|
+
resume() {
|
|
23466
|
+
},
|
|
23467
|
+
get paused() {
|
|
23468
|
+
return false;
|
|
23469
|
+
},
|
|
23470
|
+
get aborted() {
|
|
23471
|
+
return false;
|
|
23472
|
+
},
|
|
23473
|
+
get reason() {
|
|
23474
|
+
return null;
|
|
23475
|
+
},
|
|
23476
|
+
abort() {
|
|
23477
|
+
}
|
|
23478
|
+
}, err);
|
|
23479
|
+
} else {
|
|
23480
|
+
throw err;
|
|
23481
|
+
}
|
|
23482
|
+
});
|
|
23227
23483
|
} else {
|
|
23228
23484
|
return handleResult(
|
|
23229
23485
|
dispatch,
|
|
@@ -24231,10 +24487,15 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24231
24487
|
var { assertCacheKey, assertCacheValue } = require_cache();
|
|
24232
24488
|
var { zstdCompressSync, zstdDecompressSync } = __require("node:zlib");
|
|
24233
24489
|
var DatabaseSync;
|
|
24234
|
-
var VERSION =
|
|
24490
|
+
var VERSION = 5;
|
|
24235
24491
|
var MAX_ENTRY_SIZE = 2 * 1e3 * 1e3 * 1e3;
|
|
24236
24492
|
var COMPRESS_THRESHOLD = 1024 * 1024;
|
|
24237
24493
|
var hasZstd = typeof zstdCompressSync === "function" && typeof zstdDecompressSync === "function";
|
|
24494
|
+
var SQLITE_BUSY = 5;
|
|
24495
|
+
var SQLITE_LOCKED = 6;
|
|
24496
|
+
function isLockedError(err) {
|
|
24497
|
+
return err?.errcode === SQLITE_BUSY || err?.errcode === SQLITE_LOCKED;
|
|
24498
|
+
}
|
|
24238
24499
|
module.exports = class SqliteCacheStore {
|
|
24239
24500
|
#maxEntrySize = MAX_ENTRY_SIZE;
|
|
24240
24501
|
#maxCount = Infinity;
|
|
@@ -24417,7 +24678,7 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24417
24678
|
*/
|
|
24418
24679
|
get(key) {
|
|
24419
24680
|
assertCacheKey(key);
|
|
24420
|
-
const value2 = this.#findValue(key);
|
|
24681
|
+
const value2 = this.#lockSafe(() => this.#findValue(key));
|
|
24421
24682
|
return value2 ? {
|
|
24422
24683
|
body: value2.body ? value2.compressed === "zstd" ? zstdDecompressSync(Buffer.from(value2.body.buffer, value2.body.byteOffset, value2.body.byteLength)) : Buffer.from(value2.body.buffer, value2.body.byteOffset, value2.body.byteLength) : void 0,
|
|
24423
24684
|
statusCode: value2.statusCode,
|
|
@@ -24452,9 +24713,9 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24452
24713
|
compressed = "zstd";
|
|
24453
24714
|
}
|
|
24454
24715
|
}
|
|
24455
|
-
const existingValue = this.#findValue(key, true);
|
|
24716
|
+
const existingValue = this.#lockSafe(() => this.#findValue(key, true));
|
|
24456
24717
|
if (existingValue) {
|
|
24457
|
-
this.#updateValueQuery.run(
|
|
24718
|
+
this.#lockSafe(() => this.#updateValueQuery.run(
|
|
24458
24719
|
storedBody,
|
|
24459
24720
|
compressed,
|
|
24460
24721
|
value2.deleteAt,
|
|
@@ -24467,9 +24728,9 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24467
24728
|
value2.cachedAt,
|
|
24468
24729
|
value2.staleAt,
|
|
24469
24730
|
existingValue.id
|
|
24470
|
-
);
|
|
24731
|
+
));
|
|
24471
24732
|
} else {
|
|
24472
|
-
this.#insertValueQuery.run(
|
|
24733
|
+
this.#lockSafe(() => this.#insertValueQuery.run(
|
|
24473
24734
|
url3,
|
|
24474
24735
|
key.method,
|
|
24475
24736
|
storedBody,
|
|
@@ -24483,7 +24744,7 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24483
24744
|
value2.vary ? JSON.stringify(value2.vary) : null,
|
|
24484
24745
|
value2.cachedAt,
|
|
24485
24746
|
value2.staleAt
|
|
24486
|
-
);
|
|
24747
|
+
));
|
|
24487
24748
|
this.#prune();
|
|
24488
24749
|
}
|
|
24489
24750
|
}
|
|
@@ -24522,20 +24783,46 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
24522
24783
|
if (typeof key !== "object") {
|
|
24523
24784
|
throw new TypeError(`expected key to be object, got ${typeof key}`);
|
|
24524
24785
|
}
|
|
24525
|
-
this.#deleteByUrlQuery.run(this.#makeValueUrl(key));
|
|
24786
|
+
this.#lockSafe(() => this.#deleteByUrlQuery.run(this.#makeValueUrl(key)));
|
|
24787
|
+
}
|
|
24788
|
+
/**
|
|
24789
|
+
* Runs a database operation, skipping it when another connection holds the
|
|
24790
|
+
* database lock.
|
|
24791
|
+
*
|
|
24792
|
+
* The cache store is meant to be shared between processes, and SQLite reports
|
|
24793
|
+
* a concurrent writer as SQLITE_BUSY/SQLITE_LOCKED. Those errors are
|
|
24794
|
+
* transient, and caching is best effort: the entry is skipped and the next
|
|
24795
|
+
* request retries, rather than failing the request that triggered the write.
|
|
24796
|
+
*
|
|
24797
|
+
* @template T
|
|
24798
|
+
* @param {() => T} fn
|
|
24799
|
+
* @returns {T | undefined}
|
|
24800
|
+
*/
|
|
24801
|
+
#lockSafe(fn) {
|
|
24802
|
+
try {
|
|
24803
|
+
return fn();
|
|
24804
|
+
} catch (err) {
|
|
24805
|
+
if (!isLockedError(err)) {
|
|
24806
|
+
throw err;
|
|
24807
|
+
}
|
|
24808
|
+
return void 0;
|
|
24809
|
+
}
|
|
24526
24810
|
}
|
|
24527
24811
|
#prune() {
|
|
24528
|
-
if (Number.isFinite(this.#maxCount)
|
|
24529
|
-
|
|
24812
|
+
if (Number.isFinite(this.#maxCount)) {
|
|
24813
|
+
const size = this.#lockSafe(() => this.size);
|
|
24814
|
+
if (size === void 0 || size <= this.#maxCount) {
|
|
24815
|
+
return 0;
|
|
24816
|
+
}
|
|
24530
24817
|
}
|
|
24531
24818
|
{
|
|
24532
|
-
const removed = this.#deleteExpiredValuesQuery.run(Date.now()).changes;
|
|
24819
|
+
const removed = this.#lockSafe(() => this.#deleteExpiredValuesQuery.run(Date.now()).changes);
|
|
24533
24820
|
if (removed) {
|
|
24534
24821
|
return removed;
|
|
24535
24822
|
}
|
|
24536
24823
|
}
|
|
24537
24824
|
{
|
|
24538
|
-
const removed = this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes;
|
|
24825
|
+
const removed = this.#lockSafe(() => this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes);
|
|
24539
24826
|
if (removed) {
|
|
24540
24827
|
return removed;
|
|
24541
24828
|
}
|
|
@@ -25524,41 +25811,64 @@ var require_request2 = __commonJS({
|
|
|
25524
25811
|
var { URLSerializer } = require_data_url();
|
|
25525
25812
|
var { kConstruct } = require_symbols();
|
|
25526
25813
|
var assert2 = __require("node:assert");
|
|
25527
|
-
var {
|
|
25528
|
-
|
|
25529
|
-
var requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
|
|
25530
|
-
signal.removeEventListener("abort", abort);
|
|
25814
|
+
var requestFinalizer = new FinalizationRegistry(({ signal, reference }) => {
|
|
25815
|
+
removeSignalFollower(signal, reference);
|
|
25531
25816
|
});
|
|
25532
|
-
var
|
|
25533
|
-
var
|
|
25534
|
-
|
|
25535
|
-
|
|
25536
|
-
|
|
25537
|
-
|
|
25538
|
-
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
|
|
25547
|
-
|
|
25548
|
-
|
|
25549
|
-
|
|
25550
|
-
|
|
25551
|
-
|
|
25552
|
-
|
|
25553
|
-
|
|
25554
|
-
|
|
25555
|
-
|
|
25556
|
-
|
|
25557
|
-
|
|
25558
|
-
|
|
25559
|
-
|
|
25560
|
-
|
|
25817
|
+
var requestSignals = /* @__PURE__ */ new WeakMap();
|
|
25818
|
+
var signalFollowers = /* @__PURE__ */ new WeakMap();
|
|
25819
|
+
function removeSignalFollower(signal, reference) {
|
|
25820
|
+
const followers = signalFollowers.get(signal);
|
|
25821
|
+
if (followers instanceof Set) {
|
|
25822
|
+
followers.delete(reference);
|
|
25823
|
+
if (followers.size !== 0) return;
|
|
25824
|
+
}
|
|
25825
|
+
signal.removeEventListener("abort", abortSignalFollowers);
|
|
25826
|
+
signalFollowers.delete(signal);
|
|
25827
|
+
}
|
|
25828
|
+
function abortSignalFollower(reference, reason2) {
|
|
25829
|
+
requestFinalizer.unregister(reference);
|
|
25830
|
+
const ac = reference.deref();
|
|
25831
|
+
if (ac !== void 0) {
|
|
25832
|
+
requestSignals.delete(ac.signal);
|
|
25833
|
+
ac.abort(reason2);
|
|
25834
|
+
}
|
|
25835
|
+
}
|
|
25836
|
+
function abortSignalFollowers() {
|
|
25837
|
+
this.removeEventListener("abort", abortSignalFollowers);
|
|
25838
|
+
const followers = signalFollowers.get(this);
|
|
25839
|
+
if (followers instanceof Set) {
|
|
25840
|
+
for (const reference of followers) {
|
|
25841
|
+
abortSignalFollower(reference, this.reason);
|
|
25842
|
+
}
|
|
25843
|
+
followers.clear();
|
|
25844
|
+
} else {
|
|
25845
|
+
abortSignalFollower(followers, this.reason);
|
|
25846
|
+
}
|
|
25847
|
+
signalFollowers.delete(this);
|
|
25848
|
+
}
|
|
25849
|
+
function createDependentSignal(signal) {
|
|
25850
|
+
const ac = new AbortController();
|
|
25851
|
+
if (signal == null) return ac.signal;
|
|
25852
|
+
if (signal.aborted) {
|
|
25853
|
+
ac.abort(signal.reason);
|
|
25854
|
+
return ac.signal;
|
|
25855
|
+
}
|
|
25856
|
+
const reference = new WeakRef(ac);
|
|
25857
|
+
const followers = signalFollowers.get(signal);
|
|
25858
|
+
if (followers === void 0) {
|
|
25859
|
+
util.addAbortListener(signal, abortSignalFollowers);
|
|
25860
|
+
signalFollowers.set(signal, reference);
|
|
25861
|
+
} else if (followers instanceof WeakRef) {
|
|
25862
|
+
const controllers = /* @__PURE__ */ new Set();
|
|
25863
|
+
controllers.add(followers);
|
|
25864
|
+
controllers.add(reference);
|
|
25865
|
+
signalFollowers.set(signal, controllers);
|
|
25866
|
+
} else {
|
|
25867
|
+
followers.add(reference);
|
|
25561
25868
|
}
|
|
25869
|
+
requestFinalizer.register(ac, { signal, reference }, reference);
|
|
25870
|
+
requestSignals.set(ac.signal, { controller: ac, source: signal, reference });
|
|
25871
|
+
return ac.signal;
|
|
25562
25872
|
}
|
|
25563
25873
|
var patchMethodWarning = false;
|
|
25564
25874
|
var setRequestSignal;
|
|
@@ -25576,12 +25886,6 @@ var require_request2 = __commonJS({
|
|
|
25576
25886
|
/** @type {Headers} */
|
|
25577
25887
|
#headers;
|
|
25578
25888
|
#state;
|
|
25579
|
-
/**
|
|
25580
|
-
* Removes the `abort` listener that makes this request's signal follow the
|
|
25581
|
-
* passed signal. `null` when no such listener was registered.
|
|
25582
|
-
* @type {(() => void) | null}
|
|
25583
|
-
*/
|
|
25584
|
-
#abortCleanup = null;
|
|
25585
25889
|
// https://fetch.spec.whatwg.org/#dom-request
|
|
25586
25890
|
constructor(input2, init = void 0) {
|
|
25587
25891
|
webidl.util.markAsUncloneable(this);
|
|
@@ -25767,27 +26071,7 @@ var require_request2 = __commonJS({
|
|
|
25767
26071
|
signal = init.signal;
|
|
25768
26072
|
}
|
|
25769
26073
|
this.#state = request2;
|
|
25770
|
-
|
|
25771
|
-
this.#signal = ac.signal;
|
|
25772
|
-
if (signal != null) {
|
|
25773
|
-
if (signal.aborted) {
|
|
25774
|
-
ac.abort(signal.reason);
|
|
25775
|
-
} else {
|
|
25776
|
-
this[kAbortController] = ac;
|
|
25777
|
-
const acRef = new WeakRef(ac);
|
|
25778
|
-
const abort = buildAbort(acRef);
|
|
25779
|
-
if (abortSignalHasEventHandlerLeakWarning && getMaxListeners(signal) === defaultMaxListeners) {
|
|
25780
|
-
setMaxListeners(1500, signal);
|
|
25781
|
-
}
|
|
25782
|
-
const removeAbortListener = util.addAbortListener(signal, abort);
|
|
25783
|
-
requestFinalizer.register(ac, { signal, abort }, abort);
|
|
25784
|
-
this.#abortCleanup = () => {
|
|
25785
|
-
requestFinalizer.unregister(abort);
|
|
25786
|
-
removeAbortListener();
|
|
25787
|
-
this.#abortCleanup = null;
|
|
25788
|
-
};
|
|
25789
|
-
}
|
|
25790
|
-
}
|
|
26074
|
+
this.#signal = createDependentSignal(signal);
|
|
25791
26075
|
this.#headers = new Headers(kConstruct);
|
|
25792
26076
|
setHeadersList(this.#headers, request2.headersList);
|
|
25793
26077
|
setHeadersGuard(this.#headers, "request");
|
|
@@ -25981,23 +26265,8 @@ var require_request2 = __commonJS({
|
|
|
25981
26265
|
throw new TypeError("unusable");
|
|
25982
26266
|
}
|
|
25983
26267
|
const clonedRequest = cloneRequest(this.#state);
|
|
25984
|
-
const
|
|
25985
|
-
|
|
25986
|
-
ac.abort(this.signal.reason);
|
|
25987
|
-
} else {
|
|
25988
|
-
let list2 = dependentControllerMap.get(this.signal);
|
|
25989
|
-
if (list2 === void 0) {
|
|
25990
|
-
list2 = /* @__PURE__ */ new Set();
|
|
25991
|
-
dependentControllerMap.set(this.signal, list2);
|
|
25992
|
-
}
|
|
25993
|
-
const acRef = new WeakRef(ac);
|
|
25994
|
-
list2.add(acRef);
|
|
25995
|
-
util.addAbortListener(
|
|
25996
|
-
ac.signal,
|
|
25997
|
-
buildAbort(acRef)
|
|
25998
|
-
);
|
|
25999
|
-
}
|
|
26000
|
-
return fromInnerRequest(clonedRequest, this.#dispatcher, ac.signal, getHeadersGuard(this.#headers));
|
|
26268
|
+
const signal = createDependentSignal(this.#signal);
|
|
26269
|
+
return fromInnerRequest(clonedRequest, this.#dispatcher, signal, getHeadersGuard(this.#headers));
|
|
26001
26270
|
}
|
|
26002
26271
|
[nodeUtil.inspect.custom](depth, options) {
|
|
26003
26272
|
if (options.depth === null) {
|
|
@@ -26043,7 +26312,12 @@ var require_request2 = __commonJS({
|
|
|
26043
26312
|
request2.#state = newState;
|
|
26044
26313
|
};
|
|
26045
26314
|
removeRequestAbortListener = (request2) => {
|
|
26046
|
-
request2.#
|
|
26315
|
+
const state = requestSignals.get(request2.#signal);
|
|
26316
|
+
if (state !== void 0) {
|
|
26317
|
+
requestSignals.delete(request2.#signal);
|
|
26318
|
+
requestFinalizer.unregister(state.reference);
|
|
26319
|
+
removeSignalFollower(state.source, state.reference);
|
|
26320
|
+
}
|
|
26047
26321
|
};
|
|
26048
26322
|
webidl.is.Request = (arg) => {
|
|
26049
26323
|
return arg != null && typeof arg === "object" && #state in arg;
|
|
@@ -26325,7 +26599,7 @@ var require_subresource_integrity = __commonJS({
|
|
|
26325
26599
|
}
|
|
26326
26600
|
function parseMetadata(metadata2) {
|
|
26327
26601
|
const result2 = [];
|
|
26328
|
-
for (const item of metadata2.split(
|
|
26602
|
+
for (const item of metadata2.split(/[\t\n\f\r ]+/)) {
|
|
26329
26603
|
const expressionAndOptions = item.split("?", 1);
|
|
26330
26604
|
const algorithmExpression = expressionAndOptions[0];
|
|
26331
26605
|
let base64Value = "";
|
|
@@ -26576,11 +26850,8 @@ var require_fetch = __commonJS({
|
|
|
26576
26850
|
cleanupAbortListeners();
|
|
26577
26851
|
},
|
|
26578
26852
|
processResponse,
|
|
26579
|
-
dispatcher: getRequestDispatcher(requestObject)
|
|
26853
|
+
dispatcher: getRequestDispatcher(requestObject)
|
|
26580
26854
|
// undici
|
|
26581
|
-
// Keep requestObject alive to prevent its AbortController from being GC'd
|
|
26582
|
-
// See https://github.com/nodejs/undici/issues/4627
|
|
26583
|
-
requestObject
|
|
26584
26855
|
});
|
|
26585
26856
|
return p.promise;
|
|
26586
26857
|
}
|
|
@@ -26648,10 +26919,8 @@ var require_fetch = __commonJS({
|
|
|
26648
26919
|
processResponseEndOfBody,
|
|
26649
26920
|
processResponseConsumeBody,
|
|
26650
26921
|
useParallelQueue = false,
|
|
26651
|
-
dispatcher: dispatcher2 = getGlobalDispatcher()
|
|
26922
|
+
dispatcher: dispatcher2 = getGlobalDispatcher()
|
|
26652
26923
|
// undici
|
|
26653
|
-
requestObject = null
|
|
26654
|
-
// Keep alive to prevent AbortController GC, see #4627
|
|
26655
26924
|
}) {
|
|
26656
26925
|
assert2(dispatcher2);
|
|
26657
26926
|
let taskDestination = null;
|
|
@@ -26674,9 +26943,7 @@ var require_fetch = __commonJS({
|
|
|
26674
26943
|
processResponseConsumeBody,
|
|
26675
26944
|
processResponseEndOfBody,
|
|
26676
26945
|
taskDestination,
|
|
26677
|
-
crossOriginIsolatedCapability
|
|
26678
|
-
// Keep requestObject alive to prevent its AbortController from being GC'd
|
|
26679
|
-
requestObject
|
|
26946
|
+
crossOriginIsolatedCapability
|
|
26680
26947
|
};
|
|
26681
26948
|
assert2(!request2.body || request2.body.stream);
|
|
26682
26949
|
if (request2.window === "client") {
|
|
@@ -56540,7 +56807,9 @@ var import_ipaddr2 = __toESM(require_ipaddr(), 1);
|
|
|
56540
56807
|
// ../../src/contracts/plans.ts
|
|
56541
56808
|
var ACCOUNT_PLANS = Object.freeze({
|
|
56542
56809
|
starter: Object.freeze({
|
|
56543
|
-
|
|
56810
|
+
// HTTP, certificate and heartbeat checks run on the host and cost close
|
|
56811
|
+
// to nothing; scripts, which cost runner time, stay at one (PRICING.md).
|
|
56812
|
+
monitors: 10,
|
|
56544
56813
|
// HTTP, certificate, heartbeat, MCP, TCP and DNS checks.
|
|
56545
56814
|
checkMinInterval: 1800,
|
|
56546
56815
|
scriptMonitors: 1,
|
|
@@ -58326,7 +58595,7 @@ import { performance as performance4 } from "node:perf_hooks";
|
|
|
58326
58595
|
// package.json
|
|
58327
58596
|
var package_default = {
|
|
58328
58597
|
name: "@waitcher/cli",
|
|
58329
|
-
version: "0.2.
|
|
58598
|
+
version: "0.2.28",
|
|
58330
58599
|
description: "Synthetic monitoring from your repository: deploy HTTP, certificate, heartbeat, API, browser and visual monitors from waitcher.json.",
|
|
58331
58600
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
58332
58601
|
author: "S\u0142awomir Radzymi\u0144ski",
|
|
@@ -60307,11 +60576,11 @@ var CONFIG_LIMITS = Object.freeze({
|
|
|
60307
60576
|
secretBytes: 8192
|
|
60308
60577
|
});
|
|
60309
60578
|
var RUNTIME_PINS = Object.freeze({
|
|
60310
|
-
e2e: "0.
|
|
60311
|
-
"@e2e-dev/web": "0.
|
|
60579
|
+
e2e: "0.24.0",
|
|
60580
|
+
"@e2e-dev/web": "0.16.1",
|
|
60312
60581
|
esbuild: "0.28.2"
|
|
60313
60582
|
});
|
|
60314
|
-
var RUNTIME_PREVIOUS = Object.freeze({});
|
|
60583
|
+
var RUNTIME_PREVIOUS = Object.freeze({ e2e: "0.21.1", "@e2e-dev/web": "0.15.1" });
|
|
60315
60584
|
var RUNTIME_OVERRIDES = Object.freeze({ e2e: { zod: "4.6.7" } });
|
|
60316
60585
|
var runtimePinStatus = (name5, found, previous = RUNTIME_PREVIOUS) => found === RUNTIME_PINS[name5] ? "current" : found !== null && found === previous[name5] ? "previous" : "mismatch";
|
|
60317
60586
|
var runtimePackages = (browser) => browser ? ["e2e", "@e2e-dev/web", "esbuild"] : ["e2e", "esbuild"];
|
|
@@ -61276,7 +61545,7 @@ async function runtime(project, browser, ai = false) {
|
|
|
61276
61545
|
}
|
|
61277
61546
|
const root = await locate("e2e", RUNTIME_PINS.e2e);
|
|
61278
61547
|
if (browser) await locate("@e2e-dev/web", RUNTIME_PINS["@e2e-dev/web"]);
|
|
61279
|
-
if (ai) await locate("ai", "7.0.
|
|
61548
|
+
if (ai) await locate("ai", "7.0.177");
|
|
61280
61549
|
return join8(root, "dist/cli/bin.js");
|
|
61281
61550
|
}
|
|
61282
61551
|
async function inventory(root) {
|
|
@@ -62760,13 +63029,13 @@ function deployNextSteps(result2, {
|
|
|
62760
63029
|
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";
|
|
62761
63030
|
|
|
62762
63031
|
// ../../skills/waitcher/references/authoring.md
|
|
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.
|
|
63032
|
+
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.24.0` and, for browser tests, `@e2e-dev/web@0.16.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';
|
|
62764
63033
|
|
|
62765
63034
|
// ../../skills/waitcher/references/ai-and-agents.md
|
|
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";
|
|
63035
|
+
var ai_and_agents_default = "# AI endpoints, agent outcomes and model steps\n\nRead only when `waitcher system capabilities` reports the feature and the user needs it. Deterministic HTTP, API and browser monitors need none of this; see [authoring](authoring.md).\n\n## Agent outcome checks\n\nFor hosted scripts using `#waitcher/scenario`, first confirm `features.scenarioEvidence` through `system capabilities`, alongside script admission. Older servers may not provide this helper. Do not silently remove required scenario checks to make an unsupported run pass. Capability discovery is separate from native security, capacity and production release acceptance.\n\nFor an agent that changes application state, start with `monitor init --template agent-outcome --file outcome.json --target https://product.example/api/`. It creates a paused ordinary API script, with no model binding or paid-provider requirement. Adapt its fixed `agent/tasks` submission and `notes/{runId}` resource paths, disposable test namespace and exact expected fields. It submits one action, ignores claims of success and response-provided URLs, then independently reads the known resource at most three times. A fresh per-run random `id` and `correlationId` must both match, alongside the expected result. Action transport errors are never automatically retried. Cleanup runs in `finally` only after an independent read proves the resource belongs to this run; cleanup failures fail the test. If ownership or the action result is uncertain, it records cleanup as unverified and leaves state untouched. Reconcile possible late actions before repeating a mutating test. This pattern verifies the chosen outcome, not the agent's overall quality or the correctness of its explanation.\n\nThe starter uses the optional `#waitcher/scenario` helper with required submit/action, observe, verify and cleanup phases. `createScenario({id, phases})` returns `phase(id, callback)`, `assert(boolean)` and `incomplete(reason)`. Call signals only inside an active phase. Every scenario needs a required verify phase, and an executed verify phase must call `scenario.assert` at least once; an empty verification cannot establish pass. `assert(false)` records a business failure even if caught; ordinary callback exceptions and `incomplete(\"CLEANUP_UNVERIFIED\")` record coverage errors. Inspect `.e2e/waitcher-scenarios.json` in the private evidence: required phases that never ran or remain in flight also prevent a pass. Coverage error takes precedence while retaining failed verification facts. A false agent claim can therefore produce a failed verify phase and an overall error when cleanup remains uncertain. The helper does not automatically classify arbitrary E2E assertions or infer agent/tool traces. Use stable non-secret scenario/phase IDs, avoid raw response values in assertions, and do not use report labels as secret storage.\n\nUse the unchanged file with `monitor validate`, account-free `run local --file outcome.json --runtime YOUR_PINNED_RUNTIME`, and the existing API-script editor or `monitor apply --file outcome.json --dry-run`. Keep it paused after applying. Project authors can extract the script into `scriptFile`, keep helper imports and use `monitor build` to create one portable script; `#waitcher/scenario` stays external and is supplied by the manifest runner. The complete CLI includes `scenario-runtime.mjs`; keep package companions together. Standalone `--project` needs its own helper integration. The starter's default is credential-free. Optional local/trusted-administrator bearer tokens use `CHECK_AGENT_ACTION_TOKEN`, `CHECK_RESOURCE_READ_TOKEN` and `CHECK_RESOURCE_CLEANUP_TOKEN`, explicitly listed in `settings.envNames` and supplied outside the manifest. Hosted personal scripts receive `CHECK_*` values only from their project environment's secrets (`waitcher secret set`), never from the server's environment; do not work around that boundary. Do not log credentials or response bodies, and do not promise complete trace masking for arbitrary custom environment values. Local success does not establish hosted admission or isolation.\n\n## Scenario evidence\n\nInspect readable scenario evidence with `waitcher run scenarios --id RUN_ID`, or use `waitcher run scenarios --directory PRIVATE_RUN_DIR` for account-free local inspection without a server/runtime. Add `--json` for the exact shared report DTO. Do not combine selectors or pass `--server` for local inspection. Inspection of failed/error runs succeeds; execution exit codes remain unchanged. Keep authoritative run status separate from evidence availability: empty valid reports verify no business outcome, and pending/not-recorded/expired/invalid reports cannot establish a pass. Local evidence is checked against its recorded inventory and checksum; never edit it to manufacture a successful outcome.\n\n## AI product endpoints\n\nFor a single AI product endpoint, prefer a declarative `type: \"ai\"` fixture over an E2E script. Run `monitor init --type ai --target https://product.example/ai --file ai.json`, replace the sample request and response checks with the product contract, then `monitor validate --file ai.json`. JSON-pointer assertions support exact equality, type, existence and literal case-sensitive contains/not-contains/contains-any/contains-all checks; an optional bounded response schema checks structure. `run local --file ai.json` uses the same one-POST adapter without an account, model connection, provider key or E2E runtime. It only reaches public HTTPS endpoints and supports optional verified `httpAuth` references as described below; arbitrary custom headers and account-session inheritance are forbidden. Inspect the structured per-assertion report and distinguish transport coverage errors from product assertion failures. Applying the same file to hosted monitoring requires `features.aiEndpoints`; personal admission also requires a currently verified `httpAuth` binding; keep it paused unless scheduling is authorized. This verifies a chosen fixture, not general agent quality or a calibrated semantic judge.\n\nFor a small set of representative prompts against the same endpoint, use `aiEndpoint.adapter: \"json-http-suite-v1\"` and `cases` with 1\u20135 objects containing a stable unique `id`, readable `name`, positive `revision` (default 1), literal JSON-object `fixture`, and assertions and/or response schema. The suite `invocationBudget` equals its case count and is filled in when omitted. Validate offline and run the unchanged manifest locally before applying it; hosted capability `features.aiEndpointSuites` must be available. Cases run serially under one total monitor timeout. Assertion failures permit later cases; a transport/deadline error stops them as `not-run`. Inspect every case and coverage summary, not only the overall status. The controller reserves the full case count before any hosted request, and partial/uncertain runs retain that conservative allowance. Reported attempted requests can therefore be fewer than charged units. Deterministic suites do not provide semantic grading; do not describe text matching as semantic correctness. Single fixtures and each suite case can opt into literal variables with variables:{name:\"string\"} and exact {{name}} placeholders inside fixture string values. Without variables, braces remain literal. Use at most 16 names, ASCII letter followed by letters/digits/underscores (64 characters); prototype-related names are refused. Each value fits 4 KiB UTF-8, maps and rendered fixtures 16 KiB and complete configurations 64 KiB. No expressions, environment lookup, key/URL/assertion/rubric interpolation, matrix expansion or recursive replacement is supported. Missing/malformed placeholders reject before requests. Use non-secret data. Validate locally and preview before applying: exports keep authored maps while enqueue freezes rendered literal requests. Release comparisons use effective rendered bodies, so a changed variable value can be a changed policy even with the same case revision.\n\nFor optional semantic endpoint grading, use `json-http-graded-suite-v1`, portable schemaVersion 2 and explicit context (even the default project/environment). Set the top-level `judge` connectionId/configurationRevision/model/budget and add a rubric to each selected case: stable id/revision, criteria, outputPath, threshold and optional reference examples. Keep target credentials separate from judge keys. Hosted use requires `features.endpointJudges`; local use accepts the same private `--connections-file` map without an account, UI or E2E runtime. Only the selected output and rubric criteria/examples reach the judge. Known echoed managed product keys are refused before grading. Inspect score, verdict, rubric hash and private model-usage.json: malformed/unavailable/unknown/over-budget grading is inconclusive coverage and cannot pass or recover a product incident. There are no retries or fallback models. Every report currently marks calibration unverified; labelled reference examples do not prove accuracy. Keep calibration, pricing and release acceptance distinct from a controlled protocol pass.\n\nTo measure a rubric against labelled examples, use `monitor calibrate --id ID --file REQUEST_JSON` for a saved hosted monitor, then `monitor calibrations --id ID` or `monitor calibration --id ID --calibration-id ID` to inspect retained measurements. The request contains `caseId`, `dataset` and optional `repeats`. For account-free local measurement, use `run calibrate --file MONITOR --case-id CASE --dataset DATASET --connections-file PRIVATE_MAP`; `--dataset` is the dataset object alone. Use 2\u20134 fictional labelled outputs and 1\u20133 repeats, within the saved judge call/token budget and a total 30-second ceiling. Calibration calls only the judge, not the product endpoint, and creates no health runs, incidents or recovery. Keep known keys out of dataset/rubric identifiers, object keys and content as well as prompts. Inspect agreement over valid evaluated decisions, disagreement, repeat instability and technical coverage errors separately. A valid expected inconclusive can agree; a provider error cannot. Inspect private model usage for actual reservations. Exit 4 means disagreement, instability or coverage failure; never erase those results to obtain a green check. A small successful sample applies only to its exact dataset/rubric/model identity and does not establish general accuracy or automatically change the monitor\u2019s unverified calibration label.\n\nFor release regressions, use `project compare --id PROJECT_ID --deployment-id DEPLOYMENT_ID` and follow the opaque `next` cursor with `--before`. AI rows include case-level comparisons from frozen queued definitions and retained structured reports. Inspect each case classification and compatibility reasons. A different fixture, assertion, rubric, judge model or policy identity cannot establish a product regression; do not compare numeric scores across changed policies. Missing/invalid reports and unexecuted cases are coverage gaps. Follow the owned run references for evidence. Last passing and first failure are useful only for the matching case policy; a pass from another case or rubric is not a reproduction baseline. Display-name changes and JSON object key order do not change the evaluation policy. Comparison is read-only and never schedules another paid request.\n\n## AI steps in browser and API scripts\n\nFor personal AI-assisted browser journeys, require both `features.ai` and `features.isolatedAi` alongside script admission. Keep the `ai` model connection binding optional; deterministic scripts need no model or provider key. Hosted personal runs always use server-owned isolated policy and an explicitly model-capable isolated worker. An older worker, withdrawn capability or missing connection is a coverage failure, never a reason to switch accounts or execute through a trusted lane. Use the same version-2 manifest locally with a private connection map before applying it paused. Only attempt-scoped broker authority enters the disposable runtime; upstream keys stay controller-side. Screenshots, page content and prompts used by AI steps reach the selected provider. Inspect native assertions plus authoritative model usage/error evidence; catching an SDK error does not make a run healthy. No browser login-state import or stored application credentials are supported by this capability. API scripts have no built-in screen observation engine: do not call screen-based agent.assert/waitFor/extract on API data. In manifest mode, import {assertGrade, grade} from \"#waitcher/ai\" and pass {data: selectedJsonOrText, rubric: criteria, threshold: 0.8}. The optional judgeModel grades the selected data, otherwise model is used. Keep expected facts in versioned fixtures; send no credentials or unnecessary response fields. Selected JSON is limited to 8 KiB and rubric to 2 KiB. grade returns {verdict,score}; assertGrade throws on non-pass. Any failure, valid inconclusive or technical grading error remains authoritative even when caught or ignored. Inspect private waitcher-data-grades.json alongside model usage and the native report. No retries/fallbacks occur. The alias survives monitor build and is supplied by run local --file and hosted script execution; standalone --project needs its own integration. Deterministic scripts need no binding; fixed endpoint fixtures can use the declarative graded adapter instead.\n\nFor an existing project's custom model setup, use `--project`. A schemaVersion 2 manifest with an `ai` binding can also run unchanged locally using `--connections-file /private/connections.json`, without login. The private map has schemaVersion 1 and a connections array; each record contains id, configurationRevision, provider openrouter (the only provider for AI scripts; anthropic connections serve hosted agent checks only), projectId, environmentId, allowed models and credentialFile. Credential paths resolve relative to the map. IDs/revisions/models and explicit manifest scope must match. Keep both map and key files private (chmod 600); inline keys, provider URLs and symlinks are refused. The selected runtime also needs ai@7.0.177. The complete CLI package ships model-client.mjs and notices; copying only cli.mjs is insufficient for bound AI execution.\n\nThe local manifest runner keeps the provider key in its parent and passes a temporary loopback grant to the test. It uses the hosted transport and per-run budget/outcome rules, but no hosted account/day ledger. Read model-usage.json as well as the native report: caught provider/budget failures may leave a native passed test while Waitcher correctly records error. Unknown usage stays reserved, SDK retries count separately, and local success does not verify hosted enablement or key freshness. Provider keys are not forwarded to the child, and literal temporary broker tokens are redacted from normal text evidence; trusted local code can read its filesystem and is not a sandbox. Traces default on, video stays opt-in.\n\nIn the project's `e2e.config.ts`, construct the chosen provider's AI SDK model under `agents.default.model`, following the installed framework's types. The provider reads its local key; a key alone does not configure a model. Never copy a user's provider key into a monitor manifest or use an operator's account key.\n\nMix exact assertions with selected `agent.act`, `agent.assert`, `agent.waitFor` and schema-bound `agent.extract` calls. AI operations may transmit screen content to the provider and incur cost; preserve the user's provider/call authorization. Step-level `maxModelCalls` is not a whole-run spending limit. Hosted connection/broker/budget support is separate and must be discovered from actual capabilities rather than assumed from a local run.\n\n## Protected product requests\n\nFor protected product operations, use monitor init --template protected-agent-outcome --request-policy-file POLICY.json --project-id UUID --environment-id UUID --file monitor.json. The public policy contains connections with id, canonical HTTPS origin and httpAuth references (targetId, credentialId, credentialRevision); operations with id, connection, method, path, optional static body, responsePointers and maxCalls; and budget.calls. Paths are fixed absolute paths with at most one whole {resourceId} UUID segment. Static JSON bodies may use only exact string leaves {{resourceId}}. Callers cannot choose URLs, methods, headers, bodies, query parameters or UUIDs. GET permits at most three calls, POST and DELETE one; DELETE requires the UUID path and POST must use the run identity. Limits are four connections, eight operations and eight total calls.\n\nThe protected starter requires submit POST, observe GET (three reads), cleanup DELETE, a five-call budget and response pointers /id, /correlationId, /title, /completed. Configure the static submission body to create a note with the parent-generated UUID in both id and correlationId, title Waitcher outcome check, and completed true. The optional #waitcher/requests SDK exposes requestOperation and requestResourceId. Responses contain status and a data map keyed by configured JSON pointers. The script never trusts the agent reply as proof of resulting state, never retries the action, and only cleans up independently proven run-owned state.\n\nLocal execution uses the existing --http-credentials-file private map: schemaVersion 1 and credentials entries with targetId, credentialId, credentialRevision, origin, header and credentialFile. Header is the credential header name (for example Authorization or X-Api-Key); its raw value stays in a separate private regular file. Map and key files require mode600 and exact reference/revision/origin matches. Keys stay in the CLI parent, never script, manifest, CLI arguments or custom environment. No account, app or AI provider is required locally. Keep request-runtime.mjs with the complete CLI package. For source projects use scriptFile, monitor build, then run local --file; standalone project mode does not inject the protected helper. Hosted use requires explicit capability and isolated execution even for administrators. Combined AI or browser-state bindings need their independent authority. Inspect request-usage.json, scenario and native reports. Caught budget errors, uncertain dispatch and unfinished calls cannot establish a healthy result; never replay mutations automatically.\n\nScenario request associations are optional recorded evidence. The request helper automatically records each issued request UUID on its originating phase. In a verify phase, call `scenario.referenceRequest(response.requestId)` for a request from an earlier completed observe phase in the same scenario; use the validated response envelope UUID, never an ID from response data. The protected starter references its last independent observation before asserting the business state. Read associations with `run scenarios`; `run diagnose` joins them to this run's request records and labels each ID `matched`, `not-found` or `unavailable`. These are script-reported phase associations. A matching controller row proves accounting correspondence, not the correctness of a phase or business outcome. Local matches remain local helper reports. Older evidence without association fields is not recorded, rather than an empty verified list. UNKNOWN requests remain charged and incomplete; no association authorizes mutation replay.\n";
|
|
62767
63036
|
|
|
62768
63037
|
// ../../skills/waitcher/references/deploy.md
|
|
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.
|
|
63038
|
+
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.24.0`, `@e2e-dev/web@0.16.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';
|
|
62770
63039
|
|
|
62771
63040
|
// ../../skills/waitcher/references/diagnosis.md
|
|
62772
63041
|
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';
|
|
@@ -64380,7 +64649,7 @@ Pass {data:selectedJsonOrText,rubric:criteria,threshold:0.8}; judgeModel or mode
|
|
|
64380
64649
|
grades it with the same binding budget. Selected JSON <=8 KiB, rubric <=2 KiB.
|
|
64381
64650
|
Failures and inconclusive/technical errors remain authoritative even when caught.
|
|
64382
64651
|
Inspect waitcher-data-grades.json. Project mode does not inject this helper.
|
|
64383
|
-
Manifest AI needs ai@7.0.
|
|
64652
|
+
Manifest AI needs ai@7.0.177 in the selected runtime, alongside pinned E2E packages.
|
|
64384
64653
|
The CLI package includes its model-client.mjs companion and license notices.
|
|
64385
64654
|
Provider keys stay in the CLI parent; the test receives a temporary loopback token.
|
|
64386
64655
|
Per-run call/output/reservation bounds apply, including SDK retries. Local runs
|