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/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as ListArchivedSandboxesOptions, q as ListArchivedSandboxesResponse, A as ArchivedSandboxInfo, r as SandboxPortAccess, s as SnapshotOptions, t as CreateSnapshotResponse, u as SnapshotAndWaitOptions, v as CreatePoolOptions, w as CreateSandboxPoolResponse, x as SandboxPoolInfo, y as UpdatePoolOptions } from './sandbox-image-
|
|
2
|
-
export { z as CheckpointType, B as ContainerResourcesInfo, E as ContainerState, F as CreateSandboxImageOptions, G as DirectoryEntry, I as DockerfileBuildPlan, J as DockerfileInstruction, K as Image, M as ImageBuildOperation, N as ImageBuildOperationType, N as ImageBuildOperationTypeValue, Q as ImageOptions, T as NetworkConfig, V as OutputMode, W as PoolContainerInfo, X as ProcessStatus, Y as
|
|
1
|
+
import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as ListArchivedSandboxesOptions, q as ListArchivedSandboxesResponse, A as ArchivedSandboxInfo, r as SandboxPortAccess, s as SnapshotOptions, t as CreateSnapshotResponse, u as SnapshotAndWaitOptions, v as CreatePoolOptions, w as CreateSandboxPoolResponse, x as SandboxPoolInfo, y as UpdatePoolOptions } from './sandbox-image-BBcx3bSx.cjs';
|
|
2
|
+
export { z as CheckpointType, B as ContainerResourcesInfo, E as ContainerState, F as CreateSandboxImageOptions, G as DirectoryEntry, I as DockerfileBuildPlan, J as DockerfileInstruction, K as Image, M as ImageBuildOperation, N as ImageBuildOperationType, N as ImageBuildOperationTypeValue, Q as ImageOptions, T as NetworkConfig, V as OutputMode, W as PoolContainerInfo, X as ProcessStatus, Y as ProcessUser, Z as ProcessUserSpec, _ as SandboxImageSource, $ as SnapshotStatus, a0 as SnapshotType, a1 as SnapshotWaitCondition, a2 as StdinMode, a3 as createSandboxImage, a4 as dockerfileContent } from './sandbox-image-BBcx3bSx.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The return value of every SDK operation. Carries the W3C `trace_id` so callers
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as ListArchivedSandboxesOptions, q as ListArchivedSandboxesResponse, A as ArchivedSandboxInfo, r as SandboxPortAccess, s as SnapshotOptions, t as CreateSnapshotResponse, u as SnapshotAndWaitOptions, v as CreatePoolOptions, w as CreateSandboxPoolResponse, x as SandboxPoolInfo, y as UpdatePoolOptions } from './sandbox-image-
|
|
2
|
-
export { z as CheckpointType, B as ContainerResourcesInfo, E as ContainerState, F as CreateSandboxImageOptions, G as DirectoryEntry, I as DockerfileBuildPlan, J as DockerfileInstruction, K as Image, M as ImageBuildOperation, N as ImageBuildOperationType, N as ImageBuildOperationTypeValue, Q as ImageOptions, T as NetworkConfig, V as OutputMode, W as PoolContainerInfo, X as ProcessStatus, Y as
|
|
1
|
+
import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as ListArchivedSandboxesOptions, q as ListArchivedSandboxesResponse, A as ArchivedSandboxInfo, r as SandboxPortAccess, s as SnapshotOptions, t as CreateSnapshotResponse, u as SnapshotAndWaitOptions, v as CreatePoolOptions, w as CreateSandboxPoolResponse, x as SandboxPoolInfo, y as UpdatePoolOptions } from './sandbox-image-BBcx3bSx.js';
|
|
2
|
+
export { z as CheckpointType, B as ContainerResourcesInfo, E as ContainerState, F as CreateSandboxImageOptions, G as DirectoryEntry, I as DockerfileBuildPlan, J as DockerfileInstruction, K as Image, M as ImageBuildOperation, N as ImageBuildOperationType, N as ImageBuildOperationTypeValue, Q as ImageOptions, T as NetworkConfig, V as OutputMode, W as PoolContainerInfo, X as ProcessStatus, Y as ProcessUser, Z as ProcessUserSpec, _ as SandboxImageSource, $ as SnapshotStatus, a0 as SnapshotType, a1 as SnapshotWaitCondition, a2 as StdinMode, a3 as createSandboxImage, a4 as dockerfileContent } from './sandbox-image-BBcx3bSx.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The return value of every SDK operation. Carries the W3C `trace_id` so callers
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
|
|
|
13
13
|
var init_defaults = __esm({
|
|
14
14
|
"src/defaults.ts"() {
|
|
15
15
|
"use strict";
|
|
16
|
-
SDK_VERSION = "0.5.
|
|
16
|
+
SDK_VERSION = "0.5.17";
|
|
17
17
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
18
18
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
19
19
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -2978,6 +2978,15 @@ var init_url = __esm({
|
|
|
2978
2978
|
|
|
2979
2979
|
// src/sandbox.ts
|
|
2980
2980
|
import WebSocket2 from "ws";
|
|
2981
|
+
function processUserPayload(user) {
|
|
2982
|
+
if (user == null) {
|
|
2983
|
+
return DEFAULT_PROCESS_USER;
|
|
2984
|
+
}
|
|
2985
|
+
if (typeof user === "string" && user.trim() === "") {
|
|
2986
|
+
throw new SandboxError("process user must not be empty");
|
|
2987
|
+
}
|
|
2988
|
+
return user;
|
|
2989
|
+
}
|
|
2981
2990
|
function normalizePtyMessage(message) {
|
|
2982
2991
|
if (Buffer.isBuffer(message)) return message;
|
|
2983
2992
|
if (Array.isArray(message)) {
|
|
@@ -3001,7 +3010,7 @@ function sendPtyFrame(socket, frame) {
|
|
|
3001
3010
|
socket.send(frame, (error) => error ? reject(error) : resolve());
|
|
3002
3011
|
});
|
|
3003
3012
|
}
|
|
3004
|
-
var PTY_OP_DATA, PTY_OP_RESIZE, PTY_OP_READY, PTY_OP_EXIT, Pty, Sandbox;
|
|
3013
|
+
var DEFAULT_PROCESS_USER, PTY_OP_DATA, PTY_OP_RESIZE, PTY_OP_READY, PTY_OP_EXIT, Pty, Sandbox;
|
|
3005
3014
|
var init_sandbox = __esm({
|
|
3006
3015
|
"src/sandbox.ts"() {
|
|
3007
3016
|
"use strict";
|
|
@@ -3013,6 +3022,7 @@ var init_sandbox = __esm({
|
|
|
3013
3022
|
init_tunnel();
|
|
3014
3023
|
init_sse();
|
|
3015
3024
|
init_url();
|
|
3025
|
+
DEFAULT_PROCESS_USER = "tl-user";
|
|
3016
3026
|
PTY_OP_DATA = 0;
|
|
3017
3027
|
PTY_OP_RESIZE = 1;
|
|
3018
3028
|
PTY_OP_READY = 2;
|
|
@@ -3433,6 +3443,8 @@ var init_sandbox = __esm({
|
|
|
3433
3443
|
if (options?.env) body.env = options.env;
|
|
3434
3444
|
if (options?.workingDir) body.working_dir = options.workingDir;
|
|
3435
3445
|
if (options?.timeout != null) body.timeout = options.timeout;
|
|
3446
|
+
const user = processUserPayload(options?.user);
|
|
3447
|
+
body.user = user;
|
|
3436
3448
|
const sseStream = await this.http.requestStream(
|
|
3437
3449
|
"POST",
|
|
3438
3450
|
"/api/v1/processes/run",
|
|
@@ -3476,6 +3488,8 @@ var init_sandbox = __esm({
|
|
|
3476
3488
|
if (options?.args != null) payload.args = options.args;
|
|
3477
3489
|
if (options?.env != null) payload.env = options.env;
|
|
3478
3490
|
if (options?.workingDir != null) payload.working_dir = options.workingDir;
|
|
3491
|
+
const user = processUserPayload(options?.user);
|
|
3492
|
+
payload.user = user;
|
|
3479
3493
|
if (options?.stdinMode != null && options.stdinMode !== "closed" /* CLOSED */) {
|
|
3480
3494
|
payload.stdin_mode = options.stdinMode;
|
|
3481
3495
|
}
|
|
@@ -5063,12 +5077,16 @@ function optionalNumber(object, key) {
|
|
|
5063
5077
|
}
|
|
5064
5078
|
return value;
|
|
5065
5079
|
}
|
|
5066
|
-
async function runChecked(sandbox, command, args, env, workingDir) {
|
|
5067
|
-
const
|
|
5080
|
+
async function runChecked(sandbox, command, args, env, workingDir, user) {
|
|
5081
|
+
const options = {
|
|
5068
5082
|
args,
|
|
5069
5083
|
env,
|
|
5070
5084
|
workingDir
|
|
5071
|
-
}
|
|
5085
|
+
};
|
|
5086
|
+
if (user != null) {
|
|
5087
|
+
options.user = user;
|
|
5088
|
+
}
|
|
5089
|
+
const result = await sandbox.run(command, options);
|
|
5072
5090
|
if (result.exitCode !== 0) {
|
|
5073
5091
|
throw new Error(
|
|
5074
5092
|
`Command '${command} ${args.join(" ")}' failed with exit code ${result.exitCode}`
|
|
@@ -5080,7 +5098,8 @@ async function runStreaming(sandbox, emit, sleep3, command, args = [], env, work
|
|
|
5080
5098
|
const proc = await sandbox.startProcess(command, {
|
|
5081
5099
|
args,
|
|
5082
5100
|
env,
|
|
5083
|
-
workingDir
|
|
5101
|
+
workingDir,
|
|
5102
|
+
user: ROOTFS_BUILDER_PROCESS_USER
|
|
5084
5103
|
});
|
|
5085
5104
|
let stdoutSeen = 0;
|
|
5086
5105
|
let stderrSeen = 0;
|
|
@@ -5122,13 +5141,37 @@ function emitOutputLines(emit, stream, response, seen) {
|
|
|
5122
5141
|
emit({ type: "build_log", stream, message: line });
|
|
5123
5142
|
}
|
|
5124
5143
|
}
|
|
5144
|
+
async function ensureRemoteBuildRoot(sandbox) {
|
|
5145
|
+
await runChecked(
|
|
5146
|
+
sandbox,
|
|
5147
|
+
"mkdir",
|
|
5148
|
+
["-p", REMOTE_BUILD_DIR],
|
|
5149
|
+
void 0,
|
|
5150
|
+
void 0,
|
|
5151
|
+
ROOTFS_BUILDER_PROCESS_USER
|
|
5152
|
+
);
|
|
5153
|
+
await runChecked(
|
|
5154
|
+
sandbox,
|
|
5155
|
+
"chmod",
|
|
5156
|
+
["0777", REMOTE_BUILD_DIR],
|
|
5157
|
+
void 0,
|
|
5158
|
+
void 0,
|
|
5159
|
+
ROOTFS_BUILDER_PROCESS_USER
|
|
5160
|
+
);
|
|
5161
|
+
}
|
|
5162
|
+
async function ensureRemoteDirectory(sandbox, remotePath) {
|
|
5163
|
+
await runChecked(sandbox, "mkdir", ["-p", remotePath]);
|
|
5164
|
+
}
|
|
5165
|
+
async function ensureRemoteParentDir(sandbox, remotePath) {
|
|
5166
|
+
await ensureRemoteDirectory(sandbox, path.posix.dirname(remotePath));
|
|
5167
|
+
}
|
|
5125
5168
|
async function copyLocalPathToSandbox(sandbox, localPath, remotePath) {
|
|
5126
5169
|
const fileStats = await stat(localPath).catch(() => null);
|
|
5127
5170
|
if (!fileStats) {
|
|
5128
5171
|
throw new Error(`Local path not found: ${localPath}`);
|
|
5129
5172
|
}
|
|
5130
5173
|
if (fileStats.isFile()) {
|
|
5131
|
-
await
|
|
5174
|
+
await ensureRemoteParentDir(sandbox, remotePath);
|
|
5132
5175
|
await sandbox.writeFile(remotePath, await readFile(localPath));
|
|
5133
5176
|
return;
|
|
5134
5177
|
}
|
|
@@ -5140,14 +5183,10 @@ async function copyLocalPathToSandbox(sandbox, localPath, remotePath) {
|
|
|
5140
5183
|
const sourcePath = path.join(localPath, entry.name);
|
|
5141
5184
|
const destinationPath = path.posix.join(remotePath, entry.name);
|
|
5142
5185
|
if (entry.isDirectory()) {
|
|
5143
|
-
await
|
|
5186
|
+
await ensureRemoteDirectory(sandbox, destinationPath);
|
|
5144
5187
|
await copyLocalPathToSandbox(sandbox, sourcePath, destinationPath);
|
|
5145
5188
|
} else if (entry.isFile()) {
|
|
5146
|
-
await
|
|
5147
|
-
sandbox,
|
|
5148
|
-
"mkdir",
|
|
5149
|
-
["-p", path.posix.dirname(destinationPath)]
|
|
5150
|
-
);
|
|
5189
|
+
await ensureRemoteParentDir(sandbox, destinationPath);
|
|
5151
5190
|
await sandbox.writeFile(destinationPath, await readFile(sourcePath));
|
|
5152
5191
|
}
|
|
5153
5192
|
}
|
|
@@ -5244,6 +5283,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
5244
5283
|
message: `Rootfs builder sandbox ${sandbox.sandboxId} is running`
|
|
5245
5284
|
});
|
|
5246
5285
|
emit({ type: "status", message: "Uploading build context..." });
|
|
5286
|
+
await ensureRemoteBuildRoot(sandbox);
|
|
5247
5287
|
await copyLocalPathToSandbox(sandbox, plan.contextDir, REMOTE_CONTEXT_DIR);
|
|
5248
5288
|
const spec = await buildRootfsSpec(
|
|
5249
5289
|
preparedSpec,
|
|
@@ -5251,7 +5291,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
5251
5291
|
plan,
|
|
5252
5292
|
options.diskMb
|
|
5253
5293
|
);
|
|
5254
|
-
await
|
|
5294
|
+
await ensureRemoteParentDir(sandbox, REMOTE_SPEC_PATH);
|
|
5255
5295
|
await sandbox.writeFile(
|
|
5256
5296
|
REMOTE_SPEC_PATH,
|
|
5257
5297
|
new TextEncoder().encode(JSON.stringify(spec, null, 2))
|
|
@@ -5334,7 +5374,7 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
5334
5374
|
{ emit: ndjsonStdoutEmit }
|
|
5335
5375
|
);
|
|
5336
5376
|
}
|
|
5337
|
-
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;
|
|
5377
|
+
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;
|
|
5338
5378
|
var init_sandbox_image = __esm({
|
|
5339
5379
|
"src/sandbox-image.ts"() {
|
|
5340
5380
|
"use strict";
|
|
@@ -5349,6 +5389,7 @@ var init_sandbox_image = __esm({
|
|
|
5349
5389
|
ROOTFS_BUILDER_BIN_DIR = "/usr/local/bin";
|
|
5350
5390
|
ROOTFS_BUILDER_PATH = "/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
5351
5391
|
ROOTFS_BUILDER_COMMAND = "tl-rootfs-build";
|
|
5392
|
+
ROOTFS_BUILDER_PROCESS_USER = "root";
|
|
5352
5393
|
UNSUPPORTED_DOCKERFILE_INSTRUCTIONS = /* @__PURE__ */ new Set([
|
|
5353
5394
|
"ARG",
|
|
5354
5395
|
"ONBUILD",
|