tensorlake 0.5.140 → 0.5.141
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 +80 -55
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.js +80 -55
- 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 +251 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -10
- package/dist/index.d.ts +77 -10
- package/dist/index.js +248 -131
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +80 -55
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +80 -55
- 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 +20 -20
- package/runtime/typescript-function-runner/package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ var init_defaults = __esm({
|
|
|
46
46
|
"src/defaults.ts"() {
|
|
47
47
|
"use strict";
|
|
48
48
|
init_esm_shims();
|
|
49
|
-
SDK_VERSION = "0.5.
|
|
49
|
+
SDK_VERSION = "0.5.141";
|
|
50
50
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
51
51
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
52
52
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -79,7 +79,7 @@ function formatErrorDetails(errorDetails) {
|
|
|
79
79
|
}
|
|
80
80
|
return String(errorDetails);
|
|
81
81
|
}
|
|
82
|
-
var SandboxException, SandboxError, SandboxPending, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError, RequestNotFinishedError, RequestFailedError, RequestExecutionError;
|
|
82
|
+
var SandboxException, SandboxError, SandboxResizeError, SandboxPending, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError, RequestNotFinishedError, RequestFailedError, RequestExecutionError;
|
|
83
83
|
var init_errors = __esm({
|
|
84
84
|
"src/errors.ts"() {
|
|
85
85
|
"use strict";
|
|
@@ -100,6 +100,25 @@ var init_errors = __esm({
|
|
|
100
100
|
if (options?.sandboxId !== void 0) this.sandboxId = options.sandboxId;
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
+
SandboxResizeError = class extends SandboxError {
|
|
104
|
+
generation;
|
|
105
|
+
info;
|
|
106
|
+
constructor(payload) {
|
|
107
|
+
const resources = payload.info?.resources;
|
|
108
|
+
const allocation = resources ? `${resources.cpus} CPUs, ${resources.memoryMb} MiB memory, ${resources.diskMb} MiB disk` : "unavailable";
|
|
109
|
+
super(
|
|
110
|
+
`Sandbox ${payload.sandboxId} resize generation ${payload.generation}: ${payload.message}; last confirmed allocation: ${allocation}`,
|
|
111
|
+
{ reason: payload.reason, sandboxId: payload.sandboxId }
|
|
112
|
+
);
|
|
113
|
+
this.name = "SandboxResizeError";
|
|
114
|
+
this.generation = payload.generation;
|
|
115
|
+
this.info = payload.info ?? void 0;
|
|
116
|
+
}
|
|
117
|
+
/** Last confirmed allocation, if an observation was available. */
|
|
118
|
+
get confirmedResources() {
|
|
119
|
+
return this.info?.resources;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
103
122
|
SandboxPending = class extends SandboxError {
|
|
104
123
|
pendingReason;
|
|
105
124
|
timeout;
|
|
@@ -471,12 +490,148 @@ var init_native_worker_client = __esm({
|
|
|
471
490
|
}
|
|
472
491
|
};
|
|
473
492
|
runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
474
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
493
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
|
|
475
494
|
);
|
|
476
495
|
runtimes = globalThis;
|
|
477
496
|
}
|
|
478
497
|
});
|
|
479
498
|
|
|
499
|
+
// src/models.ts
|
|
500
|
+
function isSandboxPending(status) {
|
|
501
|
+
return String(status) === "pending" /* PENDING */;
|
|
502
|
+
}
|
|
503
|
+
function camelToSnake(str) {
|
|
504
|
+
return str.replace(CAMEL_TO_SNAKE_RE, (ch) => "_" + ch.toLowerCase());
|
|
505
|
+
}
|
|
506
|
+
function snakeToCamel(str) {
|
|
507
|
+
return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
508
|
+
}
|
|
509
|
+
function toSnakeKeys(obj) {
|
|
510
|
+
if (Array.isArray(obj)) return obj.map(toSnakeKeys);
|
|
511
|
+
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
512
|
+
const result = {};
|
|
513
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
514
|
+
result[camelToSnake(k)] = toSnakeKeys(v);
|
|
515
|
+
}
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
518
|
+
return obj;
|
|
519
|
+
}
|
|
520
|
+
function parseTimestamp(v) {
|
|
521
|
+
if (v == null) return void 0;
|
|
522
|
+
if (v instanceof Date) return v;
|
|
523
|
+
if (typeof v === "string") {
|
|
524
|
+
const parsed = Date.parse(v);
|
|
525
|
+
return Number.isNaN(parsed) ? void 0 : new Date(parsed);
|
|
526
|
+
}
|
|
527
|
+
const ts = Number(v);
|
|
528
|
+
if (isNaN(ts)) return void 0;
|
|
529
|
+
if (ts > 1e15) return new Date(ts / 1e3);
|
|
530
|
+
if (ts > 1e12) return new Date(ts);
|
|
531
|
+
return new Date(ts * 1e3);
|
|
532
|
+
}
|
|
533
|
+
function fromSnakeKeys(obj, idField) {
|
|
534
|
+
if (Array.isArray(obj))
|
|
535
|
+
return obj.map((item) => fromSnakeKeys(item, idField));
|
|
536
|
+
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
537
|
+
const result = {};
|
|
538
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
539
|
+
let key;
|
|
540
|
+
if (k === "id" && idField) {
|
|
541
|
+
key = idField;
|
|
542
|
+
} else {
|
|
543
|
+
key = snakeToCamel(k);
|
|
544
|
+
}
|
|
545
|
+
if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
|
|
546
|
+
result[key] = parseTimestamp(v);
|
|
547
|
+
} else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
|
|
548
|
+
result[key] = fromSnakeKeys(v);
|
|
549
|
+
} else if (Array.isArray(v)) {
|
|
550
|
+
result[key] = v.map((item) => fromSnakeKeys(item));
|
|
551
|
+
} else {
|
|
552
|
+
result[key] = v === null ? void 0 : v;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
557
|
+
return obj;
|
|
558
|
+
}
|
|
559
|
+
var SandboxStatus, SandboxPendingReason, TERMINATION_REASON_NO_CAPACITY, TERMINATION_REASON_CANCELLED, SnapshotStatus, ProcessStatus, StdinMode, OutputMode, ContainerState, ResizeStatus, ResizeErrorReason, CAMEL_TO_SNAKE_RE;
|
|
560
|
+
var init_models = __esm({
|
|
561
|
+
"src/models.ts"() {
|
|
562
|
+
"use strict";
|
|
563
|
+
init_esm_shims();
|
|
564
|
+
SandboxStatus = /* @__PURE__ */ ((SandboxStatus2) => {
|
|
565
|
+
SandboxStatus2["PENDING"] = "pending";
|
|
566
|
+
SandboxStatus2["RUNNING"] = "running";
|
|
567
|
+
SandboxStatus2["SNAPSHOTTING"] = "snapshotting";
|
|
568
|
+
SandboxStatus2["SUSPENDING"] = "suspending";
|
|
569
|
+
SandboxStatus2["SUSPENDED"] = "suspended";
|
|
570
|
+
SandboxStatus2["TERMINATED"] = "terminated";
|
|
571
|
+
SandboxStatus2["TIMEOUT"] = "timeout";
|
|
572
|
+
SandboxStatus2["FAILED"] = "failed";
|
|
573
|
+
return SandboxStatus2;
|
|
574
|
+
})(SandboxStatus || {});
|
|
575
|
+
SandboxPendingReason = /* @__PURE__ */ ((SandboxPendingReason2) => {
|
|
576
|
+
SandboxPendingReason2["SCHEDULING"] = "scheduling";
|
|
577
|
+
SandboxPendingReason2["WAITING_FOR_CONTAINER"] = "waiting_for_container";
|
|
578
|
+
SandboxPendingReason2["NO_EXECUTORS_AVAILABLE"] = "no_executors_available";
|
|
579
|
+
SandboxPendingReason2["NO_RESOURCES_AVAILABLE"] = "no_resources_available";
|
|
580
|
+
SandboxPendingReason2["POOL_AT_CAPACITY"] = "pool_at_capacity";
|
|
581
|
+
SandboxPendingReason2["MAX_CAPACITY_REACHED"] = "max_capacity_reached";
|
|
582
|
+
SandboxPendingReason2["NO_EXECUTOR_FOR_SNAPSHOT_LOCATION"] = "no_executor_for_snapshot_location";
|
|
583
|
+
SandboxPendingReason2["UNPLACEABLE"] = "unplaceable";
|
|
584
|
+
return SandboxPendingReason2;
|
|
585
|
+
})(SandboxPendingReason || {});
|
|
586
|
+
TERMINATION_REASON_NO_CAPACITY = "no_capacity";
|
|
587
|
+
TERMINATION_REASON_CANCELLED = "cancelled";
|
|
588
|
+
SnapshotStatus = /* @__PURE__ */ ((SnapshotStatus2) => {
|
|
589
|
+
SnapshotStatus2["IN_PROGRESS"] = "in_progress";
|
|
590
|
+
SnapshotStatus2["LOCAL_READY"] = "local_ready";
|
|
591
|
+
SnapshotStatus2["COMPLETED"] = "completed";
|
|
592
|
+
SnapshotStatus2["FAILED"] = "failed";
|
|
593
|
+
return SnapshotStatus2;
|
|
594
|
+
})(SnapshotStatus || {});
|
|
595
|
+
ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
|
|
596
|
+
ProcessStatus2["RUNNING"] = "running";
|
|
597
|
+
ProcessStatus2["EXITED"] = "exited";
|
|
598
|
+
ProcessStatus2["SIGNALED"] = "signaled";
|
|
599
|
+
ProcessStatus2["OOM_KILLED"] = "oom_killed";
|
|
600
|
+
return ProcessStatus2;
|
|
601
|
+
})(ProcessStatus || {});
|
|
602
|
+
StdinMode = /* @__PURE__ */ ((StdinMode2) => {
|
|
603
|
+
StdinMode2["CLOSED"] = "closed";
|
|
604
|
+
StdinMode2["PIPE"] = "pipe";
|
|
605
|
+
return StdinMode2;
|
|
606
|
+
})(StdinMode || {});
|
|
607
|
+
OutputMode = /* @__PURE__ */ ((OutputMode2) => {
|
|
608
|
+
OutputMode2["CAPTURE"] = "capture";
|
|
609
|
+
OutputMode2["DISCARD"] = "discard";
|
|
610
|
+
return OutputMode2;
|
|
611
|
+
})(OutputMode || {});
|
|
612
|
+
ContainerState = /* @__PURE__ */ ((ContainerState2) => {
|
|
613
|
+
ContainerState2["IDLE"] = "Idle";
|
|
614
|
+
ContainerState2["RUNNING"] = "Running";
|
|
615
|
+
return ContainerState2;
|
|
616
|
+
})(ContainerState || {});
|
|
617
|
+
ResizeStatus = /* @__PURE__ */ ((ResizeStatus2) => {
|
|
618
|
+
ResizeStatus2["PENDING"] = "pending";
|
|
619
|
+
ResizeStatus2["SUCCEEDED"] = "succeeded";
|
|
620
|
+
ResizeStatus2["FAILED"] = "failed";
|
|
621
|
+
return ResizeStatus2;
|
|
622
|
+
})(ResizeStatus || {});
|
|
623
|
+
ResizeErrorReason = /* @__PURE__ */ ((ResizeErrorReason2) => {
|
|
624
|
+
ResizeErrorReason2["FAILED"] = "failed";
|
|
625
|
+
ResizeErrorReason2["TIMEOUT"] = "timeout";
|
|
626
|
+
ResizeErrorReason2["SUPERSEDED"] = "superseded";
|
|
627
|
+
ResizeErrorReason2["INTERRUPTED"] = "interrupted";
|
|
628
|
+
ResizeErrorReason2["INCOMPATIBLE_RESPONSE"] = "incompatible_response";
|
|
629
|
+
return ResizeErrorReason2;
|
|
630
|
+
})(ResizeErrorReason || {});
|
|
631
|
+
CAMEL_TO_SNAKE_RE = /[A-Z]/g;
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
|
|
480
635
|
// src/native-sandbox.ts
|
|
481
636
|
function loadNativeSandboxBinding() {
|
|
482
637
|
return cachedBinding ??= workerBinding();
|
|
@@ -504,6 +659,11 @@ function translateNativeError(error, context) {
|
|
|
504
659
|
return new SandboxError(String(error));
|
|
505
660
|
}
|
|
506
661
|
const { category, status, message } = payload;
|
|
662
|
+
if (category === "resize") {
|
|
663
|
+
return new SandboxResizeError(
|
|
664
|
+
fromSnakeKeys(JSON.parse(message), "sandboxId")
|
|
665
|
+
);
|
|
666
|
+
}
|
|
507
667
|
if (category === "connection") {
|
|
508
668
|
return new SandboxConnectionError(message, { cause: error });
|
|
509
669
|
}
|
|
@@ -616,134 +776,13 @@ var init_native_sandbox = __esm({
|
|
|
616
776
|
"src/native-sandbox.ts"() {
|
|
617
777
|
"use strict";
|
|
618
778
|
init_esm_shims();
|
|
779
|
+
init_models();
|
|
619
780
|
init_errors();
|
|
620
781
|
init_native_worker_client();
|
|
621
782
|
init_native_worker_protocol();
|
|
622
783
|
}
|
|
623
784
|
});
|
|
624
785
|
|
|
625
|
-
// src/models.ts
|
|
626
|
-
function isSandboxPending(status) {
|
|
627
|
-
return String(status) === "pending" /* PENDING */;
|
|
628
|
-
}
|
|
629
|
-
function camelToSnake(str) {
|
|
630
|
-
return str.replace(CAMEL_TO_SNAKE_RE, (ch) => "_" + ch.toLowerCase());
|
|
631
|
-
}
|
|
632
|
-
function snakeToCamel(str) {
|
|
633
|
-
return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
634
|
-
}
|
|
635
|
-
function toSnakeKeys(obj) {
|
|
636
|
-
if (Array.isArray(obj)) return obj.map(toSnakeKeys);
|
|
637
|
-
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
638
|
-
const result = {};
|
|
639
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
640
|
-
result[camelToSnake(k)] = toSnakeKeys(v);
|
|
641
|
-
}
|
|
642
|
-
return result;
|
|
643
|
-
}
|
|
644
|
-
return obj;
|
|
645
|
-
}
|
|
646
|
-
function parseTimestamp(v) {
|
|
647
|
-
if (v == null) return void 0;
|
|
648
|
-
if (v instanceof Date) return v;
|
|
649
|
-
if (typeof v === "string") {
|
|
650
|
-
const parsed = Date.parse(v);
|
|
651
|
-
return Number.isNaN(parsed) ? void 0 : new Date(parsed);
|
|
652
|
-
}
|
|
653
|
-
const ts = Number(v);
|
|
654
|
-
if (isNaN(ts)) return void 0;
|
|
655
|
-
if (ts > 1e15) return new Date(ts / 1e3);
|
|
656
|
-
if (ts > 1e12) return new Date(ts);
|
|
657
|
-
return new Date(ts * 1e3);
|
|
658
|
-
}
|
|
659
|
-
function fromSnakeKeys(obj, idField) {
|
|
660
|
-
if (Array.isArray(obj))
|
|
661
|
-
return obj.map((item) => fromSnakeKeys(item, idField));
|
|
662
|
-
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
663
|
-
const result = {};
|
|
664
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
665
|
-
let key;
|
|
666
|
-
if (k === "id" && idField) {
|
|
667
|
-
key = idField;
|
|
668
|
-
} else {
|
|
669
|
-
key = snakeToCamel(k);
|
|
670
|
-
}
|
|
671
|
-
if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
|
|
672
|
-
result[key] = parseTimestamp(v);
|
|
673
|
-
} else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
|
|
674
|
-
result[key] = fromSnakeKeys(v);
|
|
675
|
-
} else if (Array.isArray(v)) {
|
|
676
|
-
result[key] = v.map((item) => fromSnakeKeys(item));
|
|
677
|
-
} else {
|
|
678
|
-
result[key] = v === null ? void 0 : v;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
return result;
|
|
682
|
-
}
|
|
683
|
-
return obj;
|
|
684
|
-
}
|
|
685
|
-
var SandboxStatus, SandboxPendingReason, TERMINATION_REASON_NO_CAPACITY, TERMINATION_REASON_CANCELLED, SnapshotStatus, ProcessStatus, StdinMode, OutputMode, ContainerState, CAMEL_TO_SNAKE_RE;
|
|
686
|
-
var init_models = __esm({
|
|
687
|
-
"src/models.ts"() {
|
|
688
|
-
"use strict";
|
|
689
|
-
init_esm_shims();
|
|
690
|
-
SandboxStatus = /* @__PURE__ */ ((SandboxStatus2) => {
|
|
691
|
-
SandboxStatus2["PENDING"] = "pending";
|
|
692
|
-
SandboxStatus2["RUNNING"] = "running";
|
|
693
|
-
SandboxStatus2["SNAPSHOTTING"] = "snapshotting";
|
|
694
|
-
SandboxStatus2["SUSPENDING"] = "suspending";
|
|
695
|
-
SandboxStatus2["SUSPENDED"] = "suspended";
|
|
696
|
-
SandboxStatus2["TERMINATED"] = "terminated";
|
|
697
|
-
SandboxStatus2["TIMEOUT"] = "timeout";
|
|
698
|
-
SandboxStatus2["FAILED"] = "failed";
|
|
699
|
-
return SandboxStatus2;
|
|
700
|
-
})(SandboxStatus || {});
|
|
701
|
-
SandboxPendingReason = /* @__PURE__ */ ((SandboxPendingReason2) => {
|
|
702
|
-
SandboxPendingReason2["SCHEDULING"] = "scheduling";
|
|
703
|
-
SandboxPendingReason2["WAITING_FOR_CONTAINER"] = "waiting_for_container";
|
|
704
|
-
SandboxPendingReason2["NO_EXECUTORS_AVAILABLE"] = "no_executors_available";
|
|
705
|
-
SandboxPendingReason2["NO_RESOURCES_AVAILABLE"] = "no_resources_available";
|
|
706
|
-
SandboxPendingReason2["POOL_AT_CAPACITY"] = "pool_at_capacity";
|
|
707
|
-
SandboxPendingReason2["MAX_CAPACITY_REACHED"] = "max_capacity_reached";
|
|
708
|
-
SandboxPendingReason2["NO_EXECUTOR_FOR_SNAPSHOT_LOCATION"] = "no_executor_for_snapshot_location";
|
|
709
|
-
SandboxPendingReason2["UNPLACEABLE"] = "unplaceable";
|
|
710
|
-
return SandboxPendingReason2;
|
|
711
|
-
})(SandboxPendingReason || {});
|
|
712
|
-
TERMINATION_REASON_NO_CAPACITY = "no_capacity";
|
|
713
|
-
TERMINATION_REASON_CANCELLED = "cancelled";
|
|
714
|
-
SnapshotStatus = /* @__PURE__ */ ((SnapshotStatus2) => {
|
|
715
|
-
SnapshotStatus2["IN_PROGRESS"] = "in_progress";
|
|
716
|
-
SnapshotStatus2["LOCAL_READY"] = "local_ready";
|
|
717
|
-
SnapshotStatus2["COMPLETED"] = "completed";
|
|
718
|
-
SnapshotStatus2["FAILED"] = "failed";
|
|
719
|
-
return SnapshotStatus2;
|
|
720
|
-
})(SnapshotStatus || {});
|
|
721
|
-
ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
|
|
722
|
-
ProcessStatus2["RUNNING"] = "running";
|
|
723
|
-
ProcessStatus2["EXITED"] = "exited";
|
|
724
|
-
ProcessStatus2["SIGNALED"] = "signaled";
|
|
725
|
-
ProcessStatus2["OOM_KILLED"] = "oom_killed";
|
|
726
|
-
return ProcessStatus2;
|
|
727
|
-
})(ProcessStatus || {});
|
|
728
|
-
StdinMode = /* @__PURE__ */ ((StdinMode2) => {
|
|
729
|
-
StdinMode2["CLOSED"] = "closed";
|
|
730
|
-
StdinMode2["PIPE"] = "pipe";
|
|
731
|
-
return StdinMode2;
|
|
732
|
-
})(StdinMode || {});
|
|
733
|
-
OutputMode = /* @__PURE__ */ ((OutputMode2) => {
|
|
734
|
-
OutputMode2["CAPTURE"] = "capture";
|
|
735
|
-
OutputMode2["DISCARD"] = "discard";
|
|
736
|
-
return OutputMode2;
|
|
737
|
-
})(OutputMode || {});
|
|
738
|
-
ContainerState = /* @__PURE__ */ ((ContainerState2) => {
|
|
739
|
-
ContainerState2["IDLE"] = "Idle";
|
|
740
|
-
ContainerState2["RUNNING"] = "Running";
|
|
741
|
-
return ContainerState2;
|
|
742
|
-
})(ContainerState || {});
|
|
743
|
-
CAMEL_TO_SNAKE_RE = /[A-Z]/g;
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
|
|
747
786
|
// src/pending-sandbox.ts
|
|
748
787
|
var PendingSandbox;
|
|
749
788
|
var init_pending_sandbox = __esm({
|
|
@@ -3963,8 +4002,12 @@ var init_sandbox = __esm({
|
|
|
3963
4002
|
return info.status;
|
|
3964
4003
|
}
|
|
3965
4004
|
/**
|
|
3966
|
-
* Update this sandbox's properties
|
|
3967
|
-
*
|
|
4005
|
+
* Update this sandbox's properties or resize its resources.
|
|
4006
|
+
*
|
|
4007
|
+
* Resource targets use create's cpus, memoryMb, and diskMb names. Resize
|
|
4008
|
+
* waits by default; wait=false returns admission. Timeout does not cancel it.
|
|
4009
|
+
* Wait, timeout, and pollInterval are ignored on non-resource updates.
|
|
4010
|
+
* A no-op returns current resources with absent or earlier resize metadata.
|
|
3968
4011
|
*
|
|
3969
4012
|
* Naming an ephemeral sandbox makes it non-ephemeral and enables
|
|
3970
4013
|
* suspend/resume. For `network`, omit to keep the current policy, pass an
|
|
@@ -3977,6 +4020,14 @@ var init_sandbox = __esm({
|
|
|
3977
4020
|
this._setName(info.name ?? null);
|
|
3978
4021
|
return info;
|
|
3979
4022
|
}
|
|
4023
|
+
/** Wait for this exact resize generation without submitting another update. */
|
|
4024
|
+
async waitForResourceResize(generation, options = {}) {
|
|
4025
|
+
const client = this.requireLifecycleClient("waitForResourceResize");
|
|
4026
|
+
const info = await client.waitForResourceResize(this.lifecycleIdentifier, generation, options);
|
|
4027
|
+
this._setLifecycleIdentifier(info.sandboxId);
|
|
4028
|
+
this._setName(info.name ?? null);
|
|
4029
|
+
return info;
|
|
4030
|
+
}
|
|
3980
4031
|
/**
|
|
3981
4032
|
* Suspend this sandbox.
|
|
3982
4033
|
*
|
|
@@ -4661,6 +4712,16 @@ function validateUserPort(port) {
|
|
|
4661
4712
|
function dedupeAndSortPorts(ports) {
|
|
4662
4713
|
return [...new Set(ports)].sort((a, b) => a - b);
|
|
4663
4714
|
}
|
|
4715
|
+
function validateResizeWait(options) {
|
|
4716
|
+
const timeout = options.timeout ?? 300;
|
|
4717
|
+
const poll = options.pollInterval ?? 1;
|
|
4718
|
+
if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout < 0) {
|
|
4719
|
+
throw new SandboxError("timeout must be finite and non-negative");
|
|
4720
|
+
}
|
|
4721
|
+
if (typeof poll !== "number" || !Number.isFinite(poll) || poll <= 0) {
|
|
4722
|
+
throw new SandboxError("pollInterval must be finite and positive");
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4664
4725
|
var DEFAULT_WAIT_POLL_INTERVAL_SEC, GPU_MODELS, SandboxClient, RESERVED_SANDBOX_MANAGEMENT_PORT;
|
|
4665
4726
|
var init_client = __esm({
|
|
4666
4727
|
"src/client.ts"() {
|
|
@@ -5044,9 +5105,39 @@ var init_client = __esm({
|
|
|
5044
5105
|
traceId
|
|
5045
5106
|
});
|
|
5046
5107
|
}
|
|
5047
|
-
/**
|
|
5108
|
+
/**
|
|
5109
|
+
* Update properties or resize a Running Cloud Hypervisor sandbox.
|
|
5110
|
+
* Resource names match create. Resize waits by default; wait=false returns
|
|
5111
|
+
* admission. Timeout leaves the resize running and reports its generation.
|
|
5112
|
+
* Wait, timeout, and pollInterval are ignored on non-resource updates.
|
|
5113
|
+
* A no-op returns current resources with absent or earlier resize metadata.
|
|
5114
|
+
*/
|
|
5048
5115
|
async update(sandboxId, options) {
|
|
5049
5116
|
const body = {};
|
|
5117
|
+
const resources = {};
|
|
5118
|
+
for (const [field, wire, value] of [
|
|
5119
|
+
["cpus", "cpus", options.cpus],
|
|
5120
|
+
["memoryMb", "memory_mb", options.memoryMb],
|
|
5121
|
+
["diskMb", "disk_mb", options.diskMb]
|
|
5122
|
+
]) {
|
|
5123
|
+
if (value === void 0) continue;
|
|
5124
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
5125
|
+
throw new SandboxError(
|
|
5126
|
+
`${field} ${String(value)} must be a finite positive ${field === "cpus" ? "whole-vCPU count" : "integer number of MiB"}`
|
|
5127
|
+
);
|
|
5128
|
+
}
|
|
5129
|
+
resources[wire] = value;
|
|
5130
|
+
}
|
|
5131
|
+
const resizing = Object.keys(resources).length > 0;
|
|
5132
|
+
if (resizing) {
|
|
5133
|
+
validateResizeWait(options);
|
|
5134
|
+
if (options.name != null || options.allowUnauthenticatedAccess != null || options.exposedPorts != null || options.network !== void 0) {
|
|
5135
|
+
throw new SandboxError(
|
|
5136
|
+
"resources cannot be combined with other sandbox update fields"
|
|
5137
|
+
);
|
|
5138
|
+
}
|
|
5139
|
+
body.resources = resources;
|
|
5140
|
+
}
|
|
5050
5141
|
if (options.name != null) body.name = options.name;
|
|
5051
5142
|
if (options.allowUnauthenticatedAccess != null) {
|
|
5052
5143
|
body.allow_unauthenticated_access = options.allowUnauthenticatedAccess;
|
|
@@ -5063,7 +5154,30 @@ var init_client = __esm({
|
|
|
5063
5154
|
);
|
|
5064
5155
|
}
|
|
5065
5156
|
return this.tracedJson(
|
|
5066
|
-
() => this.native.updateSandbox(
|
|
5157
|
+
() => resizing ? this.native.updateSandbox(
|
|
5158
|
+
sandboxId,
|
|
5159
|
+
JSON.stringify(body),
|
|
5160
|
+
options.wait ?? true,
|
|
5161
|
+
options.timeout ?? 300,
|
|
5162
|
+
options.pollInterval ?? 1
|
|
5163
|
+
) : this.native.updateSandbox(sandboxId, JSON.stringify(body)),
|
|
5164
|
+
"sandboxId",
|
|
5165
|
+
{ sandboxId, notFoundKind: "sandbox" }
|
|
5166
|
+
);
|
|
5167
|
+
}
|
|
5168
|
+
/** Wait for this exact generation. Timeout leaves the resize running. */
|
|
5169
|
+
async waitForResourceResize(sandboxId, generation, options = {}) {
|
|
5170
|
+
validateResizeWait(options);
|
|
5171
|
+
if (!Number.isSafeInteger(generation) || generation < 1) {
|
|
5172
|
+
throw new SandboxError("generation must be a positive safe integer");
|
|
5173
|
+
}
|
|
5174
|
+
return this.tracedJson(
|
|
5175
|
+
() => this.native.waitForResourceResize(
|
|
5176
|
+
sandboxId,
|
|
5177
|
+
generation,
|
|
5178
|
+
options.timeout ?? 300,
|
|
5179
|
+
options.pollInterval ?? 1
|
|
5180
|
+
),
|
|
5067
5181
|
"sandboxId",
|
|
5068
5182
|
{ sandboxId, notFoundKind: "sandbox" }
|
|
5069
5183
|
);
|
|
@@ -6814,7 +6928,7 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
6814
6928
|
const dockerfilePath = parsed.positionals[0];
|
|
6815
6929
|
if (!dockerfilePath) {
|
|
6816
6930
|
throw new Error(
|
|
6817
|
-
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory
|
|
6931
|
+
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
6818
6932
|
);
|
|
6819
6933
|
}
|
|
6820
6934
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -6866,7 +6980,7 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
6866
6980
|
const imageReference = parsed.positionals[0];
|
|
6867
6981
|
if (!imageReference) {
|
|
6868
6982
|
throw new Error(
|
|
6869
|
-
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory
|
|
6983
|
+
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
6870
6984
|
);
|
|
6871
6985
|
}
|
|
6872
6986
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -9946,6 +10060,8 @@ export {
|
|
|
9946
10060
|
RequestExecutionError,
|
|
9947
10061
|
RequestFailedError,
|
|
9948
10062
|
RequestNotFinishedError,
|
|
10063
|
+
ResizeErrorReason,
|
|
10064
|
+
ResizeStatus,
|
|
9949
10065
|
Sandbox,
|
|
9950
10066
|
SandboxClient,
|
|
9951
10067
|
SandboxConnectionError,
|
|
@@ -9954,6 +10070,7 @@ export {
|
|
|
9954
10070
|
SandboxNotFoundError,
|
|
9955
10071
|
SandboxPending,
|
|
9956
10072
|
SandboxPendingReason,
|
|
10073
|
+
SandboxResizeError,
|
|
9957
10074
|
SandboxStatus,
|
|
9958
10075
|
SnapshotStatus,
|
|
9959
10076
|
StdinMode,
|