@trigger.dev/core 0.0.0-v3-prerelease-20240703161020 → 0.0.0-v3-prerelease-20240705100038

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 (53) hide show
  1. package/dist/{catalog-9G8AqnI9.d.ts → catalog-N-X0Te3W.d.mts} +5 -23
  2. package/dist/{catalog-Y0mRLMtJ.d.mts → catalog-NxVZnWZh.d.ts} +5 -23
  3. package/dist/{common-55Mqj8JP.d.mts → common-fIyU5pmz.d.mts} +13 -0
  4. package/dist/{common-55Mqj8JP.d.ts → common-fIyU5pmz.d.ts} +13 -0
  5. package/dist/{manager-6NRInm7C.d.ts → manager-2ZQ3_twq.d.ts} +1 -1
  6. package/dist/{manager-2AqSY67c.d.mts → manager-X_HrWQ7_.d.mts} +1 -1
  7. package/dist/{messages-nXkzt5CT.d.mts → messages-Sggr4tid.d.mts} +162 -0
  8. package/dist/{messages-nXkzt5CT.d.ts → messages-Sggr4tid.d.ts} +162 -0
  9. package/dist/{schemas-CeAee_C2.d.mts → schemas-Zy7mGFgD.d.mts} +19 -0
  10. package/dist/{schemas-CeAee_C2.d.ts → schemas-Zy7mGFgD.d.ts} +19 -0
  11. package/dist/tracer-N0p2Fuuv.d.mts +23 -0
  12. package/dist/tracer-N0p2Fuuv.d.ts +23 -0
  13. package/dist/v3/dev/index.d.mts +2 -2
  14. package/dist/v3/dev/index.d.ts +2 -2
  15. package/dist/v3/dev/index.js.map +1 -1
  16. package/dist/v3/dev/index.mjs.map +1 -1
  17. package/dist/v3/index.d.mts +49 -38
  18. package/dist/v3/index.d.ts +49 -38
  19. package/dist/v3/index.js +432 -303
  20. package/dist/v3/index.js.map +1 -1
  21. package/dist/v3/index.mjs +430 -304
  22. package/dist/v3/index.mjs.map +1 -1
  23. package/dist/v3/otel/index.js +5 -2
  24. package/dist/v3/otel/index.js.map +1 -1
  25. package/dist/v3/otel/index.mjs +5 -2
  26. package/dist/v3/otel/index.mjs.map +1 -1
  27. package/dist/v3/prod/index.d.mts +3 -3
  28. package/dist/v3/prod/index.d.ts +3 -3
  29. package/dist/v3/schemas/index.d.mts +16 -4
  30. package/dist/v3/schemas/index.d.ts +16 -4
  31. package/dist/v3/schemas/index.js +3 -1
  32. package/dist/v3/schemas/index.js.map +1 -1
  33. package/dist/v3/schemas/index.mjs +3 -1
  34. package/dist/v3/schemas/index.mjs.map +1 -1
  35. package/dist/v3/utils/timers.d.mts +6 -0
  36. package/dist/v3/utils/timers.d.ts +6 -0
  37. package/dist/v3/utils/timers.js +31 -0
  38. package/dist/v3/utils/timers.js.map +1 -0
  39. package/dist/v3/utils/timers.mjs +28 -0
  40. package/dist/v3/utils/timers.mjs.map +1 -0
  41. package/dist/v3/workers/index.d.mts +7 -6
  42. package/dist/v3/workers/index.d.ts +7 -6
  43. package/dist/v3/workers/index.js +202 -92
  44. package/dist/v3/workers/index.js.map +1 -1
  45. package/dist/v3/workers/index.mjs +202 -92
  46. package/dist/v3/workers/index.mjs.map +1 -1
  47. package/dist/v3/zodfetch.d.mts +14 -2
  48. package/dist/v3/zodfetch.d.ts +14 -2
  49. package/dist/v3/zodfetch.js +244 -28
  50. package/dist/v3/zodfetch.js.map +1 -1
  51. package/dist/v3/zodfetch.mjs +242 -29
  52. package/dist/v3/zodfetch.mjs.map +1 -1
  53. package/package.json +9 -1
