@trigger.dev/core 0.0.0-v3-prerelease-20240703181409 → 0.0.0-v3-prerelease-20240708162325

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 (45) 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/index.d.mts +50 -38
  16. package/dist/v3/index.d.ts +50 -38
  17. package/dist/v3/index.js +466 -303
  18. package/dist/v3/index.js.map +1 -1
  19. package/dist/v3/index.mjs +463 -304
  20. package/dist/v3/index.mjs.map +1 -1
  21. package/dist/v3/otel/index.js +15 -5
  22. package/dist/v3/otel/index.js.map +1 -1
  23. package/dist/v3/otel/index.mjs +15 -5
  24. package/dist/v3/otel/index.mjs.map +1 -1
  25. package/dist/v3/prod/index.d.mts +3 -3
  26. package/dist/v3/prod/index.d.ts +3 -3
  27. package/dist/v3/schemas/index.d.mts +16 -4
  28. package/dist/v3/schemas/index.d.ts +16 -4
  29. package/dist/v3/schemas/index.js +3 -1
  30. package/dist/v3/schemas/index.js.map +1 -1
  31. package/dist/v3/schemas/index.mjs +3 -1
  32. package/dist/v3/schemas/index.mjs.map +1 -1
  33. package/dist/v3/workers/index.d.mts +7 -6
  34. package/dist/v3/workers/index.d.ts +7 -6
  35. package/dist/v3/workers/index.js +246 -96
  36. package/dist/v3/workers/index.js.map +1 -1
  37. package/dist/v3/workers/index.mjs +246 -96
  38. package/dist/v3/workers/index.mjs.map +1 -1
  39. package/dist/v3/zodfetch.d.mts +14 -2
  40. package/dist/v3/zodfetch.d.ts +14 -2
  41. package/dist/v3/zodfetch.js +244 -28
  42. package/dist/v3/zodfetch.js.map +1 -1
  43. package/dist/v3/zodfetch.mjs +242 -29
  44. package/dist/v3/zodfetch.mjs.map +1 -1
  45. package/package.json +1 -1
@@ -1,12 +1,13 @@
1
1
  import * as logsAPI from '@opentelemetry/api-logs';
2
2
  import { TracingSDK } from '../otel/index.mjs';
3
3
  export { TracingDiagnosticLogLevel, recordSpanException } from '../otel/index.mjs';
