tensorlake 0.5.7 → 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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as SandboxPortAccess, q as SnapshotOptions, r as CreateSnapshotResponse, s as SnapshotAndWaitOptions, t as CreatePoolOptions, u as CreateSandboxPoolResponse, v as SandboxPoolInfo, w as UpdatePoolOptions } from './sandbox-image-BMDaNpZ2.cjs';
2
- export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as StdinMode, Z as createSandboxImage, _ as dockerfileContent } from './sandbox-image-BMDaNpZ2.cjs';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as SandboxPortAccess, q as SnapshotOptions, r as CreateSnapshotResponse, s as SnapshotAndWaitOptions, t as CreatePoolOptions, u as CreateSandboxPoolResponse, v as SandboxPoolInfo, w as UpdatePoolOptions } from './sandbox-image-CUEKMhZ1.cjs';
2
+ export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as SnapshotWaitCondition, Z as StdinMode, _ as createSandboxImage, $ as dockerfileContent } from './sandbox-image-CUEKMhZ1.cjs';
3
3
 
4
4
  /**
5
5
  * The return value of every SDK operation. Carries the W3C `trace_id` so callers
@@ -236,11 +236,10 @@ declare class Sandbox {
236
236
  */
237
237
  resume(options?: SuspendResumeOptions): Promise<void>;
238
238
  /**
239
- * Create a snapshot of this sandbox's filesystem and wait for it to
240
- * be committed.
239
+ * Create a checkpoint of this sandbox and wait for it to be locally ready.
241
240
  *
242
- * By default blocks until the snapshot artifact is ready and returns
243
- * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
241
+ * By default blocks until the checkpoint is resumable and returns
242
+ * `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
244
243
  * (returns `undefined`).
245
244
  */
246
245
  checkpoint(options?: CheckpointOptions): Promise<Traced<SnapshotInfo> | undefined>;
