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

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 +143 -4720
  82. package/dist/v3/index.d.ts +143 -4720
  83. package/dist/v3/index.js +837 -624
  84. package/dist/v3/index.js.map +1 -1
  85. package/dist/v3/index.mjs +824 -624
  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 +4741 -0
  104. package/dist/v3/schemas/index.d.ts +4741 -0
  105. package/dist/v3/schemas/index.js +2039 -0
  106. package/dist/v3/schemas/index.js.map +1 -0
  107. package/dist/v3/schemas/index.mjs +1900 -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 +2367 -0
  130. package/dist/v3/utils/ioSerialization.js.map +1 -0
  131. package/dist/v3/utils/ioSerialization.mjs +2358 -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 +719 -279
  154. package/dist/v3/workers/index.js.map +1 -1
  155. package/dist/v3/workers/index.mjs +717 -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 +152 -8
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-20240718194312";
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 [
@@ -641,7 +722,10 @@ var TriggerTaskRequestBody = z.object({
641
722
  concurrencyKey: z.string().optional(),
642
723
  idempotencyKey: z.string().optional(),
643
724
  test: z.boolean().optional(),
644
- payloadType: z.string().optional()
725
+ payloadType: z.string().optional(),
726
+ delay: z.string().or(z.coerce.date()).optional(),
727
+ ttl: z.string().or(z.number().nonnegative().int()).optional(),
728
+ maxAttempts: z.number().int().optional()
645
729
  }).optional()
646
730
  });
647
731
  var TriggerTaskResponse = z.object({
@@ -668,6 +752,9 @@ var GetBatchResponseBody = z.object({
668
752
  ])
669
753
  }))
670
754
  });
755
+ var RescheduleRunRequestBody = z.object({
756
+ delay: z.string().or(z.coerce.date())
757
+ });
671
758
  var GetEnvironmentVariablesResponseBody = z.object({
672
759
  variables: z.record(z.string())
673
760
  });
