langsmith 0.5.14 → 0.5.16
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/README.md +2 -2
- package/dist/client.cjs +4 -0
- package/dist/client.js +4 -0
- package/dist/experimental/sandbox/client.cjs +35 -13
- package/dist/experimental/sandbox/client.d.ts +12 -3
- package/dist/experimental/sandbox/client.js +36 -14
- package/dist/experimental/sandbox/helpers.cjs +22 -0
- package/dist/experimental/sandbox/helpers.d.ts +8 -0
- package/dist/experimental/sandbox/helpers.js +21 -0
- package/dist/experimental/sandbox/index.d.ts +1 -1
- package/dist/experimental/sandbox/sandbox.cjs +24 -0
- package/dist/experimental/sandbox/sandbox.d.ts +6 -0
- package/dist/experimental/sandbox/sandbox.js +24 -0
- package/dist/experimental/sandbox/types.d.ts +32 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/utils/fs.d.ts +1 -1
- package/dist/wrappers/anthropic.cjs +4 -0
- package/dist/wrappers/anthropic.d.ts +1 -0
- package/dist/wrappers/anthropic.js +4 -0
- package/dist/wrappers/gemini.cjs +1 -1
- package/dist/wrappers/gemini.js +1 -1
- package/package.json +18 -15
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains the TypeScript client for interacting with the [LangSmith
|
|
|
8
8
|
To install:
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
|
|
11
|
+
pnpm add langsmith
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
LangSmith helps you and your team develop and evaluate language models and intelligent agents. It is compatible with any LLM Application and provides seamless integration with [LangChain](https://github.com/hwchase17/langchainjs), a widely recognized open-source framework that simplifies the process for developers to create powerful language model applications.
|
|
@@ -43,7 +43,7 @@ You can log traces natively in your LangChain application or using a LangSmith R
|
|
|
43
43
|
LangSmith seamlessly integrates with the JavaScript LangChain library to record traces from your LLM applications.
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
|
|
46
|
+
pnpm add langchain
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
1. **Copy the environment variables from the Settings Page and add them to your application.**
|
package/dist/client.cjs
CHANGED
|
@@ -603,6 +603,10 @@ class Client {
|
|
|
603
603
|
this.webUrl = "https://eu.smith.langchain.com";
|
|
604
604
|
return this.webUrl;
|
|
605
605
|
}
|
|
606
|
+
else if (this.apiUrl.split(".", 1)[0].includes("aws")) {
|
|
607
|
+
this.webUrl = "https://aws.smith.langchain.com";
|
|
608
|
+
return this.webUrl;
|
|
609
|
+
}
|
|
606
610
|
else if (this.apiUrl.split(".", 1)[0].includes("beta")) {
|
|
607
611
|
this.webUrl = "https://beta.smith.langchain.com";
|
|
608
612
|
return this.webUrl;
|
package/dist/client.js
CHANGED
|
@@ -565,6 +565,10 @@ export class Client {
|
|
|
565
565
|
this.webUrl = "https://eu.smith.langchain.com";
|
|
566
566
|
return this.webUrl;
|
|
567
567
|
}
|
|
568
|
+
else if (this.apiUrl.split(".", 1)[0].includes("aws")) {
|
|
569
|
+
this.webUrl = "https://aws.smith.langchain.com";
|
|
570
|
+
return this.webUrl;
|
|
571
|
+
}
|
|
568
572
|
else if (this.apiUrl.split(".", 1)[0].includes("beta")) {
|
|
569
573
|
this.webUrl = "https://beta.smith.langchain.com";
|
|
570
574
|
return this.webUrl;
|
|
@@ -524,6 +524,7 @@ class SandboxClient {
|
|
|
524
524
|
* @returns Created Sandbox.
|
|
525
525
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
526
526
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
527
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
527
528
|
*
|
|
528
529
|
* @example
|
|
529
530
|
* ```typescript
|
|
@@ -537,7 +538,9 @@ class SandboxClient {
|
|
|
537
538
|
* ```
|
|
538
539
|
*/
|
|
539
540
|
async createSandbox(templateName, options = {}) {
|
|
540
|
-
const { name, timeout = 30, waitForReady = true } = options;
|
|
541
|
+
const { name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, } = options;
|
|
542
|
+
(0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
|
|
543
|
+
(0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
|
|
541
544
|
const url = `${this._baseUrl}/boxes`;
|
|
542
545
|
const payload = {
|
|
543
546
|
template_name: templateName,
|
|
@@ -549,6 +552,12 @@ class SandboxClient {
|
|
|
549
552
|
if (name) {
|
|
550
553
|
payload.name = name;
|
|
551
554
|
}
|
|
555
|
+
if (ttlSeconds !== undefined) {
|
|
556
|
+
payload.ttl_seconds = ttlSeconds;
|
|
557
|
+
}
|
|
558
|
+
if (idleTtlSeconds !== undefined) {
|
|
559
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
560
|
+
}
|
|
552
561
|
const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
|
|
553
562
|
const response = await this._fetch(url, {
|
|
554
563
|
method: "POST",
|
|
@@ -600,18 +609,29 @@ class SandboxClient {
|
|
|
600
609
|
const data = await response.json();
|
|
601
610
|
return (data.sandboxes ?? []).map((s) => new sandbox_js_1.Sandbox(s, this));
|
|
602
611
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
612
|
+
async updateSandbox(name, newNameOrOptions) {
|
|
613
|
+
const options = typeof newNameOrOptions === "string"
|
|
614
|
+
? { newName: newNameOrOptions }
|
|
615
|
+
: newNameOrOptions;
|
|
616
|
+
const { newName, ttlSeconds, idleTtlSeconds } = options;
|
|
617
|
+
(0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
|
|
618
|
+
(0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
|
|
619
|
+
if (newName === undefined &&
|
|
620
|
+
ttlSeconds === undefined &&
|
|
621
|
+
idleTtlSeconds === undefined) {
|
|
622
|
+
return this.getSandbox(name);
|
|
623
|
+
}
|
|
613
624
|
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
|
|
614
|
-
const payload = {
|
|
625
|
+
const payload = {};
|
|
626
|
+
if (newName !== undefined) {
|
|
627
|
+
payload.name = newName;
|
|
628
|
+
}
|
|
629
|
+
if (ttlSeconds !== undefined) {
|
|
630
|
+
payload.ttl_seconds = ttlSeconds;
|
|
631
|
+
}
|
|
632
|
+
if (idleTtlSeconds !== undefined) {
|
|
633
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
634
|
+
}
|
|
615
635
|
const response = await this._fetch(url, {
|
|
616
636
|
method: "PATCH",
|
|
617
637
|
headers: { "Content-Type": "application/json" },
|
|
@@ -622,7 +642,9 @@ class SandboxClient {
|
|
|
622
642
|
throw new errors_js_1.LangSmithResourceNotFoundError(`Sandbox '${name}' not found`, "sandbox");
|
|
623
643
|
}
|
|
624
644
|
if (response.status === 409) {
|
|
625
|
-
throw new errors_js_1.LangSmithResourceNameConflictError(
|
|
645
|
+
throw new errors_js_1.LangSmithResourceNameConflictError(newName !== undefined
|
|
646
|
+
? `Sandbox name '${newName}' already in use`
|
|
647
|
+
: "Sandbox update conflict (name may already be in use)", "sandbox");
|
|
626
648
|
}
|
|
627
649
|
await (0, helpers_js_1.handleClientHttpError)(response);
|
|
628
650
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main SandboxClient class for interacting with the sandbox server API.
|
|
3
3
|
*/
|
|
4
|
-
import type { CreatePoolOptions, CreateSandboxOptions, CreateTemplateOptions, CreateVolumeOptions, Pool, ResourceStatus, SandboxClientConfig, SandboxTemplate, UpdatePoolOptions, UpdateTemplateOptions, UpdateVolumeOptions, Volume, WaitForSandboxOptions } from "./types.js";
|
|
4
|
+
import type { CreatePoolOptions, CreateSandboxOptions, CreateTemplateOptions, CreateVolumeOptions, Pool, ResourceStatus, SandboxClientConfig, SandboxTemplate, UpdatePoolOptions, UpdateSandboxOptions, UpdateTemplateOptions, UpdateVolumeOptions, Volume, WaitForSandboxOptions } from "./types.js";
|
|
5
5
|
import { Sandbox } from "./sandbox.js";
|
|
6
6
|
/**
|
|
7
7
|
* Client for interacting with the Sandbox Server API.
|
|
@@ -191,6 +191,7 @@ export declare class SandboxClient {
|
|
|
191
191
|
* @returns Created Sandbox.
|
|
192
192
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
193
193
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
194
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
194
195
|
*
|
|
195
196
|
* @example
|
|
196
197
|
* ```typescript
|
|
@@ -225,11 +226,19 @@ export declare class SandboxClient {
|
|
|
225
226
|
*
|
|
226
227
|
* @param name - Current sandbox name.
|
|
227
228
|
* @param newName - New display name.
|
|
228
|
-
|
|
229
|
+
*/
|
|
230
|
+
updateSandbox(name: string, newName: string): Promise<Sandbox>;
|
|
231
|
+
/**
|
|
232
|
+
* Update a sandbox's name and/or TTL settings.
|
|
233
|
+
*
|
|
234
|
+
* @param name - Current sandbox name.
|
|
235
|
+
* @param options - Fields to update. Omit a field to leave it unchanged.
|
|
236
|
+
* @returns Updated Sandbox. If no fields are provided, returns the current sandbox.
|
|
229
237
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
230
238
|
* @throws LangSmithResourceNameConflictError if newName is already in use.
|
|
239
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
231
240
|
*/
|
|
232
|
-
updateSandbox(name: string,
|
|
241
|
+
updateSandbox(name: string, options: UpdateSandboxOptions): Promise<Sandbox>;
|
|
233
242
|
/**
|
|
234
243
|
* Delete a Sandbox.
|
|
235
244
|
*
|
|
@@ -6,7 +6,7 @@ import { _getFetchImplementation } from "../../singletons/fetch.js";
|
|
|
6
6
|
import { AsyncCaller } from "../../utils/async_caller.js";
|
|
7
7
|
import { Sandbox } from "./sandbox.js";
|
|
8
8
|
import { LangSmithResourceCreationError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, } from "./errors.js";
|
|
9
|
-
import { handleClientHttpError, handleConflictError, handlePoolError, handleResourceInUseError, handleSandboxCreationError, handleVolumeCreationError, } from "./helpers.js";
|
|
9
|
+
import { handleClientHttpError, handleConflictError, handlePoolError, handleResourceInUseError, handleSandboxCreationError, handleVolumeCreationError, validateTtl, } from "./helpers.js";
|
|
10
10
|
/**
|
|
11
11
|
* Get the default sandbox API endpoint from environment.
|
|
12
12
|
*
|
|
@@ -521,6 +521,7 @@ export class SandboxClient {
|
|
|
521
521
|
* @returns Created Sandbox.
|
|
522
522
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
523
523
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
524
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
524
525
|
*
|
|
525
526
|
* @example
|
|
526
527
|
* ```typescript
|
|
@@ -534,7 +535,9 @@ export class SandboxClient {
|
|
|
534
535
|
* ```
|
|
535
536
|
*/
|
|
536
537
|
async createSandbox(templateName, options = {}) {
|
|
537
|
-
const { name, timeout = 30, waitForReady = true } = options;
|
|
538
|
+
const { name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, } = options;
|
|
539
|
+
validateTtl(ttlSeconds, "ttlSeconds");
|
|
540
|
+
validateTtl(idleTtlSeconds, "idleTtlSeconds");
|
|
538
541
|
const url = `${this._baseUrl}/boxes`;
|
|
539
542
|
const payload = {
|
|
540
543
|
template_name: templateName,
|
|
@@ -546,6 +549,12 @@ export class SandboxClient {
|
|
|
546
549
|
if (name) {
|
|
547
550
|
payload.name = name;
|
|
548
551
|
}
|
|
552
|
+
if (ttlSeconds !== undefined) {
|
|
553
|
+
payload.ttl_seconds = ttlSeconds;
|
|
554
|
+
}
|
|
555
|
+
if (idleTtlSeconds !== undefined) {
|
|
556
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
557
|
+
}
|
|
549
558
|
const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
|
|
550
559
|
const response = await this._fetch(url, {
|
|
551
560
|
method: "POST",
|
|
@@ -597,18 +606,29 @@ export class SandboxClient {
|
|
|
597
606
|
const data = await response.json();
|
|
598
607
|
return (data.sandboxes ?? []).map((s) => new Sandbox(s, this));
|
|
599
608
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
609
|
+
async updateSandbox(name, newNameOrOptions) {
|
|
610
|
+
const options = typeof newNameOrOptions === "string"
|
|
611
|
+
? { newName: newNameOrOptions }
|
|
612
|
+
: newNameOrOptions;
|
|
613
|
+
const { newName, ttlSeconds, idleTtlSeconds } = options;
|
|
614
|
+
validateTtl(ttlSeconds, "ttlSeconds");
|
|
615
|
+
validateTtl(idleTtlSeconds, "idleTtlSeconds");
|
|
616
|
+
if (newName === undefined &&
|
|
617
|
+
ttlSeconds === undefined &&
|
|
618
|
+
idleTtlSeconds === undefined) {
|
|
619
|
+
return this.getSandbox(name);
|
|
620
|
+
}
|
|
610
621
|
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
|
|
611
|
-
const payload = {
|
|
622
|
+
const payload = {};
|
|
623
|
+
if (newName !== undefined) {
|
|
624
|
+
payload.name = newName;
|
|
625
|
+
}
|
|
626
|
+
if (ttlSeconds !== undefined) {
|
|
627
|
+
payload.ttl_seconds = ttlSeconds;
|
|
628
|
+
}
|
|
629
|
+
if (idleTtlSeconds !== undefined) {
|
|
630
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
631
|
+
}
|
|
612
632
|
const response = await this._fetch(url, {
|
|
613
633
|
method: "PATCH",
|
|
614
634
|
headers: { "Content-Type": "application/json" },
|
|
@@ -619,7 +639,9 @@ export class SandboxClient {
|
|
|
619
639
|
throw new LangSmithResourceNotFoundError(`Sandbox '${name}' not found`, "sandbox");
|
|
620
640
|
}
|
|
621
641
|
if (response.status === 409) {
|
|
622
|
-
throw new LangSmithResourceNameConflictError(
|
|
642
|
+
throw new LangSmithResourceNameConflictError(newName !== undefined
|
|
643
|
+
? `Sandbox name '${newName}' already in use`
|
|
644
|
+
: "Sandbox update conflict (name may already be in use)", "sandbox");
|
|
623
645
|
}
|
|
624
646
|
await handleClientHttpError(response);
|
|
625
647
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* exceptions. They contain no I/O operations.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.validateTtl = validateTtl;
|
|
9
10
|
exports.parseErrorResponse = parseErrorResponse;
|
|
10
11
|
exports.parseValidationError = parseValidationError;
|
|
11
12
|
exports.extractQuotaType = extractQuotaType;
|
|
@@ -17,6 +18,27 @@ exports.handleSandboxHttpError = handleSandboxHttpError;
|
|
|
17
18
|
exports.handleConflictError = handleConflictError;
|
|
18
19
|
exports.handleResourceInUseError = handleResourceInUseError;
|
|
19
20
|
const errors_js_1 = require("./errors.cjs");
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Input validation
|
|
23
|
+
// =============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Validate TTL values for sandbox create/update (minute resolution).
|
|
26
|
+
*
|
|
27
|
+
* @param value - TTL in seconds (`undefined` means unset; `0` disables).
|
|
28
|
+
* @param name - Parameter name for error messages.
|
|
29
|
+
* @throws LangSmithValidationError if negative or not a multiple of 60 (when non-zero).
|
|
30
|
+
*/
|
|
31
|
+
function validateTtl(value, name) {
|
|
32
|
+
if (value === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (value < 0) {
|
|
36
|
+
throw new errors_js_1.LangSmithValidationError(`${name} must be >= 0, got ${value}`, name);
|
|
37
|
+
}
|
|
38
|
+
if (value !== 0 && value % 60 !== 0) {
|
|
39
|
+
throw new errors_js_1.LangSmithValidationError(`${name} must be a multiple of 60 seconds, got ${value}`, name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
20
42
|
/**
|
|
21
43
|
* Parse standardized error response.
|
|
22
44
|
*
|
|
@@ -4,6 +4,14 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Validate TTL values for sandbox create/update (minute resolution).
|
|
9
|
+
*
|
|
10
|
+
* @param value - TTL in seconds (`undefined` means unset; `0` disables).
|
|
11
|
+
* @param name - Parameter name for error messages.
|
|
12
|
+
* @throws LangSmithValidationError if negative or not a multiple of 60 (when non-zero).
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateTtl(value: number | undefined, name: string): void;
|
|
7
15
|
interface ParsedError {
|
|
8
16
|
errorType?: string;
|
|
9
17
|
message: string;
|
|
@@ -5,6 +5,27 @@
|
|
|
5
5
|
* exceptions. They contain no I/O operations.
|
|
6
6
|
*/
|
|
7
7
|
import { LangSmithQuotaExceededError, LangSmithResourceAlreadyExistsError, LangSmithResourceInUseError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxError, LangSmithSandboxConnectionError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithValidationError, } from "./errors.js";
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Input validation
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Validate TTL values for sandbox create/update (minute resolution).
|
|
13
|
+
*
|
|
14
|
+
* @param value - TTL in seconds (`undefined` means unset; `0` disables).
|
|
15
|
+
* @param name - Parameter name for error messages.
|
|
16
|
+
* @throws LangSmithValidationError if negative or not a multiple of 60 (when non-zero).
|
|
17
|
+
*/
|
|
18
|
+
export function validateTtl(value, name) {
|
|
19
|
+
if (value === undefined) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (value < 0) {
|
|
23
|
+
throw new LangSmithValidationError(`${name} must be >= 0, got ${value}`, name);
|
|
24
|
+
}
|
|
25
|
+
if (value !== 0 && value % 60 !== 0) {
|
|
26
|
+
throw new LangSmithValidationError(`${name} must be a multiple of 60 seconds, got ${value}`, name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
8
29
|
/**
|
|
9
30
|
* Parse standardized error response.
|
|
10
31
|
*
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
export { SandboxClient } from "./client.js";
|
|
26
26
|
export { Sandbox } from "./sandbox.js";
|
|
27
27
|
export { CommandHandle } from "./command_handle.js";
|
|
28
|
-
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceSpec, ResourceStatus, VolumeMountSpec, Volume, SandboxTemplate, Pool, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, WaitForSandboxOptions, CreateVolumeOptions, CreateTemplateOptions, UpdateTemplateOptions, CreatePoolOptions, UpdateVolumeOptions, UpdatePoolOptions, } from "./types.js";
|
|
28
|
+
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceSpec, ResourceStatus, VolumeMountSpec, Volume, SandboxTemplate, Pool, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, CreateVolumeOptions, CreateTemplateOptions, UpdateTemplateOptions, CreatePoolOptions, UpdateVolumeOptions, UpdatePoolOptions, } from "./types.js";
|
|
29
29
|
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
|
@@ -85,6 +85,27 @@ class Sandbox {
|
|
|
85
85
|
writable: true,
|
|
86
86
|
value: void 0
|
|
87
87
|
});
|
|
88
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
89
|
+
Object.defineProperty(this, "ttl_seconds", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
95
|
+
/** Idle timeout TTL in seconds (`0` means disabled). */
|
|
96
|
+
Object.defineProperty(this, "idle_ttl_seconds", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
configurable: true,
|
|
99
|
+
writable: true,
|
|
100
|
+
value: void 0
|
|
101
|
+
});
|
|
102
|
+
/** Computed expiration timestamp when a TTL is active. */
|
|
103
|
+
Object.defineProperty(this, "expires_at", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: void 0
|
|
108
|
+
});
|
|
88
109
|
Object.defineProperty(this, "_client", {
|
|
89
110
|
enumerable: true,
|
|
90
111
|
configurable: true,
|
|
@@ -99,6 +120,9 @@ class Sandbox {
|
|
|
99
120
|
this.id = data.id;
|
|
100
121
|
this.created_at = data.created_at;
|
|
101
122
|
this.updated_at = data.updated_at;
|
|
123
|
+
this.ttl_seconds = data.ttl_seconds;
|
|
124
|
+
this.idle_ttl_seconds = data.idle_ttl_seconds;
|
|
125
|
+
this.expires_at = data.expires_at;
|
|
102
126
|
this._client = client;
|
|
103
127
|
}
|
|
104
128
|
/**
|
|
@@ -38,6 +38,12 @@ export declare class Sandbox {
|
|
|
38
38
|
readonly created_at?: string;
|
|
39
39
|
/** Timestamp when the sandbox was last updated. */
|
|
40
40
|
readonly updated_at?: string;
|
|
41
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
42
|
+
readonly ttl_seconds?: number;
|
|
43
|
+
/** Idle timeout TTL in seconds (`0` means disabled). */
|
|
44
|
+
readonly idle_ttl_seconds?: number;
|
|
45
|
+
/** Computed expiration timestamp when a TTL is active. */
|
|
46
|
+
readonly expires_at?: string;
|
|
41
47
|
private _client;
|
|
42
48
|
/**
|
|
43
49
|
* Validate and return the dataplane URL.
|
|
@@ -82,6 +82,27 @@ export class Sandbox {
|
|
|
82
82
|
writable: true,
|
|
83
83
|
value: void 0
|
|
84
84
|
});
|
|
85
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
86
|
+
Object.defineProperty(this, "ttl_seconds", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: void 0
|
|
91
|
+
});
|
|
92
|
+
/** Idle timeout TTL in seconds (`0` means disabled). */
|
|
93
|
+
Object.defineProperty(this, "idle_ttl_seconds", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
97
|
+
value: void 0
|
|
98
|
+
});
|
|
99
|
+
/** Computed expiration timestamp when a TTL is active. */
|
|
100
|
+
Object.defineProperty(this, "expires_at", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: void 0
|
|
105
|
+
});
|
|
85
106
|
Object.defineProperty(this, "_client", {
|
|
86
107
|
enumerable: true,
|
|
87
108
|
configurable: true,
|
|
@@ -96,6 +117,9 @@ export class Sandbox {
|
|
|
96
117
|
this.id = data.id;
|
|
97
118
|
this.created_at = data.created_at;
|
|
98
119
|
this.updated_at = data.updated_at;
|
|
120
|
+
this.ttl_seconds = data.ttl_seconds;
|
|
121
|
+
this.idle_ttl_seconds = data.idle_ttl_seconds;
|
|
122
|
+
this.expires_at = data.expires_at;
|
|
99
123
|
this._client = client;
|
|
100
124
|
}
|
|
101
125
|
/**
|
|
@@ -85,6 +85,12 @@ export interface SandboxData {
|
|
|
85
85
|
status_message?: string;
|
|
86
86
|
created_at?: string;
|
|
87
87
|
updated_at?: string;
|
|
88
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled, omitted/`undefined` means not set). */
|
|
89
|
+
ttl_seconds?: number;
|
|
90
|
+
/** Idle timeout TTL in seconds (`0` means disabled, omitted/`undefined` means not set). */
|
|
91
|
+
idle_ttl_seconds?: number;
|
|
92
|
+
/** Computed expiration timestamp when a TTL is active, else omitted/`undefined`. */
|
|
93
|
+
expires_at?: string;
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
96
|
* Configuration options for the SandboxClient.
|
|
@@ -248,6 +254,32 @@ export interface CreateSandboxOptions {
|
|
|
248
254
|
* Default: true.
|
|
249
255
|
*/
|
|
250
256
|
waitForReady?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Maximum lifetime in seconds from creation. The sandbox is deleted after
|
|
259
|
+
* this duration. Must be a multiple of 60, or `0`/`undefined` to disable or omit.
|
|
260
|
+
*/
|
|
261
|
+
ttlSeconds?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Idle timeout in seconds. The sandbox is deleted after this much inactivity.
|
|
264
|
+
* Must be a multiple of 60, or `0`/`undefined` to disable or omit.
|
|
265
|
+
*/
|
|
266
|
+
idleTtlSeconds?: number;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Options for updating a sandbox (name and/or TTL).
|
|
270
|
+
*/
|
|
271
|
+
export interface UpdateSandboxOptions {
|
|
272
|
+
/** New display name. */
|
|
273
|
+
newName?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Maximum lifetime in seconds from creation. Must be a multiple of 60.
|
|
276
|
+
* Pass `0` to disable absolute TTL.
|
|
277
|
+
*/
|
|
278
|
+
ttlSeconds?: number;
|
|
279
|
+
/**
|
|
280
|
+
* Idle timeout in seconds. Must be a multiple of 60. Pass `0` to disable.
|
|
281
|
+
*/
|
|
282
|
+
idleTtlSeconds?: number;
|
|
251
283
|
}
|
|
252
284
|
/**
|
|
253
285
|
* Options for waiting for a sandbox to become ready.
|
package/dist/index.cjs
CHANGED
|
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { r
|
|
|
17
17
|
Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function () { return index_js_1.PromptCache; } });
|
|
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
|
-
// Update using
|
|
21
|
-
exports.__version__ = "0.5.
|
|
20
|
+
// Update using pnpm bump-version
|
|
21
|
+
exports.__version__ = "0.5.16";
|
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.5.
|
|
8
|
+
export declare const __version__ = "0.5.16";
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
|
4
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
|
-
// Update using
|
|
8
|
-
export const __version__ = "0.5.
|
|
7
|
+
// Update using pnpm bump-version
|
|
8
|
+
export const __version__ = "0.5.16";
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* via the package.json browser field.
|
|
6
6
|
*/
|
|
7
7
|
import * as nodePath from "node:path";
|
|
8
|
-
export declare const path: nodePath
|
|
8
|
+
export declare const path: typeof nodePath;
|
|
9
9
|
export declare function mkdir(dir: string): Promise<void>;
|
|
10
10
|
export declare function writeFileAtomic(filePath: string, content: string): Promise<void>;
|
|
11
11
|
export declare function readdir(dir: string): Promise<string[]>;
|
|
@@ -325,6 +325,10 @@ const wrapAnthropic = (anthropic, options) => {
|
|
|
325
325
|
Object.assign(tracedBeta.messages, anthropic.beta.messages);
|
|
326
326
|
// Wrap beta.messages.create
|
|
327
327
|
tracedBeta.messages.create = (0, traceable_js_1.traceable)(anthropic.beta.messages.create.bind(anthropic.beta.messages), messagesCreateConfig);
|
|
328
|
+
// Wrap beta.messages.parse if it exists
|
|
329
|
+
if (typeof anthropic.beta.messages.parse === "function") {
|
|
330
|
+
tracedBeta.messages.parse = (0, traceable_js_1.traceable)(anthropic.beta.messages.parse.bind(anthropic.beta.messages), messagesCreateConfig);
|
|
331
|
+
}
|
|
328
332
|
// Wrap beta.messages.stream if it exists
|
|
329
333
|
if (typeof anthropic.beta.messages.stream === "function") {
|
|
330
334
|
tracedBeta.messages.stream = (0, traceable_js_1.traceable)(wrapStreamMethod(anthropic.beta.messages.stream.bind(anthropic.beta.messages)), {
|
|
@@ -6,6 +6,7 @@ import { KVMap } from "../schemas.js";
|
|
|
6
6
|
type ExtraRunTreeConfig = Pick<Partial<RunTreeConfig>, "name" | "metadata" | "tags">;
|
|
7
7
|
type MessagesNamespace = {
|
|
8
8
|
create: (...args: any[]) => any;
|
|
9
|
+
parse?: (...args: any[]) => any;
|
|
9
10
|
stream: (...args: any[]) => any;
|
|
10
11
|
};
|
|
11
12
|
type AnthropicType = {
|
|
@@ -321,6 +321,10 @@ export const wrapAnthropic = (anthropic, options) => {
|
|
|
321
321
|
Object.assign(tracedBeta.messages, anthropic.beta.messages);
|
|
322
322
|
// Wrap beta.messages.create
|
|
323
323
|
tracedBeta.messages.create = traceable(anthropic.beta.messages.create.bind(anthropic.beta.messages), messagesCreateConfig);
|
|
324
|
+
// Wrap beta.messages.parse if it exists
|
|
325
|
+
if (typeof anthropic.beta.messages.parse === "function") {
|
|
326
|
+
tracedBeta.messages.parse = traceable(anthropic.beta.messages.parse.bind(anthropic.beta.messages), messagesCreateConfig);
|
|
327
|
+
}
|
|
324
328
|
// Wrap beta.messages.stream if it exists
|
|
325
329
|
if (typeof anthropic.beta.messages.stream === "function") {
|
|
326
330
|
tracedBeta.messages.stream = traceable(wrapStreamMethod(anthropic.beta.messages.stream.bind(anthropic.beta.messages)), {
|
package/dist/wrappers/gemini.cjs
CHANGED
|
@@ -166,7 +166,7 @@ const chatAggregator = (input) => {
|
|
|
166
166
|
return result;
|
|
167
167
|
};
|
|
168
168
|
function processGeminiInputs(inputs) {
|
|
169
|
-
const { contents,
|
|
169
|
+
const { contents, ...rest } = inputs;
|
|
170
170
|
if (!contents)
|
|
171
171
|
return inputs;
|
|
172
172
|
if (typeof contents === "string") {
|
package/dist/wrappers/gemini.js
CHANGED
|
@@ -163,7 +163,7 @@ const chatAggregator = (input) => {
|
|
|
163
163
|
return result;
|
|
164
164
|
};
|
|
165
165
|
function processGeminiInputs(inputs) {
|
|
166
|
-
const { contents,
|
|
166
|
+
const { contents, ...rest } = inputs;
|
|
167
167
|
if (!contents)
|
|
168
168
|
return inputs;
|
|
169
169
|
if (typeof contents === "string") {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.16",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
|
-
"packageManager": "
|
|
5
|
+
"packageManager": "pnpm@10.33.0",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/",
|
|
8
8
|
"client.cjs",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"main": "./dist/index.js",
|
|
107
107
|
"types": "./dist/index.d.ts",
|
|
108
108
|
"scripts": {
|
|
109
|
-
"build": "
|
|
110
|
-
"build:typedoc": "
|
|
109
|
+
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs && node scripts/create-entrypoints.js",
|
|
110
|
+
"build:typedoc": "pnpm build && rm -rf ./_build/api_refs && npx typedoc",
|
|
111
111
|
"bump-version": "node scripts/bump-version.js",
|
|
112
112
|
"check-version": "node scripts/check-version.js",
|
|
113
113
|
"check-npm-version": "node scripts/check-npm-version.js",
|
|
@@ -116,17 +116,17 @@
|
|
|
116
116
|
"build:cjs": "echo '{}' > src/package.json && tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rm -r dist-cjs src/package.json",
|
|
117
117
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests --testPathIgnorePatterns='\\.int\\.test.[tj]s' --testTimeout 30000",
|
|
118
118
|
"test:integration": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000",
|
|
119
|
-
"test:single": "NODE_OPTIONS=--experimental-vm-modules
|
|
120
|
-
"watch:single": "NODE_OPTIONS=--experimental-vm-modules
|
|
119
|
+
"test:single": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --config jest.config.cjs --testTimeout 100000",
|
|
120
|
+
"watch:single": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --watch --config jest.config.cjs --testTimeout 100000",
|
|
121
121
|
"test:vitest": "vitest run --config vitest.config.ts",
|
|
122
122
|
"test:eval:vitest": "vitest run --config ls.vitest.config.ts",
|
|
123
123
|
"lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
124
|
-
"lint:fix": "
|
|
124
|
+
"lint:fix": "pnpm lint --fix",
|
|
125
125
|
"format": "prettier --write 'src/**/*.{ts,tsx,mts}'",
|
|
126
126
|
"format:check": "prettier --check 'src/**/*.{ts,tsx,mts}'",
|
|
127
127
|
"check:types": "tsc --noEmit",
|
|
128
128
|
"precommit": "lint-staged",
|
|
129
|
-
"prepublish": "
|
|
129
|
+
"prepublish": "pnpm run build"
|
|
130
130
|
},
|
|
131
131
|
"repository": {
|
|
132
132
|
"type": "git",
|
|
@@ -145,7 +145,6 @@
|
|
|
145
145
|
},
|
|
146
146
|
"homepage": "https://github.com/langchain-ai/langsmith-sdk#readme",
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@types/uuid": "^10.0.0",
|
|
149
148
|
"chalk": "^5.6.2",
|
|
150
149
|
"console-table-printer": "^2.12.1",
|
|
151
150
|
"p-queue": "^6.6.2",
|
|
@@ -157,7 +156,7 @@
|
|
|
157
156
|
"@ai-sdk/openai": "^3.0.0",
|
|
158
157
|
"@ai-sdk/provider": "^3.0.0",
|
|
159
158
|
"@anthropic-ai/claude-agent-sdk": "^0.2.83",
|
|
160
|
-
"@anthropic-ai/sdk": "^0.
|
|
159
|
+
"@anthropic-ai/sdk": "^0.80.0",
|
|
161
160
|
"@babel/preset-env": "^7.22.4",
|
|
162
161
|
"@faker-js/faker": "^8.4.1",
|
|
163
162
|
"@google/genai": "^1.29.0",
|
|
@@ -167,13 +166,16 @@
|
|
|
167
166
|
"@langchain/langgraph": "^0.3.6",
|
|
168
167
|
"@langchain/openai": "^0.5.16",
|
|
169
168
|
"@opentelemetry/api": "^1.9.0",
|
|
170
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
171
|
-
"@opentelemetry/
|
|
169
|
+
"@opentelemetry/auto-instrumentations-node": "^0.72.0",
|
|
170
|
+
"@opentelemetry/context-async-hooks": "^2.6.1",
|
|
171
|
+
"@opentelemetry/sdk-node": "^0.214.0",
|
|
172
172
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
173
173
|
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
174
174
|
"@tsconfig/recommended": "^1.0.2",
|
|
175
175
|
"@types/jest": "^29.5.1",
|
|
176
176
|
"@types/node-fetch": "^2.6.12",
|
|
177
|
+
"@types/semver": "^7.7.1",
|
|
178
|
+
"@types/uuid": "^10.0.0",
|
|
177
179
|
"@types/ws": "^8.18.1",
|
|
178
180
|
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
179
181
|
"@typescript-eslint/parser": "^5.59.8",
|
|
@@ -450,9 +452,10 @@
|
|
|
450
452
|
},
|
|
451
453
|
"./package.json": "./package.json"
|
|
452
454
|
},
|
|
453
|
-
"
|
|
454
|
-
"
|
|
455
|
-
|
|
455
|
+
"pnpm": {
|
|
456
|
+
"overrides": {
|
|
457
|
+
"js-yaml": "^4.1.1"
|
|
458
|
+
}
|
|
456
459
|
},
|
|
457
460
|
"browser": {
|
|
458
461
|
"./dist/utils/fs.js": "./dist/utils/fs.browser.js"
|