4
- import { b as TaskRunExecution, T as TaskRunExecutionResult } from '../../common-55Mqj8JP.mjs';
5
- import { B as BackgroundWorkerProperties } from '../../messages-nXkzt5CT.mjs';
6
- import { C as Config, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../schemas-CeAee_C2.mjs';
7
- import { T as TriggerTracer, P as ProjectConfig, H as HandleErrorFunction, a as TaskMetadataWithFunctions, U as UsageMeasurement, C as Clock, b as ClockTime, c as TaskCatalog, d as UsageManager, e as UsageSample } from '../../catalog-Y0mRLMtJ.mjs';
8
- export { O as OtelTaskLogger, l as logLevels, u as usage } from '../../catalog-Y0mRLMtJ.mjs';
9
- export { R as RuntimeManager } from '../../manager-2AqSY67c.mjs';
4
+ import { b as TaskRunExecution, T as TaskRunExecutionResult } from '../../common-fIyU5pmz.mjs';
5
+ import { B as BackgroundWorkerProperties } from '../../messages-Sggr4tid.mjs';
6
+ import { C as Config, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../schemas-Zy7mGFgD.mjs';
7
+ import { P as ProjectConfig, H as HandleErrorFunction, T as TaskMetadataWithFunctions, U as UsageMeasurement, C as Clock, a as ClockTime, b as TaskCatalog, c as UsageManager, d as UsageSample } from '../../catalog-N-X0Te3W.mjs';
8
+ export { O as OtelTaskLogger, l as logLevels, u as usage } from '../../catalog-N-X0Te3W.mjs';
9
+ import { T as TriggerTracer } from '../../tracer-N0p2Fuuv.mjs';
10
+ export { R as RuntimeManager } from '../../manager-X_HrWQ7_.mjs';
10
11
  import { PreciseDate } from '@google-cloud/precise-date';
11
12
  import { LogRecordProcessor, LogRecord } from '@opentelemetry/sdk-logs';
12
13
  import { SpanProcessor, Span } from '@opentelemetry/sdk-trace-base';
@@ -1,12 +1,13 @@
1
1
  import * as logsAPI from '@opentelemetry/api-logs';
2
2
  import { TracingSDK } from '../otel/index.js';
3
3
  export { TracingDiagnosticLogLevel, recordSpanException } from '../otel/index.js';
4
- import { b as TaskRunExecution, T as TaskRunExecutionResult } from '../../common-55Mqj8JP.js';
5
- import { B as BackgroundWorkerProperties } from '../../messages-nXkzt5CT.js';
6
- import { C as Config, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../schemas-CeAee_C2.js';
7
- import { T as TriggerTracer, P as ProjectConfig, H as HandleErrorFunction, a as TaskMetadataWithFunctions, U as UsageMeasurement, C as Clock, b as ClockTime, c as TaskCatalog, d as UsageManager, e as UsageSample } from '../../catalog-9G8AqnI9.js';
8
- export { O as OtelTaskLogger, l as logLevels, u as usage } from '../../catalog-9G8AqnI9.js';
9
- export { R as RuntimeManager } from '../../manager-6NRInm7C.js';
4
+ import { b as TaskRunExecution, T as TaskRunExecutionResult } from '../../common-fIyU5pmz.js';
5
+ import { B as BackgroundWorkerProperties } from '../../messages-Sggr4tid.js';
6
+ import { C as Config, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../schemas-Zy7mGFgD.js';
7
+ import { P as ProjectConfig, H as HandleErrorFunction, T as TaskMetadataWithFunctions, U as UsageMeasurement, C as Clock, a as ClockTime, b as TaskCatalog, c as UsageManager, d as UsageSample } from '../../catalog-NxVZnWZh.js';
8
+ export { O as OtelTaskLogger, l as logLevels, u as usage } from '../../catalog-NxVZnWZh.js';
9
+ import { T as TriggerTracer } from '../../tracer-N0p2Fuuv.js';
10
+ export { R as RuntimeManager } from '../../manager-2ZQ3_twq.js';
10
11
  import { PreciseDate } from '@google-cloud/precise-date';
11
12
  import { LogRecordProcessor, LogRecord } from '@opentelemetry/sdk-logs';
12
13
  import { SpanProcessor, Span } from '@opentelemetry/sdk-trace-base';
@@ -76,6 +76,39 @@ var SerializedError = zod.z.object({
76
76
  name: zod.z.string().optional(),
77
77
  stackTrace: zod.z.string().optional()
78
78
  });
79
+ function sanitizeError(error) {
80
+ switch (error.type) {
81
+ case "BUILT_IN_ERROR": {
82
+ return {
83
+ type: "BUILT_IN_ERROR",
84
+ message: error.message?.replace(/\0/g, ""),
85
+ name: error.name?.replace(/\0/g, ""),
86
+ stackTrace: error.stackTrace?.replace(/\0/g, "")
87
+ };
88
+ }
89
+ case "STRING_ERROR": {
90
+ return {
91
+ type: "STRING_ERROR",
92
+ raw: error.raw.replace(/\0/g, "")
93
+ };
94
+ }
95
+ case "CUSTOM_ERROR": {
96
+ return {
97
+ type: "CUSTOM_ERROR",
98
+ raw: error.raw.replace(/\0/g, "")
99
+ };
100
+ }
101
+ case "INTERNAL_ERROR": {
102
+ return {
103
+ type: "INTERNAL_ERROR",
104
+ code: error.code,
105
+ message: error.message?.replace(/\0/g, ""),
106
+ stackTrace: error.stackTrace?.replace(/\0/g, "")
107
+ };
108
+ }
109
+ }
110
+ }
111
+ __name(sanitizeError, "sanitizeError");
79
112
 
80
113
  // src/v3/limits.ts
81
114
  var OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 256;
@@ -138,7 +171,10 @@ var SemanticInternalAttributes = {
138
171
  LINK_TITLE: "$link.title",
139
172
  IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
140
173
  USAGE_DURATION_MS: "$usage.durationMs",
141
- USAGE_COST_IN_CENTS: "$usage.costInCents"
174
+ USAGE_COST_IN_CENTS: "$usage.costInCents",
175
+ RATE_LIMIT_LIMIT: "response.rateLimit.limit",
176
+ RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
177
+ RATE_LIMIT_RESET: "response.rateLimit.reset"
142
178
  };
143
179
 
144
180
  // src/v3/utils/flattenAttributes.ts
@@ -370,7 +406,7 @@ function getEnvVar(name) {
370
406
  __name(getEnvVar, "getEnvVar");
371
407
 
372
408
  // package.json
373
- var version = "0.0.0-v3-prerelease-20240703181409";
409
+ var version = "0.0.0-v3-prerelease-20240708162325";
374
410
 
375
411
  // src/v3/otel/tracingSDK.ts
376
412
  var _a;
@@ -511,17 +547,24 @@ __name(setLogLevel, "setLogLevel");
511
547
  // src/v3/otel/index.ts
512
548
  function recordSpanException(span, error) {
513
549
  if (error instanceof Error) {
514
- span.recordException(error);
550
+ span.recordException(sanitizeSpanError(error));
515
551
  } else if (typeof error === "string") {
516
- span.recordException(new Error(error));
552
+ span.recordException(error.replace(/\0/g, ""));
517
553
  } else {
518
- span.recordException(new Error(JSON.stringify(error)));
554
+ span.recordException(JSON.stringify(error).replace(/\0/g, ""));
519
555
  }
520
556
  span.setStatus({
521
557
  code: api.SpanStatusCode.ERROR
522
558
  });
523
559
  }
524
560
  __name(recordSpanException, "recordSpanException");
561
+ function sanitizeSpanError(error) {
562
+ const sanitizedError = new Error(error.message.replace(/\0/g, ""));
563
+ sanitizedError.name = error.name.replace(/\0/g, "");
564
+ sanitizedError.stack = error.stack?.replace(/\0/g, "");
565
+ return sanitizedError;
566
+ }
567
+ __name(sanitizeSpanError, "sanitizeSpanError");
525
568
  var MachineCpu = zod.z.union([
526
569
  zod.z.literal(0.25),
527
570
  zod.z.literal(0.5),
@@ -621,6 +664,7 @@ var TaskRun = zod.z.object({
621
664
  createdAt: zod.z.coerce.date(),
622
665
  startedAt: zod.z.coerce.date().default(() => /* @__PURE__ */ new Date()),
623
666
  idempotencyKey: zod.z.string().optional(),
667
+ maxAttempts: zod.z.number().optional(),
624
668
  durationMs: zod.z.number().default(0),
625
669
  costInCents: zod.z.number().default(0),
626
670
  baseCostInCents: zod.z.number().default(0)
@@ -988,7 +1032,8 @@ var TriggerTaskRequestBody = zod.z.object({
988
1032
  test: zod.z.boolean().optional(),
989
1033
  payloadType: zod.z.string().optional(),
990
1034
  delay: zod.z.string().or(zod.z.coerce.date()).optional(),
991
- ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional()
1035
+ ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional(),
1036
+ maxAttempts: zod.z.number().int().optional()
992
1037
  }).optional()
993
1038
  });
994
1039
  var TriggerTaskResponse = zod.z.object({
@@ -1318,10 +1363,34 @@ var EnvironmentVariable = zod.z.object({
1318
1363
  });
1319
1364
  var EnvironmentVariables = zod.z.array(EnvironmentVariable);
1320
1365
 
1366
+ // src/v3/utils/retries.ts
1367
+ var defaultRetryOptions = {
1368
+ maxAttempts: 3,
1369
+ factor: 2,
1370
+ minTimeoutInMs: 1e3,
1371
+ maxTimeoutInMs: 6e4,
1372
+ randomize: true
1373
+ };
1374
+ function calculateNextRetryDelay(options, attempt) {
1375
+ const opts = {
1376
+ ...defaultRetryOptions,
1377
+ ...options
1378
+ };
1379
+ if (attempt >= opts.maxAttempts) {
1380
+ return;
1381
+ }
1382
+ const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
1383
+ const random = randomize ? Math.random() + 1 : 1;
1384
+ const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
1385
+ return Math.round(timeout);
1386
+ }
1387
+ __name(calculateNextRetryDelay, "calculateNextRetryDelay");
1388
+
1321
1389
  // src/v3/apiClient/errors.ts
1322
1390
  var _ApiError = class _ApiError extends Error {
1323
1391
  constructor(status, error, message, headers) {
1324
1392
  super(`${_ApiError.makeMessage(status, error, message)}`);
1393
+ this.name = "TriggerApiError";
1325
1394
  this.status = status;
1326
1395
  this.headers = headers;
1327
1396
  const data = error;
@@ -1442,6 +1511,16 @@ var _RateLimitError = class _RateLimitError extends ApiError {
1442
1511
  super(...arguments);
1443
1512
  __publicField(this, "status", 429);
1444
1513
  }
1514
+ get millisecondsUntilReset() {
1515
+ const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
1516
+ if (typeof resetAtUnixEpochMs === "string") {
1517
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
1518
+ if (isNaN(resetAtUnixEpoch)) {
1519
+ return;
1520
+ }
1521
+ return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
1522
+ }
1523
+ }
1445
1524
  };
1446
1525
  __name(_RateLimitError, "RateLimitError");
1447
1526
  var RateLimitError = _RateLimitError;
@@ -1456,28 +1535,11 @@ function castToError(err) {
1456
1535
  }
1457
1536
  __name(castToError, "castToError");
1458
1537
 
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);
1538
+ // src/v3/utils/styleAttributes.ts
1539
+ function accessoryAttributes(accessory) {
1540
+ return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
1479
1541
  }
1480
- __name(calculateNextRetryDelay, "calculateNextRetryDelay");
1542
+ __name(accessoryAttributes, "accessoryAttributes");
1481
1543
 
1482
1544
  // src/v3/apiClient/pagination.ts
1483
1545
  var _CursorPage = class _CursorPage {
@@ -1637,16 +1699,43 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
1637
1699
  return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
1638
1700
  }
1639
1701
  __name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
1640
- async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1702
+ async function traceZodFetch(params, callback) {
1703
+ if (!params.options?.tracer) {
1704
+ return callback();
1705
+ }
1706
+ const url = new URL(params.url);
1707
+ const method = params.requestInit?.method ?? "GET";
1708
+ const name = params.options.name ?? `${method} ${url.pathname}`;
1709
+ return await params.options.tracer.startActiveSpan(name, async (span) => {
1710
+ return await callback(span);
1711
+ }, {
1712
+ attributes: {
1713
+ [SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
1714
+ ...params.options.attributes
1715
+ }
1716
+ });
1717
+ }
1718
+ __name(traceZodFetch, "traceZodFetch");
1719
+ async function _doZodFetch(schema, url, requestInit, options) {
1720
+ const $requestInit = await requestInit;
1721
+ return traceZodFetch({
1722
+ url,
1723
+ requestInit: $requestInit,
1724
+ options
1725
+ }, async (span) => {
1726
+ return await _doZodFetchWithRetries(schema, url, $requestInit, options);
1727
+ });
1728
+ }
1729
+ __name(_doZodFetch, "_doZodFetch");
1730
+ async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
1641
1731
  try {
1642
- const $requestInit = await requestInit;
1643
- const response = await fetch(url, requestInitWithCache($requestInit));
1732
+ const response = await fetch(url, requestInitWithCache(requestInit));
1644
1733
  const responseHeaders = createResponseHeaders(response.headers);
1645
1734
  if (!response.ok) {
1646
1735
  const retryResult = shouldRetry(response, attempt, options?.retry);
1647
1736
  if (retryResult.retry) {
1648
- await new Promise((resolve) => setTimeout(resolve, retryResult.delay));
1649
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
1737
+ await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
1738
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
1650
1739
  } else {
1651
1740
  const errText = await response.text().catch((e) => castToError2(e).message);
1652
1741
  const errJSON = safeJsonParse(errText);
@@ -1674,8 +1763,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1674
1763
  };
1675
1764
  const delay = calculateNextRetryDelay(retry, attempt);
1676
1765
  if (delay) {
1677
- await new Promise((resolve) => setTimeout(resolve, delay));
1678
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
1766
+ await waitForRetry(url, attempt + 1, delay, options, requestInit);
1767
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
1679
1768
  }
1680
1769
  }
1681
1770
  throw new ApiConnectionError({
@@ -1683,7 +1772,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1683
1772
  });
1684
1773
  }
1685
1774
  }
1686
- __name(_doZodFetch, "_doZodFetch");
1775
+ __name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
1687
1776
  function castToError2(err) {
1688
1777
  if (err instanceof Error)
1689
1778
  return err;
@@ -1720,8 +1809,25 @@ function shouldRetry(response, attempt, retryOptions) {
1720
1809
  return shouldRetryForOptions();
1721
1810
  if (response.status === 409)
1722
1811
  return shouldRetryForOptions();
1723
- if (response.status === 429)
1812
+ if (response.status === 429) {
1813
+ if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
1814
+ return {
1815
+ retry: false
1816
+ };
1817
+ }
1818
+ const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
1819
+ if (resetAtUnixEpochMs) {
1820
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
1821
+ const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
1822
+ if (delay > 0) {
1823
+ return {
1824
+ retry: true,
1825
+ delay
1826
+ };
1827
+ }
1828
+ }
1724
1829
  return shouldRetryForOptions();
1830
+ }
1725
1831
  if (response.status >= 500)
1726
1832
  return shouldRetryForOptions();
1727
1833
  return {
@@ -1884,9 +1990,32 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
1884
1990
  }, "#fetchPage");
1885
1991
  __name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
1886
1992
  var OffsetLimitPagePromise = _OffsetLimitPagePromise;
1993
+ async function waitForRetry(url, attempt, delay, options, requestInit, response) {
1994
+ if (options?.tracer) {
1995
+ const method = requestInit?.method ?? "GET";
1996
+ return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
1997
+ await new Promise((resolve) => setTimeout(resolve, delay));
1998
+ }, {
1999
+ attributes: {
2000
+ [SemanticInternalAttributes.STYLE_ICON]: "wait",
2001
+ ...accessoryAttributes({
2002
+ items: [
2003
+ {
2004
+ text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
2005
+ variant: "normal"
2006
+ }
2007
+ ],
2008
+ style: "codepath"
2009
+ })
2010
+ }
2011
+ });
2012
+ }
2013
+ await new Promise((resolve) => setTimeout(resolve, delay));
2014
+ }
2015
+ __name(waitForRetry, "waitForRetry");
1887
2016
 
1888
2017
  // src/v3/apiClient/index.ts
1889
- var zodFetchOptions = {
2018
+ var DEFAULT_ZOD_FETCH_OPTIONS = {
1890
2019
  retry: {
1891
2020
  maxAttempts: 3,
1892
2021
  minTimeoutInMs: 1e3,
@@ -1897,17 +2026,18 @@ var zodFetchOptions = {
1897
2026
  };
1898
2027
  var _getHeaders, getHeaders_fn;
1899
2028
  var _ApiClient = class _ApiClient {
1900
- constructor(baseUrl, accessToken) {
2029
+ constructor(baseUrl, accessToken, requestOptions = {}) {
1901
2030
  __privateAdd(this, _getHeaders);
1902
2031
  this.accessToken = accessToken;
1903
2032
  this.baseUrl = baseUrl.replace(/\/$/, "");
2033
+ this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
1904
2034
  }
1905
- async getRunResult(runId) {
2035
+ async getRunResult(runId, requestOptions) {
1906
2036
  try {
1907
2037
  return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
1908
2038
  method: "GET",
1909
2039
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1910
- }, zodFetchOptions);
2040
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1911
2041
  } catch (error) {
1912
2042
  if (error instanceof ApiError) {
1913
2043
  if (error.status === 404) {
@@ -1917,47 +2047,47 @@ var _ApiClient = class _ApiClient {
1917
2047
  throw error;
1918
2048
  }
1919
2049
  }
1920
- async getBatchResults(batchId) {
2050
+ async getBatchResults(batchId, requestOptions) {
1921
2051
  return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
1922
2052
  method: "GET",
1923
2053
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1924
- }, zodFetchOptions);
2054
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1925
2055
  }
1926
- triggerTask(taskId, body, options) {
2056
+ triggerTask(taskId, body, options, requestOptions) {
1927
2057
  const encodedTaskId = encodeURIComponent(taskId);
1928
2058
  return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
1929
2059
  method: "POST",
1930
2060
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
1931
2061
  body: JSON.stringify(body)
1932
- }, zodFetchOptions);
2062
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1933
2063
  }
1934
- batchTriggerTask(taskId, body, options) {
2064
+ batchTriggerTask(taskId, body, options, requestOptions) {
1935
2065
  const encodedTaskId = encodeURIComponent(taskId);
1936
2066
  return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
1937
2067
  method: "POST",
1938
2068
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
1939
2069
  body: JSON.stringify(body)
1940
- }, zodFetchOptions);
2070
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1941
2071
  }
1942
- createUploadPayloadUrl(filename) {
2072
+ createUploadPayloadUrl(filename, requestOptions) {
1943
2073
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
1944
2074
  method: "PUT",
1945
2075
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1946
- }, zodFetchOptions);
2076
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1947
2077
  }
1948
- getPayloadUrl(filename) {
2078
+ getPayloadUrl(filename, requestOptions) {
1949
2079
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
1950
2080
  method: "GET",
1951
2081
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1952
- }, zodFetchOptions);
2082
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1953
2083
  }
1954
- retrieveRun(runId) {
2084
+ retrieveRun(runId, requestOptions) {
1955
2085
  return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
1956
2086
  method: "GET",
1957
2087
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1958
- }, zodFetchOptions);
2088
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1959
2089
  }
1960
- listRuns(query) {
2090
+ listRuns(query, requestOptions) {
1961
2091
  const searchParams = createSearchQueryForListRuns(query);
1962
2092
  return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
1963
2093
  query: searchParams,
@@ -1967,9 +2097,9 @@ var _ApiClient = class _ApiClient {
1967
2097
  }, {
1968
2098
  method: "GET",
1969
2099
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1970
- }, zodFetchOptions);
2100
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1971
2101
  }
1972
- listProjectRuns(projectRef, query) {
2102
+ listProjectRuns(projectRef, query, requestOptions) {
1973
2103
  const searchParams = createSearchQueryForListRuns(query);
1974
2104
  if (query?.env) {
1975
2105
  searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
@@ -1982,35 +2112,35 @@ var _ApiClient = class _ApiClient {
1982
2112
  }, {
1983
2113
  method: "GET",
1984
2114
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1985
- }, zodFetchOptions);
2115
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1986
2116
  }
1987
- replayRun(runId) {
2117
+ replayRun(runId, requestOptions) {
1988
2118
  return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
1989
2119
  method: "POST",
1990
2120
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1991
- }, zodFetchOptions);
2121
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1992
2122
  }
1993
- cancelRun(runId) {
2123
+ cancelRun(runId, requestOptions) {
1994
2124
  return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
1995
2125
  method: "POST",
1996
2126
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1997
- }, zodFetchOptions);
2127
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1998
2128
  }
1999
- rescheduleRun(runId, body) {
2129
+ rescheduleRun(runId, body, requestOptions) {
2000
2130
  return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
2001
2131
  method: "POST",
2002
2132
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2003
2133
  body: JSON.stringify(body)
2004
- }, zodFetchOptions);
2134
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2005
2135
  }
2006
- createSchedule(options) {
2136
+ createSchedule(options, requestOptions) {
2007
2137
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
2008
2138
  method: "POST",
2009
2139
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2010
2140
  body: JSON.stringify(options)
2011
- });
2141
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2012
2142
  }
2013
- listSchedules(options) {
2143
+ listSchedules(options, requestOptions) {
2014
2144
  const searchParams = new URLSearchParams();
2015
2145
  if (options?.page) {
2016
2146
  searchParams.append("page", options.page.toString());
@@ -2024,77 +2154,77 @@ var _ApiClient = class _ApiClient {
2024
2154
  }, {
2025
2155
  method: "GET",
2026
2156
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2027
- });
2157
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2028
2158
  }
2029
- retrieveSchedule(scheduleId) {
2159
+ retrieveSchedule(scheduleId, requestOptions) {
2030
2160
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
2031
2161
  method: "GET",
2032
2162
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2033
- });
2163
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2034
2164
  }
2035
- updateSchedule(scheduleId, options) {
2165
+ updateSchedule(scheduleId, options, requestOptions) {
2036
2166
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
2037
2167
  method: "PUT",
2038
2168
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2039
2169
  body: JSON.stringify(options)
2040
- });
2170
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2041
2171
  }
2042
- deactivateSchedule(scheduleId) {
2172
+ deactivateSchedule(scheduleId, requestOptions) {
2043
2173
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
2044
2174
  method: "POST",
2045
2175
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2046
- });
2176
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2047
2177
  }
2048
- activateSchedule(scheduleId) {
2178
+ activateSchedule(scheduleId, requestOptions) {
2049
2179
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
2050
2180
  method: "POST",
2051
2181
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2052
- });
2182
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2053
2183
  }
2054
- deleteSchedule(scheduleId) {
2184
+ deleteSchedule(scheduleId, requestOptions) {
2055
2185
  return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
2056
2186
  method: "DELETE",
2057
2187
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2058
- });
2188
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2059
2189
  }
2060
- listEnvVars(projectRef, slug) {
2190
+ listEnvVars(projectRef, slug, requestOptions) {
2061
2191
  return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
2062
2192
  method: "GET",
2063
2193
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2064
- });
2194
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2065
2195
  }