@@ -700,7 +787,8 @@ var InitializeDeploymentRequestBody = z.object({
700
787
  var DeploymentErrorData = z.object({
701
788
  name: z.string(),
702
789
  message: z.string(),
703
- stack: z.string().optional()
790
+ stack: z.string().optional(),
791
+ stderr: z.string().optional()
704
792
  });
705
793
  var GetDeploymentResponseBody = z.object({
706
794
  id: z.string(),
@@ -738,20 +826,42 @@ var ReplayRunResponse = z.object({
738
826
  var CanceledRunResponse = z.object({
739
827
  id: z.string()
740
828
  });
829
+ var ScheduleType = z.union([
830
+ z.literal("DECLARATIVE"),
831
+ z.literal("IMPERATIVE")
832
+ ]);
741
833
  var ScheduledTaskPayload = z.object({
742
834
  /** The schedule id associated with this run (you can have many schedules for the same task).
743
835
  You can use this to remove the schedule, update it, etc */
744
836
  scheduleId: z.string(),
837
+ /** The type of schedule – `"DECLARATIVE"` or `"IMPERATIVE"`.
838
+ *
839
+ * **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.
840
+ *
841
+ * **IMPERATIVE** – created using the `schedules.create` functions or in the dashboard.
842
+ */
843
+ type: ScheduleType,
745
844
  /** 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. */
845
+ * Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
846
+ *
847
+ * This date is UTC. To output it as a string with a timezone you would do this:
848
+ * ```ts
849
+ * const formatted = payload.timestamp.toLocaleString("en-US", {
850
+ timeZone: payload.timezone,
851
+ });
852
+ ``` */
747
853
  timestamp: z.date(),
748
854
  /** When the task was last run (it has been).
749
- This can be undefined if it's never been run */
855
+ This can be undefined if it's never been run. This date is UTC. */
750
856
  lastTimestamp: z.date().optional(),
751
857
  /** You can optionally provide an external id when creating the schedule.
752
858
  Usually you would use a userId or some other unique identifier.
753
859
  This defaults to undefined if you didn't provide one. */
754
860
  externalId: z.string().optional(),
861
+ /** The IANA timezone the schedule is set to. The default is UTC.
862
+ * You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
863
+ */
864
+ timezone: z.string(),
755
865
  /** The next 5 dates this task is scheduled to run */
756
866
  upcoming: z.array(z.date())
757
867
  });
@@ -775,17 +885,30 @@ var CreateScheduleOptions = z.object({
775
885
 
776
886
  */
777
887
  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.
888
+ /** You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
779
889
  *
780
- * This is useful if you don't want to create duplicate schedules for a user. */
781
- deduplicationKey: z.string().optional(),
890
+ * This is required to prevent you from creating duplicate schedules. */
891
+ deduplicationKey: z.string(),
782
892
  /** Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
783
893
  *
784
894
  * This allows you to have per-user CRON tasks.
785
895
  */
786
- externalId: z.string().optional()
896
+ externalId: z.string().optional(),
897
+ /** Optionally, you can specify a timezone in the IANA format. If unset it will use UTC.
898
+ * If specified then the CRON will be evaluated in that timezone and will respect daylight savings.
899
+ *
900
+ * 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.
901
+ *
902
+ * You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
903
+ *
904
+ * @example "America/New_York", "Europe/London", "Asia/Tokyo", "Africa/Cairo"
905
+ *
906
+ */
907
+ timezone: z.string().optional()
908
+ });
909
+ var UpdateScheduleOptions = CreateScheduleOptions.omit({
910
+ deduplicationKey: true
787
911
  });
788
- var UpdateScheduleOptions = CreateScheduleOptions;
789
912
  var ScheduleGenerator = z.object({
790
913
  type: z.literal("CRON"),
791
914
  expression: z.string(),
@@ -793,11 +916,13 @@ var ScheduleGenerator = z.object({
793
916
  });
794
917
  var ScheduleObject = z.object({
795
918
  id: z.string(),
919
+ type: ScheduleType,
796
920
  task: z.string(),
797
921
  active: z.boolean(),
798
922
  deduplicationKey: z.string().nullish(),
799
923
  externalId: z.string().nullish(),
800
924
  generator: ScheduleGenerator,
925
+ timezone: z.string(),
801
926
  nextRun: z.coerce.date().nullish(),
802
927
  environments: z.array(z.object({
803
928
  id: z.string(),
@@ -820,6 +945,9 @@ var ListScheduleOptions = z.object({
820
945
  page: z.number().optional(),
821
946
  perPage: z.number().optional()
822
947
  });
948
+ var TimezonesResult = z.object({
949
+ timezones: z.array(z.string())
950
+ });
823
951
  var RunStatus = z.enum([
824
952
  /// Task hasn't been deployed yet but is waiting to be executed
825
953
  "WAITING_FOR_DEPLOY",
@@ -842,7 +970,11 @@ var RunStatus = z.enum([
842
970
  /// Task was interrupted during execution, mostly this happens in development environments
843
971
  "INTERRUPTED",
844
972
  /// Task has failed to complete, due to an error in the system
845
- "SYSTEM_FAILURE"
973
+ "SYSTEM_FAILURE",
974
+ /// Task has been scheduled to run at a specific time
975
+ "DELAYED",
976
+ /// Task has expired and won't be executed
977
+ "EXPIRED"
846
978
  ]);
847
979
  var AttemptStatus = z.enum([
848
980
  "PENDING",
@@ -879,12 +1011,17 @@ var CommonRunFields = {
879
1011
  createdAt: z.coerce.date(),
880
1012
  updatedAt: z.coerce.date(),
881
1013
  startedAt: z.coerce.date().optional(),
882
- finishedAt: z.coerce.date().optional()
1014
+ finishedAt: z.coerce.date().optional(),
1015
+ delayedUntil: z.coerce.date().optional(),
1016
+ ttl: z.string().optional(),
1017
+ expiredAt: z.coerce.date().optional()
883
1018
  };
884
1019
  var RetrieveRunResponse = z.object({
885
1020
  ...CommonRunFields,
886
1021
  payload: z.any().optional(),
1022
+ payloadPresignedUrl: z.string().optional(),
887
1023
  output: z.any().optional(),
1024
+ outputPresignedUrl: z.string().optional(),
888
1025
  schedule: RunScheduleDetails.optional(),
889
1026
  attempts: z.array(z.object({
890
1027
  id: z.string(),
@@ -943,7 +1080,7 @@ var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
943
1080
  type: z.literal("SCHEDULE_ATTEMPT"),
944
1081
  image: z.string(),
945
1082
  version: z.string(),
946
- machine: Machine,
1083
+ machine: MachinePreset,
947
1084
  // identifiers
948
1085
  id: z.string().optional(),
949
1086
  envId: z.string(),
@@ -1113,47 +1250,15 @@ var ProdChildToWorkerMessages = {
1113
1250
  id: z.string()
1114
1251
  })
1115
1252
  },
1116
- TASK_RUN_HEARTBEAT: {
1117
- message: z.object({
1118
- version: z.literal("v1").default("v1"),
1119
- id: z.string()
1120
- })
1121
- },
1122
1253
  READY_TO_DISPOSE: {
1123
1254
  message: z.undefined()
1124
1255
  },
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
1256
  WAIT_FOR_DURATION: {
1150
1257
  message: z.object({
1151
1258
  version: z.literal("v1").default("v1"),
1152
1259
  ms: z.number(),
1153
- now: z.number()
1154
- }),
1155
- callback: z.object({
1156
- willCheckpointAndRestore: z.boolean()
1260
+ now: z.number(),
1261
+ waitThresholdInMs: z.number()
1157
1262
  })
1158
1263
  },
1159
1264
  WAIT_FOR_TASK: {
@@ -1232,7 +1337,8 @@ var ProviderToPlatformMessages = {
1232
1337
  reason: z.string().optional(),
1233
1338
  exitCode: z.number().optional(),
1234
1339
  message: z.string().optional(),
1235
- logs: z.string().optional()
1340
+ logs: z.string().optional(),
1341
+ overrideCompletion: z.boolean().optional()
1236
1342
  })
1237
1343
  },
1238
1344
  INDEXING_FAILED: {
@@ -1242,20 +1348,14 @@ var ProviderToPlatformMessages = {
1242
1348
  error: z.object({
1243
1349
  name: z.string(),
1244
1350
  message: z.string(),
1245
- stack: z.string().optional()
1246
- })
1351
+ stack: z.string().optional(),
1352
+ stderr: z.string().optional()
1353
+ }),
1354
+ overrideCompletion: z.boolean().optional()
1247
1355
  })
1248
1356
  }
1249
1357
  };
1250
1358
  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
1359
  INDEX: {
1260
1360
  message: z.object({
1261
1361
  version: z.literal("v1").default("v1"),
@@ -1276,7 +1376,8 @@ var PlatformToProviderMessages = {
1276
1376
  error: z.object({
1277
1377
  name: z.string(),
1278
1378
  message: z.string(),
1279
- stack: z.string().optional()
1379
+ stack: z.string().optional(),
1380
+ stderr: z.string().optional()
1280
1381
  })
1281
1382
  }),
1282
1383
  z.object({
@@ -1284,7 +1385,6 @@ var PlatformToProviderMessages = {
1284
1385
  })
1285
1386
  ])
1286
1387
  },
1287
- // TODO: this should be a shared queue message instead
1288
1388
  RESTORE: {
1289
1389
  message: z.object({
1290
1390
  version: z.literal("v1").default("v1"),
@@ -1295,7 +1395,7 @@ var PlatformToProviderMessages = {
1295
1395
  location: z.string(),
1296
1396
  reason: z.string().optional(),
1297
1397
  imageRef: z.string(),
1298
- machine: Machine,
1398
+ machine: MachinePreset,
1299
1399
  // identifiers
1300
1400
  checkpointId: z.string(),
1301
1401
  envId: z.string(),
@@ -1304,21 +1404,6 @@ var PlatformToProviderMessages = {
1304
1404
  projectId: z.string(),
1305
1405
  runId: z.string()
1306
1406
  })
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
1407
  }
1323
1408
  };
1324
1409
  var CreateWorkerMessage = z.object({
@@ -1376,6 +1461,7 @@ var CoordinatorToPlatformMessages = {
1376
1461
  })
1377
1462
  ])
1378
1463
  },
1464
+ // Deprecated: Only workers without lazy attempt support will use this
1379
1465
  READY_FOR_EXECUTION: {
1380
1466
  message: z.object({
1381
1467
  version: z.literal("v1").default("v1"),
@@ -1472,6 +1558,10 @@ var CoordinatorToPlatformMessages = {
1472
1558
  attemptNumber: z.number()
1473
1559
  })
1474
1560
  ])
1561
+ }),
1562
+ callback: z.object({
1563
+ version: z.literal("v1").default("v1"),
1564
+ keepRunAlive: z.boolean()
1475
1565
  })
1476
1566
  },
1477
1567
  INDEXING_FAILED: {
@@ -1481,7 +1571,8 @@ var CoordinatorToPlatformMessages = {
1481
1571
  error: z.object({
1482
1572
  name: z.string(),
1483
1573
  message: z.string(),
1484
- stack: z.string().optional()
1574
+ stack: z.string().optional(),
1575
+ stderr: z.string().optional()
1485
1576
  })
1486
1577
  })
1487
1578
  },
@@ -1534,6 +1625,12 @@ var PlatformToCoordinatorMessages = {
1534
1625
  version: z.literal("v1").default("v1"),
1535
1626
  runId: z.string()
1536
1627
  })
1628
+ },
1629
+ DYNAMIC_CONFIG: {
1630
+ message: z.object({
1631
+ version: z.literal("v1").default("v1"),
1632
+ checkpointThresholdInMs: z.number()
1633
+ })
1537
1634
  }
1538
1635
  };
1539
1636
  var ClientToSharedQueueMessages = {
@@ -1579,10 +1676,9 @@ var IndexTasksMessage = z.object({
1579
1676
  packageVersion: z.string()
1580
1677
  });
1581
1678
  var ProdWorkerToCoordinatorMessages = {
1582
- LOG: {
1679
+ TEST: {
1583
1680
  message: z.object({
1584
- version: z.literal("v1").default("v1"),
1585
- text: z.string()
1681
+ version: z.literal("v1").default("v1")
1586
1682
  }),
1587
1683
  callback: z.void()
1588
1684
  },
@@ -1605,6 +1701,7 @@ var ProdWorkerToCoordinatorMessages = {
1605
1701
  })
1606
1702
  ])
1607
1703
  },
1704
+ // Deprecated: Only workers without lazy attempt support will use this
1608
1705
  READY_FOR_EXECUTION: {
1609
1706
  message: z.object({
1610
1707
  version: z.literal("v1").default("v1"),
@@ -1691,7 +1788,10 @@ var ProdWorkerToCoordinatorMessages = {
1691
1788
  },
1692
1789
  WAIT_FOR_TASK: {
1693
1790
  message: z.object({
1694
- version: z.literal("v1").default("v1"),
1791
+ version: z.enum([
1792
+ "v1",
1793
+ "v2"
1794
+ ]).default("v1"),
1695
1795
  friendlyId: z.string(),
1696
1796
  // This is the attempt that is waiting
1697
1797
  attemptFriendlyId: z.string()
@@ -1702,7 +1802,10 @@ var ProdWorkerToCoordinatorMessages = {
1702
1802
  },
1703
1803
  WAIT_FOR_BATCH: {
1704
1804
  message: z.object({
1705
- version: z.literal("v1").default("v1"),
1805
+ version: z.enum([
1806
+ "v1",
1807
+ "v2"
1808
+ ]).default("v1"),
1706
1809
  batchFriendlyId: z.string(),
1707
1810
  runFriendlyIds: z.string().array(),
1708
1811
  // This is the attempt that is waiting
@@ -1719,7 +1822,8 @@ var ProdWorkerToCoordinatorMessages = {
1719
1822
  error: z.object({
1720
1823
  name: z.string(),
1721
1824
  message: z.string(),
1722
- stack: z.string().optional()
1825
+ stack: z.string().optional(),
1826
+ stderr: z.string().optional()
1723
1827
  })
1724
1828
  })
1725
1829
  },
@@ -1748,6 +1852,12 @@ var ProdWorkerToCoordinatorMessages = {
1748
1852
  stack: z.string().optional()
1749
1853
  })
1750
1854
  })
1855
+ },
1856
+ SET_STATE: {
1857
+ message: z.object({
1858
+ version: z.literal("v1").default("v1"),
1859
+ attemptFriendlyId: z.string().optional()
1860
+ })
1751
1861
  }
1752
1862
  };
1753
1863
  var CoordinatorToProdWorkerMessages = {
@@ -1765,6 +1875,7 @@ var CoordinatorToProdWorkerMessages = {
1765
1875
  attemptId: z.string()
1766
1876
  })
1767
1877
  },
1878
+ // Deprecated: Only workers without lazy attempt support will use this
1768
1879
  EXECUTE_TASK_RUN: {
1769
1880
  message: z.object({
1770
1881
  version: z.literal("v1").default("v1"),
@@ -1811,6 +1922,9 @@ var ProdWorkerSocketData = z.object({
1811
1922
  deploymentId: z.string(),
1812
1923
  deploymentVersion: z.string()
1813
1924
  });
1925
+ var CoordinatorSocketData = z.object({
1926
+ supportsDynamicConfig: z.string().optional()
1927
+ });
1814
1928
  var PRIMARY_VARIANT = "primary";
1815
1929
  var Variant = z.enum([
1816
1930
  PRIMARY_VARIANT
@@ -2058,6 +2172,10 @@ var SemanticInternalAttributes = {
2058
2172
  TASK_EXPORT_NAME: "ctx.task.exportName",
2059
2173
  QUEUE_NAME: "ctx.queue.name",
2060
2174
  QUEUE_ID: "ctx.queue.id",
2175
+ MACHINE_PRESET_NAME: "ctx.machine.name",
2176
+ MACHINE_PRESET_CPU: "ctx.machine.cpu",
2177
+ MACHINE_PRESET_MEMORY: "ctx.machine.memory",
2178
+ MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
2061
2179
  SPAN_PARTIAL: "$span.partial",
2062
2180
  SPAN_ID: "$span.span_id",
2063
2181
  OUTPUT: "$output",
@@ -2081,7 +2199,12 @@ var SemanticInternalAttributes = {
2081
2199
  RETRY_DELAY: "retry.delay",
2082
2200
  RETRY_COUNT: "retry.count",
2083
2201
  LINK_TITLE: "$link.title",
2084
- IDEMPOTENCY_KEY: "ctx.run.idempotencyKey"
2202
+ IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
2203
+ USAGE_DURATION_MS: "$usage.durationMs",
2204
+ USAGE_COST_IN_CENTS: "$usage.costInCents",
2205
+ RATE_LIMIT_LIMIT: "response.rateLimit.limit",
2206
+ RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
2207
+ RATE_LIMIT_RESET: "response.rateLimit.reset"
2085
2208
  };
2086
2209
 
2087
2210
  // src/v3/taskContext/index.ts
@@ -2145,7 +2268,11 @@ var _TaskContextAPI = class _TaskContextAPI {
2145
2268
  [SemanticInternalAttributes.ORGANIZATION_SLUG]: this.ctx.organization.slug,
2146
2269
  [SemanticInternalAttributes.ORGANIZATION_NAME]: this.ctx.organization.name,
2147
2270
  [SemanticInternalAttributes.BATCH_ID]: this.ctx.batch?.id,
2148
- [SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey
2271
+ [SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey,
2272
+ [SemanticInternalAttributes.MACHINE_PRESET_NAME]: this.ctx.machine?.name,
2273
+ [SemanticInternalAttributes.MACHINE_PRESET_CPU]: this.ctx.machine?.cpu,
2274
+ [SemanticInternalAttributes.MACHINE_PRESET_MEMORY]: this.ctx.machine?.memory,
2275
+ [SemanticInternalAttributes.MACHINE_PRESET_CENTS_PER_MS]: this.ctx.machine?.centsPerMs
2149
2276
  };
2150
2277
  }
2151
2278
  return {};
@@ -2167,160 +2294,22 @@ var TaskContextAPI = _TaskContextAPI;
2167
2294
  // src/v3/task-context-api.ts
2168
2295
  var taskContext = TaskContextAPI.getInstance();
2169
2296
 
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);
2297
+ // src/retry.ts
2298
+ function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
2299
+ if (!resets)
2300
+ return;
2301
+ switch (format) {
2302
+ case "iso_8601_duration_openai_variant": {
2303
+ return calculateISO8601DurationOpenAIVariantResetAt(resets, now);
2216
2304
  }
2217
- if (status === 422) {
2218
- return new UnprocessableEntityError(status, error, message, headers);
2305
+ case "iso_8601": {
2306
+ return calculateISO8601ResetAt(resets, now);
2219
2307
  }
2220
- if (status === 429) {
2221
- return new RateLimitError(status, error, message, headers);
2308
+ case "unix_timestamp": {
2309
+ return calculateUnixTimestampResetAt(resets, now);
2222
2310
  }
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);
2311
+ case "unix_timestamp_in_ms": {
2312
+ return calculateUnixTimestampInMsResetAt(resets, now);
2324
2313
  }
2325
2314
  }
2326
2315
  }
@@ -2400,17 +2389,292 @@ function calculateNextRetryDelay(options, attempt) {
2400
2389
  if (attempt >= opts.maxAttempts) {
2401
2390
  return;
2402
2391
  }
2403
- const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
2404
- const random = randomize ? Math.random() + 1 : 1;
2405
- const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
2406
- return Math.round(timeout);
2392
+ const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
2393
+ const random = randomize ? Math.random() + 1 : 1;
2394
+ const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
2395
+ return Math.round(timeout);
2396
+ }
2397
+ __name(calculateNextRetryDelay, "calculateNextRetryDelay");
2398
+ function calculateResetAt2(resets, format, now = Date.now()) {
2399
+ const resetAt = calculateResetAt(resets, format, new Date(now));
2400
+ return resetAt?.getTime();
2401
+ }
2402
+ __name(calculateResetAt2, "calculateResetAt");
2403
+
2404
+ // src/v3/apiClient/errors.ts
2405
+ var _ApiError = class _ApiError extends Error {
2406
+ constructor(status, error, message, headers) {
2407
+ super(`${_ApiError.makeMessage(status, error, message)}`);
2408
+ this.name = "TriggerApiError";
2409
+ this.status = status;
2410
+ this.headers = headers;
2411
+ const data = error;
2412
+ this.error = data;
2413
+ this.code = data?.["code"];
2414
+ this.param = data?.["param"];
2415
+ this.type = data?.["type"];
2416
+ }
2417
+ static makeMessage(status, error, message) {
2418
+ const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
2419
+ if (status && msg) {
2420
+ return `${status} ${msg}`;
2421
+ }
2422
+ if (status) {
2423
+ return `${status} status code (no body)`;
2424
+ }
2425
+ if (msg) {
2426
+ return msg;
2427
+ }
2428
+ return "(no status code or body)";
2429
+ }
2430
+ static generate(status, errorResponse, message, headers) {
2431
+ if (!status) {
2432
+ return new ApiConnectionError({
2433
+ cause: castToError(errorResponse)
2434
+ });
2435
+ }
2436
+ const error = errorResponse?.["error"];
2437
+ if (status === 400) {
2438
+ return new BadRequestError(status, error, message, headers);
2439
+ }
2440
+ if (status === 401) {
2441
+ return new AuthenticationError(status, error, message, headers);
2442
+ }
2443
+ if (status === 403) {
2444
+ return new PermissionDeniedError(status, error, message, headers);
2445
+ }
2446
+ if (status === 404) {
2447
+ return new NotFoundError(status, error, message, headers);
2448
+ }
2449
+ if (status === 409) {
2450
+ return new ConflictError(status, error, message, headers);
2451
+ }
2452
+ if (status === 422) {
2453
+ return new UnprocessableEntityError(status, error, message, headers);
2454
+ }
2455
+ if (status === 429) {
2456
+ return new RateLimitError(status, error, message, headers);
2457
+ }
2458
+ if (status >= 500) {
2459
+ return new InternalServerError(status, error, message, headers);
2460
+ }
2461
+ return new _ApiError(status, error, message, headers);
2462
+ }
2463
+ };
2464
+ __name(_ApiError, "ApiError");
2465
+ var ApiError = _ApiError;
2466
+ var _ApiConnectionError = class _ApiConnectionError extends ApiError {
2467
+ constructor({ message, cause }) {
2468
+ super(void 0, void 0, message || "Connection error.", void 0);
2469
+ __publicField(this, "status");
2470
+ if (cause)
2471
+ this.cause = cause;
2472
+ }
2473
+ };
2474
+ __name(_ApiConnectionError, "ApiConnectionError");
2475
+ var ApiConnectionError = _ApiConnectionError;
2476
+ var _BadRequestError = class _BadRequestError extends ApiError {
2477
+ constructor() {
2478
+ super(...arguments);
2479
+ __publicField(this, "status", 400);
2480
+ }
2481
+ };
2482
+ __name(_BadRequestError, "BadRequestError");
2483
+ var BadRequestError = _BadRequestError;
2484
+ var _AuthenticationError = class _AuthenticationError extends ApiError {
2485
+ constructor() {
2486
+ super(...arguments);
2487
+ __publicField(this, "status", 401);
2488
+ }
2489
+ };
2490
+ __name(_AuthenticationError, "AuthenticationError");
2491
+ var AuthenticationError = _AuthenticationError;
2492
+ var _PermissionDeniedError = class _PermissionDeniedError extends ApiError {
2493
+ constructor() {
2494
+ super(...arguments);
2495
+ __publicField(this, "status", 403);
2496
+ }
2497
+ };
2498
+ __name(_PermissionDeniedError, "PermissionDeniedError");
2499
+ var PermissionDeniedError = _PermissionDeniedError;
2500
+ var _NotFoundError = class _NotFoundError extends ApiError {
2501
+ constructor() {
2502
+ super(...arguments);
2503
+ __publicField(this, "status", 404);
2504
+ }
2505
+ };
2506
+ __name(_NotFoundError, "NotFoundError");
2507
+ var NotFoundError = _NotFoundError;
2508
+ var _ConflictError = class _ConflictError extends ApiError {
2509
+ constructor() {
2510
+ super(...arguments);
2511
+ __publicField(this, "status", 409);
2512
+ }
2513
+ };
2514
+ __name(_ConflictError, "ConflictError");
2515
+ var ConflictError = _ConflictError;
2516
+ var _UnprocessableEntityError = class _UnprocessableEntityError extends ApiError {
2517
+ constructor() {
2518
+ super(...arguments);
2519
+ __publicField(this, "status", 422);
2520
+ }
2521
+ };
2522
+ __name(_UnprocessableEntityError, "UnprocessableEntityError");
2523
+ var UnprocessableEntityError = _UnprocessableEntityError;
2524
+ var _RateLimitError = class _RateLimitError extends ApiError {
2525
+ constructor() {
2526
+ super(...arguments);
2527
+ __publicField(this, "status", 429);
2528
+ }
2529
+ get millisecondsUntilReset() {
2530
+ const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
2531
+ if (typeof resetAtUnixEpochMs === "string") {
2532
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
2533
+ if (isNaN(resetAtUnixEpoch)) {
2534
+ return;
2535
+ }
2536
+ return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
2537
+ }
2538
+ }
2539
+ };
2540
+ __name(_RateLimitError, "RateLimitError");
2541
+ var RateLimitError = _RateLimitError;
2542
+ var _InternalServerError = class _InternalServerError extends ApiError {
2543
+ };
2544
+ __name(_InternalServerError, "InternalServerError");
2545
+ var InternalServerError = _InternalServerError;
2546
+ function castToError(err) {
2547
+ if (err instanceof Error)
2548
+ return err;
2549
+ return new Error(err);
2550
+ }
2551
+ __name(castToError, "castToError");
2552
+
2553
+ // src/v3/utils/flattenAttributes.ts
2554
+ var NULL_SENTINEL = "$@null((";
2555
+ function flattenAttributes(obj, prefix) {
2556
+ const result = {};
2557
+ if (obj === void 0) {
2558
+ return result;
2559
+ }
2560
+ if (obj === null) {
2561
+ result[prefix || ""] = NULL_SENTINEL;
2562
+ return result;
2563
+ }
2564
+ if (typeof obj === "string") {
2565
+ result[prefix || ""] = obj;
2566
+ return result;
2567
+ }
2568
+ if (typeof obj === "number") {
2569
+ result[prefix || ""] = obj;
2570
+ return result;
2571
+ }
2572
+ if (typeof obj === "boolean") {
2573
+ result[prefix || ""] = obj;
2574
+ return result;
2575
+ }
2576
+ for (const [key, value] of Object.entries(obj)) {
2577
+ const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
2578
+ if (Array.isArray(value)) {
2579
+ for (let i = 0; i < value.length; i++) {
2580
+ if (typeof value[i] === "object" && value[i] !== null) {
2581
+ Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
2582
+ } else {
2583
+ if (value[i] === null) {
2584
+ result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
2585
+ } else {
2586
+ result[`${newPrefix}.[${i}]`] = value[i];
2587
+ }
2588
+ }
2589
+ }
2590
+ } else if (isRecord(value)) {
2591
+ Object.assign(result, flattenAttributes(value, newPrefix));
2592
+ } else {
2593
+ if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
2594
+ result[newPrefix] = value;
2595
+ } else if (value === null) {
2596
+ result[newPrefix] = NULL_SENTINEL;
2597
+ }
2598
+ }
2599
+ }
2600
+ return result;
2601
+ }
2602
+ __name(flattenAttributes, "flattenAttributes");
2603
+ function isRecord(value) {
2604
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2605
+ }
2606
+ __name(isRecord, "isRecord");
2607
+ function unflattenAttributes(obj) {
2608
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
2609
+ return obj;
2610
+ }
2611
+ if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
2612
+ return rehydrateNull(obj[""]);
2613
+ }
2614
+ if (Object.keys(obj).length === 0) {
2615
+ return;
2616
+ }
2617
+ const result = {};
2618
+ for (const [key, value] of Object.entries(obj)) {
2619
+ const parts = key.split(".").reduce((acc, part) => {
2620
+ if (part.includes("[")) {
2621
+ const subparts = part.split(/\[|\]/).filter((p) => p !== "");
2622
+ acc.push(...subparts);
2623
+ } else {
2624
+ acc.push(part);
2625
+ }
2626
+ return acc;
2627
+ }, []);
2628
+ let current = result;
2629
+ for (let i = 0; i < parts.length - 1; i++) {
2630
+ const part = parts[i];
2631
+ const nextPart = parts[i + 1];
2632
+ const isArray = /^\d+$/.test(nextPart);
2633
+ if (isArray && !Array.isArray(current[part])) {
2634
+ current[part] = [];
2635
+ } else if (!isArray && current[part] === void 0) {
2636
+ current[part] = {};
2637
+ }
2638
+ current = current[part];
2639
+ }
2640
+ const lastPart = parts[parts.length - 1];
2641
+ current[lastPart] = rehydrateNull(value);
2642
+ }
2643
+ if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
2644
+ const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
2645
+ const arrayResult = Array(maxIndex + 1);
2646
+ for (const key in result) {
2647
+ arrayResult[parseInt(key)] = result[key];
2648
+ }
2649
+ return arrayResult;
2650
+ }
2651
+ return result;
2652
+ }
2653
+ __name(unflattenAttributes, "unflattenAttributes");
2654
+ function primitiveValueOrflattenedAttributes(obj, prefix) {
2655
+ if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
2656
+ return obj;
2657
+ }
2658
+ const attributes = flattenAttributes(obj, prefix);
2659
+ if (prefix !== void 0 && typeof attributes[prefix] !== "undefined" && attributes[prefix] !== null) {
2660
+ return attributes[prefix];
2661
+ }
2662
+ return attributes;
2663
+ }
2664
+ __name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
2665
+ function rehydrateNull(value) {
2666
+ if (value === NULL_SENTINEL) {
2667
+ return null;
2668
+ }
2669
+ return value;
2407
2670
  }
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();
2671
+ __name(rehydrateNull, "rehydrateNull");
2672
+
2673
+ // src/v3/utils/styleAttributes.ts
2674
+ function accessoryAttributes(accessory) {
2675
+ return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
2412
2676
  }
2413
- __name(calculateResetAt2, "calculateResetAt");
2677
+ __name(accessoryAttributes, "accessoryAttributes");
2414
2678
 
2415
2679
  // src/v3/apiClient/pagination.ts
2416
2680
  var _CursorPage = class _CursorPage {
@@ -2520,6 +2784,12 @@ var defaultRetryOptions2 = {
2520
2784
  maxTimeoutInMs: 6e4,
2521
2785
  randomize: false
2522
2786
  };
2787
+ var requestOptionsKeys = {
2788
+ retry: true
2789
+ };
2790
+ var isRequestOptions = /* @__PURE__ */ __name((obj) => {
2791
+ return typeof obj === "object" && obj !== null && !isEmptyObj(obj) && Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k));
2792
+ }, "isRequestOptions");
2523
2793
  function zodfetch(schema, url, requestInit, options) {
2524
2794
  return new ApiPromise(_doZodFetch(schema, url, requestInit, options));
2525
2795
  }
@@ -2570,47 +2840,47 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
2570
2840
  return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
2571
2841
  }
2572
2842
  __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));
2843
+ async function traceZodFetch(params, callback) {
2844
+ if (!params.options?.tracer) {
2845
+ return callback();
2846
+ }
2847
+ const url = new URL(params.url);
2848
+ const method = params.requestInit?.method ?? "GET";
2849
+ const name = params.options.name ?? `${method} ${url.pathname}`;
2850
+ return await params.options.tracer.startActiveSpan(name, async (span) => {
2851
+ return await callback(span);
2852
+ }, {
2853
+ attributes: {
2854
+ [SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
2855
+ ...params.options.attributes
2856
+ }
2857
+ });
2576
2858
  }
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;
2859
+ __name(traceZodFetch, "traceZodFetch");
2860
+ async function _doZodFetch(schema, url, requestInit, options) {
2861
+ const $requestInit = await requestInit;
2862
+ return traceZodFetch({
2863
+ url,
2864
+ requestInit: $requestInit,
2865
+ options
2866
+ }, async (span) => {
2867
+ const result = await _doZodFetchWithRetries(schema, url, $requestInit, options);
2868
+ if (options?.onResponseBody && span) {
2869
+ options.onResponseBody(result.data, span);
2870
+ }
2871
+ return result;
2872
+ });
2597
2873
  }
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) {
2874
+ __name(_doZodFetch, "_doZodFetch");
2875
+ async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
2605
2876
  try {
2606
- const $requestInit = await requestInit;
2607
- const response = await fetch(url, requestInitWithCache($requestInit));
2877
+ const response = await fetch(url, requestInitWithCache(requestInit));
2608
2878
  const responseHeaders = createResponseHeaders(response.headers);
2609
2879
  if (!response.ok) {
2610
2880
  const retryResult = shouldRetry(response, attempt, options?.retry);
2611
2881
  if (retryResult.retry) {
2612
- await new Promise((resolve) => setTimeout(resolve, retryResult.delay));
2613
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
2882
+ await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
2883
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
2614
2884
  } else {
2615
2885
  const errText = await response.text().catch((e) => castToError2(e).message);
2616
2886
  const errJSON = safeJsonParse(errText);
@@ -2638,8 +2908,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2638
2908
  };
2639
2909
  const delay = calculateNextRetryDelay(retry, attempt);
2640
2910
  if (delay) {
2641
- await new Promise((resolve) => setTimeout(resolve, delay));
2642
- return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
2911
+ await waitForRetry(url, attempt + 1, delay, options, requestInit);
2912
+ return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
2643
2913
  }
2644
2914
  }
2645
2915
  throw new ApiConnectionError({
@@ -2647,7 +2917,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2647
2917
  });
2648
2918
  }
2649
2919
  }
2650
- __name(_doZodFetch, "_doZodFetch");
2920
+ __name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
2651
2921
  function castToError2(err) {
2652
2922
  if (err instanceof Error)
2653
2923
  return err;
@@ -2684,8 +2954,25 @@ function shouldRetry(response, attempt, retryOptions) {
2684
2954
  return shouldRetryForOptions();
2685
2955
  if (response.status === 409)
2686
2956
  return shouldRetryForOptions();
2687
- if (response.status === 429)
2957
+ if (response.status === 429) {
2958
+ if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
2959
+ return {
2960
+ retry: false
2961
+ };
2962
+ }
2963
+ const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
2964
+ if (resetAtUnixEpochMs) {
2965
+ const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
2966
+ const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
2967
+ if (delay > 0) {
2968
+ return {
2969
+ retry: true,
2970
+ delay
2971
+ };
2972
+ }
2973
+ }
2688
2974
  return shouldRetryForOptions();
2975
+ }
2689
2976
  if (response.status >= 500)
2690
2977
  return shouldRetryForOptions();
2691
2978
  return {
@@ -2726,95 +3013,6 @@ function requestInitWithCache(requestInit) {
2726
3013
  }
2727
3014
  }
2728
3015
  __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
3016
  var _ApiPromise = class _ApiPromise extends Promise {
2819
3017
  constructor(responsePromise) {
2820
3018
  super((resolve) => {
@@ -2937,9 +3135,44 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
2937
3135
  }, "#fetchPage");
2938
3136
  __name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
2939
3137
  var OffsetLimitPagePromise = _OffsetLimitPagePromise;
3138
+ async function waitForRetry(url, attempt, delay, options, requestInit, response) {
3139
+ if (options?.tracer) {
3140
+ const method = requestInit?.method ?? "GET";
3141
+ return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
3142
+ await new Promise((resolve) => setTimeout(resolve, delay));
3143
+ }, {
3144
+ attributes: {
3145
+ [SemanticInternalAttributes.STYLE_ICON]: "wait",
3146
+ ...accessoryAttributes({
3147
+ items: [
3148
+ {
3149
+ text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
3150
+ variant: "normal"
3151
+ }
3152
+ ],
3153
+ style: "codepath"
3154
+ })
3155
+ }
3156
+ });
3157
+ }
3158
+ await new Promise((resolve) => setTimeout(resolve, delay));
3159
+ }
3160
+ __name(waitForRetry, "waitForRetry");
3161
+ function isEmptyObj(obj) {
3162
+ if (!obj)
3163
+ return true;
3164
+ for (const _k in obj)
3165
+ return false;
3166
+ return true;
3167
+ }
3168
+ __name(isEmptyObj, "isEmptyObj");
3169
+ function hasOwn(obj, key) {
3170
+ return Object.prototype.hasOwnProperty.call(obj, key);
3171
+ }
3172
+ __name(hasOwn, "hasOwn");
2940
3173
 
2941
3174
  // src/v3/apiClient/index.ts
2942
- var zodFetchOptions = {
3175
+ var DEFAULT_ZOD_FETCH_OPTIONS = {
2943
3176
  retry: {
2944
3177
  maxAttempts: 3,
2945
3178
  minTimeoutInMs: 1e3,
@@ -2950,17 +3183,18 @@ var zodFetchOptions = {
2950
3183
  };
2951
3184
  var _getHeaders, getHeaders_fn;
2952
3185
  var _ApiClient = class _ApiClient {
2953
- constructor(baseUrl, accessToken) {
3186
+ constructor(baseUrl, accessToken, requestOptions = {}) {
2954
3187
  __privateAdd(this, _getHeaders);
2955
3188
  this.accessToken = accessToken;
2956
3189
  this.baseUrl = baseUrl.replace(/\/$/, "");
3190
+ this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
2957
3191
  }
2958
- async getRunResult(runId) {
3192
+ async getRunResult(runId, requestOptions) {
2959
3193
  try {
2960
3194
  return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
2961
3195
  method: "GET",
2962
3196
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2963
- }, zodFetchOptions);
3197
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2964
3198
  } catch (error) {
2965
3199
  if (error instanceof ApiError) {
2966
3200
  if (error.status === 404) {
@@ -2970,47 +3204,47 @@ var _ApiClient = class _ApiClient {
2970
3204
  throw error;
2971
3205
  }
2972
3206
  }
2973
- async getBatchResults(batchId) {
3207
+ async getBatchResults(batchId, requestOptions) {
2974
3208
  return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
2975
3209
  method: "GET",
2976
3210
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2977
- }, zodFetchOptions);
3211
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2978
3212
  }
2979
- triggerTask(taskId, body, options) {
3213
+ triggerTask(taskId, body, options, requestOptions) {
2980
3214
  const encodedTaskId = encodeURIComponent(taskId);
2981
3215
  return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
2982
3216
  method: "POST",
2983
3217
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
2984
3218
  body: JSON.stringify(body)
2985
- }, zodFetchOptions);
3219
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2986
3220
  }
2987
- batchTriggerTask(taskId, body, options) {
3221
+ batchTriggerTask(taskId, body, options, requestOptions) {
2988
3222
  const encodedTaskId = encodeURIComponent(taskId);
2989
3223
  return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
2990
3224
  method: "POST",
2991
3225
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
2992
3226
  body: JSON.stringify(body)
2993
- }, zodFetchOptions);
3227
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
2994
3228
  }
2995
- createUploadPayloadUrl(filename) {
3229
+ createUploadPayloadUrl(filename, requestOptions) {
2996
3230
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
2997
3231
  method: "PUT",
2998
3232
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2999
- }, zodFetchOptions);
3233
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3000
3234
  }
3001
- getPayloadUrl(filename) {
3235
+ getPayloadUrl(filename, requestOptions) {
3002
3236
  return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
3003
3237
  method: "GET",
3004
3238
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3005
- }, zodFetchOptions);
3239
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3006
3240
  }
3007
- retrieveRun(runId) {
3241
+ retrieveRun(runId, requestOptions) {
3008
3242
  return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
3009
3243
  method: "GET",
3010
3244
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3011
- }, zodFetchOptions);
3245
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3012
3246
  }
3013
- listRuns(query) {
3247
+ listRuns(query, requestOptions) {
3014
3248
  const searchParams = createSearchQueryForListRuns(query);
3015
3249
  return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
3016
3250
  query: searchParams,
@@ -3020,9 +3254,9 @@ var _ApiClient = class _ApiClient {
3020
3254
  }, {
3021
3255
  method: "GET",
3022
3256
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3023
- }, zodFetchOptions);
3257
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3024
3258
  }
3025
- listProjectRuns(projectRef, query) {
3259
+ listProjectRuns(projectRef, query, requestOptions) {
3026
3260
  const searchParams = createSearchQueryForListRuns(query);
3027
3261
  if (query?.env) {
3028
3262
  searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
@@ -3035,28 +3269,35 @@ var _ApiClient = class _ApiClient {
3035
3269
  }, {
3036
3270
  method: "GET",
3037
3271
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3038
- }, zodFetchOptions);
3272
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3039
3273
  }
3040
- replayRun(runId) {
3274
+ replayRun(runId, requestOptions) {
3041
3275
  return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
3042
3276
  method: "POST",
3043
3277
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3044
- }, zodFetchOptions);
3278
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3045
3279
  }
3046
- cancelRun(runId) {
3280
+ cancelRun(runId, requestOptions) {
3047
3281
  return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
3048
3282
  method: "POST",
3049
3283
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3050
- }, zodFetchOptions);
3284
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3285
+ }
3286
+ rescheduleRun(runId, body, requestOptions) {
3287
+ return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
3288
+ method: "POST",
3289
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3290
+ body: JSON.stringify(body)
3291
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3051
3292
  }
3052
- createSchedule(options) {
3293
+ createSchedule(options, requestOptions) {
3053
3294
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
3054
3295
  method: "POST",
3055
3296
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3056
3297
  body: JSON.stringify(options)
3057
- });
3298
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3058
3299
  }
3059
- listSchedules(options) {
3300
+ listSchedules(options, requestOptions) {
3060
3301
  const searchParams = new URLSearchParams();
3061
3302
  if (options?.page) {
3062
3303
  searchParams.append("page", options.page.toString());
@@ -3070,84 +3311,77 @@ var _ApiClient = class _ApiClient {
3070
3311
  }, {
3071
3312
  method: "GET",
3072
3313
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3073
- });
3314
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3074
3315
  }
3075
- retrieveSchedule(scheduleId) {
3316
+ retrieveSchedule(scheduleId, requestOptions) {
3076
3317
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
3077
3318
  method: "GET",
3078
3319
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3079
- });
3320
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3080
3321
  }
3081
- updateSchedule(scheduleId, options) {
3322
+ updateSchedule(scheduleId, options, requestOptions) {
3082
3323
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
3083
3324
  method: "PUT",
3084
3325
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3085
3326
  body: JSON.stringify(options)
3086
- });
3327
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3087
3328
  }
3088
- deactivateSchedule(scheduleId) {
3329
+ deactivateSchedule(scheduleId, requestOptions) {
3089
3330
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
3090
3331
  method: "POST",
3091
3332
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3092
- });
3333
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3093
3334
  }
3094
- activateSchedule(scheduleId) {
3335
+ activateSchedule(scheduleId, requestOptions) {
3095
3336
  return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
3096
3337
  method: "POST",
3097
3338
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3098
- });
3339
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3099
3340
  }
3100
- deleteSchedule(scheduleId) {
3341
+ deleteSchedule(scheduleId, requestOptions) {
3101
3342
  return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
3102
3343
  method: "DELETE",
3103
3344
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3104
- });
3345
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3105
3346
  }