@@ -413,7 +412,8 @@ declare class SandboxClient {
413
412
  *
414
413
  * This call **returns immediately** with a `snapshotId` and `in_progress`
415
414
  * status — the snapshot is created asynchronously. Poll `getSnapshot()` until
416
- * `completed` or `failed`, or use `snapshotAndWait()` to block automatically.
415
+ * `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
416
+ * block automatically.
417
417
  *
418
418
  * @param options.snapshotType - `"filesystem"` for cold-boot snapshots (e.g. image builds).
419
419
  * Omit to use the server default (`filesystem`).
@@ -426,9 +426,11 @@ declare class SandboxClient {
426
426
  /** Delete a snapshot by ID. */
427
427
  deleteSnapshot(snapshotId: string): Promise<void>;
428
428
  /**
429
- * Create a snapshot and block until it is committed.
429
+ * Create a snapshot and block until it is locally ready.
430
430
  *
431
- * Combines `snapshot()` with polling `getSnapshot()` until `completed`.
431
+ * Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
432
+ * or `completed`. Pass `{ waitUntil: "completed" }` when durable
433
+ * `snapshotUri` metadata is required.
432
434
  * Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
433
435
  * without managing the client separately.
434
436
  *
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as SandboxPortAccess, q as SnapshotOptions, r as CreateSnapshotResponse, s as SnapshotAndWaitOptions, t as CreatePoolOptions, u as CreateSandboxPoolResponse, v as SandboxPoolInfo, w as UpdatePoolOptions } from './sandbox-image-BMDaNpZ2.js';
2
- export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as StdinMode, Z as createSandboxImage, _ as dockerfileContent } from './sandbox-image-BMDaNpZ2.js';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, g as SuspendResumeOptions, h as CheckpointOptions, R as RunOptions, i as CommandResult, j as StartProcessOptions, P as ProcessInfo, k as SendSignalResponse, O as OutputResponse, l as OutputEvent, L as ListDirectoryResponse, m as PtySessionInfo, H as HealthResponse, D as DaemonInfo, n as CreateSandboxOptions, o as CreateSandboxResponse, p as SandboxPortAccess, q as SnapshotOptions, r as CreateSnapshotResponse, s as SnapshotAndWaitOptions, t as CreatePoolOptions, u as CreateSandboxPoolResponse, v as SandboxPoolInfo, w as UpdatePoolOptions } from './sandbox-image-CUEKMhZ1.js';
2
+ export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as SnapshotWaitCondition, Z as StdinMode, _ as createSandboxImage, $ as dockerfileContent } from './sandbox-image-CUEKMhZ1.js';
3
3
 
4
4
  /**
5
5
  * The return value of every SDK operation. Carries the W3C `trace_id` so callers
@@ -236,11 +236,10 @@ declare class Sandbox {
236
236
  */
237
237
  resume(options?: SuspendResumeOptions): Promise<void>;
238
238
  /**
239
- * Create a snapshot of this sandbox's filesystem and wait for it to
240
- * be committed.
239
+ * Create a checkpoint of this sandbox and wait for it to be locally ready.
241
240
  *
242
- * By default blocks until the snapshot artifact is ready and returns
243
- * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
241
+ * By default blocks until the checkpoint is resumable and returns
242
+ * `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
244
243
  * (returns `undefined`).
245
244
  */
246
245
  checkpoint(options?: CheckpointOptions): Promise<Traced<SnapshotInfo> | undefined>;
@@ -413,7 +412,8 @@ declare class SandboxClient {
413
412
  *
414
413
  * This call **returns immediately** with a `snapshotId` and `in_progress`
415
414
  * status — the snapshot is created asynchronously. Poll `getSnapshot()` until
416
- * `completed` or `failed`, or use `snapshotAndWait()` to block automatically.
415
+ * `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
416
+ * block automatically.
417
417
  *
418
418
  * @param options.snapshotType - `"filesystem"` for cold-boot snapshots (e.g. image builds).
419
419
  * Omit to use the server default (`filesystem`).
@@ -426,9 +426,11 @@ declare class SandboxClient {
426
426
  /** Delete a snapshot by ID. */
427
427
  deleteSnapshot(snapshotId: string): Promise<void>;
428
428
  /**
429
- * Create a snapshot and block until it is committed.
429
+ * Create a snapshot and block until it is locally ready.
430
430
  *
431
- * Combines `snapshot()` with polling `getSnapshot()` until `completed`.
431
+ * Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
432
+ * or `completed`. Pass `{ waitUntil: "completed" }` when durable
433
+ * `snapshotUri` metadata is required.
432
434
  * Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
433
435
  * without managing the client separately.
434
436
  *
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
13
13
  var init_defaults = __esm({
14
14
  "src/defaults.ts"() {
15
15
  "use strict";
16
- SDK_VERSION = "0.5.7";
16
+ SDK_VERSION = "0.5.10";
17
17
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
18
18
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
19
19
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -408,11 +408,12 @@ var init_models = __esm({
408
408
  SandboxStatus3["TERMINATED"] = "terminated";
409
409
  return SandboxStatus3;
410
410
  })(SandboxStatus || {});
411
- SnapshotStatus = /* @__PURE__ */ ((SnapshotStatus3) => {
412
- SnapshotStatus3["IN_PROGRESS"] = "in_progress";
413
- SnapshotStatus3["COMPLETED"] = "completed";
414
- SnapshotStatus3["FAILED"] = "failed";
415
- return SnapshotStatus3;
411
+ SnapshotStatus = /* @__PURE__ */ ((SnapshotStatus2) => {
412
+ SnapshotStatus2["IN_PROGRESS"] = "in_progress";
413
+ SnapshotStatus2["LOCAL_READY"] = "local_ready";
414
+ SnapshotStatus2["COMPLETED"] = "completed";
415
+ SnapshotStatus2["FAILED"] = "failed";
416
+ return SnapshotStatus2;
416
417
  })(SnapshotStatus || {});
417
418
  ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
418
419
  ProcessStatus2["RUNNING"] = "running";
@@ -3377,11 +3378,10 @@ var init_sandbox = __esm({
3377
3378
  await client.resume(this.lifecycleIdentifier, options);
3378
3379
  }
3379
3380
  /**
3380
- * Create a snapshot of this sandbox's filesystem and wait for it to
3381
- * be committed.
3381
+ * Create a checkpoint of this sandbox and wait for it to be locally ready.
3382
3382
  *
3383
- * By default blocks until the snapshot artifact is ready and returns
3384
- * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
3383
+ * By default blocks until the checkpoint is resumable and returns
3384
+ * `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
3385
3385
  * (returns `undefined`).
3386
3386
  */
3387
3387
  async checkpoint(options) {
@@ -3393,7 +3393,8 @@ var init_sandbox = __esm({
3393
3393
  return client.snapshotAndWait(this.lifecycleIdentifier, {
3394
3394
  timeout: options?.timeout,
3395
3395
  pollInterval: options?.pollInterval,
3396
- snapshotType: options?.checkpointType
3396
+ snapshotType: options?.checkpointType,
3397
+ waitUntil: options?.waitUntil
3397
3398
  });
3398
3399
  }
3399
3400
  /**
@@ -3788,6 +3789,12 @@ __export(client_exports, {
3788
3789
  function sleep2(ms) {
3789
3790
  return new Promise((resolve) => setTimeout(resolve, ms));
3790
3791
  }
3792
+ function snapshotStatusSatisfiesWaitCondition(status, waitUntil) {
3793
+ if (waitUntil === "local_ready") {
3794
+ return status === "local_ready" /* LOCAL_READY */ || status === "completed" /* COMPLETED */;
3795
+ }
3796
+ return status === "completed" /* COMPLETED */;
3797
+ }
3791
3798
  function formatStartupFailureMessage(sandboxId, status, options) {
3792
3799
  const prefix = status === "terminated" /* TERMINATED */ ? `Sandbox ${sandboxId} terminated during startup` : `Sandbox ${sandboxId} became ${status} during startup`;
3793
3800
  const detail = formatErrorDetails(options.errorDetails);
@@ -4088,7 +4095,8 @@ var init_client = __esm({
4088
4095
  *
4089
4096
  * This call **returns immediately** with a `snapshotId` and `in_progress`
4090
4097
  * status — the snapshot is created asynchronously. Poll `getSnapshot()` until
4091
- * `completed` or `failed`, or use `snapshotAndWait()` to block automatically.
4098
+ * `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
4099
+ * block automatically.
4092
4100
  *
4093
4101
  * @param options.snapshotType - `"filesystem"` for cold-boot snapshots (e.g. image builds).
4094
4102
  * Omit to use the server default (`filesystem`).
@@ -4129,9 +4137,11 @@ var init_client = __esm({
4129
4137
  );
4130
4138
  }
4131
4139
  /**
4132
- * Create a snapshot and block until it is committed.
4140
+ * Create a snapshot and block until it is locally ready.
4133
4141
  *
4134
- * Combines `snapshot()` with polling `getSnapshot()` until `completed`.
4142
+ * Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
4143
+ * or `completed`. Pass `{ waitUntil: "completed" }` when durable
4144
+ * `snapshotUri` metadata is required.
4135
4145
  * Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
4136
4146
  * without managing the client separately.
4137
4147
  *
@@ -4144,13 +4154,14 @@ var init_client = __esm({
4144
4154
  async snapshotAndWait(sandboxId, options) {
4145
4155
  const timeout = options?.timeout ?? 300;
4146
4156
  const pollInterval = options?.pollInterval ?? 1;
4157
+ const waitUntil = options?.waitUntil ?? "local_ready";
4147
4158
  const result = await this.snapshot(sandboxId, {
4148
4159
  snapshotType: options?.snapshotType
4149
4160
  });
4150
4161
  const deadline = Date.now() + timeout * 1e3;
4151
4162
  while (Date.now() < deadline) {
4152
4163
  const info = await this.getSnapshot(result.snapshotId);
4153
- if (info.status === "completed" /* COMPLETED */) return info;
4164
+ if (snapshotStatusSatisfiesWaitCondition(info.status, waitUntil)) return info;
4154
4165
  if (info.status === "failed" /* FAILED */) {
4155
4166
  throw new SandboxError(
4156
4167
  `Snapshot ${result.snapshotId} failed: ${info.error}`
@@ -4159,7 +4170,7 @@ var init_client = __esm({
4159
4170
  await sleep2(pollInterval * 1e3);
4160
4171
  }
4161
4172
  throw new SandboxError(
4162
- `Snapshot ${result.snapshotId} did not complete within ${timeout}s`
4173
+ `Snapshot ${result.snapshotId} did not reach ${waitUntil} within ${timeout}s`
4163
4174
  );
4164
4175
  }
4165
4176
  // --- Pools ---
@@ -4444,6 +4455,7 @@ __export(sandbox_image_exports, {
4444
4455
  loadDockerfilePlan: () => loadDockerfilePlan,
4445
4456
  loadImagePlan: () => loadImagePlan,
4446
4457
  logicalDockerfileLines: () => logicalDockerfileLines,
4458
+ registerImage: () => registerImage,
4447
4459
  runCreateSandboxImageCli: () => runCreateSandboxImageCli
4448
4460
  });
4449
4461
  import { readFile, readdir, stat } from "fs/promises";
@@ -5069,23 +5081,26 @@ async function executeDockerfilePlan(sandbox, plan, emit, sleep3) {
5069
5081
  );
5070
5082
  }
5071
5083
  }
5072
- async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic) {
5073
- if (!context.organizationId || !context.projectId) {
5074
- throw new Error(
5075
- "Organization ID and Project ID are required. Run 'tl login' and 'tl init'."
5076
- );
5077
- }
5084
+ async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic, snapshotFormatVersion) {
5078
5085
  const bearerToken = context.apiKey ?? context.personalAccessToken;
5079
5086
  if (!bearerToken) {
5080
5087
  throw new Error("Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT.");
5081
5088
  }
5082
5089
  const baseUrl = context.apiUrl.replace(/\/+$/, "");
5083
- const url = `${baseUrl}/platform/v1/organizations/${encodeURIComponent(context.organizationId)}/projects/${encodeURIComponent(context.projectId)}/sandbox-templates`;
5084
5090
  const headers = {
5085
5091
  Authorization: `Bearer ${bearerToken}`,
5086
5092
  "Content-Type": "application/json"
5087
5093
  };
5088
- if (context.personalAccessToken && !context.apiKey) {
5094
+ let url;
5095
+ if (context.apiKey) {
5096
+ url = `${baseUrl}/platform/v1/sandbox-templates`;
5097
+ } else {
5098
+ if (!context.organizationId || !context.projectId) {
5099
+ throw new Error(
5100
+ "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."
5101
+ );
5102
+ }
5103
+ url = `${baseUrl}/platform/v1/organizations/${encodeURIComponent(context.organizationId)}/projects/${encodeURIComponent(context.projectId)}/sandbox-templates`;
5089
5104
  headers["X-Forwarded-Organization-Id"] = context.organizationId;
5090
5105
  headers["X-Forwarded-Project-Id"] = context.projectId;
5091
5106
  }
@@ -5098,6 +5113,7 @@ async function registerImage(context, name, dockerfile, snapshotId, snapshotSand
5098
5113
  snapshotId,
5099
5114
  snapshotSandboxId,
5100
5115
  snapshotUri,
5116
+ ...snapshotFormatVersion ? { snapshotFormatVersion } : {},
5101
5117
  snapshotSizeBytes,
5102
5118
  rootfsDiskBytes,
5103
5119
  public: isPublic
@@ -5140,7 +5156,8 @@ async function createSandboxImage(source, options = {}, deps = {}) {
5140
5156
  await executeDockerfilePlan(sandbox, plan, emit, sleep3);
5141
5157
  emit({ type: "status", message: "Creating snapshot..." });
5142
5158
  const snapshot = await client.snapshotAndWait(sandbox.sandboxId, {
5143
- snapshotType: "filesystem"
5159
+ snapshotType: "filesystem",
5160
+ waitUntil: "completed"
5144
5161
  });
5145
5162
  emit({
5146
5163
  type: "snapshot_created",
@@ -5174,7 +5191,8 @@ async function createSandboxImage(source, options = {}, deps = {}) {
5174
5191
  snapshot.snapshotUri,
5175
5192
  snapshot.sizeBytes,
5176
5193
  snapshot.rootfsDiskBytes,
5177
- options.isPublic ?? false
5194
+ options.isPublic ?? false,
5195
+ snapshot.snapshotFormatVersion
5178
5196
  );
5179
5197
  emit({
5180
5198
  type: "image_registered",