langsmith 0.8.8 → 0.8.9

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.
Files changed (46) hide show
  1. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.cjs +10 -0
  2. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.d.ts +10 -0
  3. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.js +10 -0
  4. package/dist/_openapi_client/resources/annotation-queues/runs.cjs +13 -1
  5. package/dist/_openapi_client/resources/annotation-queues/runs.d.ts +13 -1
  6. package/dist/_openapi_client/resources/annotation-queues/runs.js +13 -1
  7. package/dist/_openapi_client/resources/datasets/experiment-runs.cjs +2 -0
  8. package/dist/_openapi_client/resources/datasets/experiment-runs.d.ts +2 -0
  9. package/dist/_openapi_client/resources/datasets/experiment-runs.js +2 -0
  10. package/dist/_openapi_client/resources/issues.d.ts +1 -1
  11. package/dist/_openapi_client/resources/public/runs.cjs +9 -7
  12. package/dist/_openapi_client/resources/public/runs.d.ts +8 -6
  13. package/dist/_openapi_client/resources/public/runs.js +9 -7
  14. package/dist/_openapi_client/resources/runs/runs.cjs +11 -6
  15. package/dist/_openapi_client/resources/runs/runs.d.ts +11 -6
  16. package/dist/_openapi_client/resources/runs/runs.js +11 -6
  17. package/dist/_openapi_client/resources/runs/share.cjs +4 -0
  18. package/dist/_openapi_client/resources/runs/share.d.ts +4 -0
  19. package/dist/_openapi_client/resources/runs/share.js +4 -0
  20. package/dist/_openapi_client/resources/threads.cjs +11 -8
  21. package/dist/_openapi_client/resources/threads.d.ts +11 -8
  22. package/dist/_openapi_client/resources/threads.js +11 -8
  23. package/dist/_openapi_client/resources/traces.cjs +6 -3
  24. package/dist/_openapi_client/resources/traces.d.ts +6 -3
  25. package/dist/_openapi_client/resources/traces.js +6 -3
  26. package/dist/client.cjs +262 -20
  27. package/dist/client.d.ts +53 -3
  28. package/dist/client.js +262 -20
  29. package/dist/evaluation/evaluate_comparative.cjs +7 -4
  30. package/dist/evaluation/evaluate_comparative.js +7 -4
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/sandbox/command_handle.cjs +34 -7
  35. package/dist/sandbox/command_handle.d.ts +1 -0
  36. package/dist/sandbox/command_handle.js +34 -7
  37. package/dist/sandbox/ws_execute.cjs +7 -3
  38. package/dist/sandbox/ws_execute.d.ts +4 -2
  39. package/dist/sandbox/ws_execute.js +7 -3
  40. package/dist/utils/v2_migration.cjs +18 -0
  41. package/dist/utils/v2_migration.d.ts +8 -0
  42. package/dist/utils/v2_migration.js +16 -0
  43. package/dist/utils/warn.cjs +30 -4
  44. package/dist/utils/warn.d.ts +4 -1
  45. package/dist/utils/warn.js +29 -4
  46. package/package.json +1 -1
