@trigger.dev/sdk 0.2.21 → 0.2.22

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.
package/dist/index.js CHANGED
@@ -348,12 +348,28 @@ var ResolveRunOnceOuputSchema = import_zod8.z.object({
348
348
  output: SerializableJsonSchema.optional()
349
349
  });
350
350
 
351
- // src/events.ts
351
+ // ../common-schemas/src/kv.ts
352
352
  var import_zod9 = require("zod");
353
+ var KVGetSchema = import_zod9.z.object({
354
+ key: import_zod9.z.string(),
355
+ namespace: import_zod9.z.string()
356
+ });
357
+ var KVDeleteSchema = import_zod9.z.object({
358
+ key: import_zod9.z.string(),
359
+ namespace: import_zod9.z.string()
360
+ });
361
+ var KVSetSchema = import_zod9.z.object({
362
+ key: import_zod9.z.string(),
363
+ namespace: import_zod9.z.string(),
364
+ value: SerializableJsonSchema
365
+ });
366
+
367
+ // src/events.ts
368
+ var import_zod10 = require("zod");
353
369
  var import_slug = __toESM(require("slug"));
354
370
  var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
355
371
  function customEvent(options) {
356
- const schema = options.schema ?? import_zod9.z.any();
372
+ const schema = options.schema ?? import_zod10.z.any();
357
373
  return {
358
374
  metadata: {
359
375
  type: "CUSTOM_EVENT",
@@ -384,7 +400,7 @@ function scheduleEvent(options) {
384
400
  }
385
401
  __name(scheduleEvent, "scheduleEvent");
386
402
  function webhookEvent(options) {
387
- const schema = options.schema ?? import_zod9.z.any();
403
+ const schema = options.schema ?? import_zod10.z.any();
388
404
  return {
389
405
  metadata: {
390
406
  type: "WEBHOOK",
@@ -414,301 +430,378 @@ function webhookEvent(options) {
414
430
  __name(webhookEvent, "webhookEvent");
415
431
 
416
432
  // ../internal-bridge/src/schemas/host.ts
417
- var import_zod10 = require("zod");
433
+ var import_zod11 = require("zod");
418
434
  var HostRPCSchema = {
419
435
  TRIGGER_WORKFLOW: {
420
- request: import_zod10.z.object({
421
- id: import_zod10.z.string(),
422
- trigger: import_zod10.z.object({
436
+ request: import_zod11.z.object({
437
+ id: import_zod11.z.string(),
438
+ trigger: import_zod11.z.object({
423
439
  input: JsonSchema.default({}),
424
440
  context: JsonSchema.default({})
425
441
  }),
426
- meta: import_zod10.z.object({
427
- environment: import_zod10.z.string(),
428
- workflowId: import_zod10.z.string(),
429
- organizationId: import_zod10.z.string(),
430
- apiKey: import_zod10.z.string(),
431
- isTest: import_zod10.z.boolean().default(false),
432
- appOrigin: import_zod10.z.string(),
433
- attempt: import_zod10.z.number().optional()
442
+ meta: import_zod11.z.object({
443
+ environment: import_zod11.z.string(),
444
+ workflowId: import_zod11.z.string(),
445
+ organizationId: import_zod11.z.string(),
446
+ apiKey: import_zod11.z.string(),
447
+ isTest: import_zod11.z.boolean().default(false),
448
+ appOrigin: import_zod11.z.string(),
449
+ attempt: import_zod11.z.number().optional()
434
450
  })
435
451
  }),
436
- response: import_zod10.z.boolean()
452
+ response: import_zod11.z.boolean()
437
453
  },
438
454
  RESOLVE_REQUEST: {
439
- request: import_zod10.z.object({
440
- id: import_zod10.z.string(),
441
- key: import_zod10.z.string(),
455
+ request: import_zod11.z.object({
456
+ id: import_zod11.z.string(),
457
+ key: import_zod11.z.string(),
442
458
  output: JsonSchema.default({}),
443
- meta: import_zod10.z.object({
444
- environment: import_zod10.z.string(),
445
- workflowId: import_zod10.z.string(),
446
- organizationId: import_zod10.z.string(),
447
- apiKey: import_zod10.z.string(),
448
- runId: import_zod10.z.string()
459
+ meta: import_zod11.z.object({
460
+ environment: import_zod11.z.string(),
461
+ workflowId: import_zod11.z.string(),
462
+ organizationId: import_zod11.z.string(),
463
+ apiKey: import_zod11.z.string(),
464
+ runId: import_zod11.z.string()
449
465
  })
450
466
  }),
451
- response: import_zod10.z.boolean()
467
+ response: import_zod11.z.boolean()
452
468
  },
453
469
  RESOLVE_DELAY: {
454
- request: import_zod10.z.object({
455
- id: import_zod10.z.string(),
456
- key: import_zod10.z.string(),
457
- meta: import_zod10.z.object({
458
- environment: import_zod10.z.string(),
459
- workflowId: import_zod10.z.string(),
460
- organizationId: import_zod10.z.string(),
461
- apiKey: import_zod10.z.string(),
462
- runId: import_zod10.z.string()
470
+ request: import_zod11.z.object({
471
+ id: import_zod11.z.string(),
472
+ key: import_zod11.z.string(),
473
+ meta: import_zod11.z.object({
474
+ environment: import_zod11.z.string(),
475
+ workflowId: import_zod11.z.string(),
476
+ organizationId: import_zod11.z.string(),
477
+ apiKey: import_zod11.z.string(),
478
+ runId: import_zod11.z.string()
463
479
  })
464
480
  }),
465
- response: import_zod10.z.boolean()
481
+ response: import_zod11.z.boolean()
466
482
  },
467
483
  REJECT_REQUEST: {
468
- request: import_zod10.z.object({
469
- id: import_zod10.z.string(),
470
- key: import_zod10.z.string(),
484
+ request: import_zod11.z.object({
485
+ id: import_zod11.z.string(),
486
+ key: import_zod11.z.string(),
471
487
  error: JsonSchema.default({}),
472
- meta: import_zod10.z.object({
473
- environment: import_zod10.z.string(),
474
- workflowId: import_zod10.z.string(),
475
- organizationId: import_zod10.z.string(),
476
- apiKey: import_zod10.z.string(),
477
- runId: import_zod10.z.string()
488
+ meta: import_zod11.z.object({
489
+ environment: import_zod11.z.string(),
490
+ workflowId: import_zod11.z.string(),
491
+ organizationId: import_zod11.z.string(),
492
+ apiKey: import_zod11.z.string(),
493
+ runId: import_zod11.z.string()
478
494
  })
479
495
  }),
480
- response: import_zod10.z.boolean()
496
+ response: import_zod11.z.boolean()
481
497
  },
482
498
  RESOLVE_FETCH_REQUEST: {
483
- request: import_zod10.z.object({
484
- id: import_zod10.z.string(),
485
- key: import_zod10.z.string(),
499
+ request: import_zod11.z.object({
500
+ id: import_zod11.z.string(),
501
+ key: import_zod11.z.string(),
486
502
  output: FetchOutputSchema,
487
- meta: import_zod10.z.object({
488
- environment: import_zod10.z.string(),
489
- workflowId: import_zod10.z.string(),
490
- organizationId: import_zod10.z.string(),
491
- apiKey: import_zod10.z.string(),
492
- runId: import_zod10.z.string()
503
+ meta: import_zod11.z.object({
504
+ environment: import_zod11.z.string(),
505
+ workflowId: import_zod11.z.string(),
506
+ organizationId: import_zod11.z.string(),
507
+ apiKey: import_zod11.z.string(),
508
+ runId: import_zod11.z.string()
493
509
  })
494
510
  }),
495
- response: import_zod10.z.boolean()
511
+ response: import_zod11.z.boolean()
496
512
  },
497
513
  REJECT_FETCH_REQUEST: {
498
- request: import_zod10.z.object({
499
- id: import_zod10.z.string(),
500
- key: import_zod10.z.string(),
514
+ request: import_zod11.z.object({
515
+ id: import_zod11.z.string(),
516
+ key: import_zod11.z.string(),
501
517
  error: JsonSchema.default({}),
502
- meta: import_zod10.z.object({
503
- environment: import_zod10.z.string(),
504
- workflowId: import_zod10.z.string(),
505
- organizationId: import_zod10.z.string(),
506
- apiKey: import_zod10.z.string(),
507
- runId: import_zod10.z.string()
518
+ meta: import_zod11.z.object({
519
+ environment: import_zod11.z.string(),
520
+ workflowId: import_zod11.z.string(),
521
+ organizationId: import_zod11.z.string(),
522
+ apiKey: import_zod11.z.string(),
523
+ runId: import_zod11.z.string()
508
524
  })
509
525
  }),
510
- response: import_zod10.z.boolean()
526
+ response: import_zod11.z.boolean()
511
527
  },
512
528
  RESOLVE_RUN_ONCE: {
513
- request: import_zod10.z.object({
514
- id: import_zod10.z.string(),
515
- key: import_zod10.z.string(),
529
+ request: import_zod11.z.object({
530
+ id: import_zod11.z.string(),
531
+ key: import_zod11.z.string(),
516
532
  output: ResolveRunOnceOuputSchema,
517
- meta: import_zod10.z.object({
518
- environment: import_zod10.z.string(),
519
- workflowId: import_zod10.z.string(),
520
- organizationId: import_zod10.z.string(),
521
- apiKey: import_zod10.z.string(),
522
- runId: import_zod10.z.string()
533
+ meta: import_zod11.z.object({
534
+ environment: import_zod11.z.string(),
535
+ workflowId: import_zod11.z.string(),
536
+ organizationId: import_zod11.z.string(),
537
+ apiKey: import_zod11.z.string(),
538
+ runId: import_zod11.z.string()
539
+ })
540
+ }),
541
+ response: import_zod11.z.boolean()
542
+ },
543
+ RESOLVE_KV_GET: {
544
+ request: import_zod11.z.object({
545
+ key: import_zod11.z.string(),
546
+ output: SerializableJsonSchema,
547
+ meta: import_zod11.z.object({
548
+ environment: import_zod11.z.string(),
549
+ workflowId: import_zod11.z.string(),
550
+ organizationId: import_zod11.z.string(),
551
+ apiKey: import_zod11.z.string(),
552
+ runId: import_zod11.z.string()
553
+ })
554
+ }),
555
+ response: import_zod11.z.boolean()
556
+ },
557
+ RESOLVE_KV_SET: {
558
+ request: import_zod11.z.object({
559
+ key: import_zod11.z.string(),
560
+ meta: import_zod11.z.object({
561
+ environment: import_zod11.z.string(),
562
+ workflowId: import_zod11.z.string(),
563
+ organizationId: import_zod11.z.string(),
564
+ apiKey: import_zod11.z.string(),
565
+ runId: import_zod11.z.string()
566
+ })
567
+ }),
568
+ response: import_zod11.z.boolean()
569
+ },
570
+ RESOLVE_KV_DELETE: {
571
+ request: import_zod11.z.object({
572
+ key: import_zod11.z.string(),
573
+ meta: import_zod11.z.object({
574
+ environment: import_zod11.z.string(),
575
+ workflowId: import_zod11.z.string(),
576
+ organizationId: import_zod11.z.string(),
577
+ apiKey: import_zod11.z.string(),
578
+ runId: import_zod11.z.string()
523
579
  })
524
580
  }),
525
- response: import_zod10.z.boolean()
581
+ response: import_zod11.z.boolean()
526
582
  }
527
583
  };
528
584
 
529
585
  // ../internal-bridge/src/schemas/server.ts
530
- var import_zod11 = require("zod");
586
+ var import_zod12 = require("zod");
531
587
  var ServerRPCSchema = {
532
588
  INITIALIZE_DELAY: {
533
- request: import_zod11.z.object({
534
- runId: import_zod11.z.string(),
535
- key: import_zod11.z.string(),
589
+ request: import_zod12.z.object({
590
+ runId: import_zod12.z.string(),
591
+ key: import_zod12.z.string(),
536
592
  wait: WaitSchema,
537
- timestamp: import_zod11.z.string()
593
+ timestamp: import_zod12.z.string()
538
594
  }),
539
- response: import_zod11.z.boolean()
595
+ response: import_zod12.z.boolean()
540
596
  },
541
597
  SEND_REQUEST: {
542
- request: import_zod11.z.object({
543
- runId: import_zod11.z.string(),
544
- key: import_zod11.z.string(),
545
- request: import_zod11.z.object({
546
- service: import_zod11.z.string(),
547
- endpoint: import_zod11.z.string(),
548
- params: import_zod11.z.any(),
549
- version: import_zod11.z.string().optional()
598
+ request: import_zod12.z.object({
599
+ runId: import_zod12.z.string(),
600
+ key: import_zod12.z.string(),
601
+ request: import_zod12.z.object({
602
+ service: import_zod12.z.string(),
603
+ endpoint: import_zod12.z.string(),
604
+ params: import_zod12.z.any(),
605
+ version: import_zod12.z.string().optional()
550
606
  }),
551
- timestamp: import_zod11.z.string()
607
+ timestamp: import_zod12.z.string()
552
608
  }),
553
- response: import_zod11.z.boolean()
609
+ response: import_zod12.z.boolean()
554
610
  },
555
611
  SEND_FETCH: {
556
- request: import_zod11.z.object({
557
- runId: import_zod11.z.string(),
558
- key: import_zod11.z.string(),
612
+ request: import_zod12.z.object({
613
+ runId: import_zod12.z.string(),
614
+ key: import_zod12.z.string(),
559
615
  fetch: FetchRequestSchema,
560
- timestamp: import_zod11.z.string()
616
+ timestamp: import_zod12.z.string()
561
617
  }),
562
- response: import_zod11.z.boolean()
618
+ response: import_zod12.z.boolean()
563
619
  },
564
620
  SEND_LOG: {
565
- request: import_zod11.z.object({
566
- runId: import_zod11.z.string(),
567
- key: import_zod11.z.string(),
568
- log: import_zod11.z.object({
569
- message: import_zod11.z.string(),
570
- level: import_zod11.z.enum([
621
+ request: import_zod12.z.object({
622
+ runId: import_zod12.z.string(),
623
+ key: import_zod12.z.string(),
624
+ log: import_zod12.z.object({
625
+ message: import_zod12.z.string(),
626
+ level: import_zod12.z.enum([
571
627
  "DEBUG",
572
628
  "INFO",
573
629
  "WARN",
574
630
  "ERROR"
575
631
  ]),
576
- properties: import_zod11.z.string().optional()
632
+ properties: import_zod12.z.string().optional()
577
633
  }),
578
- timestamp: import_zod11.z.string()
634
+ timestamp: import_zod12.z.string()
579
635
  }),
580
- response: import_zod11.z.boolean()
636
+ response: import_zod12.z.boolean()
581
637
  },
582
638
  SEND_EVENT: {
583
- request: import_zod11.z.object({
584
- runId: import_zod11.z.string(),
585
- key: import_zod11.z.string(),
639
+ request: import_zod12.z.object({
640
+ runId: import_zod12.z.string(),
641
+ key: import_zod12.z.string(),
586
642
  event: CustomEventSchema,
587
- timestamp: import_zod11.z.string()
643
+ timestamp: import_zod12.z.string()
588
644
  }),
589
- response: import_zod11.z.boolean()
645
+ response: import_zod12.z.boolean()
590
646
  },
591
647
  INITIALIZE_HOST: {
592
- request: import_zod11.z.object({
593
- apiKey: import_zod11.z.string(),
594
- workflowId: import_zod11.z.string(),
595
- workflowName: import_zod11.z.string(),
648
+ request: import_zod12.z.object({
649
+ apiKey: import_zod12.z.string(),
650
+ workflowId: import_zod12.z.string(),
651
+ workflowName: import_zod12.z.string(),
596
652
  trigger: TriggerMetadataSchema,
597
- packageVersion: import_zod11.z.string(),
598
- packageName: import_zod11.z.string(),
599
- triggerTTL: import_zod11.z.number().optional()
653
+ packageVersion: import_zod12.z.string(),
654
+ packageName: import_zod12.z.string(),
655
+ triggerTTL: import_zod12.z.number().optional()
600
656
  }),
601
- response: import_zod11.z.discriminatedUnion("type", [
602
- import_zod11.z.object({
603
- type: import_zod11.z.literal("success")
657
+ response: import_zod12.z.discriminatedUnion("type", [
658
+ import_zod12.z.object({
659
+ type: import_zod12.z.literal("success")
604
660
  }),
605
- import_zod11.z.object({
606
- type: import_zod11.z.literal("error"),
607
- message: import_zod11.z.string()
661
+ import_zod12.z.object({
662
+ type: import_zod12.z.literal("error"),
663
+ message: import_zod12.z.string()
608
664
  })
609
665
  ]).nullable()
610
666
  },
611
667
  INITIALIZE_HOST_V2: {
612
- request: import_zod11.z.object({
613
- apiKey: import_zod11.z.string(),
614
- workflowId: import_zod11.z.string(),
615
- workflowName: import_zod11.z.string(),
668
+ request: import_zod12.z.object({
669
+ apiKey: import_zod12.z.string(),
670
+ workflowId: import_zod12.z.string(),
671
+ workflowName: import_zod12.z.string(),
616
672
  trigger: TriggerMetadataSchema,
617
- packageVersion: import_zod11.z.string(),
618
- packageName: import_zod11.z.string(),
619
- triggerTTL: import_zod11.z.number().optional(),
673
+ packageVersion: import_zod12.z.string(),
674
+ packageName: import_zod12.z.string(),
675
+ triggerTTL: import_zod12.z.number().optional(),
620
676
  metadata: SerializableJsonSchema.optional()
621
677
  }),
622
- response: import_zod11.z.discriminatedUnion("type", [
623
- import_zod11.z.object({
624
- type: import_zod11.z.literal("success"),
625
- data: import_zod11.z.object({
626
- workflow: import_zod11.z.object({
627
- id: import_zod11.z.string(),
628
- slug: import_zod11.z.string()
678
+ response: import_zod12.z.discriminatedUnion("type", [
679
+ import_zod12.z.object({
680
+ type: import_zod12.z.literal("success"),
681
+ data: import_zod12.z.object({
682
+ workflow: import_zod12.z.object({
683
+ id: import_zod12.z.string(),
684
+ slug: import_zod12.z.string()
629
685
  }),
630
- environment: import_zod11.z.object({
631
- id: import_zod11.z.string(),
632
- slug: import_zod11.z.string()
686
+ environment: import_zod12.z.object({
687
+ id: import_zod12.z.string(),
688
+ slug: import_zod12.z.string()
633
689
  }),
634
- organization: import_zod11.z.object({
635
- id: import_zod11.z.string(),
636
- slug: import_zod11.z.string()
690
+ organization: import_zod12.z.object({
691
+ id: import_zod12.z.string(),
692
+ slug: import_zod12.z.string()
637
693
  }),
638
- isNew: import_zod11.z.boolean(),
639
- url: import_zod11.z.string()
694
+ isNew: import_zod12.z.boolean(),
695
+ url: import_zod12.z.string()
640
696
  })
641
697
  }),
642
- import_zod11.z.object({
643
- type: import_zod11.z.literal("error"),
644
- message: import_zod11.z.string()
698
+ import_zod12.z.object({
699
+ type: import_zod12.z.literal("error"),
700
+ message: import_zod12.z.string()
645
701
  })
646
702
  ]).nullable()
647
703
  },
648
704
  START_WORKFLOW_RUN: {
649
- request: import_zod11.z.object({
650
- runId: import_zod11.z.string(),
651
- timestamp: import_zod11.z.string()
705
+ request: import_zod12.z.object({
706
+ runId: import_zod12.z.string(),
707
+ timestamp: import_zod12.z.string()
652
708
  }),
653
- response: import_zod11.z.boolean()
709
+ response: import_zod12.z.boolean()
654
710
  },
655
711
  COMPLETE_WORKFLOW_RUN: {
656
- request: import_zod11.z.object({
657
- runId: import_zod11.z.string(),
658
- output: import_zod11.z.string().optional(),
659
- timestamp: import_zod11.z.string()
712
+ request: import_zod12.z.object({
713
+ runId: import_zod12.z.string(),
714
+ output: import_zod12.z.string().optional(),
715
+ timestamp: import_zod12.z.string()
660
716
  }),
661
- response: import_zod11.z.boolean()
717
+ response: import_zod12.z.boolean()
662
718
  },
663
719
  SEND_WORKFLOW_ERROR: {
664
- request: import_zod11.z.object({
665
- runId: import_zod11.z.string(),
666
- error: import_zod11.z.object({
667
- name: import_zod11.z.string(),
668
- message: import_zod11.z.string(),
669
- stackTrace: import_zod11.z.string().optional()
720
+ request: import_zod12.z.object({
721
+ runId: import_zod12.z.string(),
722
+ error: import_zod12.z.object({
723
+ name: import_zod12.z.string(),
724
+ message: import_zod12.z.string(),
725
+ stackTrace: import_zod12.z.string().optional()
670
726
  }),
671
- timestamp: import_zod11.z.string()
727
+ timestamp: import_zod12.z.string()
672
728
  }),
673
- response: import_zod11.z.boolean()
729
+ response: import_zod12.z.boolean()
674
730
  },
675
731
  INITIALIZE_RUN_ONCE: {
676
- request: import_zod11.z.object({
677
- runId: import_zod11.z.string(),
678
- key: import_zod11.z.string(),
679
- timestamp: import_zod11.z.string(),
732
+ request: import_zod12.z.object({
733
+ runId: import_zod12.z.string(),
734
+ key: import_zod12.z.string(),
735
+ timestamp: import_zod12.z.string(),
680
736
  runOnce: InitializeRunOnceSchema
681
737
  }),
682
- response: import_zod11.z.boolean()
738
+ response: import_zod12.z.boolean()
683
739
  },
684
740
  COMPLETE_RUN_ONCE: {
685
- request: import_zod11.z.object({
686
- runId: import_zod11.z.string(),
687
- key: import_zod11.z.string(),
688
- timestamp: import_zod11.z.string(),
741
+ request: import_zod12.z.object({
742
+ runId: import_zod12.z.string(),
743
+ key: import_zod12.z.string(),
744
+ timestamp: import_zod12.z.string(),
689
745
  runOnce: CompleteRunOnceSchema
690
746
  }),
691
- response: import_zod11.z.boolean()
747
+ response: import_zod12.z.boolean()
748
+ },
749
+ SEND_KV_GET: {
750
+ request: import_zod12.z.object({
751
+ runId: import_zod12.z.string(),
752
+ key: import_zod12.z.string(),
753
+ timestamp: import_zod12.z.string(),
754
+ get: import_zod12.z.object({
755
+ namespace: import_zod12.z.string(),
756
+ key: import_zod12.z.string()
757
+ })
758
+ }),
759
+ response: import_zod12.z.boolean()
760
+ },
761
+ SEND_KV_SET: {
762
+ request: import_zod12.z.object({
763
+ runId: import_zod12.z.string(),
764
+ key: import_zod12.z.string(),
765
+ timestamp: import_zod12.z.string(),
766
+ set: import_zod12.z.object({
767
+ namespace: import_zod12.z.string(),
768
+ key: import_zod12.z.string(),
769
+ value: SerializableJsonSchema
770
+ })
771
+ }),
772
+ response: import_zod12.z.boolean()
773
+ },
774
+ SEND_KV_DELETE: {
775
+ request: import_zod12.z.object({
776
+ runId: import_zod12.z.string(),
777
+ key: import_zod12.z.string(),
778
+ timestamp: import_zod12.z.string(),
779
+ delete: import_zod12.z.object({
780
+ namespace: import_zod12.z.string(),
781
+ key: import_zod12.z.string()
782
+ })
783
+ }),
784
+ response: import_zod12.z.boolean()
692
785
  }
693
786
  };
694
787
 
695
788
  // ../internal-bridge/src/schemas/common.ts
696
- var import_zod12 = require("zod");
697
- var MESSAGE_META = import_zod12.z.object({
698
- data: import_zod12.z.any(),
699
- id: import_zod12.z.string(),
700
- type: import_zod12.z.union([
701
- import_zod12.z.literal("ACK"),
702
- import_zod12.z.literal("MESSAGE")
789
+ var import_zod13 = require("zod");
790
+ var MESSAGE_META = import_zod13.z.object({
791
+ data: import_zod13.z.any(),
792
+ id: import_zod13.z.string(),
793
+ type: import_zod13.z.union([
794
+ import_zod13.z.literal("ACK"),
795
+ import_zod13.z.literal("MESSAGE")
703
796
  ])
704
797
  });
705
- var TriggerEnvironmentSchema = import_zod12.z.enum([
798
+ var TriggerEnvironmentSchema = import_zod13.z.enum([
706
799
  "live",
707
800
  "development"
708
801
  ]);
709
802
 
710
803
  // ../internal-bridge/src/zodRPC.ts
711
- var import_zod13 = require("zod");
804
+ var import_zod14 = require("zod");
712
805
  var import_node_crypto = require("crypto");
713
806
 
714
807
  // ../internal-bridge/src/logger.ts
@@ -775,13 +868,17 @@ var Logger = class {
775
868
  ...__privateMethod(this, _formatTags, formatTags_fn).call(this)
776
869
  ]);
777
870
  }
778
- debug(...args) {
871
+ debug(message, ...args) {
779
872
  if (__privateGet(this, _level) < 5)
780
873
  return;
781
- console.debug(`[${formattedDateTime()}] ${__privateMethod(this, _formatName, formatName_fn).call(this)} `, ...[
782
- ...args,
783
- ...__privateMethod(this, _formatTags, formatTags_fn).call(this)
784
- ]);
874
+ const structuredLog = {
875
+ timestamp: formattedDateTime(),
876
+ name: __privateGet(this, _name),
877
+ tags: __privateGet(this, _tags),
878
+ message,
879
+ args: structureArgs(args)
880
+ };
881
+ console.debug(JSON.stringify(structuredLog));
785
882
  }
786
883
  };
787
884
  __name(Logger, "Logger");
@@ -812,13 +909,23 @@ function formattedDateTime() {
812
909
  return `${formattedHours}:${formattedMinutes}:${formattedSeconds}.${formattedMilliseconds}`;
813
910
  }
814
911
  __name(formattedDateTime, "formattedDateTime");
912
+ function structureArgs(args) {
913
+ if (args.length === 0) {
914
+ return;
915
+ }
916
+ if (args.length === 1 && typeof args[0] === "object") {
917
+ return args[0];
918
+ }
919
+ return args;
920
+ }
921
+ __name(structureArgs, "structureArgs");
815
922
 
816
923
  // ../internal-bridge/src/zodRPC.ts
817
- var RPCMessageSchema = import_zod13.z.object({
818
- id: import_zod13.z.string(),
819
- methodName: import_zod13.z.string(),
820
- data: import_zod13.z.any(),
821
- kind: import_zod13.z.enum([
924
+ var RPCMessageSchema = import_zod14.z.object({
925
+ id: import_zod14.z.string(),
926
+ methodName: import_zod14.z.string(),
927
+ data: import_zod14.z.any(),
928
+ kind: import_zod14.z.enum([
822
929
  "CALL",
823
930
  "RESPONSE"
824
931
  ])
@@ -898,7 +1005,7 @@ onCall_fn = /* @__PURE__ */ __name(async function(message) {
898
1005
  try {
899
1006
  await __privateMethod(this, _handleCall, handleCall_fn).call(this, message);
900
1007
  } catch (callError) {
901
- if (callError instanceof import_zod13.ZodError) {
1008
+ if (callError instanceof import_zod14.ZodError) {
902
1009
  __privateGet(this, _logger).error(`[ZodRPC] Received invalid call:
903
1010
  ${JSON.stringify(message)}: `, callError.errors);
904
1011
  } else {
@@ -912,7 +1019,7 @@ onResponse_fn = /* @__PURE__ */ __name(async function(message1) {
912
1019
  try {
913
1020
  await __privateMethod(this, _handleResponse, handleResponse_fn).call(this, message1);
914
1021
  } catch (callError) {
915
- if (callError instanceof import_zod13.ZodError) {
1022
+ if (callError instanceof import_zod14.ZodError) {
916
1023
  __privateGet(this, _logger).error(`[ZodRPC] Received invalid response
917
1024
 
918
1025
  ${JSON.stringify(message1)}: `, callError.flatten());
@@ -988,11 +1095,11 @@ __name(packageResponse, "packageResponse");
988
1095
  // src/client.ts
989
1096
  var import_uuid2 = require("uuid");
990
1097
  var import_ws = require("ws");
991
- var import_zod14 = require("zod");
1098
+ var import_zod15 = require("zod");
992
1099
 
993
1100
  // package.json
994
1101
  var name = "@trigger.dev/sdk";
995
- var version = "0.2.21";
1102
+ var version = "0.2.22";
996
1103
 
997
1104
  // src/connection.ts
998
1105
  var import_uuid = require("uuid");
@@ -1176,7 +1283,7 @@ startPingInterval_fn = /* @__PURE__ */ __name(function() {
1176
1283
  __privateGet(this, _logger2).error(err);
1177
1284
  }
1178
1285
  if (lastSuccessfulPing.getTime() < new Date().getTime() - __privateGet(this, _closeUnresponsiveConnectionTimeoutMs)) {
1179
- __privateGet(this, _logger2).error("No pong received in last three minutes, closing connection to Interval and retrying...");
1286
+ __privateGet(this, _logger2).error("No pong received in last three minutes, closing connection to Trigger.dev and retrying...");
1180
1287
  if (__privateGet(this, _pingIntervalHandle)) {
1181
1288
  clearInterval(__privateGet(this, _pingIntervalHandle));
1182
1289
  __privateSet(this, _pingIntervalHandle, void 0);
@@ -1245,17 +1352,54 @@ __name(ContextLogger, "ContextLogger");
1245
1352
 
1246
1353
  // src/client.ts
1247
1354
  var import_zod_error = require("zod-error");
1248
- var import_terminal_link = __toESM(require("terminal-link"));
1249
- var import_chalk = __toESM(require("chalk"));
1250
- var import_git_repo_info = __toESM(require("git-repo-info"));
1251
- var import_git_remote_origin_url = __toESM(require("git-remote-origin-url"));
1252
1355
  var import_promises = require("fs/promises");
1356
+
1357
+ // src/keyValueStorage.ts
1358
+ var ContextKeyValueStorage = class {
1359
+ constructor(namespace, onGet, onSet, onDelete) {
1360
+ this.namespace = namespace;
1361
+ this.onGet = onGet;
1362
+ this.onSet = onSet;
1363
+ this.onDelete = onDelete;
1364
+ this.getCount = 0;
1365
+ this.setCount = 0;
1366
+ this.deleteCount = 0;
1367
+ }
1368
+ get(key) {
1369
+ const operation = {
1370
+ key,
1371
+ namespace: this.namespace,
1372
+ idempotencyKey: `get:${this.namespace}:${key}:${this.getCount++}`
1373
+ };
1374
+ return this.onGet(operation);
1375
+ }
1376
+ set(key, value) {
1377
+ const operation = {
1378
+ key,
1379
+ namespace: this.namespace,
1380
+ idempotencyKey: `set:${this.namespace}:${key}:${this.setCount++}`,
1381
+ value
1382
+ };
1383
+ return this.onSet(operation);
1384
+ }
1385
+ delete(key) {
1386
+ const operation = {
1387
+ key,
1388
+ namespace: this.namespace,
1389
+ idempotencyKey: `delete:${this.namespace}:${key}:${this.deleteCount++}`
1390
+ };
1391
+ return this.onDelete(operation);
1392
+ }
1393
+ };
1394
+ __name(ContextKeyValueStorage, "ContextKeyValueStorage");
1395
+
1396
+ // src/client.ts
1253
1397
  var zodErrorMessageOptions = {
1254
1398
  delimiter: {
1255
1399
  error: " \u{1F525} "
1256
1400
  }
1257
1401
  };
1258
- var _trigger, _options, _connection2, _serverRPC, _apiKey, _endpoint, _isConnected, _retryIntervalMs, _logger3, _closedByUser, _registerResponse, _responseCompleteCallbacks, _waitForCallbacks, _fetchCallbacks, _runOnceCallbacks, _initializeConnection, initializeConnection_fn, _initializeRPC, initializeRPC_fn, _initializeHost, initializeHost_fn, _send, send_fn;
1402
+ var _trigger, _options, _connection2, _serverRPC, _apiKey, _endpoint, _isConnected, _retryIntervalMs, _logger3, _closedByUser, _registerResponse, _responseCompleteCallbacks, _waitForCallbacks, _fetchCallbacks, _runOnceCallbacks, _kvGetCallbacks, _kvSetCallbacks, _kvDeleteCallbacks, _initializeConnection, initializeConnection_fn, _initializeRPC, initializeRPC_fn, _initializeHost, initializeHost_fn, _send, send_fn;
1259
1403
  var TriggerClient = class {
1260
1404
  constructor(trigger, options) {
1261
1405
  __privateAdd(this, _initializeConnection);
@@ -1277,6 +1421,9 @@ var TriggerClient = class {
1277
1421
  __privateAdd(this, _waitForCallbacks, /* @__PURE__ */ new Map());
1278
1422
  __privateAdd(this, _fetchCallbacks, /* @__PURE__ */ new Map());
1279
1423
  __privateAdd(this, _runOnceCallbacks, /* @__PURE__ */ new Map());
1424
+ __privateAdd(this, _kvGetCallbacks, /* @__PURE__ */ new Map());
1425
+ __privateAdd(this, _kvSetCallbacks, /* @__PURE__ */ new Map());
1426
+ __privateAdd(this, _kvDeleteCallbacks, /* @__PURE__ */ new Map());
1280
1427
  __privateSet(this, _trigger, trigger);
1281
1428
  __privateSet(this, _options, options);
1282
1429
  const apiKey = __privateGet(this, _options).apiKey ?? process.env.TRIGGER_API_KEY;
@@ -1295,12 +1442,13 @@ var TriggerClient = class {
1295
1442
  await __privateMethod(this, _initializeConnection, initializeConnection_fn).call(this, instanceId);
1296
1443
  __privateMethod(this, _initializeRPC, initializeRPC_fn).call(this);
1297
1444
  await __privateMethod(this, _initializeHost, initializeHost_fn).call(this);
1445
+ const terminalLink = (await import("terminal-link")).default;
1298
1446
  if (__privateGet(this, _registerResponse)?.isNew) {
1299
- __privateGet(this, _logger3).logClean(`\u{1F389} Successfully registered "${__privateGet(this, _trigger).name}" to trigger.dev \u{1F449} ${(0, import_terminal_link.default)("View on dashboard", __privateGet(this, _registerResponse).url, {
1447
+ __privateGet(this, _logger3).logClean(`\u{1F389} Successfully registered "${__privateGet(this, _trigger).name}" to trigger.dev \u{1F449} ${terminalLink("View on dashboard", __privateGet(this, _registerResponse).url, {
1300
1448
  fallback: (text, url) => `${text}: (${url})`
1301
1449
  })}. Listening for events...`);
1302
1450
  } else {
1303
- __privateGet(this, _logger3).log(`\u2728 Connected and listening for events \u{1F449} ${(0, import_terminal_link.default)("View on dashboard", __privateGet(this, _registerResponse).url, {
1451
+ __privateGet(this, _logger3).log(`\u2728 Connected and listening for events \u{1F449} ${terminalLink("View on dashboard", __privateGet(this, _registerResponse).url, {
1304
1452
  fallback: (text, url) => `${text}: (${url})`
1305
1453
  })}`);
1306
1454
  }
@@ -1334,6 +1482,9 @@ _responseCompleteCallbacks = new WeakMap();
1334
1482
  _waitForCallbacks = new WeakMap();
1335
1483
  _fetchCallbacks = new WeakMap();
1336
1484
  _runOnceCallbacks = new WeakMap();
1485
+ _kvGetCallbacks = new WeakMap();
1486
+ _kvSetCallbacks = new WeakMap();
1487
+ _kvDeleteCallbacks = new WeakMap();
1337
1488
  _initializeConnection = new WeakSet();
1338
1489
  initializeConnection_fn = /* @__PURE__ */ __name(async function(instanceId) {
1339
1490
  const id = instanceId ?? (0, import_uuid2.v4)();
@@ -1356,7 +1507,8 @@ initializeConnection_fn = /* @__PURE__ */ __name(async function(instanceId) {
1356
1507
  __privateSet(this, _closedByUser, false);
1357
1508
  return;
1358
1509
  }
1359
- __privateGet(this, _logger3).error(`${import_chalk.default.red("error")} Could not connect to trigger.dev${reason ? `: ${reason}` : `(code ${code})`}`);
1510
+ const chalk = (await import("chalk")).default;
1511
+ __privateGet(this, _logger3).error(`${chalk.red("error")} Could not connect to trigger.dev${reason ? `: ${reason}` : `(code ${code})`}`);
1360
1512
  if (!__privateGet(this, _isConnected))
1361
1513
  return;
1362
1514
  __privateGet(this, _logger3).log("\u{1F50C} Reconnecting to trigger.dev...");
@@ -1455,6 +1607,39 @@ initializeRPC_fn = /* @__PURE__ */ __name(async function() {
1455
1607
  reject(data.error);
1456
1608
  return true;
1457
1609
  },
1610
+ RESOLVE_KV_GET: async (data) => {
1611
+ __privateGet(this, _logger3).debug("Handling RESOLVE_KV_GET", data);
1612
+ const getCallbacks = __privateGet(this, _kvGetCallbacks).get(messageKey(data.meta.runId, data.key));
1613
+ if (!getCallbacks) {
1614
+ __privateGet(this, _logger3).debug(`Could not find kvGet callbacks for request ID ${messageKey(data.meta.runId, data.key)}. This can happen when a workflow run is resumed`);
1615
+ return true;
1616
+ }
1617
+ const { resolve } = getCallbacks;
1618
+ resolve(data.output);
1619
+ return true;
1620
+ },
1621
+ RESOLVE_KV_SET: async (data) => {
1622
+ __privateGet(this, _logger3).debug("Handling RESOLVE_KV_SET", data);
1623
+ const setCallbacks = __privateGet(this, _kvSetCallbacks).get(messageKey(data.meta.runId, data.key));
1624
+ if (!setCallbacks) {
1625
+ __privateGet(this, _logger3).debug(`Could not find kvSet callbacks for request ID ${messageKey(data.meta.runId, data.key)}. This can happen when a workflow run is resumed`);
1626
+ return true;
1627
+ }
1628
+ const { resolve } = setCallbacks;
1629
+ resolve();
1630
+ return true;
1631
+ },
1632
+ RESOLVE_KV_DELETE: async (data) => {
1633
+ __privateGet(this, _logger3).debug("Handling RESOLVE_KV_DELETE", data);
1634
+ const deleteCallbacks = __privateGet(this, _kvDeleteCallbacks).get(messageKey(data.meta.runId, data.key));
1635
+ if (!deleteCallbacks) {
1636
+ __privateGet(this, _logger3).debug(`Could not find kvDelete callbacks for request ID ${messageKey(data.meta.runId, data.key)}. This can happen when a workflow run is resumed`);
1637
+ return true;
1638
+ }
1639
+ const { resolve } = deleteCallbacks;
1640
+ resolve();
1641
+ return true;
1642
+ },
1458
1643
  TRIGGER_WORKFLOW: async (data) => {
1459
1644
  __privateGet(this, _logger3).debug("Handling TRIGGER_WORKFLOW", data);
1460
1645
  const parsedEventData = __privateGet(this, _options).on.schema.safeParse(data.trigger.input);
@@ -1493,15 +1678,76 @@ initializeRPC_fn = /* @__PURE__ */ __name(async function() {
1493
1678
  status: response.status,
1494
1679
  ok: response.ok,
1495
1680
  headers: response.headers,
1496
- body: response.body ? (options.responseSchema ?? import_zod14.z.any()).parse(response.body) : void 0
1681
+ body: response.body ? (options.responseSchema ?? import_zod15.z.any()).parse(response.body) : void 0
1497
1682
  };
1498
1683
  }, "fetchFunction");
1684
+ const kvGetFunction = /* @__PURE__ */ __name(async (op) => {
1685
+ const result = new Promise((resolve, reject) => {
1686
+ __privateGet(this, _kvGetCallbacks).set(messageKey(data.id, op.idempotencyKey), {
1687
+ resolve,
1688
+ reject
1689
+ });
1690
+ });
1691
+ await serverRPC.send("SEND_KV_GET", {
1692
+ runId: data.id,
1693
+ key: op.idempotencyKey,
1694
+ get: {
1695
+ namespace: op.namespace,
1696
+ key: op.key
1697
+ },
1698
+ timestamp: String(highPrecisionTimestamp())
1699
+ });
1700
+ const output = await result;
1701
+ return output;
1702
+ }, "kvGetFunction");
1703
+ const kvSetFunction = /* @__PURE__ */ __name(async (op) => {
1704
+ const result = new Promise((resolve, reject) => {
1705
+ __privateGet(this, _kvSetCallbacks).set(messageKey(data.id, op.idempotencyKey), {
1706
+ resolve,
1707
+ reject
1708
+ });
1709
+ });
1710
+ await serverRPC.send("SEND_KV_SET", {
1711
+ runId: data.id,
1712
+ key: op.idempotencyKey,
1713
+ set: {
1714
+ namespace: op.namespace,
1715
+ key: op.key,
1716
+ value: op.value
1717
+ },
1718
+ timestamp: String(highPrecisionTimestamp())
1719
+ });
1720
+ await result;
1721
+ return;
1722
+ }, "kvSetFunction");
1723
+ const kvDeleteFunction = /* @__PURE__ */ __name(async (op) => {
1724
+ const result = new Promise((resolve, reject) => {
1725
+ __privateGet(this, _kvDeleteCallbacks).set(messageKey(data.id, op.idempotencyKey), {
1726
+ resolve,
1727
+ reject
1728
+ });
1729
+ });
1730
+ await serverRPC.send("SEND_KV_DELETE", {
1731
+ runId: data.id,
1732
+ key: op.idempotencyKey,
1733
+ delete: {
1734
+ namespace: op.namespace,
1735
+ key: op.key
1736
+ },
1737
+ timestamp: String(highPrecisionTimestamp())
1738
+ });
1739
+ await result;
1740
+ return;
1741
+ }, "kvDeleteFunction");
1499
1742
  const ctx = {
1500
1743
  id: data.id,
1501
1744
  environment: data.meta.environment,
1502
1745
  apiKey: data.meta.apiKey,
1503
1746
  organizationId: data.meta.organizationId,
1504
1747
  isTest: data.meta.isTest,
1748
+ kv: new ContextKeyValueStorage(`workflow:${data.meta.workflowId}`, kvGetFunction, kvSetFunction, kvDeleteFunction),
1749
+ globalKv: new ContextKeyValueStorage(`org:${data.meta.organizationId}`, kvGetFunction, kvSetFunction, kvDeleteFunction),
1750
+ runKv: new ContextKeyValueStorage(`run:${data.id}`, kvGetFunction, kvSetFunction, kvDeleteFunction),
1505
1751
  logger: new ContextLogger(async (level, message, properties) => {
1506
1752
  await serverRPC.send("SEND_LOG", {
1507
1753
  runId: data.id,
@@ -1617,6 +1863,7 @@ initializeRPC_fn = /* @__PURE__ */ __name(async function() {
1617
1863
  };
1618
1864
  const eventData = parsedEventData.data;
1619
1865
  __privateGet(this, _logger3).debug("Parsed event data", eventData);
1866
+ const terminalLink = (await import("terminal-link")).default;
1620
1867
  triggerRunLocalStorage.run({
1621
1868
  performRequest: async (key, options) => {
1622
1869
  const result = new Promise((resolve, reject) => {
@@ -1657,7 +1904,7 @@ initializeRPC_fn = /* @__PURE__ */ __name(async function() {
1657
1904
  }, () => {
1658
1905
  __privateGet(this, _logger3).debug("Running trigger...");
1659
1906
  if (typeof data.meta.attempt === "number" && data.meta.attempt === 0) {
1660
- __privateGet(this, _logger3).log(`Run ${data.id} started \u{1F449} ${(0, import_terminal_link.default)("View on dashboard", `${__privateGet(this, _registerResponse).url}/runs/${data.id}`, {
1907
+ __privateGet(this, _logger3).log(`Run ${data.id} started \u{1F449} ${terminalLink("View on dashboard", `${__privateGet(this, _registerResponse).url}/runs/${data.id}`, {
1661
1908
  fallback: (text, url) => `${text}: (${url})`
1662
1909
  })}`);
1663
1910
  }
@@ -1666,7 +1913,7 @@ initializeRPC_fn = /* @__PURE__ */ __name(async function() {
1666
1913
  timestamp: String(highPrecisionTimestamp())
1667
1914
  }).then(() => {
1668
1915
  return __privateGet(this, _trigger).options.run(eventData, ctx).then((output) => {
1669
- __privateGet(this, _logger3).log(`Run ${data.id} complete \u{1F449} ${(0, import_terminal_link.default)("View on dashboard", `${__privateGet(this, _registerResponse).url}/runs/${data.id}`, {
1916
+ __privateGet(this, _logger3).log(`Run ${data.id} complete \u{1F449} ${terminalLink("View on dashboard", `${__privateGet(this, _registerResponse).url}/runs/${data.id}`, {
1670
1917
  fallback: (text, url) => `${text}: (${url})`
1671
1918
  })}`);
1672
1919
  return serverRPC.send("COMPLETE_WORKFLOW_RUN", {
@@ -1683,9 +1930,9 @@ initializeRPC_fn = /* @__PURE__ */ __name(async function() {
1683
1930
  stackTrace: error2.stack
1684
1931
  };
1685
1932
  }
1686
- const parsedError = import_zod14.z.object({
1687
- name: import_zod14.z.string(),
1688
- message: import_zod14.z.string()
1933
+ const parsedError = import_zod15.z.object({
1934
+ name: import_zod15.z.string(),
1935
+ message: import_zod15.z.string()
1689
1936
  }).passthrough().safeParse(error2);
1690
1937
  if (parsedError.success) {
1691
1938
  return parsedError.data;
@@ -1725,7 +1972,7 @@ initializeHost_fn = /* @__PURE__ */ __name(async function() {
1725
1972
  if (!__privateGet(this, _serverRPC)) {
1726
1973
  throw new Error("Cannot initialize host without an RPC connection");
1727
1974
  }
1728
- const repoInfo = safeGetRepoInfo();
1975
+ const repoInfo = await safeGetRepoInfo();
1729
1976
  const remoteUrl = repoInfo ? await getRemoteUrl(repoInfo.commonGitDir) : void 0;
1730
1977
  const packageMetadata = await getTriggerPackageEnvVars(process.env);
1731
1978
  const response = await __privateMethod(this, _send, send_fn).call(this, "INITIALIZE_HOST_V2", {
@@ -1745,7 +1992,8 @@ initializeHost_fn = /* @__PURE__ */ __name(async function() {
1745
1992
  commitMessage: repoInfo.commitMessage,
1746
1993
  origin: remoteUrl
1747
1994
  } : void 0,
1748
- packageMetadata
1995
+ packageMetadata,
1996
+ env: gatherEnvVars(process.env)
1749
1997
  }
1750
1998
  });
1751
1999
  if (!response) {
@@ -1805,7 +2053,8 @@ async function getTriggerPackageEnvVars(env) {
1805
2053
  __name(getTriggerPackageEnvVars, "getTriggerPackageEnvVars");
1806
2054
  async function getRemoteUrl(cwd) {
1807
2055
  try {
1808
- return await (0, import_git_remote_origin_url.default)({
2056
+ const gitRemoteOriginUrl = (await import("git-remote-origin-url")).default;
2057
+ return await gitRemoteOriginUrl({
1809
2058
  cwd
1810
2059
  });
1811
2060
  } catch (err) {
@@ -1813,18 +2062,28 @@ async function getRemoteUrl(cwd) {
1813
2062
  }
1814
2063
  }
1815
2064
  __name(getRemoteUrl, "getRemoteUrl");
1816
- function safeGetRepoInfo() {
2065
+ async function safeGetRepoInfo() {
1817
2066
  try {
1818
- return (0, import_git_repo_info.default)();
2067
+ const gitRepoInfo = (await import("git-repo-info")).default;
2068
+ return gitRepoInfo();
1819
2069
  } catch (err) {
1820
2070
  return;
1821
2071
  }
1822
2072
  }
1823
2073
  __name(safeGetRepoInfo, "safeGetRepoInfo");
2074
+ function gatherEnvVars(env) {
2075
+ if (!env) {
2076
+ return {};
2077
+ }
2078
+ const envVars = Object.entries(env).filter(([key]) => key.startsWith("TRIGGER_") && key !== "TRIGGER_API_KEY").map(([key, value]) => [
2079
+ key.replace("TRIGGER_", ""),
2080
+ `${value}`
2081
+ ]);
2082
+ return Object.fromEntries(envVars);
2083
+ }
2084
+ __name(gatherEnvVars, "gatherEnvVars");
1824
2085
 
1825
2086
  // src/trigger/index.ts
1826
- var import_chalk2 = __toESM(require("chalk"));
1827
- var import_terminal_link2 = __toESM(require("terminal-link"));
1828
2087
  var _client, _getApiKey, getApiKey_fn;
1829
2088
  var Trigger = class {
1830
2089
  constructor(options) {
@@ -1834,15 +2093,17 @@ var Trigger = class {
1834
2093
  }
1835
2094
  async listen() {
1836
2095
  const apiKey = __privateMethod(this, _getApiKey, getApiKey_fn).call(this);
2096
+ const chalk = (await import("chalk")).default;
2097
+ const terminalLink = (await import("terminal-link")).default;
1837
2098
  if (apiKey.status === "invalid") {
1838
- console.log(`${import_chalk2.default.red("Trigger.dev error")}: ${import_chalk2.default.bold(this.id)} is has an invalid API key ("${import_chalk2.default.italic(apiKey.apiKey)}"), please set the TRIGGER_API_KEY environment variable or pass the apiKey option to a valid value. ${(0, import_terminal_link2.default)("Get your API key here", "https://app.trigger.dev", {
2099
+ console.log(`${chalk.red("Trigger.dev error")}: ${chalk.bold(this.id)} is has an invalid API key ("${chalk.italic(apiKey.apiKey)}"), please set the TRIGGER_API_KEY environment variable or pass the apiKey option to a valid value. ${terminalLink("Get your API key here", "https://app.trigger.dev", {
1839
2100
  fallback(text, url) {
1840
2101
  return `${text} \u{1F449} ${url}`;
1841
2102
  }
1842
2103
  })}`);
1843
2104
  return;
1844
2105
  } else if (apiKey.status === "missing") {
1845
- console.log(`${import_chalk2.default.red("Trigger.dev error")}: ${import_chalk2.default.bold(this.id)} is missing an API key, please set the TRIGGER_API_KEY environment variable or pass the apiKey option to the Trigger constructor. ${(0, import_terminal_link2.default)("Get your API key here", "https://app.trigger.dev", {
2106
+ console.log(`${chalk.red("Trigger.dev error")}: ${chalk.bold(this.id)} is missing an API key, please set the TRIGGER_API_KEY environment variable or pass the apiKey option to the Trigger constructor. ${terminalLink("Get your API key here", "https://app.trigger.dev", {
1846
2107
  fallback(text, url) {
1847
2108
  return `${text} \u{1F449} ${url}`;
1848
2109
  }