langsmith 0.8.9 → 0.8.11

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 (41) hide show
  1. package/dist/client.cjs +33 -4
  2. package/dist/client.d.ts +10 -6
  3. package/dist/client.js +33 -4
  4. package/dist/experimental/vercel/_agent_type.cjs +30 -0
  5. package/dist/experimental/vercel/_agent_type.d.ts +5 -0
  6. package/dist/experimental/vercel/_agent_type.js +26 -0
  7. package/dist/experimental/vercel/telemetry.cjs +2 -7
  8. package/dist/experimental/vercel/telemetry.js +2 -7
  9. package/dist/experimental/vercel/wrap.cjs +5 -11
  10. package/dist/experimental/vercel/wrap.js +6 -12
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/sandbox/client.cjs +11 -5
  15. package/dist/sandbox/client.d.ts +4 -4
  16. package/dist/sandbox/client.js +11 -5
  17. package/dist/sandbox/index.cjs +2 -1
  18. package/dist/sandbox/index.d.ts +2 -2
  19. package/dist/sandbox/index.js +1 -1
  20. package/dist/sandbox/mounts.cjs +25 -2
  21. package/dist/sandbox/mounts.d.ts +12 -1
  22. package/dist/sandbox/mounts.js +24 -2
  23. package/dist/sandbox/proxy_config.cjs +28 -4
  24. package/dist/sandbox/proxy_config.d.ts +4 -2
  25. package/dist/sandbox/proxy_config.js +28 -4
  26. package/dist/sandbox/types.d.ts +36 -1
  27. package/dist/utils/_git.cjs +28 -1
  28. package/dist/utils/_git.js +28 -1
  29. package/dist/utils/ls_agent_type.cjs +31 -0
  30. package/dist/utils/ls_agent_type.d.ts +9 -0
  31. package/dist/utils/ls_agent_type.js +25 -0
  32. package/dist/utils/profiles.cjs +125 -1
  33. package/dist/utils/profiles.d.ts +6 -0
  34. package/dist/utils/profiles.js +124 -1
  35. package/dist/wrappers/anthropic.cjs +39 -6
  36. package/dist/wrappers/anthropic.js +39 -6
  37. package/dist/wrappers/openai.cjs +4 -0
  38. package/dist/wrappers/openai.js +4 -0
  39. package/dist/wrappers/openai_agents.cjs +15 -12
  40. package/dist/wrappers/openai_agents.js +15 -12
  41. package/package.json +12 -2
package/dist/client.cjs CHANGED
@@ -893,7 +893,8 @@ class Client {
893
893
  config.hideInputs ?? config.anonymizer ?? defaultConfig.hideInputs;
894
894
  this.hideOutputs =
895
895
  config.hideOutputs ?? config.anonymizer ?? defaultConfig.hideOutputs;
896
- this.hideMetadata = config.hideMetadata ?? defaultConfig.hideMetadata;
896
+ this.hideMetadata =
897
+ config.hideMetadata ?? config.anonymizer ?? defaultConfig.hideMetadata;
897
898
  this.anonymizer = config.anonymizer;
898
899
  this.omitTracedRuntimeInfo = config.omitTracedRuntimeInfo ?? false;
899
900
  this.autoBatchTracing = config.autoBatchTracing ?? this.autoBatchTracing;
@@ -1555,6 +1556,9 @@ class Client {
1555
1556
  const batchSizeBytes = batch.reduce((sum, item) => sum + (item.size ?? 0), 0);
1556
1557
  try {
1557
1558
  if (this.langSmithToOTELTranslator !== undefined) {
1559
+ for (const item of batch) {
1560
+ item.item = await this._maskRunMetadata(item.item);
1561
+ }
1558
1562
  this._sendBatchToOTELTranslator(batch);
1559
1563
  }
1560
1564
  else {
@@ -1635,6 +1639,25 @@ class Client {
1635
1639
  this.langSmithToOTELTranslator.exportBatch(operations, otelContextMap);
1636
1640
  }
1637
1641
  }
1642
+ async _maskRunMetadata(run) {
1643
+ if (run.extra?.metadata == null) {
1644
+ return run;
1645
+ }
1646
+ return {
1647
+ ...run,
1648
+ extra: {
1649
+ ...run.extra,
1650
+ metadata: await this.processMetadata(run.extra.metadata),
1651
+ },
1652
+ };
1653
+ }
1654
+ async _mergeRuntimeEnvAndMaskMetadata(run) {
1655
+ const merged = mergeRuntimeEnvIntoRun(run, this.cachedLSEnvVarsForMetadata, this.omitTracedRuntimeInfo);
1656
+ if (this.omitTracedRuntimeInfo) {
1657
+ return merged;
1658
+ }
1659
+ return this._maskRunMetadata(merged);
1660
+ }
1638
1661
  async processRunOperation(item) {
1639
1662
  clearTimeout(this.autoBatchTimeout);
1640
1663
  this.autoBatchTimeout = undefined;
@@ -1791,7 +1814,7 @@ class Client {
1791
1814
  }).catch(console.error);
1792
1815
  return;
1793
1816
  }
1794
- const mergedRunCreateParam = mergeRuntimeEnvIntoRun(runCreate, this.cachedLSEnvVarsForMetadata, this.omitTracedRuntimeInfo);
1817
+ const mergedRunCreateParam = await this._mergeRuntimeEnvAndMaskMetadata(runCreate);
1795
1818
  if (options?.apiKey !== undefined) {
1796
1819
  headers["x-api-key"] = options.apiKey;
1797
1820
  }
@@ -2980,7 +3003,7 @@ class Client {
2980
3003
  _hostUrl: this.getHostUrl(),
2981
3004
  }));
