New:Socket for Asana Is Now Available.Learn more
Get Started

langsmith

Package Overview
Dependencies
Maintainers
5
Versions
449
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

langsmith - npm Package Compare versions

Comparing version
0.8.11
to
0.8.12
+6
-0
dist/_openapi_client/resources/issues.d.ts

@@ -24,2 +24,8 @@ import { APIResource } from '../core/resource.js';

actions?: unknown;
auto_resolution_evidence?: unknown;
/**
* Nil unless eligible: "auto_close" or "prompt". Evidence carries the deciding
* gate.
*/
auto_resolution_state?: string;
created_at?: string;

@@ -26,0 +32,0 @@ description?: string;

+2
-2

@@ -63,4 +63,4 @@ "use strict";

* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
* session_id, or dataset_id is required. resource_id, type, and feedback_key may
* be supplied with group_by to narrow listing aggregations.
* session_id, or dataset_id is required. resource_id, type, feedback_key, and
* tag_value_id may be supplied with group_by to narrow listing aggregations.
*/

@@ -67,0 +67,0 @@ spend(query, options) {

@@ -37,4 +37,4 @@ import { APIResource } from '../core/resource.js';

* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
* session_id, or dataset_id is required. resource_id, type, and feedback_key may
* be supplied with group_by to narrow listing aggregations.
* session_id, or dataset_id is required. resource_id, type, feedback_key, and
* tag_value_id may be supplied with group_by to narrow listing aggregations.
*/

@@ -291,2 +291,7 @@ spend(query: OnlineEvaluatorSpendParams, options?: RequestOptions): APIPromise<GetOnlineEvaluatorSpendResponse>;

/**
* Filter grouped results to evaluators, projects, or datasets tagged with all
* supplied tag value IDs. Only valid with group_by.
*/
tag_value_id?: Array<string>;
/**
* Filter grouped results by evaluator type: 'llm' or 'code'. Only valid with

@@ -293,0 +298,0 @@ * group_by.

@@ -60,4 +60,4 @@ // @ts-nocheck

* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
* session_id, or dataset_id is required. resource_id, type, and feedback_key may
* be supplied with group_by to narrow listing aggregations.
* session_id, or dataset_id is required. resource_id, type, feedback_key, and
* tag_value_id may be supplied with group_by to narrow listing aggregations.
*/

@@ -64,0 +64,0 @@ spend(query, options) {

@@ -72,3 +72,3 @@ import { APIResource } from '../../core/resource.js';

/**
* Header param: application/json
* Header param: application/json or text/event-stream
*/

@@ -75,0 +75,0 @@ Accept?: string;

@@ -13,2 +13,4 @@ "use strict";

* `snapshot_name`; if neither is provided, the server uses the default snapshot.
* `snapshot_name` accepts a Docker-style `name` or `name:tag` reference (a bare
* name resolves to `name:latest`).
*/

@@ -15,0 +17,0 @@ create(body, options) {

@@ -9,2 +9,4 @@ import { APIResource } from '../../core/resource.js';

* `snapshot_name`; if neither is provided, the server uses the default snapshot.
* `snapshot_name` accepts a Docker-style `name` or `name:tag` reference (a bare
* name resolves to `name:latest`).
*/

@@ -76,2 +78,8 @@ create(body: BoxCreateParams, options?: RequestOptions): APIPromise<SandboxesAPI.SandboxResponse>;

};
/**
* Memory for the sandbox, in bytes. Memory is tied to CPU at 4 GiB per vCPU: omit
* it and it follows that ratio; set it and it must stay within 50% of the ratio
* for the requested CPU, so a 1 vCPU sandbox accepts 2-6 GiB. Setting memory
* without CPU derives the CPU from the same ratio. Maximum 64 GiB.
*/
mem_bytes?: number;

@@ -99,3 +107,12 @@ mount_config?: BoxCreateParams.MountConfig;

restore_memory?: boolean;
/**
* Snapshot is a Docker-style name or name:tag reference to boot from. A bare name
* resolves to name:latest.
*/
snapshot?: string;
snapshot_id?: string;
/**
* SnapshotName is a synonym for Snapshot, accepted for compatibility with clients
* that predate it. Set one or the other.
*/
snapshot_name?: string;

@@ -445,2 +462,6 @@ tag_value_ids?: Array<string>;

idle_ttl_seconds?: number;
/**
* New memory for the sandbox, in bytes. The 4 GiB per vCPU ratio applies when the
* sandbox is created; a resize enforces only the maximum of 64 GiB.
*/
mem_bytes?: number;

@@ -603,2 +624,6 @@ name?: string;

};
/**
* mutable Docker-style tag; defaults to "latest"
*/
tag?: string;
}

