tensorlake 0.4.49 → 0.5.0

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,23 @@
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-BQ6fJT92.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-BQ6fJT92.cjs';
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';
3
+
4
+ /**
5
+ * The return value of every SDK operation. Carries the W3C `trace_id` so callers
6
+ * can correlate a specific request with its server-side spans in Datadog APM or
7
+ * any other OTEL-compatible backend.
8
+ *
9
+ * Because this is an intersection type, all properties of `T` are accessible
10
+ * directly — existing code that ignores `traceId` continues to compile and run
11
+ * unchanged.
12
+ *
13
+ * @example
14
+ * const sandbox = await client.createSandbox(req);
15
+ * console.log(sandbox.id); // existing field — unchanged
16
+ * console.log(sandbox.traceId); // new: look this up in Datadog APM
17
+ */
18
+ type Traced<T> = T & {
19
+ readonly traceId: string;
20
+ };
3
21
 
4
22
  type MouseButton = "left" | "middle" | "right";
5
23
  interface ConnectDesktopOptions {
@@ -147,6 +165,7 @@ declare class Pty {
147
165
  */
148
166
  declare class Sandbox {
149
167
  readonly sandboxId: string;
168
+ traceId: string | null;
150
169
  private readonly http;
151
170
  private readonly baseUrl;
152
171
  private readonly wsHeaders;
@@ -155,7 +174,56 @@ declare class Sandbox {
155
174
  constructor(options: SandboxOptions);
156
175
  /** @internal Used by SandboxClient.createAndConnect to set ownership. */
157
176
  _setOwner(client: SandboxClient): void;
177
+ /**
178
+ * Create a new sandbox and return a connected, running handle.
179
+ *
180
+ * Covers both fresh sandbox creation and restore-from-snapshot (set
181
+ * `snapshotId`). Blocks until the sandbox is `Running`.
182
+ */
183
+ static create(options?: CreateAndConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
184
+ /**
185
+ * Attach to an existing sandbox and return a connected handle.
186
+ *
187
+ * Verifies the sandbox exists via a server GET call, then returns a handle
188
+ * in whatever state the sandbox is in. Does **not** auto-resume a suspended
189
+ * sandbox — call `sandbox.resume()` explicitly.
190
+ */
191
+ static connect(options: ConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
192
+ /** Get information about a snapshot by ID. No sandbox handle needed. */
193
+ static getSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo>;
194
+ /** Delete a snapshot by ID. No sandbox handle needed. */
195
+ static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
196
+ private requireLifecycleClient;
197
+ /**
198
+ * Suspend this sandbox.
199
+ *
200
+ * By default blocks until the sandbox is fully `Suspended`. Pass
201
+ * `{ wait: false }` for fire-and-return.
202
+ */
203
+ suspend(options?: SuspendResumeOptions): Promise<void>;
204
+ /**
205
+ * Resume this sandbox.
206
+ *
207
+ * By default blocks until the sandbox is `Running` and routable. Pass
208
+ * `{ wait: false }` for fire-and-return.
209
+ */
210
+ resume(options?: SuspendResumeOptions): Promise<void>;
211
+ /**
212
+ * Create a snapshot of this sandbox's filesystem and wait for it to
213
+ * be committed.
214
+ *
215
+ * By default blocks until the snapshot artifact is ready and returns
216
+ * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
217
+ * (returns `undefined`).
218
+ */
219
+ checkpoint(options?: CheckpointOptions): Promise<SnapshotInfo | undefined>;
220
+ /**
221
+ * List snapshots taken from this sandbox.
222
+ */
223
+ listSnapshots(): Promise<SnapshotInfo[]>;
224
+ /** Close the HTTP client. The sandbox keeps running. */
158
225
  close(): void;
226
+ /** Terminate the sandbox and release all resources. */
159
227
  terminate(): Promise<void>;
160
228
  /**
161
229
  * Run a command to completion and return its output.
@@ -164,36 +232,67 @@ declare class Sandbox {
164
232
  * the process, streams output, and delivers the exit code over one connection.
165
233
  */
166
234
  run(command: string, options?: RunOptions): Promise<CommandResult>;
235
+ /**
236
+ * Start a process in the sandbox without waiting for it to exit.
237
+ *
238
+ * Returns a `ProcessInfo` with the assigned `pid`. Use `getProcess()` to
239
+ * poll status, or `followStdout()` / `followOutput()` to stream output
240
+ * until the process exits. Use `run()` instead to block until completion
241
+ * and get combined output in one call.
242
+ */
167
243
  startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
244
+ /** List all processes (running and exited) tracked by the sandbox daemon. */
168
245
  listProcesses(): Promise<ProcessInfo[]>;
246
+ /** Get current status and metadata for a process by PID. */
169
247
  getProcess(pid: number): Promise<ProcessInfo>;
248
+ /** Send SIGKILL to a process. */
170
249
  killProcess(pid: number): Promise<void>;
250
+ /** Send an arbitrary signal to a process (e.g. `15` for SIGTERM, `9` for SIGKILL). */
171
251
  sendSignal(pid: number, signal: number): Promise<SendSignalResponse>;
252
+ /** Write bytes to a process's stdin. The process must have been started with `stdinMode: StdinMode.PIPE`. */
172
253
  writeStdin(pid: number, data: Uint8Array): Promise<void>;
254
+ /** Close a process's stdin pipe, signalling EOF to the process. */
173
255
  closeStdin(pid: number): Promise<void>;
256
+ /** Return all captured stdout lines produced so far by a process. */
174
257
  getStdout(pid: number): Promise<OutputResponse>;
258
+ /** Return all captured stderr lines produced so far by a process. */
175
259
  getStderr(pid: number): Promise<OutputResponse>;
260
+ /** Return all captured stdout+stderr lines produced so far by a process. */
176
261
  getOutput(pid: number): Promise<OutputResponse>;
262
+ /** Stream stdout events from a process until it exits. Yields one `OutputEvent` per line. */
177
263
  followStdout(pid: number, options?: {
178
264
  signal?: AbortSignal;
179
265
  }): AsyncIterable<OutputEvent>;
266
+ /** Stream stderr events from a process until it exits. Yields one `OutputEvent` per line. */
180
267
  followStderr(pid: number, options?: {
181
268
  signal?: AbortSignal;
182
269
  }): AsyncIterable<OutputEvent>;
270
+ /** Stream combined stdout+stderr events from a process until it exits. Yields one `OutputEvent` per line. */
183
271
  followOutput(pid: number, options?: {
184
272
  signal?: AbortSignal;
185
273
  }): AsyncIterable<OutputEvent>;
274
+ /** Read a file from the sandbox and return its raw bytes. */
186
275
  readFile(path: string): Promise<Uint8Array>;
276
+ /** Write raw bytes to a file in the sandbox, creating it if it does not exist. */
187
277
  writeFile(path: string, content: Uint8Array): Promise<void>;
278
+ /** Delete a file from the sandbox. */
188
279
  deleteFile(path: string): Promise<void>;
280
+ /** List the contents of a directory in the sandbox. */
189
281
  listDirectory(path: string): Promise<ListDirectoryResponse>;
282
+ /** Create an interactive PTY session. Returns a `sessionId` and `token` for WebSocket connection via `connectPty()`. */
190
283
  createPtySession(options: CreatePtySessionOptions): Promise<PtySessionInfo>;
284
+ /** Create a PTY session and connect to it immediately. Cleans up the session if the WebSocket connection fails. */
191
285
  createPty(options: CreatePtyOptions): Promise<Pty>;
286
+ /** Attach to an existing PTY session by ID and token and return a connected `Pty` handle. */
192
287
  connectPty(sessionId: string, token: string, options?: PtyConnectionOptions): Promise<Pty>;
288
+ /** Open a TCP tunnel to a port inside the sandbox and return the local listener. */
193
289
  createTunnel(remotePort: number, options?: CreateTunnelOptions): Promise<TcpTunnel>;
290
+ /** Connect to a sandbox VNC session for programmatic desktop control. */
194
291
  connectDesktop(options?: ConnectDesktopOptions): Promise<Desktop>;
195
292
  ptyWsUrl(sessionId: string, token: string): string;
293
+ /** Check the sandbox daemon health. */
196
294
  health(): Promise<HealthResponse>;
295
+ /** Get sandbox daemon info (version, uptime, process counts). */
197
296
  info(): Promise<DaemonInfo>;
198
297
  }
199
298
 
@@ -211,7 +310,8 @@ declare class SandboxClient {
211
310
  private readonly projectId;
212
311
  private readonly namespace;
213
312
  private readonly local;
214
- constructor(options?: SandboxClientOptions);
313
+ /** @internal Pass `true` to suppress the deprecation warning when used by `Sandbox.create()` / `Sandbox.connect()`. */
314
+ constructor(options?: SandboxClientOptions, _internal?: boolean);
215
315
  /** Create a client for the TensorLake cloud platform. */
216
316
  static forCloud(options?: {
217
317
  apiKey?: string;
@@ -226,30 +326,107 @@ declare class SandboxClient {
226
326
  }): SandboxClient;
227
327
  close(): void;
228
328
  private path;
229
- create(options?: CreateSandboxOptions): Promise<CreateSandboxResponse>;
329
+ /** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
330
+ create(options?: CreateSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
331
+ /** Get current state and metadata for a sandbox by ID. */
230
332
  get(sandboxId: string): Promise<SandboxInfo>;
333
+ /** List all sandboxes in the namespace. */
231
334
  list(): Promise<SandboxInfo[]>;
335
+ /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
232
336
  update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
337
+ /** Get the current proxy port settings for a sandbox. */
233
338
  getPortAccess(sandboxId: string): Promise<SandboxPortAccess>;
339
+ /** Add one or more user ports to the sandbox proxy allowlist. */
234
340
  exposePorts(sandboxId: string, ports: number[], options?: {
235
341
  allowUnauthenticatedAccess?: boolean;
236
342
  }): Promise<SandboxInfo>;
343
+ /** Remove one or more user ports from the sandbox proxy allowlist. */
237
344
  unexposePorts(sandboxId: string, ports: number[]): Promise<SandboxInfo>;
345
+ /** Terminate and delete a sandbox. */
238
346
  delete(sandboxId: string): Promise<void>;
239
- suspend(sandboxId: string): Promise<void>;
240
- resume(sandboxId: string): Promise<void>;
241
- claim(poolId: string): Promise<CreateSandboxResponse>;
347
+ /**
348
+ * Suspend a named sandbox, preserving its state for later resume.
349
+ *
350
+ * Only sandboxes created with a `name` can be suspended; ephemeral sandboxes
351
+ * cannot. By default blocks until the sandbox is fully `Suspended`. Pass
352
+ * `{ wait: false }` to return immediately after the request is sent
353
+ * (fire-and-return); the server processes the suspend asynchronously.
354
+ *
355
+ * @param sandboxId - ID or name of the sandbox.
356
+ * @param options.wait - If `true` (default), poll until `Suspended`. Pass `false` to fire-and-return.
357
+ * @param options.timeout - Max seconds to wait when `wait=true` (default 300).
358
+ * @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
359
+ * @throws {SandboxError} If `wait=true` and the sandbox does not reach `Suspended` within `timeout`.
360
+ */
361
+ suspend(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
362
+ /**
363
+ * Resume a suspended sandbox and bring it back to `Running`.
364
+ *
365
+ * By default blocks until the sandbox is `Running` and routable. Pass
366
+ * `{ wait: false }` to return immediately after the request is sent
367
+ * (fire-and-return); the server processes the resume asynchronously.
368
+ *
369
+ * @param sandboxId - ID or name of the sandbox.
370
+ * @param options.wait - If `true` (default), poll until `Running`. Pass `false` to fire-and-return.
371
+ * @param options.timeout - Max seconds to wait when `wait=true` (default 300).
372
+ * @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
373
+ * @throws {SandboxError} If `wait=true` and the sandbox does not reach `Running` within `timeout`.
374
+ */
375
+ resume(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
376
+ /** Claim a warm sandbox from a pool, creating one if no warm containers are available. */
377
+ claim(poolId: string): Promise<Traced<CreateSandboxResponse>>;
378
+ /**
379
+ * Request a snapshot of a running sandbox's filesystem.
380
+ *
381
+ * This call **returns immediately** with a `snapshotId` and `in_progress`
382
+ * status — the snapshot is created asynchronously. Poll `getSnapshot()` until
383
+ * `completed` or `failed`, or use `snapshotAndWait()` to block automatically.
384
+ *
385
+ * @param options.contentMode - `"filesystem_only"` for cold-boot snapshots (e.g. image builds).
386
+ * Omit to use the server default (full VM snapshot).
387
+ */
242
388
  snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
389
+ /** Get current status and metadata for a snapshot by ID. */
243
390
  getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
391
+ /** List all snapshots in the namespace. */
244
392
  listSnapshots(): Promise<SnapshotInfo[]>;
393
+ /** Delete a snapshot by ID. */
245
394
  deleteSnapshot(snapshotId: string): Promise<void>;
395
+ /**
396
+ * Create a snapshot and block until it is committed.
397
+ *
398
+ * Combines `snapshot()` with polling `getSnapshot()` until `completed`.
399
+ * Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
400
+ * without managing the client separately.
401
+ *
402
+ * @param sandboxId - ID of the running sandbox to snapshot.
403
+ * @param options.timeout - Max seconds to wait (default 300).
404
+ * @param options.pollInterval - Seconds between status polls (default 1).
405
+ * @param options.contentMode - Content mode passed through to `snapshot()`.
406
+ * @throws {SandboxError} If the snapshot fails or `timeout` elapses.
407
+ */
246
408
  snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<SnapshotInfo>;
409
+ /** Create a new sandbox pool with warm pre-booted containers. */
247
410
  createPool(options: CreatePoolOptions): Promise<CreateSandboxPoolResponse>;
411
+ /** Get current state and metadata for a sandbox pool by ID. */
248
412
  getPool(poolId: string): Promise<SandboxPoolInfo>;
413
+ /** List all sandbox pools in the namespace. */
249
414
  listPools(): Promise<SandboxPoolInfo[]>;
415
+ /** Replace the configuration of an existing sandbox pool. */
250
416
  updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
417
+ /** Delete a sandbox pool. Fails if the pool has active containers. */
251
418
  deletePool(poolId: string): Promise<void>;
419
+ /** Return a `Sandbox` handle for an existing running sandbox without verifying it exists. */
252
420
  connect(identifier: string, proxyUrl?: string, routingHint?: string): Sandbox;
421
+ /**
422
+ * Create a sandbox, wait for it to reach `Running`, and return a connected handle.
423
+ *
424
+ * Blocks until the sandbox is ready or `startupTimeout` elapses. The returned
425
+ * `Sandbox` auto-terminates when `terminate()` is called.
426
+ *
427
+ * @param options.startupTimeout - Max seconds to wait for `Running` status (default 60).
428
+ * @throws {SandboxError} If the sandbox terminates during startup or the timeout elapses.
429
+ */
253
430
  createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
254
431
  }
255
432
 
@@ -498,4 +675,4 @@ declare class RequestExecutionError extends Error {
498
675
  constructor(message: string, functionName?: string);
499
676
  }
500
677
 
501
- export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, CommandResult, type ConnectDesktopOptions, 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, TcpTunnel, type TunnelAddress, UpdatePoolOptions, type UpsertSecretResponse };
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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,23 @@
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-BQ6fJT92.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-BQ6fJT92.js';
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';
3
+
4
+ /**
5
+ * The return value of every SDK operation. Carries the W3C `trace_id` so callers
6
+ * can correlate a specific request with its server-side spans in Datadog APM or
7
+ * any other OTEL-compatible backend.
8
+ *
9
+ * Because this is an intersection type, all properties of `T` are accessible
10
+ * directly — existing code that ignores `traceId` continues to compile and run
11
+ * unchanged.
12
+ *
13
+ * @example
14
+ * const sandbox = await client.createSandbox(req);
15
+ * console.log(sandbox.id); // existing field — unchanged
16
+ * console.log(sandbox.traceId); // new: look this up in Datadog APM
17
+ */
18
+ type Traced<T> = T & {
19
+ readonly traceId: string;
20
+ };
3
21
 
4
22
  type MouseButton = "left" | "middle" | "right";
5
23
  interface ConnectDesktopOptions {
@@ -147,6 +165,7 @@ declare class Pty {
147
165
  */
148
166
  declare class Sandbox {
149
167
  readonly sandboxId: string;
168
+ traceId: string | null;
150
169
  private readonly http;
151
170
  private readonly baseUrl;
152
171
  private readonly wsHeaders;
@@ -155,7 +174,56 @@ declare class Sandbox {
155
174
  constructor(options: SandboxOptions);
156
175
  /** @internal Used by SandboxClient.createAndConnect to set ownership. */
157
176
  _setOwner(client: SandboxClient): void;
177
+ /**
178
+ * Create a new sandbox and return a connected, running handle.
179
+ *
180
+ * Covers both fresh sandbox creation and restore-from-snapshot (set
181
+ * `snapshotId`). Blocks until the sandbox is `Running`.
182
+ */
183
+ static create(options?: CreateAndConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
184
+ /**
185
+ * Attach to an existing sandbox and return a connected handle.
186
+ *
187
+ * Verifies the sandbox exists via a server GET call, then returns a handle
188
+ * in whatever state the sandbox is in. Does **not** auto-resume a suspended
189
+ * sandbox — call `sandbox.resume()` explicitly.
190
+ */
191
+ static connect(options: ConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
192
+ /** Get information about a snapshot by ID. No sandbox handle needed. */
193
+ static getSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo>;
194
+ /** Delete a snapshot by ID. No sandbox handle needed. */
195
+ static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
196
+ private requireLifecycleClient;
197
+ /**
198
+ * Suspend this sandbox.
199
+ *
200
+ * By default blocks until the sandbox is fully `Suspended`. Pass
201
+ * `{ wait: false }` for fire-and-return.
202
+ */
203
+ suspend(options?: SuspendResumeOptions): Promise<void>;
204
+ /**
205
+ * Resume this sandbox.
206
+ *
207
+ * By default blocks until the sandbox is `Running` and routable. Pass
208
+ * `{ wait: false }` for fire-and-return.
209
+ */
210
+ resume(options?: SuspendResumeOptions): Promise<void>;
211
+ /**
212
+ * Create a snapshot of this sandbox's filesystem and wait for it to
213
+ * be committed.
214
+ *
215
+ * By default blocks until the snapshot artifact is ready and returns
216
+ * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
217
+ * (returns `undefined`).
218
+ */
219
+ checkpoint(options?: CheckpointOptions): Promise<SnapshotInfo | undefined>;
220
+ /**
221
+ * List snapshots taken from this sandbox.
222
+ */
223
+ listSnapshots(): Promise<SnapshotInfo[]>;
224
+ /** Close the HTTP client. The sandbox keeps running. */
158
225
  close(): void;
226
+ /** Terminate the sandbox and release all resources. */
159
227
  terminate(): Promise<void>;
160
228
  /**
161
229
  * Run a command to completion and return its output.
@@ -164,36 +232,67 @@ declare class Sandbox {
164
232
  * the process, streams output, and delivers the exit code over one connection.
165
233
  */
166
234
  run(command: string, options?: RunOptions): Promise<CommandResult>;
235
+ /**
236
+ * Start a process in the sandbox without waiting for it to exit.
237
+ *
238
+ * Returns a `ProcessInfo` with the assigned `pid`. Use `getProcess()` to
239
+ * poll status, or `followStdout()` / `followOutput()` to stream output
240
+ * until the process exits. Use `run()` instead to block until completion
241
+ * and get combined output in one call.
242
+ */
167
243
  startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
244
+ /** List all processes (running and exited) tracked by the sandbox daemon. */
168
245
  listProcesses(): Promise<ProcessInfo[]>;
246
+ /** Get current status and metadata for a process by PID. */
169
247
  getProcess(pid: number): Promise<ProcessInfo>;
248
+ /** Send SIGKILL to a process. */
170
249
  killProcess(pid: number): Promise<void>;
250
+ /** Send an arbitrary signal to a process (e.g. `15` for SIGTERM, `9` for SIGKILL). */
171
251
  sendSignal(pid: number, signal: number): Promise<SendSignalResponse>;
252
+ /** Write bytes to a process's stdin. The process must have been started with `stdinMode: StdinMode.PIPE`. */
172
253
  writeStdin(pid: number, data: Uint8Array): Promise<void>;
254
+ /** Close a process's stdin pipe, signalling EOF to the process. */
173
255
  closeStdin(pid: number): Promise<void>;
256
+ /** Return all captured stdout lines produced so far by a process. */
174
257
  getStdout(pid: number): Promise<OutputResponse>;
258
+ /** Return all captured stderr lines produced so far by a process. */
175
259
  getStderr(pid: number): Promise<OutputResponse>;
260
+ /** Return all captured stdout+stderr lines produced so far by a process. */
176
261
  getOutput(pid: number): Promise<OutputResponse>;
262
+ /** Stream stdout events from a process until it exits. Yields one `OutputEvent` per line. */
177
263
  followStdout(pid: number, options?: {
178
264
  signal?: AbortSignal;
179
265
  }): AsyncIterable<OutputEvent>;
266
+ /** Stream stderr events from a process until it exits. Yields one `OutputEvent` per line. */
180
267
  followStderr(pid: number, options?: {
181
268
  signal?: AbortSignal;
182
269
  }): AsyncIterable<OutputEvent>;
270
+ /** Stream combined stdout+stderr events from a process until it exits. Yields one `OutputEvent` per line. */
183
271
  followOutput(pid: number, options?: {
184
272
  signal?: AbortSignal;
185
273
  }): AsyncIterable<OutputEvent>;
274
+ /** Read a file from the sandbox and return its raw bytes. */
186
275
  readFile(path: string): Promise<Uint8Array>;
276
+ /** Write raw bytes to a file in the sandbox, creating it if it does not exist. */
187
277
  writeFile(path: string, content: Uint8Array): Promise<void>;
278
+ /** Delete a file from the sandbox. */
188
279
  deleteFile(path: string): Promise<void>;
280
+ /** List the contents of a directory in the sandbox. */
189
281
  listDirectory(path: string): Promise<ListDirectoryResponse>;
282
+ /** Create an interactive PTY session. Returns a `sessionId` and `token` for WebSocket connection via `connectPty()`. */
190
283
  createPtySession(options: CreatePtySessionOptions): Promise<PtySessionInfo>;
284
+ /** Create a PTY session and connect to it immediately. Cleans up the session if the WebSocket connection fails. */
191
285
  createPty(options: CreatePtyOptions): Promise<Pty>;
286
+ /** Attach to an existing PTY session by ID and token and return a connected `Pty` handle. */
192
287
  connectPty(sessionId: string, token: string, options?: PtyConnectionOptions): Promise<Pty>;
288
+ /** Open a TCP tunnel to a port inside the sandbox and return the local listener. */
193
289
  createTunnel(remotePort: number, options?: CreateTunnelOptions): Promise<TcpTunnel>;
290
+ /** Connect to a sandbox VNC session for programmatic desktop control. */
194
291
  connectDesktop(options?: ConnectDesktopOptions): Promise<Desktop>;
195
292
  ptyWsUrl(sessionId: string, token: string): string;
293
+ /** Check the sandbox daemon health. */
196
294
  health(): Promise<HealthResponse>;
295
+ /** Get sandbox daemon info (version, uptime, process counts). */
197
296
  info(): Promise<DaemonInfo>;
198
297
  }
199
298
 
@@ -211,7 +310,8 @@ declare class SandboxClient {
211
310
  private readonly projectId;
212
311
  private readonly namespace;
213
312
  private readonly local;
214
- constructor(options?: SandboxClientOptions);
313
+ /** @internal Pass `true` to suppress the deprecation warning when used by `Sandbox.create()` / `Sandbox.connect()`. */
314
+ constructor(options?: SandboxClientOptions, _internal?: boolean);
215
315
  /** Create a client for the TensorLake cloud platform. */
216
316
  static forCloud(options?: {
217
317
  apiKey?: string;
@@ -226,30 +326,107 @@ declare class SandboxClient {
226
326
  }): SandboxClient;
227
327
  close(): void;
228
328
  private path;
229
- create(options?: CreateSandboxOptions): Promise<CreateSandboxResponse>;
329
+ /** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
330
+ create(options?: CreateSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
331
+ /** Get current state and metadata for a sandbox by ID. */
230
332
  get(sandboxId: string): Promise<SandboxInfo>;
333
+ /** List all sandboxes in the namespace. */
231
334
  list(): Promise<SandboxInfo[]>;
335
+ /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
232
336
  update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
337
+ /** Get the current proxy port settings for a sandbox. */
233
338
  getPortAccess(sandboxId: string): Promise<SandboxPortAccess>;
339
+ /** Add one or more user ports to the sandbox proxy allowlist. */
234
340
  exposePorts(sandboxId: string, ports: number[], options?: {
235
341
  allowUnauthenticatedAccess?: boolean;
236
342
  }): Promise<SandboxInfo>;
343
+ /** Remove one or more user ports from the sandbox proxy allowlist. */
237
344
  unexposePorts(sandboxId: string, ports: number[]): Promise<SandboxInfo>;
345
+ /** Terminate and delete a sandbox. */
238
346
  delete(sandboxId: string): Promise<void>;
239
- suspend(sandboxId: string): Promise<void>;
240
- resume(sandboxId: string): Promise<void>;
241
- claim(poolId: string): Promise<CreateSandboxResponse>;
347
+ /**
348
+ * Suspend a named sandbox, preserving its state for later resume.
349
+ *
350
+ * Only sandboxes created with a `name` can be suspended; ephemeral sandboxes
351
+ * cannot. By default blocks until the sandbox is fully `Suspended`. Pass
352
+ * `{ wait: false }` to return immediately after the request is sent
353
+ * (fire-and-return); the server processes the suspend asynchronously.
354
+ *
355
+ * @param sandboxId - ID or name of the sandbox.
356
+ * @param options.wait - If `true` (default), poll until `Suspended`. Pass `false` to fire-and-return.
357
+ * @param options.timeout - Max seconds to wait when `wait=true` (default 300).
358
+ * @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
359
+ * @throws {SandboxError} If `wait=true` and the sandbox does not reach `Suspended` within `timeout`.
360
+ */
361
+ suspend(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
362
+ /**
363
+ * Resume a suspended sandbox and bring it back to `Running`.
364
+ *
365
+ * By default blocks until the sandbox is `Running` and routable. Pass
366
+ * `{ wait: false }` to return immediately after the request is sent
367
+ * (fire-and-return); the server processes the resume asynchronously.
368
+ *
369
+ * @param sandboxId - ID or name of the sandbox.
370
+ * @param options.wait - If `true` (default), poll until `Running`. Pass `false` to fire-and-return.
371
+ * @param options.timeout - Max seconds to wait when `wait=true` (default 300).
372
+ * @param options.pollInterval - Seconds between status polls when `wait=true` (default 1).
373
+ * @throws {SandboxError} If `wait=true` and the sandbox does not reach `Running` within `timeout`.
374
+ */
375
+ resume(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
376
+ /** Claim a warm sandbox from a pool, creating one if no warm containers are available. */
377
+ claim(poolId: string): Promise<Traced<CreateSandboxResponse>>;
378
+ /**
379
+ * Request a snapshot of a running sandbox's filesystem.
380
+ *
381
+ * This call **returns immediately** with a `snapshotId` and `in_progress`
382
+ * status — the snapshot is created asynchronously. Poll `getSnapshot()` until
383
+ * `completed` or `failed`, or use `snapshotAndWait()` to block automatically.
384
+ *
385
+ * @param options.contentMode - `"filesystem_only"` for cold-boot snapshots (e.g. image builds).
386
+ * Omit to use the server default (full VM snapshot).
387
+ */
242
388
  snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
389
+ /** Get current status and metadata for a snapshot by ID. */
243
390
  getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
391
+ /** List all snapshots in the namespace. */
244
392
  listSnapshots(): Promise<SnapshotInfo[]>;
393
+ /** Delete a snapshot by ID. */
245
394
  deleteSnapshot(snapshotId: string): Promise<void>;
395
+ /**
396
+ * Create a snapshot and block until it is committed.
397
+ *
398
+ * Combines `snapshot()` with polling `getSnapshot()` until `completed`.
399
+ * Prefer `sandbox.checkpoint()` on a `Sandbox` handle for the same behavior
400
+ * without managing the client separately.
401
+ *
402
+ * @param sandboxId - ID of the running sandbox to snapshot.
403
+ * @param options.timeout - Max seconds to wait (default 300).
404
+ * @param options.pollInterval - Seconds between status polls (default 1).
405
+ * @param options.contentMode - Content mode passed through to `snapshot()`.
406
+ * @throws {SandboxError} If the snapshot fails or `timeout` elapses.
407
+ */
246
408
  snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<SnapshotInfo>;
409
+ /** Create a new sandbox pool with warm pre-booted containers. */
247
410
  createPool(options: CreatePoolOptions): Promise<CreateSandboxPoolResponse>;
411
+ /** Get current state and metadata for a sandbox pool by ID. */
248
412
  getPool(poolId: string): Promise<SandboxPoolInfo>;
413
+ /** List all sandbox pools in the namespace. */
249
414
  listPools(): Promise<SandboxPoolInfo[]>;
415
+ /** Replace the configuration of an existing sandbox pool. */
250
416
  updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
417
+ /** Delete a sandbox pool. Fails if the pool has active containers. */
251
418
  deletePool(poolId: string): Promise<void>;
419
+ /** Return a `Sandbox` handle for an existing running sandbox without verifying it exists. */
252
420
  connect(identifier: string, proxyUrl?: string, routingHint?: string): Sandbox;
421
+ /**
422
+ * Create a sandbox, wait for it to reach `Running`, and return a connected handle.
423
+ *
424
+ * Blocks until the sandbox is ready or `startupTimeout` elapses. The returned
425
+ * `Sandbox` auto-terminates when `terminate()` is called.
426
+ *
427
+ * @param options.startupTimeout - Max seconds to wait for `Running` status (default 60).
428
+ * @throws {SandboxError} If the sandbox terminates during startup or the timeout elapses.
429
+ */
253
430
  createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
254
431
  }
255
432
 
@@ -498,4 +675,4 @@ declare class RequestExecutionError extends Error {
498
675
  constructor(message: string, functionName?: string);
499
676
  }
500
677
 
501
- export { APIClient, type ApiKeyIntrospection, type ApplicationBuildContext, type ApplicationBuildImageResult, type ApplicationBuildResponse, type ApplicationManifest, type ApplicationSummary, type BinaryPayload, type BuildInfo, type BuildLogEntry, CloudClient, type CloudClientOptions, CommandResult, type ConnectDesktopOptions, 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, TcpTunnel, type TunnelAddress, UpdatePoolOptions, type UpsertSecretResponse };
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 };