3106
- listEnvVars(projectRef, slug) {
3347
+ listEnvVars(projectRef, slug, requestOptions) {
3107
3348
  return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
3108
3349
  method: "GET",
3109
3350
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3110
- });
3351
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3111
3352
  }
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
- }
3353
+ importEnvVars(projectRef, slug, body, requestOptions) {
3354
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
3355
+ method: "POST",
3356
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3357
+ body: JSON.stringify(body)
3358
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3125
3359
  }
3126
- retrieveEnvVar(projectRef, slug, key) {
3360
+ retrieveEnvVar(projectRef, slug, key, requestOptions) {
3127
3361
  return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
3128
3362
  method: "GET",
3129
3363
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3130
- });
3364
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3131
3365
  }
3132
- createEnvVar(projectRef, slug, body) {
3366
+ createEnvVar(projectRef, slug, body, requestOptions) {
3133
3367
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
3134
3368
  method: "POST",
3135
3369
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3136
3370
  body: JSON.stringify(body)
3137
- });
3371
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3138
3372
  }
3139
- updateEnvVar(projectRef, slug, key, body) {
3373
+ updateEnvVar(projectRef, slug, key, body, requestOptions) {
3140
3374
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
3141
3375
  method: "PUT",
3142
3376
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
3143
3377
  body: JSON.stringify(body)
3144
- });
3378
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3145
3379
  }