@@ -138,7 +138,10 @@ var SemanticInternalAttributes = {
138
138
  LINK_TITLE: "$link.title",
139
139
  IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
140
140
  USAGE_DURATION_MS: "$usage.durationMs",
141
- USAGE_COST_IN_CENTS: "$usage.costInCents"
141
+ USAGE_COST_IN_CENTS: "$usage.costInCents",
142
+ RATE_LIMIT_LIMIT: "response.rateLimit.limit",
143
+ RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
144
+ RATE_LIMIT_RESET: "response.rateLimit.reset"
142
145
  };
143
146
 
144
147
  // src/v3/utils/flattenAttributes.ts
@@ -370,7 +373,7 @@ function getEnvVar(name) {
370
373
  __name(getEnvVar, "getEnvVar");
371
374
 
372
375
  // package.json
373
- var version = "0.0.0-v3-prerelease-20240703161020";
376
+ var version = "0.0.0-v3-prerelease-20240705100038";
374
377
 
375
378
  // src/v3/otel/tracingSDK.ts
376
379
  var _a;
@@ -621,6 +624,7 @@ var TaskRun = zod.z.object({
621
624
  createdAt: zod.z.coerce.date(),
622
625
  startedAt: zod.z.coerce.date().default(() => /* @__PURE__ */ new Date()),
623
626
  idempotencyKey: zod.z.string().optional(),
627
+ maxAttempts: zod.z.number().optional(),
624
628
  durationMs: zod.z.number().default(0),
625
629
  costInCents: zod.z.number().default(0),
626
630
  baseCostInCents: zod.z.number().default(0)
@@ -988,7 +992,8 @@ var TriggerTaskRequestBody = zod.z.object({
988
992
  test: zod.z.boolean().optional(),
989
993
  payloadType: zod.z.string().optional(),
990
994
  delay: zod.z.string().or(zod.z.coerce.date()).optional(),
991
- ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional()
995
+ ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional(),
996
+ maxAttempts: zod.z.number().int().optional()
992
997
  }).optional()
993
998
  });
994
999
  var TriggerTaskResponse = zod.z.object({
@@ -1318,10 +1323,34 @@ var EnvironmentVariable = zod.z.object({
1318
1323
  });
1319
1324
  var EnvironmentVariables = zod.z.array(EnvironmentVariable);
1320
1325
 
1326
+ // src/v3/utils/retries.ts
1327
+ var defaultRetryOptions = {
1328
+ maxAttempts: 3,
1329
+ factor: 2,
1330
+ minTimeoutInMs: 1e3,
1331
+ maxTimeoutInMs: 6e4,
1332
+ randomize: true
1333
+ };
1334
+ function calculateNextRetryDelay(options, attempt) {
1335
+ const opts = {
1336
+ ...defaultRetryOptions,
1337
+ ...options
1338
+ };
1339
+ if (attempt >= opts.maxAttempts) {
1340
+ return;
1341
+ }
1342
+ const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
1343
+ const random = randomize ? Math.random() + 1 : 1;
1344
+ const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
1345
+ return Math.round(timeout);
1346
+ }
1347
+ __name(calculateNextRetryDelay, "calculateNextRetryDelay");
1348
+
1321
1349
  // src/v3/apiClient/errors.ts
1322
1350
  var _ApiError = class _ApiError extends Error {
1323
1351
  constructor(status, error, message, headers) {
1324
1352
  super(`${_ApiError.makeMessage(status, error, message)}`);
1353
+ this.name = "TriggerApiError";
1325
1354
  this.status = status;
1326
1355
  this.headers = headers;
1327
1356
  const data = error;
@@ -1442,6 +1471,16 @@ var _RateLimitError = class _RateLimitError extends ApiError {
1442
1471
  super(...arguments);
1443
1472
  __publicField(this, "status", 429);
1444
1473
  }
1474
+ get millisecondsUntilReset() {
1475
+ const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
1476
+ if (typeof resetAtUnixEpochMs === "string") {
1477
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
1478
+ if (isNaN(resetAtUnixEpoch)) {
1479
+ return;
1480
+ }
1481
+ return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
1482
+ }
1483
+ }
1445
1484
  };
1446
1485
  __name(_RateLimitError, "RateLimitError");
1447
1486
  var RateLimitError = _RateLimitError;
@@ -1456,28 +1495,11 @@ function castToError(err) {
1456
1495
  }
1457
1496
  __name(castToError, "castToError");
1458
1497
 
1459
- // src/v3/utils/retries.ts
1460
- var defaultRetryOptions = {
1461
- maxAttempts: 3,
1462
- factor: 2,
1463
- minTimeoutInMs: 1e3,
1464
- maxTimeoutInMs: 6e4,
1465
- randomize: true
1466
- };
1467
- function calculateNextRetryDelay(options, attempt) {
1468
- const opts = {
1469
- ...defaultRetryOptions,
1470
- ...options
1471
- };
1472
- if (attempt >= opts.maxAttempts) {
1473
- return;
1474
- }
1475
- const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
1476
- const random = randomize ? Math.random() + 1 : 1;
1477
- const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
1478
- return Math.round(timeout);
1498
+ // src/v3/utils/styleAttributes.ts
1499
+ function accessoryAttributes(accessory) {
1500
+ return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
1479
1501
  }
1480
- __name(calculateNextRetryDelay, "calculateNextRetryDelay");
1502
+ __name(accessoryAttributes, "accessoryAttributes");
1481
1503
 
1482
1504
  // src/v3/apiClient/pagination.ts
1483
1505
  var _CursorPage = class _CursorPage {
@@ -1637,16 +1659,43 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
1637
1659
  return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
1638
1660
  }
1639
1661
  __name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
1640
- async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1662
+ async function traceZodFetch(params, callback) {
1663
+ if (!params.options?.tracer) {
1664
+ return callback();
1665
+ }
1666
+ const url = new URL(params.url);
1667
+ const method = params.requestInit?.method ?? "GET";
1668
+ const name = params.options.name ?? `${method} ${url.pathname}`;
1669
+ return await params.options.tracer.startActiveSpan(name, async (span) => {
1670
+ return await callback(span);
1671
+ }, {
1672
+ attributes: {
1673
+ [SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
1674
+ ...params.options.attributes
1675
+ }
1676
+ });
1677
+ }
1678
+ __name(traceZodFetch, "traceZodFetch");
1679
+ async function _doZodFetch(schema, url, requestInit, options) {
1680
+ const $requestInit = await requestInit;
1681
+ return traceZodFetch({
1682
+ url,
1683
+ requestInit: $requestInit,
1684
+ options
1685
+ }, async (span) => {
1686
+ return await _doZodFetchWithRetries(schema, url, $requestInit, options);
1687
+ });
1688
+ }
1689
+ __name(_doZodFetch, "_doZodFetch");
1690
+ async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
1641
1691
  try {
1642
- const $requestInit = await requestInit;
1643
- const response = await fetch(url, requestInitWithCache($requestInit));
1692
+ const response = await fetch(url, requestInitWithCache(requestInit));
1644
1693
  const responseHeaders = createResponseHeaders(response.headers);
1645
1694
  if (!response.ok) {
1646
1695
  const retryResult = shouldRetry(response, attempt, options?.retry);
1647
1696
  if (retryResult.retry) {
1648
- await new Promise((resolve) => setTimeout(resolve, retryResult.delay));
1649
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
1697
+ await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
1698
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
1650
1699
  } else {
1651
1700
  const errText = await response.text().catch((e) => castToError2(e).message);
1652
1701
  const errJSON = safeJsonParse(errText);
@@ -1674,8 +1723,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1674
1723
  };
1675
1724
  const delay = calculateNextRetryDelay(retry, attempt);
1676
1725
  if (delay) {
1677
- await new Promise((resolve) => setTimeout(resolve, delay));
1678
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
1726
+ await waitForRetry(url, attempt + 1, delay, options, requestInit);
1727
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
1679
1728
  }
1680
1729
  }
1681
1730
  throw new ApiConnectionError({
@@ -1683,7 +1732,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1683
1732
  });
1684
1733
  }
1685
1734
  }
1686
- __name(_doZodFetch, "_doZodFetch");
1735
+ __name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
1687
1736
  function castToError2(err) {
1688
1737
  if (err instanceof Error)
1689
1738
  return err;
@@ -1720,8 +1769,25 @@ function shouldRetry(response, attempt, retryOptions) {
1720
1769
  return shouldRetryForOptions();
1721
1770
  if (response.status === 409)
1722
1771
  return shouldRetryForOptions();
1723
- if (response.status === 429)
1772
+ if (response.status === 429) {
1773
+ if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
1774
+ return {
1775
+ retry: false
1776
+ };
1777
+ }
1778
+ const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
1779
+ if (resetAtUnixEpochMs) {
1780
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
1781
+ const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
1782
+ if (delay > 0) {
1783
+ return {
1784
+ retry: true,
1785
+ delay
1786
+ };
1787
+ }
1788
+ }
1724
1789
  return shouldRetryForOptions();
1790
+ }
1725
1791
  if (response.status >= 500)
1726
1792
  return shouldRetryForOptions();
1727
1793
  return {
@@ -1884,9 +1950,32 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
1884
1950
  }, "#fetchPage");
1885
1951
  __name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
1886
1952
  var OffsetLimitPagePromise = _OffsetLimitPagePromise;
1953
+ async function waitForRetry(url, attempt, delay, options, requestInit, response) {
1954
+ if (options?.tracer) {
1955
+ const method = requestInit?.method ?? "GET";
1956
+ return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
1957
+ await new Promise((resolve) => setTimeout(resolve, delay));
1958
+ }, {
1959
+ attributes: {
1960
+ [SemanticInternalAttributes.STYLE_ICON]: "wait",
1961
+ ...accessoryAttributes({
1962
+ items: [
1963
+ {
1964
+ text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
1965
+ variant: "normal"
1966
+ }
1967
+ ],
1968
+ style: "codepath"
1969
+ })
1970
+ }
1971
+ });
1972
+ }
1973
+ await new Promise((resolve) => setTimeout(resolve, delay));
1974
+ }
1975
+ __name(waitForRetry, "waitForRetry");
1887
1976
 
1888
1977
  // src/v3/apiClient/index.ts
1889
- var zodFetchOptions = {
1978
+ var DEFAULT_ZOD_FETCH_OPTIONS = {
1890
1979
  retry: {
1891
1980
  maxAttempts: 3,
1892
1981
  minTimeoutInMs: 1e3,
@@ -1897,17 +1986,18 @@ var zodFetchOptions = {
1897
1986
  };
1898
1987
  var _getHeaders, getHeaders_fn;
1899
1988
  var _ApiClient = class _ApiClient {
1900
- constructor(baseUrl, accessToken) {
1989
+ constructor(baseUrl, accessToken, requestOptions = {}) {
1901
1990
  __privateAdd(this, _getHeaders);
1902
1991
  this.accessToken = accessToken;
1903
1992
  this.baseUrl = baseUrl.replace(/\/$/, "");
1993
+ this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
1904
1994
  }
1905
- async getRunResult(runId) {
1995
+ async getRunResult(runId, requestOptions) {
1906
1996
  try {
1907
1997
  return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
1908
1998
  method: "GET",
1909
1999
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1910
- }, zodFetchOptions);
2000
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1911
2001
  } catch (error) {
1912
2002
  if (error instanceof ApiError) {
1913
2003
  if (error.status === 404) {
@@ -1917,47 +2007,47 @@ var _ApiClient = class _ApiClient {
1917
2007
  throw error;
1918
2008
  }
1919
2009
  }
1920
- async getBatchResults(batchId) {
2010
+ async getBatchResults(batchId, requestOptions) {
1921
2011
  return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
1922
2012
  method: "GET",
1923
2013
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1924
- }, zodFetchOptions);
2014
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1925
2015
  }
1926
- triggerTask(taskId, body, options) {
2016
+ triggerTask(taskId, body, options, requestOptions) {
1927
2017
  const encodedTaskId = encodeURIComponent(taskId);
1928
2018
  return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
1929
2019
  method: "POST",
1930
2020
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
1931
2021
  body: JSON.stringify(body)
1932
- }, zodFetchOptions);
2022
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1933
2023
  }
1934
- batchTriggerTask(taskId, body, options) {
2024
+ batchTriggerTask(taskId, body, options, requestOptions) {
1935
2025
  const encodedTaskId = encodeURIComponent(taskId);
1936
2026
  return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
1937
2027
  method: "POST",
1938
2028
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
1939
2029
  body: JSON.stringify(body)
1940
- }, zodFetchOptions);
2030
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1941
2031
  }
1942
- createUploadPayloadUrl(filename) {
2032
+ createUploadPayloadUrl(filename, requestOptions) {
1943
2033
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
1944
2034
  method: "PUT",
1945
2035
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1946
- }, zodFetchOptions);
2036
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1947
2037
  }
1948
- getPayloadUrl(filename) {
2038
+ getPayloadUrl(filename, requestOptions) {
1949
2039
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
1950
2040
  method: "GET",
1951
2041
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1952
- }, zodFetchOptions);
2042
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1953
2043
  }
1954
- retrieveRun(runId) {
2044
+ retrieveRun(runId, requestOptions) {
1955
2045
  return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
1956
2046
  method: "GET",
1957
2047
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1958
- }, zodFetchOptions);
2048
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1959
2049
  }
1960
- listRuns(query) {
2050
+ listRuns(query, requestOptions) {
1961
2051
  const searchParams = createSearchQueryForListRuns(query);
1962
2052
  return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
1963
2053
  query: searchParams,
@@ -1967,9 +2057,9 @@ var _ApiClient = class _ApiClient {
1967
2057
  }, {
1968
2058
  method: "GET",
1969
2059
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1970
- }, zodFetchOptions);
2060
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1971
2061
  }
1972
- listProjectRuns(projectRef, query) {
2062
+ listProjectRuns(projectRef, query, requestOptions) {
1973
2063
  const searchParams = createSearchQueryForListRuns(query);
1974
2064
  if (query?.env) {
1975
2065
  searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
@@ -1982,35 +2072,35 @@ var _ApiClient = class _ApiClient {
1982
2072
  }, {
1983
2073
  method: "GET",
1984
2074
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1985
- }, zodFetchOptions);
2075
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1986
2076
  }
1987
- replayRun(runId) {
2077
+ replayRun(runId, requestOptions) {
1988
2078
  return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
1989
2079
  method: "POST",
1990
2080
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1991
- }, zodFetchOptions);
2081
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1992
2082
  }
1993
- cancelRun(runId) {
2083
+ cancelRun(runId, requestOptions) {
1994
2084
  return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
1995
2085
  method: "POST",
1996
2086
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1997
- }, zodFetchOptions);
2087
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1998
2088
  }
1999
- rescheduleRun(runId, body) {
2089
+ rescheduleRun(runId, body, requestOptions) {
2000
2090
  return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
2001
2091
  method: "POST",
2002
2092
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2003
2093
  body: JSON.stringify(body)
2004
- }, zodFetchOptions);
2094
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2005
2095
  }
2006
- createSchedule(options) {
2096
+ createSchedule(options, requestOptions) {
2007
2097
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
2008
2098
  method: "POST",
2009
2099
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2010
2100
  body: JSON.stringify(options)
2011
- });
2101
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2012
2102
  }
2013
- listSchedules(options) {
2103
+ listSchedules(options, requestOptions) {
2014
2104
  const searchParams = new URLSearchParams();
2015
2105
  if (options?.page) {
2016
2106
  searchParams.append("page", options.page.toString());
@@ -2024,77 +2114,77 @@ var _ApiClient = class _ApiClient {
2024
2114
  }, {
2025
2115
  method: "GET",
2026
2116
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2027
- });
2117
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2028
2118
  }
2029
- retrieveSchedule(scheduleId) {
2119
+ retrieveSchedule(scheduleId, requestOptions) {
2030
2120
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
2031
2121
  method: "GET",
2032
2122
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2033
- });
2123
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2034
2124
  }
2035
- updateSchedule(scheduleId, options) {
2125
+ updateSchedule(scheduleId, options, requestOptions) {
2036
2126
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
2037
2127
  method: "PUT",
2038
2128
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2039
2129
  body: JSON.stringify(options)
2040
- });
2130
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2041
2131
  }
