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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePtySessionOptions, S as SandboxOptions, R as RunOptions, a as CommandResult, b as StartProcessOptions, P as ProcessInfo, c as SendSignalResponse, O as OutputResponse, d as OutputEvent, L as ListDirectoryResponse, e as PtySessionInfo, H as HealthResponse, D as DaemonInfo, f as SandboxClientOptions, g as CreateSandboxOptions, h as CreateSandboxResponse, i as SandboxInfo, U as UpdateSandboxOptions, j as SandboxPortAccess, k as CreateSnapshotResponse, l as SnapshotInfo, m as SnapshotAndWaitOptions, n as CreatePoolOptions, o as CreateSandboxPoolResponse, p as SandboxPoolInfo, q as UpdatePoolOptions, r as CreateAndConnectOptions } from './sandbox-image-DKPhc4Lv.cjs';
2
- export { s as ContainerResourcesInfo, t as ContainerState, u as CreateSandboxImageOptions, v as DirectoryEntry, w as DockerfileBuildPlan, x as DockerfileInstruction, I as Image, y as ImageBuildOperation, z as ImageBuildOperationType, z as ImageBuildOperationTypeValue, A as ImageOptions, N as NetworkConfig, B as OutputMode, E as PoolContainerInfo, F as ProcessStatus, G as SandboxImageSource, J as SandboxStatus, K as SnapshotStatus, M as StdinMode, Q as createSandboxImage, T as dockerfileContent } from './sandbox-image-DKPhc4Lv.cjs';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, R as RunOptions, a as CommandResult, b as StartProcessOptions, P as ProcessInfo, c as SendSignalResponse, O as OutputResponse, d as OutputEvent, L as ListDirectoryResponse, e as PtySessionInfo, H as HealthResponse, D as DaemonInfo, f as SandboxClientOptions, g as CreateSandboxOptions, h as CreateSandboxResponse, i as SandboxInfo, U as UpdateSandboxOptions, j as SandboxPortAccess, k as SnapshotOptions, l as CreateSnapshotResponse, m as SnapshotInfo, n as SnapshotAndWaitOptions, o as CreatePoolOptions, p as CreateSandboxPoolResponse, q as SandboxPoolInfo, r as UpdatePoolOptions, s as CreateAndConnectOptions } from './sandbox-image-Dr9SQaCc.cjs';
2
+ export { t as ContainerResourcesInfo, u as ContainerState, v as CreateSandboxImageOptions, w as DirectoryEntry, x as DockerfileBuildPlan, y as DockerfileInstruction, I as Image, z as ImageBuildOperation, A as ImageBuildOperationType, A as ImageBuildOperationTypeValue, B as ImageOptions, N as NetworkConfig, E as OutputMode, F as PoolContainerInfo, G as ProcessStatus, J as SandboxImageSource, K as SandboxStatus, M as SnapshotContentMode, Q as SnapshotStatus, T as StdinMode, V as createSandboxImage, W as dockerfileContent } from './sandbox-image-Dr9SQaCc.cjs';
3
3
 
4
4
  type PtyDataHandler = (data: Uint8Array) => void;
5
5
  type PtyExitHandler = (exitCode: number) => void;
