tensorlake 0.5.14 → 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 +38 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +38 -14
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +38 -14
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +1 -1
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";
|
|
@@ -5077,13 +5077,16 @@ function optionalNumber(object, key) {
|
|
|
5077
5077
|
}
|
|
5078
5078
|
return value;
|
|
5079
5079
|
}
|
|
5080
|
-
async function runChecked(sandbox, command, args, env, workingDir) {
|
|
5081
|
-
const
|
|
5080
|
+
async function runChecked(sandbox, command, args, env, workingDir, user) {
|
|
5081
|
+
const options = {
|
|
5082
5082
|
args,
|
|
5083
5083
|
env,
|
|
5084
|
-
workingDir
|
|
5085
|
-
|
|
5086
|
-
|
|
5084
|
+
workingDir
|
|
5085
|
+
};
|
|
5086
|
+
if (user != null) {
|
|
5087
|
+
options.user = user;
|
|
5088
|
+
}
|
|
5089
|
+
const result = await sandbox.run(command, options);
|
|
5087
5090
|
if (result.exitCode !== 0) {
|
|
5088
5091
|
throw new Error(
|
|
5089
5092
|
`Command '${command} ${args.join(" ")}' failed with exit code ${result.exitCode}`
|
|
@@ -5138,13 +5141,37 @@ function emitOutputLines(emit, stream, response, seen) {
|
|
|
5138
5141
|
emit({ type: "build_log", stream, message: line });
|
|
5139
5142
|
}
|
|
5140
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
|
+
}
|
|
5141
5168
|
async function copyLocalPathToSandbox(sandbox, localPath, remotePath) {
|
|
5142
5169
|
const fileStats = await stat(localPath).catch(() => null);
|
|
5143
5170
|
if (!fileStats) {
|
|
5144
5171
|
throw new Error(`Local path not found: ${localPath}`);
|
|
5145
5172
|
}
|
|
5146
5173
|
if (fileStats.isFile()) {
|
|
5147
|
-
await
|
|
5174
|
+
await ensureRemoteParentDir(sandbox, remotePath);
|
|
5148
5175
|
await sandbox.writeFile(remotePath, await readFile(localPath));
|
|
5149
5176
|
return;
|
|
5150
5177
|
}
|
|
@@ -5156,14 +5183,10 @@ async function copyLocalPathToSandbox(sandbox, localPath, remotePath) {
|
|
|
5156
5183
|
const sourcePath = path.join(localPath, entry.name);
|
|
5157
5184
|
const destinationPath = path.posix.join(remotePath, entry.name);
|
|
5158
5185
|
if (entry.isDirectory()) {
|
|
5159
|
-
await
|
|
5186
|
+
await ensureRemoteDirectory(sandbox, destinationPath);
|
|
5160
5187
|
await copyLocalPathToSandbox(sandbox, sourcePath, destinationPath);
|
|
5161
5188
|
} else if (entry.isFile()) {
|
|
5162
|
-
await
|
|
5163
|
-
sandbox,
|
|
5164
|
-
"mkdir",
|
|
5165
|
-
["-p", path.posix.dirname(destinationPath)]
|
|
5166
|
-
);
|
|
5189
|
+
await ensureRemoteParentDir(sandbox, destinationPath);
|
|
5167
5190
|
await sandbox.writeFile(destinationPath, await readFile(sourcePath));
|
|
5168
5191
|
}
|
|
5169
5192
|
}
|
|
@@ -5260,6 +5283,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
5260
5283
|
message: `Rootfs builder sandbox ${sandbox.sandboxId} is running`
|
|
5261
5284
|
});
|
|
5262
5285
|
emit({ type: "status", message: "Uploading build context..." });
|
|
5286
|
+
await ensureRemoteBuildRoot(sandbox);
|
|
5263
5287
|
await copyLocalPathToSandbox(sandbox, plan.contextDir, REMOTE_CONTEXT_DIR);
|
|
5264
5288
|
const spec = await buildRootfsSpec(
|
|
5265
5289
|
preparedSpec,
|
|
@@ -5267,7 +5291,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
5267
5291
|
plan,
|
|
5268
5292
|
options.diskMb
|
|
5269
5293
|
);
|
|
5270
|
-
await
|
|
5294
|
+
await ensureRemoteParentDir(sandbox, REMOTE_SPEC_PATH);
|
|
5271
5295
|
await sandbox.writeFile(
|
|
5272
5296
|
REMOTE_SPEC_PATH,
|
|
5273
5297
|
new TextEncoder().encode(JSON.stringify(spec, null, 2))
|