langsmith 0.5.21 → 0.5.22
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 +60 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.js +60 -0
- 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/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 +19 -5
- 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
|
@@ -11,12 +11,8 @@ exports.parseErrorResponse = parseErrorResponse;
|
|
|
11
11
|
exports.parseValidationError = parseValidationError;
|
|
12
12
|
exports.extractQuotaType = extractQuotaType;
|
|
13
13
|
exports.handleSandboxCreationError = handleSandboxCreationError;
|
|
14
|
-
exports.handleVolumeCreationError = handleVolumeCreationError;
|
|
15
|
-
exports.handlePoolError = handlePoolError;
|
|
16
14
|
exports.handleClientHttpError = handleClientHttpError;
|
|
17
15
|
exports.handleSandboxHttpError = handleSandboxHttpError;
|
|
18
|
-
exports.handleConflictError = handleConflictError;
|
|
19
|
-
exports.handleResourceInUseError = handleResourceInUseError;
|
|
20
16
|
const errors_js_1 = require("./errors.cjs");
|
|
21
17
|
// =============================================================================
|
|
22
18
|
// Input validation
|
|
@@ -115,11 +111,6 @@ function extractQuotaType(message) {
|
|
|
115
111
|
else if (messageLower.includes("memory")) {
|
|
116
112
|
return "memory";
|
|
117
113
|
}
|
|
118
|
-
// Check for volume count quota
|
|
119
|
-
else if (messageLower.includes("volume") &&
|
|
120
|
-
(messageLower.includes("count") || messageLower.includes("limit"))) {
|
|
121
|
-
return "volume_count";
|
|
122
|
-
}
|
|
123
114
|
else if (messageLower.includes("storage")) {
|
|
124
115
|
return "storage";
|
|
125
116
|
}
|
|
@@ -140,6 +131,7 @@ function extractQuotaType(message) {
|
|
|
140
131
|
*/
|
|
141
132
|
async function handleSandboxCreationError(response) {
|
|
142
133
|
const status = response.status;
|
|
134
|
+
const clonedResponse = response.clone();
|
|
143
135
|
const data = await parseErrorResponse(response);
|
|
144
136
|
if (status === 408) {
|
|
145
137
|
// Timeout - include the message which contains last known status
|
|
@@ -147,7 +139,6 @@ async function handleSandboxCreationError(response) {
|
|
|
147
139
|
}
|
|
148
140
|
else if (status === 422) {
|
|
149
141
|
// Check if this is a Pydantic validation error (bad input) vs creation error
|
|
150
|
-
const clonedResponse = response.clone();
|
|
151
142
|
const details = await parseValidationError(clonedResponse);
|
|
152
143
|
if (details.length > 0 && details.some((d) => d.type === "value_error")) {
|
|
153
144
|
// Pydantic validation error (bad input - exceeds server limits)
|
|
@@ -168,86 +159,20 @@ async function handleSandboxCreationError(response) {
|
|
|
168
159
|
// Service Unavailable - scheduling failed
|
|
169
160
|
throw new errors_js_1.LangSmithSandboxCreationError(data.message, data.errorType || "Unschedulable");
|
|
170
161
|
}
|
|
171
|
-
// Fall through to generic handling
|
|
172
|
-
return handleClientHttpError(
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Handle HTTP errors specific to volume creation.
|
|
176
|
-
*
|
|
177
|
-
* Maps API error responses to specific exception types:
|
|
178
|
-
* - 429: LangSmithQuotaExceededError (org limits exceeded)
|
|
179
|
-
* - 503: LangSmithSandboxCreationError (provisioning failed)
|
|
180
|
-
* - 504: LangSmithResourceTimeoutError (volume didn't become ready in time)
|
|
181
|
-
* - Other: Falls through to generic error handling
|
|
182
|
-
*/
|
|
183
|
-
async function handleVolumeCreationError(response) {
|
|
184
|
-
const status = response.status;
|
|
185
|
-
const data = await parseErrorResponse(response);
|
|
186
|
-
if (status === 429) {
|
|
187
|
-
// Organization quota exceeded - extract type or default to volume_count
|
|
188
|
-
const quotaType = extractQuotaType(data.message) ?? "unknown";
|
|
189
|
-
throw new errors_js_1.LangSmithQuotaExceededError(data.message, quotaType);
|
|
190
|
-
}
|
|
191
|
-
else if (status === 503) {
|
|
192
|
-
// Provisioning failed (invalid storage class, quota exceeded)
|
|
193
|
-
throw new errors_js_1.LangSmithSandboxCreationError(data.message, "VolumeProvisioning");
|
|
194
|
-
}
|
|
195
|
-
else if (status === 504) {
|
|
196
|
-
// Timeout - volume didn't become ready in time
|
|
197
|
-
throw new errors_js_1.LangSmithResourceTimeoutError(data.message, "volume");
|
|
198
|
-
}
|
|
199
|
-
// Fall through to generic handling
|
|
200
|
-
return handleClientHttpError(response);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Handle HTTP errors specific to pool creation/update.
|
|
204
|
-
*
|
|
205
|
-
* Maps API error responses to specific exception types:
|
|
206
|
-
* - 400: LangSmithResourceNotFoundError or LangSmithValidationError (template has volumes)
|
|
207
|
-
* - 409: LangSmithResourceAlreadyExistsError
|
|
208
|
-
* - 429: LangSmithQuotaExceededError (org limits exceeded)
|
|
209
|
-
* - 504: LangSmithResourceTimeoutError (timeout waiting for ready replicas)
|
|
210
|
-
* - Other: Falls through to generic error handling
|
|
211
|
-
*/
|
|
212
|
-
async function handlePoolError(response) {
|
|
213
|
-
const status = response.status;
|
|
214
|
-
const data = await parseErrorResponse(response);
|
|
215
|
-
const errorType = data.errorType;
|
|
216
|
-
if (status === 400) {
|
|
217
|
-
// Check the error type to determine the specific exception
|
|
218
|
-
if (errorType === "TemplateNotFound") {
|
|
219
|
-
throw new errors_js_1.LangSmithResourceNotFoundError(data.message, "template");
|
|
220
|
-
}
|
|
221
|
-
else if (errorType === "LangSmithValidationError") {
|
|
222
|
-
// Template has volumes attached
|
|
223
|
-
throw new errors_js_1.LangSmithValidationError(data.message, undefined, undefined, errorType);
|
|
224
|
-
}
|
|
225
|
-
// Generic bad request - fall through to generic handling
|
|
226
|
-
}
|
|
227
|
-
else if (status === 409) {
|
|
228
|
-
// Pool already exists
|
|
229
|
-
throw new errors_js_1.LangSmithResourceAlreadyExistsError(data.message, "pool");
|
|
230
|
-
}
|
|
231
|
-
else if (status === 429) {
|
|
232
|
-
// Organization quota exceeded - extract type or default to pool_count
|
|
233
|
-
const quotaType = extractQuotaType(data.message) ?? "unknown";
|
|
234
|
-
throw new errors_js_1.LangSmithQuotaExceededError(data.message, quotaType);
|
|
235
|
-
}
|
|
236
|
-
else if (status === 504) {
|
|
237
|
-
// Timeout waiting for pool to be ready
|
|
238
|
-
throw new errors_js_1.LangSmithResourceTimeoutError(data.message, "pool");
|
|
239
|
-
}
|
|
240
|
-
// Fall through to generic handling
|
|
241
|
-
return handleClientHttpError(response);
|
|
162
|
+
// Fall through to generic handling — pass clone since body is already consumed
|
|
163
|
+
return handleClientHttpError(clonedResponse);
|
|
242
164
|
}
|
|
243
165
|
/**
|
|
244
166
|
* Handle HTTP errors and raise appropriate exceptions (for client operations).
|
|
245
167
|
*/
|
|
246
168
|
async function handleClientHttpError(response) {
|
|
169
|
+
const status = response.status;
|
|
170
|
+
// Only clone when we need to read the body twice (status 422 reads it again
|
|
171
|
+
// for structured validation details after parseErrorResponse consumes it).
|
|
172
|
+
const clonedResponse = status === 422 ? response.clone() : null;
|
|
247
173
|
const data = await parseErrorResponse(response);
|
|
248
174
|
const message = data.message;
|
|
249
175
|
const errorType = data.errorType;
|
|
250
|
-
const status = response.status;
|
|
251
176
|
if (status === 401 || status === 403) {
|
|
252
177
|
throw new errors_js_1.LangSmithSandboxAuthenticationError(message);
|
|
253
178
|
}
|
|
@@ -255,8 +180,7 @@ async function handleClientHttpError(response) {
|
|
|
255
180
|
throw new errors_js_1.LangSmithResourceNotFoundError(message);
|
|
256
181
|
}
|
|
257
182
|
// Handle validation errors (invalid resource values, formats, etc.)
|
|
258
|
-
if (status === 422) {
|
|
259
|
-
const clonedResponse = response.clone();
|
|
183
|
+
if (status === 422 && clonedResponse) {
|
|
260
184
|
const details = await parseValidationError(clonedResponse);
|
|
261
185
|
const field = details[0]?.loc?.slice(-1)[0];
|
|
262
186
|
throw new errors_js_1.LangSmithValidationError(message, field, details);
|
|
@@ -321,17 +245,3 @@ async function handleSandboxHttpError(response) {
|
|
|
321
245
|
}
|
|
322
246
|
throw new errors_js_1.LangSmithSandboxError(message);
|
|
323
247
|
}
|
|
324
|
-
/**
|
|
325
|
-
* Handle 409 Conflict errors for resource name conflicts.
|
|
326
|
-
*/
|
|
327
|
-
async function handleConflictError(response, resourceType) {
|
|
328
|
-
const data = await parseErrorResponse(response);
|
|
329
|
-
throw new errors_js_1.LangSmithResourceNameConflictError(data.message, resourceType);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Handle 409 Conflict errors for resources in use.
|
|
333
|
-
*/
|
|
334
|
-
async function handleResourceInUseError(response, resourceType) {
|
|
335
|
-
const data = await parseErrorResponse(response);
|
|
336
|
-
throw new errors_js_1.LangSmithResourceInUseError(data.message, resourceType);
|
|
337
|
-
}
|
|
@@ -49,27 +49,6 @@ export declare function extractQuotaType(message: string): string | undefined;
|
|
|
49
49
|
* - Other: Falls through to generic error handling
|
|
50
50
|
*/
|
|
51
51
|
export declare function handleSandboxCreationError(response: Response): Promise<never>;
|
|
52
|
-
/**
|
|
53
|
-
* Handle HTTP errors specific to volume creation.
|
|
54
|
-
*
|
|
55
|
-
* Maps API error responses to specific exception types:
|
|
56
|
-
* - 429: LangSmithQuotaExceededError (org limits exceeded)
|
|
57
|
-
* - 503: LangSmithSandboxCreationError (provisioning failed)
|
|
58
|
-
* - 504: LangSmithResourceTimeoutError (volume didn't become ready in time)
|
|
59
|
-
* - Other: Falls through to generic error handling
|
|
60
|
-
*/
|
|
61
|
-
export declare function handleVolumeCreationError(response: Response): Promise<never>;
|
|
62
|
-
/**
|
|
63
|
-
* Handle HTTP errors specific to pool creation/update.
|
|
64
|
-
*
|
|
65
|
-
* Maps API error responses to specific exception types:
|
|
66
|
-
* - 400: LangSmithResourceNotFoundError or LangSmithValidationError (template has volumes)
|
|
67
|
-
* - 409: LangSmithResourceAlreadyExistsError
|
|
68
|
-
* - 429: LangSmithQuotaExceededError (org limits exceeded)
|
|
69
|
-
* - 504: LangSmithResourceTimeoutError (timeout waiting for ready replicas)
|
|
70
|
-
* - Other: Falls through to generic error handling
|
|
71
|
-
*/
|
|
72
|
-
export declare function handlePoolError(response: Response): Promise<never>;
|
|
73
52
|
/**
|
|
74
53
|
* Handle HTTP errors and raise appropriate exceptions (for client operations).
|
|
75
54
|
*/
|
|
@@ -87,12 +66,4 @@ export declare function handleClientHttpError(response: Response): Promise<never
|
|
|
87
66
|
* - 403 -> LangSmithSandboxOperationError (permission denied)
|
|
88
67
|
*/
|
|
89
68
|
export declare function handleSandboxHttpError(response: Response): Promise<never>;
|
|
90
|
-
/**
|
|
91
|
-
* Handle 409 Conflict errors for resource name conflicts.
|
|
92
|
-
*/
|
|
93
|
-
export declare function handleConflictError(response: Response, resourceType: string): Promise<never>;
|
|
94
|
-
/**
|
|
95
|
-
* Handle 409 Conflict errors for resources in use.
|
|
96
|
-
*/
|
|
97
|
-
export declare function handleResourceInUseError(response: Response, resourceType: string): Promise<never>;
|
|
98
69
|
export {};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* These functions are used to parse error responses and raise appropriate
|
|
5
5
|
* exceptions. They contain no I/O operations.
|
|
6
6
|
*/
|
|
7
|
-
import { LangSmithQuotaExceededError,
|
|
7
|
+
import { LangSmithQuotaExceededError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxError, LangSmithSandboxConnectionError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithValidationError, } from "./errors.js";
|
|
8
8
|
// =============================================================================
|
|
9
9
|
// Input validation
|
|
10
10
|
// =============================================================================
|
|
@@ -102,11 +102,6 @@ export function extractQuotaType(message) {
|
|
|
102
102
|
else if (messageLower.includes("memory")) {
|
|
103
103
|
return "memory";
|
|
104
104
|
}
|
|
105
|
-
// Check for volume count quota
|
|
106
|
-
else if (messageLower.includes("volume") &&
|
|
107
|
-
(messageLower.includes("count") || messageLower.includes("limit"))) {
|
|
108
|
-
return "volume_count";
|
|
109
|
-
}
|
|
110
105
|
else if (messageLower.includes("storage")) {
|
|
111
106
|
return "storage";
|
|
112
107
|
}
|
|
@@ -127,6 +122,7 @@ export function extractQuotaType(message) {
|
|
|
127
122
|
*/
|
|
128
123
|
export async function handleSandboxCreationError(response) {
|
|
129
124
|
const status = response.status;
|
|
125
|
+
const clonedResponse = response.clone();
|
|
130
126
|
const data = await parseErrorResponse(response);
|
|
131
127
|
if (status === 408) {
|
|
132
128
|
// Timeout - include the message which contains last known status
|
|
@@ -134,7 +130,6 @@ export async function handleSandboxCreationError(response) {
|
|
|
134
130
|
}
|
|
135
131
|
else if (status === 422) {
|
|
136
132
|
// Check if this is a Pydantic validation error (bad input) vs creation error
|
|
137
|
-
const clonedResponse = response.clone();
|
|
138
133
|
const details = await parseValidationError(clonedResponse);
|
|
139
134
|
if (details.length > 0 && details.some((d) => d.type === "value_error")) {
|
|
140
135
|
// Pydantic validation error (bad input - exceeds server limits)
|
|
@@ -155,86 +150,20 @@ export async function handleSandboxCreationError(response) {
|
|
|
155
150
|
// Service Unavailable - scheduling failed
|
|
156
151
|
throw new LangSmithSandboxCreationError(data.message, data.errorType || "Unschedulable");
|
|
157
152
|
}
|
|
158
|
-
// Fall through to generic handling
|
|
159
|
-
return handleClientHttpError(
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Handle HTTP errors specific to volume creation.
|
|
163
|
-
*
|
|
164
|
-
* Maps API error responses to specific exception types:
|
|
165
|
-
* - 429: LangSmithQuotaExceededError (org limits exceeded)
|
|
166
|
-
* - 503: LangSmithSandboxCreationError (provisioning failed)
|
|
167
|
-
* - 504: LangSmithResourceTimeoutError (volume didn't become ready in time)
|
|
168
|
-
* - Other: Falls through to generic error handling
|
|
169
|
-
*/
|
|
170
|
-
export async function handleVolumeCreationError(response) {
|
|
171
|
-
const status = response.status;
|
|
172
|
-
const data = await parseErrorResponse(response);
|
|
173
|
-
if (status === 429) {
|
|
174
|
-
// Organization quota exceeded - extract type or default to volume_count
|
|
175
|
-
const quotaType = extractQuotaType(data.message) ?? "unknown";
|
|
176
|
-
throw new LangSmithQuotaExceededError(data.message, quotaType);
|
|
177
|
-
}
|
|
178
|
-
else if (status === 503) {
|
|
179
|
-
// Provisioning failed (invalid storage class, quota exceeded)
|
|
180
|
-
throw new LangSmithSandboxCreationError(data.message, "VolumeProvisioning");
|
|
181
|
-
}
|
|
182
|
-
else if (status === 504) {
|
|
183
|
-
// Timeout - volume didn't become ready in time
|
|
184
|
-
throw new LangSmithResourceTimeoutError(data.message, "volume");
|
|
185
|
-
}
|
|
186
|
-
// Fall through to generic handling
|
|
187
|
-
return handleClientHttpError(response);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Handle HTTP errors specific to pool creation/update.
|
|
191
|
-
*
|
|
192
|
-
* Maps API error responses to specific exception types:
|
|
193
|
-
* - 400: LangSmithResourceNotFoundError or LangSmithValidationError (template has volumes)
|
|
194
|
-
* - 409: LangSmithResourceAlreadyExistsError
|
|
195
|
-
* - 429: LangSmithQuotaExceededError (org limits exceeded)
|
|
196
|
-
* - 504: LangSmithResourceTimeoutError (timeout waiting for ready replicas)
|
|
197
|
-
* - Other: Falls through to generic error handling
|
|
198
|
-
*/
|
|
199
|
-
export async function handlePoolError(response) {
|
|
200
|
-
const status = response.status;
|
|
201
|
-
const data = await parseErrorResponse(response);
|
|
202
|
-
const errorType = data.errorType;
|
|
203
|
-
if (status === 400) {
|
|
204
|
-
// Check the error type to determine the specific exception
|
|
205
|
-
if (errorType === "TemplateNotFound") {
|
|
206
|
-
throw new LangSmithResourceNotFoundError(data.message, "template");
|
|
207
|
-
}
|
|
208
|
-
else if (errorType === "LangSmithValidationError") {
|
|
209
|
-
// Template has volumes attached
|
|
210
|
-
throw new LangSmithValidationError(data.message, undefined, undefined, errorType);
|
|
211
|
-
}
|
|
212
|
-
// Generic bad request - fall through to generic handling
|
|
213
|
-
}
|
|
214
|
-
else if (status === 409) {
|
|
215
|
-
// Pool already exists
|
|
216
|
-
throw new LangSmithResourceAlreadyExistsError(data.message, "pool");
|
|
217
|
-
}
|
|
218
|
-
else if (status === 429) {
|
|
219
|
-
// Organization quota exceeded - extract type or default to pool_count
|
|
220
|
-
const quotaType = extractQuotaType(data.message) ?? "unknown";
|
|
221
|
-
throw new LangSmithQuotaExceededError(data.message, quotaType);
|
|
222
|
-
}
|
|
223
|
-
else if (status === 504) {
|
|
224
|
-
// Timeout waiting for pool to be ready
|
|
225
|
-
throw new LangSmithResourceTimeoutError(data.message, "pool");
|
|
226
|
-
}
|
|
227
|
-
// Fall through to generic handling
|
|
228
|
-
return handleClientHttpError(response);
|
|
153
|
+
// Fall through to generic handling — pass clone since body is already consumed
|
|
154
|
+
return handleClientHttpError(clonedResponse);
|
|
229
155
|
}
|
|
230
156
|
/**
|
|
231
157
|
* Handle HTTP errors and raise appropriate exceptions (for client operations).
|
|
232
158
|
*/
|
|
233
159
|
export async function handleClientHttpError(response) {
|
|
160
|
+
const status = response.status;
|
|
161
|
+
// Only clone when we need to read the body twice (status 422 reads it again
|
|
162
|
+
// for structured validation details after parseErrorResponse consumes it).
|
|
163
|
+
const clonedResponse = status === 422 ? response.clone() : null;
|
|
234
164
|
const data = await parseErrorResponse(response);
|
|
235
165
|
const message = data.message;
|
|
236
166
|
const errorType = data.errorType;
|
|
237
|
-
const status = response.status;
|
|
238
167
|
if (status === 401 || status === 403) {
|
|
239
168
|
throw new LangSmithSandboxAuthenticationError(message);
|
|
240
169
|
}
|
|
@@ -242,8 +171,7 @@ export async function handleClientHttpError(response) {
|
|
|
242
171
|
throw new LangSmithResourceNotFoundError(message);
|
|
243
172
|
}
|
|
244
173
|
// Handle validation errors (invalid resource values, formats, etc.)
|
|
245
|
-
if (status === 422) {
|
|
246
|
-
const clonedResponse = response.clone();
|
|
174
|
+
if (status === 422 && clonedResponse) {
|
|
247
175
|
const details = await parseValidationError(clonedResponse);
|
|
248
176
|
const field = details[0]?.loc?.slice(-1)[0];
|
|
249
177
|
throw new LangSmithValidationError(message, field, details);
|
|
@@ -308,17 +236,3 @@ export async function handleSandboxHttpError(response) {
|
|
|
308
236
|
}
|
|
309
237
|
throw new LangSmithSandboxError(message);
|
|
310
238
|
}
|
|
311
|
-
/**
|
|
312
|
-
* Handle 409 Conflict errors for resource name conflicts.
|
|
313
|
-
*/
|
|
314
|
-
export async function handleConflictError(response, resourceType) {
|
|
315
|
-
const data = await parseErrorResponse(response);
|
|
316
|
-
throw new LangSmithResourceNameConflictError(data.message, resourceType);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Handle 409 Conflict errors for resources in use.
|
|
320
|
-
*/
|
|
321
|
-
export async function handleResourceInUseError(response, resourceType) {
|
|
322
|
-
const data = await parseErrorResponse(response);
|
|
323
|
-
throw new LangSmithResourceInUseError(data.message, resourceType);
|
|
324
|
-
}
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
13
13
|
* const client = new SandboxClient();
|
|
14
14
|
*
|
|
15
|
-
* const
|
|
15
|
+
* const snapshot = await client.createSnapshot(
|
|
16
|
+
* "python",
|
|
17
|
+
* "python:3.12-slim",
|
|
18
|
+
* 1_073_741_824
|
|
19
|
+
* );
|
|
20
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
16
21
|
* try {
|
|
17
22
|
* const result = await sandbox.run("python --version");
|
|
18
23
|
* console.log(result.stdout);
|
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
12
12
|
* const client = new SandboxClient();
|
|
13
13
|
*
|
|
14
|
-
* const
|
|
14
|
+
* const snapshot = await client.createSnapshot(
|
|
15
|
+
* "python",
|
|
16
|
+
* "python:3.12-slim",
|
|
17
|
+
* 1_073_741_824
|
|
18
|
+
* );
|
|
19
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
15
20
|
* try {
|
|
16
21
|
* const result = await sandbox.run("python --version");
|
|
17
22
|
* console.log(result.stdout);
|
|
@@ -25,5 +30,5 @@
|
|
|
25
30
|
export { SandboxClient } from "./client.js";
|
|
26
31
|
export { Sandbox } from "./sandbox.js";
|
|
27
32
|
export { CommandHandle } from "./command_handle.js";
|
|
28
|
-
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions,
|
|
33
|
+
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxProxyConfig, CreateSnapshotOptions, CaptureSnapshotOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
|
|
29
34
|
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
12
12
|
* const client = new SandboxClient();
|
|
13
13
|
*
|
|
14
|
-
* const
|
|
14
|
+
* const snapshot = await client.createSnapshot(
|
|
15
|
+
* "python",
|
|
16
|
+
* "python:3.12-slim",
|
|
17
|
+
* 1_073_741_824
|
|
18
|
+
* );
|
|
19
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
15
20
|
* try {
|
|
16
21
|
* const result = await sandbox.run("python --version");
|
|
17
22
|
* console.log(result.stdout);
|
|
@@ -17,7 +17,7 @@ const ws_execute_js_1 = require("./ws_execute.cjs");
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```typescript
|
|
20
|
-
* const sandbox = await client.createSandbox(
|
|
20
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
21
21
|
* try {
|
|
22
22
|
* const result = await sandbox.run("python --version");
|
|
23
23
|
* console.log(result.stdout);
|
|
@@ -38,13 +38,6 @@ class Sandbox {
|
|
|
38
38
|
writable: true,
|
|
39
39
|
value: void 0
|
|
40
40
|
});
|
|
41
|
-
/** Name of the template used to create this sandbox. */
|
|
42
|
-
Object.defineProperty(this, "template_name", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
41
|
/** URL for data plane operations (file I/O, command execution). */
|
|
49
42
|
Object.defineProperty(this, "dataplane_url", {
|
|
50
43
|
enumerable: true,
|
|
@@ -143,7 +136,6 @@ class Sandbox {
|
|
|
143
136
|
value: void 0
|
|
144
137
|
});
|
|
145
138
|
this.name = data.name;
|
|
146
|
-
this.template_name = data.template_name;
|
|
147
139
|
this.dataplane_url = data.dataplane_url;
|
|
148
140
|
this.status = data.status;
|
|
149
141
|
this.status_message = data.status_message;
|
|
@@ -360,7 +352,7 @@ class Sandbox {
|
|
|
360
352
|
*
|
|
361
353
|
* @example
|
|
362
354
|
* ```typescript
|
|
363
|
-
* const sandbox = await client.createSandbox(
|
|
355
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
364
356
|
* try {
|
|
365
357
|
* await sandbox.run("echo hello");
|
|
366
358
|
* } finally {
|
|
@@ -395,7 +387,7 @@ class Sandbox {
|
|
|
395
387
|
* Capture a snapshot from this sandbox.
|
|
396
388
|
*
|
|
397
389
|
* @param name - Snapshot name.
|
|
398
|
-
* @param options - Capture options (
|
|
390
|
+
* @param options - Capture options (timeout).
|
|
399
391
|
* @returns Snapshot in "ready" status.
|
|
400
392
|
*/
|
|
401
393
|
async captureSnapshot(name, options = {}) {
|
|
@@ -12,7 +12,7 @@ import { CommandHandle } from "./command_handle.js";
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
* const sandbox = await client.createSandbox(
|
|
15
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
16
16
|
* try {
|
|
17
17
|
* const result = await sandbox.run("python --version");
|
|
18
18
|
* console.log(result.stdout);
|
|
@@ -26,8 +26,6 @@ import { CommandHandle } from "./command_handle.js";
|
|
|
26
26
|
export declare class Sandbox {
|
|
27
27
|
/** Display name (can be updated). */
|
|
28
28
|
readonly name: string;
|
|
29
|
-
/** Name of the template used to create this sandbox. */
|
|
30
|
-
readonly template_name?: string;
|
|
31
29
|
/** URL for data plane operations (file I/O, command execution). */
|
|
32
30
|
dataplane_url?: string;
|
|
33
31
|
/** Provisioning status ("provisioning", "ready", "failed", "stopped"). */
|
|
@@ -146,7 +144,7 @@ export declare class Sandbox {
|
|
|
146
144
|
*
|
|
147
145
|
* @example
|
|
148
146
|
* ```typescript
|
|
149
|
-
* const sandbox = await client.createSandbox(
|
|
147
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
150
148
|
* try {
|
|
151
149
|
* await sandbox.run("echo hello");
|
|
152
150
|
* } finally {
|
|
@@ -171,7 +169,7 @@ export declare class Sandbox {
|
|
|
171
169
|
* Capture a snapshot from this sandbox.
|
|
172
170
|
*
|
|
173
171
|
* @param name - Snapshot name.
|
|
174
|
-
* @param options - Capture options (
|
|
172
|
+
* @param options - Capture options (timeout).
|
|
175
173
|
* @returns Snapshot in "ready" status.
|
|
176
174
|
*/
|
|
177
175
|
captureSnapshot(name: string, options?: CaptureSnapshotOptions): Promise<Snapshot>;
|
|
@@ -14,7 +14,7 @@ import { reconnectWsStream, runWsStream } from "./ws_execute.js";
|
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
17
|
-
* const sandbox = await client.createSandbox(
|
|
17
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
18
18
|
* try {
|
|
19
19
|
* const result = await sandbox.run("python --version");
|
|
20
20
|
* console.log(result.stdout);
|
|
@@ -35,13 +35,6 @@ export class Sandbox {
|
|
|
35
35
|
writable: true,
|
|
36
36
|
value: void 0
|
|
37
37
|
});
|
|
38
|
-
/** Name of the template used to create this sandbox. */
|
|
39
|
-
Object.defineProperty(this, "template_name", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: void 0
|
|
44
|
-
});
|
|
45
38
|
/** URL for data plane operations (file I/O, command execution). */
|
|
46
39
|
Object.defineProperty(this, "dataplane_url", {
|
|
47
40
|
enumerable: true,
|
|
@@ -140,7 +133,6 @@ export class Sandbox {
|
|
|
140
133
|
value: void 0
|
|
141
134
|
});
|
|
142
135
|
this.name = data.name;
|
|
143
|
-
this.template_name = data.template_name;
|
|
144
136
|
this.dataplane_url = data.dataplane_url;
|
|
145
137
|
this.status = data.status;
|
|
146
138
|
this.status_message = data.status_message;
|
|
@@ -357,7 +349,7 @@ export class Sandbox {
|
|
|
357
349
|
*
|
|
358
350
|
* @example
|
|
359
351
|
* ```typescript
|
|
360
|
-
* const sandbox = await client.createSandbox(
|
|
352
|
+
* const sandbox = await client.createSandbox(snapshot.id);
|
|
361
353
|
* try {
|
|
362
354
|
* await sandbox.run("echo hello");
|
|
363
355
|
* } finally {
|
|
@@ -392,7 +384,7 @@ export class Sandbox {
|
|
|
392
384
|
* Capture a snapshot from this sandbox.
|
|
393
385
|
*
|
|
394
386
|
* @param name - Snapshot name.
|
|
395
|
-
* @param options - Capture options (
|
|
387
|
+
* @param options - Capture options (timeout).
|
|
396
388
|
* @returns Snapshot in "ready" status.
|
|
397
389
|
*/
|
|
398
390
|
async captureSnapshot(name, options = {}) {
|