@lizard-build/sdk 0.1.40 → 0.1.41
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/README.md +58 -258
- package/dist/index.d.mts +52 -54
- package/dist/index.d.ts +52 -54
- package/dist/index.js +36 -40
- package/dist/index.mjs +36 -40
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ declare class AddonsAPI {
|
|
|
114
114
|
memoryMb?: number;
|
|
115
115
|
storageGb?: number;
|
|
116
116
|
}): Promise<Addon>;
|
|
117
|
-
/** Restart an addon
|
|
117
|
+
/** Restart an addon. */
|
|
118
118
|
redeploy(projectId: string, addonId: string): Promise<void>;
|
|
119
119
|
rename(projectId: string, addonId: string, name: string): Promise<unknown>;
|
|
120
120
|
secrets(projectId: string, addonId: string): Promise<Array<{
|
|
@@ -395,7 +395,7 @@ interface ProcessInfo {
|
|
|
395
395
|
/** Signals accepted by {@link Process.kill}. */
|
|
396
396
|
type ProcessSignal = 'SIGTERM' | 'SIGKILL' | 'SIGINT' | 'SIGHUP' | 'SIGQUIT' | 'SIGUSR1' | 'SIGUSR2';
|
|
397
397
|
/**
|
|
398
|
-
* The result of a process execution inside a Lizard
|
|
398
|
+
* The result of a process execution inside a Lizard sandbox.
|
|
399
399
|
*/
|
|
400
400
|
interface ProcessResult {
|
|
401
401
|
stdout: string;
|
|
@@ -418,7 +418,7 @@ interface ProcessOpts {
|
|
|
418
418
|
onPid?: (pid: number) => void;
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
|
-
* Runs processes inside a Lizard sandbox
|
|
421
|
+
* Runs processes inside a Lizard sandbox.
|
|
422
422
|
*
|
|
423
423
|
* Access via `sandbox.process`.
|
|
424
424
|
*/
|
|
@@ -427,12 +427,12 @@ declare class Process {
|
|
|
427
427
|
private readonly config;
|
|
428
428
|
constructor(sandboxId: string, config: ConnectionConfig);
|
|
429
429
|
/**
|
|
430
|
-
* Execute a command inside the
|
|
430
|
+
* Execute a command inside the sandbox and wait for it to complete.
|
|
431
431
|
*
|
|
432
432
|
* The command runs in a shell inside the Lizard sandbox and returns
|
|
433
433
|
* stdout, stderr, and the exit code when it finishes.
|
|
434
434
|
*
|
|
435
|
-
* @param cmd Shell command to run inside the
|
|
435
|
+
* @param cmd Shell command to run inside the sandbox.
|
|
436
436
|
* @param opts Optional execution options — environment variables, working
|
|
437
437
|
* directory, user, and timeout.
|
|
438
438
|
*
|
|
@@ -511,7 +511,7 @@ interface FileInfo {
|
|
|
511
511
|
modTime?: number;
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
|
-
* Read and write files inside a Lizard sandbox
|
|
514
|
+
* Read and write files inside a Lizard sandbox.
|
|
515
515
|
*
|
|
516
516
|
* Access via `sandbox.fs`.
|
|
517
517
|
*/
|
|
@@ -520,23 +520,24 @@ declare class Fs {
|
|
|
520
520
|
private readonly config;
|
|
521
521
|
constructor(sandboxId: string, config: ConnectionConfig);
|
|
522
522
|
/**
|
|
523
|
-
* Write a file into the
|
|
523
|
+
* Write a file into the sandbox filesystem.
|
|
524
524
|
*
|
|
525
525
|
* Creates parent directories automatically if they don't exist.
|
|
526
|
+
* Byte input must contain valid UTF-8; arbitrary binary uploads are unsupported.
|
|
526
527
|
*
|
|
527
528
|
* @example
|
|
528
529
|
* ```ts
|
|
529
530
|
* await sandbox.fs.write('/app/index.js', 'console.log("hello")')
|
|
530
531
|
* ```
|
|
531
532
|
*
|
|
532
|
-
* @example Write
|
|
533
|
+
* @example Write UTF-8 bytes:
|
|
533
534
|
* ```ts
|
|
534
|
-
* await sandbox.fs.write('/app/
|
|
535
|
+
* await sandbox.fs.write('/app/notes.txt', new TextEncoder().encode('hello'))
|
|
535
536
|
* ```
|
|
536
537
|
*/
|
|
537
538
|
write(path: string, data: string | Uint8Array, opts?: FsOpts): Promise<void>;
|
|
538
539
|
/**
|
|
539
|
-
* Read a file from the
|
|
540
|
+
* Read a file from the sandbox filesystem.
|
|
540
541
|
*
|
|
541
542
|
* @returns The file contents as a UTF-8 string.
|
|
542
543
|
*
|
|
@@ -546,22 +547,23 @@ declare class Fs {
|
|
|
546
547
|
* ```
|
|
547
548
|
*/
|
|
548
549
|
read(path: string, opts?: FsOpts): Promise<string>;
|
|
550
|
+
/** Read a file as bytes. */
|
|
551
|
+
readBytes(path: string, opts?: FsOpts): Promise<Uint8Array>;
|
|
549
552
|
/**
|
|
550
|
-
* List files and directories at the given path inside the
|
|
553
|
+
* List files and directories at the given path inside the sandbox.
|
|
551
554
|
*
|
|
552
555
|
* @example
|
|
553
556
|
* ```ts
|
|
554
557
|
* const entries = await sandbox.fs.list('/app')
|
|
555
558
|
* ```
|
|
556
559
|
*/
|
|
557
|
-
readBytes(path: string, opts?: FsOpts): Promise<Uint8Array>;
|
|
558
560
|
list(path: string, opts?: FsOpts): Promise<FileInfo[]>;
|
|
559
561
|
/**
|
|
560
|
-
* Remove a file or directory from the
|
|
562
|
+
* Remove a file or directory from the sandbox filesystem.
|
|
561
563
|
*/
|
|
562
564
|
remove(path: string, opts?: FsOpts): Promise<void>;
|
|
563
565
|
/**
|
|
564
|
-
* Create a directory (and any missing parents) inside the
|
|
566
|
+
* Create a directory (and any missing parents) inside the sandbox.
|
|
565
567
|
*/
|
|
566
568
|
makeDir(path: string, opts?: FsOpts): Promise<void>;
|
|
567
569
|
/**
|
|
@@ -730,10 +732,9 @@ declare class SandboxClient {
|
|
|
730
732
|
}
|
|
731
733
|
|
|
732
734
|
/**
|
|
733
|
-
* A
|
|
735
|
+
* A Linux sandbox running on Kubernetes.
|
|
734
736
|
*
|
|
735
|
-
*
|
|
736
|
-
* process namespace, restored from a pre-warmed template snapshot.
|
|
737
|
+
* Run commands, read and write files, and expose HTTP ports in a sandbox.
|
|
737
738
|
*
|
|
738
739
|
* Sandboxes are **ephemeral**: killing one, or letting it hit its timeout, discards
|
|
739
740
|
* everything written inside it. State that has to outlive a sandbox belongs on a
|
|
@@ -745,10 +746,14 @@ declare class SandboxClient {
|
|
|
745
746
|
* import { Sandbox } from '@lizard-build/sdk'
|
|
746
747
|
*
|
|
747
748
|
* const sandbox = await Sandbox.create('base', { project: 'my-project' })
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
749
|
+
* try {
|
|
750
|
+
* await sandbox.fs.write('/tmp/hello.txt', 'hello world')
|
|
751
|
+
* const result = await sandbox.process.exec('cat /tmp/hello.txt')
|
|
752
|
+
* if (result.exitCode !== 0) throw new Error(result.stderr)
|
|
753
|
+
* console.log(result.stdout)
|
|
754
|
+
* } finally {
|
|
755
|
+
* await sandbox.kill()
|
|
756
|
+
* }
|
|
752
757
|
* ```
|
|
753
758
|
*
|
|
754
759
|
* @example Carry work across sandboxes with a volume:
|
|
@@ -769,11 +774,11 @@ declare class Sandbox extends SandboxClient {
|
|
|
769
774
|
protected static readonly defaultTemplate: string;
|
|
770
775
|
protected static readonly defaultTimeoutMs: number;
|
|
771
776
|
/**
|
|
772
|
-
* Unique identifier of this sandbox
|
|
777
|
+
* Unique identifier of this sandbox.
|
|
773
778
|
*/
|
|
774
779
|
readonly sandboxId: string;
|
|
775
780
|
/**
|
|
776
|
-
* Read and write files inside the
|
|
781
|
+
* Read and write files inside the sandbox filesystem.
|
|
777
782
|
*
|
|
778
783
|
* @example
|
|
779
784
|
* ```ts
|
|
@@ -783,7 +788,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
783
788
|
*/
|
|
784
789
|
readonly fs: Fs;
|
|
785
790
|
/**
|
|
786
|
-
* Execute processes inside the
|
|
791
|
+
* Execute processes inside the sandbox.
|
|
787
792
|
*
|
|
788
793
|
* @example
|
|
789
794
|
* ```ts
|
|
@@ -807,16 +812,15 @@ declare class Sandbox extends SandboxClient {
|
|
|
807
812
|
/**
|
|
808
813
|
* Create a new Lizard sandbox from the specified template.
|
|
809
814
|
*
|
|
810
|
-
*
|
|
811
|
-
*
|
|
812
|
-
* `lizard push`.
|
|
815
|
+
* Template availability and installed tools depend on the platform and region.
|
|
816
|
+
* Use `base` for shell commands or `CodeSandbox` for stateful code execution.
|
|
813
817
|
*
|
|
814
818
|
* @param template Name of the sandbox template to boot from.
|
|
815
819
|
*
|
|
816
820
|
* @example
|
|
817
821
|
* ```ts
|
|
818
822
|
* const sandbox = await Sandbox.create('base', { project: 'my-project' })
|
|
819
|
-
* const
|
|
823
|
+
* const pythonSandbox = await Sandbox.create('code-interpreter-v1', { project: 'my-project', timeoutMs: 10 * 60 * 1000 })
|
|
820
824
|
* ```
|
|
821
825
|
*/
|
|
822
826
|
static create(template: string, opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -826,11 +830,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
826
830
|
* Verifies the sandbox exists and is reachable, then returns a handle to it.
|
|
827
831
|
* Throws `NotFoundError` if it has been killed or has expired.
|
|
828
832
|
*
|
|
829
|
-
*
|
|
830
|
-
* reconnecting to might be paused. Sandboxes are pods now and pause/resume is a
|
|
831
|
-
* `501` on every one of them, so that call turned every `connect()` into an
|
|
832
|
-
* error against a perfectly healthy sandbox. Connecting does not need to change
|
|
833
|
-
* a sandbox's state, so it no longer tries to.
|
|
833
|
+
* Connecting reads sandbox metadata without changing its state.
|
|
834
834
|
*
|
|
835
835
|
* @example
|
|
836
836
|
* ```ts
|
|
@@ -852,25 +852,21 @@ declare class Sandbox extends SandboxClient {
|
|
|
852
852
|
/**
|
|
853
853
|
* Kill the sandbox and release its resources immediately.
|
|
854
854
|
*
|
|
855
|
-
* @returns `true` if the
|
|
855
|
+
* @returns `true` if the sandbox was terminated, `false` if it was already gone.
|
|
856
856
|
*/
|
|
857
857
|
kill(opts?: ConnectionOpts): Promise<boolean>;
|
|
858
858
|
/**
|
|
859
|
-
*
|
|
859
|
+
* Request sandbox pause. The Kubernetes backend returns HTTP 501.
|
|
860
860
|
*
|
|
861
|
-
* @deprecated
|
|
862
|
-
*
|
|
863
|
-
* checkpoint of the pod, which is not built. To park work across a gap, put it on a
|
|
864
|
-
* {@link Volume} and create a fresh sandbox on that volume later; the volume is the
|
|
865
|
-
* part that is meant to outlive a sandbox.
|
|
861
|
+
* @deprecated Unsupported on Kubernetes. Save files to a {@link Volume}
|
|
862
|
+
* and attach it to a new sandbox instead.
|
|
866
863
|
*/
|
|
867
864
|
pause(opts?: ConnectionOpts): Promise<boolean>;
|
|
868
865
|
/**
|
|
869
|
-
*
|
|
866
|
+
* Request sandbox resume. The Kubernetes backend returns HTTP 501.
|
|
870
867
|
*
|
|
871
|
-
* @deprecated
|
|
872
|
-
*
|
|
873
|
-
* calls this, so reconnecting to a running sandbox works without it.
|
|
868
|
+
* @deprecated Unsupported on Kubernetes. Use {@link Sandbox.connect} to
|
|
869
|
+
* reconnect to a running sandbox.
|
|
874
870
|
*/
|
|
875
871
|
resume(opts?: ConnectionOpts): Promise<boolean>;
|
|
876
872
|
/**
|
|
@@ -884,23 +880,25 @@ declare class Sandbox extends SandboxClient {
|
|
|
884
880
|
*/
|
|
885
881
|
setTimeout(timeoutMs: number, opts?: ConnectionOpts): Promise<void>;
|
|
886
882
|
/**
|
|
887
|
-
*
|
|
883
|
+
* Register a public HTTPS route and return its hostname without a scheme.
|
|
888
884
|
*
|
|
889
|
-
* Useful for accessing HTTP servers started inside the
|
|
885
|
+
* Useful for accessing HTTP servers started inside the sandbox from your
|
|
890
886
|
* agent or tests without additional tunneling.
|
|
891
887
|
*
|
|
892
888
|
* @example
|
|
893
889
|
* ```ts
|
|
894
|
-
*
|
|
895
|
-
* const
|
|
896
|
-
*
|
|
890
|
+
* // Start an HTTP server on port 3000 before exposing it.
|
|
891
|
+
* const hostname = await sandbox.getHost(3000)
|
|
892
|
+
* console.log(`https://${hostname}`)
|
|
897
893
|
* ```
|
|
898
894
|
*/
|
|
899
895
|
getHost(port: number, opts?: ConnectionOpts): Promise<string>;
|
|
896
|
+
/** Fork is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
900
897
|
fork(opts?: {
|
|
901
898
|
count?: number;
|
|
902
899
|
timeoutMs?: number;
|
|
903
900
|
}): Promise<unknown>;
|
|
901
|
+
/** Snapshot creation is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
904
902
|
snapshot(name?: string): Promise<unknown>;
|
|
905
903
|
unexpose(port: number): Promise<void>;
|
|
906
904
|
logs(opts?: {
|
|
@@ -908,6 +906,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
908
906
|
signal?: AbortSignal;
|
|
909
907
|
}): AsyncGenerator<StreamEvent, any, any>;
|
|
910
908
|
static snapshots(projectId: string, opts?: ConnectionOpts): Promise<unknown[]>;
|
|
909
|
+
/** Snapshot restore is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
911
910
|
static restore(snapshotId: string, opts?: ConnectionOpts & {
|
|
912
911
|
timeoutMs?: number;
|
|
913
912
|
}): Promise<Sandbox>;
|
|
@@ -1602,7 +1601,7 @@ type OutputItem = {
|
|
|
1602
1601
|
message: string;
|
|
1603
1602
|
traceback: string;
|
|
1604
1603
|
};
|
|
1605
|
-
/** Error
|
|
1604
|
+
/** Error returned in Execution.error when executed code raises an exception. */
|
|
1606
1605
|
declare class ExecutionError extends Error {
|
|
1607
1606
|
readonly name: string;
|
|
1608
1607
|
readonly traceback: string;
|
|
@@ -1637,7 +1636,7 @@ interface RunCodeOpts {
|
|
|
1637
1636
|
context?: CodeContext;
|
|
1638
1637
|
/** Extra environment variables available to the code. */
|
|
1639
1638
|
envs?: Record<string, string>;
|
|
1640
|
-
/**
|
|
1639
|
+
/** Client timeout in milliseconds. No client timer is set when omitted. */
|
|
1641
1640
|
timeoutMs?: number;
|
|
1642
1641
|
onStdout?: (data: string) => void;
|
|
1643
1642
|
onStderr?: (data: string) => void;
|
|
@@ -1659,7 +1658,7 @@ interface CreateContextOpts {
|
|
|
1659
1658
|
*
|
|
1660
1659
|
* @example
|
|
1661
1660
|
* ```ts
|
|
1662
|
-
* import { CodeSandbox } from 'lizard/
|
|
1661
|
+
* import { CodeSandbox } from '@lizard-build/sdk'
|
|
1663
1662
|
*
|
|
1664
1663
|
* const sandbox = await CodeSandbox.create({ project: 'my-project' })
|
|
1665
1664
|
*
|
|
@@ -1690,8 +1689,7 @@ declare class CodeSandbox extends Sandbox {
|
|
|
1690
1689
|
*
|
|
1691
1690
|
* @returns Execution result with stdout, stderr, results, and any error.
|
|
1692
1691
|
*
|
|
1693
|
-
*
|
|
1694
|
-
* default context exists — which cannot happen in normal usage.
|
|
1692
|
+
* Code errors appear in `execution.error`; request failures throw.
|
|
1695
1693
|
*
|
|
1696
1694
|
* @example
|
|
1697
1695
|
* ```ts
|
package/dist/index.js
CHANGED
|
@@ -501,12 +501,12 @@ var Process = class {
|
|
|
501
501
|
this.config = config;
|
|
502
502
|
}
|
|
503
503
|
/**
|
|
504
|
-
* Execute a command inside the
|
|
504
|
+
* Execute a command inside the sandbox and wait for it to complete.
|
|
505
505
|
*
|
|
506
506
|
* The command runs in a shell inside the Lizard sandbox and returns
|
|
507
507
|
* stdout, stderr, and the exit code when it finishes.
|
|
508
508
|
*
|
|
509
|
-
* @param cmd Shell command to run inside the
|
|
509
|
+
* @param cmd Shell command to run inside the sandbox.
|
|
510
510
|
* @param opts Optional execution options — environment variables, working
|
|
511
511
|
* directory, user, and timeout.
|
|
512
512
|
*
|
|
@@ -638,18 +638,19 @@ var Fs = class {
|
|
|
638
638
|
this.config = config;
|
|
639
639
|
}
|
|
640
640
|
/**
|
|
641
|
-
* Write a file into the
|
|
641
|
+
* Write a file into the sandbox filesystem.
|
|
642
642
|
*
|
|
643
643
|
* Creates parent directories automatically if they don't exist.
|
|
644
|
+
* Byte input must contain valid UTF-8; arbitrary binary uploads are unsupported.
|
|
644
645
|
*
|
|
645
646
|
* @example
|
|
646
647
|
* ```ts
|
|
647
648
|
* await sandbox.fs.write('/app/index.js', 'console.log("hello")')
|
|
648
649
|
* ```
|
|
649
650
|
*
|
|
650
|
-
* @example Write
|
|
651
|
+
* @example Write UTF-8 bytes:
|
|
651
652
|
* ```ts
|
|
652
|
-
* await sandbox.fs.write('/app/
|
|
653
|
+
* await sandbox.fs.write('/app/notes.txt', new TextEncoder().encode('hello'))
|
|
653
654
|
* ```
|
|
654
655
|
*/
|
|
655
656
|
async write(path, data, opts) {
|
|
@@ -662,7 +663,7 @@ var Fs = class {
|
|
|
662
663
|
if (!res.ok) await handleApiError(res);
|
|
663
664
|
}
|
|
664
665
|
/**
|
|
665
|
-
* Read a file from the
|
|
666
|
+
* Read a file from the sandbox filesystem.
|
|
666
667
|
*
|
|
667
668
|
* @returns The file contents as a UTF-8 string.
|
|
668
669
|
*
|
|
@@ -679,14 +680,7 @@ var Fs = class {
|
|
|
679
680
|
if (!res.ok) await handleApiError(res);
|
|
680
681
|
return res.text();
|
|
681
682
|
}
|
|
682
|
-
/**
|
|
683
|
-
* List files and directories at the given path inside the microVM.
|
|
684
|
-
*
|
|
685
|
-
* @example
|
|
686
|
-
* ```ts
|
|
687
|
-
* const entries = await sandbox.fs.list('/app')
|
|
688
|
-
* ```
|
|
689
|
-
*/
|
|
683
|
+
/** Read a file as bytes. */
|
|
690
684
|
async readBytes(path, opts) {
|
|
691
685
|
const url = new URL(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files`);
|
|
692
686
|
url.searchParams.set("path", path);
|
|
@@ -695,6 +689,14 @@ var Fs = class {
|
|
|
695
689
|
if (!res.ok) await handleApiError(res);
|
|
696
690
|
return new Uint8Array(await res.arrayBuffer());
|
|
697
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* List files and directories at the given path inside the sandbox.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```ts
|
|
697
|
+
* const entries = await sandbox.fs.list('/app')
|
|
698
|
+
* ```
|
|
699
|
+
*/
|
|
698
700
|
async list(path, opts) {
|
|
699
701
|
const url = new URL(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files/list`);
|
|
700
702
|
url.searchParams.set("path", path);
|
|
@@ -704,7 +706,7 @@ var Fs = class {
|
|
|
704
706
|
return res.json();
|
|
705
707
|
}
|
|
706
708
|
/**
|
|
707
|
-
* Remove a file or directory from the
|
|
709
|
+
* Remove a file or directory from the sandbox filesystem.
|
|
708
710
|
*/
|
|
709
711
|
async remove(path, opts) {
|
|
710
712
|
const res = await fetch(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files`, {
|
|
@@ -715,7 +717,7 @@ var Fs = class {
|
|
|
715
717
|
if (!res.ok) await handleApiError(res);
|
|
716
718
|
}
|
|
717
719
|
/**
|
|
718
|
-
* Create a directory (and any missing parents) inside the
|
|
720
|
+
* Create a directory (and any missing parents) inside the sandbox.
|
|
719
721
|
*/
|
|
720
722
|
async makeDir(path, opts) {
|
|
721
723
|
await this.execInternal(`mkdir -p ${JSON.stringify(path)}`, opts?.user);
|
|
@@ -943,11 +945,7 @@ var Sandbox = class extends SandboxClient {
|
|
|
943
945
|
* Verifies the sandbox exists and is reachable, then returns a handle to it.
|
|
944
946
|
* Throws `NotFoundError` if it has been killed or has expired.
|
|
945
947
|
*
|
|
946
|
-
*
|
|
947
|
-
* reconnecting to might be paused. Sandboxes are pods now and pause/resume is a
|
|
948
|
-
* `501` on every one of them, so that call turned every `connect()` into an
|
|
949
|
-
* error against a perfectly healthy sandbox. Connecting does not need to change
|
|
950
|
-
* a sandbox's state, so it no longer tries to.
|
|
948
|
+
* Connecting reads sandbox metadata without changing its state.
|
|
951
949
|
*
|
|
952
950
|
* @example
|
|
953
951
|
* ```ts
|
|
@@ -972,29 +970,25 @@ var Sandbox = class extends SandboxClient {
|
|
|
972
970
|
/**
|
|
973
971
|
* Kill the sandbox and release its resources immediately.
|
|
974
972
|
*
|
|
975
|
-
* @returns `true` if the
|
|
973
|
+
* @returns `true` if the sandbox was terminated, `false` if it was already gone.
|
|
976
974
|
*/
|
|
977
975
|
async kill(opts) {
|
|
978
976
|
return SandboxClient.killSandbox(this.sandboxId, this.resolveOpts(opts));
|
|
979
977
|
}
|
|
980
978
|
/**
|
|
981
|
-
*
|
|
979
|
+
* Request sandbox pause. The Kubernetes backend returns HTTP 501.
|
|
982
980
|
*
|
|
983
|
-
* @deprecated
|
|
984
|
-
*
|
|
985
|
-
* checkpoint of the pod, which is not built. To park work across a gap, put it on a
|
|
986
|
-
* {@link Volume} and create a fresh sandbox on that volume later; the volume is the
|
|
987
|
-
* part that is meant to outlive a sandbox.
|
|
981
|
+
* @deprecated Unsupported on Kubernetes. Save files to a {@link Volume}
|
|
982
|
+
* and attach it to a new sandbox instead.
|
|
988
983
|
*/
|
|
989
984
|
async pause(opts) {
|
|
990
985
|
return SandboxClient.pauseSandbox(this.sandboxId, this.resolveOpts(opts));
|
|
991
986
|
}
|
|
992
987
|
/**
|
|
993
|
-
*
|
|
988
|
+
* Request sandbox resume. The Kubernetes backend returns HTTP 501.
|
|
994
989
|
*
|
|
995
|
-
* @deprecated
|
|
996
|
-
*
|
|
997
|
-
* calls this, so reconnecting to a running sandbox works without it.
|
|
990
|
+
* @deprecated Unsupported on Kubernetes. Use {@link Sandbox.connect} to
|
|
991
|
+
* reconnect to a running sandbox.
|
|
998
992
|
*/
|
|
999
993
|
async resume(opts) {
|
|
1000
994
|
return SandboxClient.resumeSandbox(this.sandboxId, this.resolveOpts(opts));
|
|
@@ -1014,25 +1008,27 @@ var Sandbox = class extends SandboxClient {
|
|
|
1014
1008
|
return SandboxClient.setTimeoutSandbox(this.sandboxId, timeoutMs, this.resolveOpts(opts));
|
|
1015
1009
|
}
|
|
1016
1010
|
/**
|
|
1017
|
-
*
|
|
1011
|
+
* Register a public HTTPS route and return its hostname without a scheme.
|
|
1018
1012
|
*
|
|
1019
|
-
* Useful for accessing HTTP servers started inside the
|
|
1013
|
+
* Useful for accessing HTTP servers started inside the sandbox from your
|
|
1020
1014
|
* agent or tests without additional tunneling.
|
|
1021
1015
|
*
|
|
1022
1016
|
* @example
|
|
1023
1017
|
* ```ts
|
|
1024
|
-
*
|
|
1025
|
-
* const
|
|
1026
|
-
*
|
|
1018
|
+
* // Start an HTTP server on port 3000 before exposing it.
|
|
1019
|
+
* const hostname = await sandbox.getHost(3000)
|
|
1020
|
+
* console.log(`https://${hostname}`)
|
|
1027
1021
|
* ```
|
|
1028
1022
|
*/
|
|
1029
1023
|
async getHost(port, opts) {
|
|
1030
1024
|
const { hostname } = await SandboxClient.exposeSandboxPort(this.sandboxId, port, this.resolveOpts(opts));
|
|
1031
1025
|
return hostname;
|
|
1032
1026
|
}
|
|
1027
|
+
/** Fork is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
1033
1028
|
fork(opts = {}) {
|
|
1034
1029
|
return new PlatformClient(this.resolveOpts()).post(`/api/sandboxes/${this.sandboxId}/fork`, { count: opts.count ?? 1, timeoutMs: opts.timeoutMs ?? 0 });
|
|
1035
1030
|
}
|
|
1031
|
+
/** Snapshot creation is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
1036
1032
|
snapshot(name) {
|
|
1037
1033
|
return new PlatformClient(this.resolveOpts()).post(`/api/sandboxes/${this.sandboxId}/snapshot`, { name });
|
|
1038
1034
|
}
|
|
@@ -1045,6 +1041,7 @@ var Sandbox = class extends SandboxClient {
|
|
|
1045
1041
|
static snapshots(projectId, opts) {
|
|
1046
1042
|
return new PlatformClient(opts ?? {}).get(`/api/projects/${projectId}/snapshots`);
|
|
1047
1043
|
}
|
|
1044
|
+
/** Snapshot restore is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
1048
1045
|
static async restore(snapshotId, opts) {
|
|
1049
1046
|
const result = await new PlatformClient(opts ?? {}).post(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}/fork`, { timeoutMs: opts?.timeoutMs ?? 0 });
|
|
1050
1047
|
return new this({ ...opts, sandboxId: result.sandboxId ?? result.id });
|
|
@@ -1157,7 +1154,7 @@ var AddonsAPI = class {
|
|
|
1157
1154
|
});
|
|
1158
1155
|
return this.get(projectId, addonId);
|
|
1159
1156
|
}
|
|
1160
|
-
/** Restart an addon
|
|
1157
|
+
/** Restart an addon. */
|
|
1161
1158
|
redeploy(projectId, addonId) {
|
|
1162
1159
|
return this.client.post(`/api/projects/${projectId}/addons/${addonId}/redeploy`, {});
|
|
1163
1160
|
}
|
|
@@ -1759,8 +1756,7 @@ var CodeSandbox = class extends Sandbox {
|
|
|
1759
1756
|
*
|
|
1760
1757
|
* @returns Execution result with stdout, stderr, results, and any error.
|
|
1761
1758
|
*
|
|
1762
|
-
*
|
|
1763
|
-
* default context exists — which cannot happen in normal usage.
|
|
1759
|
+
* Code errors appear in `execution.error`; request failures throw.
|
|
1764
1760
|
*
|
|
1765
1761
|
* @example
|
|
1766
1762
|
* ```ts
|