@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.js
CHANGED
|
@@ -311,10 +311,27 @@ var init_native_binding = __esm({
|
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
|
|
314
|
+
// src/enum.ts
|
|
315
|
+
function enumValue(values, value) {
|
|
316
|
+
return typeof value === "string" && Object.values(values).includes(value) ? value : values.UNKNOWN;
|
|
317
|
+
}
|
|
318
|
+
function withRaw(value, raw) {
|
|
319
|
+
return Object.defineProperty(value, "raw", { value: raw, enumerable: false, configurable: true });
|
|
320
|
+
}
|
|
321
|
+
var init_enum = __esm({
|
|
322
|
+
"src/enum.ts"() {
|
|
323
|
+
"use strict";
|
|
324
|
+
init_esm_shims();
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
314
328
|
// src/image-builds.ts
|
|
315
329
|
import path3 from "path";
|
|
316
330
|
import os from "os";
|
|
317
331
|
import { existsSync as existsSync2, mkdtempSync, rmSync } from "fs";
|
|
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,13 +439,65 @@ async function __runWithInterrupt(signal, run) {
|
|
|
397
439
|
binding.releaseImageBuildInterrupt(interruptId);
|
|
398
440
|
}
|
|
399
441
|
}
|
|
400
|
-
var ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
442
|
+
var 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_esm_shims();
|
|
447
|
+
init_enum();
|
|
405
448
|
init_image();
|
|
406
449
|
init_sandbox_image();
|
|
450
|
+
ImageBuildStatus = /* @__PURE__ */ ((ImageBuildStatus2) => {
|
|
451
|
+
ImageBuildStatus2["PENDING"] = "pending";
|
|
452
|
+
ImageBuildStatus2["RUNNING"] = "running";
|
|
453
|
+
ImageBuildStatus2["SUCCEEDED"] = "succeeded";
|
|
454
|
+
ImageBuildStatus2["FAILED"] = "failed";
|
|
455
|
+
ImageBuildStatus2["CANCELLED"] = "cancelled";
|
|
456
|
+
ImageBuildStatus2["UNKNOWN"] = "unknown";
|
|
457
|
+
return ImageBuildStatus2;
|
|
458
|
+
})(ImageBuildStatus || {});
|
|
459
|
+
ImageBuildPhase = /* @__PURE__ */ ((ImageBuildPhase2) => {
|
|
460
|
+
ImageBuildPhase2["AWAITING_CONTEXT"] = "awaiting_context";
|
|
461
|
+
ImageBuildPhase2["STARTING_BUILDER"] = "starting_builder";
|
|
462
|
+
ImageBuildPhase2["EXECUTING"] = "executing";
|
|
463
|
+
ImageBuildPhase2["SNAPSHOTTING"] = "snapshotting";
|
|
464
|
+
ImageBuildPhase2["PUBLISHING"] = "publishing";
|
|
465
|
+
ImageBuildPhase2["FINISHED"] = "finished";
|
|
466
|
+
ImageBuildPhase2["UNKNOWN"] = "unknown";
|
|
467
|
+
return ImageBuildPhase2;
|
|
468
|
+
})(ImageBuildPhase || {});
|
|
469
|
+
ImageBuildKind = /* @__PURE__ */ ((ImageBuildKind2) => {
|
|
470
|
+
ImageBuildKind2["DOCKERFILE"] = "dockerfile";
|
|
471
|
+
ImageBuildKind2["IMPORT"] = "import";
|
|
472
|
+
ImageBuildKind2["DIRECT"] = "direct";
|
|
473
|
+
ImageBuildKind2["UNKNOWN"] = "unknown";
|
|
474
|
+
return ImageBuildKind2;
|
|
475
|
+
})(ImageBuildKind || {});
|
|
476
|
+
ImageBuildCancellationOutcome = /* @__PURE__ */ ((ImageBuildCancellationOutcome2) => {
|
|
477
|
+
ImageBuildCancellationOutcome2["CANCELLED"] = "cancelled";
|
|
478
|
+
ImageBuildCancellationOutcome2["ALREADY_CANCELLED"] = "already_cancelled";
|
|
479
|
+
ImageBuildCancellationOutcome2["ALREADY_COMPLETED"] = "already_completed";
|
|
480
|
+
ImageBuildCancellationOutcome2["ALREADY_FAILED"] = "already_failed";
|
|
481
|
+
ImageBuildCancellationOutcome2["NOT_ADMITTED"] = "not_admitted";
|
|
482
|
+
ImageBuildCancellationOutcome2["UNCONFIRMED"] = "unconfirmed";
|
|
483
|
+
ImageBuildCancellationOutcome2["UNKNOWN"] = "unknown";
|
|
484
|
+
return ImageBuildCancellationOutcome2;
|
|
485
|
+
})(ImageBuildCancellationOutcome || {});
|
|
486
|
+
ImageBuildErrorCode = /* @__PURE__ */ ((ImageBuildErrorCode2) => {
|
|
487
|
+
ImageBuildErrorCode2["USAGE"] = "usage";
|
|
488
|
+
ImageBuildErrorCode2["AUTH"] = "auth";
|
|
489
|
+
ImageBuildErrorCode2["NOT_FOUND"] = "not_found";
|
|
490
|
+
ImageBuildErrorCode2["IMAGE_BUILD_IN_PROGRESS"] = "image_build_in_progress";
|
|
491
|
+
ImageBuildErrorCode2["CLIENT_REQUEST_ID_MISMATCH"] = "client_request_id_mismatch";
|
|
492
|
+
ImageBuildErrorCode2["FAILED"] = "failed";
|
|
493
|
+
ImageBuildErrorCode2["CANCELLED"] = "cancelled";
|
|
494
|
+
ImageBuildErrorCode2["TIMEOUT"] = "timeout";
|
|
495
|
+
ImageBuildErrorCode2["INTERRUPTED"] = "interrupted";
|
|
496
|
+
ImageBuildErrorCode2["SERVICE"] = "service";
|
|
497
|
+
ImageBuildErrorCode2["INTERNAL"] = "internal";
|
|
498
|
+
ImageBuildErrorCode2["UNKNOWN"] = "unknown";
|
|
499
|
+
return ImageBuildErrorCode2;
|
|
500
|
+
})(ImageBuildErrorCode || {});
|
|
407
501
|
ImageBuildError = class extends Error {
|
|
408
502
|
code;
|
|
409
503
|
buildId;
|
|
@@ -413,7 +507,11 @@ var init_image_builds = __esm({
|
|
|
413
507
|
super(details.message);
|
|
414
508
|
this.name = "ImageBuildError";
|
|
415
509
|
this.code = details.code;
|
|
416
|
-
this.details = details;
|
|
510
|
+
this.details = { ...details };
|
|
511
|
+
withRaw(this, {});
|
|
512
|
+
if ("confirmed" in details) {
|
|
513
|
+
this.details.confirmed = details.confirmed === true && isConfirmedCancellation(details.outcome);
|
|
514
|
+
}
|
|
417
515
|
if (details.buildId) this.buildId = details.buildId;
|
|
418
516
|
if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
|
|
419
517
|
}
|
|
@@ -445,7 +543,7 @@ var init_image_builds = __esm({
|
|
|
445
543
|
super(details);
|
|
446
544
|
this.name = "ImageBuildFailedError";
|
|
447
545
|
this.error = details.error ?? "no error recorded";
|
|
448
|
-
if (details.info) this.info =
|
|
546
|
+
if (details.info) this.info = details.info;
|
|
449
547
|
}
|
|
450
548
|
};
|
|
451
549
|
ImageBuildCancelledError = class extends ImageBuildError {
|
|
@@ -453,7 +551,7 @@ var init_image_builds = __esm({
|
|
|
453
551
|
constructor(details) {
|
|
454
552
|
super(details);
|
|
455
553
|
this.name = "ImageBuildCancelledError";
|
|
456
|
-
if (details.info) this.info =
|
|
554
|
+
if (details.info) this.info = details.info;
|
|
457
555
|
}
|
|
458
556
|
};
|
|
459
557
|
ImageBuildTimeoutError = class extends ImageBuildError {
|
|
@@ -469,8 +567,8 @@ var init_image_builds = __esm({
|
|
|
469
567
|
constructor(details) {
|
|
470
568
|
super(details);
|
|
471
569
|
this.name = "ImageBuildInterruptedError";
|
|
472
|
-
this.outcome = details.outcome ?? "unconfirmed"
|
|
473
|
-
this.confirmed = details.confirmed === true;
|
|
570
|
+
this.outcome = details.outcome ?? "unconfirmed" /* UNCONFIRMED */;
|
|
571
|
+
this.confirmed = this.details.confirmed === true;
|
|
474
572
|
if (details.result) this.result = details.result;
|
|
475
573
|
}
|
|
476
574
|
};
|