langsmith 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +16 -1
- package/dist/client.d.ts +10 -0
- package/dist/client.js +16 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{experimental/sandbox → sandbox}/client.cjs +25 -71
- package/dist/{experimental/sandbox → sandbox}/client.d.ts +15 -31
- package/dist/{experimental/sandbox → sandbox}/client.js +25 -71
- package/dist/{experimental/sandbox → sandbox}/index.cjs +1 -1
- package/dist/{experimental/sandbox → sandbox}/index.d.ts +1 -1
- package/dist/{experimental/sandbox → sandbox}/index.js +1 -1
- package/dist/{experimental/sandbox → sandbox}/sandbox.cjs +18 -12
- package/dist/{experimental/sandbox → sandbox}/sandbox.d.ts +13 -7
- package/dist/{experimental/sandbox → sandbox}/sandbox.js +18 -12
- package/dist/{experimental/sandbox → sandbox}/types.d.ts +39 -21
- package/package.json +14 -14
- package/sandbox.cjs +1 -0
- package/sandbox.d.cts +1 -0
- package/sandbox.d.ts +1 -0
- package/sandbox.js +1 -0
- package/experimental/sandbox.cjs +0 -1
- package/experimental/sandbox.d.cts +0 -1
- package/experimental/sandbox.d.ts +0 -1
- package/experimental/sandbox.js +0 -1
- /package/dist/{experimental/sandbox → sandbox}/command_handle.cjs +0 -0
- /package/dist/{experimental/sandbox → sandbox}/command_handle.d.ts +0 -0
- /package/dist/{experimental/sandbox → sandbox}/command_handle.js +0 -0
- /package/dist/{experimental/sandbox → sandbox}/errors.cjs +0 -0
- /package/dist/{experimental/sandbox → sandbox}/errors.d.ts +0 -0
- /package/dist/{experimental/sandbox → sandbox}/errors.js +0 -0
- /package/dist/{experimental/sandbox → sandbox}/helpers.cjs +0 -0
- /package/dist/{experimental/sandbox → sandbox}/helpers.d.ts +0 -0
- /package/dist/{experimental/sandbox → sandbox}/helpers.js +0 -0
- /package/dist/{experimental/sandbox → sandbox}/types.cjs +0 -0
- /package/dist/{experimental/sandbox → sandbox}/types.js +0 -0
- /package/dist/{experimental/sandbox → sandbox}/ws_execute.cjs +0 -0
- /package/dist/{experimental/sandbox → sandbox}/ws_execute.d.ts +0 -0
- /package/dist/{experimental/sandbox → sandbox}/ws_execute.js +0 -0
package/dist/client.cjs
CHANGED
|
@@ -4668,6 +4668,11 @@ class Client {
|
|
|
4668
4668
|
* the prompt contents, not merely the publishing account. Prompts from your
|
|
4669
4669
|
* own or your organization's account can still be unsafe if that account or
|
|
4670
4670
|
* prompt was compromised.
|
|
4671
|
+
*
|
|
4672
|
+
* When pulling a trusted external prompt, prefer pinning to a specific commit
|
|
4673
|
+
* rather than following a mutable latest version. Using `includeModel: true`
|
|
4674
|
+
* increases risk and should be avoided for public prompts or prompts outside
|
|
4675
|
+
* your own organization.
|
|
4671
4676
|
*/
|
|
4672
4677
|
async pullPromptCommit(promptIdentifier, options) {
|
|
4673
4678
|
assertPullPublicPromptAllowed(promptIdentifier, options?.dangerouslyPullPublicPrompt);
|
|
@@ -4703,6 +4708,11 @@ class Client {
|
|
|
4703
4708
|
* the prompt contents, not merely the publishing account. Prompts from your
|
|
4704
4709
|
* own or your organization's account can still be unsafe if that account or
|
|
4705
4710
|
* prompt was compromised.
|
|
4711
|
+
*
|
|
4712
|
+
* When pulling a trusted external prompt, prefer pinning to a specific commit
|
|
4713
|
+
* rather than following a mutable latest version. Using `includeModel: true`
|
|
4714
|
+
* increases risk and should be avoided for public prompts or prompts outside
|
|
4715
|
+
* your own organization.
|
|
4706
4716
|
* @private
|
|
4707
4717
|
*/
|
|
4708
4718
|
async _pullPrompt(promptIdentifier, options) {
|
|
@@ -4888,7 +4898,12 @@ class Client {
|
|
|
4888
4898
|
});
|
|
4889
4899
|
const data = (await response.json());
|
|
4890
4900
|
const commitHash = data.commit.commit_hash;
|
|
4891
|
-
|
|
4901
|
+
let ownerForUrl = owner;
|
|
4902
|
+
if (owner === "-") {
|
|
4903
|
+
const settings = await this._getSettings();
|
|
4904
|
+
ownerForUrl = settings.tenant_handle || owner;
|
|
4905
|
+
}
|
|
4906
|
+
return `${this.getHostUrl()}/hub/${ownerForUrl}/${name}:${commitHash.slice(0, 8)}`;
|
|
4892
4907
|
}
|
|
4893
4908
|
async _deleteDirectory(identifier) {
|
|
4894
4909
|
const [owner, name] = (0, prompts_js_1.parseHubIdentifier)(identifier);
|
package/dist/client.d.ts
CHANGED
|
@@ -1346,6 +1346,11 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
1346
1346
|
* the prompt contents, not merely the publishing account. Prompts from your
|
|
1347
1347
|
* own or your organization's account can still be unsafe if that account or
|
|
1348
1348
|
* prompt was compromised.
|
|
1349
|
+
*
|
|
1350
|
+
* When pulling a trusted external prompt, prefer pinning to a specific commit
|
|
1351
|
+
* rather than following a mutable latest version. Using `includeModel: true`
|
|
1352
|
+
* increases risk and should be avoided for public prompts or prompts outside
|
|
1353
|
+
* your own organization.
|
|
1349
1354
|
*/
|
|
1350
1355
|
pullPromptCommit(promptIdentifier: string, options?: {
|
|
1351
1356
|
includeModel?: boolean;
|
|
@@ -1372,6 +1377,11 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
1372
1377
|
* the prompt contents, not merely the publishing account. Prompts from your
|
|
1373
1378
|
* own or your organization's account can still be unsafe if that account or
|
|
1374
1379
|
* prompt was compromised.
|
|
1380
|
+
*
|
|
1381
|
+
* When pulling a trusted external prompt, prefer pinning to a specific commit
|
|
1382
|
+
* rather than following a mutable latest version. Using `includeModel: true`
|
|
1383
|
+
* increases risk and should be avoided for public prompts or prompts outside
|
|
1384
|
+
* your own organization.
|
|
1375
1385
|
* @private
|
|
1376
1386
|
*/
|
|
1377
1387
|
_pullPrompt(promptIdentifier: string, options?: {
|
package/dist/client.js
CHANGED
|
@@ -4630,6 +4630,11 @@ export class Client {
|
|
|
4630
4630
|
* the prompt contents, not merely the publishing account. Prompts from your
|
|
4631
4631
|
* own or your organization's account can still be unsafe if that account or
|
|
4632
4632
|
* prompt was compromised.
|
|
4633
|
+
*
|
|
4634
|
+
* When pulling a trusted external prompt, prefer pinning to a specific commit
|
|
4635
|
+
* rather than following a mutable latest version. Using `includeModel: true`
|
|
4636
|
+
* increases risk and should be avoided for public prompts or prompts outside
|
|
4637
|
+
* your own organization.
|
|
4633
4638
|
*/
|
|
4634
4639
|
async pullPromptCommit(promptIdentifier, options) {
|
|
4635
4640
|
assertPullPublicPromptAllowed(promptIdentifier, options?.dangerouslyPullPublicPrompt);
|
|
@@ -4665,6 +4670,11 @@ export class Client {
|
|
|
4665
4670
|
* the prompt contents, not merely the publishing account. Prompts from your
|
|
4666
4671
|
* own or your organization's account can still be unsafe if that account or
|
|
4667
4672
|
* prompt was compromised.
|
|
4673
|
+
*
|
|
4674
|
+
* When pulling a trusted external prompt, prefer pinning to a specific commit
|
|
4675
|
+
* rather than following a mutable latest version. Using `includeModel: true`
|
|
4676
|
+
* increases risk and should be avoided for public prompts or prompts outside
|
|
4677
|
+
* your own organization.
|
|
4668
4678
|
* @private
|
|
4669
4679
|
*/
|
|
4670
4680
|
async _pullPrompt(promptIdentifier, options) {
|
|
@@ -4850,7 +4860,12 @@ export class Client {
|
|
|
4850
4860
|
});
|
|
4851
4861
|
const data = (await response.json());
|
|
4852
4862
|
const commitHash = data.commit.commit_hash;
|
|
4853
|
-
|
|
4863
|
+
let ownerForUrl = owner;
|
|
4864
|
+
if (owner === "-") {
|
|
4865
|
+
const settings = await this._getSettings();
|
|
4866
|
+
ownerForUrl = settings.tenant_handle || owner;
|
|
4867
|
+
}
|
|
4868
|
+
return `${this.getHostUrl()}/hub/${ownerForUrl}/${name}:${commitHash.slice(0, 8)}`;
|
|
4854
4869
|
}
|
|
4855
4870
|
async _deleteDirectory(identifier) {
|
|
4856
4871
|
const [owner, name] = parseHubIdentifier(identifier);
|
package/dist/index.cjs
CHANGED
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
|
|
|
18
18
|
Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
|
|
19
19
|
Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
|
|
20
20
|
// Update using pnpm bump-version
|
|
21
|
-
exports.__version__ = "0.
|
|
21
|
+
exports.__version__ = "0.7.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
6
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
7
7
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
|
-
export declare const __version__ = "0.
|
|
8
|
+
export declare const __version__ = "0.7.0";
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { getDefaultProjectName } from "./utils/project.js";
|
|
|
5
5
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
6
6
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
7
7
|
// Update using pnpm bump-version
|
|
8
|
-
export const __version__ = "0.
|
|
8
|
+
export const __version__ = "0.7.0";
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SandboxClient = void 0;
|
|
7
|
-
const env_js_1 = require("
|
|
8
|
-
const fetch_js_1 = require("
|
|
9
|
-
const async_caller_js_1 = require("
|
|
7
|
+
const env_js_1 = require("../utils/env.cjs");
|
|
8
|
+
const fetch_js_1 = require("../singletons/fetch.cjs");
|
|
9
|
+
const async_caller_js_1 = require("../utils/async_caller.cjs");
|
|
10
10
|
const sandbox_js_1 = require("./sandbox.cjs");
|
|
11
11
|
const errors_js_1 = require("./errors.cjs");
|
|
12
12
|
const helpers_js_1 = require("./helpers.cjs");
|
|
@@ -54,7 +54,7 @@ function getDefaultApiKey() {
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* ```typescript
|
|
57
|
-
* import { SandboxClient } from "langsmith/
|
|
57
|
+
* import { SandboxClient } from "langsmith/sandbox";
|
|
58
58
|
*
|
|
59
59
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
60
60
|
* const client = new SandboxClient();
|
|
@@ -65,13 +65,8 @@ function getDefaultApiKey() {
|
|
|
65
65
|
* apiKey: "your-api-key",
|
|
66
66
|
* });
|
|
67
67
|
*
|
|
68
|
-
* //
|
|
69
|
-
* const
|
|
70
|
-
* "python",
|
|
71
|
-
* "python:3.12-slim",
|
|
72
|
-
* 1_073_741_824 // 1 GiB
|
|
73
|
-
* );
|
|
74
|
-
* const sandbox = await client.createSandbox(snapshot.id);
|
|
68
|
+
* // Create a sandbox with the default runtime
|
|
69
|
+
* const sandbox = await client.createSandbox();
|
|
75
70
|
* try {
|
|
76
71
|
* const result = await sandbox.run("python --version");
|
|
77
72
|
* console.log(result.stdout);
|
|
@@ -79,8 +74,6 @@ function getDefaultApiKey() {
|
|
|
79
74
|
* await sandbox.delete();
|
|
80
75
|
* }
|
|
81
76
|
* ```
|
|
82
|
-
*
|
|
83
|
-
* @experimental This feature is experimental, and breaking changes are expected.
|
|
84
77
|
*/
|
|
85
78
|
class SandboxClient {
|
|
86
79
|
constructor(config = {}) {
|
|
@@ -160,56 +153,17 @@ class SandboxClient {
|
|
|
160
153
|
}
|
|
161
154
|
return response;
|
|
162
155
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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.
|
|
180
|
-
* @returns Created Sandbox.
|
|
181
|
-
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
182
|
-
* @throws SandboxCreationError if sandbox creation fails.
|
|
183
|
-
* @throws LangSmithValidationError if TTL values are invalid, or if neither
|
|
184
|
-
* (or both) of `snapshotId` / `options.snapshotName` are provided.
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
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
|
-
* });
|
|
198
|
-
* try {
|
|
199
|
-
* const result = await sandbox.run("echo hello");
|
|
200
|
-
* console.log(result.stdout);
|
|
201
|
-
* } finally {
|
|
202
|
-
* await sandbox.delete();
|
|
203
|
-
* }
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
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");
|
|
156
|
+
async createSandbox(snapshotIdOrOptions, options = {}) {
|
|
157
|
+
const snapshotId = typeof snapshotIdOrOptions === "string" ? snapshotIdOrOptions : undefined;
|
|
158
|
+
const resolvedOptions = typeof snapshotIdOrOptions === "object" && snapshotIdOrOptions !== null
|
|
159
|
+
? snapshotIdOrOptions
|
|
160
|
+
: options;
|
|
161
|
+
const { snapshotName, name, timeout = 30, waitForReady = true, idleTtlSeconds, deleteAfterStopSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = resolvedOptions;
|
|
162
|
+
if (snapshotId && snapshotName) {
|
|
163
|
+
throw new errors_js_1.LangSmithValidationError("At most one of snapshotId or options.snapshotName may be set", "snapshotId");
|
|
210
164
|
}
|
|
211
|
-
(0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
|
|
212
165
|
(0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
|
|
166
|
+
(0, helpers_js_1.validateTtl)(deleteAfterStopSeconds, "deleteAfterStopSeconds");
|
|
213
167
|
const url = `${this._baseUrl}/boxes`;
|
|
214
168
|
const payload = {
|
|
215
169
|
wait_for_ready: waitForReady,
|
|
@@ -226,12 +180,12 @@ class SandboxClient {
|
|
|
226
180
|
if (name) {
|
|
227
181
|
payload.name = name;
|
|
228
182
|
}
|
|
229
|
-
if (ttlSeconds !== undefined) {
|
|
230
|
-
payload.ttl_seconds = ttlSeconds;
|
|
231
|
-
}
|
|
232
183
|
if (idleTtlSeconds !== undefined) {
|
|
233
184
|
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
234
185
|
}
|
|
186
|
+
if (deleteAfterStopSeconds !== undefined) {
|
|
187
|
+
payload.delete_after_stop_seconds = deleteAfterStopSeconds;
|
|
188
|
+
}
|
|
235
189
|
if (vCpus !== undefined) {
|
|
236
190
|
payload.vcpus = vCpus;
|
|
237
191
|
}
|
|
@@ -299,12 +253,12 @@ class SandboxClient {
|
|
|
299
253
|
const options = typeof newNameOrOptions === "string"
|
|
300
254
|
? { newName: newNameOrOptions }
|
|
301
255
|
: newNameOrOptions;
|
|
302
|
-
const { newName,
|
|
303
|
-
(0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
|
|
256
|
+
const { newName, idleTtlSeconds, deleteAfterStopSeconds } = options;
|
|
304
257
|
(0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
|
|
258
|
+
(0, helpers_js_1.validateTtl)(deleteAfterStopSeconds, "deleteAfterStopSeconds");
|
|
305
259
|
if (newName === undefined &&
|
|
306
|
-
|
|
307
|
-
|
|
260
|
+
idleTtlSeconds === undefined &&
|
|
261
|
+
deleteAfterStopSeconds === undefined) {
|
|
308
262
|
return this.getSandbox(name);
|
|
309
263
|
}
|
|
310
264
|
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
|
|
@@ -312,12 +266,12 @@ class SandboxClient {
|
|
|
312
266
|
if (newName !== undefined) {
|
|
313
267
|
payload.name = newName;
|
|
314
268
|
}
|
|
315
|
-
if (ttlSeconds !== undefined) {
|
|
316
|
-
payload.ttl_seconds = ttlSeconds;
|
|
317
|
-
}
|
|
318
269
|
if (idleTtlSeconds !== undefined) {
|
|
319
270
|
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
320
271
|
}
|
|
272
|
+
if (deleteAfterStopSeconds !== undefined) {
|
|
273
|
+
payload.delete_after_stop_seconds = deleteAfterStopSeconds;
|
|
274
|
+
}
|
|
321
275
|
const response = await this._fetch(url, {
|
|
322
276
|
method: "PATCH",
|
|
323
277
|
headers: { "Content-Type": "application/json" },
|
|
@@ -10,7 +10,7 @@ import { Sandbox } from "./sandbox.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
|
-
* import { SandboxClient } from "langsmith/
|
|
13
|
+
* import { SandboxClient } from "langsmith/sandbox";
|
|
14
14
|
*
|
|
15
15
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
16
16
|
* const client = new SandboxClient();
|
|
@@ -21,13 +21,8 @@ import { Sandbox } from "./sandbox.js";
|
|
|
21
21
|
* apiKey: "your-api-key",
|
|
22
22
|
* });
|
|
23
23
|
*
|
|
24
|
-
* //
|
|
25
|
-
* const
|
|
26
|
-
* "python",
|
|
27
|
-
* "python:3.12-slim",
|
|
28
|
-
* 1_073_741_824 // 1 GiB
|
|
29
|
-
* );
|
|
30
|
-
* const sandbox = await client.createSandbox(snapshot.id);
|
|
24
|
+
* // Create a sandbox with the default runtime
|
|
25
|
+
* const sandbox = await client.createSandbox();
|
|
31
26
|
* try {
|
|
32
27
|
* const result = await sandbox.run("python --version");
|
|
33
28
|
* console.log(result.stdout);
|
|
@@ -35,8 +30,6 @@ import { Sandbox } from "./sandbox.js";
|
|
|
35
30
|
* await sandbox.delete();
|
|
36
31
|
* }
|
|
37
32
|
* ```
|
|
38
|
-
*
|
|
39
|
-
* @experimental This feature is experimental, and breaking changes are expected.
|
|
40
33
|
*/
|
|
41
34
|
export declare class SandboxClient {
|
|
42
35
|
private _baseUrl;
|
|
@@ -45,35 +38,24 @@ export declare class SandboxClient {
|
|
|
45
38
|
private _caller;
|
|
46
39
|
constructor(config?: SandboxClientConfig);
|
|
47
40
|
/**
|
|
48
|
-
* Create a new Sandbox
|
|
41
|
+
* Create a new Sandbox.
|
|
49
42
|
*
|
|
50
43
|
* Remember to call `sandbox.delete()` when done to clean up resources.
|
|
51
44
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* snapshot
|
|
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.
|
|
45
|
+
* @param snapshotId - Optional snapshot ID to boot from.
|
|
46
|
+
* @param options - Creation options. Use `options.snapshotName` to boot from
|
|
47
|
+
* a named snapshot instead of the default runtime.
|
|
61
48
|
* @returns Created Sandbox.
|
|
62
49
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
63
50
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
64
|
-
* @throws LangSmithValidationError if TTL values are invalid, or if
|
|
65
|
-
*
|
|
51
|
+
* @throws LangSmithValidationError if TTL values are invalid, or if both
|
|
52
|
+
* `snapshotId` and `options.snapshotName` are provided.
|
|
66
53
|
*
|
|
67
54
|
* @example
|
|
68
55
|
* ```typescript
|
|
69
|
-
* const
|
|
70
|
-
* "python",
|
|
71
|
-
* "python:3.12-slim",
|
|
72
|
-
* 1_073_741_824
|
|
73
|
-
* );
|
|
74
|
-
* const sandbox = await client.createSandbox(snapshot.id);
|
|
56
|
+
* const sandbox = await client.createSandbox();
|
|
75
57
|
* // Or, resolve by snapshot name:
|
|
76
|
-
* const sandbox = await client.createSandbox(
|
|
58
|
+
* const sandbox = await client.createSandbox({
|
|
77
59
|
* snapshotName: "python",
|
|
78
60
|
* });
|
|
79
61
|
* try {
|
|
@@ -84,6 +66,7 @@ export declare class SandboxClient {
|
|
|
84
66
|
* }
|
|
85
67
|
* ```
|
|
86
68
|
*/
|
|
69
|
+
createSandbox(options?: CreateSandboxOptions): Promise<Sandbox>;
|
|
87
70
|
createSandbox(snapshotId?: string, options?: CreateSandboxOptions): Promise<Sandbox>;
|
|
88
71
|
/**
|
|
89
72
|
* Get a Sandbox by name.
|
|
@@ -111,14 +94,15 @@ export declare class SandboxClient {
|
|
|
111
94
|
*/
|
|
112
95
|
updateSandbox(name: string, newName: string): Promise<Sandbox>;
|
|
113
96
|
/**
|
|
114
|
-
* Update a sandbox's name and/or
|
|
97
|
+
* Update a sandbox's name and/or retention settings (idle stop and
|
|
98
|
+
* delete-after-stop).
|
|
115
99
|
*
|
|
116
100
|
* @param name - Current sandbox name.
|
|
117
101
|
* @param options - Fields to update. Omit a field to leave it unchanged.
|
|
118
102
|
* @returns Updated Sandbox. If no fields are provided, returns the current sandbox.
|
|
119
103
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
120
104
|
* @throws LangSmithResourceNameConflictError if newName is already in use.
|
|
121
|
-
* @throws LangSmithValidationError if
|
|
105
|
+
* @throws LangSmithValidationError if retention values are invalid.
|
|
122
106
|
*/
|
|
123
107
|
updateSandbox(name: string, options: UpdateSandboxOptions): Promise<Sandbox>;
|
|
124
108
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main SandboxClient class for interacting with the sandbox server API.
|
|
3
3
|
*/
|
|
4
|
-
import { getLangSmithEnvironmentVariable } from "
|
|
5
|
-
import { _getFetchImplementation } from "
|
|
6
|
-
import { AsyncCaller } from "
|
|
4
|
+
import { getLangSmithEnvironmentVariable } from "../utils/env.js";
|
|
5
|
+
import { _getFetchImplementation } from "../singletons/fetch.js";
|
|
6
|
+
import { AsyncCaller } from "../utils/async_caller.js";
|
|
7
7
|
import { Sandbox } from "./sandbox.js";
|
|
8
8
|
import { LangSmithResourceCreationError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, LangSmithValidationError, } from "./errors.js";
|
|
9
9
|
import { handleClientHttpError, handleSandboxCreationError, validateTtl, } from "./helpers.js";
|
|
@@ -51,7 +51,7 @@ function getDefaultApiKey() {
|
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* ```typescript
|
|
54
|
-
* import { SandboxClient } from "langsmith/
|
|
54
|
+
* import { SandboxClient } from "langsmith/sandbox";
|
|
55
55
|
*
|
|
56
56
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
57
57
|
* const client = new SandboxClient();
|
|
@@ -62,13 +62,8 @@ function getDefaultApiKey() {
|
|
|
62
62
|
* apiKey: "your-api-key",
|
|
63
63
|
* });
|
|
64
64
|
*
|
|
65
|
-
* //
|
|
66
|
-
* const
|
|
67
|
-
* "python",
|
|
68
|
-
* "python:3.12-slim",
|
|
69
|
-
* 1_073_741_824 // 1 GiB
|
|
70
|
-
* );
|
|
71
|
-
* const sandbox = await client.createSandbox(snapshot.id);
|
|
65
|
+
* // Create a sandbox with the default runtime
|
|
66
|
+
* const sandbox = await client.createSandbox();
|
|
72
67
|
* try {
|
|
73
68
|
* const result = await sandbox.run("python --version");
|
|
74
69
|
* console.log(result.stdout);
|
|
@@ -76,8 +71,6 @@ function getDefaultApiKey() {
|
|
|
76
71
|
* await sandbox.delete();
|
|
77
72
|
* }
|
|
78
73
|
* ```
|
|
79
|
-
*
|
|
80
|
-
* @experimental This feature is experimental, and breaking changes are expected.
|
|
81
74
|
*/
|
|
82
75
|
export class SandboxClient {
|
|
83
76
|
constructor(config = {}) {
|
|
@@ -157,56 +150,17 @@ export class SandboxClient {
|
|
|
157
150
|
}
|
|
158
151
|
return response;
|
|
159
152
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
* Exactly one of `snapshotId` (positional) or `options.snapshotName` must
|
|
169
|
-
* be provided. When `snapshotName` is used, the server resolves it to a
|
|
170
|
-
* snapshot owned by the caller's tenant.
|
|
171
|
-
*
|
|
172
|
-
* @param snapshotId - ID of the snapshot to boot from. Create one with
|
|
173
|
-
* `createSnapshot()` or `captureSnapshot()`, or pass an existing snapshot ID.
|
|
174
|
-
* Pass `undefined` when booting by name via `options.snapshotName`.
|
|
175
|
-
* @param options - Creation options. Use `options.snapshotName` to boot
|
|
176
|
-
* by snapshot name instead of ID.
|
|
177
|
-
* @returns Created Sandbox.
|
|
178
|
-
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
179
|
-
* @throws SandboxCreationError if sandbox creation fails.
|
|
180
|
-
* @throws LangSmithValidationError if TTL values are invalid, or if neither
|
|
181
|
-
* (or both) of `snapshotId` / `options.snapshotName` are provided.
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* ```typescript
|
|
185
|
-
* const snapshot = await client.createSnapshot(
|
|
186
|
-
* "python",
|
|
187
|
-
* "python:3.12-slim",
|
|
188
|
-
* 1_073_741_824
|
|
189
|
-
* );
|
|
190
|
-
* const sandbox = await client.createSandbox(snapshot.id);
|
|
191
|
-
* // Or, resolve by snapshot name:
|
|
192
|
-
* const sandbox = await client.createSandbox(undefined, {
|
|
193
|
-
* snapshotName: "python",
|
|
194
|
-
* });
|
|
195
|
-
* try {
|
|
196
|
-
* const result = await sandbox.run("echo hello");
|
|
197
|
-
* console.log(result.stdout);
|
|
198
|
-
* } finally {
|
|
199
|
-
* await sandbox.delete();
|
|
200
|
-
* }
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
async createSandbox(snapshotId, options = {}) {
|
|
204
|
-
const { snapshotName, name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = options;
|
|
205
|
-
if (!!snapshotId === !!snapshotName) {
|
|
206
|
-
throw new LangSmithValidationError("Exactly one of snapshotId or options.snapshotName must be set", "snapshotId");
|
|
153
|
+
async createSandbox(snapshotIdOrOptions, options = {}) {
|
|
154
|
+
const snapshotId = typeof snapshotIdOrOptions === "string" ? snapshotIdOrOptions : undefined;
|
|
155
|
+
const resolvedOptions = typeof snapshotIdOrOptions === "object" && snapshotIdOrOptions !== null
|
|
156
|
+
? snapshotIdOrOptions
|
|
157
|
+
: options;
|
|
158
|
+
const { snapshotName, name, timeout = 30, waitForReady = true, idleTtlSeconds, deleteAfterStopSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = resolvedOptions;
|
|
159
|
+
if (snapshotId && snapshotName) {
|
|
160
|
+
throw new LangSmithValidationError("At most one of snapshotId or options.snapshotName may be set", "snapshotId");
|
|
207
161
|
}
|
|
208
|
-
validateTtl(ttlSeconds, "ttlSeconds");
|
|
209
162
|
validateTtl(idleTtlSeconds, "idleTtlSeconds");
|
|
163
|
+
validateTtl(deleteAfterStopSeconds, "deleteAfterStopSeconds");
|
|
210
164
|
const url = `${this._baseUrl}/boxes`;
|
|
211
165
|
const payload = {
|
|
212
166
|
wait_for_ready: waitForReady,
|
|
@@ -223,12 +177,12 @@ export class SandboxClient {
|
|
|
223
177
|
if (name) {
|
|
224
178
|
payload.name = name;
|
|
225
179
|
}
|
|
226
|
-
if (ttlSeconds !== undefined) {
|
|
227
|
-
payload.ttl_seconds = ttlSeconds;
|
|
228
|
-
}
|
|
229
180
|
if (idleTtlSeconds !== undefined) {
|
|
230
181
|
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
231
182
|
}
|
|
183
|
+
if (deleteAfterStopSeconds !== undefined) {
|
|
184
|
+
payload.delete_after_stop_seconds = deleteAfterStopSeconds;
|
|
185
|
+
}
|
|
232
186
|
if (vCpus !== undefined) {
|
|
233
187
|
payload.vcpus = vCpus;
|
|
234
188
|
}
|
|
@@ -296,12 +250,12 @@ export class SandboxClient {
|
|
|
296
250
|
const options = typeof newNameOrOptions === "string"
|
|
297
251
|
? { newName: newNameOrOptions }
|
|
298
252
|
: newNameOrOptions;
|
|
299
|
-
const { newName,
|
|
300
|
-
validateTtl(ttlSeconds, "ttlSeconds");
|
|
253
|
+
const { newName, idleTtlSeconds, deleteAfterStopSeconds } = options;
|
|
301
254
|
validateTtl(idleTtlSeconds, "idleTtlSeconds");
|
|
255
|
+
validateTtl(deleteAfterStopSeconds, "deleteAfterStopSeconds");
|
|
302
256
|
if (newName === undefined &&
|
|
303
|
-
|
|
304
|
-
|
|
257
|
+
idleTtlSeconds === undefined &&
|
|
258
|
+
deleteAfterStopSeconds === undefined) {
|
|
305
259
|
return this.getSandbox(name);
|
|
306
260
|
}
|
|
307
261
|
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
|
|
@@ -309,12 +263,12 @@ export class SandboxClient {
|
|
|
309
263
|
if (newName !== undefined) {
|
|
310
264
|
payload.name = newName;
|
|
311
265
|
}
|
|
312
|
-
if (ttlSeconds !== undefined) {
|
|
313
|
-
payload.ttl_seconds = ttlSeconds;
|
|
314
|
-
}
|
|
315
266
|
if (idleTtlSeconds !== undefined) {
|
|
316
267
|
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
317
268
|
}
|
|
269
|
+
if (deleteAfterStopSeconds !== undefined) {
|
|
270
|
+
payload.delete_after_stop_seconds = deleteAfterStopSeconds;
|
|
271
|
+
}
|
|
318
272
|
const response = await this._fetch(url, {
|
|
319
273
|
method: "PATCH",
|
|
320
274
|
headers: { "Content-Type": "application/json" },
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import { SandboxClient } from "langsmith/
|
|
10
|
+
* import { SandboxClient } from "langsmith/sandbox";
|
|
11
11
|
*
|
|
12
12
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
13
13
|
* const client = new SandboxClient();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import { SandboxClient } from "langsmith/
|
|
9
|
+
* import { SandboxClient } from "langsmith/sandbox";
|
|
10
10
|
*
|
|
11
11
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
12
12
|
* const client = new SandboxClient();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import { SandboxClient } from "langsmith/
|
|
9
|
+
* import { SandboxClient } from "langsmith/sandbox";
|
|
10
10
|
*
|
|
11
11
|
* // Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
|
|
12
12
|
* const client = new SandboxClient();
|
|
@@ -25,8 +25,6 @@ const ws_execute_js_1 = require("./ws_execute.cjs");
|
|
|
25
25
|
* await sandbox.delete();
|
|
26
26
|
* }
|
|
27
27
|
* ```
|
|
28
|
-
*
|
|
29
|
-
* @experimental This feature is experimental, and breaking changes are expected.
|
|
30
28
|
*/
|
|
31
29
|
class Sandbox {
|
|
32
30
|
/** @internal */
|
|
@@ -80,26 +78,34 @@ class Sandbox {
|
|
|
80
78
|
writable: true,
|
|
81
79
|
value: void 0
|
|
82
80
|
});
|
|
83
|
-
/**
|
|
84
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Idle timeout TTL in seconds (`0` means disabled).
|
|
83
|
+
* New sandboxes receive a server-side default of `600` seconds (10 minutes)
|
|
84
|
+
* when the caller did not set `idleTtlSeconds` explicitly. The launcher
|
|
85
|
+
* stops the sandbox after this many idle seconds.
|
|
86
|
+
*/
|
|
87
|
+
Object.defineProperty(this, "idle_ttl_seconds", {
|
|
85
88
|
enumerable: true,
|
|
86
89
|
configurable: true,
|
|
87
90
|
writable: true,
|
|
88
91
|
value: void 0
|
|
89
92
|
});
|
|
90
93
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* when the caller did not set `idleTtlSeconds` explicitly.
|
|
94
|
+
* Seconds after the sandbox enters the `stopped` state before it (and
|
|
95
|
+
* its filesystem clone) are permanently deleted (`0` means disabled).
|
|
94
96
|
*/
|
|
95
|
-
Object.defineProperty(this, "
|
|
97
|
+
Object.defineProperty(this, "delete_after_stop_seconds", {
|
|
96
98
|
enumerable: true,
|
|
97
99
|
configurable: true,
|
|
98
100
|
writable: true,
|
|
99
101
|
value: void 0
|
|
100
102
|
});
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Timestamp when the sandbox transitioned to `stopped`, or `undefined`
|
|
105
|
+
* while running. The deletion deadline is
|
|
106
|
+
* `stopped_at + delete_after_stop_seconds`.
|
|
107
|
+
*/
|
|
108
|
+
Object.defineProperty(this, "stopped_at", {
|
|
103
109
|
enumerable: true,
|
|
104
110
|
configurable: true,
|
|
105
111
|
writable: true,
|
|
@@ -146,9 +152,9 @@ class Sandbox {
|
|
|
146
152
|
this.id = data.id;
|
|
147
153
|
this.created_at = data.created_at;
|
|
148
154
|
this.updated_at = data.updated_at;
|
|
149
|
-
this.ttl_seconds = data.ttl_seconds;
|
|
150
155
|
this.idle_ttl_seconds = data.idle_ttl_seconds;
|
|
151
|
-
this.
|
|
156
|
+
this.delete_after_stop_seconds = data.delete_after_stop_seconds;
|
|
157
|
+
this.stopped_at = data.stopped_at ?? undefined;
|
|
152
158
|
this.snapshot_id = data.snapshot_id;
|
|
153
159
|
this.vCpus = data.vcpus;
|
|
154
160
|
this.mem_bytes = data.mem_bytes;
|
|
@@ -20,8 +20,6 @@ import { CommandHandle } from "./command_handle.js";
|
|
|
20
20
|
* await sandbox.delete();
|
|
21
21
|
* }
|
|
22
22
|
* ```
|
|
23
|
-
*
|
|
24
|
-
* @experimental This feature is experimental, and breaking changes are expected.
|
|
25
23
|
*/
|
|
26
24
|
export declare class Sandbox {
|
|
27
25
|
/** Display name (can be updated). */
|
|
@@ -38,16 +36,24 @@ export declare class Sandbox {
|
|
|
38
36
|
readonly created_at?: string;
|
|
39
37
|
/** Timestamp when the sandbox was last updated. */
|
|
40
38
|
readonly updated_at?: string;
|
|
41
|
-
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
42
|
-
readonly ttl_seconds?: number;
|
|
43
39
|
/**
|
|
44
40
|
* Idle timeout TTL in seconds (`0` means disabled).
|
|
45
41
|
* New sandboxes receive a server-side default of `600` seconds (10 minutes)
|
|
46
|
-
* when the caller did not set `idleTtlSeconds` explicitly.
|
|
42
|
+
* when the caller did not set `idleTtlSeconds` explicitly. The launcher
|
|
43
|
+
* stops the sandbox after this many idle seconds.
|
|
47
44
|
*/
|
|
48
45
|
readonly idle_ttl_seconds?: number;
|
|
49
|
-
/**
|
|
50
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Seconds after the sandbox enters the `stopped` state before it (and
|
|
48
|
+
* its filesystem clone) are permanently deleted (`0` means disabled).
|
|
49
|
+
*/
|
|
50
|
+
readonly delete_after_stop_seconds?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Timestamp when the sandbox transitioned to `stopped`, or `undefined`
|
|
53
|
+
* while running. The deletion deadline is
|
|
54
|
+
* `stopped_at + delete_after_stop_seconds`.
|
|
55
|
+
*/
|
|
56
|
+
readonly stopped_at?: string;
|
|
51
57
|
/** Snapshot ID used to create this sandbox. */
|
|
52
58
|
readonly snapshot_id?: string;
|
|
53
59
|
/** Number of vCPUs allocated. */
|
|
@@ -22,8 +22,6 @@ import { reconnectWsStream, runWsStream } from "./ws_execute.js";
|
|
|
22
22
|
* await sandbox.delete();
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
25
|
-
*
|
|
26
|
-
* @experimental This feature is experimental, and breaking changes are expected.
|
|
27
25
|
*/
|
|
28
26
|
export class Sandbox {
|
|
29
27
|
/** @internal */
|
|
@@ -77,26 +75,34 @@ export class Sandbox {
|
|
|
77
75
|
writable: true,
|
|
78
76
|
value: void 0
|
|
79
77
|
});
|
|
80
|
-
/**
|
|
81
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Idle timeout TTL in seconds (`0` means disabled).
|
|
80
|
+
* New sandboxes receive a server-side default of `600` seconds (10 minutes)
|
|
81
|
+
* when the caller did not set `idleTtlSeconds` explicitly. The launcher
|
|
82
|
+
* stops the sandbox after this many idle seconds.
|
|
83
|
+
*/
|
|
84
|
+
Object.defineProperty(this, "idle_ttl_seconds", {
|
|
82
85
|
enumerable: true,
|
|
83
86
|
configurable: true,
|
|
84
87
|
writable: true,
|
|
85
88
|
value: void 0
|
|
86
89
|
});
|
|
87
90
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* when the caller did not set `idleTtlSeconds` explicitly.
|
|
91
|
+
* Seconds after the sandbox enters the `stopped` state before it (and
|
|
92
|
+
* its filesystem clone) are permanently deleted (`0` means disabled).
|
|
91
93
|
*/
|
|
92
|
-
Object.defineProperty(this, "
|
|
94
|
+
Object.defineProperty(this, "delete_after_stop_seconds", {
|
|
93
95
|
enumerable: true,
|
|
94
96
|
configurable: true,
|
|
95
97
|
writable: true,
|
|
96
98
|
value: void 0
|
|
97
99
|
});
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Timestamp when the sandbox transitioned to `stopped`, or `undefined`
|
|
102
|
+
* while running. The deletion deadline is
|
|
103
|
+
* `stopped_at + delete_after_stop_seconds`.
|
|
104
|
+
*/
|
|
105
|
+
Object.defineProperty(this, "stopped_at", {
|
|
100
106
|
enumerable: true,
|
|
101
107
|
configurable: true,
|
|
102
108
|
writable: true,
|
|
@@ -143,9 +149,9 @@ export class Sandbox {
|
|
|
143
149
|
this.id = data.id;
|
|
144
150
|
this.created_at = data.created_at;
|
|
145
151
|
this.updated_at = data.updated_at;
|
|
146
|
-
this.ttl_seconds = data.ttl_seconds;
|
|
147
152
|
this.idle_ttl_seconds = data.idle_ttl_seconds;
|
|
148
|
-
this.
|
|
153
|
+
this.delete_after_stop_seconds = data.delete_after_stop_seconds;
|
|
154
|
+
this.stopped_at = data.stopped_at ?? undefined;
|
|
149
155
|
this.snapshot_id = data.snapshot_id;
|
|
150
156
|
this.vCpus = data.vcpus;
|
|
151
157
|
this.mem_bytes = data.mem_bytes;
|
|
@@ -53,12 +53,24 @@ export interface SandboxData {
|
|
|
53
53
|
status_message?: string;
|
|
54
54
|
created_at?: string;
|
|
55
55
|
updated_at?: string;
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Idle timeout in seconds. The launcher stops the sandbox after this
|
|
58
|
+
* many seconds of inactivity. `0` disables the idle stop;
|
|
59
|
+
* omitted/`undefined` means not set (the server applies a default).
|
|
60
|
+
*/
|
|
59
61
|
idle_ttl_seconds?: number;
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Seconds after a sandbox enters the `stopped` state before it (and its
|
|
64
|
+
* filesystem clone) are permanently deleted. `0` disables stop-anchored
|
|
65
|
+
* deletion; omitted/`undefined` falls back to the server default.
|
|
66
|
+
*/
|
|
67
|
+
delete_after_stop_seconds?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Timestamp when the sandbox transitioned to the `stopped` state, or
|
|
70
|
+
* `undefined` while running. The deletion deadline is
|
|
71
|
+
* `stopped_at + delete_after_stop_seconds`.
|
|
72
|
+
*/
|
|
73
|
+
stopped_at?: string;
|
|
62
74
|
/** Snapshot ID used to create this sandbox. */
|
|
63
75
|
snapshot_id?: string;
|
|
64
76
|
/** Number of vCPUs allocated. */
|
|
@@ -243,8 +255,8 @@ export interface SandboxProxyConfig {
|
|
|
243
255
|
*/
|
|
244
256
|
export interface CreateSandboxOptions {
|
|
245
257
|
/**
|
|
246
|
-
*
|
|
247
|
-
* `snapshotId
|
|
258
|
+
* Optional snapshot name to boot from. Mutually exclusive with the positional
|
|
259
|
+
* `snapshotId`.
|
|
248
260
|
* Resolved server-side to a snapshot owned by the caller's tenant.
|
|
249
261
|
*/
|
|
250
262
|
snapshotName?: string;
|
|
@@ -264,16 +276,20 @@ export interface CreateSandboxOptions {
|
|
|
264
276
|
*/
|
|
265
277
|
waitForReady?: boolean;
|
|
266
278
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
279
|
+
* Idle timeout in seconds. The launcher stops the sandbox after this many
|
|
280
|
+
* seconds of inactivity. Must be a multiple of 60. Pass `0` to disable
|
|
281
|
+
* the idle stop. When omitted, the server applies a default of `600`
|
|
282
|
+
* seconds (10 minutes).
|
|
269
283
|
*/
|
|
270
|
-
|
|
284
|
+
idleTtlSeconds?: number;
|
|
271
285
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
286
|
+
* Seconds after the sandbox enters the `stopped` state before it (and
|
|
287
|
+
* its filesystem clone) are permanently deleted. Must be a multiple of
|
|
288
|
+
* 60. Pass `0` to disable stop-anchored deletion (manual cleanup
|
|
289
|
+
* required). When omitted, the server applies its configured default
|
|
290
|
+
* (typically 14 days).
|
|
275
291
|
*/
|
|
276
|
-
|
|
292
|
+
deleteAfterStopSeconds?: number;
|
|
277
293
|
/** Number of vCPUs. */
|
|
278
294
|
vCpus?: number;
|
|
279
295
|
/** Memory in bytes. */
|
|
@@ -363,21 +379,23 @@ export interface StartSandboxOptions {
|
|
|
363
379
|
signal?: AbortSignal;
|
|
364
380
|
}
|
|
365
381
|
/**
|
|
366
|
-
* Options for updating a sandbox (name and/or
|
|
382
|
+
* Options for updating a sandbox (name and/or retention settings).
|
|
367
383
|
*/
|
|
368
384
|
export interface UpdateSandboxOptions {
|
|
369
385
|
/** New display name. */
|
|
370
386
|
newName?: string;
|
|
371
387
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
388
|
+
* Idle timeout in seconds. Must be a multiple of 60. Pass `0` to disable
|
|
389
|
+
* the idle stop. Omit (or pass `undefined`) to leave the existing value
|
|
390
|
+
* unchanged.
|
|
374
391
|
*/
|
|
375
|
-
|
|
392
|
+
idleTtlSeconds?: number;
|
|
376
393
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
394
|
+
* Seconds after entering `stopped` before deletion. Must be a multiple
|
|
395
|
+
* of 60. Pass `0` to disable stop-anchored deletion. Omit (or pass
|
|
396
|
+
* `undefined`) to leave the existing value unchanged.
|
|
379
397
|
*/
|
|
380
|
-
|
|
398
|
+
deleteAfterStopSeconds?: number;
|
|
381
399
|
}
|
|
382
400
|
/**
|
|
383
401
|
* Options for waiting for a sandbox to become ready.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
5
|
"packageManager": "pnpm@10.33.0",
|
|
6
6
|
"files": [
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
"experimental/anthropic.js",
|
|
98
98
|
"experimental/anthropic.d.ts",
|
|
99
99
|
"experimental/anthropic.d.cts",
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
100
|
+
"sandbox.cjs",
|
|
101
|
+
"sandbox.js",
|
|
102
|
+
"sandbox.d.ts",
|
|
103
|
+
"sandbox.d.cts",
|
|
104
104
|
"index.cjs",
|
|
105
105
|
"index.js",
|
|
106
106
|
"index.d.ts",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"@ai-sdk/openai": "^3.0.0",
|
|
157
157
|
"@ai-sdk/provider": "^3.0.0",
|
|
158
158
|
"@anthropic-ai/claude-agent-sdk": "^0.2.83",
|
|
159
|
-
"@anthropic-ai/sdk": "^0.
|
|
159
|
+
"@anthropic-ai/sdk": "^0.94.0",
|
|
160
160
|
"@babel/preset-env": "^7.22.4",
|
|
161
161
|
"@faker-js/faker": "^8.4.1",
|
|
162
162
|
"@google/genai": "^1.29.0",
|
|
@@ -167,9 +167,9 @@
|
|
|
167
167
|
"@langchain/openai": "^0.6.17",
|
|
168
168
|
"@openai/agents": "^0.8.3",
|
|
169
169
|
"@opentelemetry/api": "^1.9.0",
|
|
170
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
170
|
+
"@opentelemetry/auto-instrumentations-node": "^0.75.0",
|
|
171
171
|
"@opentelemetry/context-async-hooks": "^2.6.1",
|
|
172
|
-
"@opentelemetry/sdk-node": "^0.
|
|
172
|
+
"@opentelemetry/sdk-node": "^0.217.0",
|
|
173
173
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
174
174
|
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
175
175
|
"@tsconfig/recommended": "^1.0.2",
|
|
@@ -446,14 +446,14 @@
|
|
|
446
446
|
"import": "./experimental/anthropic.js",
|
|
447
447
|
"require": "./experimental/anthropic.cjs"
|
|
448
448
|
},
|
|
449
|
-
"./
|
|
449
|
+
"./sandbox": {
|
|
450
450
|
"types": {
|
|
451
|
-
"import": "./
|
|
452
|
-
"require": "./
|
|
453
|
-
"default": "./
|
|
451
|
+
"import": "./sandbox.d.ts",
|
|
452
|
+
"require": "./sandbox.d.cts",
|
|
453
|
+
"default": "./sandbox.d.ts"
|
|
454
454
|
},
|
|
455
|
-
"import": "./
|
|
456
|
-
"require": "./
|
|
455
|
+
"import": "./sandbox.js",
|
|
456
|
+
"require": "./sandbox.cjs"
|
|
457
457
|
},
|
|
458
458
|
"./package.json": "./package.json"
|
|
459
459
|
},
|
package/sandbox.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/sandbox/index.cjs');
|
package/sandbox.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/sandbox/index.js'
|
package/sandbox.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/sandbox/index.js'
|
package/sandbox.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/sandbox/index.js'
|
package/experimental/sandbox.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/experimental/sandbox/index.cjs');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/experimental/sandbox/index.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/experimental/sandbox/index.js'
|
package/experimental/sandbox.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/experimental/sandbox/index.js'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|