langsmith 0.8.7 → 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 (83) hide show
  1. package/dist/_openapi_client/client.cjs +8 -0
  2. package/dist/_openapi_client/client.d.ts +3 -0
  3. package/dist/_openapi_client/client.js +8 -0
  4. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.cjs +157 -0
  5. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.d.ts +382 -0
  6. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.js +120 -0
  7. package/dist/_openapi_client/resources/annotation-queues/items.cjs +84 -0
  8. package/dist/_openapi_client/resources/annotation-queues/items.d.ts +207 -0
  9. package/dist/_openapi_client/resources/annotation-queues/items.js +80 -0
  10. package/dist/_openapi_client/resources/annotation-queues/runs.cjs +73 -0
  11. package/dist/_openapi_client/resources/annotation-queues/runs.d.ts +197 -0
  12. package/dist/_openapi_client/resources/annotation-queues/runs.js +69 -0
  13. package/dist/_openapi_client/resources/datasets/experiment-runs.cjs +3 -1
  14. package/dist/_openapi_client/resources/datasets/experiment-runs.d.ts +2 -0
  15. package/dist/_openapi_client/resources/datasets/experiment-runs.js +3 -1
  16. package/dist/_openapi_client/resources/index.cjs +3 -1
  17. package/dist/_openapi_client/resources/index.d.ts +1 -0
  18. package/dist/_openapi_client/resources/index.js +1 -0
  19. package/dist/_openapi_client/resources/info.cjs +3 -1
  20. package/dist/_openapi_client/resources/info.d.ts +16 -22
  21. package/dist/_openapi_client/resources/info.js +3 -1
  22. package/dist/_openapi_client/resources/issues.cjs +2 -2
  23. package/dist/_openapi_client/resources/issues.d.ts +1 -1
  24. package/dist/_openapi_client/resources/issues.js +2 -2
  25. package/dist/_openapi_client/resources/online-evaluators.cjs +7 -7
  26. package/dist/_openapi_client/resources/online-evaluators.d.ts +8 -0
  27. package/dist/_openapi_client/resources/online-evaluators.js +7 -7
  28. package/dist/_openapi_client/resources/public/runs.cjs +10 -8
  29. package/dist/_openapi_client/resources/public/runs.d.ts +9 -7
  30. package/dist/_openapi_client/resources/public/runs.js +10 -8
  31. package/dist/_openapi_client/resources/runs/runs.cjs +14 -9
  32. package/dist/_openapi_client/resources/runs/runs.d.ts +20 -10
  33. package/dist/_openapi_client/resources/runs/runs.js +14 -9
  34. package/dist/_openapi_client/resources/runs/share.cjs +6 -2
  35. package/dist/_openapi_client/resources/runs/share.d.ts +4 -0
  36. package/dist/_openapi_client/resources/runs/share.js +6 -2
  37. package/dist/_openapi_client/resources/sandboxes/boxes.cjs +10 -10
  38. package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +40 -0
  39. package/dist/_openapi_client/resources/sandboxes/boxes.js +10 -10
  40. package/dist/_openapi_client/resources/sandboxes/registries.cjs +5 -5
  41. package/dist/_openapi_client/resources/sandboxes/registries.js +5 -5
  42. package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +17 -0
  43. package/dist/_openapi_client/resources/sandboxes/snapshots.cjs +4 -4
  44. package/dist/_openapi_client/resources/sandboxes/snapshots.d.ts +12 -0
  45. package/dist/_openapi_client/resources/sandboxes/snapshots.js +4 -4
  46. package/dist/_openapi_client/resources/threads.cjs +14 -11
  47. package/dist/_openapi_client/resources/threads.d.ts +13 -9
  48. package/dist/_openapi_client/resources/threads.js +14 -11
  49. package/dist/_openapi_client/resources/traces.cjs +8 -5
  50. package/dist/_openapi_client/resources/traces.d.ts +7 -4
  51. package/dist/_openapi_client/resources/traces.js +8 -5
  52. package/dist/client.cjs +318 -40
  53. package/dist/client.d.ts +111 -25
  54. package/dist/client.js +318 -40
  55. package/dist/evaluation/evaluate_comparative.cjs +7 -4
  56. package/dist/evaluation/evaluate_comparative.js +7 -4
  57. package/dist/index.cjs +1 -1
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/sandbox/command_handle.cjs +38 -11
  61. package/dist/sandbox/command_handle.d.ts +1 -0
  62. package/dist/sandbox/command_handle.js +39 -12
  63. package/dist/sandbox/errors.cjs +16 -1
  64. package/dist/sandbox/errors.d.ts +11 -0
  65. package/dist/sandbox/errors.js +14 -0
  66. package/dist/sandbox/index.cjs +2 -1
  67. package/dist/sandbox/index.d.ts +1 -1
  68. package/dist/sandbox/index.js +1 -1
  69. package/dist/sandbox/sandbox.cjs +22 -4
  70. package/dist/sandbox/sandbox.js +24 -6
  71. package/dist/sandbox/ws_execute.cjs +82 -11
  72. package/dist/sandbox/ws_execute.d.ts +12 -2
  73. package/dist/sandbox/ws_execute.js +79 -11
  74. package/dist/utils/v2_migration.cjs +18 -0
  75. package/dist/utils/v2_migration.d.ts +8 -0
  76. package/dist/utils/v2_migration.js +16 -0
  77. package/dist/utils/warn.cjs +30 -4
  78. package/dist/utils/warn.d.ts +4 -1
  79. package/dist/utils/warn.js +29 -4
  80. package/package.json +1 -1
  81. package/dist/utils/constants.cjs +0 -4
  82. package/dist/utils/constants.d.ts +0 -1
  83. package/dist/utils/constants.js +0 -1