2982
3005
  }
2983
- async createProject({ projectName, description = null, metadata = null, upsert = false, projectExtra = null, referenceDatasetId = null, numExamples = null, numRepetitions = null, evaluatorKeys = null, }) {
3006
+ async createProject({ projectName, description = null, metadata = null, upsert = false, projectExtra = null, referenceDatasetId = null, numExamples = null, numRepetitions = null, evaluatorKeys = null, tagValueIds = null, }) {
2984
3007
  const upsert_ = upsert ? `?upsert=true` : "";
2985
3008
  const endpoint = `${this.apiUrl}/sessions${upsert_}`;
2986
3009
  const extra = projectExtra || {};
@@ -3004,6 +3027,9 @@ class Client {
3004
3027
  if (evaluatorKeys != null && evaluatorKeys.length > 0) {
3005
3028
  body["evaluator_keys"] = evaluatorKeys;
3006
3029
  }
3030
+ if (tagValueIds !== null) {
3031
+ body["tag_value_ids"] = tagValueIds;
3032
+ }
3007
3033
  const serializedBody = JSON.stringify(body);
3008
3034
  const response = await this.caller.call(async () => {
3009
3035
  const res = await this._fetch(endpoint, {
@@ -3247,7 +3273,7 @@ class Client {
3247
3273
  const result = await response.json();
3248
3274
  return result;
3249
3275
  }
3250
- async createDataset(name, { description, dataType, inputsSchema, outputsSchema, metadata, } = {}) {
3276
+ async createDataset(name, { description, dataType, inputsSchema, outputsSchema, metadata, tagValueIds, } = {}) {
3251
3277
  const body = {
3252
3278
  name,
3253
3279
  description,
@@ -3262,6 +3288,9 @@ class Client {
3262
3288
  if (outputsSchema) {
3263
3289
  body.outputs_schema_definition = outputsSchema;
3264
3290
  }
3291
+ if (tagValueIds !== undefined) {
3292
+ body.tag_value_ids = tagValueIds;
3293
+ }
3265
3294
  const serializedBody = JSON.stringify(body);
3266
3295
  const response = await this.caller.call(async () => {
3267
3296
  const res = await this._fetch(`${this.apiUrl}/datasets`, {
package/dist/client.d.ts CHANGED
@@ -20,11 +20,11 @@ export interface ClientConfig {
20
20
  timeout_ms?: number;
21
21
  webUrl?: string;
22
22
  /**
23
- * A function applied for masking serialized run inputs and outputs,
24
- * before sending to the API. Can be called with raw inputs, raw
25
- * outputs, or a nested `{ error: string }` object for errors.
23
+ * A function applied for masking serialized run inputs, outputs and
24
+ * metadata, before sending to the API. Can be called with raw inputs, raw
25
+ * outputs, raw metadata, or a nested `{ error: string }` object for errors.
26
26
  *
27
- * If a `hideInputs` or `hideOutputs` function is present,
27
+ * If a `hideInputs`, `hideOutputs` or `hideMetadata` function is present,
28
28
  * the client will call it instead of the anonymizer as appropriate.
29
29
  */
30
30
  anonymizer?: (values: KVMap) => KVMap | Promise<KVMap>;
@@ -413,6 +413,7 @@ export type CreateProjectParams = {
413
413
  numExamples?: number | null;
414
414
  numRepetitions?: number | null;
415
415
  evaluatorKeys?: string[] | null;
416
+ tagValueIds?: string[] | null;
416
417
  };
417
418
  type AutoBatchQueueItem = {
418
419
  action: "create" | "update";
@@ -670,6 +671,8 @@ export declare class Client implements LangSmithTracingClientInterface {
670
671
  private static _writeTraceToFallbackDir;
671
672
  private _processBatch;
672
673
  private _sendBatchToOTELTranslator;
674
+ private _maskRunMetadata;
675
+ private _mergeRuntimeEnvAndMaskMetadata;
673
676
  private processRunOperation;
674
677
  protected _getServerInfo(): Promise<any>;
675
678
  private _checkStainlessVersion;
@@ -872,7 +875,7 @@ export declare class Client implements LangSmithTracingClientInterface {
872
875
  listSharedExamples(shareToken: string, options?: {
873
876
  exampleIds?: string[];
874
877
  }): Promise<Example[]>;
875
- createProject({ projectName, description, metadata, upsert, projectExtra, referenceDatasetId, numExamples, numRepetitions, evaluatorKeys, }: CreateProjectParams): Promise<TracerSession>;
878
+ createProject({ projectName, description, metadata, upsert, projectExtra, referenceDatasetId, numExamples, numRepetitions, evaluatorKeys, tagValueIds, }: CreateProjectParams): Promise<TracerSession>;
876
879
  updateProject(projectId: string, { name, description, metadata, projectExtra, endTime, }: {
877
880
  name?: string | null;
878
881
  description?: string | null;
@@ -914,12 +917,13 @@ export declare class Client implements LangSmithTracingClientInterface {
914
917
  projectName?: string;
915
918
  }): Promise<void>;
916
919
  uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, dataType, name, }: UploadCSVParams): Promise<Dataset>;
917
- createDataset(name: string, { description, dataType, inputsSchema, outputsSchema, metadata, }?: {
920
+ createDataset(name: string, { description, dataType, inputsSchema, outputsSchema, metadata, tagValueIds, }?: {
918
921
  description?: string;
919
922
  dataType?: DataType;
920
923
  inputsSchema?: KVMap;
921
924
  outputsSchema?: KVMap;
922
925
  metadata?: RecordStringAny;
926
+ tagValueIds?: string[];
923
927
  }): Promise<Dataset>;
924
928
  readDataset({ datasetId, datasetName, }: {
925
929
  datasetId?: string;
package/dist/client.js CHANGED
@@ -854,7 +854,8 @@ export class Client {
854
854
  config.hideInputs ?? config.anonymizer ?? defaultConfig.hideInputs;
855
855
  this.hideOutputs =
856
856
  config.hideOutputs ?? config.anonymizer ?? defaultConfig.hideOutputs;
857
- this.hideMetadata = config.hideMetadata ?? defaultConfig.hideMetadata;
857
+ this.hideMetadata =
858
+ config.hideMetadata ?? config.anonymizer ?? defaultConfig.hideMetadata;
858
859
  this.anonymizer = config.anonymizer;
859
860
  this.omitTracedRuntimeInfo = config.omitTracedRuntimeInfo ?? false;
860
861
  this.autoBatchTracing = config.autoBatchTracing ?? this.autoBatchTracing;
@@ -1516,6 +1517,9 @@ export class Client {
1516
1517
  const batchSizeBytes = batch.reduce((sum, item) => sum + (item.size ?? 0), 0);
1517
1518
  try {
1518
1519
  if (this.langSmithToOTELTranslator !== undefined) {
1520
+ for (const item of batch) {
1521
+ item.item = await this._maskRunMetadata(item.item);
1522
+ }
1519
1523
  this._sendBatchToOTELTranslator(batch);
1520
1524
  }
1521
1525
  else {
@@ -1596,6 +1600,25 @@ export class Client {
1596
1600
  this.langSmithToOTELTranslator.exportBatch(operations, otelContextMap);
1597
1601
  }
1598
1602
  }
1603
+ async _maskRunMetadata(run) {
1604
+ if (run.extra?.metadata == null) {
1605
+ return run;
1606
+ }
1607
+ return {
1608
+ ...run,
1609
+ extra: {
1610
+ ...run.extra,
1611
+ metadata: await this.processMetadata(run.extra.metadata),
1612
+ },
1613
+ };
1614
+ }
1615
+ async _mergeRuntimeEnvAndMaskMetadata(run) {
1616
+ const merged = mergeRuntimeEnvIntoRun(run, this.cachedLSEnvVarsForMetadata, this.omitTracedRuntimeInfo);
1617
+ if (this.omitTracedRuntimeInfo) {
1618
+ return merged;
1619
+ }
1620
+ return this._maskRunMetadata(merged);
1621
+ }
1599
1622
  async processRunOperation(item) {
1600
1623
  clearTimeout(this.autoBatchTimeout);
1601
1624
  this.autoBatchTimeout = undefined;
@@ -1752,7 +1775,7 @@ export class Client {
1752
1775
  }).catch(console.error);
1753
1776
  return;
1754
1777
  }
1755
- const mergedRunCreateParam = mergeRuntimeEnvIntoRun(runCreate, this.cachedLSEnvVarsForMetadata, this.omitTracedRuntimeInfo);
1778
+ const mergedRunCreateParam = await this._mergeRuntimeEnvAndMaskMetadata(runCreate);
1756
1779
  if (options?.apiKey !== undefined) {
1757
1780
  headers["x-api-key"] = options.apiKey;
1758
1781
  }
@@ -2941,7 +2964,7 @@ export class Client {
2941
2964
  _hostUrl: this.getHostUrl(),
2942
2965
  }));
2943
2966
  }
2944
- async createProject({ projectName, description = null, metadata = null, upsert = false, projectExtra = null, referenceDatasetId = null, numExamples = null, numRepetitions = null, evaluatorKeys = null, }) {
2967
+ async createProject({ projectName, description = null, metadata = null, upsert = false, projectExtra = null, referenceDatasetId = null, numExamples = null, numRepetitions = null, evaluatorKeys = null, tagValueIds = null, }) {
2945
2968
  const upsert_ = upsert ? `?upsert=true` : "";
2946
2969
  const endpoint = `${this.apiUrl}/sessions${upsert_}`;
2947
2970
  const extra = projectExtra || {};
@@ -2965,6 +2988,9 @@ export class Client {
2965
2988
  if (evaluatorKeys != null && evaluatorKeys.length > 0) {
2966
2989
  body["evaluator_keys"] = evaluatorKeys;
2967
2990
  }
2991
+ if (tagValueIds !== null) {
2992
+ body["tag_value_ids"] = tagValueIds;
2993
+ }
2968
2994
  const serializedBody = JSON.stringify(body);
2969
2995
  const response = await this.caller.call(async () => {
2970
2996
  const res = await this._fetch(endpoint, {
@@ -3208,7 +3234,7 @@ export class Client {
3208
3234
  const result = await response.json();
3209
3235
  return result;
3210
3236
  }
3211
- async createDataset(name, { description, dataType, inputsSchema, outputsSchema, metadata, } = {}) {
3237
+ async createDataset(name, { description, dataType, inputsSchema, outputsSchema, metadata, tagValueIds, } = {}) {
3212
3238
  const body = {
3213
3239
  name,
3214
3240
  description,
@@ -3223,6 +3249,9 @@ export class Client {
3223
3249
  if (outputsSchema) {
3224
3250
  body.outputs_schema_definition = outputsSchema;
3225
3251
  }
3252
+ if (tagValueIds !== undefined) {
3253
+ body.tag_value_ids = tagValueIds;
3254
+ }
3226
3255
  const serializedBody = JSON.stringify(body);
3227
3256
  const response = await this.caller.call(async () => {
3228
3257
  const res = await this._fetch(`${this.apiUrl}/datasets`, {
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveVercelLsAgentType = resolveVercelLsAgentType;
4
+ exports.vercelLsAgentTypeMetadata = vercelLsAgentTypeMetadata;
5
+ const run_trees_js_1 = require("../../run_trees.cjs");
6
+ const traceable_js_1 = require("../../singletons/traceable.cjs");
7
+ const ls_agent_type_js_1 = require("../../utils/ls_agent_type.cjs");
8
+ // Vercel builds its traceable's `metadata` config eagerly, before traceable
9
+ // itself runs — this resolver stamps `ls_agent_type` at that moment.
10
+ // Traceable's own propagation would carry a parent's middleware/subagent/
11
+ // compaction/"root" tag down on its own. This resolver is needed
12
+ // for correct default tagging of the root `ls_agent_type` == root
13
+ // and tagging of subagents.
14
+ function resolveVercelLsAgentType(parentRunTree) {
15
+ const parent = parentRunTree ?? (0, traceable_js_1.getCurrentRunTree)(true);
16
+ if (!(0, run_trees_js_1.isRunTree)(parent))
17
+ return (0, ls_agent_type_js_1.resolveDefaultLsAgentType)(parent);
18
+ const parentTag = parent.extra?.metadata?.ls_agent_type;
19
+ if (typeof parentTag === "string" && ls_agent_type_js_1.NON_ROOT_LS_AGENT_TYPES.has(parentTag)) {
20
+ return parentTag;
21
+ }
22
+ if (parent.run_type === "tool")
23
+ return "subagent";
24
+ if (parentTag === "root")
25
+ return "root";
26
+ return undefined;
27
+ }
28
+ function vercelLsAgentTypeMetadata(parentRunTree) {
29
+ return (0, ls_agent_type_js_1.lsAgentTypeMetadata)(resolveVercelLsAgentType(parentRunTree));
30
+ }
@@ -0,0 +1,5 @@
1
+ import { LsAgentType } from "../../utils/ls_agent_type.js";
2
+ export declare function resolveVercelLsAgentType(parentRunTree?: unknown): LsAgentType | undefined;
3
+ export declare function vercelLsAgentTypeMetadata(parentRunTree?: unknown): {
4
+ ls_agent_type?: LsAgentType;
5
+ };
@@ -0,0 +1,26 @@
1
+ import { isRunTree } from "../../run_trees.js";
2
+ import { getCurrentRunTree } from "../../singletons/traceable.js";
3
+ import { NON_ROOT_LS_AGENT_TYPES, lsAgentTypeMetadata, resolveDefaultLsAgentType, } from "../../utils/ls_agent_type.js";
4
+ // Vercel builds its traceable's `metadata` config eagerly, before traceable
5
+ // itself runs — this resolver stamps `ls_agent_type` at that moment.
6
+ // Traceable's own propagation would carry a parent's middleware/subagent/
7
+ // compaction/"root" tag down on its own. This resolver is needed
8
+ // for correct default tagging of the root `ls_agent_type` == root
9
+ // and tagging of subagents.
10
+ export function resolveVercelLsAgentType(parentRunTree) {
11
+ const parent = parentRunTree ?? getCurrentRunTree(true);
12
+ if (!isRunTree(parent))
13
+ return resolveDefaultLsAgentType(parent);
14
+ const parentTag = parent.extra?.metadata?.ls_agent_type;
15
+ if (typeof parentTag === "string" && NON_ROOT_LS_AGENT_TYPES.has(parentTag)) {
16
+ return parentTag;
17
+ }
18
+ if (parent.run_type === "tool")
19
+ return "subagent";
20
+ if (parentTag === "root")
21
+ return "root";
22
+ return undefined;
23
+ }
24
+ export function vercelLsAgentTypeMetadata(parentRunTree) {
25
+ return lsAgentTypeMetadata(resolveVercelLsAgentType(parentRunTree));
26
+ }
@@ -7,6 +7,7 @@ const env_js_1 = require("../../env.cjs");
7
7
  const utils_js_1 = require("./utils.cjs");
8
8
  const utils_js_2 = require("./utils.cjs");
9
9
  const types_js_1 = require("../../utils/types.cjs");
10
+ const _agent_type_js_1 = require("./_agent_type.cjs");
10
11
  function _formatMessages(messages) {
11
12
  if (!Array.isArray(messages))
12
13
  return messages;
@@ -52,12 +53,6 @@ event, traceRawHttp) {
52
53
  }
53
54
  return (0, utils_js_1.convertMessageToTracedFormat)(output);
54
55
  }
55
- function _getLsAgentType(parentRunTree) {
56
- if ((0, run_trees_js_1.isRunTree)(parentRunTree) && parentRunTree.run_type === "tool") {
57
- return "subagent";
58
- }
59
- return "root";
60
- }
61
56
  function _hasNonzeroUsageMetadata(runTree) {
62
57
  const usageMetadata = runTree.extra?.metadata?.usage_metadata;
63
58
  if (!(0, types_js_1.isRecord)(usageMetadata))
@@ -200,7 +195,7 @@ function LangSmithTelemetry(config) {
200
195
  metadata: {
201
196
  ...customMetadata,
202
197
  ai_sdk_method: event.operationId,
203
- ls_agent_type: _getLsAgentType(parentRunTree),
198
+ ...(0, _agent_type_js_1.vercelLsAgentTypeMetadata)(parentRunTree),
204
199
  ls_model_name: event.modelId,
205
200
  ls_integration: "vercel-ai-sdk-telemetry",
206
201
  },
@@ -4,6 +4,7 @@ import { isEnvTracingEnabled } from "../../env.js";
4
4
  import { convertMessageToTracedFormat } from "./utils.js";
5
5
  import { setUsageMetadataOnRunTree } from "./utils.js";
6
6
  import { isPrimitive, isRecord } from "../../utils/types.js";
7
+ import { vercelLsAgentTypeMetadata } from "./_agent_type.js";
7
8
  function _formatMessages(messages) {
8
9
  if (!Array.isArray(messages))
9
10
  return messages;
@@ -49,12 +50,6 @@ event, traceRawHttp) {
49
50
  }
50
51
  return convertMessageToTracedFormat(output);
51
52
  }
52
- function _getLsAgentType(parentRunTree) {
53
- if (isRunTree(parentRunTree) && parentRunTree.run_type === "tool") {
54
- return "subagent";
55
- }
56
- return "root";
57
- }
58
53
  function _hasNonzeroUsageMetadata(runTree) {
59
54
  const usageMetadata = runTree.extra?.metadata?.usage_metadata;
60
55
  if (!isRecord(usageMetadata))
@@ -197,7 +192,7 @@ export function LangSmithTelemetry(config) {
197
192
  metadata: {
198
193
  ...customMetadata,
199
194
  ai_sdk_method: event.operationId,
200
- ls_agent_type: _getLsAgentType(parentRunTree),
195
+ ...vercelLsAgentTypeMetadata(parentRunTree),
201
196
  ls_model_name: event.modelId,
202
197
  ls_integration: "vercel-ai-sdk-telemetry",
203
198
  },
@@ -5,6 +5,7 @@ const middleware_js_1 = require("./middleware.cjs");
5
5
  const utils_js_1 = require("./utils.cjs");
6
6
  Object.defineProperty(exports, "convertMessageToTracedFormat", { enumerable: true, get: function () { return utils_js_1.convertMessageToTracedFormat; } });
7
7
  const traceable_js_1 = require("../../traceable.cjs");
8
+ const _agent_type_js_1 = require("./_agent_type.cjs");
8
9
  const _getModelDisplayName = (model) => {
9
10
  if (typeof model === "string") {
10
11
  return model;
@@ -118,19 +119,12 @@ const _resolveConfigs = (baseLsConfig, runtimeLsConfig) => {
118
119
  resolvedToolConfig,
119
120
  };
120
121
  };
121
- const _getLsAgentType = () => {
122
- const parentRun = (0, traceable_js_1.getCurrentRunTree)(true);
123
- if (parentRun != null && parentRun.run_type === "tool") {
124
- return "subagent";
125
- }
126
- return "root";
127
- };
128
122
  const _getGenerateTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolvedLsConfig, hasExplicitOutput, hasExplicitExperimentalOutput, traceResponseMetadata, }) => {
129
123
  return {
130
124
  name: runName ?? _getModelDisplayName(model),
131
125
  ...resolvedLsConfig,
132
126
  metadata: {
133
- ls_agent_type: _getLsAgentType(),
127
+ ...(0, _agent_type_js_1.vercelLsAgentTypeMetadata)(),
134
128
  ai_sdk_method: aiSdkMethodName ?? "ai.generateText",
135
129
  ...resolvedLsConfig?.metadata,
136
130
  },
@@ -206,7 +200,7 @@ const _getStreamTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolved
206
200
  name: runName ?? _getModelDisplayName(model),
207
201
  ...resolvedLsConfig,
208
202
  metadata: {
209
- ls_agent_type: _getLsAgentType(),
203
+ ...(0, _agent_type_js_1.vercelLsAgentTypeMetadata)(),
210
204
  ai_sdk_method: aiSdkMethodName ?? "ai.streamText",
211
205
  ...resolvedLsConfig?.metadata,
212
206
  },
@@ -409,7 +403,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
409
403
  name: _getModelDisplayName(params.model),
410
404
  ...resolvedLsConfig,
411
405
  metadata: {
412
- ls_agent_type: _getLsAgentType(),
406
+ ...(0, _agent_type_js_1.vercelLsAgentTypeMetadata)(),
413
407
  ai_sdk_method: "ai.generateObject",
414
408
  ...resolvedLsConfig?.metadata,
415
409
  },
@@ -531,7 +525,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
531
525
  name: _getModelDisplayName(params.model),
532
526
  ...resolvedLsConfig,
533
527
  metadata: {
534
- ls_agent_type: _getLsAgentType(),
528
+ ...(0, _agent_type_js_1.vercelLsAgentTypeMetadata)(),
535
529
  ai_sdk_method: "ai.streamObject",
536
530
  ...resolvedLsConfig?.metadata,
537
531
  },
@@ -1,6 +1,7 @@
1
1
  import { LangSmithMiddleware, } from "./middleware.js";
2
2
  import { convertMessageToTracedFormat } from "./utils.js";
3
- import { isTraceableFunction, traceable, getCurrentRunTree, } from "../../traceable.js";
3
+ import { isTraceableFunction, traceable } from "../../traceable.js";
4
+ import { vercelLsAgentTypeMetadata } from "./_agent_type.js";
4
5
  const _getModelDisplayName = (model) => {
5
6
  if (typeof model === "string") {
6
7
  return model;
@@ -114,19 +115,12 @@ const _resolveConfigs = (baseLsConfig, runtimeLsConfig) => {
114
115
  resolvedToolConfig,
115
116
  };
116
117
  };
117
- const _getLsAgentType = () => {
118
- const parentRun = getCurrentRunTree(true);
119
- if (parentRun != null && parentRun.run_type === "tool") {
120
- return "subagent";
121
- }
122
- return "root";
123
- };
124
118
  const _getGenerateTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolvedLsConfig, hasExplicitOutput, hasExplicitExperimentalOutput, traceResponseMetadata, }) => {
125
119
  return {
126
120
  name: runName ?? _getModelDisplayName(model),
127
121
  ...resolvedLsConfig,
128
122
  metadata: {
129
- ls_agent_type: _getLsAgentType(),
123
+ ...vercelLsAgentTypeMetadata(),
130
124
  ai_sdk_method: aiSdkMethodName ?? "ai.generateText",
131
125
  ...resolvedLsConfig?.metadata,
132
126
  },
@@ -202,7 +196,7 @@ const _getStreamTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolved
202
196
  name: runName ?? _getModelDisplayName(model),
203
197
  ...resolvedLsConfig,
204
198
  metadata: {
205
- ls_agent_type: _getLsAgentType(),
199
+ ...vercelLsAgentTypeMetadata(),
206
200
  ai_sdk_method: aiSdkMethodName ?? "ai.streamText",
207
201
  ...resolvedLsConfig?.metadata,
208
202
  },
@@ -404,7 +398,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
404
398
  name: _getModelDisplayName(params.model),
405
399
  ...resolvedLsConfig,
406
400
  metadata: {
407
- ls_agent_type: _getLsAgentType(),
401
+ ...vercelLsAgentTypeMetadata(),
408
402
  ai_sdk_method: "ai.generateObject",
409
403
  ...resolvedLsConfig?.metadata,
410
404
  },
@@ -526,7 +520,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
526
520
  name: _getModelDisplayName(params.model),
527
521
  ...resolvedLsConfig,
528
522
  metadata: {
529
- ls_agent_type: _getLsAgentType(),
523
+ ...vercelLsAgentTypeMetadata(),
530
524
  ai_sdk_method: "ai.streamObject",
531
525
  ...resolvedLsConfig?.metadata,
532
526
  },
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.9";
38
+ exports.__version__ = "0.8.11";
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.9";
10
+ export declare const __version__ = "0.8.11";
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.9";
10
+ export const __version__ = "0.8.11";
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";
@@ -698,13 +698,19 @@ class SandboxClient {
698
698
  *
699
699
  * @param name - Snapshot name.
700
700
  * @param dockerfile - Local Dockerfile path, relative to context by default.
701
- * @param fsCapacityBytes - Filesystem capacity in bytes.
702
- * @param options - Build context, args, target, build log callback, builder
703
- * vCPUs/memory, timeout.
701
+ * @param fsCapacityBytesOrOptions - Optional filesystem capacity in bytes, or
702
+ * build options. When omitted, the server applies its default capacity.
703
+ * @param options - Build options when capacity is passed separately.
704
704
  * @returns Snapshot in "ready" status.
705
705
  */
706
- async createSnapshotFromDockerfile(name, dockerfile, fsCapacityBytes, options = {}) {
707
- const { context = ".", buildArgs, target, onBuildLog, vCpus, memBytes, timeout = 60, } = options;
706
+ async createSnapshotFromDockerfile(name, dockerfile, fsCapacityBytesOrOptions, options = {}) {
707
+ const fsCapacityBytes = typeof fsCapacityBytesOrOptions === "number"
708
+ ? fsCapacityBytesOrOptions
709
+ : undefined;
710
+ const resolvedOptions = typeof fsCapacityBytesOrOptions === "number"
711
+ ? options
712
+ : (fsCapacityBytesOrOptions ?? options);
713
+ const { context = ".", buildArgs, target, onBuildLog, vCpus, memBytes, timeout = 60, } = resolvedOptions;
708
714
  const { contextPath, dockerfileRel } = await resolveDockerfileContext(dockerfile, context);
709
715
  const builderName = `snapshot-builder-${(0, index_js_2.v4)().replace(/-/g, "").slice(0, 12)}`;
710
716
  // Stage the build on the capacity-backed root filesystem, not /tmp.
@@ -208,12 +208,12 @@ export declare class SandboxClient {
208
208
  *
209
209
  * @param name - Snapshot name.
210
210
  * @param dockerfile - Local Dockerfile path, relative to context by default.
211
- * @param fsCapacityBytes - Filesystem capacity in bytes.
212
- * @param options - Build context, args, target, build log callback, builder
213
- * vCPUs/memory, timeout.
211
+ * @param fsCapacityBytesOrOptions - Optional filesystem capacity in bytes, or
212
+ * build options. When omitted, the server applies its default capacity.
213
+ * @param options - Build options when capacity is passed separately.
214
214
  * @returns Snapshot in "ready" status.
215
215
  */
216
- createSnapshotFromDockerfile(name: string, dockerfile: string, fsCapacityBytes: number, options?: CreateDockerfileSnapshotOptions): Promise<Snapshot>;
216
+ createSnapshotFromDockerfile(name: string, dockerfile: string, fsCapacityBytesOrOptions?: number | CreateDockerfileSnapshotOptions, options?: CreateDockerfileSnapshotOptions): Promise<Snapshot>;
217
217
  /**
218
218
  * Capture a snapshot from a running sandbox.
219
219
  *
@@ -695,13 +695,19 @@ export class SandboxClient {
695
695
  *
696
696
  * @param name - Snapshot name.
697
697
  * @param dockerfile - Local Dockerfile path, relative to context by default.
698
- * @param fsCapacityBytes - Filesystem capacity in bytes.
699
- * @param options - Build context, args, target, build log callback, builder
700
- * vCPUs/memory, timeout.
698
+ * @param fsCapacityBytesOrOptions - Optional filesystem capacity in bytes, or
699
+ * build options. When omitted, the server applies its default capacity.
700
+ * @param options - Build options when capacity is passed separately.
701
701
  * @returns Snapshot in "ready" status.
702
702
  */
703
- async createSnapshotFromDockerfile(name, dockerfile, fsCapacityBytes, options = {}) {
704
- const { context = ".", buildArgs, target, onBuildLog, vCpus, memBytes, timeout = 60, } = options;
703
+ async createSnapshotFromDockerfile(name, dockerfile, fsCapacityBytesOrOptions, options = {}) {
704
+ const fsCapacityBytes = typeof fsCapacityBytesOrOptions === "number"
705
+ ? fsCapacityBytesOrOptions
706
+ : undefined;
707
+ const resolvedOptions = typeof fsCapacityBytesOrOptions === "number"
708
+ ? options
709
+ : (fsCapacityBytesOrOptions ?? options);
710
+ const { context = ".", buildArgs, target, onBuildLog, vCpus, memBytes, timeout = 60, } = resolvedOptions;
705
711
  const { contextPath, dockerfileRel } = await resolveDockerfileContext(dockerfile, context);
706
712
  const builderName = `snapshot-builder-${uuidv4().replace(/-/g, "").slice(0, 12)}`;
707
713
  // Stage the build on the capacity-backed root filesystem, not /tmp.
@@ -29,7 +29,7 @@
29
29
  * @packageDocumentation
30
30
  */
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectTimeoutError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.s3Mount = exports.mountConfig = exports.gitMount = exports.gcsMount = exports.workspaceSecret = exports.proxyConfig = exports.opaqueSecret = exports.gcpAuth = exports.awsAuth = exports.CommandHandle = exports.Sandbox = exports.SandboxClient = void 0;
32
+ exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectTimeoutError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.s3Mount = exports.mountConfig = exports.gitMount = exports.gcsMount = exports.contextHubMount = exports.workspaceSecret = exports.proxyConfig = exports.opaqueSecret = exports.gcpAuth = exports.awsAuth = exports.CommandHandle = exports.Sandbox = exports.SandboxClient = void 0;
33
33
  // Main classes
34
34
  var client_js_1 = require("./client.cjs");
35
35
  Object.defineProperty(exports, "SandboxClient", { enumerable: true, get: function () { return client_js_1.SandboxClient; } });
@@ -44,6 +44,7 @@ Object.defineProperty(exports, "opaqueSecret", { enumerable: true, get: function
44
44
  Object.defineProperty(exports, "proxyConfig", { enumerable: true, get: function () { return proxy_config_js_1.proxyConfig; } });
45
45
  Object.defineProperty(exports, "workspaceSecret", { enumerable: true, get: function () { return proxy_config_js_1.workspaceSecret; } });
46
46
  var mounts_js_1 = require("./mounts.cjs");
47
+ Object.defineProperty(exports, "contextHubMount", { enumerable: true, get: function () { return mounts_js_1.contextHubMount; } });
47
48
  Object.defineProperty(exports, "gcsMount", { enumerable: true, get: function () { return mounts_js_1.gcsMount; } });
48
49
  Object.defineProperty(exports, "gitMount", { enumerable: true, get: function () { return mounts_js_1.gitMount; } });
49
50
  Object.defineProperty(exports, "mountConfig", { enumerable: true, get: function () { return mounts_js_1.mountConfig; } });
@@ -31,6 +31,6 @@ export { SandboxClient } from "./client.js";
31
31
  export { Sandbox } from "./sandbox.js";
32
32
  export { CommandHandle } from "./command_handle.js";
33
33
  export { awsAuth, gcpAuth, opaqueSecret, proxyConfig, workspaceSecret, } from "./proxy_config.js";
34
- export { gcsMount, gitMount, mountConfig, s3Mount } from "./mounts.js";
35
- export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxAwsAuthRule, SandboxAwsMountAuthConfig, SandboxGcpAuthRule, SandboxGcpMountAuthConfig, SandboxMountAuth, SandboxMountAuthConfig, SandboxMountConfig, SandboxProxyConfig, SandboxProxyRule, SandboxProxySecret, SandboxMount, MountCacheConfig, GCSMountConfig, GCSMountSpec, GitMountConfig, GitMountRefSpec, GitMountSpec, S3MountConfig, S3MountSpec, CreateSnapshotOptions, CreateDockerfileSnapshotOptions, CaptureSnapshotOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
34
+ export { contextHubMount, gcsMount, gitMount, mountConfig, s3Mount, } from "./mounts.js";
35
+ export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxAwsAuthRule, SandboxAwsMountAuthConfig, SandboxGcpAuthRule, SandboxGcpMountAuthConfig, SandboxMountAuth, SandboxMountAuthConfig, SandboxMountConfig, SandboxProxyConfig, SandboxProxyRule, SandboxProxySecret, SandboxMount, MountCacheConfig, ContextHubMountConfig, ContextHubMountSpec, GCSMountConfig, GCSMountSpec, GitMountConfig, GitMountRefSpec, GitMountSpec, S3MountConfig, S3MountSpec, CreateSnapshotOptions, CreateDockerfileSnapshotOptions, CaptureSnapshotOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
36
36
  export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxConnectTimeoutError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
@@ -32,7 +32,7 @@ export { SandboxClient } from "./client.js";
32
32
  export { Sandbox } from "./sandbox.js";
33
33
  export { CommandHandle } from "./command_handle.js";
34
34
  export { awsAuth, gcpAuth, opaqueSecret, proxyConfig, workspaceSecret, } from "./proxy_config.js";
35
- export { gcsMount, gitMount, mountConfig, s3Mount } from "./mounts.js";
35
+ export { contextHubMount, gcsMount, gitMount, mountConfig, s3Mount, } from "./mounts.js";
36
36
  // Errors
37
37
  export {
38
38
  // Base and connection errors