@trigger.dev/core 0.0.0-prerelease-20240603154820 → 0.0.0-prerelease-20240723165848

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 (187) hide show
  1. package/dist/api-Pl9fxB8v.d.mts +13879 -0
  2. package/dist/api-sNoooMbT.d.ts +13879 -0
  3. package/dist/{catalog-dRKTgwQ7.d.ts → catalog-H7yFiZ60.d.mts} +52 -52
  4. package/dist/{catalog-XTlJQaMn.d.mts → catalog-h79CG5Wy.d.ts} +52 -52
  5. package/dist/{manager-JkbddlcO.d.mts → common-CLW82lkt.d.mts} +280 -16
  6. package/dist/{manager-JkbddlcO.d.ts → common-CLW82lkt.d.ts} +280 -16
  7. package/dist/{eventFilterMatches-2kHImluE.d.mts → eventFilter-66NaBAMi.d.mts} +1 -3
  8. package/dist/{eventFilterMatches-2kHImluE.d.ts → eventFilter-66NaBAMi.d.ts} +1 -3
  9. package/dist/eventFilterMatches.d.mts +6 -0
  10. package/dist/eventFilterMatches.d.ts +6 -0
  11. package/dist/eventFilterMatches.js +165 -0
  12. package/dist/eventFilterMatches.js.map +1 -0
  13. package/dist/eventFilterMatches.mjs +163 -0
  14. package/dist/eventFilterMatches.mjs.map +1 -0
  15. package/dist/index.d.mts +14 -16716
  16. package/dist/index.d.ts +14 -16716
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +1 -1
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/json-DBPEJQRe.d.mts +16 -0
  22. package/dist/json-DBPEJQRe.d.ts +16 -0
  23. package/dist/manager-KvCabW1a.d.mts +18 -0
  24. package/dist/manager-OBA35PzR.d.ts +18 -0
  25. package/dist/{messages-6_-q72KG.d.mts → messages-JvHJ83wv.d.mts} +2978 -291
  26. package/dist/{messages-6_-q72KG.d.ts → messages-JvHJ83wv.d.ts} +2978 -291
  27. package/dist/replacements.d.mts +22 -0
  28. package/dist/replacements.d.ts +22 -0
  29. package/dist/replacements.js +33 -0
  30. package/dist/replacements.js.map +1 -0
  31. package/dist/replacements.mjs +28 -0
  32. package/dist/replacements.mjs.map +1 -0
  33. package/dist/requestFilter-HNZQEpQb.d.ts +180 -0
  34. package/dist/requestFilter-b5W2_1oP.d.mts +180 -0
  35. package/dist/requestFilterMatches.d.mts +13 -0
  36. package/dist/requestFilterMatches.d.ts +13 -0
  37. package/dist/requestFilterMatches.js +238 -0
  38. package/dist/requestFilterMatches.js.map +1 -0
  39. package/dist/requestFilterMatches.mjs +235 -0
  40. package/dist/requestFilterMatches.mjs.map +1 -0
  41. package/dist/retry.d.mts +10 -0
  42. package/dist/retry.d.ts +10 -0
  43. package/dist/retry.js +100 -0
  44. package/dist/retry.js.map +1 -0
  45. package/dist/retry.mjs +97 -0
  46. package/dist/retry.mjs.map +1 -0
  47. package/dist/schemas/index.d.mts +2611 -0
  48. package/dist/schemas/index.d.ts +2611 -0
  49. package/dist/schemas/index.js +1630 -0
  50. package/dist/schemas/index.js.map +1 -0
  51. package/dist/schemas/index.mjs +1463 -0
  52. package/dist/schemas/index.mjs.map +1 -0
  53. package/dist/{schemas-r4ZP9S-F.d.mts → schemas-C9ssfehv.d.mts} +270 -33
  54. package/dist/{schemas-r4ZP9S-F.d.ts → schemas-C9ssfehv.d.ts} +270 -33
  55. package/dist/taskLogger-CzADe4je.d.ts +33 -0
  56. package/dist/taskLogger-r_AFTX45.d.mts +33 -0
  57. package/dist/tracer-N0p2Fuuv.d.mts +23 -0
  58. package/dist/tracer-N0p2Fuuv.d.ts +23 -0
  59. package/dist/types.d.mts +11 -0
  60. package/dist/types.d.ts +11 -0
  61. package/dist/types.js +4 -0
  62. package/dist/types.js.map +1 -0
  63. package/dist/types.mjs +3 -0
  64. package/dist/types.mjs.map +1 -0
  65. package/dist/utils.d.mts +7 -0
  66. package/dist/utils.d.ts +7 -0
  67. package/dist/utils.js +33 -0
  68. package/dist/utils.js.map +1 -0
  69. package/dist/utils.mjs +30 -0
  70. package/dist/utils.mjs.map +1 -0
  71. package/dist/v3/dev/index.d.mts +2 -1
  72. package/dist/v3/dev/index.d.ts +2 -1
  73. package/dist/v3/dev/index.js.map +1 -1
  74. package/dist/v3/dev/index.mjs.map +1 -1
  75. package/dist/v3/errors.d.mts +39 -0
  76. package/dist/v3/errors.d.ts +39 -0
  77. package/dist/v3/errors.js +204 -0
  78. package/dist/v3/errors.js.map +1 -0
  79. package/dist/v3/errors.mjs +195 -0
  80. package/dist/v3/errors.mjs.map +1 -0
  81. package/dist/v3/index.d.mts +172 -4737
  82. package/dist/v3/index.d.ts +172 -4737
  83. package/dist/v3/index.js +871 -620
  84. package/dist/v3/index.js.map +1 -1
  85. package/dist/v3/index.mjs +856 -620
  86. package/dist/v3/index.mjs.map +1 -1
  87. package/dist/v3/logger-api.d.mts +24 -0
  88. package/dist/v3/logger-api.d.ts +24 -0
  89. package/dist/v3/logger-api.js +118 -0
  90. package/dist/v3/logger-api.js.map +1 -0
  91. package/dist/v3/logger-api.mjs +116 -0
  92. package/dist/v3/logger-api.mjs.map +1 -0
  93. package/dist/v3/otel/index.js +36 -12
  94. package/dist/v3/otel/index.js.map +1 -1
  95. package/dist/v3/otel/index.mjs +36 -12
  96. package/dist/v3/otel/index.mjs.map +1 -1
  97. package/dist/v3/prod/index.d.mts +4 -3
  98. package/dist/v3/prod/index.d.ts +4 -3
  99. package/dist/v3/prod/index.js +7 -131
  100. package/dist/v3/prod/index.js.map +1 -1
  101. package/dist/v3/prod/index.mjs +7 -131
  102. package/dist/v3/prod/index.mjs.map +1 -1
  103. package/dist/v3/schemas/index.d.mts +4807 -0
  104. package/dist/v3/schemas/index.d.ts +4807 -0
  105. package/dist/v3/schemas/index.js +2065 -0
  106. package/dist/v3/schemas/index.js.map +1 -0
  107. package/dist/v3/schemas/index.mjs +1924 -0
  108. package/dist/v3/schemas/index.mjs.map +1 -0
  109. package/dist/v3/semanticInternalAttributes.d.mts +56 -0
  110. package/dist/v3/semanticInternalAttributes.d.ts +56 -0
  111. package/dist/v3/semanticInternalAttributes.js +61 -0
  112. package/dist/v3/semanticInternalAttributes.js.map +1 -0
  113. package/dist/v3/semanticInternalAttributes.mjs +59 -0
  114. package/dist/v3/semanticInternalAttributes.mjs.map +1 -0
  115. package/dist/v3/utils/durations.d.mts +15 -0
  116. package/dist/v3/utils/durations.d.ts +15 -0
  117. package/dist/v3/utils/durations.js +93 -0
  118. package/dist/v3/utils/durations.js.map +1 -0
  119. package/dist/v3/utils/durations.mjs +82 -0
  120. package/dist/v3/utils/durations.mjs.map +1 -0
  121. package/dist/v3/utils/flattenAttributes.d.mts +8 -0
  122. package/dist/v3/utils/flattenAttributes.d.ts +8 -0
  123. package/dist/v3/utils/flattenAttributes.js +131 -0
  124. package/dist/v3/utils/flattenAttributes.js.map +1 -0
  125. package/dist/v3/utils/flattenAttributes.mjs +126 -0
  126. package/dist/v3/utils/flattenAttributes.mjs.map +1 -0
  127. package/dist/v3/utils/ioSerialization.d.mts +21 -0
  128. package/dist/v3/utils/ioSerialization.d.ts +21 -0
  129. package/dist/v3/utils/ioSerialization.js +2403 -0
  130. package/dist/v3/utils/ioSerialization.js.map +1 -0
  131. package/dist/v3/utils/ioSerialization.mjs +2394 -0
  132. package/dist/v3/utils/ioSerialization.mjs.map +1 -0
  133. package/dist/v3/utils/omit.d.mts +3 -0
  134. package/dist/v3/utils/omit.d.ts +3 -0
  135. package/dist/v3/utils/omit.js +20 -0
  136. package/dist/v3/utils/omit.js.map +1 -0
  137. package/dist/v3/utils/omit.mjs +18 -0
  138. package/dist/v3/utils/omit.mjs.map +1 -0
  139. package/dist/v3/utils/retries.d.mts +46 -0
  140. package/dist/v3/utils/retries.d.ts +46 -0
  141. package/dist/v3/utils/retries.js +118 -0
  142. package/dist/v3/utils/retries.js.map +1 -0
  143. package/dist/v3/utils/retries.mjs +113 -0
  144. package/dist/v3/utils/retries.mjs.map +1 -0
  145. package/dist/v3/utils/timers.d.mts +6 -0
  146. package/dist/v3/utils/timers.d.ts +6 -0
  147. package/dist/v3/utils/timers.js +31 -0
  148. package/dist/v3/utils/timers.js.map +1 -0
  149. package/dist/v3/utils/timers.mjs +28 -0
  150. package/dist/v3/utils/timers.mjs.map +1 -0
  151. package/dist/v3/workers/index.d.mts +56 -8
  152. package/dist/v3/workers/index.d.ts +56 -8
  153. package/dist/v3/workers/index.js +755 -279
  154. package/dist/v3/workers/index.js.map +1 -1
  155. package/dist/v3/workers/index.mjs +753 -280
  156. package/dist/v3/workers/index.mjs.map +1 -1
  157. package/dist/v3/zodIpc.js.map +1 -1
  158. package/dist/v3/zodIpc.mjs.map +1 -1
  159. package/dist/v3/zodMessageHandler.d.mts +16 -3
  160. package/dist/v3/zodMessageHandler.d.ts +16 -3
  161. package/dist/v3/zodMessageHandler.js +77 -23
  162. package/dist/v3/zodMessageHandler.js.map +1 -1
  163. package/dist/v3/zodMessageHandler.mjs +77 -23
  164. package/dist/v3/zodMessageHandler.mjs.map +1 -1
  165. package/dist/v3/zodNamespace.js +59 -28
  166. package/dist/v3/zodNamespace.js.map +1 -1
  167. package/dist/v3/zodNamespace.mjs +60 -29
  168. package/dist/v3/zodNamespace.mjs.map +1 -1
  169. package/dist/v3/zodSocket.d.mts +8 -3
  170. package/dist/v3/zodSocket.d.ts +8 -3
  171. package/dist/v3/zodSocket.js +56 -25
  172. package/dist/v3/zodSocket.js.map +1 -1
  173. package/dist/v3/zodSocket.mjs +57 -26
  174. package/dist/v3/zodSocket.mjs.map +1 -1
  175. package/dist/v3/zodfetch.d.mts +15 -58
  176. package/dist/v3/zodfetch.d.ts +15 -58
  177. package/dist/v3/zodfetch.js +246 -156
  178. package/dist/v3/zodfetch.js.map +1 -1
  179. package/dist/v3/zodfetch.mjs +244 -149
  180. package/dist/v3/zodfetch.mjs.map +1 -1
  181. package/dist/versions.d.mts +11 -0
  182. package/dist/versions.d.ts +11 -0
  183. package/dist/versions.js +31 -0
  184. package/dist/versions.js.map +1 -0
  185. package/dist/versions.mjs +27 -0
  186. package/dist/versions.mjs.map +1 -0
  187. package/package.json +154 -10
package/dist/v3/index.mjs CHANGED
@@ -1,8 +1,6 @@
1
1
  import { propagation, context, trace, SpanStatusCode } from '@opentelemetry/api';
2
2
  import { z } from 'zod';
3
3
  import { fromZodError } from 'zod-validation-error';
4
- import { FormDataEncoder } from 'form-data-encoder';
5
- import { Readable } from 'node:stream';
6
4
  import { PreciseDate } from '@google-cloud/precise-date';
7
5
  import { logs } from '@opentelemetry/api-logs';
8
6
  import humanizeDuration from 'humanize-duration';
@@ -29,7 +27,7 @@ var __privateMethod = (obj, member, method) => {
29
27
  };
30
28
 
31
29
  // package.json
