@buddy-works/sandbox-sdk 0.0.3-rc.0 → 0.1.0-rc.1

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.
@@ -0,0 +1,1629 @@
1
+ import { z } from "zod";
2
+ import { inspect } from "node:util";
3
+ import { Writable } from "node:stream";
4
+
5
+ //#region src/api/openapi/types.gen.d.ts
6
+ /**
7
+ * Sandbox reference
8
+ */
9
+ type SandboxIdView = {
10
+ /**
11
+ * API endpoint to GET this object
12
+ */
13
+ readonly url?: string;
14
+ /**
15
+ * Web URL to view this object in Buddy.works
16
+ */
17
+ readonly html_url?: string;
18
+ /**
19
+ * The ID of the sandbox
20
+ */
21
+ id?: string;
22
+ /**
23
+ * A human-readable ID. Alphanumeric characters, underscores, and hyphens (hyphens cannot appear at the start or end).
24
+ */
25
+ identifier?: string;
26
+ /**
27
+ * The name of the sandbox
28
+ */
29
+ name?: string;
30
+ /**
31
+ * The current status of the sandbox
32
+ */
33
+ status?: "STARTING" | "STOPPING" | "FAILED" | "RUNNING" | "STOPPED" | "RESTORING";
34
+ };
35
+ /**
36
+ * Integration reference
37
+ */
38
+ type IntegrationIdView = {
39
+ /**
40
+ * API endpoint to GET this object
41
+ */
42
+ readonly url?: string;
43
+ /**
44
+ * Web URL to view this object in Buddy.works
45
+ */
46
+ readonly html_url?: string;
47
+ /**
48
+ * A human-readable ID of the integration
49
+ */
50
+ identifier?: string;
51
+ /**
52
+ * The unique hash ID of the integration
53
+ */
54
+ hash_id?: string;
55
+ /**
56
+ * The name of the integration
57
+ */
58
+ name?: string;
59
+ /**
60
+ * The type of integration
61
+ */
62
+ type?: "GIT_HUB" | "BITBUCKET" | "GOOGLE" | "DIGITAL_OCEAN" | "SLACK" | "MODULUS" | "HEROKU" | "AMAZON" | "GIT_LAB" | "SHOPIFY" | "GIT_HUB_ENTERPRISE" | "GIT_LAB_ENTERPRISE" | "PUSHOVER" | "PUSHBULLET" | "RACKSPACE" | "CUSTOM" | "CLOUDFLARE" | "NEW_RELIC" | "SENTRY" | "ROLLBAR" | "DATADOG" | "DO_SPACES" | "HONEYBADGER" | "VULTR" | "SENTRY_ENTERPRISE" | "LOGGLY" | "HIP_CHAT" | "FIREBASE" | "TELEGRAM" | "AZURE" | "UPCLOUD" | "GHOST_INSPECTOR" | "NETLIFY" | "AZURE_CLOUD" | "MICROSOFT_TEAMS" | "GOOGLE_SERVICE_ACCOUNT" | "GOOGLE_PLAY_STORE" | "DOCKER_HUB" | "APP_STORE" | "GIT_HUB_APP" | "GIT_HUB_APP_ENTERPRISE" | "GIT_HUB_API" | "ATOP" | "SNYK" | "STACK_HAWK" | "BLACKFIRE" | "BACKBLAZE" | "ONE_LOGIN" | "OKTA" | "CONTENTFUL";
63
+ /**
64
+ * The authentication method used by the integration
65
+ */
66
+ auth_type?: "OAUTH" | "TOKEN" | "API_KEY" | "APP" | "APP_SPRYKER" | "TOKEN_APP_EXTENSION" | "DEFAULT" | "OIDC" | "TRUSTED" | "APP_RW";
67
+ /**
68
+ * The host URL for custom integrations
69
+ */
70
+ host_url?: string;
71
+ /**
72
+ * The webhook URL for receiving notifications
73
+ */
74
+ webhook_address?: string;
75
+ /**
76
+ * The ATOP service URL
77
+ */
78
+ atop_url?: string;
79
+ /**
80
+ * The application ID for Azure Cloud integrations
81
+ */
82
+ app_id?: string;
83
+ /**
84
+ * The Google Cloud project ID
85
+ */
86
+ google_project?: string;
87
+ /**
88
+ * The JWT audience for token validation
89
+ */
90
+ audience?: string;
91
+ };
92
+ /**
93
+ * User/member reference
94
+ */
95
+ type MemberView = {
96
+ /**
97
+ * API endpoint to GET this object
98
+ */
99
+ readonly url?: string;
100
+ /**
101
+ * Web URL to view this object in Buddy.works
102
+ */
103
+ readonly html_url?: string;
104
+ /**
105
+ * The ID of the user
106
+ */
107
+ id?: number;
108
+ /**
109
+ * The name of the user
110
+ */
111
+ name?: string;
112
+ /**
113
+ * The avatar URL of the user
114
+ */
115
+ avatar_url?: string;
116
+ /**
117
+ * The email address of the user
118
+ */
119
+ email?: string;
120
+ /**
121
+ * Whether the user has admin privileges
122
+ */
123
+ admin?: boolean;
124
+ /**
125
+ * Whether the user is workspace owner
126
+ */
127
+ workspace_owner?: boolean;
128
+ };
129
+ type ProjectView = {
130
+ /**
131
+ * API endpoint to GET this object
132
+ */
133
+ readonly url?: string;
134
+ /**
135
+ * Web URL to view this object in Buddy.works
136
+ */
137
+ readonly html_url?: string;
138
+ /**
139
+ * The human-readable ID of the project
140
+ */
141
+ name?: string;
142
+ /**
143
+ * The Name of the project
144
+ */
145
+ display_name: string;
146
+ /**
147
+ * The status of the project
148
+ */
149
+ status?: string;
150
+ /**
151
+ * Indicates if this is a public project
152
+ */
153
+ access?: "PRIVATE" | "PUBLIC";
154
+ /**
155
+ * The creation date of the project
156
+ */
157
+ create_date?: Date;
158
+ /**
159
+ * Repo slug of the Bitbucket, GitHub or GitLab project. Required when adding the integrated project
160
+ */
161
+ external_project_id?: string;
162
+ /**
163
+ * ID of the project in GitLab
164
+ */
165
+ git_lab_project_id?: number;
166
+ /**
167
+ * SSH or HTTPS url of the git repository. Required when adding the project integrated with custom git repository
168
+ */
169
+ custom_repo_url?: string;
170
+ /**
171
+ * Username used to authorize access to the git repository. Required when adding the project integrated with custom git repository
172
+ */
173
+ custom_repo_user?: string;
174
+ /**
175
+ * Password used to authorize access to the git repository. Required when adding the project integrated with custom git repository and the provided `custom_repo_url` is the HTTPS url
176
+ */
177
+ custom_repo_pass?: string;
178
+ /**
179
+ * The ID of the private SSH key used to authorize access to the git repository. Required when adding the project integrated with private git server by SSH url
180
+ */
181
+ custom_repo_ssh_key_id?: number;
182
+ created_by?: MemberView;
183
+ /**
184
+ * The HTTP repository URL
185
+ */
186
+ http_repository?: string;
187
+ /**
188
+ * The SSH repository URL
189
+ */
190
+ ssh_repository?: string;
191
+ /**
192
+ * The default branch name
193
+ */
194
+ default_branch?: string;
195
+ integration?: IntegrationIdView;
196
+ /**
197
+ * Defines whether the submodules are fetched during the runs in this project
198
+ */
199
+ fetch_submodules?: boolean;
200
+ /**
201
+ * Name of the key that will be used to authorize while fetching the submodules. Required when `fetch_submodules` is set to `true`
202
+ */
203
+ fetch_submodules_env_key?: string;
204
+ /**
205
+ * Enables/disables pull requests in the project. Available only for projects synchronized with GitHub or GitHub Enterprise repository
206
+ */
207
+ allow_pull_requests?: boolean;
208
+ /**
209
+ * If set to true, the default branch will be updated from GitHub/GitLab/Bitbucket.
210
+ */
211
+ update_default_branch_from_external?: boolean;
212
+ /**
213
+ * If set to true, the project is created without any repository attached.
214
+ */
215
+ without_repository?: boolean;
216
+ };
217
+ /**
218
+ * The TLS/SSL encryption settings of the tunnel
219
+ */
220
+ type TlsSettingsView = {
221
+ /**
222
+ * API endpoint to GET this object
223
+ */
224
+ readonly url?: string;
225
+ /**
226
+ * Web URL to view this object in Buddy.works
227
+ */
228
+ readonly html_url?: string;
229
+ /**
230
+ * Where to terminate TLS connection
231
+ */
232
+ terminate_at?: "REGION" | "AGENT" | "TARGET";
233
+ };
234
+ /**
235
+ * The HTTP-specific settings of the tunnel
236
+ */
237
+ type HttpSettingsView = {
238
+ /**
239
+ * API endpoint to GET this object
240
+ */
241
+ readonly url?: string;
242
+ /**
243
+ * Web URL to view this object in Buddy.works
244
+ */
245
+ readonly html_url?: string;
246
+ /**
247
+ * Whether to verify SSL/TLS certificates
248
+ */
249
+ verify_certificate?: boolean;
250
+ /**
251
+ * Enable HTTP compression
252
+ */
253
+ compression?: boolean;
254
+ /**
255
+ * Enable HTTP/2 protocol support
256
+ */
257
+ http2?: boolean;
258
+ /**
259
+ * Log incoming HTTP requests
260
+ */
261
+ log_requests?: boolean;
262
+ /**
263
+ * Custom HTTP headers to add to requests
264
+ */
265
+ request_headers?: Array<{
266
+ [key: string]: string;
267
+ }>;
268
+ /**
269
+ * List of allowed User-Agent strings
270
+ */
271
+ whitelist_user_agents?: Array<string>;
272
+ /**
273
+ * Rewrite the Host header to this value
274
+ */
275
+ rewrite_host_header?: string;
276
+ /**
277
+ * Custom HTTP headers to add to responses
278
+ */
279
+ response_headers?: Array<{
280
+ [key: string]: string;
281
+ }>;
282
+ /**
283
+ * Basic authentication username
284
+ */
285
+ login?: string;
286
+ /**
287
+ * Circuit breaker threshold (number of failed requests)
288
+ */
289
+ circuit_breaker?: number;
290
+ /**
291
+ * Base path for serving requests
292
+ */
293
+ serve_path?: string;
294
+ /**
295
+ * Type of authentication used
296
+ */
297
+ auth_type?: "NONE" | "BASIC" | "BUDDY";
298
+ };
299
+ type TunnelView = {
300
+ /**
301
+ * API endpoint to GET this object
302
+ */
303
+ readonly url?: string;
304
+ /**
305
+ * Web URL to view this object in Buddy.works
306
+ */
307
+ readonly html_url?: string;
308
+ /**
309
+ * The name of the tunnel
310
+ */
311
+ name: string;
312
+ /**
313
+ * The endpoint URL of the tunnel
314
+ */
315
+ endpoint: string;
316
+ /**
317
+ * The type of the tunnel
318
+ */
319
+ type: "TCP" | "TLS" | "HTTP" | "SSH";
320
+ /**
321
+ * The region where the tunnel is deployed
322
+ */
323
+ region: "US" | "EU" | "AS";
324
+ /**
325
+ * The IP addresses or domains allowed to access the tunnel
326
+ */
327
+ whitelist?: Array<string>;
328
+ /**
329
+ * The connection timeout of the tunnel in seconds
330
+ */
331
+ timeout?: number;
332
+ http?: HttpSettingsView;
333
+ tls?: TlsSettingsView;
334
+ /**
335
+ * The url of the tunnel
336
+ */
337
+ endpoint_url?: string;
338
+ };
339
+ type SandboxesView = {
340
+ /**
341
+ * API endpoint to GET this object
342
+ */
343
+ readonly url?: string;
344
+ /**
345
+ * Web URL to view this object in Buddy.works
346
+ */
347
+ readonly html_url?: string;
348
+ sandboxes?: Array<SandboxIdView>;
349
+ };
350
+ /**
351
+ * Sandbox content listing
352
+ */
353
+ type SandboxContentView = {
354
+ /**
355
+ * API endpoint to GET this object
356
+ */
357
+ readonly url?: string;
358
+ /**
359
+ * Web URL to view this object in Buddy.works
360
+ */
361
+ readonly html_url?: string;
362
+ /**
363
+ * List of content items in the directory
364
+ */
365
+ contents?: Array<SandboxContentItem>;
366
+ };
367
+ /**
368
+ * Content item in a sandbox
369
+ */
370
+ type SandboxContentItem = {
371
+ /**
372
+ * API endpoint to GET this object
373
+ */
374
+ readonly url?: string;
375
+ /**
376
+ * Web URL to view this object in Buddy.works
377
+ */
378
+ readonly html_url?: string;
379
+ /**
380
+ * The content type (FILE or DIR)
381
+ */
382
+ type?: "FILE" | "DIR";
383
+ /**
384
+ * The name of the file or directory
385
+ */
386
+ name?: string;
387
+ /**
388
+ * The path to the file or directory
389
+ */
390
+ path?: string;
391
+ /**
392
+ * The size of the file in bytes
393
+ */
394
+ size?: bigint;
395
+ };
396
+ type SandboxCommandView = {
397
+ /**
398
+ * API endpoint to GET this object
399
+ */
400
+ readonly url?: string;
401
+ /**
402
+ * Web URL to view this object in Buddy.works
403
+ */
404
+ readonly html_url?: string;
405
+ /**
406
+ * The ID of the command
407
+ */
408
+ id?: string;
409
+ /**
410
+ * Command to execute in the sandbox
411
+ */
412
+ command?: string;
413
+ /**
414
+ * Runtime environment for command execution (default: `BASH`)
415
+ */
416
+ runtime?: "BASH" | "JAVASCRIPT" | "TYPESCRIPT" | "PYTHON";
417
+ /**
418
+ * Command execution status
419
+ */
420
+ status?: "INPROGRESS" | "SUCCESSFUL" | "FAILED";
421
+ /**
422
+ * Command exit code
423
+ */
424
+ exit_code?: number;
425
+ /**
426
+ * API endpoint URL to retrieve logs for this command
427
+ */
428
+ logs_url?: string;
429
+ };
430
+ type SandboxCommandLog = {
431
+ /**
432
+ * The type of command output stream
433
+ */
434
+ type?: "STDOUT" | "STDERR";
435
+ /**
436
+ * The command execution logs.
437
+ */
438
+ data?: string;
439
+ };
440
+ type ExecuteSandboxCommandRequest = {
441
+ /**
442
+ * Command to execute in the sandbox
443
+ */
444
+ command: string;
445
+ /**
446
+ * Runtime environment for command execution (default: `BASH`)
447
+ */
448
+ runtime?: "BASH" | "JAVASCRIPT" | "TYPESCRIPT" | "PYTHON";
449
+ };
450
+ /**
451
+ * The list of variables you can use the action
452
+ */
453
+ type EnvironmentVariableView = {
454
+ /**
455
+ * The ID of the variable
456
+ */
457
+ id?: number;
458
+ /**
459
+ * The name of the variable
460
+ */
461
+ key?: string;
462
+ /**
463
+ * The value of the variable
464
+ */
465
+ value?: string;
466
+ /**
467
+ * The type of the added variable
468
+ */
469
+ type?: "VAR" | "FILE" | "SSH_KEY" | "IOS_KEYCHAIN" | "IOS_PROVISION_PROFILES" | "SSH_PUBLIC_KEY" | "GPG_KEY";
470
+ /**
471
+ * If set to `true` the variable value will be encrypted and hidden
472
+ */
473
+ encrypted?: boolean;
474
+ /**
475
+ * If set to `true` the variable value can be set by Buddy actions
476
+ */
477
+ settable?: boolean;
478
+ /**
479
+ * Available only if `type=VAR`. If set to `true` the variable value can be set by Buddy actions only for execution time
480
+ */
481
+ run_only_settable?: boolean;
482
+ /**
483
+ * The optional description of the variable
484
+ */
485
+ description?: string;
486
+ /**
487
+ * Initial path for the variable
488
+ */
489
+ init_path?: string;
490
+ /**
491
+ * Default value for the variable
492
+ */
493
+ defaults?: string;
494
+ /**
495
+ * Specifies where to copy the file on each run. Set if `type` is `SSH_KEY`
496
+ */
497
+ file_path?: string;
498
+ /**
499
+ * File permission set on copy to a container on each run. Set if `type` is `SSH_KEY`
500
+ */
501
+ file_chmod?: string;
502
+ /**
503
+ * Set if `type` is `SSH_KEY`. If it's `NONE`, the variable can be used as a parameter in an action. For `CONTAINER`, the given key is additionally copied to an action container on each run
504
+ */
505
+ file_place?: "NONE" | "CONTAINER";
506
+ /**
507
+ * Whether the file is binary
508
+ */
509
+ binary?: boolean;
510
+ /**
511
+ * Public value for SSH key type variables
512
+ */
513
+ public_value?: string;
514
+ /**
515
+ * Fingerprint of SSH key
516
+ */
517
+ key_fingerprint?: string;
518
+ /**
519
+ * Checksum of the variable value
520
+ */
521
+ checksum?: string;
522
+ /**
523
+ * Password for certificates
524
+ */
525
+ password?: string;
526
+ /**
527
+ * Passphrase for encrypted SSH keys
528
+ */
529
+ passphrase?: string;
530
+ /**
531
+ * GPG key identifier
532
+ */
533
+ key_identifier?: string;
534
+ };
535
+ type CloneSandboxRequest = {
536
+ /**
537
+ * The ID of the sandbox to clone
538
+ */
539
+ source_sandbox_id: string;
540
+ /**
541
+ * The name of the sandbox
542
+ */
543
+ name: string;
544
+ /**
545
+ * A human-readable ID. Alphanumeric characters, underscores, and hyphens (hyphens cannot appear at the start or end).
546
+ */
547
+ identifier?: string;
548
+ };
549
+ type SandboxResponse = {
550
+ /**
551
+ * API endpoint to GET this object
552
+ */
553
+ readonly url?: string;
554
+ /**
555
+ * Web URL to view this object in Buddy.works
556
+ */
557
+ readonly html_url?: string;
558
+ /**
559
+ * The ID of the sandbox
560
+ */
561
+ id?: string;
562
+ /**
563
+ * A human-readable ID. Alphanumeric characters, underscores, and hyphens (hyphens cannot appear at the start or end).
564
+ */
565
+ identifier?: string;
566
+ /**
567
+ * The name of the sandbox
568
+ */
569
+ name?: string;
570
+ /**
571
+ * The current status of the sandbox
572
+ */
573
+ status?: "STARTING" | "STOPPING" | "FAILED" | "RUNNING" | "STOPPED" | "RESTORING";
574
+ /**
575
+ * The operating system of the sandbox ["ubuntu:22.04", "ubuntu:24.04"]
576
+ */
577
+ os?: string;
578
+ /**
579
+ * The resource configuration of the sandbox (CPU x RAM)
580
+ */
581
+ resources?: "1x2" | "2x4" | "3x6" | "4x8" | "5x10" | "6x12" | "7x14" | "8x16" | "9x18" | "10x20" | "11x22" | "12x24" | "CUSTOM";
582
+ /**
583
+ * The commands to run during setup of the sandbox
584
+ */
585
+ install_commands?: string;
586
+ /**
587
+ * The run command of the sandbox
588
+ */
589
+ run_command?: string;
590
+ /**
591
+ * The application directory of the sandbox
592
+ */
593
+ app_dir?: string;
594
+ /**
595
+ * The application type of the sandbox (passed command or existent service eg. apache2)
596
+ */
597
+ app_type?: "CMD" | "SERVICE";
598
+ /**
599
+ * The list of tags associated with the sandbox
600
+ */
601
+ tags?: Array<string>;
602
+ /**
603
+ * The current application status of the sandbox
604
+ */
605
+ app_status?: "NONE" | "RUNNING" | "ENDED" | "FAILED";
606
+ /**
607
+ * The boot logs of the sandbox
608
+ */
609
+ boot_logs?: Array<string>;
610
+ /**
611
+ * The current setup status of the sandbox
612
+ */
613
+ setup_status?: "INPROGRESS" | "SUCCESS" | "FAILED";
614
+ /**
615
+ * The tunnel endpoints of the sandbox
616
+ */
617
+ endpoints?: Array<TunnelView>;
618
+ project?: ProjectView;
619
+ /**
620
+ * The environment variables of the sandbox
621
+ */
622
+ variables?: Array<EnvironmentVariableView>;
623
+ };
624
+ /**
625
+ * The environment variables of the sandbox
626
+ */
627
+ type AddVariableInObjectRequestWritable = {
628
+ /**
629
+ * The name of the variable
630
+ */
631
+ key: string;
632
+ /**
633
+ * The value of the variable
634
+ */
635
+ value?: string;
636
+ /**
637
+ * If set to `true` the variable value can be set by Buddy actions
638
+ */
639
+ settable?: boolean;
640
+ /**
641
+ * Available only if `type=VAR`. If set to `true` the variable value can be set by Buddy actions only for execution time
642
+ */
643
+ run_only_settable?: boolean;
644
+ /**
645
+ * If set to `true` the variable value will be encrypted and hidden
646
+ */
647
+ encrypted?: boolean;
648
+ /**
649
+ * The optional description of the variable
650
+ */
651
+ description?: string;
652
+ /**
653
+ * Initial path for the variable
654
+ */
655
+ init_path?: string;
656
+ /**
657
+ * Default value for the variable
658
+ */
659
+ defaults?: string;
660
+ /**
661
+ * Specifies where to copy the file on each run. Set if `type` is `SSH_KEY`
662
+ */
663
+ file_path?: string;
664
+ /**
665
+ * File permission set on copy to a container on each run. Set if `type` is `SSH_KEY`
666
+ */
667
+ file_chmod?: string;
668
+ /**
669
+ * Set if `type` is `SSH_KEY`. If it's `NONE`, the variable can be used as a parameter in an action. For `CONTAINER`, the given key is additionally copied to an action container on each run
670
+ */
671
+ file_place?: "NONE" | "CONTAINER";
672
+ /**
673
+ * Password for certificates
674
+ */
675
+ password?: string;
676
+ /**
677
+ * Passphrase for encrypted SSH keys
678
+ */
679
+ passphrase?: string;
680
+ /**
681
+ * GPG key identifier
682
+ */
683
+ key_identifier?: string;
684
+ /**
685
+ * The type of the added variable
686
+ */
687
+ type: "VAR" | "FILE" | "SSH_KEY" | "IOS_KEYCHAIN" | "IOS_PROVISION_PROFILES" | "SSH_PUBLIC_KEY" | "GPG_KEY";
688
+ };
689
+ /**
690
+ * The TLS/SSL encryption settings of the tunnel
691
+ */
692
+ type TlsSettingsViewWritable = {
693
+ /**
694
+ * Private key for TLS certificate
695
+ */
696
+ private_key?: string;
697
+ /**
698
+ * TLS certificate
699
+ */
700
+ certificate?: string;
701
+ /**
702
+ * Certificate Authority certificate
703
+ */
704
+ ca_certificate?: string;
705
+ /**
706
+ * Where to terminate TLS connection
707
+ */
708
+ terminate_at?: "REGION" | "AGENT" | "TARGET";
709
+ };
710
+ /**
711
+ * The HTTP-specific settings of the tunnel
712
+ */
713
+ type HttpSettingsViewWritable = {
714
+ /**
715
+ * Whether to verify SSL/TLS certificates
716
+ */
717
+ verify_certificate?: boolean;
718
+ /**
719
+ * Enable HTTP compression
720
+ */
721
+ compression?: boolean;
722
+ /**
723
+ * Enable HTTP/2 protocol support
724
+ */
725
+ http2?: boolean;
726
+ /**
727
+ * Log incoming HTTP requests
728
+ */
729
+ log_requests?: boolean;
730
+ /**
731
+ * Custom HTTP headers to add to requests
732
+ */
733
+ request_headers?: Array<{
734
+ [key: string]: string;
735
+ }>;
736
+ /**
737
+ * List of allowed User-Agent strings
738
+ */
739
+ whitelist_user_agents?: Array<string>;
740
+ /**
741
+ * Rewrite the Host header to this value
742
+ */
743
+ rewrite_host_header?: string;
744
+ /**
745
+ * Custom HTTP headers to add to responses
746
+ */
747
+ response_headers?: Array<{
748
+ [key: string]: string;
749
+ }>;
750
+ /**
751
+ * Basic authentication username
752
+ */
753
+ login?: string;
754
+ /**
755
+ * Basic authentication password
756
+ */
757
+ password?: string;
758
+ /**
759
+ * Custom TLS Certificate Authority
760
+ */
761
+ tls_ca?: string;
762
+ /**
763
+ * Circuit breaker threshold (number of failed requests)
764
+ */
765
+ circuit_breaker?: number;
766
+ /**
767
+ * Base path for serving requests
768
+ */
769
+ serve_path?: string;
770
+ /**
771
+ * Type of authentication used
772
+ */
773
+ auth_type?: "NONE" | "BASIC" | "BUDDY";
774
+ };
775
+ type TunnelViewWritable = {
776
+ /**
777
+ * The name of the tunnel
778
+ */
779
+ name: string;
780
+ /**
781
+ * The endpoint URL of the tunnel
782
+ */
783
+ endpoint: string;
784
+ /**
785
+ * The type of the tunnel
786
+ */
787
+ type: "TCP" | "TLS" | "HTTP" | "SSH";
788
+ /**
789
+ * The region where the tunnel is deployed
790
+ */
791
+ region: "US" | "EU" | "AS";
792
+ /**
793
+ * The IP addresses or domains allowed to access the tunnel
794
+ */
795
+ whitelist?: Array<string>;
796
+ /**
797
+ * The connection timeout of the tunnel in seconds
798
+ */
799
+ timeout?: number;
800
+ http?: HttpSettingsViewWritable;
801
+ tls?: TlsSettingsViewWritable;
802
+ /**
803
+ * The url of the tunnel
804
+ */
805
+ endpoint_url?: string;
806
+ };
807
+ type CreateNewSandboxRequestWritable = {
808
+ /**
809
+ * The name of the sandbox
810
+ */
811
+ name: string;
812
+ /**
813
+ * A human-readable ID. Alphanumeric characters, underscores, and hyphens (hyphens cannot appear at the start or end).
814
+ */
815
+ identifier?: string;
816
+ /**
817
+ * The operating system of the sandbox ["ubuntu:22.04", "ubuntu:24.04"]
818
+ */
819
+ os: string;
820
+ /**
821
+ * The resource configuration of the sandbox (CPU x RAM)
822
+ */
823
+ resources?: "1x2" | "2x4" | "3x6" | "4x8" | "5x10" | "6x12" | "7x14" | "8x16" | "9x18" | "10x20" | "11x22" | "12x24" | "CUSTOM";
824
+ /**
825
+ * The commands to run during setup of the sandbox
826
+ */
827
+ install_commands?: string;
828
+ /**
829
+ * The run command of the sandbox
830
+ */
831
+ run_command?: string;
832
+ /**
833
+ * The application directory of the sandbox
834
+ */
835
+ app_dir?: string;
836
+ /**
837
+ * The application type of the sandbox (passed command or existent service eg. apache2)
838
+ */
839
+ app_type?: "CMD" | "SERVICE";
840
+ /**
841
+ * The list of tags associated with the sandbox
842
+ */
843
+ tags?: Array<string>;
844
+ /**
845
+ * The tunnel endpoints of the sandbox
846
+ */
847
+ endpoints?: Array<TunnelViewWritable>;
848
+ /**
849
+ * The environment variables of the sandbox
850
+ */
851
+ variables?: Array<AddVariableInObjectRequestWritable>;
852
+ };
853
+ type CreateFromSnapshotRequestWritable = {
854
+ /**
855
+ * The ID of the snapshot to create from
856
+ */
857
+ snapshot_id: string;
858
+ /**
859
+ * The name of the sandbox
860
+ */
861
+ name: string;
862
+ /**
863
+ * A human-readable ID. Alphanumeric characters, underscores, and hyphens (hyphens cannot appear at the start or end).
864
+ */
865
+ identifier?: string;
866
+ /**
867
+ * The operating system of the sandbox ["ubuntu:22.04", "ubuntu:24.04"]
868
+ */
869
+ os?: string;
870
+ /**
871
+ * The resource configuration of the sandbox (CPU x RAM)
872
+ */
873
+ resources?: "1x2" | "2x4" | "3x6" | "4x8" | "5x10" | "6x12" | "7x14" | "8x16" | "9x18" | "10x20" | "11x22" | "12x24" | "CUSTOM";
874
+ /**
875
+ * The commands to run during setup of the sandbox
876
+ */
877
+ install_commands?: string;
878
+ /**
879
+ * The run command of the sandbox
880
+ */
881
+ run_command?: string;
882
+ /**
883
+ * The application directory of the sandbox
884
+ */
885
+ app_dir?: string;
886
+ /**
887
+ * The application type of the sandbox (passed command or existent service eg. apache2)
888
+ */
889
+ app_type?: "CMD" | "SERVICE";
890
+ /**
891
+ * The list of tags associated with the sandbox
892
+ */
893
+ tags?: Array<string>;
894
+ /**
895
+ * The tunnel endpoints of the sandbox
896
+ */
897
+ endpoints?: Array<TunnelViewWritable>;
898
+ /**
899
+ * The environment variables of the sandbox
900
+ */
901
+ variables?: Array<EnvironmentVariableView>;
902
+ };
903
+ type GetSandboxesData = {
904
+ body?: never;
905
+ path: {
906
+ /**
907
+ * The human-readable ID of the workspace
908
+ */
909
+ workspace_domain: string;
910
+ };
911
+ query: {
912
+ /**
913
+ * The human-readable ID of the project to filter sandboxes
914
+ */
915
+ project_name: string;
916
+ };
917
+ url: "/workspaces/{workspace_domain}/sandboxes";
918
+ };
919
+ type AddSandboxData = {
920
+ body?: CloneSandboxRequest | CreateFromSnapshotRequestWritable | CreateNewSandboxRequestWritable;
921
+ path: {
922
+ /**
923
+ * The human-readable ID of the workspace
924
+ */
925
+ workspace_domain: string;
926
+ };
927
+ query: {
928
+ /**
929
+ * The human-readable ID of the project to filter sandboxes
930
+ */
931
+ project_name: string;
932
+ };
933
+ url: "/workspaces/{workspace_domain}/sandboxes";
934
+ };
935
+ type DeleteSandboxData = {
936
+ body?: never;
937
+ path: {
938
+ /**
939
+ * The human-readable ID of the workspace
940
+ */
941
+ workspace_domain: string;
942
+ /**
943
+ * The ID of the sandbox
944
+ */
945
+ id: string;
946
+ };
947
+ query?: never;
948
+ url: "/workspaces/{workspace_domain}/sandboxes/{id}";
949
+ };
950
+ type GetSandboxData = {
951
+ body?: never;
952
+ path: {
953
+ /**
954
+ * The human-readable ID of the workspace
955
+ */
956
+ workspace_domain: string;
957
+ /**
958
+ * The ID of the sandbox
959
+ */
960
+ id: string;
961
+ };
962
+ query?: never;
963
+ url: "/workspaces/{workspace_domain}/sandboxes/{id}";
964
+ };
965
+ type GetSandboxResponses = {
966
+ 200: SandboxResponse;
967
+ };
968
+ type GetSandboxResponse = GetSandboxResponses[keyof GetSandboxResponses];
969
+ type ExecuteSandboxCommandData = {
970
+ body?: ExecuteSandboxCommandRequest;
971
+ path: {
972
+ /**
973
+ * The human-readable ID of the workspace
974
+ */
975
+ workspace_domain: string;
976
+ /**
977
+ * The ID of the sandbox
978
+ */
979
+ sandbox_id: string;
980
+ };
981
+ query?: never;
982
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/commands";
983
+ };
984
+ type ExecuteSandboxCommandResponses = {
985
+ 200: SandboxCommandView;
986
+ };
987
+ type ExecuteSandboxCommandResponse = ExecuteSandboxCommandResponses[keyof ExecuteSandboxCommandResponses];
988
+ type GetSandboxCommandData = {
989
+ body?: never;
990
+ path: {
991
+ /**
992
+ * The human-readable ID of the workspace
993
+ */
994
+ workspace_domain: string;
995
+ /**
996
+ * The ID of the sandbox
997
+ */
998
+ sandbox_id: string;
999
+ /**
1000
+ * The ID of the command
1001
+ */
1002
+ id: string;
1003
+ };
1004
+ query?: never;
1005
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/commands/{id}";
1006
+ };
1007
+ type GetSandboxCommandLogsData = {
1008
+ body?: never;
1009
+ path: {
1010
+ /**
1011
+ * The human-readable ID of the workspace
1012
+ */
1013
+ workspace_domain: string;
1014
+ /**
1015
+ * The ID of the sandbox
1016
+ */
1017
+ sandbox_id: string;
1018
+ /**
1019
+ * The ID of the command
1020
+ */
1021
+ command_id: string;
1022
+ };
1023
+ query?: {
1024
+ /**
1025
+ * If true, streams logs until the command completes
1026
+ */
1027
+ follow?: boolean;
1028
+ };
1029
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/commands/{command_id}/logs";
1030
+ };
1031
+ type TerminateSandboxCommandData = {
1032
+ body?: never;
1033
+ path: {
1034
+ /**
1035
+ * The human-readable ID of the workspace
1036
+ */
1037
+ workspace_domain: string;
1038
+ /**
1039
+ * The ID of the sandbox
1040
+ */
1041
+ sandbox_id: string;
1042
+ /**
1043
+ * The ID of the command
1044
+ */
1045
+ command_id: string;
1046
+ };
1047
+ query?: never;
1048
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/commands/{command_id}/terminate";
1049
+ };
1050
+ type DeleteSandboxFileData = {
1051
+ body?: never;
1052
+ path: {
1053
+ /**
1054
+ * The human-readable ID of the workspace
1055
+ */
1056
+ workspace_domain: string;
1057
+ /**
1058
+ * The ID of the sandbox
1059
+ */
1060
+ sandbox_id: string;
1061
+ /**
1062
+ * Absolute path to the file or directory to delete
1063
+ */
1064
+ path: string;
1065
+ };
1066
+ query?: never;
1067
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/content/{path}";
1068
+ };
1069
+ type DeleteSandboxFileResponses = {
1070
+ /**
1071
+ * File or directory deleted successfully
1072
+ */
1073
+ 204: void;
1074
+ };
1075
+ type DeleteSandboxFileResponse = DeleteSandboxFileResponses[keyof DeleteSandboxFileResponses];
1076
+ type GetSandboxContentData = {
1077
+ body?: never;
1078
+ path: {
1079
+ /**
1080
+ * The human-readable ID of the workspace
1081
+ */
1082
+ workspace_domain: string;
1083
+ /**
1084
+ * The ID of the sandbox
1085
+ */
1086
+ sandbox_id: string;
1087
+ /**
1088
+ * Absolute path to the file or directory. Recommended directory is `/buddy`
1089
+ */
1090
+ path: string;
1091
+ };
1092
+ query?: never;
1093
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/content/{path}";
1094
+ };
1095
+ type GetSandboxContentResponses = {
1096
+ /**
1097
+ * Content retrieved successfully
1098
+ */
1099
+ 200: SandboxContentView;
1100
+ };
1101
+ type GetSandboxContentResponse = GetSandboxContentResponses[keyof GetSandboxContentResponses];
1102
+ type CreateSandboxDirectoryData = {
1103
+ body?: never;
1104
+ path: {
1105
+ /**
1106
+ * The human-readable ID of the workspace
1107
+ */
1108
+ workspace_domain: string;
1109
+ /**
1110
+ * The ID of the sandbox
1111
+ */
1112
+ sandbox_id: string;
1113
+ /**
1114
+ * Absolute path where the directory should be created
1115
+ */
1116
+ path: string;
1117
+ };
1118
+ query?: never;
1119
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/content/{path}";
1120
+ };
1121
+ type CreateSandboxDirectoryResponses = {
1122
+ /**
1123
+ * Directory created successfully
1124
+ */
1125
+ 201: SandboxContentItem;
1126
+ };
1127
+ type CreateSandboxDirectoryResponse = CreateSandboxDirectoryResponses[keyof CreateSandboxDirectoryResponses];
1128
+ type UploadSandboxFileResponses = {
1129
+ /**
1130
+ * File uploaded successfully
1131
+ */
1132
+ 201: SandboxContentItem;
1133
+ };
1134
+ type UploadSandboxFileResponse = UploadSandboxFileResponses[keyof UploadSandboxFileResponses];
1135
+ type RestartSandboxData = {
1136
+ body?: never;
1137
+ path: {
1138
+ /**
1139
+ * The human-readable ID of the workspace
1140
+ */
1141
+ workspace_domain: string;
1142
+ /**
1143
+ * The ID of the sandbox
1144
+ */
1145
+ sandbox_id: string;
1146
+ };
1147
+ query?: never;
1148
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/restart";
1149
+ };
1150
+ type StartSandboxData = {
1151
+ body?: never;
1152
+ path: {
1153
+ /**
1154
+ * The human-readable ID of the workspace
1155
+ */
1156
+ workspace_domain: string;
1157
+ /**
1158
+ * The ID of the sandbox
1159
+ */
1160
+ sandbox_id: string;
1161
+ };
1162
+ query?: never;
1163
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/start";
1164
+ };
1165
+ type StopSandboxData = {
1166
+ body?: never;
1167
+ path: {
1168
+ /**
1169
+ * The human-readable ID of the workspace
1170
+ */
1171
+ workspace_domain: string;
1172
+ /**
1173
+ * The ID of the sandbox
1174
+ */
1175
+ sandbox_id: string;
1176
+ };
1177
+ query?: never;
1178
+ url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/stop";
1179
+ };
1180
+ //#endregion
1181
+ //#region src/core/http-client.d.ts
1182
+ /** Configuration options for creating an HttpClient instance */
1183
+ interface HttpClientConfig {
1184
+ /** Base URL prepended to all request paths */
1185
+ baseURL?: string;
1186
+ /** Request timeout in milliseconds */
1187
+ timeout?: number;
1188
+ /** Default headers sent with every request */
1189
+ headers?: Record<string, string>;
1190
+ /** Enable detailed request/response logging */
1191
+ debugMode?: boolean;
1192
+ }
1193
+ /** Per-request configuration options */
1194
+ interface RequestConfig {
1195
+ /** Disable automatic retry on transient failures */
1196
+ skipRetry?: boolean;
1197
+ /** URL query parameters to append */
1198
+ queryParams?: Record<string, string | number | boolean | undefined>;
1199
+ /** Additional headers for this request only */
1200
+ headers?: Record<string, string>;
1201
+ /** Response parsing mode */
1202
+ responseType?: "json" | "text";
1203
+ }
1204
+ /** Normalized HTTP response with status, data, and headers */
1205
+ interface HttpResponse<T = unknown> {
1206
+ /** HTTP status code (e.g. 200, 404) */
1207
+ status: number;
1208
+ /** HTTP status text (e.g. "OK", "Not Found") */
1209
+ statusText: string;
1210
+ /** Parsed response body */
1211
+ data: T;
1212
+ /** Response headers */
1213
+ headers: Headers;
1214
+ }
1215
+ /** Base HTTP client with retry logic, timeout handling, and authentication support */
1216
+ declare class HttpClient {
1217
+ #private;
1218
+ protected readonly debugMode: boolean;
1219
+ /** Create a new HTTP client with optional base URL, timeout, and headers */
1220
+ constructor(config?: HttpClientConfig);
1221
+ /** Perform a GET request */
1222
+ get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
1223
+ /** Perform a POST request with optional body data */
1224
+ post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>;
1225
+ /** Perform a DELETE request */
1226
+ delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
1227
+ /** Set the Bearer token for authenticated requests */
1228
+ setAuthToken(token: string): void;
1229
+ }
1230
+ //#endregion
1231
+ //#region src/types/utils.d.ts
1232
+ /**
1233
+ * Utility type to make some properties of an object required.
1234
+ */
1235
+ type WithRequired<T, K extends keyof T> = T & { [P in K]-?: NonNullable<T[P]> };
1236
+ //#endregion
1237
+ //#region src/types/index.d.ts
1238
+ type Data = {
1239
+ body?: Record<string, unknown>;
1240
+ path?: Record<string, string>;
1241
+ query?: Record<string, string | boolean>;
1242
+ url: string;
1243
+ };
1244
+ type OmitIfEmpty<T> = keyof T extends never ? never : T;
1245
+ type ClientPath<D extends Data> = NonNullable<D["path"]> extends infer P extends object ? OmitIfEmpty<Omit<P, "workspace_domain">> : never;
1246
+ type ClientQuery<D extends Data> = NonNullable<D["query"]> extends infer Q extends object ? OmitIfEmpty<Omit<Q, "project_name">> : never;
1247
+ type PathProp<D extends Data> = [ClientPath<D>] extends [never] ? {
1248
+ path?: undefined;
1249
+ } : {
1250
+ path: ClientPath<D>;
1251
+ };
1252
+ type QueryProp<D extends Data> = [ClientQuery<D>] extends [never] ? {
1253
+ query?: undefined;
1254
+ } : {
1255
+ query: ClientQuery<D>;
1256
+ };
1257
+ type ClientData<D extends Data> = Omit<WithRequired<D, D["body"] extends undefined ? never : "body">, "url" | "path" | "query"> & PathProp<D> & QueryProp<D>;
1258
+ //#endregion
1259
+ //#region src/core/buddy-api-client.d.ts
1260
+ /** Configuration options for creating a BuddyApiClient instance */
1261
+ interface BuddyApiConfig extends Omit<HttpClientConfig, "baseURL"> {
1262
+ /** Buddy workspace domain (e.g. "mycompany") */
1263
+ workspace: string;
1264
+ /** Project name within the workspace */
1265
+ project_name: string;
1266
+ /** API authentication token (falls back to BUDDY_TOKEN env var) */
1267
+ token?: string;
1268
+ /** Base URL of the Buddy API */
1269
+ apiUrl: string;
1270
+ }
1271
+ /** API client for Buddy sandbox operations with request validation and response transformation */
1272
+ declare class BuddyApiClient extends HttpClient {
1273
+ #private;
1274
+ readonly workspace: BuddyApiConfig["workspace"];
1275
+ readonly project_name: BuddyApiConfig["project_name"];
1276
+ /** Create a new sandbox */
1277
+ addSandbox<const Data$1 extends AddSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
1278
+ /** Get a specific sandbox by its ID */
1279
+ getSandboxById<const Data$1 extends GetSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
1280
+ /** Execute a command in a sandbox */
1281
+ executeCommand<const Data$1 extends ExecuteSandboxCommandData>(data: ClientData<Data$1>): Promise<SandboxCommandView>;
1282
+ /** Get a specific command execution details */
1283
+ getCommandDetails<const Data$1 extends GetSandboxCommandData>(data: ClientData<Data$1>): Promise<SandboxCommandView>;
1284
+ /** Terminate a running command in a sandbox */
1285
+ terminateCommand<const Data$1 extends TerminateSandboxCommandData>(data: ClientData<Data$1>): Promise<SandboxCommandView>;
1286
+ /** Delete a sandbox by its ID */
1287
+ deleteSandboxById<const Data$1 extends DeleteSandboxData>(data: ClientData<Data$1>): Promise<void>;
1288
+ /** Get all sandboxes in the workspace for a specific project */
1289
+ getSandboxes<const Data$1 extends GetSandboxesData>(data: ClientData<Data$1>): Promise<SandboxesView>;
1290
+ /** Start a sandbox */
1291
+ startSandbox<const Data$1 extends StartSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
1292
+ /** Stop a sandbox */
1293
+ stopSandbox<const Data$1 extends StopSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
1294
+ /** Restart a sandbox */
1295
+ restartSandbox<const Data$1 extends RestartSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
1296
+ /** Get sandbox content (list files/directories at a path) */
1297
+ getSandboxContent<const Data$1 extends GetSandboxContentData>(data: ClientData<Data$1>): Promise<GetSandboxContentResponse>;
1298
+ /** Delete a file or directory from a sandbox */
1299
+ deleteSandboxFile<const Data$1 extends DeleteSandboxFileData>(data: ClientData<Data$1>): Promise<DeleteSandboxFileResponse>;
1300
+ /** Create a directory in a sandbox */
1301
+ createSandboxDirectory<const Data$1 extends CreateSandboxDirectoryData>(data: ClientData<Data$1>): Promise<CreateSandboxDirectoryResponse>;
1302
+ /** Upload a file to a sandbox */
1303
+ uploadSandboxFile(data: {
1304
+ body: Blob | File;
1305
+ path: {
1306
+ sandbox_id: string;
1307
+ path: string;
1308
+ };
1309
+ }): Promise<UploadSandboxFileResponse>;
1310
+ /** Download content from a sandbox (file or directory as tar.gz) */
1311
+ downloadSandboxContent(data: {
1312
+ path: {
1313
+ sandbox_id: string;
1314
+ path: string;
1315
+ };
1316
+ }): Promise<{
1317
+ data: ArrayBuffer;
1318
+ filename: string;
1319
+ }>;
1320
+ /** Stream logs from a specific command execution */
1321
+ streamCommandLogs<const Data$1 extends GetSandboxCommandLogsData>(data: ClientData<Data$1>): AsyncGenerator<SandboxCommandLog, void, unknown>;
1322
+ /** Create a new Buddy API client instance */
1323
+ constructor(config: BuddyApiConfig);
1324
+ }
1325
+ //#endregion
1326
+ //#region src/entity/command.d.ts
1327
+ /** Represents a running or completed command execution in a sandbox */
1328
+ declare class Command {
1329
+ protected readonly commandResponse: ExecuteSandboxCommandResponse;
1330
+ protected readonly client: BuddyApiClient;
1331
+ protected readonly sandboxId: string;
1332
+ protected readonly commandId: string;
1333
+ /** Create a new Command instance from an API response */
1334
+ constructor({
1335
+ commandResponse,
1336
+ client,
1337
+ sandboxId
1338
+ }: {
1339
+ commandResponse: ExecuteSandboxCommandResponse;
1340
+ client: BuddyApiClient;
1341
+ sandboxId: string;
1342
+ });
1343
+ /** The raw command response data from the API */
1344
+ get data(): SandboxCommandView;
1345
+ /**
1346
+ * Stream logs from the command in real-time
1347
+ * @returns AsyncGenerator yielding log entries with type and data
1348
+ */
1349
+ logs({
1350
+ follow
1351
+ }?: {
1352
+ follow?: boolean;
1353
+ }): AsyncGenerator<SandboxCommandLog, void, unknown>;
1354
+ /**
1355
+ * Wait for the command to finish execution
1356
+ * @returns Command instance with final response data
1357
+ */
1358
+ wait(): Promise<Command>;
1359
+ /**
1360
+ * Get all output from the command (waits for completion)
1361
+ * @returns Complete output as a string
1362
+ */
1363
+ output(stream?: "STDOUT" | "STDERR" | "BOTH"): Promise<string>;
1364
+ /**
1365
+ * Get all stdout output from the command (waits for completion)
1366
+ * @returns Stdout as a string
1367
+ */
1368
+ stdout(): Promise<string>;
1369
+ /**
1370
+ * Get all stderr output from the command (waits for completion)
1371
+ * @returns Stderr as a string
1372
+ */
1373
+ stderr(): Promise<string>;
1374
+ /** Terminate the running command */
1375
+ kill(): Promise<void>;
1376
+ /**
1377
+ * Poll the API until the command reaches a terminal state
1378
+ * @returns Final command response
1379
+ */
1380
+ protected pollForCommandCompletion(pollIntervalMs?: number): Promise<ExecuteSandboxCommandResponse>;
1381
+ }
1382
+ //#endregion
1383
+ //#region src/utils/regions.d.ts
1384
+ declare const REGIONS: {
1385
+ readonly US: "US";
1386
+ readonly EU: "EU";
1387
+ readonly AP: "AP";
1388
+ };
1389
+ type Region = (typeof REGIONS)[keyof typeof REGIONS];
1390
+ declare const API_URLS: Record<Region, string>;
1391
+ //#endregion
1392
+ //#region src/utils/client.d.ts
1393
+ /** Connection configuration for workspace and API authentication */
1394
+ interface ConnectionConfig {
1395
+ /** Workspace name/slug (falls back to BUDDY_WORKSPACE env var) */
1396
+ workspace?: string;
1397
+ /** Project name/slug (falls back to BUDDY_PROJECT env var) */
1398
+ project?: string;
1399
+ /** API authentication token (falls back to BUDDY_TOKEN env var) */
1400
+ token?: string;
1401
+ /** API region: US, EU, or AP (falls back to BUDDY_REGION env var) */
1402
+ region?: Region;
1403
+ /** Custom API URL for testing (falls back to BUDDY_API_URL env var) */
1404
+ apiUrl?: string;
1405
+ }
1406
+ //#endregion
1407
+ //#region src/entity/filesystem.d.ts
1408
+ /**
1409
+ * File information returned by file system operations
1410
+ */
1411
+ interface FileInfo {
1412
+ /** File or directory name */
1413
+ name: string;
1414
+ /** Full path to the file or directory */
1415
+ path: string;
1416
+ /** Type: "FILE" or "DIR" */
1417
+ type: "FILE" | "DIR";
1418
+ /** Size in bytes (for files) */
1419
+ size?: bigint;
1420
+ /** API URL for this item */
1421
+ url?: string;
1422
+ /** Web URL for viewing in Buddy.works */
1423
+ htmlUrl?: string;
1424
+ }
1425
+ /**
1426
+ * Configuration for getting a FileSystem instance
1427
+ */
1428
+ interface GetFileSystemConfig {
1429
+ /** Optional connection configuration to override defaults */
1430
+ connection?: ConnectionConfig;
1431
+ }
1432
+ /**
1433
+ * Provides file system operations within a Sandbox.
1434
+ *
1435
+ * FileSystem instances can be created either direct via `FileSystem.forSandbox()`
1436
+ * or accessed via the `Sandbox.fs` property.
1437
+ */
1438
+ declare class FileSystem {
1439
+ #private;
1440
+ /**
1441
+ * Create a FileSystem instance for a specific sandbox.
1442
+ *
1443
+ * @param sandboxId - The ID of the sandbox
1444
+ * @param config - Optional configuration including connection settings
1445
+ * @returns A FileSystem instance for the specified sandbox
1446
+ */
1447
+ static forSandbox(sandboxId: string, config?: GetFileSystemConfig): FileSystem;
1448
+ constructor(client: BuddyApiClient, sandboxId: string);
1449
+ /**
1450
+ * Lists contents of a directory in the Sandbox.
1451
+ *
1452
+ * @param dirPath - Directory path to list. Relative paths are resolved based on the sandbox working directory.
1453
+ * @returns Array of file and directory information
1454
+ */
1455
+ listFiles(dirPath: string): Promise<FileInfo[]>;
1456
+ /**
1457
+ * Create a new directory in the Sandbox.
1458
+ *
1459
+ * @param dirPath - Path where the directory should be created
1460
+ */
1461
+ createFolder(dirPath: string): Promise<void>;
1462
+ /**
1463
+ * Deletes a file or directory from the Sandbox.
1464
+ *
1465
+ * @param filePath - Path to the file or directory to delete
1466
+ */
1467
+ deleteFile(filePath: string): Promise<void>;
1468
+ /**
1469
+ * Downloads a file from the Sandbox.
1470
+ *
1471
+ * @param remotePath - Path to the file in the Sandbox
1472
+ * @param localPath - Optional local path to save the file
1473
+ * @returns File contents as a Buffer
1474
+ */
1475
+ downloadFile(remotePath: string, localPath?: string): Promise<Buffer>;
1476
+ /**
1477
+ * Uploads a file to the Sandbox.
1478
+ *
1479
+ * @param source - Buffer with content or path to local file
1480
+ * @param remotePath - Destination path in the Sandbox
1481
+ */
1482
+ uploadFile(source: Buffer | string, remotePath: string): Promise<void>;
1483
+ }
1484
+ //#endregion
1485
+ //#region src/entity/sandbox.d.ts
1486
+ /**
1487
+ * Configuration for creating a new sandbox
1488
+ */
1489
+ interface CreateSandboxConfig extends Partial<CreateNewSandboxRequestWritable> {
1490
+ /** Optional connection configuration to override defaults */
1491
+ connection?: ConnectionConfig;
1492
+ }
1493
+ /**
1494
+ * Configuration for getting an existing sandbox
1495
+ */
1496
+ interface GetSandboxConfig {
1497
+ /** Optional connection configuration to override defaults */
1498
+ connection?: ConnectionConfig;
1499
+ }
1500
+ /**
1501
+ * Configuration for listing sandboxes
1502
+ */
1503
+ interface ListSandboxesConfig {
1504
+ /** Optional connection configuration to override defaults */
1505
+ connection?: ConnectionConfig;
1506
+ }
1507
+ /**
1508
+ * Options for running a command in the sandbox
1509
+ */
1510
+ interface RunCommandOptions extends ExecuteSandboxCommandRequest {
1511
+ /** Stream to write stdout to (default: process.stdout, null to disable) */
1512
+ stdout?: Writable | null;
1513
+ /** Stream to write stderr to (default: process.stderr, null to disable) */
1514
+ stderr?: Writable | null;
1515
+ /** Whether to run the command in detached mode (non-blocking) */
1516
+ detached?: boolean;
1517
+ }
1518
+ declare class Sandbox {
1519
+ #private;
1520
+ /** The raw sandbox response data from the API */
1521
+ get data(): SandboxResponse;
1522
+ /** The sandbox ID, throws if not initialized */
1523
+ get initializedId(): NonNullable<GetSandboxResponse["id"]>;
1524
+ /**
1525
+ * File system operations for this sandbox.
1526
+ * Provides methods for listing, uploading, downloading, and managing files.
1527
+ */
1528
+ get fs(): FileSystem;
1529
+ /**
1530
+ * Create a new sandbox
1531
+ * @param config - Sandbox configuration including identifier, name, os, and optional connection settings
1532
+ * @returns A ready-to-use Sandbox instance
1533
+ */
1534
+ static create(config?: CreateSandboxConfig): Promise<Sandbox>;
1535
+ /**
1536
+ * Get an existing sandbox by its identifier
1537
+ * @param identifier - Identifier of the sandbox to retrieve
1538
+ * @param config - Optional configuration including connection settings
1539
+ * @returns The Sandbox instance
1540
+ */
1541
+ static getByIdentifier(identifier: NonNullable<GetSandboxResponse["identifier"]>, config?: GetSandboxConfig): Promise<Sandbox>;
1542
+ /**
1543
+ * Get an existing sandbox by its ID
1544
+ * @param sandboxId - ID of the sandbox to retrieve
1545
+ * @param config - Optional configuration including connection settings
1546
+ * @returns The Sandbox instance
1547
+ */
1548
+ static getById(sandboxId: NonNullable<GetSandboxResponse["id"]>, config?: GetSandboxConfig): Promise<Sandbox>;
1549
+ /**
1550
+ * List all sandboxes in the workspace
1551
+ *
1552
+ * Returns a simplified view of each sandbox (id, identifier, name, status, urls)
1553
+ * rather than full Sandbox instances. Use `getById()` or `getByIdentifier()`
1554
+ * to get a full Sandbox instance for a specific sandbox.
1555
+ *
1556
+ * @param config - Optional configuration including connection settings
1557
+ * @returns Array of simplified sandbox objects
1558
+ */
1559
+ static list(config?: ListSandboxesConfig): Promise<SandboxIdView[]>;
1560
+ /**
1561
+ * Execute a command in the sandbox
1562
+ * @returns Command instance (call wait() for blocking execution)
1563
+ */
1564
+ runCommand(options: RunCommandOptions): Promise<Command>;
1565
+ /**
1566
+ * Delete the sandbox permanently
1567
+ */
1568
+ destroy(): Promise<void>;
1569
+ /**
1570
+ * Refresh the sandbox data from the API
1571
+ * Updates the internal state with the latest sandbox information
1572
+ */
1573
+ refresh(): Promise<void>;
1574
+ /**
1575
+ * Wait until the sandbox setup is complete
1576
+ * @param pollIntervalMs - How often to check the status (default: 1000ms)
1577
+ */
1578
+ waitUntilReady(pollIntervalMs?: number): Promise<void>;
1579
+ /**
1580
+ * Wait until the sandbox is in RUNNING state
1581
+ * @param pollIntervalMs - How often to check the status (default: 1000ms)
1582
+ * @param maxWaitMs - Maximum time to wait before timing out (default: 60000ms)
1583
+ */
1584
+ waitUntilRunning(pollIntervalMs?: number, maxWaitMs?: number): Promise<void>;
1585
+ /**
1586
+ * Wait until the sandbox is in STOPPED state
1587
+ * @param pollIntervalMs - How often to check the status (default: 1000ms)
1588
+ * @param maxWaitMs - Maximum time to wait before timing out (default: 60000ms)
1589
+ */
1590
+ waitUntilStopped(pollIntervalMs?: number, maxWaitMs?: number): Promise<void>;
1591
+ /**
1592
+ * Start a stopped sandbox
1593
+ * Waits until the sandbox reaches RUNNING state
1594
+ */
1595
+ start(): Promise<void>;
1596
+ /**
1597
+ * Stop a running sandbox
1598
+ * Waits until the sandbox reaches STOPPED state
1599
+ */
1600
+ stop(): Promise<void>;
1601
+ /**
1602
+ * Restart the sandbox
1603
+ * Waits until the sandbox reaches RUNNING state and setup is complete
1604
+ */
1605
+ restart(): Promise<void>;
1606
+ private constructor();
1607
+ }
1608
+ //#endregion
1609
+ //#region src/errors/index.d.ts
1610
+ declare const ERROR_CODES: {
1611
+ /** HTTP errors - use statusCode field to distinguish (401, 403, 404, 500, etc.) */readonly HTTP_ERROR: "HTTP_ERROR"; /** Zod validation errors from user input */
1612
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR"; /** All other errors (config, streaming, internal, etc.) */
1613
+ readonly GENERIC_ERROR: "GENERIC_ERROR";
1614
+ };
1615
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
1616
+ declare class BuddySDKError extends Error {
1617
+ readonly code: ErrorCode;
1618
+ readonly statusCode?: number;
1619
+ readonly details?: unknown;
1620
+ readonly cause?: Error;
1621
+ constructor(message: string, options?: {
1622
+ code?: ErrorCode;
1623
+ statusCode?: number;
1624
+ details?: unknown;
1625
+ cause?: Error;
1626
+ });
1627
+ }
1628
+ //#endregion
1629
+ export { API_URLS, BuddyApiClient, BuddySDKError, Command, type ConnectionConfig, type CreateSandboxConfig, ERROR_CODES, type ErrorCode, type FileInfo, FileSystem, type GetFileSystemConfig, type GetSandboxConfig, type ListSandboxesConfig, REGIONS, type Region, Sandbox, type SandboxIdView };