@tensorlakeai/tensorlake 0.5.153 → 0.5.156
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/applications/index.cjs +260 -71
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.d.cts +3 -3
- package/dist/applications/index.d.ts +3 -3
- package/dist/applications/index.js +260 -71
- package/dist/applications/index.js.map +1 -1
- package/dist/function-agent/main.cjs +1 -1
- package/dist/function-agent/main.js +1 -1
- package/dist/function-executor/main.cjs +2 -2
- package/dist/function-executor/main.js +2 -2
- package/dist/index.cjs +344 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -38
- package/dist/index.d.ts +95 -38
- package/dist/index.js +339 -106
- package/dist/index.js.map +1 -1
- package/dist/{remote-B3vn4tt1.d.cts → remote-CEs4GFGP.d.cts} +1 -1
- package/dist/{remote-DqBUuciu.d.ts → remote-DYBXCTNC.d.ts} +1 -1
- package/dist/{sandbox-image-BMiFlzAs.d.cts → sandbox-image-C2GTVnx3.d.cts} +99 -52
- package/dist/{sandbox-image-BMiFlzAs.d.ts → sandbox-image-C2GTVnx3.d.ts} +99 -52
- package/dist/sandbox-image.cjs +248 -61
- 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 +248 -61
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +7 -7
- package/runtime/function-executor/manifest.json +5 -5
- package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
- package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
- package/runtime/function-executor/package/package.json +1 -1
- package/runtime/typescript-function-runner/manifest.json +5 -5
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +26 -26
- package/runtime/typescript-function-runner/package/package.json +7 -7
package/dist/sandbox-image.js
CHANGED
|
@@ -148,10 +148,11 @@ var init_image = __esm({
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
* Build this image as a sandbox
|
|
151
|
+
* Build this image and register it as a CAS sandbox image (the default) or,
|
|
152
|
+
* with `cas: false`, a legacy sandbox image.
|
|
152
153
|
*
|
|
153
154
|
* Materializes the image in a build sandbox, snapshots the filesystem,
|
|
154
|
-
* and registers the snapshot
|
|
155
|
+
* and registers the snapshot under the image's name.
|
|
155
156
|
*/
|
|
156
157
|
async build(options = {}) {
|
|
157
158
|
const { createSandboxImage: createSandboxImage2 } = await Promise.resolve().then(() => (init_sandbox_image(), sandbox_image_exports));
|
|
@@ -311,10 +312,27 @@ var init_native_binding = __esm({
|
|
|
311
312
|
}
|
|
312
313
|
});
|
|
313
314
|
|
|
315
|
+
// src/enum.ts
|
|
316
|
+
function enumValue(values, value) {
|
|
317
|
+
return typeof value === "string" && Object.values(values).includes(value) ? value : values.UNKNOWN;
|
|
318
|
+
}
|
|
319
|
+
function withRaw(value, raw) {
|
|
320
|
+
return Object.defineProperty(value, "raw", { value: raw, enumerable: false, configurable: true });
|
|
321
|
+
}
|
|
322
|
+
var init_enum = __esm({
|
|
323
|
+
"src/enum.ts"() {
|
|
324
|
+
"use strict";
|
|
325
|
+
init_esm_shims();
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
314
329
|
// src/image-builds.ts
|
|
315
330
|
import path3 from "path";
|
|
316
331
|
import os from "os";
|
|
317
332
|
import { existsSync as existsSync2, mkdtempSync, rmSync } from "fs";
|
|
333
|
+
function isConfirmedCancellation(outcome) {
|
|
334
|
+
return outcome === "cancelled" /* CANCELLED */ || outcome === "already_cancelled" /* ALREADY_CANCELLED */ || outcome === "already_failed" /* ALREADY_FAILED */;
|
|
335
|
+
}
|
|
318
336
|
function camelize(key) {
|
|
319
337
|
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
320
338
|
}
|
|
@@ -332,48 +350,73 @@ function toImageBuildError(error) {
|
|
|
332
350
|
if (key === "category") continue;
|
|
333
351
|
details[camelize(key)] = value;
|
|
334
352
|
}
|
|
353
|
+
details.code = enumValue(ImageBuildErrorCode, details.code || "internal" /* INTERNAL */);
|
|
354
|
+
if ("activeKind" in details) details.activeKind = details.activeKind ? enumValue(ImageBuildKind, details.activeKind) : null;
|
|
355
|
+
if ("activeStatus" in details) details.activeStatus = details.activeStatus ? enumValue(ImageBuildStatus, details.activeStatus) : null;
|
|
356
|
+
if ("outcome" in details) details.outcome = details.outcome ? enumValue(ImageBuildCancellationOutcome, details.outcome) : null;
|
|
357
|
+
if ("info" in details) details.info = buildInfoOrNull(details.info);
|
|
335
358
|
const typed = details;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return new ImageBuildTimeoutError(typed);
|
|
347
|
-
case "interrupted":
|
|
348
|
-
return new ImageBuildInterruptedError(typed);
|
|
349
|
-
default:
|
|
350
|
-
return new ImageBuildError(typed);
|
|
351
|
-
}
|
|
359
|
+
const errors = {
|
|
360
|
+
not_found: ImageBuildNotFoundError,
|
|
361
|
+
image_build_in_progress: ImageBuildInProgressError,
|
|
362
|
+
failed: ImageBuildFailedError,
|
|
363
|
+
cancelled: ImageBuildCancelledError,
|
|
364
|
+
timeout: ImageBuildTimeoutError,
|
|
365
|
+
interrupted: ImageBuildInterruptedError
|
|
366
|
+
};
|
|
367
|
+
const ErrorClass = errors[typed.code] ?? ImageBuildError;
|
|
368
|
+
return withRaw(new ErrorClass(typed), payload);
|
|
352
369
|
}
|
|
353
370
|
function camelizeRecord(value) {
|
|
354
371
|
const out = {};
|
|
355
372
|
for (const [key, inner] of Object.entries(value)) out[camelize(key)] = inner;
|
|
356
373
|
return out;
|
|
357
374
|
}
|
|
358
|
-
function
|
|
375
|
+
function buildInfoOrNull(value) {
|
|
376
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
377
|
+
try {
|
|
378
|
+
return parseBuildInfo(value);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
if (error instanceof ImageBuildError) return null;
|
|
381
|
+
throw error;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function decodeResponse(value) {
|
|
385
|
+
try {
|
|
386
|
+
const raw = typeof value === "string" ? JSON.parse(value) : value;
|
|
387
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new TypeError("expected a response object");
|
|
388
|
+
return raw;
|
|
389
|
+
} catch (error) {
|
|
390
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: `Invalid image-build response: ${String(error)}` }), { response: value });
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function parseBuildInfo(value) {
|
|
394
|
+
const raw = decodeResponse(value);
|
|
395
|
+
if (raw.status == null) {
|
|
396
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build response: missing status" }), { response: value });
|
|
397
|
+
}
|
|
398
|
+
const attempt = raw.attempt_no ?? 0;
|
|
399
|
+
const attemptNo = Number(attempt);
|
|
400
|
+
if (typeof attempt !== "number" && typeof attempt !== "string" || typeof attempt === "string" && attempt.trim() === "" || !Number.isSafeInteger(attemptNo)) {
|
|
401
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build attempt_no" }), { response: value });
|
|
402
|
+
}
|
|
359
403
|
const camel = camelizeRecord(raw);
|
|
360
404
|
const result = raw.result && typeof raw.result === "object" ? camelizeRecord(raw.result) : null;
|
|
361
|
-
return {
|
|
405
|
+
return withRaw({
|
|
362
406
|
buildId: String(raw.build_id ?? ""),
|
|
363
407
|
clientRequestId: camel.clientRequestId ?? null,
|
|
364
|
-
kind:
|
|
408
|
+
kind: raw.kind ? enumValue(ImageBuildKind, raw.kind) : null,
|
|
365
409
|
name: raw.name ?? null,
|
|
366
|
-
status:
|
|
367
|
-
phase: raw.phase
|
|
368
|
-
attemptNo
|
|
410
|
+
status: enumValue(ImageBuildStatus, raw.status),
|
|
411
|
+
phase: raw.phase ? enumValue(ImageBuildPhase, raw.phase) : null,
|
|
412
|
+
attemptNo,
|
|
369
413
|
builderSandboxId: camel.builderSandboxId ?? null,
|
|
370
414
|
error: raw.error ?? null,
|
|
371
415
|
result,
|
|
372
416
|
operationDeadlineMs: camel.operationDeadlineMs ?? null,
|
|
373
417
|
createdAtMs: camel.createdAtMs ?? null,
|
|
374
|
-
updatedAtMs: camel.updatedAtMs ?? null
|
|
375
|
-
|
|
376
|
-
};
|
|
418
|
+
updatedAtMs: camel.updatedAtMs ?? null
|
|
419
|
+
}, raw);
|
|
377
420
|
}
|
|
378
421
|
async function __runWithInterrupt(signal, run) {
|
|
379
422
|
const binding = __imageBuildInternals.loadNativeBinding();
|
|
@@ -397,13 +440,65 @@ async function __runWithInterrupt(signal, run) {
|
|
|
397
440
|
binding.releaseImageBuildInterrupt(interruptId);
|
|
398
441
|
}
|
|
399
442
|
}
|
|
400
|
-
var ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
443
|
+
var ImageBuildStatus, ImageBuildPhase, ImageBuildKind, ImageBuildCancellationOutcome, ImageBuildErrorCode, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
401
444
|
var init_image_builds = __esm({
|
|
402
445
|
"src/image-builds.ts"() {
|
|
403
446
|
"use strict";
|
|
404
447
|
init_esm_shims();
|
|
448
|
+
init_enum();
|
|
405
449
|
init_image();
|
|
406
450
|
init_sandbox_image();
|
|
451
|
+
ImageBuildStatus = /* @__PURE__ */ ((ImageBuildStatus2) => {
|
|
452
|
+
ImageBuildStatus2["PENDING"] = "pending";
|
|
453
|
+
ImageBuildStatus2["RUNNING"] = "running";
|
|
454
|
+
ImageBuildStatus2["SUCCEEDED"] = "succeeded";
|
|
455
|
+
ImageBuildStatus2["FAILED"] = "failed";
|
|
456
|
+
ImageBuildStatus2["CANCELLED"] = "cancelled";
|
|
457
|
+
ImageBuildStatus2["UNKNOWN"] = "unknown";
|
|
458
|
+
return ImageBuildStatus2;
|
|
459
|
+
})(ImageBuildStatus || {});
|
|
460
|
+
ImageBuildPhase = /* @__PURE__ */ ((ImageBuildPhase2) => {
|
|
461
|
+
ImageBuildPhase2["AWAITING_CONTEXT"] = "awaiting_context";
|
|
462
|
+
ImageBuildPhase2["STARTING_BUILDER"] = "starting_builder";
|
|
463
|
+
ImageBuildPhase2["EXECUTING"] = "executing";
|
|
464
|
+
ImageBuildPhase2["SNAPSHOTTING"] = "snapshotting";
|
|
465
|
+
ImageBuildPhase2["PUBLISHING"] = "publishing";
|
|
466
|
+
ImageBuildPhase2["FINISHED"] = "finished";
|
|
467
|
+
ImageBuildPhase2["UNKNOWN"] = "unknown";
|
|
468
|
+
return ImageBuildPhase2;
|
|
469
|
+
})(ImageBuildPhase || {});
|
|
470
|
+
ImageBuildKind = /* @__PURE__ */ ((ImageBuildKind2) => {
|
|
471
|
+
ImageBuildKind2["DOCKERFILE"] = "dockerfile";
|
|
472
|
+
ImageBuildKind2["IMPORT"] = "import";
|
|
473
|
+
ImageBuildKind2["DIRECT"] = "direct";
|
|
474
|
+
ImageBuildKind2["UNKNOWN"] = "unknown";
|
|
475
|
+
return ImageBuildKind2;
|
|
476
|
+
})(ImageBuildKind || {});
|
|
477
|
+
ImageBuildCancellationOutcome = /* @__PURE__ */ ((ImageBuildCancellationOutcome2) => {
|
|
478
|
+
ImageBuildCancellationOutcome2["CANCELLED"] = "cancelled";
|
|
479
|
+
ImageBuildCancellationOutcome2["ALREADY_CANCELLED"] = "already_cancelled";
|
|
480
|
+
ImageBuildCancellationOutcome2["ALREADY_COMPLETED"] = "already_completed";
|
|
481
|
+
ImageBuildCancellationOutcome2["ALREADY_FAILED"] = "already_failed";
|
|
482
|
+
ImageBuildCancellationOutcome2["NOT_ADMITTED"] = "not_admitted";
|
|
483
|
+
ImageBuildCancellationOutcome2["UNCONFIRMED"] = "unconfirmed";
|
|
484
|
+
ImageBuildCancellationOutcome2["UNKNOWN"] = "unknown";
|
|
485
|
+
return ImageBuildCancellationOutcome2;
|
|
486
|
+
})(ImageBuildCancellationOutcome || {});
|
|
487
|
+
ImageBuildErrorCode = /* @__PURE__ */ ((ImageBuildErrorCode2) => {
|
|
488
|
+
ImageBuildErrorCode2["USAGE"] = "usage";
|
|
489
|
+
ImageBuildErrorCode2["AUTH"] = "auth";
|
|
490
|
+
ImageBuildErrorCode2["NOT_FOUND"] = "not_found";
|
|
491
|
+
ImageBuildErrorCode2["IMAGE_BUILD_IN_PROGRESS"] = "image_build_in_progress";
|
|
492
|
+
ImageBuildErrorCode2["CLIENT_REQUEST_ID_MISMATCH"] = "client_request_id_mismatch";
|
|
493
|
+
ImageBuildErrorCode2["FAILED"] = "failed";
|
|
494
|
+
ImageBuildErrorCode2["CANCELLED"] = "cancelled";
|
|
495
|
+
ImageBuildErrorCode2["TIMEOUT"] = "timeout";
|
|
496
|
+
ImageBuildErrorCode2["INTERRUPTED"] = "interrupted";
|
|
497
|
+
ImageBuildErrorCode2["SERVICE"] = "service";
|
|
498
|
+
ImageBuildErrorCode2["INTERNAL"] = "internal";
|
|
499
|
+
ImageBuildErrorCode2["UNKNOWN"] = "unknown";
|
|
500
|
+
return ImageBuildErrorCode2;
|
|
501
|
+
})(ImageBuildErrorCode || {});
|
|
407
502
|
ImageBuildError = class extends Error {
|
|
408
503
|
code;
|
|
409
504
|
buildId;
|
|
@@ -413,7 +508,11 @@ var init_image_builds = __esm({
|
|
|
413
508
|
super(details.message);
|
|
414
509
|
this.name = "ImageBuildError";
|
|
415
510
|
this.code = details.code;
|
|
416
|
-
this.details = details;
|
|
511
|
+
this.details = { ...details };
|
|
512
|
+
withRaw(this, {});
|
|
513
|
+
if ("confirmed" in details) {
|
|
514
|
+
this.details.confirmed = details.confirmed === true && isConfirmedCancellation(details.outcome);
|
|
515
|
+
}
|
|
417
516
|
if (details.buildId) this.buildId = details.buildId;
|
|
418
517
|
if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
|
|
419
518
|
}
|
|
@@ -445,7 +544,7 @@ var init_image_builds = __esm({
|
|
|
445
544
|
super(details);
|
|
446
545
|
this.name = "ImageBuildFailedError";
|
|
447
546
|
this.error = details.error ?? "no error recorded";
|
|
448
|
-
if (details.info) this.info =
|
|
547
|
+
if (details.info) this.info = details.info;
|
|
449
548
|
}
|
|
450
549
|
};
|
|
451
550
|
ImageBuildCancelledError = class extends ImageBuildError {
|
|
@@ -453,7 +552,7 @@ var init_image_builds = __esm({
|
|
|
453
552
|
constructor(details) {
|
|
454
553
|
super(details);
|
|
455
554
|
this.name = "ImageBuildCancelledError";
|
|
456
|
-
if (details.info) this.info =
|
|
555
|
+
if (details.info) this.info = details.info;
|
|
457
556
|
}
|
|
458
557
|
};
|
|
459
558
|
ImageBuildTimeoutError = class extends ImageBuildError {
|
|
@@ -469,8 +568,8 @@ var init_image_builds = __esm({
|
|
|
469
568
|
constructor(details) {
|
|
470
569
|
super(details);
|
|
471
570
|
this.name = "ImageBuildInterruptedError";
|
|
472
|
-
this.outcome = details.outcome ?? "unconfirmed"
|
|
473
|
-
this.confirmed = details.confirmed === true;
|
|
571
|
+
this.outcome = details.outcome ?? "unconfirmed" /* UNCONFIRMED */;
|
|
572
|
+
this.confirmed = this.details.confirmed === true;
|
|
474
573
|
if (details.result) this.result = details.result;
|
|
475
574
|
}
|
|
476
575
|
};
|
|
@@ -533,16 +632,58 @@ function defaultRegisteredName(dockerfilePath) {
|
|
|
533
632
|
const parsed = path4.parse(dockerfilePath);
|
|
534
633
|
if (parsed.name.toLowerCase() === "dockerfile") {
|
|
535
634
|
const parentName = path4.basename(path4.dirname(dockerfilePath)).trim();
|
|
536
|
-
return parentName ||
|
|
635
|
+
return parentName || DEFAULT_SANDBOX_IMAGE_NAME;
|
|
537
636
|
}
|
|
538
|
-
return parsed.name ||
|
|
637
|
+
return parsed.name || DEFAULT_SANDBOX_IMAGE_NAME;
|
|
638
|
+
}
|
|
639
|
+
function registeredImageName(explicit, generated, cas, fallback = DEFAULT_SANDBOX_IMAGE_NAME) {
|
|
640
|
+
if (explicit || generated === void 0) {
|
|
641
|
+
const name = explicit ?? "";
|
|
642
|
+
return cas ? canonicalCasImageName(name) : name;
|
|
643
|
+
}
|
|
644
|
+
return cas ? casImageNameFrom(generated, fallback) : generated;
|
|
645
|
+
}
|
|
646
|
+
function canonicalCasImageName(name) {
|
|
647
|
+
return name.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
648
|
+
}
|
|
649
|
+
function casImageNameFrom(raw, fallback) {
|
|
650
|
+
const lowered = canonicalCasImageName(raw);
|
|
651
|
+
if (isAddressableCasImageName(lowered)) {
|
|
652
|
+
return lowered;
|
|
653
|
+
}
|
|
654
|
+
let name = "";
|
|
655
|
+
for (const original of lowered) {
|
|
656
|
+
const ch = /^[a-z0-9._-]$/.test(original) ? original : "-";
|
|
657
|
+
const previous = name[name.length - 1];
|
|
658
|
+
if (CAS_NAME_SEPARATORS.includes(ch) && previous !== void 0 && CAS_NAME_SEPARATORS.includes(previous)) {
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
name += ch;
|
|
662
|
+
}
|
|
663
|
+
name = name.replace(/^[._-]+|[._-]+$/g, "").slice(0, MAX_CAS_IMAGE_NAME_LENGTH).replace(/[._-]+$/, "");
|
|
664
|
+
return isAddressableCasImageName(name) ? name : fallback;
|
|
665
|
+
}
|
|
666
|
+
function isAddressableCasImageName(name) {
|
|
667
|
+
if (name.length === 0 || name.length > MAX_CAS_IMAGE_NAME_LENGTH || RESERVED_IMAGE_NAME_PREFIXES.some((prefix) => name.startsWith(prefix)) || /^[0-9a-f]{64}$/.test(name)) {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
const colon = name.indexOf(":");
|
|
671
|
+
const repository = colon === -1 ? name : name.slice(0, colon);
|
|
672
|
+
if (!repository.split("/").every((component) => /^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(component))) {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
if (colon === -1) {
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
const tag = name.slice(colon + 1);
|
|
679
|
+
return tag.length > 0 && tag.length <= 128 && /^[a-z0-9._-]+$/.test(tag) && !tag.startsWith(".") && !tag.startsWith("-");
|
|
539
680
|
}
|
|
540
681
|
function defaultRegisteredNameFromImage(imageReference) {
|
|
541
682
|
const withoutDigest = imageReference.split("@", 1)[0] ?? imageReference;
|
|
542
683
|
const lastSegment = withoutDigest.split("/").pop() ?? withoutDigest;
|
|
543
684
|
const colonIndex = lastSegment.lastIndexOf(":");
|
|
544
685
|
const name = colonIndex > 0 && colonIndex < lastSegment.length - 1 ? lastSegment.slice(0, colonIndex) : lastSegment;
|
|
545
|
-
return name ||
|
|
686
|
+
return name || DEFAULT_IMPORTED_IMAGE_NAME;
|
|
546
687
|
}
|
|
547
688
|
function noopEmit(_event) {
|
|
548
689
|
}
|
|
@@ -645,7 +786,11 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
645
786
|
if (!text.endsWith("\n")) text += "\n";
|
|
646
787
|
dockerfileText = text;
|
|
647
788
|
nativeContextDir = resolvedContext;
|
|
648
|
-
effectiveName =
|
|
789
|
+
effectiveName = registeredImageName(
|
|
790
|
+
options.registeredName ?? source.name,
|
|
791
|
+
void 0,
|
|
792
|
+
options.cas ?? true
|
|
793
|
+
);
|
|
649
794
|
} else if (typeof source === "string") {
|
|
650
795
|
const resolvedPath = path4.resolve(source);
|
|
651
796
|
if (!existsSync3(resolvedPath)) {
|
|
@@ -654,7 +799,11 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
654
799
|
dockerfilePath = resolvedPath;
|
|
655
800
|
dockerfileText = void 0;
|
|
656
801
|
nativeContextDir = void 0;
|
|
657
|
-
effectiveName =
|
|
802
|
+
effectiveName = registeredImageName(
|
|
803
|
+
options.registeredName,
|
|
804
|
+
defaultRegisteredName(resolvedPath),
|
|
805
|
+
options.cas ?? true
|
|
806
|
+
);
|
|
658
807
|
} else {
|
|
659
808
|
throw new TypeError(
|
|
660
809
|
`source must be an Image or a Dockerfile path, got ${typeof source}`
|
|
@@ -678,12 +827,16 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
678
827
|
deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
|
|
679
828
|
);
|
|
680
829
|
}
|
|
681
|
-
|
|
830
|
+
const cas = options.cas ?? true;
|
|
831
|
+
if (options.signal !== void 0 && !cas) {
|
|
682
832
|
throw new Error(
|
|
683
|
-
"signal is
|
|
833
|
+
"signal is not supported for legacy image builds (cas: false): a legacy image build has no build operation to cancel"
|
|
684
834
|
);
|
|
685
835
|
}
|
|
686
|
-
emit({
|
|
836
|
+
emit({
|
|
837
|
+
type: "status",
|
|
838
|
+
message: `Building ${cas ? "CAS" : "legacy"} image '${effectiveName}'...`
|
|
839
|
+
});
|
|
687
840
|
const binding = loadNativeBinding();
|
|
688
841
|
let emitError;
|
|
689
842
|
const nativeOptions = {
|
|
@@ -705,7 +858,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
705
858
|
dockerConfigJson: options.dockerConfigJson,
|
|
706
859
|
dockerfileText,
|
|
707
860
|
contextDir: nativeContextDir,
|
|
708
|
-
cas
|
|
861
|
+
cas,
|
|
709
862
|
buildArgs: options.buildArgs
|
|
710
863
|
};
|
|
711
864
|
const forward = (event) => {
|
|
@@ -715,7 +868,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
715
868
|
emitError ??= error;
|
|
716
869
|
}
|
|
717
870
|
};
|
|
718
|
-
const resultJson =
|
|
871
|
+
const resultJson = cas ? await __runWithInterrupt(
|
|
719
872
|
options.signal,
|
|
720
873
|
(interruptId) => binding.buildSandboxImage(nativeOptions, forward, interruptId)
|
|
721
874
|
) : await binding.buildSandboxImage(nativeOptions, forward);
|
|
@@ -746,7 +899,12 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
746
899
|
}
|
|
747
900
|
const reference = imageReference.trim();
|
|
748
901
|
const context = buildContextFromEnv();
|
|
749
|
-
const effectiveName =
|
|
902
|
+
const effectiveName = registeredImageName(
|
|
903
|
+
options.registeredName,
|
|
904
|
+
defaultRegisteredNameFromImage(reference),
|
|
905
|
+
options.cas ?? true,
|
|
906
|
+
DEFAULT_IMPORTED_IMAGE_NAME
|
|
907
|
+
);
|
|
750
908
|
if (effectiveName === DEFAULT_IMAGE_NAME2) {
|
|
751
909
|
console.warn(
|
|
752
910
|
`Importing sandbox image with the default name "${DEFAULT_IMAGE_NAME2}". Pass \`registeredName\` to avoid collisions with other default-named images in this project.`
|
|
@@ -764,14 +922,15 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
764
922
|
deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
|
|
765
923
|
);
|
|
766
924
|
}
|
|
767
|
-
|
|
925
|
+
const cas = options.cas ?? true;
|
|
926
|
+
if (options.signal !== void 0 && !cas) {
|
|
768
927
|
throw new Error(
|
|
769
|
-
"signal is
|
|
928
|
+
"signal is not supported for legacy image imports (cas: false): a legacy image import has no build operation to cancel"
|
|
770
929
|
);
|
|
771
930
|
}
|
|
772
931
|
emit({
|
|
773
932
|
type: "status",
|
|
774
|
-
message: `Importing
|
|
933
|
+
message: `Importing '${reference}' as ${cas ? "CAS" : "legacy"} image '${effectiveName}'...`
|
|
775
934
|
});
|
|
776
935
|
const binding = loadNativeBinding();
|
|
777
936
|
let emitError;
|
|
@@ -792,7 +951,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
792
951
|
userAgent: void 0,
|
|
793
952
|
dockerCompat: options.dockerCompat ?? false,
|
|
794
953
|
dockerConfigJson: options.dockerConfigJson,
|
|
795
|
-
cas
|
|
954
|
+
cas
|
|
796
955
|
};
|
|
797
956
|
const forward = (event) => {
|
|
798
957
|
try {
|
|
@@ -801,7 +960,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
801
960
|
emitError ??= error;
|
|
802
961
|
}
|
|
803
962
|
};
|
|
804
|
-
const resultJson =
|
|
963
|
+
const resultJson = cas ? await __runWithInterrupt(
|
|
805
964
|
options.signal,
|
|
806
965
|
(interruptId) => binding.importSandboxImage(nativeOptions, forward, interruptId)
|
|
807
966
|
) : await binding.importSandboxImage(nativeOptions, forward);
|
|
@@ -858,15 +1017,29 @@ async function deleteSandboxImage(imageName) {
|
|
|
858
1017
|
if (typeof imageName !== "string" || imageName.length === 0) {
|
|
859
1018
|
throw new TypeError("imageName must be a non-empty string");
|
|
860
1019
|
}
|
|
861
|
-
|
|
1020
|
+
warnIncompleteLegacyCleanup(
|
|
1021
|
+
await loadNativeBinding().deleteSandboxImage(catalogOptionsFromEnv(), imageName)
|
|
1022
|
+
);
|
|
862
1023
|
}
|
|
863
1024
|
async function deleteSandboxImageWithCredentials(credentials, imageName) {
|
|
864
1025
|
if (typeof imageName !== "string" || imageName.length === 0) {
|
|
865
1026
|
throw new TypeError("imageName must be a non-empty string");
|
|
866
1027
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
1028
|
+
warnIncompleteLegacyCleanup(
|
|
1029
|
+
await loadNativeBinding().deleteSandboxImage(
|
|
1030
|
+
catalogOptionsFromCredentials(credentials),
|
|
1031
|
+
imageName
|
|
1032
|
+
)
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
function warnIncompleteLegacyCleanup(failure) {
|
|
1036
|
+
if (failure == null) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const legacyImageId = failure.legacyImageId ?? void 0;
|
|
1040
|
+
const label = legacyImageId ? ` (${legacyImageId})` : "";
|
|
1041
|
+
console.warn(
|
|
1042
|
+
`Deleted CAS image '${failure.legacyImageName}', but could not delete the legacy image of the same name${label}, which can no longer start sandboxes: ${failure.error}. Delete it with deleteSandboxImage("${legacyImageId ?? failure.legacyImageName}").`
|
|
870
1043
|
);
|
|
871
1044
|
}
|
|
872
1045
|
async function findSandboxImageByName(imageName) {
|
|
@@ -910,13 +1083,14 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
910
1083
|
disk_mb: { type: "string" },
|
|
911
1084
|
builder_disk_mb: { type: "string" },
|
|
912
1085
|
docker_compat: { type: "boolean", default: false },
|
|
913
|
-
public: { type: "boolean", default: false }
|
|
1086
|
+
public: { type: "boolean", default: false },
|
|
1087
|
+
"no-cas": { type: "boolean", default: false }
|
|
914
1088
|
}
|
|
915
1089
|
});
|
|
916
1090
|
const dockerfilePath = parsed.positionals[0];
|
|
917
1091
|
if (!dockerfilePath) {
|
|
918
1092
|
throw new Error(
|
|
919
|
-
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
1093
|
+
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public] [--no-cas]"
|
|
920
1094
|
);
|
|
921
1095
|
}
|
|
922
1096
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -948,7 +1122,8 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
948
1122
|
diskMb,
|
|
949
1123
|
builderDiskMb,
|
|
950
1124
|
dockerCompat: parsed.values.docker_compat,
|
|
951
|
-
isPublic: parsed.values.public
|
|
1125
|
+
isPublic: parsed.values.public,
|
|
1126
|
+
cas: !parsed.values["no-cas"]
|
|
952
1127
|
},
|
|
953
1128
|
{ emit: ndjsonStdoutEmit, _allowPat: true }
|
|
954
1129
|
);
|
|
@@ -964,13 +1139,14 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
964
1139
|
disk_mb: { type: "string" },
|
|
965
1140
|
builder_disk_mb: { type: "string" },
|
|
966
1141
|
docker_compat: { type: "boolean", default: false },
|
|
967
|
-
public: { type: "boolean", default: false }
|
|
1142
|
+
public: { type: "boolean", default: false },
|
|
1143
|
+
"no-cas": { type: "boolean", default: false }
|
|
968
1144
|
}
|
|
969
1145
|
});
|
|
970
1146
|
const imageReference = parsed.positionals[0];
|
|
971
1147
|
if (!imageReference) {
|
|
972
1148
|
throw new Error(
|
|
973
|
-
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
1149
|
+
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public] [--no-cas]"
|
|
974
1150
|
);
|
|
975
1151
|
}
|
|
976
1152
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -1002,12 +1178,13 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
1002
1178
|
diskMb,
|
|
1003
1179
|
builderDiskMb,
|
|
1004
1180
|
dockerCompat: parsed.values.docker_compat,
|
|
1005
|
-
isPublic: parsed.values.public
|
|
1181
|
+
isPublic: parsed.values.public,
|
|
1182
|
+
cas: !parsed.values["no-cas"]
|
|
1006
1183
|
},
|
|
1007
1184
|
{ emit: ndjsonStdoutEmit, _allowPat: true }
|
|
1008
1185
|
);
|
|
1009
1186
|
}
|
|
1010
|
-
var cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2, __imageBuildInternals;
|
|
1187
|
+
var cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2, DEFAULT_SANDBOX_IMAGE_NAME, DEFAULT_IMPORTED_IMAGE_NAME, CAS_NAME_SEPARATORS, RESERVED_IMAGE_NAME_PREFIXES, MAX_CAS_IMAGE_NAME_LENGTH, __imageBuildInternals;
|
|
1011
1188
|
var init_sandbox_image = __esm({
|
|
1012
1189
|
"src/sandbox-image.ts"() {
|
|
1013
1190
|
init_esm_shims();
|
|
@@ -1015,6 +1192,11 @@ var init_sandbox_image = __esm({
|
|
|
1015
1192
|
init_native_binding();
|
|
1016
1193
|
init_image_builds();
|
|
1017
1194
|
DEFAULT_IMAGE_NAME2 = "default";
|
|
1195
|
+
DEFAULT_SANDBOX_IMAGE_NAME = "sandbox-image";
|
|
1196
|
+
DEFAULT_IMPORTED_IMAGE_NAME = "imported-image";
|
|
1197
|
+
CAS_NAME_SEPARATORS = "._-";
|
|
1198
|
+
RESERVED_IMAGE_NAME_PREFIXES = ["sandbox_template_", "image_", "cas-v1:"];
|
|
1199
|
+
MAX_CAS_IMAGE_NAME_LENGTH = 255;
|
|
1018
1200
|
__imageBuildInternals = {
|
|
1019
1201
|
loadNativeBinding: () => loadNativeBinding(),
|
|
1020
1202
|
buildContextFromEnv: () => buildContextFromEnv(),
|
|
@@ -1023,7 +1205,12 @@ var init_sandbox_image = __esm({
|
|
|
1023
1205
|
eventToEmitDict: (event) => eventToEmitDict(event),
|
|
1024
1206
|
imageRequiresContext: (image) => imageRequiresContext(image),
|
|
1025
1207
|
defaultRegisteredName: (dockerfilePath) => defaultRegisteredName(dockerfilePath),
|
|
1026
|
-
defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference)
|
|
1208
|
+
defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference),
|
|
1209
|
+
registeredImageName: (explicit, generated, cas, fallback) => registeredImageName(explicit, generated, cas, fallback),
|
|
1210
|
+
casImageNameFrom: (raw, fallback) => casImageNameFrom(raw, fallback),
|
|
1211
|
+
canonicalCasImageName: (name) => canonicalCasImageName(name),
|
|
1212
|
+
isAddressableCasImageName: (name) => isAddressableCasImageName(name),
|
|
1213
|
+
defaultImportedImageName: DEFAULT_IMPORTED_IMAGE_NAME
|
|
1027
1214
|
};
|
|
1028
1215
|
}
|
|
1029
1216
|
});
|