langsmith 0.7.11 → 0.7.13
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/_openapi_client/client.cjs +16 -0
- package/dist/_openapi_client/client.d.ts +6 -0
- package/dist/_openapi_client/client.js +16 -0
- package/dist/_openapi_client/core/pagination.cjs +2 -2
- package/dist/_openapi_client/core/pagination.js +2 -2
- package/dist/_openapi_client/internal/utils/query.cjs +1 -1
- package/dist/_openapi_client/internal/utils/query.js +1 -1
- package/dist/_openapi_client/resources/datasets/runs.d.ts +2 -1
- package/dist/_openapi_client/resources/index.cjs +5 -1
- package/dist/_openapi_client/resources/index.d.ts +2 -0
- package/dist/_openapi_client/resources/index.js +2 -0
- package/dist/_openapi_client/resources/runs/index.cjs +9 -0
- package/dist/_openapi_client/resources/runs/index.d.ts +2 -0
- package/dist/_openapi_client/resources/runs/index.js +4 -0
- package/dist/_openapi_client/resources/runs/rules.cjs +9 -0
- package/dist/_openapi_client/resources/runs/rules.d.ts +3 -0
- package/dist/_openapi_client/resources/runs/rules.js +5 -0
- package/dist/_openapi_client/resources/runs/runs.cjs +115 -0
- package/dist/_openapi_client/resources/runs/runs.d.ts +800 -0
- package/dist/_openapi_client/resources/runs/runs.js +78 -0
- package/dist/_openapi_client/resources/runs.cjs +19 -0
- package/dist/_openapi_client/resources/runs.d.ts +1 -0
- package/dist/_openapi_client/resources/runs.js +3 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.cjs +86 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +458 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.js +82 -0
- package/dist/_openapi_client/resources/sandboxes/registries.cjs +44 -0
- package/dist/_openapi_client/resources/sandboxes/registries.d.ts +67 -0
- package/dist/_openapi_client/resources/sandboxes/registries.js +40 -0
- package/dist/_openapi_client/resources/sandboxes/sandboxes.cjs +72 -0
- package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +308 -0
- package/dist/_openapi_client/resources/sandboxes/sandboxes.js +35 -0
- package/dist/_openapi_client/resources/sandboxes/snapshots.cjs +39 -0
- package/dist/_openapi_client/resources/sandboxes/snapshots.d.ts +62 -0
- package/dist/_openapi_client/resources/sandboxes/snapshots.js +35 -0
- package/dist/client.cjs +7 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/sandbox/client.cjs +58 -15
- package/dist/sandbox/client.d.ts +27 -1
- package/dist/sandbox/client.js +54 -11
- package/dist/sandbox/sandbox.cjs +7 -6
- package/dist/sandbox/sandbox.d.ts +7 -2
- package/dist/sandbox/sandbox.js +8 -7
- package/dist/sandbox/types.d.ts +1 -7
- package/dist/utils/constants.cjs +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { APIResource } from '../../core/resource.js';
|
|
2
|
+
import * as SandboxesAPI from './sandboxes.js';
|
|
3
|
+
import { APIPromise } from '../../core/api-promise.js';
|
|
4
|
+
import { RequestOptions } from '../../internal/request-options.js';
|
|
5
|
+
export declare class Snapshots extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Create a snapshot from a Docker image (async build).
|
|
8
|
+
*/
|
|
9
|
+
create(body: SnapshotCreateParams, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a sandbox snapshot by ID.
|
|
12
|
+
*/
|
|
13
|
+
retrieve(snapshotID: string, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* List sandbox snapshots for the authenticated tenant, with optional filtering,
|
|
16
|
+
* sorting, and pagination.
|
|
17
|
+
*/
|
|
18
|
+
list(query?: SnapshotListParams | null | undefined, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotListResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Delete a snapshot by ID. The underlying storage is reclaimed asynchronously.
|
|
21
|
+
*/
|
|
22
|
+
delete(snapshotID: string, options?: RequestOptions): APIPromise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface SnapshotCreateParams {
|
|
25
|
+
docker_image: string;
|
|
26
|
+
fs_capacity_bytes: number;
|
|
27
|
+
name: string;
|
|
28
|
+
registry_id?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SnapshotListParams {
|
|
31
|
+
/**
|
|
32
|
+
* Filter by creator identity. Only 'me' is supported.
|
|
33
|
+
*/
|
|
34
|
+
created_by?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Maximum number of results
|
|
37
|
+
*/
|
|
38
|
+
limit?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Filter by name substring
|
|
41
|
+
*/
|
|
42
|
+
name_contains?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Pagination offset
|
|
45
|
+
*/
|
|
46
|
+
offset?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Sort column (name, status, created_at)
|
|
49
|
+
*/
|
|
50
|
+
sort_by?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Sort direction (asc, desc)
|
|
53
|
+
*/
|
|
54
|
+
sort_direction?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Filter by status (building, ready, failed, deleting)
|
|
57
|
+
*/
|
|
58
|
+
status?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare namespace Snapshots {
|
|
61
|
+
export { type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams };
|
|
62
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
import { APIResource } from '../../core/resource.js';
|
|
4
|
+
import { buildHeaders } from '../../internal/headers.js';
|
|
5
|
+
import { path } from '../../internal/utils/path.js';
|
|
6
|
+
export class Snapshots extends APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Create a snapshot from a Docker image (async build).
|
|
9
|
+
*/
|
|
10
|
+
create(body, options) {
|
|
11
|
+
return this._client.post('/v2/sandboxes/snapshots', { body, ...options });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get a sandbox snapshot by ID.
|
|
15
|
+
*/
|
|
16
|
+
retrieve(snapshotID, options) {
|
|
17
|
+
return this._client.get(path `/v2/sandboxes/snapshots/${snapshotID}`, options);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* List sandbox snapshots for the authenticated tenant, with optional filtering,
|
|
21
|
+
* sorting, and pagination.
|
|
22
|
+
*/
|
|
23
|
+
list(query = {}, options) {
|
|
24
|
+
return this._client.get('/v2/sandboxes/snapshots', { query, ...options });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Delete a snapshot by ID. The underlying storage is reclaimed asynchronously.
|
|
28
|
+
*/
|
|
29
|
+
delete(snapshotID, options) {
|
|
30
|
+
return this._client.delete(path `/v2/sandboxes/snapshots/${snapshotID}`, {
|
|
31
|
+
...options,
|
|
32
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/client.cjs
CHANGED
|
@@ -968,6 +968,13 @@ class Client {
|
|
|
968
968
|
get onlineEvaluators() {
|
|
969
969
|
return this.openAPIClient.onlineEvaluators;
|
|
970
970
|
}
|
|
971
|
+
get runs() {
|
|
972
|
+
return this.openAPIClient.runs;
|
|
973
|
+
}
|
|
974
|
+
/** Access the v2 sandboxes resource (registries, snapshots, boxes). */
|
|
975
|
+
get sandboxes() {
|
|
976
|
+
return this.openAPIClient.sandboxes;
|
|
977
|
+
}
|
|
971
978
|
async processInputs(inputs) {
|
|
972
979
|
if (this.hideInputs === false) {
|
|
973
980
|
return inputs;
|
package/dist/client.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShare
|
|
|
4
4
|
import { type TracingMode } from "./utils/env.js";
|
|
5
5
|
import { EvaluationResult, EvaluationResults } from "./evaluation/evaluator.js";
|
|
6
6
|
import { OnlineEvaluators } from "./_openapi_client/resources/online-evaluators.js";
|
|
7
|
+
import { Runs as OpenAPIRuns } from "./_openapi_client/resources/runs.js";
|
|
8
|
+
import { Sandboxes } from "./_openapi_client/resources/sandboxes/sandboxes.js";
|
|
7
9
|
import { PromptCache } from "./utils/prompt_cache/index.js";
|
|
8
10
|
import { ProfileAuth } from "./utils/profiles.js";
|
|
9
11
|
export interface ClientConfig {
|
|
@@ -502,6 +504,9 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
502
504
|
private _newOpenAPIClient;
|
|
503
505
|
private _getPlatformEndpointPath;
|
|
504
506
|
get onlineEvaluators(): OnlineEvaluators;
|
|
507
|
+
get runs(): OpenAPIRuns;
|
|
508
|
+
/** Access the v2 sandboxes resource (registries, snapshots, boxes). */
|
|
509
|
+
get sandboxes(): Sandboxes;
|
|
505
510
|
private processInputs;
|
|
506
511
|
private processOutputs;
|
|
507
512
|
private processMetadata;
|
package/dist/client.js
CHANGED
|
@@ -929,6 +929,13 @@ export class Client {
|
|
|
929
929
|
get onlineEvaluators() {
|
|
930
930
|
return this.openAPIClient.onlineEvaluators;
|
|
931
931
|
}
|
|
932
|
+
get runs() {
|
|
933
|
+
return this.openAPIClient.runs;
|
|
934
|
+
}
|
|
935
|
+
/** Access the v2 sandboxes resource (registries, snapshots, boxes). */
|
|
936
|
+
get sandboxes() {
|
|
937
|
+
return this.openAPIClient.sandboxes;
|
|
938
|
+
}
|
|
932
939
|
async processInputs(inputs) {
|
|
933
940
|
if (this.hideInputs === false) {
|
|
934
941
|
return inputs;
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,6 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
|
|
|
20
20
|
Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
|
|
21
21
|
Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
|
|
22
22
|
// Update using pnpm bump-version
|
|
23
|
-
exports.__version__ = "0.7.
|
|
23
|
+
exports.__version__ = "0.7.13";
|
|
24
24
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
25
25
|
exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { getDefaultProjectName } from "./utils/project.js";
|
|
|
6
6
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
7
7
|
export { isTracingEnabled } from "./utils/guard.js";
|
|
8
8
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
9
|
-
export declare const __version__ = "0.7.
|
|
9
|
+
export declare const __version__ = "0.7.13";
|
|
10
10
|
export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,6 @@ export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
|
6
6
|
export { isTracingEnabled } from "./utils/guard.js";
|
|
7
7
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
8
|
// Update using pnpm bump-version
|
|
9
|
-
export const __version__ = "0.7.
|
|
9
|
+
export const __version__ = "0.7.13";
|
|
10
10
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
11
11
|
export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/sandbox/client.cjs
CHANGED
|
@@ -7,11 +7,12 @@ exports.SandboxClient = void 0;
|
|
|
7
7
|
const env_js_1 = require("../utils/env.cjs");
|
|
8
8
|
const fetch_js_1 = require("../singletons/fetch.cjs");
|
|
9
9
|
const async_caller_js_1 = require("../utils/async_caller.cjs");
|
|
10
|
+
const index_js_1 = require("../_openapi_client/index.cjs");
|
|
10
11
|
const sandbox_js_1 = require("./sandbox.cjs");
|
|
11
12
|
const errors_js_1 = require("./errors.cjs");
|
|
12
13
|
const helpers_js_1 = require("./helpers.cjs");
|
|
13
14
|
const mounts_js_1 = require("./mounts.cjs");
|
|
14
|
-
const
|
|
15
|
+
const index_js_2 = require("../utils/uuid/src/index.cjs");
|
|
15
16
|
/**
|
|
16
17
|
* Sleep that can be interrupted by an AbortSignal.
|
|
17
18
|
* Resolves after `ms` milliseconds or rejects immediately if the signal fires.
|
|
@@ -296,6 +297,12 @@ class SandboxClient {
|
|
|
296
297
|
writable: true,
|
|
297
298
|
value: void 0
|
|
298
299
|
});
|
|
300
|
+
Object.defineProperty(this, "_registriesClient", {
|
|
301
|
+
enumerable: true,
|
|
302
|
+
configurable: true,
|
|
303
|
+
writable: true,
|
|
304
|
+
value: void 0
|
|
305
|
+
});
|
|
299
306
|
this._baseUrl = (config.apiEndpoint ?? getDefaultApiEndpoint()).replace(/\/$/, "");
|
|
300
307
|
this._apiKey = config.apiKey ?? getDefaultApiKey();
|
|
301
308
|
this._defaultHeaders = { ...(config.headers ?? {}) };
|
|
@@ -305,6 +312,51 @@ class SandboxClient {
|
|
|
305
312
|
maxConcurrency: config.maxConcurrency ?? Infinity,
|
|
306
313
|
});
|
|
307
314
|
}
|
|
315
|
+
_apiRoot() {
|
|
316
|
+
const suffix = "/v2/sandboxes";
|
|
317
|
+
return this._baseUrl.endsWith(suffix)
|
|
318
|
+
? this._baseUrl.slice(0, -suffix.length)
|
|
319
|
+
: this._baseUrl;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Manage sandbox image registries: create, list, retrieve, update, delete.
|
|
323
|
+
*
|
|
324
|
+
* A registry stores credentials for pulling private images. Create one, then
|
|
325
|
+
* pass its `id` as `registryId` when building a snapshot.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const registry = await client.registries.create({
|
|
330
|
+
* name: "internal",
|
|
331
|
+
* url: "registry.example.com",
|
|
332
|
+
* username: "robot",
|
|
333
|
+
* password: process.env.REGISTRY_PASSWORD,
|
|
334
|
+
* });
|
|
335
|
+
* const snapshot = await client.createSnapshot(
|
|
336
|
+
* "internal-python",
|
|
337
|
+
* "registry.example.com/internal/python:3.12",
|
|
338
|
+
* 2_147_483_648,
|
|
339
|
+
* { registryId: registry.id },
|
|
340
|
+
* );
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
get registries() {
|
|
344
|
+
if (!this._registriesClient) {
|
|
345
|
+
const defaultHeaders = {
|
|
346
|
+
...this._defaultHeaders,
|
|
347
|
+
};
|
|
348
|
+
if (this._apiKey === undefined) {
|
|
349
|
+
defaultHeaders["X-API-Key"] = null;
|
|
350
|
+
}
|
|
351
|
+
this._registriesClient = new index_js_1.Langsmith({
|
|
352
|
+
apiKey: this._apiKey,
|
|
353
|
+
baseURL: this._apiRoot(),
|
|
354
|
+
defaultHeaders,
|
|
355
|
+
fetch: this._fetchImpl,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return this._registriesClient.sandboxes.registries;
|
|
359
|
+
}
|
|
308
360
|
/**
|
|
309
361
|
* Internal fetch method that adds authentication headers.
|
|
310
362
|
*
|
|
@@ -619,11 +671,11 @@ class SandboxClient {
|
|
|
619
671
|
* @param name - Snapshot name.
|
|
620
672
|
* @param dockerImage - Docker image to build from (e.g., "python:3.12-slim").
|
|
621
673
|
* @param fsCapacityBytes - Filesystem capacity in bytes.
|
|
622
|
-
* @param options - Additional options (registry
|
|
674
|
+
* @param options - Additional options (registry ID, timeout).
|
|
623
675
|
* @returns Snapshot in "ready" status.
|
|
624
676
|
*/
|
|
625
677
|
async createSnapshot(name, dockerImage, fsCapacityBytes, options = {}) {
|
|
626
|
-
const { registryId,
|
|
678
|
+
const { registryId, timeout = 60, signal } = options;
|
|
627
679
|
const url = `${this._baseUrl}/snapshots`;
|
|
628
680
|
const payload = {
|
|
629
681
|
name,
|
|
@@ -633,15 +685,6 @@ class SandboxClient {
|
|
|
633
685
|
if (registryId !== undefined) {
|
|
634
686
|
payload.registry_id = registryId;
|
|
635
687
|
}
|
|
636
|
-
if (registryUrl !== undefined) {
|
|
637
|
-
payload.registry_url = registryUrl;
|
|
638
|
-
}
|
|
639
|
-
if (registryUsername !== undefined) {
|
|
640
|
-
payload.registry_username = registryUsername;
|
|
641
|
-
}
|
|
642
|
-
if (registryPassword !== undefined) {
|
|
643
|
-
payload.registry_password = registryPassword;
|
|
644
|
-
}
|
|
645
688
|
const response = await this._postJson(url, payload, { signal });
|
|
646
689
|
const snapshot = (await response.json());
|
|
647
690
|
return this.waitForSnapshot(snapshot.id, { timeout, signal });
|
|
@@ -663,18 +706,18 @@ class SandboxClient {
|
|
|
663
706
|
async createSnapshotFromDockerfile(name, dockerfile, fsCapacityBytes, options = {}) {
|
|
664
707
|
const { context = ".", buildArgs, target, onBuildLog, vCpus, memBytes, timeout = 60, } = options;
|
|
665
708
|
const { contextPath, dockerfileRel } = await resolveDockerfileContext(dockerfile, context);
|
|
666
|
-
const builderName = `snapshot-builder-${(0,
|
|
709
|
+
const builderName = `snapshot-builder-${(0, index_js_2.v4)().replace(/-/g, "").slice(0, 12)}`;
|
|
667
710
|
// Stage the build on the capacity-backed root filesystem, not /tmp.
|
|
668
711
|
// Inside the sandbox /tmp is a RAM-backed tmpfs that fsCapacityBytes does
|
|
669
712
|
// not size, and BuildKit's native snapshotter writes a full copy of every
|
|
670
713
|
// layer under its root, so a /tmp build exhausts guest RAM and fails with
|
|
671
714
|
// "No space left on device".
|
|
672
|
-
const buildRoot = `/var/lib/langsmith-build/${(0,
|
|
715
|
+
const buildRoot = `/var/lib/langsmith-build/${(0, index_js_2.v4)()
|
|
673
716
|
.replace(/-/g, "")
|
|
674
717
|
.slice(0, 12)}`;
|
|
675
718
|
const remoteContext = `${buildRoot}/context`;
|
|
676
719
|
const remoteTar = `${buildRoot}/context.tar`;
|
|
677
|
-
const imageRef = `langsmith-snapshot-build:${(0,
|
|
720
|
+
const imageRef = `langsmith-snapshot-build:${(0, index_js_2.v4)().replace(/-/g, "")}`;
|
|
678
721
|
const buildkitRoot = `${buildRoot}/buildkit-root`;
|
|
679
722
|
const buildkitRun = `${buildRoot}/buildkit-run`;
|
|
680
723
|
const builder = await this.createSandbox({
|
package/dist/sandbox/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main SandboxClient class for interacting with the sandbox server API.
|
|
3
3
|
*/
|
|
4
|
+
import { Registries } from "../_openapi_client/resources/sandboxes/registries.js";
|
|
4
5
|
import type { CaptureSnapshotOptions, CreateDockerfileSnapshotOptions, CreateSandboxOptions, CreateSnapshotOptions, ListSnapshotsOptions, ResourceStatus, SandboxClientConfig, Snapshot, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, WaitForSnapshotOptions } from "./types.js";
|
|
5
6
|
import { Sandbox } from "./sandbox.js";
|
|
6
7
|
/**
|
|
@@ -37,7 +38,32 @@ export declare class SandboxClient {
|
|
|
37
38
|
private _defaultHeaders;
|
|
38
39
|
private _fetchImpl;
|
|
39
40
|
private _caller;
|
|
41
|
+
private _registriesClient?;
|
|
40
42
|
constructor(config?: SandboxClientConfig);
|
|
43
|
+
private _apiRoot;
|
|
44
|
+
/**
|
|
45
|
+
* Manage sandbox image registries: create, list, retrieve, update, delete.
|
|
46
|
+
*
|
|
47
|
+
* A registry stores credentials for pulling private images. Create one, then
|
|
48
|
+
* pass its `id` as `registryId` when building a snapshot.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const registry = await client.registries.create({
|
|
53
|
+
* name: "internal",
|
|
54
|
+
* url: "registry.example.com",
|
|
55
|
+
* username: "robot",
|
|
56
|
+
* password: process.env.REGISTRY_PASSWORD,
|
|
57
|
+
* });
|
|
58
|
+
* const snapshot = await client.createSnapshot(
|
|
59
|
+
* "internal-python",
|
|
60
|
+
* "registry.example.com/internal/python:3.12",
|
|
61
|
+
* 2_147_483_648,
|
|
62
|
+
* { registryId: registry.id },
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
get registries(): Registries;
|
|
41
67
|
/**
|
|
42
68
|
* Create a new Sandbox.
|
|
43
69
|
*
|
|
@@ -169,7 +195,7 @@ export declare class SandboxClient {
|
|
|
169
195
|
* @param name - Snapshot name.
|
|
170
196
|
* @param dockerImage - Docker image to build from (e.g., "python:3.12-slim").
|
|
171
197
|
* @param fsCapacityBytes - Filesystem capacity in bytes.
|
|
172
|
-
* @param options - Additional options (registry
|
|
198
|
+
* @param options - Additional options (registry ID, timeout).
|
|
173
199
|
* @returns Snapshot in "ready" status.
|
|
174
200
|
*/
|
|
175
201
|
createSnapshot(name: string, dockerImage: string, fsCapacityBytes: number, options?: CreateSnapshotOptions): Promise<Snapshot>;
|
package/dist/sandbox/client.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { getLangSmithEnvironmentVariable } from "../utils/env.js";
|
|
5
5
|
import { _getFetchImplementation } from "../singletons/fetch.js";
|
|
6
6
|
import { AsyncCaller } from "../utils/async_caller.js";
|
|
7
|
+
import { Langsmith as OpenAPILangsmith } from "../_openapi_client/index.js";
|
|
7
8
|
import { Sandbox } from "./sandbox.js";
|
|
8
9
|
import { LangSmithResourceCreationError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, LangSmithValidationError, } from "./errors.js";
|
|
9
10
|
import { handleClientHttpError, handleSandboxCreationError, validateTtl, } from "./helpers.js";
|
|
@@ -293,6 +294,12 @@ export class SandboxClient {
|
|
|
293
294
|
writable: true,
|
|
294
295
|
value: void 0
|
|
295
296
|
});
|
|
297
|
+
Object.defineProperty(this, "_registriesClient", {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
configurable: true,
|
|
300
|
+
writable: true,
|
|
301
|
+
value: void 0
|
|
302
|
+
});
|
|
296
303
|
this._baseUrl = (config.apiEndpoint ?? getDefaultApiEndpoint()).replace(/\/$/, "");
|
|
297
304
|
this._apiKey = config.apiKey ?? getDefaultApiKey();
|
|
298
305
|
this._defaultHeaders = { ...(config.headers ?? {}) };
|
|
@@ -302,6 +309,51 @@ export class SandboxClient {
|
|
|
302
309
|
maxConcurrency: config.maxConcurrency ?? Infinity,
|
|
303
310
|
});
|
|
304
311
|
}
|
|
312
|
+
_apiRoot() {
|
|
313
|
+
const suffix = "/v2/sandboxes";
|
|
314
|
+
return this._baseUrl.endsWith(suffix)
|
|
315
|
+
? this._baseUrl.slice(0, -suffix.length)
|
|
316
|
+
: this._baseUrl;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Manage sandbox image registries: create, list, retrieve, update, delete.
|
|
320
|
+
*
|
|
321
|
+
* A registry stores credentials for pulling private images. Create one, then
|
|
322
|
+
* pass its `id` as `registryId` when building a snapshot.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const registry = await client.registries.create({
|
|
327
|
+
* name: "internal",
|
|
328
|
+
* url: "registry.example.com",
|
|
329
|
+
* username: "robot",
|
|
330
|
+
* password: process.env.REGISTRY_PASSWORD,
|
|
331
|
+
* });
|
|
332
|
+
* const snapshot = await client.createSnapshot(
|
|
333
|
+
* "internal-python",
|
|
334
|
+
* "registry.example.com/internal/python:3.12",
|
|
335
|
+
* 2_147_483_648,
|
|
336
|
+
* { registryId: registry.id },
|
|
337
|
+
* );
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
get registries() {
|
|
341
|
+
if (!this._registriesClient) {
|
|
342
|
+
const defaultHeaders = {
|
|
343
|
+
...this._defaultHeaders,
|
|
344
|
+
};
|
|
345
|
+
if (this._apiKey === undefined) {
|
|
346
|
+
defaultHeaders["X-API-Key"] = null;
|
|
347
|
+
}
|
|
348
|
+
this._registriesClient = new OpenAPILangsmith({
|
|
349
|
+
apiKey: this._apiKey,
|
|
350
|
+
baseURL: this._apiRoot(),
|
|
351
|
+
defaultHeaders,
|
|
352
|
+
fetch: this._fetchImpl,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return this._registriesClient.sandboxes.registries;
|
|
356
|
+
}
|
|
305
357
|
/**
|
|
306
358
|
* Internal fetch method that adds authentication headers.
|
|
307
359
|
*
|
|
@@ -616,11 +668,11 @@ export class SandboxClient {
|
|
|
616
668
|
* @param name - Snapshot name.
|
|
617
669
|
* @param dockerImage - Docker image to build from (e.g., "python:3.12-slim").
|
|
618
670
|
* @param fsCapacityBytes - Filesystem capacity in bytes.
|
|
619
|
-
* @param options - Additional options (registry
|
|
671
|
+
* @param options - Additional options (registry ID, timeout).
|
|
620
672
|
* @returns Snapshot in "ready" status.
|
|
621
673
|
*/
|
|
622
674
|
async createSnapshot(name, dockerImage, fsCapacityBytes, options = {}) {
|
|
623
|
-
const { registryId,
|
|
675
|
+
const { registryId, timeout = 60, signal } = options;
|
|
624
676
|
const url = `${this._baseUrl}/snapshots`;
|
|
625
677
|
const payload = {
|
|
626
678
|
name,
|
|
@@ -630,15 +682,6 @@ export class SandboxClient {
|
|
|
630
682
|
if (registryId !== undefined) {
|
|
631
683
|
payload.registry_id = registryId;
|
|
632
684
|
}
|
|
633
|
-
if (registryUrl !== undefined) {
|
|
634
|
-
payload.registry_url = registryUrl;
|
|
635
|
-
}
|
|
636
|
-
if (registryUsername !== undefined) {
|
|
637
|
-
payload.registry_username = registryUsername;
|
|
638
|
-
}
|
|
639
|
-
if (registryPassword !== undefined) {
|
|
640
|
-
payload.registry_password = registryPassword;
|
|
641
|
-
}
|
|
642
685
|
const response = await this._postJson(url, payload, { signal });
|
|
643
686
|
const snapshot = (await response.json());
|
|
644
687
|
return this.waitForSnapshot(snapshot.id, { timeout, signal });
|
package/dist/sandbox/sandbox.cjs
CHANGED
|
@@ -162,15 +162,16 @@ class Sandbox {
|
|
|
162
162
|
this._client = client;
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
165
|
+
* Return the dataplane URL.
|
|
166
|
+
*
|
|
167
|
+
* The client does not gate on lifecycle status: a stopped sandbox is resumed
|
|
168
|
+
* by the platform when the dataplane request arrives, so only the presence of
|
|
169
|
+
* a URL is required here. A genuinely not-ready box surfaces the server's
|
|
170
|
+
* LangSmithSandboxNotReadyError from the request itself.
|
|
171
|
+
*
|
|
167
172
|
* @throws LangSmithDataplaneNotConfiguredError if dataplane_url is not configured.
|
|
168
173
|
*/
|
|
169
174
|
requireDataplaneUrl() {
|
|
170
|
-
if (this.status && this.status !== "ready") {
|
|
171
|
-
throw new errors_js_1.LangSmithSandboxNotReadyError(`Sandbox '${this.name}' is not ready (status: ${this.status}). ` +
|
|
172
|
-
"Use waitForSandbox() to wait for the sandbox to become ready.");
|
|
173
|
-
}
|
|
174
175
|
if (!this.dataplane_url) {
|
|
175
176
|
throw new errors_js_1.LangSmithDataplaneNotConfiguredError(`Sandbox '${this.name}' does not have a dataplane_url configured. ` +
|
|
176
177
|
"Runtime operations require a dataplane URL.");
|
|
@@ -64,8 +64,13 @@ export declare class Sandbox {
|
|
|
64
64
|
readonly fs_capacity_bytes?: number;
|
|
65
65
|
private _client;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* Return the dataplane URL.
|
|
68
|
+
*
|
|
69
|
+
* The client does not gate on lifecycle status: a stopped sandbox is resumed
|
|
70
|
+
* by the platform when the dataplane request arrives, so only the presence of
|
|
71
|
+
* a URL is required here. A genuinely not-ready box surfaces the server's
|
|
72
|
+
* LangSmithSandboxNotReadyError from the request itself.
|
|
73
|
+
*
|
|
69
74
|
* @throws LangSmithDataplaneNotConfiguredError if dataplane_url is not configured.
|
|
70
75
|
*/
|
|
71
76
|
private requireDataplaneUrl;
|
package/dist/sandbox/sandbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sandbox class for interacting with a specific sandbox instance.
|
|
3
3
|
*/
|
|
4
|
-
import { LangSmithDataplaneNotConfiguredError
|
|
4
|
+
import { LangSmithDataplaneNotConfiguredError } from "./errors.js";
|
|
5
5
|
import { handleSandboxHttpError } from "./helpers.js";
|
|
6
6
|
import { CommandHandle } from "./command_handle.js";
|
|
7
7
|
import { reconnectWsStream, runWsStream } from "./ws_execute.js";
|
|
@@ -159,15 +159,16 @@ export class Sandbox {
|
|
|
159
159
|
this._client = client;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
162
|
+
* Return the dataplane URL.
|
|
163
|
+
*
|
|
164
|
+
* The client does not gate on lifecycle status: a stopped sandbox is resumed
|
|
165
|
+
* by the platform when the dataplane request arrives, so only the presence of
|
|
166
|
+
* a URL is required here. A genuinely not-ready box surfaces the server's
|
|
167
|
+
* LangSmithSandboxNotReadyError from the request itself.
|
|
168
|
+
*
|
|
164
169
|
* @throws LangSmithDataplaneNotConfiguredError if dataplane_url is not configured.
|
|
165
170
|
*/
|
|
166
171
|
requireDataplaneUrl() {
|
|
167
|
-
if (this.status && this.status !== "ready") {
|
|
168
|
-
throw new LangSmithSandboxNotReadyError(`Sandbox '${this.name}' is not ready (status: ${this.status}). ` +
|
|
169
|
-
"Use waitForSandbox() to wait for the sandbox to become ready.");
|
|
170
|
-
}
|
|
171
172
|
if (!this.dataplane_url) {
|
|
172
173
|
throw new LangSmithDataplaneNotConfiguredError(`Sandbox '${this.name}' does not have a dataplane_url configured. ` +
|
|
173
174
|
"Runtime operations require a dataplane URL.");
|
package/dist/sandbox/types.d.ts
CHANGED
|
@@ -477,14 +477,8 @@ export interface CreateSandboxOptions {
|
|
|
477
477
|
* Options for creating a snapshot from a Docker image.
|
|
478
478
|
*/
|
|
479
479
|
export interface CreateSnapshotOptions {
|
|
480
|
-
/** Private registry ID
|
|
480
|
+
/** Private registry ID. */
|
|
481
481
|
registryId?: string;
|
|
482
|
-
/** Registry URL for private images. */
|
|
483
|
-
registryUrl?: string;
|
|
484
|
-
/** Registry username. */
|
|
485
|
-
registryUsername?: string;
|
|
486
|
-
/** Registry password. */
|
|
487
|
-
registryPassword?: string;
|
|
488
482
|
/** Timeout in seconds when waiting for ready. Default: 60. */
|
|
489
483
|
timeout?: number;
|
|
490
484
|
/** AbortSignal for cancellation. */
|
package/dist/utils/constants.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const _MIN_BACKEND_VERSION = "0.16.
|
|
1
|
+
export declare const _MIN_BACKEND_VERSION = "0.16.6rc1";
|
package/dist/utils/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const _MIN_BACKEND_VERSION = "0.16.
|
|
1
|
+
export const _MIN_BACKEND_VERSION = "0.16.6rc1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
5
|
"packageManager": "pnpm@10.33.0",
|
|
6
6
|
"files": [
|
|
@@ -156,9 +156,9 @@
|
|
|
156
156
|
"p-queue": "6.6.2"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@ai-sdk/openai": "4.0.0-
|
|
160
|
-
"@ai-sdk/provider": "4.0.0-
|
|
161
|
-
"@ai-sdk/anthropic": "4.0.0-
|
|
159
|
+
"@ai-sdk/openai": "4.0.0-beta.74",
|
|
160
|
+
"@ai-sdk/provider": "4.0.0-beta.19",
|
|
161
|
+
"@ai-sdk/anthropic": "4.0.0-beta.67",
|
|
162
162
|
"@anthropic-ai/claude-agent-sdk": "^0.3.150",
|
|
163
163
|
"@anthropic-ai/sdk": "^0.98.0",
|
|
164
164
|
"@babel/preset-env": "^7.22.4",
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
"@types/ws": "^8.18.1",
|
|
185
185
|
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
186
186
|
"@typescript-eslint/parser": "^5.59.8",
|
|
187
|
-
"ai": "7.0.0-
|
|
187
|
+
"ai": "7.0.0-beta.178",
|
|
188
188
|
"babel-jest": "^30.2.0",
|
|
189
189
|
"cross-env": "^10.1.0",
|
|
190
190
|
"dotenv": "^17.3.1",
|