tensorlake 0.5.1 → 0.5.2

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/index.cjs CHANGED
@@ -3721,6 +3721,38 @@ __export(client_exports, {
3721
3721
  function sleep2(ms) {
3722
3722
  return new Promise((resolve) => setTimeout(resolve, ms));
3723
3723
  }
3724
+ function formatStartupFailureMessage(sandboxId, status, options) {
3725
+ const prefix = status === "terminated" /* TERMINATED */ ? `Sandbox ${sandboxId} terminated during startup` : `Sandbox ${sandboxId} became ${status} during startup`;
3726
+ const detail = formatErrorDetails(options.errorDetails);
3727
+ if (detail) {
3728
+ return `${prefix}: ${detail}`;
3729
+ }
3730
+ if (options.terminationReason) {
3731
+ return `${prefix}: termination reason: ${options.terminationReason}`;
3732
+ }
3733
+ return prefix;
3734
+ }
3735
+ function formatErrorDetails(errorDetails) {
3736
+ if (errorDetails == null) return void 0;
3737
+ if (typeof errorDetails === "string") {
3738
+ const detail = errorDetails.trim();
3739
+ return detail || void 0;
3740
+ }
3741
+ if (Array.isArray(errorDetails)) {
3742
+ const parts = errorDetails.map((item) => formatErrorDetails(item)).filter((item) => Boolean(item));
3743
+ return parts.length > 0 ? parts.join("; ") : JSON.stringify(errorDetails);
3744
+ }
3745
+ if (typeof errorDetails === "object") {
3746
+ for (const key of ["message", "detail", "error", "reason"]) {
3747
+ const value = errorDetails[key];
3748
+ if (typeof value === "string" && value.trim()) {
3749
+ return value.trim();
3750
+ }
3751
+ }
3752
+ return JSON.stringify(errorDetails);
3753
+ }
3754
+ return String(errorDetails);
3755
+ }
3724
3756
  function normalizeUserPorts(ports) {
3725
3757
  return dedupeAndSortPorts(ports.map(validateUserPort));
3726
3758
  }
@@ -4171,15 +4203,26 @@ var init_client = __esm({
4171
4203
  if (result.status === "running" /* RUNNING */) {
4172
4204
  return finishConnect(result.routingHint, result.name);
4173
4205
  }
4206
+ if (result.status === "suspended" /* SUSPENDED */ || result.status === "terminated" /* TERMINATED */) {
4207
+ throw new SandboxError(
4208
+ formatStartupFailureMessage(result.sandboxId, result.status, {
4209
+ errorDetails: result.errorDetails,
4210
+ terminationReason: result.terminationReason
4211
+ })
4212
+ );
4213
+ }
4174
4214
  const deadline = Date.now() + startupTimeout * 1e3;
4175
4215
  while (Date.now() < deadline) {
4176
4216
  const info = await this.get(result.sandboxId);
4177
4217
  if (info.status === "running" /* RUNNING */) {
4178
4218
  return finishConnect(info.routingHint, info.name);
4179
4219
  }
4180
- if (info.status === "terminated" /* TERMINATED */) {
4220
+ if (info.status === "suspended" /* SUSPENDED */ || info.status === "terminated" /* TERMINATED */) {
4181
4221
  throw new SandboxError(
4182
- `Sandbox ${result.sandboxId} terminated during startup`
4222
+ formatStartupFailureMessage(result.sandboxId, info.status, {
4223
+ errorDetails: info.errorDetails,
4224
+ terminationReason: info.terminationReason
4225
+ })
4183
4226
  );
4184
4227
  }
4185
4228
  await sleep2(500);
@@ -4956,7 +4999,7 @@ async function executeDockerfilePlan(sandbox, plan, emit, sleep3) {
4956
4999
  );
4957
5000
  }
4958
5001
  }
4959
- async function registerImage(context, name, dockerfile, snapshotId, snapshotUri, isPublic) {
5002
+ async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic) {
4960
5003
  if (!context.organizationId || !context.projectId) {
4961
5004
  throw new Error(
4962
5005
  "Organization ID and Project ID are required. Run 'tl login' and 'tl init'."
@@ -4983,8 +5026,11 @@ async function registerImage(context, name, dockerfile, snapshotId, snapshotUri,
4983
5026
  name,
4984
5027
  dockerfile,
4985
5028
  snapshotId,
5029
+ snapshotSandboxId,
4986
5030
  snapshotUri,
4987
- isPublic
5031
+ snapshotSizeBytes,
5032
+ rootfsDiskBytes,
5033
+ public: isPublic
4988
5034
  })
4989
5035
  });
4990
5036
  if (!response.ok) {
@@ -5035,6 +5081,16 @@ async function createSandboxImage(source, options = {}, deps = {}) {
5035
5081
  `Snapshot ${snapshot.snapshotId} is missing snapshotUri and cannot be registered as a sandbox image.`
5036
5082
  );
5037
5083
  }
5084
+ if (snapshot.sizeBytes == null) {
5085
+ throw new Error(
5086
+ `Snapshot ${snapshot.snapshotId} is missing sizeBytes and cannot be registered as a sandbox image.`
5087
+ );
5088
+ }
5089
+ if (snapshot.rootfsDiskBytes == null) {
5090
+ throw new Error(
5091
+ `Snapshot ${snapshot.snapshotId} is missing rootfsDiskBytes and cannot be registered as a sandbox image.`
5092
+ );
5093
+ }
5038
5094
  emit({
5039
5095
  type: "status",
5040
5096
  message: `Registering image '${plan.registeredName}'...`
@@ -5044,7 +5100,10 @@ async function createSandboxImage(source, options = {}, deps = {}) {
5044
5100
  plan.registeredName,
5045
5101
  plan.dockerfileText,
5046
5102
  snapshot.snapshotId,
5103
+ snapshot.sandboxId,
5047
5104
  snapshot.snapshotUri,
5105
+ snapshot.sizeBytes,
5106
+ snapshot.rootfsDiskBytes,
5048
5107
  options.isPublic ?? false
5049
5108
  );
5050
5109
  emit({