langsmith 0.5.21 → 0.5.23

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.
Files changed (42) hide show
  1. package/dist/client.cjs +327 -10
  2. package/dist/client.d.ts +90 -1
  3. package/dist/client.js +330 -13
  4. package/dist/evaluation/_runner.cjs +1 -4
  5. package/dist/evaluation/_runner.js +1 -4
  6. package/dist/experimental/sandbox/client.cjs +102 -427
  7. package/dist/experimental/sandbox/client.d.ts +68 -159
  8. package/dist/experimental/sandbox/client.js +104 -429
  9. package/dist/experimental/sandbox/errors.cjs +1 -2
  10. package/dist/experimental/sandbox/errors.d.ts +1 -2
  11. package/dist/experimental/sandbox/errors.js +1 -2
  12. package/dist/experimental/sandbox/helpers.cjs +8 -98
  13. package/dist/experimental/sandbox/helpers.d.ts +0 -29
  14. package/dist/experimental/sandbox/helpers.js +9 -95
  15. package/dist/experimental/sandbox/index.cjs +6 -1
  16. package/dist/experimental/sandbox/index.d.ts +7 -2
  17. package/dist/experimental/sandbox/index.js +6 -1
  18. package/dist/experimental/sandbox/sandbox.cjs +3 -11
  19. package/dist/experimental/sandbox/sandbox.d.ts +3 -5
  20. package/dist/experimental/sandbox/sandbox.js +3 -11
  21. package/dist/experimental/sandbox/types.d.ts +32 -149
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/schemas.d.ts +54 -0
  26. package/dist/utils/error.cjs +7 -0
  27. package/dist/utils/error.d.ts +1 -0
  28. package/dist/utils/error.js +6 -0
  29. package/dist/utils/fast-safe-stringify/index.cjs +228 -0
  30. package/dist/utils/fast-safe-stringify/index.d.ts +33 -0
  31. package/dist/utils/fast-safe-stringify/index.js +227 -0
  32. package/dist/utils/prompts.cjs +7 -2
  33. package/dist/utils/prompts.d.ts +6 -1
  34. package/dist/utils/prompts.js +6 -1
  35. package/dist/wrappers/openai_agents.cjs +849 -0
  36. package/dist/wrappers/openai_agents.d.ts +92 -0
  37. package/dist/wrappers/openai_agents.js +845 -0
  38. package/package.json +22 -6
  39. package/wrappers/openai_agents.cjs +1 -0
  40. package/wrappers/openai_agents.d.cts +1 -0
  41. package/wrappers/openai_agents.d.ts +1 -0
  42. package/wrappers/openai_agents.js +1 -0