2066
- importEnvVars(projectRef, slug, body) {
2196
+ importEnvVars(projectRef, slug, body, requestOptions) {
2067
2197
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
2068
2198
  method: "POST",
2069
2199
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2070
2200
  body: JSON.stringify(body)
2071
- });
2201
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2072
2202
  }
2073
- retrieveEnvVar(projectRef, slug, key) {
2203
+ retrieveEnvVar(projectRef, slug, key, requestOptions) {
2074
2204
  return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
2075
2205
  method: "GET",
2076
2206
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2077
- });
2207
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2078
2208
  }
2079
- createEnvVar(projectRef, slug, body) {
2209
+ createEnvVar(projectRef, slug, body, requestOptions) {
2080
2210
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
2081
2211
  method: "POST",
2082
2212
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2083
2213
  body: JSON.stringify(body)
2084
- });
2214
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2085
2215
  }
2086
- updateEnvVar(projectRef, slug, key, body) {
2216
+ updateEnvVar(projectRef, slug, key, body, requestOptions) {
2087
2217
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
2088
2218
  method: "PUT",
2089
2219
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2090
2220
  body: JSON.stringify(body)
2091
- });
2221
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2092
2222
  }
2093
- deleteEnvVar(projectRef, slug, key) {
2223
+ deleteEnvVar(projectRef, slug, key, requestOptions) {
2094
2224
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
2095
2225
  method: "DELETE",
2096
2226
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2097
- });
2227
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2098
2228
  }
