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.
package/dist/index.d.cts CHANGED
@@ -146,7 +146,7 @@ declare class SandboxClient {
146
146
  listPools(): Promise<SandboxPoolInfo[]>;
147
147
  updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
148
148
  deletePool(poolId: string): Promise<void>;
149
- connect(sandboxId: string, proxyUrl?: string): Sandbox;
149
+ connect(identifier: string, proxyUrl?: string): Sandbox;
150
150
  createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
151
151
  }
152
152
 
package/dist/index.d.ts CHANGED
@@ -146,7 +146,7 @@ declare class SandboxClient {
146
146
  listPools(): Promise<SandboxPoolInfo[]>;
147
147
  updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
148
148
  deletePool(poolId: string): Promise<void>;
149
- connect(sandboxId: string, proxyUrl?: string): Sandbox;
149
+ connect(identifier: string, proxyUrl?: string): Sandbox;
150
150
  createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
151
151
  }
152
152
 
package/dist/index.js CHANGED
@@ -96,7 +96,8 @@ var HttpClient = class {
96
96
  timeoutMs;
97
97
  abortController = null;
98
98
  constructor(options) {
99
- this.baseUrl = options.baseUrl.replace(/\/+$/, "");
99
+ const url = options.baseUrl;
100
+ this.baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
100
101
  this.maxRetries = options.maxRetries ?? MAX_RETRIES;
101
102
  this.retryBackoffMs = options.retryBackoffMs ?? RETRY_BACKOFF_MS;
102
103
  this.timeoutMs = options.timeoutMs ?? DEFAULT_HTTP_TIMEOUT_MS;
@@ -424,6 +425,9 @@ async function* parseSSEStream(stream, signal) {
424
425
  }
425
426
 
426
427
  // src/url.ts
428
+ function trimTrailingSlashes(url) {
429
+ return url.endsWith("/") ? url.slice(0, -1) : url;
430
+ }
427
431
  function isLocalhost(apiUrl) {
428
432
  try {
429
433
  const parsed = new URL(apiUrl);
@@ -453,7 +457,7 @@ function resolveProxyTarget(proxyUrl, sandboxId) {
453
457
  const host = parsed.hostname;
454
458
  if (host === "localhost" || host === "127.0.0.1") {
455
459
  return {
456
- baseUrl: proxyUrl.replace(/\/+$/, ""),
460
+ baseUrl: trimTrailingSlashes(proxyUrl),
457
461
  hostHeader: `${sandboxId}.local`
458
462
  };
459
463
  }
@@ -464,7 +468,7 @@ function resolveProxyTarget(proxyUrl, sandboxId) {
464
468
  };
465
469
  } catch {
466
470
  return {
467
- baseUrl: `${proxyUrl.replace(/\/+$/, "")}/${sandboxId}`,
471
+ baseUrl: `${trimTrailingSlashes(proxyUrl)}/${sandboxId}`,
468
472
  hostHeader: void 0
469
473
  };
470
474
  }
@@ -1259,10 +1263,10 @@ var SandboxClient = class _SandboxClient {
1259
1263
  );
1260
1264
  }
1261
1265
  // --- Connect ---
1262
- connect(sandboxId, proxyUrl) {
1266
+ connect(identifier, proxyUrl) {
1263
1267
  const resolvedProxy = proxyUrl ?? resolveProxyUrl(this.apiUrl);
1264
1268
  return new Sandbox({
1265
- sandboxId,
1269
+ sandboxId: identifier,
1266
1270
  proxyUrl: resolvedProxy,
1267
1271
  apiKey: this.apiKey,
1268
1272
  organizationId: this.organizationId,
@@ -1499,7 +1503,7 @@ var CloudClient = class _CloudClient {
1499
1503
  );
1500
1504
  const response = await this.http.requestResponse(
1501
1505
  "PUT",
1502
- `${trimTrailingSlashes(buildServicePath)}/builds`,
1506
+ `${trimTrailingSlashes2(buildServicePath)}/builds`,
1503
1507
  { body: form }
1504
1508
  );
1505
1509
  const raw = await parseJsonResponse(response);
@@ -1509,7 +1513,7 @@ var CloudClient = class _CloudClient {
1509
1513
  const form = createApplicationBuildForm(request, imageContexts);
1510
1514
  const response = await this.http.requestResponse(
1511
1515
  "POST",
1512
- trimTrailingSlashes(buildServicePath),
1516
+ trimTrailingSlashes2(buildServicePath),
1513
1517
  { body: form }
1514
1518
  );
1515
1519
  const raw = await parseJsonResponse(response);
@@ -1518,34 +1522,34 @@ var CloudClient = class _CloudClient {
1518
1522
  async applicationBuildInfo(buildServicePath, applicationBuildId) {
1519
1523
  const raw = await this.http.requestJson(
1520
1524
  "GET",
1521
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1525
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1522
1526
  );
1523
1527
  return fromSnakeKeys(raw);
1524
1528
  }
1525
1529
  async cancelApplicationBuild(buildServicePath, applicationBuildId) {
1526
1530
  const raw = await this.http.requestJson(
1527
1531
  "POST",
1528
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1532
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1529
1533
  );
1530
1534
  return fromSnakeKeys(raw);
1531
1535
  }
1532
1536
  async buildInfo(buildServicePath, buildId) {
1533
1537
  const raw = await this.http.requestJson(
1534
1538
  "GET",
1535
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1539
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1536
1540
  );
1537
1541
  return fromSnakeKeys(raw);
1538
1542
  }
1539
1543
  async cancelBuild(buildServicePath, buildId) {
1540
1544
  await this.http.requestResponse(
1541
1545
  "POST",
1542
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1546
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1543
1547
  );
1544
1548
  }
1545
1549
  async *streamBuildLogs(buildServicePath, buildId, signal) {
1546
1550
  const stream = await this.http.requestStream(
1547
1551
  "GET",
1548
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1552
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1549
1553
  { signal }
1550
1554
  );
1551
1555
  for await (const event of parseSSEStream(stream, signal)) {
@@ -1621,8 +1625,8 @@ function createApplicationBuildForm(request, imageContexts) {
1621
1625
  }
1622
1626
  return form;
1623
1627
  }
1624
- function trimTrailingSlashes(value) {
1625
- return value.replace(/\/+$/, "");
1628
+ function trimTrailingSlashes2(value) {
1629
+ return value.endsWith("/") ? value.slice(0, -1) : value;
1626
1630
  }
1627
1631
  function toBlobPart(data) {
1628
1632
  if (typeof data === "string" || data instanceof Blob) {