@trigger.dev/core 3.0.0-beta.37 → 3.0.0-beta.38

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 (37) hide show
  1. package/dist/{catalog-dRKTgwQ7.d.ts → catalog-Tdea4K0I.d.mts} +43 -3
  2. package/dist/{catalog-XTlJQaMn.d.mts → catalog-yeAHwmSe.d.ts} +43 -3
  3. package/dist/{manager-JkbddlcO.d.mts → manager-S98VaLUy.d.mts} +244 -1
  4. package/dist/{manager-JkbddlcO.d.ts → manager-S98VaLUy.d.ts} +244 -1
  5. package/dist/{messages-9lty-Du5.d.mts → messages-BD0yXLtn.d.mts} +2370 -141
  6. package/dist/{messages-9lty-Du5.d.ts → messages-BD0yXLtn.d.ts} +2370 -141
  7. package/dist/{schemas-r4ZP9S-F.d.mts → schemas-XNxZYXOy.d.mts} +199 -33
  8. package/dist/{schemas-r4ZP9S-F.d.ts → schemas-XNxZYXOy.d.ts} +199 -33
  9. package/dist/v3/dev/index.d.mts +1 -1
  10. package/dist/v3/dev/index.d.ts +1 -1
  11. package/dist/v3/index.d.mts +117 -52
  12. package/dist/v3/index.d.ts +117 -52
  13. package/dist/v3/index.js +204 -58
  14. package/dist/v3/index.js.map +1 -1
  15. package/dist/v3/index.mjs +199 -58
  16. package/dist/v3/index.mjs.map +1 -1
  17. package/dist/v3/otel/index.js +15 -5
  18. package/dist/v3/otel/index.js.map +1 -1
  19. package/dist/v3/otel/index.mjs +15 -5
  20. package/dist/v3/otel/index.mjs.map +1 -1
  21. package/dist/v3/prod/index.d.mts +2 -2
  22. package/dist/v3/prod/index.d.ts +2 -2
  23. package/dist/v3/prod/index.js.map +1 -1
  24. package/dist/v3/prod/index.mjs.map +1 -1
  25. package/dist/v3/workers/index.d.mts +54 -8
  26. package/dist/v3/workers/index.d.ts +54 -8
  27. package/dist/v3/workers/index.js +404 -43
  28. package/dist/v3/workers/index.js.map +1 -1
  29. package/dist/v3/workers/index.mjs +402 -44
  30. package/dist/v3/workers/index.mjs.map +1 -1
  31. package/dist/v3/zodIpc.js.map +1 -1
  32. package/dist/v3/zodIpc.mjs.map +1 -1
  33. package/dist/v3/zodMessageHandler.d.mts +1 -1
  34. package/dist/v3/zodMessageHandler.d.ts +1 -1
  35. package/dist/v3/zodfetch.d.mts +1 -1
  36. package/dist/v3/zodfetch.d.ts +1 -1
  37. package/package.json +1 -1
package/dist/v3/index.mjs CHANGED
@@ -29,7 +29,7 @@ var __privateMethod = (obj, member, method) => {
29
29
  };
30
30
 
31
31
  // package.json
32
- var version = "3.0.0-beta.37";
32
+ var version = "3.0.0-beta.38";
33
33
  var dependencies = {
34
34
  "@google-cloud/precise-date": "^4.0.0",
35
35
  "@opentelemetry/api": "^1.8.0",
@@ -65,6 +65,41 @@ var GetPersonalAccessTokenResponseSchema = z.object({
65
65
  obfuscatedToken: z.string()
66
66
  }).nullable()
67
67
  });