@@ -4,8 +4,9 @@ import { ItemsCursorGetPagination, type ItemsCursorGetPaginationParams, ItemsCur
4
4
  import { RequestOptions } from '../internal/request-options.js';
5
5
  export declare class Threads extends APIResource {
6
6
  /**
7
- * **Alpha:** The request and response contract may change; Retrieve all traces
8
- * belonging to a specific thread within a project.
7
+ * Retrieve all traces belonging to a specific thread within a project.
8
+ *
9
+ * Self-hosted deployments require LangSmith `v0.16` or later.
9
10
  *
10
11
  * @example
11
12
  * ```ts
@@ -20,9 +21,10 @@ export declare class Threads extends APIResource {
20
21
  */
21
22
  listTraces(threadID: string, query: ThreadListTracesParams, options?: RequestOptions): PagePromise<ThreadTracesItemsCursorGetPagination, ThreadTrace>;
22
23
  /**
23
- * **Alpha:** The request and response contract may change; Query threads within a
24
- * project (session), with cursor-based pagination. Returns threads matching the
25
- * given time range and optional filter.
24
+ * Query threads within a project (session), with cursor-based pagination. Returns
25
+ * threads matching the given time range and optional filter.
26
+ *
27
+ * Self-hosted deployments require LangSmith `v0.16` or later.
26
28
  *
27
29
  * @example
28
30
  * ```ts
@@ -34,9 +36,10 @@ export declare class Threads extends APIResource {
34
36
  */
35
37
  query(body: ThreadQueryParams, options?: RequestOptions): PagePromise<ThreadsItemsCursorPostPagination, Thread>;
36
38
  /**
37
- * **Alpha:** The request and response contract may change; Compute aggregate stats
38
- * for a single thread (turn count, latency percentiles, token/cost sums, and
39
- * detail breakdowns) within a project.
39
+ * Compute aggregate stats for a single thread (turn count, latency percentiles,
40
+ * token/cost sums, and detail breakdowns) within a project.
41
+ *
42
+ * Self-hosted deployments require LangSmith `v0.16` or later.
40
43
  *
41
44
  * @example
42
45
  * ```ts
@@ -5,8 +5,9 @@ import { ItemsCursorGetPagination, ItemsCursorPostPagination, } from '../core/pa
5
5
  import { path } from '../internal/utils/path.js';
6
6
  export class Threads extends APIResource {
7
7
  /**
8
- * **Alpha:** The request and response contract may change; Retrieve all traces
9
- * belonging to a specific thread within a project.
8
+ * Retrieve all traces belonging to a specific thread within a project.
9
+ *
10
+ * Self-hosted deployments require LangSmith `v0.16` or later.
10
11
  *
11
12
  * @example
12
13
  * ```ts
@@ -23,9 +24,10 @@ export class Threads extends APIResource {
23
24
  return this._client.getAPIList(path `/api/v2/threads/${threadID}/traces`, (ItemsCursorGetPagination), { query, ...options });
24
25
  }
25
26
  /**
26
- * **Alpha:** The request and response contract may change; Query threads within a
27
- * project (session), with cursor-based pagination. Returns threads matching the
28
- * given time range and optional filter.
27
+ * Query threads within a project (session), with cursor-based pagination. Returns
28
+ * threads matching the given time range and optional filter.
29
+ *
30
+ * Self-hosted deployments require LangSmith `v0.16` or later.
29
31
  *
30
32
  * @example
31
33
  * ```ts
@@ -43,9 +45,10 @@ export class Threads extends APIResource {
43
45
  });
44
46
  }
45
47
  /**
46
- * **Alpha:** The request and response contract may change; Compute aggregate stats
47
- * for a single thread (turn count, latency percentiles, token/cost sums, and
48
- * detail breakdowns) within a project.
48
+ * Compute aggregate stats for a single thread (turn count, latency percentiles,
49
+ * token/cost sums, and detail breakdowns) within a project.
50
+ *
51
+ * Self-hosted deployments require LangSmith `v0.16` or later.
49
52
  *
50
53
  * @example
51
54
  * ```ts
@@ -9,9 +9,10 @@ const headers_js_1 = require("../internal/headers.cjs");
9
9
  const path_js_1 = require("../internal/utils/path.cjs");
10
10
  class Traces extends resource_js_1.APIResource {
11
11
  /**
12
- * **Alpha:** The request and response contract may change; Returns runs for a
13
- * trace ID within min/max start time. Optional `filter`; repeatable `selects` to
14
- * select fields to return.
12
+ * Returns runs for a trace ID within min/max start time. Optional `filter`;
13
+ * repeatable `selects` to select fields to return.
14
+ *
15
+ * Self-hosted deployments require LangSmith `v0.16` or later.
15
16
  *
16
17
  * @example
17
18
  * ```ts
@@ -42,6 +43,8 @@ class Traces extends resource_js_1.APIResource {
42
43
  * Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
43
44
  * and field projection (`selects`).
44
45
  *
46
+ * Self-hosted deployments require LangSmith `v0.16` or later.
47
+ *
45
48
  * @example
46
49
  * ```ts
47
50
  * // Automatically fetches more pages as needed.
@@ -5,9 +5,10 @@ import { ItemsCursorPostPagination, type ItemsCursorPostPaginationParams, PagePr
5
5
  import { RequestOptions } from '../internal/request-options.js';
6
6
  export declare class Traces extends APIResource {
7
7
  /**
8
- * **Alpha:** The request and response contract may change; Returns runs for a
9
- * trace ID within min/max start time. Optional `filter`; repeatable `selects` to
10
- * select fields to return.
8
+ * Returns runs for a trace ID within min/max start time. Optional `filter`;
9
+ * repeatable `selects` to select fields to return.
10
+ *
11
+ * Self-hosted deployments require LangSmith `v0.16` or later.
11
12
  *
12
13
  * @example
13
14
  * ```ts
@@ -31,6 +32,8 @@ export declare class Traces extends APIResource {
31
32
  * Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
32
33
  * and field projection (`selects`).
33
34
  *
35
+ * Self-hosted deployments require LangSmith `v0.16` or later.
36
+ *
34
37
  * @example
35
38
  * ```ts
36
39
  * // Automatically fetches more pages as needed.
@@ -6,9 +6,10 @@ import { buildHeaders } from '../internal/headers.js';
6
6
  import { path } from '../internal/utils/path.js';
7
7
  export class Traces extends APIResource {
8
8
  /**
9
- * **Alpha:** The request and response contract may change; Returns runs for a
10
- * trace ID within min/max start time. Optional `filter`; repeatable `selects` to
11
- * select fields to return.
9
+ * Returns runs for a trace ID within min/max start time. Optional `filter`;
10
+ * repeatable `selects` to select fields to return.
11
+ *
12
+ * Self-hosted deployments require LangSmith `v0.16` or later.
12
13
  *
13
14
  * @example
14
15
  * ```ts
@@ -39,6 +40,8 @@ export class Traces extends APIResource {
39
40
  * Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
40
41
  * and field projection (`selects`).
41
42
  *
43
+ * Self-hosted deployments require LangSmith `v0.16` or later.
44
+ *
42
45
  * @example
43
46
  * ```ts
44
47
  * // Automatically fetches more pages as needed.
package/dist/client.cjs CHANGED
@@ -46,6 +46,7 @@ const index_js_1 = require("./index.cjs");
46
46
  const index_js_2 = require("./_openapi_client/index.cjs");
47
47
  const _uuid_js_1 = require("./utils/_uuid.cjs");
48
48
  const warn_js_1 = require("./utils/warn.cjs");
49
+ const v2_migration_js_1 = require("./utils/v2_migration.cjs");
49
50
  const prompts_js_1 = require("./utils/prompts.cjs");
50
51
  const error_js_1 = require("./utils/error.cjs");
51
52
  const index_js_3 = require("./utils/prompt_cache/index.cjs");
@@ -192,6 +193,72 @@ exports.DEFAULT_MAX_SIZE_BYTES = 1024 * 1024 * 1024; // 1GB
192
193
  const SERVER_INFO_REQUEST_TIMEOUT_MS = 10000;
193
194
  /** Maximum number of operations to batch in a single request. */
194
195
  const DEFAULT_BATCH_SIZE_LIMIT = 100;
196
+ /**
197
+ * Reject header names or values that could alter a request's framing.
198
+ *
199
+ * `Headers` does this for us, and does it the same way `fetch` will.
200
+ */
201
+ function assertValidHeader(name, value) {
202
+ new Headers({ [name]: value });
203
+ }
204
+ /** Reject a malformed header up front, before it can reach a request. */
205
+ function assertValidHeaders(headers) {
206
+ for (const [name, value] of Object.entries(headers ?? {})) {
207
+ assertValidHeader(name, value);
208
+ }
209
+ }
210
+ /**
211
+ * Fold a `HeadersInit` into a plain object so it can be spread.
212
+ *
213
+ * Names are matched case-insensitively with the last value winning, keeping the
214
+ * first spelling seen. A plain object would instead keep both spellings, which
215
+ * `Headers` later joins into a `"first, second"` list rather than an override.
216
+ * Every name and value is validated on the way through.
217
+ */
218
+ function normalizeHeaders(headers) {
219
+ if (!headers)
220
+ return {};
221
+ const entries = headers instanceof Headers
222
+ ? [...headers.entries()]
223
+ : Array.isArray(headers)
224
+ ? headers.map(([name, value]) => [name, value])
225
+ : Object.entries(headers);
226
+ const normalized = {};
227
+ const nameByLower = new Map();
228
+ for (const [name, value] of entries) {
229
+ assertValidHeader(name, value);
230
+ const lowerName = name.toLowerCase();
231
+ const existingName = nameByLower.get(lowerName);
232
+ if (existingName === undefined) {
233
+ nameByLower.set(lowerName, name);
234
+ normalized[name] = value;
235
+ }
236
+ else {
237
+ normalized[existingName] = value;
238
+ }
239
+ }
240
+ return normalized;
241
+ }
242
+ /**
243
+ * Merge the caller's two header channels, then drop the `reserved` names.
244
+ *
245
+ * `overrides` wins, matched case-insensitively so a header supplied through both
246
+ * channels is overridden rather than turned into a `"first, second"` list.
247
+ */
248
+ function mergeCallerHeaders(base, overrides, reserved) {
249
+ const merged = { ...base };
250
+ const nameByLower = new Map(Object.keys(merged).map((name) => [name.toLowerCase(), name]));
251
+ for (const [name, value] of Object.entries(overrides)) {
252
+ const lowerName = name.toLowerCase();
253
+ merged[nameByLower.get(lowerName) ?? name] = value;
254
+ }
255
+ for (const name of Object.keys(merged)) {
256
+ if (reserved.has(name.toLowerCase())) {
257
+ delete merged[name];
258
+ }
259
+ }
260
+ return merged;
261
+ }
195
262
  class AutoBatchQueue {
196
263
  constructor(maxSizeBytes) {
197
264
  Object.defineProperty(this, "items", {
@@ -611,13 +678,26 @@ class Client {
611
678
  writable: true,
612
679
  value: void 0
613
680
  });
681
+ /** `config.fetchOptions` without its `headers`, which are merged separately. */
614
682
  Object.defineProperty(this, "fetchOptions", {
615
683
  enumerable: true,
616
684
  configurable: true,
617
685
  writable: true,
618
686
  value: void 0
619
687
  });
620
- Object.defineProperty(this, "openAPIClient", {
688
+ Object.defineProperty(this, "_fetchOptionsHeaders", {
689
+ enumerable: true,
690
+ configurable: true,
691
+ writable: true,
692
+ value: {}
693
+ });
694
+ Object.defineProperty(this, "_openAPIClient", {
695
+ enumerable: true,
696
+ configurable: true,
697
+ writable: true,
698
+ value: void 0
699
+ });
700
+ Object.defineProperty(this, "_openAPIClientSignature", {
621
701
  enumerable: true,
622
702
  configurable: true,
623
703
  writable: true,
@@ -822,8 +902,15 @@ class Client {
822
902
  config.blockOnRootRunFinalization ?? this.blockOnRootRunFinalization;
823
903
  this.batchSizeBytesLimit = config.batchSizeBytesLimit;
824
904
  this.batchSizeLimit = config.batchSizeLimit;
825
- this.fetchOptions = config.fetchOptions || {};
826
- this.openAPIClient = this._newOpenAPIClient();
905
+ const { headers: fetchOptionsHeaders, ...fetchOptions } = config.fetchOptions || {};
906
+ this.fetchOptions = fetchOptions;
907
+ // Kept apart from `fetchOptions` so they can be merged *under* the required
908
+ // headers instead of replacing the whole set at each call site.
909
+ this._fetchOptionsHeaders = normalizeHeaders(fetchOptionsHeaders);
910
+ // Validated eagerly so malformed input fails at construction, but stored
911
+ // as given: `get headers` hands this object back to the caller.
912
+ assertValidHeaders(config.headers);
913
+ this._customHeaders = config.headers ?? {};
827
914
  this.manualFlushMode = config.manualFlushMode ?? this.manualFlushMode;
828
915
  this._tracingMode = (0, env_js_1.resolveTracingMode)(config.tracingMode);
829
916
  if (this._tracingMode === "otel") {
@@ -858,8 +945,6 @@ class Client {
858
945
  // Use the global singleton instance
859
946
  this._promptCache = index_js_3.promptCacheSingleton;
860
947
  }
861
- // Initialize custom headers
862
- this._customHeaders = config.headers ?? {};
863
948
  }
864
949
  static getDefaultClientConfig() {
865
950
  const profileConfig = (0, profiles_js_1.loadProfileClientConfig)();
@@ -931,11 +1016,46 @@ class Client {
931
1016
  return this.webUrl;
932
1017
  }
933
1018
  }
1019
+ /**
1020
+ * The headers this client sets from its own config, which a caller-supplied
1021
+ * header must not replace.
1022
+ *
1023
+ * Only what the client *actually* supplies: passing an explicit `Authorization`
1024
+ * or `x-api-key` header with no configured credential is a supported way to
1025
+ * authenticate (see `hasExplicitAuthHeader`), so those must survive.
1026
+ */
1027
+ get _sdkControlledHeaders() {
1028
+ const names = new Set();
1029
+ if (this.apiKey !== undefined) {
1030
+ names.add("x-api-key");
1031
+ }
1032
+ else {
1033
+ const profileAuthHeader = this.profileAuth?.currentAuthHeader();
1034
+ if (profileAuthHeader) {
1035
+ names.add(profileAuthHeader.name.toLowerCase());
1036
+ }
1037
+ }
1038
+ if (this.workspaceId) {
1039
+ names.add("x-tenant-id");
1040
+ }
1041
+ return names;
1042
+ }
1043
+ /**
1044
+ * Headers supplied by the caller, through either `config.headers` or
1045
+ * `config.fetchOptions.headers`, with the ones this SDK sets removed.
1046
+ *
1047
+ * `_customHeaders` is normalized here rather than at assignment because it is
1048
+ * public and mutable: `get headers` hands back the caller's own object, so its
1049
+ * contents can change (and can become malformed) at any point.
1050
+ */
1051
+ get _callerHeaders() {
1052
+ return mergeCallerHeaders(normalizeHeaders(this._customHeaders), this._fetchOptionsHeaders, this._sdkControlledHeaders);
1053
+ }
934
1054
  get _mergedHeaders() {
935
- // Start with custom headers so they don't override required headers
1055
+ // Start with caller-supplied headers so they don't override required headers
936
1056
  const headers = {
937
1057
  "User-Agent": `langsmith-js/${index_js_1.__version__}`,
938
- ...this._customHeaders,
1058
+ ...this._callerHeaders,
939
1059
  };
940
1060
  // Required headers that should not be overridden
941
1061
  if (this.apiKey !== undefined) {
@@ -952,6 +1072,35 @@ class Client {
952
1072
  }
953
1073
  return headers;
954
1074
  }
1075
+ /**
1076
+ * The auth options and caller headers to build the generated client with.
1077
+ *
1078
+ * The generated client applies `defaultHeaders` *after* its own auth headers,
1079
+ * so the ones this SDK sets are already dropped from `_callerHeaders` to keep
1080
+ * the precedence of `_mergedHeaders`, where required headers win.
1081
+ */
1082
+ get _openAPIAuth() {
1083
+ const headers = { ...this._callerHeaders };
1084
+ // A caller may authenticate by supplying `x-api-key` themselves. The
1085
+ // generated client rejects that as a header (its `validateHeaders` requires
1086
+ // its own `apiKey` to be set), so hand it over as the `apiKey` option and
1087
+ // drop the header to avoid sending the same value twice.
1088
+ const callerApiKeyName = Object.keys(headers).find((name) => name.toLowerCase() === "x-api-key");
1089
+ let apiKey = this.apiKey;
1090
+ if (apiKey === undefined && callerApiKeyName !== undefined) {
1091
+ apiKey = headers[callerApiKeyName] ?? undefined;
1092
+ delete headers[callerApiKeyName];
1093
+ }
1094
+ if (apiKey === undefined && this.workspaceId === undefined) {
1095
+ // Let the wrapped `fetch` supply auth (profile auth, an explicit
1096
+ // `Authorization` header, or none at all).
1097
+ headers["X-API-Key"] = null;
1098
+ }
1099
+ return {
1100
+ apiKey,
1101
+ defaultHeaders: Object.keys(headers).length > 0 ? headers : undefined,
1102
+ };
1103
+ }
955
1104
  /**
956
1105
  * Get or set custom headers for the client.
957
1106
  * Custom headers are merged with default headers (User-Agent, x-api-key, x-tenant-id).
@@ -961,6 +1110,7 @@ class Client {
961
1110
  return this._customHeaders;
962
1111
  }
963
1112
  set headers(value) {
1113
+ assertValidHeaders(value);
964
1114
  this._customHeaders = value ?? {};
965
1115
  }
966
1116
  _getOpenAPIBaseUrl() {
@@ -971,19 +1121,36 @@ class Client {
971
1121
  }
972
1122
  return url;
973
1123
  }
974
- _newOpenAPIClient() {
975
- const defaultHeaders = this.apiKey === undefined && this.workspaceId === undefined
976
- ? { "X-API-Key": null }
977
- : undefined;
978
- const { method: _method, headers: _headers, body: _body, signal: _signal, ...openAPIFetchOptions } = this.fetchOptions;
1124
+ /**
1125
+ * The generated OpenAPI client, rebuilt whenever its auth or headers change.
1126
+ *
1127
+ * The generated client captures `defaultHeaders` and `apiKey` when it is
1128
+ * built, while the handwritten paths recompute `_mergedHeaders` per request.
1129
+ * Rebuilding on change keeps the two halves from diverging when the inputs
1130
+ * move underneath us — a caller mutating the object returned by
1131
+ * `get headers`, or a profile whose auth header only becomes available after
1132
+ * its token is refreshed.
1133
+ */
1134
+ get openAPIClient() {
1135
+ const auth = this._openAPIAuth;
1136
+ const signature = JSON.stringify([auth.apiKey, auth.defaultHeaders]);
1137
+ if (this._openAPIClient === undefined ||
1138
+ this._openAPIClientSignature !== signature) {
1139
+ this._openAPIClientSignature = signature;
1140
+ this._openAPIClient = this._newOpenAPIClient(auth);
1141
+ }
1142
+ return this._openAPIClient;
1143
+ }
1144
+ _newOpenAPIClient(auth = this._openAPIAuth) {
1145
+ const { method: _method, body: _body, signal: _signal, ...openAPIFetchOptions } = this.fetchOptions;
979
1146
  return new index_js_2.Langsmith({
980
- apiKey: this.apiKey,
1147
+ apiKey: auth.apiKey,
981
1148
  tenantID: this.workspaceId,
982
1149
  baseURL: this._getOpenAPIBaseUrl(),
983
1150
  timeout: this.timeout_ms,
984
1151
  fetch: this._fetch,
985
1152
  fetchOptions: openAPIFetchOptions,
986
- defaultHeaders,
1153
+ defaultHeaders: auth.defaultHeaders,
987
1154
  });
988
1155
  }
989
1156
  _getPlatformEndpointPath(path) {
@@ -1560,7 +1727,7 @@ class Client {
1560
1727
  async _checkFeedbackSessionId() {
1561
1728
  const docs = "https://docs.langchain.com/langsmith/smithdb-sdk-migration#feedback-create";
1562
1729
  const serverInfo = await this._ensureServerInfo();
1563
- if (serverInfo.instance_flags?.ch_query_enabled === false) {
1730
+ if ((0, v2_migration_js_1.getQueryBackend)(serverInfo.instance_flags) === v2_migration_js_1.QueryBackend.SMITHDB_ONLY) {
1564
1731
  throw new Error(`sessionId must be provided when creating feedback for a run: this ` +
1565
1732
  `deployment cannot locate the run without it. See ${docs}`);
1566
1733
  }
@@ -2085,7 +2252,22 @@ class Client {
2085
2252
  return res;
2086
2253
  });
2087
2254
  }
2255
+ /** @deprecated Use `client.runs.retrieve()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-retrieve for the migration guide. Will be removed after Jan 31, 2027. */
2088
2256
  async readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
2257
+ (0, warn_js_1.warnOnce)("readRun() is deprecated and will be removed after Jan 31, 2027. " +
2258
+ "Use client.runs.retrieve() instead. " +
2259
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-retrieve for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_READ_RUN" });
2260
+ return this._readRun(runId, { loadChildRuns });
2261
+ }
2262
+ /**
2263
+ * Fetch a run without emitting the `readRun()` deprecation warning.
2264
+ *
2265
+ * Internal callers use this so that a supported method doesn't warn about a
2266
+ * deprecated one the caller never invoked.
2267
+ *
2268
+ * @internal
2269
+ */
2270
+ async _readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
2089
2271
  (0, _uuid_js_1.assertUuid)(runId);
2090
2272
  let run = _normalizeRunTimestamps(await this._get(`/runs/${runId}`));
2091
2273
  if (loadChildRuns) {
@@ -2093,7 +2275,11 @@ class Client {
2093
2275
  }
2094
2276
  return run;
2095
2277
  }
2278
+ /** @deprecated Use `client.runs.getURL()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-get-url for the migration guide. Will be removed after Jan 31, 2027. */
2096
2279
  async getRunUrl({ runId, run, projectOpts, }) {
2280
+ (0, warn_js_1.warnOnce)("getRunUrl() is deprecated and will be removed after Jan 31, 2027. " +
2281
+ "Use client.runs.getURL() instead. " +
2282
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-get-url for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_GET_RUN_URL" });
2097
2283
  if (run !== undefined) {
2098
2284
  let sessionId;
2099
2285
  if (run.session_id) {
@@ -2115,7 +2301,9 @@ class Client {
2115
2301
  return `${this.getHostUrl()}/o/${tenantId}/projects/p/${sessionId}/r/${run.id}?poll=true`;
2116
2302
  }
2117
2303
  else if (runId !== undefined) {
2118
- const run_ = await this.readRun(runId);
2304
+ // Via _readRun() rather than readRun() so callers don't also get a
2305
+ // readRun deprecation warning for a method they never called.
2306
+ const run_ = await this._readRun(runId);
2119
2307
  if (!run_.app_path) {
2120
2308
  throw new Error(`Run ${runId} has no app_path`);
2121
2309
  }
@@ -2127,7 +2315,7 @@ class Client {
2127
2315
  }
2128
2316
  }
2129
2317
  async _loadChildRuns(run) {
2130
- const childRuns = await toArray(this.listRuns({
2318
+ const childRuns = await toArray(this._listRuns({
2131
2319
  isRoot: false,
2132
2320
  projectId: run.session_id,
2133
2321
  traceId: run.trace_id,
@@ -2160,6 +2348,7 @@ class Client {
2160
2348
  }
2161
2349
  /**
2162
2350
  * List runs from the LangSmith server.
2351
+ * @deprecated Use `client.runs.query()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-query for the migration guide. Will be removed after Jan 31, 2027.
2163
2352
  * @param projectId - The ID of the project to filter by.
2164
2353
  * @param projectName - The name of the project to filter by.
2165
2354
  * @param parentRunId - The ID of the parent run to filter by.
@@ -2241,6 +2430,20 @@ class Client {
2241
2430
  * });
2242
2431
  */
2243
2432
  async *listRuns(props) {
2433
+ (0, warn_js_1.warnOnce)("listRuns() is deprecated and will be removed after Jan 31, 2027. " +
2434
+ "Use client.runs.query() instead. " +
2435
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-query for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_LIST_RUNS" });
2436
+ yield* this._listRuns(props);
2437
+ }
2438
+ /**
2439
+ * List runs without emitting the `listRuns()` deprecation warning.
2440
+ *
2441
+ * Internal callers use this so that a supported method doesn't warn about a
2442
+ * deprecated one the caller never invoked.
2443
+ *
2444
+ * @internal
2445
+ */
2446
+ async *_listRuns(props) {
2244
2447
  const { projectId, projectName, parentRunId, traceId, referenceExampleId, startTime, executionOrder, isRoot, runType, error, id, query, filter, traceFilter, treeFilter, limit, select, order, } = props;
2245
2448
  let projectIds = [];
2246
2449
  if (projectId) {
@@ -2374,7 +2577,11 @@ class Client {
2374
2577
  }
2375
2578
  }
2376
2579
  }
2580
+ /** @deprecated Use `client.threads.listTraces()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-list-traces for the migration guide. Will be removed after Jan 31, 2027. */
2377
2581
  async *readThread(props) {
2582
+ (0, warn_js_1.warnOnce)("readThread() is deprecated and will be removed after Jan 31, 2027. " +
2583
+ "Use client.threads.listTraces() instead. " +
2584
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-list-traces for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_READ_THREAD" });
2378
2585
  const { threadId, projectId, projectName, isRoot = true, limit, filter: userFilter, order = "asc", } = props;
2379
2586
  if (!projectId && !projectName) {
2380
2587
  throw new Error("threadId requires projectId or projectName");
@@ -2383,7 +2590,9 @@ class Client {
2383
2590
  const combinedFilter = userFilter
2384
2591
  ? `and(${threadFilter}, ${userFilter})`
2385
2592
  : threadFilter;
2386
- yield* this.listRuns({
2593
+ // Via _listRuns() rather than listRuns(): readThread() already warned, and it
2594
+ // points at threads.listTraces() rather than listRuns()'s runs.query().
2595
+ yield* this._listRuns({
2387
2596
  projectId: projectId ?? undefined,
2388
2597
  projectName: projectName ?? undefined,
2389
2598
  isRoot,
@@ -2392,7 +2601,11 @@ class Client {
2392
2601
  order,
2393
2602
  });
2394
2603
  }
2604
+ /** @deprecated Use `client.threads.query()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-query for the migration guide. Will be removed after Jan 31, 2027. */
2395
2605
  async listThreads(props) {
2606
+ (0, warn_js_1.warnOnce)("listThreads() is deprecated and will be removed after Jan 31, 2027. " +
2607
+ "Use client.threads.query() instead. " +
2608
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-query for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_LIST_THREADS" });
2396
2609
  const { projectId, projectName, limit, offset = 0, filter, startTime, isRoot = true, } = props;
2397
2610
  if (!projectId && !projectName) {
2398
2611
  throw new Error("Either projectId or projectName must be provided");
@@ -2542,7 +2755,11 @@ class Client {
2542
2755
  const result = await response.json();
2543
2756
  return result;
2544
2757
  }
2758
+ /** @deprecated Use `client.runs.share.create()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide. Will be removed after Jan 31, 2027. */
2545
2759
  async shareRun(runId, { shareId } = {}) {
2760
+ (0, warn_js_1.warnOnce)("shareRun() is deprecated and will be removed after Jan 31, 2027. " +
2761
+ "Use client.runs.share.create() instead. " +
2762
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_SHARE_RUN" });
2546
2763
  const data = {
2547
2764
  run_id: runId,
2548
2765
  share_token: shareId || uuid.v4(),
@@ -2566,7 +2783,11 @@ class Client {
2566
2783
  }
2567
2784
  return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
2568
2785
  }
2786
+ /** @deprecated Use `client.runs.share.delete()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide. Will be removed after Jan 31, 2027. */
2569
2787
  async unshareRun(runId) {
2788
+ (0, warn_js_1.warnOnce)("unshareRun() is deprecated and will be removed after Jan 31, 2027. " +
2789
+ "Use client.runs.share.delete() instead. " +
2790
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_UNSHARE_RUN" });
2570
2791
  (0, _uuid_js_1.assertUuid)(runId);
2571
2792
  await this.caller.call(async () => {
2572
2793
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
@@ -2579,7 +2800,14 @@ class Client {
2579
2800
  return res;
2580
2801
  });
2581
2802
  }
2803
+ /** @deprecated Use `client.runs.retrieve({ selects: ["SHARE_URL"] })` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide. Will be removed after Jan 31, 2027. */
2582
2804
  async readRunSharedLink(runId) {
2805
+ (0, warn_js_1.warnOnce)("readRunSharedLink() is deprecated and will be removed after Jan 31, 2027. " +
2806
+ 'Use client.runs.retrieve({ selects: ["SHARE_URL"] }) instead. ' +
2807
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.", {
2808
+ type: "DeprecationWarning",
2809
+ code: "LANGSMITH_DEPRECATED_READ_RUN_SHARED_LINK",
2810
+ });
2583
2811
  (0, _uuid_js_1.assertUuid)(runId);
2584
2812
  const response = await this.caller.call(async () => {
2585
2813
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
@@ -2597,7 +2825,14 @@ class Client {
2597
2825
  }
2598
2826
  return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
2599
2827
  }
2828
+ /** @deprecated Use `client.public.runs.query()` instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide. Will be removed after Jan 31, 2027. */
2600
2829
  async listSharedRuns(shareToken, { runIds, } = {}) {
2830
+ (0, warn_js_1.warnOnce)("listSharedRuns() is deprecated and will be removed after Jan 31, 2027. " +
2831
+ "Use client.public.runs.query() instead. " +
2832
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.", {
2833
+ type: "DeprecationWarning",
2834
+ code: "LANGSMITH_DEPRECATED_LIST_SHARED_RUNS",
2835
+ });
2601
2836
  const queryParams = new URLSearchParams({
2602
2837
  share_token: shareToken,
2603
2838
  });
@@ -4186,8 +4421,9 @@ class Client {
4186
4421
  * - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
4187
4422
  * it can be located directly without a scan. Required for workspaces served
4188
4423
  * by SmithDB; routes to `POST /runs/by-key`.
4189
- * - `string[]`: a plain list of run IDs. This path will be deprecated in a
4190
- * future release; prefer the key form. Routes to `POST /runs`.
4424
+ * - `string[]`: a plain list of run IDs. **Deprecated**: this path will be
4425
+ * removed after Jan 31, 2027; prefer the key form. Routes to `POST /runs`.
4426
+ * See https://docs.langchain.com/langsmith/smithdb-sdk-migration#annotation-queues-add-runs.
4191
4427
  *
4192
4428
  * If every element is a string (or the list is empty) it is treated as run
4193
4429
  * IDs; otherwise the list is treated as `RunKey` objects.
@@ -4218,6 +4454,12 @@ class Client {
4218
4454
  }));
4219
4455
  }
4220
4456
  else {
4457
+ (0, warn_js_1.warnOnce)("Passing run IDs as strings to addRunsToAnnotationQueue() is deprecated and will be removed after Jan 31, 2027. " +
4458
+ "Use RunKey[] instead. " +
4459
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#annotation-queues-add-runs for the migration guide.", {
4460
+ type: "DeprecationWarning",
4461
+ code: "LANGSMITH_DEPRECATED_ADD_RUNS_STRING_IDS",
4462
+ });
4221
4463
  url = base;
4222
4464
  body = JSON.stringify(runs.map((id, i) => (0, _uuid_js_1.assertUuid)(id, `runs[${i}]`).toString()));
4223
4465
  }