tensorlake 0.5.139 → 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.
@@ -402,7 +402,7 @@ var NativeWorkerClient = class {
402
402
  }
403
403
  };
404
404
  var runtimeKey = /* @__PURE__ */ Symbol.for(
405
- `tensorlake.native.worker.${false ? "source" : "0.5.139"}.v1`
405
+ `tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
406
406
  );
407
407
  var runtimes = globalThis;
408
408
  function configureNativeWorker(workerPath) {
@@ -390,7 +390,7 @@ var NativeWorkerClient = class {
390
390
  }
391
391
  };
392
392
  var runtimeKey = /* @__PURE__ */ Symbol.for(
393
- `tensorlake.native.worker.${false ? "source" : "0.5.139"}.v1`
393
+ `tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
394
394
  );
395
395
  var runtimes = globalThis;
396
396
  function configureNativeWorker(workerPath) {
@@ -51,7 +51,7 @@ var cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1")
51
51
  var closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
52
52
 
53
53
  // src/defaults.ts
54
- var SDK_VERSION = "0.5.139";
54
+ var SDK_VERSION = "0.5.141";
55
55
  var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
56
56
  var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
57
57
  var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -247,7 +247,7 @@ var NativeWorkerClient = class {
247
247
  }
248
248
  };
249
249
  var runtimeKey = /* @__PURE__ */ Symbol.for(
250
- `tensorlake.native.worker.${false ? "source" : "0.5.139"}.v1`
250
+ `tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
251
251
  );
252
252
  var runtimes = globalThis;
253
253
  function configureNativeWorker(workerPath) {
@@ -10,7 +10,7 @@ var cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1")
10
10
  var closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
11
11
 
12
12
  // src/defaults.ts
13
- var SDK_VERSION = "0.5.139";
13
+ var SDK_VERSION = "0.5.141";
14
14
  var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
15
15
  var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
16
16
  var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -206,7 +206,7 @@ var NativeWorkerClient = class {
206
206
  }
207
207
  };
208
208
  var runtimeKey = /* @__PURE__ */ Symbol.for(
209
- `tensorlake.native.worker.${false ? "source" : "0.5.139"}.v1`
209
+ `tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
210
210
  );
211
211
  var runtimes = globalThis;
212
212
  function configureNativeWorker(workerPath) {
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.139";
52
+ SDK_VERSION = "0.5.141";
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";
@@ -82,7 +82,7 @@ function formatErrorDetails(errorDetails) {
82
82
  }
83
83
  return String(errorDetails);
84
84
  }
