tensorlake 0.5.31 → 0.5.33
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 +68 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -8
- package/dist/index.d.ts +47 -8
- package/dist/index.js +68 -11
- package/dist/index.js.map +1 -1
- package/dist/native/darwin-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 +2 -2
|
Binary file
|
package/dist/bin/darwin-arm64/tl
CHANGED
|
Binary file
|
|
Binary file
|
package/dist/bin/linux-x64/tl
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
|
|
|
35
35
|
var init_defaults = __esm({
|
|
36
36
|
"src/defaults.ts"() {
|
|
37
37
|
"use strict";
|
|
38
|
-
SDK_VERSION = "0.5.
|
|
38
|
+
SDK_VERSION = "0.5.33";
|
|
39
39
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
40
40
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
41
41
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -48,6 +48,28 @@ var init_defaults = __esm({
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
// src/errors.ts
|
|
51
|
+
function describeError(err) {
|
|
52
|
+
const parts = [];
|
|
53
|
+
const seen = /* @__PURE__ */ new Set();
|
|
54
|
+
let current = err;
|
|
55
|
+
for (let depth = 0; depth < 6; depth++) {
|
|
56
|
+
if (current == null || typeof current !== "object" || seen.has(current)) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
seen.add(current);
|
|
60
|
+
const e = current;
|
|
61
|
+
const message = typeof e.message === "string" ? e.message.trim() : "";
|
|
62
|
+
const code = typeof e.code === "string" ? e.code : void 0;
|
|
63
|
+
let segment = message;
|
|
64
|
+
if (code && (!message || !message.includes(code))) {
|
|
65
|
+
segment = segment ? `${segment} (${code})` : code;
|
|
66
|
+
}
|
|
67
|
+
if (segment && !parts.includes(segment)) parts.push(segment);
|
|
68
|
+
current = e.cause;
|
|
69
|
+
}
|
|
70
|
+
if (parts.length > 0) return parts.join(": ");
|
|
71
|
+
return err instanceof Error ? err.message : String(err);
|
|
72
|
+
}
|
|
51
73
|
var SandboxException, SandboxError, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError, RequestNotFinishedError, RequestFailedError, RequestExecutionError;
|
|
52
74
|
var init_errors = __esm({
|
|
53
75
|
"src/errors.ts"() {
|
|
@@ -65,9 +87,10 @@ var init_errors = __esm({
|
|
|
65
87
|
}
|
|
66
88
|
};
|
|
67
89
|
SandboxConnectionError = class extends SandboxError {
|
|
68
|
-
constructor(message) {
|
|
90
|
+
constructor(message, options) {
|
|
69
91
|
super(`Connection error: ${message}`);
|
|
70
92
|
this.name = "SandboxConnectionError";
|
|
93
|
+
if (options?.cause !== void 0) this.cause = options.cause;
|
|
71
94
|
}
|
|
72
95
|
};
|
|
73
96
|
SandboxNotFoundError = class extends SandboxError {
|
|
@@ -334,7 +357,11 @@ var init_http = __esm({
|
|
|
334
357
|
await sleep(delay);
|
|
335
358
|
}
|
|
336
359
|
this.abortController = new AbortController();
|
|
337
|
-
|
|
360
|
+
let timedOut = false;
|
|
361
|
+
const timeoutId = this.timeoutMs == null ? null : setTimeout(() => {
|
|
362
|
+
timedOut = true;
|
|
363
|
+
this.abortController?.abort();
|
|
364
|
+
}, this.timeoutMs);
|
|
338
365
|
const combinedSignal = signal ? anySignal([signal, this.abortController.signal]) : this.abortController.signal;
|
|
339
366
|
try {
|
|
340
367
|
const response = await (0, import_undici.fetch)(url, {
|
|
@@ -362,16 +389,22 @@ var init_http = __esm({
|
|
|
362
389
|
if (err instanceof RemoteAPIError || err instanceof SandboxNotFoundError || err instanceof PoolNotFoundError || err instanceof PoolInUseError) {
|
|
363
390
|
throw err;
|
|
364
391
|
}
|
|
365
|
-
if (signal?.aborted) {
|
|
366
|
-
throw new SandboxConnectionError("
|
|
392
|
+
if (signal?.aborted && !timedOut) {
|
|
393
|
+
throw new SandboxConnectionError("request aborted by caller", {
|
|
394
|
+
cause: err
|
|
395
|
+
});
|
|
367
396
|
}
|
|
368
397
|
lastError = err instanceof Error ? err : new Error(String(err));
|
|
369
398
|
if (attempt >= this.maxRetries) {
|
|
370
|
-
|
|
399
|
+
const detail = timedOut ? `request timed out after ${this.timeoutMs}ms` : describeError(err);
|
|
400
|
+
throw new SandboxConnectionError(detail, { cause: err });
|
|
371
401
|
}
|
|
372
402
|
}
|
|
373
403
|
}
|
|
374
|
-
throw new SandboxConnectionError(
|
|
404
|
+
throw new SandboxConnectionError(
|
|
405
|
+
lastError ? describeError(lastError) : "request failed",
|
|
406
|
+
{ cause: lastError }
|
|
407
|
+
);
|
|
375
408
|
}
|
|
376
409
|
};
|
|
377
410
|
}
|
|
@@ -3501,6 +3534,11 @@ var init_sandbox = __esm({
|
|
|
3501
3534
|
const client = this.requireLifecycleClient("resume");
|
|
3502
3535
|
await client.resume(this.lifecycleIdentifier, options);
|
|
3503
3536
|
}
|
|
3537
|
+
/** Live-copy this running sandbox. */
|
|
3538
|
+
async copy(options) {
|
|
3539
|
+
const client = this.requireLifecycleClient("copy");
|
|
3540
|
+
return client.copy(this.lifecycleIdentifier, options);
|
|
3541
|
+
}
|
|
3504
3542
|
/**
|
|
3505
3543
|
* Create a checkpoint of this sandbox and wait for it to be locally ready.
|
|
3506
3544
|
*
|
|
@@ -3994,7 +4032,7 @@ function validateUserPort(port) {
|
|
|
3994
4032
|
function dedupeAndSortPorts(ports) {
|
|
3995
4033
|
return [...new Set(ports)].sort((a, b) => a - b);
|
|
3996
4034
|
}
|
|
3997
|
-
var CREATE_SANDBOX_RETRYABLE_STATUS_CODES, CREATE_SANDBOX_ALLOWED_ERROR_STATUS_CODES, SandboxClient, RESERVED_SANDBOX_MANAGEMENT_PORT;
|
|
4035
|
+
var CREATE_SANDBOX_RETRYABLE_STATUS_CODES, CREATE_SANDBOX_ALLOWED_ERROR_STATUS_CODES, COPY_SANDBOX_ALLOWED_ERROR_STATUS_CODES, SandboxClient, RESERVED_SANDBOX_MANAGEMENT_PORT;
|
|
3998
4036
|
var init_client = __esm({
|
|
3999
4037
|
"src/client.ts"() {
|
|
4000
4038
|
"use strict";
|
|
@@ -4006,6 +4044,7 @@ var init_client = __esm({
|
|
|
4006
4044
|
init_url();
|
|
4007
4045
|
CREATE_SANDBOX_RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([502, 503]);
|
|
4008
4046
|
CREATE_SANDBOX_ALLOWED_ERROR_STATUS_CODES = /* @__PURE__ */ new Set([504]);
|
|
4047
|
+
COPY_SANDBOX_ALLOWED_ERROR_STATUS_CODES = /* @__PURE__ */ new Set([422, 504]);
|
|
4009
4048
|
SandboxClient = class _SandboxClient {
|
|
4010
4049
|
http;
|
|
4011
4050
|
apiUrl;
|
|
@@ -4104,7 +4143,6 @@ var init_client = __esm({
|
|
|
4104
4143
|
}
|
|
4105
4144
|
};
|
|
4106
4145
|
if (options?.image != null) body.image = options.image;
|
|
4107
|
-
if (options?.secretNames != null) body.secret_names = options.secretNames;
|
|
4108
4146
|
if (options?.timeoutSecs != null) body.timeout_secs = options.timeoutSecs;
|
|
4109
4147
|
if (options?.entrypoint != null) body.entrypoint = options.entrypoint;
|
|
4110
4148
|
if (options?.snapshotId != null) body.snapshot_id = options.snapshotId;
|
|
@@ -4326,6 +4364,27 @@ var init_client = __esm({
|
|
|
4326
4364
|
const result = fromSnakeKeys(raw, "sandboxId");
|
|
4327
4365
|
return Object.assign(result, { traceId: raw.traceId });
|
|
4328
4366
|
}
|
|
4367
|
+
/**
|
|
4368
|
+
* Live-copy a running sandbox.
|
|
4369
|
+
*
|
|
4370
|
+
* The server creates `times` running copies from the source sandbox. Partial
|
|
4371
|
+
* responses can include failed copies; inspect each returned sandbox's
|
|
4372
|
+
* `status` and `reason`.
|
|
4373
|
+
*/
|
|
4374
|
+
async copy(sandboxId, options) {
|
|
4375
|
+
const times = options?.times ?? 1;
|
|
4376
|
+
if (!Number.isInteger(times) || times < 1) {
|
|
4377
|
+
throw new SandboxError("times must be a positive integer");
|
|
4378
|
+
}
|
|
4379
|
+
const client = this.withRequestTimeout(options?.requestTimeout);
|
|
4380
|
+
const raw = await client.http.requestJson(
|
|
4381
|
+
"POST",
|
|
4382
|
+
client.path(`sandbox/${sandboxId}/copy?times=${encodeURIComponent(String(times))}`),
|
|
4383
|
+
{ allowedErrorStatusCodes: COPY_SANDBOX_ALLOWED_ERROR_STATUS_CODES }
|
|
4384
|
+
);
|
|
4385
|
+
const result = fromSnakeKeys(raw, "sandboxId");
|
|
4386
|
+
return Object.assign(result, { traceId: raw.traceId });
|
|
4387
|
+
}
|
|
4329
4388
|
// --- Snapshots ---
|
|
4330
4389
|
/**
|
|
4331
4390
|
* Request a snapshot of a running sandbox's filesystem.
|
|
@@ -4422,7 +4481,6 @@ var init_client = __esm({
|
|
|
4422
4481
|
},
|
|
4423
4482
|
timeout_secs: options.timeoutSecs ?? 0
|
|
4424
4483
|
};
|
|
4425
|
-
if (options.secretNames != null) body.secret_names = options.secretNames;
|
|
4426
4484
|
if (options.entrypoint != null) body.entrypoint = options.entrypoint;
|
|
4427
4485
|
if (options.maxContainers != null) body.max_containers = options.maxContainers;
|
|
4428
4486
|
if (options.warmContainers != null) body.warm_containers = options.warmContainers;
|
|
@@ -4463,7 +4521,6 @@ var init_client = __esm({
|
|
|
4463
4521
|
},
|
|
4464
4522
|
timeout_secs: options.timeoutSecs ?? 0
|
|
4465
4523
|
};
|
|
4466
|
-
if (options.secretNames != null) body.secret_names = options.secretNames;
|
|
4467
4524
|
if (options.entrypoint != null) body.entrypoint = options.entrypoint;
|
|
4468
4525
|
if (options.maxContainers != null) body.max_containers = options.maxContainers;
|
|
4469
4526
|
if (options.warmContainers != null) body.warm_containers = options.warmContainers;
|