2042
- deactivateSchedule(scheduleId) {
2132
+ deactivateSchedule(scheduleId, requestOptions) {
2043
2133
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
2044
2134
  method: "POST",
2045
2135
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2046
- });
2136
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2047
2137
  }
2048
- activateSchedule(scheduleId) {
2138
+ activateSchedule(scheduleId, requestOptions) {
2049
2139
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
2050
2140
  method: "POST",
2051
2141
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2052
- });
2142
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2053
2143
  }
2054
- deleteSchedule(scheduleId) {
2144
+ deleteSchedule(scheduleId, requestOptions) {
2055
2145
  return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
2056
2146
  method: "DELETE",
2057
2147
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2058
- });
2148
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2059
2149
  }
2060
- listEnvVars(projectRef, slug) {
2150
+ listEnvVars(projectRef, slug, requestOptions) {
2061
2151
  return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
2062
2152
  method: "GET",
2063
2153
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2064
- });
2154
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2065
2155
  }
2066
- importEnvVars(projectRef, slug, body) {
2156
+ importEnvVars(projectRef, slug, body, requestOptions) {
2067
2157
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
2068
2158
  method: "POST",
2069
2159
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2070
2160
  body: JSON.stringify(body)
2071
- });
2161
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2072
2162
  }
2073
- retrieveEnvVar(projectRef, slug, key) {
2163
+ retrieveEnvVar(projectRef, slug, key, requestOptions) {
2074
2164
  return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
2075
2165
  method: "GET",
2076
2166
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2077
- });
2167
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2078
2168
  }
