tensorlake 0.5.0 → 0.5.2

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 SuspendResumeOptions, f as CheckpointOptions, R as RunOptions, g as CommandResult, h as StartProcessOptions, P as ProcessInfo, i as SendSignalResponse, O as OutputResponse, j as OutputEvent, L as ListDirectoryResponse, k as PtySessionInfo, H as HealthResponse, D as DaemonInfo, l as CreateSandboxOptions, m as CreateSandboxResponse, n as SandboxInfo, U as UpdateSandboxOptions, o as SandboxPortAccess, p as SnapshotOptions, q as CreateSnapshotResponse, r as SnapshotAndWaitOptions, s as CreatePoolOptions, t as CreateSandboxPoolResponse, u as SandboxPoolInfo, v as UpdatePoolOptions } from './sandbox-image-CMJ_FOOV.cjs';
2
- export { w as ContainerResourcesInfo, x as ContainerState, y as CreateSandboxImageOptions, z as DirectoryEntry, A as DockerfileBuildPlan, B as DockerfileInstruction, I as Image, E as ImageBuildOperation, F as ImageBuildOperationType, F as ImageBuildOperationTypeValue, G as ImageOptions, N as NetworkConfig, J as OutputMode, K as PoolContainerInfo, M as ProcessStatus, Q as SandboxImageSource, T as SandboxStatus, V as SnapshotContentMode, W as SnapshotStatus, X as StdinMode, Y as createSandboxImage, Z as dockerfileContent } from './sandbox-image-CMJ_FOOV.cjs';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxStatus, U as UpdateSandboxOptions, f as SandboxInfo, 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-B0WMhyoM.cjs';
2
+ export { x as ContainerResourcesInfo, y as ContainerState, z as CreateSandboxImageOptions, A as DirectoryEntry, B as DockerfileBuildPlan, E as DockerfileInstruction, I as Image, F as ImageBuildOperation, G as ImageBuildOperationType, G as ImageBuildOperationTypeValue, J as ImageOptions, N as NetworkConfig, K as OutputMode, M as PoolContainerInfo, Q as ProcessStatus, T as SandboxImageSource, V as SnapshotContentMode, W as SnapshotStatus, X as StdinMode, Y as createSandboxImage, Z as dockerfileContent } from './sandbox-image-B0WMhyoM.cjs';
3
3
 
4
4
  /**
5
5
  * The return value of every SDK operation. Carries the W3C `trace_id` so callers
@@ -171,7 +171,14 @@ declare class Sandbox {
171
171
  private readonly wsHeaders;
172
172
  private ownsSandbox;
173
173
  private lifecycleClient;
174
+ private lifecycleIdentifier;
175
+ private sandboxName;
174
176
  constructor(options: SandboxOptions);
177
+ get name(): string | null;
178
+ /** @internal Used by client wiring to keep locally cached name in sync. */
179
+ _setName(name: string | null): void;
180
+ /** @internal Used by lifecycle operations to pin to canonical sandbox ID. */
181
+ _setLifecycleIdentifier(identifier: string): void;
175
182
  /** @internal Used by SandboxClient.createAndConnect to set ownership. */
176
183
  _setOwner(client: SandboxClient): void;
177
184
  /**
@@ -194,6 +201,20 @@ declare class Sandbox {
194
201
  /** Delete a snapshot by ID. No sandbox handle needed. */
195
202
  static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
196
203
  private requireLifecycleClient;
204
+ /**
205
+ * Fetch the current sandbox status from the server.
206
+ *
207
+ * Always hits the network — the value is not cached locally because the
208
+ * status changes over the sandbox's lifecycle.
209
+ */
210
+ status(): Promise<SandboxStatus>;
211
+ /**
212
+ * Update this sandbox's properties (name, exposed ports, proxy auth).
213
+ *
214
+ * Naming an ephemeral sandbox makes it non-ephemeral and enables
215
+ * suspend/resume.
216
+ */
217
+ update(options: UpdateSandboxOptions): Promise<SandboxInfo>;
197
218
  /**
198
219
  * Suspend this sandbox.
199
220
  *
@@ -220,7 +241,7 @@ declare class Sandbox {
220
241
  /**
221
242
  * List snapshots taken from this sandbox.
222
243
  */
223
- listSnapshots(): Promise<SnapshotInfo[]>;
244
+ listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
224
245
  /** Close the HTTP client. The sandbox keeps running. */