32
- var version = "0.0.0-prerelease-20240603154820";
30
+ var version = "0.0.0-prerelease-20240723165848";
33
31
  var dependencies = {
34
32
  "@google-cloud/precise-date": "^4.0.0",
35
33
  "@opentelemetry/api": "^1.8.0",
@@ -43,9 +41,8 @@ var dependencies = {
43
41
  "@opentelemetry/sdk-trace-base": "^1.22.0",
44
42
  "@opentelemetry/sdk-trace-node": "^1.22.0",
45
43
  "@opentelemetry/semantic-conventions": "^1.22.0",
46
- "form-data-encoder": "^4.0.2",
47
44
  "humanize-duration": "^3.27.3",
48
- "socket.io-client": "4.7.4",
45
+ "socket.io-client": "4.7.5",
49
46
  superjson: "^2.2.1",
50
47
  ulidx: "^2.2.1",
51
48
  zod: "3.22.3",
@@ -65,6 +62,41 @@ var GetPersonalAccessTokenResponseSchema = z.object({
65
62
  obfuscatedToken: z.string()
66
63
  }).nullable()
67
64
  });
65
+ var MachineCpu = z.union([
66
+ z.literal(0.25),
67
+ z.literal(0.5),
68
+ z.literal(1),
69
+ z.literal(2),
70
+ z.literal(4)
71
+ ]);
72
+ var MachineMemory = z.union([
73
+ z.literal(0.25),
74
+ z.literal(0.5),
75
+ z.literal(1),
76
+ z.literal(2),
77
+ z.literal(4),
78
+ z.literal(8)
79
+ ]);
80
+ var MachinePresetName = z.enum([
81
+ "micro",
82
+ "small-1x",
83
+ "small-2x",
84
+ "medium-1x",
85
+ "medium-2x",
86
+ "large-1x",
87
+ "large-2x"
88
+ ]);
89
+ var MachineConfig = z.object({
90
+ cpu: MachineCpu.optional(),
91
+ memory: MachineMemory.optional(),
92
+ preset: MachinePresetName.optional()
93
+ });
94
+ var MachinePreset = z.object({
95
+ name: MachinePresetName,
96
+ cpu: z.number(),
97
+ memory: z.number(),
98
+ centsPerMs: z.number()
99
+ });
68
100
  var TaskRunBuiltInError = z.object({
69
101
  type: z.literal("BUILT_IN_ERROR"),
70
102
  name: z.string(),
@@ -110,7 +142,8 @@ var TaskRunInternalError = z.object({
110
142
  "GRACEFUL_EXIT_TIMEOUT",
111
143
  "TASK_RUN_HEARTBEAT_TIMEOUT"
112
144
  ]),
113
- message: z.string().optional()
145
+ message: z.string().optional(),
146
+ stackTrace: z.string().optional()
114
147
  });
