@bugbug-io/cli 14.5.0 → 14.6.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.
@@ -62,7 +62,7 @@ import {
62
62
  waitForSuiteRun,
63
63
  waitForTestRun,
64
64
  writeReportXml
65
- } from "./chunk-2ZIWRWZK.js";
65
+ } from "./chunk-RONAEYWS.js";
66
66
  import "./chunk-XLIBEETK.js";
67
67
  import "./chunk-3PJ4ZE2N.js";
68
68
  import {
@@ -11130,5 +11130,5 @@ react-router/dist/development/index.mjs:
11130
11130
  * @license MIT
11131
11131
  *)
11132
11132
  */
11133
- //# sourceMappingURL=NavigatorApp-76WOOBZX.js.map
11133
+ //# sourceMappingURL=NavigatorApp-5E5EE7CU.js.map
11134
11134
  //# debugId=9e90a61c-d567-5034-bd9e-55c33ff018a1
@@ -12,7 +12,7 @@ var startNavigator = async (opts = {}) => {
12
12
  const [{ render }, React, { NavigatorApp }] = await Promise.all([
13
13
  import("./render-CSMURV5U.js"),
14
14
  importReact(),
15
- import("./NavigatorApp-76WOOBZX.js")
15
+ import("./NavigatorApp-5E5EE7CU.js")
16
16
  ]);
17
17
  const element = React.createElement(
18
18
  NavigatorApp,
@@ -27,5 +27,5 @@ var startNavigator = async (opts = {}) => {
27
27
  export {
28
28
  startNavigator
29
29
  };
30
- //# sourceMappingURL=app-SJH7MMH6.js.map
30
+ //# sourceMappingURL=app-RFZH4MU7.js.map
31
31
  //# debugId=cecc8c80-302a-54e0-a1fb-74d6bb70c0a1
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="11f5fc11-595f-51d4-8e05-bca1f6eb53a0")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2c40ab42-03d3-514a-a95d-bd3f25f12c2c")}catch(e){}}();
3
3
  import { createRequire as __nodeCreateRequire } from 'node:module';
4
4
  const require = __nodeCreateRequire(import.meta.url);
5
5
  import {
@@ -8930,7 +8930,7 @@ var require_main = __commonJS({
8930
8930
  // ../core/package.json
8931
8931
  var package_default = {
8932
8932
  name: "@bugbug-io/core",
8933
- version: "14.5.0",
8933
+ version: "14.6.0",
8934
8934
  private: true,
8935
8935
  type: "module",
8936
8936
  main: "dist/index.js",
@@ -58262,7 +58262,7 @@ var readEnvFiles2 = (cwd) => {
58262
58262
  var buildUserAgent2 = (clientType, version) => `BugBug ${clientType.toUpperCase()} ${version}`;
58263
58263
  var package_default2 = {
58264
58264
  name: "@bugbug-io/core",
58265
- version: "14.5.0",
58265
+ version: "14.6.0",
58266
58266
  private: true,
58267
58267
  type: "module",
58268
58268
  main: "dist/index.js",
@@ -58488,12 +58488,15 @@ var RATE_LIMIT_MIN_WINDOW_MS = 1e3;
58488
58488
  var RATE_LIMIT_MAX_WINDOW_MS = 6e4;
58489
58489
  var RateLimiter = class {
58490
58490
  #requests = [];
58491
+ #activeRequests = 0;
58492
+ #slotQueue = [];
58491
58493
  #config;
58492
58494
  constructor(config) {
58493
58495
  this.#warnIfUnsupportedConfig(config);
58494
58496
  this.#config = {
58495
58497
  maxRequests: config.maxRequests,
58496
58498
  windowMs: config.windowMs,
58499
+ maxConcurrentRequests: config.maxConcurrentRequests ?? Number.POSITIVE_INFINITY,
58497
58500
  retryAfter: config.retryAfter || 1e3,
58498
58501
  retryServer429: config.retryServer429 ?? true,
58499
58502
  exponentialBackoff: {
@@ -58531,51 +58534,67 @@ var RateLimiter = class {
58531
58534
  * @throws {RateLimitError} When retries are exhausted or `retryServer429` is
58532
58535
  * disabled and the server returned 429.
58533
58536
  */
58534
- async execute(fn) {
58537
+ async execute(fn, options = {}) {
58538
+ const retryServer429 = options.retryServer429 ?? this.#config.retryServer429;
58535
58539
  let lastError = null;
58536
- for (let attempt = 0; attempt <= this.#config.exponentialBackoff.maxRetries; attempt++) {
58537
- if (!this.#canMakeRequest()) {
58538
- const waitTime = this.#getWaitTime();
58539
- const gateError = new RateLimitError(
58540
- waitTime,
58541
- `Rate limit exceeded. Wait ${waitTime}ms before retrying.`
58542
- );
58543
- lastError = gateError;
58544
- if (attempt === this.#config.exponentialBackoff.maxRetries) {
58545
- throw gateError;
58546
- }
58547
- await this.#sleep(this.#computeBackoff(attempt, gateError.retryAfter));
58548
- continue;
58549
- }
58550
- const stamp = this.#recordRequest();
58551
- try {
58552
- return await fn();
58553
- } catch (fnError) {
58554
- this.#releaseRequest(stamp);
58555
- if (!(fnError instanceof RateLimitError)) {
58556
- throw fnError;
58557
- }
58558
- lastError = fnError;
58559
- if (!this.#config.retryServer429) {
58560
- throw fnError;
58540
+ await this.#acquireSlot();
58541
+ try {
58542
+ for (let attempt = 0; attempt <= this.#config.exponentialBackoff.maxRetries; attempt++) {
58543
+ if (!this.#canMakeRequest()) {
58544
+ const waitTime = this.#getWaitTime();
58545
+ const gateError = new RateLimitError(
58546
+ waitTime,
58547
+ `Rate limit exceeded. Wait ${waitTime}ms before retrying.`
58548
+ );
58549
+ lastError = gateError;
58550
+ if (attempt === this.#config.exponentialBackoff.maxRetries) {
58551
+ throw gateError;
58552
+ }
58553
+ await this.#sleep(this.#computeBackoff(attempt, gateError.retryAfter));
58554
+ continue;
58561
58555
  }
58562
- if (attempt === this.#config.exponentialBackoff.maxRetries) {
58563
- throw fnError;
58556
+ const stamp = this.#recordRequest();
58557
+ try {
58558
+ return await fn();
58559
+ } catch (fnError) {
58560
+ this.#releaseRequest(stamp);
58561
+ if (!(fnError instanceof RateLimitError)) {
58562
+ throw fnError;
58563
+ }
58564
+ lastError = fnError;
58565
+ if (!retryServer429) {
58566
+ throw fnError;
58567
+ }
58568
+ if (attempt === this.#config.exponentialBackoff.maxRetries) {
58569
+ throw fnError;
58570
+ }
58571
+ await this.#sleep(this.#computeBackoff(attempt, fnError.retryAfter));
58564
58572
  }
58565
- await this.#sleep(this.#computeBackoff(attempt, fnError.retryAfter));
58566
58573
  }
58574
+ throw lastError || new Error("Max retries exceeded");
58575
+ } finally {
58576
+ this.#releaseSlot();
58567
58577
  }
58568
- throw lastError || new Error("Max retries exceeded");
58569
58578
  }
58570
58579
  #computeBackoff = (attempt, retryAfter) => {
58571
- const baseDelay = retryAfter || this.#config.exponentialBackoff.baseDelay;
58572
- const delay = Math.min(
58573
- baseDelay * Math.pow(2, attempt),
58574
- this.#config.exponentialBackoff.maxDelay
58575
- );
58580
+ const baseDelay = retryAfter ?? this.#config.exponentialBackoff.baseDelay;
58581
+ const computedDelay = baseDelay * Math.pow(2, attempt);
58582
+ const delay = retryAfter !== void 0 ? Math.max(retryAfter, computedDelay) : Math.min(computedDelay, this.#config.exponentialBackoff.maxDelay);
58576
58583
  const jitter = Math.random() * 0.1 * delay;
58577
58584
  return delay + jitter;
58578
58585
  };
58586
+ async #acquireSlot() {
58587
+ while (this.#activeRequests >= this.#config.maxConcurrentRequests) {
58588
+ await new Promise((resolve42) => {
58589
+ this.#slotQueue.push(resolve42);
58590
+ });
58591
+ }
58592
+ this.#activeRequests++;
58593
+ }
58594
+ #releaseSlot() {
58595
+ this.#activeRequests = Math.max(0, this.#activeRequests - 1);
58596
+ this.#slotQueue.shift()?.();
58597
+ }
58579
58598
  /**
58580
58599
  * Sleep utility
58581
58600
  */
@@ -58780,6 +58799,16 @@ var BugBugApiClient = class {
58780
58799
  const resolved = resolveEnvConfig2({
58781
58800
  overrides: { token: config.apiToken, apiUrl: config.apiUrl, projectId: config.projectId }
58782
58801
  });
58802
+ const rateLimit = config.rateLimit || {
58803
+ maxRequests: 100,
58804
+ windowMs: 6e4,
58805
+ exponentialBackoff: {
58806
+ baseDelay: 1e3,
58807
+ maxDelay: 3e4,
58808
+ maxRetries: 3
58809
+ }
58810
+ };
58811
+ const rateLimiter = config.rateLimiter ?? new RateLimiter(rateLimit);
58783
58812
  this.#config = {
58784
58813
  apiToken: resolved.token ?? "",
58785
58814
  projectId: resolved.projectId ?? "",
@@ -58788,15 +58817,7 @@ var BugBugApiClient = class {
58788
58817
  verbose: config.verbose || false,
58789
58818
  logLevel: config.logLevel || "info",
58790
58819
  timeout: config.timeout || 3e4,
58791
- rateLimit: config.rateLimit || {
58792
- maxRequests: 100,
58793
- windowMs: 6e4,
58794
- exponentialBackoff: {
58795
- baseDelay: 1e3,
58796
- maxDelay: 3e4,
58797
- maxRetries: 3
58798
- }
58799
- },
58820
+ rateLimit,
58800
58821
  requestHeaders: {
58801
58822
  "User-Agent": buildUserAgent2("sdk", getVersion2()),
58802
58823
  ...config.requestHeaders
@@ -58806,11 +58827,12 @@ var BugBugApiClient = class {
58806
58827
  onAfterRequest: config.onAfterRequest || (() => {
58807
58828
  }),
58808
58829
  onRequestError: config.onRequestError || (() => {
58809
- })
58830
+ }),
58831
+ rateLimiter
58810
58832
  };
58811
58833
  this.#validateConfig();
58812
58834
  this.#client = this.#createApiClient();
58813
- this.#rateLimiter = new RateLimiter(this.#config.rateLimit);
58835
+ this.#rateLimiter = rateLimiter;
58814
58836
  }
58815
58837
  #createApiClient = () => createClient({
58816
58838
  baseUrl: this.#config.apiUrl,
@@ -58890,71 +58912,75 @@ var BugBugApiClient = class {
58890
58912
  headers: customHeaders
58891
58913
  };
58892
58914
  this.#config.onBeforeRequest(requestData);
58893
- return this.#rateLimiter.execute(async () => {
58894
- const abortContext = this.#createAbortContext(signal, timeout);
58895
- try {
58896
- if (this.#config.verbose) {
58897
- this.#log("debug", `\u2192 ${method} ${path3}`, { params, body });
58898
- }
58899
- const requestOptions = {
58900
- signal: abortContext.signal,
58901
- headers: {
58902
- ...customHeaders,
58903
- ...this.#identityHeaders()
58915
+ return this.#rateLimiter.execute(
58916
+ async () => {
58917
+ const abortContext = this.#createAbortContext(signal, timeout);
58918
+ try {
58919
+ this.#throwIfAlreadyAborted(abortContext, requestOrigin);
58920
+ if (this.#config.verbose) {
58921
+ this.#log("debug", `\u2192 ${method} ${path3}`, { params, body });
58922
+ }
58923
+ const requestOptions = {
58924
+ signal: abortContext.signal,
58925
+ headers: {
58926
+ ...customHeaders,
58927
+ ...this.#identityHeaders()
58928
+ }
58929
+ };
58930
+ if (scopedParams) {
58931
+ requestOptions.params = scopedParams;
58904
58932
  }
58905
- };
58906
- if (scopedParams) {
58907
- requestOptions.params = scopedParams;
58908
- }
58909
- if (body !== void 0) {
58910
- requestOptions.body = body;
58911
- }
58912
- let response;
58913
- switch (method) {
58914
- case "GET":
58915
- response = await this.#client.GET(path3, requestOptions);
58916
- break;
58917
- case "POST":
58918
- response = await this.#client.POST(path3, requestOptions);
58919
- break;
58920
- case "PUT":
58921
- response = await this.#client.PUT(path3, requestOptions);
58922
- break;
58923
- case "DELETE":
58924
- response = await this.#client.DELETE(path3, requestOptions);
58925
- break;
58926
- case "PATCH":
58927
- response = await this.#client.PATCH(path3, requestOptions);
58928
- break;
58929
- default:
58930
- throw new ValidationError(`Unsupported HTTP method: ${method}`);
58931
- }
58932
- abortContext.clear();
58933
- if (this.#config.verbose) {
58934
- this.#log("debug", `\u2190 ${response.response?.status} ${method} ${path3}`, {
58935
- status: response.response?.status,
58936
- statusText: response.response?.statusText
58937
- });
58938
- }
58939
- if (response.error) {
58940
- this.#config.onRequestError(requestData, response.response, response.error);
58941
- await this.#handleOpenApiError(response.error, response.response, requestOrigin);
58942
- }
58943
- const result = response.data;
58944
- this.#config.onAfterRequest(requestData);
58945
- return result;
58946
- } catch (error3) {
58947
- abortContext.clear();
58948
- if (error3 instanceof SyntaxError) {
58949
- throw new UnexpectedResponseError(
58950
- formatUnexpectedResponseMessage(error3, method, requestUrl),
58951
- error3,
58952
- requestOrigin
58953
- );
58933
+ if (body !== void 0) {
58934
+ requestOptions.body = body;
58935
+ }
58936
+ let response;
58937
+ switch (method) {
58938
+ case "GET":
58939
+ response = await this.#client.GET(path3, requestOptions);
58940
+ break;
58941
+ case "POST":
58942
+ response = await this.#client.POST(path3, requestOptions);
58943
+ break;
58944
+ case "PUT":
58945
+ response = await this.#client.PUT(path3, requestOptions);
58946
+ break;
58947
+ case "DELETE":
58948
+ response = await this.#client.DELETE(path3, requestOptions);
58949
+ break;
58950
+ case "PATCH":
58951
+ response = await this.#client.PATCH(path3, requestOptions);
58952
+ break;
58953
+ default:
58954
+ throw new ValidationError(`Unsupported HTTP method: ${method}`);
58955
+ }
58956
+ abortContext.clear();
58957
+ if (this.#config.verbose) {
58958
+ this.#log("debug", `\u2190 ${response.response?.status} ${method} ${path3}`, {
58959
+ status: response.response?.status,
58960
+ statusText: response.response?.statusText
58961
+ });
58962
+ }
58963
+ if (response.error) {
58964
+ this.#config.onRequestError(requestData, response.response, response.error);
58965
+ await this.#handleOpenApiError(response.error, response.response, requestOrigin);
58966
+ }
58967
+ const result = response.data;
58968
+ this.#config.onAfterRequest(requestData);
58969
+ return result;
58970
+ } catch (error3) {
58971
+ abortContext.clear();
58972
+ if (error3 instanceof SyntaxError) {
58973
+ throw new UnexpectedResponseError(
58974
+ formatUnexpectedResponseMessage(error3, method, requestUrl),
58975
+ error3,
58976
+ requestOrigin
58977
+ );
58978
+ }
58979
+ throw this.#toTransportError(error3, requestOrigin, abortContext);
58954
58980
  }
58955
- throw this.#toTransportError(error3, requestOrigin, abortContext);
58956
- }
58957
- });
58981
+ },
58982
+ { retryServer429: this.#canRetryServer429(method) }
58983
+ );
58958
58984
  };
58959
58985
  /**
58960
58986
  * Handle OpenAPI fetch errors. Always reads the real `response.status` so
@@ -59262,46 +59288,59 @@ var BugBugApiClient = class {
59262
59288
  };
59263
59289
  const requestOrigin = { method, url };
59264
59290
  this.#config.onBeforeRequest(requestData);
59265
- return this.#rateLimiter.execute(async () => {
59266
- const abortContext = this.#createAbortContext(signal, timeout);
59267
- try {
59268
- if (this.#config.verbose) {
59269
- this.#log("debug", `\u2192 ${method} ${path3} (raw)`, { queryParams, pathParams });
59270
- }
59271
- const response = await fetch(url, {
59272
- method,
59273
- redirect,
59274
- headers: {
59275
- // Caller headers go first so the SDK's auth + identification
59276
- // headers always win — a stray `Authorization` in caller-supplied
59277
- // headers would otherwise silently replace the SDK token.
59278
- ...customHeaders,
59279
- ...authenticated ? this.#identityHeaders() : this.#requestHeaders(),
59280
- ...contentType ? { "Content-Type": contentType } : {}
59281
- },
59282
- ...body !== void 0 ? { body } : {},
59283
- signal: abortContext.signal
59284
- });
59285
- abortContext.clear();
59286
- if (this.#config.verbose) {
59287
- this.#log("debug", `\u2190 ${response.status} ${method} ${path3}`, {
59288
- status: response.status,
59289
- statusText: response.statusText
59291
+ return this.#rateLimiter.execute(
59292
+ async () => {
59293
+ const abortContext = this.#createAbortContext(signal, timeout);
59294
+ try {
59295
+ this.#throwIfAlreadyAborted(abortContext, requestOrigin);
59296
+ if (this.#config.verbose) {
59297
+ this.#log("debug", `\u2192 ${method} ${path3} (raw)`, { queryParams, pathParams });
59298
+ }
59299
+ const response = await fetch(url, {
59300
+ method,
59301
+ redirect,
59302
+ headers: {
59303
+ // Caller headers go first so the SDK's auth + identification
59304
+ // headers always win — a stray `Authorization` in caller-supplied
59305
+ // headers would otherwise silently replace the SDK token.
59306
+ ...customHeaders,
59307
+ ...authenticated ? this.#identityHeaders() : this.#requestHeaders(),
59308
+ ...contentType ? { "Content-Type": contentType } : {}
59309
+ },
59310
+ ...body !== void 0 ? { body } : {},
59311
+ signal: abortContext.signal
59290
59312
  });
59313
+ abortContext.clear();
59314
+ if (this.#config.verbose) {
59315
+ this.#log("debug", `\u2190 ${response.status} ${method} ${path3}`, {
59316
+ status: response.status,
59317
+ statusText: response.statusText
59318
+ });
59319
+ }
59320
+ if (!response.ok && !(acceptRedirect && response.status >= 300 && response.status < 400)) {
59321
+ const errorText = await response.text();
59322
+ this.#config.onRequestError(requestData, response, new Error(errorText));
59323
+ await this.#handleOpenApiError(errorText, response, requestOrigin);
59324
+ }
59325
+ const result = await readBody(response);
59326
+ this.#config.onAfterRequest(requestData);
59327
+ return result;
59328
+ } catch (error3) {
59329
+ abortContext.clear();
59330
+ throw this.#toTransportError(error3, requestOrigin, abortContext);
59291
59331
  }
59292
- if (!response.ok && !(acceptRedirect && response.status >= 300 && response.status < 400)) {
59293
- const errorText = await response.text();
59294
- this.#config.onRequestError(requestData, response, new Error(errorText));
59295
- await this.#handleOpenApiError(errorText, response, requestOrigin);
59296
- }
59297
- const result = await readBody(response);
59298
- this.#config.onAfterRequest(requestData);
59299
- return result;
59300
- } catch (error3) {
59301
- abortContext.clear();
59302
- throw this.#toTransportError(error3, requestOrigin, abortContext);
59303
- }
59304
- });
59332
+ },
59333
+ { retryServer429: this.#canRetryServer429(method) }
59334
+ );
59335
+ };
59336
+ #canRetryServer429 = (method) => method === "GET" && this.#config.rateLimit.retryServer429 !== false;
59337
+ #throwIfAlreadyAborted = (abortContext, requestOrigin) => {
59338
+ if (!abortContext.signal.aborted) return;
59339
+ throw this.#toTransportError(
59340
+ new DOMException("The operation was aborted.", "AbortError"),
59341
+ requestOrigin,
59342
+ abortContext
59343
+ );
59305
59344
  };
59306
59345
  #createAbortContext = (signal, timeout) => {
59307
59346
  const controller = new AbortController();
@@ -59366,9 +59405,12 @@ var BugBugApiClient = class {
59366
59405
  if (updates.apiToken || updates.apiUrl) {
59367
59406
  this.#client = this.#createApiClient();
59368
59407
  }
59369
- if (updates.rateLimit) {
59408
+ if (updates.rateLimiter) {
59409
+ this.#rateLimiter = updates.rateLimiter;
59410
+ } else if (updates.rateLimit) {
59370
59411
  this.#rateLimiter = new RateLimiter(this.#config.rateLimit);
59371
59412
  }
59413
+ this.#config.rateLimiter = this.#rateLimiter;
59372
59414
  };
59373
59415
  /**
59374
59416
  * Snapshot of the in-process rate-limiter state.
@@ -64916,5 +64958,5 @@ export {
64916
64958
  formatErrorMessage,
64917
64959
  showError
64918
64960
  };
64919
- //# sourceMappingURL=chunk-2ZIWRWZK.js.map
64920
- //# debugId=11f5fc11-595f-51d4-8e05-bca1f6eb53a0
64961
+ //# sourceMappingURL=chunk-RONAEYWS.js.map
64962
+ //# debugId=2c40ab42-03d3-514a-a95d-bd3f25f12c2c
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ import {
55
55
  waitForSuiteRun,
56
56
  waitForTestRun,
57
57
  writeReportXml
58
- } from "./chunk-2ZIWRWZK.js";
58
+ } from "./chunk-RONAEYWS.js";
59
59
  import "./chunk-XLIBEETK.js";
60
60
  import "./chunk-3PJ4ZE2N.js";
61
61
  import {
@@ -4235,7 +4235,7 @@ program2.exitOverride();
4235
4235
  });
4236
4236
  analytics.trackEvent("cli_session_started");
4237
4237
  if (startupMode.type === "commandline" && await shouldRedirectUnauthenticatedCommandToInit(process.argv, hasUsableSession)) {
4238
- const { startNavigator } = await import("./app-SJH7MMH6.js");
4238
+ const { startNavigator } = await import("./app-RFZH4MU7.js");
4239
4239
  await startNavigator({
4240
4240
  initialRoute: "/init",
4241
4241
  initialRouteState: {
@@ -4247,7 +4247,7 @@ program2.exitOverride();
4247
4247
  return;
4248
4248
  }
4249
4249
  if (startupMode.type === "navigator") {
4250
- const { startNavigator } = await import("./app-SJH7MMH6.js");
4250
+ const { startNavigator } = await import("./app-RFZH4MU7.js");
4251
4251
  await startNavigator({
4252
4252
  initialRoute: startupMode.route,
4253
4253
  token: config.token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugbug-io/cli",
3
- "version": "14.5.0",
3
+ "version": "14.6.0",
4
4
  "description": "BugBug CLI for test automation, CI workflows, and AI-agent plugin installation",
5
5
  "type": "module",
6
6
  "bin": {