225
246
  close(): void;
226
247
  /** Terminate the sandbox and release all resources. */
@@ -242,7 +263,7 @@ declare class Sandbox {
242
263
  */
243
264
  startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
244
265
  /** List all processes (running and exited) tracked by the sandbox daemon. */
245
- listProcesses(): Promise<ProcessInfo[]>;
266
+ listProcesses(): Promise<Traced<ProcessInfo[]>>;
246
267
  /** Get current status and metadata for a process by PID. */
247
268
  getProcess(pid: number): Promise<ProcessInfo>;
248
269
  /** Send SIGKILL to a process. */
@@ -331,7 +352,7 @@ declare class SandboxClient {
331
352
  /** Get current state and metadata for a sandbox by ID. */
332
353
  get(sandboxId: string): Promise<SandboxInfo>;
333
354
  /** List all sandboxes in the namespace. */
334
- list(): Promise<SandboxInfo[]>;
355
+ list(): Promise<Traced<SandboxInfo[]>>;
335
356
  /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
336
357
  update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
337
358
  /** Get the current proxy port settings for a sandbox. */
@@ -389,7 +410,7 @@ declare class SandboxClient {
389
410
  /** Get current status and metadata for a snapshot by ID. */
390
411
  getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
391
412
  /** List all snapshots in the namespace. */
392
- listSnapshots(): Promise<SnapshotInfo[]>;
413
+ listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
393
414
  /** Delete a snapshot by ID. */
394
415
  deleteSnapshot(snapshotId: string): Promise<void>;
395
416
  /**
@@ -411,7 +432,7 @@ declare class SandboxClient {
411
432
  /** Get current state and metadata for a sandbox pool by ID. */
412
433
  getPool(poolId: string): Promise<SandboxPoolInfo>;
413
434
  /** List all sandbox pools in the namespace. */
414
- listPools(): Promise<SandboxPoolInfo[]>;
435
+ listPools(): Promise<Traced<SandboxPoolInfo[]>>;
415
436
  /** Replace the configuration of an existing sandbox pool. */
416
437
  updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
417
438
  /** Delete a sandbox pool. Fails if the pool has active containers. */
@@ -675,4 +696,4 @@ declare class RequestExecutionError extends Error {
675
696
  constructor(message: string, functionName?: string);
676
697
  }
677
698
 
678
- export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CheckpointOptions, CloudClient, type CloudClientOptions, CommandResult, type ConnectDesktopOptions, ConnectOptions, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, type CreateTunnelOptions, DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, HealthResponse, ListDirectoryResponse, type MouseButton, 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, SuspendResumeOptions, TcpTunnel, type TunnelAddress, UpdatePoolOptions, type UpsertSecretResponse };
699
+ export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CheckpointOptions, CloudClient, type CloudClientOptions, CommandResult, type ConnectDesktopOptions, ConnectOptions, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, type CreateTunnelOptions, DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, HealthResponse, ListDirectoryResponse, type MouseButton, 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, SandboxStatus, type Secret, type SecretsList, type SecretsPagination, SendSignalResponse, SnapshotAndWaitOptions, SnapshotInfo, SnapshotOptions, type StartImageBuildRequest, StartProcessOptions, SuspendResumeOptions, TcpTunnel, type TunnelAddress, UpdatePoolOptions, type UpsertSecretResponse };
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 SuspendResumeOptions, f as CheckpointOptions, R as RunOptions, g as CommandResult, h as StartProcessOptions, P as ProcessInfo, i as SendSignalResponse, O as OutputResponse, j as OutputEvent, L as ListDirectoryResponse, k as PtySessionInfo, H as HealthResponse, D as DaemonInfo, l as CreateSandboxOptions, m as CreateSandboxResponse, n as SandboxInfo, U as UpdateSandboxOptions, o as SandboxPortAccess, p as SnapshotOptions, q as CreateSnapshotResponse, r as SnapshotAndWaitOptions, s as CreatePoolOptions, t as CreateSandboxPoolResponse, u as SandboxPoolInfo, v as UpdatePoolOptions } from './sandbox-image-CMJ_FOOV.js';
2
- export { w as ContainerResourcesInfo, x as ContainerState, y as CreateSandboxImageOptions, z as DirectoryEntry, A as DockerfileBuildPlan, B as DockerfileInstruction, I as Image, E as ImageBuildOperation, F as ImageBuildOperationType, F as ImageBuildOperationTypeValue, G as ImageOptions, N as NetworkConfig, J as OutputMode, K as PoolContainerInfo, M as ProcessStatus, Q as SandboxImageSource, T as SandboxStatus, V as SnapshotContentMode, W as SnapshotStatus, X as StdinMode, Y as createSandboxImage, Z as dockerfileContent } from './sandbox-image-CMJ_FOOV.js';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxStatus, U as UpdateSandboxOptions, f as SandboxInfo, 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-B0WMhyoM.js';
2
+ export { x as ContainerResourcesInfo, y as ContainerState, z as CreateSandboxImageOptions, A as DirectoryEntry, B as DockerfileBuildPlan, E as DockerfileInstruction, I as Image, F as ImageBuildOperation, G as ImageBuildOperationType, G as ImageBuildOperationTypeValue, J as ImageOptions, N as NetworkConfig, K as OutputMode, M as PoolContainerInfo, Q as ProcessStatus, T as SandboxImageSource, V as SnapshotContentMode, W as SnapshotStatus, X as StdinMode, Y as createSandboxImage, Z as dockerfileContent } from './sandbox-image-B0WMhyoM.js';
3
3
 