@@ -136,7 +136,7 @@ declare class SandboxClient {
136
136
  suspend(sandboxId: string): Promise<void>;
137
137
  resume(sandboxId: string): Promise<void>;
138
138
  claim(poolId: string): Promise<CreateSandboxResponse>;
139
- snapshot(sandboxId: string): Promise<CreateSnapshotResponse>;
139
+ snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
140
140
  getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
141
141
  listSnapshots(): Promise<SnapshotInfo[]>;
142
142
  deleteSnapshot(snapshotId: string): Promise<void>;
@@ -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
 
@@ -395,4 +395,4 @@ declare class RequestExecutionError extends Error {
395
395
  constructor(message: string, functionName?: string);
396
396
  }
397
397
 
398
- export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, CommandResult, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, DaemonInfo, HealthResponse, ListDirectoryResponse, type NewSecret, OutputEvent, OutputResponse, PoolInUseError, PoolNotFoundError, ProcessInfo, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, PtySessionInfo, RemoteAPIError, type RequestErrorInfo, RequestExecutionError, RequestFailedError, type RequestInput, type RequestMetadata, RequestNotFinishedError, type RequestOutput, RunOptions, Sandbox, SandboxClient, SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, SandboxInfo, SandboxNotFoundError, SandboxOptions, SandboxPoolInfo, SandboxPortAccess, type Secret, type SecretsList, type SecretsPagination, SendSignalResponse, SnapshotAndWaitOptions, SnapshotInfo, type StartImageBuildRequest, StartProcessOptions, UpdatePoolOptions, type UpsertSecretResponse };
398
+ export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, CommandResult, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, DaemonInfo, HealthResponse, ListDirectoryResponse, type NewSecret, OutputEvent, OutputResponse, PoolInUseError, PoolNotFoundError, ProcessInfo, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, PtySessionInfo, RemoteAPIError, type RequestErrorInfo, RequestExecutionError, RequestFailedError, type RequestInput, type RequestMetadata, RequestNotFinishedError, type RequestOutput, RunOptions, Sandbox, SandboxClient, SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, SandboxInfo, SandboxNotFoundError, SandboxOptions, SandboxPoolInfo, SandboxPortAccess, type Secret, type SecretsList, type SecretsPagination, SendSignalResponse, SnapshotAndWaitOptions, SnapshotInfo, SnapshotOptions, type StartImageBuildRequest, StartProcessOptions, UpdatePoolOptions, type UpsertSecretResponse };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePtySessionOptions, S as SandboxOptions, R as RunOptions, a as CommandResult, b as StartProcessOptions, P as ProcessInfo, c as SendSignalResponse, O as OutputResponse, d as OutputEvent, L as ListDirectoryResponse, e as PtySessionInfo, H as HealthResponse, D as DaemonInfo, f as SandboxClientOptions, g as CreateSandboxOptions, h as CreateSandboxResponse, i as SandboxInfo, U as UpdateSandboxOptions, j as SandboxPortAccess, k as CreateSnapshotResponse, l as SnapshotInfo, m as SnapshotAndWaitOptions, n as CreatePoolOptions, o as CreateSandboxPoolResponse, p as SandboxPoolInfo, q as UpdatePoolOptions, r as CreateAndConnectOptions } from './sandbox-image-DKPhc4Lv.js';
2
- export { s as ContainerResourcesInfo, t as ContainerState, u as CreateSandboxImageOptions, v as DirectoryEntry, w as DockerfileBuildPlan, x as DockerfileInstruction, I as Image, y as ImageBuildOperation, z as ImageBuildOperationType, z as ImageBuildOperationTypeValue, A as ImageOptions, N as NetworkConfig, B as OutputMode, E as PoolContainerInfo, F as ProcessStatus, G as SandboxImageSource, J as SandboxStatus, K as SnapshotStatus, M as StdinMode, Q as createSandboxImage, T as dockerfileContent } from './sandbox-image-DKPhc4Lv.js';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, R as RunOptions, a as CommandResult, b as StartProcessOptions, P as ProcessInfo, c as SendSignalResponse, O as OutputResponse, d as OutputEvent, L as ListDirectoryResponse, e as PtySessionInfo, H as HealthResponse, D as DaemonInfo, f as SandboxClientOptions, g as CreateSandboxOptions, h as CreateSandboxResponse, i as SandboxInfo, U as UpdateSandboxOptions, j as SandboxPortAccess, k as SnapshotOptions, l as CreateSnapshotResponse, m as SnapshotInfo, n as SnapshotAndWaitOptions, o as CreatePoolOptions, p as CreateSandboxPoolResponse, q as SandboxPoolInfo, r as UpdatePoolOptions, s as CreateAndConnectOptions } from './sandbox-image-Dr9SQaCc.js';
2
+ export { t as ContainerResourcesInfo, u as ContainerState, v as CreateSandboxImageOptions, w as DirectoryEntry, x as DockerfileBuildPlan, y as DockerfileInstruction, I as Image, z as ImageBuildOperation, A as ImageBuildOperationType, A as ImageBuildOperationTypeValue, B as ImageOptions, N as NetworkConfig, E as OutputMode, F as PoolContainerInfo, G as ProcessStatus, J as SandboxImageSource, K as SandboxStatus, M as SnapshotContentMode, Q as SnapshotStatus, T as StdinMode, V as createSandboxImage, W as dockerfileContent } from './sandbox-image-Dr9SQaCc.js';
3
3
 