2099
2229
  };
2100
2230
  _getHeaders = new WeakSet();
@@ -2149,6 +2279,20 @@ function createSearchQueryForListRuns(query) {
2149
2279
  return searchParams;
2150
2280
  }
2151
2281
  __name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
2282
+ function mergeRequestOptions(defaultOptions, options) {
2283
+ if (!options) {
2284
+ return defaultOptions;
2285
+ }
2286
+ return {
2287
+ ...defaultOptions,
2288
+ ...options,
2289
+ retry: {
2290
+ ...defaultOptions.retry,
2291
+ ...options.retry
2292
+ }
2293
+ };
2294
+ }
2295
+ __name(mergeRequestOptions, "mergeRequestOptions");
2152
2296
 
2153
2297
  // src/v3/apiClientManager/index.ts
2154
2298
  var API_NAME2 = "api-client";
@@ -2413,12 +2557,6 @@ async function loadSuperJSON() {
2413
2557
  }
2414
2558
  __name(loadSuperJSON, "loadSuperJSON");
2415
2559
 
2416
- // src/v3/utils/styleAttributes.ts
2417
- function accessoryAttributes(accessory) {
2418
- return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
2419
- }
2420
- __name(accessoryAttributes, "accessoryAttributes");
2421
-
2422
2560
  // src/v3/workers/taskExecutor.ts