@@ -50,7 +50,7 @@ function getDefaultApiKey() {
50
50
  /**
51
51
  * Client for interacting with the Sandbox Server API.
52
52
  *
53
- * This client provides a simple interface for managing sandboxes and templates.
53
+ * This client provides a simple interface for managing sandboxes and snapshots.
54
54
  *
55
55
  * @example
56
56
  * ```typescript
@@ -65,8 +65,13 @@ function getDefaultApiKey() {
65
65
  * apiKey: "your-api-key",
66
66
  * });
67
67
  *
68
- * // Create a sandbox and run commands
69
- * const sandbox = await client.createSandbox("python-sandbox");
68
+ * // Build a snapshot, then create a sandbox from it
69
+ * const snapshot = await client.createSnapshot(
70
+ * "python",
71
+ * "python:3.12-slim",
72
+ * 1_073_741_824 // 1 GiB
73
+ * );
74
+ * const sandbox = await client.createSandbox(snapshot.id);
70
75
  * try {
71
76
  * const result = await sandbox.run("python --version");
72
77
  * console.log(result.stdout);
@@ -156,421 +161,40 @@ class SandboxClient {
156
161
  return response;
157
162
  }
158
163
  // =========================================================================
159
- // Volume Operations
160
- // =========================================================================
161
- /**
162
- * Create a new persistent volume.
163
- *
164
- * Creates a persistent storage volume that can be referenced in templates.
165
- *
166
- * @param name - Volume name.
167
- * @param options - Creation options including size and optional timeout.
168
- * @returns Created Volume.
169
- * @throws SandboxCreationError if volume provisioning fails.
170
- * @throws ResourceTimeoutError if volume doesn't become ready within timeout.
171
- */
172
- async createVolume(name, options) {
173
- const { size, timeout = 60 } = options;
174
- const url = `${this._baseUrl}/volumes`;
175
- const payload = {
176
- name,
177
- size,
178
- wait_for_ready: true,
179
- timeout,
180
- };
181
- const response = await this._fetch(url, {
182
- method: "POST",
183
- headers: { "Content-Type": "application/json" },
184
- body: JSON.stringify(payload),
185
- signal: AbortSignal.timeout((timeout + 30) * 1000),
186
- });
187
- if (!response.ok) {
188
- await (0, helpers_js_1.handleVolumeCreationError)(response);
189
- }
190
- return (await response.json());
191
- }
192
- /**
193
- * Get a volume by name.
194
- *
195
- * @param name - Volume name.
196
- * @returns Volume.
197
- * @throws LangSmithResourceNotFoundError if volume not found.
198
- */
199
- async getVolume(name) {
200
- const url = `${this._baseUrl}/volumes/${encodeURIComponent(name)}`;
201
- const response = await this._fetch(url);
202
- if (!response.ok) {
203
- if (response.status === 404) {
204
- throw new errors_js_1.LangSmithResourceNotFoundError(`Volume '${name}' not found`, "volume");
205
- }
206
- await (0, helpers_js_1.handleClientHttpError)(response);
207
- }
208
- return (await response.json());
209
- }
210
- /**
211
- * List all volumes.
212
- *
213
- * @returns List of Volumes.
214
- */
215
- async listVolumes() {
216
- const url = `${this._baseUrl}/volumes`;
217
- const response = await this._fetch(url);
218
- if (!response.ok) {
219
- if (response.status === 404) {
220
- throw new errors_js_1.LangSmithSandboxAPIError(`API endpoint not found: ${url}. Check that apiEndpoint is correct.`);
221
- }
222
- await (0, helpers_js_1.handleClientHttpError)(response);
223
- }
224
- const data = await response.json();
225
- return (data.volumes ?? []);
226
- }
227
- /**
228
- * Delete a volume.
229
- *
230
- * @param name - Volume name.
231
- * @throws LangSmithResourceNotFoundError if volume not found.
232
- * @throws ResourceInUseError if volume is referenced by templates.
233
- */
234
- async deleteVolume(name) {
235
- const url = `${this._baseUrl}/volumes/${encodeURIComponent(name)}`;
236
- const response = await this._fetch(url, { method: "DELETE" });
237
- if (!response.ok) {
238
- if (response.status === 404) {
239
- throw new errors_js_1.LangSmithResourceNotFoundError(`Volume '${name}' not found`, "volume");
240
- }
241
- if (response.status === 409) {
242
- await (0, helpers_js_1.handleResourceInUseError)(response, "volume");
243
- }
244
- await (0, helpers_js_1.handleClientHttpError)(response);
245
- }
246
- }
247
- /**
248
- * Update a volume's name and/or size.
249
- *
250
- * You can update the display name, size, or both in a single request.
251
- * Only storage size increases are allowed (storage backend limitation).
252
- *
253
- * @param name - Current volume name.
254
- * @param options - Update options.
255
- * @returns Updated Volume.
256
- * @throws LangSmithResourceNotFoundError if volume not found.
257
- * @throws ValidationError if storage decrease attempted.
258
- * @throws LangSmithResourceNameConflictError if newName is already in use.
259
- */
260
- async updateVolume(name, options) {
261
- const { newName, size } = options;
262
- if (newName === undefined && size === undefined) {
263
- // Nothing to update, just return the current volume
264
- return this.getVolume(name);
265
- }
266
- const url = `${this._baseUrl}/volumes/${encodeURIComponent(name)}`;
267
- const payload = {};
268
- if (newName !== undefined) {
269
- payload.name = newName;
270
- }
271
- if (size !== undefined) {
272
- payload.size = size;
273
- }
274
- const response = await this._fetch(url, {
275
- method: "PATCH",
276
- headers: { "Content-Type": "application/json" },
277
- body: JSON.stringify(payload),
278
- });
279
- if (!response.ok) {
280
- if (response.status === 404) {
281
- throw new errors_js_1.LangSmithResourceNotFoundError(`Volume '${name}' not found`, "volume");
282
- }
283
- if (response.status === 409) {
284
- await (0, helpers_js_1.handleConflictError)(response, "volume");
285
- }
286
- await (0, helpers_js_1.handleClientHttpError)(response);
287
- }
288
- return (await response.json());
289
- }
290
- // =========================================================================
291
- // Template Operations
292
- // =========================================================================
293
- /**
294
- * Create a new SandboxTemplate.
295
- *
296
- * Only the container image, resource limits, and volume mounts can be
297
- * configured. All other container details are handled by the server.
298
- *
299
- * @param name - Template name.
300
- * @param options - Creation options including image and resource limits.
301
- * @returns Created SandboxTemplate.
302
- */
303
- async createTemplate(name, options) {
304
- const { image, cpu = "500m", memory = "512Mi", storage, volumeMounts, } = options;
305
- const url = `${this._baseUrl}/templates`;
306
- const payload = {
307
- name,
308
- image,
309
- resources: {
310
- cpu,
311
- memory,
312
- },
313
- };
314
- if (storage) {
315
- payload.resources.storage = storage;
316
- }
317
- if (volumeMounts && volumeMounts.length > 0) {
318
- payload.volume_mounts = volumeMounts.map((vm) => ({
319
- volume_name: vm.volume_name,
320
- mount_path: vm.mount_path,
321
- }));
322
- }
323
- const response = await this._fetch(url, {
324
- method: "POST",
325
- headers: { "Content-Type": "application/json" },
326
- body: JSON.stringify(payload),
327
- });
328
- if (!response.ok) {
329
- await (0, helpers_js_1.handleClientHttpError)(response);
330
- }
331
- return (await response.json());
332
- }
333
- /**
334
- * Get a SandboxTemplate by name.
335
- *
336
- * @param name - Template name.
337
- * @returns SandboxTemplate.
338
- * @throws LangSmithResourceNotFoundError if template not found.
339
- */
340
- async getTemplate(name) {
341
- const url = `${this._baseUrl}/templates/${encodeURIComponent(name)}`;
342
- const response = await this._fetch(url);
343
- if (!response.ok) {
344
- if (response.status === 404) {
345
- throw new errors_js_1.LangSmithResourceNotFoundError(`Template '${name}' not found`, "template");
346
- }
347
- await (0, helpers_js_1.handleClientHttpError)(response);
348
- }
349
- return (await response.json());
350
- }
351
- /**
352
- * List all SandboxTemplates.
353
- *
354
- * @returns List of SandboxTemplates.
355
- */
356
- async listTemplates() {
357
- const url = `${this._baseUrl}/templates`;
358
- const response = await this._fetch(url);
359
- if (!response.ok) {
360
- if (response.status === 404) {
361
- throw new errors_js_1.LangSmithSandboxAPIError(`API endpoint not found: ${url}. Check that apiEndpoint is correct.`);
362
- }
363
- await (0, helpers_js_1.handleClientHttpError)(response);
364
- }
365
- const data = await response.json();
366
- return (data.templates ?? []);
367
- }
368
- /**
369
- * Update a template.
370
- *
371
- * @param name - Current template name.
372
- * @param options - Update options (e.g., newName).
373
- * @returns Updated SandboxTemplate.
374
- * @throws LangSmithResourceNotFoundError if template not found.
375
- * @throws LangSmithResourceNameConflictError if newName is already in use.
376
- */
377
- async updateTemplate(name, options) {
378
- const { newName } = options;
379
- if (newName === undefined) {
380
- // Nothing to update, just return the current template
381
- return this.getTemplate(name);
382
- }
383
- const url = `${this._baseUrl}/templates/${encodeURIComponent(name)}`;
384
- const payload = { name: newName };
385
- const response = await this._fetch(url, {
386
- method: "PATCH",
387
- headers: { "Content-Type": "application/json" },
388
- body: JSON.stringify(payload),
389
- });
390
- if (!response.ok) {
391
- if (response.status === 404) {
392
- throw new errors_js_1.LangSmithResourceNotFoundError(`Template '${name}' not found`, "template");
393
- }
394
- if (response.status === 409) {
395
- await (0, helpers_js_1.handleConflictError)(response, "template");
396
- }
397
- await (0, helpers_js_1.handleClientHttpError)(response);
398
- }
399
- return (await response.json());
400
- }
401
- /**
402
- * Delete a SandboxTemplate.
403
- *
404
- * @param name - Template name.
405
- * @throws LangSmithResourceNotFoundError if template not found.
406
- * @throws ResourceInUseError if template is referenced by sandboxes or pools.
407
- */
408
- async deleteTemplate(name) {
409
- const url = `${this._baseUrl}/templates/${encodeURIComponent(name)}`;
410
- const response = await this._fetch(url, { method: "DELETE" });
411
- if (!response.ok) {
412
- if (response.status === 404) {
413
- throw new errors_js_1.LangSmithResourceNotFoundError(`Template '${name}' not found`, "template");
414
- }
415
- if (response.status === 409) {
416
- await (0, helpers_js_1.handleResourceInUseError)(response, "template");
417
- }
418
- await (0, helpers_js_1.handleClientHttpError)(response);
419
- }
420
- }
421
- // =========================================================================
422
- // Pool Operations
423
- // =========================================================================
424
- /**
425
- * Create a new Sandbox Pool.
426
- *
427
- * Pools pre-provision sandboxes from a template for faster startup.
428
- *
429
- * @param name - Pool name (lowercase letters, numbers, hyphens; max 63 chars).
430
- * @param options - Creation options including templateName, replicas, and optional timeout.
431
- * @returns Created Pool.
432
- * @throws LangSmithResourceNotFoundError if template not found.
433
- * @throws ValidationError if template has volumes attached.
434
- * @throws ResourceAlreadyExistsError if pool with this name already exists.
435
- * @throws ResourceTimeoutError if pool doesn't reach ready state within timeout.
436
- * @throws QuotaExceededError if organization quota is exceeded.
437
- */
438
- async createPool(name, options) {
439
- const { templateName, replicas, timeout = 30 } = options;
440
- const url = `${this._baseUrl}/pools`;
441
- const payload = {
442
- name,
443
- template_name: templateName,
444
- replicas,
445
- wait_for_ready: true,
446
- timeout,
447
- };
448
- const response = await this._fetch(url, {
449
- method: "POST",
450
- headers: { "Content-Type": "application/json" },
451
- body: JSON.stringify(payload),
452
- signal: AbortSignal.timeout((timeout + 30) * 1000),
453
- });
454
- if (!response.ok) {
455
- await (0, helpers_js_1.handlePoolError)(response);
456
- }
457
- return (await response.json());
458
- }
459
- /**
460
- * Get a Pool by name.
461
- *
462
- * @param name - Pool name.
463
- * @returns Pool.
464
- * @throws LangSmithResourceNotFoundError if pool not found.
465
- */
466
- async getPool(name) {
467
- const url = `${this._baseUrl}/pools/${encodeURIComponent(name)}`;
468
- const response = await this._fetch(url);
469
- if (!response.ok) {
470
- if (response.status === 404) {
471
- throw new errors_js_1.LangSmithResourceNotFoundError(`Pool '${name}' not found`, "pool");
472
- }
473
- await (0, helpers_js_1.handleClientHttpError)(response);
474
- }
475
- return (await response.json());
476
- }
477
- /**
478
- * List all Pools.
479
- *
480
- * @returns List of Pools.
481
- */
482
- async listPools() {
483
- const url = `${this._baseUrl}/pools`;
484
- const response = await this._fetch(url);
485
- if (!response.ok) {
486
- if (response.status === 404) {
487
- throw new errors_js_1.LangSmithSandboxAPIError(`API endpoint not found: ${url}. Check that apiEndpoint is correct.`);
488
- }
489
- await (0, helpers_js_1.handleClientHttpError)(response);
490
- }
491
- const data = await response.json();
492
- return (data.pools ?? []);
493
- }
494
- /**
495
- * Update a Pool's name and/or replica count.
496
- *
497
- * You can update the display name, replica count, or both.
498
- * The template reference cannot be changed after creation.
499
- *
500
- * @param name - Current pool name.
501
- * @param options - Update options.
502
- * @returns Updated Pool.
503
- * @throws LangSmithResourceNotFoundError if pool not found.
504
- * @throws ValidationError if template was deleted.
505
- * @throws LangSmithResourceNameConflictError if newName is already in use.
506
- * @throws QuotaExceededError if quota exceeded when scaling up.
507
- */
508
- async updatePool(name, options) {
509
- const { newName, replicas } = options;
510
- if (newName === undefined && replicas === undefined) {
511
- // Nothing to update, just return the current pool
512
- return this.getPool(name);
513
- }
514
- const url = `${this._baseUrl}/pools/${encodeURIComponent(name)}`;
515
- const payload = {};
516
- if (newName !== undefined) {
517
- payload.name = newName;
518
- }
519
- if (replicas !== undefined) {
520
- payload.replicas = replicas;
521
- }
522
- const response = await this._fetch(url, {
523
- method: "PATCH",
524
- headers: { "Content-Type": "application/json" },
525
- body: JSON.stringify(payload),
526
- });
527
- if (!response.ok) {
528
- if (response.status === 404) {
529
- throw new errors_js_1.LangSmithResourceNotFoundError(`Pool '${name}' not found`, "pool");
530
- }
531
- if (response.status === 409) {
532
- await (0, helpers_js_1.handleConflictError)(response, "pool");
533
- }
534
- await (0, helpers_js_1.handlePoolError)(response);
535
- }
536
- return (await response.json());
537
- }
538
- /**
539
- * Delete a Pool.
540
- *
541
- * This will terminate all sandboxes in the pool.
542
- *
543
- * @param name - Pool name.
544
- * @throws LangSmithResourceNotFoundError if pool not found.
545
- */
546
- async deletePool(name) {
547
- const url = `${this._baseUrl}/pools/${encodeURIComponent(name)}`;
548
- const response = await this._fetch(url, { method: "DELETE" });
549
- if (!response.ok) {
550
- if (response.status === 404) {
551
- throw new errors_js_1.LangSmithResourceNotFoundError(`Pool '${name}' not found`, "pool");
552
- }
553
- await (0, helpers_js_1.handleClientHttpError)(response);
554
- }
555
- }
556
- // =========================================================================
557
164
  // Sandbox Operations
558
165
  // =========================================================================
559
166
  /**
560
- * Create a new Sandbox.
167
+ * Create a new Sandbox from a snapshot.
561
168
  *
562
169
  * Remember to call `sandbox.delete()` when done to clean up resources.
563
170
  *
564
- * @param templateName - Name of the SandboxTemplate to use.
565
- * @param options - Creation options.
171
+ * Exactly one of `snapshotId` (positional) or `options.snapshotName` must
172
+ * be provided. When `snapshotName` is used, the server resolves it to a
173
+ * snapshot owned by the caller's tenant.
174
+ *
175
+ * @param snapshotId - ID of the snapshot to boot from. Create one with
176
+ * `createSnapshot()` or `captureSnapshot()`, or pass an existing snapshot ID.
177
+ * Pass `undefined` when booting by name via `options.snapshotName`.
178
+ * @param options - Creation options. Use `options.snapshotName` to boot
179
+ * by snapshot name instead of ID.
566
180
  * @returns Created Sandbox.
567
181
  * @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
568
182
  * @throws SandboxCreationError if sandbox creation fails.
569
- * @throws LangSmithValidationError if TTL values are invalid.
183
+ * @throws LangSmithValidationError if TTL values are invalid, or if neither
184
+ * (or both) of `snapshotId` / `options.snapshotName` are provided.
570
185
  *
571
186
  * @example
572
187
  * ```typescript
573
- * const sandbox = await client.createSandbox("python-sandbox");
188
+ * const snapshot = await client.createSnapshot(
189
+ * "python",
190
+ * "python:3.12-slim",
191
+ * 1_073_741_824
192
+ * );
193
+ * const sandbox = await client.createSandbox(snapshot.id);
194
+ * // Or, resolve by snapshot name:
195
+ * const sandbox = await client.createSandbox(undefined, {
196
+ * snapshotName: "python",
197
+ * });
574
198
  * try {
575
199
  * const result = await sandbox.run("echo hello");
576
200
  * console.log(result.stdout);
@@ -579,13 +203,10 @@ class SandboxClient {
579
203
  * }
580
204
  * ```
581
205
  */
582
- async createSandbox(templateName, options = {}) {
583
- const { snapshotId, name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = options;
584
- if (!templateName && !snapshotId) {
585
- throw new Error("Either templateName or snapshotId is required");
586
- }
587
- if (templateName && snapshotId) {
588
- throw new Error("Cannot specify both templateName and snapshotId");
206
+ async createSandbox(snapshotId, options = {}) {
207
+ const { snapshotName, name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = options;
208
+ if (!!snapshotId === !!snapshotName) {
209
+ throw new errors_js_1.LangSmithValidationError("Exactly one of snapshotId or options.snapshotName must be set", "snapshotId");
589
210
  }
590
211
  (0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
591
212
  (0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
@@ -593,12 +214,12 @@ class SandboxClient {
593
214
  const payload = {
594
215
  wait_for_ready: waitForReady,
595
216
  };
596
- if (templateName) {
597
- payload.template_name = templateName;
598
- }
599
217
  if (snapshotId) {
600
218
  payload.snapshot_id = snapshotId;
601
219
  }
220
+ if (snapshotName) {
221
+ payload.snapshot_name = snapshotName;
222
+ }
602
223
  if (waitForReady) {
603
224
  payload.timeout = timeout;
604
225
  }
@@ -768,7 +389,7 @@ class SandboxClient {
768
389
  *
769
390
  * @example
770
391
  * ```typescript
771
- * const sandbox = await client.createSandbox("python-sandbox", { waitForReady: false });
392
+ * const sandbox = await client.createSandbox(snapshot.id, { waitForReady: false });
772
393
  * // ... do other work ...
773
394
  * const readySandbox = await client.waitForSandbox(sandbox.name);
774
395
  * ```
@@ -864,16 +485,13 @@ class SandboxClient {
864
485
  *
865
486
  * @param sandboxName - Name of the sandbox to capture from.
866
487
  * @param name - Snapshot name.
867
- * @param options - Capture options (checkpoint, timeout).
488
+ * @param options - Capture options (timeout).
868
489
  * @returns Snapshot in "ready" status.
869
490
  */
870
491
  async captureSnapshot(sandboxName, name, options = {}) {
871
- const { checkpoint, timeout = 60, signal } = options;
492
+ const { timeout = 60, signal } = options;
872
493
  const url = `${this._baseUrl}/boxes/${encodeURIComponent(sandboxName)}/snapshot`;
873
494
  const payload = { name };
874
- if (checkpoint !== undefined) {
875
- payload.checkpoint = checkpoint;
876
- }
877
495
  const response = await this._postJson(url, payload, { signal });
878
496
  const snapshot = (await response.json());
879
497
  return this.waitForSnapshot(snapshot.id, { timeout, signal });
@@ -896,13 +514,50 @@ class SandboxClient {
896
514
  return (await response.json());
897
515
  }
898
516
  /**
899
- * List all snapshots.
517
+ * List snapshots, optionally filtered and paginated server-side.
900
518
  *
901
- * @returns List of Snapshots.
519
+ * The backend always paginates this endpoint. When `limit` is omitted the
520
+ * server applies a default page size (currently 50), so a single call is
521
+ * not guaranteed to return every snapshot visible to the tenant. To iterate
522
+ * through all results, repeat the call with increasing `offset` values (or
523
+ * an explicit `limit`) until fewer than `limit` snapshots come back.
524
+ *
525
+ * @param options - Optional filter/pagination options.
526
+ * - `nameContains`: case-insensitive substring match on snapshot name.
527
+ * - `limit`: page size; must be between 1 and 500 (inclusive). Defaults
528
+ * to 50 server-side when omitted.
529
+ * - `offset`: number of snapshots to skip; must be `>= 0`.
530
+ *
531
+ * Values outside those ranges are rejected by the server.
532
+ * @returns A single page of Snapshots matching the provided filters.
533
+ *
534
+ * @example
535
+ * ```typescript
536
+ * const firstPage = await client.listSnapshots();
537
+ * const page = await client.listSnapshots({
538
+ * nameContains: "python",
539
+ * limit: 100,
540
+ * offset: 0,
541
+ * });
542
+ * ```
902
543
  */
903
- async listSnapshots() {
904
- const url = `${this._baseUrl}/snapshots`;
905
- const response = await this._fetch(url);
544
+ async listSnapshots(options = {}) {
545
+ const { nameContains, limit, offset, signal } = options;
546
+ const params = new URLSearchParams();
547
+ if (nameContains !== undefined) {
548
+ params.set("name_contains", nameContains);
549
+ }
550
+ if (limit !== undefined) {
551
+ params.set("limit", String(limit));
552
+ }
553
+ if (offset !== undefined) {
554
+ params.set("offset", String(offset));
555
+ }
556
+ const query = params.toString();
557
+ const url = query
558
+ ? `${this._baseUrl}/snapshots?${query}`
559
+ : `${this._baseUrl}/snapshots`;
560
+ const response = await this._fetch(url, { signal });
906
561
  if (!response.ok) {
907
562
  await (0, helpers_js_1.handleClientHttpError)(response);
908
563
  }
@@ -952,5 +607,25 @@ class SandboxClient {
952
607
  }
953
608
  throw new errors_js_1.LangSmithResourceTimeoutError(`Snapshot '${snapshotId}' did not become ready within ${timeout}s`, "snapshot", lastStatus);
954
609
  }
610
+ /**
611
+ * Returns a string representation of the SandboxClient instance.
612
+ * This method is called when the object is converted to a string
613
+ * or logged, ensuring sensitive information like API keys is not exposed.
614
+ *
615
+ * @returns A string representation of the SandboxClient.
616
+ */
617
+ toString() {
618
+ return `[LangSmithSandboxClient apiEndpoint=${JSON.stringify(this._baseUrl)}]`;
619
+ }
620
+ /**
621
+ * Custom inspect method for Node.js.
622
+ * This method is called when the object is inspected in the Node.js REPL
623
+ * or with console.log, ensuring sensitive information like API keys is not exposed.
624
+ *
625
+ * @returns A string representation of the SandboxClient for inspection.
626
+ */
627
+ [Symbol.for("nodejs.util.inspect.custom")]() {
628
+ return this.toString();
629
+ }
955
630
  }
956
631
  exports.SandboxClient = SandboxClient;