@tensorlakeai/tensorlake 0.5.153 → 0.5.154
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 +131 -33
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.js +131 -33
- 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 +195 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -15
- package/dist/index.d.ts +70 -15
- package/dist/index.js +190 -61
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +129 -31
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +129 -31
- 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.cjs
CHANGED
|
@@ -314,7 +314,24 @@ var init_native_binding = __esm({
|
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
+
// src/enum.ts
|
|
318
|
+
function enumValue(values, value) {
|
|
319
|
+
return typeof value === "string" && Object.values(values).includes(value) ? value : values.UNKNOWN;
|
|
320
|
+
}
|
|
321
|
+
function withRaw(value, raw) {
|
|
322
|
+
return Object.defineProperty(value, "raw", { value: raw, enumerable: false, configurable: true });
|
|
323
|
+
}
|
|
324
|
+
var init_enum = __esm({
|
|
325
|
+
"src/enum.ts"() {
|
|
326
|
+
"use strict";
|
|
327
|
+
init_cjs_shims();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
317
331
|
// src/image-builds.ts
|
|
332
|
+
function isConfirmedCancellation(outcome) {
|
|
333
|
+
return outcome === "cancelled" /* CANCELLED */ || outcome === "already_cancelled" /* ALREADY_CANCELLED */ || outcome === "already_failed" /* ALREADY_FAILED */;
|
|
334
|
+
}
|
|
318
335
|
function camelize(key) {
|
|
319
336
|
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
320
337
|
}
|
|
@@ -332,48 +349,73 @@ function toImageBuildError(error) {
|
|
|
332
349
|
if (key === "category") continue;
|
|
333
350
|
details[camelize(key)] = value;
|
|
334
351
|
}
|
|
352
|
+
details.code = enumValue(ImageBuildErrorCode, details.code || "internal" /* INTERNAL */);
|
|
353
|
+
if ("activeKind" in details) details.activeKind = details.activeKind ? enumValue(ImageBuildKind, details.activeKind) : null;
|
|
354
|
+
if ("activeStatus" in details) details.activeStatus = details.activeStatus ? enumValue(ImageBuildStatus, details.activeStatus) : null;
|
|
355
|
+
if ("outcome" in details) details.outcome = details.outcome ? enumValue(ImageBuildCancellationOutcome, details.outcome) : null;
|
|
356
|
+
if ("info" in details) details.info = buildInfoOrNull(details.info);
|
|
335
357
|
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
|
-
}
|
|
358
|
+
const errors = {
|
|
359
|
+
not_found: ImageBuildNotFoundError,
|
|
360
|
+
image_build_in_progress: ImageBuildInProgressError,
|
|
361
|
+
failed: ImageBuildFailedError,
|
|
362
|
+
cancelled: ImageBuildCancelledError,
|
|
363
|
+
timeout: ImageBuildTimeoutError,
|
|
364
|
+
interrupted: ImageBuildInterruptedError
|
|
365
|
+
};
|
|
366
|
+
const ErrorClass = errors[typed.code] ?? ImageBuildError;
|
|
367
|
+
return withRaw(new ErrorClass(typed), payload);
|
|
352
368
|
}
|
|
353
369
|
function camelizeRecord(value) {
|
|
354
370
|
const out = {};
|
|
355
371
|
for (const [key, inner] of Object.entries(value)) out[camelize(key)] = inner;
|
|
356
372
|
return out;
|
|
357
373
|
}
|
|
358
|
-
function
|
|
374
|
+
function buildInfoOrNull(value) {
|
|
375
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
376
|
+
try {
|
|
377
|
+
return parseBuildInfo(value);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
if (error instanceof ImageBuildError) return null;
|
|
380
|
+
throw error;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function decodeResponse(value) {
|
|
384
|
+
try {
|
|
385
|
+
const raw = typeof value === "string" ? JSON.parse(value) : value;
|
|
386
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new TypeError("expected a response object");
|
|
387
|
+
return raw;
|
|
388
|
+
} catch (error) {
|
|
389
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: `Invalid image-build response: ${String(error)}` }), { response: value });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function parseBuildInfo(value) {
|
|
393
|
+
const raw = decodeResponse(value);
|
|
394
|
+
if (raw.status == null) {
|
|
395
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build response: missing status" }), { response: value });
|
|
396
|
+
}
|
|
397
|
+
const attempt = raw.attempt_no ?? 0;
|
|
398
|
+
const attemptNo = Number(attempt);
|
|
399
|
+
if (typeof attempt !== "number" && typeof attempt !== "string" || typeof attempt === "string" && attempt.trim() === "" || !Number.isSafeInteger(attemptNo)) {
|
|
400
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build attempt_no" }), { response: value });
|
|
401
|
+
}
|
|
359
402
|
const camel = camelizeRecord(raw);
|
|
360
403
|
const result = raw.result && typeof raw.result === "object" ? camelizeRecord(raw.result) : null;
|
|
361
|
-
return {
|
|
404
|
+
return withRaw({
|
|
362
405
|
buildId: String(raw.build_id ?? ""),
|
|
363
406
|
clientRequestId: camel.clientRequestId ?? null,
|
|
364
|
-
kind:
|
|
407
|
+
kind: raw.kind ? enumValue(ImageBuildKind, raw.kind) : null,
|
|
365
408
|
name: raw.name ?? null,
|
|
366
|
-
status:
|
|
367
|
-
phase: raw.phase
|
|
368
|
-
attemptNo
|
|
409
|
+
status: enumValue(ImageBuildStatus, raw.status),
|
|
410
|
+
phase: raw.phase ? enumValue(ImageBuildPhase, raw.phase) : null,
|
|
411
|
+
attemptNo,
|
|
369
412
|
builderSandboxId: camel.builderSandboxId ?? null,
|
|
370
413
|
error: raw.error ?? null,
|
|
371
414
|
result,
|
|
372
415
|
operationDeadlineMs: camel.operationDeadlineMs ?? null,
|
|
373
416
|
createdAtMs: camel.createdAtMs ?? null,
|
|
374
|
-
updatedAtMs: camel.updatedAtMs ?? null
|
|
375
|
-
|
|
376
|
-
};
|
|
417
|
+
updatedAtMs: camel.updatedAtMs ?? null
|
|
418
|
+
}, raw);
|
|
377
419
|
}
|
|
378
420
|
async function __runWithInterrupt(signal, run) {
|
|
379
421
|
const binding = __imageBuildInternals.loadNativeBinding();
|
|
@@ -397,16 +439,68 @@ async function __runWithInterrupt(signal, run) {
|
|
|
397
439
|
binding.releaseImageBuildInterrupt(interruptId);
|
|
398
440
|
}
|
|
399
441
|
}
|
|
400
|
-
var import_node_path2, import_node_os, import_node_fs, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
442
|
+
var import_node_path2, import_node_os, import_node_fs, ImageBuildStatus, ImageBuildPhase, ImageBuildKind, ImageBuildCancellationOutcome, ImageBuildErrorCode, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
401
443
|
var init_image_builds = __esm({
|
|
402
444
|
"src/image-builds.ts"() {
|
|
403
445
|
"use strict";
|
|
404
446
|
init_cjs_shims();
|
|
405
447
|
import_node_path2 = __toESM(require("path"), 1);
|
|
448
|
+
init_enum();
|
|
406
449
|
import_node_os = __toESM(require("os"), 1);
|
|
407
450
|
import_node_fs = require("fs");
|
|
408
451
|
init_image();
|
|
409
452
|
init_sandbox_image();
|
|
453
|
+
ImageBuildStatus = /* @__PURE__ */ ((ImageBuildStatus2) => {
|
|
454
|
+
ImageBuildStatus2["PENDING"] = "pending";
|
|
455
|
+
ImageBuildStatus2["RUNNING"] = "running";
|
|
456
|
+
ImageBuildStatus2["SUCCEEDED"] = "succeeded";
|
|
457
|
+
ImageBuildStatus2["FAILED"] = "failed";
|
|
458
|
+
ImageBuildStatus2["CANCELLED"] = "cancelled";
|
|
459
|
+
ImageBuildStatus2["UNKNOWN"] = "unknown";
|
|
460
|
+
return ImageBuildStatus2;
|
|
461
|
+
})(ImageBuildStatus || {});
|
|
462
|
+
ImageBuildPhase = /* @__PURE__ */ ((ImageBuildPhase2) => {
|
|
463
|
+
ImageBuildPhase2["AWAITING_CONTEXT"] = "awaiting_context";
|
|
464
|
+
ImageBuildPhase2["STARTING_BUILDER"] = "starting_builder";
|
|
465
|
+
ImageBuildPhase2["EXECUTING"] = "executing";
|
|
466
|
+
ImageBuildPhase2["SNAPSHOTTING"] = "snapshotting";
|
|
467
|
+
ImageBuildPhase2["PUBLISHING"] = "publishing";
|
|
468
|
+
ImageBuildPhase2["FINISHED"] = "finished";
|
|
469
|
+
ImageBuildPhase2["UNKNOWN"] = "unknown";
|
|
470
|
+
return ImageBuildPhase2;
|
|
471
|
+
})(ImageBuildPhase || {});
|
|
472
|
+
ImageBuildKind = /* @__PURE__ */ ((ImageBuildKind2) => {
|
|
473
|
+
ImageBuildKind2["DOCKERFILE"] = "dockerfile";
|
|
474
|
+
ImageBuildKind2["IMPORT"] = "import";
|
|
475
|
+
ImageBuildKind2["DIRECT"] = "direct";
|
|
476
|
+
ImageBuildKind2["UNKNOWN"] = "unknown";
|
|
477
|
+
return ImageBuildKind2;
|
|
478
|
+
})(ImageBuildKind || {});
|
|
479
|
+
ImageBuildCancellationOutcome = /* @__PURE__ */ ((ImageBuildCancellationOutcome2) => {
|
|
480
|
+
ImageBuildCancellationOutcome2["CANCELLED"] = "cancelled";
|
|
481
|
+
ImageBuildCancellationOutcome2["ALREADY_CANCELLED"] = "already_cancelled";
|
|
482
|
+
ImageBuildCancellationOutcome2["ALREADY_COMPLETED"] = "already_completed";
|
|
483
|
+
ImageBuildCancellationOutcome2["ALREADY_FAILED"] = "already_failed";
|
|
484
|
+
ImageBuildCancellationOutcome2["NOT_ADMITTED"] = "not_admitted";
|
|
485
|
+
ImageBuildCancellationOutcome2["UNCONFIRMED"] = "unconfirmed";
|
|
486
|
+
ImageBuildCancellationOutcome2["UNKNOWN"] = "unknown";
|
|
487
|
+
return ImageBuildCancellationOutcome2;
|
|
488
|
+
})(ImageBuildCancellationOutcome || {});
|
|
489
|
+
ImageBuildErrorCode = /* @__PURE__ */ ((ImageBuildErrorCode2) => {
|
|
490
|
+
ImageBuildErrorCode2["USAGE"] = "usage";
|
|
491
|
+
ImageBuildErrorCode2["AUTH"] = "auth";
|
|
492
|
+
ImageBuildErrorCode2["NOT_FOUND"] = "not_found";
|
|
493
|
+
ImageBuildErrorCode2["IMAGE_BUILD_IN_PROGRESS"] = "image_build_in_progress";
|
|
494
|
+
ImageBuildErrorCode2["CLIENT_REQUEST_ID_MISMATCH"] = "client_request_id_mismatch";
|
|
495
|
+
ImageBuildErrorCode2["FAILED"] = "failed";
|
|
496
|
+
ImageBuildErrorCode2["CANCELLED"] = "cancelled";
|
|
497
|
+
ImageBuildErrorCode2["TIMEOUT"] = "timeout";
|
|
498
|
+
ImageBuildErrorCode2["INTERRUPTED"] = "interrupted";
|
|
499
|
+
ImageBuildErrorCode2["SERVICE"] = "service";
|
|
500
|
+
ImageBuildErrorCode2["INTERNAL"] = "internal";
|
|
501
|
+
ImageBuildErrorCode2["UNKNOWN"] = "unknown";
|
|
502
|
+
return ImageBuildErrorCode2;
|
|
503
|
+
})(ImageBuildErrorCode || {});
|
|
410
504
|
ImageBuildError = class extends Error {
|
|
411
505
|
code;
|
|
412
506
|
buildId;
|
|
@@ -416,7 +510,11 @@ var init_image_builds = __esm({
|
|
|
416
510
|
super(details.message);
|
|
417
511
|
this.name = "ImageBuildError";
|
|
418
512
|
this.code = details.code;
|
|
419
|
-
this.details = details;
|
|
513
|
+
this.details = { ...details };
|
|
514
|
+
withRaw(this, {});
|
|
515
|
+
if ("confirmed" in details) {
|
|
516
|
+
this.details.confirmed = details.confirmed === true && isConfirmedCancellation(details.outcome);
|
|
517
|
+
}
|
|
420
518
|
if (details.buildId) this.buildId = details.buildId;
|
|
421
519
|
if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
|
|
422
520
|
}
|
|
@@ -448,7 +546,7 @@ var init_image_builds = __esm({
|
|
|
448
546
|
super(details);
|
|
449
547
|
this.name = "ImageBuildFailedError";
|
|
450
548
|
this.error = details.error ?? "no error recorded";
|
|
451
|
-
if (details.info) this.info =
|
|
549
|
+
if (details.info) this.info = details.info;
|
|
452
550
|
}
|
|
453
551
|
};
|
|
454
552
|
ImageBuildCancelledError = class extends ImageBuildError {
|
|
@@ -456,7 +554,7 @@ var init_image_builds = __esm({
|
|
|
456
554
|
constructor(details) {
|
|
457
555
|
super(details);
|
|
458
556
|
this.name = "ImageBuildCancelledError";
|
|
459
|
-
if (details.info) this.info =
|
|
557
|
+
if (details.info) this.info = details.info;
|
|
460
558
|
}
|
|
461
559
|
};
|
|
462
560
|
ImageBuildTimeoutError = class extends ImageBuildError {
|
|
@@ -472,8 +570,8 @@ var init_image_builds = __esm({
|
|
|
472
570
|
constructor(details) {
|
|
473
571
|
super(details);
|
|
474
572
|
this.name = "ImageBuildInterruptedError";
|
|
475
|
-
this.outcome = details.outcome ?? "unconfirmed"
|
|
476
|
-
this.confirmed = details.confirmed === true;
|
|
573
|
+
this.outcome = details.outcome ?? "unconfirmed" /* UNCONFIRMED */;
|
|
574
|
+
this.confirmed = this.details.confirmed === true;
|
|
477
575
|
if (details.result) this.result = details.result;
|
|
478
576
|
}
|
|
479
577
|
};
|