@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/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ var init_defaults = __esm({
|
|
|
49
49
|
"src/defaults.ts"() {
|
|
50
50
|
"use strict";
|
|
51
51
|
init_cjs_shims();
|
|
52
|
-
SDK_VERSION = "0.5.
|
|
52
|
+
SDK_VERSION = "0.5.156";
|
|
53
53
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
54
54
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
55
55
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -60,6 +60,20 @@ var init_defaults = __esm({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
// src/enum.ts
|
|
64
|
+
function enumValue(values, value) {
|
|
65
|
+
return typeof value === "string" && Object.values(values).includes(value) ? value : values.UNKNOWN;
|
|
66
|
+
}
|
|
67
|
+
function withRaw(value, raw) {
|
|
68
|
+
return Object.defineProperty(value, "raw", { value: raw, enumerable: false, configurable: true });
|
|
69
|
+
}
|
|
70
|
+
var init_enum = __esm({
|
|
71
|
+
"src/enum.ts"() {
|
|
72
|
+
"use strict";
|
|
73
|
+
init_cjs_shims();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
63
77
|
// src/errors.ts
|
|
64
78
|
function formatErrorDetails(errorDetails) {
|
|
65
79
|
if (errorDetails == null) return void 0;
|
|
@@ -498,7 +512,7 @@ var init_native_worker_client = __esm({
|
|
|
498
512
|
}
|
|
499
513
|
};
|
|
500
514
|
runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
501
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
515
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.156"}.v1`
|
|
502
516
|
);
|
|
503
517
|
runtimes = globalThis;
|
|
504
518
|
}
|
|
@@ -600,6 +614,7 @@ var init_models = __esm({
|
|
|
600
614
|
SnapshotStatus2["FAILED"] = "failed";
|
|
601
615
|
SnapshotStatus2["DELETING"] = "deleting";
|
|
602
616
|
SnapshotStatus2["REPLICATING"] = "replicating";
|
|
617
|
+
SnapshotStatus2["UNKNOWN"] = "unknown";
|
|
603
618
|
return SnapshotStatus2;
|
|
604
619
|
})(SnapshotStatus || {});
|
|
605
620
|
ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
|
|
@@ -4496,6 +4511,18 @@ __export(client_exports, {
|
|
|
4496
4511
|
DEFAULT_WAIT_POLL_INTERVAL_SEC: () => DEFAULT_WAIT_POLL_INTERVAL_SEC,
|
|
4497
4512
|
SandboxClient: () => SandboxClient
|
|
4498
4513
|
});
|
|
4514
|
+
function parseSnapshot(raw) {
|
|
4515
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
4516
|
+
throw new SandboxError("Invalid snapshot response: expected an object");
|
|
4517
|
+
}
|
|
4518
|
+
if (raw.status == null) {
|
|
4519
|
+
throw new SandboxError("Invalid snapshot response: missing status");
|
|
4520
|
+
}
|
|
4521
|
+
return withRaw({
|
|
4522
|
+
...fromSnakeKeys(raw, "snapshotId"),
|
|
4523
|
+
status: enumValue(SnapshotStatus, raw.status)
|
|
4524
|
+
}, raw);
|
|
4525
|
+
}
|
|
4499
4526
|
function requireReadOnlySnapshotPin(fileSystemId, mountPath, readOnly, snapshotId) {
|
|
4500
4527
|
if (snapshotId != null && readOnly !== true) {
|
|
4501
4528
|
throw new SandboxError(
|
|
@@ -4617,6 +4644,7 @@ var init_client = __esm({
|
|
|
4617
4644
|
"use strict";
|
|
4618
4645
|
init_cjs_shims();
|
|
4619
4646
|
init_defaults();
|
|
4647
|
+
init_enum();
|
|
4620
4648
|
init_errors();
|
|
4621
4649
|
init_native_worker_client();
|
|
4622
4650
|
init_native_sandbox();
|
|
@@ -5264,18 +5292,18 @@ var init_client = __esm({
|
|
|
5264
5292
|
* block automatically.
|
|
5265
5293
|
*/
|
|
5266
5294
|
async snapshot(sandboxId, options) {
|
|
5267
|
-
|
|
5295
|
+
const { json } = await callNative(
|
|
5268
5296
|
() => this.native.createSnapshot(sandboxId, options?.snapshotType ?? null),
|
|
5269
|
-
"snapshotId",
|
|
5270
5297
|
{ sandboxId, notFoundKind: "sandbox" }
|
|
5271
5298
|
);
|
|
5299
|
+
return parseSnapshot(JSON.parse(json));
|
|
5272
5300
|
}
|
|
5273
5301
|
/** Get current status and metadata for a snapshot by ID. */
|
|
5274
5302
|
async getSnapshot(snapshotId) {
|
|
5275
|
-
|
|
5276
|
-
() => this.native.getSnapshot(snapshotId)
|
|
5277
|
-
"snapshotId"
|
|
5303
|
+
const { traceId, json } = await callNative(
|
|
5304
|
+
() => this.native.getSnapshot(snapshotId)
|
|
5278
5305
|
);
|
|
5306
|
+
return Object.assign(parseSnapshot(JSON.parse(json)), { traceId });
|
|
5279
5307
|
}
|
|
5280
5308
|
/** List all snapshots in the namespace. */
|
|
5281
5309
|
async listSnapshots() {
|
|
@@ -5283,9 +5311,14 @@ var init_client = __esm({
|
|
|
5283
5311
|
() => this.native.listSnapshots()
|
|
5284
5312
|
);
|
|
5285
5313
|
const parsed = JSON.parse(json);
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5314
|
+
if (parsed !== null && (typeof parsed !== "object" || Array.isArray(parsed))) {
|
|
5315
|
+
throw new SandboxError("Invalid snapshot list response: expected an object");
|
|
5316
|
+
}
|
|
5317
|
+
const records = parsed?.snapshots ?? [];
|
|
5318
|
+
if (!Array.isArray(records)) {
|
|
5319
|
+
throw new SandboxError("Invalid snapshot list response: snapshots must be an array");
|
|
5320
|
+
}
|
|
5321
|
+
const snapshots = records.map((s) => parseSnapshot(s));
|
|
5289
5322
|
return Object.assign(snapshots, { traceId });
|
|
5290
5323
|
}
|
|
5291
5324
|
/** Delete a snapshot by ID. */
|
|
@@ -5686,10 +5719,11 @@ var init_image = __esm({
|
|
|
5686
5719
|
});
|
|
5687
5720
|
}
|
|
5688
5721
|
/**
|
|
5689
|
-
* Build this image as a sandbox
|
|
5722
|
+
* Build this image and register it as a CAS sandbox image (the default) or,
|
|
5723
|
+
* with `cas: false`, a legacy sandbox image.
|
|
5690
5724
|
*
|
|
5691
5725
|
* Materializes the image in a build sandbox, snapshots the filesystem,
|
|
5692
|
-
* and registers the snapshot
|
|
5726
|
+
* and registers the snapshot under the image's name.
|
|
5693
5727
|
*/
|
|
5694
5728
|
async build(options = {}) {
|
|
5695
5729
|
const { createSandboxImage: createSandboxImage2 } = await Promise.resolve().then(() => (init_sandbox_image(), sandbox_image_exports));
|
|
@@ -5850,6 +5884,9 @@ var init_native_binding = __esm({
|
|
|
5850
5884
|
});
|
|
5851
5885
|
|
|
5852
5886
|
// src/image-builds.ts
|
|
5887
|
+
function isConfirmedCancellation(outcome) {
|
|
5888
|
+
return outcome === "cancelled" /* CANCELLED */ || outcome === "already_cancelled" /* ALREADY_CANCELLED */ || outcome === "already_failed" /* ALREADY_FAILED */;
|
|
5889
|
+
}
|
|
5853
5890
|
function camelize(key) {
|
|
5854
5891
|
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
5855
5892
|
}
|
|
@@ -5867,62 +5904,87 @@ function toImageBuildError(error) {
|
|
|
5867
5904
|
if (key === "category") continue;
|
|
5868
5905
|
details[camelize(key)] = value;
|
|
5869
5906
|
}
|
|
5907
|
+
details.code = enumValue(ImageBuildErrorCode, details.code || "internal" /* INTERNAL */);
|
|
5908
|
+
if ("activeKind" in details) details.activeKind = details.activeKind ? enumValue(ImageBuildKind, details.activeKind) : null;
|
|
5909
|
+
if ("activeStatus" in details) details.activeStatus = details.activeStatus ? enumValue(ImageBuildStatus, details.activeStatus) : null;
|
|
5910
|
+
if ("outcome" in details) details.outcome = details.outcome ? enumValue(ImageBuildCancellationOutcome, details.outcome) : null;
|
|
5911
|
+
if ("info" in details) details.info = buildInfoOrNull(details.info);
|
|
5870
5912
|
const typed = details;
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
return new ImageBuildTimeoutError(typed);
|
|
5882
|
-
case "interrupted":
|
|
5883
|
-
return new ImageBuildInterruptedError(typed);
|
|
5884
|
-
default:
|
|
5885
|
-
return new ImageBuildError(typed);
|
|
5886
|
-
}
|
|
5913
|
+
const errors = {
|
|
5914
|
+
not_found: ImageBuildNotFoundError,
|
|
5915
|
+
image_build_in_progress: ImageBuildInProgressError,
|
|
5916
|
+
failed: ImageBuildFailedError,
|
|
5917
|
+
cancelled: ImageBuildCancelledError,
|
|
5918
|
+
timeout: ImageBuildTimeoutError,
|
|
5919
|
+
interrupted: ImageBuildInterruptedError
|
|
5920
|
+
};
|
|
5921
|
+
const ErrorClass = errors[typed.code] ?? ImageBuildError;
|
|
5922
|
+
return withRaw(new ErrorClass(typed), payload);
|
|
5887
5923
|
}
|
|
5888
5924
|
function camelizeRecord(value) {
|
|
5889
5925
|
const out = {};
|
|
5890
5926
|
for (const [key, inner] of Object.entries(value)) out[camelize(key)] = inner;
|
|
5891
5927
|
return out;
|
|
5892
5928
|
}
|
|
5893
|
-
function
|
|
5929
|
+
function buildInfoOrNull(value) {
|
|
5930
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
5931
|
+
try {
|
|
5932
|
+
return parseBuildInfo(value);
|
|
5933
|
+
} catch (error) {
|
|
5934
|
+
if (error instanceof ImageBuildError) return null;
|
|
5935
|
+
throw error;
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
function decodeResponse(value) {
|
|
5939
|
+
try {
|
|
5940
|
+
const raw = typeof value === "string" ? JSON.parse(value) : value;
|
|
5941
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new TypeError("expected a response object");
|
|
5942
|
+
return raw;
|
|
5943
|
+
} catch (error) {
|
|
5944
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: `Invalid image-build response: ${String(error)}` }), { response: value });
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5947
|
+
function parseBuildInfo(value) {
|
|
5948
|
+
const raw = decodeResponse(value);
|
|
5949
|
+
if (raw.status == null) {
|
|
5950
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build response: missing status" }), { response: value });
|
|
5951
|
+
}
|
|
5952
|
+
const attempt = raw.attempt_no ?? 0;
|
|
5953
|
+
const attemptNo = Number(attempt);
|
|
5954
|
+
if (typeof attempt !== "number" && typeof attempt !== "string" || typeof attempt === "string" && attempt.trim() === "" || !Number.isSafeInteger(attemptNo)) {
|
|
5955
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build attempt_no" }), { response: value });
|
|
5956
|
+
}
|
|
5894
5957
|
const camel = camelizeRecord(raw);
|
|
5895
5958
|
const result = raw.result && typeof raw.result === "object" ? camelizeRecord(raw.result) : null;
|
|
5896
|
-
return {
|
|
5959
|
+
return withRaw({
|
|
5897
5960
|
buildId: String(raw.build_id ?? ""),
|
|
5898
5961
|
clientRequestId: camel.clientRequestId ?? null,
|
|
5899
|
-
kind:
|
|
5962
|
+
kind: raw.kind ? enumValue(ImageBuildKind, raw.kind) : null,
|
|
5900
5963
|
name: raw.name ?? null,
|
|
5901
|
-
status:
|
|
5902
|
-
phase: raw.phase
|
|
5903
|
-
attemptNo
|
|
5964
|
+
status: enumValue(ImageBuildStatus, raw.status),
|
|
5965
|
+
phase: raw.phase ? enumValue(ImageBuildPhase, raw.phase) : null,
|
|
5966
|
+
attemptNo,
|
|
5904
5967
|
builderSandboxId: camel.builderSandboxId ?? null,
|
|
5905
5968
|
error: raw.error ?? null,
|
|
5906
5969
|
result,
|
|
5907
5970
|
operationDeadlineMs: camel.operationDeadlineMs ?? null,
|
|
5908
5971
|
createdAtMs: camel.createdAtMs ?? null,
|
|
5909
|
-
updatedAtMs: camel.updatedAtMs ?? null
|
|
5910
|
-
|
|
5911
|
-
};
|
|
5972
|
+
updatedAtMs: camel.updatedAtMs ?? null
|
|
5973
|
+
}, raw);
|
|
5912
5974
|
}
|
|
5913
5975
|
function parseResult(json) {
|
|
5914
|
-
return camelizeRecord(
|
|
5976
|
+
return camelizeRecord(decodeResponse(json));
|
|
5915
5977
|
}
|
|
5916
5978
|
function credentialsFromEnv() {
|
|
5917
5979
|
const context = __imageBuildInternals.buildContextFromEnv();
|
|
5918
5980
|
if (!context.apiKey) {
|
|
5919
5981
|
if (context.personalAccessToken) {
|
|
5920
5982
|
throw new ImageBuildError({
|
|
5921
|
-
code: "auth"
|
|
5983
|
+
code: "auth" /* AUTH */,
|
|
5922
5984
|
message: "Sandbox image SDKs require TENSORLAKE_API_KEY. Personal access tokens are CLI-only."
|
|
5923
5985
|
});
|
|
5924
5986
|
}
|
|
5925
|
-
throw new ImageBuildError({ code: "auth"
|
|
5987
|
+
throw new ImageBuildError({ code: "auth" /* AUTH */, message: "Missing TENSORLAKE_API_KEY credentials." });
|
|
5926
5988
|
}
|
|
5927
5989
|
return { apiUrl: context.apiUrl, bearerToken: context.apiKey, namespace: context.namespace };
|
|
5928
5990
|
}
|
|
@@ -5936,19 +5998,19 @@ function clientOptions(credentials) {
|
|
|
5936
5998
|
}
|
|
5937
5999
|
function rejectLegacyReference(buildId) {
|
|
5938
6000
|
if (typeof buildId !== "string" || buildId.trim().length === 0) {
|
|
5939
|
-
throw new ImageBuildError({ code: "usage"
|
|
6001
|
+
throw new ImageBuildError({ code: "usage" /* USAGE */, message: "buildId must be a non-empty string" });
|
|
5940
6002
|
}
|
|
5941
6003
|
if (buildId.startsWith("sandbox_template_")) {
|
|
5942
6004
|
throw new ImageBuildError({
|
|
5943
|
-
code: "usage"
|
|
5944
|
-
message: `'${buildId}' is a legacy
|
|
6005
|
+
code: "usage" /* USAGE */,
|
|
6006
|
+
message: `'${buildId}' is a legacy image id; legacy images have no build operation to get, wait for or cancel`,
|
|
5945
6007
|
buildId
|
|
5946
6008
|
});
|
|
5947
6009
|
}
|
|
5948
6010
|
if (buildId.startsWith("image_")) {
|
|
5949
6011
|
throw new ImageBuildError({
|
|
5950
|
-
code: "usage"
|
|
5951
|
-
message: `'${buildId}' is
|
|
6012
|
+
code: "usage" /* USAGE */,
|
|
6013
|
+
message: `'${buildId}' is a CAS image id, not a build id; look the CAS image up with findSandboxImageByName or use the build id admission returned`,
|
|
5952
6014
|
buildId
|
|
5953
6015
|
});
|
|
5954
6016
|
}
|
|
@@ -5994,8 +6056,15 @@ function makeEmitter(options) {
|
|
|
5994
6056
|
};
|
|
5995
6057
|
}
|
|
5996
6058
|
function decodeStarted(json, credentials) {
|
|
5997
|
-
const payload =
|
|
5998
|
-
|
|
6059
|
+
const payload = decodeResponse(json);
|
|
6060
|
+
const build = payload.build;
|
|
6061
|
+
if (!build || typeof build !== "object" || Array.isArray(build) || typeof build.build_id !== "string" || !build.build_id.trim()) {
|
|
6062
|
+
throw withRaw(new ImageBuildError({
|
|
6063
|
+
code: "service" /* SERVICE */,
|
|
6064
|
+
message: "Invalid image-build admission: expected a build with a non-empty build_id"
|
|
6065
|
+
}), { response: payload });
|
|
6066
|
+
}
|
|
6067
|
+
return new ImageBuildHandle(parseBuildInfo(build), credentials, payload.client_request_id);
|
|
5999
6068
|
}
|
|
6000
6069
|
async function startImageBuild(source, options = {}, deps = {}) {
|
|
6001
6070
|
const emitter = makeEmitter({ emit: deps.emit ?? options.emit, verbose: options.verbose });
|
|
@@ -6020,19 +6089,27 @@ async function startImageBuild(source, options = {}, deps = {}) {
|
|
|
6020
6089
|
let text = dockerfileContent(source);
|
|
6021
6090
|
if (!text.endsWith("\n")) text += "\n";
|
|
6022
6091
|
dockerfileText = text;
|
|
6023
|
-
name =
|
|
6092
|
+
name = __imageBuildInternals.registeredImageName(
|
|
6093
|
+
options.registeredName ?? source.name,
|
|
6094
|
+
void 0,
|
|
6095
|
+
true
|
|
6096
|
+
);
|
|
6024
6097
|
} else if (typeof source === "string") {
|
|
6025
6098
|
const resolved = import_node_path2.default.resolve(source);
|
|
6026
6099
|
if (!(0, import_node_fs.existsSync)(resolved)) throw new Error(`Dockerfile not found: ${source}`);
|
|
6027
6100
|
dockerfilePath = resolved;
|
|
6028
|
-
name =
|
|
6101
|
+
name = __imageBuildInternals.registeredImageName(
|
|
6102
|
+
options.registeredName,
|
|
6103
|
+
__imageBuildInternals.defaultRegisteredName(resolved),
|
|
6104
|
+
true
|
|
6105
|
+
);
|
|
6029
6106
|
} else {
|
|
6030
6107
|
throw new TypeError(`source must be an Image or a Dockerfile path, got ${typeof source}`);
|
|
6031
6108
|
}
|
|
6032
6109
|
try {
|
|
6033
6110
|
const credentials = credentialsFromEnv();
|
|
6034
6111
|
const binding = __imageBuildInternals.loadNativeBinding();
|
|
6035
|
-
emitter.emit({ type: "status", message: `Building image '${name}'...` });
|
|
6112
|
+
emitter.emit({ type: "status", message: `Building CAS image '${name}'...` });
|
|
6036
6113
|
const json = await __runWithInterrupt(
|
|
6037
6114
|
options.signal,
|
|
6038
6115
|
(interruptId) => binding.startImageBuild(
|
|
@@ -6068,11 +6145,16 @@ async function startImageImport(imageReference, options = {}, deps = {}) {
|
|
|
6068
6145
|
throw new Error("image reference to import must not be empty");
|
|
6069
6146
|
}
|
|
6070
6147
|
const reference = imageReference.trim();
|
|
6071
|
-
const name =
|
|
6148
|
+
const name = __imageBuildInternals.registeredImageName(
|
|
6149
|
+
options.registeredName,
|
|
6150
|
+
__imageBuildInternals.defaultRegisteredNameFromImage(reference),
|
|
6151
|
+
true,
|
|
6152
|
+
__imageBuildInternals.defaultImportedImageName
|
|
6153
|
+
);
|
|
6072
6154
|
const emitter = makeEmitter({ emit: deps.emit ?? options.emit, verbose: options.verbose });
|
|
6073
6155
|
const credentials = credentialsFromEnv();
|
|
6074
6156
|
const binding = __imageBuildInternals.loadNativeBinding();
|
|
6075
|
-
emitter.emit({ type: "status", message: `Importing
|
|
6157
|
+
emitter.emit({ type: "status", message: `Importing '${reference}' as CAS image '${name}'...` });
|
|
6076
6158
|
const json = await __runWithInterrupt(
|
|
6077
6159
|
options.signal,
|
|
6078
6160
|
(interruptId) => binding.startImageImport(
|
|
@@ -6107,7 +6189,7 @@ async function getImageBuild(buildId) {
|
|
|
6107
6189
|
} catch (error) {
|
|
6108
6190
|
throw toImageBuildError(error);
|
|
6109
6191
|
}
|
|
6110
|
-
return new ImageBuildHandle(parseBuildInfo(
|
|
6192
|
+
return new ImageBuildHandle(parseBuildInfo(json), credentials);
|
|
6111
6193
|
}
|
|
6112
6194
|
async function waitImageBuild(buildId, options = {}) {
|
|
6113
6195
|
rejectLegacyReference(buildId);
|
|
@@ -6138,36 +6220,84 @@ async function cancelImageBuildWith(credentials, selector) {
|
|
|
6138
6220
|
} catch (error) {
|
|
6139
6221
|
throw toImageBuildError(error);
|
|
6140
6222
|
}
|
|
6141
|
-
const payload =
|
|
6142
|
-
const outcome =
|
|
6143
|
-
return {
|
|
6144
|
-
outcome,
|
|
6145
|
-
build: payload.build ? parseBuildInfo(payload.build) : null,
|
|
6146
|
-
confirmed: ["cancelled", "already_cancelled", "already_failed"].includes(outcome)
|
|
6147
|
-
};
|
|
6223
|
+
const payload = decodeResponse(json);
|
|
6224
|
+
const outcome = enumValue(ImageBuildCancellationOutcome, payload.outcome);
|
|
6225
|
+
return withRaw({ outcome, build: buildInfoOrNull(payload.build), confirmed: isConfirmedCancellation(outcome) }, payload);
|
|
6148
6226
|
}
|
|
6149
6227
|
async function cancelImageBuild(selector) {
|
|
6150
6228
|
const hasBuild = selector.buildId != null;
|
|
6151
6229
|
const hasRequest = selector.clientRequestId != null;
|
|
6152
6230
|
if (hasBuild === hasRequest) {
|
|
6153
6231
|
throw new ImageBuildError({
|
|
6154
|
-
code: "usage"
|
|
6232
|
+
code: "usage" /* USAGE */,
|
|
6155
6233
|
message: "pass exactly one of buildId or clientRequestId"
|
|
6156
6234
|
});
|
|
6157
6235
|
}
|
|
6158
6236
|
if (selector.buildId != null) rejectLegacyReference(selector.buildId);
|
|
6159
6237
|
return cancelImageBuildWith(credentialsFromEnv(), selector);
|
|
6160
6238
|
}
|
|
6161
|
-
var import_node_path2, import_node_os, import_node_fs, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError, ImageBuildHandle;
|
|
6239
|
+
var import_node_path2, import_node_os, import_node_fs, ImageBuildStatus, ImageBuildPhase, ImageBuildKind, ImageBuildCancellationOutcome, ImageBuildErrorCode, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError, ImageBuildHandle;
|
|
6162
6240
|
var init_image_builds = __esm({
|
|
6163
6241
|
"src/image-builds.ts"() {
|
|
6164
6242
|
"use strict";
|
|
6165
6243
|
init_cjs_shims();
|
|
6166
6244
|
import_node_path2 = __toESM(require("path"), 1);
|
|
6245
|
+
init_enum();
|
|
6167
6246
|
import_node_os = __toESM(require("os"), 1);
|
|
6168
6247
|
import_node_fs = require("fs");
|
|
6169
6248
|
init_image();
|
|
6170
6249
|
init_sandbox_image();
|
|
6250
|
+
ImageBuildStatus = /* @__PURE__ */ ((ImageBuildStatus2) => {
|
|
6251
|
+
ImageBuildStatus2["PENDING"] = "pending";
|
|
6252
|
+
ImageBuildStatus2["RUNNING"] = "running";
|
|
6253
|
+
ImageBuildStatus2["SUCCEEDED"] = "succeeded";
|
|
6254
|
+
ImageBuildStatus2["FAILED"] = "failed";
|
|
6255
|
+
ImageBuildStatus2["CANCELLED"] = "cancelled";
|
|
6256
|
+
ImageBuildStatus2["UNKNOWN"] = "unknown";
|
|
6257
|
+
return ImageBuildStatus2;
|
|
6258
|
+
})(ImageBuildStatus || {});
|
|
6259
|
+
ImageBuildPhase = /* @__PURE__ */ ((ImageBuildPhase2) => {
|
|
6260
|
+
ImageBuildPhase2["AWAITING_CONTEXT"] = "awaiting_context";
|
|
6261
|
+
ImageBuildPhase2["STARTING_BUILDER"] = "starting_builder";
|
|
6262
|
+
ImageBuildPhase2["EXECUTING"] = "executing";
|
|
6263
|
+
ImageBuildPhase2["SNAPSHOTTING"] = "snapshotting";
|
|
6264
|
+
ImageBuildPhase2["PUBLISHING"] = "publishing";
|
|
6265
|
+
ImageBuildPhase2["FINISHED"] = "finished";
|
|
6266
|
+
ImageBuildPhase2["UNKNOWN"] = "unknown";
|
|
6267
|
+
return ImageBuildPhase2;
|
|
6268
|
+
})(ImageBuildPhase || {});
|
|
6269
|
+
ImageBuildKind = /* @__PURE__ */ ((ImageBuildKind2) => {
|
|
6270
|
+
ImageBuildKind2["DOCKERFILE"] = "dockerfile";
|
|
6271
|
+
ImageBuildKind2["IMPORT"] = "import";
|
|
6272
|
+
ImageBuildKind2["DIRECT"] = "direct";
|
|
6273
|
+
ImageBuildKind2["UNKNOWN"] = "unknown";
|
|
6274
|
+
return ImageBuildKind2;
|
|
6275
|
+
})(ImageBuildKind || {});
|
|
6276
|
+
ImageBuildCancellationOutcome = /* @__PURE__ */ ((ImageBuildCancellationOutcome2) => {
|
|
6277
|
+
ImageBuildCancellationOutcome2["CANCELLED"] = "cancelled";
|
|
6278
|
+
ImageBuildCancellationOutcome2["ALREADY_CANCELLED"] = "already_cancelled";
|
|
6279
|
+
ImageBuildCancellationOutcome2["ALREADY_COMPLETED"] = "already_completed";
|
|
6280
|
+
ImageBuildCancellationOutcome2["ALREADY_FAILED"] = "already_failed";
|
|
6281
|
+
ImageBuildCancellationOutcome2["NOT_ADMITTED"] = "not_admitted";
|
|
6282
|
+
ImageBuildCancellationOutcome2["UNCONFIRMED"] = "unconfirmed";
|
|
6283
|
+
ImageBuildCancellationOutcome2["UNKNOWN"] = "unknown";
|
|
6284
|
+
return ImageBuildCancellationOutcome2;
|
|
6285
|
+
})(ImageBuildCancellationOutcome || {});
|
|
6286
|
+
ImageBuildErrorCode = /* @__PURE__ */ ((ImageBuildErrorCode2) => {
|
|
6287
|
+
ImageBuildErrorCode2["USAGE"] = "usage";
|
|
6288
|
+
ImageBuildErrorCode2["AUTH"] = "auth";
|
|
6289
|
+
ImageBuildErrorCode2["NOT_FOUND"] = "not_found";
|
|
6290
|
+
ImageBuildErrorCode2["IMAGE_BUILD_IN_PROGRESS"] = "image_build_in_progress";
|
|
6291
|
+
ImageBuildErrorCode2["CLIENT_REQUEST_ID_MISMATCH"] = "client_request_id_mismatch";
|
|
6292
|
+
ImageBuildErrorCode2["FAILED"] = "failed";
|
|
6293
|
+
ImageBuildErrorCode2["CANCELLED"] = "cancelled";
|
|
6294
|
+
ImageBuildErrorCode2["TIMEOUT"] = "timeout";
|
|
6295
|
+
ImageBuildErrorCode2["INTERRUPTED"] = "interrupted";
|
|
6296
|
+
ImageBuildErrorCode2["SERVICE"] = "service";
|
|
6297
|
+
ImageBuildErrorCode2["INTERNAL"] = "internal";
|
|
6298
|
+
ImageBuildErrorCode2["UNKNOWN"] = "unknown";
|
|
6299
|
+
return ImageBuildErrorCode2;
|
|
6300
|
+
})(ImageBuildErrorCode || {});
|
|
6171
6301
|
ImageBuildError = class extends Error {
|
|
6172
6302
|
code;
|
|
6173
6303
|
buildId;
|
|
@@ -6177,7 +6307,11 @@ var init_image_builds = __esm({
|
|
|
6177
6307
|
super(details.message);
|
|
6178
6308
|
this.name = "ImageBuildError";
|
|
6179
6309
|
this.code = details.code;
|
|
6180
|
-
this.details = details;
|
|
6310
|
+
this.details = { ...details };
|
|
6311
|
+
withRaw(this, {});
|
|
6312
|
+
if ("confirmed" in details) {
|
|
6313
|
+
this.details.confirmed = details.confirmed === true && isConfirmedCancellation(details.outcome);
|
|
6314
|
+
}
|
|
6181
6315
|
if (details.buildId) this.buildId = details.buildId;
|
|
6182
6316
|
if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
|
|
6183
6317
|
}
|
|
@@ -6209,7 +6343,7 @@ var init_image_builds = __esm({
|
|
|
6209
6343
|
super(details);
|
|
6210
6344
|
this.name = "ImageBuildFailedError";
|
|
6211
6345
|
this.error = details.error ?? "no error recorded";
|
|
6212
|
-
if (details.info) this.info =
|
|
6346
|
+
if (details.info) this.info = details.info;
|
|
6213
6347
|
}
|
|
6214
6348
|
};
|
|
6215
6349
|
ImageBuildCancelledError = class extends ImageBuildError {
|
|
@@ -6217,7 +6351,7 @@ var init_image_builds = __esm({
|
|
|
6217
6351
|
constructor(details) {
|
|
6218
6352
|
super(details);
|
|
6219
6353
|
this.name = "ImageBuildCancelledError";
|
|
6220
|
-
if (details.info) this.info =
|
|
6354
|
+
if (details.info) this.info = details.info;
|
|
6221
6355
|
}
|
|
6222
6356
|
};
|
|
6223
6357
|
ImageBuildTimeoutError = class extends ImageBuildError {
|
|
@@ -6233,8 +6367,8 @@ var init_image_builds = __esm({
|
|
|
6233
6367
|
constructor(details) {
|
|
6234
6368
|
super(details);
|
|
6235
6369
|
this.name = "ImageBuildInterruptedError";
|
|
6236
|
-
this.outcome = details.outcome ?? "unconfirmed"
|
|
6237
|
-
this.confirmed = details.confirmed === true;
|
|
6370
|
+
this.outcome = details.outcome ?? "unconfirmed" /* UNCONFIRMED */;
|
|
6371
|
+
this.confirmed = this.details.confirmed === true;
|
|
6238
6372
|
if (details.result) this.result = details.result;
|
|
6239
6373
|
}
|
|
6240
6374
|
};
|
|
@@ -6267,7 +6401,7 @@ var init_image_builds = __esm({
|
|
|
6267
6401
|
} catch (error) {
|
|
6268
6402
|
throw toImageBuildError(error);
|
|
6269
6403
|
}
|
|
6270
|
-
this.#info = parseBuildInfo(
|
|
6404
|
+
this.#info = parseBuildInfo(json);
|
|
6271
6405
|
return this.#info;
|
|
6272
6406
|
}
|
|
6273
6407
|
/**
|
|
@@ -6288,8 +6422,12 @@ var init_image_builds = __esm({
|
|
|
6288
6422
|
)
|
|
6289
6423
|
);
|
|
6290
6424
|
emitter.rethrow();
|
|
6291
|
-
const
|
|
6292
|
-
|
|
6425
|
+
const raw = decodeResponse(json);
|
|
6426
|
+
const result = camelizeRecord(raw);
|
|
6427
|
+
this.#info = withRaw(
|
|
6428
|
+
{ ...this.#info, status: "succeeded" /* SUCCEEDED */, result },
|
|
6429
|
+
{ ...this.#info.raw, status: "succeeded", result: raw }
|
|
6430
|
+
);
|
|
6293
6431
|
return result;
|
|
6294
6432
|
}
|
|
6295
6433
|
/** Cancel this build by its id (the sufficient selector). */
|
|
@@ -6352,16 +6490,58 @@ function defaultRegisteredName(dockerfilePath) {
|
|
|
6352
6490
|
const parsed = import_node_path3.default.parse(dockerfilePath);
|
|
6353
6491
|
if (parsed.name.toLowerCase() === "dockerfile") {
|
|
6354
6492
|
const parentName = import_node_path3.default.basename(import_node_path3.default.dirname(dockerfilePath)).trim();
|
|
6355
|
-
return parentName ||
|
|
6493
|
+
return parentName || DEFAULT_SANDBOX_IMAGE_NAME;
|
|
6494
|
+
}
|
|
6495
|
+
return parsed.name || DEFAULT_SANDBOX_IMAGE_NAME;
|
|
6496
|
+
}
|
|
6497
|
+
function registeredImageName(explicit, generated, cas, fallback = DEFAULT_SANDBOX_IMAGE_NAME) {
|
|
6498
|
+
if (explicit || generated === void 0) {
|
|
6499
|
+
const name = explicit ?? "";
|
|
6500
|
+
return cas ? canonicalCasImageName(name) : name;
|
|
6356
6501
|
}
|
|
6357
|
-
return
|
|
6502
|
+
return cas ? casImageNameFrom(generated, fallback) : generated;
|
|
6503
|
+
}
|
|
6504
|
+
function canonicalCasImageName(name) {
|
|
6505
|
+
return name.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
6506
|
+
}
|
|
6507
|
+
function casImageNameFrom(raw, fallback) {
|
|
6508
|
+
const lowered = canonicalCasImageName(raw);
|
|
6509
|
+
if (isAddressableCasImageName(lowered)) {
|
|
6510
|
+
return lowered;
|
|
6511
|
+
}
|
|
6512
|
+
let name = "";
|
|
6513
|
+
for (const original of lowered) {
|
|
6514
|
+
const ch = /^[a-z0-9._-]$/.test(original) ? original : "-";
|
|
6515
|
+
const previous = name[name.length - 1];
|
|
6516
|
+
if (CAS_NAME_SEPARATORS.includes(ch) && previous !== void 0 && CAS_NAME_SEPARATORS.includes(previous)) {
|
|
6517
|
+
continue;
|
|
6518
|
+
}
|
|
6519
|
+
name += ch;
|
|
6520
|
+
}
|
|
6521
|
+
name = name.replace(/^[._-]+|[._-]+$/g, "").slice(0, MAX_CAS_IMAGE_NAME_LENGTH).replace(/[._-]+$/, "");
|
|
6522
|
+
return isAddressableCasImageName(name) ? name : fallback;
|
|
6523
|
+
}
|
|
6524
|
+
function isAddressableCasImageName(name) {
|
|
6525
|
+
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)) {
|
|
6526
|
+
return false;
|
|
6527
|
+
}
|
|
6528
|
+
const colon = name.indexOf(":");
|
|
6529
|
+
const repository = colon === -1 ? name : name.slice(0, colon);
|
|
6530
|
+
if (!repository.split("/").every((component) => /^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(component))) {
|
|
6531
|
+
return false;
|
|
6532
|
+
}
|
|
6533
|
+
if (colon === -1) {
|
|
6534
|
+
return true;
|
|
6535
|
+
}
|
|
6536
|
+
const tag = name.slice(colon + 1);
|
|
6537
|
+
return tag.length > 0 && tag.length <= 128 && /^[a-z0-9._-]+$/.test(tag) && !tag.startsWith(".") && !tag.startsWith("-");
|
|
6358
6538
|
}
|
|
6359
6539
|
function defaultRegisteredNameFromImage(imageReference) {
|
|
6360
6540
|
const withoutDigest = imageReference.split("@", 1)[0] ?? imageReference;
|
|
6361
6541
|
const lastSegment = withoutDigest.split("/").pop() ?? withoutDigest;
|
|
6362
6542
|
const colonIndex = lastSegment.lastIndexOf(":");
|
|
6363
6543
|
const name = colonIndex > 0 && colonIndex < lastSegment.length - 1 ? lastSegment.slice(0, colonIndex) : lastSegment;
|
|
6364
|
-
return name ||
|
|
6544
|
+
return name || DEFAULT_IMPORTED_IMAGE_NAME;
|
|
6365
6545
|
}
|
|
6366
6546
|
function noopEmit(_event) {
|
|
6367
6547
|
}
|
|
@@ -6464,7 +6644,11 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
6464
6644
|
if (!text.endsWith("\n")) text += "\n";
|
|
6465
6645
|
dockerfileText = text;
|
|
6466
6646
|
nativeContextDir = resolvedContext;
|
|
6467
|
-
effectiveName =
|
|
6647
|
+
effectiveName = registeredImageName(
|
|
6648
|
+
options.registeredName ?? source.name,
|
|
6649
|
+
void 0,
|
|
6650
|
+
options.cas ?? true
|
|
6651
|
+
);
|
|
6468
6652
|
} else if (typeof source === "string") {
|
|
6469
6653
|
const resolvedPath = import_node_path3.default.resolve(source);
|
|
6470
6654
|
if (!(0, import_node_fs2.existsSync)(resolvedPath)) {
|
|
@@ -6473,7 +6657,11 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
6473
6657
|
dockerfilePath = resolvedPath;
|
|
6474
6658
|
dockerfileText = void 0;
|
|
6475
6659
|
nativeContextDir = void 0;
|
|
6476
|
-
effectiveName =
|
|
6660
|
+
effectiveName = registeredImageName(
|
|
6661
|
+
options.registeredName,
|
|
6662
|
+
defaultRegisteredName(resolvedPath),
|
|
6663
|
+
options.cas ?? true
|
|
6664
|
+
);
|
|
6477
6665
|
} else {
|
|
6478
6666
|
throw new TypeError(
|
|
6479
6667
|
`source must be an Image or a Dockerfile path, got ${typeof source}`
|
|
@@ -6497,12 +6685,16 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
6497
6685
|
deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
|
|
6498
6686
|
);
|
|
6499
6687
|
}
|
|
6500
|
-
|
|
6688
|
+
const cas = options.cas ?? true;
|
|
6689
|
+
if (options.signal !== void 0 && !cas) {
|
|
6501
6690
|
throw new Error(
|
|
6502
|
-
"signal is
|
|
6691
|
+
"signal is not supported for legacy image builds (cas: false): a legacy image build has no build operation to cancel"
|
|
6503
6692
|
);
|
|
6504
6693
|
}
|
|
6505
|
-
emit({
|
|
6694
|
+
emit({
|
|
6695
|
+
type: "status",
|
|
6696
|
+
message: `Building ${cas ? "CAS" : "legacy"} image '${effectiveName}'...`
|
|
6697
|
+
});
|
|
6506
6698
|
const binding = loadNativeBinding();
|
|
6507
6699
|
let emitError;
|
|
6508
6700
|
const nativeOptions = {
|
|
@@ -6524,7 +6716,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
6524
6716
|
dockerConfigJson: options.dockerConfigJson,
|
|
6525
6717
|
dockerfileText,
|
|
6526
6718
|
contextDir: nativeContextDir,
|
|
6527
|
-
cas
|
|
6719
|
+
cas,
|
|
6528
6720
|
buildArgs: options.buildArgs
|
|
6529
6721
|
};
|
|
6530
6722
|
const forward = (event) => {
|
|
@@ -6534,7 +6726,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
|
|
|
6534
6726
|
emitError ??= error;
|
|
6535
6727
|
}
|
|
6536
6728
|
};
|
|
6537
|
-
const resultJson =
|
|
6729
|
+
const resultJson = cas ? await __runWithInterrupt(
|
|
6538
6730
|
options.signal,
|
|
6539
6731
|
(interruptId) => binding.buildSandboxImage(nativeOptions, forward, interruptId)
|
|
6540
6732
|
) : await binding.buildSandboxImage(nativeOptions, forward);
|
|
@@ -6565,7 +6757,12 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
6565
6757
|
}
|
|
6566
6758
|
const reference = imageReference.trim();
|
|
6567
6759
|
const context = buildContextFromEnv();
|
|
6568
|
-
const effectiveName =
|
|
6760
|
+
const effectiveName = registeredImageName(
|
|
6761
|
+
options.registeredName,
|
|
6762
|
+
defaultRegisteredNameFromImage(reference),
|
|
6763
|
+
options.cas ?? true,
|
|
6764
|
+
DEFAULT_IMPORTED_IMAGE_NAME
|
|
6765
|
+
);
|
|
6569
6766
|
if (effectiveName === DEFAULT_IMAGE_NAME2) {
|
|
6570
6767
|
console.warn(
|
|
6571
6768
|
`Importing sandbox image with the default name "${DEFAULT_IMAGE_NAME2}". Pass \`registeredName\` to avoid collisions with other default-named images in this project.`
|
|
@@ -6583,14 +6780,15 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
6583
6780
|
deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
|
|
6584
6781
|
);
|
|
6585
6782
|
}
|
|
6586
|
-
|
|
6783
|
+
const cas = options.cas ?? true;
|
|
6784
|
+
if (options.signal !== void 0 && !cas) {
|
|
6587
6785
|
throw new Error(
|
|
6588
|
-
"signal is
|
|
6786
|
+
"signal is not supported for legacy image imports (cas: false): a legacy image import has no build operation to cancel"
|
|
6589
6787
|
);
|
|
6590
6788
|
}
|
|
6591
6789
|
emit({
|
|
6592
6790
|
type: "status",
|
|
6593
|
-
message: `Importing
|
|
6791
|
+
message: `Importing '${reference}' as ${cas ? "CAS" : "legacy"} image '${effectiveName}'...`
|
|
6594
6792
|
});
|
|
6595
6793
|
const binding = loadNativeBinding();
|
|
6596
6794
|
let emitError;
|
|
@@ -6611,7 +6809,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
6611
6809
|
userAgent: void 0,
|
|
6612
6810
|
dockerCompat: options.dockerCompat ?? false,
|
|
6613
6811
|
dockerConfigJson: options.dockerConfigJson,
|
|
6614
|
-
cas
|
|
6812
|
+
cas
|
|
6615
6813
|
};
|
|
6616
6814
|
const forward = (event) => {
|
|
6617
6815
|
try {
|
|
@@ -6620,7 +6818,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
|
|
|
6620
6818
|
emitError ??= error;
|
|
6621
6819
|
}
|
|
6622
6820
|
};
|
|
6623
|
-
const resultJson =
|
|
6821
|
+
const resultJson = cas ? await __runWithInterrupt(
|
|
6624
6822
|
options.signal,
|
|
6625
6823
|
(interruptId) => binding.importSandboxImage(nativeOptions, forward, interruptId)
|
|
6626
6824
|
) : await binding.importSandboxImage(nativeOptions, forward);
|
|
@@ -6677,15 +6875,29 @@ async function deleteSandboxImage(imageName) {
|
|
|
6677
6875
|
if (typeof imageName !== "string" || imageName.length === 0) {
|
|
6678
6876
|
throw new TypeError("imageName must be a non-empty string");
|
|
6679
6877
|
}
|
|
6680
|
-
|
|
6878
|
+
warnIncompleteLegacyCleanup(
|
|
6879
|
+
await loadNativeBinding().deleteSandboxImage(catalogOptionsFromEnv(), imageName)
|
|
6880
|
+
);
|
|
6681
6881
|
}
|
|
6682
6882
|
async function deleteSandboxImageWithCredentials(credentials, imageName) {
|
|
6683
6883
|
if (typeof imageName !== "string" || imageName.length === 0) {
|
|
6684
6884
|
throw new TypeError("imageName must be a non-empty string");
|
|
6685
6885
|
}
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6886
|
+
warnIncompleteLegacyCleanup(
|
|
6887
|
+
await loadNativeBinding().deleteSandboxImage(
|
|
6888
|
+
catalogOptionsFromCredentials(credentials),
|
|
6889
|
+
imageName
|
|
6890
|
+
)
|
|
6891
|
+
);
|
|
6892
|
+
}
|
|
6893
|
+
function warnIncompleteLegacyCleanup(failure) {
|
|
6894
|
+
if (failure == null) {
|
|
6895
|
+
return;
|
|
6896
|
+
}
|
|
6897
|
+
const legacyImageId = failure.legacyImageId ?? void 0;
|
|
6898
|
+
const label = legacyImageId ? ` (${legacyImageId})` : "";
|
|
6899
|
+
console.warn(
|
|
6900
|
+
`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}").`
|
|
6689
6901
|
);
|
|
6690
6902
|
}
|
|
6691
6903
|
async function findSandboxImageByName(imageName) {
|
|
@@ -6729,13 +6941,14 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
6729
6941
|
disk_mb: { type: "string" },
|
|
6730
6942
|
builder_disk_mb: { type: "string" },
|
|
6731
6943
|
docker_compat: { type: "boolean", default: false },
|
|
6732
|
-
public: { type: "boolean", default: false }
|
|
6944
|
+
public: { type: "boolean", default: false },
|
|
6945
|
+
"no-cas": { type: "boolean", default: false }
|
|
6733
6946
|
}
|
|
6734
6947
|
});
|
|
6735
6948
|
const dockerfilePath = parsed.positionals[0];
|
|
6736
6949
|
if (!dockerfilePath) {
|
|
6737
6950
|
throw new Error(
|
|
6738
|
-
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
6951
|
+
"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]"
|
|
6739
6952
|
);
|
|
6740
6953
|
}
|
|
6741
6954
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -6767,7 +6980,8 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
6767
6980
|
diskMb,
|
|
6768
6981
|
builderDiskMb,
|
|
6769
6982
|
dockerCompat: parsed.values.docker_compat,
|
|
6770
|
-
isPublic: parsed.values.public
|
|
6983
|
+
isPublic: parsed.values.public,
|
|
6984
|
+
cas: !parsed.values["no-cas"]
|
|
6771
6985
|
},
|
|
6772
6986
|
{ emit: ndjsonStdoutEmit, _allowPat: true }
|
|
6773
6987
|
);
|
|
@@ -6783,13 +6997,14 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
6783
6997
|
disk_mb: { type: "string" },
|
|
6784
6998
|
builder_disk_mb: { type: "string" },
|
|
6785
6999
|
docker_compat: { type: "boolean", default: false },
|
|
6786
|
-
public: { type: "boolean", default: false }
|
|
7000
|
+
public: { type: "boolean", default: false },
|
|
7001
|
+
"no-cas": { type: "boolean", default: false }
|
|
6787
7002
|
}
|
|
6788
7003
|
});
|
|
6789
7004
|
const imageReference = parsed.positionals[0];
|
|
6790
7005
|
if (!imageReference) {
|
|
6791
7006
|
throw new Error(
|
|
6792
|
-
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
7007
|
+
"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]"
|
|
6793
7008
|
);
|
|
6794
7009
|
}
|
|
6795
7010
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -6821,12 +7036,13 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
6821
7036
|
diskMb,
|
|
6822
7037
|
builderDiskMb,
|
|
6823
7038
|
dockerCompat: parsed.values.docker_compat,
|
|
6824
|
-
isPublic: parsed.values.public
|
|
7039
|
+
isPublic: parsed.values.public,
|
|
7040
|
+
cas: !parsed.values["no-cas"]
|
|
6825
7041
|
},
|
|
6826
7042
|
{ emit: ndjsonStdoutEmit, _allowPat: true }
|
|
6827
7043
|
);
|
|
6828
7044
|
}
|
|
6829
|
-
var import_node_path3, import_node_os2, import_node_fs2, import_node_util, cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2, __imageBuildInternals;
|
|
7045
|
+
var import_node_path3, import_node_os2, import_node_fs2, import_node_util, 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;
|
|
6830
7046
|
var init_sandbox_image = __esm({
|
|
6831
7047
|
"src/sandbox-image.ts"() {
|
|
6832
7048
|
"use strict";
|
|
@@ -6839,6 +7055,11 @@ var init_sandbox_image = __esm({
|
|
|
6839
7055
|
init_native_binding();
|
|
6840
7056
|
init_image_builds();
|
|
6841
7057
|
DEFAULT_IMAGE_NAME2 = "default";
|
|
7058
|
+
DEFAULT_SANDBOX_IMAGE_NAME = "sandbox-image";
|
|
7059
|
+
DEFAULT_IMPORTED_IMAGE_NAME = "imported-image";
|
|
7060
|
+
CAS_NAME_SEPARATORS = "._-";
|
|
7061
|
+
RESERVED_IMAGE_NAME_PREFIXES = ["sandbox_template_", "image_", "cas-v1:"];
|
|
7062
|
+
MAX_CAS_IMAGE_NAME_LENGTH = 255;
|
|
6842
7063
|
__imageBuildInternals = {
|
|
6843
7064
|
loadNativeBinding: () => loadNativeBinding(),
|
|
6844
7065
|
buildContextFromEnv: () => buildContextFromEnv(),
|
|
@@ -6847,7 +7068,12 @@ var init_sandbox_image = __esm({
|
|
|
6847
7068
|
eventToEmitDict: (event) => eventToEmitDict(event),
|
|
6848
7069
|
imageRequiresContext: (image) => imageRequiresContext(image),
|
|
6849
7070
|
defaultRegisteredName: (dockerfilePath) => defaultRegisteredName(dockerfilePath),
|
|
6850
|
-
defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference)
|
|
7071
|
+
defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference),
|
|
7072
|
+
registeredImageName: (explicit, generated, cas, fallback) => registeredImageName(explicit, generated, cas, fallback),
|
|
7073
|
+
casImageNameFrom: (raw, fallback) => casImageNameFrom(raw, fallback),
|
|
7074
|
+
canonicalCasImageName: (name) => canonicalCasImageName(name),
|
|
7075
|
+
isAddressableCasImageName: (name) => isAddressableCasImageName(name),
|
|
7076
|
+
defaultImportedImageName: DEFAULT_IMPORTED_IMAGE_NAME
|
|
6851
7077
|
};
|
|
6852
7078
|
}
|
|
6853
7079
|
});
|
|
@@ -6873,14 +7099,19 @@ __export(index_exports, {
|
|
|
6873
7099
|
Headers: () => Headers,
|
|
6874
7100
|
HttpBody: () => HttpBody,
|
|
6875
7101
|
Image: () => Image,
|
|
7102
|
+
ImageBuildCancellationOutcome: () => ImageBuildCancellationOutcome,
|
|
6876
7103
|
ImageBuildCancelledError: () => ImageBuildCancelledError,
|
|
6877
7104
|
ImageBuildError: () => ImageBuildError,
|
|
7105
|
+
ImageBuildErrorCode: () => ImageBuildErrorCode,
|
|
6878
7106
|
ImageBuildFailedError: () => ImageBuildFailedError,
|
|
6879
7107
|
ImageBuildHandle: () => ImageBuildHandle,
|
|
6880
7108
|
ImageBuildInProgressError: () => ImageBuildInProgressError,
|
|
6881
7109
|
ImageBuildInterruptedError: () => ImageBuildInterruptedError,
|
|
7110
|
+
ImageBuildKind: () => ImageBuildKind,
|
|
6882
7111
|
ImageBuildNotFoundError: () => ImageBuildNotFoundError,
|
|
6883
7112
|
ImageBuildOperationType: () => ImageBuildOperationType,
|
|
7113
|
+
ImageBuildPhase: () => ImageBuildPhase,
|
|
7114
|
+
ImageBuildStatus: () => ImageBuildStatus,
|
|
6884
7115
|
ImageBuildTimeoutError: () => ImageBuildTimeoutError,
|
|
6885
7116
|
MountError: () => MountError,
|
|
6886
7117
|
OutputMode: () => OutputMode,
|
|
@@ -7100,10 +7331,12 @@ var CloudClient = class _CloudClient {
|
|
|
7100
7331
|
);
|
|
7101
7332
|
}
|
|
7102
7333
|
/**
|
|
7103
|
-
* Delete a registered sandbox image by name or id through the
|
|
7104
|
-
* catalog, with this client's credentials: an `image_` id or a name
|
|
7105
|
-
*
|
|
7106
|
-
* name registered only in the
|
|
7334
|
+
* Delete a registered CAS or legacy sandbox image by name or id through the
|
|
7335
|
+
* merged catalog, with this client's credentials: an `image_` id or a name
|
|
7336
|
+
* the CAS image registry knows deletes a CAS image, a `sandbox_template_` id
|
|
7337
|
+
* or a name registered only in the legacy image registry deletes a legacy
|
|
7338
|
+
* image.
|
|
7339
|
+
* A name is deleted from both the CAS and the legacy image registries.
|
|
7107
7340
|
* Rejects when neither catalog knows the reference. The same semantics
|
|
7108
7341
|
* and accepted differences as the module-level `deleteSandboxImage`.
|
|
7109
7342
|
*/
|
|
@@ -7111,10 +7344,10 @@ var CloudClient = class _CloudClient {
|
|
|
7111
7344
|
await deleteSandboxImageWithCredentials(this.catalogCredentials(), imageName);
|
|
7112
7345
|
}
|
|
7113
7346
|
/**
|
|
7114
|
-
* Look up a registered sandbox image by name or id through
|
|
7115
|
-
* catalog, with this client's credentials. Returns the image in
|
|
7116
|
-
* sandbox-template shape, or `null` when neither the
|
|
7117
|
-
*
|
|
7347
|
+
* Look up a registered CAS or legacy sandbox image by name or id through
|
|
7348
|
+
* the merged catalog, with this client's credentials. Returns the image in
|
|
7349
|
+
* the sandbox-template shape, or `null` when neither the CAS nor the legacy
|
|
7350
|
+
* image registry knows the reference. An explicit organization/project
|
|
7118
7351
|
* scope (the client's, or the call's override) addresses that project's
|
|
7119
7352
|
* routes directly, as before; without one the key's own scope applies.
|
|
7120
7353
|
*/
|
|
@@ -10503,14 +10736,19 @@ init_models();
|
|
|
10503
10736
|
Headers,
|
|
10504
10737
|
HttpBody,
|
|
10505
10738
|
Image,
|
|
10739
|
+
ImageBuildCancellationOutcome,
|
|
10506
10740
|
ImageBuildCancelledError,
|
|
10507
10741
|
ImageBuildError,
|
|
10742
|
+
ImageBuildErrorCode,
|
|
10508
10743
|
ImageBuildFailedError,
|
|
10509
10744
|
ImageBuildHandle,
|
|
10510
10745
|
ImageBuildInProgressError,
|
|
10511
10746
|
ImageBuildInterruptedError,
|
|
10747
|
+
ImageBuildKind,
|
|
10512
10748
|
ImageBuildNotFoundError,
|
|
10513
10749
|
ImageBuildOperationType,
|
|
10750
|
+
ImageBuildPhase,
|
|
10751
|
+
ImageBuildStatus,
|
|
10514
10752
|
ImageBuildTimeoutError,
|
|
10515
10753
|
MountError,
|
|
10516
10754
|
OutputMode,
|