2423
2561
  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
2562
  var _TaskExecutor = class _TaskExecutor {
@@ -2506,7 +2644,7 @@ var _TaskExecutor = class _TaskExecutor {
2506
2644
  return {
2507
2645
  id: execution.run.id,
2508
2646
  ok: false,
2509
- error: handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError),
2647
+ error: sanitizeError(handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError)),
2510
2648
  retry: handleErrorResult.status === "retry" ? handleErrorResult.retry : void 0,
2511
2649
  skippedRetrying: handleErrorResult.status === "skipped"
2512
2650
  };
@@ -2695,7 +2833,19 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payloa
2695
2833
  status: "noop"
2696
2834
  };
2697
2835
  }
2698
- const delay = calculateNextRetryDelay(retry, execution.attempt.number);
2836
+ if (error2 instanceof Error && error2.name === "AbortTaskRunError") {
2837
+ return {
2838
+ status: "skipped"
2839
+ };
2840
+ }
2841
+ if (execution.run.maxAttempts) {
2842
+ retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
2843
+ }
2844
+ let delay = calculateNextRetryDelay(retry, execution.attempt.number);
2845
+ if (delay && error2 instanceof Error && error2.name === "TriggerApiError" && error2.status === 429) {
2846
+ const rateLimitError = error2;
2847
+ delay = rateLimitError.millisecondsUntilReset;
2848
+ }
2699
2849
  if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
2700
2850
  return {
2701
2851
  status: "skipped"