package/dist/client.d.ts CHANGED
@@ -7,6 +7,7 @@ import { OnlineEvaluators as Evaluators } from "./_openapi_client/resources/onli
7
7
  import { Runs as OpenAPIRuns } from "./_openapi_client/resources/runs.js";
8
8
  import { Sandboxes } from "./_openapi_client/resources/sandboxes/sandboxes.js";
9
9
  import { Datasets } from "./_openapi_client/resources/datasets/datasets.js";
10
+ import { AnnotationQueues } from "./_openapi_client/resources/annotation-queues/annotation-queues.js";
10
11
  import { Threads } from "./_openapi_client/resources/threads.js";
11
12
  import { Traces } from "./_openapi_client/resources/traces.js";
12
13
  import { Public } from "./_openapi_client/resources/public/public.js";
@@ -335,6 +336,51 @@ interface ProjectOptions {
335
336
  }
336
337
  type RecordStringAny = Record<string, any>;
337
338
  export type FeedbackSourceType = "model" | "api" | "app";
339
+ export type CreateFeedbackOptions = {
340
+ /** The metric name, tag, or aspect to provide feedback on. */
341
+ key: string;
342
+ score?: ScoreType;
343
+ value?: ValueType;
344
+ correction?: object;
345
+ comment?: string;
346
+ sourceInfo?: object;
347
+ feedbackSourceType?: FeedbackSourceType;
348
+ feedbackConfig?: FeedbackConfig;
349
+ sourceRunId?: string;
350
+ feedbackId?: string;
351
+ comparativeExperimentId?: string;
352
+ /**
353
+ * The run's start time, ISO string or epoch ms. Better performance if provided.
354
+ */
355
+ startTime?: number | string;
356
+ /** If false, create feedback without extending the trace's retention tier. */
357
+ extendTraceRetention?: boolean;
358
+ };
359
+ /** @deprecated Pass all params within an object and populate sessionId. */
360
+ export type CreateFeedbackLegacyOptions = Omit<CreateFeedbackOptions, "key"> & {
361
+ /** @deprecated This option is no longer used. */
362
+ eager?: boolean;
363
+ /**
364
+ * The session (project) ID of the run. Required for run-level feedback;
365
+ * omitting it is deprecated. See
366
+ * https://docs.langchain.com/langsmith/smithdb-sdk-migration#feedback-create
367
+ */
368
+ sessionId?: string;
369
+ /** The project (or experiment) to provide feedback on, for session-level feedback. */
370
+ projectId?: string;
371
+ };
372
+ export type CreateFeedbackParams = CreateFeedbackOptions & ({
373
+ /** The run to provide feedback on. */
374
+ runId: string;
375
+ /** The session (project) ID of the run. */
376
+ sessionId: string;
377
+ projectId?: never;
378
+ } | {
379
+ runId?: null;
380
+ /** The project (or experiment) to provide feedback on. */
381
+ projectId: string;
382
+ sessionId?: never;
383
+ });
338
384
  export type CreateExampleOptions = {
339
385
  /** The ID of the dataset to create the example in. */
340
386
  datasetId?: string;
@@ -397,7 +443,7 @@ export interface ListThreadsItem extends Thread {
397
443
  runs: Run[];
398
444
  }
399
445
  export declare function mergeRuntimeEnvIntoRun<T extends RunCreate | RunUpdate>(run: T, cachedEnvVars?: Record<string, string>, omitTracedRuntimeInfo?: boolean): T;
400
- export declare function _checkBackendVersion(version: string, minVersion?: string): void;
446
+ export declare function _checkBackendVersion(backendVersion: string, minVersion: string): void;
401
447
  export declare const DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES: number;
402
448
  /** Default maximum memory (1GB) for queue size limits. */
403
449
  export declare const DEFAULT_MAX_SIZE_BYTES: number;
@@ -455,14 +501,17 @@ export declare class Client implements LangSmithTracingClientInterface {
455
501
  private autoBatchAggregationDelayMs;
456
502
  private batchSizeBytesLimit?;
457
503
  private batchSizeLimit?;
504
+ /** `config.fetchOptions` without its `headers`, which are merged separately. */
458
505
  private fetchOptions;
459
- private openAPIClient;
506
+ private _fetchOptionsHeaders;
507
+ private _openAPIClient?;
508
+ private _openAPIClientSignature?;
460
509
  private settings;
461
510
  private blockOnRootRunFinalization;
462
511
  private traceBatchConcurrency;
463
512
  private _serverInfo;
464
513
  private _getServerInfoPromise?;
465
- private _stainlessVersionChecked;
514
+ private _stainlessVersionsChecked;
466
515
  private manualFlushMode;
467
516
  private _serializeWorker?;
468
517
  /**
@@ -509,7 +558,33 @@ export declare class Client implements LangSmithTracingClientInterface {
509
558
  constructor(config?: ClientConfig);
510
559
  static getDefaultClientConfig(): DefaultClientConfig;
511
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();
512
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();
513
588
  /**
514
589
  * Get or set custom headers for the client.
515
590
  * Custom headers are merged with default headers (User-Agent, x-api-key, x-tenant-id).
@@ -518,6 +593,17 @@ export declare class Client implements LangSmithTracingClientInterface {
518
593
  get headers(): Record<string, string>;
519
594
  set headers(value: Record<string, string> | undefined);
520
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();
521
607
  private _newOpenAPIClient;
522
608
  private _getPlatformEndpointPath;
523
609
  get evaluators(): Evaluators;
@@ -526,6 +612,8 @@ export declare class Client implements LangSmithTracingClientInterface {
526
612
  get sandboxes(): Sandboxes;
527
613
  /** Access the v2 datasets resource (experimentRuns, etc.). */
528
614
  get datasets(): Datasets;
615
+ /** Access the annotation queues resource (runs, items). */
616
+ get annotationQueues(): AnnotationQueues;
529
617
  /** Access the threads resource (query, stats, listTraces). */
530
618
  get threads(): Threads;
531
619
  /** Access the traces resource (query, listRuns). */
@@ -587,6 +675,11 @@ export declare class Client implements LangSmithTracingClientInterface {
587
675
  private _checkStainlessVersion;
588
676
  protected _ensureServerInfo(): Promise<Record<string, any>>;
589
677
  _supportsSDBQuery(): Promise<boolean>;
678
+ /**
679
+ * Throw on SmithDB-only deployments, warn elsewhere. Call only when run-level
680
+ * feedback has no sessionId.
681
+ */
682
+ private _checkFeedbackSessionId;
590
683
  protected _getSettings(): Promise<LangSmithSettings>;
591
684
  /**
592
685
  * Flushes current queued traces.
@@ -634,9 +727,11 @@ export declare class Client implements LangSmithTracingClientInterface {
634
727
  apiUrl?: string;
635
728
  workspaceId?: string;
636
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. */
637
731
  readRun(runId: string, { loadChildRuns }?: {
638
732
  loadChildRuns: boolean;
639
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. */
640
735
  getRunUrl({ runId, run, projectOpts, }: {
641
736
  runId?: string;
642
737
  run?: Run;
@@ -645,6 +740,7 @@ export declare class Client implements LangSmithTracingClientInterface {
645
740
  private _loadChildRuns;
646
741
  /**
647
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.
648
744
  * @param projectId - The ID of the project to filter by.
649
745
  * @param projectName - The name of the project to filter by.
650
746
  * @param parentRunId - The ID of the parent run to filter by.
@@ -727,7 +823,9 @@ export declare class Client implements LangSmithTracingClientInterface {
727
823
  */
728
824
  listRuns(props: ListRunsParams): AsyncIterable<Run>;
729
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. */
730
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. */
731
829
  listThreads(props: ListThreadsParams): Promise<ListThreadsItem[]>;
732
830
  getRunStats({ id, trace, parentRun, runType, projectNames, projectIds, referenceExampleIds, startTime, endTime, error, query, filter, traceFilter, treeFilter, isRoot, dataSourceType, }: {
733
831
  id?: string[];
@@ -747,11 +845,15 @@ export declare class Client implements LangSmithTracingClientInterface {
747
845
  isRoot?: boolean;
748
846
  dataSourceType?: string;
749
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. */
750
849
  shareRun(runId: string, { shareId }?: {
751
850
  shareId?: string;
752
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. */
753
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. */
754
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. */
755
857
  listSharedRuns(shareToken: string, { runIds, }?: {
756
858
  runIds?: string[];
757
859
  }): Promise<Run[]>;
@@ -963,26 +1065,9 @@ export declare class Client implements LangSmithTracingClientInterface {
963
1065
  exampleIds: string[];
964
1066
  remove?: boolean;
965
1067
  }): Promise<void>;
966
- createFeedback(runId: string | null, key: string, { score, value, correction, comment, sourceInfo, feedbackSourceType, sourceRunId, feedbackId, feedbackConfig, projectId, comparativeExperimentId, sessionId, startTime, extendTraceRetention, }: {
967
- score?: ScoreType;
968
- value?: ValueType;
969
- correction?: object;
970
- comment?: string;
971
- sourceInfo?: object;
972
- feedbackSourceType?: FeedbackSourceType;
973
- feedbackConfig?: FeedbackConfig;
974
- sourceRunId?: string;
975
- feedbackId?: string;
976
- eager?: boolean;
977
- projectId?: string;
978
- comparativeExperimentId?: string;
979
- /** The session (project) ID of the run this feedback is for. */
980
- sessionId?: string;
981
- /** The start time of the run this feedback is for. Accepts ISO string or epoch ms. */
982
- startTime?: number | string;
983
- /** If false, create feedback without extending the trace's retention tier. */
984
- extendTraceRetention?: boolean;
985
- }): Promise<Feedback>;
1068
+ createFeedback(params: CreateFeedbackParams): Promise<Feedback>;
1069
+ /** @deprecated Pass all params within an object and populate sessionId. */
1070
+ createFeedback(runId: string | null, key: string, options: CreateFeedbackLegacyOptions): Promise<Feedback>;
986
1071
  updateFeedback(feedbackId: string, { score, value, correction, comment, }: {
987
1072
  score?: number | boolean | null;
988
1073
  value?: number | boolean | string | object | null;
@@ -1160,8 +1245,9 @@ export declare class Client implements LangSmithTracingClientInterface {
1160
1245
  * - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
1161
1246
  * it can be located directly without a scan. Required for workspaces served
1162
1247
  * by SmithDB; routes to `POST /runs/by-key`.
1163
- * - `string[]`: a plain list of run IDs. This path will be deprecated in a
1164
- * 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.
1165
1251
  *
1166
1252
  * If every element is a string (or the list is empty) it is treated as run
1167
1253
  * IDs; otherwise the list is treated as `RunKey` objects.