tensorlake 0.5.0 → 0.5.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.
- package/dist/bin/darwin-arm64/tensorlake +0 -0
- package/dist/bin/darwin-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 +84 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -8
- package/dist/index.d.ts +29 -8
- package/dist/index.js +84 -29
- package/dist/index.js.map +1 -1
- package/dist/{sandbox-image-CMJ_FOOV.d.cts → sandbox-image-CEGsGg4V.d.cts} +6 -2
- package/dist/{sandbox-image-CMJ_FOOV.d.ts → sandbox-image-CEGsGg4V.d.ts} +6 -2
- package/dist/sandbox-image.cjs +84 -29
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.d.cts +1 -1
- package/dist/sandbox-image.d.ts +1 -1
- package/dist/sandbox-image.js +84 -29
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +1 -1
package/dist/sandbox-image.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { z as CreateSandboxImageOptions, B as DockerfileBuildPlan, E as DockerfileInstruction, T as SandboxImageSource, Y as createSandboxImage, _ as defaultRegisteredName, $ as loadDockerfilePlan, a0 as loadImagePlan, a1 as logicalDockerfileLines, a2 as runCreateSandboxImageCli } from './sandbox-image-CEGsGg4V.cjs';
|
package/dist/sandbox-image.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { z as CreateSandboxImageOptions, B as DockerfileBuildPlan, E as DockerfileInstruction, T as SandboxImageSource, Y as createSandboxImage, _ as defaultRegisteredName, $ as loadDockerfilePlan, a0 as loadImagePlan, a1 as logicalDockerfileLines, a2 as runCreateSandboxImageCli } from './sandbox-image-CEGsGg4V.js';
|
package/dist/sandbox-image.js
CHANGED
|
@@ -3103,8 +3103,11 @@ var init_sandbox = __esm({
|
|
|
3103
3103
|
wsHeaders;
|
|
3104
3104
|
ownsSandbox = false;
|
|
3105
3105
|
lifecycleClient = null;
|
|
3106
|
+
lifecycleIdentifier;
|
|
3107
|
+
sandboxName = null;
|
|
3106
3108
|
constructor(options) {
|
|
3107
3109
|
this.sandboxId = options.sandboxId;
|
|
3110
|
+
this.lifecycleIdentifier = options.sandboxId;
|
|
3108
3111
|
const proxyUrl = options.proxyUrl ?? SANDBOX_PROXY_URL;
|
|
3109
3112
|
const { baseUrl, hostHeader } = resolveProxyTarget(proxyUrl, options.sandboxId);
|
|
3110
3113
|
this.baseUrl = baseUrl;
|
|
@@ -3130,6 +3133,17 @@ var init_sandbox = __esm({
|
|
|
3130
3133
|
routingHint: options.routingHint
|
|
3131
3134
|
});
|
|
3132
3135
|
}
|
|
3136
|
+
get name() {
|
|
3137
|
+
return this.sandboxName;
|
|
3138
|
+
}
|
|
3139
|
+
/** @internal Used by client wiring to keep locally cached name in sync. */
|
|
3140
|
+
_setName(name) {
|
|
3141
|
+
this.sandboxName = name;
|
|
3142
|
+
}
|
|
3143
|
+
/** @internal Used by lifecycle operations to pin to canonical sandbox ID. */
|
|
3144
|
+
_setLifecycleIdentifier(identifier) {
|
|
3145
|
+
this.lifecycleIdentifier = identifier;
|
|
3146
|
+
}
|
|
3133
3147
|
/** @internal Used by SandboxClient.createAndConnect to set ownership. */
|
|
3134
3148
|
_setOwner(client) {
|
|
3135
3149
|
this.ownsSandbox = true;
|
|
@@ -3167,9 +3181,15 @@ var init_sandbox = __esm({
|
|
|
3167
3181
|
/* _internal */
|
|
3168
3182
|
true
|
|
3169
3183
|
);
|
|
3170
|
-
await client.get(options.sandboxId);
|
|
3171
|
-
const sandbox = client.connect(
|
|
3184
|
+
const info = await client.get(options.sandboxId);
|
|
3185
|
+
const sandbox = client.connect(
|
|
3186
|
+
info.sandboxId,
|
|
3187
|
+
options.proxyUrl,
|
|
3188
|
+
options.routingHint ?? info.routingHint
|
|
3189
|
+
);
|
|
3172
3190
|
sandbox.lifecycleClient = client;
|
|
3191
|
+
sandbox._setLifecycleIdentifier(info.sandboxId);
|
|
3192
|
+
sandbox._setName(info.name ?? null);
|
|
3173
3193
|
return sandbox;
|
|
3174
3194
|
}
|
|
3175
3195
|
// --- Static snapshot management ---
|
|
@@ -3202,6 +3222,32 @@ var init_sandbox = __esm({
|
|
|
3202
3222
|
}
|
|
3203
3223
|
return this.lifecycleClient;
|
|
3204
3224
|
}
|
|
3225
|
+
/**
|
|
3226
|
+
* Fetch the current sandbox status from the server.
|
|
3227
|
+
*
|
|
3228
|
+
* Always hits the network — the value is not cached locally because the
|
|
3229
|
+
* status changes over the sandbox's lifecycle.
|
|
3230
|
+
*/
|
|
3231
|
+
async status() {
|
|
3232
|
+
const client = this.requireLifecycleClient("read_status");
|
|
3233
|
+
const info = await client.get(this.lifecycleIdentifier);
|
|
3234
|
+
this._setLifecycleIdentifier(info.sandboxId);
|
|
3235
|
+
this._setName(info.name ?? null);
|
|
3236
|
+
return info.status;
|
|
3237
|
+
}
|
|
3238
|
+
/**
|
|
3239
|
+
* Update this sandbox's properties (name, exposed ports, proxy auth).
|
|
3240
|
+
*
|
|
3241
|
+
* Naming an ephemeral sandbox makes it non-ephemeral and enables
|
|
3242
|
+
* suspend/resume.
|
|
3243
|
+
*/
|
|
3244
|
+
async update(options) {
|
|
3245
|
+
const client = this.requireLifecycleClient("update");
|
|
3246
|
+
const info = await client.update(this.lifecycleIdentifier, options);
|
|
3247
|
+
this._setLifecycleIdentifier(info.sandboxId);
|
|
3248
|
+
this._setName(info.name ?? null);
|
|
3249
|
+
return info;
|
|
3250
|
+
}
|
|
3205
3251
|
/**
|
|
3206
3252
|
* Suspend this sandbox.
|
|
3207
3253
|
*
|
|
@@ -3210,7 +3256,7 @@ var init_sandbox = __esm({
|
|
|
3210
3256
|
*/
|
|
3211
3257
|
async suspend(options) {
|
|
3212
3258
|
const client = this.requireLifecycleClient("suspend");
|
|
3213
|
-
await client.suspend(this.
|
|
3259
|
+
await client.suspend(this.lifecycleIdentifier, options);
|
|
3214
3260
|
}
|
|
3215
3261
|
/**
|
|
3216
3262
|
* Resume this sandbox.
|
|
@@ -3220,7 +3266,7 @@ var init_sandbox = __esm({
|
|
|
3220
3266
|
*/
|
|
3221
3267
|
async resume(options) {
|
|
3222
3268
|
const client = this.requireLifecycleClient("resume");
|
|
3223
|
-
await client.resume(this.
|
|
3269
|
+
await client.resume(this.lifecycleIdentifier, options);
|
|
3224
3270
|
}
|
|
3225
3271
|
/**
|
|
3226
3272
|
* Create a snapshot of this sandbox's filesystem and wait for it to
|
|
@@ -3233,10 +3279,10 @@ var init_sandbox = __esm({
|
|
|
3233
3279
|
async checkpoint(options) {
|
|
3234
3280
|
const client = this.requireLifecycleClient("checkpoint");
|
|
3235
3281
|
if (options?.wait === false) {
|
|
3236
|
-
await client.snapshot(this.
|
|
3282
|
+
await client.snapshot(this.lifecycleIdentifier, { contentMode: options.contentMode });
|
|
3237
3283
|
return void 0;
|
|
3238
3284
|
}
|
|
3239
|
-
return client.snapshotAndWait(this.
|
|
3285
|
+
return client.snapshotAndWait(this.lifecycleIdentifier, {
|
|
3240
3286
|
timeout: options?.timeout,
|
|
3241
3287
|
pollInterval: options?.pollInterval,
|
|
3242
3288
|
contentMode: options?.contentMode
|
|
@@ -3248,7 +3294,8 @@ var init_sandbox = __esm({
|
|
|
3248
3294
|
async listSnapshots() {
|
|
3249
3295
|
const client = this.requireLifecycleClient("listSnapshots");
|
|
3250
3296
|
const all = await client.listSnapshots();
|
|
3251
|
-
|
|
3297
|
+
const filtered = all.filter((s) => s.sandboxId === this.lifecycleIdentifier);
|
|
3298
|
+
return Object.assign(filtered, { traceId: all.traceId });
|
|
3252
3299
|
}
|
|
3253
3300
|
/** Close the HTTP client. The sandbox keeps running. */
|
|
3254
3301
|
close() {
|
|
@@ -3261,7 +3308,7 @@ var init_sandbox = __esm({
|
|
|
3261
3308
|
this.lifecycleClient = null;
|
|
3262
3309
|
this.close();
|
|
3263
3310
|
if (client) {
|
|
3264
|
-
await client.delete(this.
|
|
3311
|
+
await client.delete(this.lifecycleIdentifier);
|
|
3265
3312
|
}
|
|
3266
3313
|
}
|
|
3267
3314
|
// --- High-level convenience ---
|
|
@@ -3342,7 +3389,8 @@ var init_sandbox = __esm({
|
|
|
3342
3389
|
"GET",
|
|
3343
3390
|
"/api/v1/processes"
|
|
3344
3391
|
);
|
|
3345
|
-
|
|
3392
|
+
const processes = (raw.processes ?? []).map((p) => fromSnakeKeys(p));
|
|
3393
|
+
return Object.assign(processes, { traceId: raw.traceId });
|
|
3346
3394
|
}
|
|
3347
3395
|
/** Get current status and metadata for a process by PID. */
|
|
3348
3396
|
async getProcess(pid) {
|
|
@@ -3679,7 +3727,7 @@ var init_client = __esm({
|
|
|
3679
3727
|
resources: {
|
|
3680
3728
|
cpus: options?.cpus ?? 1,
|
|
3681
3729
|
memory_mb: options?.memoryMb ?? 1024,
|
|
3682
|
-
|
|
3730
|
+
...options?.diskMb != null ? { disk_mb: options.diskMb } : {}
|
|
3683
3731
|
}
|
|
3684
3732
|
};
|
|
3685
3733
|
if (options?.image != null) body.image = options.image;
|
|
@@ -3717,9 +3765,10 @@ var init_client = __esm({
|
|
|
3717
3765
|
"GET",
|
|
3718
3766
|
this.path("sandboxes")
|
|
3719
3767
|
);
|
|
3720
|
-
|
|
3768
|
+
const sandboxes = (raw.sandboxes ?? []).map(
|
|
3721
3769
|
(s) => fromSnakeKeys(s, "sandboxId")
|
|
3722
3770
|
);
|
|
3771
|
+
return Object.assign(sandboxes, { traceId: raw.traceId });
|
|
3723
3772
|
}
|
|
3724
3773
|
/** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
|
|
3725
3774
|
async update(sandboxId, options) {
|
|
@@ -3889,9 +3938,10 @@ var init_client = __esm({
|
|
|
3889
3938
|
"GET",
|
|
3890
3939
|
this.path("snapshots")
|
|
3891
3940
|
);
|
|
3892
|
-
|
|
3941
|
+
const snapshots = (raw.snapshots ?? []).map(
|
|
3893
3942
|
(s) => fromSnakeKeys(s, "snapshotId")
|
|
3894
3943
|
);
|
|
3944
|
+
return Object.assign(snapshots, { traceId: raw.traceId });
|
|
3895
3945
|
}
|
|
3896
3946
|
/** Delete a snapshot by ID. */
|
|
3897
3947
|
async deleteSnapshot(snapshotId) {
|
|
@@ -3971,9 +4021,10 @@ var init_client = __esm({
|
|
|
3971
4021
|
"GET",
|
|
3972
4022
|
this.path("sandbox-pools")
|
|
3973
4023
|
);
|
|
3974
|
-
|
|
4024
|
+
const pools = (raw.pools ?? []).map(
|
|
3975
4025
|
(p) => fromSnakeKeys(p, "poolId")
|
|
3976
4026
|
);
|
|
4027
|
+
return Object.assign(pools, { traceId: raw.traceId });
|
|
3977
4028
|
}
|
|
3978
4029
|
/** Replace the configuration of an existing sandbox pool. */
|
|
3979
4030
|
async updatePool(poolId, options) {
|
|
@@ -4028,26 +4079,24 @@ var init_client = __esm({
|
|
|
4028
4079
|
*/
|
|
4029
4080
|
async createAndConnect(options) {
|
|
4030
4081
|
const startupTimeout = options?.startupTimeout ?? 60;
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
result = await this.create(options);
|
|
4036
|
-
}
|
|
4037
|
-
if (result.status === "running" /* RUNNING */) {
|
|
4038
|
-
const sandbox = this.connect(result.sandboxId, options?.proxyUrl, result.routingHint);
|
|
4082
|
+
const result = options?.poolId != null ? await this.claim(options.poolId) : await this.create(options);
|
|
4083
|
+
const requestedName = options?.poolId != null ? null : options?.name ?? null;
|
|
4084
|
+
const finishConnect = (routingHint, name) => {
|
|
4085
|
+
const sandbox = this.connect(result.sandboxId, options?.proxyUrl, routingHint);
|
|
4039
4086
|
sandbox._setOwner(this);
|
|
4040
4087
|
sandbox.traceId = result.traceId;
|
|
4088
|
+
sandbox._setLifecycleIdentifier(result.sandboxId);
|
|
4089
|
+
sandbox._setName(name ?? requestedName);
|
|
4041
4090
|
return sandbox;
|
|
4091
|
+
};
|
|
4092
|
+
if (result.status === "running" /* RUNNING */) {
|
|
4093
|
+
return finishConnect(result.routingHint, result.name);
|
|
4042
4094
|
}
|
|
4043
4095
|
const deadline = Date.now() + startupTimeout * 1e3;
|
|
4044
4096
|
while (Date.now() < deadline) {
|
|
4045
4097
|
const info = await this.get(result.sandboxId);
|
|
4046
4098
|
if (info.status === "running" /* RUNNING */) {
|
|
4047
|
-
|
|
4048
|
-
sandbox._setOwner(this);
|
|
4049
|
-
sandbox.traceId = result.traceId;
|
|
4050
|
-
return sandbox;
|
|
4099
|
+
return finishConnect(info.routingHint, info.name);
|
|
4051
4100
|
}
|
|
4052
4101
|
if (info.status === "terminated" /* TERMINATED */) {
|
|
4053
4102
|
throw new SandboxError(
|
|
@@ -4786,7 +4835,8 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
4786
4835
|
sandbox = await client.createAndConnect({
|
|
4787
4836
|
...plan.baseImage == null ? {} : { image: plan.baseImage },
|
|
4788
4837
|
cpus: options.cpus ?? 2,
|
|
4789
|
-
memoryMb: options.memoryMb ?? 4096
|
|
4838
|
+
memoryMb: options.memoryMb ?? 4096,
|
|
4839
|
+
...options.diskMb != null ? { diskMb: options.diskMb } : {}
|
|
4790
4840
|
});
|
|
4791
4841
|
emit({
|
|
4792
4842
|
type: "status",
|
|
@@ -4799,8 +4849,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
4799
4849
|
});
|
|
4800
4850
|
emit({
|
|
4801
4851
|
type: "snapshot_created",
|
|
4802
|
-
snapshot_id: snapshot.snapshotId
|
|
4803
|
-
snapshot_uri: snapshot.snapshotUri ?? null
|
|
4852
|
+
snapshot_id: snapshot.snapshotId
|
|
4804
4853
|
});
|
|
4805
4854
|
if (!snapshot.snapshotUri) {
|
|
4806
4855
|
throw new Error(
|
|
@@ -4844,27 +4893,33 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
4844
4893
|
name: { type: "string", short: "n" },
|
|
4845
4894
|
cpus: { type: "string" },
|
|
4846
4895
|
memory: { type: "string" },
|
|
4896
|
+
disk: { type: "string" },
|
|
4847
4897
|
public: { type: "boolean", default: false }
|
|
4848
4898
|
}
|
|
4849
4899
|
});
|
|
4850
4900
|
const dockerfilePath = parsed.positionals[0];
|
|
4851
4901
|
if (!dockerfilePath) {
|
|
4852
|
-
throw new Error("Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--public]");
|
|
4902
|
+
throw new Error("Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--disk GB] [--public]");
|
|
4853
4903
|
}
|
|
4854
4904
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
4855
4905
|
const memoryMb = parsed.values.memory != null ? Number(parsed.values.memory) : void 0;
|
|
4906
|
+
const diskGb = parsed.values.disk != null ? Number(parsed.values.disk) : void 0;
|
|
4856
4907
|
if (cpus != null && !Number.isFinite(cpus)) {
|
|
4857
4908
|
throw new Error(`Invalid --cpus value: ${parsed.values.cpus}`);
|
|
4858
4909
|
}
|
|
4859
4910
|
if (memoryMb != null && !Number.isInteger(memoryMb)) {
|
|
4860
4911
|
throw new Error(`Invalid --memory value: ${parsed.values.memory}`);
|
|
4861
4912
|
}
|
|
4913
|
+
if (diskGb != null && !Number.isInteger(diskGb)) {
|
|
4914
|
+
throw new Error(`Invalid --disk value: ${parsed.values.disk}`);
|
|
4915
|
+
}
|
|
4862
4916
|
await createSandboxImage(
|
|
4863
4917
|
dockerfilePath,
|
|
4864
4918
|
{
|
|
4865
4919
|
registeredName: parsed.values.name,
|
|
4866
4920
|
cpus,
|
|
4867
4921
|
memoryMb,
|
|
4922
|
+
diskMb: diskGb != null ? diskGb * 1024 : void 0,
|
|
4868
4923
|
isPublic: parsed.values.public
|
|
4869
4924
|
},
|
|
4870
4925
|
{ emit: ndjsonStdoutEmit }
|