@@ -45,12 +45,15 @@ import {
45
45
} from "@trigger.dev/core/v3/workers" ;
46
46
47
47
export class CliApiClient {
48
+ private engineURL : string ;
49
+
48
50
constructor (
49
51
public readonly apiURL : string ,
50
52
// TODO: consider making this required
51
53
public readonly accessToken ?: string
52
54
) {
53
55
this . apiURL = apiURL . replace ( / \/ $ / , "" ) ;
56
+ this . engineURL = this . apiURL ;
54
57
}
55
58
56
59
async createAuthorizationCode ( ) {
@@ -418,6 +421,7 @@ export class CliApiClient {
418
421
heartbeatRun : this . devHeartbeatRun . bind ( this ) ,
419
422
startRunAttempt : this . devStartRunAttempt . bind ( this ) ,
420
423
completeRunAttempt : this . devCompleteRunAttempt . bind ( this ) ,
424
+ setEngineURL : this . setEngineURL . bind ( this ) ,
421
425
} as const ;
422
426
}
423
427
@@ -486,7 +490,7 @@ export class CliApiClient {
486
490
throw new Error ( "devConfig: No access token" ) ;
487
491
}
488
492
489
- return wrapZodFetch ( DevConfigResponseBody , `${ this . apiURL } /engine/v1/dev/config` , {
493
+ return wrapZodFetch ( DevConfigResponseBody , `${ this . engineURL } /engine/v1/dev/config` , {
490
494
headers : {
491
495
Authorization : `Bearer ${ this . accessToken } ` ,
492
496
Accept : "application/json" ,
@@ -503,7 +507,7 @@ export class CliApiClient {
503
507
const maxRetries = 5 ;
504
508
const retryDelay = 1000 ; // Start with 1 second delay
505
509
506
- const eventSource = new EventSource ( `${ this . apiURL } /engine/v1/dev/presence` , {
510
+ const eventSource = new EventSource ( `${ this . engineURL } /engine/v1/dev/presence` , {
507
511
fetch : ( input , init ) =>
508
512
fetch ( input , {
509
513
...init ,
@@ -557,7 +561,7 @@ export class CliApiClient {
557
561
throw new Error ( "devConfig: No access token" ) ;
558
562
}
559
563
560
- return wrapZodFetch ( DevDequeueResponseBody , `${ this . apiURL } /engine/v1/dev/dequeue` , {
564
+ return wrapZodFetch ( DevDequeueResponseBody , `${ this . engineURL } /engine/v1/dev/dequeue` , {
561
565
method : "POST" ,
562
566
headers : {
563
567
Authorization : `Bearer ${ this . accessToken } ` ,
@@ -575,7 +579,7 @@ export class CliApiClient {
575
579
throw new Error ( "devConfig: No access token" ) ;
576
580
}
577
581
578
- return wrapZodFetch ( z . unknown ( ) , `${ this . apiURL } /engine/v1/dev/runs/${ runId } /logs/debug` , {
582
+ return wrapZodFetch ( z . unknown ( ) , `${ this . engineURL } /engine/v1/dev/runs/${ runId } /logs/debug` , {
579
583
method : "POST" ,
580
584
headers : {
581
585
Authorization : `Bearer ${ this . accessToken } ` ,
@@ -591,7 +595,7 @@ export class CliApiClient {
591
595
) : Promise < ApiResult < WorkloadRunLatestSnapshotResponseBody > > {
592
596
return wrapZodFetch (
593
597
WorkloadRunLatestSnapshotResponseBody ,
594
- `${ this . apiURL } /engine/v1/dev/runs/${ runId } /snapshots/latest` ,
598
+ `${ this . engineURL } /engine/v1/dev/runs/${ runId } /snapshots/latest` ,
595
599
{
596
600
method : "GET" ,
597
601
headers : {
@@ -609,7 +613,7 @@ export class CliApiClient {
609
613
) : Promise < ApiResult < WorkloadHeartbeatResponseBody > > {
610
614
return wrapZodFetch (
611
615
WorkloadHeartbeatResponseBody ,
612
- `${ this . apiURL } /engine/v1/dev/runs/${ runId } /snapshots/${ snapshotId } /heartbeat` ,
616
+ `${ this . engineURL } /engine/v1/dev/runs/${ runId } /snapshots/${ snapshotId } /heartbeat` ,
613
617
{
614
618
method : "POST" ,
615
619
headers : {
@@ -628,7 +632,7 @@ export class CliApiClient {
628
632
) : Promise < ApiResult < WorkloadRunAttemptStartResponseBody > > {
629
633
return wrapZodFetch (
630
634
WorkloadRunAttemptStartResponseBody ,
631
- `${ this . apiURL } /engine/v1/dev/runs/${ runId } /snapshots/${ snapshotId } /attempts/start` ,
635
+ `${ this . engineURL } /engine/v1/dev/runs/${ runId } /snapshots/${ snapshotId } /attempts/start` ,
632
636
{
633
637
method : "POST" ,
634
638
headers : {
@@ -648,7 +652,7 @@ export class CliApiClient {
648
652
) : Promise < ApiResult < WorkloadRunAttemptCompleteResponseBody > > {
649
653
return wrapZodFetch (
650
654
WorkloadRunAttemptCompleteResponseBody ,
651
- `${ this . apiURL } /engine/v1/dev/runs/${ runId } /snapshots/${ snapshotId } /attempts/complete` ,
655
+ `${ this . engineURL } /engine/v1/dev/runs/${ runId } /snapshots/${ snapshotId } /attempts/complete` ,
652
656
{
653
657
method : "POST" ,
654
658
headers : {
@@ -659,4 +663,8 @@ export class CliApiClient {
659
663
}
660
664
) ;
661
665
}
666
+
667
+ private setEngineURL ( engineURL : string ) {
668
+ this . engineURL = engineURL . replace ( / \/ $ / , "" ) ;
669
+ }
662
670
}
0 commit comments