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.
- package/dist/client.cjs +327 -10
- package/dist/client.d.ts +90 -1
- package/dist/client.js +330 -13
- package/dist/evaluation/_runner.cjs +1 -4
- package/dist/evaluation/_runner.js +1 -4
- package/dist/experimental/sandbox/client.cjs +102 -427
- package/dist/experimental/sandbox/client.d.ts +68 -159
- package/dist/experimental/sandbox/client.js +104 -429
- package/dist/experimental/sandbox/errors.cjs +1 -2
- package/dist/experimental/sandbox/errors.d.ts +1 -2
- package/dist/experimental/sandbox/errors.js +1 -2
- package/dist/experimental/sandbox/helpers.cjs +8 -98
- package/dist/experimental/sandbox/helpers.d.ts +0 -29
- package/dist/experimental/sandbox/helpers.js +9 -95
- package/dist/experimental/sandbox/index.cjs +6 -1
- package/dist/experimental/sandbox/index.d.ts +7 -2
- package/dist/experimental/sandbox/index.js +6 -1
- package/dist/experimental/sandbox/sandbox.cjs +3 -11
- package/dist/experimental/sandbox/sandbox.d.ts +3 -5
- package/dist/experimental/sandbox/sandbox.js +3 -11
- package/dist/experimental/sandbox/types.d.ts +32 -149
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +54 -0
- package/dist/utils/error.cjs +7 -0
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +6 -0
- package/dist/utils/fast-safe-stringify/index.cjs +228 -0
- package/dist/utils/fast-safe-stringify/index.d.ts +33 -0
- package/dist/utils/fast-safe-stringify/index.js +227 -0
- package/dist/utils/prompts.cjs +7 -2
- package/dist/utils/prompts.d.ts +6 -1
- package/dist/utils/prompts.js +6 -1
- package/dist/wrappers/openai_agents.cjs +849 -0
- package/dist/wrappers/openai_agents.d.ts +92 -0
- package/dist/wrappers/openai_agents.js +845 -0
- package/package.json +22 -6
- package/wrappers/openai_agents.cjs +1 -0
- package/wrappers/openai_agents.d.cts +1 -0
- package/wrappers/openai_agents.d.ts +1 -0
- package/wrappers/openai_agents.js +1 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main SandboxClient class for interacting with the sandbox server API.
|
|
3
3
|
*/
|
|
4
|
-
import type { CaptureSnapshotOptions,
|
|
4
|
+
import type { CaptureSnapshotOptions, CreateSandboxOptions, CreateSnapshotOptions, ListSnapshotsOptions, ResourceStatus, SandboxClientConfig, Snapshot, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, WaitForSnapshotOptions } from "./types.js";
|
|
5
5
|
import { Sandbox } from "./sandbox.js";
|
|
6
6
|
/**
|
|
7
7
|
* Client for interacting with the Sandbox Server API.
|
|
8
8
|
*
|
|
9
|
-
* This client provides a simple interface for managing sandboxes and
|
|
9
|
+
* This client provides a simple interface for managing sandboxes and snapshots.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
@@ -21,8 +21,13 @@ import { Sandbox } from "./sandbox.js";
|
|
|
21
21
|
* apiKey: "your-api-key",
|
|
22
22
|
* });
|
|
23
23
|
*
|
|
24
|
-
* //
|
|
25
|
-
* const
|
|
24
|
+
* // Build a snapshot, then create a sandbox from it
|
|
25
|
+
* const snapshot = await client.createSnapshot(
|
|
26
|
+
* "python",
|
|
27
|
+
* "python:3.12-slim",
|
|
28
|
+
* 1_073_741_824 // 1 GiB
|
|
29
|
+
* );
|
|
30
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
26
31
|
* try {
|
|
27
32
|
* const result = await sandbox.run("python --version");
|
|
28
33
|
* console.log(result.stdout);
|
|
@@ -40,164 +45,37 @@ export declare class SandboxClient {
|
|
|
40
45
|
private _caller;
|
|
41
46
|
constructor(config?: SandboxClientConfig);
|
|
42
47
|
/**
|
|
43
|
-
* Create a new
|
|
44
|
-
*
|
|
45
|
-
* Creates a persistent storage volume that can be referenced in templates.
|
|
46
|
-
*
|
|
47
|
-
* @param name - Volume name.
|
|
48
|
-
* @param options - Creation options including size and optional timeout.
|
|
49
|
-
* @returns Created Volume.
|
|
50
|
-
* @throws SandboxCreationError if volume provisioning fails.
|
|
51
|
-
* @throws ResourceTimeoutError if volume doesn't become ready within timeout.
|
|
52
|
-
*/
|
|
53
|
-
createVolume(name: string, options: CreateVolumeOptions): Promise<Volume>;
|
|
54
|
-
/**
|
|
55
|
-
* Get a volume by name.
|
|
56
|
-
*
|
|
57
|
-
* @param name - Volume name.
|
|
58
|
-
* @returns Volume.
|
|
59
|
-
* @throws LangSmithResourceNotFoundError if volume not found.
|
|
60
|
-
*/
|
|
61
|
-
getVolume(name: string): Promise<Volume>;
|
|
62
|
-
/**
|
|
63
|
-
* List all volumes.
|
|
64
|
-
*
|
|
65
|
-
* @returns List of Volumes.
|
|
66
|
-
*/
|
|
67
|
-
listVolumes(): Promise<Volume[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Delete a volume.
|
|
70
|
-
*
|
|
71
|
-
* @param name - Volume name.
|
|
72
|
-
* @throws LangSmithResourceNotFoundError if volume not found.
|
|
73
|
-
* @throws ResourceInUseError if volume is referenced by templates.
|
|
74
|
-
*/
|
|
75
|
-
deleteVolume(name: string): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Update a volume's name and/or size.
|
|
78
|
-
*
|
|
79
|
-
* You can update the display name, size, or both in a single request.
|
|
80
|
-
* Only storage size increases are allowed (storage backend limitation).
|
|
81
|
-
*
|
|
82
|
-
* @param name - Current volume name.
|
|
83
|
-
* @param options - Update options.
|
|
84
|
-
* @returns Updated Volume.
|
|
85
|
-
* @throws LangSmithResourceNotFoundError if volume not found.
|
|
86
|
-
* @throws ValidationError if storage decrease attempted.
|
|
87
|
-
* @throws LangSmithResourceNameConflictError if newName is already in use.
|
|
88
|
-
*/
|
|
89
|
-
updateVolume(name: string, options: UpdateVolumeOptions): Promise<Volume>;
|
|
90
|
-
/**
|
|
91
|
-
* Create a new SandboxTemplate.
|
|
92
|
-
*
|
|
93
|
-
* Only the container image, resource limits, and volume mounts can be
|
|
94
|
-
* configured. All other container details are handled by the server.
|
|
95
|
-
*
|
|
96
|
-
* @param name - Template name.
|
|
97
|
-
* @param options - Creation options including image and resource limits.
|
|
98
|
-
* @returns Created SandboxTemplate.
|
|
99
|
-
*/
|
|
100
|
-
createTemplate(name: string, options: CreateTemplateOptions): Promise<SandboxTemplate>;
|
|
101
|
-
/**
|
|
102
|
-
* Get a SandboxTemplate by name.
|
|
103
|
-
*
|
|
104
|
-
* @param name - Template name.
|
|
105
|
-
* @returns SandboxTemplate.
|
|
106
|
-
* @throws LangSmithResourceNotFoundError if template not found.
|
|
107
|
-
*/
|
|
108
|
-
getTemplate(name: string): Promise<SandboxTemplate>;
|
|
109
|
-
/**
|
|
110
|
-
* List all SandboxTemplates.
|
|
111
|
-
*
|
|
112
|
-
* @returns List of SandboxTemplates.
|
|
113
|
-
*/
|
|
114
|
-
listTemplates(): Promise<SandboxTemplate[]>;
|
|
115
|
-
/**
|
|
116
|
-
* Update a template.
|
|
117
|
-
*
|
|
118
|
-
* @param name - Current template name.
|
|
119
|
-
* @param options - Update options (e.g., newName).
|
|
120
|
-
* @returns Updated SandboxTemplate.
|
|
121
|
-
* @throws LangSmithResourceNotFoundError if template not found.
|
|
122
|
-
* @throws LangSmithResourceNameConflictError if newName is already in use.
|
|
123
|
-
*/
|
|
124
|
-
updateTemplate(name: string, options: UpdateTemplateOptions): Promise<SandboxTemplate>;
|
|
125
|
-
/**
|
|
126
|
-
* Delete a SandboxTemplate.
|
|
127
|
-
*
|
|
128
|
-
* @param name - Template name.
|
|
129
|
-
* @throws LangSmithResourceNotFoundError if template not found.
|
|
130
|
-
* @throws ResourceInUseError if template is referenced by sandboxes or pools.
|
|
131
|
-
*/
|
|
132
|
-
deleteTemplate(name: string): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Create a new Sandbox Pool.
|
|
135
|
-
*
|
|
136
|
-
* Pools pre-provision sandboxes from a template for faster startup.
|
|
137
|
-
*
|
|
138
|
-
* @param name - Pool name (lowercase letters, numbers, hyphens; max 63 chars).
|
|
139
|
-
* @param options - Creation options including templateName, replicas, and optional timeout.
|
|
140
|
-
* @returns Created Pool.
|
|
141
|
-
* @throws LangSmithResourceNotFoundError if template not found.
|
|
142
|
-
* @throws ValidationError if template has volumes attached.
|
|
143
|
-
* @throws ResourceAlreadyExistsError if pool with this name already exists.
|
|
144
|
-
* @throws ResourceTimeoutError if pool doesn't reach ready state within timeout.
|
|
145
|
-
* @throws QuotaExceededError if organization quota is exceeded.
|
|
146
|
-
*/
|
|
147
|
-
createPool(name: string, options: CreatePoolOptions): Promise<Pool>;
|
|
148
|
-
/**
|
|
149
|
-
* Get a Pool by name.
|
|
150
|
-
*
|
|
151
|
-
* @param name - Pool name.
|
|
152
|
-
* @returns Pool.
|
|
153
|
-
* @throws LangSmithResourceNotFoundError if pool not found.
|
|
154
|
-
*/
|
|
155
|
-
getPool(name: string): Promise<Pool>;
|
|
156
|
-
/**
|
|
157
|
-
* List all Pools.
|
|
158
|
-
*
|
|
159
|
-
* @returns List of Pools.
|
|
160
|
-
*/
|
|
161
|
-
listPools(): Promise<Pool[]>;
|
|
162
|
-
/**
|
|
163
|
-
* Update a Pool's name and/or replica count.
|
|
164
|
-
*
|
|
165
|
-
* You can update the display name, replica count, or both.
|
|
166
|
-
* The template reference cannot be changed after creation.
|
|
167
|
-
*
|
|
168
|
-
* @param name - Current pool name.
|
|
169
|
-
* @param options - Update options.
|
|
170
|
-
* @returns Updated Pool.
|
|
171
|
-
* @throws LangSmithResourceNotFoundError if pool not found.
|
|
172
|
-
* @throws ValidationError if template was deleted.
|
|
173
|
-
* @throws LangSmithResourceNameConflictError if newName is already in use.
|
|
174
|
-
* @throws QuotaExceededError if quota exceeded when scaling up.
|
|
175
|
-
*/
|
|
176
|
-
updatePool(name: string, options: UpdatePoolOptions): Promise<Pool>;
|
|
177
|
-
/**
|
|
178
|
-
* Delete a Pool.
|
|
179
|
-
*
|
|
180
|
-
* This will terminate all sandboxes in the pool.
|
|
181
|
-
*
|
|
182
|
-
* @param name - Pool name.
|
|
183
|
-
* @throws LangSmithResourceNotFoundError if pool not found.
|
|
184
|
-
*/
|
|
185
|
-
deletePool(name: string): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* Create a new Sandbox.
|
|
48
|
+
* Create a new Sandbox from a snapshot.
|
|
188
49
|
*
|
|
189
50
|
* Remember to call `sandbox.delete()` when done to clean up resources.
|
|
190
51
|
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
52
|
+
* Exactly one of `snapshotId` (positional) or `options.snapshotName` must
|
|
53
|
+
* be provided. When `snapshotName` is used, the server resolves it to a
|
|
54
|
+
* snapshot owned by the caller's tenant.
|
|
55
|
+
*
|
|
56
|
+
* @param snapshotId - ID of the snapshot to boot from. Create one with
|
|
57
|
+
* `createSnapshot()` or `captureSnapshot()`, or pass an existing snapshot ID.
|
|
58
|
+
* Pass `undefined` when booting by name via `options.snapshotName`.
|
|
59
|
+
* @param options - Creation options. Use `options.snapshotName` to boot
|
|
60
|
+
* by snapshot name instead of ID.
|
|
193
61
|
* @returns Created Sandbox.
|
|
194
62
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
195
63
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
196
|
-
* @throws LangSmithValidationError if TTL values are invalid
|
|
64
|
+
* @throws LangSmithValidationError if TTL values are invalid, or if neither
|
|
65
|
+
* (or both) of `snapshotId` / `options.snapshotName` are provided.
|
|
197
66
|
*
|
|
198
67
|
* @example
|
|
199
68
|
* ```typescript
|
|
200
|
-
* const
|
|
69
|
+
* const snapshot = await client.createSnapshot(
|
|
70
|
+
* "python",
|
|
71
|
+
* "python:3.12-slim",
|
|
72
|
+
* 1_073_741_824
|
|
73
|
+
* );
|
|
74
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
75
|
+
* // Or, resolve by snapshot name:
|
|
76
|
+
* const sandbox = await client.createSandbox(undefined, {
|
|
77
|
+
* snapshotName: "python",
|
|
78
|
+
* });
|
|
201
79
|
* try {
|
|
202
80
|
* const result = await sandbox.run("echo hello");
|
|
203
81
|
* console.log(result.stdout);
|
|
@@ -206,7 +84,7 @@ export declare class SandboxClient {
|
|
|
206
84
|
* }
|
|
207
85
|
* ```
|
|
208
86
|
*/
|
|
209
|
-
createSandbox(
|
|
87
|
+
createSandbox(snapshotId?: string, options?: CreateSandboxOptions): Promise<Sandbox>;
|
|
210
88
|
/**
|
|
211
89
|
* Get a Sandbox by name.
|
|
212
90
|
*
|
|
@@ -278,7 +156,7 @@ export declare class SandboxClient {
|
|
|
278
156
|
*
|
|
279
157
|
* @example
|
|
280
158
|
* ```typescript
|
|
281
|
-
* const sandbox = await client.createSandbox(
|
|
159
|
+
* const sandbox = await client.createSandbox(snapshot.id, { waitForReady: false });
|
|
282
160
|
* // ... do other work ...
|
|
283
161
|
* const readySandbox = await client.waitForSandbox(sandbox.name);
|
|
284
162
|
* ```
|
|
@@ -317,7 +195,7 @@ export declare class SandboxClient {
|
|
|
317
195
|
*
|
|
318
196
|
* @param sandboxName - Name of the sandbox to capture from.
|
|
319
197
|
* @param name - Snapshot name.
|
|
320
|
-
* @param options - Capture options (
|
|
198
|
+
* @param options - Capture options (timeout).
|
|
321
199
|
* @returns Snapshot in "ready" status.
|
|
322
200
|
*/
|
|
323
201
|
captureSnapshot(sandboxName: string, name: string, options?: CaptureSnapshotOptions): Promise<Snapshot>;
|
|
@@ -331,11 +209,34 @@ export declare class SandboxClient {
|
|
|
331
209
|
signal?: AbortSignal;
|
|
332
210
|
}): Promise<Snapshot>;
|
|
333
211
|
/**
|
|
334
|
-
* List
|
|
212
|
+
* List snapshots, optionally filtered and paginated server-side.
|
|
213
|
+
*
|
|
214
|
+
* The backend always paginates this endpoint. When `limit` is omitted the
|
|
215
|
+
* server applies a default page size (currently 50), so a single call is
|
|
216
|
+
* not guaranteed to return every snapshot visible to the tenant. To iterate
|
|
217
|
+
* through all results, repeat the call with increasing `offset` values (or
|
|
218
|
+
* an explicit `limit`) until fewer than `limit` snapshots come back.
|
|
335
219
|
*
|
|
336
|
-
* @
|
|
220
|
+
* @param options - Optional filter/pagination options.
|
|
221
|
+
* - `nameContains`: case-insensitive substring match on snapshot name.
|
|
222
|
+
* - `limit`: page size; must be between 1 and 500 (inclusive). Defaults
|
|
223
|
+
* to 50 server-side when omitted.
|
|
224
|
+
* - `offset`: number of snapshots to skip; must be `>= 0`.
|
|
225
|
+
*
|
|
226
|
+
* Values outside those ranges are rejected by the server.
|
|
227
|
+
* @returns A single page of Snapshots matching the provided filters.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const firstPage = await client.listSnapshots();
|
|
232
|
+
* const page = await client.listSnapshots({
|
|
233
|
+
* nameContains: "python",
|
|
234
|
+
* limit: 100,
|
|
235
|
+
* offset: 0,
|
|
236
|
+
* });
|
|
237
|
+
* ```
|
|
337
238
|
*/
|
|
338
|
-
listSnapshots(): Promise<Snapshot[]>;
|
|
239
|
+
listSnapshots(options?: ListSnapshotsOptions): Promise<Snapshot[]>;
|
|
339
240
|
/**
|
|
340
241
|
* Delete a snapshot.
|
|
341
242
|
*
|
|
@@ -350,4 +251,12 @@ export declare class SandboxClient {
|
|
|
350
251
|
* @returns Snapshot in "ready" status.
|
|
351
252
|
*/
|
|
352
253
|
waitForSnapshot(snapshotId: string, options?: WaitForSnapshotOptions): Promise<Snapshot>;
|
|
254
|
+
/**
|
|
255
|
+
* Returns a string representation of the SandboxClient instance.
|
|
256
|
+
* This method is called when the object is converted to a string
|
|
257
|
+
* or logged, ensuring sensitive information like API keys is not exposed.
|
|
258
|
+
*
|
|
259
|
+
* @returns A string representation of the SandboxClient.
|
|
260
|
+
*/
|
|
261
|
+
toString(): string;
|
|
353
262
|
}
|