2079
- createEnvVar(projectRef, slug, body) {
2169
+ createEnvVar(projectRef, slug, body, requestOptions) {
2080
2170
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
2081
2171
  method: "POST",
2082
2172
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2083
2173
  body: JSON.stringify(body)
2084
- });
2174
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2085
2175
  }
2086
- updateEnvVar(projectRef, slug, key, body) {
2176
+ updateEnvVar(projectRef, slug, key, body, requestOptions) {
2087
2177
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
2088
2178
  method: "PUT",
2089
2179
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2090
2180
  body: JSON.stringify(body)
2091
- });
2181
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2092
2182
  }
2093
- deleteEnvVar(projectRef, slug, key) {
2183
+ deleteEnvVar(projectRef, slug, key, requestOptions) {
2094
2184
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
2095
2185
  method: "DELETE",
2096
2186
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2097
- });
2187
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2098
2188
  }
2099
2189
  };
2100
2190
  _getHeaders = new WeakSet();
@@ -2149,6 +2239,20 @@ function createSearchQueryForListRuns(query) {
2149
2239
  return searchParams;
2150
2240
  }
2151
2241
  __name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
2242
+ function mergeRequestOptions(defaultOptions, options) {
2243
+ if (!options) {
2244
+ return defaultOptions;
2245
+ }
2246
+ return {
2247
+ ...defaultOptions,
2248
+ ...options,
2249
+ retry: {
2250
+ ...defaultOptions.retry,
2251
+ ...options.retry
2252
+ }
2253
+ };
2254
+ }
2255
+ __name(mergeRequestOptions, "mergeRequestOptions");
2152
2256
 
