tensorlake 0.5.6 → 0.5.7

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 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-BmhjX2bC.cjs';
2
- export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as StdinMode, Z as createSandboxImage, _ as dockerfileContent } from './sandbox-image-BmhjX2bC.cjs';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, 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-BMDaNpZ2.cjs';
2
+ export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as StdinMode, Z as createSandboxImage, _ as dockerfileContent } from './sandbox-image-BMDaNpZ2.cjs';
3
3
 
4
4
  /**
5
5
  * The return value of every SDK operation. Carries the W3C `trace_id` so callers
@@ -191,8 +191,8 @@ declare class Sandbox {
191
191
  /**
192
192
  * Attach to an existing sandbox and return a connected handle.
193
193
  *
194
- * Verifies the sandbox exists via a server GET call, then returns a handle
195
- * in whatever state the sandbox is in. Does **not** auto-resume a suspended
194
+ * Returns immediately without contacting the server. Call `sandbox.info()`
195
+ * to fetch the current state on demand. Does **not** auto-resume a suspended
196
196
  * sandbox — call `sandbox.resume()` explicitly.
197
197
  */
198
198
  static connect(options: ConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
@@ -200,7 +200,13 @@ declare class Sandbox {
200
200
  static getSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo>;
201
201
  /** Delete a snapshot by ID. No sandbox handle needed. */
202
202
  static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
203
+ /** List all sandboxes. No sandbox handle needed. */
204
+ static list(options?: Partial<SandboxClientOptions>): Promise<SandboxInfo[]>;
205
+ /** List all snapshots in the project. No sandbox handle needed. */
206
+ static listSnapshots(options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo[]>;
203
207
  private requireLifecycleClient;
208
+ /** Fetch the current sandbox information from the server on demand. */
209
+ info(): Promise<Traced<SandboxInfo>>;
204
210
  /**
205
211
  * Fetch the current sandbox status from the server.
206
212
  *
@@ -214,7 +220,7 @@ declare class Sandbox {
214
220
  * Naming an ephemeral sandbox makes it non-ephemeral and enables
215
221
  * suspend/resume.
216
222
  */
217
- update(options: UpdateSandboxOptions): Promise<SandboxInfo>;
223
+ update(options: UpdateSandboxOptions): Promise<Traced<SandboxInfo>>;
218
224
  /**
219
225
  * Suspend this sandbox.
220
226
  *
@@ -237,7 +243,7 @@ declare class Sandbox {
237
243
  * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
238
244
  * (returns `undefined`).
239
245
  */
240
- checkpoint(options?: CheckpointOptions): Promise<SnapshotInfo | undefined>;
246
+ checkpoint(options?: CheckpointOptions): Promise<Traced<SnapshotInfo> | undefined>;
241
247
  /**
242
248
  * List snapshots taken from this sandbox.
243
249
  */
@@ -252,7 +258,7 @@ declare class Sandbox {
252
258
  * Uses a single streaming `POST /api/v1/processes/run` request that starts
253
259
  * the process, streams output, and delivers the exit code over one connection.
254
260
  */
255
- run(command: string, options?: RunOptions): Promise<CommandResult>;
261
+ run(command: string, options?: RunOptions): Promise<Traced<CommandResult>>;
256
262
  /**
257
263
  * Start a process in the sandbox without waiting for it to exit.
258
264
  *
@@ -261,25 +267,25 @@ declare class Sandbox {
261
267
  * until the process exits. Use `run()` instead to block until completion
262
268
  * and get combined output in one call.
263
269
  */
264
- startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
270
+ startProcess(command: string, options?: StartProcessOptions): Promise<Traced<ProcessInfo>>;
265
271
  /** List all processes (running and exited) tracked by the sandbox daemon. */
266
272
  listProcesses(): Promise<Traced<ProcessInfo[]>>;
267
273
  /** Get current status and metadata for a process by PID. */
268
- getProcess(pid: number): Promise<ProcessInfo>;
274
+ getProcess(pid: number): Promise<Traced<ProcessInfo>>;
269
275
  /** Send SIGKILL to a process. */
270
276
  killProcess(pid: number): Promise<void>;
271
277
  /** Send an arbitrary signal to a process (e.g. `15` for SIGTERM, `9` for SIGKILL). */
272
- sendSignal(pid: number, signal: number): Promise<SendSignalResponse>;
278
+ sendSignal(pid: number, signal: number): Promise<Traced<SendSignalResponse>>;
273
279
  /** Write bytes to a process's stdin. The process must have been started with `stdinMode: StdinMode.PIPE`. */
274
280
  writeStdin(pid: number, data: Uint8Array): Promise<void>;
275
281
  /** Close a process's stdin pipe, signalling EOF to the process. */
276
282
  closeStdin(pid: number): Promise<void>;
277
283
  /** Return all captured stdout lines produced so far by a process. */
278
- getStdout(pid: number): Promise<OutputResponse>;
284
+ getStdout(pid: number): Promise<Traced<OutputResponse>>;
279
285
  /** Return all captured stderr lines produced so far by a process. */
280
- getStderr(pid: number): Promise<OutputResponse>;
286
+ getStderr(pid: number): Promise<Traced<OutputResponse>>;
281
287
  /** Return all captured stdout+stderr lines produced so far by a process. */
282
- getOutput(pid: number): Promise<OutputResponse>;
288
+ getOutput(pid: number): Promise<Traced<OutputResponse>>;
283
289
  /** Stream stdout events from a process until it exits. Yields one `OutputEvent` per line. */
284
290
  followStdout(pid: number, options?: {
285
291
  signal?: AbortSignal;
@@ -293,15 +299,15 @@ declare class Sandbox {
293
299
  signal?: AbortSignal;
294
300
  }): AsyncIterable<OutputEvent>;
295
301
  /** Read a file from the sandbox and return its raw bytes. */
296
- readFile(path: string): Promise<Uint8Array>;
302
+ readFile(path: string): Promise<Traced<Uint8Array>>;
297
303
  /** Write raw bytes to a file in the sandbox, creating it if it does not exist. */
298
304
  writeFile(path: string, content: Uint8Array): Promise<void>;
299
305
  /** Delete a file from the sandbox. */
300
306
  deleteFile(path: string): Promise<void>;
301
307
  /** List the contents of a directory in the sandbox. */
302
- listDirectory(path: string): Promise<ListDirectoryResponse>;
308
+ listDirectory(path: string): Promise<Traced<ListDirectoryResponse>>;
303
309
  /** Create an interactive PTY session. Returns a `sessionId` and `token` for WebSocket connection via `connectPty()`. */
304
- createPtySession(options: CreatePtySessionOptions): Promise<PtySessionInfo>;
310
+ createPtySession(options: CreatePtySessionOptions): Promise<Traced<PtySessionInfo>>;
305
311
  /** Create a PTY session and connect to it immediately. Cleans up the session if the WebSocket connection fails. */
306
312
  createPty(options: CreatePtyOptions): Promise<Pty>;
307
313
  /** Attach to an existing PTY session by ID and token and return a connected `Pty` handle. */
@@ -318,9 +324,9 @@ declare class Sandbox {
318
324
  private waitForPortReady;
319
325
  ptyWsUrl(sessionId: string, token: string): string;
320
326
  /** Check the sandbox daemon health. */
321
- health(): Promise<HealthResponse>;
327
+ health(): Promise<Traced<HealthResponse>>;
322
328
  /** Get sandbox daemon info (version, uptime, process counts). */
323
- info(): Promise<DaemonInfo>;
329
+ daemonInfo(): Promise<Traced<DaemonInfo>>;
324
330
  }
325
331
 
326
332
  /**
@@ -356,11 +362,11 @@ declare class SandboxClient {
356
362
  /** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
357
363
  create(options?: CreateSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
358
364
  /** Get current state and metadata for a sandbox by ID. */
359
- get(sandboxId: string): Promise<SandboxInfo>;
365
+ get(sandboxId: string): Promise<Traced<SandboxInfo>>;
360
366
  /** List all sandboxes in the namespace. */
361
367
  list(): Promise<Traced<SandboxInfo[]>>;
362
368
  /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
363
- update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
369
+ update(sandboxId: string, options: UpdateSandboxOptions): Promise<Traced<SandboxInfo>>;
364
370
  /** Get the current proxy port settings for a sandbox. */
365
371
  getPortAccess(sandboxId: string): Promise<SandboxPortAccess>;
366
372
  /** Add one or more user ports to the sandbox proxy allowlist. */
@@ -414,7 +420,7 @@ declare class SandboxClient {
414
420
  */
415
421
  snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
416
422
  /** Get current status and metadata for a snapshot by ID. */
417
- getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
423
+ getSnapshot(snapshotId: string): Promise<Traced<SnapshotInfo>>;
418
424
  /** List all snapshots in the namespace. */
419
425
  listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
420
426
  /** Delete a snapshot by ID. */
@@ -432,7 +438,7 @@ declare class SandboxClient {
432
438
  * @param options.snapshotType - Snapshot type passed through to `snapshot()`.
433
439
  * @throws {SandboxError} If the snapshot fails or `timeout` elapses.
434
440
  */
435
- snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<SnapshotInfo>;
441
+ snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<Traced<SnapshotInfo>>;
436
442
  /** Create a new sandbox pool with warm pre-booted containers. */
437
443
  createPool(options: CreatePoolOptions): Promise<CreateSandboxPoolResponse>;
438
444
  /** Get current state and metadata for a sandbox pool by ID. */
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 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-BmhjX2bC.js';
2
- export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as StdinMode, Z as createSandboxImage, _ as dockerfileContent } from './sandbox-image-BmhjX2bC.js';
1
+ import { C as CreatePtySessionOptions, S as SandboxOptions, a as CreateAndConnectOptions, b as SandboxClientOptions, c as ConnectOptions, d as SnapshotInfo, e as SandboxInfo, f as SandboxStatus, U as UpdateSandboxOptions, 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-BMDaNpZ2.js';
2
+ export { x as CheckpointType, y as ContainerResourcesInfo, z as ContainerState, A as CreateSandboxImageOptions, B as DirectoryEntry, E as DockerfileBuildPlan, F as DockerfileInstruction, I as Image, G as ImageBuildOperation, J as ImageBuildOperationType, J as ImageBuildOperationTypeValue, K as ImageOptions, N as NetworkConfig, M as OutputMode, Q as PoolContainerInfo, T as ProcessStatus, V as SandboxImageSource, W as SnapshotStatus, X as SnapshotType, Y as StdinMode, Z as createSandboxImage, _ as dockerfileContent } from './sandbox-image-BMDaNpZ2.js';
3
3
 
4
4
  /**
5
5
  * The return value of every SDK operation. Carries the W3C `trace_id` so callers
@@ -191,8 +191,8 @@ declare class Sandbox {
191
191
  /**
192
192
  * Attach to an existing sandbox and return a connected handle.
193
193
  *
194
- * Verifies the sandbox exists via a server GET call, then returns a handle
195
- * in whatever state the sandbox is in. Does **not** auto-resume a suspended
194
+ * Returns immediately without contacting the server. Call `sandbox.info()`
195
+ * to fetch the current state on demand. Does **not** auto-resume a suspended
196
196
  * sandbox — call `sandbox.resume()` explicitly.
197
197
  */
198
198
  static connect(options: ConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
@@ -200,7 +200,13 @@ declare class Sandbox {
200
200
  static getSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo>;
201
201
  /** Delete a snapshot by ID. No sandbox handle needed. */
202
202
  static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
203
+ /** List all sandboxes. No sandbox handle needed. */
204
+ static list(options?: Partial<SandboxClientOptions>): Promise<SandboxInfo[]>;
205
+ /** List all snapshots in the project. No sandbox handle needed. */
206
+ static listSnapshots(options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo[]>;
203
207
  private requireLifecycleClient;
208
+ /** Fetch the current sandbox information from the server on demand. */
209
+ info(): Promise<Traced<SandboxInfo>>;
204
210
  /**
205
211
  * Fetch the current sandbox status from the server.
206
212
  *
@@ -214,7 +220,7 @@ declare class Sandbox {
214
220
  * Naming an ephemeral sandbox makes it non-ephemeral and enables
215
221
  * suspend/resume.
216
222
  */
217
- update(options: UpdateSandboxOptions): Promise<SandboxInfo>;
223
+ update(options: UpdateSandboxOptions): Promise<Traced<SandboxInfo>>;
218
224
  /**
219
225
  * Suspend this sandbox.
220
226
  *
@@ -237,7 +243,7 @@ declare class Sandbox {
237
243
  * the completed `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
238
244
  * (returns `undefined`).
239
245
  */
240
- checkpoint(options?: CheckpointOptions): Promise<SnapshotInfo | undefined>;
246
+ checkpoint(options?: CheckpointOptions): Promise<Traced<SnapshotInfo> | undefined>;
241
247
  /**
242
248
  * List snapshots taken from this sandbox.
243
249
  */
@@ -252,7 +258,7 @@ declare class Sandbox {
252
258
  * Uses a single streaming `POST /api/v1/processes/run` request that starts
253
259
  * the process, streams output, and delivers the exit code over one connection.
254
260
  */
255
- run(command: string, options?: RunOptions): Promise<CommandResult>;
261
+ run(command: string, options?: RunOptions): Promise<Traced<CommandResult>>;
256
262
  /**
257
263
  * Start a process in the sandbox without waiting for it to exit.
258
264
  *
@@ -261,25 +267,25 @@ declare class Sandbox {
261
267
  * until the process exits. Use `run()` instead to block until completion
262
268
  * and get combined output in one call.
263
269
  */
264
- startProcess(command: string, options?: StartProcessOptions): Promise<ProcessInfo>;
270
+ startProcess(command: string, options?: StartProcessOptions): Promise<Traced<ProcessInfo>>;
265
271
  /** List all processes (running and exited) tracked by the sandbox daemon. */
266
272
  listProcesses(): Promise<Traced<ProcessInfo[]>>;
267
273
  /** Get current status and metadata for a process by PID. */
268
- getProcess(pid: number): Promise<ProcessInfo>;
274
+ getProcess(pid: number): Promise<Traced<ProcessInfo>>;
269
275
  /** Send SIGKILL to a process. */
270
276
  killProcess(pid: number): Promise<void>;
271
277
  /** Send an arbitrary signal to a process (e.g. `15` for SIGTERM, `9` for SIGKILL). */
272
- sendSignal(pid: number, signal: number): Promise<SendSignalResponse>;
278
+ sendSignal(pid: number, signal: number): Promise<Traced<SendSignalResponse>>;
273
279
  /** Write bytes to a process's stdin. The process must have been started with `stdinMode: StdinMode.PIPE`. */
274
280
  writeStdin(pid: number, data: Uint8Array): Promise<void>;
275
281
  /** Close a process's stdin pipe, signalling EOF to the process. */
276
282
  closeStdin(pid: number): Promise<void>;
277
283
  /** Return all captured stdout lines produced so far by a process. */
278
- getStdout(pid: number): Promise<OutputResponse>;
284
+ getStdout(pid: number): Promise<Traced<OutputResponse>>;
279
285
  /** Return all captured stderr lines produced so far by a process. */
280
- getStderr(pid: number): Promise<OutputResponse>;
286
+ getStderr(pid: number): Promise<Traced<OutputResponse>>;
281
287
  /** Return all captured stdout+stderr lines produced so far by a process. */
282
- getOutput(pid: number): Promise<OutputResponse>;
288
+ getOutput(pid: number): Promise<Traced<OutputResponse>>;
283
289
  /** Stream stdout events from a process until it exits. Yields one `OutputEvent` per line. */
284
290
  followStdout(pid: number, options?: {
285
291
  signal?: AbortSignal;
@@ -293,15 +299,15 @@ declare class Sandbox {
293
299
  signal?: AbortSignal;
294
300
  }): AsyncIterable<OutputEvent>;
295
301
  /** Read a file from the sandbox and return its raw bytes. */
296
- readFile(path: string): Promise<Uint8Array>;
302
+ readFile(path: string): Promise<Traced<Uint8Array>>;
297
303
  /** Write raw bytes to a file in the sandbox, creating it if it does not exist. */
298
304
  writeFile(path: string, content: Uint8Array): Promise<void>;
299
305
  /** Delete a file from the sandbox. */
300
306
  deleteFile(path: string): Promise<void>;
301
307
  /** List the contents of a directory in the sandbox. */
302
- listDirectory(path: string): Promise<ListDirectoryResponse>;
308
+ listDirectory(path: string): Promise<Traced<ListDirectoryResponse>>;
303
309
  /** Create an interactive PTY session. Returns a `sessionId` and `token` for WebSocket connection via `connectPty()`. */
304
- createPtySession(options: CreatePtySessionOptions): Promise<PtySessionInfo>;
310
+ createPtySession(options: CreatePtySessionOptions): Promise<Traced<PtySessionInfo>>;
305
311
  /** Create a PTY session and connect to it immediately. Cleans up the session if the WebSocket connection fails. */
306
312
  createPty(options: CreatePtyOptions): Promise<Pty>;
307
313
  /** Attach to an existing PTY session by ID and token and return a connected `Pty` handle. */
@@ -318,9 +324,9 @@ declare class Sandbox {
318
324
  private waitForPortReady;
319
325
  ptyWsUrl(sessionId: string, token: string): string;
320
326
  /** Check the sandbox daemon health. */
321
- health(): Promise<HealthResponse>;
327
+ health(): Promise<Traced<HealthResponse>>;
322
328
  /** Get sandbox daemon info (version, uptime, process counts). */
323
- info(): Promise<DaemonInfo>;
329
+ daemonInfo(): Promise<Traced<DaemonInfo>>;
324
330
  }
325
331
 
326
332
  /**
@@ -356,11 +362,11 @@ declare class SandboxClient {
356
362
  /** Create a new sandbox. Returns immediately; the sandbox may still be starting. Use `createAndConnect()` for a blocking, ready-to-use handle. */
357
363
  create(options?: CreateSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
358
364
  /** Get current state and metadata for a sandbox by ID. */
359
- get(sandboxId: string): Promise<SandboxInfo>;
365
+ get(sandboxId: string): Promise<Traced<SandboxInfo>>;
360
366
  /** List all sandboxes in the namespace. */
361
367
  list(): Promise<Traced<SandboxInfo[]>>;
362
368
  /** Update sandbox properties such as name, exposed ports, and proxy auth settings. */
363
- update(sandboxId: string, options: UpdateSandboxOptions): Promise<SandboxInfo>;
369
+ update(sandboxId: string, options: UpdateSandboxOptions): Promise<Traced<SandboxInfo>>;
364
370
  /** Get the current proxy port settings for a sandbox. */
365
371
  getPortAccess(sandboxId: string): Promise<SandboxPortAccess>;
366
372
  /** Add one or more user ports to the sandbox proxy allowlist. */
@@ -414,7 +420,7 @@ declare class SandboxClient {
414
420
  */
415
421
  snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
416
422
  /** Get current status and metadata for a snapshot by ID. */
417
- getSnapshot(snapshotId: string): Promise<SnapshotInfo>;
423
+ getSnapshot(snapshotId: string): Promise<Traced<SnapshotInfo>>;
418
424
  /** List all snapshots in the namespace. */
419
425
  listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
420
426
  /** Delete a snapshot by ID. */
@@ -432,7 +438,7 @@ declare class SandboxClient {
432
438
  * @param options.snapshotType - Snapshot type passed through to `snapshot()`.
433
439
  * @throws {SandboxError} If the snapshot fails or `timeout` elapses.
434
440
  */
435
- snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<SnapshotInfo>;
441
+ snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<Traced<SnapshotInfo>>;
436
442
  /** Create a new sandbox pool with warm pre-booted containers. */
437
443
  createPool(options: CreatePoolOptions): Promise<CreateSandboxPoolResponse>;
438
444
  /** Get current state and metadata for a sandbox pool by ID. */
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
13
13
  var init_defaults = __esm({
14
14
  "src/defaults.ts"() {
15
15
  "use strict";
16
- SDK_VERSION = "0.4.49";
16
+ SDK_VERSION = "0.5.7";
17
17
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
18
18
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
19
19
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -218,6 +218,9 @@ var init_http = __esm({
218
218
  if (options.hostHeader) {
219
219
  this.headers["Host"] = options.hostHeader;
220
220
  }
221
+ if (options.sandboxIdHeader) {
222
+ this.headers["X-Tensorlake-Sandbox-Id"] = options.sandboxIdHeader;
223
+ }
221
224
  if (options.routingHint) {
222
225
  this.headers["X-Tensorlake-Route-Hint"] = options.routingHint;
223
226
  }
@@ -2929,21 +2932,36 @@ function resolveProxyTarget(proxyUrl, sandboxId) {
2929
2932
  if (host === "localhost" || host === "127.0.0.1") {
2930
2933
  return {
2931
2934
  baseUrl: trimTrailingSlashes(proxyUrl),
2932
- hostHeader: `${sandboxId}.local`
2935
+ hostHeader: `${sandboxId}.local`,
2936
+ sandboxIdHeader: void 0
2933
2937
  };
2934
2938
  }
2935
2939
  const port = parsed.port ? `:${parsed.port}` : "";
2936
2940
  return {
2937
- baseUrl: `${parsed.protocol}//${sandboxId}.${host}${port}`,
2938
- hostHeader: void 0
2941
+ baseUrl: `${parsed.protocol}//${host}${port}`,
2942
+ hostHeader: void 0,
2943
+ sandboxIdHeader: sandboxId
2939
2944
  };
2940
2945
  } catch {
2941
2946
  return {
2942
2947
  baseUrl: `${trimTrailingSlashes(proxyUrl)}/${sandboxId}`,
2943
- hostHeader: void 0
2948
+ hostHeader: void 0,
2949
+ sandboxIdHeader: void 0
2944
2950
  };
2945
2951
  }
2946
2952
  }
2953
+ function resolveSandboxLifecycleUrl(apiUrl) {
2954
+ if (isLocalhost(apiUrl)) return apiUrl;
2955
+ try {
2956
+ const parsed = new URL(apiUrl);
2957
+ if (parsed.hostname.startsWith("api.")) {
2958
+ parsed.hostname = "sandbox." + parsed.hostname.slice(4);
2959
+ return parsed.toString().replace(/\/$/, "");
2960
+ }
2961
+ } catch {
2962
+ }
2963
+ return apiUrl;
2964
+ }
2947
2965
  function lifecyclePath(path2, isLocal, namespace) {
2948
2966
  if (isLocal) {
2949
2967
  return `/v1/namespaces/${namespace}/${path2}`;
@@ -3170,7 +3188,7 @@ var init_sandbox = __esm({
3170
3188
  this.sandboxId = options.sandboxId;
3171
3189
  this.lifecycleIdentifier = options.sandboxId;
3172
3190
  const proxyUrl = options.proxyUrl ?? SANDBOX_PROXY_URL;
3173
- const { baseUrl, hostHeader } = resolveProxyTarget(proxyUrl, options.sandboxId);
3191
+ const { baseUrl, hostHeader, sandboxIdHeader } = resolveProxyTarget(proxyUrl, options.sandboxId);
3174
3192
  this.baseUrl = baseUrl;
3175
3193
  this.wsHeaders = {};
3176
3194
  if (options.apiKey) {
@@ -3185,12 +3203,16 @@ var init_sandbox = __esm({
3185
3203
  if (hostHeader) {
3186
3204
  this.wsHeaders.Host = hostHeader;
3187
3205
  }
3206
+ if (sandboxIdHeader) {
3207
+ this.wsHeaders["X-Tensorlake-Sandbox-Id"] = sandboxIdHeader;
3208
+ }
3188
3209
  this.http = new HttpClient({
3189
3210
  baseUrl,
3190
3211
  apiKey: options.apiKey,
3191
3212
  organizationId: options.organizationId,
3192
3213
  projectId: options.projectId,
3193
3214
  hostHeader,
3215
+ sandboxIdHeader,
3194
3216
  routingHint: options.routingHint
3195
3217
  });
3196
3218
  }
@@ -3231,8 +3253,8 @@ var init_sandbox = __esm({
3231
3253
  /**
3232
3254
  * Attach to an existing sandbox and return a connected handle.
3233
3255
  *
3234
- * Verifies the sandbox exists via a server GET call, then returns a handle
3235
- * in whatever state the sandbox is in. Does **not** auto-resume a suspended
3256
+ * Returns immediately without contacting the server. Call `sandbox.info()`
3257
+ * to fetch the current state on demand. Does **not** auto-resume a suspended
3236
3258
  * sandbox — call `sandbox.resume()` explicitly.
3237
3259
  */
3238
3260
  static async connect(options) {
@@ -3242,15 +3264,12 @@ var init_sandbox = __esm({
3242
3264
  /* _internal */
3243
3265
  true
3244
3266
  );
3245
- const info = await client.get(options.sandboxId);
3246
3267
  const sandbox = client.connect(
3247
- info.sandboxId,
3268
+ options.sandboxId,
3248
3269
  options.proxyUrl,
3249
- options.routingHint ?? info.routingHint
3270
+ options.routingHint
3250
3271
  );
3251
3272
  sandbox.lifecycleClient = client;
3252
- sandbox._setLifecycleIdentifier(info.sandboxId);
3253
- sandbox._setName(info.name ?? null);
3254
3273
  return sandbox;
3255
3274
  }
3256
3275
  // --- Static snapshot management ---
@@ -3274,6 +3293,26 @@ var init_sandbox = __esm({
3274
3293
  );
3275
3294
  await client.deleteSnapshot(snapshotId);
3276
3295
  }
3296
+ /** List all sandboxes. No sandbox handle needed. */
3297
+ static async list(options) {
3298
+ const { SandboxClient: SandboxClient2 } = await Promise.resolve().then(() => (init_client(), client_exports));
3299
+ const client = new SandboxClient2(
3300
+ options,
3301
+ /* _internal */
3302
+ true
3303
+ );
3304
+ return client.list();
3305
+ }
3306
+ /** List all snapshots in the project. No sandbox handle needed. */
3307
+ static async listSnapshots(options) {
3308
+ const { SandboxClient: SandboxClient2 } = await Promise.resolve().then(() => (init_client(), client_exports));
3309
+ const client = new SandboxClient2(
3310
+ options,
3311
+ /* _internal */
3312
+ true
3313
+ );
3314
+ return client.listSnapshots();
3315
+ }
3277
3316
  // --- Instance lifecycle methods ---
3278
3317
  requireLifecycleClient(operation) {
3279
3318
  if (!this.lifecycleClient) {
@@ -3283,6 +3322,14 @@ var init_sandbox = __esm({
3283
3322
  }
3284
3323
  return this.lifecycleClient;
3285
3324
  }
3325
+ /** Fetch the current sandbox information from the server on demand. */
3326
+ async info() {
3327
+ const client = this.requireLifecycleClient("info");
3328
+ const info = await client.get(this.lifecycleIdentifier);
3329
+ this._setLifecycleIdentifier(info.sandboxId);
3330
+ this._setName(info.name ?? null);
3331
+ return info;
3332
+ }
3286
3333
  /**
3287
3334
  * Fetch the current sandbox status from the server.
3288
3335
  *
@@ -3390,6 +3437,7 @@ var init_sandbox = __esm({
3390
3437
  "/api/v1/processes/run",
3391
3438
  { json: body }
3392
3439
  );
3440
+ const traceId = sseStream.traceId;
3393
3441
  const stdoutLines = [];
3394
3442
  const stderrLines = [];
3395
3443
  let exitCode = -1;
@@ -3408,11 +3456,10 @@ var init_sandbox = __esm({
3408
3456
  }
3409
3457
  }
3410
3458
  }
3411
- return {
3412
- exitCode,
3413
- stdout: stdoutLines.join("\n"),
3414
- stderr: stderrLines.join("\n")
3415
- };
3459
+ return Object.assign(
3460
+ { exitCode, stdout: stdoutLines.join("\n"), stderr: stderrLines.join("\n") },
3461
+ { traceId }
3462
+ );
3416
3463
  }
3417
3464
  // --- Process management ---
3418
3465
  /**
@@ -3442,7 +3489,7 @@ var init_sandbox = __esm({
3442
3489
  "/api/v1/processes",
3443
3490
  { body: payload }
3444
3491
  );
3445
- return fromSnakeKeys(raw);
3492
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3446
3493
  }
3447
3494
  /** List all processes (running and exited) tracked by the sandbox daemon. */
3448
3495
  async listProcesses() {
@@ -3459,7 +3506,7 @@ var init_sandbox = __esm({
3459
3506
  "GET",
3460
3507
  `/api/v1/processes/${pid}`
3461
3508
  );
3462
- return fromSnakeKeys(raw);
3509
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3463
3510
  }
3464
3511
  /** Send SIGKILL to a process. */
3465
3512
  async killProcess(pid) {
@@ -3472,7 +3519,7 @@ var init_sandbox = __esm({
3472
3519
  `/api/v1/processes/${pid}/signal`,
3473
3520
  { body: { signal } }
3474
3521
  );
3475
- return fromSnakeKeys(raw);
3522
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3476
3523
  }
3477
3524
  // --- Process I/O ---
3478
3525
  /** Write bytes to a process's stdin. The process must have been started with `stdinMode: StdinMode.PIPE`. */
@@ -3492,7 +3539,7 @@ var init_sandbox = __esm({
3492
3539
  "GET",
3493
3540
  `/api/v1/processes/${pid}/stdout`
3494
3541
  );
3495
- return fromSnakeKeys(raw);
3542
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3496
3543
  }
3497
3544
  /** Return all captured stderr lines produced so far by a process. */
3498
3545
  async getStderr(pid) {
@@ -3500,7 +3547,7 @@ var init_sandbox = __esm({
3500
3547
  "GET",
3501
3548
  `/api/v1/processes/${pid}/stderr`
3502
3549
  );
3503
- return fromSnakeKeys(raw);
3550
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3504
3551
  }
3505
3552
  /** Return all captured stdout+stderr lines produced so far by a process. */
3506
3553
  async getOutput(pid) {
@@ -3508,7 +3555,7 @@ var init_sandbox = __esm({
3508
3555
  "GET",
3509
3556
  `/api/v1/processes/${pid}/output`
3510
3557
  );
3511
- return fromSnakeKeys(raw);
3558
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3512
3559
  }
3513
3560
  // --- Streaming (SSE) ---
3514
3561
  /** Stream stdout events from a process until it exits. Yields one `OutputEvent` per line. */
@@ -3582,7 +3629,7 @@ var init_sandbox = __esm({
3582
3629
  "GET",
3583
3630
  `/api/v1/files/list?path=${encodeURIComponent(path2)}`
3584
3631
  );
3585
- return fromSnakeKeys(raw);
3632
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3586
3633
  }
3587
3634
  // --- PTY ---
3588
3635
  /** Create an interactive PTY session. Returns a `sessionId` and `token` for WebSocket connection via `connectPty()`. */
@@ -3600,7 +3647,7 @@ var init_sandbox = __esm({
3600
3647
  "/api/v1/pty",
3601
3648
  { body: payload }
3602
3649
  );
3603
- return fromSnakeKeys(raw);
3650
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3604
3651
  }
3605
3652
  /** Create a PTY session and connect to it immediately. Cleans up the session if the WebSocket connection fails. */
3606
3653
  async createPty(options) {
@@ -3719,15 +3766,15 @@ var init_sandbox = __esm({
3719
3766
  "GET",
3720
3767
  "/api/v1/health"
3721
3768
  );
3722
- return fromSnakeKeys(raw);
3769
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3723
3770
  }
3724
3771
  /** Get sandbox daemon info (version, uptime, process counts). */
3725
- async info() {
3772
+ async daemonInfo() {
3726
3773
  const raw = await this.http.requestJson(
3727
3774
  "GET",
3728
3775
  "/api/v1/info"
3729
3776
  );
3730
- return fromSnakeKeys(raw);
3777
+ return Object.assign(fromSnakeKeys(raw), { traceId: raw.traceId });
3731
3778
  }
3732
3779
  };
3733
3780
  }
@@ -3820,7 +3867,7 @@ var init_client = __esm({
3820
3867
  this.namespace = options?.namespace ?? NAMESPACE;
3821
3868
  this.local = isLocalhost(this.apiUrl);
3822
3869
  this.http = new HttpClient({
3823
- baseUrl: this.apiUrl,
3870
+ baseUrl: resolveSandboxLifecycleUrl(this.apiUrl),
3824
3871
  apiKey: this.apiKey,
3825
3872
  organizationId: this.organizationId,
3826
3873
  projectId: this.projectId,
@@ -3888,7 +3935,7 @@ var init_client = __esm({
3888
3935
  "GET",
3889
3936
  this.path(`sandboxes/${sandboxId}`)
3890
3937
  );
3891
- return fromSnakeKeys(raw, "sandboxId");
3938
+ return Object.assign(fromSnakeKeys(raw, "sandboxId"), { traceId: raw.traceId });
3892
3939
  }
3893
3940
  /** List all sandboxes in the namespace. */
3894
3941
  async list() {
@@ -3919,7 +3966,7 @@ var init_client = __esm({
3919
3966
  this.path(`sandboxes/${sandboxId}`),
3920
3967
  { body }
3921
3968
  );
3922
- return fromSnakeKeys(raw, "sandboxId");
3969
+ return Object.assign(fromSnakeKeys(raw, "sandboxId"), { traceId: raw.traceId });
3923
3970
  }
3924
3971
  /** Get the current proxy port settings for a sandbox. */
3925
3972
  async getPortAccess(sandboxId) {
@@ -4061,7 +4108,7 @@ var init_client = __esm({
4061
4108
  "GET",
4062
4109
  this.path(`snapshots/${snapshotId}`)
4063
4110
  );
4064
- return fromSnakeKeys(raw, "snapshotId");
4111
+ return Object.assign(fromSnakeKeys(raw, "snapshotId"), { traceId: raw.traceId });
4065
4112
  }
4066
4113
  /** List all snapshots in the namespace. */
4067
4114
  async listSnapshots() {