4
4
  type PtyDataHandler = (data: Uint8Array) => void;
5
5
  type PtyExitHandler = (exitCode: number) => void;
@@ -136,7 +136,7 @@ declare class SandboxClient {
136
136
  suspend(sandboxId: string): Promise<void>;
137
137
  resume(sandboxId: string): Promise<void>;
138
138
  claim(poolId: string): Promise<CreateSandboxResponse>;
139
- snapshot(sandboxId: string): Promise<CreateSnapshotResponse>;
139
+ snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
140
140
  getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
141
141
  listSnapshots(): Promise<SnapshotInfo[]>;
142
142
  deleteSnapshot(snapshotId: string): Promise<void>;
@@ -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
 
@@ -395,4 +395,4 @@ declare class RequestExecutionError extends Error {
395
395
  constructor(message: string, functionName?: string);
396
396
  }
397
397
 
398
- export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, CommandResult, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, DaemonInfo, HealthResponse, ListDirectoryResponse, type NewSecret, OutputEvent, OutputResponse, PoolInUseError, PoolNotFoundError, ProcessInfo, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, PtySessionInfo, RemoteAPIError, type RequestErrorInfo, RequestExecutionError, RequestFailedError, type RequestInput, type RequestMetadata, RequestNotFinishedError, type RequestOutput, RunOptions, Sandbox, SandboxClient, SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, SandboxInfo, SandboxNotFoundError, SandboxOptions, SandboxPoolInfo, SandboxPortAccess, type Secret, type SecretsList, type SecretsPagination, SendSignalResponse, SnapshotAndWaitOptions, SnapshotInfo, type StartImageBuildRequest, StartProcessOptions, UpdatePoolOptions, type UpsertSecretResponse };
398
+ export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, CommandResult, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, DaemonInfo, HealthResponse, ListDirectoryResponse, type NewSecret, OutputEvent, OutputResponse, PoolInUseError, PoolNotFoundError, ProcessInfo, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, PtySessionInfo, RemoteAPIError, type RequestErrorInfo, RequestExecutionError, RequestFailedError, type RequestInput, type RequestMetadata, RequestNotFinishedError, type RequestOutput, RunOptions, Sandbox, SandboxClient, SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, SandboxInfo, SandboxNotFoundError, SandboxOptions, SandboxPoolInfo, SandboxPortAccess, type Secret, type SecretsList, type SecretsPagination, SendSignalResponse, SnapshotAndWaitOptions, SnapshotInfo, SnapshotOptions, type StartImageBuildRequest, StartProcessOptions, UpdatePoolOptions, type UpsertSecretResponse };
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
  }
@@ -1145,10 +1149,12 @@ var SandboxClient = class _SandboxClient {
1145
1149
  return fromSnakeKeys(raw, "sandboxId");
1146
1150
  }
1147
1151
  // --- Snapshots ---
