tensorlake 0.5.9 → 0.5.10

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.
@@ -1 +1 @@
1
- export { A as CreateSandboxImageOptions, E as DockerfileBuildPlan, F as DockerfileInstruction, V as SandboxImageSource, Z as createSandboxImage, $ as defaultRegisteredName, a0 as loadDockerfilePlan, a1 as loadImagePlan, a2 as logicalDockerfileLines, a3 as runCreateSandboxImageCli } from './sandbox-image-BMDaNpZ2.cjs';
1
+ export { a0 as BuildContext, A as CreateSandboxImageOptions, E as DockerfileBuildPlan, F as DockerfileInstruction, V as SandboxImageSource, _ as createSandboxImage, a1 as defaultRegisteredName, a2 as loadDockerfilePlan, a3 as loadImagePlan, a4 as logicalDockerfileLines, a5 as registerImage, a6 as runCreateSandboxImageCli } from './sandbox-image-CUEKMhZ1.cjs';
@@ -1 +1 @@
1
- export { A as CreateSandboxImageOptions, E as DockerfileBuildPlan, F as DockerfileInstruction, V as SandboxImageSource, Z as createSandboxImage, $ as defaultRegisteredName, a0 as loadDockerfilePlan, a1 as loadImagePlan, a2 as logicalDockerfileLines, a3 as runCreateSandboxImageCli } from './sandbox-image-BMDaNpZ2.js';
1
+ export { a0 as BuildContext, A as CreateSandboxImageOptions, E as DockerfileBuildPlan, F as DockerfileInstruction, V as SandboxImageSource, _ as createSandboxImage, a1 as defaultRegisteredName, a2 as loadDockerfilePlan, a3 as loadImagePlan, a4 as logicalDockerfileLines, a5 as registerImage, a6 as runCreateSandboxImageCli } from './sandbox-image-CUEKMhZ1.js';
@@ -61,7 +61,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
61
61
  var init_defaults = __esm({
62
62
  "src/defaults.ts"() {
63
63
  "use strict";
64
- SDK_VERSION = "0.5.9";
64
+ SDK_VERSION = "0.5.10";
65
65
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
66
66
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
67
67
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -3316,11 +3316,10 @@ var init_sandbox = __esm({
3316
3316
  await client.resume(this.lifecycleIdentifier, options);
3317
3317
  }
3318
3318
  /**
3319
- * Create a snapshot of this sandbox's filesystem and wait for it to
3320
- * be committed.
3319
+ * Create a checkpoint of this sandbox and wait for it to be locally ready.
3321
3320
  *
3322
- * By default blocks until the snapshot artifact is ready and returns
3323
- * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
3321
+ * By default blocks until the checkpoint is resumable and returns
3322
+ * `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
3324
3323
  * (returns `undefined`).
3325
3324
  */
3326
3325
  async checkpoint(options) {
@@ -3332,7 +3331,8 @@ var init_sandbox = __esm({
3332
3331
  return client.snapshotAndWait(this.lifecycleIdentifier, {
3333
3332
  timeout: options?.timeout,
3334
3333
  pollInterval: options?.pollInterval,
3335
- snapshotType: options?.checkpointType
3334
+ snapshotType: options?.checkpointType,
3335
+ waitUntil: options?.waitUntil
3336
3336
  });
3337
3337
  }
3338
3338
  /**
@@ -3727,6 +3727,12 @@ __export(client_exports, {
3727
3727
  function sleep2(ms) {
3728
3728
  return new Promise((resolve) => setTimeout(resolve, ms));
3729
3729
  }
3730
+ function snapshotStatusSatisfiesWaitCondition(status, waitUntil) {
3731
+ if (waitUntil === "local_ready") {
3732
+ return status === "local_ready" /* LOCAL_READY */ || status === "completed" /* COMPLETED */;
3733
+ }
3734
+ return status === "completed" /* COMPLETED */;
3735
+ }
3730
3736
  function formatStartupFailureMessage(sandboxId, status, options) {
3731
3737
  const prefix = status === "terminated" /* TERMINATED */ ? `Sandbox ${sandboxId} terminated during startup` : `Sandbox ${sandboxId} became ${status} during startup`;
3732
3738
  const detail = formatErrorDetails(options.errorDetails);
@@ -4027,7 +4033,8 @@ var init_client = __esm({
4027
4033
  *
4028
4034
  * This call **returns immediately** with a `snapshotId` and `in_progress`
4029
4035
  * status — the snapshot is created asynchronously. Poll `getSnapshot()` until
4030
- * `completed` or `failed`, or use `snapshotAndWait()` to block automatically.
4036
+ * `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
4037
+ * block automatically.
4031
4038
  *
4032
4039
  * @param options.snapshotType - `"filesystem"` for cold-boot snapshots (e.g. image builds).
4033
4040
  * Omit to use the server default (`filesystem`).
@@ -4068,9 +4075,11 @@ var init_client = __esm({
4068
4075
  );
4069
4076
  }
4070
4077
  /**
4071
- * Create a snapshot and block until it is committed.
4078
+ * Create a snapshot and block until it is locally ready.
4072
4079
  *
4073
- * Combines `snapshot()` with polling `getSnapshot()` until `completed`.
4080
+ * Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
4081
+ * or `completed`. Pass `{ waitUntil: "completed" }` when durable
4082
+ * `snapshotUri` metadata is required.
4074
4083
  * Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
4075
4084
  * without managing the client separately.
4076
4085
  *
@@ -4083,13 +4092,14 @@ var init_client = __esm({
4083
4092
  async snapshotAndWait(sandboxId, options) {
4084
4093
  const timeout = options?.timeout ?? 300;
4085
4094
  const pollInterval = options?.pollInterval ?? 1;
4095
+ const waitUntil = options?.waitUntil ?? "local_ready";
4086
4096
  const result = await this.snapshot(sandboxId, {
4087
4097
  snapshotType: options?.snapshotType
4088
4098
  });
4089
4099
  const deadline = Date.now() + timeout * 1e3;
4090
4100
  while (Date.now() < deadline) {
4091
4101
  const info = await this.getSnapshot(result.snapshotId);
4092
- if (info.status === "completed" /* COMPLETED */) return info;
4102
+ if (snapshotStatusSatisfiesWaitCondition(info.status, waitUntil)) return info;
4093
4103
  if (info.status === "failed" /* FAILED */) {
4094
4104
  throw new SandboxError(
4095
4105
  `Snapshot ${result.snapshotId} failed: ${info.error}`
@@ -4098,7 +4108,7 @@ var init_client = __esm({
4098
4108
  await sleep2(pollInterval * 1e3);
4099
4109
  }
4100
4110
  throw new SandboxError(
4101
- `Snapshot ${result.snapshotId} did not complete within ${timeout}s`
4111
+ `Snapshot ${result.snapshotId} did not reach ${waitUntil} within ${timeout}s`
4102
4112
  );
4103
4113
  }
4104
4114
  // --- Pools ---
@@ -4905,23 +4915,26 @@ async function executeDockerfilePlan(sandbox, plan, emit, sleep3) {
4905
4915
  );
4906
4916
  }
4907
4917
  }
4908
- async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic) {
4909
- if (!context.organizationId || !context.projectId) {
4910
- throw new Error(
4911
- "Organization ID and Project ID are required. Run 'tl login' and 'tl init'."
4912
- );
4913
- }
4918
+ async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic, snapshotFormatVersion) {
4914
4919
  const bearerToken = context.apiKey ?? context.personalAccessToken;
4915
4920
  if (!bearerToken) {
4916
4921
  throw new Error("Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT.");
4917
4922
  }
4918
4923
  const baseUrl = context.apiUrl.replace(/\/+$/, "");
4919
- const url = `${baseUrl}/platform/v1/organizations/${encodeURIComponent(context.organizationId)}/projects/${encodeURIComponent(context.projectId)}/sandbox-templates`;
4920
4924
  const headers = {
4921
4925
  Authorization: `Bearer ${bearerToken}`,
4922
4926
  "Content-Type": "application/json"
4923
4927
  };
4924
- if (context.personalAccessToken && !context.apiKey) {
4928
+ let url;
4929
+ if (context.apiKey) {
4930
+ url = `${baseUrl}/platform/v1/sandbox-templates`;
4931
+ } else {
4932
+ if (!context.organizationId || !context.projectId) {
4933
+ throw new Error(
4934
+ "Personal Access Token authentication requires TENSORLAKE_ORGANIZATION_ID and TENSORLAKE_PROJECT_ID to be set (e.g. via 'tl login && tl init'). To skip this requirement, authenticate with TENSORLAKE_API_KEY instead \u2014 API keys are bound to a single project at creation."
4935
+ );
4936
+ }
4937
+ url = `${baseUrl}/platform/v1/organizations/${encodeURIComponent(context.organizationId)}/projects/${encodeURIComponent(context.projectId)}/sandbox-templates`;
4925
4938
  headers["X-Forwarded-Organization-Id"] = context.organizationId;
4926
4939
  headers["X-Forwarded-Project-Id"] = context.projectId;
4927
4940
  }
@@ -4934,6 +4947,7 @@ async function registerImage(context, name, dockerfile, snapshotId, snapshotSand
4934
4947
  snapshotId,
4935
4948
  snapshotSandboxId,
4936
4949
  snapshotUri,
4950
+ ...snapshotFormatVersion ? { snapshotFormatVersion } : {},
4937
4951
  snapshotSizeBytes,
4938
4952
  rootfsDiskBytes,
4939
4953
  public: isPublic
@@ -4976,7 +4990,8 @@ async function createSandboxImage(source, options = {}, deps = {}) {
4976
4990
  await executeDockerfilePlan(sandbox, plan, emit, sleep3);
4977
4991
  emit({ type: "status", message: "Creating snapshot..." });
4978
4992
  const snapshot = await client.snapshotAndWait(sandbox.sandboxId, {
4979
- snapshotType: "filesystem"
4993
+ snapshotType: "filesystem",
4994
+ waitUntil: "completed"
4980
4995
  });
4981
4996
  emit({
4982
4997
  type: "snapshot_created",
@@ -5010,7 +5025,8 @@ async function createSandboxImage(source, options = {}, deps = {}) {
5010
5025
  snapshot.snapshotUri,
5011
5026
  snapshot.sizeBytes,
5012
5027
  snapshot.rootfsDiskBytes,
5013
- options.isPublic ?? false
5028
+ options.isPublic ?? false,
5029
+ snapshot.snapshotFormatVersion
5014
5030
  );
5015
5031
  emit({
5016
5032
  type: "image_registered",
@@ -5100,6 +5116,7 @@ export {
5100
5116
  loadDockerfilePlan,
5101
5117
  loadImagePlan,
5102
5118
  logicalDockerfileLines,
5119
+ registerImage,
5103
5120
  runCreateSandboxImageCli
5104
5121
  };
5105
5122
  //# sourceMappingURL=sandbox-image.js.map