langsmith 0.8.11 → 0.8.12
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/resources/issues.d.ts +6 -0
- package/dist/_openapi_client/resources/online-evaluators.cjs +2 -2
- package/dist/_openapi_client/resources/online-evaluators.d.ts +7 -2
- package/dist/_openapi_client/resources/online-evaluators.js +2 -2
- package/dist/_openapi_client/resources/public/runs.d.ts +1 -1
- package/dist/_openapi_client/resources/sandboxes/boxes.cjs +2 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +25 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.js +2 -0
- package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +7 -2
- package/dist/_openapi_client/resources/sandboxes/sandboxes.js +1 -1
- package/dist/_openapi_client/resources/sandboxes/snapshots.cjs +12 -2
- package/dist/_openapi_client/resources/sandboxes/snapshots.d.ts +25 -3
- package/dist/_openapi_client/resources/sandboxes/snapshots.js +12 -2
- package/dist/_openapi_client/resources/threads.cjs +1 -1
- package/dist/_openapi_client/resources/threads.d.ts +26 -1
- package/dist/_openapi_client/resources/threads.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/sandbox/client.cjs +55 -7
- package/dist/sandbox/client.d.ts +27 -1
- package/dist/sandbox/client.js +55 -7
- package/dist/sandbox/errors.cjs +17 -6
- package/dist/sandbox/errors.d.ts +12 -5
- package/dist/sandbox/errors.js +15 -5
- package/dist/sandbox/index.cjs +2 -1
- package/dist/sandbox/index.d.ts +2 -2
- package/dist/sandbox/index.js +1 -1
- package/dist/sandbox/sandbox.cjs +27 -1
- package/dist/sandbox/sandbox.d.ts +25 -1
- package/dist/sandbox/sandbox.js +28 -2
- package/dist/sandbox/types.d.ts +35 -0
- package/dist/sandbox/ws_execute.cjs +7 -3
- package/dist/sandbox/ws_execute.js +8 -4
- package/package.json +1 -1
|
@@ -21,6 +21,12 @@ export type IssuesOffsetPaginationIssues = OffsetPaginationIssues<Issue>;
|
|
|
21
21
|
export interface Issue {
|
|
22
22
|
id?: string;
|
|
23
23
|
actions?: unknown;
|
|
24
|
+
auto_resolution_evidence?: unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Nil unless eligible: "auto_close" or "prompt". Evidence carries the deciding
|
|
27
|
+
* gate.
|
|
28
|
+
*/
|
|
29
|
+
auto_resolution_state?: string;
|
|
24
30
|
created_at?: string;
|
|
25
31
|
description?: string;
|
|
26
32
|
first_seen_at?: string;
|
|
@@ -60,8 +60,8 @@ class OnlineEvaluators extends resource_js_1.APIResource {
|
|
|
60
60
|
/**
|
|
61
61
|
* Returns per-day LLM evaluator spend for the requested 7-day period, grouped by
|
|
62
62
|
* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
|
|
63
|
-
* session_id, or dataset_id is required. resource_id, type,
|
|
64
|
-
* be supplied with group_by to narrow listing aggregations.
|
|
63
|
+
* session_id, or dataset_id is required. resource_id, type, feedback_key, and
|
|
64
|
+
* tag_value_id may be supplied with group_by to narrow listing aggregations.
|
|
65
65
|
*/
|
|
66
66
|
spend(query, options) {
|
|
67
67
|
return this._client.get('/api/v1/platform/evaluators/spend', { query, ...options });
|
|
@@ -34,8 +34,8 @@ export declare class OnlineEvaluators extends APIResource {
|
|
|
34
34
|
/**
|
|
35
35
|
* Returns per-day LLM evaluator spend for the requested 7-day period, grouped by
|
|
36
36
|
* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
|
|
37
|
-
* session_id, or dataset_id is required. resource_id, type,
|
|
38
|
-
* be supplied with group_by to narrow listing aggregations.
|
|
37
|
+
* session_id, or dataset_id is required. resource_id, type, feedback_key, and
|
|
38
|
+
* tag_value_id may be supplied with group_by to narrow listing aggregations.
|
|
39
39
|
*/
|
|
40
40
|
spend(query: OnlineEvaluatorSpendParams, options?: RequestOptions): APIPromise<GetOnlineEvaluatorSpendResponse>;
|
|
41
41
|
}
|
|
@@ -286,6 +286,11 @@ export interface OnlineEvaluatorSpendParams {
|
|
|
286
286
|
* Filter to a specific project (UUID). Mutually exclusive with group_by.
|
|
287
287
|
*/
|
|
288
288
|
session_id?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Filter grouped results to evaluators, projects, or datasets tagged with all
|
|
291
|
+
* supplied tag value IDs. Only valid with group_by.
|
|
292
|
+
*/
|
|
293
|
+
tag_value_id?: Array<string>;
|
|
289
294
|
/**
|
|
290
295
|
* Filter grouped results by evaluator type: 'llm' or 'code'. Only valid with
|
|
291
296
|
* group_by.
|
|
@@ -57,8 +57,8 @@ export class OnlineEvaluators extends APIResource {
|
|
|
57
57
|
/**
|
|
58
58
|
* Returns per-day LLM evaluator spend for the requested 7-day period, grouped by
|
|
59
59
|
* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
|
|
60
|
-
* session_id, or dataset_id is required. resource_id, type,
|
|
61
|
-
* be supplied with group_by to narrow listing aggregations.
|
|
60
|
+
* session_id, or dataset_id is required. resource_id, type, feedback_key, and
|
|
61
|
+
* tag_value_id may be supplied with group_by to narrow listing aggregations.
|
|
62
62
|
*/
|
|
63
63
|
spend(query, options) {
|
|
64
64
|
return this._client.get('/api/v1/platform/evaluators/spend', { query, ...options });
|
|
@@ -69,7 +69,7 @@ export interface RunQueryParams {
|
|
|
69
69
|
*/
|
|
70
70
|
selects?: Array<'ID' | 'NAME' | 'RUN_TYPE' | 'STATUS' | 'START_TIME' | 'END_TIME' | 'LATENCY_SECONDS' | 'FIRST_TOKEN_TIME' | 'ERROR' | 'ERROR_PREVIEW' | 'EXTRA' | 'METADATA' | 'INPUTS_PREVIEW' | 'OUTPUTS_PREVIEW' | 'PARENT_RUN_ID' | 'PARENT_RUN_IDS' | 'PROJECT_ID' | 'TRACE_ID' | 'THREAD_ID' | 'DOTTED_ORDER' | 'IS_ROOT' | 'REFERENCE_DATASET_ID' | 'TOTAL_TOKENS' | 'PROMPT_TOKENS' | 'COMPLETION_TOKENS' | 'TOTAL_COST' | 'PROMPT_COST' | 'COMPLETION_COST' | 'PROMPT_TOKEN_DETAILS' | 'COMPLETION_TOKEN_DETAILS' | 'PROMPT_COST_DETAILS' | 'COMPLETION_COST_DETAILS' | 'PRICE_MODEL_ID' | 'TAGS' | 'THREAD_EVALUATION_TIME' | 'FEEDBACK_STATS'>;
|
|
71
71
|
/**
|
|
72
|
-
* Header param: application/json
|
|
72
|
+
* Header param: application/json or text/event-stream
|
|
73
73
|
*/
|
|
74
74
|
Accept?: string;
|
|
75
75
|
}
|
|
@@ -10,6 +10,8 @@ class Boxes extends resource_js_1.APIResource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Create a new sandbox from a snapshot. Provide at most one of `snapshot_id` or
|
|
12
12
|
* `snapshot_name`; if neither is provided, the server uses the default snapshot.
|
|
13
|
+
* `snapshot_name` accepts a Docker-style `name` or `name:tag` reference (a bare
|
|
14
|
+
* name resolves to `name:latest`).
|
|
13
15
|
*/
|
|
14
16
|
create(body, options) {
|
|
15
17
|
return this._client.post('/api/v2/sandboxes/boxes', { body, ...options });
|
|
@@ -6,6 +6,8 @@ export declare class Boxes extends APIResource {
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a new sandbox from a snapshot. Provide at most one of `snapshot_id` or
|
|
8
8
|
* `snapshot_name`; if neither is provided, the server uses the default snapshot.
|
|
9
|
+
* `snapshot_name` accepts a Docker-style `name` or `name:tag` reference (a bare
|
|
10
|
+
* name resolves to `name:latest`).
|
|
9
11
|
*/
|
|
10
12
|
create(body: BoxCreateParams, options?: RequestOptions): APIPromise<SandboxesAPI.SandboxResponse>;
|
|
11
13
|
/**
|
|
@@ -72,6 +74,12 @@ export interface BoxCreateParams {
|
|
|
72
74
|
labels?: {
|
|
73
75
|
[key: string]: string;
|
|
74
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Memory for the sandbox, in bytes. Memory is tied to CPU at 4 GiB per vCPU: omit
|
|
79
|
+
* it and it follows that ratio; set it and it must stay within 50% of the ratio
|
|
80
|
+
* for the requested CPU, so a 1 vCPU sandbox accepts 2-6 GiB. Setting memory
|
|
81
|
+
* without CPU derives the CPU from the same ratio. Maximum 64 GiB.
|
|
82
|
+
*/
|
|
75
83
|
mem_bytes?: number;
|
|
76
84
|
mount_config?: BoxCreateParams.MountConfig;
|
|
77
85
|
name?: string;
|
|
@@ -94,7 +102,16 @@ export interface BoxCreateParams {
|
|
|
94
102
|
* Applies to this request only.
|
|
95
103
|
*/
|
|
96
104
|
restore_memory?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Snapshot is a Docker-style name or name:tag reference to boot from. A bare name
|
|
107
|
+
* resolves to name:latest.
|
|
108
|
+
*/
|
|
109
|
+
snapshot?: string;
|
|
97
110
|
snapshot_id?: string;
|
|
111
|
+
/**
|
|
112
|
+
* SnapshotName is a synonym for Snapshot, accepted for compatibility with clients
|
|
113
|
+
* that predate it. Set one or the other.
|
|
114
|
+
*/
|
|
98
115
|
snapshot_name?: string;
|
|
99
116
|
tag_value_ids?: Array<string>;
|
|
100
117
|
vcpus?: number;
|
|
@@ -439,6 +456,10 @@ export interface BoxUpdateParams {
|
|
|
439
456
|
delete_after_stop_seconds?: number;
|
|
440
457
|
fs_capacity_bytes?: number;
|
|
441
458
|
idle_ttl_seconds?: number;
|
|
459
|
+
/**
|
|
460
|
+
* New memory for the sandbox, in bytes. The 4 GiB per vCPU ratio applies when the
|
|
461
|
+
* sandbox is created; a resize enforces only the maximum of 64 GiB.
|
|
462
|
+
*/
|
|
442
463
|
mem_bytes?: number;
|
|
443
464
|
name?: string;
|
|
444
465
|
proxy_config?: BoxUpdateParams.ProxyConfig;
|
|
@@ -596,6 +617,10 @@ export interface BoxCreateSnapshotParams {
|
|
|
596
617
|
labels?: {
|
|
597
618
|
[key: string]: string;
|
|
598
619
|
};
|
|
620
|
+
/**
|
|
621
|
+
* mutable Docker-style tag; defaults to "latest"
|
|
622
|
+
*/
|
|
623
|
+
tag?: string;
|
|
599
624
|
}
|
|
600
625
|
export interface BoxGenerateServiceURLParams {
|
|
601
626
|
expires_in_seconds?: number;
|
|
@@ -7,6 +7,8 @@ export class Boxes extends APIResource {
|
|
|
7
7
|
/**
|
|
8
8
|
* Create a new sandbox from a snapshot. Provide at most one of `snapshot_id` or
|
|
9
9
|
* `snapshot_name`; if neither is provided, the server uses the default snapshot.
|
|
10
|
+
* `snapshot_name` accepts a Docker-style `name` or `name:tag` reference (a bare
|
|
11
|
+
* name resolves to `name:latest`).
|
|
10
12
|
*/
|
|
11
13
|
create(body, options) {
|
|
12
14
|
return this._client.post('/api/v2/sandboxes/boxes', { body, ...options });
|
|
@@ -4,7 +4,7 @@ import { BoxCreateParams, BoxCreateSnapshotParams, BoxGenerateServiceURLParams,
|
|
|
4
4
|
import * as RegistriesAPI from './registries.js';
|
|
5
5
|
import { Registries, RegistryCreateParams, RegistryListParams, RegistryListResponse, RegistryResponse, RegistryUpdateParams } from './registries.js';
|
|
6
6
|
import * as SnapshotsAPI from './snapshots.js';
|
|
7
|
-
import { SnapshotCreateParams, SnapshotListParams, Snapshots } from './snapshots.js';
|
|
7
|
+
import { SnapshotCreateParams, SnapshotListParams, SnapshotRetrieveByNameResponse, Snapshots } from './snapshots.js';
|
|
8
8
|
export declare class Sandboxes extends APIResource {
|
|
9
9
|
boxes: BoxesAPI.Boxes;
|
|
10
10
|
registries: RegistriesAPI.Registries;
|
|
@@ -411,11 +411,16 @@ export interface SnapshotResponse {
|
|
|
411
411
|
source_sandbox_id?: string;
|
|
412
412
|
status?: string;
|
|
413
413
|
status_message?: string;
|
|
414
|
+
/**
|
|
415
|
+
* Tags currently resolving to this snapshot, under Name. A snapshot with no tags
|
|
416
|
+
* is dangling — addressable only by id.
|
|
417
|
+
*/
|
|
418
|
+
tags?: Array<string>;
|
|
414
419
|
updated_at?: string;
|
|
415
420
|
}
|
|
416
421
|
export declare namespace Sandboxes {
|
|
417
422
|
export { type SandboxListResponse as SandboxListResponse, type SandboxResponse as SandboxResponse, type SandboxStatusResponse as SandboxStatusResponse, type ServiceURLResponse as ServiceURLResponse, type SnapshotListResponse as SnapshotListResponse, type SnapshotResponse as SnapshotResponse, };
|
|
418
423
|
export { Boxes as Boxes, type BoxCreateParams as BoxCreateParams, type BoxUpdateParams as BoxUpdateParams, type BoxListParams as BoxListParams, type BoxCreateSnapshotParams as BoxCreateSnapshotParams, type BoxGenerateServiceURLParams as BoxGenerateServiceURLParams, };
|
|
419
424
|
export { Registries as Registries, type RegistryListResponse as RegistryListResponse, type RegistryResponse as RegistryResponse, type RegistryCreateParams as RegistryCreateParams, type RegistryUpdateParams as RegistryUpdateParams, type RegistryListParams as RegistryListParams, };
|
|
420
|
-
export { Snapshots as Snapshots, type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams, };
|
|
425
|
+
export { Snapshots as Snapshots, type SnapshotRetrieveByNameResponse as SnapshotRetrieveByNameResponse, type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams, };
|
|
421
426
|
}
|
|
@@ -6,7 +6,7 @@ import { Boxes, } from './boxes.js';
|
|
|
6
6
|
import * as RegistriesAPI from './registries.js';
|
|
7
7
|
import { Registries, } from './registries.js';
|
|
8
8
|
import * as SnapshotsAPI from './snapshots.js';
|
|
9
|
-
import { Snapshots } from './snapshots.js';
|
|
9
|
+
import { Snapshots, } from './snapshots.js';
|
|
10
10
|
export class Sandboxes extends APIResource {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
@@ -14,7 +14,9 @@ class Snapshots extends resource_js_1.APIResource {
|
|
|
14
14
|
return this._client.post('/api/v2/sandboxes/snapshots', { body, ...options });
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Get a sandbox snapshot by ID.
|
|
17
|
+
* Get a sandbox snapshot by ID or by a Docker-style reference. A bare name means
|
|
18
|
+
* name:latest, falling back to the newest ready untagged snapshot of that name. To
|
|
19
|
+
* list the tags under a name, use /api/v2/sandboxes/snapshots-by-name/{name}.
|
|
18
20
|
*/
|
|
19
21
|
retrieve(snapshotID, options) {
|
|
20
22
|
return this._client.get((0, path_js_1.path) `/api/v2/sandboxes/snapshots/${snapshotID}`, options);
|
|
@@ -27,7 +29,8 @@ class Snapshots extends resource_js_1.APIResource {
|
|
|
27
29
|
return this._client.get('/api/v2/sandboxes/snapshots', { query, ...options });
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
|
-
* Delete a snapshot by ID
|
|
32
|
+
* Delete a snapshot by ID or by a Docker-style name[:tag] reference. The
|
|
33
|
+
* underlying storage is reclaimed asynchronously.
|
|
31
34
|
*/
|
|
32
35
|
delete(snapshotID, options) {
|
|
33
36
|
return this._client.delete((0, path_js_1.path) `/api/v2/sandboxes/snapshots/${snapshotID}`, {
|
|
@@ -35,5 +38,12 @@ class Snapshots extends resource_js_1.APIResource {
|
|
|
35
38
|
headers: (0, headers_js_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
|
|
36
39
|
});
|
|
37
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a snapshot name and every tag under it, with the snapshot each tag resolves
|
|
43
|
+
* to. To fetch one snapshot, use /api/v2/sandboxes/snapshots/{snapshot_id}.
|
|
44
|
+
*/
|
|
45
|
+
retrieveByName(name, options) {
|
|
46
|
+
return this._client.get((0, path_js_1.path) `/api/v2/sandboxes/snapshots-by-name/${name}`, options);
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
exports.Snapshots = Snapshots;
|
|
@@ -8,7 +8,9 @@ export declare class Snapshots extends APIResource {
|
|
|
8
8
|
*/
|
|
9
9
|
create(body: SnapshotCreateParams, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotResponse>;
|
|
10
10
|
/**
|
|
11
|
-
* Get a sandbox snapshot by ID.
|
|
11
|
+
* Get a sandbox snapshot by ID or by a Docker-style reference. A bare name means
|
|
12
|
+
* name:latest, falling back to the newest ready untagged snapshot of that name. To
|
|
13
|
+
* list the tags under a name, use /api/v2/sandboxes/snapshots-by-name/{name}.
|
|
12
14
|
*/
|
|
13
15
|
retrieve(snapshotID: string, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotResponse>;
|
|
14
16
|
/**
|
|
@@ -17,9 +19,25 @@ export declare class Snapshots extends APIResource {
|
|
|
17
19
|
*/
|
|
18
20
|
list(query?: SnapshotListParams | null | undefined, options?: RequestOptions): APIPromise<SandboxesAPI.SnapshotListResponse>;
|
|
19
21
|
/**
|
|
20
|
-
* Delete a snapshot by ID
|
|
22
|
+
* Delete a snapshot by ID or by a Docker-style name[:tag] reference. The
|
|
23
|
+
* underlying storage is reclaimed asynchronously.
|
|
21
24
|
*/
|
|
22
25
|
delete(snapshotID: string, options?: RequestOptions): APIPromise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a snapshot name and every tag under it, with the snapshot each tag resolves
|
|
28
|
+
* to. To fetch one snapshot, use /api/v2/sandboxes/snapshots/{snapshot_id}.
|
|
29
|
+
*/
|
|
30
|
+
retrieveByName(name: string, options?: RequestOptions): APIPromise<SnapshotRetrieveByNameResponse>;
|
|
31
|
+
}
|
|
32
|
+
export interface SnapshotRetrieveByNameResponse {
|
|
33
|
+
name?: string;
|
|
34
|
+
tags?: Array<SnapshotRetrieveByNameResponse.Tag>;
|
|
35
|
+
}
|
|
36
|
+
export declare namespace SnapshotRetrieveByNameResponse {
|
|
37
|
+
interface Tag {
|
|
38
|
+
snapshot_id?: string;
|
|
39
|
+
tag?: string;
|
|
40
|
+
}
|
|
23
41
|
}
|
|
24
42
|
export interface SnapshotCreateParams {
|
|
25
43
|
docker_image: string;
|
|
@@ -33,6 +51,10 @@ export interface SnapshotCreateParams {
|
|
|
33
51
|
[key: string]: string;
|
|
34
52
|
};
|
|
35
53
|
registry_id?: string;
|
|
54
|
+
/**
|
|
55
|
+
* mutable Docker-style tag; defaults to "latest"
|
|
56
|
+
*/
|
|
57
|
+
tag?: string;
|
|
36
58
|
}
|
|
37
59
|
export interface SnapshotListParams {
|
|
38
60
|
/**
|
|
@@ -70,5 +92,5 @@ export interface SnapshotListParams {
|
|
|
70
92
|
status?: string;
|
|
71
93
|
}
|
|
72
94
|
export declare namespace Snapshots {
|
|
73
|
-
export { type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams };
|
|
95
|
+
export { type SnapshotRetrieveByNameResponse as SnapshotRetrieveByNameResponse, type SnapshotCreateParams as SnapshotCreateParams, type SnapshotListParams as SnapshotListParams, };
|
|
74
96
|
}
|
|
@@ -11,7 +11,9 @@ export class Snapshots extends APIResource {
|
|
|
11
11
|
return this._client.post('/api/v2/sandboxes/snapshots', { body, ...options });
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Get a sandbox snapshot by ID.
|
|
14
|
+
* Get a sandbox snapshot by ID or by a Docker-style reference. A bare name means
|
|
15
|
+
* name:latest, falling back to the newest ready untagged snapshot of that name. To
|
|
16
|
+
* list the tags under a name, use /api/v2/sandboxes/snapshots-by-name/{name}.
|
|
15
17
|
*/
|
|
16
18
|
retrieve(snapshotID, options) {
|
|
17
19
|
return this._client.get(path `/api/v2/sandboxes/snapshots/${snapshotID}`, options);
|
|
@@ -24,7 +26,8 @@ export class Snapshots extends APIResource {
|
|
|
24
26
|
return this._client.get('/api/v2/sandboxes/snapshots', { query, ...options });
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
|
-
* Delete a snapshot by ID
|
|
29
|
+
* Delete a snapshot by ID or by a Docker-style name[:tag] reference. The
|
|
30
|
+
* underlying storage is reclaimed asynchronously.
|
|
28
31
|
*/
|
|
29
32
|
delete(snapshotID, options) {
|
|
30
33
|
return this._client.delete(path `/api/v2/sandboxes/snapshots/${snapshotID}`, {
|
|
@@ -32,4 +35,11 @@ export class Snapshots extends APIResource {
|
|
|
32
35
|
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
33
36
|
});
|
|
34
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a snapshot name and every tag under it, with the snapshot each tag resolves
|
|
40
|
+
* to. To fetch one snapshot, use /api/v2/sandboxes/snapshots/{snapshot_id}.
|
|
41
|
+
*/
|
|
42
|
+
retrieveByName(name, options) {
|
|
43
|
+
return this._client.get(path `/api/v2/sandboxes/snapshots-by-name/${name}`, options);
|
|
44
|
+
}
|
|
35
45
|
}
|
|
@@ -28,7 +28,7 @@ class Threads extends resource_js_1.APIResource {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Query threads within a project (session), with cursor-based pagination. Returns
|
|
31
|
-
* threads matching the given time range and optional
|
|
31
|
+
* threads matching the given time range and optional filters.
|
|
32
32
|
*
|
|
33
33
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
34
34
|
*
|
|
@@ -22,7 +22,7 @@ export declare class Threads extends APIResource {
|
|
|
22
22
|
listTraces(threadID: string, query: ThreadListTracesParams, options?: RequestOptions): PagePromise<ThreadTracesItemsCursorGetPagination, ThreadTrace>;
|
|
23
23
|
/**
|
|
24
24
|
* Query threads within a project (session), with cursor-based pagination. Returns
|
|
25
|
-
* threads matching the given time range and optional
|
|
25
|
+
* threads matching the given time range and optional filters.
|
|
26
26
|
*
|
|
27
27
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
28
28
|
*
|
|
@@ -658,6 +658,31 @@ export interface ThreadQueryParams extends ItemsCursorPostPaginationParams {
|
|
|
658
658
|
* `project_id` is the tracing project UUID.
|
|
659
659
|
*/
|
|
660
660
|
project_id?: string;
|
|
661
|
+
/**
|
|
662
|
+
* `thread_filter` narrows results using a LangSmith filter expression evaluated
|
|
663
|
+
* against each complete thread summary. Self-hosted deployments require LangSmith
|
|
664
|
+
* v0.17 or later; unsupported deployments return 501. See
|
|
665
|
+
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
666
|
+
* for syntax.
|
|
667
|
+
*/
|
|
668
|
+
thread_filter?: string;
|
|
669
|
+
/**
|
|
670
|
+
* `trace_filter` narrows results to threads containing at least one trace whose
|
|
671
|
+
* root run matches this LangSmith filter expression. Trace-level aggregate fields
|
|
672
|
+
* are evaluated using the complete trace summary. Self-hosted deployments require
|
|
673
|
+
* LangSmith v0.17 or later; unsupported deployments return 501. See
|
|
674
|
+
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
675
|
+
* for syntax.
|
|
676
|
+
*/
|
|
677
|
+
trace_filter?: string;
|
|
678
|
+
/**
|
|
679
|
+
* `tree_filter` narrows results to threads containing at least one trace with a
|
|
680
|
+
* matching run anywhere in its run tree. Self-hosted deployments require LangSmith
|
|
681
|
+
* v0.17 or later; unsupported deployments return 501. See
|
|
682
|
+
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
683
|
+
* for syntax.
|
|
684
|
+
*/
|
|
685
|
+
tree_filter?: string;
|
|
661
686
|
}
|
|
662
687
|
export interface ThreadStatsParams {
|
|
663
688
|
/**
|
|
@@ -25,7 +25,7 @@ export class Threads extends APIResource {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Query threads within a project (session), with cursor-based pagination. Returns
|
|
28
|
-
* threads matching the given time range and optional
|
|
28
|
+
* threads matching the given time range and optional filters.
|
|
29
29
|
*
|
|
30
30
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
31
31
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,6 @@ Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, g
|
|
|
35
35
|
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return error_js_1.RateLimitError; } });
|
|
36
36
|
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_js_1.InternalServerError; } });
|
|
37
37
|
// Update using pnpm bump-version
|
|
38
|
-
exports.__version__ = "0.8.
|
|
38
|
+
exports.__version__ = "0.8.12";
|
|
39
39
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
40
40
|
exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { computeRunIdForSecondaryReplica, uuid7, uuid7FromTime, } from "./uuid.j
|
|
|
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
9
|
export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
|
|
10
|
-
export declare const __version__ = "0.8.
|
|
10
|
+
export declare const __version__ = "0.8.12";
|
|
11
11
|
export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,6 @@ export { isTracingEnabled } from "./utils/guard.js";
|
|
|
7
7
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
8
|
export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
|
|
9
9
|
// Update using pnpm bump-version
|
|
10
|
-
export const __version__ = "0.8.
|
|
10
|
+
export const __version__ = "0.8.12";
|
|
11
11
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
12
12
|
export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/sandbox/client.cjs
CHANGED
|
@@ -403,6 +403,10 @@ class SandboxClient {
|
|
|
403
403
|
* Callers can add specific status checks (e.g. 404) before calling this.
|
|
404
404
|
* @internal
|
|
405
405
|
*/
|
|
406
|
+
_boxUrl(name, ...segments) {
|
|
407
|
+
const suffix = segments.length ? `/${segments.join("/")}` : "";
|
|
408
|
+
return `${this._baseUrl}/boxes/${encodeURIComponent(name)}${suffix}`;
|
|
409
|
+
}
|
|
406
410
|
async _postJson(url, body, options) {
|
|
407
411
|
const response = await this._fetch(url, {
|
|
408
412
|
method: "POST",
|
|
@@ -487,7 +491,7 @@ class SandboxClient {
|
|
|
487
491
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
488
492
|
*/
|
|
489
493
|
async getSandbox(name, options) {
|
|
490
|
-
const url =
|
|
494
|
+
const url = this._boxUrl(name);
|
|
491
495
|
const response = await this._fetch(url, { signal: options?.signal });
|
|
492
496
|
if (!response.ok) {
|
|
493
497
|
if (response.status === 404) {
|
|
@@ -527,7 +531,7 @@ class SandboxClient {
|
|
|
527
531
|
deleteAfterStopSeconds === undefined) {
|
|
528
532
|
return this.getSandbox(name);
|
|
529
533
|
}
|
|
530
|
-
const url =
|
|
534
|
+
const url = this._boxUrl(name);
|
|
531
535
|
const payload = {};
|
|
532
536
|
if (newName !== undefined) {
|
|
533
537
|
payload.name = newName;
|
|
@@ -564,7 +568,7 @@ class SandboxClient {
|
|
|
564
568
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
565
569
|
*/
|
|
566
570
|
async deleteSandbox(name) {
|
|
567
|
-
const url =
|
|
571
|
+
const url = this._boxUrl(name);
|
|
568
572
|
const response = await this._fetch(url, { method: "DELETE" });
|
|
569
573
|
if (!response.ok) {
|
|
570
574
|
if (response.status === 404) {
|
|
@@ -584,7 +588,7 @@ class SandboxClient {
|
|
|
584
588
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
585
589
|
*/
|
|
586
590
|
async getSandboxStatus(name, options) {
|
|
587
|
-
const url =
|
|
591
|
+
const url = this._boxUrl(name, "status");
|
|
588
592
|
const response = await this._fetch(url, { signal: options?.signal });
|
|
589
593
|
if (!response.ok) {
|
|
590
594
|
if (response.status === 404) {
|
|
@@ -647,17 +651,61 @@ class SandboxClient {
|
|
|
647
651
|
*/
|
|
648
652
|
async startSandbox(name, options = {}) {
|
|
649
653
|
const { timeout = 120, signal } = options;
|
|
650
|
-
const url =
|
|
654
|
+
const url = this._boxUrl(name, "start");
|
|
651
655
|
await this._postJson(url, {}, { signal });
|
|
652
656
|
return this.waitForSandbox(name, { timeout, signal });
|
|
653
657
|
}
|
|
658
|
+
/**
|
|
659
|
+
* Create a link that downloads one file from a sandbox.
|
|
660
|
+
*
|
|
661
|
+
* The link carries its own token, so anyone holding the URL can fetch that
|
|
662
|
+
* one file without a LangSmith credential. It is pinned to the sandbox and
|
|
663
|
+
* the exact path and cannot be repointed at another file. Fetching wakes a
|
|
664
|
+
* stopped sandbox.
|
|
665
|
+
*
|
|
666
|
+
* Do not modify the file after minting a link for it. The link is pinned to
|
|
667
|
+
* a path, not to a snapshot of the contents, so a later write to that path
|
|
668
|
+
* may or may not be reflected in what the link serves. Write a new file and
|
|
669
|
+
* mint a new link when the contents change.
|
|
670
|
+
*
|
|
671
|
+
* @param name - Sandbox name.
|
|
672
|
+
* @param path - File path inside the sandbox.
|
|
673
|
+
* @param options - Expiry and response header overrides.
|
|
674
|
+
* @returns The link and its expiry, if any.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* const link = await client.generateDownloadURL("my-vm", "/tmp/report.pdf");
|
|
679
|
+
* console.log(link.download_url);
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
682
|
+
async generateDownloadURL(name, path, options = {}) {
|
|
683
|
+
const { expiresInSeconds, contentType, contentDisposition, signal } = options;
|
|
684
|
+
if (expiresInSeconds !== undefined && expiresInSeconds < 1) {
|
|
685
|
+
throw new errors_js_1.LangSmithValidationError(`expiresInSeconds must be greater than 0 (got ${expiresInSeconds}); ` +
|
|
686
|
+
`omit it for a link that never expires`);
|
|
687
|
+
}
|
|
688
|
+
const url = this._boxUrl(name, "download-url");
|
|
689
|
+
const payload = { path };
|
|
690
|
+
if (expiresInSeconds !== undefined) {
|
|
691
|
+
payload.expires_in_seconds = expiresInSeconds;
|
|
692
|
+
}
|
|
693
|
+
if (contentType !== undefined) {
|
|
694
|
+
payload.content_type = contentType;
|
|
695
|
+
}
|
|
696
|
+
if (contentDisposition !== undefined) {
|
|
697
|
+
payload.content_disposition = contentDisposition;
|
|
698
|
+
}
|
|
699
|
+
const response = await this._postJson(url, payload, { signal });
|
|
700
|
+
return (await response.json());
|
|
701
|
+
}
|
|
654
702
|
/**
|
|
655
703
|
* Stop a running sandbox (preserves sandbox files for later restart).
|
|
656
704
|
*
|
|
657
705
|
* @param name - Sandbox name.
|
|
658
706
|
*/
|
|
659
707
|
async stopSandbox(name) {
|
|
660
|
-
const url =
|
|
708
|
+
const url = this._boxUrl(name, "stop");
|
|
661
709
|
await this._postJson(url, {});
|
|
662
710
|
}
|
|
663
711
|
// =========================================================================
|
|
@@ -778,7 +826,7 @@ class SandboxClient {
|
|
|
778
826
|
*/
|
|
779
827
|
async captureSnapshot(sandboxName, name, options = {}) {
|
|
780
828
|
const { dockerImage, fsCapacityBytes, timeout = 60, signal } = options;
|
|
781
|
-
const url =
|
|
829
|
+
const url = this._boxUrl(sandboxName, "snapshot");
|
|
782
830
|
const payload = { name };
|
|
783
831
|
if (dockerImage !== undefined) {
|
|
784
832
|
payload.docker_image = dockerImage;
|
package/dist/sandbox/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Main SandboxClient class for interacting with the sandbox server API.
|
|
3
3
|
*/
|
|
4
4
|
import { Registries } from "../_openapi_client/resources/sandboxes/registries.js";
|
|
5
|
-
import type { CaptureSnapshotOptions, CreateDockerfileSnapshotOptions, CreateSandboxOptions, CreateSnapshotOptions, ListSnapshotsOptions, ResourceStatus, SandboxClientConfig, Snapshot, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, WaitForSnapshotOptions } from "./types.js";
|
|
5
|
+
import type { CaptureSnapshotOptions, CreateDockerfileSnapshotOptions, CreateSandboxOptions, CreateSnapshotOptions, DownloadURL, GenerateDownloadURLOptions, ListSnapshotsOptions, ResourceStatus, SandboxClientConfig, Snapshot, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, WaitForSnapshotOptions } from "./types.js";
|
|
6
6
|
import { Sandbox } from "./sandbox.js";
|
|
7
7
|
/**
|
|
8
8
|
* Client for interacting with the Sandbox Server API.
|
|
@@ -64,6 +64,7 @@ export declare class SandboxClient {
|
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
get registries(): Registries;
|
|
67
|
+
private _postJson;
|
|
67
68
|
/**
|
|
68
69
|
* Create a new Sandbox.
|
|
69
70
|
*
|
|
@@ -181,6 +182,31 @@ export declare class SandboxClient {
|
|
|
181
182
|
* @returns Sandbox in "ready" status.
|
|
182
183
|
*/
|
|
183
184
|
startSandbox(name: string, options?: StartSandboxOptions): Promise<Sandbox>;
|
|
185
|
+
/**
|
|
186
|
+
* Create a link that downloads one file from a sandbox.
|
|
187
|
+
*
|
|
188
|
+
* The link carries its own token, so anyone holding the URL can fetch that
|
|
189
|
+
* one file without a LangSmith credential. It is pinned to the sandbox and
|
|
190
|
+
* the exact path and cannot be repointed at another file. Fetching wakes a
|
|
191
|
+
* stopped sandbox.
|
|
192
|
+
*
|
|
193
|
+
* Do not modify the file after minting a link for it. The link is pinned to
|
|
194
|
+
* a path, not to a snapshot of the contents, so a later write to that path
|
|
195
|
+
* may or may not be reflected in what the link serves. Write a new file and
|
|
196
|
+
* mint a new link when the contents change.
|
|
197
|
+
*
|
|
198
|
+
* @param name - Sandbox name.
|
|
199
|
+
* @param path - File path inside the sandbox.
|
|
200
|
+
* @param options - Expiry and response header overrides.
|
|
201
|
+
* @returns The link and its expiry, if any.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const link = await client.generateDownloadURL("my-vm", "/tmp/report.pdf");
|
|
206
|
+
* console.log(link.download_url);
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
generateDownloadURL(name: string, path: string, options?: GenerateDownloadURLOptions): Promise<DownloadURL>;
|
|
184
210
|
/**
|
|
185
211
|
* Stop a running sandbox (preserves sandbox files for later restart).
|
|
186
212
|
*
|
package/dist/sandbox/client.js
CHANGED
|
@@ -400,6 +400,10 @@ export class SandboxClient {
|
|
|
400
400
|
* Callers can add specific status checks (e.g. 404) before calling this.
|
|
401
401
|
* @internal
|
|
402
402
|
*/
|
|
403
|
+
_boxUrl(name, ...segments) {
|
|
404
|
+
const suffix = segments.length ? `/${segments.join("/")}` : "";
|
|
405
|
+
return `${this._baseUrl}/boxes/${encodeURIComponent(name)}${suffix}`;
|
|
406
|
+
}
|
|
403
407
|
async _postJson(url, body, options) {
|
|
404
408
|
const response = await this._fetch(url, {
|
|
405
409
|
method: "POST",
|
|
@@ -484,7 +488,7 @@ export class SandboxClient {
|
|
|
484
488
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
485
489
|
*/
|
|
486
490
|
async getSandbox(name, options) {
|
|
487
|
-
const url =
|
|
491
|
+
const url = this._boxUrl(name);
|
|
488
492
|
const response = await this._fetch(url, { signal: options?.signal });
|
|
489
493
|
if (!response.ok) {
|
|
490
494
|
if (response.status === 404) {
|
|
@@ -524,7 +528,7 @@ export class SandboxClient {
|
|
|
524
528
|
deleteAfterStopSeconds === undefined) {
|
|
525
529
|
return this.getSandbox(name);
|
|
526
530
|
}
|
|
527
|
-
const url =
|
|
531
|
+
const url = this._boxUrl(name);
|
|
528
532
|
const payload = {};
|
|
529
533
|
if (newName !== undefined) {
|
|
530
534
|
payload.name = newName;
|
|
@@ -561,7 +565,7 @@ export class SandboxClient {
|
|
|
561
565
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
562
566
|
*/
|
|
563
567
|
async deleteSandbox(name) {
|
|
564
|
-
const url =
|
|
568
|
+
const url = this._boxUrl(name);
|
|
565
569
|
const response = await this._fetch(url, { method: "DELETE" });
|
|
566
570
|
if (!response.ok) {
|
|
567
571
|
if (response.status === 404) {
|
|
@@ -581,7 +585,7 @@ export class SandboxClient {
|
|
|
581
585
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
582
586
|
*/
|
|
583
587
|
async getSandboxStatus(name, options) {
|
|
584
|
-
const url =
|
|
588
|
+
const url = this._boxUrl(name, "status");
|
|
585
589
|
const response = await this._fetch(url, { signal: options?.signal });
|
|
586
590
|
if (!response.ok) {
|
|
587
591
|
if (response.status === 404) {
|
|
@@ -644,17 +648,61 @@ export class SandboxClient {
|
|
|
644
648
|
*/
|
|
645
649
|
async startSandbox(name, options = {}) {
|
|
646
650
|
const { timeout = 120, signal } = options;
|
|
647
|
-
const url =
|
|
651
|
+
const url = this._boxUrl(name, "start");
|
|
648
652
|
await this._postJson(url, {}, { signal });
|
|
649
653
|
return this.waitForSandbox(name, { timeout, signal });
|
|
650
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* Create a link that downloads one file from a sandbox.
|
|
657
|
+
*
|
|
658
|
+
* The link carries its own token, so anyone holding the URL can fetch that
|
|
659
|
+
* one file without a LangSmith credential. It is pinned to the sandbox and
|
|
660
|
+
* the exact path and cannot be repointed at another file. Fetching wakes a
|
|
661
|
+
* stopped sandbox.
|
|
662
|
+
*
|
|
663
|
+
* Do not modify the file after minting a link for it. The link is pinned to
|
|
664
|
+
* a path, not to a snapshot of the contents, so a later write to that path
|
|
665
|
+
* may or may not be reflected in what the link serves. Write a new file and
|
|
666
|
+
* mint a new link when the contents change.
|
|
667
|
+
*
|
|
668
|
+
* @param name - Sandbox name.
|
|
669
|
+
* @param path - File path inside the sandbox.
|
|
670
|
+
* @param options - Expiry and response header overrides.
|
|
671
|
+
* @returns The link and its expiry, if any.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const link = await client.generateDownloadURL("my-vm", "/tmp/report.pdf");
|
|
676
|
+
* console.log(link.download_url);
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
async generateDownloadURL(name, path, options = {}) {
|
|
680
|
+
const { expiresInSeconds, contentType, contentDisposition, signal } = options;
|
|
681
|
+
if (expiresInSeconds !== undefined && expiresInSeconds < 1) {
|
|
682
|
+
throw new LangSmithValidationError(`expiresInSeconds must be greater than 0 (got ${expiresInSeconds}); ` +
|
|
683
|
+
`omit it for a link that never expires`);
|
|
684
|
+
}
|
|
685
|
+
const url = this._boxUrl(name, "download-url");
|
|
686
|
+
const payload = { path };
|
|
687
|
+
if (expiresInSeconds !== undefined) {
|
|
688
|
+
payload.expires_in_seconds = expiresInSeconds;
|
|
689
|
+
}
|
|
690
|
+
if (contentType !== undefined) {
|
|
691
|
+
payload.content_type = contentType;
|
|
692
|
+
}
|
|
693
|
+
if (contentDisposition !== undefined) {
|
|
694
|
+
payload.content_disposition = contentDisposition;
|
|
695
|
+
}
|
|
696
|
+
const response = await this._postJson(url, payload, { signal });
|
|
697
|
+
return (await response.json());
|
|
698
|
+
}
|
|
651
699
|
/**
|
|
652
700
|
* Stop a running sandbox (preserves sandbox files for later restart).
|
|
653
701
|
*
|
|
654
702
|
* @param name - Sandbox name.
|
|
655
703
|
*/
|
|
656
704
|
async stopSandbox(name) {
|
|
657
|
-
const url =
|
|
705
|
+
const url = this._boxUrl(name, "stop");
|
|
658
706
|
await this._postJson(url, {});
|
|
659
707
|
}
|
|
660
708
|
// =========================================================================
|
|
@@ -775,7 +823,7 @@ export class SandboxClient {
|
|
|
775
823
|
*/
|
|
776
824
|
async captureSnapshot(sandboxName, name, options = {}) {
|
|
777
825
|
const { dockerImage, fsCapacityBytes, timeout = 60, signal } = options;
|
|
778
|
-
const url =
|
|
826
|
+
const url = this._boxUrl(sandboxName, "snapshot");
|
|
779
827
|
const payload = { name };
|
|
780
828
|
if (dockerImage !== undefined) {
|
|
781
829
|
payload.docker_image = dockerImage;
|
package/dist/sandbox/errors.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* properties for specific handling when needed.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
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;
|
|
10
|
+
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;
|
|
11
11
|
/**
|
|
12
12
|
* Base exception for sandbox client errors.
|
|
13
13
|
*/
|
|
@@ -53,6 +53,19 @@ class LangSmithSandboxConnectionError extends LangSmithSandboxError {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
exports.LangSmithSandboxConnectionError = LangSmithSandboxConnectionError;
|
|
56
|
+
/**
|
|
57
|
+
* Raised when a transient connection failure occurs before a command starts.
|
|
58
|
+
*
|
|
59
|
+
* `run()` retries this error with the same command ID so the server can
|
|
60
|
+
* deduplicate an attempt whose outcome is unknown.
|
|
61
|
+
*/
|
|
62
|
+
class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "LangSmithSandboxRetryableConnectionError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.LangSmithSandboxRetryableConnectionError = LangSmithSandboxRetryableConnectionError;
|
|
56
69
|
// =============================================================================
|
|
57
70
|
// Resource Errors (type-based, with resourceType property)
|
|
58
71
|
// =============================================================================
|
|
@@ -375,12 +388,10 @@ exports.LangSmithStreamEndedBeforeStartedError = LangSmithStreamEndedBeforeStart
|
|
|
375
388
|
/**
|
|
376
389
|
* Thrown when the socket fails or times out before the WebSocket handshake.
|
|
377
390
|
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* command. run() retries this with backoff; a plain connection error (a
|
|
381
|
-
* rejected handshake) is permanent and propagates immediately.
|
|
391
|
+
* The execute frame was never sent, so re-issuing the same command ID cannot
|
|
392
|
+
* double-run a command.
|
|
382
393
|
*/
|
|
383
|
-
class LangSmithSandboxConnectTimeoutError extends
|
|
394
|
+
class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxRetryableConnectionError {
|
|
384
395
|
constructor(message) {
|
|
385
396
|
super(message);
|
|
386
397
|
this.name = "LangSmithSandboxConnectTimeoutError";
|
package/dist/sandbox/errors.d.ts
CHANGED
|
@@ -31,6 +31,15 @@ export declare class LangSmithSandboxAuthenticationError extends LangSmithSandbo
|
|
|
31
31
|
export declare class LangSmithSandboxConnectionError extends LangSmithSandboxError {
|
|
32
32
|
constructor(message: string);
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Raised when a transient connection failure occurs before a command starts.
|
|
36
|
+
*
|
|
37
|
+
* `run()` retries this error with the same command ID so the server can
|
|
38
|
+
* deduplicate an attempt whose outcome is unknown.
|
|
39
|
+
*/
|
|
40
|
+
export declare class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
34
43
|
/**
|
|
35
44
|
* Raised when a resource is not found.
|
|
36
45
|
*/
|
|
@@ -168,12 +177,10 @@ export declare class LangSmithStreamEndedBeforeStartedError extends LangSmithSan
|
|
|
168
177
|
/**
|
|
169
178
|
* Thrown when the socket fails or times out before the WebSocket handshake.
|
|
170
179
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* command. run() retries this with backoff; a plain connection error (a
|
|
174
|
-
* rejected handshake) is permanent and propagates immediately.
|
|
180
|
+
* The execute frame was never sent, so re-issuing the same command ID cannot
|
|
181
|
+
* double-run a command.
|
|
175
182
|
*/
|
|
176
|
-
export declare class LangSmithSandboxConnectTimeoutError extends
|
|
183
|
+
export declare class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxRetryableConnectionError {
|
|
177
184
|
constructor(message: string);
|
|
178
185
|
}
|
|
179
186
|
/**
|
package/dist/sandbox/errors.js
CHANGED
|
@@ -46,6 +46,18 @@ export class LangSmithSandboxConnectionError extends LangSmithSandboxError {
|
|
|
46
46
|
this.name = "LangSmithSandboxConnectionError";
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Raised when a transient connection failure occurs before a command starts.
|
|
51
|
+
*
|
|
52
|
+
* `run()` retries this error with the same command ID so the server can
|
|
53
|
+
* deduplicate an attempt whose outcome is unknown.
|
|
54
|
+
*/
|
|
55
|
+
export class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = "LangSmithSandboxRetryableConnectionError";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
49
61
|
// =============================================================================
|
|
50
62
|
// Resource Errors (type-based, with resourceType property)
|
|
51
63
|
// =============================================================================
|
|
@@ -354,12 +366,10 @@ export class LangSmithStreamEndedBeforeStartedError extends LangSmithSandboxOper
|
|
|
354
366
|
/**
|
|
355
367
|
* Thrown when the socket fails or times out before the WebSocket handshake.
|
|
356
368
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* command. run() retries this with backoff; a plain connection error (a
|
|
360
|
-
* rejected handshake) is permanent and propagates immediately.
|
|
369
|
+
* The execute frame was never sent, so re-issuing the same command ID cannot
|
|
370
|
+
* double-run a command.
|
|
361
371
|
*/
|
|
362
|
-
export class LangSmithSandboxConnectTimeoutError extends
|
|
372
|
+
export class LangSmithSandboxConnectTimeoutError extends LangSmithSandboxRetryableConnectionError {
|
|
363
373
|
constructor(message) {
|
|
364
374
|
super(message);
|
|
365
375
|
this.name = "LangSmithSandboxConnectTimeoutError";
|
package/dist/sandbox/index.cjs
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* @packageDocumentation
|
|
30
30
|
*/
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
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;
|
|
32
|
+
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;
|
|
33
33
|
// Main classes
|
|
34
34
|
var client_js_1 = require("./client.cjs");
|
|
35
35
|
Object.defineProperty(exports, "SandboxClient", { enumerable: true, get: function () { return client_js_1.SandboxClient; } });
|
|
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "LangSmithSandboxError", { enumerable: true, get:
|
|
|
56
56
|
Object.defineProperty(exports, "LangSmithSandboxAPIError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxAPIError; } });
|
|
57
57
|
Object.defineProperty(exports, "LangSmithSandboxAuthenticationError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxAuthenticationError; } });
|
|
58
58
|
Object.defineProperty(exports, "LangSmithSandboxConnectionError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxConnectionError; } });
|
|
59
|
+
Object.defineProperty(exports, "LangSmithSandboxRetryableConnectionError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxRetryableConnectionError; } });
|
|
59
60
|
Object.defineProperty(exports, "LangSmithSandboxConnectTimeoutError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxConnectTimeoutError; } });
|
|
60
61
|
Object.defineProperty(exports, "LangSmithSandboxServerReloadError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxServerReloadError; } });
|
|
61
62
|
// Resource errors (type-based with resourceType attribute)
|
package/dist/sandbox/index.d.ts
CHANGED
|
@@ -32,5 +32,5 @@ export { Sandbox } from "./sandbox.js";
|
|
|
32
32
|
export { CommandHandle } from "./command_handle.js";
|
|
33
33
|
export { awsAuth, gcpAuth, opaqueSecret, proxyConfig, workspaceSecret, } from "./proxy_config.js";
|
|
34
34
|
export { contextHubMount, gcsMount, gitMount, mountConfig, s3Mount, } from "./mounts.js";
|
|
35
|
-
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";
|
|
36
|
-
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
|
35
|
+
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";
|
|
36
|
+
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxRetryableConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
package/dist/sandbox/index.js
CHANGED
|
@@ -36,7 +36,7 @@ export { contextHubMount, gcsMount, gitMount, mountConfig, s3Mount, } from "./mo
|
|
|
36
36
|
// Errors
|
|
37
37
|
export {
|
|
38
38
|
// Base and connection errors
|
|
39
|
-
LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError,
|
|
39
|
+
LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxRetryableConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError,
|
|
40
40
|
// Resource errors (type-based with resourceType attribute)
|
|
41
41
|
LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError,
|
|
42
42
|
// Validation and quota errors
|
package/dist/sandbox/sandbox.cjs
CHANGED
|
@@ -264,7 +264,7 @@ class Sandbox {
|
|
|
264
264
|
// Idempotent re-issue (same command_id): neither an early close nor a
|
|
265
265
|
// failed connect can have started a second command.
|
|
266
266
|
if (!(e instanceof errors_js_1.LangSmithStreamEndedBeforeStartedError) &&
|
|
267
|
-
!(e instanceof errors_js_1.
|
|
267
|
+
!(e instanceof errors_js_1.LangSmithSandboxRetryableConnectionError)) {
|
|
268
268
|
throw e;
|
|
269
269
|
}
|
|
270
270
|
attempt++;
|
|
@@ -410,6 +410,32 @@ class Sandbox {
|
|
|
410
410
|
const buffer = await response.arrayBuffer();
|
|
411
411
|
return new Uint8Array(buffer);
|
|
412
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Create a link that downloads one file from this sandbox.
|
|
415
|
+
*
|
|
416
|
+
* The link carries its own token, so anyone holding the URL can fetch that
|
|
417
|
+
* one file without a LangSmith credential. Fetching wakes a stopped sandbox.
|
|
418
|
+
*
|
|
419
|
+
* Do not modify the file after minting a link for it. The link is pinned to
|
|
420
|
+
* a path, not to a snapshot of the contents, so a later write to that path
|
|
421
|
+
* may or may not be reflected in what the link serves. Write a new file and
|
|
422
|
+
* mint a new link when the contents change.
|
|
423
|
+
*
|
|
424
|
+
* @param path - File path inside the sandbox.
|
|
425
|
+
* @param options - Expiry and response header overrides.
|
|
426
|
+
* @returns The link and its expiry, if any.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* const link = await sandbox.generateDownloadURL("/tmp/report.pdf", {
|
|
431
|
+
* expiresInSeconds: 3600,
|
|
432
|
+
* });
|
|
433
|
+
* console.log(link.download_url);
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
async generateDownloadURL(path, options = {}) {
|
|
437
|
+
return this._client.generateDownloadURL(this.name, path, options);
|
|
438
|
+
}
|
|
413
439
|
/**
|
|
414
440
|
* Delete this sandbox.
|
|
415
441
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sandbox class for interacting with a specific sandbox instance.
|
|
3
3
|
*/
|
|
4
|
-
import type { CaptureSnapshotOptions, ExecutionResult, RunOptions, Snapshot, StartSandboxOptions } from "./types.js";
|
|
4
|
+
import type { CaptureSnapshotOptions, DownloadURL, ExecutionResult, GenerateDownloadURLOptions, RunOptions, Snapshot, StartSandboxOptions } from "./types.js";
|
|
5
5
|
import { CommandHandle } from "./command_handle.js";
|
|
6
6
|
/**
|
|
7
7
|
* Represents an active sandbox for running commands and file operations.
|
|
@@ -155,6 +155,30 @@ export declare class Sandbox {
|
|
|
155
155
|
* ```
|
|
156
156
|
*/
|
|
157
157
|
read(path: string, timeout?: number): Promise<Uint8Array>;
|
|
158
|
+
/**
|
|
159
|
+
* Create a link that downloads one file from this sandbox.
|
|
160
|
+
*
|
|
161
|
+
* The link carries its own token, so anyone holding the URL can fetch that
|
|
162
|
+
* one file without a LangSmith credential. Fetching wakes a stopped sandbox.
|
|
163
|
+
*
|
|
164
|
+
* Do not modify the file after minting a link for it. The link is pinned to
|
|
165
|
+
* a path, not to a snapshot of the contents, so a later write to that path
|
|
166
|
+
* may or may not be reflected in what the link serves. Write a new file and
|
|
167
|
+
* mint a new link when the contents change.
|
|
168
|
+
*
|
|
169
|
+
* @param path - File path inside the sandbox.
|
|
170
|
+
* @param options - Expiry and response header overrides.
|
|
171
|
+
* @returns The link and its expiry, if any.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const link = await sandbox.generateDownloadURL("/tmp/report.pdf", {
|
|
176
|
+
* expiresInSeconds: 3600,
|
|
177
|
+
* });
|
|
178
|
+
* console.log(link.download_url);
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
generateDownloadURL(path: string, options?: GenerateDownloadURLOptions): Promise<DownloadURL>;
|
|
158
182
|
/**
|
|
159
183
|
* Delete this sandbox.
|
|
160
184
|
*
|
package/dist/sandbox/sandbox.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Sandbox class for interacting with a specific sandbox instance.
|
|
3
3
|
*/
|
|
4
4
|
import { uuid7 } from "../uuid.js";
|
|
5
|
-
import { LangSmithDataplaneNotConfiguredError,
|
|
5
|
+
import { LangSmithDataplaneNotConfiguredError, LangSmithSandboxRetryableConnectionError, LangSmithStreamEndedBeforeStartedError, } from "./errors.js";
|
|
6
6
|
import { handleSandboxHttpError } from "./helpers.js";
|
|
7
7
|
import { CommandHandle } from "./command_handle.js";
|
|
8
8
|
import { connectDeadline, isWsAvailable, openTimeoutFor, reconnectWsStream, remainingBudget, runWsStream, } from "./ws_execute.js";
|
|
@@ -261,7 +261,7 @@ export class Sandbox {
|
|
|
261
261
|
// Idempotent re-issue (same command_id): neither an early close nor a
|
|
262
262
|
// failed connect can have started a second command.
|
|
263
263
|
if (!(e instanceof LangSmithStreamEndedBeforeStartedError) &&
|
|
264
|
-
!(e instanceof
|
|
264
|
+
!(e instanceof LangSmithSandboxRetryableConnectionError)) {
|
|
265
265
|
throw e;
|
|
266
266
|
}
|
|
267
267
|
attempt++;
|
|
@@ -407,6 +407,32 @@ export class Sandbox {
|
|
|
407
407
|
const buffer = await response.arrayBuffer();
|
|
408
408
|
return new Uint8Array(buffer);
|
|
409
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Create a link that downloads one file from this sandbox.
|
|
412
|
+
*
|
|
413
|
+
* The link carries its own token, so anyone holding the URL can fetch that
|
|
414
|
+
* one file without a LangSmith credential. Fetching wakes a stopped sandbox.
|
|
415
|
+
*
|
|
416
|
+
* Do not modify the file after minting a link for it. The link is pinned to
|
|
417
|
+
* a path, not to a snapshot of the contents, so a later write to that path
|
|
418
|
+
* may or may not be reflected in what the link serves. Write a new file and
|
|
419
|
+
* mint a new link when the contents change.
|
|
420
|
+
*
|
|
421
|
+
* @param path - File path inside the sandbox.
|
|
422
|
+
* @param options - Expiry and response header overrides.
|
|
423
|
+
* @returns The link and its expiry, if any.
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```typescript
|
|
427
|
+
* const link = await sandbox.generateDownloadURL("/tmp/report.pdf", {
|
|
428
|
+
* expiresInSeconds: 3600,
|
|
429
|
+
* });
|
|
430
|
+
* console.log(link.download_url);
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
async generateDownloadURL(path, options = {}) {
|
|
434
|
+
return this._client.generateDownloadURL(this.name, path, options);
|
|
435
|
+
}
|
|
410
436
|
/**
|
|
411
437
|
* Delete this sandbox.
|
|
412
438
|
*
|
package/dist/sandbox/types.d.ts
CHANGED
|
@@ -559,6 +559,41 @@ export interface CaptureSnapshotOptions {
|
|
|
559
559
|
/** AbortSignal for cancellation. */
|
|
560
560
|
signal?: AbortSignal;
|
|
561
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* How a download link asks the browser to handle the file.
|
|
564
|
+
*/
|
|
565
|
+
export type DownloadContentDisposition = "attachment" | "inline";
|
|
566
|
+
/**
|
|
567
|
+
* Options for minting a sandbox file download link.
|
|
568
|
+
*/
|
|
569
|
+
export interface GenerateDownloadURLOptions {
|
|
570
|
+
/**
|
|
571
|
+
* Link TTL in seconds. Omit for a link that never expires.
|
|
572
|
+
*/
|
|
573
|
+
expiresInSeconds?: number;
|
|
574
|
+
/** Content-Type to serve the file as. */
|
|
575
|
+
contentType?: string;
|
|
576
|
+
/** Content-Disposition to serve the file with. */
|
|
577
|
+
contentDisposition?: DownloadContentDisposition;
|
|
578
|
+
/** AbortSignal for cancellation. */
|
|
579
|
+
signal?: AbortSignal;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* A link that downloads one sandbox file with no LangSmith credential.
|
|
583
|
+
*
|
|
584
|
+
* The link is pinned to the sandbox, the file path, and the response headers,
|
|
585
|
+
* so it cannot be repointed at another file. It is pinned to the path rather
|
|
586
|
+
* than to a snapshot of the contents, so the file must not be modified while
|
|
587
|
+
* the link is in use.
|
|
588
|
+
*/
|
|
589
|
+
export interface DownloadURL {
|
|
590
|
+
/** The full URL to fetch. Supports GET, HEAD, and Range. */
|
|
591
|
+
download_url: string;
|
|
592
|
+
/** The signed token embedded in `download_url`. */
|
|
593
|
+
token: string;
|
|
594
|
+
/** Expiry timestamp, or null for a link that never expires. */
|
|
595
|
+
expires_at: string | null;
|
|
596
|
+
}
|
|
562
597
|
/**
|
|
563
598
|
* Options for listing snapshots. All fields are optional and independent.
|
|
564
599
|
*
|
|
@@ -35,6 +35,7 @@ exports.WS_OPEN_TIMEOUT = envTimeout("SANDBOX_WS_TIMEOUT_OPEN", 30);
|
|
|
35
35
|
// Ceiling on the whole connect phase. Without it, retrying a blackholed
|
|
36
36
|
// handshake costs MAX_AUTO_RECONNECTS + 1 full open timeouts plus backoff.
|
|
37
37
|
exports.WS_CONNECT_BUDGET = envTimeout("SANDBOX_WS_TIMEOUT_CONNECT_BUDGET", 120);
|
|
38
|
+
const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([500, 502, 503, 504]);
|
|
38
39
|
function nowSeconds() {
|
|
39
40
|
return performance.now() / 1000;
|
|
40
41
|
}
|
|
@@ -184,8 +185,8 @@ function raiseForWsError(msg, commandId = "") {
|
|
|
184
185
|
* Create a ws WebSocket connection and return a promise that resolves when open
|
|
185
186
|
* or rejects on error.
|
|
186
187
|
*
|
|
187
|
-
*
|
|
188
|
-
* non-101
|
|
188
|
+
* Socket-level failures and transient 5xx responses are retryable. Other
|
|
189
|
+
* non-101 responses are permanent connection errors.
|
|
189
190
|
*/
|
|
190
191
|
async function connectWs(url, headers, openTimeout = exports.WS_OPEN_TIMEOUT) {
|
|
191
192
|
const { WebSocket: WS } = await ensureWs();
|
|
@@ -210,7 +211,10 @@ async function connectWs(url, headers, openTimeout = exports.WS_OPEN_TIMEOUT) {
|
|
|
210
211
|
if (settled)
|
|
211
212
|
return;
|
|
212
213
|
settled = true;
|
|
213
|
-
|
|
214
|
+
const ErrorType = RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)
|
|
215
|
+
? errors_js_1.LangSmithSandboxRetryableConnectionError
|
|
216
|
+
: errors_js_1.LangSmithSandboxConnectionError;
|
|
217
|
+
reject(new ErrorType(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
|
|
214
218
|
});
|
|
215
219
|
// Stays attached after settling so a late error has a listener and cannot
|
|
216
220
|
// become an unhandled 'error' event.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Uses the `ws` npm package (optional peer dependency).
|
|
5
5
|
* Install with: npm install ws
|
|
6
6
|
*/
|
|
7
|
-
import { LangSmithCommandTimeoutError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxOperationError, LangSmithSandboxServerReloadError, } from "./errors.js";
|
|
7
|
+
import { LangSmithCommandTimeoutError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxOperationError, LangSmithSandboxRetryableConnectionError, LangSmithSandboxServerReloadError, } from "./errors.js";
|
|
8
8
|
import { getLangSmithEnvironmentVariable } from "../utils/env.js";
|
|
9
9
|
/** Read a WebSocket timeout override, in seconds. `<= 0` disables it. */
|
|
10
10
|
function envTimeout(name, defaultSeconds) {
|
|
@@ -23,6 +23,7 @@ export const WS_OPEN_TIMEOUT = envTimeout("SANDBOX_WS_TIMEOUT_OPEN", 30);
|
|
|
23
23
|
// Ceiling on the whole connect phase. Without it, retrying a blackholed
|
|
24
24
|
// handshake costs MAX_AUTO_RECONNECTS + 1 full open timeouts plus backoff.
|
|
25
25
|
export const WS_CONNECT_BUDGET = envTimeout("SANDBOX_WS_TIMEOUT_CONNECT_BUDGET", 120);
|
|
26
|
+
const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([500, 502, 503, 504]);
|
|
26
27
|
function nowSeconds() {
|
|
27
28
|
return performance.now() / 1000;
|
|
28
29
|
}
|
|
@@ -171,8 +172,8 @@ export function raiseForWsError(msg, commandId = "") {
|
|
|
171
172
|
* Create a ws WebSocket connection and return a promise that resolves when open
|
|
172
173
|
* or rejects on error.
|
|
173
174
|
*
|
|
174
|
-
*
|
|
175
|
-
* non-101
|
|
175
|
+
* Socket-level failures and transient 5xx responses are retryable. Other
|
|
176
|
+
* non-101 responses are permanent connection errors.
|
|
176
177
|
*/
|
|
177
178
|
async function connectWs(url, headers, openTimeout = WS_OPEN_TIMEOUT) {
|
|
178
179
|
const { WebSocket: WS } = await ensureWs();
|
|
@@ -197,7 +198,10 @@ async function connectWs(url, headers, openTimeout = WS_OPEN_TIMEOUT) {
|
|
|
197
198
|
if (settled)
|
|
198
199
|
return;
|
|
199
200
|
settled = true;
|
|
200
|
-
|
|
201
|
+
const ErrorType = RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)
|
|
202
|
+
? LangSmithSandboxRetryableConnectionError
|
|
203
|
+
: LangSmithSandboxConnectionError;
|
|
204
|
+
reject(new ErrorType(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
|
|
201
205
|
});
|
|
202
206
|
// Stays attached after settling so a late error has a listener and cannot
|
|
203
207
|
// become an unhandled 'error' event.
|