3146
- deleteEnvVar(projectRef, slug, key) {
3380
+ deleteEnvVar(projectRef, slug, key, requestOptions) {
3147
3381
  return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
3148
3382
  method: "DELETE",
3149
3383
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3150
- });
3384
+ }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
3151
3385
  }
3152
3386
  };
3153
3387
  _getHeaders = new WeakSet();
@@ -3202,6 +3436,20 @@ function createSearchQueryForListRuns(query) {
3202
3436
  return searchParams;
3203
3437
  }
3204
3438
  __name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
3439
+ function mergeRequestOptions(defaultOptions, options) {
3440
+ if (!options) {
3441
+ return defaultOptions;
3442
+ }
3443
+ return {
3444
+ ...defaultOptions,
3445
+ ...options,
3446
+ retry: {
3447
+ ...defaultOptions.retry,
3448
+ ...options.retry
3449
+ }
3450
+ };
3451
+ }
3452
+ __name(mergeRequestOptions, "mergeRequestOptions");
3205
3453
  var _SimpleClock = class _SimpleClock {
3206
3454
  preciseNow() {
3207
3455
  const now = new PreciseDate();
@@ -3294,128 +3542,6 @@ function calculateAttributeValueLength(value) {
3294
3542
  return 0;
3295
3543
  }
3296
3544
  __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
3545
  var _NoopTaskLogger = class _NoopTaskLogger {
3420
3546
  debug() {
3421
3547
  }
@@ -3513,8 +3639,77 @@ var _NoopRuntimeManager = class _NoopRuntimeManager {
3513
3639
  __name(_NoopRuntimeManager, "NoopRuntimeManager");
3514
3640
  var NoopRuntimeManager = _NoopRuntimeManager;
3515
3641
 
3642
+ // src/v3/usage/noopUsageManager.ts
3643
+ var _NoopUsageManager = class _NoopUsageManager {
3644
+ disable() {
3645
+ }
3646
+ start() {
3647
+ return {
3648
+ sample: () => ({
3649
+ cpuTime: 0,
3650
+ wallTime: 0
3651
+ })
3652
+ };
3653
+ }
3654
+ stop(measurement) {
3655
+ return measurement.sample();
3656
+ }
3657
+ pauseAsync(cb) {
3658
+ return cb();
3659
+ }
3660
+ sample() {
3661
+ return void 0;
3662
+ }
3663
+ };
3664
+ __name(_NoopUsageManager, "NoopUsageManager");
3665
+ var NoopUsageManager = _NoopUsageManager;
3666
+
3667
+ // src/v3/usage/api.ts
3668
+ var API_NAME4 = "usage";
3669
+ var NOOP_USAGE_MANAGER = new NoopUsageManager();
3670
+ var _getUsageManager, getUsageManager_fn;
3671
+ var _UsageAPI = class _UsageAPI {
3672
+ constructor() {
3673
+ __privateAdd(this, _getUsageManager);
3674
+ }
3675
+ static getInstance() {
3676
+ if (!this._instance) {
3677
+ this._instance = new _UsageAPI();
3678
+ }
3679
+ return this._instance;
3680
+ }
3681
+ setGlobalUsageManager(manager) {
3682
+ return registerGlobal(API_NAME4, manager);
3683
+ }
3684
+ disable() {
3685
+ __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).disable();
3686
+ unregisterGlobal(API_NAME4);
3687
+ }
3688
+ start() {
3689
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).start();
3690
+ }
3691
+ stop(measurement) {
3692
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).stop(measurement);
3693
+ }
3694
+ pauseAsync(cb) {
3695
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).pauseAsync(cb);
3696
+ }
3697
+ sample() {
3698
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).sample();
3699
+ }
3700
+ };
3701
+ _getUsageManager = new WeakSet();
3702
+ getUsageManager_fn = /* @__PURE__ */ __name(function() {
3703
+ return getGlobal(API_NAME4) ?? NOOP_USAGE_MANAGER;
3704
+ }, "#getUsageManager");
3705
+ __name(_UsageAPI, "UsageAPI");
3706
+ var UsageAPI = _UsageAPI;
3707
+
3708
+ // src/v3/usage-api.ts
3709
+ var usage = UsageAPI.getInstance();
3710
+
3516
3711
  // src/v3/runtime/index.ts