4
4
  /**
5
5
  * The return value of every SDK operation. Carries the W3C `trace_id` so callers
@@ -171,7 +171,14 @@ declare class Sandbox {
171
171
  private readonly wsHeaders;
172
172
  private ownsSandbox;
173
173
  private lifecycleClient;
174
+ private lifecycleIdentifier;
175
+ private sandboxName;
174
176
  constructor(options: SandboxOptions);
177
+ get name(): string | null;
178
+ /** @internal Used by client wiring to keep locally cached name in sync. */
179
+ _setName(name: string | null): void;
180
+ /** @internal Used by lifecycle operations to pin to canonical sandbox ID. */
181
+ _setLifecycleIdentifier(identifier: string): void;
175
182
  /** @internal Used by SandboxClient.createAndConnect to set ownership. */
176
183
  _setOwner(client: SandboxClient): void;
177
184
  /**
@@ -194,6 +201,20 @@ declare class Sandbox {
194
201
  /** Delete a snapshot by ID. No sandbox handle needed. */
195
202
  static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
196
203
  private requireLifecycleClient;
204
+ /**
205
+ * Fetch the current sandbox status from the server.
206
+ *
207
+ * Always hits the network — the value is not cached locally because the
208
+ * status changes over the sandbox's lifecycle.
209
+ */
210
+ status(): Promise<SandboxStatus>;
211
+ /**
212
+ * Update this sandbox's properties (name, exposed ports, proxy auth).
213
+ *
214
+ * Naming an ephemeral sandbox makes it non-ephemeral and enables
215
+ * suspend/resume.
216
+ */
217
+ update(options: UpdateSandboxOptions): Promise<SandboxInfo>;
197
218
  /**
198
219
  * Suspend this sandbox.
199
220
  *
@@ -220,7 +241,7 @@ declare class Sandbox {
220
241
  /**
221
242
  * List snapshots taken from this sandbox.
222
243
  */
223
- listSnapshots(): Promise<SnapshotInfo[]>;
244
+ listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
224
245
  /** Close the HTTP client. The sandbox keeps running. */
225
246
  close(): void;
226
247
  /** Terminate the sandbox and release all resources. */
