tensorlake 0.5.37 → 0.5.40
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/bin/darwin-arm64/tensorlake +0 -0
- package/dist/bin/darwin-arm64/tl +0 -0
- package/dist/bin/linux-arm64/tensorlake +0 -0
- package/dist/bin/linux-arm64/tl +0 -0
- package/dist/bin/linux-x64/tensorlake +0 -0
- package/dist/bin/linux-x64/tl +0 -0
- package/dist/bin/win32-x64/tensorlake.exe +0 -0
- package/dist/bin/win32-x64/tl.exe +0 -0
- package/dist/index.cjs +808 -798
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -36
- package/dist/index.d.ts +96 -36
- package/dist/index.js +805 -796
- package/dist/index.js.map +1 -1
- package/dist/native/darwin-arm64/tensorlake-node.node +0 -0
- package/dist/native/linux-arm64/tensorlake-node.node +0 -0
- package/dist/native/linux-x64/tensorlake-node.node +0 -0
- package/dist/native/win32-x64/tensorlake-node.node +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -18,6 +18,86 @@ type Traced<T> = T & {
|
|
|
18
18
|
readonly traceId: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Bridge to the Rust core's sandbox lifecycle + proxy clients (`napi-rs`).
|
|
23
|
+
*
|
|
24
|
+
* The proxy data path (process/file/stream ops) is served by the Rust core so
|
|
25
|
+
* it shares `reqwest`'s connection pool — replacing the previous undici path,
|
|
26
|
+
* which multiplexed every parallel request onto a single, untuned HTTP/2
|
|
27
|
+
* connection. The native binding is required: there is no JS fallback.
|
|
28
|
+
*
|
|
29
|
+
* Convention (mirrors the Python binding): structured payloads cross as JSON
|
|
30
|
+
* strings, bytes as `Buffer`, and every call surfaces the W3C `traceId`.
|
|
31
|
+
* Errors arrive as a JSON `{category, status, message}` string in the native
|
|
32
|
+
* error message; {@link translateNativeError} rethrows them as the SDK's typed
|
|
33
|
+
* errors.
|
|
34
|
+
*/
|
|
35
|
+
interface TracedJson {
|
|
36
|
+
traceId: string;
|
|
37
|
+
json: string;
|
|
38
|
+
}
|
|
39
|
+
interface TracedBytes {
|
|
40
|
+
traceId: string;
|
|
41
|
+
data: Buffer;
|
|
42
|
+
}
|
|
43
|
+
interface TracedEvents {
|
|
44
|
+
traceId: string;
|
|
45
|
+
events: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Per-event callback used by the streaming proxy methods. */
|
|
48
|
+
type NativeEmit = (eventJson: string) => void;
|
|
49
|
+
interface NativeSandboxProxyClient {
|
|
50
|
+
baseUrl(): string;
|
|
51
|
+
startProcess(payloadJson: string): Promise<TracedJson>;
|
|
52
|
+
listProcesses(): Promise<TracedJson>;
|
|
53
|
+
getProcess(pid: number): Promise<TracedJson>;
|
|
54
|
+
killProcess(pid: number): Promise<string>;
|
|
55
|
+
restartProcess(pid: number): Promise<TracedJson>;
|
|
56
|
+
sendSignal(pid: number, signal: number): Promise<TracedJson>;
|
|
57
|
+
writeStdin(pid: number, data: Buffer): Promise<string>;
|
|
58
|
+
closeStdin(pid: number): Promise<string>;
|
|
59
|
+
getStdout(pid: number): Promise<TracedJson>;
|
|
60
|
+
getStderr(pid: number): Promise<TracedJson>;
|
|
61
|
+
getOutput(pid: number): Promise<TracedJson>;
|
|
62
|
+
followStdout(pid: number, emit: NativeEmit): Promise<string>;
|
|
63
|
+
followStderr(pid: number, emit: NativeEmit): Promise<string>;
|
|
64
|
+
followOutput(pid: number, emit: NativeEmit): Promise<string>;
|
|
65
|
+
runProcess(payloadJson: string): Promise<TracedEvents>;
|
|
66
|
+
runProcessStreaming(payloadJson: string, emit: NativeEmit): Promise<string>;
|
|
67
|
+
readFile(path: string): Promise<TracedBytes>;
|
|
68
|
+
writeFile(path: string, content: Buffer): Promise<string>;
|
|
69
|
+
uploadFile(path: string, localPath: string): Promise<string>;
|
|
70
|
+
deleteFile(path: string): Promise<string>;
|
|
71
|
+
listDirectory(path: string): Promise<TracedJson>;
|
|
72
|
+
createPtySession(payloadJson: string): Promise<TracedJson>;
|
|
73
|
+
deletePtySession(sessionId: string): Promise<string>;
|
|
74
|
+
health(): Promise<TracedJson>;
|
|
75
|
+
info(): Promise<TracedJson>;
|
|
76
|
+
}
|
|
77
|
+
interface NativeSandboxClient {
|
|
78
|
+
createSandbox(requestJson: string): Promise<TracedJson>;
|
|
79
|
+
claimSandbox(poolId: string): Promise<TracedJson>;
|
|
80
|
+
copySandbox(sandboxId: string, times: number): Promise<TracedJson>;
|
|
81
|
+
getSandbox(sandboxId: string): Promise<TracedJson>;
|
|
82
|
+
listSandboxes(): Promise<TracedJson>;
|
|
83
|
+
listArchivedSandboxes(limit?: number | null, cursor?: string | null, direction?: string | null): Promise<TracedJson>;
|
|
84
|
+
getArchivedSandbox(sandboxId: string): Promise<TracedJson>;
|
|
85
|
+
updateSandbox(sandboxId: string, requestJson: string): Promise<TracedJson>;
|
|
86
|
+
deleteSandbox(sandboxId: string): Promise<string>;
|
|
87
|
+
suspendSandbox(sandboxId: string): Promise<string>;
|
|
88
|
+
resumeSandbox(sandboxId: string): Promise<string>;
|
|
89
|
+
createSnapshot(sandboxId: string, snapshotType?: string | null): Promise<TracedJson>;
|
|
90
|
+
getSnapshot(snapshotId: string): Promise<TracedJson>;
|
|
91
|
+
listSnapshots(): Promise<TracedJson>;
|
|
92
|
+
deleteSnapshot(snapshotId: string): Promise<string>;
|
|
93
|
+
createPool(requestJson: string): Promise<TracedJson>;
|
|
94
|
+
getPool(poolId: string): Promise<TracedJson>;
|
|
95
|
+
listPools(): Promise<TracedJson>;
|
|
96
|
+
updatePool(poolId: string, requestJson: string): Promise<TracedJson>;
|
|
97
|
+
deletePool(poolId: string): Promise<string>;
|
|
98
|
+
connectProxy(proxyUrl: string, sandboxId: string, routingHint?: string | null, requestTimeoutSec?: number | null): NativeSandboxProxyClient;
|
|
99
|
+
}
|
|
100
|
+
|
|
21
101
|
declare enum SandboxStatus {
|
|
22
102
|
PENDING = "pending",
|
|
23
103
|
RUNNING = "running",
|
|
@@ -421,6 +501,12 @@ interface SandboxOptions {
|
|
|
421
501
|
requestTimeout?: number;
|
|
422
502
|
/** @deprecated Use requestTimeout. Optional total HTTP request timeout in milliseconds for sandbox proxy operations. */
|
|
423
503
|
timeoutMs?: number;
|
|
504
|
+
/**
|
|
505
|
+
* @internal Shared Rust-backed lifecycle client. When provided, the proxy
|
|
506
|
+
* client is minted via `connectProxy` so it reuses this client's connection
|
|
507
|
+
* pool (HTTP/2 coalescing across sandboxes).
|
|
508
|
+
*/
|
|
509
|
+
nativeClient?: NativeSandboxClient;
|
|
424
510
|
}
|
|
425
511
|
interface CreateAndConnectOptions extends CreateSandboxOptions {
|
|
426
512
|
poolId?: string;
|
|
@@ -597,7 +683,6 @@ declare class Sandbox {
|
|
|
597
683
|
readonly sandboxId: string;
|
|
598
684
|
traceId: string | null;
|
|
599
685
|
private readonly proxy;
|
|
600
|
-
private readonly http;
|
|
601
686
|
private ownsSandbox;
|
|
602
687
|
private lifecycleClient;
|
|
603
688
|
private lifecycleIdentifier;
|
|
@@ -682,7 +767,7 @@ declare class Sandbox {
|
|
|
682
767
|
* List snapshots taken from this sandbox.
|
|
683
768
|
*/
|
|
684
769
|
listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
|
|
685
|
-
/** Close the
|
|
770
|
+
/** Close the proxy connection. The sandbox keeps running. */
|
|
686
771
|
close(): void;
|
|
687
772
|
/** Terminate the sandbox and release all resources. */
|
|
688
773
|
terminate(): Promise<void>;
|
|
@@ -768,19 +853,18 @@ declare class Sandbox {
|
|
|
768
853
|
/**
|
|
769
854
|
* Client for managing TensorLake sandboxes, pools, and snapshots.
|
|
770
855
|
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
856
|
+
* This is a thin shim over the Rust core ({@link NativeSandboxClient}): every
|
|
857
|
+
* call marshals a request to JSON, delegates the RPC (URL resolution,
|
|
858
|
+
* namespacing, retries, connection pooling) to Rust, and reshapes the JSON
|
|
859
|
+
* response. There is no TypeScript-side HTTP transport.
|
|
773
860
|
*/
|
|
774
861
|
declare class SandboxClient {
|
|
775
|
-
private readonly
|
|
862
|
+
private readonly native;
|
|
776
863
|
private readonly apiUrl;
|
|
777
864
|
private readonly apiKey;
|
|
778
865
|
private readonly organizationId;
|
|
779
866
|
private readonly projectId;
|
|
780
867
|
private readonly namespace;
|
|
781
|
-
private readonly local;
|
|
782
|
-
private readonly maxRetries;
|
|
783
|
-
private readonly retryBackoffMs;
|
|
784
868
|
private readonly requestTimeoutMs;
|
|
785
869
|
/** @internal Pass `true` to suppress the deprecation warning when used by `Sandbox.create()` / `Sandbox.connect()`. */
|
|
786
870
|
constructor(options?: SandboxClientOptions, _internal?: boolean);
|
|
@@ -802,7 +886,10 @@ declare class SandboxClient {
|
|
|
802
886
|
}): SandboxClient;
|
|
803
887
|
close(): void;
|
|
804
888
|
private withRequestTimeout;
|
|
805
|
-
|
|
889
|
+
/** Run a native JSON call and reshape it into a `Traced<T>`. */
|
|
890
|
+
private tracedJson;
|
|
891
|
+
/** Run a native JSON call and reshape it into a plain `T` (no trace id). */
|
|
892
|
+
private plainJson;
|
|
806
893
|
/** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
|
|
807
894
|
create(options?: CreateSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
|
|
808
895
|
/** Get current state and metadata for a sandbox by ID. */
|
|
@@ -837,12 +924,6 @@ declare class SandboxClient {
|
|
|
837
924
|
* cannot. By default blocks until the sandbox is fully `Suspended`. Pass
|
|
838
925
|
* `{ wait: false }` to return immediately after the request is sent
|
|
839
926
|
* (fire-and-return); the server processes the suspend asynchronously.
|
|
840
|
-
*
|
|
841
|
-
* @param sandboxId - ID or name of the sandbox.
|
|
842
|
-
* @param options.wait - If `true` (default), poll until `Suspended`. Pass `false` to fire-and-return.
|
|
843
|
-
* @param options.timeout - Max seconds to wait when `wait=true` (default 300).
|
|
844
|
-
* @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
|
|
845
|
-
* @throws {SandboxError} If `wait=true` and the sandbox does not reach `Suspended` within `timeout`.
|
|
846
927
|
*/
|
|
847
928
|
suspend(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
|
|
848
929
|
/**
|
|
@@ -851,12 +932,6 @@ declare class SandboxClient {
|
|
|
851
932
|
* By default blocks until the sandbox is `Running` and routable. Pass
|
|
852
933
|
* `{ wait: false }` to return immediately after the request is sent
|
|
853
934
|
* (fire-and-return); the server processes the resume asynchronously.
|
|
854
|
-
*
|
|
855
|
-
* @param sandboxId - ID or name of the sandbox.
|
|
856
|
-
* @param options.wait - If `true` (default), poll until `Running`. Pass `false` to fire-and-return.
|
|
857
|
-
* @param options.timeout - Max seconds to wait when `wait=true` (default 300).
|
|
858
|
-
* @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
|
|
859
|
-
* @throws {SandboxError} If `wait=true` and the sandbox does not reach `Running` within `timeout`.
|
|
860
935
|
*/
|
|
861
936
|
resume(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
|
|
862
937
|
/** Claim a warm sandbox from a pool, creating one if no warm containers are available. */
|
|
@@ -876,9 +951,6 @@ declare class SandboxClient {
|
|
|
876
951
|
* status — the snapshot is created asynchronously. Poll `getSnapshot()` until
|
|
877
952
|
* `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
|
|
878
953
|
* block automatically.
|
|
879
|
-
*
|
|
880
|
-
* @param options.snapshotType - `"filesystem"` for cold-boot snapshots (e.g. image builds).
|
|
881
|
-
* Omit to use the server default (`filesystem`).
|
|
882
954
|
*/
|
|
883
955
|
snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
|
|
884
956
|
/** Get current status and metadata for a snapshot by ID. */
|
|
@@ -893,14 +965,6 @@ declare class SandboxClient {
|
|
|
893
965
|
* Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
|
|
894
966
|
* or `completed`. Pass `{ waitUntil: "completed" }` when durable
|
|
895
967
|
* `snapshotUri` metadata is required.
|
|
896
|
-
* Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
|
|
897
|
-
* without managing the client separately.
|
|
898
|
-
*
|
|
899
|
-
* @param sandboxId - ID of the running sandbox to snapshot.
|
|
900
|
-
* @param options.timeout - Max seconds to wait (default 300).
|
|
901
|
-
* @param options.pollInterval - Seconds between status polls (default 1).
|
|
902
|
-
* @param options.snapshotType - Snapshot type passed through to `snapshot()`.
|
|
903
|
-
* @throws {SandboxError} If the snapshot fails or `timeout` elapses.
|
|
904
968
|
*/
|
|
905
969
|
snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<Traced<SnapshotInfo>>;
|
|
906
970
|
/** Create a new sandbox pool with warm pre-booted containers. */
|
|
@@ -920,10 +984,6 @@ declare class SandboxClient {
|
|
|
920
984
|
*
|
|
921
985
|
* Blocks until the sandbox is ready or `requestTimeout` elapses. The returned
|
|
922
986
|
* `Sandbox` auto-terminates when `terminate()` is called.
|
|
923
|
-
*
|
|
924
|
-
* @param options.requestTimeout - Max seconds to wait for `Running` status (default: client requestTimeout).
|
|
925
|
-
* @param options.startupTimeout - Deprecated alias for `requestTimeout`.
|
|
926
|
-
* @throws {SandboxError} If the sandbox terminates during startup or the timeout elapses.
|
|
927
987
|
*/
|
|
928
988
|
createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
|
|
929
989
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,86 @@ type Traced<T> = T & {
|
|
|
18
18
|
readonly traceId: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Bridge to the Rust core's sandbox lifecycle + proxy clients (`napi-rs`).
|
|
23
|
+
*
|
|
24
|
+
* The proxy data path (process/file/stream ops) is served by the Rust core so
|
|
25
|
+
* it shares `reqwest`'s connection pool — replacing the previous undici path,
|
|
26
|
+
* which multiplexed every parallel request onto a single, untuned HTTP/2
|
|
27
|
+
* connection. The native binding is required: there is no JS fallback.
|
|
28
|
+
*
|
|
29
|
+
* Convention (mirrors the Python binding): structured payloads cross as JSON
|
|
30
|
+
* strings, bytes as `Buffer`, and every call surfaces the W3C `traceId`.
|
|
31
|
+
* Errors arrive as a JSON `{category, status, message}` string in the native
|
|
32
|
+
* error message; {@link translateNativeError} rethrows them as the SDK's typed
|
|
33
|
+
* errors.
|
|
34
|
+
*/
|
|
35
|
+
interface TracedJson {
|
|
36
|
+
traceId: string;
|
|
37
|
+
json: string;
|
|
38
|
+
}
|
|
39
|
+
interface TracedBytes {
|
|
40
|
+
traceId: string;
|
|
41
|
+
data: Buffer;
|
|
42
|
+
}
|
|
43
|
+
interface TracedEvents {
|
|
44
|
+
traceId: string;
|
|
45
|
+
events: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Per-event callback used by the streaming proxy methods. */
|
|
48
|
+
type NativeEmit = (eventJson: string) => void;
|
|
49
|
+
interface NativeSandboxProxyClient {
|
|
50
|
+
baseUrl(): string;
|
|
51
|
+
startProcess(payloadJson: string): Promise<TracedJson>;
|
|
52
|
+
listProcesses(): Promise<TracedJson>;
|
|
53
|
+
getProcess(pid: number): Promise<TracedJson>;
|
|
54
|
+
killProcess(pid: number): Promise<string>;
|
|
55
|
+
restartProcess(pid: number): Promise<TracedJson>;
|
|
56
|
+
sendSignal(pid: number, signal: number): Promise<TracedJson>;
|
|
57
|
+
writeStdin(pid: number, data: Buffer): Promise<string>;
|
|
58
|
+
closeStdin(pid: number): Promise<string>;
|
|
59
|
+
getStdout(pid: number): Promise<TracedJson>;
|
|
60
|
+
getStderr(pid: number): Promise<TracedJson>;
|
|
61
|
+
getOutput(pid: number): Promise<TracedJson>;
|
|
62
|
+
followStdout(pid: number, emit: NativeEmit): Promise<string>;
|
|
63
|
+
followStderr(pid: number, emit: NativeEmit): Promise<string>;
|
|
64
|
+
followOutput(pid: number, emit: NativeEmit): Promise<string>;
|
|
65
|
+
runProcess(payloadJson: string): Promise<TracedEvents>;
|
|
66
|
+
runProcessStreaming(payloadJson: string, emit: NativeEmit): Promise<string>;
|
|
67
|
+
readFile(path: string): Promise<TracedBytes>;
|
|
68
|
+
writeFile(path: string, content: Buffer): Promise<string>;
|
|
69
|
+
uploadFile(path: string, localPath: string): Promise<string>;
|
|
70
|
+
deleteFile(path: string): Promise<string>;
|
|
71
|
+
listDirectory(path: string): Promise<TracedJson>;
|
|
72
|
+
createPtySession(payloadJson: string): Promise<TracedJson>;
|
|
73
|
+
deletePtySession(sessionId: string): Promise<string>;
|
|
74
|
+
health(): Promise<TracedJson>;
|
|
75
|
+
info(): Promise<TracedJson>;
|
|
76
|
+
}
|
|
77
|
+
interface NativeSandboxClient {
|
|
78
|
+
createSandbox(requestJson: string): Promise<TracedJson>;
|
|
79
|
+
claimSandbox(poolId: string): Promise<TracedJson>;
|
|
80
|
+
copySandbox(sandboxId: string, times: number): Promise<TracedJson>;
|
|
81
|
+
getSandbox(sandboxId: string): Promise<TracedJson>;
|
|
82
|
+
listSandboxes(): Promise<TracedJson>;
|
|
83
|
+
listArchivedSandboxes(limit?: number | null, cursor?: string | null, direction?: string | null): Promise<TracedJson>;
|
|
84
|
+
getArchivedSandbox(sandboxId: string): Promise<TracedJson>;
|
|
85
|
+
updateSandbox(sandboxId: string, requestJson: string): Promise<TracedJson>;
|
|
86
|
+
deleteSandbox(sandboxId: string): Promise<string>;
|
|
87
|
+
suspendSandbox(sandboxId: string): Promise<string>;
|
|
88
|
+
resumeSandbox(sandboxId: string): Promise<string>;
|
|
89
|
+
createSnapshot(sandboxId: string, snapshotType?: string | null): Promise<TracedJson>;
|
|
90
|
+
getSnapshot(snapshotId: string): Promise<TracedJson>;
|
|
91
|
+
listSnapshots(): Promise<TracedJson>;
|
|
92
|
+
deleteSnapshot(snapshotId: string): Promise<string>;
|
|
93
|
+
createPool(requestJson: string): Promise<TracedJson>;
|
|
94
|
+
getPool(poolId: string): Promise<TracedJson>;
|
|
95
|
+
listPools(): Promise<TracedJson>;
|
|
96
|
+
updatePool(poolId: string, requestJson: string): Promise<TracedJson>;
|
|
97
|
+
deletePool(poolId: string): Promise<string>;
|
|
98
|
+
connectProxy(proxyUrl: string, sandboxId: string, routingHint?: string | null, requestTimeoutSec?: number | null): NativeSandboxProxyClient;
|
|
99
|
+
}
|
|
100
|
+
|
|
21
101
|
declare enum SandboxStatus {
|
|
22
102
|
PENDING = "pending",
|
|
23
103
|
RUNNING = "running",
|
|
@@ -421,6 +501,12 @@ interface SandboxOptions {
|
|
|
421
501
|
requestTimeout?: number;
|
|
422
502
|
/** @deprecated Use requestTimeout. Optional total HTTP request timeout in milliseconds for sandbox proxy operations. */
|
|
423
503
|
timeoutMs?: number;
|
|
504
|
+
/**
|
|
505
|
+
* @internal Shared Rust-backed lifecycle client. When provided, the proxy
|
|
506
|
+
* client is minted via `connectProxy` so it reuses this client's connection
|
|
507
|
+
* pool (HTTP/2 coalescing across sandboxes).
|
|
508
|
+
*/
|
|
509
|
+
nativeClient?: NativeSandboxClient;
|
|
424
510
|
}
|
|
425
511
|
interface CreateAndConnectOptions extends CreateSandboxOptions {
|
|
426
512
|
poolId?: string;
|
|
@@ -597,7 +683,6 @@ declare class Sandbox {
|
|
|
597
683
|
readonly sandboxId: string;
|
|
598
684
|
traceId: string | null;
|
|
599
685
|
private readonly proxy;
|
|
600
|
-
private readonly http;
|
|
601
686
|
private ownsSandbox;
|
|
602
687
|
private lifecycleClient;
|
|
603
688
|
private lifecycleIdentifier;
|
|
@@ -682,7 +767,7 @@ declare class Sandbox {
|
|
|
682
767
|
* List snapshots taken from this sandbox.
|
|
683
768
|
*/
|
|
684
769
|
listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
|
|
685
|
-
/** Close the
|
|
770
|
+
/** Close the proxy connection. The sandbox keeps running. */
|
|
686
771
|
close(): void;
|
|
687
772
|
/** Terminate the sandbox and release all resources. */
|
|
688
773
|
terminate(): Promise<void>;
|
|
@@ -768,19 +853,18 @@ declare class Sandbox {
|
|
|
768
853
|
/**
|
|
769
854
|
* Client for managing TensorLake sandboxes, pools, and snapshots.
|
|
770
855
|
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
856
|
+
* This is a thin shim over the Rust core ({@link NativeSandboxClient}): every
|
|
857
|
+
* call marshals a request to JSON, delegates the RPC (URL resolution,
|
|
858
|
+
* namespacing, retries, connection pooling) to Rust, and reshapes the JSON
|
|
859
|
+
* response. There is no TypeScript-side HTTP transport.
|
|
773
860
|
*/
|
|
774
861
|
declare class SandboxClient {
|
|
775
|
-
private readonly
|
|
862
|
+
private readonly native;
|
|
776
863
|
private readonly apiUrl;
|
|
777
864
|
private readonly apiKey;
|
|
778
865
|
private readonly organizationId;
|
|
779
866
|
private readonly projectId;
|
|
780
867
|
private readonly namespace;
|
|
781
|
-
private readonly local;
|
|
782
|
-
private readonly maxRetries;
|
|
783
|
-
private readonly retryBackoffMs;
|
|
784
868
|
private readonly requestTimeoutMs;
|
|
785
869
|
/** @internal Pass `true` to suppress the deprecation warning when used by `Sandbox.create()` / `Sandbox.connect()`. */
|
|
786
870
|
constructor(options?: SandboxClientOptions, _internal?: boolean);
|
|
@@ -802,7 +886,10 @@ declare class SandboxClient {
|
|
|
802
886
|
}): SandboxClient;
|
|
803
887
|
close(): void;
|
|
804
888
|
private withRequestTimeout;
|
|
805
|
-
|
|
889
|
+
/** Run a native JSON call and reshape it into a `Traced<T>`. */
|
|
890
|
+
private tracedJson;
|
|
891
|
+
/** Run a native JSON call and reshape it into a plain `T` (no trace id). */
|
|
892
|
+
private plainJson;
|
|
806
893
|
/** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
|
|
807
894
|
create(options?: CreateSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
|
|
808
895
|
/** Get current state and metadata for a sandbox by ID. */
|
|
@@ -837,12 +924,6 @@ declare class SandboxClient {
|
|
|
837
924
|
* cannot. By default blocks until the sandbox is fully `Suspended`. Pass
|
|
838
925
|
* `{ wait: false }` to return immediately after the request is sent
|
|
839
926
|
* (fire-and-return); the server processes the suspend asynchronously.
|
|
840
|
-
*
|
|
841
|
-
* @param sandboxId - ID or name of the sandbox.
|
|
842
|
-
* @param options.wait - If `true` (default), poll until `Suspended`. Pass `false` to fire-and-return.
|
|
843
|
-
* @param options.timeout - Max seconds to wait when `wait=true` (default 300).
|
|
844
|
-
* @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
|
|
845
|
-
* @throws {SandboxError} If `wait=true` and the sandbox does not reach `Suspended` within `timeout`.
|
|
846
927
|
*/
|
|
847
928
|
suspend(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
|
|
848
929
|
/**
|
|
@@ -851,12 +932,6 @@ declare class SandboxClient {
|
|
|
851
932
|
* By default blocks until the sandbox is `Running` and routable. Pass
|
|
852
933
|
* `{ wait: false }` to return immediately after the request is sent
|
|
853
934
|
* (fire-and-return); the server processes the resume asynchronously.
|
|
854
|
-
*
|
|
855
|
-
* @param sandboxId - ID or name of the sandbox.
|
|
856
|
-
* @param options.wait - If `true` (default), poll until `Running`. Pass `false` to fire-and-return.
|
|
857
|
-
* @param options.timeout - Max seconds to wait when `wait=true` (default 300).
|
|
858
|
-
* @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
|
|
859
|
-
* @throws {SandboxError} If `wait=true` and the sandbox does not reach `Running` within `timeout`.
|
|
860
935
|
*/
|
|
861
936
|
resume(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
|
|
862
937
|
/** Claim a warm sandbox from a pool, creating one if no warm containers are available. */
|
|
@@ -876,9 +951,6 @@ declare class SandboxClient {
|
|
|
876
951
|
* status — the snapshot is created asynchronously. Poll `getSnapshot()` until
|
|
877
952
|
* `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
|
|
878
953
|
* block automatically.
|
|
879
|
-
*
|
|
880
|
-
* @param options.snapshotType - `"filesystem"` for cold-boot snapshots (e.g. image builds).
|
|
881
|
-
* Omit to use the server default (`filesystem`).
|
|
882
954
|
*/
|
|
883
955
|
snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
|
|
884
956
|
/** Get current status and metadata for a snapshot by ID. */
|
|
@@ -893,14 +965,6 @@ declare class SandboxClient {
|
|
|
893
965
|
* Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
|
|
894
966
|
* or `completed`. Pass `{ waitUntil: "completed" }` when durable
|
|
895
967
|
* `snapshotUri` metadata is required.
|
|
896
|
-
* Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
|
|
897
|
-
* without managing the client separately.
|
|
898
|
-
*
|
|
899
|
-
* @param sandboxId - ID of the running sandbox to snapshot.
|
|
900
|
-
* @param options.timeout - Max seconds to wait (default 300).
|
|
901
|
-
* @param options.pollInterval - Seconds between status polls (default 1).
|
|
902
|
-
* @param options.snapshotType - Snapshot type passed through to `snapshot()`.
|
|
903
|
-
* @throws {SandboxError} If the snapshot fails or `timeout` elapses.
|
|
904
968
|
*/
|
|
905
969
|
snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<Traced<SnapshotInfo>>;
|
|
906
970
|
/** Create a new sandbox pool with warm pre-booted containers. */
|
|
@@ -920,10 +984,6 @@ declare class SandboxClient {
|
|
|
920
984
|
*
|
|
921
985
|
* Blocks until the sandbox is ready or `requestTimeout` elapses. The returned
|
|
922
986
|
* `Sandbox` auto-terminates when `terminate()` is called.
|
|
923
|
-
*
|
|
924
|
-
* @param options.requestTimeout - Max seconds to wait for `Running` status (default: client requestTimeout).
|
|
925
|
-
* @param options.startupTimeout - Deprecated alias for `requestTimeout`.
|
|
926
|
-
* @throws {SandboxError} If the sandbox terminates during startup or the timeout elapses.
|
|
927
987
|
*/
|
|
928
988
|
createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
|
|
929
989
|
}
|