3517
- var API_NAME4 = "runtime";
3712
+ var API_NAME5 = "runtime";
3518
3713
  var NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
3519
3714
  var _getRuntimeManager, getRuntimeManager_fn;
3520
3715
  var _RuntimeAPI = class _RuntimeAPI {
@@ -3528,28 +3723,28 @@ var _RuntimeAPI = class _RuntimeAPI {
3528
3723
  return this._instance;
3529
3724
  }
3530
3725
  waitForDuration(ms) {
3531
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms);
3726
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms));
3532
3727
  }
3533
3728
  waitUntil(date) {
3534
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date);
3729
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date));
3535
3730
  }
3536
3731
  waitForTask(params) {
3537
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params);
3732
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params));
3538
3733
  }
3539
3734
  waitForBatch(params) {
3540
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params);
3735
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params));
3541
3736
  }
3542
3737
  setGlobalRuntimeManager(runtimeManager) {
3543
- return registerGlobal(API_NAME4, runtimeManager);
3738
+ return registerGlobal(API_NAME5, runtimeManager);
3544
3739
  }
3545
3740
  disable() {
3546
3741
  __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).disable();
3547
- unregisterGlobal(API_NAME4);
3742
+ unregisterGlobal(API_NAME5);
3548
3743
  }
3549
3744
  };