@@ -242,7 +263,7 @@ declare class Sandbox {
242
263
  */
243
264
  startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
244
265
  /** List all processes (running and exited) tracked by the sandbox daemon. */
245
- listProcesses(): Promise<ProcessInfo[]>;
266
+ listProcesses(): Promise<Traced<ProcessInfo[]>>;
246
267
  /** Get current status and metadata for a process by PID. */
247
268
  getProcess(pid: number): Promise<ProcessInfo>;
248
269
  /** Send SIGKILL to a process. */
@@ -331,7 +352,7 @@ declare class SandboxClient {
331
352
  /** Get current state and metadata for a sandbox by ID. */
332
353
  get(sandboxId: string): Promise<SandboxInfo>;
333
354
  /** List all sandboxes in the namespace. */
334
- list(): Promise<SandboxInfo[]>;
355
+ list(): Promise<Traced<SandboxInfo[]>>;
335
356
  /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
336
357
  update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
337
358
  /** Get the current proxy port settings for a sandbox. */
@@ -389,7 +410,7 @@ declare class SandboxClient {
389
410
  /** Get current status and metadata for a snapshot by ID. */
390
411
  getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
391
412
  /** List all snapshots in the namespace. */
392
- listSnapshots(): Promise<SnapshotInfo[]>;
413
+ listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
393
414
  /** Delete a snapshot by ID. */
394
415
  deleteSnapshot(snapshotId: string): Promise<void>;
395
416
  /**
@@ -411,7 +432,7 @@ declare class SandboxClient {
411
432
  /** Get current state and metadata for a sandbox pool by ID. */
412
433
  getPool(poolId: string): Promise<SandboxPoolInfo>;
413
434
  /** List all sandbox pools in the namespace. */
414
- listPools(): Promise<SandboxPoolInfo[]>;
435
+ listPools(): Promise<Traced<SandboxPoolInfo[]>>;
415
436
  /** Replace the configuration of an existing sandbox pool. */
416
437
  updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
417
438
  /** Delete a sandbox pool. Fails if the pool has active containers. */
@@ -675,4 +696,4 @@ declare class RequestExecutionError extends Error {
675
696
  constructor(message: string, functionName?: string);
676
697
  }
677
698
 
678
- export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CheckpointOptions, CloudClient, type CloudClientOptions, CommandResult, type ConnectDesktopOptions, ConnectOptions, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, type CreateTunnelOptions, DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, HealthResponse, ListDirectoryResponse, type MouseButton, 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, SuspendResumeOptions, TcpTunnel, type TunnelAddress, UpdatePoolOptions, type UpsertSecretResponse };
699
+ export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CheckpointOptions, CloudClient, type CloudClientOptions, CommandResult, type ConnectDesktopOptions, ConnectOptions, CreateAndConnectOptions, type CreateApplicationBuildImageRequest, type CreateApplicationBuildRequest, CreatePoolOptions, type CreatePtyOptions, CreatePtySessionOptions, CreateSandboxOptions, CreateSandboxPoolResponse, CreateSandboxResponse, CreateSnapshotResponse, type CreateTunnelOptions, DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, HealthResponse, ListDirectoryResponse, type MouseButton, 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, SandboxStatus, type Secret, type SecretsList, type SecretsPagination, SendSignalResponse, SnapshotAndWaitOptions, SnapshotInfo, SnapshotOptions, type StartImageBuildRequest, StartProcessOptions, SuspendResumeOptions, TcpTunnel, type TunnelAddress, UpdatePoolOptions, type UpsertSecretResponse };
package/dist/index.js CHANGED
@@ -3164,8 +3164,11 @@ var init_sandbox = __esm({
3164
3164
  wsHeaders;
3165
3165
  ownsSandbox = false;
3166
3166
  lifecycleClient = null;
3167
+ lifecycleIdentifier;
3168
+ sandboxName = null;
3167
3169
  constructor(options) {
3168
3170
  this.sandboxId = options.sandboxId;
3171
+ this.lifecycleIdentifier = options.sandboxId;
3169
3172
  const proxyUrl = options.proxyUrl ?? SANDBOX_PROXY_URL;
3170
3173
  const { baseUrl, hostHeader } = resolveProxyTarget(proxyUrl, options.sandboxId);
3171
3174
  this.baseUrl = baseUrl;
@@ -3191,6 +3194,17 @@ var init_sandbox = __esm({
3191
3194
  routingHint: options.routingHint
3192
3195
  });
3193
3196
  }
3197
+ get name() {
3198
+ return this.sandboxName;
3199
+ }
3200
+ /** @internal Used by client wiring to keep locally cached name in sync. */
3201
+ _setName(name) {
3202
+ this.sandboxName = name;
3203
+ }
3204
+ /** @internal Used by lifecycle operations to pin to canonical sandbox ID. */
3205
+ _setLifecycleIdentifier(identifier) {
3206
+ this.lifecycleIdentifier = identifier;
3207
+ }
3194
3208
  /** @internal Used by SandboxClient.createAndConnect to set ownership. */
3195
3209
  _setOwner(client) {
3196
3210
  this.ownsSandbox = true;
@@ -3228,9 +3242,15 @@ var init_sandbox = __esm({
3228
3242
  /* _internal */
3229
3243
  true
3230
3244
  );
3231
- await client.get(options.sandboxId);
3232
- const sandbox = client.connect(options.sandboxId, options.proxyUrl, options.routingHint);
3245
+ const info = await client.get(options.sandboxId);
3246
+ const sandbox = client.connect(
3247
+ info.sandboxId,
3248
+ options.proxyUrl,
3249
+ options.routingHint ?? info.routingHint
3250
+ );
3233
3251
  sandbox.lifecycleClient = client;
3252
+ sandbox._setLifecycleIdentifier(info.sandboxId);
3253
+ sandbox._setName(info.name ?? null);
3234
3254
  return sandbox;
3235
3255
  }
3236
3256
  // --- Static snapshot management ---
@@ -3263,6 +3283,32 @@ var init_sandbox = __esm({
3263
3283
  }
3264
3284
  return this.lifecycleClient;
3265
3285
  }
3286
+ /**
3287
+ * Fetch the current sandbox status from the server.
3288
+ *
3289
+ * Always hits the network — the value is not cached locally because the
3290
+ * status changes over the sandbox's lifecycle.
3291
+ */
3292
+ async status() {
3293
+ const client = this.requireLifecycleClient("read_status");
3294
+ const info = await client.get(this.lifecycleIdentifier);
3295
+ this._setLifecycleIdentifier(info.sandboxId);
3296
+ this._setName(info.name ?? null);
3297
+ return info.status;
3298
+ }
3299
+ /**
3300
+ * Update this sandbox's properties (name, exposed ports, proxy auth).
3301
+ *
3302
+ * Naming an ephemeral sandbox makes it non-ephemeral and enables
3303
+ * suspend/resume.
3304
+ */
3305
+ async update(options) {
3306
+ const client = this.requireLifecycleClient("update");
3307
+ const info = await client.update(this.lifecycleIdentifier, options);
3308
+ this._setLifecycleIdentifier(info.sandboxId);
3309
+ this._setName(info.name ?? null);
3310
+ return info;
3311
+ }
3266
3312
  /**
3267
3313
  * Suspend this sandbox.
3268
3314
  *
@@ -3271,7 +3317,7 @@ var init_sandbox = __esm({
3271
3317
  */
3272
3318
  async suspend(options) {
3273
3319
  const client = this.requireLifecycleClient("suspend");
3274
- await client.suspend(this.sandboxId, options);
3320
+ await client.suspend(this.lifecycleIdentifier, options);
3275
3321
  }
3276
3322
  /**
3277
3323
  * Resume this sandbox.
@@ -3281,7 +3327,7 @@ var init_sandbox = __esm({
3281
3327
  */
3282
3328
  async resume(options) {
3283
3329
  const client = this.requireLifecycleClient("resume");
3284
- await client.resume(this.sandboxId, options);
3330
+ await client.resume(this.lifecycleIdentifier, options);
3285
3331
  }
3286
3332
  /**
3287
3333
  * Create a snapshot of this sandbox's filesystem and wait for it to
@@ -3294,10 +3340,10 @@ var init_sandbox = __esm({
3294
3340
  async checkpoint(options) {
3295
3341
  const client = this.requireLifecycleClient("checkpoint");
3296
3342
  if (options?.wait === false) {
3297
- await client.snapshot(this.sandboxId, { contentMode: options.contentMode });
3343
+ await client.snapshot(this.lifecycleIdentifier, { contentMode: options.contentMode });
3298
3344
  return void 0;
3299
3345
  }
3300
- return client.snapshotAndWait(this.sandboxId, {
3346
+ return client.snapshotAndWait(this.lifecycleIdentifier, {
3301
3347
  timeout: options?.timeout,
3302
3348
  pollInterval: options?.pollInterval,
3303
3349
  contentMode: options?.contentMode
@@ -3309,7 +3355,8 @@ var init_sandbox = __esm({
3309
3355
  async listSnapshots() {
3310
3356
  const client = this.requireLifecycleClient("listSnapshots");
3311
3357
  const all = await client.listSnapshots();
3312
- return all.filter((s) => s.sandboxId === this.sandboxId);
3358
+ const filtered = all.filter((s) => s.sandboxId === this.lifecycleIdentifier);
3359
+ return Object.assign(filtered, { traceId: all.traceId });
3313
3360
  }
3314
3361
  /** Close the HTTP client. The sandbox keeps running. */
3315
3362
  close() {
@@ -3322,7 +3369,7 @@ var init_sandbox = __esm({
3322
3369
  this.lifecycleClient = null;
3323
3370
  this.close();
3324
3371
  if (client) {
3325
- await client.delete(this.sandboxId);
3372
+ await client.delete(this.lifecycleIdentifier);
3326
3373
  }
3327
3374
  }
3328
3375
  // --- High-level convenience ---
@@ -3403,7 +3450,8 @@ var init_sandbox = __esm({
3403
3450
  "GET",
3404
3451
  "/api/v1/processes"
3405
3452
  );
3406
- return (raw.processes ?? []).map((p) => fromSnakeKeys(p));
3453
+ const processes = (raw.processes ?? []).map((p) => fromSnakeKeys(p));
3454
+ return Object.assign(processes, { traceId: raw.traceId });
3407
3455
  }
3408
3456
  /** Get current status and metadata for a process by PID. */
3409
3457
  async getProcess(pid) {
@@ -3655,6 +3703,38 @@ __export(client_exports, {
3655
3703
  function sleep2(ms) {
3656
3704
  return new Promise((resolve) => setTimeout(resolve, ms));
3657
3705
  }
3706
+ function formatStartupFailureMessage(sandboxId, status, options) {
3707
+ const prefix = status === "terminated" /* TERMINATED */ ? `Sandbox ${sandboxId} terminated during startup` : `Sandbox ${sandboxId} became ${status} during startup`;
3708
+ const detail = formatErrorDetails(options.errorDetails);
3709
+ if (detail) {
3710
+ return `${prefix}: ${detail}`;
3711
+ }
3712
+ if (options.terminationReason) {
3713
+ return `${prefix}: termination reason: ${options.terminationReason}`;
3714
+ }
3715
+ return prefix;
3716
+ }
3717
+ function formatErrorDetails(errorDetails) {
3718
+ if (errorDetails == null) return void 0;
3719
+ if (typeof errorDetails === "string") {
3720
+ const detail = errorDetails.trim();
3721
+ return detail || void 0;
3722
+ }
3723
+ if (Array.isArray(errorDetails)) {
3724
+ const parts = errorDetails.map((item) => formatErrorDetails(item)).filter((item) => Boolean(item));
3725
+ return parts.length > 0 ? parts.join("; ") : JSON.stringify(errorDetails);
3726
+ }
3727
+ if (typeof errorDetails === "object") {
3728
+ for (const key of ["message", "detail", "error", "reason"]) {
3729
+ const value = errorDetails[key];
3730
+ if (typeof value === "string" && value.trim()) {
3731
+ return value.trim();
3732
+ }
3733
+ }
3734
+ return JSON.stringify(errorDetails);
3735
+ }
3736
+ return String(errorDetails);
3737
+ }
3658
3738
  function normalizeUserPorts(ports) {
3659
3739
  return dedupeAndSortPorts(ports.map(validateUserPort));
3660
3740
  }
@@ -3740,7 +3820,7 @@ var init_client = __esm({
3740
3820
  resources: {
3741
3821
  cpus: options?.cpus ?? 1,
3742
3822
  memory_mb: options?.memoryMb ?? 1024,
3743
- ephemeral_disk_mb: options?.ephemeralDiskMb ?? 1024
3823
+ ...options?.diskMb != null ? { disk_mb: options.diskMb } : {}
3744
3824
  }
3745
3825
  };
3746
3826
  if (options?.image != null) body.image = options.image;
@@ -3778,9 +3858,10 @@ var init_client = __esm({
3778
3858
  "GET",
3779
3859
  this.path("sandboxes")
3780
3860
  );
3781
- return (raw.sandboxes ?? []).map(
3861
+ const sandboxes = (raw.sandboxes ?? []).map(
3782
3862
  (s) => fromSnakeKeys(s, "sandboxId")
3783
3863
  );
3864
+ return Object.assign(sandboxes, { traceId: raw.traceId });
3784
3865
  }
3785
3866
  /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
3786
3867
  async update(sandboxId, options) {
@@ -3950,9 +4031,10 @@ var init_client = __esm({
3950
4031
  "GET",
3951
4032
  this.path("snapshots")
3952
4033
  );
3953
- return (raw.snapshots ?? []).map(
4034
+ const snapshots = (raw.snapshots ?? []).map(
3954
4035
  (s) => fromSnakeKeys(s, "snapshotId")
3955
4036
  );
4037
+ return Object.assign(snapshots, { traceId: raw.traceId });
3956
4038
  }
3957
4039
  /** Delete a snapshot by ID. */
3958
4040
  async deleteSnapshot(snapshotId) {
@@ -4032,9 +4114,10 @@ var init_client = __esm({
4032
4114
  "GET",
4033
4115
  this.path("sandbox-pools")
4034
4116
  );
4035
- return (raw.pools ?? []).map(
4117
+ const pools = (raw.pools ?? []).map(
4036
4118
  (p) => fromSnakeKeys(p, "poolId")
4037
4119
  );
4120
+ return Object.assign(pools, { traceId: raw.traceId });
4038
4121
  }
4039
4122
  /** Replace the configuration of an existing sandbox pool. */
4040
4123
  async updatePool(poolId, options) {
@@ -4089,30 +4172,39 @@ var init_client = __esm({
4089
4172
  */
4090
4173
  async createAndConnect(options) {
4091
4174
  const startupTimeout = options?.startupTimeout ?? 60;
4092
- let result;
4093
- if (options?.poolId != null) {
4094
- result = await this.claim(options.poolId);
4095
- } else {
4096
- result = await this.create(options);
4097
- }
4098
- if (result.status === "running" /* RUNNING */) {
4099
- const sandbox = this.connect(result.sandboxId, options?.proxyUrl, result.routingHint);
4175
+ const result = options?.poolId != null ? await this.claim(options.poolId) : await this.create(options);
4176
+ const requestedName = options?.poolId != null ? null : options?.name ?? null;
4177
+ const finishConnect = (routingHint, name) => {
4178
+ const sandbox = this.connect(result.sandboxId, options?.proxyUrl, routingHint);
4100
4179
  sandbox._setOwner(this);
4101
4180
  sandbox.traceId = result.traceId;
4181
+ sandbox._setLifecycleIdentifier(result.sandboxId);
4182
+ sandbox._setName(name ?? requestedName);
4102
4183
  return sandbox;
4184
+ };
4185
+ if (result.status === "running" /* RUNNING */) {
4186
+ return finishConnect(result.routingHint, result.name);
4187
+ }
4188
+ if (result.status === "suspended" /* SUSPENDED */ || result.status === "terminated" /* TERMINATED */) {
4189
+ throw new SandboxError(
4190
+ formatStartupFailureMessage(result.sandboxId, result.status, {
4191
+ errorDetails: result.errorDetails,
4192
+ terminationReason: result.terminationReason
4193
+ })
4194
+ );
4103
4195
  }
4104
4196
  const deadline = Date.now() + startupTimeout * 1e3;
4105
4197
  while (Date.now() < deadline) {
4106
4198
  const info = await this.get(result.sandboxId);
4107
4199
  if (info.status === "running" /* RUNNING */) {
4108
- const sandbox = this.connect(result.sandboxId, options?.proxyUrl, info.routingHint);
4109
- sandbox._setOwner(this);
4110
- sandbox.traceId = result.traceId;
4111
- return sandbox;
4200
+ return finishConnect(info.routingHint, info.name);
4112
4201
  }
4113
- if (info.status === "terminated" /* TERMINATED */) {
4202
+ if (info.status === "suspended" /* SUSPENDED */ || info.status === "terminated" /* TERMINATED */) {
4114
4203
  throw new SandboxError(
4115
- `Sandbox ${result.sandboxId} terminated during startup`
4204
+ formatStartupFailureMessage(result.sandboxId, info.status, {
4205
+ errorDetails: info.errorDetails,
4206
+ terminationReason: info.terminationReason
4207
+ })
4116
4208
  );
4117
4209
  }
4118
4210
  await sleep2(500);
@@ -4892,7 +4984,7 @@ async function executeDockerfilePlan(sandbox, plan, emit, sleep3) {
4892
4984
  );
4893
4985
  }
4894
4986
  }
4895
- async function registerImage(context, name, dockerfile, snapshotId, snapshotUri, isPublic) {
4987
+ async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic) {
4896
4988
  if (!context.organizationId || !context.projectId) {
4897
4989
  throw new Error(
4898
4990
  "Organization ID and Project ID are required. Run 'tl login' and 'tl init'."
@@ -4919,8 +5011,11 @@ async function registerImage(context, name, dockerfile, snapshotId, snapshotUri,
4919
5011
  name,
4920
5012
  dockerfile,
4921
5013
  snapshotId,
5014
+ snapshotSandboxId,
4922
5015
  snapshotUri,
4923
- isPublic
5016
+ snapshotSizeBytes,
5017
+ rootfsDiskBytes,
5018
+ public: isPublic
4924
5019
  })
4925
5020
  });
4926
5021
  if (!response.ok) {
@@ -4950,7 +5045,8 @@ async function createSandboxImage(source, options = {}, deps = {}) {
4950
5045
  sandbox = await client.createAndConnect({
4951
5046
  ...plan.baseImage == null ? {} : { image: plan.baseImage },
4952
5047
  cpus: options.cpus ?? 2,
4953
- memoryMb: options.memoryMb ?? 4096
5048
+ memoryMb: options.memoryMb ?? 4096,
5049
+ ...options.diskMb != null ? { diskMb: options.diskMb } : {}
4954
5050
  });
4955
5051
  emit({
4956
5052
  type: "status",
@@ -4963,14 +5059,23 @@ async function createSandboxImage(source, options = {}, deps = {}) {
4963
5059
  });
4964
5060
  emit({
4965
5061
  type: "snapshot_created",
4966
- snapshot_id: snapshot.snapshotId,
4967
- snapshot_uri: snapshot.snapshotUri ?? null
5062
+ snapshot_id: snapshot.snapshotId
4968
5063
  });
4969
5064
  if (!snapshot.snapshotUri) {
4970
5065
  throw new Error(
4971
5066
  `Snapshot ${snapshot.snapshotId} is missing snapshotUri and cannot be registered as a sandbox image.`
4972
5067
  );
4973
5068
  }
5069
+ if (snapshot.sizeBytes == null) {
5070
+ throw new Error(
5071
+ `Snapshot ${snapshot.snapshotId} is missing sizeBytes and cannot be registered as a sandbox image.`
5072
+ );
5073
+ }
5074
+ if (snapshot.rootfsDiskBytes == null) {
5075
+ throw new Error(
5076
+ `Snapshot ${snapshot.snapshotId} is missing rootfsDiskBytes and cannot be registered as a sandbox image.`
5077
+ );
5078
+ }
4974
5079
  emit({
4975
5080
  type: "status",
4976
5081
  message: `Registering image '${plan.registeredName}'...`
@@ -4980,7 +5085,10 @@ async function createSandboxImage(source, options = {}, deps = {}) {
4980
5085
  plan.registeredName,
4981
5086
  plan.dockerfileText,
4982
5087
  snapshot.snapshotId,
5088
+ snapshot.sandboxId,
4983
5089
  snapshot.snapshotUri,
5090
+ snapshot.sizeBytes,
5091
+ snapshot.rootfsDiskBytes,
4984
5092
  options.isPublic ?? false
4985
5093
  );
4986
5094
  emit({
@@ -5008,27 +5116,33 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
5008
5116
  name: { type: "string", short: "n" },
5009
5117
  cpus: { type: "string" },
5010
5118
  memory: { type: "string" },
5119
+ disk: { type: "string" },
5011
5120
  public: { type: "boolean", default: false }
5012
5121
  }
5013
5122
  });
5014
5123
  const dockerfilePath = parsed.positionals[0];
5015
5124
  if (!dockerfilePath) {
5016
- throw new Error("Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--public]");
5125
+ throw new Error("Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--disk GB] [--public]");
5017
5126
  }
5018
5127
  const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
5019
5128
  const memoryMb = parsed.values.memory != null ? Number(parsed.values.memory) : void 0;
5129
+ const diskGb = parsed.values.disk != null ? Number(parsed.values.disk) : void 0;
5020
5130
  if (cpus != null && !Number.isFinite(cpus)) {
5021
5131
  throw new Error(`Invalid --cpus value: ${parsed.values.cpus}`);
5022
5132
  }
5023
5133
  if (memoryMb != null && !Number.isInteger(memoryMb)) {
5024
5134
  throw new Error(`Invalid --memory value: ${parsed.values.memory}`);
5025
5135
  }
5136
+ if (diskGb != null && !Number.isInteger(diskGb)) {
5137
+ throw new Error(`Invalid --disk value: ${parsed.values.disk}`);
5138
+ }
5026
5139
  await createSandboxImage(
5027
5140
  dockerfilePath,
5028
5141
  {
5029
5142
  registeredName: parsed.values.name,
5030
5143
  cpus,
5031
5144
  memoryMb,
5145
+ diskMb: diskGb != null ? diskGb * 1024 : void 0,
5032
5146
  isPublic: parsed.values.public
5033
5147
  },
5034
5148
  { emit: ndjsonStdoutEmit }