langsmith 0.10.11 → 0.10.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/CHANGELOG.md +28 -0
- package/README.md +198 -198
- package/lib/address.d.mts +35 -56
- package/lib/address.d.mts.map +1 -1
- package/lib/address.d.ts +35 -56
- package/lib/address.d.ts.map +1 -1
- package/lib/address.js +91 -156
- package/lib/address.js.map +1 -1
- package/lib/address.mjs +83 -151
- package/lib/address.mjs.map +1 -1
- package/lib/client.d.mts +1 -1
- package/lib/client.d.mts.map +1 -1
- package/lib/client.d.ts +1 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +11 -10
- package/lib/client.js.map +1 -1
- package/lib/client.mjs +4 -3
- package/lib/client.mjs.map +1 -1
- package/lib/run_trees.d.mts +1 -1
- package/lib/run_trees.d.mts.map +1 -1
- package/lib/run_trees.d.ts +1 -1
- package/lib/run_trees.d.ts.map +1 -1
- package/lib/run_trees.js +11 -9
- package/lib/run_trees.js.map +1 -1
- package/lib/run_trees.mjs +7 -5
- package/lib/run_trees.mjs.map +1 -1
- package/lib/sandbox/index.d.mts +1 -1
- package/lib/sandbox/index.d.mts.map +1 -1
- package/lib/sandbox/index.d.ts +1 -1
- package/lib/sandbox/index.d.ts.map +1 -1
- package/lib/sandbox/index.js.map +1 -1
- package/lib/sandbox/index.mjs.map +1 -1
- package/lib/sandbox/mounts.d.mts +3 -2
- package/lib/sandbox/mounts.d.mts.map +1 -1
- package/lib/sandbox/mounts.d.ts +3 -2
- package/lib/sandbox/mounts.d.ts.map +1 -1
- package/lib/sandbox/mounts.js +6 -1
- package/lib/sandbox/mounts.js.map +1 -1
- package/lib/sandbox/mounts.mjs +6 -1
- package/lib/sandbox/mounts.mjs.map +1 -1
- package/lib/sandbox/types.d.mts +7 -0
- package/lib/sandbox/types.d.mts.map +1 -1
- package/lib/sandbox/types.d.ts +7 -0
- package/lib/sandbox/types.d.ts.map +1 -1
- package/lib/sandbox/verify.d.mts.map +1 -1
- package/lib/sandbox/verify.d.ts.map +1 -1
- package/lib/sandbox/verify.js +81 -19
- package/lib/sandbox/verify.js.map +1 -1
- package/lib/sandbox/verify.mjs +81 -19
- package/lib/sandbox/verify.mjs.map +1 -1
- package/lib/utils/addressing.d.mts +1 -1
- package/lib/utils/addressing.d.mts.map +1 -1
- package/lib/utils/addressing.d.ts +1 -1
- package/lib/utils/addressing.d.ts.map +1 -1
- package/lib/utils/addressing.js +4 -4
- package/lib/utils/addressing.js.map +1 -1
- package/lib/utils/addressing.mjs +5 -5
- package/lib/utils/addressing.mjs.map +1 -1
- package/package.json +22 -10
- package/resources/annotation-queues/annotation-queues.d.mts +33 -2
- package/resources/annotation-queues/annotation-queues.d.mts.map +1 -1
- package/resources/annotation-queues/annotation-queues.d.ts +33 -2
- package/resources/annotation-queues/annotation-queues.d.ts.map +1 -1
- package/resources/annotation-queues/annotation-queues.js.map +1 -1
- package/resources/annotation-queues/annotation-queues.mjs.map +1 -1
- package/resources/runs/runs.d.mts +14 -1
- package/resources/runs/runs.d.mts.map +1 -1
- package/resources/runs/runs.d.ts +14 -1
- package/resources/runs/runs.d.ts.map +1 -1
- package/resources/runs/runs.js +4 -0
- package/resources/runs/runs.js.map +1 -1
- package/resources/runs/runs.mjs +4 -0
- package/resources/runs/runs.mjs.map +1 -1
- package/resources/sandboxes/boxes.d.mts +32 -0
- package/resources/sandboxes/boxes.d.mts.map +1 -1
- package/resources/sandboxes/boxes.d.ts +32 -0
- package/resources/sandboxes/boxes.d.ts.map +1 -1
- package/resources/sandboxes/sandboxes.d.mts +32 -0
- package/resources/sandboxes/sandboxes.d.mts.map +1 -1
- package/resources/sandboxes/sandboxes.d.ts +32 -0
- package/resources/sandboxes/sandboxes.d.ts.map +1 -1
- package/resources/sandboxes/sandboxes.js.map +1 -1
- package/resources/sandboxes/sandboxes.mjs.map +1 -1
- package/resources/threads/threads.d.mts +13 -1
- package/resources/threads/threads.d.mts.map +1 -1
- package/resources/threads/threads.d.ts +13 -1
- package/resources/threads/threads.d.ts.map +1 -1
- package/resources/threads/threads.js +4 -0
- package/resources/threads/threads.js.map +1 -1
- package/resources/threads/threads.mjs +4 -0
- package/resources/threads/threads.mjs.map +1 -1
- package/resources/traces.d.mts +34 -16
- package/resources/traces.d.mts.map +1 -1
- package/resources/traces.d.ts +34 -16
- package/resources/traces.d.ts.map +1 -1
- package/resources/traces.js +7 -1
- package/resources/traces.js.map +1 -1
- package/resources/traces.mjs +7 -1
- package/resources/traces.mjs.map +1 -1
- package/src/lib/address.ts +138 -180
- package/src/lib/client.ts +4 -5
- package/src/lib/run_trees.ts +8 -5
- package/src/lib/sandbox/README.md +3 -2
- package/src/lib/sandbox/index.ts +1 -0
- package/src/lib/sandbox/mounts.ts +8 -0
- package/src/lib/sandbox/types.ts +8 -0
- package/src/lib/sandbox/verify.ts +107 -28
- package/src/lib/utils/addressing.ts +8 -5
- package/src/resources/annotation-queues/annotation-queues.ts +46 -2
- package/src/resources/runs/runs.ts +15 -1
- package/src/resources/sandboxes/boxes.ts +40 -0
- package/src/resources/sandboxes/sandboxes.ts +40 -0
- package/src/resources/threads/threads.ts +14 -1
- package/src/resources/traces.ts +38 -16
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/traces.d.mts
CHANGED
|
@@ -32,6 +32,10 @@ export declare class Traces extends APIResource {
|
|
|
32
32
|
* Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
|
|
33
33
|
* and field projection (`selects`).
|
|
34
34
|
*
|
|
35
|
+
* When `ai_search` is set, `Accept: text/event-stream` is required; requests
|
|
36
|
+
* without it return 406. AI search is unavailable on deployments that route
|
|
37
|
+
* queries to the v1 backend and returns 501 there.
|
|
38
|
+
*
|
|
35
39
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
36
40
|
*
|
|
37
41
|
* @example
|
|
@@ -42,7 +46,7 @@ export declare class Traces extends APIResource {
|
|
|
42
46
|
* }
|
|
43
47
|
* ```
|
|
44
48
|
*/
|
|
45
|
-
query(
|
|
49
|
+
query(params: TraceQueryParams, options?: RequestOptions): PagePromise<TracesItemsCursorPostPagination, Trace>;
|
|
46
50
|
}
|
|
47
51
|
export type TracesItemsCursorPostPagination = ItemsCursorPostPagination<Trace>;
|
|
48
52
|
export interface Trace {
|
|
@@ -125,46 +129,60 @@ export interface TraceListRunsParams {
|
|
|
125
129
|
}
|
|
126
130
|
export interface TraceQueryParams extends ItemsCursorPostPaginationParams {
|
|
127
131
|
/**
|
|
128
|
-
* `
|
|
129
|
-
*
|
|
132
|
+
* Body param: `ai_search` is a plain-language criterion evaluated against the
|
|
133
|
+
* messages from the agent trajectory scoped to the trace. AND-ed with the ordinary
|
|
134
|
+
* filters. Requires semantic filtering enabled for the deployment. Must contain
|
|
135
|
+
* nonempty text of at most 2000 UTF-8 bytes.
|
|
136
|
+
*/
|
|
137
|
+
ai_search?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Body param: `max_start_time` is the exclusive upper bound for the root-run start
|
|
140
|
+
* time scan (RFC3339). Defaults to the request time when omitted.
|
|
130
141
|
*/
|
|
131
142
|
max_start_time?: string;
|
|
132
143
|
/**
|
|
133
|
-
* `min_start_time` is the inclusive lower bound for the root-run start
|
|
134
|
-
* (RFC3339). Defaults to 24 hours before the request when omitted.
|
|
144
|
+
* Body param: `min_start_time` is the inclusive lower bound for the root-run start
|
|
145
|
+
* time scan (RFC3339). Defaults to 24 hours before the request when omitted.
|
|
135
146
|
*/
|
|
136
147
|
min_start_time?: string;
|
|
137
148
|
/**
|
|
138
|
-
* `project_id` is the UUID of the tracing project that owns the
|
|
149
|
+
* Body param: `project_id` is the UUID of the tracing project that owns the
|
|
150
|
+
* traces. Required.
|
|
139
151
|
*/
|
|
140
152
|
project_id?: string;
|
|
141
153
|
/**
|
|
142
|
-
* `selects` lists which properties to include on each returned trace.
|
|
143
|
-
* listed here are routed to the appropriate sub-object on each item:
|
|
154
|
+
* Body param: `selects` lists which properties to include on each returned trace.
|
|
155
|
+
* Properties listed here are routed to the appropriate sub-object on each item:
|
|
144
156
|
* `total_tokens`, `total_cost`, and `first_token_time` appear under
|
|
145
157
|
* `trace_aggregates`; everything else appears under `root_run`. If omitted, only
|
|
146
158
|
* `id` is returned on `root_run`.
|
|
147
159
|
*/
|
|
148
160
|
selects?: Array<RunsAPI.RunSelectField>;
|
|
149
161
|
/**
|
|
150
|
-
* `trace_filter` narrows results to traces whose root run matches this
|
|
151
|
-
* filter expression. This filter targets root runs only —
|
|
152
|
-
* implied. See
|
|
162
|
+
* Body param: `trace_filter` narrows results to traces whose root run matches this
|
|
163
|
+
* LangSmith filter expression. This filter targets root runs only —
|
|
164
|
+
* `is_root = true` is implied. See
|
|
153
165
|
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
154
166
|
* for syntax.
|
|
155
167
|
*/
|
|
156
168
|
trace_filter?: string;
|
|
157
169
|
/**
|
|
158
|
-
* `trace_ids` is an optional fast-path restriction to a known set of
|
|
159
|
-
* Equivalent in result to including each UUID in a `trace_filter`,
|
|
160
|
-
* efficient at scale.
|
|
170
|
+
* Body param: `trace_ids` is an optional fast-path restriction to a known set of
|
|
171
|
+
* trace UUIDs. Equivalent in result to including each UUID in a `trace_filter`,
|
|
172
|
+
* but more efficient at scale.
|
|
161
173
|
*/
|
|
162
174
|
trace_ids?: Array<string>;
|
|
163
175
|
/**
|
|
164
|
-
* `tree_filter` narrows results to traces containing at least one run
|
|
165
|
-
* the run tree (root or descendant) that matches this LangSmith filter
|
|
176
|
+
* Body param: `tree_filter` narrows results to traces containing at least one run
|
|
177
|
+
* anywhere in the run tree (root or descendant) that matches this LangSmith filter
|
|
178
|
+
* expression.
|
|
166
179
|
*/
|
|
167
180
|
tree_filter?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Header param: application/json, or text/event-stream (required when ai_search is
|
|
183
|
+
* set)
|
|
184
|
+
*/
|
|
185
|
+
Accept?: string;
|
|
168
186
|
}
|
|
169
187
|
export declare namespace Traces {
|
|
170
188
|
export { type Trace as Trace, type TraceAggregates as TraceAggregates, type TraceListRunsResponse as TraceListRunsResponse, type TracesItemsCursorPostPagination as TracesItemsCursorPostPagination, type TraceListRunsParams as TraceListRunsParams, type TraceQueryParams as TraceQueryParams, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.d.mts","sourceRoot":"","sources":["../src/resources/traces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAC/C,OAAO,KAAK,OAAO,wBAAoB;AACvC,OAAO,EAAE,UAAU,EAAE,gCAA4B;AACjD,OAAO,EACL,yBAAyB,EACzB,KAAK,+BAA+B,EACpC,WAAW,EACZ,+BAA2B;AAE5B,OAAO,EAAE,cAAc,EAAE,wCAAoC;AAG7D,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,qBAAqB,CAAC;IASpC
|
|
1
|
+
{"version":3,"file":"traces.d.mts","sourceRoot":"","sources":["../src/resources/traces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAC/C,OAAO,KAAK,OAAO,wBAAoB;AACvC,OAAO,EAAE,UAAU,EAAE,gCAA4B;AACjD,OAAO,EACL,yBAAyB,EACzB,KAAK,+BAA+B,EACpC,WAAW,EACZ,+BAA2B;AAE5B,OAAO,EAAE,cAAc,EAAE,wCAAoC;AAG7D,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,qBAAqB,CAAC;IASpC;;;;;;;;;;;;;;;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|
@@ -32,6 +32,10 @@ export declare class Traces extends APIResource {
|
|
|
32
32
|
* Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
|
|
33
33
|
* and field projection (`selects`).
|
|
34
34
|
*
|
|
35
|
+
* When `ai_search` is set, `Accept: text/event-stream` is required; requests
|
|
36
|
+
* without it return 406. AI search is unavailable on deployments that route
|
|
37
|
+
* queries to the v1 backend and returns 501 there.
|
|
38
|
+
*
|
|
35
39
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
36
40
|
*
|
|
37
41
|
* @example
|
|
@@ -42,7 +46,7 @@ export declare class Traces extends APIResource {
|
|
|
42
46
|
* }
|
|
43
47
|
* ```
|
|
44
48
|
*/
|
|
45
|
-
query(
|
|
49
|
+
query(params: TraceQueryParams, options?: RequestOptions): PagePromise<TracesItemsCursorPostPagination, Trace>;
|
|
46
50
|
}
|
|
47
51
|
export type TracesItemsCursorPostPagination = ItemsCursorPostPagination<Trace>;
|
|
48
52
|
export interface Trace {
|
|
@@ -125,46 +129,60 @@ export interface TraceListRunsParams {
|
|
|
125
129
|
}
|
|
126
130
|
export interface TraceQueryParams extends ItemsCursorPostPaginationParams {
|
|
127
131
|
/**
|
|
128
|
-
* `
|
|
129
|
-
*
|
|
132
|
+
* Body param: `ai_search` is a plain-language criterion evaluated against the
|
|
133
|
+
* messages from the agent trajectory scoped to the trace. AND-ed with the ordinary
|
|
134
|
+
* filters. Requires semantic filtering enabled for the deployment. Must contain
|
|
135
|
+
* nonempty text of at most 2000 UTF-8 bytes.
|
|
136
|
+
*/
|
|
137
|
+
ai_search?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Body param: `max_start_time` is the exclusive upper bound for the root-run start
|
|
140
|
+
* time scan (RFC3339). Defaults to the request time when omitted.
|
|
130
141
|
*/
|
|
131
142
|
max_start_time?: string;
|
|
132
143
|
/**
|
|
133
|
-
* `min_start_time` is the inclusive lower bound for the root-run start
|
|
134
|
-
* (RFC3339). Defaults to 24 hours before the request when omitted.
|
|
144
|
+
* Body param: `min_start_time` is the inclusive lower bound for the root-run start
|
|
145
|
+
* time scan (RFC3339). Defaults to 24 hours before the request when omitted.
|
|
135
146
|
*/
|
|
136
147
|
min_start_time?: string;
|
|
137
148
|
/**
|
|
138
|
-
* `project_id` is the UUID of the tracing project that owns the
|
|
149
|
+
* Body param: `project_id` is the UUID of the tracing project that owns the
|
|
150
|
+
* traces. Required.
|
|
139
151
|
*/
|
|
140
152
|
project_id?: string;
|
|
141
153
|
/**
|
|
142
|
-
* `selects` lists which properties to include on each returned trace.
|
|
143
|
-
* listed here are routed to the appropriate sub-object on each item:
|
|
154
|
+
* Body param: `selects` lists which properties to include on each returned trace.
|
|
155
|
+
* Properties listed here are routed to the appropriate sub-object on each item:
|
|
144
156
|
* `total_tokens`, `total_cost`, and `first_token_time` appear under
|
|
145
157
|
* `trace_aggregates`; everything else appears under `root_run`. If omitted, only
|
|
146
158
|
* `id` is returned on `root_run`.
|
|
147
159
|
*/
|
|
148
160
|
selects?: Array<RunsAPI.RunSelectField>;
|
|
149
161
|
/**
|
|
150
|
-
* `trace_filter` narrows results to traces whose root run matches this
|
|
151
|
-
* filter expression. This filter targets root runs only —
|
|
152
|
-
* implied. See
|
|
162
|
+
* Body param: `trace_filter` narrows results to traces whose root run matches this
|
|
163
|
+
* LangSmith filter expression. This filter targets root runs only —
|
|
164
|
+
* `is_root = true` is implied. See
|
|
153
165
|
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
154
166
|
* for syntax.
|
|
155
167
|
*/
|
|
156
168
|
trace_filter?: string;
|
|
157
169
|
/**
|
|
158
|
-
* `trace_ids` is an optional fast-path restriction to a known set of
|
|
159
|
-
* Equivalent in result to including each UUID in a `trace_filter`,
|
|
160
|
-
* efficient at scale.
|
|
170
|
+
* Body param: `trace_ids` is an optional fast-path restriction to a known set of
|
|
171
|
+
* trace UUIDs. Equivalent in result to including each UUID in a `trace_filter`,
|
|
172
|
+
* but more efficient at scale.
|
|
161
173
|
*/
|
|
162
174
|
trace_ids?: Array<string>;
|
|
163
175
|
/**
|
|
164
|
-
* `tree_filter` narrows results to traces containing at least one run
|
|
165
|
-
* the run tree (root or descendant) that matches this LangSmith filter
|
|
176
|
+
* Body param: `tree_filter` narrows results to traces containing at least one run
|
|
177
|
+
* anywhere in the run tree (root or descendant) that matches this LangSmith filter
|
|
178
|
+
* expression.
|
|
166
179
|
*/
|
|
167
180
|
tree_filter?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Header param: application/json, or text/event-stream (required when ai_search is
|
|
183
|
+
* set)
|
|
184
|
+
*/
|
|
185
|
+
Accept?: string;
|
|
168
186
|
}
|
|
169
187
|
export declare namespace Traces {
|
|
170
188
|
export { type Trace as Trace, type TraceAggregates as TraceAggregates, type TraceListRunsResponse as TraceListRunsResponse, type TracesItemsCursorPostPagination as TracesItemsCursorPostPagination, type TraceListRunsParams as TraceListRunsParams, type TraceQueryParams as TraceQueryParams, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../src/resources/traces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,KAAK,OAAO,uBAAoB;AACvC,OAAO,EAAE,UAAU,EAAE,+BAA4B;AACjD,OAAO,EACL,yBAAyB,EACzB,KAAK,+BAA+B,EACpC,WAAW,EACZ,8BAA2B;AAE5B,OAAO,EAAE,cAAc,EAAE,uCAAoC;AAG7D,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,qBAAqB,CAAC;IASpC
|
|
1
|
+
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../src/resources/traces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,O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AW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,OAAO,EACL,KAAK,KAAK,IAAI,KAAK,EACnB,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,gBAAgB,IAAI,gBAAgB,GAC1C,CAAC;CACH"}
|
package/resources/traces.js
CHANGED
|
@@ -42,6 +42,10 @@ class Traces extends resource_1.APIResource {
|
|
|
42
42
|
* Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
|
|
43
43
|
* and field projection (`selects`).
|
|
44
44
|
*
|
|
45
|
+
* When `ai_search` is set, `Accept: text/event-stream` is required; requests
|
|
46
|
+
* without it return 406. AI search is unavailable on deployments that route
|
|
47
|
+
* queries to the v1 backend and returns 501 there.
|
|
48
|
+
*
|
|
45
49
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
46
50
|
*
|
|
47
51
|
* @example
|
|
@@ -52,11 +56,13 @@ class Traces extends resource_1.APIResource {
|
|
|
52
56
|
* }
|
|
53
57
|
* ```
|
|
54
58
|
*/
|
|
55
|
-
query(
|
|
59
|
+
query(params, options) {
|
|
60
|
+
const { Accept, ...body } = params;
|
|
56
61
|
return this._client.getAPIList('/api/v2/traces/query', (pagination_1.ItemsCursorPostPagination), {
|
|
57
62
|
body,
|
|
58
63
|
method: 'post',
|
|
59
64
|
...options,
|
|
65
|
+
headers: (0, headers_1.buildHeaders)([{ ...(Accept != null ? { Accept: Accept } : undefined) }, options?.headers]),
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
}
|
package/resources/traces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../src/resources/traces.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AC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACpG,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CACH,MAAwB,EACxB,OAAwB;QAExB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAA,sCAAgC,CAAA,EAAE;YACvF,IAAI;YACJ,MAAM,EAAE,MAAM;YACd,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACpG,CAAC,CAAC;IACL,CAAC;CACF;AAnED,wBAmEC"}
|
package/resources/traces.mjs
CHANGED
|
@@ -39,6 +39,10 @@ export class Traces extends APIResource {
|
|
|
39
39
|
* Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
|
|
40
40
|
* and field projection (`selects`).
|
|
41
41
|
*
|
|
42
|
+
* When `ai_search` is set, `Accept: text/event-stream` is required; requests
|
|
43
|
+
* without it return 406. AI search is unavailable on deployments that route
|
|
44
|
+
* queries to the v1 backend and returns 501 there.
|
|
45
|
+
*
|
|
42
46
|
* Self-hosted deployments require LangSmith `v0.16` or later.
|
|
43
47
|
*
|
|
44
48
|
* @example
|
|
@@ -49,11 +53,13 @@ export class Traces extends APIResource {
|
|
|
49
53
|
* }
|
|
50
54
|
* ```
|
|
51
55
|
*/
|
|
52
|
-
query(
|
|
56
|
+
query(params, options) {
|
|
57
|
+
const { Accept, ...body } = params;
|
|
53
58
|
return this._client.getAPIList('/api/v2/traces/query', (ItemsCursorPostPagination), {
|
|
54
59
|
body,
|
|
55
60
|
method: 'post',
|
|
56
61
|
...options,
|
|
62
|
+
headers: buildHeaders([{ ...(Accept != null ? { Accept: Accept } : undefined) }, options?.headers]),
|
|
57
63
|
});
|
|
58
64
|
}
|
|
59
65
|
}
|
package/resources/traces.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.mjs","sourceRoot":"","sources":["../src/resources/traces.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAG/C,OAAO,EACL,yBAAyB,GAG1B,+BAA2B;AAC5B,OAAO,EAAE,YAAY,EAAE,gCAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,mCAA+B;AAE9C,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,OAAe,EACf,MAA2B,EAC3B,OAAwB;QAExB,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,kBAAkB,OAAO,OAAO,EAAE;YAC5D,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACpG,CAAC,CAAC;IACL,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"traces.mjs","sourceRoot":"","sources":["../src/resources/traces.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAG/C,OAAO,EACL,yBAAyB,GAG1B,+BAA2B;AAC5B,OAAO,EAAE,YAAY,EAAE,gCAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,mCAA+B;AAE9C,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,OAAe,EACf,MAA2B,EAC3B,OAAwB;QAExB,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,kBAAkB,OAAO,OAAO,EAAE;YAC5D,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACpG,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CACH,MAAwB,EACxB,OAAwB;QAExB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAA,yBAAgC,CAAA,EAAE;YACvF,IAAI;YACJ,MAAM,EAAE,MAAM;YACd,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACpG,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/src/lib/address.ts
CHANGED
|
@@ -26,32 +26,67 @@ export type Environment = "local" | "development" | "staging" | "production";
|
|
|
26
26
|
*/
|
|
27
27
|
export type Lrn = `lrn:agents/${string}/environments/${Environment}`;
|
|
28
28
|
|
|
29
|
-
/** (beta) The
|
|
30
|
-
export
|
|
31
|
-
kind: "AGENT"
|
|
32
|
-
id
|
|
33
|
-
environment
|
|
34
|
-
}
|
|
29
|
+
/** (beta) The address of an agent's environment. */
|
|
30
|
+
export interface AgentAddress {
|
|
31
|
+
kind: "AGENT";
|
|
32
|
+
id: string;
|
|
33
|
+
environment: Uppercase<Environment>;
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
/** (beta)
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
/** (beta) Construct and validate an agent address; plain objects are also accepted. */
|
|
37
|
+
export class AgentAddress {
|
|
38
|
+
constructor(id: string, environment: Environment | (string & {})) {
|
|
39
|
+
const address = ensureAgent({ kind: "AGENT", id, environment });
|
|
40
|
+
this.kind = address.kind;
|
|
41
|
+
this.id = address.id;
|
|
42
|
+
this.environment = address.environment;
|
|
43
|
+
Object.freeze(this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** (beta) The address of an experiment's tracing project. */
|
|
48
|
+
export interface ExperimentAddress {
|
|
49
|
+
kind: "EXPERIMENT";
|
|
50
|
+
id: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** (beta) Construct and validate an experiment address. */
|
|
54
|
+
export class ExperimentAddress {
|
|
55
|
+
constructor(id: string) {
|
|
56
|
+
const address = ensureAddress({ kind: "EXPERIMENT", id });
|
|
57
|
+
this.kind = address.kind;
|
|
58
|
+
this.id = address.id;
|
|
59
|
+
Object.freeze(this);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** (beta) The address of the workspace's shared evaluators project. */
|
|
64
|
+
export interface EvaluatorAddress {
|
|
65
|
+
kind: "EVALUATOR";
|
|
40
66
|
}
|
|
41
67
|
|
|
68
|
+
/** (beta) Construct the workspace's evaluators address. */
|
|
69
|
+
export class EvaluatorAddress {
|
|
70
|
+
constructor() {
|
|
71
|
+
this.kind = "EVALUATOR";
|
|
72
|
+
Object.freeze(this);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** (beta) A feature that holds traces in a tracing project. */
|
|
77
|
+
export type Address = AgentAddress | ExperimentAddress | EvaluatorAddress;
|
|
78
|
+
|
|
79
|
+
/** (beta) An address as the resolve endpoint takes it. */
|
|
80
|
+
export type ApiAddress = Address;
|
|
81
|
+
|
|
42
82
|
const UUID_PATTERN =
|
|
43
83
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
44
84
|
|
|
45
85
|
// The server's agent id rule: a DNS label, so a hostname can carry the id.
|
|
46
86
|
const AGENT_ID_PATTERN = /^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
47
|
-
const ENVIRONMENTS
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"staging",
|
|
51
|
-
"production",
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
// The wire form of an agent address. The parts are validated by `AgentAddress`.
|
|
87
|
+
const ENVIRONMENTS = ["local", "development", "staging", "production"];
|
|
88
|
+
|
|
89
|
+
// The wire form of an agent address. The parts are validated at entrypoints.
|
|
55
90
|
const LRN_PATTERN = /^lrn:agents\/([^/]+)\/environments\/([^/]+)$/;
|
|
56
91
|
|
|
57
92
|
const ENV_NAMES = ["LANGSMITH_AGENT_ID", "LANGSMITH_AGENT_ENVIRONMENT"];
|
|
@@ -64,189 +99,112 @@ export class EnvAddressError extends Error {
|
|
|
64
99
|
}
|
|
65
100
|
}
|
|
66
101
|
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @param id 1 to 63 lowercase ASCII letters, digits or hyphens, starting
|
|
83
|
-
* with a letter and ending with a letter or digit. The server creates the
|
|
84
|
-
* agent on first use.
|
|
85
|
-
* @param environment One of `local`, `development`, `staging` or `production`, in
|
|
86
|
-
* any case.
|
|
87
|
-
* @throws If a value is invalid.
|
|
88
|
-
*/
|
|
89
|
-
constructor(id: string, environment: Environment | (string & {})) {
|
|
90
|
-
if (typeof id !== "string" || !AGENT_ID_PATTERN.test(id)) {
|
|
91
|
-
throw new Error(
|
|
92
|
-
"Address agent id must be 1 to 63 lowercase ASCII letters, digits, or " +
|
|
93
|
-
"hyphens, start with a letter, and end with a letter or digit, got " +
|
|
94
|
-
`${JSON.stringify(id)}. Use an id such as "support-agent".`,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
const normalized =
|
|
98
|
-
typeof environment === "string" ? environment.toLowerCase() : undefined;
|
|
99
|
-
if (normalized === undefined || !ENVIRONMENTS.includes(normalized)) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Address environment must be one of ${ENVIRONMENTS.join(", ")}, got ` +
|
|
102
|
-
`${JSON.stringify(environment)}.`,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
this.id = id;
|
|
106
|
-
this.environment = normalized as Environment;
|
|
107
|
-
Object.freeze(this);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
toApiAddress(): ApiAddress {
|
|
111
|
-
return {
|
|
112
|
-
kind: "AGENT",
|
|
113
|
-
id: this.id,
|
|
114
|
-
environment: this.environment.toUpperCase() as Uppercase<Environment>,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** @internal */
|
|
119
|
-
_toLrn(): Lrn {
|
|
120
|
-
return `lrn:agents/${this.id}/environments/${this.environment}`;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @internal Parse an LRN read from the wire, such as a `baggage` header. The
|
|
125
|
-
* value is untrusted, so it is not echoed in the error.
|
|
126
|
-
* @throws If `value` is not an agent LRN, or names an invalid id or environment.
|
|
127
|
-
*/
|
|
128
|
-
static _fromLrn(value: unknown): AgentAddress {
|
|
129
|
-
const match = typeof value === "string" ? LRN_PATTERN.exec(value) : null;
|
|
130
|
-
if (match === null) {
|
|
131
|
-
throw new Error("Not an agent address.");
|
|
132
|
-
}
|
|
133
|
-
return new AgentAddress(match[1], match[2]);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Read the agent named by `LANGSMITH_AGENT_ID` and
|
|
138
|
-
* `LANGSMITH_AGENT_ENVIRONMENT`; `undefined` if neither is set.
|
|
139
|
-
* @throws {EnvAddressError} If only one is set, or a value is invalid.
|
|
140
|
-
*/
|
|
141
|
-
static fromEnv(): AgentAddress | undefined {
|
|
142
|
-
const values = ENV_NAMES.map((name) => getEnvironmentVariable(name));
|
|
143
|
-
if (!values.some(Boolean)) {
|
|
144
|
-
return undefined;
|
|
145
|
-
}
|
|
146
|
-
try {
|
|
147
|
-
const missing = ENV_NAMES.filter((_, i) => !values[i]);
|
|
148
|
-
if (missing.length > 0) {
|
|
149
|
-
throw new Error(`An address needs ${missing.join(" and ")} as well.`);
|
|
150
|
-
}
|
|
151
|
-
return new AgentAddress(values[0] as string, values[1] as string);
|
|
152
|
-
} catch (e) {
|
|
153
|
-
const present = ENV_NAMES.flatMap((name, i) =>
|
|
154
|
-
values[i] ? [`${name}=${JSON.stringify(values[i])}`] : [],
|
|
155
|
-
).join(", ");
|
|
156
|
-
throw new EnvAddressError(
|
|
157
|
-
`The LANGSMITH_AGENT_* env vars can't address a run (${present}): ${
|
|
158
|
-
(e as Error).message
|
|
159
|
-
}`,
|
|
160
|
-
);
|
|
161
|
-
}
|
|
102
|
+
/** Validate an address at an SDK entrypoint and return a normalized copy. */
|
|
103
|
+
export function ensureAddress<K extends Address["kind"]>(value: {
|
|
104
|
+
kind: K;
|
|
105
|
+
id?: unknown;
|
|
106
|
+
environment?: unknown;
|
|
107
|
+
}): Extract<Address, { kind: K }>;
|
|
108
|
+
export function ensureAddress(value: unknown): Address | undefined;
|
|
109
|
+
export function ensureAddress(value: unknown): Address | undefined {
|
|
110
|
+
if (value == null) return undefined;
|
|
111
|
+
if (typeof value !== "object") {
|
|
112
|
+
throw new Error(
|
|
113
|
+
"address must be an AgentAddress, ExperimentAddress or EvaluatorAddress object.",
|
|
114
|
+
);
|
|
162
115
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
export class ExperimentAddress implements Address {
|
|
167
|
-
/** Always lowercase. */
|
|
168
|
-
readonly id: string;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @param id The experiment's UUID.
|
|
172
|
-
* @throws If `id` is not a UUID.
|
|
173
|
-
*/
|
|
174
|
-
constructor(id: string) {
|
|
116
|
+
const { kind, id, environment } = value as Record<string, unknown>;
|
|
117
|
+
if (kind === "EVALUATOR") return { kind };
|
|
118
|
+
if (kind === "EXPERIMENT") {
|
|
175
119
|
if (typeof id !== "string" || !UUID_PATTERN.test(id)) {
|
|
176
120
|
throw new Error(
|
|
177
121
|
`Experiment id must be a UUID, got ${JSON.stringify(id)}.`,
|
|
178
122
|
);
|
|
179
123
|
}
|
|
180
|
-
|
|
181
|
-
Object.freeze(this);
|
|
124
|
+
return { kind, id: id.toLowerCase() };
|
|
182
125
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
126
|
+
if (kind !== "AGENT") {
|
|
127
|
+
throw new Error(
|
|
128
|
+
"address must be an AgentAddress, ExperimentAddress or EvaluatorAddress object.",
|
|
129
|
+
);
|
|
186
130
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
131
|
+
if (typeof id !== "string" || !AGENT_ID_PATTERN.test(id)) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
"Address agent id must be 1 to 63 lowercase ASCII letters, digits, or " +
|
|
134
|
+
"hyphens, start with a letter, and end with a letter or digit, got " +
|
|
135
|
+
`${JSON.stringify(id)}. Use an id such as "support-agent".`,
|
|
136
|
+
);
|
|
193
137
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
138
|
+
const normalized =
|
|
139
|
+
typeof environment === "string" ? environment.toLowerCase() : undefined;
|
|
140
|
+
if (normalized === undefined || !ENVIRONMENTS.includes(normalized)) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`Address environment must be one of ${ENVIRONMENTS.join(
|
|
143
|
+
", ",
|
|
144
|
+
)}, got ${JSON.stringify(environment)}.`,
|
|
145
|
+
);
|
|
197
146
|
}
|
|
147
|
+
return {
|
|
148
|
+
kind,
|
|
149
|
+
id,
|
|
150
|
+
environment: normalized.toUpperCase() as Uppercase<Environment>,
|
|
151
|
+
};
|
|
198
152
|
}
|
|
199
153
|
|
|
200
|
-
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
154
|
+
/** @internal Only agent addresses can receive traces. */
|
|
155
|
+
export function ensureAgent(value: {
|
|
156
|
+
kind: "AGENT";
|
|
157
|
+
id?: unknown;
|
|
158
|
+
environment?: unknown;
|
|
159
|
+
}): AgentAddress;
|
|
160
|
+
export function ensureAgent(value: unknown): AgentAddress | undefined;
|
|
205
161
|
export function ensureAgent(value: unknown): AgentAddress | undefined {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
if (value instanceof AgentAddress) {
|
|
210
|
-
return value;
|
|
211
|
-
}
|
|
212
|
-
if (
|
|
213
|
-
typeof value === "object" &&
|
|
214
|
-
typeof (value as Address).toApiAddress === "function"
|
|
215
|
-
) {
|
|
162
|
+
const address = ensureAddress(value);
|
|
163
|
+
if (address && address.kind !== "AGENT") {
|
|
216
164
|
throw new Error(
|
|
217
|
-
`Only an AgentAddress can receive traces, got ${
|
|
218
|
-
(value as object).constructor?.name ?? "an unknown address"
|
|
219
|
-
}.`,
|
|
165
|
+
`Only an AgentAddress can receive traces, got ${address.kind}.`,
|
|
220
166
|
);
|
|
221
167
|
}
|
|
222
|
-
|
|
223
|
-
"address must be an AgentAddress such as `new AgentAddress(id, environment)`, got " +
|
|
224
|
-
`${typeof value === "string" ? JSON.stringify(value) : typeof value}.`,
|
|
225
|
-
);
|
|
168
|
+
return address;
|
|
226
169
|
}
|
|
227
170
|
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
171
|
+
/** @internal Convert a validated address to the ingestion wire format. */
|
|
172
|
+
export function addressToLrn(address: AgentAddress): Lrn {
|
|
173
|
+
return `lrn:agents/${address.id}/environments/${
|
|
174
|
+
address.environment.toLowerCase() as Environment
|
|
175
|
+
}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** @internal Parse and validate an address from untrusted wire data. */
|
|
179
|
+
export function addressFromLrn(value: unknown): AgentAddress {
|
|
180
|
+
const match = typeof value === "string" ? LRN_PATTERN.exec(value) : null;
|
|
181
|
+
if (!match) throw new Error("Not an agent address.");
|
|
182
|
+
return ensureAgent({ kind: "AGENT", id: match[1], environment: match[2] });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** @internal Read and validate the address named by environment variables. */
|
|
186
|
+
export function addressFromEnv(): AgentAddress | undefined {
|
|
187
|
+
const values = ENV_NAMES.map((name) => getEnvironmentVariable(name));
|
|
188
|
+
if (!values.some(Boolean)) return undefined;
|
|
189
|
+
try {
|
|
190
|
+
const missing = ENV_NAMES.filter((_, i) => !values[i]);
|
|
191
|
+
if (missing.length)
|
|
192
|
+
throw new Error(`An address needs ${missing.join(" and ")} as well.`);
|
|
193
|
+
return ensureAgent({
|
|
194
|
+
kind: "AGENT",
|
|
195
|
+
id: values[0],
|
|
196
|
+
environment: values[1],
|
|
197
|
+
});
|
|
198
|
+
} catch (e) {
|
|
199
|
+
throw new EnvAddressError(
|
|
200
|
+
`The LANGSMITH_AGENT_* env vars can't address a run: ${
|
|
201
|
+
(e as Error).message
|
|
202
|
+
}`,
|
|
203
|
+
);
|
|
242
204
|
}
|
|
243
|
-
throw new Error(
|
|
244
|
-
"address must be an AgentAddress, ExperimentAddress or EvaluatorAddress, got " +
|
|
245
|
-
`${typeof value === "string" ? JSON.stringify(value) : typeof value}.`,
|
|
246
|
-
);
|
|
247
205
|
}
|
|
248
206
|
|
|
249
|
-
/** @internal The
|
|
207
|
+
/** @internal The environment variable names an address reads. */
|
|
250
208
|
export function envNames(): string[] {
|
|
251
209
|
return ENV_NAMES;
|
|
252
210
|
}
|