3550
3745
  _getRuntimeManager = new WeakSet();
3551
3746
  getRuntimeManager_fn = /* @__PURE__ */ __name(function() {
3552
- return getGlobal(API_NAME4) ?? NOOP_RUNTIME_MANAGER;
3747
+ return getGlobal(API_NAME5) ?? NOOP_RUNTIME_MANAGER;
3553
3748
  }, "#getRuntimeManager");
3554
3749
  __name(_RuntimeAPI, "RuntimeAPI");
3555
3750
  var RuntimeAPI = _RuntimeAPI;
@@ -3566,7 +3761,7 @@ function getEnvVar(name) {
3566
3761
  __name(getEnvVar, "getEnvVar");
3567
3762
 
3568
3763
  // src/v3/apiClientManager/index.ts
3569
- var API_NAME5 = "api-client";
3764
+ var API_NAME6 = "api-client";
3570
3765
  var _getConfig, getConfig_fn;
3571
3766
  var _APIClientManagerAPI = class _APIClientManagerAPI {
3572
3767
  constructor() {
@@ -3579,10 +3774,10 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
3579
3774
  return this._instance;
3580
3775
  }
3581
3776
  disable() {
3582
- unregisterGlobal(API_NAME5);
3777
+ unregisterGlobal(API_NAME6);
3583
3778
  }
3584
3779
  setGlobalAPIClientConfiguration(config) {
3585
- return registerGlobal(API_NAME5, config);
3780
+ return registerGlobal(API_NAME6, config);
3586
3781
  }
3587
3782
  get baseURL() {
3588
3783
  const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
@@ -3601,7 +3796,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
3601
3796
  };
3602
3797
  _getConfig = new WeakSet();
3603
3798
  getConfig_fn = /* @__PURE__ */ __name(function() {
3604
- return getGlobal(API_NAME5);
3799
+ return getGlobal(API_NAME6);
3605
3800
  }, "#getConfig");
3606
3801
  __name(_APIClientManagerAPI, "APIClientManagerAPI");
3607
3802
  var APIClientManagerAPI = _APIClientManagerAPI;
@@ -3636,7 +3831,7 @@ __name(_NoopTaskCatalog, "NoopTaskCatalog");
3636
3831
  var NoopTaskCatalog = _NoopTaskCatalog;
3637
3832
 
3638
3833
  // src/v3/task-catalog/index.ts
3639
- var API_NAME6 = "task-catalog";
3834
+ var API_NAME7 = "task-catalog";
3640
3835
  var NOOP_TASK_CATALOG = new NoopTaskCatalog();
3641
3836
  var _getCatalog, getCatalog_fn;
3642
3837
  var _TaskCatalogAPI = class _TaskCatalogAPI {
@@ -3650,10 +3845,10 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
3650
3845
  return this._instance;
3651
3846
  }
3652
3847
  setGlobalTaskCatalog(taskCatalog2) {
3653
- return registerGlobal(API_NAME6, taskCatalog2);
3848
+ return registerGlobal(API_NAME7, taskCatalog2);
3654
3849
  }
3655
3850
  disable() {
3656
- unregisterGlobal(API_NAME6);
3851
+ unregisterGlobal(API_NAME7);
3657
3852
  }
3658
3853
  registerTaskMetadata(task) {
3659
3854
  __privateMethod(this, _getCatalog, getCatalog_fn).call(this).registerTaskMetadata(task);
@@ -3679,7 +3874,7 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
3679
3874
  };
3680
3875
  _getCatalog = new WeakSet();
3681
3876
  getCatalog_fn = /* @__PURE__ */ __name(function() {
3682
- return getGlobal(API_NAME6) ?? NOOP_TASK_CATALOG;
3877
+ return getGlobal(API_NAME7) ?? NOOP_TASK_CATALOG;
3683
3878
  }, "#getCatalog");
3684
3879
  __name(_TaskCatalogAPI, "TaskCatalogAPI");
3685
3880
  var TaskCatalogAPI = _TaskCatalogAPI;
@@ -3791,14 +3986,17 @@ var _TriggerTracer = class _TriggerTracer {
3791
3986
  attributes,
3792
3987
  startTime: clock.preciseNow()
3793
3988
  }, 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();
3989
+ if (taskContext.ctx) {
3990
+ this.tracer.startSpan(name, {
3991
+ ...options,
3992
+ attributes: {
3993
+ ...attributes,
3994
+ [SemanticInternalAttributes.SPAN_PARTIAL]: true,
3995
+ [SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
3996
+ }
3997
+ }, parentContext).end();
3998
+ }
3999
+ const usageMeasurement = usage.start();
3802
4000
  try {
3803
4001
  return await fn(span);
3804
4002
  } catch (e) {
@@ -3810,6 +4008,14 @@ var _TriggerTracer = class _TriggerTracer {
3810
4008
  });
3811
4009
  throw e;
3812
4010
  } finally {
4011
+ if (taskContext.ctx) {
4012
+ const usageSample = usage.stop(usageMeasurement);
4013
+ const machine = taskContext.ctx.machine;
4014
+ span.setAttributes({
4015
+ [SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
4016
+ [SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
4017
+ });
4018
+ }
3813
4019
  span.end(clock.preciseNow());
3814
4020
  }
3815
4021
  });
@@ -4001,12 +4207,6 @@ function omit(obj, ...keys) {
4001
4207
  }
4002
4208
  __name(omit, "omit");
4003
4209
 
4004
- // src/v3/utils/styleAttributes.ts
4005
- function accessoryAttributes(accessory) {
4006
- return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
4007
- }
4008
- __name(accessoryAttributes, "accessoryAttributes");
4009
-
4010
4210
  // src/v3/utils/detectDependencyVersion.ts
4011
4211
  function detectDependencyVersion(dependency) {
4012
4212
  return dependencies[dependency];
@@ -4082,7 +4282,7 @@ async function conditionallyExportPacket(packet, pathPrefix, tracer) {
4082
4282
  return packet;
4083
4283
  }
4084
4284
  __name(conditionallyExportPacket, "conditionallyExportPacket");
4085
- function packetRequiresOffloading(packet) {
4285
+ function packetRequiresOffloading(packet, lengthLimit) {
4086
4286
  if (!packet.data) {
4087
4287
  return {
4088
4288
  needsOffloading: false,
@@ -4091,7 +4291,7 @@ function packetRequiresOffloading(packet) {
4091
4291
  }
4092
4292
  const byteSize = Buffer.byteLength(packet.data, "utf8");
4093
4293
  return {
4094
- needsOffloading: byteSize >= OFFLOAD_IO_PACKET_LENGTH_LIMIT,
4294
+ needsOffloading: byteSize >= (lengthLimit ?? OFFLOAD_IO_PACKET_LENGTH_LIMIT),
4095
4295
  size: byteSize
4096
4296
  };
4097
4297
  }
@@ -4282,6 +4482,6 @@ function safeJsonParse2(value) {
4282
4482
  }
4283
4483
  __name(safeJsonParse2, "safeJsonParse");
4284
4484
 
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 };
4485
+ export { AbortTaskRunError, 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, 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
4486
  //# sourceMappingURL=out.js.map
4287
4487
  //# sourceMappingURL=index.mjs.map