2153
2257
  // src/v3/apiClientManager/index.ts
2154
2258
  var API_NAME2 = "api-client";
@@ -2413,12 +2517,6 @@ async function loadSuperJSON() {
2413
2517
  }
2414
2518
  __name(loadSuperJSON, "loadSuperJSON");
2415
2519
 
2416
- // src/v3/utils/styleAttributes.ts
2417
- function accessoryAttributes(accessory) {
2418
- return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
2419
- }
2420
- __name(accessoryAttributes, "accessoryAttributes");
2421
-
2422
2520
  // src/v3/workers/taskExecutor.ts
2423
2521
  var _callRun, callRun_fn, _callInitFunctions, callInitFunctions_fn, _callConfigInit, callConfigInit_fn, _callOnSuccessFunctions, callOnSuccessFunctions_fn, _callOnSuccessFunction, callOnSuccessFunction_fn, _callOnFailureFunctions, callOnFailureFunctions_fn, _callOnFailureFunction, callOnFailureFunction_fn, _callOnStartFunctions, callOnStartFunctions_fn, _callOnStartFunction, callOnStartFunction_fn, _callTaskCleanup, callTaskCleanup_fn, _handleError, handleError_fn;
2424
2522
  var _TaskExecutor = class _TaskExecutor {
@@ -2695,7 +2793,19 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payloa
2695
2793
  status: "noop"
2696
2794
  };
2697
2795
  }
2698
- const delay = calculateNextRetryDelay(retry, execution.attempt.number);
2796
+ if (error2 instanceof Error && error2.name === "AbortTaskRunError") {
2797
+ return {
2798
+ status: "skipped"
2799
+ };
2800
+ }
2801
+ if (execution.run.maxAttempts) {
2802
+ retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
2803
+ }
2804
+ let delay = calculateNextRetryDelay(retry, execution.attempt.number);
2805
+ if (delay && error2 instanceof Error && error2.name === "TriggerApiError" && error2.status === 429) {
2806
+ const rateLimitError = error2;
2807
+ delay = rateLimitError.millisecondsUntilReset;
2808
+ }
2699
2809
  if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
2700
2810
  return {
2701
2811
  status: "skipped"