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
package/dist/client.d.ts CHANGED
@@ -501,8 +501,11 @@ export declare class Client implements LangSmithTracingClientInterface {
501
501
  private autoBatchAggregationDelayMs;
502
502
  private batchSizeBytesLimit?;
503
503
  private batchSizeLimit?;
504
+ /** `config.fetchOptions` without its `headers`, which are merged separately. */
504
505
  private fetchOptions;
505
- private openAPIClient;
506
+ private _fetchOptionsHeaders;
507
+ private _openAPIClient?;
508
+ private _openAPIClientSignature?;
506
509
  private settings;
507
510
  private blockOnRootRunFinalization;
508
511
  private traceBatchConcurrency;
@@ -555,7 +558,33 @@ export declare class Client implements LangSmithTracingClientInterface {
555
558
  constructor(config?: ClientConfig);
556
559
  static getDefaultClientConfig(): DefaultClientConfig;
557
560
  getHostUrl(): string;
561
+ /**
562
+ * The headers this client sets from its own config, which a caller-supplied
563
+ * header must not replace.
564
+ *
565
+ * Only what the client *actually* supplies: passing an explicit `Authorization`
566
+ * or `x-api-key` header with no configured credential is a supported way to
567
+ * authenticate (see `hasExplicitAuthHeader`), so those must survive.
568
+ */
569
+ private get _sdkControlledHeaders();
570
+ /**
571
+ * Headers supplied by the caller, through either `config.headers` or
572
+ * `config.fetchOptions.headers`, with the ones this SDK sets removed.
573
+ *
574
+ * `_customHeaders` is normalized here rather than at assignment because it is
575
+ * public and mutable: `get headers` hands back the caller's own object, so its
576
+ * contents can change (and can become malformed) at any point.
577
+ */
578
+ private get _callerHeaders();
558
579
  private get _mergedHeaders();
580
+ /**
581
+ * The auth options and caller headers to build the generated client with.
582
+ *
583
+ * The generated client applies `defaultHeaders` *after* its own auth headers,
584
+ * so the ones this SDK sets are already dropped from `_callerHeaders` to keep
585
+ * the precedence of `_mergedHeaders`, where required headers win.
586
+ */
587
+ private get _openAPIAuth();
559
588
  /**
560
589
  * Get or set custom headers for the client.
561
590
  * Custom headers are merged with default headers (User-Agent, x-api-key, x-tenant-id).
@@ -564,6 +593,17 @@ export declare class Client implements LangSmithTracingClientInterface {
564
593
  get headers(): Record<string, string>;
565
594
  set headers(value: Record<string, string> | undefined);
566
595
  private _getOpenAPIBaseUrl;
596
+ /**
597
+ * The generated OpenAPI client, rebuilt whenever its auth or headers change.
598
+ *
599
+ * The generated client captures `defaultHeaders` and `apiKey` when it is
600
+ * built, while the handwritten paths recompute `_mergedHeaders` per request.
601
+ * Rebuilding on change keeps the two halves from diverging when the inputs
602
+ * move underneath us — a caller mutating the object returned by
603
+ * `get headers`, or a profile whose auth header only becomes available after
604
+ * its token is refreshed.
605
+ */
606
+ private get openAPIClient();
567
607
  private _newOpenAPIClient;
568
608
  private _getPlatformEndpointPath;
569
609
  get evaluators(): Evaluators;
@@ -687,9 +727,11 @@ export declare class Client implements LangSmithTracingClientInterface {
687
727
  apiUrl?: string;
688
728
  workspaceId?: string;
689
729
  }): Promise<void>;
730
+ /** @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. */
690
731
  readRun(runId: string, { loadChildRuns }?: {
691
732
  loadChildRuns: boolean;
692
733
  }): Promise<Run>;
734
+ /** @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. */
693
735
  getRunUrl({ runId, run, projectOpts, }: {
694
736
  runId?: string;
695
737
  run?: Run;
@@ -698,6 +740,7 @@ export declare class Client implements LangSmithTracingClientInterface {
698
740
  private _loadChildRuns;
699
741
  /**
700
742
  * List runs from the LangSmith server.
743
+ * @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.
701
744
  * @param projectId - The ID of the project to filter by.
702
745
  * @param projectName - The name of the project to filter by.
703
746
  * @param parentRunId - The ID of the parent run to filter by.
@@ -780,7 +823,9 @@ export declare class Client implements LangSmithTracingClientInterface {
780
823
  */
781
824
  listRuns(props: ListRunsParams): AsyncIterable<Run>;
782
825
  listGroupRuns(props: GroupRunsParams): AsyncIterable<Thread>;
826
+ /** @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. */
783
827
  readThread(props: ReadThreadParams): AsyncIterable<Run>;
828
+ /** @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. */
784
829
  listThreads(props: ListThreadsParams): Promise<ListThreadsItem[]>;
785
830
  getRunStats({ id, trace, parentRun, runType, projectNames, projectIds, referenceExampleIds, startTime, endTime, error, query, filter, traceFilter, treeFilter, isRoot, dataSourceType, }: {
786
831
  id?: string[];
@@ -800,11 +845,15 @@ export declare class Client implements LangSmithTracingClientInterface {
800
845
  isRoot?: boolean;
801
846
  dataSourceType?: string;
802
847
  }): Promise<any>;
848
+ /** @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. */
803
849
  shareRun(runId: string, { shareId }?: {
804
850
  shareId?: string;
805
851
  }): Promise<string>;
852
+ /** @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. */
806
853
  unshareRun(runId: string): Promise<void>;
854
+ /** @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. */
807
855
  readRunSharedLink(runId: string): Promise<string | undefined>;
856
+ /** @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. */
808
857
  listSharedRuns(shareToken: string, { runIds, }?: {
809
858
  runIds?: string[];
810
859
  }): Promise<Run[]>;
@@ -1196,8 +1245,9 @@ export declare class Client implements LangSmithTracingClientInterface {
1196
1245
  * - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
1197
1246
  * it can be located directly without a scan. Required for workspaces served
1198
1247
  * by SmithDB; routes to `POST /runs/by-key`.
1199
- * - `string[]`: a plain list of run IDs. This path will be deprecated in a
1200
- * future release; prefer the key form. Routes to `POST /runs`.
1248
+ * - `string[]`: a plain list of run IDs. **Deprecated**: this path will be
1249
+ * removed after Jan 31, 2027; prefer the key form. Routes to `POST /runs`.
1250
+ * See https://docs.langchain.com/langsmith/smithdb-sdk-migration#annotation-queues-add-runs.
1201
1251
  *
1202
1252
  * If every element is a string (or the list is empty) it is treated as run
1203
1253
  * IDs; otherwise the list is treated as `RunKey` objects.
package/dist/client.js CHANGED
@@ -8,6 +8,7 @@ import { __version__ } from "./index.js";
8
8
  import { Langsmith as OpenAPILangsmith } from "./_openapi_client/index.js";
9
9
  import { assertUuid } from "./utils/_uuid.js";
10
10
  import { warnOnce } from "./utils/warn.js";
11
+ import { getQueryBackend, QueryBackend } from "./utils/v2_migration.js";
11
12
  import { parseHubIdentifier } from "./utils/prompts.js";
12
13
  import { raiseForStatus, isLangSmithNotFoundError, isLangSmithConflictError, } from "./utils/error.js";
13
14
  import { promptCacheSingleton, } from "./utils/prompt_cache/index.js";
@@ -154,6 +155,72 @@ export const DEFAULT_MAX_SIZE_BYTES = 1024 * 1024 * 1024; // 1GB
154
155
  const SERVER_INFO_REQUEST_TIMEOUT_MS = 10000;
155
156
  /** Maximum number of operations to batch in a single request. */
156
157
  const DEFAULT_BATCH_SIZE_LIMIT = 100;
158
+ /**
159
+ * Reject header names or values that could alter a request's framing.
160
+ *
161
+ * `Headers` does this for us, and does it the same way `fetch` will.
162
+ */
163
+ function assertValidHeader(name, value) {
164
+ new Headers({ [name]: value });
165
+ }
166
+ /** Reject a malformed header up front, before it can reach a request. */
167
+ function assertValidHeaders(headers) {
168
+ for (const [name, value] of Object.entries(headers ?? {})) {
169
+ assertValidHeader(name, value);
170
+ }
171
+ }
172
+ /**
173
+ * Fold a `HeadersInit` into a plain object so it can be spread.
174
+ *
175
+ * Names are matched case-insensitively with the last value winning, keeping the
176
+ * first spelling seen. A plain object would instead keep both spellings, which
177
+ * `Headers` later joins into a `"first, second"` list rather than an override.
178
+ * Every name and value is validated on the way through.
179
+ */
180
+ function normalizeHeaders(headers) {
181
+ if (!headers)
182
+ return {};
183
+ const entries = headers instanceof Headers
184
+ ? [...headers.entries()]
185
+ : Array.isArray(headers)
186
+ ? headers.map(([name, value]) => [name, value])
187
+ : Object.entries(headers);
188
+ const normalized = {};
189
+ const nameByLower = new Map();
190
+ for (const [name, value] of entries) {
191
+ assertValidHeader(name, value);
192
+ const lowerName = name.toLowerCase();
193
+ const existingName = nameByLower.get(lowerName);
194
+ if (existingName === undefined) {
195
+ nameByLower.set(lowerName, name);
196
+ normalized[name] = value;
197
+ }
198
+ else {
199
+ normalized[existingName] = value;
200
+ }
201
+ }
202
+ return normalized;
203
+ }
204
+ /**
205
+ * Merge the caller's two header channels, then drop the `reserved` names.
206
+ *
207
+ * `overrides` wins, matched case-insensitively so a header supplied through both
208
+ * channels is overridden rather than turned into a `"first, second"` list.
209
+ */
210
+ function mergeCallerHeaders(base, overrides, reserved) {
211
+ const merged = { ...base };
212
+ const nameByLower = new Map(Object.keys(merged).map((name) => [name.toLowerCase(), name]));
213
+ for (const [name, value] of Object.entries(overrides)) {
214
+ const lowerName = name.toLowerCase();
215
+ merged[nameByLower.get(lowerName) ?? name] = value;
216
+ }
217
+ for (const name of Object.keys(merged)) {
218
+ if (reserved.has(name.toLowerCase())) {
219
+ delete merged[name];
220
+ }
221
+ }
222
+ return merged;
223
+ }
157
224
  export class AutoBatchQueue {
158
225
  constructor(maxSizeBytes) {
159
226
  Object.defineProperty(this, "items", {
@@ -572,13 +639,26 @@ export class Client {
572
639
  writable: true,
573
640
  value: void 0
574
641
  });
642
+ /** `config.fetchOptions` without its `headers`, which are merged separately. */
575
643
  Object.defineProperty(this, "fetchOptions", {
576
644
  enumerable: true,
577
645
  configurable: true,
578
646
  writable: true,
579
647
  value: void 0
580
648
  });
581
- Object.defineProperty(this, "openAPIClient", {
649
+ Object.defineProperty(this, "_fetchOptionsHeaders", {
650
+ enumerable: true,
651
+ configurable: true,
652
+ writable: true,
653
+ value: {}
654
+ });
655
+ Object.defineProperty(this, "_openAPIClient", {
656
+ enumerable: true,
657
+ configurable: true,
658
+ writable: true,
659
+ value: void 0
660
+ });
661
+ Object.defineProperty(this, "_openAPIClientSignature", {
582
662
  enumerable: true,
583
663
  configurable: true,
584
664
  writable: true,
@@ -783,8 +863,15 @@ export class Client {
783
863
  config.blockOnRootRunFinalization ?? this.blockOnRootRunFinalization;
784
864
  this.batchSizeBytesLimit = config.batchSizeBytesLimit;
785
865
  this.batchSizeLimit = config.batchSizeLimit;
786
- this.fetchOptions = config.fetchOptions || {};
787
- this.openAPIClient = this._newOpenAPIClient();
866
+ const { headers: fetchOptionsHeaders, ...fetchOptions } = config.fetchOptions || {};
867
+ this.fetchOptions = fetchOptions;
868
+ // Kept apart from `fetchOptions` so they can be merged *under* the required
869
+ // headers instead of replacing the whole set at each call site.
870
+ this._fetchOptionsHeaders = normalizeHeaders(fetchOptionsHeaders);
871
+ // Validated eagerly so malformed input fails at construction, but stored
872
+ // as given: `get headers` hands this object back to the caller.
873
+ assertValidHeaders(config.headers);
874
+ this._customHeaders = config.headers ?? {};
788
875
  this.manualFlushMode = config.manualFlushMode ?? this.manualFlushMode;
789
876
  this._tracingMode = resolveTracingMode(config.tracingMode);
790
877
  if (this._tracingMode === "otel") {
@@ -819,8 +906,6 @@ export class Client {
819
906
  // Use the global singleton instance
820
907
  this._promptCache = promptCacheSingleton;
821
908
  }
822
- // Initialize custom headers
823
- this._customHeaders = config.headers ?? {};
824
909
  }
825
910
  static getDefaultClientConfig() {
826
911
  const profileConfig = loadProfileClientConfig();
@@ -892,11 +977,46 @@ export class Client {
892
977
  return this.webUrl;
893
978
  }
894
979
  }
980
+ /**
981
+ * The headers this client sets from its own config, which a caller-supplied
982
+ * header must not replace.
983
+ *
984
+ * Only what the client *actually* supplies: passing an explicit `Authorization`
985
+ * or `x-api-key` header with no configured credential is a supported way to
986
+ * authenticate (see `hasExplicitAuthHeader`), so those must survive.
987
+ */
988
+ get _sdkControlledHeaders() {
989
+ const names = new Set();
990
+ if (this.apiKey !== undefined) {
991
+ names.add("x-api-key");
992
+ }
993
+ else {
994
+ const profileAuthHeader = this.profileAuth?.currentAuthHeader();
995
+ if (profileAuthHeader) {
996
+ names.add(profileAuthHeader.name.toLowerCase());
997
+ }
998
+ }
999
+ if (this.workspaceId) {
1000
+ names.add("x-tenant-id");
1001
+ }
1002
+ return names;
1003
+ }
1004
+ /**
1005
+ * Headers supplied by the caller, through either `config.headers` or
1006
+ * `config.fetchOptions.headers`, with the ones this SDK sets removed.
1007
+ *
1008
+ * `_customHeaders` is normalized here rather than at assignment because it is
1009
+ * public and mutable: `get headers` hands back the caller's own object, so its
1010
+ * contents can change (and can become malformed) at any point.
1011
+ */
1012
+ get _callerHeaders() {
1013
+ return mergeCallerHeaders(normalizeHeaders(this._customHeaders), this._fetchOptionsHeaders, this._sdkControlledHeaders);
1014
+ }
895
1015
  get _mergedHeaders() {
896
- // Start with custom headers so they don't override required headers
1016
+ // Start with caller-supplied headers so they don't override required headers
897
1017
  const headers = {
898
1018
  "User-Agent": `langsmith-js/${__version__}`,
899
- ...this._customHeaders,
1019
+ ...this._callerHeaders,
900
1020
  };
901
1021
  // Required headers that should not be overridden
902
1022
  if (this.apiKey !== undefined) {
@@ -913,6 +1033,35 @@ export class Client {
913
1033
  }
914
1034
  return headers;
915
1035
  }
1036
+ /**
1037
+ * The auth options and caller headers to build the generated client with.
1038
+ *
1039
+ * The generated client applies `defaultHeaders` *after* its own auth headers,
1040
+ * so the ones this SDK sets are already dropped from `_callerHeaders` to keep
1041
+ * the precedence of `_mergedHeaders`, where required headers win.
1042
+ */
1043
+ get _openAPIAuth() {
1044
+ const headers = { ...this._callerHeaders };
1045
+ // A caller may authenticate by supplying `x-api-key` themselves. The
1046
+ // generated client rejects that as a header (its `validateHeaders` requires
1047
+ // its own `apiKey` to be set), so hand it over as the `apiKey` option and
1048
+ // drop the header to avoid sending the same value twice.
1049
+ const callerApiKeyName = Object.keys(headers).find((name) => name.toLowerCase() === "x-api-key");
1050
+ let apiKey = this.apiKey;
1051
+ if (apiKey === undefined && callerApiKeyName !== undefined) {
1052
+ apiKey = headers[callerApiKeyName] ?? undefined;
1053
+ delete headers[callerApiKeyName];
1054
+ }
1055
+ if (apiKey === undefined && this.workspaceId === undefined) {
1056
+ // Let the wrapped `fetch` supply auth (profile auth, an explicit
1057
+ // `Authorization` header, or none at all).
1058
+ headers["X-API-Key"] = null;
1059
+ }
1060
+ return {
1061
+ apiKey,
1062
+ defaultHeaders: Object.keys(headers).length > 0 ? headers : undefined,
1063
+ };
1064
+ }
916
1065
  /**
917
1066
  * Get or set custom headers for the client.
918
1067
  * Custom headers are merged with default headers (User-Agent, x-api-key, x-tenant-id).
@@ -922,6 +1071,7 @@ export class Client {
922
1071
  return this._customHeaders;
923
1072
  }
924
1073
  set headers(value) {
1074
+ assertValidHeaders(value);
925
1075
  this._customHeaders = value ?? {};
926
1076
  }
927
1077
  _getOpenAPIBaseUrl() {
@@ -932,19 +1082,36 @@ export class Client {
932
1082
  }
933
1083
  return url;
934
1084
  }
935
- _newOpenAPIClient() {
936
- const defaultHeaders = this.apiKey === undefined && this.workspaceId === undefined
937
- ? { "X-API-Key": null }
938
- : undefined;
939
- const { method: _method, headers: _headers, body: _body, signal: _signal, ...openAPIFetchOptions } = this.fetchOptions;
1085
+ /**
1086
+ * The generated OpenAPI client, rebuilt whenever its auth or headers change.
1087
+ *
1088
+ * The generated client captures `defaultHeaders` and `apiKey` when it is
1089
+ * built, while the handwritten paths recompute `_mergedHeaders` per request.
1090
+ * Rebuilding on change keeps the two halves from diverging when the inputs
1091
+ * move underneath us — a caller mutating the object returned by
1092
+ * `get headers`, or a profile whose auth header only becomes available after
1093
+ * its token is refreshed.
1094
+ */
1095
+ get openAPIClient() {
1096
+ const auth = this._openAPIAuth;
1097
+ const signature = JSON.stringify([auth.apiKey, auth.defaultHeaders]);
1098
+ if (this._openAPIClient === undefined ||
1099
+ this._openAPIClientSignature !== signature) {
1100
+ this._openAPIClientSignature = signature;
1101
+ this._openAPIClient = this._newOpenAPIClient(auth);
1102
+ }
1103
+ return this._openAPIClient;
1104
+ }
1105
+ _newOpenAPIClient(auth = this._openAPIAuth) {
1106
+ const { method: _method, body: _body, signal: _signal, ...openAPIFetchOptions } = this.fetchOptions;
940
1107
  return new OpenAPILangsmith({
941
- apiKey: this.apiKey,
1108
+ apiKey: auth.apiKey,
942
1109
  tenantID: this.workspaceId,
943
1110
  baseURL: this._getOpenAPIBaseUrl(),
944
1111
  timeout: this.timeout_ms,
945
1112
  fetch: this._fetch,
946
1113
  fetchOptions: openAPIFetchOptions,
947
- defaultHeaders,
1114
+ defaultHeaders: auth.defaultHeaders,
948
1115
  });
949
1116
  }
950
1117
  _getPlatformEndpointPath(path) {
@@ -1521,7 +1688,7 @@ export class Client {
1521
1688
  async _checkFeedbackSessionId() {
1522
1689
  const docs = "https://docs.langchain.com/langsmith/smithdb-sdk-migration#feedback-create";
1523
1690
  const serverInfo = await this._ensureServerInfo();
1524
- if (serverInfo.instance_flags?.ch_query_enabled === false) {
1691
+ if (getQueryBackend(serverInfo.instance_flags) === QueryBackend.SMITHDB_ONLY) {
1525
1692
  throw new Error(`sessionId must be provided when creating feedback for a run: this ` +
1526
1693
  `deployment cannot locate the run without it. See ${docs}`);
1527
1694
  }
@@ -2046,7 +2213,22 @@ export class Client {
2046
2213
  return res;
2047
2214
  });
2048
2215
  }
2216
+ /** @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. */
2049
2217
  async readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
2218
+ warnOnce("readRun() is deprecated and will be removed after Jan 31, 2027. " +
2219
+ "Use client.runs.retrieve() instead. " +
2220
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-retrieve for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_READ_RUN" });
2221
+ return this._readRun(runId, { loadChildRuns });
2222
+ }
2223
+ /**
2224
+ * Fetch a run without emitting the `readRun()` deprecation warning.
2225
+ *
2226
+ * Internal callers use this so that a supported method doesn't warn about a
2227
+ * deprecated one the caller never invoked.
2228
+ *
2229
+ * @internal
2230
+ */
2231
+ async _readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
2050
2232
  assertUuid(runId);
2051
2233
  let run = _normalizeRunTimestamps(await this._get(`/runs/${runId}`));
2052
2234
  if (loadChildRuns) {
@@ -2054,7 +2236,11 @@ export class Client {
2054
2236
  }
2055
2237
  return run;
2056
2238
  }
2239
+ /** @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. */
2057
2240
  async getRunUrl({ runId, run, projectOpts, }) {
2241
+ warnOnce("getRunUrl() is deprecated and will be removed after Jan 31, 2027. " +
2242
+ "Use client.runs.getURL() instead. " +
2243
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-get-url for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_GET_RUN_URL" });
2058
2244
  if (run !== undefined) {
2059
2245
  let sessionId;
2060
2246
  if (run.session_id) {
@@ -2076,7 +2262,9 @@ export class Client {
2076
2262
  return `${this.getHostUrl()}/o/${tenantId}/projects/p/${sessionId}/r/${run.id}?poll=true`;
2077
2263
  }
2078
2264
  else if (runId !== undefined) {
2079
- const run_ = await this.readRun(runId);
2265
+ // Via _readRun() rather than readRun() so callers don't also get a
2266
+ // readRun deprecation warning for a method they never called.
2267
+ const run_ = await this._readRun(runId);
2080
2268
  if (!run_.app_path) {
2081
2269
  throw new Error(`Run ${runId} has no app_path`);
2082
2270
  }
@@ -2088,7 +2276,7 @@ export class Client {
2088
2276
  }
2089
2277
  }
2090
2278
  async _loadChildRuns(run) {
2091
- const childRuns = await toArray(this.listRuns({
2279
+ const childRuns = await toArray(this._listRuns({
2092
2280
  isRoot: false,
2093
2281
  projectId: run.session_id,
2094
2282
  traceId: run.trace_id,
@@ -2121,6 +2309,7 @@ export class Client {
2121
2309
  }
2122
2310
  /**
2123
2311
  * List runs from the LangSmith server.
2312
+ * @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.
2124
2313
  * @param projectId - The ID of the project to filter by.
2125
2314
  * @param projectName - The name of the project to filter by.
2126
2315
  * @param parentRunId - The ID of the parent run to filter by.
@@ -2202,6 +2391,20 @@ export class Client {
2202
2391
  * });
2203
2392
  */
2204
2393
  async *listRuns(props) {
2394
+ warnOnce("listRuns() is deprecated and will be removed after Jan 31, 2027. " +
2395
+ "Use client.runs.query() instead. " +
2396
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-query for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_LIST_RUNS" });
2397
+ yield* this._listRuns(props);
2398
+ }
2399
+ /**
2400
+ * List runs without emitting the `listRuns()` deprecation warning.
2401
+ *
2402
+ * Internal callers use this so that a supported method doesn't warn about a
2403
+ * deprecated one the caller never invoked.
2404
+ *
2405
+ * @internal
2406
+ */
2407
+ async *_listRuns(props) {
2205
2408
  const { projectId, projectName, parentRunId, traceId, referenceExampleId, startTime, executionOrder, isRoot, runType, error, id, query, filter, traceFilter, treeFilter, limit, select, order, } = props;
2206
2409
  let projectIds = [];
2207
2410
  if (projectId) {
@@ -2335,7 +2538,11 @@ export class Client {
2335
2538
  }
2336
2539
  }
2337
2540
  }
2541
+ /** @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. */
2338
2542
  async *readThread(props) {
2543
+ warnOnce("readThread() is deprecated and will be removed after Jan 31, 2027. " +
2544
+ "Use client.threads.listTraces() instead. " +
2545
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-list-traces for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_READ_THREAD" });
2339
2546
  const { threadId, projectId, projectName, isRoot = true, limit, filter: userFilter, order = "asc", } = props;
2340
2547
  if (!projectId && !projectName) {
2341
2548
  throw new Error("threadId requires projectId or projectName");
@@ -2344,7 +2551,9 @@ export class Client {
2344
2551
  const combinedFilter = userFilter
2345
2552
  ? `and(${threadFilter}, ${userFilter})`
2346
2553
  : threadFilter;
2347
- yield* this.listRuns({
2554
+ // Via _listRuns() rather than listRuns(): readThread() already warned, and it
2555
+ // points at threads.listTraces() rather than listRuns()'s runs.query().
2556
+ yield* this._listRuns({
2348
2557
  projectId: projectId ?? undefined,
2349
2558
  projectName: projectName ?? undefined,
2350
2559
  isRoot,
@@ -2353,7 +2562,11 @@ export class Client {
2353
2562
  order,
2354
2563
  });
2355
2564
  }
2565
+ /** @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. */
2356
2566
  async listThreads(props) {
2567
+ warnOnce("listThreads() is deprecated and will be removed after Jan 31, 2027. " +
2568
+ "Use client.threads.query() instead. " +
2569
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-query for the migration guide.", { type: "DeprecationWarning", code: "LANGSMITH_DEPRECATED_LIST_THREADS" });
2357
2570
  const { projectId, projectName, limit, offset = 0, filter, startTime, isRoot = true, } = props;
2358
2571
  if (!projectId && !projectName) {
2359
2572
  throw new Error("Either projectId or projectName must be provided");
@@ -2503,7 +2716,11 @@ export class Client {
2503
2716
  const result = await response.json();
2504
2717
  return result;
2505
2718
  }
2719
+ /** @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. */
2506
2720
  async shareRun(runId, { shareId } = {}) {
2721
+ warnOnce("shareRun() is deprecated and will be removed after Jan 31, 2027. " +
2722
+ "Use client.runs.share.create() instead. " +
2723
+ "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" });
2507
2724
  const data = {
2508
2725
  run_id: runId,
2509
2726
  share_token: shareId || uuid.v4(),
@@ -2527,7 +2744,11 @@ export class Client {
2527
2744
  }
2528
2745
  return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
2529
2746
  }
2747
+ /** @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. */
2530
2748
  async unshareRun(runId) {
2749
+ warnOnce("unshareRun() is deprecated and will be removed after Jan 31, 2027. " +
2750
+ "Use client.runs.share.delete() instead. " +
2751
+ "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" });
2531
2752
  assertUuid(runId);
2532
2753
  await this.caller.call(async () => {
2533
2754
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
@@ -2540,7 +2761,14 @@ export class Client {
2540
2761
  return res;
2541
2762
  });
2542
2763
  }
2764
+ /** @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. */
2543
2765
  async readRunSharedLink(runId) {
2766
+ warnOnce("readRunSharedLink() is deprecated and will be removed after Jan 31, 2027. " +
2767
+ 'Use client.runs.retrieve({ selects: ["SHARE_URL"] }) instead. ' +
2768
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.", {
2769
+ type: "DeprecationWarning",
2770
+ code: "LANGSMITH_DEPRECATED_READ_RUN_SHARED_LINK",
2771
+ });
2544
2772
  assertUuid(runId);
2545
2773
  const response = await this.caller.call(async () => {
2546
2774
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
@@ -2558,7 +2786,14 @@ export class Client {
2558
2786
  }
2559
2787
  return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
2560
2788
  }
2789
+ /** @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. */
2561
2790
  async listSharedRuns(shareToken, { runIds, } = {}) {
2791
+ warnOnce("listSharedRuns() is deprecated and will be removed after Jan 31, 2027. " +
2792
+ "Use client.public.runs.query() instead. " +
2793
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.", {
2794
+ type: "DeprecationWarning",
2795
+ code: "LANGSMITH_DEPRECATED_LIST_SHARED_RUNS",
2796
+ });
2562
2797
  const queryParams = new URLSearchParams({
2563
2798
  share_token: shareToken,
2564
2799
  });
@@ -4147,8 +4382,9 @@ export class Client {
4147
4382
  * - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
4148
4383
  * it can be located directly without a scan. Required for workspaces served
4149
4384
  * by SmithDB; routes to `POST /runs/by-key`.
4150
- * - `string[]`: a plain list of run IDs. This path will be deprecated in a
4151
- * future release; prefer the key form. Routes to `POST /runs`.
4385
+ * - `string[]`: a plain list of run IDs. **Deprecated**: this path will be
4386
+ * removed after Jan 31, 2027; prefer the key form. Routes to `POST /runs`.
4387
+ * See https://docs.langchain.com/langsmith/smithdb-sdk-migration#annotation-queues-add-runs.
4152
4388
  *
4153
4389
  * If every element is a string (or the list is empty) it is treated as run
4154
4390
  * IDs; otherwise the list is treated as `RunKey` objects.
@@ -4179,6 +4415,12 @@ export class Client {
4179
4415
  }));
4180
4416
  }
4181
4417
  else {
4418
+ warnOnce("Passing run IDs as strings to addRunsToAnnotationQueue() is deprecated and will be removed after Jan 31, 2027. " +
4419
+ "Use RunKey[] instead. " +
4420
+ "See https://docs.langchain.com/langsmith/smithdb-sdk-migration#annotation-queues-add-runs for the migration guide.", {
4421
+ type: "DeprecationWarning",
4422
+ code: "LANGSMITH_DEPRECATED_ADD_RUNS_STRING_IDS",
4423
+ });
4182
4424
  url = base;
4183
4425
  body = JSON.stringify(runs.map((id, i) => assertUuid(id, `runs[${i}]`).toString()));
4184
4426
  }
@@ -24,10 +24,13 @@ async function loadTracesForExperiment(client, project, options) {
24
24
  const isRoot = options.loadNested ? undefined : true;
25
25
  const runs = (await client._supportsSDBQuery())
26
26
  ? await (0, v2_migration_js_1.loadTracesV2)(client, project, { isRoot })
27
- : await client.listRuns({
28
- projectId: project.id,
29
- executionOrder: options.loadNested ? undefined : 1,
30
- });
27
+ : // Via _listRuns() rather than listRuns(): evaluate() is supported, so
28
+ // callers have nothing to migrate; how it loads traces is an
29
+ // implementation detail.
30
+ await client._listRuns({
31
+ projectId: project.id,
32
+ executionOrder: options.loadNested ? undefined : 1,
33
+ });
31
34
  const treeMap = {};
32
35
  const runIdMap = {};
33
36
  const results = [];
@@ -17,10 +17,13 @@ export async function loadTracesForExperiment(client, project, options) {
17
17
  const isRoot = options.loadNested ? undefined : true;
18
18
  const runs = (await client._supportsSDBQuery())
19
19
  ? await loadTracesV2(client, project, { isRoot })
20
- : await client.listRuns({
21
- projectId: project.id,
22
- executionOrder: options.loadNested ? undefined : 1,
23
- });
20
+ : // Via _listRuns() rather than listRuns(): evaluate() is supported, so
21
+ // callers have nothing to migrate; how it loads traces is an
22
+ // implementation detail.
23
+ await client._listRuns({
24
+ projectId: project.id,
25
+ executionOrder: options.loadNested ? undefined : 1,
26
+ });
24
27
  const treeMap = {};
25
28
  const runIdMap = {};
26
29
  const results = [];
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.8";
38
+ exports.__version__ = "0.8.9";
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.8";
10
+ export declare const __version__ = "0.8.9";
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.8";
10
+ export const __version__ = "0.8.9";
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";