115
148
  var TaskRunError = z.discriminatedUnion("type", [
116
149
  TaskRunBuiltInError,
@@ -126,7 +159,12 @@ var TaskRun = z.object({
126
159
  tags: z.array(z.string()),
127
160
  isTest: z.boolean().default(false),
128
161
  createdAt: z.coerce.date(),
129
- idempotencyKey: z.string().optional()
162
+ startedAt: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
163
+ idempotencyKey: z.string().optional(),
164
+ maxAttempts: z.number().optional(),
165
+ durationMs: z.number().default(0),
166
+ costInCents: z.number().default(0),
167
+ baseCostInCents: z.number().default(0)
130
168
  });
131
169
  var TaskRunExecutionTask = z.object({
132
170
  id: z.string(),
@@ -177,7 +215,8 @@ var TaskRunExecution = z.object({
177
215
  environment: TaskRunExecutionEnvironment,
178
216
  organization: TaskRunExecutionOrganization,
179
217
  project: TaskRunExecutionProject,
180
- batch: TaskRunExecutionBatch.optional()
218
+ batch: TaskRunExecutionBatch.optional(),
219
+ machine: MachinePreset.optional()
181
220
  });
182
221
  var TaskRunContext = z.object({
183
222
  task: TaskRunExecutionTask,
@@ -193,25 +232,31 @@ var TaskRunContext = z.object({
193
232
  environment: TaskRunExecutionEnvironment,
194
233
  organization: TaskRunExecutionOrganization,
195
234
  project: TaskRunExecutionProject,
196
- batch: TaskRunExecutionBatch.optional()
235
+ batch: TaskRunExecutionBatch.optional(),
236
+ machine: MachinePreset.optional()
197
237
  });
198
238
  var TaskRunExecutionRetry = z.object({
199
239
  timestamp: z.number(),
200
240
  delay: z.number(),
201
241
  error: z.unknown().optional()
202
242
  });
243
+ var TaskRunExecutionUsage = z.object({
244
+ durationMs: z.number()
245
+ });
203
246
  var TaskRunFailedExecutionResult = z.object({
204
247
  ok: z.literal(false),
205
248
  id: z.string(),
206
249
  error: TaskRunError,
207
250
  retry: TaskRunExecutionRetry.optional(),
208
- skippedRetrying: z.boolean().optional()
251
+ skippedRetrying: z.boolean().optional(),
252
+ usage: TaskRunExecutionUsage.optional()
209
253
  });
210
254
  var TaskRunSuccessfulExecutionResult = z.object({
211
255
  ok: z.literal(true),
212
256
  id: z.string(),
213
257
  output: z.string().optional(),
214
- outputType: z.string()
258
+ outputType: z.string(),
259
+ usage: TaskRunExecutionUsage.optional()
215
260
  });
216
261
  var TaskRunExecutionResult = z.discriminatedUnion("ok", [
217
262
  TaskRunSuccessfulExecutionResult,
@@ -229,26 +274,6 @@ var EnvironmentType = z.enum([
229
274
  "DEVELOPMENT",
230
275
  "PREVIEW"
231
276
  ]);
232
- var MachineCpu = z.union([
233
- z.literal(0.25),
234
- z.literal(0.5),
235
- z.literal(1),
236
- z.literal(2),
237
- z.literal(4)
238
- ]).default(0.5);
239
- var MachineMemory = z.union([
240
- z.literal(0.25),
241
- z.literal(0.5),
242
- z.literal(1),
243
- z.literal(2),
244
- z.literal(4),
245
- z.literal(8)
246
- ]).default(1);
247
- var Machine = z.object({
248
- version: z.literal("v1").default("v1"),
249
- cpu: MachineCpu,
250
- memory: MachineMemory
251
- });
252
277
  var TaskRunExecutionPayload = z.object({
253
278
  execution: TaskRunExecution,
254
279
  traceContext: z.record(z.unknown()),
@@ -259,6 +284,12 @@ var ProdTaskRunExecution = TaskRunExecution.extend({
259
284
  id: z.string(),
260
285
  contentHash: z.string(),
261
286
  version: z.string()
287
+ }),
288
+ machine: MachinePreset.default({
289
+ name: "small-1x",
290
+ cpu: 1,
291
+ memory: 1,
292
+ centsPerMs: 0
262
293
  })
263
294
  });
264
295
  var ProdTaskRunExecutionPayload = z.object({
@@ -358,13 +389,18 @@ var QueueOptions = z.object({
358
389
  /** @deprecated This feature is coming soon */
359
390
  rateLimit: RateLimitOptions.optional()
360
391
  });
392
+ var ScheduleMetadata = z.object({
393
+ cron: z.string(),
394
+ timezone: z.string()
395
+ });
361
396
  var TaskMetadata = z.object({
362
397
  id: z.string(),
363
398
  packageVersion: z.string(),
364
399
  queue: QueueOptions.optional(),
365
400
  retry: RetryOptions.optional(),
366
- machine: Machine.partial().optional(),
367
- triggerSource: z.string().optional()
401
+ machine: MachineConfig.optional(),
402
+ triggerSource: z.string().optional(),
403
+ schedule: ScheduleMetadata.optional()
368
404
  });
369
405
  var TaskFileMetadata = z.object({
370
406
  filePath: z.string(),
@@ -375,8 +411,9 @@ var TaskMetadataWithFilePath = z.object({
375
411
  packageVersion: z.string(),
376
412
  queue: QueueOptions.optional(),
377
413
  retry: RetryOptions.optional(),
378
- machine: Machine.partial().optional(),
414
+ machine: MachineConfig.optional(),
379
415
  triggerSource: z.string().optional(),
416
+ schedule: ScheduleMetadata.optional(),
380
417
  filePath: z.string(),
381
418
  exportName: z.string()
382
419
  });
@@ -413,7 +450,8 @@ var Config = z.object({
413
450
  ])).optional(),
414
451
  logLevel: z.string().optional(),
415
452
  enableConsoleLogging: z.boolean().optional(),
416
- postInstall: z.string().optional()
453
+ postInstall: z.string().optional(),
454
+ extraCACerts: z.string().optional()
417
455
  });
418
456
  var WaitReason = z.enum([
419
457
  "WAIT_FOR_DURATION",
@@ -422,6 +460,7 @@ var WaitReason = z.enum([
422
460
  ]);
423
461
  var TaskRunExecutionLazyAttemptPayload = z.object({
424
462
  runId: z.string(),
463
+ attemptCount: z.number().optional(),
425
464
  messageId: z.string(),
426
465
  isTest: z.boolean(),
427
466
  traceContext: z.record(z.unknown()),
@@ -435,8 +474,9 @@ var TaskResource = z.object({
435
474
  exportName: z.string(),
436
475
  queue: QueueOptions.optional(),
437
476
  retry: RetryOptions.optional(),
438
- machine: Machine.partial().optional(),
439
- triggerSource: z.string().optional()
477
+ machine: MachineConfig.optional(),
478
+ triggerSource: z.string().optional(),
479
+ schedule: ScheduleMetadata.optional()
440
480
  });
441
481
  var BackgroundWorkerMetadata = z.object({
442
482
  packageVersion: z.string(),
@@ -448,6 +488,14 @@ var ImageDetailsMetadata = z.object({
448
488
  contentHash: z.string(),
449
489
  imageTag: z.string()
450
490
  });
491
+ var _AbortTaskRunError = class _AbortTaskRunError extends Error {
492
+ constructor(message) {
493
+ super(message);
494
+ this.name = "AbortTaskRunError";
495
+ }
496
+ };
497
+ __name(_AbortTaskRunError, "AbortTaskRunError");
498
+ var AbortTaskRunError = _AbortTaskRunError;
451
499
  function parseError(error) {
452
500
  if (error instanceof Error) {
453
501
  return {
@@ -528,6 +576,39 @@ function createJsonErrorObject(error) {
528
576
  }
529
577
  }
530
578
  __name(createJsonErrorObject, "createJsonErrorObject");
579
+ function sanitizeError(error) {
580
+ switch (error.type) {
581
+ case "BUILT_IN_ERROR": {
582
+ return {
583
+ type: "BUILT_IN_ERROR",
584
+ message: error.message?.replace(/\0/g, ""),
585
+ name: error.name?.replace(/\0/g, ""),
586
+ stackTrace: error.stackTrace?.replace(/\0/g, "")
587
+ };
588
+ }
589
+ case "STRING_ERROR": {
590
+ return {
591
+ type: "STRING_ERROR",
592
+ raw: error.raw.replace(/\0/g, "")
593
+ };
594
+ }
595
+ case "CUSTOM_ERROR": {
596
+ return {
597
+ type: "CUSTOM_ERROR",
598
+ raw: error.raw.replace(/\0/g, "")
599
+ };
600
+ }
601
+ case "INTERNAL_ERROR": {
602
+ return {
603
+ type: "INTERNAL_ERROR",
604
+ code: error.code,
605
+ message: error.message?.replace(/\0/g, ""),
606
+ stackTrace: error.stackTrace?.replace(/\0/g, "")
607
+ };
608
+ }
609
+ }
610
+ }
611
+ __name(sanitizeError, "sanitizeError");
531
612
  function correctErrorStackTrace(stackTrace, projectDir, options) {
532
613
  const [errorLine, ...traceLines] = stackTrace.split("\n");
533
614
  return [
@@ -630,6 +711,22 @@ var CreateBackgroundWorkerResponse = z.object({
630
711
  version: z.string(),
631
712
  contentHash: z.string()
632
713
  });
714
+ var RunTag = z.string().max(64, "Tags must be less than 64 characters");
715
+ var RunTags = z.union([
716
+ RunTag,
717
+ z.tuple([
718
+ RunTag
719
+ ]),
720
+ z.tuple([
721
+ RunTag,
722
+ RunTag
723
+ ]),
724
+ z.tuple([
725
+ RunTag,
726
+ RunTag,
727
+ RunTag
728
+ ])
729
+ ]);
633
730
  var TriggerTaskRequestBody = z.object({
634
731
  payload: z.any(),
635
732
  context: z.any(),
@@ -641,7 +738,11 @@ var TriggerTaskRequestBody = z.object({
641
738
  concurrencyKey: z.string().optional(),
642
739
  idempotencyKey: z.string().optional(),
643
740
  test: z.boolean().optional(),
644
- payloadType: z.string().optional()
741
+ payloadType: z.string().optional(),
742
+ delay: z.string().or(z.coerce.date()).optional(),
743
+ ttl: z.string().or(z.number().nonnegative().int()).optional(),
744
+ tags: RunTags.optional(),
745
+ maxAttempts: z.number().int().optional()
645
746
  }).optional()
646
747
  });
647
748
  var TriggerTaskResponse = z.object({
@@ -668,6 +769,12 @@ var GetBatchResponseBody = z.object({
668
769
  ])
669
770
  }))
670
771
  });
772
+ var AddTagsRequestBody = z.object({
773
+ tags: RunTags
774
+ });
775
+ var RescheduleRunRequestBody = z.object({
776
+ delay: z.string().or(z.coerce.date())
777
+ });
671
778
  var GetEnvironmentVariablesResponseBody = z.object({
672
779
  variables: z.record(z.string())
673
780
  });
@@ -700,7 +807,8 @@ var InitializeDeploymentRequestBody = z.object({
700
807
  var DeploymentErrorData = z.object({
701
808
  name: z.string(),
702
809
  message: z.string(),
703
- stack: z.string().optional()
810
+ stack: z.string().optional(),
811
+ stderr: z.string().optional()
704
812
  });
705
813
  var GetDeploymentResponseBody = z.object({
706
814
  id: z.string(),
@@ -738,20 +846,42 @@ var ReplayRunResponse = z.object({
738
846
  var CanceledRunResponse = z.object({
739
847
  id: z.string()
740
848
  });
849
+ var ScheduleType = z.union([
850
+ z.literal("DECLARATIVE"),
851
+ z.literal("IMPERATIVE")
852
+ ]);
741
853
  var ScheduledTaskPayload = z.object({
742
854
  /** The schedule id associated with this run (you can have many schedules for the same task).
743
855
  You can use this to remove the schedule, update it, etc */
744
856
  scheduleId: z.string(),
857
+ /** The type of schedule – `"DECLARATIVE"` or `"IMPERATIVE"`.
858
+ *
859
+ * **DECLARATIVE** – defined inline on your `schedules.task` using the `cron` property. They can only be created, updated or deleted by modifying the `cron` property on your task.
860
+ *
861
+ * **IMPERATIVE** – created using the `schedules.create` functions or in the dashboard.
862
+ */
863
+ type: ScheduleType,
745
864
  /** When the task was scheduled to run.
746
- * Note this will be slightly different from `new Date()` because it takes a few ms to run the task. */
865
+ * Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
866
+ *
867
+ * This date is UTC. To output it as a string with a timezone you would do this:
868
+ * ```ts
869
+ * const formatted = payload.timestamp.toLocaleString("en-US", {
870
+ timeZone: payload.timezone,
871
+ });
872
+ ``` */
747
873
  timestamp: z.date(),
748
874
  /** When the task was last run (it has been).
749
- This can be undefined if it's never been run */
875
+ This can be undefined if it's never been run. This date is UTC. */
750
876
  lastTimestamp: z.date().optional(),
751
877
  /** You can optionally provide an external id when creating the schedule.
752
878
  Usually you would use a userId or some other unique identifier.
753
879
  This defaults to undefined if you didn't provide one. */
754
880
  externalId: z.string().optional(),
881
+ /** The IANA timezone the schedule is set to. The default is UTC.
882
+ * You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
883
+ */
884
+ timezone: z.string(),
755
885
  /** The next 5 dates this task is scheduled to run */
756
886
  upcoming: z.array(z.date())
757
887
  });
@@ -775,17 +905,30 @@ var CreateScheduleOptions = z.object({
775
905
 
776
906
  */
777
907
  cron: z.string(),
778
- /** (Optional) You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
908
+ /** You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
779
909
  *
780
- * This is useful if you don't want to create duplicate schedules for a user. */
781
- deduplicationKey: z.string().optional(),
910
+ * This is required to prevent you from creating duplicate schedules. */
911
+ deduplicationKey: z.string(),
782
912
  /** Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
783
913
  *
784
914
  * This allows you to have per-user CRON tasks.
785
915
  */
786
- externalId: z.string().optional()
916
+ externalId: z.string().optional(),
917
+ /** Optionally, you can specify a timezone in the IANA format. If unset it will use UTC.
918
+ * If specified then the CRON will be evaluated in that timezone and will respect daylight savings.
919
+ *
920
+ * If you set the CRON to `0 0 * * *` and the timezone to `America/New_York` then the task will run at midnight in New York time, no matter whether it's daylight savings or not.
921
+ *
922
+ * You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
923
+ *
924
+ * @example "America/New_York", "Europe/London", "Asia/Tokyo", "Africa/Cairo"
925
+ *
926
+ */
927
+ timezone: z.string().optional()
928
+ });
929
+ var UpdateScheduleOptions = CreateScheduleOptions.omit({
930
+ deduplicationKey: true
787
931
  });
788
- var UpdateScheduleOptions = CreateScheduleOptions;
789
932
  var ScheduleGenerator = z.object({
790
933
  type: z.literal("CRON"),
791
934
  expression: z.string(),
@@ -793,11 +936,13 @@ var ScheduleGenerator = z.object({
793
936
  });
794
937
  var ScheduleObject = z.object({
795
938
  id: z.string(),
939
+ type: ScheduleType,
796
940
  task: z.string(),
797
941
  active: z.boolean(),
798
942
  deduplicationKey: z.string().nullish(),
799
943
  externalId: z.string().nullish(),
800
944
  generator: ScheduleGenerator,
945
+ timezone: z.string(),
801
946
  nextRun: z.coerce.date().nullish(),
802
947
  environments: z.array(z.object({
803
948
  id: z.string(),
@@ -820,6 +965,9 @@ var ListScheduleOptions = z.object({
820
965
  page: z.number().optional(),
821
966
  perPage: z.number().optional()
822
967
  });
968
+ var TimezonesResult = z.object({
969
+ timezones: z.array(z.string())
970
+ });
823
971
  var RunStatus = z.enum([
824
972
  /// Task hasn't been deployed yet but is waiting to be executed
825
973
  "WAITING_FOR_DEPLOY",
@@ -842,7 +990,11 @@ var RunStatus = z.enum([
842
990
  /// Task was interrupted during execution, mostly this happens in development environments
843
991
  "INTERRUPTED",
844
992
  /// Task has failed to complete, due to an error in the system
845
- "SYSTEM_FAILURE"
993
+ "SYSTEM_FAILURE",
994
+ /// Task has been scheduled to run at a specific time
995
+ "DELAYED",
996
+ /// Task has expired and won't be executed
997
+ "EXPIRED"
846
998
  ]);
847
999
  var AttemptStatus = z.enum([
848
1000
  "PENDING",
@@ -879,12 +1031,21 @@ var CommonRunFields = {
879
1031
  createdAt: z.coerce.date(),
880
1032
  updatedAt: z.coerce.date(),
881
1033
  startedAt: z.coerce.date().optional(),
882
- finishedAt: z.coerce.date().optional()
1034
+ finishedAt: z.coerce.date().optional(),
1035
+ delayedUntil: z.coerce.date().optional(),
1036
+ ttl: z.string().optional(),
1037
+ expiredAt: z.coerce.date().optional(),
1038
+ tags: z.string().array(),
1039
+ costInCents: z.number(),
1040
+ baseCostInCents: z.number(),
1041
+ durationMs: z.number()
883
1042
  };
884
1043
  var RetrieveRunResponse = z.object({
885
1044
  ...CommonRunFields,
886
1045
  payload: z.any().optional(),
1046
+ payloadPresignedUrl: z.string().optional(),
887
1047
  output: z.any().optional(),
1048
+ outputPresignedUrl: z.string().optional(),
888
1049
  schedule: RunScheduleDetails.optional(),
889
1050
  attempts: z.array(z.object({
890
1051
  id: z.string(),
@@ -943,7 +1104,7 @@ var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
943
1104
  type: z.literal("SCHEDULE_ATTEMPT"),
944
1105
  image: z.string(),
945
1106
  version: z.string(),
946
- machine: Machine,
1107
+ machine: MachinePreset,
947
1108
  // identifiers
948
1109
  id: z.string().optional(),
949
1110
  envId: z.string(),
@@ -1113,47 +1274,15 @@ var ProdChildToWorkerMessages = {
1113
1274
  id: z.string()
1114
1275
  })
1115
1276
  },
1116
- TASK_RUN_HEARTBEAT: {
1117
- message: z.object({
1118
- version: z.literal("v1").default("v1"),
1119
- id: z.string()
1120
- })
1121
- },
1122
1277
  READY_TO_DISPOSE: {
1123
1278
  message: z.undefined()
1124
1279
  },
1125
- READY_FOR_CHECKPOINT: {
1126
- message: z.object({
1127
- version: z.literal("v1").default("v1")
1128
- })
1129
- },
1130
- CANCEL_CHECKPOINT: {
1131
- message: z.discriminatedUnion("version", [
1132
- z.object({
1133
- version: z.literal("v1")
1134
- }),
1135
- z.object({
1136
- version: z.literal("v2"),
1137
- reason: WaitReason.optional()
1138
- })
1139
- ]).default({
1140
- version: "v1"
1141
- }),
1142
- callback: z.object({
1143
- // TODO: Figure out how best to handle callback schema parsing in zod IPC
1144
- version: z.literal("v2"),
1145
- checkpointCanceled: z.boolean(),
1146
- reason: WaitReason.optional()
1147
- })
1148
- },
1149
1280
  WAIT_FOR_DURATION: {
1150
1281
  message: z.object({
1151
1282
  version: z.literal("v1").default("v1"),
1152
1283
  ms: z.number(),
1153
- now: z.number()
1154
- }),
1155
- callback: z.object({
1156
- willCheckpointAndRestore: z.boolean()
1284
+ now: z.number(),
1285
+ waitThresholdInMs: z.number()
1157
1286
  })
1158
1287
  },
1159
1288
  WAIT_FOR_TASK: {
@@ -1232,7 +1361,8 @@ var ProviderToPlatformMessages = {
1232
1361
  reason: z.string().optional(),
1233
1362
  exitCode: z.number().optional(),
1234
1363
  message: z.string().optional(),
1235
- logs: z.string().optional()
1364
+ logs: z.string().optional(),
1365
+ overrideCompletion: z.boolean().optional()
1236
1366
  })
1237
1367
  },
1238
1368
  INDEXING_FAILED: {
@@ -1242,20 +1372,14 @@ var ProviderToPlatformMessages = {
1242
1372
  error: z.object({
1243
1373
  name: z.string(),
1244
1374
  message: z.string(),
1245
- stack: z.string().optional()
1246
- })
1375
+ stack: z.string().optional(),
1376
+ stderr: z.string().optional()
1377
+ }),
1378
+ overrideCompletion: z.boolean().optional()
1247
1379
  })
1248
1380
  }
1249
1381
  };
1250
1382
  var PlatformToProviderMessages = {
1251
- HEALTH: {
1252
- message: z.object({
1253
- version: z.literal("v1").default("v1")
1254
- }),
1255
- callback: z.object({
1256
- status: z.literal("ok")
1257
- })
1258
- },
1259
1383
  INDEX: {
1260
1384
  message: z.object({
1261
1385
  version: z.literal("v1").default("v1"),
@@ -1276,7 +1400,8 @@ var PlatformToProviderMessages = {
1276
1400
  error: z.object({
1277
1401
  name: z.string(),
1278
1402
  message: z.string(),
1279
- stack: z.string().optional()
1403
+ stack: z.string().optional(),
1404
+ stderr: z.string().optional()
1280
1405
  })
1281
1406
  }),
1282
1407
  z.object({
@@ -1284,7 +1409,6 @@ var PlatformToProviderMessages = {
1284
1409
  })
1285
1410
  ])
1286
1411
  },
1287
- // TODO: this should be a shared queue message instead
1288
1412
  RESTORE: {
1289
1413
  message: z.object({
1290
1414
  version: z.literal("v1").default("v1"),
@@ -1295,7 +1419,7 @@ var PlatformToProviderMessages = {
1295
1419
  location: z.string(),
1296
1420
  reason: z.string().optional(),
1297
1421
  imageRef: z.string(),
1298
- machine: Machine,
1422
+ machine: MachinePreset,
1299
1423
  // identifiers
1300
1424
  checkpointId: z.string(),
1301
1425
  envId: z.string(),
@@ -1304,21 +1428,6 @@ var PlatformToProviderMessages = {
1304
1428
  projectId: z.string(),
1305
1429
  runId: z.string()
1306
1430
  })
1307
- },
1308
- DELETE: {
1309
- message: z.object({
1310
- version: z.literal("v1").default("v1"),
1311
- name: z.string()
1312
- }),
1313
- callback: z.object({
1314
- message: z.string()
1315
- })
1316
- },
1317
- GET: {
1318
- message: z.object({
1319
- version: z.literal("v1").default("v1"),
1320
- name: z.string()
1321
- })
1322
1431
  }
1323
1432
  };
1324
1433
  var CreateWorkerMessage = z.object({
@@ -1376,6 +1485,7 @@ var CoordinatorToPlatformMessages = {
1376
1485
  })
1377
1486
  ])
1378
1487
  },
1488
+ // Deprecated: Only workers without lazy attempt support will use this
1379
1489
  READY_FOR_EXECUTION: {
1380
1490
  message: z.object({
1381
1491
  version: z.literal("v1").default("v1"),
@@ -1472,6 +1582,10 @@ var CoordinatorToPlatformMessages = {
1472
1582
  attemptNumber: z.number()
1473
1583
  })
1474
1584
  ])
1585
+ }),
1586
+ callback: z.object({
1587
+ version: z.literal("v1").default("v1"),
1588
+ keepRunAlive: z.boolean()
1475
1589
  })
1476
1590
  },
1477
1591
  INDEXING_FAILED: {
@@ -1481,7 +1595,8 @@ var CoordinatorToPlatformMessages = {
1481
1595
  error: z.object({
1482
1596
  name: z.string(),
1483
1597
  message: z.string(),
1484
- stack: z.string().optional()
1598
+ stack: z.string().optional(),
1599
+ stderr: z.string().optional()
1485
1600
  })
1486
1601
  })
1487
1602
  },
@@ -1534,6 +1649,12 @@ var PlatformToCoordinatorMessages = {
1534
1649
  version: z.literal("v1").default("v1"),
1535
1650
  runId: z.string()
1536
1651
  })
1652
+ },
1653
+ DYNAMIC_CONFIG: {
1654
+ message: z.object({
1655
+ version: z.literal("v1").default("v1"),
1656
+ checkpointThresholdInMs: z.number()
1657
+ })
1537
1658
  }
1538
1659
  };
1539
1660
  var ClientToSharedQueueMessages = {
@@ -1579,10 +1700,9 @@ var IndexTasksMessage = z.object({
1579
1700
  packageVersion: z.string()
1580
1701
  });
1581
1702
  var ProdWorkerToCoordinatorMessages = {
1582
- LOG: {
1703
+ TEST: {
1583
1704
  message: z.object({
1584
- version: z.literal("v1").default("v1"),
1585
- text: z.string()
1705
+ version: z.literal("v1").default("v1")
1586
1706
  }),
1587
1707
  callback: z.void()
1588
1708
  },
@@ -1605,6 +1725,7 @@ var ProdWorkerToCoordinatorMessages = {
1605
1725
  })
1606
1726
  ])
1607
1727
  },
1728
+ // Deprecated: Only workers without lazy attempt support will use this
1608
1729
  READY_FOR_EXECUTION: {
1609
1730
  message: z.object({
1610
1731
  version: z.literal("v1").default("v1"),
@@ -1691,7 +1812,10 @@ var ProdWorkerToCoordinatorMessages = {
1691
1812
  },
1692
1813
  WAIT_FOR_TASK: {
1693
1814
  message: z.object({
1694
- version: z.literal("v1").default("v1"),
1815
+ version: z.enum([
1816
+ "v1",
1817
+ "v2"
1818
+ ]).default("v1"),
1695
1819
  friendlyId: z.string(),
1696
1820
  // This is the attempt that is waiting
1697
1821
  attemptFriendlyId: z.string()
@@ -1702,7 +1826,10 @@ var ProdWorkerToCoordinatorMessages = {
1702
1826
  },
1703
1827
  WAIT_FOR_BATCH: {
1704
1828
  message: z.object({
1705
- version: z.literal("v1").default("v1"),
1829
+ version: z.enum([
1830
+ "v1",
1831
+ "v2"
1832
+ ]).default("v1"),
1706
1833
  batchFriendlyId: z.string(),
1707
1834
  runFriendlyIds: z.string().array(),
1708
1835
  // This is the attempt that is waiting
@@ -1719,7 +1846,8 @@ var ProdWorkerToCoordinatorMessages = {
1719
1846
  error: z.object({
1720
1847
  name: z.string(),
1721
1848
  message: z.string(),
1722
- stack: z.string().optional()
1849
+ stack: z.string().optional(),
1850
+ stderr: z.string().optional()
1723
1851
  })
1724
1852
  })
1725
1853
  },
@@ -1748,6 +1876,12 @@ var ProdWorkerToCoordinatorMessages = {
1748
1876
  stack: z.string().optional()
1749
1877
  })
1750
1878
  })
1879
+ },
1880
+ SET_STATE: {
1881
+ message: z.object({
1882
+ version: z.literal("v1").default("v1"),
1883
+ attemptFriendlyId: z.string().optional()
1884
+ })
1751
1885
  }
1752
1886
  };
1753
1887
  var CoordinatorToProdWorkerMessages = {
@@ -1765,6 +1899,7 @@ var CoordinatorToProdWorkerMessages = {
1765
1899
  attemptId: z.string()
1766
1900
  })
1767
1901
  },
1902
+ // Deprecated: Only workers without lazy attempt support will use this
1768
1903
  EXECUTE_TASK_RUN: {
1769
1904
  message: z.object({
1770
1905
  version: z.literal("v1").default("v1"),
@@ -1811,6 +1946,9 @@ var ProdWorkerSocketData = z.object({
1811
1946
  deploymentId: z.string(),
1812
1947
  deploymentVersion: z.string()
1813
1948
  });
1949
+ var CoordinatorSocketData = z.object({
1950
+ supportsDynamicConfig: z.string().optional()
1951
+ });
1814
1952
  var PRIMARY_VARIANT = "primary";
1815
1953
  var Variant = z.enum([
1816
1954
  PRIMARY_VARIANT
@@ -2058,6 +2196,10 @@ var SemanticInternalAttributes = {
2058
2196
  TASK_EXPORT_NAME: "ctx.task.exportName",
2059
2197
  QUEUE_NAME: "ctx.queue.name",
2060
2198
  QUEUE_ID: "ctx.queue.id",
2199
+ MACHINE_PRESET_NAME: "ctx.machine.name",
2200
+ MACHINE_PRESET_CPU: "ctx.machine.cpu",
2201
+ MACHINE_PRESET_MEMORY: "ctx.machine.memory",
2202
+ MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
2061
2203
  SPAN_PARTIAL: "$span.partial",
2062
2204
  SPAN_ID: "$span.span_id",
2063
2205
  OUTPUT: "$output",
@@ -2081,7 +2223,12 @@ var SemanticInternalAttributes = {
2081
2223
  RETRY_DELAY: "retry.delay",
2082
2224
  RETRY_COUNT: "retry.count",
2083
2225
  LINK_TITLE: "$link.title",
2084
- IDEMPOTENCY_KEY: "ctx.run.idempotencyKey"
2226
+ IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
2227
+ USAGE_DURATION_MS: "$usage.durationMs",
2228
+ USAGE_COST_IN_CENTS: "$usage.costInCents",
2229
+ RATE_LIMIT_LIMIT: "response.rateLimit.limit",
2230
+ RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
2231
+ RATE_LIMIT_RESET: "response.rateLimit.reset"
2085
2232
  };
2086
2233
 
2087
2234
  // src/v3/taskContext/index.ts
@@ -2145,7 +2292,11 @@ var _TaskContextAPI = class _TaskContextAPI {
2145
2292
  [SemanticInternalAttributes.ORGANIZATION_SLUG]: this.ctx.organization.slug,
2146
2293
  [SemanticInternalAttributes.ORGANIZATION_NAME]: this.ctx.organization.name,
2147
2294
  [SemanticInternalAttributes.BATCH_ID]: this.ctx.batch?.id,
2148
- [SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey
2295
+ [SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey,
2296
+ [SemanticInternalAttributes.MACHINE_PRESET_NAME]: this.ctx.machine?.name,
2297
+ [SemanticInternalAttributes.MACHINE_PRESET_CPU]: this.ctx.machine?.cpu,
2298
+ [SemanticInternalAttributes.MACHINE_PRESET_MEMORY]: this.ctx.machine?.memory,
2299
+ [SemanticInternalAttributes.MACHINE_PRESET_CENTS_PER_MS]: this.ctx.machine?.centsPerMs
2149
2300
  };
2150
2301
  }
2151
2302
  return {};
@@ -2167,160 +2318,22 @@ var TaskContextAPI = _TaskContextAPI;
2167
2318
  // src/v3/task-context-api.ts
2168
2319
  var taskContext = TaskContextAPI.getInstance();
2169
2320
 
2170
- // src/v3/apiClient/errors.ts
2171
- var _ApiError = class _ApiError extends Error {
2172
- constructor(status, error, message, headers) {
2173
- super(`${_ApiError.makeMessage(status, error, message)}`);
2174
- this.status = status;
2175
- this.headers = headers;
2176
- const data = error;
2177
- this.error = data;
2178
- this.code = data?.["code"];
2179
- this.param = data?.["param"];
2180
- this.type = data?.["type"];
2181
- }
2182
- static makeMessage(status, error, message) {
2183
- const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
2184
- if (status && msg) {
2185
- return `${status} ${msg}`;
2186
- }
2187
- if (status) {
2188
- return `${status} status code (no body)`;
2189
- }
2190
- if (msg) {
2191
- return msg;
2192
- }
2193
- return "(no status code or body)";
2194
- }
2195
- static generate(status, errorResponse, message, headers) {
2196
- if (!status) {
2197
- return new ApiConnectionError({
2198
- cause: castToError(errorResponse)
2199
- });
2200
- }
2201
- const error = errorResponse?.["error"];
2202
- if (status === 400) {
2203
- return new BadRequestError(status, error, message, headers);
2204
- }
2205
- if (status === 401) {
2206
- return new AuthenticationError(status, error, message, headers);
2207
- }
2208
- if (status === 403) {
2209
- return new PermissionDeniedError(status, error, message, headers);
2210
- }
2211
- if (status === 404) {
2212
- return new NotFoundError(status, error, message, headers);
2213
- }
2214
- if (status === 409) {
2215
- return new ConflictError(status, error, message, headers);
2321
+ // src/retry.ts
2322
+ function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
2323
+ if (!resets)
2324
+ return;
2325
+ switch (format) {
2326
+ case "iso_8601_duration_openai_variant": {
2327
+ return calculateISO8601DurationOpenAIVariantResetAt(resets, now);
2216
2328
  }
2217
- if (status === 422) {
2218
- return new UnprocessableEntityError(status, error, message, headers);
2329
+ case "iso_8601": {
2330
+ return calculateISO8601ResetAt(resets, now);
2219
2331
  }
2220
- if (status === 429) {
2221
- return new RateLimitError(status, error, message, headers);
2332
+ case "unix_timestamp": {
2333
+ return calculateUnixTimestampResetAt(resets, now);
2222
2334
  }
2223
- if (status >= 500) {
2224
- return new InternalServerError(status, error, message, headers);
2225
- }
2226
- return new _ApiError(status, error, message, headers);
2227
- }
2228
- };
2229
- __name(_ApiError, "ApiError");
2230
- var ApiError = _ApiError;
2231
- var _ApiConnectionError = class _ApiConnectionError extends ApiError {
2232
- constructor({ message, cause }) {
2233
- super(void 0, void 0, message || "Connection error.", void 0);
2234
- __publicField(this, "status");
2235
- if (cause)
2236
- this.cause = cause;
2237
- }
2238
- };
2239
- __name(_ApiConnectionError, "ApiConnectionError");
2240
- var ApiConnectionError = _ApiConnectionError;
2241
- var _BadRequestError = class _BadRequestError extends ApiError {
2242
- constructor() {
2243
- super(...arguments);
2244
- __publicField(this, "status", 400);
2245
- }
2246
- };
2247
- __name(_BadRequestError, "BadRequestError");
2248
- var BadRequestError = _BadRequestError;
2249
- var _AuthenticationError = class _AuthenticationError extends ApiError {
2250
- constructor() {
2251
- super(...arguments);
2252
- __publicField(this, "status", 401);
2253
- }
2254
- };
2255
- __name(_AuthenticationError, "AuthenticationError");
2256
- var AuthenticationError = _AuthenticationError;
2257
- var _PermissionDeniedError = class _PermissionDeniedError extends ApiError {
2258
- constructor() {
2259
- super(...arguments);
2260
- __publicField(this, "status", 403);
2261
- }
2262
- };
2263
- __name(_PermissionDeniedError, "PermissionDeniedError");
2264
- var PermissionDeniedError = _PermissionDeniedError;
2265
- var _NotFoundError = class _NotFoundError extends ApiError {
2266
- constructor() {
2267
- super(...arguments);
2268
- __publicField(this, "status", 404);
2269
- }
2270
- };
2271
- __name(_NotFoundError, "NotFoundError");
2272
- var NotFoundError = _NotFoundError;
2273
- var _ConflictError = class _ConflictError extends ApiError {
2274
- constructor() {
2275
- super(...arguments);
2276
- __publicField(this, "status", 409);
2277
- }
2278
- };
2279
- __name(_ConflictError, "ConflictError");
2280
- var ConflictError = _ConflictError;
2281
- var _UnprocessableEntityError = class _UnprocessableEntityError extends ApiError {
2282
- constructor() {
2283
- super(...arguments);
2284
- __publicField(this, "status", 422);
2285
- }
2286
- };
2287
- __name(_UnprocessableEntityError, "UnprocessableEntityError");
2288
- var UnprocessableEntityError = _UnprocessableEntityError;
2289
- var _RateLimitError = class _RateLimitError extends ApiError {
2290
- constructor() {
2291
- super(...arguments);
2292
- __publicField(this, "status", 429);
2293
- }
2294
- };
2295
- __name(_RateLimitError, "RateLimitError");
2296
- var RateLimitError = _RateLimitError;
2297
- var _InternalServerError = class _InternalServerError extends ApiError {
2298
- };
2299
- __name(_InternalServerError, "InternalServerError");
2300
- var InternalServerError = _InternalServerError;
2301
- function castToError(err) {
2302
- if (err instanceof Error)
2303
- return err;
2304
- return new Error(err);
2305
- }
2306
- __name(castToError, "castToError");
2307
-
2308
- // src/retry.ts
2309
- function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
2310
- if (!resets)
2311
- return;
2312
- switch (format) {
2313
- case "iso_8601_duration_openai_variant": {
2314
- return calculateISO8601DurationOpenAIVariantResetAt(resets, now);
2315
- }
2316
- case "iso_8601": {
2317
- return calculateISO8601ResetAt(resets, now);
2318
- }
2319
- case "unix_timestamp": {
2320
- return calculateUnixTimestampResetAt(resets, now);
2321
- }
2322
- case "unix_timestamp_in_ms": {
2323
- return calculateUnixTimestampInMsResetAt(resets, now);
2335
+ case "unix_timestamp_in_ms": {
2336
+ return calculateUnixTimestampInMsResetAt(resets, now);
2324
2337
  }
2325
2338
  }
2326
2339
  }
@@ -2405,12 +2418,287 @@ function calculateNextRetryDelay(options, attempt) {
2405
2418
  const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
2406
2419
  return Math.round(timeout);
2407
2420
  }
2408
- __name(calculateNextRetryDelay, "calculateNextRetryDelay");
2409
- function calculateResetAt2(resets, format, now = Date.now()) {
2410
- const resetAt = calculateResetAt(resets, format, new Date(now));
2411
- return resetAt?.getTime();
2421
+ __name(calculateNextRetryDelay, "calculateNextRetryDelay");
2422
+ function calculateResetAt2(resets, format, now = Date.now()) {
2423
+ const resetAt = calculateResetAt(resets, format, new Date(now));
2424
+ return resetAt?.getTime();
2425
+ }
2426
+ __name(calculateResetAt2, "calculateResetAt");
2427
+
2428
+ // src/v3/apiClient/errors.ts
2429
+ var _ApiError = class _ApiError extends Error {
2430
+ constructor(status, error, message, headers) {
2431
+ super(`${_ApiError.makeMessage(status, error, message)}`);
2432
+ this.name = "TriggerApiError";
2433
+ this.status = status;
2434
+ this.headers = headers;
2435
+ const data = error;
2436
+ this.error = data;
2437
+ this.code = data?.["code"];
2438
+ this.param = data?.["param"];
2439
+ this.type = data?.["type"];
2440
+ }
2441
+ static makeMessage(status, error, message) {
2442
+ const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
2443
+ if (status && msg) {
2444
+ return `${status} ${msg}`;
2445
+ }
2446
+ if (status) {
2447
+ return `${status} status code (no body)`;
2448
+ }
2449
+ if (msg) {
2450
+ return msg;
2451
+ }
2452
+ return "(no status code or body)";
2453
+ }
2454
+ static generate(status, errorResponse, message, headers) {
2455
+ if (!status) {
2456
+ return new ApiConnectionError({
2457
+ cause: castToError(errorResponse)
2458
+ });
2459
+ }
2460
+ const error = errorResponse?.["error"];
2461
+ if (status === 400) {
2462
+ return new BadRequestError(status, error, message, headers);
2463
+ }
2464
+ if (status === 401) {
2465
+ return new AuthenticationError(status, error, message, headers);
2466
+ }
2467
+ if (status === 403) {
2468
+ return new PermissionDeniedError(status, error, message, headers);
2469
+ }
2470
+ if (status === 404) {
2471
+ return new NotFoundError(status, error, message, headers);
2472
+ }
2473
+ if (status === 409) {
2474
+ return new ConflictError(status, error, message, headers);
2475
+ }
2476
+ if (status === 422) {
2477
+ return new UnprocessableEntityError(status, error, message, headers);
2478
+ }
2479
+ if (status === 429) {
2480
+ return new RateLimitError(status, error, message, headers);
2481
+ }
2482
+ if (status >= 500) {
2483
+ return new InternalServerError(status, error, message, headers);
2484
+ }
2485
+ return new _ApiError(status, error, message, headers);
2486
+ }
2487
+ };
2488
+ __name(_ApiError, "ApiError");
2489
+ var ApiError = _ApiError;
2490
+ var _ApiConnectionError = class _ApiConnectionError extends ApiError {
2491
+ constructor({ message, cause }) {
2492
+ super(void 0, void 0, message || "Connection error.", void 0);
2493
+ __publicField(this, "status");
2494
+ if (cause)
2495
+ this.cause = cause;
2496
+ }
2497
+ };
2498
+ __name(_ApiConnectionError, "ApiConnectionError");
2499
+ var ApiConnectionError = _ApiConnectionError;
2500
+ var _BadRequestError = class _BadRequestError extends ApiError {
2501
+ constructor() {
2502
+ super(...arguments);
2503
+ __publicField(this, "status", 400);
2504
+ }
2505
+ };
2506
+ __name(_BadRequestError, "BadRequestError");
2507
+ var BadRequestError = _BadRequestError;
2508
+ var _AuthenticationError = class _AuthenticationError extends ApiError {
2509
+ constructor() {
2510
+ super(...arguments);
2511
+ __publicField(this, "status", 401);
2512
+ }
2513
+ };
2514
+ __name(_AuthenticationError, "AuthenticationError");
2515
+ var AuthenticationError = _AuthenticationError;
2516
+ var _PermissionDeniedError = class _PermissionDeniedError extends ApiError {
2517
+ constructor() {
2518
+ super(...arguments);
2519
+ __publicField(this, "status", 403);
2520
+ }
2521
+ };
2522
+ __name(_PermissionDeniedError, "PermissionDeniedError");
2523
+ var PermissionDeniedError = _PermissionDeniedError;
2524
+ var _NotFoundError = class _NotFoundError extends ApiError {
2525
+ constructor() {
2526
+ super(...arguments);
2527
+ __publicField(this, "status", 404);
2528
+ }
2529
+ };
2530
+ __name(_NotFoundError, "NotFoundError");
2531
+ var NotFoundError = _NotFoundError;
2532
+ var _ConflictError = class _ConflictError extends ApiError {
2533
+ constructor() {
2534
+ super(...arguments);
2535
+ __publicField(this, "status", 409);
2536
+ }
2537
+ };
2538
+ __name(_ConflictError, "ConflictError");
2539
+ var ConflictError = _ConflictError;
2540
+ var _UnprocessableEntityError = class _UnprocessableEntityError extends ApiError {
2541
+ constructor() {
2542
+ super(...arguments);
2543
+ __publicField(this, "status", 422);
2544
+ }
2545
+ };
2546
+ __name(_UnprocessableEntityError, "UnprocessableEntityError");
2547
+ var UnprocessableEntityError = _UnprocessableEntityError;
2548
+ var _RateLimitError = class _RateLimitError extends ApiError {
2549
+ constructor() {
2550
+ super(...arguments);
2551
+ __publicField(this, "status", 429);
2552
+ }
2553
+ get millisecondsUntilReset() {
2554
+ const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
2555
+ if (typeof resetAtUnixEpochMs === "string") {
2556
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
2557
+ if (isNaN(resetAtUnixEpoch)) {
2558
+ return;
2559
+ }
2560
+ return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
2561
+ }
2562
+ }
2563
+ };
2564
+ __name(_RateLimitError, "RateLimitError");
2565
+ var RateLimitError = _RateLimitError;
2566
+ var _InternalServerError = class _InternalServerError extends ApiError {
2567
+ };
2568
+ __name(_InternalServerError, "InternalServerError");
2569
+ var InternalServerError = _InternalServerError;
2570
+ function castToError(err) {
2571
+ if (err instanceof Error)
2572
+ return err;
2573
+ return new Error(err);
2574
+ }
2575
+ __name(castToError, "castToError");
2576
+
2577
+ // src/v3/utils/flattenAttributes.ts
2578
+ var NULL_SENTINEL = "$@null((";
2579
+ function flattenAttributes(obj, prefix) {
2580
+ const result = {};
2581
+ if (obj === void 0) {
2582
+ return result;
2583
+ }
2584
+ if (obj === null) {
2585
+ result[prefix || ""] = NULL_SENTINEL;
2586
+ return result;
2587
+ }
2588
+ if (typeof obj === "string") {
2589
+ result[prefix || ""] = obj;
2590
+ return result;
2591
+ }
2592
+ if (typeof obj === "number") {
2593
+ result[prefix || ""] = obj;
2594
+ return result;
2595
+ }
2596
+ if (typeof obj === "boolean") {
2597
+ result[prefix || ""] = obj;
2598
+ return result;
2599
+ }
2600
+ for (const [key, value] of Object.entries(obj)) {
2601
+ const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
2602
+ if (Array.isArray(value)) {
2603
+ for (let i = 0; i < value.length; i++) {
2604
+ if (typeof value[i] === "object" && value[i] !== null) {
2605
+ Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
2606
+ } else {
2607
+ if (value[i] === null) {
2608
+ result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
2609
+ } else {
2610
+ result[`${newPrefix}.[${i}]`] = value[i];
2611
+ }
2612
+ }
2613
+ }
2614
+ } else if (isRecord(value)) {
2615
+ Object.assign(result, flattenAttributes(value, newPrefix));
2616
+ } else {
2617
+ if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
2618
+ result[newPrefix] = value;
2619
+ } else if (value === null) {
2620
+ result[newPrefix] = NULL_SENTINEL;
2621
+ }
2622
+ }
2623
+ }
2624
+ return result;
2625
+ }
2626
+ __name(flattenAttributes, "flattenAttributes");
2627
+ function isRecord(value) {
2628
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2629
+ }
2630
+ __name(isRecord, "isRecord");
2631
+ function unflattenAttributes(obj) {
2632
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
2633
+ return obj;
2634
+ }
2635
+ if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
2636
+ return rehydrateNull(obj[""]);
2637
+ }
2638
+ if (Object.keys(obj).length === 0) {
2639
+ return;
2640
+ }
2641
+ const result = {};
2642
+ for (const [key, value] of Object.entries(obj)) {
2643
+ const parts = key.split(".").reduce((acc, part) => {
2644
+ if (part.includes("[")) {
2645
+ const subparts = part.split(/\[|\]/).filter((p) => p !== "");
2646
+ acc.push(...subparts);
2647
+ } else {
2648
+ acc.push(part);
2649
+ }
2650
+ return acc;
2651
+ }, []);
2652
+ let current = result;
2653
+ for (let i = 0; i < parts.length - 1; i++) {
2654
+ const part = parts[i];
2655
+ const nextPart = parts[i + 1];
2656
+ const isArray = /^\d+$/.test(nextPart);
2657
+ if (isArray && !Array.isArray(current[part])) {
2658
+ current[part] = [];
2659
+ } else if (!isArray && current[part] === void 0) {
2660
+ current[part] = {};
2661
+ }
2662
+ current = current[part];
2663
+ }
2664
+ const lastPart = parts[parts.length - 1];
2665
+ current[lastPart] = rehydrateNull(value);
2666
+ }
2667
+ if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
2668
+ const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
2669
+ const arrayResult = Array(maxIndex + 1);
2670
+ for (const key in result) {
2671
+ arrayResult[parseInt(key)] = result[key];
2672
+ }
2673
+ return arrayResult;
2674
+ }
2675
+ return result;
2676
+ }
2677
+ __name(unflattenAttributes, "unflattenAttributes");
2678
+ function primitiveValueOrflattenedAttributes(obj, prefix) {
2679
+ if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
2680
+ return obj;
2681
+ }
2682
+ const attributes = flattenAttributes(obj, prefix);
2683
+ if (prefix !== void 0 && typeof attributes[prefix] !== "undefined" && attributes[prefix] !== null) {
2684
+ return attributes[prefix];
2685
+ }
2686
+ return attributes;
2687
+ }
2688
+ __name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
2689
+ function rehydrateNull(value) {
2690
+ if (value === NULL_SENTINEL) {
2691
+ return null;
2692
+ }
2693
+ return value;
2694
+ }
2695
+ __name(rehydrateNull, "rehydrateNull");
2696
+
2697
+ // src/v3/utils/styleAttributes.ts
2698
+ function accessoryAttributes(accessory) {
2699
+ return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
2412
2700
  }
2413
- __name(calculateResetAt2, "calculateResetAt");
2701
+ __name(accessoryAttributes, "accessoryAttributes");
2414
2702
 
2415
2703
  // src/v3/apiClient/pagination.ts
2416
2704
  var _CursorPage = class _CursorPage {
@@ -2520,6 +2808,12 @@ var defaultRetryOptions2 = {
2520
2808
  maxTimeoutInMs: 6e4,
2521
2809
  randomize: false
2522
2810
  };
2811
+ var requestOptionsKeys = {
2812
+ retry: true
2813
+ };
2814
+ var isRequestOptions = /* @__PURE__ */ __name((obj) => {
2815
+ return typeof obj === "object" && obj !== null && !isEmptyObj(obj) && Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k));
2816
+ }, "isRequestOptions");
2523
2817
  function zodfetch(schema, url, requestInit, options) {
2524
2818
  return new ApiPromise(_doZodFetch(schema, url, requestInit, options));
2525
2819
  }
@@ -2570,47 +2864,47 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
2570
2864
  return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
2571
2865
  }
2572
2866
  __name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
2573
- function zodupload(schema, url, body, requestInit, options) {
2574
- const finalRequestInit = createMultipartFormRequestInit(body, requestInit);
2575
- return new ApiPromise(_doZodFetch(schema, url, finalRequestInit, options));
2867
+ async function traceZodFetch(params, callback) {
2868
+ if (!params.options?.tracer) {
2869
+ return callback();
2870
+ }
2871
+ const url = new URL(params.url);
2872
+ const method = params.requestInit?.method ?? "GET";
2873
+ const name = params.options.name ?? `${method} ${url.pathname}`;
2874
+ return await params.options.tracer.startActiveSpan(name, async (span) => {
2875
+ return await callback(span);
2876
+ }, {
2877
+ attributes: {
2878
+ [SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
2879
+ ...params.options.attributes
2880
+ }
2881
+ });
2576
2882
  }
2577
- __name(zodupload, "zodupload");
2578
- async function createMultipartFormRequestInit(body, requestInit) {
2579
- const form = await createForm(body);
2580
- const encoder = new FormDataEncoder(form);
2581
- const finalHeaders = {};
2582
- for (const [key, value] of Object.entries(requestInit?.headers || {})) {
2583
- finalHeaders[key] = value;
2584
- }
2585
- for (const [key, value] of Object.entries(encoder.headers)) {
2586
- finalHeaders[key] = value;
2587
- }
2588
- finalHeaders["Content-Length"] = String(encoder.contentLength);
2589
- const finalRequestInit = {
2590
- ...requestInit,
2591
- headers: finalHeaders,
2592
- body: Readable.from(encoder),
2593
- // @ts-expect-error
2594
- duplex: "half"
2595
- };
2596
- return finalRequestInit;
2883
+ __name(traceZodFetch, "traceZodFetch");
2884
+ async function _doZodFetch(schema, url, requestInit, options) {
2885
+ const $requestInit = await requestInit;
2886
+ return traceZodFetch({
2887
+ url,
2888
+ requestInit: $requestInit,
2889
+ options
2890
+ }, async (span) => {
2891
+ const result = await _doZodFetchWithRetries(schema, url, $requestInit, options);
2892
+ if (options?.onResponseBody && span) {
2893
+ options.onResponseBody(result.data, span);
2894
+ }
2895
+ return result;
2896
+ });
2597
2897
  }
2598
- __name(createMultipartFormRequestInit, "createMultipartFormRequestInit");
2599
- var createForm = /* @__PURE__ */ __name(async (body) => {
2600
- const form = new FormData();
2601
- await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
2602
- return form;
2603
- }, "createForm");
2604
- async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2898
+ __name(_doZodFetch, "_doZodFetch");
2899
+ async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
2605
2900
  try {
2606
- const $requestInit = await requestInit;
2607
- const response = await fetch(url, requestInitWithCache($requestInit));
2901
+ const response = await fetch(url, requestInitWithCache(requestInit));
2608
2902
  const responseHeaders = createResponseHeaders(response.headers);
2609
2903
  if (!response.ok) {
2610
2904
  const retryResult = shouldRetry(response, attempt, options?.retry);
2611
2905
  if (retryResult.retry) {
2612
- await new Promise((resolve) => setTimeout(resolve, retryResult.delay));
2613
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
2906
+ await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
2907
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
2614
2908
  } else {
2615
2909
  const errText = await response.text().catch((e) => castToError2(e).message);
2616
2910
  const errJSON = safeJsonParse(errText);
@@ -2638,8 +2932,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2638
2932
  };
2639
2933
  const delay = calculateNextRetryDelay(retry, attempt);
2640
2934
  if (delay) {
2641
- await new Promise((resolve) => setTimeout(resolve, delay));
2642
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
2935
+ await waitForRetry(url, attempt + 1, delay, options, requestInit);
2936
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
2643
2937
  }
2644
2938
  }
2645
2939
  throw new ApiConnectionError({
@@ -2647,7 +2941,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2647
2941
  });
2648
2942
  }
2649
2943
  }
2650
- __name(_doZodFetch, "_doZodFetch");
2944
+ __name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
2651
2945
  function castToError2(err) {
2652
2946
  if (err instanceof Error)
2653
2947
  return err;
@@ -2684,8 +2978,25 @@ function shouldRetry(response, attempt, retryOptions) {
2684
2978
  return shouldRetryForOptions();
2685
2979
  if (response.status === 409)
2686
2980
  return shouldRetryForOptions();
2687
- if (response.status === 429)
2981
+ if (response.status === 429) {
2982
+ if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
2983
+ return {
2984
+ retry: false
2985
+ };
2986
+ }
2987
+ const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
2988
+ if (resetAtUnixEpochMs) {
2989
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
2990
+ const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
2991
+ if (delay > 0) {
2992
+ return {
2993
+ retry: true,
2994
+ delay
2995
+ };
2996
+ }
2997
+ }
2688
2998
  return shouldRetryForOptions();
2999
+ }
2689
3000
  if (response.status >= 500)
2690
3001
  return shouldRetryForOptions();
2691
3002
  return {
@@ -2726,95 +3037,6 @@ function requestInitWithCache(requestInit) {
2726
3037
  }
2727
3038
  }
2728
3039
  __name(requestInitWithCache, "requestInitWithCache");
2729
- var addFormValue = /* @__PURE__ */ __name(async (form, key, value) => {
2730
- if (value === void 0)
2731
- return;
2732
- if (value == null) {
2733
- throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
2734
- }
2735
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
2736
- form.append(key, String(value));
2737
- } else if (isUploadable(value) || isBlobLike(value) || value instanceof Buffer || value instanceof ArrayBuffer) {
2738
- const file = await toFile(value);
2739
- form.append(key, file);
2740
- } else if (Array.isArray(value)) {
2741
- await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
2742
- } else if (typeof value === "object") {
2743
- await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
2744
- } else {
2745
- throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
2746
- }
2747
- }, "addFormValue");
2748
- async function toFile(value, name, options) {
2749
- value = await value;
2750
- options ??= isFileLike(value) ? {
2751
- lastModified: value.lastModified,
2752
- type: value.type
2753
- } : {};
2754
- if (isResponseLike(value)) {
2755
- const blob = await value.blob();
2756
- name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file";
2757
- return new File([
2758
- blob
2759
- ], name, options);
2760
- }
2761
- const bits = await getBytes(value);
2762
- name ||= getName(value) ?? "unknown_file";
2763
- if (!options.type) {
2764
- const type = bits[0]?.type;
2765
- if (typeof type === "string") {
2766
- options = {
2767
- ...options,
2768
- type
2769
- };
2770
- }
2771
- }
2772
- return new File(bits, name, options);
2773
- }
2774
- __name(toFile, "toFile");
2775
- function getName(value) {
2776
- return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || // For fs.ReadStream
2777
- getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
2778
- }
2779
- __name(getName, "getName");
2780
- var getStringFromMaybeBuffer = /* @__PURE__ */ __name((x) => {
2781
- if (typeof x === "string")
2782
- return x;
2783
- if (typeof Buffer !== "undefined" && x instanceof Buffer)
2784
- return String(x);
2785
- return void 0;
2786
- }, "getStringFromMaybeBuffer");
2787
- async function getBytes(value) {
2788
- let parts = [];
2789
- if (typeof value === "string" || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
2790
- value instanceof ArrayBuffer) {
2791
- parts.push(value);
2792
- } else if (isBlobLike(value)) {
2793
- parts.push(await value.arrayBuffer());
2794
- } else if (isAsyncIterableIterator(value)) {
2795
- for await (const chunk of value) {
2796
- parts.push(chunk);
2797
- }
2798
- } else {
2799
- throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor?.name}; props: ${propsForError(value)}`);
2800
- }
2801
- return parts;
2802
- }
2803
- __name(getBytes, "getBytes");
2804
- function propsForError(value) {
2805
- const props = Object.getOwnPropertyNames(value);
2806
- return `[${props.map((p) => `"${p}"`).join(", ")}]`;
2807
- }
2808
- __name(propsForError, "propsForError");
2809
- var isAsyncIterableIterator = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function", "isAsyncIterableIterator");
2810
- var isResponseLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function", "isResponseLike");
2811
- var isFileLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value), "isFileLike");
2812
- var isBlobLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.size === "number" && typeof value.type === "string" && typeof value.text === "function" && typeof value.slice === "function" && typeof value.arrayBuffer === "function", "isBlobLike");
2813
- var isFsReadStream = /* @__PURE__ */ __name((value) => value instanceof Readable, "isFsReadStream");
2814
- var isUploadable = /* @__PURE__ */ __name((value) => {
2815
- return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
2816
- }, "isUploadable");
2817
- var isRecordLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => typeof key === "string" && typeof value[key] === "string"), "isRecordLike");
2818
3040
  var _ApiPromise = class _ApiPromise extends Promise {
2819
3041
  constructor(responsePromise) {
2820
3042
  super((resolve) => {
@@ -2937,9 +3159,44 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
2937
3159
  }, "#fetchPage");
2938
3160
  __name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
2939
3161
  var OffsetLimitPagePromise = _OffsetLimitPagePromise;
3162
+ async function waitForRetry(url, attempt, delay, options, requestInit, response) {
3163
+ if (options?.tracer) {
3164
+ const method = requestInit?.method ?? "GET";
3165
+ return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
3166
+ await new Promise((resolve) => setTimeout(resolve, delay));
3167
+ }, {
3168
+ attributes: {
3169
+ [SemanticInternalAttributes.STYLE_ICON]: "wait",
3170
+ ...accessoryAttributes({
3171
+ items: [
3172
+ {
3173
+ text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
3174
+ variant: "normal"
3175
+ }
3176
+ ],
3177
+ style: "codepath"
3178
+ })
3179
+ }
3180
+ });
3181
+ }
3182
+ await new Promise((resolve) => setTimeout(resolve, delay));
3183
+ }
3184
+ __name(waitForRetry, "waitForRetry");
3185
+ function isEmptyObj(obj) {
3186
+ if (!obj)
3187
+ return true;
3188
+ for (const _k in obj)
3189
+ return false;
3190
+ return true;
3191
+ }
3192
+ __name(isEmptyObj, "isEmptyObj");
3193
+ function hasOwn(obj, key) {
3194
+ return Object.prototype.hasOwnProperty.call(obj, key);
3195
+ }
3196
+ __name(hasOwn, "hasOwn");
2940
3197
 
2941
3198
  // src/v3/apiClient/index.ts
2942
- var zodFetchOptions = {
3199
+ var DEFAULT_ZOD_FETCH_OPTIONS = {
2943
3200
  retry: {
2944
3201
  maxAttempts: 3,
2945
3202
  minTimeoutInMs: 1e3,
@@ -2950,17 +3207,18 @@ var zodFetchOptions = {
2950
3207
  };
2951
3208
  var _getHeaders, getHeaders_fn;
2952
3209
  var _ApiClient = class _ApiClient {
2953
- constructor(baseUrl, accessToken) {
3210
+ constructor(baseUrl, accessToken, requestOptions = {}) {
2954
3211
  __privateAdd(this, _getHeaders);
2955
3212
  this.accessToken = accessToken;
2956
3213
  this.baseUrl = baseUrl.replace(/\/$/, "");
3214
+ this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
2957
3215
  }
2958
- async getRunResult(runId) {
3216
+ async getRunResult(runId, requestOptions) {
2959
3217
  try {
2960
3218
  return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
2961
3219
  method: "GET",
2962
3220
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2963
- }, zodFetchOptions);
3221
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2964
3222
  } catch (error) {
2965
3223
  if (error instanceof ApiError) {
2966
3224
  if (error.status === 404) {
@@ -2970,47 +3228,47 @@ var _ApiClient = class _ApiClient {
2970
3228
  throw error;
2971
3229
  }
2972
3230
  }
2973
- async getBatchResults(batchId) {
3231
+ async getBatchResults(batchId, requestOptions) {
2974
3232
  return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
2975
3233
  method: "GET",
2976
3234
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2977
- }, zodFetchOptions);
3235
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2978
3236
  }
2979
- triggerTask(taskId, body, options) {
3237
+ triggerTask(taskId, body, options, requestOptions) {
2980
3238
  const encodedTaskId = encodeURIComponent(taskId);
2981
3239
  return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
2982
3240
  method: "POST",
2983
3241
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
2984
3242
  body: JSON.stringify(body)
2985
- }, zodFetchOptions);
3243
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2986
3244
  }
2987
- batchTriggerTask(taskId, body, options) {
3245
+ batchTriggerTask(taskId, body, options, requestOptions) {
2988
3246
  const encodedTaskId = encodeURIComponent(taskId);
2989
3247
  return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
2990
3248
  method: "POST",
2991
3249
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
2992
3250
  body: JSON.stringify(body)
2993
- }, zodFetchOptions);
3251
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2994
3252
  }
2995
- createUploadPayloadUrl(filename) {
3253
+ createUploadPayloadUrl(filename, requestOptions) {
2996
3254
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
2997
3255
  method: "PUT",
2998
3256
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2999
- }, zodFetchOptions);
3257
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3000
3258
  }
3001
- getPayloadUrl(filename) {
3259
+ getPayloadUrl(filename, requestOptions) {
3002
3260
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
3003
3261
  method: "GET",
3004
3262
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3005
- }, zodFetchOptions);
3263
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3006
3264
  }
3007
- retrieveRun(runId) {
3265
+ retrieveRun(runId, requestOptions) {
3008
3266
  return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
3009
3267
  method: "GET",
3010
3268
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3011
- }, zodFetchOptions);
3269
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3012
3270
  }
3013
- listRuns(query) {
3271
+ listRuns(query, requestOptions) {
3014
3272
  const searchParams = createSearchQueryForListRuns(query);
3015
3273
  return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
3016
3274
  query: searchParams,
@@ -3020,9 +3278,9 @@ var _ApiClient = class _ApiClient {
3020
3278
  }, {
3021
3279
  method: "GET",
3022
3280
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3023
- }, zodFetchOptions);
3281
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3024
3282
  }
3025
- listProjectRuns(projectRef, query) {
3283
+ listProjectRuns(projectRef, query, requestOptions) {
3026
3284
  const searchParams = createSearchQueryForListRuns(query);
3027
3285
  if (query?.env) {
3028
3286
  searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
@@ -3035,28 +3293,44 @@ var _ApiClient = class _ApiClient {
3035
3293
  }, {
3036
3294
  method: "GET",
3037
3295
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3038
- }, zodFetchOptions);
3296
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3039
3297
  }
3040
- replayRun(runId) {
3298
+ replayRun(runId, requestOptions) {
3041
3299
  return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
3042
3300
  method: "POST",
3043
3301
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3044
- }, zodFetchOptions);
3302
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3045
3303
  }
3046
- cancelRun(runId) {
3304
+ cancelRun(runId, requestOptions) {
3047
3305
  return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
3048
3306
  method: "POST",
3049
3307
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3050
- }, zodFetchOptions);
3308
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3309
+ }
3310
+ rescheduleRun(runId, body, requestOptions) {
3311
+ return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
3312
+ method: "POST",
3313
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3314
+ body: JSON.stringify(body)
3315
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3316
+ }
3317
+ addTags(runId, body, requestOptions) {
3318
+ return zodfetch(z.object({
3319
+ message: z.string()
3320
+ }), `${this.baseUrl}/api/v1/runs/${runId}/tags`, {
3321
+ method: "POST",
3322
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3323
+ body: JSON.stringify(body)
3324
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3051
3325
  }
3052
- createSchedule(options) {
3326
+ createSchedule(options, requestOptions) {
3053
3327
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
3054
3328
  method: "POST",
3055
3329
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3056
3330
  body: JSON.stringify(options)
3057
- });
3331
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3058
3332
  }
3059
- listSchedules(options) {
3333
+ listSchedules(options, requestOptions) {
3060
3334
  const searchParams = new URLSearchParams();
3061
3335
  if (options?.page) {
3062
3336
  searchParams.append("page", options.page.toString());
@@ -3070,84 +3344,77 @@ var _ApiClient = class _ApiClient {
3070
3344
  }, {
3071
3345
  method: "GET",
3072
3346
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3073
- });
3347
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3074
3348
  }
3075
- retrieveSchedule(scheduleId) {
3349
+ retrieveSchedule(scheduleId, requestOptions) {
3076
3350
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
3077
3351
  method: "GET",
3078
3352
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3079
- });
3353
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3080
3354
  }
3081
- updateSchedule(scheduleId, options) {
3355
+ updateSchedule(scheduleId, options, requestOptions) {
3082
3356
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
3083
3357
  method: "PUT",
3084
3358
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3085
3359
  body: JSON.stringify(options)
3086
- });
3360
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3087
3361
  }
3088
- deactivateSchedule(scheduleId) {
3362
+ deactivateSchedule(scheduleId, requestOptions) {
3089
3363
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
3090
3364
  method: "POST",
3091
3365
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3092
- });
3366
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3093
3367
  }
3094
- activateSchedule(scheduleId) {
3368
+ activateSchedule(scheduleId, requestOptions) {
3095
3369
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
3096
3370
  method: "POST",
3097
3371
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3098
- });
3372
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3099
3373
  }
3100
- deleteSchedule(scheduleId) {
3374
+ deleteSchedule(scheduleId, requestOptions) {
3101
3375
  return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
3102
3376
  method: "DELETE",
3103
3377
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3104
- });
3378
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3105
3379
  }
3106
- listEnvVars(projectRef, slug) {
3380
+ listEnvVars(projectRef, slug, requestOptions) {
3107
3381
  return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
3108
3382
  method: "GET",
3109
3383
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3110
- });
3384
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3111
3385
  }
3112
- importEnvVars(projectRef, slug, body) {
3113
- if (isRecordLike(body.variables)) {
3114
- return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
3115
- method: "POST",
3116
- headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3117
- body: JSON.stringify(body)
3118
- });
3119
- } else {
3120
- return zodupload(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, body, {
3121
- method: "POST",
3122
- headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3123
- });
3124
- }
3386
+ importEnvVars(projectRef, slug, body, requestOptions) {
3387
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
3388
+ method: "POST",
3389
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3390
+ body: JSON.stringify(body)
3391
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3125
3392
  }
3126
- retrieveEnvVar(projectRef, slug, key) {
3393
+ retrieveEnvVar(projectRef, slug, key, requestOptions) {
3127
3394
  return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
3128
3395
  method: "GET",
3129
3396
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3130
- });
3397
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3131
3398
  }
3132
- createEnvVar(projectRef, slug, body) {
3399
+ createEnvVar(projectRef, slug, body, requestOptions) {
3133
3400
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
3134
3401
  method: "POST",
3135
3402
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3136
3403
  body: JSON.stringify(body)
3137
- });
3404
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3138
3405
  }
3139
- updateEnvVar(projectRef, slug, key, body) {
3406
+ updateEnvVar(projectRef, slug, key, body, requestOptions) {
3140
3407
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
3141
3408
  method: "PUT",
3142
3409
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3143
3410
  body: JSON.stringify(body)
3144
- });
3411
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3145
3412
  }
3146
- deleteEnvVar(projectRef, slug, key) {
3413
+ deleteEnvVar(projectRef, slug, key, requestOptions) {
3147
3414
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
3148
3415
  method: "DELETE",
3149
3416
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3150
- });
3417
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3151
3418
  }
3152
3419
  };
3153
3420
  _getHeaders = new WeakSet();
@@ -3183,6 +3450,9 @@ function createSearchQueryForListRuns(query) {
3183
3450
  if (query.bulkAction) {
3184
3451
  searchParams.append("filter[bulkAction]", query.bulkAction);
3185
3452
  }
3453
+ if (query.tag) {
3454
+ searchParams.append("filter[tag]", Array.isArray(query.tag) ? query.tag.join(",") : query.tag);
3455
+ }
3186
3456
  if (query.schedule) {
3187
3457
  searchParams.append("filter[schedule]", query.schedule);
3188
3458
  }
@@ -3202,6 +3472,20 @@ function createSearchQueryForListRuns(query) {
3202
3472
  return searchParams;
3203
3473
  }
3204
3474
  __name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
3475
+ function mergeRequestOptions(defaultOptions, options) {
3476
+ if (!options) {
3477
+ return defaultOptions;
3478
+ }
3479
+ return {
3480
+ ...defaultOptions,
3481
+ ...options,
3482
+ retry: {
3483
+ ...defaultOptions.retry,
3484
+ ...options.retry
3485
+ }
3486
+ };
3487
+ }
3488
+ __name(mergeRequestOptions, "mergeRequestOptions");
3205
3489
  var _SimpleClock = class _SimpleClock {
3206
3490
  preciseNow() {
3207
3491
  const now = new PreciseDate();
@@ -3294,128 +3578,6 @@ function calculateAttributeValueLength(value) {
3294
3578
  return 0;
3295
3579
  }
3296
3580
  __name(calculateAttributeValueLength, "calculateAttributeValueLength");
3297
-
3298
- // src/v3/utils/flattenAttributes.ts
3299
- var NULL_SENTINEL = "$@null((";
3300
- function flattenAttributes(obj, prefix) {
3301
- const result = {};
3302
- if (obj === void 0) {
3303
- return result;
3304
- }
3305
- if (obj === null) {
3306
- result[prefix || ""] = NULL_SENTINEL;
3307
- return result;
3308
- }
3309
- if (typeof obj === "string") {
3310
- result[prefix || ""] = obj;
3311
- return result;
3312
- }
3313
- if (typeof obj === "number") {
3314
- result[prefix || ""] = obj;
3315
- return result;
3316
- }
3317
- if (typeof obj === "boolean") {
3318
- result[prefix || ""] = obj;
3319
- return result;
3320
- }
3321
- for (const [key, value] of Object.entries(obj)) {
3322
- const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
3323
- if (Array.isArray(value)) {
3324
- for (let i = 0; i < value.length; i++) {
3325
- if (typeof value[i] === "object" && value[i] !== null) {
3326
- Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
3327
- } else {
3328
- if (value[i] === null) {
3329
- result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
3330
- } else {
3331
- result[`${newPrefix}.[${i}]`] = value[i];
3332
- }
3333
- }
3334
- }
3335
- } else if (isRecord(value)) {
3336
- Object.assign(result, flattenAttributes(value, newPrefix));
3337
- } else {
3338
- if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
3339
- result[newPrefix] = value;
3340
- } else if (value === null) {
3341
- result[newPrefix] = NULL_SENTINEL;
3342
- }
3343
- }
3344
- }
3345
- return result;
3346
- }
3347
- __name(flattenAttributes, "flattenAttributes");
3348
- function isRecord(value) {
3349
- return value !== null && typeof value === "object" && !Array.isArray(value);
3350
- }
3351
- __name(isRecord, "isRecord");
3352
- function unflattenAttributes(obj) {
3353
- if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
3354
- return obj;
3355
- }
3356
- if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
3357
- return rehydrateNull(obj[""]);
3358
- }
3359
- if (Object.keys(obj).length === 0) {
3360
- return;
3361
- }
3362
- const result = {};
3363
- for (const [key, value] of Object.entries(obj)) {
3364
- const parts = key.split(".").reduce((acc, part) => {
3365
- if (part.includes("[")) {
3366
- const subparts = part.split(/\[|\]/).filter((p) => p !== "");
3367
- acc.push(...subparts);
3368
- } else {
3369
- acc.push(part);
3370
- }
3371
- return acc;
3372
- }, []);
3373
- let current = result;
3374
- for (let i = 0; i < parts.length - 1; i++) {
3375
- const part = parts[i];
3376
- const nextPart = parts[i + 1];
3377
- const isArray = /^\d+$/.test(nextPart);
3378
- if (isArray && !Array.isArray(current[part])) {
3379
- current[part] = [];
3380
- } else if (!isArray && current[part] === void 0) {
3381
- current[part] = {};
3382
- }
3383
- current = current[part];
3384
- }
3385
- const lastPart = parts[parts.length - 1];
3386
- current[lastPart] = rehydrateNull(value);
3387
- }
3388
- if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
3389
- const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
3390
- const arrayResult = Array(maxIndex + 1);
3391
- for (const key in result) {
3392
- arrayResult[parseInt(key)] = result[key];
3393
- }
3394
- return arrayResult;
3395
- }
3396
- return result;
3397
- }
3398
- __name(unflattenAttributes, "unflattenAttributes");
3399
- function primitiveValueOrflattenedAttributes(obj, prefix) {
3400
- if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
3401
- return obj;
3402
- }
3403
- const attributes = flattenAttributes(obj, prefix);
3404
- if (prefix !== void 0 && typeof attributes[prefix] !== "undefined" && attributes[prefix] !== null) {
3405
- return attributes[prefix];
3406
- }
3407
- return attributes;
3408
- }
3409
- __name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
3410
- function rehydrateNull(value) {
3411
- if (value === NULL_SENTINEL) {
3412
- return null;
3413
- }
3414
- return value;
3415
- }
3416
- __name(rehydrateNull, "rehydrateNull");
3417
-
3418
- // src/v3/logger/taskLogger.ts
3419
3581
  var _NoopTaskLogger = class _NoopTaskLogger {
3420
3582
  debug() {
3421
3583
  }
@@ -3513,8 +3675,77 @@ var _NoopRuntimeManager = class _NoopRuntimeManager {
3513
3675
  __name(_NoopRuntimeManager, "NoopRuntimeManager");
3514
3676
  var NoopRuntimeManager = _NoopRuntimeManager;
3515
3677
 
3678
+ // src/v3/usage/noopUsageManager.ts
3679
+ var _NoopUsageManager = class _NoopUsageManager {
3680
+ disable() {
3681
+ }
3682
+ start() {
3683
+ return {
3684
+ sample: () => ({
3685
+ cpuTime: 0,
3686
+ wallTime: 0
3687
+ })
3688
+ };
3689
+ }
3690
+ stop(measurement) {
3691
+ return measurement.sample();
3692
+ }
3693
+ pauseAsync(cb) {
3694
+ return cb();
3695
+ }
3696
+ sample() {
3697
+ return void 0;
3698
+ }
3699
+ };
3700
+ __name(_NoopUsageManager, "NoopUsageManager");
3701
+ var NoopUsageManager = _NoopUsageManager;
3702
+
3703
+ // src/v3/usage/api.ts
3704
+ var API_NAME4 = "usage";
3705
+ var NOOP_USAGE_MANAGER = new NoopUsageManager();
3706
+ var _getUsageManager, getUsageManager_fn;
3707
+ var _UsageAPI = class _UsageAPI {
3708
+ constructor() {
3709
+ __privateAdd(this, _getUsageManager);
3710
+ }
3711
+ static getInstance() {
3712
+ if (!this._instance) {
3713
+ this._instance = new _UsageAPI();
3714
+ }
3715
+ return this._instance;
3716
+ }
3717
+ setGlobalUsageManager(manager) {
3718
+ return registerGlobal(API_NAME4, manager);
3719
+ }
3720
+ disable() {
3721
+ __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).disable();
3722
+ unregisterGlobal(API_NAME4);
3723
+ }
3724
+ start() {
3725
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).start();
3726
+ }
3727
+ stop(measurement) {
3728
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).stop(measurement);
3729
+ }
3730
+ pauseAsync(cb) {
3731
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).pauseAsync(cb);
3732
+ }
3733
+ sample() {
3734
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).sample();
3735
+ }
3736
+ };
3737
+ _getUsageManager = new WeakSet();
3738
+ getUsageManager_fn = /* @__PURE__ */ __name(function() {
3739
+ return getGlobal(API_NAME4) ?? NOOP_USAGE_MANAGER;
3740
+ }, "#getUsageManager");
3741
+ __name(_UsageAPI, "UsageAPI");
3742
+ var UsageAPI = _UsageAPI;
3743
+
3744
+ // src/v3/usage-api.ts
3745
+ var usage = UsageAPI.getInstance();
3746
+
3516
3747
  // src/v3/runtime/index.ts
3517
- var API_NAME4 = "runtime";
3748
+ var API_NAME5 = "runtime";
3518
3749
  var NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
3519
3750
  var _getRuntimeManager, getRuntimeManager_fn;
3520
3751
  var _RuntimeAPI = class _RuntimeAPI {
@@ -3528,28 +3759,28 @@ var _RuntimeAPI = class _RuntimeAPI {
3528
3759
  return this._instance;
3529
3760
  }
3530
3761
  waitForDuration(ms) {
3531
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms);
3762
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms));
3532
3763
  }
3533
3764
  waitUntil(date) {
3534
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date);
3765
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date));
3535
3766
  }
3536
3767
  waitForTask(params) {
3537
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params);
3768
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params));
3538
3769
  }
3539
3770
  waitForBatch(params) {
3540
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params);
3771
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params));
3541
3772
  }
3542
3773
  setGlobalRuntimeManager(runtimeManager) {
3543
- return registerGlobal(API_NAME4, runtimeManager);
3774
+ return registerGlobal(API_NAME5, runtimeManager);
3544
3775
  }
3545
3776
  disable() {
3546
3777
  __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).disable();
3547
- unregisterGlobal(API_NAME4);
3778
+ unregisterGlobal(API_NAME5);
3548
3779
  }
3549
3780
  };
3550
3781
  _getRuntimeManager = new WeakSet();
3551
3782
  getRuntimeManager_fn = /* @__PURE__ */ __name(function() {
3552
- return getGlobal(API_NAME4) ?? NOOP_RUNTIME_MANAGER;
3783
+ return getGlobal(API_NAME5) ?? NOOP_RUNTIME_MANAGER;
3553
3784
  }, "#getRuntimeManager");
3554
3785
  __name(_RuntimeAPI, "RuntimeAPI");
3555
3786
  var RuntimeAPI = _RuntimeAPI;
@@ -3566,7 +3797,7 @@ function getEnvVar(name) {
3566
3797
  __name(getEnvVar, "getEnvVar");
3567
3798
 
3568
3799
  // src/v3/apiClientManager/index.ts
3569
- var API_NAME5 = "api-client";
3800
+ var API_NAME6 = "api-client";
3570
3801
  var _getConfig, getConfig_fn;
3571
3802
  var _APIClientManagerAPI = class _APIClientManagerAPI {
3572
3803
  constructor() {
@@ -3579,10 +3810,10 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
3579
3810
  return this._instance;
3580
3811
  }
3581
3812
  disable() {
3582
- unregisterGlobal(API_NAME5);
3813
+ unregisterGlobal(API_NAME6);
3583
3814
  }
3584
3815
  setGlobalAPIClientConfiguration(config) {
3585
- return registerGlobal(API_NAME5, config);
3816
+ return registerGlobal(API_NAME6, config);
3586
3817
  }
3587
3818
  get baseURL() {
3588
3819
  const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
@@ -3601,7 +3832,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
3601
3832
  };
3602
3833
  _getConfig = new WeakSet();
3603
3834
  getConfig_fn = /* @__PURE__ */ __name(function() {
3604
- return getGlobal(API_NAME5);
3835
+ return getGlobal(API_NAME6);
3605
3836
  }, "#getConfig");
3606
3837
  __name(_APIClientManagerAPI, "APIClientManagerAPI");
3607
3838
  var APIClientManagerAPI = _APIClientManagerAPI;
@@ -3636,7 +3867,7 @@ __name(_NoopTaskCatalog, "NoopTaskCatalog");
3636
3867
  var NoopTaskCatalog = _NoopTaskCatalog;
3637
3868
 
3638
3869
  // src/v3/task-catalog/index.ts
3639
- var API_NAME6 = "task-catalog";
3870
+ var API_NAME7 = "task-catalog";
3640
3871
  var NOOP_TASK_CATALOG = new NoopTaskCatalog();
3641
3872
  var _getCatalog, getCatalog_fn;
3642
3873
  var _TaskCatalogAPI = class _TaskCatalogAPI {
@@ -3650,10 +3881,10 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
3650
3881
  return this._instance;
3651
3882
  }
3652
3883
  setGlobalTaskCatalog(taskCatalog2) {
3653
- return registerGlobal(API_NAME6, taskCatalog2);
3884
+ return registerGlobal(API_NAME7, taskCatalog2);
3654
3885
  }
3655
3886
  disable() {
3656
- unregisterGlobal(API_NAME6);
3887
+ unregisterGlobal(API_NAME7);
3657
3888
  }
3658
3889
  registerTaskMetadata(task) {
3659
3890
  __privateMethod(this, _getCatalog, getCatalog_fn).call(this).registerTaskMetadata(task);
@@ -3679,7 +3910,7 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
3679
3910
  };
3680
3911
  _getCatalog = new WeakSet();
3681
3912
  getCatalog_fn = /* @__PURE__ */ __name(function() {
3682
- return getGlobal(API_NAME6) ?? NOOP_TASK_CATALOG;
3913
+ return getGlobal(API_NAME7) ?? NOOP_TASK_CATALOG;
3683
3914
  }, "#getCatalog");
3684
3915
  __name(_TaskCatalogAPI, "TaskCatalogAPI");
3685
3916
  var TaskCatalogAPI = _TaskCatalogAPI;
@@ -3791,14 +4022,17 @@ var _TriggerTracer = class _TriggerTracer {
3791
4022
  attributes,
3792
4023
  startTime: clock.preciseNow()
3793
4024
  }, parentContext, async (span) => {
3794
- this.tracer.startSpan(name, {
3795
- ...options,
3796
- attributes: {
3797
- ...attributes,
3798
- [SemanticInternalAttributes.SPAN_PARTIAL]: true,
3799
- [SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
3800
- }
3801
- }, parentContext).end();
4025
+ if (taskContext.ctx) {
4026
+ this.tracer.startSpan(name, {
4027
+ ...options,
4028
+ attributes: {
4029
+ ...attributes,
4030
+ [SemanticInternalAttributes.SPAN_PARTIAL]: true,
4031
+ [SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
4032
+ }
4033
+ }, parentContext).end();
4034
+ }
4035
+ const usageMeasurement = usage.start();
3802
4036
  try {
3803
4037
  return await fn(span);
3804
4038
  } catch (e) {
@@ -3810,6 +4044,14 @@ var _TriggerTracer = class _TriggerTracer {
3810
4044
  });
3811
4045
  throw e;
3812
4046
  } finally {
4047
+ if (taskContext.ctx) {
4048
+ const usageSample = usage.stop(usageMeasurement);
4049
+ const machine = taskContext.ctx.machine;
4050
+ span.setAttributes({
4051
+ [SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
4052
+ [SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
4053
+ });
4054
+ }
3813
4055
  span.end(clock.preciseNow());
3814
4056
  }
3815
4057
  });
@@ -4001,12 +4243,6 @@ function omit(obj, ...keys) {
4001
4243
  }
4002
4244
  __name(omit, "omit");
4003
4245
 
4004
- // src/v3/utils/styleAttributes.ts
4005
- function accessoryAttributes(accessory) {
4006
- return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
4007
- }
4008
- __name(accessoryAttributes, "accessoryAttributes");
4009
-
4010
4246
  // src/v3/utils/detectDependencyVersion.ts
4011
4247
  function detectDependencyVersion(dependency) {
4012
4248
  return dependencies[dependency];
@@ -4082,7 +4318,7 @@ async function conditionallyExportPacket(packet, pathPrefix, tracer) {
4082
4318
  return packet;
4083
4319
  }
4084
4320
  __name(conditionallyExportPacket, "conditionallyExportPacket");
4085
- function packetRequiresOffloading(packet) {
4321
+ function packetRequiresOffloading(packet, lengthLimit) {
4086
4322
  if (!packet.data) {
4087
4323
  return {
4088
4324
  needsOffloading: false,
@@ -4091,7 +4327,7 @@ function packetRequiresOffloading(packet) {
4091
4327
  }
4092
4328
  const byteSize = Buffer.byteLength(packet.data, "utf8");
4093
4329
  return {
4094
- needsOffloading: byteSize >= OFFLOAD_IO_PACKET_LENGTH_LIMIT,
4330
+ needsOffloading: byteSize >= (lengthLimit ?? OFFLOAD_IO_PACKET_LENGTH_LIMIT),
4095
4331
  size: byteSize
4096
4332
  };
4097
4333
  }
@@ -4282,6 +4518,6 @@ function safeJsonParse2(value) {
4282
4518
  }
4283
4519
  __name(safeJsonParse2, "safeJsonParse");
4284
4520
 
4285
- export { ApiClient, ApiConnectionError, ApiError, AttemptStatus, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateEnvironmentVariableRequestBody, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, CursorPage, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EnvironmentVariable, EnvironmentVariableResponseBody, EnvironmentVariableValue, EnvironmentVariables, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, ImportEnvironmentVariablesRequestBody, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListRunResponse, ListRunResponseItem, ListScheduleOptions, ListSchedulesResult, Machine, MachineCpu, MachineMemory, NULL_SENTINEL, NotFoundError, OFFLOAD_IO_PACKET_LENGTH_LIMIT, OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_LINK_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OffsetLimitPage, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RetrieveRunResponse, RetryOptions, RunEnvironmentDetails, RunScheduleDetails, RunStatus, ScheduleGenerator, ScheduleObject, ScheduledTaskPayload, SemanticInternalAttributes, SerializedError, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionLazyAttemptPayload, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, UnprocessableEntityError, UpdateEnvironmentVariableRequestBody, UpdateScheduleOptions, WaitReason, WhoAmIResponseSchema, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, clock, conditionallyExportPacket, conditionallyImportPacket, correctErrorStackTrace, createErrorTaskError, createJsonErrorObject, createPacketAttributes, createPacketAttributesAsJson, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, groupTaskMetadataIssuesByTask, imposeAttributeLimits, isCancellationSpanEvent, isExceptionSpanEvent, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseError, parsePacket, prettyPrintPacket, primitiveValueOrflattenedAttributes, runtime, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskCatalog, taskContext, unflattenAttributes, workerToChildMessages };
4521
+ export { AbortTaskRunError, AddTagsRequestBody, ApiClient, ApiConnectionError, ApiError, AttemptStatus, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorSocketData, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateEnvironmentVariableRequestBody, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, CursorPage, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EnvironmentVariable, EnvironmentVariableResponseBody, EnvironmentVariableValue, EnvironmentVariables, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, ImportEnvironmentVariablesRequestBody, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListRunResponse, ListRunResponseItem, ListScheduleOptions, ListSchedulesResult, MachineConfig, MachineCpu, MachineMemory, MachinePreset, MachinePresetName, NULL_SENTINEL, NotFoundError, OFFLOAD_IO_PACKET_LENGTH_LIMIT, OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_LINK_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OffsetLimitPage, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RescheduleRunRequestBody, RetrieveRunResponse, RetryOptions, RunEnvironmentDetails, RunScheduleDetails, RunStatus, RunTags, ScheduleGenerator, ScheduleMetadata, ScheduleObject, ScheduleType, ScheduledTaskPayload, SemanticInternalAttributes, SerializedError, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionLazyAttemptPayload, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunExecutionUsage, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TimezonesResult, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, UnprocessableEntityError, UpdateEnvironmentVariableRequestBody, UpdateScheduleOptions, WaitReason, WhoAmIResponseSchema, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, clock, conditionallyExportPacket, conditionallyImportPacket, correctErrorStackTrace, createErrorTaskError, createJsonErrorObject, createPacketAttributes, createPacketAttributesAsJson, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, groupTaskMetadataIssuesByTask, imposeAttributeLimits, isCancellationSpanEvent, isExceptionSpanEvent, isRequestOptions, logger, mergeRequestOptions, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseError, parsePacket, prettyPrintPacket, primitiveValueOrflattenedAttributes, runtime, sanitizeError, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskCatalog, taskContext, unflattenAttributes, usage, workerToChildMessages };
4286
4522
  //# sourceMappingURL=out.js.map
4287
4523
  //# sourceMappingURL=index.mjs.map