1148
- async snapshot(sandboxId) {
1152
+ async snapshot(sandboxId, options) {
1153
+ const requestOptions = options?.contentMode != null ? { body: { snapshot_content_mode: options.contentMode } } : void 0;
1149
1154
  const raw = await this.http.requestJson(
1150
1155
  "POST",
1151
- this.path(`sandboxes/${sandboxId}/snapshot`)
1156
+ this.path(`sandboxes/${sandboxId}/snapshot`),
1157
+ requestOptions
1152
1158
  );
1153
1159
  return fromSnakeKeys(raw, "snapshotId");
1154
1160
  }
@@ -1177,7 +1183,9 @@ var SandboxClient = class _SandboxClient {
1177
1183
  async snapshotAndWait(sandboxId, options) {
1178
1184
  const timeout = options?.timeout ?? 300;
1179
1185
  const pollInterval = options?.pollInterval ?? 1;
1180
- const result = await this.snapshot(sandboxId);
1186
+ const result = await this.snapshot(sandboxId, {
1187
+ contentMode: options?.contentMode
1188
+ });
1181
1189
  const deadline = Date.now() + timeout * 1e3;
1182
1190
  while (Date.now() < deadline) {
1183
1191
  const info = await this.getSnapshot(result.snapshotId);
@@ -1259,10 +1267,10 @@ var SandboxClient = class _SandboxClient {
1259
1267
  );
1260
1268
  }
1261
1269
  // --- Connect ---
1262
- connect(sandboxId, proxyUrl) {
1270
+ connect(identifier, proxyUrl) {
1263
1271
  const resolvedProxy = proxyUrl ?? resolveProxyUrl(this.apiUrl);
1264
1272
  return new Sandbox({
1265
- sandboxId,
1273
+ sandboxId: identifier,
1266
1274
  proxyUrl: resolvedProxy,
1267
1275
  apiKey: this.apiKey,
1268
1276
  organizationId: this.organizationId,
@@ -1499,7 +1507,7 @@ var CloudClient = class _CloudClient {
1499
1507
  );
1500
1508
  const response = await this.http.requestResponse(
1501
1509
  "PUT",
1502
- `${trimTrailingSlashes(buildServicePath)}/builds`,
1510
+ `${trimTrailingSlashes2(buildServicePath)}/builds`,
1503
1511
  { body: form }
1504
1512
  );
1505
1513
  const raw = await parseJsonResponse(response);
@@ -1509,7 +1517,7 @@ var CloudClient = class _CloudClient {
1509
1517
  const form = createApplicationBuildForm(request, imageContexts);
1510
1518
  const response = await this.http.requestResponse(
1511
1519
  "POST",
1512
- trimTrailingSlashes(buildServicePath),
1520
+ trimTrailingSlashes2(buildServicePath),
1513
1521
  { body: form }
1514
1522
  );
1515
1523
  const raw = await parseJsonResponse(response);
@@ -1518,34 +1526,34 @@ var CloudClient = class _CloudClient {
1518
1526
  async applicationBuildInfo(buildServicePath, applicationBuildId) {
1519
1527
  const raw = await this.http.requestJson(
1520
1528
  "GET",
1521
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1529
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1522
1530
  );
1523
1531
  return fromSnakeKeys(raw);
1524
1532
  }
1525
1533
  async cancelApplicationBuild(buildServicePath, applicationBuildId) {
1526
1534
  const raw = await this.http.requestJson(
1527
1535
  "POST",
1528
- `${trimTrailingSlashes(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1536
+ `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1529
1537
  );
1530
1538
  return fromSnakeKeys(raw);
1531
1539
  }
1532
1540
  async buildInfo(buildServicePath, buildId) {
1533
1541
  const raw = await this.http.requestJson(
1534
1542
  "GET",
1535
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1543
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1536
1544
  );
1537
1545
  return fromSnakeKeys(raw);
1538
1546
  }
1539
1547
  async cancelBuild(buildServicePath, buildId) {
1540
1548
  await this.http.requestResponse(
1541
1549
  "POST",
1542
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1550
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1543
1551
  );
1544
1552
  }
1545
1553
  async *streamBuildLogs(buildServicePath, buildId, signal) {
1546
1554
  const stream = await this.http.requestStream(
1547
1555
  "GET",
1548
- `${trimTrailingSlashes(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1556
+ `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1549
1557
  { signal }
1550
1558
  );
1551
1559
  for await (const event of parseSSEStream(stream, signal)) {
@@ -1621,8 +1629,8 @@ function createApplicationBuildForm(request, imageContexts) {
1621
1629
  }
1622
1630
  return form;
1623
1631
  }
1624
- function trimTrailingSlashes(value) {
1625
- return value.replace(/\/+$/, "");
1632
+ function trimTrailingSlashes2(value) {
1633
+ return value.endsWith("/") ? value.slice(0, -1) : value;
1626
1634
  }
1627
1635
  function toBlobPart(data) {
1628
1636
  if (typeof data === "string" || data instanceof Blob) {
@@ -2498,7 +2506,9 @@ async function createSandboxImage(source, options = {}, deps = {}) {
2498
2506
  });
2499
2507
  await executeDockerfilePlan(sandbox, plan, emit, sleep4);
2500
2508
  emit({ type: "status", message: "Creating snapshot..." });
2501
- const snapshot = await client.snapshotAndWait(sandbox.sandboxId);
2509
+ const snapshot = await client.snapshotAndWait(sandbox.sandboxId, {
2510
+ contentMode: "filesystem_only"
2511
+ });
2502
2512
  emit({
2503
2513
  type: "snapshot_created",
2504
2514
  snapshot_id: snapshot.snapshotId,