@@ -605,0 +630,0 @@ export interface BoxGenerateServiceURLParams {

@@ -10,2 +10,4 @@ // @ts-nocheck

* `snapshot_name`; if neither is provided, the server uses the default snapshot.
* `snapshot_name` accepts a Docker-style `name` or `name:tag` reference (a bare
* name resolves to `name:latest`).
*/

@@ -12,0 +14,0 @@ create(body, options) {

@@ -7,3 +7,3 @@ import { APIResource } from '../../core/resource.js';

import * as SnapshotsAPI from './snapshots.js';
import { SnapshotCreateParams, SnapshotListParams, Snapshots } from './snapshots.js';
import { SnapshotCreateParams, SnapshotListParams, SnapshotRetrieveByNameResponse, Snapshots } from './snapshots.js';
export declare class Sandboxes extends APIResource {

@@ -415,2 +415,7 @@ boxes: BoxesAPI.Boxes;

status_message?: string;
/**
* Tags currently resolving to this snapshot, under Name. A snapshot with no tags
* is dangling — addressable only by id.
*/
tags?: Array<string>;
updated_at?: string;

@@ -422,3 +427,3 @@ }

export { Registries as Registries, type RegistryListResponse as RegistryListResponse, type RegistryResponse as RegistryResponse, type RegistryCreateParams as RegistryCreateParams, type RegistryUpdateParams as RegistryUpdateParams, type RegistryListParams as RegistryListParams, };
export { Snapshots as Snapshots, type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams, };
export { Snapshots as Snapshots, type SnapshotRetrieveByNameResponse as SnapshotRetrieveByNameResponse, type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams, };
}

@@ -9,3 +9,3 @@ // @ts-nocheck

import * as SnapshotsAPI from './snapshots.js';
import { Snapshots } from './snapshots.js';
import { Snapshots, } from './snapshots.js';
export class Sandboxes extends APIResource {

@@ -12,0 +12,0 @@ constructor() {

@@ -17,3 +17,5 @@ "use strict";

/**
* Get a sandbox snapshot by ID.
* Get a sandbox snapshot by ID or by a Docker-style reference. A bare name means
* name:latest, falling back to the newest ready untagged snapshot of that name. To
* list the tags under a name, use /api/v2/sandboxes/snapshots-by-name/{name}.
*/

@@ -31,3 +33,4 @@ retrieve(snapshotID, options) {

/**
* Delete a snapshot by ID. The underlying storage is reclaimed asynchronously.
* Delete a snapshot by ID or by a Docker-style name[:tag] reference. The
* underlying storage is reclaimed asynchronously.
*/

@@ -40,3 +43,10 @@ delete(snapshotID, options) {

}
/**
* Get a snapshot name and every tag under it, with the snapshot each tag resolves
* to. To fetch one snapshot, use /api/v2/sandboxes/snapshots/{snapshot_id}.
*/
retrieveByName(name, options) {
return this._client.get((0, path_js_1.path) `/api/v2/sandboxes/snapshots-by-name/${name}`, options);
}
}
exports.Snapshots = Snapshots;

@@ -11,3 +11,5 @@ import { APIResource } from '../../core/resource.js';

/**
* Get a sandbox snapshot by ID.
* Get a sandbox snapshot by ID or by a Docker-style reference. A bare name means
* name:latest, falling back to the newest ready untagged snapshot of that name. To
* list the tags under a name, use /api/v2/sandboxes/snapshots-by-name/{name}.
*/

@@ -21,6 +23,22 @@ retrieve(snapshotID: string, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotResponse>;

/**
* Delete a snapshot by ID. The underlying storage is reclaimed asynchronously.
* Delete a snapshot by ID or by a Docker-style name[:tag] reference. The
* underlying storage is reclaimed asynchronously.
*/
delete(snapshotID: string, options?: RequestOptions): APIPromise<void>;
/**
* Get a snapshot name and every tag under it, with the snapshot each tag resolves
* to. To fetch one snapshot, use /api/v2/sandboxes/snapshots/{snapshot_id}.
*/
retrieveByName(name: string, options?: RequestOptions): APIPromise<SnapshotRetrieveByNameResponse>;
}
export interface SnapshotRetrieveByNameResponse {
name?: string;
tags?: Array<SnapshotRetrieveByNameResponse.Tag>;
}
export declare namespace SnapshotRetrieveByNameResponse {
interface Tag {
snapshot_id?: string;
tag?: string;
}
}
export interface SnapshotCreateParams {

@@ -38,2 +56,6 @@ docker_image: string;

registry_id?: string;
/**
* mutable Docker-style tag; defaults to "latest"
*/
tag?: string;
}

@@ -76,3 +98,3 @@ export interface SnapshotListParams {

export declare namespace Snapshots {
export { type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams };
export { type SnapshotRetrieveByNameResponse as SnapshotRetrieveByNameResponse, type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams, };
}

@@ -14,3 +14,5 @@ // @ts-nocheck

/**
* Get a sandbox snapshot by ID.
* Get a sandbox snapshot by ID or by a Docker-style reference. A bare name means
* name:latest, falling back to the newest ready untagged snapshot of that name. To
* list the tags under a name, use /api/v2/sandboxes/snapshots-by-name/{name}.
*/

@@ -28,3 +30,4 @@ retrieve(snapshotID, options) {

/**
* Delete a snapshot by ID. The underlying storage is reclaimed asynchronously.
* Delete a snapshot by ID or by a Docker-style name[:tag] reference. The
* underlying storage is reclaimed asynchronously.
*/

@@ -37,2 +40,9 @@ delete(snapshotID, options) {

}
/**
* Get a snapshot name and every tag under it, with the snapshot each tag resolves
* to. To fetch one snapshot, use /api/v2/sandboxes/snapshots/{snapshot_id}.
*/
retrieveByName(name, options) {
return this._client.get(path `/api/v2/sandboxes/snapshots-by-name/${name}`, options);
}
}

@@ -31,3 +31,3 @@ "use strict";

* Query threads within a project (session), with cursor-based pagination. Returns
* threads matching the given time range and optional filter.
* threads matching the given time range and optional filters.
*

@@ -34,0 +34,0 @@ * Self-hosted deployments require LangSmith `v0.16` or later.

@@ -25,3 +25,3 @@ import { APIResource } from '../core/resource.js';

* Query threads within a project (session), with cursor-based pagination. Returns
* threads matching the given time range and optional filter.
* threads matching the given time range and optional filters.
*

@@ -662,2 +662,27 @@ * Self-hosted deployments require LangSmith `v0.16` or later.

project_id?: string;
/**
* `thread_filter` narrows results using a LangSmith filter expression evaluated
* against each complete thread summary. Self-hosted deployments require LangSmith
* v0.17 or later; unsupported deployments return 501. See
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
* for syntax.
*/
thread_filter?: string;
/**
* `trace_filter` narrows results to threads containing at least one trace whose
* root run matches this LangSmith filter expression. Trace-level aggregate fields
* are evaluated using the complete trace summary. Self-hosted deployments require
* LangSmith v0.17 or later; unsupported deployments return 501. See
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
* for syntax.
*/
trace_filter?: string;
/**
* `tree_filter` narrows results to threads containing at least one trace with a
* matching run anywhere in its run tree. Self-hosted deployments require LangSmith
* v0.17 or later; unsupported deployments return 501. See
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
* for syntax.
*/
tree_filter?: string;
}

@@ -664,0 +689,0 @@ export interface ThreadStatsParams {

@@ -28,3 +28,3 @@ // @ts-nocheck

* Query threads within a project (session), with cursor-based pagination. Returns
* threads matching the given time range and optional filter.
* threads matching the given time range and optional filters.
*

@@ -31,0 +31,0 @@ * Self-hosted deployments require LangSmith `v0.16` or later.

@@ -38,4 +38,4 @@ "use strict";

// Update using pnpm bump-version
exports.__version__ = "0.8.11";
exports.__version__ = "0.8.12";
// Metadata key to hide a traced run from LangSmith's Messages View.
exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";

@@ -10,3 +10,3 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from "./client.js";

export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
export declare const __version__ = "0.8.11";
export declare const __version__ = "0.8.12";
export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";

@@ -10,4 +10,4 @@ export { Client, } from "./client.js";

// Update using pnpm bump-version
export const __version__ = "0.8.11";
export const __version__ = "0.8.12";
// Metadata key to hide a traced run from LangSmith's Messages View.
export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";

@@ -406,2 +406,6 @@ "use strict";

*/
_boxUrl(name, ...segments) {
const suffix = segments.length ? `/${segments.join("/")}` : "";
return `${this._baseUrl}/boxes/${encodeURIComponent(name)}${suffix}`;
}
async _postJson(url, body, options) {

@@ -491,3 +495,3 @@ const response = await this._fetch(url, {

async getSandbox(name, options) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
const url = this._boxUrl(name);
const response = await this._fetch(url, { signal: options?.signal });

@@ -532,3 +536,3 @@ if (!response.ok) {

}
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
const url = this._boxUrl(name);
const payload = {};

@@ -570,3 +574,3 @@ if (newName !== undefined) {

async deleteSandbox(name) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
const url = this._boxUrl(name);
const response = await this._fetch(url, { method: "DELETE" });

@@ -591,3 +595,3 @@ if (!response.ok) {

async getSandboxStatus(name, options) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}/status`;
const url = this._boxUrl(name, "status");
const response = await this._fetch(url, { signal: options?.signal });

@@ -655,3 +659,3 @@ if (!response.ok) {

const { timeout = 120, signal } = options;
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}/start`;
const url = this._boxUrl(name, "start");
await this._postJson(url, {}, { signal });

@@ -661,2 +665,46 @@ return this.waitForSandbox(name, { timeout, signal });

/**
* Create a link that downloads one file from a sandbox.
*
* The link carries its own token, so anyone holding the URL can fetch that
* one file without a LangSmith credential. It is pinned to the sandbox and
* the exact path and cannot be repointed at another file. Fetching wakes a
* stopped sandbox.
*
* Do not modify the file after minting a link for it. The link is pinned to
* a path, not to a snapshot of the contents, so a later write to that path
* may or may not be reflected in what the link serves. Write a new file and
* mint a new link when the contents change.
*
* @param name - Sandbox name.
* @param path - File path inside the sandbox.
* @param options - Expiry and response header overrides.
* @returns The link and its expiry, if any.
*
* @example
* ```typescript
* const link = await client.generateDownloadURL("my-vm", "/tmp/report.pdf");
* console.log(link.download_url);
* ```
*/
async generateDownloadURL(name, path, options = {}) {
const { expiresInSeconds, contentType, contentDisposition, signal } = options;
if (expiresInSeconds !== undefined && expiresInSeconds < 1) {
throw new errors_js_1.LangSmithValidationError(`expiresInSeconds must be greater than 0 (got ${expiresInSeconds}); ` +
`omit it for a link that never expires`);
}
const url = this._boxUrl(name, "download-url");
const payload = { path };
if (expiresInSeconds !== undefined) {
payload.expires_in_seconds = expiresInSeconds;
}
if (contentType !== undefined) {
payload.content_type = contentType;
}
if (contentDisposition !== undefined) {
payload.content_disposition = contentDisposition;
}
const response = await this._postJson(url, payload, { signal });
return (await response.json());
}
/**
* Stop a running sandbox (preserves sandbox files for later restart).

@@ -667,3 +715,3 @@ *

async stopSandbox(name) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}/stop`;
const url = this._boxUrl(name, "stop");
await this._postJson(url, {});

@@ -789,3 +837,3 @@ }

const { dockerImage, fsCapacityBytes, timeout = 60, signal } = options;
const url = `${this._baseUrl}/boxes/${encodeURIComponent(sandboxName)}/snapshot`;
const url = this._boxUrl(sandboxName, "snapshot");
const payload = { name };

@@ -792,0 +840,0 @@ if (dockerImage !== undefined) {

@@ -5,3 +5,3 @@ /**

import { Registries } from "../_openapi_client/resources/sandboxes/registries.js";
import type { CaptureSnapshotOptions, CreateDockerfileSnapshotOptions, CreateSandboxOptions, CreateSnapshotOptions, ListSnapshotsOptions, ResourceStatus, SandboxClientConfig, Snapshot, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, WaitForSnapshotOptions } from "./types.js";
import type { CaptureSnapshotOptions, CreateDockerfileSnapshotOptions, CreateSandboxOptions, CreateSnapshotOptions, DownloadURL, GenerateDownloadURLOptions, ListSnapshotsOptions, ResourceStatus, SandboxClientConfig, Snapshot, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, WaitForSnapshotOptions } from "./types.js";
import { Sandbox } from "./sandbox.js";

@@ -68,2 +68,3 @@ /**

get registries(): Registries;
private _postJson;
/**

@@ -187,2 +188,27 @@ * Create a new Sandbox.

/**
* Create a link that downloads one file from a sandbox.
*
* The link carries its own token, so anyone holding the URL can fetch that
* one file without a LangSmith credential. It is pinned to the sandbox and
* the exact path and cannot be repointed at another file. Fetching wakes a
* stopped sandbox.
*
* Do not modify the file after minting a link for it. The link is pinned to
* a path, not to a snapshot of the contents, so a later write to that path
* may or may not be reflected in what the link serves. Write a new file and
* mint a new link when the contents change.
*
* @param name - Sandbox name.
* @param path - File path inside the sandbox.
* @param options - Expiry and response header overrides.
* @returns The link and its expiry, if any.
*
* @example
* ```typescript
* const link = await client.generateDownloadURL("my-vm", "/tmp/report.pdf");
* console.log(link.download_url);
* ```
*/
generateDownloadURL(name: string, path: string, options?: GenerateDownloadURLOptions): Promise<DownloadURL>;
/**
* Stop a running sandbox (preserves sandbox files for later restart).

@@ -189,0 +215,0 @@ *

@@ -403,2 +403,6 @@ /**

*/
_boxUrl(name, ...segments) {
const suffix = segments.length ? `/${segments.join("/")}` : "";
return `${this._baseUrl}/boxes/${encodeURIComponent(name)}${suffix}`;
}
async _postJson(url, body, options) {

@@ -488,3 +492,3 @@ const response = await this._fetch(url, {

async getSandbox(name, options) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
const url = this._boxUrl(name);
const response = await this._fetch(url, { signal: options?.signal });

@@ -529,3 +533,3 @@ if (!response.ok) {

}
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
const url = this._boxUrl(name);
const payload = {};

@@ -567,3 +571,3 @@ if (newName !== undefined) {

async deleteSandbox(name) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
const url = this._boxUrl(name);
const response = await this._fetch(url, { method: "DELETE" });

@@ -588,3 +592,3 @@ if (!response.ok) {

async getSandboxStatus(name, options) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}/status`;
const url = this._boxUrl(name, "status");
const response = await this._fetch(url, { signal: options?.signal });

@@ -652,3 +656,3 @@ if (!response.ok) {

const { timeout = 120, signal } = options;
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}/start`;
const url = this._boxUrl(name, "start");
await this._postJson(url, {}, { signal });

@@ -658,2 +662,46 @@ return this.waitForSandbox(name, { timeout, signal });

/**
* Create a link that downloads one file from a sandbox.
*
* The link carries its own token, so anyone holding the URL can fetch that
* one file without a LangSmith credential. It is pinned to the sandbox and
* the exact path and cannot be repointed at another file. Fetching wakes a
* stopped sandbox.
*
* Do not modify the file after minting a link for it. The link is pinned to
* a path, not to a snapshot of the contents, so a later write to that path
* may or may not be reflected in what the link serves. Write a new file and
* mint a new link when the contents change.
*
* @param name - Sandbox name.
* @param path - File path inside the sandbox.
* @param options - Expiry and response header overrides.
* @returns The link and its expiry, if any.
*
* @example
* ```typescript
* const link = await client.generateDownloadURL("my-vm", "/tmp/report.pdf");
* console.log(link.download_url);
* ```
*/
async generateDownloadURL(name, path, options = {}) {
const { expiresInSeconds, contentType, contentDisposition, signal } = options;
if (expiresInSeconds !== undefined && expiresInSeconds < 1) {
throw new LangSmithValidationError(`expiresInSeconds must be greater than 0 (got ${expiresInSeconds}); ` +
`omit it for a link that never expires`);
}
const url = this._boxUrl(name, "download-url");
const payload = { path };
if (expiresInSeconds !== undefined) {
payload.expires_in_seconds = expiresInSeconds;
}
if (contentType !== undefined) {
payload.content_type = contentType;
}
if (contentDisposition !== undefined) {
payload.content_disposition = contentDisposition;
}
const response = await this._postJson(url, payload, { signal });
return (await response.json());
}
/**
* Stop a running sandbox (preserves sandbox files for later restart).

@@ -664,3 +712,3 @@ *

async stopSandbox(name) {
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}/stop`;
const url = this._boxUrl(name, "stop");
await this._postJson(url, {});

@@ -786,3 +834,3 @@ }

const { dockerImage, fsCapacityBytes, timeout = 60, signal } = options;
const url = `${this._baseUrl}/boxes/${encodeURIComponent(sandboxName)}/snapshot`;
const url = this._boxUrl(sandboxName, "snapshot");
const payload = { name };

@@ -789,0 +837,0 @@ if (dockerImage !== undefined) {

@@ -10,3 +10,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectTimeoutError = exports.LangSmithStreamEndedBeforeStartedError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = void 0;
exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectTimeoutError = exports.LangSmithStreamEndedBeforeStartedError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxRetryableConnectionError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = void 0;
/**

@@ -57,2 +57,15 @@ * Base exception for sandbox client errors.

exports.LangSmithSandboxConnectionError = LangSmithSandboxConnectionError;
/**
* Raised when a transient connection failure occurs before a command starts.
*
* `run()` retries this error with the same command ID so the server can
* deduplicate an attempt whose outcome is unknown.
*/
class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
constructor(message) {
super(message);
this.name = "LangSmithSandboxRetryableConnectionError";
}
}
exports.LangSmithSandboxRetryableConnectionError = LangSmithSandboxRetryableConnectionError;
// =============================================================================

@@ -380,8 +393,6 @@ // Resource Errors (type-based, with resourceType property)

*
* Distinct from its parent because it is safely retryable: the execute frame
* was never sent, so re-issuing the same command_id cannot double-run a
* command. run() retries this with backoff; a plain connection error (a
* rejected handshake) is permanent and propagates immediately.
* The execute frame was never sent, so re-issuing the same command ID cannot
* double-run a command.
*/
class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxConnectionError {
class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxRetryableConnectionError {
constructor(message) {

@@ -388,0 +399,0 @@ super(message);

@@ -35,2 +35,11 @@ /**

/**
* Raised when a transient connection failure occurs before a command starts.
*
* `run()` retries this error with the same command ID so the server can
* deduplicate an attempt whose outcome is unknown.
*/
export declare class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
constructor(message: string);
}
/**
* Raised when a resource is not found.

@@ -172,8 +181,6 @@ */

*
* Distinct from its parent because it is safely retryable: the execute frame
* was never sent, so re-issuing the same command_id cannot double-run a
* command. run() retries this with backoff; a plain connection error (a
* rejected handshake) is permanent and propagates immediately.
* The execute frame was never sent, so re-issuing the same command ID cannot
* double-run a command.
*/
export declare class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxConnectionError {
export declare class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxRetryableConnectionError {
constructor(message: string);

@@ -180,0 +187,0 @@ }

@@ -49,2 +49,14 @@ /**

}
/**
* Raised when a transient connection failure occurs before a command starts.
*
* `run()` retries this error with the same command ID so the server can
* deduplicate an attempt whose outcome is unknown.
*/
export class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
constructor(message) {
super(message);
this.name = "LangSmithSandboxRetryableConnectionError";
}
}
// =============================================================================

@@ -358,8 +370,6 @@ // Resource Errors (type-based, with resourceType property)

*
* Distinct from its parent because it is safely retryable: the execute frame
* was never sent, so re-issuing the same command_id cannot double-run a
* command. run() retries this with backoff; a plain connection error (a
* rejected handshake) is permanent and propagates immediately.
* The execute frame was never sent, so re-issuing the same command ID cannot
* double-run a command.
*/
export class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxConnectionError {
export class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxRetryableConnectionError {
constructor(message) {

@@ -366,0 +376,0 @@ super(message);

@@ -32,3 +32,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectTimeoutError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.s3Mount = exports.mountConfig = exports.gitMount = exports.gcsMount = exports.contextHubMount = exports.workspaceSecret = exports.proxyConfig = exports.opaqueSecret = exports.gcpAuth = exports.awsAuth = exports.CommandHandle = exports.Sandbox = exports.SandboxClient = void 0;
exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectTimeoutError = exports.LangSmithSandboxRetryableConnectionError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.s3Mount = exports.mountConfig = exports.gitMount = exports.gcsMount = exports.contextHubMount = exports.workspaceSecret = exports.proxyConfig = exports.opaqueSecret = exports.gcpAuth = exports.awsAuth = exports.CommandHandle = exports.Sandbox = exports.SandboxClient = void 0;
// Main classes

@@ -60,2 +60,3 @@ var client_js_1 = require("./client.cjs");

Object.defineProperty(exports, "LangSmithSandboxConnectionError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxConnectionError; } });
Object.defineProperty(exports, "LangSmithSandboxRetryableConnectionError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxRetryableConnectionError; } });
Object.defineProperty(exports, "LangSmithSandboxConnectTimeoutError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxConnectTimeoutError; } });

@@ -62,0 +63,0 @@ Object.defineProperty(exports, "LangSmithSandboxServerReloadError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxServerReloadError; } });

@@ -35,3 +35,3 @@ /**

export { contextHubMount, gcsMount, gitMount, mountConfig, s3Mount, } from "./mounts.js";
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxAwsAuthRule, SandboxAwsMountAuthConfig, SandboxGcpAuthRule, SandboxGcpMountAuthConfig, SandboxMountAuth, SandboxMountAuthConfig, SandboxMountConfig, SandboxProxyConfig, SandboxProxyRule, SandboxProxySecret, SandboxMount, MountCacheConfig, ContextHubMountConfig, ContextHubMountSpec, GCSMountConfig, GCSMountSpec, GitMountConfig, GitMountRefSpec, GitMountSpec, S3MountConfig, S3MountSpec, CreateSnapshotOptions, CreateDockerfileSnapshotOptions, CaptureSnapshotOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxAwsAuthRule, SandboxAwsMountAuthConfig, SandboxGcpAuthRule, SandboxGcpMountAuthConfig, SandboxMountAuth, SandboxMountAuthConfig, SandboxMountConfig, SandboxProxyConfig, SandboxProxyRule, SandboxProxySecret, SandboxMount, MountCacheConfig, ContextHubMountConfig, ContextHubMountSpec, GCSMountConfig, GCSMountSpec, GitMountConfig, GitMountRefSpec, GitMountSpec, S3MountConfig, S3MountSpec, CreateSnapshotOptions, CreateDockerfileSnapshotOptions, CaptureSnapshotOptions, DownloadContentDisposition, DownloadURL, GenerateDownloadURLOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxRetryableConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";

@@ -39,3 +39,3 @@ /**

// Base and connection errors
LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError,
LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxRetryableConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError,
// Resource errors (type-based with resourceType attribute)

@@ -42,0 +42,0 @@ LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError,

@@ -267,3 +267,3 @@ "use strict";

if (!(e instanceof errors_js_1.LangSmithStreamEndedBeforeStartedError) &&
!(e instanceof errors_js_1.LangSmithSandboxConnectTimeoutError)) {
!(e instanceof errors_js_1.LangSmithSandboxRetryableConnectionError)) {
throw e;

@@ -415,2 +415,28 @@ }

/**
* Create a link that downloads one file from this sandbox.
*
* The link carries its own token, so anyone holding the URL can fetch that
* one file without a LangSmith credential. Fetching wakes a stopped sandbox.
*
* Do not modify the file after minting a link for it. The link is pinned to
* a path, not to a snapshot of the contents, so a later write to that path
* may or may not be reflected in what the link serves. Write a new file and
* mint a new link when the contents change.
*
* @param path - File path inside the sandbox.
* @param options - Expiry and response header overrides.
* @returns The link and its expiry, if any.
*
* @example
* ```typescript
* const link = await sandbox.generateDownloadURL("/tmp/report.pdf", {
* expiresInSeconds: 3600,
* });
* console.log(link.download_url);
* ```
*/
async generateDownloadURL(path, options = {}) {
return this._client.generateDownloadURL(this.name, path, options);
}
/**
* Delete this sandbox.

@@ -417,0 +443,0 @@ *

/**
* Sandbox class for interacting with a specific sandbox instance.
*/
import type { CaptureSnapshotOptions, ExecutionResult, RunOptions, Snapshot, StartSandboxOptions } from "./types.js";
import type { CaptureSnapshotOptions, DownloadURL, ExecutionResult, GenerateDownloadURLOptions, RunOptions, Snapshot, StartSandboxOptions } from "./types.js";
import { CommandHandle } from "./command_handle.js";

@@ -159,2 +159,26 @@ /**

/**
* Create a link that downloads one file from this sandbox.
*
* The link carries its own token, so anyone holding the URL can fetch that
* one file without a LangSmith credential. Fetching wakes a stopped sandbox.
*
* Do not modify the file after minting a link for it. The link is pinned to
* a path, not to a snapshot of the contents, so a later write to that path
* may or may not be reflected in what the link serves. Write a new file and
* mint a new link when the contents change.
*
* @param path - File path inside the sandbox.
* @param options - Expiry and response header overrides.
* @returns The link and its expiry, if any.
*
* @example
* ```typescript
* const link = await sandbox.generateDownloadURL("/tmp/report.pdf", {
* expiresInSeconds: 3600,
* });
* console.log(link.download_url);
* ```
*/
generateDownloadURL(path: string, options?: GenerateDownloadURLOptions): Promise<DownloadURL>;
/**
* Delete this sandbox.

@@ -161,0 +185,0 @@ *

@@ -5,3 +5,3 @@ /**

import { uuid7 } from "../uuid.js";
import { LangSmithDataplaneNotConfiguredError, LangSmithSandboxConnectTimeoutError, LangSmithStreamEndedBeforeStartedError, } from "./errors.js";
import { LangSmithDataplaneNotConfiguredError, LangSmithSandboxRetryableConnectionError, LangSmithStreamEndedBeforeStartedError, } from "./errors.js";
import { handleSandboxHttpError } from "./helpers.js";

@@ -265,3 +265,3 @@ import { CommandHandle } from "./command_handle.js";

if (!(e instanceof LangSmithStreamEndedBeforeStartedError) &&
!(e instanceof LangSmithSandboxConnectTimeoutError)) {
!(e instanceof LangSmithSandboxRetryableConnectionError)) {
throw e;

@@ -413,2 +413,28 @@ }

/**
* Create a link that downloads one file from this sandbox.
*
* The link carries its own token, so anyone holding the URL can fetch that
* one file without a LangSmith credential. Fetching wakes a stopped sandbox.
*
* Do not modify the file after minting a link for it. The link is pinned to
* a path, not to a snapshot of the contents, so a later write to that path
* may or may not be reflected in what the link serves. Write a new file and
* mint a new link when the contents change.
*
* @param path - File path inside the sandbox.
* @param options - Expiry and response header overrides.
* @returns The link and its expiry, if any.
*
* @example
* ```typescript
* const link = await sandbox.generateDownloadURL("/tmp/report.pdf", {
* expiresInSeconds: 3600,
* });
* console.log(link.download_url);
* ```
*/
async generateDownloadURL(path, options = {}) {
return this._client.generateDownloadURL(this.name, path, options);
}
/**
* Delete this sandbox.

@@ -415,0 +441,0 @@ *

@@ -563,2 +563,37 @@ /**

/**
* How a download link asks the browser to handle the file.
*/
export type DownloadContentDisposition = "attachment" | "inline";
/**
* Options for minting a sandbox file download link.
*/
export interface GenerateDownloadURLOptions {
/**
* Link TTL in seconds. Omit for a link that never expires.
*/
expiresInSeconds?: number;
/** Content-Type to serve the file as. */
contentType?: string;
/** Content-Disposition to serve the file with. */
contentDisposition?: DownloadContentDisposition;
/** AbortSignal for cancellation. */
signal?: AbortSignal;
}
/**
* A link that downloads one sandbox file with no LangSmith credential.
*
* The link is pinned to the sandbox, the file path, and the response headers,
* so it cannot be repointed at another file. It is pinned to the path rather
* than to a snapshot of the contents, so the file must not be modified while
* the link is in use.
*/
export interface DownloadURL {
/** The full URL to fetch. Supports GET, HEAD, and Range. */
download_url: string;
/** The signed token embedded in `download_url`. */
token: string;
/** Expiry timestamp, or null for a link that never expires. */
expires_at: string | null;
}
/**
* Options for listing snapshots. All fields are optional and independent.

@@ -565,0 +600,0 @@ *

@@ -38,2 +38,3 @@ "use strict";

exports.WS_CONNECT_BUDGET = envTimeout("SANDBOX_WS_TIMEOUT_CONNECT_BUDGET", 120);
const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([500, 502, 503, 504]);
function nowSeconds() {

@@ -188,4 +189,4 @@ return performance.now() / 1000;

*
* A socket-level failure rejects with the retryable connect-timeout error; a
* non-101 response rejects with the permanent connection error.
* Socket-level failures and transient 5xx responses are retryable. Other
* non-101 responses are permanent connection errors.
*/

@@ -215,3 +216,6 @@ async function connectWs(url, headers, openTimeout = exports.WS_OPEN_TIMEOUT) {

settled = true;
reject(new errors_js_1.LangSmithSandboxConnectionError(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
const ErrorType = RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)
? errors_js_1.LangSmithSandboxRetryableConnectionError
: errors_js_1.LangSmithSandboxConnectionError;
reject(new ErrorType(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
});

@@ -218,0 +222,0 @@ // Stays attached after settling so a late error has a listener and cannot

@@ -7,3 +7,3 @@ /**

*/
import { LangSmithCommandTimeoutError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxOperationError, LangSmithSandboxServerReloadError, } from "./errors.js";
import { LangSmithCommandTimeoutError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxOperationError, LangSmithSandboxRetryableConnectionError, LangSmithSandboxServerReloadError, } from "./errors.js";
import { getLangSmithEnvironmentVariable } from "../utils/env.js";

@@ -27,2 +27,3 @@ /** Read a WebSocket timeout override, in seconds. `<= 0` disables it. */

export const WS_CONNECT_BUDGET = envTimeout("SANDBOX_WS_TIMEOUT_CONNECT_BUDGET", 120);
const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([500, 502, 503, 504]);
function nowSeconds() {

@@ -176,4 +177,4 @@ return performance.now() / 1000;

*
* A socket-level failure rejects with the retryable connect-timeout error; a
* non-101 response rejects with the permanent connection error.
* Socket-level failures and transient 5xx responses are retryable. Other
* non-101 responses are permanent connection errors.
*/

@@ -203,3 +204,6 @@ async function connectWs(url, headers, openTimeout = WS_OPEN_TIMEOUT) {

settled = true;
reject(new LangSmithSandboxConnectionError(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
const ErrorType = RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)
? LangSmithSandboxRetryableConnectionError
: LangSmithSandboxConnectionError;
reject(new ErrorType(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
});

@@ -206,0 +210,0 @@ // Stays attached after settling so a late error has a listener and cannot

{
"name": "langsmith",
"version": "0.8.11",
"version": "0.8.12",
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",

@@ -5,0 +5,0 @@ "packageManager": "pnpm@10.33.0",