tensorlake 0.5.34 → 0.5.35
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 +52 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +52 -2
- 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 +1 -1
|
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.35";
|
|
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";
|
|
@@ -3984,6 +3984,49 @@ var client_exports = {};
|
|
|
3984
3984
|
__export(client_exports, {
|
|
3985
3985
|
SandboxClient: () => SandboxClient
|
|
3986
3986
|
});
|
|
3987
|
+
function cloudInitIncludeData(source) {
|
|
3988
|
+
const isWindowsPath = /^[A-Za-z]:[\\/]/.test(source);
|
|
3989
|
+
try {
|
|
3990
|
+
const url = new URL(source);
|
|
3991
|
+
if ((url.protocol === "http:" || url.protocol === "https:") && url.hostname.length > 0) {
|
|
3992
|
+
return Buffer.from(`#include
|
|
3993
|
+
${url.toString()}
|
|
3994
|
+
`, "utf8");
|
|
3995
|
+
}
|
|
3996
|
+
if (!isWindowsPath) {
|
|
3997
|
+
throw new SandboxError(
|
|
3998
|
+
"cloud-init URL must be an absolute HTTP(S) URL with a host"
|
|
3999
|
+
);
|
|
4000
|
+
}
|
|
4001
|
+
} catch (error) {
|
|
4002
|
+
if (error instanceof SandboxError) throw error;
|
|
4003
|
+
if (!isWindowsPath && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(source)) {
|
|
4004
|
+
throw new SandboxError(
|
|
4005
|
+
"cloud-init URL must be an absolute HTTP(S) URL with a host"
|
|
4006
|
+
);
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
return void 0;
|
|
4010
|
+
}
|
|
4011
|
+
async function readCloudInitBase64(cloudInit) {
|
|
4012
|
+
if (cloudInit == null) return void 0;
|
|
4013
|
+
const sourceText = cloudInit instanceof URL ? cloudInit.toString() : cloudInit;
|
|
4014
|
+
const includeData = cloudInitIncludeData(sourceText);
|
|
4015
|
+
const data = includeData ?? await (0, import_promises.readFile)(sourceText).catch((error) => {
|
|
4016
|
+
throw new SandboxError(
|
|
4017
|
+
`failed to read cloud-init file ${JSON.stringify(sourceText)}: ${error}`
|
|
4018
|
+
);
|
|
4019
|
+
});
|
|
4020
|
+
if (data.length === 0) {
|
|
4021
|
+
throw new SandboxError("cloud-init user data must not be empty");
|
|
4022
|
+
}
|
|
4023
|
+
if (data.length > MAX_CLOUD_INIT_USER_DATA_BYTES) {
|
|
4024
|
+
throw new SandboxError(
|
|
4025
|
+
`cloud-init user data exceeds ${MAX_CLOUD_INIT_USER_DATA_BYTES} byte limit`
|
|
4026
|
+
);
|
|
4027
|
+
}
|
|
4028
|
+
return data.toString("base64");
|
|
4029
|
+
}
|
|
3987
4030
|
function resolveRequestTimeoutMs(options) {
|
|
3988
4031
|
if (options?.requestTimeout != null) {
|
|
3989
4032
|
return secondsToMillis4(options.requestTimeout);
|
|
@@ -4061,10 +4104,11 @@ function validateUserPort(port) {
|
|
|
4061
4104
|
function dedupeAndSortPorts(ports) {
|
|
4062
4105
|
return [...new Set(ports)].sort((a, b) => a - b);
|
|
4063
4106
|
}
|
|
4064
|
-
var CREATE_SANDBOX_RETRYABLE_STATUS_CODES, CREATE_SANDBOX_ALLOWED_ERROR_STATUS_CODES, COPY_SANDBOX_ALLOWED_ERROR_STATUS_CODES, SandboxClient, RESERVED_SANDBOX_MANAGEMENT_PORT;
|
|
4107
|
+
var import_promises, CREATE_SANDBOX_RETRYABLE_STATUS_CODES, CREATE_SANDBOX_ALLOWED_ERROR_STATUS_CODES, COPY_SANDBOX_ALLOWED_ERROR_STATUS_CODES, MAX_CLOUD_INIT_USER_DATA_BYTES, SandboxClient, RESERVED_SANDBOX_MANAGEMENT_PORT;
|
|
4065
4108
|
var init_client = __esm({
|
|
4066
4109
|
"src/client.ts"() {
|
|
4067
4110
|
"use strict";
|
|
4111
|
+
import_promises = require("fs/promises");
|
|
4068
4112
|
init_defaults();
|
|
4069
4113
|
init_errors();
|
|
4070
4114
|
init_http();
|
|
@@ -4074,6 +4118,7 @@ var init_client = __esm({
|
|
|
4074
4118
|
CREATE_SANDBOX_RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([502, 503]);
|
|
4075
4119
|
CREATE_SANDBOX_ALLOWED_ERROR_STATUS_CODES = /* @__PURE__ */ new Set([504]);
|
|
4076
4120
|
COPY_SANDBOX_ALLOWED_ERROR_STATUS_CODES = /* @__PURE__ */ new Set([422, 504]);
|
|
4121
|
+
MAX_CLOUD_INIT_USER_DATA_BYTES = 16 * 1024;
|
|
4077
4122
|
SandboxClient = class _SandboxClient {
|
|
4078
4123
|
http;
|
|
4079
4124
|
apiUrl;
|
|
@@ -4164,6 +4209,7 @@ var init_client = __esm({
|
|
|
4164
4209
|
// --- Sandbox CRUD ---
|
|
4165
4210
|
/** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
|
|
4166
4211
|
async create(options) {
|
|
4212
|
+
const cloudInitBase64 = await readCloudInitBase64(options?.cloudInit);
|
|
4167
4213
|
const body = {
|
|
4168
4214
|
resources: {
|
|
4169
4215
|
cpus: options?.cpus ?? 1,
|
|
@@ -4176,6 +4222,7 @@ var init_client = __esm({
|
|
|
4176
4222
|
if (options?.entrypoint != null) body.entrypoint = options.entrypoint;
|
|
4177
4223
|
if (options?.snapshotId != null) body.snapshot_id = options.snapshotId;
|
|
4178
4224
|
if (options?.name != null) body.name = options.name;
|
|
4225
|
+
if (cloudInitBase64 != null) body.cloud_init_base64 = cloudInitBase64;
|
|
4179
4226
|
if (options?.allowInternetAccess === false || options?.allowOut != null || options?.denyOut != null) {
|
|
4180
4227
|
body.network = {
|
|
4181
4228
|
allow_internet_access: options?.allowInternetAccess ?? true,
|
|
@@ -4593,6 +4640,9 @@ var init_client = __esm({
|
|
|
4593
4640
|
* @throws {SandboxError} If the sandbox terminates during startup or the timeout elapses.
|
|
4594
4641
|
*/
|
|
4595
4642
|
async createAndConnect(options) {
|
|
4643
|
+
if (options?.poolId != null && options?.cloudInit != null) {
|
|
4644
|
+
throw new SandboxError("cloud-init cannot be used with poolId");
|
|
4645
|
+
}
|
|
4596
4646
|
const requestTimeout = options?.requestTimeout ?? options?.startupTimeout ?? this.requestTimeoutMs / 1e3;
|
|
4597
4647
|
const requestClient = this.withRequestTimeout(requestTimeout);
|
|
4598
4648
|
const result = options?.poolId != null ? await requestClient.claim(options.poolId) : await requestClient.create(options);
|