tensorlake 0.4.41 → 0.4.43

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
@@ -156,7 +156,8 @@ var HttpClient = class {
156
156
  timeoutMs;
157
157
  abortController = null;
158
158
  constructor(options) {
159
- this.baseUrl = options.baseUrl.replace(/\/+$/, "");
159
+ const url = options.baseUrl;
160
+ this.baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
160
161
  this.maxRetries = options.maxRetries ?? MAX_RETRIES;
161
162
  this.retryBackoffMs = options.retryBackoffMs ?? RETRY_BACKOFF_MS;
162
163
  this.timeoutMs = options.timeoutMs ?? DEFAULT_HTTP_TIMEOUT_MS;
@@ -484,6 +485,9 @@ async function* parseSSEStream(stream, signal) {
484
485
  }
485
486
 
486
487
  // src/url.ts
488
+ function trimTrailingSlashes(url) {
489
+ return url.endsWith("/") ? url.slice(0, -1) : url;
490
+ }
487
491
  function isLocalhost(apiUrl) {
488
492
  try {
489
493
  const parsed = new URL(apiUrl);
@@ -513,7 +517,7 @@ function resolveProxyTarget(proxyUrl, sandboxId) {
513
517
  const host = parsed.hostname;
514
518
  if (host === "localhost" || host === "127.0.0.1") {
515
519
  return {
516
- baseUrl: proxyUrl.replace(/\/+$/, ""),
520
+ baseUrl: trimTrailingSlashes(proxyUrl),
517
521
  hostHeader: `${sandboxId}.local`
518
522
  };
519
523
  }
@@ -524,7 +528,7 @@ function resolveProxyTarget(proxyUrl, sandboxId) {
524
528
  };
525
529
  } catch {
526
530
  return {
527
- baseUrl: `${proxyUrl.replace(/\/+$/, "")}/${sandboxId}`,
531
+ baseUrl: `${trimTrailingSlashes(proxyUrl)}/${sandboxId}`,
528
532
  hostHeader: void 0
529
533
  };
530
534
  }
@@ -1205,10 +1209,12 @@ var SandboxClient = class _SandboxClient {
1205
1209
  return fromSnakeKeys(raw, "sandboxId");
1206
1210
  }
1207
1211
  // --- Snapshots ---
1208
- async snapshot(sandboxId) {
1212
+ async snapshot(sandboxId, options) {
1213
+ const requestOptions = options?.contentMode != null ? { body: { snapshot_content_mode: options.contentMode } } : void 0;
1209
1214
  const raw = await this.http.requestJson(
1210
1215
  "POST",
1211
- this.path(`sandboxes/${sandboxId}/snapshot`)
1216
+ this.path(`sandboxes/${sandboxId}/snapshot`),
1217
+ requestOptions
1212
1218
  );
1213
1219
  return fromSnakeKeys(raw, "snapshotId");
1214
1220
  }
@@ -1237,7 +1243,9 @@ var SandboxClient = class _SandboxClient {
1237
1243
  async snapshotAndWait(sandboxId, options) {
1238
1244
  const timeout = options?.timeout ?? 300;
1239
1245
  const pollInterval = options?.pollInterval ?? 1;
1240
- const result = await this.snapshot(sandboxId);
1246
+ const result = await this.snapshot(sandboxId, {
1247
+ contentMode: options?.contentMode
1248
+ });
1241
1249
  const deadline = Date.now() + timeout * 1e3;
1242
1250
  while (Date.now() < deadline) {
1243
1251
  const info = await this.getSnapshot(result.snapshotId);
@@ -1319,10 +1327,10 @@ var SandboxClient = class _SandboxClient {
1319
1327
  );
1320
1328
  }
1321
1329
  // --- Connect ---
1322
- connect(sandboxId, proxyUrl) {
1330
+ connect(identifier, proxyUrl) {
1323
1331
  const resolvedProxy = proxyUrl ?? resolveProxyUrl(this.apiUrl);
1324
1332
  return new Sandbox({
1325
- sandboxId,
1333
+ sandboxId: identifier,
1326
1334
  proxyUrl: resolvedProxy,
1327
1335
  apiKey: this.apiKey,
1328
1336
  organizationId: this.organizationId,
@@ -1559,7 +1567,7 @@ var CloudClient = class _CloudClient {
1559
1567
  );
1560
1568
  const response = await this.http.requestResponse(
1561
1569
  "PUT",
1562
- `${trimTrailingSlashes(buildServicePath)}/builds`,
1570
+ `${trimTrailingSlashes2(buildServicePath)}/builds`,
1563
1571
  { body: form }
1564
1572
  );
1565
1573
  const raw = await parseJsonResponse(response);
@@ -1569,7 +1577,7 @@ var CloudClient = class _CloudClient {
1569
1577
  const form = createApplicationBuildForm(request, imageContexts);
1570
1578
  const response = await this.http.requestResponse(
1571
1579
  "POST",
1572
- trimTrailingSlashes(buildServicePath),
1580
+ trimTrailingSlashes2(buildServicePath),
1573
1581
  { body: form }
1574
1582
  );
1575
1583
  const raw = await parseJsonResponse(response);
@@ -1578,34 +1586,34 @@ var CloudClient = class _CloudClient {
1578
1586
  async applicationBuildInfo(buildServicePath, applicationBuildId) {
1579
1587
  const raw = await this.http.requestJson(
1580
1588
  "GET",
1581
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1589
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1582
1590
  );
1583
1591
  return fromSnakeKeys(raw);
1584
1592
  }
1585
1593
  async cancelApplicationBuild(buildServicePath, applicationBuildId) {
1586
1594
  const raw = await this.http.requestJson(
1587
1595
  "POST",
1588
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1596
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1589
1597
  );
1590
1598
  return fromSnakeKeys(raw);
1591
1599
  }
1592
1600
  async buildInfo(buildServicePath, buildId) {
1593
1601
  const raw = await this.http.requestJson(
1594
1602
  "GET",
1595
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1603
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1596
1604
  );
1597
1605
  return fromSnakeKeys(raw);
1598
1606
  }
1599
1607
  async cancelBuild(buildServicePath, buildId) {
1600
1608
  await this.http.requestResponse(
1601
1609
  "POST",
1602
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1610
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1603
1611
  );
1604
1612
  }
1605
1613
  async *streamBuildLogs(buildServicePath, buildId, signal) {
1606
1614
  const stream = await this.http.requestStream(
1607
1615
  "GET",
1608
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1616
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1609
1617
  { signal }
1610
1618
  );
1611
1619
  for await (const event of parseSSEStream(stream, signal)) {
@@ -1681,8 +1689,8 @@ function createApplicationBuildForm(request, imageContexts) {
1681
1689
  }
1682
1690
  return form;
1683
1691
  }
1684
- function trimTrailingSlashes(value) {
1685
- return value.replace(/\/+$/, "");
1692
+ function trimTrailingSlashes2(value) {
1693
+ return value.endsWith("/") ? value.slice(0, -1) : value;
1686
1694
  }
1687
1695
  function toBlobPart(data) {
1688
1696
  if (typeof data === "string" || data instanceof Blob) {
@@ -2558,7 +2566,9 @@ async function createSandboxImage(source, options = {}, deps = {}) {
2558
2566
  });
2559
2567
  await executeDockerfilePlan(sandbox, plan, emit, sleep4);
2560
2568
  emit({ type: "status", message: "Creating snapshot..." });
2561
- const snapshot = await client.snapshotAndWait(sandbox.sandboxId);
2569
+ const snapshot = await client.snapshotAndWait(sandbox.sandboxId, {
2570
+ contentMode: "filesystem_only"
2571
+ });
2562
2572
  emit({
2563
2573
  type: "snapshot_created",
2564
2574
  snapshot_id: snapshot.snapshotId,