tensorlake 0.4.41 → 0.4.42

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
  }
@@ -1319,10 +1323,10 @@ var SandboxClient = class _SandboxClient {
1319
1323
  );
1320
1324
  }
1321
1325
  // --- Connect ---
1322
- connect(sandboxId, proxyUrl) {
1326
+ connect(identifier, proxyUrl) {
1323
1327
  const resolvedProxy = proxyUrl ?? resolveProxyUrl(this.apiUrl);
1324
1328
  return new Sandbox({
1325
- sandboxId,
1329
+ sandboxId: identifier,
1326
1330
  proxyUrl: resolvedProxy,
1327
1331
  apiKey: this.apiKey,
1328
1332
  organizationId: this.organizationId,
@@ -1559,7 +1563,7 @@ var CloudClient = class _CloudClient {
1559
1563
  );
1560
1564
  const response = await this.http.requestResponse(
1561
1565
  "PUT",
1562
- `${trimTrailingSlashes(buildServicePath)}/builds`,
1566
+ `${trimTrailingSlashes2(buildServicePath)}/builds`,
1563
1567
  { body: form }
1564
1568
  );
1565
1569
  const raw = await parseJsonResponse(response);
@@ -1569,7 +1573,7 @@ var CloudClient = class _CloudClient {
1569
1573
  const form = createApplicationBuildForm(request, imageContexts);
1570
1574
  const response = await this.http.requestResponse(
1571
1575
  "POST",
1572
- trimTrailingSlashes(buildServicePath),
1576
+ trimTrailingSlashes2(buildServicePath),
1573
1577
  { body: form }
1574
1578
  );
1575
1579
  const raw = await parseJsonResponse(response);
@@ -1578,34 +1582,34 @@ var CloudClient = class _CloudClient {
1578
1582
  async applicationBuildInfo(buildServicePath, applicationBuildId) {
1579
1583
  const raw = await this.http.requestJson(
1580
1584
  "GET",
1581
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1585
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1582
1586
  );
1583
1587
  return fromSnakeKeys(raw);
1584
1588
  }
1585
1589
  async cancelApplicationBuild(buildServicePath, applicationBuildId) {
1586
1590
  const raw = await this.http.requestJson(
1587
1591
  "POST",
1588
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1592
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1589
1593
  );
1590
1594
  return fromSnakeKeys(raw);
1591
1595
  }
1592
1596
  async buildInfo(buildServicePath, buildId) {
1593
1597
  const raw = await this.http.requestJson(
1594
1598
  "GET",
1595
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1599
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1596
1600
  );
1597
1601
  return fromSnakeKeys(raw);
1598
1602
  }
1599
1603
  async cancelBuild(buildServicePath, buildId) {
1600
1604
  await this.http.requestResponse(
1601
1605
  "POST",
1602
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1606
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1603
1607
  );
1604
1608
  }
1605
1609
  async *streamBuildLogs(buildServicePath, buildId, signal) {
1606
1610
  const stream = await this.http.requestStream(
1607
1611
  "GET",
1608
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1612
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1609
1613
  { signal }
1610
1614
  );
1611
1615
  for await (const event of parseSSEStream(stream, signal)) {
@@ -1681,8 +1685,8 @@ function createApplicationBuildForm(request, imageContexts) {
1681
1685
  }
1682
1686
  return form;
1683
1687
  }
1684
- function trimTrailingSlashes(value) {
1685
- return value.replace(/\/+$/, "");
1688
+ function trimTrailingSlashes2(value) {
1689
+ return value.endsWith("/") ? value.slice(0, -1) : value;
1686
1690
  }
1687
1691
  function toBlobPart(data) {
1688
1692
  if (typeof data === "string" || data instanceof Blob) {