68
+ var MachineCpu = z.union([
69
+ z.literal(0.25),
70
+ z.literal(0.5),
71
+ z.literal(1),
72
+ z.literal(2),
73
+ z.literal(4)
74
+ ]);
75
+ var MachineMemory = z.union([
76
+ z.literal(0.25),
77
+ z.literal(0.5),
78
+ z.literal(1),
79
+ z.literal(2),
80
+ z.literal(4),
81
+ z.literal(8)
82
+ ]);
83
+ var MachinePresetName = z.enum([
84
+ "micro",
85
+ "small-1x",
86
+ "small-2x",
87
+ "medium-1x",
88
+ "medium-2x",
89
+ "large-1x",
90
+ "large-2x"
91
+ ]);
92
+ var MachineConfig = z.object({
93
+ cpu: MachineCpu.optional(),
94
+ memory: MachineMemory.optional(),
95
+ preset: MachinePresetName.optional()
96
+ });
97
+ var MachinePreset = z.object({
98
+ name: MachinePresetName,
99
+ cpu: z.number(),
100
+ memory: z.number(),
101
+ centsPerMs: z.number()
102
+ });
68
103
  var TaskRunBuiltInError = z.object({
69
104
  type: z.literal("BUILT_IN_ERROR"),
70
105
  name: z.string(),
@@ -126,7 +161,11 @@ var TaskRun = z.object({
126
161
  tags: z.array(z.string()),
127
162
  isTest: z.boolean().default(false),
128
163
  createdAt: z.coerce.date(),
129
- idempotencyKey: z.string().optional()
164
+ startedAt: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
165
+ idempotencyKey: z.string().optional(),
166
+ durationMs: z.number().default(0),
167
+ costInCents: z.number().default(0),
168
+ baseCostInCents: z.number().default(0)
130
169
  });
131
170
  var TaskRunExecutionTask = z.object({
132
171
  id: z.string(),
@@ -177,7 +216,8 @@ var TaskRunExecution = z.object({
177
216
  environment: TaskRunExecutionEnvironment,
178
217
  organization: TaskRunExecutionOrganization,
179
218
  project: TaskRunExecutionProject,
180
- batch: TaskRunExecutionBatch.optional()
219
+ batch: TaskRunExecutionBatch.optional(),
220
+ machine: MachinePreset.optional()
181
221
  });
182
222
  var TaskRunContext = z.object({
183
223
  task: TaskRunExecutionTask,
@@ -193,25 +233,31 @@ var TaskRunContext = z.object({
193
233
  environment: TaskRunExecutionEnvironment,
194
234
  organization: TaskRunExecutionOrganization,
195
235
  project: TaskRunExecutionProject,
196
- batch: TaskRunExecutionBatch.optional()
236
+ batch: TaskRunExecutionBatch.optional(),
237
+ machine: MachinePreset.optional()
197
238
  });
198
239
  var TaskRunExecutionRetry = z.object({
199
240
  timestamp: z.number(),
200
241
  delay: z.number(),
201
242
  error: z.unknown().optional()
202
243
  });
244
+ var TaskRunExecutionUsage = z.object({
245
+ durationMs: z.number()
246
+ });
203
247
  var TaskRunFailedExecutionResult = z.object({
204
248
  ok: z.literal(false),
205
249
  id: z.string(),
206
250
  error: TaskRunError,
207
251
  retry: TaskRunExecutionRetry.optional(),
208
- skippedRetrying: z.boolean().optional()
252
+ skippedRetrying: z.boolean().optional(),
253
+ usage: TaskRunExecutionUsage.optional()
209
254
  });
210
255
  var TaskRunSuccessfulExecutionResult = z.object({
211
256
  ok: z.literal(true),
212
257
  id: z.string(),
213
258
  output: z.string().optional(),
214
- outputType: z.string()
259
+ outputType: z.string(),
260
+ usage: TaskRunExecutionUsage.optional()
215
261
  });
216
262
  var TaskRunExecutionResult = z.discriminatedUnion("ok", [
217
263
  TaskRunSuccessfulExecutionResult,
@@ -229,26 +275,6 @@ var EnvironmentType = z.enum([
229
275
  "DEVELOPMENT",
230
276
  "PREVIEW"
231
277
  ]);
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
278
  var TaskRunExecutionPayload = z.object({
253
279
  execution: TaskRunExecution,
254
280
  traceContext: z.record(z.unknown()),
@@ -259,7 +285,8 @@ var ProdTaskRunExecution = TaskRunExecution.extend({
259
285
  id: z.string(),
260
286
  contentHash: z.string(),
261
287
  version: z.string()
262
- })
288
+ }),
289
+ machine: MachinePreset
263
290
  });
264
291
  var ProdTaskRunExecutionPayload = z.object({
265
292
  execution: ProdTaskRunExecution,
@@ -363,7 +390,7 @@ var TaskMetadata = z.object({
363
390
  packageVersion: z.string(),
364
391
  queue: QueueOptions.optional(),
365
392
  retry: RetryOptions.optional(),
366
- machine: Machine.partial().optional(),
393
+ machine: MachineConfig.optional(),
367
394
  triggerSource: z.string().optional()
368
395
  });
369
396
  var TaskFileMetadata = z.object({
@@ -375,7 +402,7 @@ var TaskMetadataWithFilePath = z.object({
375
402
  packageVersion: z.string(),
376
403
  queue: QueueOptions.optional(),
377
404
  retry: RetryOptions.optional(),
378
- machine: Machine.partial().optional(),
405
+ machine: MachineConfig.optional(),
379
406
  triggerSource: z.string().optional(),
380
407
  filePath: z.string(),
381
408
  exportName: z.string()
@@ -435,7 +462,7 @@ var TaskResource = z.object({
435
462
  exportName: z.string(),
436
463
  queue: QueueOptions.optional(),
437
464
  retry: RetryOptions.optional(),
438
- machine: Machine.partial().optional(),
465
+ machine: MachineConfig.optional(),
439
466
  triggerSource: z.string().optional()
440
467
  });
441
468
  var BackgroundWorkerMetadata = z.object({
@@ -744,15 +771,26 @@ var ScheduledTaskPayload = z.object({
744
771
  You can use this to remove the schedule, update it, etc */
745
772
  scheduleId: z.string(),
746
773
  /** When the task was scheduled to run.
747
- * Note this will be slightly different from `new Date()` because it takes a few ms to run the task. */
774
+ * Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
775
+ *
776
+ * This date is UTC. To output it as a string with a timezone you would do this:
777
+ * ```ts
778
+ * const formatted = payload.timestamp.toLocaleString("en-US", {
779
+ timeZone: payload.timezone,
780
+ });
781
+ ``` */
748
782
  timestamp: z.date(),
749
783
  /** When the task was last run (it has been).
750
- This can be undefined if it's never been run */
784
+ This can be undefined if it's never been run. This date is UTC. */
751
785
  lastTimestamp: z.date().optional(),
752
786
  /** You can optionally provide an external id when creating the schedule.
753
787
  Usually you would use a userId or some other unique identifier.
754
788
  This defaults to undefined if you didn't provide one. */
755
789
  externalId: z.string().optional(),
790
+ /** The IANA timezone the schedule is set to. The default is UTC.
791
+ * You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
792
+ */
793
+ timezone: z.string(),
756
794
  /** The next 5 dates this task is scheduled to run */
757
795
  upcoming: z.array(z.date())
758
796
  });
@@ -776,17 +814,30 @@ var CreateScheduleOptions = z.object({
776
814
 
777
815
  */
778
816
  cron: z.string(),
779
- /** (Optional) You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
817
+ /** You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
780
818
  *
781
- * This is useful if you don't want to create duplicate schedules for a user. */
782
- deduplicationKey: z.string().optional(),
819
+ * This is required to prevent you from creating duplicate schedules. */
820
+ deduplicationKey: z.string(),
783
821
  /** Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
784
822
  *
785
823
  * This allows you to have per-user CRON tasks.
786
824
  */
787
- externalId: z.string().optional()
825
+ externalId: z.string().optional(),
826
+ /** Optionally, you can specify a timezone in the IANA format. If unset it will use UTC.
827
+ * If specified then the CRON will be evaluated in that timezone and will respect daylight savings.
828
+ *
829
+ * 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.
830
+ *
831
+ * You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
832
+ *
833
+ * @example "America/New_York", "Europe/London", "Asia/Tokyo", "Africa/Cairo"
834
+ *
835
+ */
836
+ timezone: z.string().optional()
837
+ });
838
+ var UpdateScheduleOptions = CreateScheduleOptions.omit({
839
+ deduplicationKey: true
788
840
  });
789
- var UpdateScheduleOptions = CreateScheduleOptions;
790
841
  var ScheduleGenerator = z.object({
791
842
  type: z.literal("CRON"),
792
843
  expression: z.string(),
@@ -799,6 +850,7 @@ var ScheduleObject = z.object({
799
850
  deduplicationKey: z.string().nullish(),
800
851
  externalId: z.string().nullish(),
801
852
  generator: ScheduleGenerator,
853
+ timezone: z.string(),
802
854
  nextRun: z.coerce.date().nullish(),
803
855
  environments: z.array(z.object({
804
856
  id: z.string(),
@@ -821,6 +873,9 @@ var ListScheduleOptions = z.object({
821
873
  page: z.number().optional(),
822
874
  perPage: z.number().optional()
823
875
  });
876
+ var TimezonesResult = z.object({
877
+ timezones: z.array(z.string())
878
+ });
824
879
  var RunStatus = z.enum([
825
880
  /// Task hasn't been deployed yet but is waiting to be executed
826
881
  "WAITING_FOR_DEPLOY",
@@ -944,7 +999,7 @@ var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
944
999
  type: z.literal("SCHEDULE_ATTEMPT"),
945
1000
  image: z.string(),
946
1001
  version: z.string(),
947
- machine: Machine,
1002
+ machine: MachinePreset,
948
1003
  // identifiers
949
1004
  id: z.string().optional(),
950
1005
  envId: z.string(),
@@ -1289,7 +1344,7 @@ var PlatformToProviderMessages = {
1289
1344
  location: z.string(),
1290
1345
  reason: z.string().optional(),
1291
1346
  imageRef: z.string(),
1292
- machine: Machine,
1347
+ machine: MachinePreset,
1293
1348
  // identifiers
1294
1349
  checkpointId: z.string(),
1295
1350
  envId: z.string(),
@@ -2039,6 +2094,10 @@ var SemanticInternalAttributes = {
2039
2094
  TASK_EXPORT_NAME: "ctx.task.exportName",
2040
2095
  QUEUE_NAME: "ctx.queue.name",
2041
2096
  QUEUE_ID: "ctx.queue.id",
2097
+ MACHINE_PRESET_NAME: "ctx.machine.name",
2098
+ MACHINE_PRESET_CPU: "ctx.machine.cpu",
2099
+ MACHINE_PRESET_MEMORY: "ctx.machine.memory",
2100
+ MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
2042
2101
  SPAN_PARTIAL: "$span.partial",
2043
2102
  SPAN_ID: "$span.span_id",
2044
2103
  OUTPUT: "$output",
@@ -2062,7 +2121,9 @@ var SemanticInternalAttributes = {
2062
2121
  RETRY_DELAY: "retry.delay",
2063
2122
  RETRY_COUNT: "retry.count",
2064
2123
  LINK_TITLE: "$link.title",
2065
- IDEMPOTENCY_KEY: "ctx.run.idempotencyKey"
2124
+ IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
2125
+ USAGE_DURATION_MS: "$usage.durationMs",
2126
+ USAGE_COST_IN_CENTS: "$usage.costInCents"
2066
2127
  };
2067
2128
 
2068
2129
  // src/v3/taskContext/index.ts
@@ -2126,7 +2187,11 @@ var _TaskContextAPI = class _TaskContextAPI {
2126
2187
  [SemanticInternalAttributes.ORGANIZATION_SLUG]: this.ctx.organization.slug,
2127
2188
  [SemanticInternalAttributes.ORGANIZATION_NAME]: this.ctx.organization.name,
2128
2189
  [SemanticInternalAttributes.BATCH_ID]: this.ctx.batch?.id,
2129
- [SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey
2190
+ [SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey,
2191
+ [SemanticInternalAttributes.MACHINE_PRESET_NAME]: this.ctx.machine?.name,
2192
+ [SemanticInternalAttributes.MACHINE_PRESET_CPU]: this.ctx.machine?.cpu,
2193
+ [SemanticInternalAttributes.MACHINE_PRESET_MEMORY]: this.ctx.machine?.memory,
2194
+ [SemanticInternalAttributes.MACHINE_PRESET_CENTS_PER_MS]: this.ctx.machine?.centsPerMs
2130
2195
  };
2131
2196
  }
2132
2197
  return {};
@@ -3494,8 +3559,77 @@ var _NoopRuntimeManager = class _NoopRuntimeManager {
3494
3559
  __name(_NoopRuntimeManager, "NoopRuntimeManager");
3495
3560
  var NoopRuntimeManager = _NoopRuntimeManager;
3496
3561
 
3562
+ // src/v3/usage/noopUsageManager.ts
3563
+ var _NoopUsageManager = class _NoopUsageManager {
3564
+ disable() {
3565
+ }
3566
+ start() {
3567
+ return {
3568
+ sample: () => ({
3569
+ cpuTime: 0,
3570
+ wallTime: 0
3571
+ })
3572
+ };
3573
+ }
3574
+ stop(measurement) {
3575
+ return measurement.sample();
3576
+ }
3577
+ pauseAsync(cb) {
3578
+ return cb();
3579
+ }
3580
+ sample() {
3581
+ return void 0;
3582
+ }
3583
+ };
3584
+ __name(_NoopUsageManager, "NoopUsageManager");
3585
+ var NoopUsageManager = _NoopUsageManager;
3586
+
3587
+ // src/v3/usage/api.ts
3588
+ var API_NAME4 = "usage";
3589
+ var NOOP_USAGE_MANAGER = new NoopUsageManager();
3590
+ var _getUsageManager, getUsageManager_fn;
3591
+ var _UsageAPI = class _UsageAPI {
3592
+ constructor() {
3593
+ __privateAdd(this, _getUsageManager);
3594
+ }
3595
+ static getInstance() {
3596
+ if (!this._instance) {
3597
+ this._instance = new _UsageAPI();
3598
+ }
3599
+ return this._instance;
3600
+ }
3601
+ setGlobalUsageManager(manager) {
3602
+ return registerGlobal(API_NAME4, manager);
3603
+ }
3604
+ disable() {
3605
+ __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).disable();
3606
+ unregisterGlobal(API_NAME4);
3607
+ }
3608
+ start() {
3609
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).start();
3610
+ }
3611
+ stop(measurement) {
3612
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).stop(measurement);
3613
+ }
3614
+ pauseAsync(cb) {
3615
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).pauseAsync(cb);
3616
+ }
3617
+ sample() {
3618
+ return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).sample();
3619
+ }
3620
+ };
3621
+ _getUsageManager = new WeakSet();
3622
+ getUsageManager_fn = /* @__PURE__ */ __name(function() {
3623
+ return getGlobal(API_NAME4) ?? NOOP_USAGE_MANAGER;
3624
+ }, "#getUsageManager");
3625
+ __name(_UsageAPI, "UsageAPI");
3626
+ var UsageAPI = _UsageAPI;
3627
+
3628
+ // src/v3/usage-api.ts
3629
+ var usage = UsageAPI.getInstance();
3630
+
3497
3631
  // src/v3/runtime/index.ts
3498
- var API_NAME4 = "runtime";
3632
+ var API_NAME5 = "runtime";
3499
3633
  var NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
3500
3634
  var _getRuntimeManager, getRuntimeManager_fn;
3501
3635
  var _RuntimeAPI = class _RuntimeAPI {
@@ -3509,28 +3643,28 @@ var _RuntimeAPI = class _RuntimeAPI {
3509
3643
  return this._instance;
3510
3644
  }
3511
3645
  waitForDuration(ms) {
3512
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms);
3646
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms));
3513
3647
  }
3514
3648
  waitUntil(date) {
3515
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date);
3649
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date));
3516
3650
  }
3517
3651
  waitForTask(params) {
3518
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params);
3652
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params));
3519
3653
  }
3520
3654
  waitForBatch(params) {
3521
- return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params);
3655
+ return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params));
3522
3656
  }
3523
3657
  setGlobalRuntimeManager(runtimeManager) {
3524
- return registerGlobal(API_NAME4, runtimeManager);
3658
+ return registerGlobal(API_NAME5, runtimeManager);
3525
3659
  }
3526
3660
  disable() {
3527
3661
  __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).disable();
3528
- unregisterGlobal(API_NAME4);
3662
+ unregisterGlobal(API_NAME5);
3529
3663
  }
3530
3664
  };
3531
3665
  _getRuntimeManager = new WeakSet();
3532
3666
  getRuntimeManager_fn = /* @__PURE__ */ __name(function() {
3533
- return getGlobal(API_NAME4) ?? NOOP_RUNTIME_MANAGER;
3667
+ return getGlobal(API_NAME5) ?? NOOP_RUNTIME_MANAGER;
3534
3668
  }, "#getRuntimeManager");
3535
3669
  __name(_RuntimeAPI, "RuntimeAPI");
3536
3670
  var RuntimeAPI = _RuntimeAPI;
@@ -3547,7 +3681,7 @@ function getEnvVar(name) {
3547
3681
  __name(getEnvVar, "getEnvVar");
3548
3682
 
3549
3683
  // src/v3/apiClientManager/index.ts
3550
- var API_NAME5 = "api-client";
3684
+ var API_NAME6 = "api-client";
3551
3685
  var _getConfig, getConfig_fn;
3552
3686
  var _APIClientManagerAPI = class _APIClientManagerAPI {
3553
3687
  constructor() {
@@ -3560,10 +3694,10 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
3560
3694
  return this._instance;
3561
3695
  }
3562
3696
  disable() {
3563
- unregisterGlobal(API_NAME5);
3697
+ unregisterGlobal(API_NAME6);
3564
3698
  }
3565
3699
  setGlobalAPIClientConfiguration(config) {
3566
- return registerGlobal(API_NAME5, config);
3700
+ return registerGlobal(API_NAME6, config);
3567
3701
  }
3568
3702
  get baseURL() {
3569
3703
  const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
@@ -3582,7 +3716,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
3582
3716
  };
3583
3717
  _getConfig = new WeakSet();
3584
3718
  getConfig_fn = /* @__PURE__ */ __name(function() {
3585
- return getGlobal(API_NAME5);
3719
+ return getGlobal(API_NAME6);
3586
3720
  }, "#getConfig");
3587
3721
  __name(_APIClientManagerAPI, "APIClientManagerAPI");
3588
3722
  var APIClientManagerAPI = _APIClientManagerAPI;
@@ -3617,7 +3751,7 @@ __name(_NoopTaskCatalog, "NoopTaskCatalog");
3617
3751
  var NoopTaskCatalog = _NoopTaskCatalog;
3618
3752
 
3619
3753
  // src/v3/task-catalog/index.ts
3620
- var API_NAME6 = "task-catalog";
3754
+ var API_NAME7 = "task-catalog";
3621
3755
  var NOOP_TASK_CATALOG = new NoopTaskCatalog();
3622
3756
  var _getCatalog, getCatalog_fn;
3623
3757
  var _TaskCatalogAPI = class _TaskCatalogAPI {
@@ -3631,10 +3765,10 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
3631
3765
  return this._instance;
3632
3766
  }
3633
3767
  setGlobalTaskCatalog(taskCatalog2) {
3634
- return registerGlobal(API_NAME6, taskCatalog2);
3768
+ return registerGlobal(API_NAME7, taskCatalog2);
3635
3769
  }
3636
3770
  disable() {
3637
- unregisterGlobal(API_NAME6);
3771
+ unregisterGlobal(API_NAME7);
3638
3772
  }
3639
3773
  registerTaskMetadata(task) {
3640
3774
  __privateMethod(this, _getCatalog, getCatalog_fn).call(this).registerTaskMetadata(task);
@@ -3660,7 +3794,7 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
3660
3794
  };
3661
3795
  _getCatalog = new WeakSet();
3662
3796
  getCatalog_fn = /* @__PURE__ */ __name(function() {
3663
- return getGlobal(API_NAME6) ?? NOOP_TASK_CATALOG;
3797
+ return getGlobal(API_NAME7) ?? NOOP_TASK_CATALOG;
3664
3798
  }, "#getCatalog");
3665
3799
  __name(_TaskCatalogAPI, "TaskCatalogAPI");
3666
3800
  var TaskCatalogAPI = _TaskCatalogAPI;
@@ -3780,6 +3914,7 @@ var _TriggerTracer = class _TriggerTracer {
3780
3914
  [SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
3781
3915
  }
3782
3916
  }, parentContext).end();
3917
+ const usageMeasurement = usage.start();
3783
3918
  try {
3784
3919
  return await fn(span);
3785
3920
  } catch (e) {
@@ -3791,6 +3926,12 @@ var _TriggerTracer = class _TriggerTracer {
3791
3926
  });
3792
3927
  throw e;
3793
3928
  } finally {
3929
+ const usageSample = usage.stop(usageMeasurement);
3930
+ const machine = taskContext.ctx?.machine;
3931
+ span.setAttributes({
3932
+ [SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
3933
+ [SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
3934
+ });
3794
3935
  span.end(clock.preciseNow());
3795
3936
  }
3796
3937
  });
@@ -4263,6 +4404,6 @@ function safeJsonParse2(value) {
4263
4404
  }
4264
4405
  __name(safeJsonParse2, "safeJsonParse");
4265
4406
 
4266
- 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 };
4407
+ 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, 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, 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, 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, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseError, parsePacket, prettyPrintPacket, primitiveValueOrflattenedAttributes, runtime, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskCatalog, taskContext, unflattenAttributes, usage, workerToChildMessages };
4267
4408
  //# sourceMappingURL=out.js.map
4268
4409
  //# sourceMappingURL=index.mjs.map