@debugbundle/cli 1.13.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +18 -0
  2. package/dist/main.cjs +956 -524
  3. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -1198,8 +1198,8 @@ var require_util = __commonJS({
1198
1198
  if (body == null) {
1199
1199
  return 0;
1200
1200
  } else if (isStream(body)) {
1201
- const state = body._readableState;
1202
- return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) ? state.length : null;
1201
+ const state2 = body._readableState;
1202
+ return state2 && state2.objectMode === false && state2.ended === true && Number.isFinite(state2.length) ? state2.length : null;
1203
1203
  } else if (isBlobLike(body)) {
1204
1204
  return body.size != null ? body.size : null;
1205
1205
  } else if (isBuffer(body)) {
@@ -5814,7 +5814,7 @@ var require_formdata = __commonJS({
5814
5814
  }
5815
5815
  }
5816
5816
  [nodeUtil.inspect.custom](depth, options) {
5817
- const state = this.#state.reduce((a, b) => {
5817
+ const state2 = this.#state.reduce((a, b) => {
5818
5818
  if (a[b.name]) {
5819
5819
  if (Array.isArray(a[b.name])) {
5820
5820
  a[b.name].push(b.value);
@@ -5828,7 +5828,7 @@ var require_formdata = __commonJS({
5828
5828
  }, { __proto__: null });
5829
5829
  options.depth ??= depth;
5830
5830
  options.colors ??= true;
5831
- const output2 = nodeUtil.formatWithOptions(options, state);
5831
+ const output2 = nodeUtil.formatWithOptions(options, state2);
5832
5832
  return `FormData ${output2.slice(output2.indexOf("]") + 2)}`;
5833
5833
  }
5834
5834
  static {
@@ -7989,8 +7989,8 @@ var require_client_h2 = __commonJS({
7989
7989
  return body == null || util4.isBuffer(body) || util4.isBlobLike(body);
7990
7990
  }
7991
7991
  function hasResponseStarted(request) {
7992
- const state = request[kRequestStream]?.[kRequestStreamState];
7993
- return state?.responseReceived === true;
7992
+ const state2 = request[kRequestStream]?.[kRequestStreamState];
7993
+ return state2?.responseReceived === true;
7994
7994
  }
7995
7995
  function registerGoAwayRefusal(request) {
7996
7996
  const attempts = (request[kGoAwayReplayAttempts] ?? 0) + 1;
@@ -8131,16 +8131,16 @@ var require_client_h2 = __commonJS({
8131
8131
  };
8132
8132
  }
8133
8133
  function refH2Session(session) {
8134
- const state = session[kHTTP2SessionState];
8135
- if (state.refed === false) {
8136
- state.refed = true;
8134
+ const state2 = session[kHTTP2SessionState];
8135
+ if (state2.refed === false) {
8136
+ state2.refed = true;
8137
8137
  session.ref();
8138
8138
  }
8139
8139
  }
8140
8140
  function unrefH2Session(session) {
8141
- const state = session[kHTTP2SessionState];
8142
- if (state.refed === true) {
8143
- state.refed = false;
8141
+ const state2 = session[kHTTP2SessionState];
8142
+ if (state2.refed === true) {
8143
+ state2.refed = false;
8144
8144
  session.unref();
8145
8145
  }
8146
8146
  }
@@ -8166,25 +8166,25 @@ var require_client_h2 = __commonJS({
8166
8166
  }
8167
8167
  }
8168
8168
  function clearNoStreamsTimeout(session) {
8169
- const state = session[kHTTP2SessionState];
8170
- if (state?.noStreamsTimeout != null) {
8171
- clearTimeout(state.noStreamsTimeout);
8172
- state.noStreamsTimeout = null;
8169
+ const state2 = session[kHTTP2SessionState];
8170
+ if (state2?.noStreamsTimeout != null) {
8171
+ clearTimeout(state2.noStreamsTimeout);
8172
+ state2.noStreamsTimeout = null;
8173
8173
  }
8174
8174
  }
8175
8175
  function setNoStreamsTimeout(session) {
8176
8176
  const client = session[kClient];
8177
- const state = session[kHTTP2SessionState];
8177
+ const state2 = session[kHTTP2SessionState];
8178
8178
  const timeout = client[kHeadersTimeout];
8179
- if (!timeout || state.noStreamsTimeout != null) {
8179
+ if (!timeout || state2.noStreamsTimeout != null) {
8180
8180
  return;
8181
8181
  }
8182
- state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
8182
+ state2.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
8183
8183
  }
8184
8184
  function onNoStreamsTimeout(session) {
8185
8185
  const client = session[kClient];
8186
- const state = session[kHTTP2SessionState];
8187
- state.noStreamsTimeout = null;
8186
+ const state2 = session[kHTTP2SessionState];
8187
+ state2.noStreamsTimeout = null;
8188
8188
  if (client[kHTTP2Session] !== session || client[kMaxConcurrentStreams] !== 0 || client[kRunning] !== 0 || client[kPending] === 0) {
8189
8189
  return;
8190
8190
  }
@@ -8201,10 +8201,10 @@ var require_client_h2 = __commonJS({
8201
8201
  resetHttp2Session(session, err);
8202
8202
  }
8203
8203
  function clearHttp2IdleTimeout(session) {
8204
- const state = session[kHTTP2SessionState];
8205
- if (state?.idleTimeout != null) {
8206
- clearTimeout(state.idleTimeout);
8207
- state.idleTimeout = null;
8204
+ const state2 = session[kHTTP2SessionState];
8205
+ if (state2?.idleTimeout != null) {
8206
+ clearTimeout(state2.idleTimeout);
8207
+ state2.idleTimeout = null;
8208
8208
  }
8209
8209
  }
8210
8210
  function setHttp2IdleTimeout(session) {
@@ -8216,16 +8216,16 @@ var require_client_h2 = __commonJS({
8216
8216
  clearHttp2IdleTimeout(session);
8217
8217
  return;
8218
8218
  }
8219
- const state = session[kHTTP2SessionState];
8220
- if (state.idleTimeout == null) {
8221
- state.idleTimeout = setTimeout(onHttp2SessionIdleTimeout, client[kKeepAliveDefaultTimeout], session).unref();
8219
+ const state2 = session[kHTTP2SessionState];
8220
+ if (state2.idleTimeout == null) {
8221
+ state2.idleTimeout = setTimeout(onHttp2SessionIdleTimeout, client[kKeepAliveDefaultTimeout], session).unref();
8222
8222
  }
8223
8223
  }
8224
8224
  function onHttp2SessionIdleTimeout(session) {
8225
8225
  const client = session[kClient];
8226
8226
  const socket = session[kSocket];
8227
- const state = session[kHTTP2SessionState];
8228
- state.idleTimeout = null;
8227
+ const state2 = session[kHTTP2SessionState];
8228
+ state2.idleTimeout = null;
8229
8229
  if (client[kHTTP2Session] !== session || session[kOpenStreams] !== 0 || client[kSize] !== 0 || session.closed || session.destroyed) {
8230
8230
  return;
8231
8231
  }
@@ -8254,10 +8254,10 @@ var require_client_h2 = __commonJS({
8254
8254
  this[kClient][kResume]();
8255
8255
  }
8256
8256
  function onHttp2SendPing(session) {
8257
- const state = session[kHTTP2SessionState];
8258
- if ((session.closed || session.destroyed) && state.ping.interval != null) {
8259
- clearInterval(state.ping.interval);
8260
- state.ping.interval = null;
8257
+ const state2 = session[kHTTP2SessionState];
8258
+ if ((session.closed || session.destroyed) && state2.ping.interval != null) {
8259
+ clearInterval(state2.ping.interval);
8260
+ state2.ping.interval = null;
8261
8261
  return;
8262
8262
  }
8263
8263
  session.ping(onPing.bind(session));
@@ -8337,7 +8337,7 @@ var require_client_h2 = __commonJS({
8337
8337
  client[kResume]();
8338
8338
  }
8339
8339
  function onHttp2SessionClose() {
8340
- const { [kClient]: client, [kHTTP2SessionState]: state, [kSocket]: socket } = this;
8340
+ const { [kClient]: client, [kHTTP2SessionState]: state2, [kSocket]: socket } = this;
8341
8341
  const err = socket[kError] || this[kError] || new SocketError("closed", util4.getSocketInfo(socket));
8342
8342
  if (client[kHTTP2Session] === this) {
8343
8343
  client[kSocket] = null;
@@ -8346,9 +8346,9 @@ var require_client_h2 = __commonJS({
8346
8346
  }
8347
8347
  clearHttp2IdleTimeout(this);
8348
8348
  clearNoStreamsTimeout(this);
8349
- if (state.ping.interval != null) {
8350
- clearInterval(state.ping.interval);
8351
- state.ping.interval = null;
8349
+ if (state2.ping.interval != null) {
8350
+ clearInterval(state2.ping.interval);
8351
+ state2.ping.interval = null;
8352
8352
  }
8353
8353
  if (client.destroyed) {
8354
8354
  assert6(client[kPending] === 0);
@@ -8409,27 +8409,27 @@ var require_client_h2 = __commonJS({
8409
8409
  }
8410
8410
  function onUpgradeStreamClose() {
8411
8411
  this.off("error", noop);
8412
- const state = this[kRequestStreamState];
8412
+ const state2 = this[kRequestStreamState];
8413
8413
  this[kRequestStreamState] = null;
8414
- failUpgradeStream(state, new InformationalError("HTTP/2: stream closed before response headers"));
8414
+ failUpgradeStream(state2, new InformationalError("HTTP/2: stream closed before response headers"));
8415
8415
  closeStreamSession(this);
8416
8416
  }
8417
8417
  function completeRequestStream() {
8418
- const state = this[kRequestStreamState];
8419
- if (state == null) {
8418
+ const state2 = this[kRequestStreamState];
8419
+ if (state2 == null) {
8420
8420
  return;
8421
8421
  }
8422
8422
  releaseRequestStream(this);
8423
- if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
8424
- state.request.onResponseEnd(state.trailers || {});
8425
- } else if (!state.request.aborted && !state.request.completed) {
8423
+ if (state2.pendingEnd && !state2.request.aborted && !state2.request.completed) {
8424
+ state2.request.onResponseEnd(state2.trailers || {});
8425
+ } else if (!state2.request.aborted && !state2.request.completed) {
8426
8426
  util4.errorRequest(
8427
- state.client,
8428
- state.request,
8427
+ state2.client,
8428
+ state2.request,
8429
8429
  new InformationalError("HTTP/2: stream closed before the response was complete")
8430
8430
  );
8431
8431
  }
8432
- finalizeRequest(state);
8432
+ finalizeRequest(state2);
8433
8433
  closeStreamSession(this);
8434
8434
  this[kRequestStreamState] = null;
8435
8435
  }
@@ -8471,11 +8471,11 @@ var require_client_h2 = __commonJS({
8471
8471
  if (stream == null) {
8472
8472
  return;
8473
8473
  }
8474
- const state = stream[kRequestStreamState];
8475
- if (state == null) {
8474
+ const state2 = stream[kRequestStreamState];
8475
+ if (state2 == null) {
8476
8476
  return;
8477
8477
  }
8478
- const { request } = state;
8478
+ const { request } = state2;
8479
8479
  if (request[kRequestStream] === stream) {
8480
8480
  detachRequestFromStream(request);
8481
8481
  }
@@ -8484,43 +8484,43 @@ var require_client_h2 = __commonJS({
8484
8484
  stream.once("error", noop);
8485
8485
  }
8486
8486
  }
8487
- function failUpgradeStream(state, err) {
8488
- if (state == null) {
8487
+ function failUpgradeStream(state2, err) {
8488
+ if (state2 == null) {
8489
8489
  return;
8490
8490
  }
8491
- const { request } = state;
8492
- if (state.responseReceived || request.aborted || request.completed) {
8491
+ const { request } = state2;
8492
+ if (state2.responseReceived || request.aborted || request.completed) {
8493
8493
  return;
8494
8494
  }
8495
- releaseUpgradeStream(state.stream);
8496
- state.abort(err, true);
8495
+ releaseUpgradeStream(state2.stream);
8496
+ state2.abort(err, true);
8497
8497
  }
8498
8498
  function onUpgradeStreamError() {
8499
- const state = this[kRequestStreamState];
8499
+ const state2 = this[kRequestStreamState];
8500
8500
  if (typeof this.rstCode === "number" && this.rstCode !== 0) {
8501
- failUpgradeStream(state, new InformationalError(`HTTP/2: "stream error" received - code ${this.rstCode}`));
8501
+ failUpgradeStream(state2, new InformationalError(`HTTP/2: "stream error" received - code ${this.rstCode}`));
8502
8502
  } else {
8503
- failUpgradeStream(state, new InformationalError("HTTP/2: stream errored before response headers"));
8503
+ failUpgradeStream(state2, new InformationalError("HTTP/2: stream errored before response headers"));
8504
8504
  }
8505
8505
  }
8506
8506
  function onUpgradeStreamEnd() {
8507
8507
  failUpgradeStream(this[kRequestStreamState], new InformationalError("HTTP/2: stream half-closed (remote)"));
8508
8508
  }
8509
8509
  function onUpgradeStreamTimeout() {
8510
- const state = this[kRequestStreamState];
8511
- failUpgradeStream(state, new InformationalError(`HTTP/2: "stream timeout after ${state.headersTimeout}"`));
8510
+ const state2 = this[kRequestStreamState];
8511
+ failUpgradeStream(state2, new InformationalError(`HTTP/2: "stream timeout after ${state2.headersTimeout}"`));
8512
8512
  }
8513
8513
  function onUpgradeResponse(headers, _flags) {
8514
8514
  const stream = this;
8515
- const state = stream[kRequestStreamState];
8516
- const { request } = state;
8517
- state.responseReceived = true;
8515
+ const state2 = stream[kRequestStreamState];
8516
+ const { request } = state2;
8517
+ state2.responseReceived = true;
8518
8518
  const statusCode = headers[HTTP2_HEADER_STATUS];
8519
8519
  delete headers[HTTP2_HEADER_STATUS];
8520
8520
  try {
8521
8521
  request.onRequestUpgrade(statusCode, headers, stream);
8522
8522
  } catch (err) {
8523
- state.abort(err);
8523
+ state2.abort(err);
8524
8524
  return;
8525
8525
  }
8526
8526
  if (request.aborted) {
@@ -8528,14 +8528,14 @@ var require_client_h2 = __commonJS({
8528
8528
  }
8529
8529
  removeUpgradeStreamListeners(stream);
8530
8530
  detachRequestFromStream(request);
8531
- finalizeRequest(state);
8531
+ finalizeRequest(state2);
8532
8532
  }
8533
- function setupUpgradeStream(stream, state) {
8534
- const { request, headersTimeout, session } = state;
8533
+ function setupUpgradeStream(stream, state2) {
8534
+ const { request, headersTimeout, session } = state2;
8535
8535
  stream[kHTTP2Stream] = true;
8536
8536
  stream[kHTTP2Session] = session;
8537
- stream[kRequestStreamState] = state;
8538
- state.stream = stream;
8537
+ stream[kRequestStreamState] = state2;
8538
+ state2.stream = stream;
8539
8539
  bindRequestToStream(request, stream, releaseUpgradeStream);
8540
8540
  stream.once("response", onUpgradeResponse);
8541
8541
  stream.on("error", onUpgradeStreamError);
@@ -8546,13 +8546,13 @@ var require_client_h2 = __commonJS({
8546
8546
  ++session[kOpenStreams];
8547
8547
  stream.setTimeout(headersTimeout);
8548
8548
  }
8549
- function finalizeRequest(state, resetPendingIdx = false) {
8550
- if (state.requestFinalized) {
8549
+ function finalizeRequest(state2, resetPendingIdx = false) {
8550
+ if (state2.requestFinalized) {
8551
8551
  return;
8552
8552
  }
8553
- state.requestFinalized = true;
8554
- completeRequest(state.client, state.request, resetPendingIdx);
8555
- state.client[kResume]();
8553
+ state2.requestFinalized = true;
8554
+ completeRequest(state2.client, state2.request, resetPendingIdx);
8555
+ state2.client[kResume]();
8556
8556
  }
8557
8557
  function openStream(client, request, session, abort, headers, options) {
8558
8558
  try {
@@ -8587,7 +8587,7 @@ var require_client_h2 = __commonJS({
8587
8587
  const headers = buildRequestHeaders(reqHeaders);
8588
8588
  headers[HTTP2_HEADER_AUTHORITY] = host || client[kHostAuthority];
8589
8589
  headers[HTTP2_HEADER_METHOD] = method;
8590
- const state = {
8590
+ const state2 = {
8591
8591
  abort: null,
8592
8592
  body: request.body,
8593
8593
  bytesRead: 0,
@@ -8613,19 +8613,19 @@ var require_client_h2 = __commonJS({
8613
8613
  }
8614
8614
  err = err || new RequestAbortedError();
8615
8615
  util4.errorRequest(client, request, err);
8616
- if (state.stream != null) {
8616
+ if (state2.stream != null) {
8617
8617
  clearRequestStream(request);
8618
- const stream2 = state.stream;
8618
+ const stream2 = state2.stream;
8619
8619
  stream2.close();
8620
8620
  if (!stream2.destroyed) {
8621
8621
  util4.destroy(stream2);
8622
8622
  }
8623
8623
  client[kOnError](err);
8624
- finalizeRequest(state, resetPendingIdx);
8624
+ finalizeRequest(state2, resetPendingIdx);
8625
8625
  }
8626
- util4.destroy(state.body, err);
8626
+ util4.destroy(state2.body, err);
8627
8627
  };
8628
- state.abort = abort;
8628
+ state2.abort = abort;
8629
8629
  let stream = null;
8630
8630
  try {
8631
8631
  request.onRequestStart(abort, null);
@@ -8656,7 +8656,7 @@ var require_client_h2 = __commonJS({
8656
8656
  unrefH2Session(session);
8657
8657
  return false;
8658
8658
  }
8659
- setupUpgradeStream(stream, state);
8659
+ setupUpgradeStream(stream, state2);
8660
8660
  return true;
8661
8661
  }
8662
8662
  stream = openStream(client, request, session, abort, headers, { endStream: false, signal });
@@ -8664,13 +8664,13 @@ var require_client_h2 = __commonJS({
8664
8664
  unrefH2Session(session);
8665
8665
  return false;
8666
8666
  }
8667
- setupUpgradeStream(stream, state);
8667
+ setupUpgradeStream(stream, state2);
8668
8668
  return true;
8669
8669
  }
8670
8670
  headers[HTTP2_HEADER_PATH] = path;
8671
8671
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8672
8672
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
8673
- let body = state.body;
8673
+ let body = state2.body;
8674
8674
  if (body && typeof body.read === "function") {
8675
8675
  body.read(0);
8676
8676
  }
@@ -8709,9 +8709,9 @@ var require_client_h2 = __commonJS({
8709
8709
  channels.sendHeaders.publish({ request, headers: header2, socket: session[kSocket] });
8710
8710
  }
8711
8711
  const shouldEndStream = body === null || contentLength === 0;
8712
- state.body = body;
8713
- state.contentLength = contentLength;
8714
- state.expectsPayload = expectsPayload;
8712
+ state2.body = body;
8713
+ state2.contentLength = contentLength;
8714
+ state2.expectsPayload = expectsPayload;
8715
8715
  if (expectContinue) {
8716
8716
  headers[HTTP2_HEADER_EXPECT] = "100-continue";
8717
8717
  }
@@ -8720,8 +8720,8 @@ var require_client_h2 = __commonJS({
8720
8720
  return false;
8721
8721
  }
8722
8722
  stream[kHTTP2Stream] = true;
8723
- stream[kRequestStreamState] = state;
8724
- state.stream = stream;
8723
+ stream[kRequestStreamState] = state2;
8724
+ state2.stream = stream;
8725
8725
  clearHttp2IdleTimeout(session);
8726
8726
  ++session[kOpenStreams];
8727
8727
  if (headersTimeout) {
@@ -8765,11 +8765,11 @@ var require_client_h2 = __commonJS({
8765
8765
  if (stream == null) {
8766
8766
  return;
8767
8767
  }
8768
- const state = stream[kRequestStreamState];
8769
- if (state == null) {
8768
+ const state2 = stream[kRequestStreamState];
8769
+ if (state2 == null) {
8770
8770
  return;
8771
8771
  }
8772
- const { request } = state;
8772
+ const { request } = state2;
8773
8773
  if (request[kRequestStream] === stream) {
8774
8774
  detachRequestFromStream(request);
8775
8775
  }
@@ -8780,34 +8780,34 @@ var require_client_h2 = __commonJS({
8780
8780
  }
8781
8781
  function onData(chunk) {
8782
8782
  const stream = this;
8783
- const state = stream[kRequestStreamState];
8784
- if (state == null) {
8783
+ const state2 = stream[kRequestStreamState];
8784
+ if (state2 == null) {
8785
8785
  return;
8786
8786
  }
8787
- const { request, maxResponseSize, responseContentLength } = state;
8787
+ const { request, maxResponseSize, responseContentLength } = state2;
8788
8788
  if (request.aborted || request.completed) {
8789
8789
  return;
8790
8790
  }
8791
- if (responseContentLength != null && state.bytesRead + chunk.length > responseContentLength) {
8792
- state.abort(new ResponseContentLengthMismatchError());
8791
+ if (responseContentLength != null && state2.bytesRead + chunk.length > responseContentLength) {
8792
+ state2.abort(new ResponseContentLengthMismatchError());
8793
8793
  return;
8794
8794
  }
8795
- if (maxResponseSize > -1 && state.bytesRead + chunk.length > maxResponseSize) {
8796
- state.abort(new ResponseExceededMaxSizeError());
8795
+ if (maxResponseSize > -1 && state2.bytesRead + chunk.length > maxResponseSize) {
8796
+ state2.abort(new ResponseExceededMaxSizeError());
8797
8797
  return;
8798
8798
  }
8799
- state.bytesRead += chunk.length;
8799
+ state2.bytesRead += chunk.length;
8800
8800
  if (request.onResponseData(chunk) === false) {
8801
8801
  stream.pause();
8802
8802
  }
8803
8803
  }
8804
8804
  function onInterimResponse(headers) {
8805
8805
  const stream = this;
8806
- const state = stream[kRequestStreamState];
8807
- if (state == null) {
8806
+ const state2 = stream[kRequestStreamState];
8807
+ if (state2 == null) {
8808
8808
  return;
8809
8809
  }
8810
- const { request } = state;
8810
+ const { request } = state2;
8811
8811
  if (request.aborted || request.completed) {
8812
8812
  return;
8813
8813
  }
@@ -8817,26 +8817,26 @@ var require_client_h2 = __commonJS({
8817
8817
  }
8818
8818
  function onResponse(headers) {
8819
8819
  const stream = this;
8820
- const state = stream[kRequestStreamState];
8821
- if (state == null) {
8820
+ const state2 = stream[kRequestStreamState];
8821
+ if (state2 == null) {
8822
8822
  return;
8823
8823
  }
8824
- const { request } = state;
8824
+ const { request } = state2;
8825
8825
  stream.off("response", onResponse);
8826
- if (state.body != null && !state.bodySent && !stream.writableEnded) {
8826
+ if (state2.body != null && !state2.bodySent && !stream.writableEnded) {
8827
8827
  stream.removeListener("continue", writeBodyH2);
8828
8828
  stream.end();
8829
8829
  }
8830
8830
  const statusCode = Number(headers[HTTP2_HEADER_STATUS]);
8831
8831
  delete headers[HTTP2_HEADER_STATUS];
8832
8832
  request.onResponseStarted();
8833
- state.responseReceived = true;
8833
+ state2.responseReceived = true;
8834
8834
  if (request.method !== "HEAD" && statusCode !== 304) {
8835
8835
  const contentLength = headers[HTTP2_HEADER_CONTENT_LENGTH];
8836
- state.responseContentLength = contentLength == null ? null : Number(contentLength);
8836
+ state2.responseContentLength = contentLength == null ? null : Number(contentLength);
8837
8837
  }
8838
- if (state.headersTimeout || state.bodyTimeout) {
8839
- stream.setTimeout(state.bodyTimeout);
8838
+ if (state2.headersTimeout || state2.bodyTimeout) {
8839
+ stream.setTimeout(state2.bodyTimeout);
8840
8840
  }
8841
8841
  if (request.aborted || request.completed) {
8842
8842
  releaseRequestStream(stream);
@@ -8849,34 +8849,34 @@ var require_client_h2 = __commonJS({
8849
8849
  }
8850
8850
  function onEnd() {
8851
8851
  const stream = this;
8852
- const state = stream[kRequestStreamState];
8853
- if (state == null) {
8852
+ const state2 = stream[kRequestStreamState];
8853
+ if (state2 == null) {
8854
8854
  return;
8855
8855
  }
8856
- const { request } = state;
8856
+ const { request } = state2;
8857
8857
  stream.off("end", onEnd);
8858
- if (state.responseReceived) {
8858
+ if (state2.responseReceived) {
8859
8859
  if (!request.aborted && !request.completed) {
8860
- if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
8861
- state.abort(new ResponseContentLengthMismatchError());
8860
+ if (state2.responseContentLength != null && state2.bytesRead !== state2.responseContentLength) {
8861
+ state2.abort(new ResponseContentLengthMismatchError());
8862
8862
  return;
8863
8863
  }
8864
- state.pendingEnd = true;
8864
+ state2.pendingEnd = true;
8865
8865
  completeRequestStream.call(stream);
8866
8866
  }
8867
8867
  } else {
8868
- state.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
8868
+ state2.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
8869
8869
  }
8870
8870
  }
8871
- function retryRefusedStream(stream, state) {
8872
- const { client, request } = state;
8873
- if (state.responseReceived || request.aborted || request.completed || request[kRefusedStreamRetry] || !canReplayRequest(request)) {
8871
+ function retryRefusedStream(stream, state2) {
8872
+ const { client, request } = state2;
8873
+ if (state2.responseReceived || request.aborted || request.completed || request[kRefusedStreamRetry] || !canReplayRequest(request)) {
8874
8874
  return false;
8875
8875
  }
8876
8876
  request[kRefusedStreamRetry] = true;
8877
8877
  detachRequestStreamForClose(request);
8878
- state.stream = null;
8879
- state.requestFinalized = true;
8878
+ state2.stream = null;
8879
+ state2.requestFinalized = true;
8880
8880
  completeRequest(client, request);
8881
8881
  client[kQueue].splice(client[kPendingIdx], 0, request);
8882
8882
  client[kResume]();
@@ -8884,63 +8884,63 @@ var require_client_h2 = __commonJS({
8884
8884
  }
8885
8885
  function onError(err) {
8886
8886
  const stream = this;
8887
- const state = stream[kRequestStreamState];
8888
- if (state == null) {
8887
+ const state2 = stream[kRequestStreamState];
8888
+ if (state2 == null) {
8889
8889
  return;
8890
8890
  }
8891
8891
  stream.off("error", onError);
8892
- if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
8892
+ if (state2.responseContentLength != null && state2.bytesRead !== state2.responseContentLength) {
8893
8893
  err = new ResponseContentLengthMismatchError();
8894
8894
  }
8895
8895
  if (typeof stream.rstCode === "number" && stream.rstCode !== NGHTTP2_NO_ERROR) {
8896
8896
  err.http2ErrorCode = stream.rstCode;
8897
8897
  }
8898
- if (stream.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream, state)) {
8898
+ if (stream.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream, state2)) {
8899
8899
  return;
8900
8900
  }
8901
- state.abort(err);
8901
+ state2.abort(err);
8902
8902
  }
8903
8903
  function onFrameError(type, code) {
8904
8904
  const stream = this;
8905
- const state = stream[kRequestStreamState];
8906
- if (state == null) {
8905
+ const state2 = stream[kRequestStreamState];
8906
+ if (state2 == null) {
8907
8907
  return;
8908
8908
  }
8909
8909
  stream.off("frameError", onFrameError);
8910
- state.abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
8910
+ state2.abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
8911
8911
  }
8912
8912
  function onAborted() {
8913
8913
  this.off("data", onData);
8914
8914
  }
8915
8915
  function onTimeout() {
8916
8916
  const stream = this;
8917
- const state = stream[kRequestStreamState];
8918
- if (state == null) {
8917
+ const state2 = stream[kRequestStreamState];
8918
+ if (state2 == null) {
8919
8919
  return;
8920
8920
  }
8921
8921
  stream.off("timeout", onTimeout);
8922
- const err = state.responseReceived ? new BodyTimeoutError(`HTTP/2: "stream timeout after ${state.bodyTimeout}"`) : new HeadersTimeoutError(`HTTP/2: "headers timeout after ${state.headersTimeout}"`);
8923
- state.abort(err);
8922
+ const err = state2.responseReceived ? new BodyTimeoutError(`HTTP/2: "stream timeout after ${state2.bodyTimeout}"`) : new HeadersTimeoutError(`HTTP/2: "headers timeout after ${state2.headersTimeout}"`);
8923
+ state2.abort(err);
8924
8924
  }
8925
8925
  function onTrailers(trailers) {
8926
8926
  const stream = this;
8927
- const state = stream[kRequestStreamState];
8928
- if (state == null) {
8927
+ const state2 = stream[kRequestStreamState];
8928
+ if (state2 == null) {
8929
8929
  return;
8930
8930
  }
8931
- const { request } = state;
8931
+ const { request } = state2;
8932
8932
  stream.off("trailers", onTrailers);
8933
8933
  stream.off("data", onData);
8934
8934
  if (request.aborted || request.completed) {
8935
8935
  return;
8936
8936
  }
8937
- state.trailers = trailers;
8937
+ state2.trailers = trailers;
8938
8938
  }
8939
8939
  function writeBodyH2() {
8940
8940
  const stream = this;
8941
- const state = stream[kRequestStreamState];
8942
- state.bodySent = true;
8943
- const { abort, body, client, contentLength, expectsPayload, request } = state;
8941
+ const state2 = stream[kRequestStreamState];
8942
+ state2.bodySent = true;
8943
+ const { abort, body, client, contentLength, expectsPayload, request } = state2;
8944
8944
  if (!body || contentLength === 0) {
8945
8945
  writeBuffer(
8946
8946
  abort,
@@ -12185,7 +12185,7 @@ var require_retry_handler = __commonJS({
12185
12185
  onRequestUpgrade(_controller, statusCode, headers, socket) {
12186
12186
  this.handler.onRequestUpgrade?.(this.controllerProxy, statusCode, headers, socket);
12187
12187
  }
12188
- static [kRetryHandlerDefaultRetry](err, { state, opts }, cb) {
12188
+ static [kRetryHandlerDefaultRetry](err, { state: state2, opts }, cb) {
12189
12189
  const { statusCode, code, headers } = err;
12190
12190
  const { method, retryOptions } = opts;
12191
12191
  const {
@@ -12198,7 +12198,7 @@ var require_retry_handler = __commonJS({
12198
12198
  methods,
12199
12199
  retryAfter
12200
12200
  } = retryOptions;
12201
- const { counter } = state;
12201
+ const { counter } = state2;
12202
12202
  if (code && code !== "UND_ERR_REQ_RETRY" && !errorCodes.includes(code)) {
12203
12203
  cb(err);
12204
12204
  return;
@@ -12816,24 +12816,24 @@ var require_readable = __commonJS({
12816
12816
  if (consume2.body === null) {
12817
12817
  return;
12818
12818
  }
12819
- const { _readableState: state } = consume2.stream;
12820
- if (state.bufferIndex) {
12821
- const start = state.bufferIndex;
12822
- const end = state.buffer.length;
12819
+ const { _readableState: state2 } = consume2.stream;
12820
+ if (state2.bufferIndex) {
12821
+ const start = state2.bufferIndex;
12822
+ const end = state2.buffer.length;
12823
12823
  for (let n = start; n < end; n++) {
12824
- consumePush(consume2, state.buffer[n]);
12824
+ consumePush(consume2, state2.buffer[n]);
12825
12825
  }
12826
12826
  } else {
12827
- for (const chunk of state.buffer) {
12827
+ for (const chunk of state2.buffer) {
12828
12828
  consumePush(consume2, chunk);
12829
12829
  }
12830
12830
  }
12831
- const decoder2 = state.decoder;
12831
+ const decoder2 = state2.decoder;
12832
12832
  if (decoder2 != null && decoder2.lastNeed > 0) {
12833
12833
  consumePush(consume2, Buffer.from(decoder2.lastChar.subarray(0, decoder2.lastTotal - decoder2.lastNeed)));
12834
12834
  }
12835
- if (state.endEmitted) {
12836
- consumeEnd(consume2, state.encoding);
12835
+ if (state2.endEmitted) {
12836
+ consumeEnd(consume2, state2.encoding);
12837
12837
  return;
12838
12838
  }
12839
12839
  consume2.stream.on("end", function() {
@@ -16736,12 +16736,12 @@ var require_dns = __commonJS({
16736
16736
  #controller = null;
16737
16737
  #newOrigin = null;
16738
16738
  #firstTry = true;
16739
- constructor(state, { origin, handler: handler7, dispatch, newOrigin }, opts) {
16739
+ constructor(state2, { origin, handler: handler7, dispatch, newOrigin }, opts) {
16740
16740
  super(handler7);
16741
16741
  this.#origin = origin;
16742
16742
  this.#newOrigin = newOrigin;
16743
16743
  this.#opts = { ...opts };
16744
- this.#state = state;
16744
+ this.#state = state2;
16745
16745
  this.#dispatch = dispatch;
16746
16746
  }
16747
16747
  onResponseError(controller, err) {
@@ -19941,19 +19941,19 @@ var require_deduplication_handler = __commonJS({
19941
19941
  pendingTrailers: null,
19942
19942
  done: false
19943
19943
  };
19944
- const state = {
19944
+ const state2 = {
19945
19945
  aborted: false,
19946
19946
  paused: false,
19947
19947
  reason: null
19948
19948
  };
19949
19949
  waitingHandler.controller = {
19950
19950
  resume: () => {
19951
- if (state.aborted) {
19951
+ if (state2.aborted) {
19952
19952
  return;
19953
19953
  }
19954
- state.paused = false;
19954
+ state2.paused = false;
19955
19955
  this.#flushWaitingHandler(waitingHandler);
19956
- if (this.#completed && waitingHandler.pendingTrailers && waitingHandler.bufferedChunks.length === 0 && !state.paused && !state.aborted) {
19956
+ if (this.#completed && waitingHandler.pendingTrailers && waitingHandler.bufferedChunks.length === 0 && !state2.paused && !state2.aborted) {
19957
19957
  try {
19958
19958
  waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, waitingHandler.pendingTrailers);
19959
19959
  } catch (err) {
@@ -19965,31 +19965,31 @@ var require_deduplication_handler = __commonJS({
19965
19965
  this.#pruneDoneWaitingHandlers();
19966
19966
  },
19967
19967
  pause: () => {
19968
- if (!state.aborted) {
19969
- state.paused = true;
19968
+ if (!state2.aborted) {
19969
+ state2.paused = true;
19970
19970
  }
19971
19971
  },
19972
19972
  get paused() {
19973
- return state.paused;
19973
+ return state2.paused;
19974
19974
  },
19975
19975
  get aborted() {
19976
- return state.aborted;
19976
+ return state2.aborted;
19977
19977
  },
19978
19978
  get reason() {
19979
- return state.reason;
19979
+ return state2.reason;
19980
19980
  },
19981
19981
  abort: (reason) => {
19982
- if (state.aborted) {
19982
+ if (state2.aborted) {
19983
19983
  return;
19984
19984
  }
19985
- state.aborted = true;
19986
- state.reason = reason ?? null;
19985
+ state2.aborted = true;
19986
+ state2.reason = reason ?? null;
19987
19987
  waitingHandler.done = true;
19988
19988
  waitingHandler.pendingTrailers = null;
19989
19989
  waitingHandler.bufferedChunks = [];
19990
19990
  waitingHandler.bufferedBytes = 0;
19991
19991
  try {
19992
- handler7.onResponseError?.(waitingHandler.controller, state.reason ?? new RequestAbortedError());
19992
+ handler7.onResponseError?.(waitingHandler.controller, state2.reason ?? new RequestAbortedError());
19993
19993
  } catch {
19994
19994
  }
19995
19995
  }
@@ -21225,17 +21225,17 @@ var require_response = __commonJS({
21225
21225
  response.status === 0
21226
21226
  );
21227
21227
  }
21228
- function makeFilteredResponse(response, state) {
21229
- state = {
21228
+ function makeFilteredResponse(response, state2) {
21229
+ state2 = {
21230
21230
  internalResponse: response,
21231
- ...state
21231
+ ...state2
21232
21232
  };
21233
21233
  return new Proxy(response, {
21234
21234
  get(target, p) {
21235
- return p in state ? state[p] : target[p];
21235
+ return p in state2 ? state2[p] : target[p];
21236
21236
  },
21237
21237
  set(target, p, value) {
21238
- assert6(!(p in state));
21238
+ assert6(!(p in state2));
21239
21239
  target[p] = value;
21240
21240
  return true;
21241
21241
  }
@@ -66182,18 +66182,18 @@ var require_cluster = __commonJS({
66182
66182
  if (typeof res !== "string") {
66183
66183
  return callback();
66184
66184
  }
66185
- let state;
66185
+ let state2;
66186
66186
  const lines = res.split("\r\n");
66187
66187
  for (let i = 0; i < lines.length; ++i) {
66188
66188
  const parts = lines[i].split(":");
66189
66189
  if (parts[0] === "cluster_state") {
66190
- state = parts[1];
66190
+ state2 = parts[1];
66191
66191
  break;
66192
66192
  }
66193
66193
  }
66194
- if (state === "fail") {
66195
- debug3("cluster state not ok (%s)", state);
66196
- callback(null, state);
66194
+ if (state2 === "fail") {
66195
+ debug3("cluster state not ok (%s)", state2);
66196
+ callback(null, state2);
66197
66197
  } else {
66198
66198
  callback();
66199
66199
  }
@@ -75720,6 +75720,97 @@ var AnalyticsFlowCaptureSchemas = {
75720
75720
  withdraw: Context.strict()
75721
75721
  };
75722
75722
 
75723
+ // ../../packages/shared-types/src/analytics-query.ts
75724
+ var DEFAULT_LAST_MS = 7 * 24 * 60 * 60 * 1e3;
75725
+ var MAX_LAST_MS = 370 * 24 * 60 * 60 * 1e3;
75726
+ var AnalyticsMetricsQuerySchema = external_exports.object({
75727
+ project_id: external_exports.string().uuid(),
75728
+ from: external_exports.string().datetime().optional(),
75729
+ to: external_exports.string().datetime().optional(),
75730
+ last: external_exports.string().trim().min(2).max(16).optional(),
75731
+ granularity: AnalyticsMetricsGranularitySchema.optional().default("day"),
75732
+ service: external_exports.string().trim().min(1).max(120).optional(),
75733
+ environment: external_exports.string().trim().min(1).max(120).optional(),
75734
+ route: external_exports.string().trim().min(1).max(2048).refine((value) => !value.includes("?") && !value.includes("#")).optional(),
75735
+ device_type: external_exports.string().trim().min(1).max(40).optional(),
75736
+ browser: external_exports.string().trim().min(1).max(80).optional(),
75737
+ os: external_exports.string().trim().min(1).max(80).optional(),
75738
+ language: external_exports.string().trim().min(1).max(40).optional(),
75739
+ country: external_exports.string().trim().min(1).max(8).optional(),
75740
+ auth_state: external_exports.enum(["anonymous", "authenticated", "unknown"]).optional(),
75741
+ referrer: external_exports.string().trim().min(1).max(255).optional(),
75742
+ utm_source: external_exports.string().trim().min(1).max(128).optional(),
75743
+ utm_medium: external_exports.string().trim().min(1).max(128).optional(),
75744
+ utm_campaign: external_exports.string().trim().min(1).max(128).optional(),
75745
+ custom_dimensions: external_exports.record(external_exports.string().regex(/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/), external_exports.string().max(128)).refine((value) => Object.keys(value).length <= 8).optional(),
75746
+ limit: external_exports.coerce.number().int().min(1).max(100).optional().default(10)
75747
+ }).strict();
75748
+
75749
+ // ../../packages/shared-types/src/public-status.ts
75750
+ var PublicStatusIdSchema = external_exports.string().regex(/^[a-f0-9]{24}$/);
75751
+ var selection = external_exports.object({ project_id: external_exports.string().uuid(), check_ids: external_exports.array(external_exports.string().uuid()).max(50) }).strict();
75752
+ var PublicStatusSettingsSchema = external_exports.object({
75753
+ title: external_exports.string().trim().min(1).max(120),
75754
+ enabled: external_exports.boolean(),
75755
+ projects: external_exports.array(selection).min(1).max(50)
75756
+ }).strict().superRefine((value, context) => {
75757
+ if (new Set(value.projects.map((p) => p.project_id)).size !== value.projects.length || new Set(value.projects.flatMap((p) => p.check_ids)).size !== value.projects.reduce((n, p) => n + p.check_ids.length, 0) || value.projects.reduce((count, p) => count + p.check_ids.length, 0) > 500) {
75758
+ context.addIssue({
75759
+ code: external_exports.ZodIssueCode.custom,
75760
+ message: "Choose distinct projects and checks within the publication limits."
75761
+ });
75762
+ }
75763
+ });
75764
+ var state = external_exports.enum(["unknown", "operational", "degraded", "down", "paused"]);
75765
+ var percentage = external_exports.number().min(0).max(100).nullable();
75766
+ var verifiedAt = external_exports.string().datetime({ offset: true }).nullable();
75767
+ var PublicStatusDaySchema = external_exports.object({
75768
+ day: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/),
75769
+ state,
75770
+ impact: external_exports.enum(["none", "minor", "elevated", "outage"]),
75771
+ total_checks: external_exports.number().int().nonnegative(),
75772
+ successful_checks: external_exports.number().int().nonnegative(),
75773
+ failed_checks: external_exports.number().int().nonnegative(),
75774
+ degraded_checks: external_exports.number().int().nonnegative(),
75775
+ downtime_seconds: external_exports.number().nonnegative()
75776
+ }).strict();
75777
+ var checkView = external_exports.object({
75778
+ key: external_exports.string().max(40),
75779
+ name: external_exports.string().max(120),
75780
+ current_state: state,
75781
+ uptime_percentage: percentage,
75782
+ last_verified_at: verifiedAt,
75783
+ days: external_exports.array(PublicStatusDaySchema).length(30)
75784
+ }).strict();
75785
+ var PublicStatusProjectSchema = checkView.extend({ checks: external_exports.array(checkView).max(50) }).strict();
75786
+ var PublicStatusPageSchema = external_exports.object({ title: external_exports.string().max(120), projects: external_exports.array(PublicStatusProjectSchema).max(50) }).strict();
75787
+ var PublicStatusManagementSchema = external_exports.object({
75788
+ settings: PublicStatusSettingsSchema,
75789
+ public_id: PublicStatusIdSchema.nullable(),
75790
+ public_url: external_exports.string().url().nullable(),
75791
+ access_mode: external_exports.enum(["manage", "preview"])
75792
+ }).strict();
75793
+ var PublicStatusOptionsQueryObjectSchema = external_exports.object({
75794
+ cursor: external_exports.string().uuid().optional(),
75795
+ check_project_id: external_exports.string().uuid().optional(),
75796
+ check_cursor: external_exports.string().uuid().optional()
75797
+ }).strict();
75798
+ var PublicStatusOptionsQuerySchema = PublicStatusOptionsQueryObjectSchema.refine(
75799
+ (v) => !v.check_cursor || !!v.check_project_id,
75800
+ "A check cursor requires a project."
75801
+ ).refine((v) => !v.cursor || !v.check_project_id, "Project and check pagination are separate.");
75802
+ var PublicStatusOptionsSchema = external_exports.object({
75803
+ projects: external_exports.array(
75804
+ external_exports.object({
75805
+ project_id: external_exports.string().uuid(),
75806
+ name: external_exports.string(),
75807
+ checks: external_exports.array(external_exports.object({ check_id: external_exports.string().uuid(), name: external_exports.string() }).strict()).max(50),
75808
+ next_check_cursor: external_exports.string().uuid().nullable()
75809
+ }).strict()
75810
+ ).max(50),
75811
+ next_cursor: external_exports.string().uuid().nullable()
75812
+ }).strict();
75813
+
75723
75814
  // ../../packages/shared-types/src/index.ts
75724
75815
  var SeveritySchema = external_exports.enum(["low", "medium", "high", "critical"]);
75725
75816
  var BundleSdkSchema = external_exports.object({
@@ -77285,76 +77376,76 @@ var BudgetExceeded = class extends Error {
77285
77376
  function byteLength(value) {
77286
77377
  return new TextEncoder().encode(value).length;
77287
77378
  }
77288
- function mask(state) {
77289
- state.redactionCount += 1;
77379
+ function mask(state2) {
77380
+ state2.redactionCount += 1;
77290
77381
  return REDACTED2;
77291
77382
  }
77292
- function sanitizeString(value, state, allowStructured) {
77293
- if (value.length > MAX_STRING_BYTES) return mask(state);
77383
+ function sanitizeString(value, state2, allowStructured) {
77384
+ if (value.length > MAX_STRING_BYTES) return mask(state2);
77294
77385
  const length = byteLength(value);
77295
- if (length > MAX_STRING_BYTES) return mask(state);
77296
- state.textBytes += length;
77297
- if (state.textBytes > state.maxTotalBytes) throw new BudgetExceeded();
77386
+ if (length > MAX_STRING_BYTES) return mask(state2);
77387
+ state2.textBytes += length;
77388
+ if (state2.textBytes > state2.maxTotalBytes) throw new BudgetExceeded();
77298
77389
  if (allowStructured && (value.startsWith("{") || value.startsWith("["))) {
77299
77390
  try {
77300
77391
  const parsed = JSON.parse(value);
77301
77392
  if (typeof parsed === "object" && parsed !== null) {
77302
- const nested = sanitizeValue(parsed, state, 0, false);
77393
+ const nested = sanitizeValue(parsed, state2, 0, false);
77303
77394
  const encoded = JSON.stringify(nested);
77304
- if (encoded !== value) state.redactionCount += 1;
77395
+ if (encoded !== value) state2.redactionCount += 1;
77305
77396
  return encoded;
77306
77397
  }
77307
77398
  } catch (error2) {
77308
77399
  if (error2 instanceof BudgetExceeded) throw error2;
77309
77400
  }
77310
77401
  }
77311
- const result = scrubCredentialText(value, state.extra);
77312
- if (result !== value) state.redactionCount += 1;
77402
+ const result = scrubCredentialText(value, state2.extra);
77403
+ if (result !== value) state2.redactionCount += 1;
77313
77404
  if ((value.startsWith("{") || value.startsWith("[")) && result === value && /(?:password|token|secret|authorization|cookie)["']?\s*[:=]/i.test(value)) {
77314
- return mask(state);
77405
+ return mask(state2);
77315
77406
  }
77316
77407
  return result;
77317
77408
  }
77318
- function sanitizeValue(value, state, depth, allowStructured) {
77319
- state.nodes += 1;
77320
- if (state.nodes > MAX_NODES) throw new BudgetExceeded();
77321
- if (depth > MAX_DEPTH) return mask(state);
77322
- if (typeof value === "string") return sanitizeString(value, state, allowStructured);
77409
+ function sanitizeValue(value, state2, depth, allowStructured) {
77410
+ state2.nodes += 1;
77411
+ if (state2.nodes > MAX_NODES) throw new BudgetExceeded();
77412
+ if (depth > MAX_DEPTH) return mask(state2);
77413
+ if (typeof value === "string") return sanitizeString(value, state2, allowStructured);
77323
77414
  if (value === null || typeof value === "boolean") return value;
77324
77415
  if (typeof value === "number" && Number.isFinite(value)) return value;
77325
77416
  if (typeof value !== "object") throw new TypeError("unsafe_input");
77326
- if (state.seen.has(value)) return "[Circular]";
77327
- state.seen.add(value);
77417
+ if (state2.seen.has(value)) return "[Circular]";
77418
+ state2.seen.add(value);
77328
77419
  try {
77329
77420
  if (Array.isArray(value)) {
77330
- if (value.length > MAX_ENTRIES) return mask(state);
77421
+ if (value.length > MAX_ENTRIES) return mask(state2);
77331
77422
  return Array.from({ length: value.length }, (_, index) => {
77332
77423
  const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
77333
77424
  if (descriptor === void 0 || !("value" in descriptor)) throw new TypeError("unsafe_input");
77334
- return sanitizeValue(descriptor.value, state, depth + 1, allowStructured);
77425
+ return sanitizeValue(descriptor.value, state2, depth + 1, allowStructured);
77335
77426
  });
77336
77427
  }
77337
77428
  if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
77338
77429
  throw new TypeError("unsafe_input");
77339
77430
  }
77340
77431
  const keys2 = Object.keys(value);
77341
- if (keys2.length > MAX_ENTRIES) return mask(state);
77432
+ if (keys2.length > MAX_ENTRIES) return mask(state2);
77342
77433
  const result = {};
77343
77434
  for (const key of keys2) {
77344
77435
  if (key.length > 128) {
77345
- state.redactionCount += 1;
77436
+ state2.redactionCount += 1;
77346
77437
  continue;
77347
77438
  }
77348
- state.textBytes += byteLength(key);
77349
- if (state.textBytes > state.maxTotalBytes) throw new BudgetExceeded();
77350
- const safeKey = scrubCredentialText(key, state.extra);
77439
+ state2.textBytes += byteLength(key);
77440
+ if (state2.textBytes > state2.maxTotalBytes) throw new BudgetExceeded();
77441
+ const safeKey = scrubCredentialText(key, state2.extra);
77351
77442
  if (safeKey !== key) {
77352
- state.redactionCount += 1;
77443
+ state2.redactionCount += 1;
77353
77444
  continue;
77354
77445
  }
77355
77446
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
77356
77447
  if (descriptor === void 0 || !("value" in descriptor)) throw new TypeError("unsafe_input");
77357
- const safeValue = isSensitiveKey(key, state.keys) ? mask(state) : sanitizeValue(descriptor.value, state, depth + 1, allowStructured);
77448
+ const safeValue = isSensitiveKey(key, state2.keys) ? mask(state2) : sanitizeValue(descriptor.value, state2, depth + 1, allowStructured);
77358
77449
  Object.defineProperty(result, key, {
77359
77450
  value: safeValue,
77360
77451
  enumerable: true,
@@ -77364,7 +77455,7 @@ function sanitizeValue(value, state, depth, allowStructured) {
77364
77455
  }
77365
77456
  return result;
77366
77457
  } finally {
77367
- state.seen.delete(value);
77458
+ state2.seen.delete(value);
77368
77459
  }
77369
77460
  }
77370
77461
  function sanitizeTelemetry(value, options = {}) {
@@ -77377,7 +77468,7 @@ function sanitizeTelemetry(value, options = {}) {
77377
77468
  if (!Number.isInteger(maxTotalBytes) || maxTotalBytes < 1 || maxTotalBytes > 512 * 1024) {
77378
77469
  return { ok: false, reason: "unsafe_input" };
77379
77470
  }
77380
- const state = {
77471
+ const state2 = {
77381
77472
  nodes: 0,
77382
77473
  textBytes: 0,
77383
77474
  redactionCount: 0,
@@ -77386,11 +77477,11 @@ function sanitizeTelemetry(value, options = {}) {
77386
77477
  extra,
77387
77478
  maxTotalBytes
77388
77479
  };
77389
- const sanitized = sanitizeValue(value, state, 0, true);
77480
+ const sanitized = sanitizeValue(value, state2, 0, true);
77390
77481
  if (byteLength(JSON.stringify(sanitized)) > maxTotalBytes) {
77391
77482
  return { ok: false, reason: "budget_exceeded" };
77392
77483
  }
77393
- return { ok: true, value: sanitized, redactionCount: state.redactionCount };
77484
+ return { ok: true, value: sanitized, redactionCount: state2.redactionCount };
77394
77485
  } catch (error2) {
77395
77486
  return { ok: false, reason: error2 instanceof BudgetExceeded ? "budget_exceeded" : "unsafe_input" };
77396
77487
  }
@@ -84604,8 +84695,8 @@ async function readAgentAuthState(filePath = agentAuthFilePath()) {
84604
84695
  throw new Error("agent_auth_unavailable");
84605
84696
  }
84606
84697
  }
84607
- async function persistAgentAuthState(state, filePath = agentAuthFilePath()) {
84608
- const parsed = AgentAuthSchema.parse(state);
84698
+ async function persistAgentAuthState(state2, filePath = agentAuthFilePath()) {
84699
+ const parsed = AgentAuthSchema.parse(state2);
84609
84700
  await (0, import_promises7.mkdir)((0, import_node_path7.dirname)(filePath), { recursive: true, mode: 448 });
84610
84701
  const tmp = `${filePath}.${(0, import_node_crypto2.randomUUID)()}.tmp`;
84611
84702
  const file = await (0, import_promises7.open)(tmp, "wx", 384);
@@ -93193,19 +93284,19 @@ var err_out_default = ({
93193
93284
  message: message3,
93194
93285
  error_description: description,
93195
93286
  scope
93196
- }, state) => {
93287
+ }, state2) => {
93197
93288
  if (expose) {
93198
93289
  return {
93199
93290
  error: message3,
93200
93291
  ...description !== void 0 ? { error_description: description } : void 0,
93201
93292
  ...scope !== void 0 ? { scope } : void 0,
93202
- ...state !== void 0 ? { state } : void 0
93293
+ ...state2 !== void 0 ? { state: state2 } : void 0
93203
93294
  };
93204
93295
  }
93205
93296
  return {
93206
93297
  error: "server_error",
93207
93298
  error_description: "oops! something went wrong",
93208
- ...state ? { state } : void 0
93299
+ ...state2 ? { state: state2 } : void 0
93209
93300
  };
93210
93301
  };
93211
93302
 
@@ -93319,8 +93410,8 @@ var authorization_error_handler_default = (provider) => {
93319
93410
  recovery: oneRedirectUriClients
93320
93411
  }
93321
93412
  });
93322
- function getOutAndEmit(ctx, err, state) {
93323
- const out = { ...err_out_default(err, state), iss: ctx.oidc.provider.issuer };
93413
+ function getOutAndEmit(ctx, err, state2) {
93414
+ const out = { ...err_out_default(err, state2), iss: ctx.oidc.provider.issuer };
93324
93415
  if (err.expose) {
93325
93416
  provider.emit("authorization.error", ctx, err);
93326
93417
  debugError2("%o", out);
@@ -97131,7 +97222,7 @@ var confirm2 = [
97131
97222
  checkXsrf("could not find logout details"),
97132
97223
  async function endSession(ctx) {
97133
97224
  const { oidc: { session, params } } = ctx;
97134
- const { state } = session;
97225
+ const { state: state2 } = session;
97135
97226
  const {
97136
97227
  features: { backchannelLogout },
97137
97228
  cookies: { long: opts }
@@ -97140,7 +97231,7 @@ var confirm2 = [
97140
97231
  const clientIds = Object.keys(session.authorizations || {});
97141
97232
  const back = [];
97142
97233
  for (const clientId of clientIds) {
97143
- if (params.logout || clientId === state.clientId) {
97234
+ if (params.logout || clientId === state2.clientId) {
97144
97235
  const client = await clientForLogout(ctx, clientId);
97145
97236
  if (client) {
97146
97237
  const sid = session.sidFor(client.clientId);
@@ -97157,8 +97248,8 @@ var confirm2 = [
97157
97248
  }
97158
97249
  await Promise.all(back);
97159
97250
  }
97160
- if (state.clientId) {
97161
- ctx.oidc.entity("Client", await clientForLogout(ctx, state.clientId));
97251
+ if (state2.clientId) {
97252
+ ctx.oidc.entity("Client", await clientForLogout(ctx, state2.clientId));
97162
97253
  }
97163
97254
  if (params.logout) {
97164
97255
  if (session.authorizations) {
@@ -97176,24 +97267,24 @@ var confirm2 = [
97176
97267
  null,
97177
97268
  opts
97178
97269
  );
97179
- } else if (state.clientId) {
97180
- const grantId = session.grantIdFor(state.clientId);
97181
- if (grantId && !session.authorizationFor(state.clientId).persistsLogout) {
97270
+ } else if (state2.clientId) {
97271
+ const grantId = session.grantIdFor(state2.clientId);
97272
+ if (grantId && !session.authorizationFor(state2.clientId).persistsLogout) {
97182
97273
  await revoke(ctx, grantId);
97183
97274
  }
97184
97275
  session.state = void 0;
97185
97276
  if (session.authorizations) {
97186
- delete session.authorizations[state.clientId];
97277
+ delete session.authorizations[state2.clientId];
97187
97278
  }
97188
97279
  session.resetIdentifier();
97189
97280
  }
97190
- const usePostLogoutUri = state.postLogoutRedirectUri;
97191
- const forwardClientId = !usePostLogoutUri && !params.logout && state.clientId;
97281
+ const usePostLogoutUri = state2.postLogoutRedirectUri;
97282
+ const forwardClientId = !usePostLogoutUri && !params.logout && state2.clientId;
97192
97283
  const uri = redirectUri(
97193
- usePostLogoutUri ? state.postLogoutRedirectUri : ctx.oidc.urlFor("end_session_success"),
97284
+ usePostLogoutUri ? state2.postLogoutRedirectUri : ctx.oidc.urlFor("end_session_success"),
97194
97285
  {
97195
- ...usePostLogoutUri && state.state != null ? { state: state.state } : void 0,
97196
- ...forwardClientId ? { client_id: state.clientId } : void 0
97286
+ ...usePostLogoutUri && state2.state != null ? { state: state2.state } : void 0,
97287
+ ...forwardClientId ? { client_id: state2.clientId } : void 0
97197
97288
  }
97198
97289
  );
97199
97290
  ctx.oidc.provider.emit("end_session.success", ctx);
@@ -98813,8 +98904,8 @@ function getBaseModel(provider) {
98813
98904
  }
98814
98905
  ttlPercentagePassed() {
98815
98906
  const now = epoch_time_default();
98816
- const percentage = Math.floor(100 * ((now - this.iat) / (this.exp - this.iat)));
98817
- return Math.max(Math.min(100, percentage), 0);
98907
+ const percentage2 = Math.floor(100 * ((now - this.iat) / (this.exp - this.iat)));
98908
+ return Math.max(Math.min(100, percentage2), 0);
98818
98909
  }
98819
98910
  get isValid() {
98820
98911
  return !this.isExpired;
@@ -101881,9 +101972,10 @@ function buildEligibilityCtes(organizationPredicate) {
101881
101972
  )
101882
101973
  `;
101883
101974
  }
101884
- var LIST_AVAILABILITY_CHECKS_QUERY = `
101975
+ function buildAvailabilityChecksListQuery(organizationPredicate, checkPredicate, limitSql = "$3", cursorSql = "$4") {
101976
+ return `
101885
101977
  WITH
101886
- ${buildEligibilityCtes("AND p.organization_id = $2::uuid")},
101978
+ ${buildEligibilityCtes(`AND ${organizationPredicate}`)},
101887
101979
  ranked AS (
101888
101980
  SELECT
101889
101981
  c.id::text AS check_id,
@@ -101930,8 +102022,8 @@ var LIST_AVAILABILITY_CHECKS_QUERY = `
101930
102022
  LEFT JOIN monitored_project_ranks monitored_ranks
101931
102023
  ON monitored_ranks.organization_id = p.organization_id
101932
102024
  AND monitored_ranks.project_id = c.project_id
101933
- WHERE c.project_id = $1::uuid
101934
- AND p.organization_id = $2::uuid
102025
+ WHERE ${checkPredicate}
102026
+ AND ${organizationPredicate}
101935
102027
  AND c.deleted_at IS NULL
101936
102028
  )
101937
102029
  SELECT
@@ -101942,10 +102034,15 @@ var LIST_AVAILABILITY_CHECKS_QUERY = `
101942
102034
  NOT ranked.enabled OR ranked.organization_check_rank <= ranked.plan_organization_check_limit
101943
102035
  AS within_organization_active_limit
101944
102036
  FROM ranked
101945
- WHERE ($4::text IS NULL OR ranked.check_id = $4)
102037
+ WHERE (${cursorSql}::text IS NULL OR ranked.check_id = ${cursorSql})
101946
102038
  ORDER BY ranked.created_at DESC
101947
- LIMIT $3
102039
+ LIMIT ${limitSql}
101948
102040
  `;
102041
+ }
102042
+ var LIST_AVAILABILITY_CHECKS_QUERY = buildAvailabilityChecksListQuery(
102043
+ "p.organization_id = $2::uuid",
102044
+ "c.project_id = $1::uuid"
102045
+ );
101949
102046
  var CLAIM_DUE_AVAILABILITY_CHECKS_QUERY = `
101950
102047
  WITH due_organizations AS (
101951
102048
  SELECT DISTINCT p.organization_id
@@ -103254,8 +103351,41 @@ function defineStorageSchemaMigration(input3) {
103254
103351
  };
103255
103352
  }
103256
103353
 
103257
- // ../../packages/storage/src/analytics-flow-schema.ts
103354
+ // ../../packages/storage/src/public-status-schema.ts
103258
103355
  var statements = [
103356
+ `CREATE TABLE IF NOT EXISTS public_status_pages (
103357
+ id uuid PRIMARY KEY, anchor_project_id uuid NOT NULL UNIQUE REFERENCES projects(id) ON DELETE CASCADE,
103358
+ owner_user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
103359
+ organization_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
103360
+ public_id text NOT NULL UNIQUE CHECK (public_id ~ '^[a-f0-9]{24}$'),
103361
+ title text NOT NULL CHECK (length(title) BETWEEN 1 AND 120), enabled boolean NOT NULL DEFAULT false,
103362
+ created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now()
103363
+ )`,
103364
+ `CREATE TABLE IF NOT EXISTS public_status_page_projects (
103365
+ page_id uuid NOT NULL REFERENCES public_status_pages(id) ON DELETE CASCADE,
103366
+ project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
103367
+ position integer NOT NULL CHECK (position BETWEEN 0 AND 49), PRIMARY KEY(page_id, project_id)
103368
+ )`,
103369
+ `CREATE TABLE IF NOT EXISTS public_status_page_checks (
103370
+ page_id uuid NOT NULL, project_id uuid NOT NULL, check_id uuid NOT NULL REFERENCES availability_checks(id) ON DELETE CASCADE,
103371
+ PRIMARY KEY(page_id, check_id), FOREIGN KEY(page_id, project_id) REFERENCES public_status_page_projects(page_id, project_id) ON DELETE CASCADE
103372
+ )`,
103373
+ "CREATE INDEX IF NOT EXISTS public_status_page_projects_project_idx ON public_status_page_projects(project_id)",
103374
+ "CREATE INDEX IF NOT EXISTS public_status_page_checks_check_idx ON public_status_page_checks(check_id)"
103375
+ ];
103376
+ var PUBLIC_STATUS_BOOTSTRAP_STATEMENTS = statements.map(
103377
+ (s) => s.replaceAll(" IF NOT EXISTS", "")
103378
+ );
103379
+ var PUBLIC_STATUS_SCHEMA_MIGRATIONS = [
103380
+ defineStorageSchemaMigration({
103381
+ id: "202610080001_add_public_status_pages",
103382
+ description: "Add opt-in, explicitly selected public availability pages.",
103383
+ statements
103384
+ })
103385
+ ];
103386
+
103387
+ // ../../packages/storage/src/analytics-flow-schema.ts
103388
+ var statements2 = [
103259
103389
  `CREATE TABLE IF NOT EXISTS analytics_flow_definitions (
103260
103390
  id uuid PRIMARY KEY, project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
103261
103391
  flow_key text NOT NULL, version integer NOT NULL DEFAULT 1, definition jsonb NOT NULL,
@@ -103288,18 +103418,18 @@ var statements = [
103288
103418
  )`,
103289
103419
  `CREATE INDEX IF NOT EXISTS analytics_flow_rollups_expiry_idx ON analytics_flow_rollups(cohort_date, flow_id)`
103290
103420
  ];
103291
- var ANALYTICS_FLOW_BOOTSTRAP_STATEMENTS = statements.map(
103421
+ var ANALYTICS_FLOW_BOOTSTRAP_STATEMENTS = statements2.map(
103292
103422
  (statement) => statement.replaceAll(" IF NOT EXISTS", "")
103293
103423
  );
103294
103424
  var migration = {
103295
103425
  id: "202610030001_add_public_analytics_flows",
103296
103426
  description: "Add customer project flow definitions, bounded continuity and aggregate reports.",
103297
- statements
103427
+ statements: statements2
103298
103428
  };
103299
103429
  var ANALYTICS_FLOW_SCHEMA_MIGRATIONS = [defineStorageSchemaMigration(migration)];
103300
103430
 
103301
103431
  // ../../packages/storage/src/browser-recovery-schema.ts
103302
- var statements2 = [
103432
+ var statements3 = [
103303
103433
  `ALTER TABLE alert_deliveries ADD COLUMN IF NOT EXISTS coalescing_key text`,
103304
103434
  `CREATE INDEX IF NOT EXISTS alert_deliveries_coalescing_idx ON alert_deliveries (alert_id, coalescing_key, created_at) WHERE coalescing_key IS NOT NULL`,
103305
103435
  `CREATE TABLE IF NOT EXISTS browser_recovery_events (
@@ -103321,10 +103451,10 @@ var BROWSER_RECOVERY_MIGRATIONS = [
103321
103451
  defineStorageSchemaMigration({
103322
103452
  id: "202609220001_add_browser_recovery_context",
103323
103453
  description: "Index browser recovery context and separate burst suppression from alert cooldown identity",
103324
- statements: statements2
103454
+ statements: statements3
103325
103455
  })
103326
103456
  ];
103327
- var BROWSER_RECOVERY_BOOTSTRAP_STATEMENTS = statements2.filter((statement) => !statement.startsWith("ALTER TABLE")).map((statement) => statement.replaceAll(" IF NOT EXISTS", ""));
103457
+ var BROWSER_RECOVERY_BOOTSTRAP_STATEMENTS = statements3.filter((statement) => !statement.startsWith("ALTER TABLE")).map((statement) => statement.replaceAll(" IF NOT EXISTS", ""));
103328
103458
 
103329
103459
  // ../../packages/storage/src/availability-check-bootstrap-statements.ts
103330
103460
  var AVAILABILITY_CHECK_BOOTSTRAP_STATEMENTS = [
@@ -105300,7 +105430,8 @@ var STORAGE_BOOTSTRAP_STATEMENTS2 = [
105300
105430
  ...AVAILABILITY_CHECK_BOOTSTRAP_STATEMENTS,
105301
105431
  ...ANALYTICS_BOOTSTRAP_STATEMENTS,
105302
105432
  ...WORKER_JOB_BOOTSTRAP_STATEMENTS,
105303
- ...ANALYTICS_FLOW_BOOTSTRAP_STATEMENTS
105433
+ ...ANALYTICS_FLOW_BOOTSTRAP_STATEMENTS,
105434
+ ...PUBLIC_STATUS_BOOTSTRAP_STATEMENTS
105304
105435
  ];
105305
105436
 
105306
105437
  // ../../packages/storage/src/migrations.ts
@@ -107515,9 +107646,18 @@ var STORAGE_SCHEMA_MIGRATIONS2 = [
107515
107646
  ...ANALYTICS_STORAGE_SCHEMA_MIGRATIONS,
107516
107647
  ...OPENAI_OAUTH_STORAGE_SCHEMA_MIGRATIONS,
107517
107648
  ...WORKER_JOB_SCHEMA_MIGRATIONS,
107518
- ...ANALYTICS_FLOW_SCHEMA_MIGRATIONS
107649
+ ...ANALYTICS_FLOW_SCHEMA_MIGRATIONS,
107650
+ ...PUBLIC_STATUS_SCHEMA_MIGRATIONS
107519
107651
  ].sort((left, right) => left.id.localeCompare(right.id));
107520
107652
 
107653
+ // ../../packages/storage/src/public-status-store.ts
107654
+ var eligibleQuery = buildAvailabilityChecksListQuery(
107655
+ "p.organization_id IN (SELECT organization_id FROM page)",
107656
+ "c.project_id IN (SELECT project_id FROM public_status_page_projects WHERE page_id IN (SELECT id FROM page)) AND c.id IN (SELECT check_id FROM public_status_page_checks WHERE page_id IN (SELECT id FROM page))",
107657
+ "500",
107658
+ "NULL"
107659
+ );
107660
+
107521
107661
  // src/local-retrieval-store.ts
107522
107662
  var CONNECTION_FILE_PATH2 = ".debugbundle/local/connection.json";
107523
107663
  var STATE_FILE_PATH = ".debugbundle/local/state.json";
@@ -107717,15 +107857,15 @@ async function readLocalState(dependencies) {
107717
107857
  throw error2;
107718
107858
  }
107719
107859
  }
107720
- async function writeLocalState(state, dependencies) {
107860
+ async function writeLocalState(state2, dependencies) {
107721
107861
  const rootDirectory = getWorkspaceRoot(dependencies);
107722
107862
  const writeFile = dependencies?.writeFile ?? import_promises9.writeFile;
107723
- await writeFile(getStateFilePath(rootDirectory), `${JSON.stringify(state, null, 2)}
107863
+ await writeFile(getStateFilePath(rootDirectory), `${JSON.stringify(state2, null, 2)}
107724
107864
  `, "utf8");
107725
107865
  }
107726
107866
  async function updateLocalIncidentStatus(input3, dependencies) {
107727
- const state = await readLocalState(dependencies);
107728
- const incident = state.incidents[input3.incidentId];
107867
+ const state2 = await readLocalState(dependencies);
107868
+ const incident = state2.incidents[input3.incidentId];
107729
107869
  if (incident === void 0) {
107730
107870
  throw createReadError(404, "incident_not_found");
107731
107871
  }
@@ -107734,8 +107874,8 @@ async function updateLocalIncidentStatus(input3, dependencies) {
107734
107874
  status: input3.status,
107735
107875
  ...input3.status === "resolved" ? { resolved_at: (/* @__PURE__ */ new Date()).toISOString() } : { resolved_at: null }
107736
107876
  };
107737
- state.incidents[input3.incidentId] = nextIncident;
107738
- await writeLocalState(state, dependencies);
107877
+ state2.incidents[input3.incidentId] = nextIncident;
107878
+ await writeLocalState(state2, dependencies);
107739
107879
  return projectLocalEvidence(nextIncident);
107740
107880
  }
107741
107881
  async function listLocalIncidents(input3, dependencies) {
@@ -108068,8 +108208,8 @@ async function cleanProcessedEventFiles(input3, dependencies) {
108068
108208
  const stat = dependencies.stat ?? import_promises11.stat;
108069
108209
  const rootDirectory = (dependencies.cwd ?? process.cwd)();
108070
108210
  const eventsDirectoryPath = (0, import_node_path11.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH);
108071
- const state = await readLocalState(dependencies);
108072
- const lastProcessedEventFile = state.last_processed_event_file;
108211
+ const state2 = await readLocalState(dependencies);
108212
+ const lastProcessedEventFile = state2.last_processed_event_file;
108073
108213
  let eventFileNames;
108074
108214
  try {
108075
108215
  eventFileNames = (await readdir(eventsDirectoryPath)).filter((fileName) => fileName.endsWith(".events.json")).sort();
@@ -108155,8 +108295,8 @@ function sortLocalIncidentRemovalPriority(left, right) {
108155
108295
  async function applyLocalIncidentRetention(dependencies) {
108156
108296
  const rm = dependencies.rm ?? import_promises11.rm;
108157
108297
  const rootDirectory = (dependencies.cwd ?? process.cwd)();
108158
- const state = await readLocalState(dependencies);
108159
- const incidents = Object.values(state.incidents);
108298
+ const state2 = await readLocalState(dependencies);
108299
+ const incidents = Object.values(state2.incidents);
108160
108300
  if (incidents.length <= LOCAL_INCIDENT_RETENTION_LIMIT) {
108161
108301
  return {
108162
108302
  removed: 0,
@@ -108164,7 +108304,7 @@ async function applyLocalIncidentRetention(dependencies) {
108164
108304
  };
108165
108305
  }
108166
108306
  const incidentsToRemove = incidents.slice().sort(sortLocalIncidentRemovalPriority).slice(0, incidents.length - LOCAL_INCIDENT_RETENTION_LIMIT);
108167
- const nextIncidents = { ...state.incidents };
108307
+ const nextIncidents = { ...state2.incidents };
108168
108308
  for (const incident of incidentsToRemove) {
108169
108309
  delete nextIncidents[incident.incident_id];
108170
108310
  await rm(resolveWorkspacePath(rootDirectory, incident.bundle_path), { force: true });
@@ -108172,7 +108312,7 @@ async function applyLocalIncidentRetention(dependencies) {
108172
108312
  }
108173
108313
  await writeLocalState(
108174
108314
  {
108175
- ...state,
108315
+ ...state2,
108176
108316
  incidents: nextIncidents
108177
108317
  },
108178
108318
  dependencies
@@ -109002,7 +109142,12 @@ var WebhookLinksSchema = external_exports.object({
109002
109142
  reproduction: external_exports.string().min(1).optional()
109003
109143
  }).strict();
109004
109144
  var BundleLifecycleWebhookPayloadSchema = external_exports.object({
109005
- event: external_exports.enum(["bundle.created", "bundle.updated", "bundle.resolved", "improvement_bundle.created"]),
109145
+ event: external_exports.enum([
109146
+ "bundle.created",
109147
+ "bundle.updated",
109148
+ "bundle.resolved",
109149
+ "improvement_bundle.created"
109150
+ ]),
109006
109151
  occurred_at: external_exports.string().datetime(),
109007
109152
  project_id: external_exports.string().min(1),
109008
109153
  bundle_id: external_exports.string().min(1),
@@ -109042,10 +109187,15 @@ var VerificationWebhookTestPayloadSchema = external_exports.object({
109042
109187
  message: external_exports.string().min(1)
109043
109188
  }).strict()
109044
109189
  }).strict();
109190
+ var SyntheticWebhookTestPayloadSchema = VerificationWebhookTestPayloadSchema.extend({
109191
+ event: WebhookEventTypeSchema,
109192
+ event_type: WebhookEventTypeSchema
109193
+ });
109045
109194
  var WebhookEventPayloadSchema = external_exports.union([
109046
109195
  BundleLifecycleWebhookPayloadSchema,
109047
109196
  IncidentLifecycleWebhookPayloadSchema,
109048
- VerificationWebhookTestPayloadSchema
109197
+ VerificationWebhookTestPayloadSchema,
109198
+ SyntheticWebhookTestPayloadSchema
109049
109199
  ]);
109050
109200
  var WebhookFiltersSchema = external_exports.object({
109051
109201
  environment: external_exports.array(external_exports.string()).optional(),
@@ -109784,6 +109934,15 @@ async function expectNoContent(responsePromise) {
109784
109934
  }
109785
109935
  function createGitHubManagementApi(client) {
109786
109936
  return {
109937
+ async disconnectInstallation(input3) {
109938
+ return expectNoContent(
109939
+ client.request({
109940
+ method: "DELETE",
109941
+ path: "/v1/github/installation",
109942
+ bearerToken: input3.bearerToken
109943
+ })
109944
+ );
109945
+ },
109787
109946
  async getInstallation(input3) {
109788
109947
  const query = input3.projectId === void 0 ? "" : `?project_id=${encodeURIComponent(input3.projectId)}`;
109789
109948
  return expectInstallation(
@@ -110358,14 +110517,14 @@ async function promptForInteractiveLoginSelection() {
110358
110517
  ].join("\n") + "\n"
110359
110518
  );
110360
110519
  for (; ; ) {
110361
- const selection = (await readlineInterface.question("Selection [1-4]: ")).trim();
110362
- if (selection === "1") {
110520
+ const selection2 = (await readlineInterface.question("Selection [1-4]: ")).trim();
110521
+ if (selection2 === "1") {
110363
110522
  return { kind: "github" };
110364
110523
  }
110365
- if (selection === "2") {
110524
+ if (selection2 === "2") {
110366
110525
  return { kind: "github-device" };
110367
110526
  }
110368
- if (selection === "3") {
110527
+ if (selection2 === "3") {
110369
110528
  const bearerToken = (await readlineInterface.question("Paste your member token: ")).trim();
110370
110529
  if (bearerToken.length > 0) {
110371
110530
  return {
@@ -110376,7 +110535,7 @@ async function promptForInteractiveLoginSelection() {
110376
110535
  import_node_process.stdout.write("Member token cannot be empty.\n");
110377
110536
  continue;
110378
110537
  }
110379
- if (selection === "4") {
110538
+ if (selection2 === "4") {
110380
110539
  return { kind: "cancel" };
110381
110540
  }
110382
110541
  import_node_process.stdout.write("Enter 1, 2, 3, or 4.\n");
@@ -110506,20 +110665,20 @@ async function maybePromptForLoginInput(input3, dependencies) {
110506
110665
  if (!interactive) {
110507
110666
  return input3;
110508
110667
  }
110509
- const selection = await (dependencies?.promptForInteractiveLogin ?? promptForInteractiveLoginSelection)();
110510
- if (selection.kind === "cancel") {
110668
+ const selection2 = await (dependencies?.promptForInteractiveLogin ?? promptForInteractiveLoginSelection)();
110669
+ if (selection2.kind === "cancel") {
110511
110670
  return {
110512
110671
  exitCode: 4,
110513
110672
  output: "Authentication cancelled."
110514
110673
  };
110515
110674
  }
110516
- if (selection.kind === "member-token") {
110675
+ if (selection2.kind === "member-token") {
110517
110676
  return {
110518
110677
  ...input3,
110519
- bearerToken: selection.bearerToken
110678
+ bearerToken: selection2.bearerToken
110520
110679
  };
110521
110680
  }
110522
- if (selection.kind === "github-device") {
110681
+ if (selection2.kind === "github-device") {
110523
110682
  return {
110524
110683
  ...input3,
110525
110684
  githubDevice: true
@@ -114012,13 +114171,13 @@ function sortIncidentRecord(incident) {
114012
114171
  source_events: [...incident.source_events].sort(compareEventEnvelopes)
114013
114172
  };
114014
114173
  }
114015
- function serializeState(state) {
114174
+ function serializeState(state2) {
114016
114175
  const incidents = Object.fromEntries(
114017
- Object.entries(state.incidents).sort(([left], [right]) => left.localeCompare(right)).map(([incidentId, incident]) => [incidentId, sortIncidentRecord(incident)])
114176
+ Object.entries(state2.incidents).sort(([left], [right]) => left.localeCompare(right)).map(([incidentId, incident]) => [incidentId, sortIncidentRecord(incident)])
114018
114177
  );
114019
114178
  return `${JSON.stringify({
114020
114179
  version: 1,
114021
- last_processed_event_file: state.last_processed_event_file,
114180
+ last_processed_event_file: state2.last_processed_event_file,
114022
114181
  incidents
114023
114182
  }, null, 2)}
114024
114183
  `;
@@ -117835,9 +117994,10 @@ var CLI_USAGE_LINES = [
117835
117994
  " debugbundle slack delete <destination-id> --project-id <id> [--auth-file <path>] [--json]",
117836
117995
  " debugbundle webhook list --project-id <id> [--limit <n>] [--auth-file <path>] [--json]",
117837
117996
  " debugbundle webhook create --project-id <id> --url <url> --event <event[,event]> [--environment <env[,env]>] [--service <svc[,svc]>] [--severity-min <level>] [--bundle-type <type[,type]>] [--verification <true|false>] [--is-enabled <true|false>] [--auth-file <path>] [--json]",
117838
- " debugbundle webhook update <webhook-id> --project-id <id> [--url <url>] [--event <event[,event]>] [--environment <env[,env]>] [--service <svc[,svc]>] [--severity-min <level>] [--bundle-type <type[,type]>] [--verification <true|false>] [--is-enabled <true|false>] [--auth-file <path>] [--json]",
117997
+ " debugbundle webhook update <webhook-id> --project-id <id> [--url <url>] [--event <event[,event]>] [--filters-json <json>] [--environment <env[,env]>] [--service <svc[,svc]>] [--severity-min <level>] [--bundle-type <type[,type]>] [--verification <true|false>] [--is-enabled <true|false>] [--auth-file <path>] [--json]",
117998
+ " --filters-json replaces all filters ({} clears them); cannot be combined with individual filter flags.",
117839
117999
  " debugbundle webhook delete <webhook-id> --project-id <id> [--auth-file <path>] [--json]",
117840
- " debugbundle webhook test <webhook-id> --project-id <id> [--event <verification.passed|verification.failed>] [--auth-file <path>] [--json]",
118000
+ " debugbundle webhook test <webhook-id> --project-id <id> [--event <bundle.created|bundle.updated|bundle.reopened|bundle.resolved|verification.passed|verification.failed|improvement_bundle.created|incident.spike_detected>] [--auth-file <path>] [--json]",
117841
118001
  " debugbundle webhook deliveries <webhook-id> --project-id <id> [--limit <n>] [--auth-file <path>] [--json]",
117842
118002
  " debugbundle webhook retry <webhook-id> <delivery-id> --project-id <id> [--auth-file <path>] [--json]",
117843
118003
  " debugbundle weekly-report list --project-id <id> [--limit <n>] [--auth-file <path>] [--json]",
@@ -117851,7 +118011,7 @@ var CLI_USAGE_LINES = [
117851
118011
  " debugbundle capture-rule suggest <incident-id> [--auth-file <path>] [--json]",
117852
118012
  " debugbundle capture-rule create-from-suggestion <incident-id> --suggestion-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
117853
118013
  " debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop> --matcher-json <json> [--description <text>] [--enabled <true|false>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
117854
- " debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--action <demote|sample|drop>] [--matcher-json <json>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
118014
+ " debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--action <demote|sample|drop>] [--matcher-json <json>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601|null>] [--auth-file <path>] [--json]",
117855
118015
  " debugbundle capture-rule delete <rule-id> --project-id <id> [--auth-file <path>] [--json]",
117856
118016
  " debugbundle improvements list [--project-id <id>] [--environment <name>] [--service <name>] [--status <status>] [--severity <level>] [--kind <kind>] [--cursor <cursor>] [--limit <n>] [--auth-file <path>] [--json]",
117857
118017
  " debugbundle improvements get <improvement-id> [--auth-file <path>] [--json]",
@@ -117864,6 +118024,10 @@ var CLI_USAGE_LINES = [
117864
118024
  " debugbundle probe activate <project-id> --label-pattern <pattern> [--service <name>] [--environment <name>] [--ttl-seconds <n>] [--trigger-ttl-seconds <n>] [--auth-file <path>] [--json]",
117865
118025
  " debugbundle probe list <project-id> [--auth-file <path>] [--json]",
117866
118026
  " debugbundle probe deactivate <project-id> <activation-id> [--auth-file <path>] [--json]",
118027
+ " debugbundle health status get --project-id <id> [--auth-file <path>] [--json]",
118028
+ " debugbundle health status save --project-id <id> --settings-json <json> [--auth-file <path>] [--json]",
118029
+ " debugbundle health status options --project-id <id> [--cursor <project-id> | --check-project-id <project-id> [--check-cursor <check-id>]] [--auth-file <path>] [--json]",
118030
+ " debugbundle health status preview --project-id <id> [--auth-file <path>] [--json]",
117867
118031
  " debugbundle health checks list --project-id <id> [--limit <n>] [--auth-file <path>] [--json]",
117868
118032
  " debugbundle health checks get <check-id> --project-id <id> [--auth-file <path>] [--json]",
117869
118033
  " debugbundle health checks create --project-id <id> --name <name> --url <url> --interval-seconds <n> [--method <GET|HEAD>] [--expected-status-min <code>] [--expected-status-max <code>] [--timeout-ms <n>] [--failure-threshold <n>] [--recovery-threshold <n>] [--environment <name>] [--service <name|null>] [--enabled <true|false>] [--auth-file <path>] [--json]",
@@ -118045,7 +118209,7 @@ async function runValidateCommand(input3, dependencies = {}) {
118045
118209
  }
118046
118210
  }
118047
118211
  checks.push(...agentChecks(report).filter((check5) => check5.name !== "canonical-skill"));
118048
- autoFixAvailable ||= report.agents.some((agent) => [agent.instruction, agent.discovery].some((state) => state === "missing" || state === "stale"));
118212
+ autoFixAvailable ||= report.agents.some((agent) => [agent.instruction, agent.discovery].some((state2) => state2 === "missing" || state2 === "stale"));
118049
118213
  const ignore = await ensureGitignore(rootDirectory, buildManagedGitignoreSection(), input3.fix === true);
118050
118214
  const gitignoreCheck = { name: "gitignore", status: ignore.present ? "ok" : "missing", message: ignore.changed ? `Updated ${GITIGNORE_FILE_PATH}` : `${ignore.present ? "Found" : "Missing"} managed ${GITIGNORE_FILE_PATH} entries` };
118051
118215
  if (gitignoreCheck.status === "missing") {
@@ -120666,7 +120830,10 @@ async function getGitHubStatusCommand(input3, api) {
120666
120830
  ${formatProjectRepo(repo)}`
120667
120831
  };
120668
120832
  } catch (error2) {
120669
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120833
+ return {
120834
+ exitCode: mapErrorToExitCode9(error2),
120835
+ output: error2 instanceof Error ? error2.message : String(error2)
120836
+ };
120670
120837
  }
120671
120838
  }
120672
120839
  async function listGitHubRepositoriesCommand(input3, api) {
@@ -120680,7 +120847,10 @@ async function listGitHubRepositoriesCommand(input3, api) {
120680
120847
  output: input3.json ? JSON.stringify({ repositories }) : repositories.length === 0 ? "No GitHub repositories found." : repositories.map((repository) => `${repository.full_name} (${repository.default_branch})`).join("\n")
120681
120848
  };
120682
120849
  } catch (error2) {
120683
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120850
+ return {
120851
+ exitCode: mapErrorToExitCode9(error2),
120852
+ output: error2 instanceof Error ? error2.message : String(error2)
120853
+ };
120684
120854
  }
120685
120855
  }
120686
120856
  async function setProjectGitHubRepoCommand(input3, api) {
@@ -120703,7 +120873,10 @@ async function setProjectGitHubRepoCommand(input3, api) {
120703
120873
  output: input3.json ? JSON.stringify({ repo: assignedRepo }) : `Project repo set: ${formatProjectRepo(assignedRepo)}`
120704
120874
  };
120705
120875
  } catch (error2) {
120706
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120876
+ return {
120877
+ exitCode: mapErrorToExitCode9(error2),
120878
+ output: error2 instanceof Error ? error2.message : String(error2)
120879
+ };
120707
120880
  }
120708
120881
  }
120709
120882
  async function removeProjectGitHubRepoCommand(input3, api) {
@@ -120714,7 +120887,10 @@ async function removeProjectGitHubRepoCommand(input3, api) {
120714
120887
  output: input3.json ? JSON.stringify({ removed: true, project_id: input3.projectId }) : `Project repo removed: ${input3.projectId}`
120715
120888
  };
120716
120889
  } catch (error2) {
120717
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120890
+ return {
120891
+ exitCode: mapErrorToExitCode9(error2),
120892
+ output: error2 instanceof Error ? error2.message : String(error2)
120893
+ };
120718
120894
  }
120719
120895
  }
120720
120896
  async function listProjectGitHubRulesCommand(input3, api) {
@@ -120728,7 +120904,10 @@ async function listProjectGitHubRulesCommand(input3, api) {
120728
120904
  output: input3.json ? JSON.stringify({ rules }) : formatGitHubRuleTable(rules)
120729
120905
  };
120730
120906
  } catch (error2) {
120731
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120907
+ return {
120908
+ exitCode: mapErrorToExitCode9(error2),
120909
+ output: error2 instanceof Error ? error2.message : String(error2)
120910
+ };
120732
120911
  }
120733
120912
  }
120734
120913
  async function listProjectGitHubDeliveriesCommand(input3, api) {
@@ -120744,7 +120923,10 @@ async function listProjectGitHubDeliveriesCommand(input3, api) {
120744
120923
  output: input3.json ? JSON.stringify({ deliveries }) : formatGitHubDeliveryTable(deliveries)
120745
120924
  };
120746
120925
  } catch (error2) {
120747
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120926
+ return {
120927
+ exitCode: mapErrorToExitCode9(error2),
120928
+ output: error2 instanceof Error ? error2.message : String(error2)
120929
+ };
120748
120930
  }
120749
120931
  }
120750
120932
  async function retryProjectGitHubDeliveryCommand(input3, api) {
@@ -120759,7 +120941,10 @@ async function retryProjectGitHubDeliveryCommand(input3, api) {
120759
120941
  output: input3.json ? JSON.stringify({ delivery }) : `GitHub delivery retried: ${delivery.delivery_id} | ${delivery.status}`
120760
120942
  };
120761
120943
  } catch (error2) {
120762
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120944
+ return {
120945
+ exitCode: mapErrorToExitCode9(error2),
120946
+ output: error2 instanceof Error ? error2.message : String(error2)
120947
+ };
120763
120948
  }
120764
120949
  }
120765
120950
  async function createProjectGitHubRuleCommand(input3, api) {
@@ -120782,7 +120967,10 @@ async function createProjectGitHubRuleCommand(input3, api) {
120782
120967
  output: input3.json ? JSON.stringify({ rule }) : `GitHub rule created: ${rule.rule_id}`
120783
120968
  };
120784
120969
  } catch (error2) {
120785
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120970
+ return {
120971
+ exitCode: mapErrorToExitCode9(error2),
120972
+ output: error2 instanceof Error ? error2.message : String(error2)
120973
+ };
120786
120974
  }
120787
120975
  }
120788
120976
  async function updateProjectGitHubRuleCommand(input3, api) {
@@ -120806,7 +120994,10 @@ async function updateProjectGitHubRuleCommand(input3, api) {
120806
120994
  output: input3.json ? JSON.stringify({ rule }) : `GitHub rule updated: ${rule.rule_id}`
120807
120995
  };
120808
120996
  } catch (error2) {
120809
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
120997
+ return {
120998
+ exitCode: mapErrorToExitCode9(error2),
120999
+ output: error2 instanceof Error ? error2.message : String(error2)
121000
+ };
120810
121001
  }
120811
121002
  }
120812
121003
  async function deleteProjectGitHubRuleCommand(input3, api) {
@@ -120821,7 +121012,10 @@ async function deleteProjectGitHubRuleCommand(input3, api) {
120821
121012
  output: input3.json ? JSON.stringify({ deleted: true, project_id: input3.projectId, rule_id: input3.ruleId }) : `GitHub rule deleted: ${input3.ruleId}`
120822
121013
  };
120823
121014
  } catch (error2) {
120824
- return { exitCode: mapErrorToExitCode9(error2), output: error2 instanceof Error ? error2.message : String(error2) };
121015
+ return {
121016
+ exitCode: mapErrorToExitCode9(error2),
121017
+ output: error2 instanceof Error ? error2.message : String(error2)
121018
+ };
120825
121019
  }
120826
121020
  }
120827
121021
  async function getGitHubStatusWithAuthCommand(input3, dependencies) {
@@ -120991,6 +121185,33 @@ async function retryProjectGitHubDeliveryWithAuthCommand(input3, dependencies) {
120991
121185
  )
120992
121186
  });
120993
121187
  }
121188
+ async function disconnectGitHubInstallationCommand(input3, api) {
121189
+ try {
121190
+ await api.disconnectInstallation({ bearerToken: input3.bearerToken });
121191
+ return {
121192
+ exitCode: 0,
121193
+ output: input3.json ? JSON.stringify({ disconnected: true }) : "GitHub installation disconnected for the active organization and all its projects."
121194
+ };
121195
+ } catch (error2) {
121196
+ return {
121197
+ exitCode: mapErrorToExitCode9(error2),
121198
+ output: error2 instanceof Error ? error2.message : String(error2)
121199
+ };
121200
+ }
121201
+ }
121202
+ async function disconnectGitHubInstallationWithAuthCommand(input3, dependencies) {
121203
+ return runAuthenticatedCliCommand(input3, {
121204
+ createApi: createAuthenticatedGitHubManagementApi,
121205
+ dependencies,
121206
+ runCommand: (authState, api) => disconnectGitHubInstallationCommand(
121207
+ {
121208
+ bearerToken: authState.bearer_token,
121209
+ ...input3.json === void 0 ? {} : { json: input3.json }
121210
+ },
121211
+ api
121212
+ )
121213
+ });
121214
+ }
120994
121215
 
120995
121216
  // src/improvement-commands.ts
120996
121217
  function mapErrorToExitCode10(error2) {
@@ -121393,10 +121614,22 @@ async function setImprovementSettingsWithAuthCommand(input3, dependencies) {
121393
121614
  // src/management-github-improvements-command-handlers.ts
121394
121615
  async function handleGithubCommand(parsedArgv, dependencies) {
121395
121616
  const action = requirePositional(parsedArgv, 1, "action");
121617
+ if (action === "disconnect") {
121618
+ expectNoUnknownOptions(parsedArgv, ["auth-file", "json"]);
121619
+ ensureNoExtraPositionals(parsedArgv, 2);
121620
+ const input3 = appendCommonAuthOptions(
121621
+ parsedArgv,
121622
+ {}
121623
+ );
121624
+ return await (dependencies.disconnectGitHubInstallationCommand ?? disconnectGitHubInstallationWithAuthCommand)(input3);
121625
+ }
121396
121626
  if (action === "status") {
121397
121627
  expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "project-id"]);
121398
121628
  ensureNoExtraPositionals(parsedArgv, 2);
121399
- const input3 = appendCommonAuthOptions(parsedArgv, {});
121629
+ const input3 = appendCommonAuthOptions(
121630
+ parsedArgv,
121631
+ {}
121632
+ );
121400
121633
  const projectId = readStringOption(parsedArgv, "project-id");
121401
121634
  if (projectId !== void 0) {
121402
121635
  input3.projectId = projectId;
@@ -121406,7 +121639,10 @@ async function handleGithubCommand(parsedArgv, dependencies) {
121406
121639
  if (action === "repos") {
121407
121640
  expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "project-id"]);
121408
121641
  ensureNoExtraPositionals(parsedArgv, 2);
121409
- const input3 = appendCommonAuthOptions(parsedArgv, {});
121642
+ const input3 = appendCommonAuthOptions(
121643
+ parsedArgv,
121644
+ {}
121645
+ );
121410
121646
  const projectId = readStringOption(parsedArgv, "project-id");
121411
121647
  if (projectId !== void 0) {
121412
121648
  input3.projectId = projectId;
@@ -121467,9 +121703,7 @@ async function handleGithubCommand(parsedArgv, dependencies) {
121467
121703
  const rulesAction = parsedArgv.positionals[2];
121468
121704
  if (rulesAction === void 0) {
121469
121705
  ensureNoExtraPositionals(parsedArgv, 2);
121470
- return await (dependencies.listProjectGitHubRulesCommand ?? listProjectGitHubRulesWithAuthCommand)(
121471
- appendCommonAuthOptions(parsedArgv, { projectId })
121472
- );
121706
+ return await (dependencies.listProjectGitHubRulesCommand ?? listProjectGitHubRulesWithAuthCommand)(appendCommonAuthOptions(parsedArgv, { projectId }));
121473
121707
  }
121474
121708
  if (rulesAction === "create") {
121475
121709
  ensureNoExtraPositionals(parsedArgv, 3);
@@ -121499,9 +121733,7 @@ async function handleGithubCommand(parsedArgv, dependencies) {
121499
121733
  if (enabled !== void 0) {
121500
121734
  commandInput.enabled = enabled;
121501
121735
  }
121502
- return await (dependencies.createProjectGitHubRuleCommand ?? createProjectGitHubRuleWithAuthCommand)(
121503
- commandInput
121504
- );
121736
+ return await (dependencies.createProjectGitHubRuleCommand ?? createProjectGitHubRuleWithAuthCommand)(commandInput);
121505
121737
  }
121506
121738
  if (rulesAction === "update") {
121507
121739
  ensureNoExtraPositionals(parsedArgv, 4);
@@ -121523,7 +121755,8 @@ async function handleGithubCommand(parsedArgv, dependencies) {
121523
121755
  if (eventTypes !== void 0) input3.eventTypes = eventTypes;
121524
121756
  if (environments !== void 0) input3.environments = environments;
121525
121757
  if (services !== void 0) input3.services = services;
121526
- if (severityMin !== void 0) input3.severityMin = severityMin;
121758
+ if (severityMin !== void 0)
121759
+ input3.severityMin = severityMin;
121527
121760
  if (bundleType !== void 0) input3.bundleType = bundleType;
121528
121761
  if (incidentStatus !== void 0) {
121529
121762
  input3.incidentStatus = incidentStatus;
@@ -121565,18 +121798,30 @@ async function handleGithubCommand(parsedArgv, dependencies) {
121565
121798
  if (projectId === void 0) {
121566
121799
  throw new CliInputError("Missing required option --project-id.");
121567
121800
  }
121568
- return await (dependencies.removeProjectGitHubRepoCommand ?? removeProjectGitHubRepoWithAuthCommand)(
121569
- appendCommonAuthOptions(parsedArgv, { projectId })
121570
- );
121801
+ return await (dependencies.removeProjectGitHubRepoCommand ?? removeProjectGitHubRepoWithAuthCommand)(appendCommonAuthOptions(parsedArgv, { projectId }));
121571
121802
  }
121572
121803
  throw new CliInputError("Unknown github repo command.");
121573
121804
  }
121574
121805
  async function handleImprovementsCommand(parsedArgv, dependencies) {
121575
121806
  const action = requirePositional(parsedArgv, 1, "action");
121576
121807
  if (action === "list") {
121577
- expectNoUnknownOptions(parsedArgv, ["project-id", "environment", "service", "status", "severity", "kind", "cursor", "limit", "auth-file", "json"]);
121808
+ expectNoUnknownOptions(parsedArgv, [
121809
+ "project-id",
121810
+ "environment",
121811
+ "service",
121812
+ "status",
121813
+ "severity",
121814
+ "kind",
121815
+ "cursor",
121816
+ "limit",
121817
+ "auth-file",
121818
+ "json"
121819
+ ]);
121578
121820
  ensureNoExtraPositionals(parsedArgv, 2);
121579
- const input3 = appendCommonAuthOptions(parsedArgv, {});
121821
+ const input3 = appendCommonAuthOptions(
121822
+ parsedArgv,
121823
+ {}
121824
+ );
121580
121825
  const projectId = readStringOption(parsedArgv, "project-id");
121581
121826
  if (projectId !== void 0) input3.projectId = projectId;
121582
121827
  const environment = readStringOption(parsedArgv, "environment");
@@ -123111,6 +123356,142 @@ async function handleTokenCommand(parsedArgv, dependencies) {
123111
123356
  throw new CliInputError("Unknown token command.");
123112
123357
  }
123113
123358
 
123359
+ // src/public-status-commands.ts
123360
+ var PublicStatusApiError = class extends Error {
123361
+ constructor(status, message3) {
123362
+ super(message3);
123363
+ this.status = status;
123364
+ }
123365
+ };
123366
+ function createPublicStatusApi(http) {
123367
+ const path = (scope) => `/v1/projects/${encodeURIComponent(external_exports.string().uuid().parse(scope.projectId))}/status-page`;
123368
+ async function request(input3, schema) {
123369
+ const result = await http.request(input3);
123370
+ if (result.status !== 200) {
123371
+ const error2 = external_exports.object({ error: external_exports.string() }).safeParse(result.body);
123372
+ throw new PublicStatusApiError(
123373
+ result.status,
123374
+ error2.success ? error2.data.error : "Status request failed."
123375
+ );
123376
+ }
123377
+ return schema.parse(result.body);
123378
+ }
123379
+ return {
123380
+ get: (scope) => request(
123381
+ { method: "GET", path: path(scope), bearerToken: scope.bearerToken },
123382
+ PublicStatusManagementSchema
123383
+ ),
123384
+ save: (scope) => request(
123385
+ {
123386
+ method: "PUT",
123387
+ path: path(scope),
123388
+ bearerToken: scope.bearerToken,
123389
+ body: PublicStatusSettingsSchema.parse(scope.settings)
123390
+ },
123391
+ PublicStatusManagementSchema
123392
+ ),
123393
+ options: (scope) => {
123394
+ const query = PublicStatusOptionsQuerySchema.parse({
123395
+ ...scope.cursor ? { cursor: scope.cursor } : {},
123396
+ ...scope.check_project_id ? { check_project_id: scope.check_project_id } : {},
123397
+ ...scope.check_cursor ? { check_cursor: scope.check_cursor } : {}
123398
+ });
123399
+ const params = new URLSearchParams(
123400
+ Object.entries(query).filter(
123401
+ (entry) => typeof entry[1] === "string"
123402
+ )
123403
+ ).toString();
123404
+ return request(
123405
+ {
123406
+ method: "GET",
123407
+ path: `${path(scope)}/options${params ? `?${params}` : ""}`,
123408
+ bearerToken: scope.bearerToken
123409
+ },
123410
+ PublicStatusOptionsSchema
123411
+ );
123412
+ },
123413
+ preview: (scope) => request(
123414
+ { method: "GET", path: `${path(scope)}/preview`, bearerToken: scope.bearerToken },
123415
+ PublicStatusPageSchema
123416
+ )
123417
+ };
123418
+ }
123419
+ async function publicStatusWithAuthCommand(input3, dependencies) {
123420
+ return runAuthenticatedCliCommand(input3, {
123421
+ dependencies,
123422
+ async createApi(authInput, deps) {
123423
+ const authState = await (deps?.readAuthState ?? readCliAuthState)(authInput);
123424
+ return {
123425
+ authState,
123426
+ api: createPublicStatusApi(
123427
+ (deps?.createHttpClient ?? createCliHttpClient)({ baseUrl: authState.base_url })
123428
+ )
123429
+ };
123430
+ },
123431
+ async runCommand(auth, api) {
123432
+ try {
123433
+ const scope = { projectId: input3.projectId, bearerToken: auth.bearer_token };
123434
+ const result = input3.action === "save" ? await api.save({
123435
+ ...scope,
123436
+ settings: PublicStatusSettingsSchema.parse(input3.settings)
123437
+ }) : input3.action === "options" ? await api.options({
123438
+ ...scope,
123439
+ ...input3.cursor ? { cursor: input3.cursor } : {},
123440
+ ...input3.check_project_id ? { check_project_id: input3.check_project_id } : {},
123441
+ ...input3.check_cursor ? { check_cursor: input3.check_cursor } : {}
123442
+ }) : input3.action === "preview" ? await api.preview(scope) : await api.get(scope);
123443
+ return { exitCode: 0, output: JSON.stringify(result, null, input3.json ? void 0 : 2) };
123444
+ } catch (error2) {
123445
+ return {
123446
+ exitCode: error2 instanceof PublicStatusApiError ? error2.status === 401 ? 2 : error2.status === 404 ? 3 : [400, 403, 409].includes(error2.status) ? 4 : 1 : error2 instanceof external_exports.ZodError ? 4 : 1,
123447
+ output: error2 instanceof Error ? error2.message : "Status request failed."
123448
+ };
123449
+ }
123450
+ }
123451
+ });
123452
+ }
123453
+
123454
+ // src/management-status-command-handler.ts
123455
+ async function handleStatusCommand(parsed, dependencies) {
123456
+ const action = requirePositional(parsed, 2, "action");
123457
+ if (!["get", "save", "options", "preview"].includes(action))
123458
+ throw new CliInputError("Unknown health status command.");
123459
+ expectNoUnknownOptions(parsed, [
123460
+ "project-id",
123461
+ "auth-file",
123462
+ "json",
123463
+ ...action === "save" ? ["settings-json"] : action === "options" ? ["cursor", "check-project-id", "check-cursor"] : []
123464
+ ]);
123465
+ ensureNoExtraPositionals(parsed, 3);
123466
+ const projectId = readStringOption(parsed, "project-id");
123467
+ if (!projectId) throw new CliInputError("Missing required option --project-id.");
123468
+ let settings;
123469
+ if (action === "save") {
123470
+ try {
123471
+ settings = PublicStatusSettingsSchema.parse(
123472
+ JSON.parse(readStringOption(parsed, "settings-json") ?? "null")
123473
+ );
123474
+ } catch {
123475
+ throw new CliInputError(
123476
+ "--settings-json must contain a title, enabled flag and explicit project/check selections."
123477
+ );
123478
+ }
123479
+ }
123480
+ const cursor = readStringOption(parsed, "cursor");
123481
+ const checkProjectId = readStringOption(parsed, "check-project-id");
123482
+ const checkCursor = readStringOption(parsed, "check-cursor");
123483
+ return (dependencies.publicStatusCommand ?? publicStatusWithAuthCommand)(
123484
+ appendCommonAuthOptions(parsed, {
123485
+ action,
123486
+ projectId,
123487
+ ...settings === void 0 ? {} : { settings },
123488
+ ...cursor === void 0 ? {} : { cursor },
123489
+ ...checkProjectId === void 0 ? {} : { check_project_id: checkProjectId },
123490
+ ...checkCursor === void 0 ? {} : { check_cursor: checkCursor }
123491
+ })
123492
+ );
123493
+ }
123494
+
123114
123495
  // src/health-check-commands.ts
123115
123496
  var HealthCheckApiError = class extends Error {
123116
123497
  status;
@@ -123698,6 +124079,7 @@ function readRequiredName(parsedArgv) {
123698
124079
  }
123699
124080
  async function handleHealthCommand(parsedArgv, dependencies) {
123700
124081
  const resource = requirePositional(parsedArgv, 1, "resource");
124082
+ if (resource === "status") return handleStatusCommand(parsedArgv, dependencies);
123701
124083
  if (resource !== "checks") {
123702
124084
  throw new CliInputError("Unknown health command.");
123703
124085
  }
@@ -124889,10 +125271,14 @@ async function handleCapturePolicyCommand(parsedArgv, dependencies) {
124889
125271
  const clientErrorPathRuleOptions = readStringListOption(parsedArgv, "client-error-path-rule") ?? [];
124890
125272
  const clientErrorPathRulesJson = readJsonOption(parsedArgv, "client-error-path-rules-json");
124891
125273
  if (clientErrorStatuses !== void 0 && clientErrorIncidents !== "custom") {
124892
- throw new CliInputError("Use --client-error-statuses only with --client-error-incidents custom.");
125274
+ throw new CliInputError(
125275
+ "Use --client-error-statuses only with --client-error-incidents custom."
125276
+ );
124893
125277
  }
124894
125278
  if (clientErrorPathRuleOptions.length > 0 && clientErrorPathRulesJson !== void 0) {
124895
- throw new CliInputError("Use either --client-error-path-rule or --client-error-path-rules-json, not both.");
125279
+ throw new CliInputError(
125280
+ "Use either --client-error-path-rule or --client-error-path-rules-json, not both."
125281
+ );
124896
125282
  }
124897
125283
  if (clientErrorIncidents !== void 0) {
124898
125284
  switch (clientErrorIncidents) {
@@ -125085,7 +125471,7 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
125085
125471
  }
125086
125472
  const expiresAt = readStringOption(parsedArgv, "expires-at");
125087
125473
  if (expiresAt !== void 0) {
125088
- update["expires_at"] = expiresAt;
125474
+ update["expires_at"] = expiresAt === "null" ? null : expiresAt;
125089
125475
  }
125090
125476
  if (Object.keys(update).length === 0) {
125091
125477
  throw new CliInputError("At least one capture rule field must be provided.");
@@ -125117,7 +125503,15 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
125117
125503
  async function handleProbeCommand(parsedArgv, dependencies) {
125118
125504
  const action = requirePositional(parsedArgv, 1, "action");
125119
125505
  if (action === "activate") {
125120
- expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "label-pattern", "service", "environment", "ttl-seconds", "trigger-ttl-seconds"]);
125506
+ expectNoUnknownOptions(parsedArgv, [
125507
+ "auth-file",
125508
+ "json",
125509
+ "label-pattern",
125510
+ "service",
125511
+ "environment",
125512
+ "ttl-seconds",
125513
+ "trigger-ttl-seconds"
125514
+ ]);
125121
125515
  ensureNoExtraPositionals(parsedArgv, 3);
125122
125516
  const projectId = requirePositional(parsedArgv, 2, "project-id");
125123
125517
  const labelPattern = readStringOption(parsedArgv, "label-pattern");
@@ -125170,7 +125564,9 @@ async function handleProbeCommand(parsedArgv, dependencies) {
125170
125564
  function handleMemberCommand(parsedArgv, dependencies) {
125171
125565
  void parsedArgv;
125172
125566
  void dependencies;
125173
- throw new CliInputError("Use `debugbundle project members ... --project-id <id>` for project collaboration commands.");
125567
+ throw new CliInputError(
125568
+ "Use `debugbundle project members ... --project-id <id>` for project collaboration commands."
125569
+ );
125174
125570
  }
125175
125571
 
125176
125572
  // src/alert-commands.ts
@@ -125652,8 +126048,161 @@ async function deleteSlackDestinationWithAuthCommand(input3, dependencies) {
125652
126048
  });
125653
126049
  }
125654
126050
 
125655
- // src/webhook-commands.ts
126051
+ // src/weekly-report-commands.ts
125656
126052
  function mapErrorToExitCode22(error2) {
126053
+ if (!(error2 instanceof WeeklyReportApiError)) {
126054
+ return 1;
126055
+ }
126056
+ if (error2.status === 401) {
126057
+ return 2;
126058
+ }
126059
+ if (error2.status === 404) {
126060
+ return 3;
126061
+ }
126062
+ if (error2.status === 400) {
126063
+ return 4;
126064
+ }
126065
+ return 1;
126066
+ }
126067
+ function formatWeeklyReportChannelTable(channels) {
126068
+ if (channels.length === 0) {
126069
+ return "No weekly report channels found.";
126070
+ }
126071
+ return channels.map(
126072
+ (channel) => `${channel.channel_id} | ${channel.is_enabled ? "enabled" : "disabled"} | ${channel.channel} | ${channel.schedule.day_of_week}@${channel.schedule.hour_of_day} ${channel.schedule.timezone} | project=${channel.project_id}`
126073
+ ).join("\n");
126074
+ }
126075
+ async function listWeeklyReportChannelsCommand(input3, api) {
126076
+ try {
126077
+ const channels = await api.listWeeklyReportChannels({
126078
+ bearerToken: input3.bearerToken,
126079
+ projectId: input3.projectId,
126080
+ ...input3.limit !== void 0 ? { limit: input3.limit } : {}
126081
+ });
126082
+ return {
126083
+ exitCode: 0,
126084
+ output: input3.json ? JSON.stringify({ channels }) : formatWeeklyReportChannelTable(channels)
126085
+ };
126086
+ } catch (error2) {
126087
+ return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126088
+ }
126089
+ }
126090
+ async function listWeeklyReportChannelsWithAuthCommand(input3, dependencies) {
126091
+ return runAuthenticatedCliCommand(input3, {
126092
+ createApi: createAuthenticatedWeeklyReportApi,
126093
+ dependencies,
126094
+ runCommand: (authState, api) => listWeeklyReportChannelsCommand(
126095
+ {
126096
+ bearerToken: authState.bearer_token,
126097
+ projectId: input3.projectId,
126098
+ ...input3.limit !== void 0 ? { limit: input3.limit } : {},
126099
+ ...input3.json !== void 0 ? { json: input3.json } : {}
126100
+ },
126101
+ api
126102
+ )
126103
+ });
126104
+ }
126105
+ async function createWeeklyReportChannelCommand(input3, api) {
126106
+ try {
126107
+ const channel = await api.createWeeklyReportChannel({
126108
+ bearerToken: input3.bearerToken,
126109
+ projectId: input3.projectId,
126110
+ channel: input3.channel,
126111
+ config: input3.config,
126112
+ schedule: input3.schedule,
126113
+ ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {}
126114
+ });
126115
+ return {
126116
+ exitCode: 0,
126117
+ output: input3.json ? JSON.stringify({ channel }) : `Weekly report channel created: ${channel.channel_id}`
126118
+ };
126119
+ } catch (error2) {
126120
+ return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126121
+ }
126122
+ }
126123
+ async function createWeeklyReportChannelWithAuthCommand(input3, dependencies) {
126124
+ return runAuthenticatedCliCommand(input3, {
126125
+ createApi: createAuthenticatedWeeklyReportApi,
126126
+ dependencies,
126127
+ runCommand: (authState, api) => createWeeklyReportChannelCommand(
126128
+ {
126129
+ bearerToken: authState.bearer_token,
126130
+ projectId: input3.projectId,
126131
+ channel: input3.channel,
126132
+ config: input3.config,
126133
+ schedule: input3.schedule,
126134
+ ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {},
126135
+ ...input3.json !== void 0 ? { json: input3.json } : {}
126136
+ },
126137
+ api
126138
+ )
126139
+ });
126140
+ }
126141
+ async function updateWeeklyReportChannelCommand(input3, api) {
126142
+ try {
126143
+ const channel = await api.updateWeeklyReportChannel({
126144
+ bearerToken: input3.bearerToken,
126145
+ channelId: input3.channelId,
126146
+ ...input3.config !== void 0 ? { config: input3.config } : {},
126147
+ ...input3.schedule !== void 0 ? { schedule: input3.schedule } : {},
126148
+ ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {}
126149
+ });
126150
+ return {
126151
+ exitCode: 0,
126152
+ output: input3.json ? JSON.stringify({ channel }) : `Weekly report channel updated: ${channel.channel_id}`
126153
+ };
126154
+ } catch (error2) {
126155
+ return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126156
+ }
126157
+ }
126158
+ async function updateWeeklyReportChannelWithAuthCommand(input3, dependencies) {
126159
+ return runAuthenticatedCliCommand(input3, {
126160
+ createApi: createAuthenticatedWeeklyReportApi,
126161
+ dependencies,
126162
+ runCommand: (authState, api) => updateWeeklyReportChannelCommand(
126163
+ {
126164
+ bearerToken: authState.bearer_token,
126165
+ channelId: input3.channelId,
126166
+ ...input3.config !== void 0 ? { config: input3.config } : {},
126167
+ ...input3.schedule !== void 0 ? { schedule: input3.schedule } : {},
126168
+ ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {},
126169
+ ...input3.json !== void 0 ? { json: input3.json } : {}
126170
+ },
126171
+ api
126172
+ )
126173
+ });
126174
+ }
126175
+ async function deleteWeeklyReportChannelCommand(input3, api) {
126176
+ try {
126177
+ const deleted = await api.deleteWeeklyReportChannel({
126178
+ bearerToken: input3.bearerToken,
126179
+ channelId: input3.channelId
126180
+ });
126181
+ return {
126182
+ exitCode: 0,
126183
+ output: input3.json ? JSON.stringify({ channel: deleted }) : `Weekly report channel deleted: ${deleted.channel_id}`
126184
+ };
126185
+ } catch (error2) {
126186
+ return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126187
+ }
126188
+ }
126189
+ async function deleteWeeklyReportChannelWithAuthCommand(input3, dependencies) {
126190
+ return runAuthenticatedCliCommand(input3, {
126191
+ createApi: createAuthenticatedWeeklyReportApi,
126192
+ dependencies,
126193
+ runCommand: (authState, api) => deleteWeeklyReportChannelCommand(
126194
+ {
126195
+ bearerToken: authState.bearer_token,
126196
+ channelId: input3.channelId,
126197
+ ...input3.json !== void 0 ? { json: input3.json } : {}
126198
+ },
126199
+ api
126200
+ )
126201
+ });
126202
+ }
126203
+
126204
+ // src/webhook-commands.ts
126205
+ function mapErrorToExitCode23(error2) {
125657
126206
  if (!(error2 instanceof WebhookApiError)) {
125658
126207
  return 1;
125659
126208
  }
@@ -125681,7 +126230,9 @@ function formatWebhookDeliveriesTable(deliveries) {
125681
126230
  if (deliveries.length === 0) {
125682
126231
  return "No deliveries found.";
125683
126232
  }
125684
- return deliveries.map((delivery) => `${delivery.delivery_id} | ${delivery.status} | ${delivery.event_type} | attempts=${delivery.attempt_count}`).join("\n");
126233
+ return deliveries.map(
126234
+ (delivery) => `${delivery.delivery_id} | ${delivery.status} | ${delivery.event_type} | attempts=${delivery.attempt_count}`
126235
+ ).join("\n");
125685
126236
  }
125686
126237
  async function listWebhooksCommand(input3, api) {
125687
126238
  try {
@@ -125698,7 +126249,10 @@ async function listWebhooksCommand(input3, api) {
125698
126249
  output: input3.json ? JSON.stringify({ webhooks }) : formatWebhookTable(webhooks)
125699
126250
  };
125700
126251
  } catch (error2) {
125701
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126252
+ return {
126253
+ exitCode: mapErrorToExitCode23(error2),
126254
+ output: error2 instanceof Error ? error2.message : String(error2)
126255
+ };
125702
126256
  }
125703
126257
  }
125704
126258
  async function listWebhooksWithAuthCommand(input3, dependencies) {
@@ -125746,7 +126300,10 @@ async function createWebhookCommand(input3, api) {
125746
126300
  Signing secret: ${webhook.signing_secret}`
125747
126301
  };
125748
126302
  } catch (error2) {
125749
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126303
+ return {
126304
+ exitCode: mapErrorToExitCode23(error2),
126305
+ output: error2 instanceof Error ? error2.message : String(error2)
126306
+ };
125750
126307
  }
125751
126308
  }
125752
126309
  async function createWebhookWithAuthCommand(input3, dependencies) {
@@ -125800,7 +126357,10 @@ async function updateWebhookCommand(input3, api) {
125800
126357
  output: input3.json ? JSON.stringify({ webhook }) : `Webhook updated: ${webhook.webhook_id}`
125801
126358
  };
125802
126359
  } catch (error2) {
125803
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126360
+ return {
126361
+ exitCode: mapErrorToExitCode23(error2),
126362
+ output: error2 instanceof Error ? error2.message : String(error2)
126363
+ };
125804
126364
  }
125805
126365
  }
125806
126366
  async function updateWebhookWithAuthCommand(input3, dependencies) {
@@ -125846,7 +126406,10 @@ async function deleteWebhookCommand(input3, api) {
125846
126406
  output: input3.json ? JSON.stringify({ webhook }) : `Webhook deleted: ${webhook.webhook_id}`
125847
126407
  };
125848
126408
  } catch (error2) {
125849
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126409
+ return {
126410
+ exitCode: mapErrorToExitCode23(error2),
126411
+ output: error2 instanceof Error ? error2.message : String(error2)
126412
+ };
125850
126413
  }
125851
126414
  }
125852
126415
  async function deleteWebhookWithAuthCommand(input3, dependencies) {
@@ -125884,7 +126447,10 @@ async function testWebhookCommand(input3, api) {
125884
126447
  output: input3.json ? JSON.stringify({ delivery }) : `Webhook test queued: ${delivery.delivery_id} | ${delivery.event_type} | attempts=${delivery.attempt_count}`
125885
126448
  };
125886
126449
  } catch (error2) {
125887
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126450
+ return {
126451
+ exitCode: mapErrorToExitCode23(error2),
126452
+ output: error2 instanceof Error ? error2.message : String(error2)
126453
+ };
125888
126454
  }
125889
126455
  }
125890
126456
  async function testWebhookWithAuthCommand(input3, dependencies) {
@@ -125925,7 +126491,10 @@ async function listWebhookDeliveriesCommand(input3, api) {
125925
126491
  output: input3.json ? JSON.stringify({ deliveries }) : formatWebhookDeliveriesTable(deliveries)
125926
126492
  };
125927
126493
  } catch (error2) {
125928
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126494
+ return {
126495
+ exitCode: mapErrorToExitCode23(error2),
126496
+ output: error2 instanceof Error ? error2.message : String(error2)
126497
+ };
125929
126498
  }
125930
126499
  }
125931
126500
  async function listWebhookDeliveriesWithAuthCommand(input3, dependencies) {
@@ -125963,7 +126532,10 @@ async function retryWebhookDeliveryCommand(input3, api) {
125963
126532
  output: input3.json ? JSON.stringify(result) : `Delivery retried: ${result.delivery_id} | ${result.event_type}`
125964
126533
  };
125965
126534
  } catch (error2) {
125966
- return { exitCode: mapErrorToExitCode22(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126535
+ return {
126536
+ exitCode: mapErrorToExitCode23(error2),
126537
+ output: error2 instanceof Error ? error2.message : String(error2)
126538
+ };
125967
126539
  }
125968
126540
  }
125969
126541
  async function retryWebhookDeliveryWithAuthCommand(input3, dependencies) {
@@ -125987,160 +126559,36 @@ async function retryWebhookDeliveryWithAuthCommand(input3, dependencies) {
125987
126559
  });
125988
126560
  }
125989
126561
 
125990
- // src/weekly-report-commands.ts
125991
- function mapErrorToExitCode23(error2) {
125992
- if (!(error2 instanceof WeeklyReportApiError)) {
125993
- return 1;
125994
- }
125995
- if (error2.status === 401) {
125996
- return 2;
125997
- }
125998
- if (error2.status === 404) {
125999
- return 3;
126000
- }
126001
- if (error2.status === 400) {
126002
- return 4;
126003
- }
126004
- return 1;
126005
- }
126006
- function formatWeeklyReportChannelTable(channels) {
126007
- if (channels.length === 0) {
126008
- return "No weekly report channels found.";
126009
- }
126010
- return channels.map(
126011
- (channel) => `${channel.channel_id} | ${channel.is_enabled ? "enabled" : "disabled"} | ${channel.channel} | ${channel.schedule.day_of_week}@${channel.schedule.hour_of_day} ${channel.schedule.timezone} | project=${channel.project_id}`
126012
- ).join("\n");
126013
- }
126014
- async function listWeeklyReportChannelsCommand(input3, api) {
126015
- try {
126016
- const channels = await api.listWeeklyReportChannels({
126017
- bearerToken: input3.bearerToken,
126018
- projectId: input3.projectId,
126019
- ...input3.limit !== void 0 ? { limit: input3.limit } : {}
126020
- });
126021
- return {
126022
- exitCode: 0,
126023
- output: input3.json ? JSON.stringify({ channels }) : formatWeeklyReportChannelTable(channels)
126024
- };
126025
- } catch (error2) {
126026
- return { exitCode: mapErrorToExitCode23(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126027
- }
126028
- }
126029
- async function listWeeklyReportChannelsWithAuthCommand(input3, dependencies) {
126030
- return runAuthenticatedCliCommand(input3, {
126031
- createApi: createAuthenticatedWeeklyReportApi,
126032
- dependencies,
126033
- runCommand: (authState, api) => listWeeklyReportChannelsCommand(
126034
- {
126035
- bearerToken: authState.bearer_token,
126036
- projectId: input3.projectId,
126037
- ...input3.limit !== void 0 ? { limit: input3.limit } : {},
126038
- ...input3.json !== void 0 ? { json: input3.json } : {}
126039
- },
126040
- api
126041
- )
126042
- });
126043
- }
126044
- async function createWeeklyReportChannelCommand(input3, api) {
126045
- try {
126046
- const channel = await api.createWeeklyReportChannel({
126047
- bearerToken: input3.bearerToken,
126048
- projectId: input3.projectId,
126049
- channel: input3.channel,
126050
- config: input3.config,
126051
- schedule: input3.schedule,
126052
- ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {}
126053
- });
126054
- return {
126055
- exitCode: 0,
126056
- output: input3.json ? JSON.stringify({ channel }) : `Weekly report channel created: ${channel.channel_id}`
126057
- };
126058
- } catch (error2) {
126059
- return { exitCode: mapErrorToExitCode23(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126060
- }
126061
- }
126062
- async function createWeeklyReportChannelWithAuthCommand(input3, dependencies) {
126063
- return runAuthenticatedCliCommand(input3, {
126064
- createApi: createAuthenticatedWeeklyReportApi,
126065
- dependencies,
126066
- runCommand: (authState, api) => createWeeklyReportChannelCommand(
126067
- {
126068
- bearerToken: authState.bearer_token,
126069
- projectId: input3.projectId,
126070
- channel: input3.channel,
126071
- config: input3.config,
126072
- schedule: input3.schedule,
126073
- ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {},
126074
- ...input3.json !== void 0 ? { json: input3.json } : {}
126075
- },
126076
- api
126077
- )
126078
- });
126079
- }
126080
- async function updateWeeklyReportChannelCommand(input3, api) {
126081
- try {
126082
- const channel = await api.updateWeeklyReportChannel({
126083
- bearerToken: input3.bearerToken,
126084
- channelId: input3.channelId,
126085
- ...input3.config !== void 0 ? { config: input3.config } : {},
126086
- ...input3.schedule !== void 0 ? { schedule: input3.schedule } : {},
126087
- ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {}
126088
- });
126089
- return {
126090
- exitCode: 0,
126091
- output: input3.json ? JSON.stringify({ channel }) : `Weekly report channel updated: ${channel.channel_id}`
126092
- };
126093
- } catch (error2) {
126094
- return { exitCode: mapErrorToExitCode23(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126562
+ // src/webhook-command-handler.ts
126563
+ function readWebhookFilters(parsedArgv) {
126564
+ const explicitFilters = readJsonOption(parsedArgv, "filters-json");
126565
+ if (explicitFilters !== void 0) {
126566
+ if (["environment", "service", "severity-min", "bundle-type", "verification"].some(
126567
+ (option) => parsedArgv.options.has(option)
126568
+ )) {
126569
+ throw new CliInputError("--filters-json cannot be combined with individual filter options.");
126570
+ }
126571
+ const parsed = WebhookFiltersSchema.safeParse(explicitFilters);
126572
+ if (!parsed.success) {
126573
+ throw new CliInputError("Invalid value for --filters-json.");
126574
+ }
126575
+ return parsed.data;
126095
126576
  }
126096
- }
126097
- async function updateWeeklyReportChannelWithAuthCommand(input3, dependencies) {
126098
- return runAuthenticatedCliCommand(input3, {
126099
- createApi: createAuthenticatedWeeklyReportApi,
126100
- dependencies,
126101
- runCommand: (authState, api) => updateWeeklyReportChannelCommand(
126102
- {
126103
- bearerToken: authState.bearer_token,
126104
- channelId: input3.channelId,
126105
- ...input3.config !== void 0 ? { config: input3.config } : {},
126106
- ...input3.schedule !== void 0 ? { schedule: input3.schedule } : {},
126107
- ...input3.isEnabled !== void 0 ? { isEnabled: input3.isEnabled } : {},
126108
- ...input3.json !== void 0 ? { json: input3.json } : {}
126109
- },
126110
- api
126111
- )
126112
- });
126113
- }
126114
- async function deleteWeeklyReportChannelCommand(input3, api) {
126115
- try {
126116
- const deleted = await api.deleteWeeklyReportChannel({
126117
- bearerToken: input3.bearerToken,
126118
- channelId: input3.channelId
126119
- });
126120
- return {
126121
- exitCode: 0,
126122
- output: input3.json ? JSON.stringify({ channel: deleted }) : `Weekly report channel deleted: ${deleted.channel_id}`
126123
- };
126124
- } catch (error2) {
126125
- return { exitCode: mapErrorToExitCode23(error2), output: error2 instanceof Error ? error2.message : String(error2) };
126577
+ const filters = {};
126578
+ for (const [option, field] of [
126579
+ ["environment", "environment"],
126580
+ ["service", "service"],
126581
+ ["bundle-type", "bundle_type"]
126582
+ ]) {
126583
+ const values = readCsvOption(parsedArgv, option);
126584
+ if (values !== void 0) filters[field] = values;
126126
126585
  }
126586
+ const severityMin = readStringOption(parsedArgv, "severity-min");
126587
+ if (severityMin !== void 0) filters["severity_min"] = severityMin;
126588
+ const verification = readBooleanStringOption(parsedArgv, "verification");
126589
+ if (verification !== void 0) filters["verification"] = verification;
126590
+ return Object.keys(filters).length > 0 ? filters : void 0;
126127
126591
  }
126128
- async function deleteWeeklyReportChannelWithAuthCommand(input3, dependencies) {
126129
- return runAuthenticatedCliCommand(input3, {
126130
- createApi: createAuthenticatedWeeklyReportApi,
126131
- dependencies,
126132
- runCommand: (authState, api) => deleteWeeklyReportChannelCommand(
126133
- {
126134
- bearerToken: authState.bearer_token,
126135
- channelId: input3.channelId,
126136
- ...input3.json !== void 0 ? { json: input3.json } : {}
126137
- },
126138
- api
126139
- )
126140
- });
126141
- }
126142
-
126143
- // src/management-webhook-alert-slack-weekly-command-handlers.ts
126144
126592
  async function handleWebhookCommand(parsedArgv, dependencies) {
126145
126593
  const action = requirePositional(parsedArgv, 1, "action");
126146
126594
  if (action === "list") {
@@ -126191,28 +126639,8 @@ async function handleWebhookCommand(parsedArgv, dependencies) {
126191
126639
  url,
126192
126640
  events: events2
126193
126641
  });
126194
- const filters = {};
126195
- const environment = readCsvOption(parsedArgv, "environment");
126196
- if (environment !== void 0) {
126197
- filters["environment"] = environment;
126198
- }
126199
- const service = readCsvOption(parsedArgv, "service");
126200
- if (service !== void 0) {
126201
- filters["service"] = service;
126202
- }
126203
- const severityMin = readStringOption(parsedArgv, "severity-min");
126204
- if (severityMin !== void 0) {
126205
- filters["severity_min"] = severityMin;
126206
- }
126207
- const bundleType = readCsvOption(parsedArgv, "bundle-type");
126208
- if (bundleType !== void 0) {
126209
- filters["bundle_type"] = bundleType;
126210
- }
126211
- const verification = readBooleanStringOption(parsedArgv, "verification");
126212
- if (verification !== void 0) {
126213
- filters["verification"] = verification;
126214
- }
126215
- if (Object.keys(filters).length > 0) {
126642
+ const filters = readWebhookFilters(parsedArgv);
126643
+ if (filters !== void 0) {
126216
126644
  input3.filters = filters;
126217
126645
  }
126218
126646
  const isEnabled = readBooleanStringOption(parsedArgv, "is-enabled");
@@ -126233,6 +126661,7 @@ async function handleWebhookCommand(parsedArgv, dependencies) {
126233
126661
  "severity-min",
126234
126662
  "bundle-type",
126235
126663
  "verification",
126664
+ "filters-json",
126236
126665
  "is-enabled"
126237
126666
  ]);
126238
126667
  ensureNoExtraPositionals(parsedArgv, 3);
@@ -126252,28 +126681,8 @@ async function handleWebhookCommand(parsedArgv, dependencies) {
126252
126681
  if (events2 !== void 0) {
126253
126682
  input3.events = events2;
126254
126683
  }
126255
- const filters = {};
126256
- const environment = readCsvOption(parsedArgv, "environment");
126257
- if (environment !== void 0) {
126258
- filters["environment"] = environment;
126259
- }
126260
- const service = readCsvOption(parsedArgv, "service");
126261
- if (service !== void 0) {
126262
- filters["service"] = service;
126263
- }
126264
- const severityMin = readStringOption(parsedArgv, "severity-min");
126265
- if (severityMin !== void 0) {
126266
- filters["severity_min"] = severityMin;
126267
- }
126268
- const bundleType = readCsvOption(parsedArgv, "bundle-type");
126269
- if (bundleType !== void 0) {
126270
- filters["bundle_type"] = bundleType;
126271
- }
126272
- const verification = readBooleanStringOption(parsedArgv, "verification");
126273
- if (verification !== void 0) {
126274
- filters["verification"] = verification;
126275
- }
126276
- if (Object.keys(filters).length > 0) {
126684
+ const filters = readWebhookFilters(parsedArgv);
126685
+ if (filters !== void 0) {
126277
126686
  input3.filters = filters;
126278
126687
  }
126279
126688
  const isEnabled = readBooleanStringOption(parsedArgv, "is-enabled");
@@ -126312,10 +126721,11 @@ async function handleWebhookCommand(parsedArgv, dependencies) {
126312
126721
  });
126313
126722
  const eventType = readStringOption(parsedArgv, "event");
126314
126723
  if (eventType !== void 0) {
126315
- if (eventType !== "verification.passed" && eventType !== "verification.failed") {
126724
+ const parsedEvent = WebhookEventTypeSchema.safeParse(eventType);
126725
+ if (!parsedEvent.success) {
126316
126726
  throw new CliInputError("Invalid value for --event.");
126317
126727
  }
126318
- input3.eventType = eventType;
126728
+ input3.eventType = parsedEvent.data;
126319
126729
  }
126320
126730
  return await (dependencies.testWebhookCommand ?? testWebhookWithAuthCommand)(input3);
126321
126731
  }
@@ -126334,7 +126744,9 @@ async function handleWebhookCommand(parsedArgv, dependencies) {
126334
126744
  if (limit !== void 0) {
126335
126745
  input3.limit = limit;
126336
126746
  }
126337
- return await (dependencies.listWebhookDeliveriesCommand ?? listWebhookDeliveriesWithAuthCommand)(input3);
126747
+ return await (dependencies.listWebhookDeliveriesCommand ?? listWebhookDeliveriesWithAuthCommand)(
126748
+ input3
126749
+ );
126338
126750
  }
126339
126751
  if (action === "retry") {
126340
126752
  expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "project-id"]);
@@ -126348,10 +126760,14 @@ async function handleWebhookCommand(parsedArgv, dependencies) {
126348
126760
  webhookId: requirePositional(parsedArgv, 2, "webhook-id"),
126349
126761
  deliveryId: requirePositional(parsedArgv, 3, "delivery-id")
126350
126762
  });
126351
- return await (dependencies.retryWebhookDeliveryCommand ?? retryWebhookDeliveryWithAuthCommand)(input3);
126763
+ return await (dependencies.retryWebhookDeliveryCommand ?? retryWebhookDeliveryWithAuthCommand)(
126764
+ input3
126765
+ );
126352
126766
  }
126353
126767
  throw new CliInputError("Unknown webhook command.");
126354
126768
  }
126769
+
126770
+ // src/management-webhook-alert-slack-weekly-command-handlers.ts
126355
126771
  async function handleAlertCommand(parsedArgv, dependencies) {
126356
126772
  const action = requirePositional(parsedArgv, 1, "action");
126357
126773
  if (action === "groups" || action === "group") {
@@ -126457,7 +126873,9 @@ async function handleAlertCommand(parsedArgv, dependencies) {
126457
126873
  if (isEnabled !== void 0) {
126458
126874
  input3.isEnabled = isEnabled;
126459
126875
  }
126460
- return await (dependencies.createAlertCommand ?? createAlertWithAuthCommand)(input3);
126876
+ return await (dependencies.createAlertCommand ?? createAlertWithAuthCommand)(
126877
+ input3
126878
+ );
126461
126879
  }
126462
126880
  if (action === "update") {
126463
126881
  expectNoUnknownOptions(parsedArgv, [
@@ -126521,7 +126939,9 @@ async function handleAlertCommand(parsedArgv, dependencies) {
126521
126939
  if (input3.serviceId === void 0 && input3.channel === void 0 && input3.conditionType === void 0 && input3.severityMin === void 0 && input3.severityLifecycleScope === void 0 && input3.cooldownSeconds === void 0 && input3.config === void 0 && input3.rotateSigningSecret === void 0 && input3.isEnabled === void 0) {
126522
126940
  throw new CliInputError("At least one alert field must be provided.");
126523
126941
  }
126524
- return await (dependencies.updateAlertCommand ?? updateAlertWithAuthCommand)(input3);
126942
+ return await (dependencies.updateAlertCommand ?? updateAlertWithAuthCommand)(
126943
+ input3
126944
+ );
126525
126945
  }
126526
126946
  if (action === "delete") {
126527
126947
  expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "project-id"]);
@@ -126568,7 +126988,9 @@ async function handleSlackCommand(parsedArgv, dependencies) {
126568
126988
  if (returnTo !== void 0) {
126569
126989
  input3.returnTo = returnTo;
126570
126990
  }
126571
- return await (dependencies.getSlackConnectUrlCommand ?? getSlackConnectUrlWithAuthCommand)(input3);
126991
+ return await (dependencies.getSlackConnectUrlCommand ?? getSlackConnectUrlWithAuthCommand)(
126992
+ input3
126993
+ );
126572
126994
  }
126573
126995
  if (action === "test") {
126574
126996
  expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "project-id"]);
@@ -126658,9 +127080,13 @@ async function handleWeeklyReportCommand(parsedArgv, dependencies) {
126658
127080
  let weeklyReportConfig;
126659
127081
  if (channel === "slack") {
126660
127082
  if (typeof config2["slack_destination_id"] === "string") {
126661
- weeklyReportConfig = { slackDestinationId: String(config2["slack_destination_id"]) };
127083
+ weeklyReportConfig = {
127084
+ slackDestinationId: String(config2["slack_destination_id"])
127085
+ };
126662
127086
  } else {
126663
- weeklyReportConfig = { webhookUrl: String(config2["webhook_url"]) };
127087
+ weeklyReportConfig = {
127088
+ webhookUrl: String(config2["webhook_url"])
127089
+ };
126664
127090
  }
126665
127091
  } else {
126666
127092
  weeklyReportConfig = { to: config2.to };
@@ -126700,7 +127126,9 @@ async function handleWeeklyReportCommand(parsedArgv, dependencies) {
126700
127126
  const timezone = readStringOption(parsedArgv, "timezone");
126701
127127
  if (dayOfWeek !== void 0 || hourOfDay !== void 0 || timezone !== void 0) {
126702
127128
  if (dayOfWeek === void 0 || hourOfDay === void 0 || timezone === void 0) {
126703
- throw new CliInputError("Weekly report schedule updates require --day-of-week, --hour-of-day, and --timezone together.");
127129
+ throw new CliInputError(
127130
+ "Weekly report schedule updates require --day-of-week, --hour-of-day, and --timezone together."
127131
+ );
126704
127132
  }
126705
127133
  input3.schedule = { dayOfWeek, hourOfDay, timezone };
126706
127134
  }
@@ -126709,7 +127137,11 @@ async function handleWeeklyReportCommand(parsedArgv, dependencies) {
126709
127137
  if (typeof config2 !== "object" || config2 === null) {
126710
127138
  throw new CliInputError("Invalid value for --config-json.");
126711
127139
  }
126712
- input3.config = "slack_destination_id" in config2 ? { slackDestinationId: String(config2["slack_destination_id"]) } : "webhook_url" in config2 ? { webhookUrl: String(config2["webhook_url"]) } : { to: config2.to };
127140
+ input3.config = "slack_destination_id" in config2 ? {
127141
+ slackDestinationId: String(
127142
+ config2["slack_destination_id"]
127143
+ )
127144
+ } : "webhook_url" in config2 ? { webhookUrl: String(config2["webhook_url"]) } : { to: config2.to };
126713
127145
  }
126714
127146
  const isEnabled = readBooleanStringOption(parsedArgv, "is-enabled");
126715
127147
  if (isEnabled !== void 0) {
@@ -126776,7 +127208,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
126776
127208
  // package.json
126777
127209
  var package_default = {
126778
127210
  name: "@debugbundle/cli",
126779
- version: "1.13.1",
127211
+ version: "1.15.0",
126780
127212
  private: false,
126781
127213
  description: "Command-line interface for DebugBundle",
126782
127214
  license: "Apache-2.0",