tensorlake 0.5.13 → 0.5.17
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 +56 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +56 -15
- package/dist/index.js.map +1 -1
- package/dist/{sandbox-image-BepgJl5u.d.cts → sandbox-image-BBcx3bSx.d.cts} +11 -1
- package/dist/{sandbox-image-BepgJl5u.d.ts → sandbox-image-BBcx3bSx.d.ts} +11 -1
- package/dist/sandbox-image.cjs +56 -15
- 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 +56 -15
- 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 { a5 as BuildContext, F as CreateSandboxImageOptions, I as DockerfileBuildPlan, J as DockerfileInstruction, _ as SandboxImageSource, a3 as createSandboxImage, a6 as defaultRegisteredName, a7 as loadDockerfilePlan, a8 as loadImagePlan, a9 as logicalDockerfileLines, aa as registerImage, ab as runCreateSandboxImageCli } from './sandbox-image-BBcx3bSx.cjs';
|
package/dist/sandbox-image.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a5 as BuildContext, F as CreateSandboxImageOptions, I as DockerfileBuildPlan, J as DockerfileInstruction, _ as SandboxImageSource, a3 as createSandboxImage, a6 as defaultRegisteredName, a7 as loadDockerfilePlan, a8 as loadImagePlan, a9 as logicalDockerfileLines, aa as registerImage, ab as runCreateSandboxImageCli } from './sandbox-image-BBcx3bSx.js';
|
package/dist/sandbox-image.js
CHANGED
|
@@ -61,7 +61,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
|
|
|
61
61
|
var init_defaults = __esm({
|
|
62
62
|
"src/defaults.ts"() {
|
|
63
63
|
"use strict";
|
|
64
|
-
SDK_VERSION = "0.5.
|
|
64
|
+
SDK_VERSION = "0.5.17";
|
|
65
65
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
66
66
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
67
67
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -2916,6 +2916,15 @@ var init_url = __esm({
|
|
|
2916
2916
|
|
|
2917
2917
|
// src/sandbox.ts
|
|
2918
2918
|
import WebSocket2 from "ws";
|
|
2919
|
+
function processUserPayload(user) {
|
|
2920
|
+
if (user == null) {
|
|
2921
|
+
return DEFAULT_PROCESS_USER;
|
|
2922
|
+
}
|
|
2923
|
+
if (typeof user === "string" && user.trim() === "") {
|
|
2924
|
+
throw new SandboxError("process user must not be empty");
|
|
2925
|
+
}
|
|
2926
|
+
return user;
|
|
2927
|
+
}
|
|
2919
2928
|
function normalizePtyMessage(message) {
|
|
2920
2929
|
if (Buffer.isBuffer(message)) return message;
|
|
2921
2930
|
if (Array.isArray(message)) {
|
|
@@ -2939,7 +2948,7 @@ function sendPtyFrame(socket, frame) {
|
|
|
2939
2948
|
socket.send(frame, (error) => error ? reject(error) : resolve());
|
|
2940
2949
|
});
|
|
2941
2950
|
}
|
|
2942
|
-
var PTY_OP_DATA, PTY_OP_RESIZE, PTY_OP_READY, PTY_OP_EXIT, Pty, Sandbox;
|
|
2951
|
+
var DEFAULT_PROCESS_USER, PTY_OP_DATA, PTY_OP_RESIZE, PTY_OP_READY, PTY_OP_EXIT, Pty, Sandbox;
|
|
2943
2952
|
var init_sandbox = __esm({
|
|
2944
2953
|
"src/sandbox.ts"() {
|
|
2945
2954
|
"use strict";
|
|
@@ -2951,6 +2960,7 @@ var init_sandbox = __esm({
|
|
|
2951
2960
|
init_tunnel();
|
|
2952
2961
|
init_sse();
|
|
2953
2962
|
init_url();
|
|
2963
|
+
DEFAULT_PROCESS_USER = "tl-user";
|
|
2954
2964
|
PTY_OP_DATA = 0;
|
|
2955
2965
|
PTY_OP_RESIZE = 1;
|
|
2956
2966
|
PTY_OP_READY = 2;
|
|
@@ -3371,6 +3381,8 @@ var init_sandbox = __esm({
|
|
|
3371
3381
|
if (options?.env) body.env = options.env;
|
|
3372
3382
|
if (options?.workingDir) body.working_dir = options.workingDir;
|
|
3373
3383
|
if (options?.timeout != null) body.timeout = options.timeout;
|
|
3384
|
+
const user = processUserPayload(options?.user);
|
|
3385
|
+
body.user = user;
|
|
3374
3386
|
const sseStream = await this.http.requestStream(
|
|
3375
3387
|
"POST",
|
|
3376
3388
|
"/api/v1/processes/run",
|
|
@@ -3414,6 +3426,8 @@ var init_sandbox = __esm({
|
|
|
3414
3426
|
if (options?.args != null) payload.args = options.args;
|
|
3415
3427
|
if (options?.env != null) payload.env = options.env;
|
|
3416
3428
|
if (options?.workingDir != null) payload.working_dir = options.workingDir;
|
|
3429
|
+
const user = processUserPayload(options?.user);
|
|
3430
|
+
payload.user = user;
|
|
3417
3431
|
if (options?.stdinMode != null && options.stdinMode !== "closed" /* CLOSED */) {
|
|
3418
3432
|
payload.stdin_mode = options.stdinMode;
|
|
3419
3433
|
}
|
|
@@ -4897,12 +4911,16 @@ function optionalNumber(object, key) {
|
|
|
4897
4911
|
}
|
|
4898
4912
|
return value;
|
|
4899
4913
|
}
|
|
4900
|
-
async function runChecked(sandbox, command, args, env, workingDir) {
|
|
4901
|
-
const
|
|
4914
|
+
async function runChecked(sandbox, command, args, env, workingDir, user) {
|
|
4915
|
+
const options = {
|
|
4902
4916
|
args,
|
|
4903
4917
|
env,
|
|
4904
4918
|
workingDir
|
|
4905
|
-
}
|
|
4919
|
+
};
|
|
4920
|
+
if (user != null) {
|
|
4921
|
+
options.user = user;
|
|
4922
|
+
}
|
|
4923
|
+
const result = await sandbox.run(command, options);
|
|
4906
4924
|
if (result.exitCode !== 0) {
|
|
4907
4925
|
throw new Error(
|
|
4908
4926
|
`Command '${command} ${args.join(" ")}' failed with exit code ${result.exitCode}`
|
|
@@ -4914,7 +4932,8 @@ async function runStreaming(sandbox, emit, sleep3, command, args = [], env, work
|
|
|
4914
4932
|
const proc = await sandbox.startProcess(command, {
|
|
4915
4933
|
args,
|
|
4916
4934
|
env,
|
|
4917
|
-
workingDir
|
|
4935
|
+
workingDir,
|
|
4936
|
+
user: ROOTFS_BUILDER_PROCESS_USER
|
|
4918
4937
|
});
|
|
4919
4938
|
let stdoutSeen = 0;
|
|
4920
4939
|
let stderrSeen = 0;
|
|
@@ -4956,13 +4975,37 @@ function emitOutputLines(emit, stream, response, seen) {
|
|
|
4956
4975
|
emit({ type: "build_log", stream, message: line });
|
|
4957
4976
|
}
|
|
4958
4977
|
}
|
|
4978
|
+
async function ensureRemoteBuildRoot(sandbox) {
|
|
4979
|
+
await runChecked(
|
|
4980
|
+
sandbox,
|
|
4981
|
+
"mkdir",
|
|
4982
|
+
["-p", REMOTE_BUILD_DIR],
|
|
4983
|
+
void 0,
|
|
4984
|
+
void 0,
|
|
4985
|
+
ROOTFS_BUILDER_PROCESS_USER
|
|
4986
|
+
);
|
|
4987
|
+
await runChecked(
|
|
4988
|
+
sandbox,
|
|
4989
|
+
"chmod",
|
|
4990
|
+
["0777", REMOTE_BUILD_DIR],
|
|
4991
|
+
void 0,
|
|
4992
|
+
void 0,
|
|
4993
|
+
ROOTFS_BUILDER_PROCESS_USER
|
|
4994
|
+
);
|
|
4995
|
+
}
|
|
4996
|
+
async function ensureRemoteDirectory(sandbox, remotePath) {
|
|
4997
|
+
await runChecked(sandbox, "mkdir", ["-p", remotePath]);
|
|
4998
|
+
}
|
|
4999
|
+
async function ensureRemoteParentDir(sandbox, remotePath) {
|
|
5000
|
+
await ensureRemoteDirectory(sandbox, path.posix.dirname(remotePath));
|
|
5001
|
+
}
|
|
4959
5002
|
async function copyLocalPathToSandbox(sandbox, localPath, remotePath) {
|
|
4960
5003
|
const fileStats = await stat(localPath).catch(() => null);
|
|
4961
5004
|
if (!fileStats) {
|
|
4962
5005
|
throw new Error(`Local path not found: ${localPath}`);
|
|
4963
5006
|
}
|
|
4964
5007
|
if (fileStats.isFile()) {
|
|
4965
|
-
await
|
|
5008
|
+
await ensureRemoteParentDir(sandbox, remotePath);
|
|
4966
5009
|
await sandbox.writeFile(remotePath, await readFile(localPath));
|
|
4967
5010
|
return;
|
|
4968
5011
|
}
|
|
@@ -4974,14 +5017,10 @@ async function copyLocalPathToSandbox(sandbox, localPath, remotePath) {
|
|
|
4974
5017
|
const sourcePath = path.join(localPath, entry.name);
|
|
4975
5018
|
const destinationPath = path.posix.join(remotePath, entry.name);
|
|
4976
5019
|
if (entry.isDirectory()) {
|
|
4977
|
-
await
|
|
5020
|
+
await ensureRemoteDirectory(sandbox, destinationPath);
|
|
4978
5021
|
await copyLocalPathToSandbox(sandbox, sourcePath, destinationPath);
|
|
4979
5022
|
} else if (entry.isFile()) {
|
|
4980
|
-
await
|
|
4981
|
-
sandbox,
|
|
4982
|
-
"mkdir",
|
|
4983
|
-
["-p", path.posix.dirname(destinationPath)]
|
|
4984
|
-
);
|
|
5023
|
+
await ensureRemoteParentDir(sandbox, destinationPath);
|
|
4985
5024
|
await sandbox.writeFile(destinationPath, await readFile(sourcePath));
|
|
4986
5025
|
}
|
|
4987
5026
|
}
|
|
@@ -5078,6 +5117,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
5078
5117
|
message: `Rootfs builder sandbox ${sandbox.sandboxId} is running`
|
|
5079
5118
|
});
|
|
5080
5119
|
emit({ type: "status", message: "Uploading build context..." });
|
|
5120
|
+
await ensureRemoteBuildRoot(sandbox);
|
|
5081
5121
|
await copyLocalPathToSandbox(sandbox, plan.contextDir, REMOTE_CONTEXT_DIR);
|
|
5082
5122
|
const spec = await buildRootfsSpec(
|
|
5083
5123
|
preparedSpec,
|
|
@@ -5085,7 +5125,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
5085
5125
|
plan,
|
|
5086
5126
|
options.diskMb
|
|
5087
5127
|
);
|
|
5088
|
-
await
|
|
5128
|
+
await ensureRemoteParentDir(sandbox, REMOTE_SPEC_PATH);
|
|
5089
5129
|
await sandbox.writeFile(
|
|
5090
5130
|
REMOTE_SPEC_PATH,
|
|
5091
5131
|
new TextEncoder().encode(JSON.stringify(spec, null, 2))
|
|
@@ -5168,7 +5208,7 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
5168
5208
|
{ emit: ndjsonStdoutEmit }
|
|
5169
5209
|
);
|
|
5170
5210
|
}
|
|
5171
|
-
var DEFAULT_ROOTFS_DISK_MB, REMOTE_BUILD_DIR, REMOTE_CONTEXT_DIR, REMOTE_SPEC_PATH, REMOTE_METADATA_PATH, ROOTFS_BUILDER_BIN_DIR, ROOTFS_BUILDER_PATH, ROOTFS_BUILDER_COMMAND, UNSUPPORTED_DOCKERFILE_INSTRUCTIONS;
|
|
5211
|
+
var DEFAULT_ROOTFS_DISK_MB, REMOTE_BUILD_DIR, REMOTE_CONTEXT_DIR, REMOTE_SPEC_PATH, REMOTE_METADATA_PATH, ROOTFS_BUILDER_BIN_DIR, ROOTFS_BUILDER_PATH, ROOTFS_BUILDER_COMMAND, ROOTFS_BUILDER_PROCESS_USER, UNSUPPORTED_DOCKERFILE_INSTRUCTIONS;
|
|
5172
5212
|
var init_sandbox_image = __esm({
|
|
5173
5213
|
"src/sandbox-image.ts"() {
|
|
5174
5214
|
init_models();
|
|
@@ -5182,6 +5222,7 @@ var init_sandbox_image = __esm({
|
|
|
5182
5222
|
ROOTFS_BUILDER_BIN_DIR = "/usr/local/bin";
|
|
5183
5223
|
ROOTFS_BUILDER_PATH = "/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
5184
5224
|
ROOTFS_BUILDER_COMMAND = "tl-rootfs-build";
|
|
5225
|
+
ROOTFS_BUILDER_PROCESS_USER = "root";
|
|
5185
5226
|
UNSUPPORTED_DOCKERFILE_INSTRUCTIONS = /* @__PURE__ */ new Set([
|
|
5186
5227
|
"ARG",
|
|
5187
5228
|
"ONBUILD",
|