85
- var SandboxException, SandboxError, SandboxPending, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError, RequestNotFinishedError, RequestFailedError, RequestExecutionError;
85
+ var SandboxException, SandboxError, SandboxResizeError, SandboxPending, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError, RequestNotFinishedError, RequestFailedError, RequestExecutionError;
86
86
  var init_errors = __esm({
87
87
  "src/errors.ts"() {
88
88
  "use strict";
@@ -103,6 +103,25 @@ var init_errors = __esm({
103
103
  if (options?.sandboxId !== void 0) this.sandboxId = options.sandboxId;
104
104
  }
105
105
  };
106
+ SandboxResizeError = class extends SandboxError {
107
+ generation;
108
+ info;
109
+ constructor(payload) {
110
+ const resources = payload.info?.resources;
111
+ const allocation = resources ? `${resources.cpus} CPUs, ${resources.memoryMb} MiB memory, ${resources.diskMb} MiB disk` : "unavailable";
112
+ super(
113
+ `Sandbox ${payload.sandboxId} resize generation ${payload.generation}: ${payload.message}; last confirmed allocation: ${allocation}`,
114
+ { reason: payload.reason, sandboxId: payload.sandboxId }
115
+ );
116
+ this.name = "SandboxResizeError";
117
+ this.generation = payload.generation;
118
+ this.info = payload.info ?? void 0;
119
+ }
120
+ /** Last confirmed allocation, if an observation was available. */
121
+ get confirmedResources() {
122
+ return this.info?.resources;
123
+ }
124
+ };
106
125
  SandboxPending = class extends SandboxError {
107
126
  pendingReason;
108
127
  timeout;
@@ -474,12 +493,148 @@ var init_native_worker_client = __esm({
474
493
  }
475
494
  };
476
495
  runtimeKey = /* @__PURE__ */ Symbol.for(
477
- `tensorlake.native.worker.${false ? "source" : "0.5.139"}.v1`
496
+ `tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
478
497
  );
479
498
  runtimes = globalThis;
480
499
  }
481
500
  });
482
501
 
502
+ // src/models.ts
503
+ function isSandboxPending(status) {
504
+ return String(status) === "pending" /* PENDING */;
505
+ }
506
+ function camelToSnake(str) {
507
+ return str.replace(CAMEL_TO_SNAKE_RE, (ch) => "_" + ch.toLowerCase());
508
+ }
509
+ function snakeToCamel(str) {
510
+ return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
511
+ }
512
+ function toSnakeKeys(obj) {
513
+ if (Array.isArray(obj)) return obj.map(toSnakeKeys);
514
+ if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
515
+ const result = {};
516
+ for (const [k, v] of Object.entries(obj)) {
517
+ result[camelToSnake(k)] = toSnakeKeys(v);
518
+ }
519
+ return result;
520
+ }
521
+ return obj;
522
+ }
523
+ function parseTimestamp(v) {
524
+ if (v == null) return void 0;
525
+ if (v instanceof Date) return v;
526
+ if (typeof v === "string") {
527
+ const parsed = Date.parse(v);
528
+ return Number.isNaN(parsed) ? void 0 : new Date(parsed);
529
+ }
530
+ const ts = Number(v);
531
+ if (isNaN(ts)) return void 0;
532
+ if (ts > 1e15) return new Date(ts / 1e3);
533
+ if (ts > 1e12) return new Date(ts);
534
+ return new Date(ts * 1e3);
535
+ }
536
+ function fromSnakeKeys(obj, idField) {
537
+ if (Array.isArray(obj))
538
+ return obj.map((item) => fromSnakeKeys(item, idField));
539
+ if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
540
+ const result = {};
541
+ for (const [k, v] of Object.entries(obj)) {
542
+ let key;
543
+ if (k === "id" && idField) {
544
+ key = idField;
545
+ } else {
546
+ key = snakeToCamel(k);
547
+ }
548
+ if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
549
+ result[key] = parseTimestamp(v);
550
+ } else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
551
+ result[key] = fromSnakeKeys(v);
552
+ } else if (Array.isArray(v)) {
553
+ result[key] = v.map((item) => fromSnakeKeys(item));
554
+ } else {
555
+ result[key] = v === null ? void 0 : v;
556
+ }
557
+ }
558
+ return result;
559
+ }
560
+ return obj;
561
+ }
562
+ var SandboxStatus, SandboxPendingReason, TERMINATION_REASON_NO_CAPACITY, TERMINATION_REASON_CANCELLED, SnapshotStatus, ProcessStatus, StdinMode, OutputMode, ContainerState, ResizeStatus, ResizeErrorReason, CAMEL_TO_SNAKE_RE;
563
+ var init_models = __esm({
564
+ "src/models.ts"() {
565
+ "use strict";
566
+ init_cjs_shims();
567
+ SandboxStatus = /* @__PURE__ */ ((SandboxStatus2) => {
568
+ SandboxStatus2["PENDING"] = "pending";
569
+ SandboxStatus2["RUNNING"] = "running";
570
+ SandboxStatus2["SNAPSHOTTING"] = "snapshotting";
571
+ SandboxStatus2["SUSPENDING"] = "suspending";
572
+ SandboxStatus2["SUSPENDED"] = "suspended";
573
+ SandboxStatus2["TERMINATED"] = "terminated";
574
+ SandboxStatus2["TIMEOUT"] = "timeout";
575
+ SandboxStatus2["FAILED"] = "failed";
576
+ return SandboxStatus2;
577
+ })(SandboxStatus || {});
578
+ SandboxPendingReason = /* @__PURE__ */ ((SandboxPendingReason2) => {
579
+ SandboxPendingReason2["SCHEDULING"] = "scheduling";
580
+ SandboxPendingReason2["WAITING_FOR_CONTAINER"] = "waiting_for_container";
581
+ SandboxPendingReason2["NO_EXECUTORS_AVAILABLE"] = "no_executors_available";
582
+ SandboxPendingReason2["NO_RESOURCES_AVAILABLE"] = "no_resources_available";
583
+ SandboxPendingReason2["POOL_AT_CAPACITY"] = "pool_at_capacity";
584
+ SandboxPendingReason2["MAX_CAPACITY_REACHED"] = "max_capacity_reached";
585
+ SandboxPendingReason2["NO_EXECUTOR_FOR_SNAPSHOT_LOCATION"] = "no_executor_for_snapshot_location";
586
+ SandboxPendingReason2["UNPLACEABLE"] = "unplaceable";
587
+ return SandboxPendingReason2;
588
+ })(SandboxPendingReason || {});
589
+ TERMINATION_REASON_NO_CAPACITY = "no_capacity";
590
+ TERMINATION_REASON_CANCELLED = "cancelled";
591
+ SnapshotStatus = /* @__PURE__ */ ((SnapshotStatus2) => {
592
+ SnapshotStatus2["IN_PROGRESS"] = "in_progress";
593
+ SnapshotStatus2["LOCAL_READY"] = "local_ready";
594
+ SnapshotStatus2["COMPLETED"] = "completed";
595
+ SnapshotStatus2["FAILED"] = "failed";
596
+ return SnapshotStatus2;
597
+ })(SnapshotStatus || {});
598
+ ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
599
+ ProcessStatus2["RUNNING"] = "running";
600
+ ProcessStatus2["EXITED"] = "exited";
601
+ ProcessStatus2["SIGNALED"] = "signaled";
602
+ ProcessStatus2["OOM_KILLED"] = "oom_killed";
603
+ return ProcessStatus2;
604
+ })(ProcessStatus || {});
605
+ StdinMode = /* @__PURE__ */ ((StdinMode2) => {
606
+ StdinMode2["CLOSED"] = "closed";
607
+ StdinMode2["PIPE"] = "pipe";
608
+ return StdinMode2;
609
+ })(StdinMode || {});
610
+ OutputMode = /* @__PURE__ */ ((OutputMode2) => {
611
+ OutputMode2["CAPTURE"] = "capture";
612
+ OutputMode2["DISCARD"] = "discard";
613
+ return OutputMode2;
614
+ })(OutputMode || {});
615
+ ContainerState = /* @__PURE__ */ ((ContainerState2) => {
616
+ ContainerState2["IDLE"] = "Idle";
617
+ ContainerState2["RUNNING"] = "Running";
618
+ return ContainerState2;
619
+ })(ContainerState || {});
620
+ ResizeStatus = /* @__PURE__ */ ((ResizeStatus2) => {
621
+ ResizeStatus2["PENDING"] = "pending";
622
+ ResizeStatus2["SUCCEEDED"] = "succeeded";
623
+ ResizeStatus2["FAILED"] = "failed";
624
+ return ResizeStatus2;
625
+ })(ResizeStatus || {});
626
+ ResizeErrorReason = /* @__PURE__ */ ((ResizeErrorReason2) => {
627
+ ResizeErrorReason2["FAILED"] = "failed";
628
+ ResizeErrorReason2["TIMEOUT"] = "timeout";
629
+ ResizeErrorReason2["SUPERSEDED"] = "superseded";
630
+ ResizeErrorReason2["INTERRUPTED"] = "interrupted";
631
+ ResizeErrorReason2["INCOMPATIBLE_RESPONSE"] = "incompatible_response";
632
+ return ResizeErrorReason2;
633
+ })(ResizeErrorReason || {});
634
+ CAMEL_TO_SNAKE_RE = /[A-Z]/g;
635
+ }
636
+ });
637
+
483
638
  // src/native-sandbox.ts
484
639
  function loadNativeSandboxBinding() {
485
640
  return cachedBinding ??= workerBinding();
@@ -507,6 +662,11 @@ function translateNativeError(error, context) {
507
662
  return new SandboxError(String(error));
508
663
  }
509
664
  const { category, status, message } = payload;
665
+ if (category === "resize") {
666
+ return new SandboxResizeError(
667
+ fromSnakeKeys(JSON.parse(message), "sandboxId")
668
+ );
669
+ }
510
670
  if (category === "connection") {
511
671
  return new SandboxConnectionError(message, { cause: error });
512
672
  }
@@ -619,134 +779,13 @@ var init_native_sandbox = __esm({
619
779
  "src/native-sandbox.ts"() {
620
780
  "use strict";
621
781
  init_cjs_shims();
782
+ init_models();
622
783
  init_errors();
623
784
  init_native_worker_client();
624
785
  init_native_worker_protocol();
625
786
  }
626
787
  });
627
788
 
628
- // src/models.ts
629
- function isSandboxPending(status) {
630
- return String(status) === "pending" /* PENDING */;
631
- }
632
- function camelToSnake(str) {
633
- return str.replace(CAMEL_TO_SNAKE_RE, (ch) => "_" + ch.toLowerCase());
634
- }
635
- function snakeToCamel(str) {
636
- return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
637
- }
638
- function toSnakeKeys(obj) {
639
- if (Array.isArray(obj)) return obj.map(toSnakeKeys);
640
- if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
641
- const result = {};
642
- for (const [k, v] of Object.entries(obj)) {
643
- result[camelToSnake(k)] = toSnakeKeys(v);
644
- }
645
- return result;
646
- }
647
- return obj;
648
- }
649
- function parseTimestamp(v) {
650
- if (v == null) return void 0;
651
- if (v instanceof Date) return v;
652
- if (typeof v === "string") {
653
- const parsed = Date.parse(v);
654
- return Number.isNaN(parsed) ? void 0 : new Date(parsed);
655
- }
656
- const ts = Number(v);
657
- if (isNaN(ts)) return void 0;
658
- if (ts > 1e15) return new Date(ts / 1e3);
659
- if (ts > 1e12) return new Date(ts);
660
- return new Date(ts * 1e3);
661
- }
662
- function fromSnakeKeys(obj, idField) {
663
- if (Array.isArray(obj))
664
- return obj.map((item) => fromSnakeKeys(item, idField));
665
- if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
666
- const result = {};
667
- for (const [k, v] of Object.entries(obj)) {
668
- let key;
669
- if (k === "id" && idField) {
670
- key = idField;
671
- } else {
672
- key = snakeToCamel(k);
673
- }
674
- if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
675
- result[key] = parseTimestamp(v);
676
- } else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
677
- result[key] = fromSnakeKeys(v);
678
- } else if (Array.isArray(v)) {
679
- result[key] = v.map((item) => fromSnakeKeys(item));
680
- } else {
681
- result[key] = v === null ? void 0 : v;
682
- }
683
- }
684
- return result;
685
- }
686
- return obj;
687
- }
688
- var SandboxStatus, SandboxPendingReason, TERMINATION_REASON_NO_CAPACITY, TERMINATION_REASON_CANCELLED, SnapshotStatus, ProcessStatus, StdinMode, OutputMode, ContainerState, CAMEL_TO_SNAKE_RE;
689
- var init_models = __esm({
690
- "src/models.ts"() {
691
- "use strict";
692
- init_cjs_shims();
693
- SandboxStatus = /* @__PURE__ */ ((SandboxStatus2) => {
694
- SandboxStatus2["PENDING"] = "pending";
695
- SandboxStatus2["RUNNING"] = "running";
696
- SandboxStatus2["SNAPSHOTTING"] = "snapshotting";
697
- SandboxStatus2["SUSPENDING"] = "suspending";
698
- SandboxStatus2["SUSPENDED"] = "suspended";
699
- SandboxStatus2["TERMINATED"] = "terminated";
700
- SandboxStatus2["TIMEOUT"] = "timeout";
701
- SandboxStatus2["FAILED"] = "failed";
702
- return SandboxStatus2;
703
- })(SandboxStatus || {});
704
- SandboxPendingReason = /* @__PURE__ */ ((SandboxPendingReason2) => {
705
- SandboxPendingReason2["SCHEDULING"] = "scheduling";
706
- SandboxPendingReason2["WAITING_FOR_CONTAINER"] = "waiting_for_container";
707
- SandboxPendingReason2["NO_EXECUTORS_AVAILABLE"] = "no_executors_available";
708
- SandboxPendingReason2["NO_RESOURCES_AVAILABLE"] = "no_resources_available";
709
- SandboxPendingReason2["POOL_AT_CAPACITY"] = "pool_at_capacity";
710
- SandboxPendingReason2["MAX_CAPACITY_REACHED"] = "max_capacity_reached";
711
- SandboxPendingReason2["NO_EXECUTOR_FOR_SNAPSHOT_LOCATION"] = "no_executor_for_snapshot_location";
712
- SandboxPendingReason2["UNPLACEABLE"] = "unplaceable";
713
- return SandboxPendingReason2;
714
- })(SandboxPendingReason || {});
715
- TERMINATION_REASON_NO_CAPACITY = "no_capacity";
716
- TERMINATION_REASON_CANCELLED = "cancelled";
717
- SnapshotStatus = /* @__PURE__ */ ((SnapshotStatus2) => {
718
- SnapshotStatus2["IN_PROGRESS"] = "in_progress";
719
- SnapshotStatus2["LOCAL_READY"] = "local_ready";
720
- SnapshotStatus2["COMPLETED"] = "completed";
721
- SnapshotStatus2["FAILED"] = "failed";
722
- return SnapshotStatus2;
723
- })(SnapshotStatus || {});
724
- ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
725
- ProcessStatus2["RUNNING"] = "running";
726
- ProcessStatus2["EXITED"] = "exited";
727
- ProcessStatus2["SIGNALED"] = "signaled";
728
- ProcessStatus2["OOM_KILLED"] = "oom_killed";
729
- return ProcessStatus2;
730
- })(ProcessStatus || {});
731
- StdinMode = /* @__PURE__ */ ((StdinMode2) => {
732
- StdinMode2["CLOSED"] = "closed";
733
- StdinMode2["PIPE"] = "pipe";
734
- return StdinMode2;
735
- })(StdinMode || {});
736
- OutputMode = /* @__PURE__ */ ((OutputMode2) => {
737
- OutputMode2["CAPTURE"] = "capture";
738
- OutputMode2["DISCARD"] = "discard";
739
- return OutputMode2;
740
- })(OutputMode || {});
741
- ContainerState = /* @__PURE__ */ ((ContainerState2) => {
742
- ContainerState2["IDLE"] = "Idle";
743
- ContainerState2["RUNNING"] = "Running";
744
- return ContainerState2;
745
- })(ContainerState || {});
746
- CAMEL_TO_SNAKE_RE = /[A-Z]/g;
747
- }
748
- });
749
-
750
789
  // src/pending-sandbox.ts
751
790
  var PendingSandbox;
752
791
  var init_pending_sandbox = __esm({
@@ -3966,8 +4005,12 @@ var init_sandbox = __esm({
3966
4005
  return info.status;
3967
4006
  }
3968
4007
  /**
3969
- * Update this sandbox's properties (name, exposed ports, proxy auth, and
3970
- * egress network policy).
4008
+ * Update this sandbox's properties or resize its resources.
4009
+ *
4010
+ * Resource targets use create's cpus, memoryMb, and diskMb names. Resize
4011
+ * waits by default; wait=false returns admission. Timeout does not cancel it.
4012
+ * Wait, timeout, and pollInterval are ignored on non-resource updates.
4013
+ * A no-op returns current resources with absent or earlier resize metadata.
3971
4014
  *
3972
4015
  * Naming an ephemeral sandbox makes it non-ephemeral and enables
3973
4016
  * suspend/resume. For `network`, omit to keep the current policy, pass an
@@ -3980,6 +4023,14 @@ var init_sandbox = __esm({
3980
4023
  this._setName(info.name ?? null);
3981
4024
  return info;
3982
4025
  }
4026
+ /** Wait for this exact resize generation without submitting another update. */
4027
+ async waitForResourceResize(generation, options = {}) {
4028
+ const client = this.requireLifecycleClient("waitForResourceResize");
4029
+ const info = await client.waitForResourceResize(this.lifecycleIdentifier, generation, options);
4030
+ this._setLifecycleIdentifier(info.sandboxId);
4031
+ this._setName(info.name ?? null);
4032
+ return info;
4033
+ }
3983
4034
  /**
3984
4035
  * Suspend this sandbox.
3985
4036
  *
@@ -4664,6 +4715,16 @@ function validateUserPort(port) {
4664
4715
  function dedupeAndSortPorts(ports) {
4665
4716
  return [...new Set(ports)].sort((a, b) => a - b);
4666
4717
  }
4718
+ function validateResizeWait(options) {
4719
+ const timeout = options.timeout ?? 300;
4720
+ const poll = options.pollInterval ?? 1;
4721
+ if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout < 0) {
4722
+ throw new SandboxError("timeout must be finite and non-negative");
4723
+ }
4724
+ if (typeof poll !== "number" || !Number.isFinite(poll) || poll <= 0) {
4725
+ throw new SandboxError("pollInterval must be finite and positive");
4726
+ }
4727
+ }
4667
4728
  var DEFAULT_WAIT_POLL_INTERVAL_SEC, GPU_MODELS, SandboxClient, RESERVED_SANDBOX_MANAGEMENT_PORT;
4668
4729
  var init_client = __esm({
4669
4730
  "src/client.ts"() {
@@ -5047,9 +5108,39 @@ var init_client = __esm({
5047
5108
  traceId
5048
5109
  });
5049
5110
  }
5050
- /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
5111
+ /**
5112
+ * Update properties or resize a Running Cloud Hypervisor sandbox.
5113
+ * Resource names match create. Resize waits by default; wait=false returns
5114
+ * admission. Timeout leaves the resize running and reports its generation.
5115
+ * Wait, timeout, and pollInterval are ignored on non-resource updates.
5116
+ * A no-op returns current resources with absent or earlier resize metadata.
5117
+ */
5051
5118
  async update(sandboxId, options) {
5052
5119
  const body = {};
5120
+ const resources = {};
5121
+ for (const [field, wire, value] of [
5122
+ ["cpus", "cpus", options.cpus],
5123
+ ["memoryMb", "memory_mb", options.memoryMb],
5124
+ ["diskMb", "disk_mb", options.diskMb]
5125
+ ]) {
5126
+ if (value === void 0) continue;
5127
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
5128
+ throw new SandboxError(
5129
+ `${field} ${String(value)} must be a finite positive ${field === "cpus" ? "whole-vCPU count" : "integer number of MiB"}`
5130
+ );
5131
+ }
5132
+ resources[wire] = value;
5133
+ }
5134
+ const resizing = Object.keys(resources).length > 0;
5135
+ if (resizing) {
5136
+ validateResizeWait(options);
5137
+ if (options.name != null || options.allowUnauthenticatedAccess != null || options.exposedPorts != null || options.network !== void 0) {
5138
+ throw new SandboxError(
5139
+ "resources cannot be combined with other sandbox update fields"
5140
+ );
5141
+ }
5142
+ body.resources = resources;
5143
+ }
5053
5144
  if (options.name != null) body.name = options.name;
5054
5145
  if (options.allowUnauthenticatedAccess != null) {
5055
5146
  body.allow_unauthenticated_access = options.allowUnauthenticatedAccess;
@@ -5066,7 +5157,30 @@ var init_client = __esm({
5066
5157
  );
5067
5158
  }
5068
5159
  return this.tracedJson(
5069
- () => this.native.updateSandbox(sandboxId, JSON.stringify(body)),
5160
+ () => resizing ? this.native.updateSandbox(
5161
+ sandboxId,
5162
+ JSON.stringify(body),
5163
+ options.wait ?? true,
5164
+ options.timeout ?? 300,
5165
+ options.pollInterval ?? 1
5166
+ ) : this.native.updateSandbox(sandboxId, JSON.stringify(body)),
5167
+ "sandboxId",
5168
+ { sandboxId, notFoundKind: "sandbox" }
5169
+ );
5170
+ }
5171
+ /** Wait for this exact generation. Timeout leaves the resize running. */
5172
+ async waitForResourceResize(sandboxId, generation, options = {}) {
5173
+ validateResizeWait(options);
5174
+ if (!Number.isSafeInteger(generation) || generation < 1) {
5175
+ throw new SandboxError("generation must be a positive safe integer");
5176
+ }
5177
+ return this.tracedJson(
5178
+ () => this.native.waitForResourceResize(
5179
+ sandboxId,
5180
+ generation,
5181
+ options.timeout ?? 300,
5182
+ options.pollInterval ?? 1
5183
+ ),
5070
5184
  "sandboxId",
5071
5185
  { sandboxId, notFoundKind: "sandbox" }
5072
5186
  );
@@ -6813,7 +6927,7 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
6813
6927
  const dockerfilePath = parsed.positionals[0];
6814
6928
  if (!dockerfilePath) {
6815
6929
  throw new Error(
6816
- "Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--disk_mb MB] [--builder_disk_mb MB] [--docker_compat] [--public]"
6930
+ "Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
6817
6931
  );
6818
6932
  }
6819
6933
  const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
@@ -6865,7 +6979,7 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
6865
6979
  const imageReference = parsed.positionals[0];
6866
6980
  if (!imageReference) {
6867
6981
  throw new Error(
6868
- "Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MB] [--disk_mb MB] [--builder_disk_mb MB] [--docker_compat] [--public]"
6982
+ "Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
6869
6983
  );
6870
6984
  }
6871
6985
  const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
@@ -6952,6 +7066,8 @@ __export(index_exports, {
6952
7066
  RequestExecutionError: () => RequestExecutionError,
6953
7067
  RequestFailedError: () => RequestFailedError,
6954
7068
  RequestNotFinishedError: () => RequestNotFinishedError,
7069
+ ResizeErrorReason: () => ResizeErrorReason,
7070
+ ResizeStatus: () => ResizeStatus,
6955
7071
  Sandbox: () => Sandbox,
6956
7072
  SandboxClient: () => SandboxClient,
6957
7073
  SandboxConnectionError: () => SandboxConnectionError,
@@ -6960,6 +7076,7 @@ __export(index_exports, {
6960
7076
  SandboxNotFoundError: () => SandboxNotFoundError,
6961
7077
  SandboxPending: () => SandboxPending,
6962
7078
  SandboxPendingReason: () => SandboxPendingReason,
7079
+ SandboxResizeError: () => SandboxResizeError,
6963
7080
  SandboxStatus: () => SandboxStatus,
6964
7081
  SnapshotStatus: () => SnapshotStatus,
6965
7082
  StdinMode: () => StdinMode,
@@ -10019,6 +10136,8 @@ init_models();
10019
10136
  RequestExecutionError,
10020
10137
  RequestFailedError,
10021
10138
  RequestNotFinishedError,
10139
+ ResizeErrorReason,
10140
+ ResizeStatus,
10022
10141
  Sandbox,
10023
10142
  SandboxClient,
10024
10143
  SandboxConnectionError,
@@ -10027,6 +10146,7 @@ init_models();
10027
10146
  SandboxNotFoundError,
10028
10147
  SandboxPending,
10029
10148
  SandboxPendingReason,
10149
+ SandboxResizeError,
10030
10150
  SandboxStatus,
10031
10151
  SnapshotStatus,
10032
10152
  StdinMode,