langsmith 0.7.8 → 0.7.10

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 (228) hide show
  1. package/README.md +161 -15
  2. package/dist/_openapi_client/client.cjs +814 -0
  3. package/dist/_openapi_client/client.d.ts +247 -0
  4. package/dist/_openapi_client/client.js +777 -0
  5. package/dist/_openapi_client/core/api-promise.cjs +100 -0
  6. package/dist/_openapi_client/core/api-promise.d.ts +45 -0
  7. package/dist/_openapi_client/core/api-promise.js +96 -0
  8. package/dist/_openapi_client/core/error.cjs +134 -0
  9. package/dist/_openapi_client/core/error.d.ts +45 -0
  10. package/dist/_openapi_client/core/error.js +118 -0
  11. package/dist/_openapi_client/core/pagination.cjs +374 -0
  12. package/dist/_openapi_client/core/pagination.d.ts +157 -0
  13. package/dist/_openapi_client/core/pagination.js +361 -0
  14. package/dist/_openapi_client/core/resource.cjs +17 -0
  15. package/dist/_openapi_client/core/resource.d.ts +5 -0
  16. package/dist/_openapi_client/core/resource.js +13 -0
  17. package/dist/_openapi_client/core/uploads.cjs +5 -0
  18. package/dist/_openapi_client/core/uploads.d.ts +2 -0
  19. package/dist/_openapi_client/core/uploads.js +1 -0
  20. package/dist/_openapi_client/index.cjs +29 -0
  21. package/dist/_openapi_client/index.d.ts +6 -0
  22. package/dist/_openapi_client/index.js +8 -0
  23. package/dist/_openapi_client/internal/builtin-types.cjs +4 -0
  24. package/dist/_openapi_client/internal/builtin-types.d.ts +72 -0
  25. package/dist/_openapi_client/internal/builtin-types.js +3 -0
  26. package/dist/_openapi_client/internal/detect-platform.cjs +162 -0
  27. package/dist/_openapi_client/internal/detect-platform.d.ts +14 -0
  28. package/dist/_openapi_client/internal/detect-platform.js +157 -0
  29. package/dist/_openapi_client/internal/errors.cjs +41 -0
  30. package/dist/_openapi_client/internal/errors.d.ts +2 -0
  31. package/dist/_openapi_client/internal/errors.js +36 -0
  32. package/dist/_openapi_client/internal/headers.cjs +79 -0
  33. package/dist/_openapi_client/internal/headers.d.ts +18 -0
  34. package/dist/_openapi_client/internal/headers.js +74 -0
  35. package/dist/_openapi_client/internal/parse.cjs +40 -0
  36. package/dist/_openapi_client/internal/parse.d.ts +11 -0
  37. package/dist/_openapi_client/internal/parse.js +37 -0
  38. package/dist/_openapi_client/internal/qs/formats.cjs +12 -0
  39. package/dist/_openapi_client/internal/qs/formats.d.ts +6 -0
  40. package/dist/_openapi_client/internal/qs/formats.js +8 -0
  41. package/dist/_openapi_client/internal/qs/stringify.cjs +277 -0
  42. package/dist/_openapi_client/internal/qs/stringify.d.ts +2 -0
  43. package/dist/_openapi_client/internal/qs/stringify.js +274 -0
  44. package/dist/_openapi_client/internal/qs/types.cjs +2 -0
  45. package/dist/_openapi_client/internal/qs/types.d.ts +56 -0
  46. package/dist/_openapi_client/internal/qs/types.js +1 -0
  47. package/dist/_openapi_client/internal/qs/utils.cjs +230 -0
  48. package/dist/_openapi_client/internal/qs/utils.d.ts +14 -0
  49. package/dist/_openapi_client/internal/qs/utils.js +217 -0
  50. package/dist/_openapi_client/internal/request-options.cjs +14 -0
  51. package/dist/_openapi_client/internal/request-options.d.ts +74 -0
  52. package/dist/_openapi_client/internal/request-options.js +10 -0
  53. package/dist/_openapi_client/internal/shim-types.cjs +4 -0
  54. package/dist/_openapi_client/internal/shim-types.d.ts +16 -0
  55. package/dist/_openapi_client/internal/shim-types.js +3 -0
  56. package/dist/_openapi_client/internal/shims.cjs +92 -0
  57. package/dist/_openapi_client/internal/shims.d.ts +25 -0
  58. package/dist/_openapi_client/internal/shims.js +85 -0
  59. package/dist/_openapi_client/internal/to-file.cjs +91 -0
  60. package/dist/_openapi_client/internal/to-file.d.ts +44 -0
  61. package/dist/_openapi_client/internal/to-file.js +88 -0
  62. package/dist/_openapi_client/internal/types.cjs +4 -0
  63. package/dist/_openapi_client/internal/types.d.ts +35 -0
  64. package/dist/_openapi_client/internal/types.js +3 -0
  65. package/dist/_openapi_client/internal/uploads.cjs +140 -0
  66. package/dist/_openapi_client/internal/uploads.d.ts +41 -0
  67. package/dist/_openapi_client/internal/uploads.js +130 -0
  68. package/dist/_openapi_client/internal/utils/env.cjs +22 -0
  69. package/dist/_openapi_client/internal/utils/env.d.ts +8 -0
  70. package/dist/_openapi_client/internal/utils/env.js +18 -0
  71. package/dist/_openapi_client/internal/utils/log.cjs +88 -0
  72. package/dist/_openapi_client/internal/utils/log.d.ts +36 -0
  73. package/dist/_openapi_client/internal/utils/log.js +82 -0
  74. package/dist/_openapi_client/internal/utils/path.cjs +79 -0
  75. package/dist/_openapi_client/internal/utils/path.d.ts +14 -0
  76. package/dist/_openapi_client/internal/utils/path.js +74 -0
  77. package/dist/_openapi_client/internal/utils/query.cjs +42 -0
  78. package/dist/_openapi_client/internal/utils/query.d.ts +1 -0
  79. package/dist/_openapi_client/internal/utils/query.js +6 -0
  80. package/dist/_openapi_client/internal/utils/sleep.cjs +7 -0
  81. package/dist/_openapi_client/internal/utils/sleep.d.ts +1 -0
  82. package/dist/_openapi_client/internal/utils/sleep.js +3 -0
  83. package/dist/_openapi_client/internal/utils/uuid.cjs +19 -0
  84. package/dist/_openapi_client/internal/utils/uuid.d.ts +4 -0
  85. package/dist/_openapi_client/internal/utils/uuid.js +15 -0
  86. package/dist/_openapi_client/internal/utils/values.cjs +112 -0
  87. package/dist/_openapi_client/internal/utils/values.d.ts +17 -0
  88. package/dist/_openapi_client/internal/utils/values.js +94 -0
  89. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.cjs +138 -0
  90. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.d.ts +367 -0
  91. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.js +101 -0
  92. package/dist/_openapi_client/resources/annotation-queues/runs.cjs +46 -0
  93. package/dist/_openapi_client/resources/annotation-queues/runs.d.ts +128 -0
  94. package/dist/_openapi_client/resources/annotation-queues/runs.js +42 -0
  95. package/dist/_openapi_client/resources/commits.cjs +44 -0
  96. package/dist/_openapi_client/resources/commits.d.ts +204 -0
  97. package/dist/_openapi_client/resources/commits.js +40 -0
  98. package/dist/_openapi_client/resources/datasets/comparative.cjs +22 -0
  99. package/dist/_openapi_client/resources/datasets/comparative.d.ts +55 -0
  100. package/dist/_openapi_client/resources/datasets/comparative.js +18 -0
  101. package/dist/_openapi_client/resources/datasets/datasets.cjs +193 -0
  102. package/dist/_openapi_client/resources/datasets/datasets.d.ts +374 -0
  103. package/dist/_openapi_client/resources/datasets/datasets.js +156 -0
  104. package/dist/_openapi_client/resources/datasets/experiments.cjs +16 -0
  105. package/dist/_openapi_client/resources/datasets/experiments.d.ts +23 -0
  106. package/dist/_openapi_client/resources/datasets/experiments.js +12 -0
  107. package/dist/_openapi_client/resources/datasets/group.cjs +17 -0
  108. package/dist/_openapi_client/resources/datasets/group.d.ts +160 -0
  109. package/dist/_openapi_client/resources/datasets/group.js +13 -0
  110. package/dist/_openapi_client/resources/datasets/runs.cjs +29 -0
  111. package/dist/_openapi_client/resources/datasets/runs.d.ts +216 -0
  112. package/dist/_openapi_client/resources/datasets/runs.js +25 -0
  113. package/dist/_openapi_client/resources/datasets/share.cjs +32 -0
  114. package/dist/_openapi_client/resources/datasets/share.d.ts +28 -0
  115. package/dist/_openapi_client/resources/datasets/share.js +28 -0
  116. package/dist/_openapi_client/resources/datasets/splits.cjs +22 -0
  117. package/dist/_openapi_client/resources/datasets/splits.d.ts +30 -0
  118. package/dist/_openapi_client/resources/datasets/splits.js +18 -0
  119. package/dist/_openapi_client/resources/datasets/versions.cjs +23 -0
  120. package/dist/_openapi_client/resources/datasets/versions.d.ts +36 -0
  121. package/dist/_openapi_client/resources/datasets/versions.js +19 -0
  122. package/dist/_openapi_client/resources/evaluators.cjs +15 -0
  123. package/dist/_openapi_client/resources/evaluators.d.ts +125 -0
  124. package/dist/_openapi_client/resources/evaluators.js +11 -0
  125. package/dist/_openapi_client/resources/examples/bulk.cjs +24 -0
  126. package/dist/_openapi_client/resources/examples/bulk.d.ts +78 -0
  127. package/dist/_openapi_client/resources/examples/bulk.js +20 -0
  128. package/dist/_openapi_client/resources/examples/examples.cjs +124 -0
  129. package/dist/_openapi_client/resources/examples/examples.d.ts +182 -0
  130. package/dist/_openapi_client/resources/examples/examples.js +87 -0
  131. package/dist/_openapi_client/resources/examples/validate.cjs +21 -0
  132. package/dist/_openapi_client/resources/examples/validate.d.ts +38 -0
  133. package/dist/_openapi_client/resources/examples/validate.js +17 -0
  134. package/dist/_openapi_client/resources/feedback/configs.cjs +24 -0
  135. package/dist/_openapi_client/resources/feedback/configs.d.ts +18 -0
  136. package/dist/_openapi_client/resources/feedback/configs.js +20 -0
  137. package/dist/_openapi_client/resources/feedback/feedback.cjs +98 -0
  138. package/dist/_openapi_client/resources/feedback/feedback.d.ts +275 -0
  139. package/dist/_openapi_client/resources/feedback/feedback.js +61 -0
  140. package/dist/_openapi_client/resources/feedback/tokens.cjs +35 -0
  141. package/dist/_openapi_client/resources/feedback/tokens.d.ts +130 -0
  142. package/dist/_openapi_client/resources/feedback/tokens.js +31 -0
  143. package/dist/_openapi_client/resources/index.cjs +35 -0
  144. package/dist/_openapi_client/resources/index.d.ts +15 -0
  145. package/dist/_openapi_client/resources/index.js +17 -0
  146. package/dist/_openapi_client/resources/info.cjs +15 -0
  147. package/dist/_openapi_client/resources/info.d.ts +51 -0
  148. package/dist/_openapi_client/resources/info.js +11 -0
  149. package/dist/_openapi_client/resources/online-evaluators.cjs +70 -0
  150. package/dist/_openapi_client/resources/online-evaluators.d.ts +284 -0
  151. package/dist/_openapi_client/resources/online-evaluators.js +66 -0
  152. package/dist/_openapi_client/resources/public/datasets.cjs +47 -0
  153. package/dist/_openapi_client/resources/public/datasets.d.ts +152 -0
  154. package/dist/_openapi_client/resources/public/datasets.js +43 -0
  155. package/dist/_openapi_client/resources/public/public.cjs +62 -0
  156. package/dist/_openapi_client/resources/public/public.d.ts +32 -0
  157. package/dist/_openapi_client/resources/public/public.js +25 -0
  158. package/dist/_openapi_client/resources/repos/directories.cjs +40 -0
  159. package/dist/_openapi_client/resources/repos/directories.d.ts +72 -0
  160. package/dist/_openapi_client/resources/repos/directories.js +36 -0
  161. package/dist/_openapi_client/resources/repos/repos.cjs +93 -0
  162. package/dist/_openapi_client/resources/repos/repos.d.ts +188 -0
  163. package/dist/_openapi_client/resources/repos/repos.js +56 -0
  164. package/dist/_openapi_client/resources/runs/rules.cjs +9 -0
  165. package/dist/_openapi_client/resources/runs/rules.d.ts +3 -0
  166. package/dist/_openapi_client/resources/runs/rules.js +5 -0
  167. package/dist/_openapi_client/resources/runs/runs.cjs +102 -0
  168. package/dist/_openapi_client/resources/runs/runs.d.ts +542 -0
  169. package/dist/_openapi_client/resources/runs/runs.js +65 -0
  170. package/dist/_openapi_client/resources/sandboxes/boxes.cjs +86 -0
  171. package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +1121 -0
  172. package/dist/_openapi_client/resources/sandboxes/boxes.js +82 -0
  173. package/dist/_openapi_client/resources/sandboxes/sandboxes.cjs +63 -0
  174. package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +13 -0
  175. package/dist/_openapi_client/resources/sandboxes/sandboxes.js +26 -0
  176. package/dist/_openapi_client/resources/sandboxes/snapshots.cjs +39 -0
  177. package/dist/_openapi_client/resources/sandboxes/snapshots.d.ts +130 -0
  178. package/dist/_openapi_client/resources/sandboxes/snapshots.js +35 -0
  179. package/dist/_openapi_client/resources/sessions/insights.cjs +54 -0
  180. package/dist/_openapi_client/resources/sessions/insights.d.ts +246 -0
  181. package/dist/_openapi_client/resources/sessions/insights.js +50 -0
  182. package/dist/_openapi_client/resources/sessions/sessions.cjs +109 -0
  183. package/dist/_openapi_client/resources/sessions/sessions.d.ts +674 -0
  184. package/dist/_openapi_client/resources/sessions/sessions.js +72 -0
  185. package/dist/_openapi_client/resources/settings.cjs +15 -0
  186. package/dist/_openapi_client/resources/settings.d.ts +18 -0
  187. package/dist/_openapi_client/resources/settings.js +11 -0
  188. package/dist/_openapi_client/resources/workspaces.cjs +35 -0
  189. package/dist/_openapi_client/resources/workspaces.d.ts +84 -0
  190. package/dist/_openapi_client/resources/workspaces.js +31 -0
  191. package/dist/_openapi_client/version.cjs +5 -0
  192. package/dist/_openapi_client/version.d.ts +1 -0
  193. package/dist/_openapi_client/version.js +2 -0
  194. package/dist/client.cjs +48 -19
  195. package/dist/client.d.ts +5 -0
  196. package/dist/client.js +29 -0
  197. package/dist/env.cjs +3 -3
  198. package/dist/env.d.ts +1 -1
  199. package/dist/env.js +1 -1
  200. package/dist/experimental/otel/exporter.cjs +1 -1
  201. package/dist/experimental/otel/exporter.js +2 -2
  202. package/dist/experimental/vercel/telemetry.cjs +1 -1
  203. package/dist/experimental/vercel/telemetry.js +2 -2
  204. package/dist/index.cjs +4 -2
  205. package/dist/index.d.ts +2 -1
  206. package/dist/index.js +2 -1
  207. package/dist/run_trees.cjs +1 -1
  208. package/dist/run_trees.js +2 -2
  209. package/dist/sandbox/client.cjs +11 -3
  210. package/dist/sandbox/client.js +11 -3
  211. package/dist/sandbox/index.cjs +8 -2
  212. package/dist/sandbox/index.d.ts +3 -2
  213. package/dist/sandbox/index.js +2 -1
  214. package/dist/sandbox/mounts.cjs +114 -0
  215. package/dist/sandbox/mounts.d.ts +24 -0
  216. package/dist/sandbox/mounts.js +109 -0
  217. package/dist/sandbox/proxy_config.cjs +90 -5
  218. package/dist/sandbox/proxy_config.d.ts +19 -4
  219. package/dist/sandbox/proxy_config.js +86 -4
  220. package/dist/sandbox/types.d.ts +92 -3
  221. package/dist/traceable.cjs +1 -1
  222. package/dist/traceable.js +2 -2
  223. package/dist/utils/guard.cjs +13 -0
  224. package/dist/utils/guard.d.ts +6 -0
  225. package/dist/utils/guard.js +10 -0
  226. package/dist/utils/jestlike/globals.cjs +1 -1
  227. package/dist/utils/jestlike/globals.js +2 -2
  228. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import { isRunTree, RunTree } from "../../run_trees.js";
2
2
  import { getCurrentRunTree, withRunTree } from "../../singletons/traceable.js";
3
- import { isTracingEnabled } from "../../env.js";
3
+ 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";
@@ -107,7 +107,7 @@ export function LangSmithTelemetry(config) {
107
107
  /** Per-generation state keyed by AI SDK `callId` (stable across nested calls). */
108
108
  const invocationsByCallId = new Map();
109
109
  const onStart = async (event) => {
110
- if (!isTracingEnabled(tracingEnabled))
110
+ if (!isEnvTracingEnabled(tracingEnabled))
111
111
  return;
112
112
  if (!("callId" in event) || typeof event.callId !== "string")
113
113
  return;
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LS_MESSAGE_VIEW_EXCLUDE = exports.__version__ = exports.promptCacheSingleton = exports.configureGlobalPromptCache = exports.PromptCache = exports.Cache = exports.uuid7FromTime = exports.uuid7 = exports.getDefaultProjectName = exports.overrideFetchImplementation = exports.RunTree = exports.Client = void 0;
3
+ exports.LS_MESSAGE_VIEW_EXCLUDE = exports.__version__ = exports.promptCacheSingleton = exports.configureGlobalPromptCache = exports.PromptCache = exports.Cache = exports.isTracingEnabled = exports.uuid7FromTime = exports.uuid7 = exports.getDefaultProjectName = exports.overrideFetchImplementation = exports.RunTree = exports.Client = void 0;
4
4
  var client_js_1 = require("./client.cjs");
5
5
  Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_1.Client; } });
6
6
  var run_trees_js_1 = require("./run_trees.cjs");
@@ -12,12 +12,14 @@ Object.defineProperty(exports, "getDefaultProjectName", { enumerable: true, get:
12
12
  var uuid_js_1 = require("./uuid.cjs");
13
13
  Object.defineProperty(exports, "uuid7", { enumerable: true, get: function () { return uuid_js_1.uuid7; } });
14
14
  Object.defineProperty(exports, "uuid7FromTime", { enumerable: true, get: function () { return uuid_js_1.uuid7FromTime; } });
15
+ var guard_js_1 = require("./utils/guard.cjs");
16
+ Object.defineProperty(exports, "isTracingEnabled", { enumerable: true, get: function () { return guard_js_1.isTracingEnabled; } });
15
17
  var index_js_1 = require("./utils/prompt_cache/index.cjs");
16
18
  Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return index_js_1.Cache; } });
17
19
  Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function () { return index_js_1.PromptCache; } });
18
20
  Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
19
21
  Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
20
22
  // Update using pnpm bump-version
21
- exports.__version__ = "0.7.8";
23
+ exports.__version__ = "0.7.10";
22
24
  // Metadata key to hide a traced run from LangSmith's Messages View.
23
25
  exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
6
  export { uuid7, uuid7FromTime } from "./uuid.js";
7
+ export { isTracingEnabled } from "./utils/guard.js";
7
8
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
- export declare const __version__ = "0.7.8";
9
+ export declare const __version__ = "0.7.10";
9
10
  export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
package/dist/index.js CHANGED
@@ -3,8 +3,9 @@ export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  export { getDefaultProjectName } from "./utils/project.js";
5
5
  export { uuid7, uuid7FromTime } from "./uuid.js";
6
+ export { isTracingEnabled } from "./utils/guard.js";
6
7
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
7
8
  // Update using pnpm bump-version
8
- export const __version__ = "0.7.8";
9
+ export const __version__ = "0.7.10";
9
10
  // Metadata key to hide a traced run from LangSmith's Messages View.
10
11
  export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
@@ -836,7 +836,7 @@ class RunTree {
836
836
  let parentRun;
837
837
  let projectName;
838
838
  let client;
839
- let tracingEnabled = (0, env_js_1.isTracingEnabled)();
839
+ let tracingEnabled = (0, env_js_1.isEnvTracingEnabled)();
840
840
  if (callbackManager) {
841
841
  const parentRunId = callbackManager?.getParentRunId?.() ?? "";
842
842
  const langChainTracer = callbackManager?.handlers?.find((handler) => handler?.name == "langchain_tracer");
package/dist/run_trees.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Client } from "./client.js";
2
- import { isTracingEnabled } from "./env.js";
2
+ import { isEnvTracingEnabled } from "./env.js";
3
3
  import { isConflictingEndpointsError, ConflictingEndpointsError, } from "./utils/error.js";
4
4
  import { _LC_CONTEXT_VARIABLES_KEY, _REPLICA_TRACE_ROOTS_KEY, } from "./singletons/constants.js";
5
5
  import { getContextVar, setContextVar } from "./utils/context_vars.js";
@@ -830,7 +830,7 @@ export class RunTree {
830
830
  let parentRun;
831
831
  let projectName;
832
832
  let client;
833
- let tracingEnabled = isTracingEnabled();
833
+ let tracingEnabled = isEnvTracingEnabled();
834
834
  if (callbackManager) {
835
835
  const parentRunId = callbackManager?.getParentRunId?.() ?? "";
836
836
  const langChainTracer = callbackManager?.handlers?.find((handler) => handler?.name == "langchain_tracer");
@@ -10,6 +10,7 @@ const async_caller_js_1 = require("../utils/async_caller.cjs");
10
10
  const sandbox_js_1 = require("./sandbox.cjs");
11
11
  const errors_js_1 = require("./errors.cjs");
12
12
  const helpers_js_1 = require("./helpers.cjs");
13
+ const proxy_config_js_1 = require("./proxy_config.cjs");
13
14
  const index_js_1 = require("../utils/uuid/src/index.cjs");
14
15
  /**
15
16
  * Sleep that can be interrupted by an AbortSignal.
@@ -367,10 +368,13 @@ class SandboxClient {
367
368
  const resolvedOptions = typeof snapshotIdOrOptions === "object" && snapshotIdOrOptions !== null
368
369
  ? snapshotIdOrOptions
369
370
  : options;
370
- const { snapshotName, name, timeout = 30, waitForReady = true, idleTtlSeconds, deleteAfterStopSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = resolvedOptions;
371
+ const { snapshotName, name, timeout = 30, waitForReady = true, idleTtlSeconds, deleteAfterStopSeconds, vCpus, memBytes, fsCapacityBytes, mountConfig, proxyConfig, } = resolvedOptions;
371
372
  if (snapshotId && snapshotName) {
372
373
  throw new errors_js_1.LangSmithValidationError("At most one of snapshotId or options.snapshotName may be set", "snapshotId");
373
374
  }
375
+ if ("mounts" in resolvedOptions) {
376
+ throw new errors_js_1.LangSmithValidationError("mounts is not a public createSandbox option; use mountConfig", "mounts");
377
+ }
374
378
  (0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
375
379
  (0, helpers_js_1.validateTtl)(deleteAfterStopSeconds, "deleteAfterStopSeconds");
376
380
  const url = `${this._baseUrl}/boxes`;
@@ -404,8 +408,12 @@ class SandboxClient {
404
408
  if (fsCapacityBytes !== undefined) {
405
409
  payload.fs_capacity_bytes = fsCapacityBytes;
406
410
  }
407
- if (proxyConfig !== undefined) {
408
- payload.proxy_config = proxyConfig;
411
+ const effectiveProxyConfig = (0, proxy_config_js_1.mergeProxyConfigs)(mountConfig?.proxyConfig, proxyConfig);
412
+ if (mountConfig !== undefined) {
413
+ payload.mounts = mountConfig.mounts;
414
+ }
415
+ if (effectiveProxyConfig !== undefined) {
416
+ payload.proxy_config = effectiveProxyConfig;
409
417
  }
410
418
  const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
411
419
  const response = await this._fetch(url, {
@@ -7,6 +7,7 @@ import { AsyncCaller } from "../utils/async_caller.js";
7
7
  import { Sandbox } from "./sandbox.js";
8
8
  import { LangSmithResourceCreationError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, LangSmithValidationError, } from "./errors.js";
9
9
  import { handleClientHttpError, handleSandboxCreationError, validateTtl, } from "./helpers.js";
10
+ import { mergeProxyConfigs } from "./proxy_config.js";
10
11
  import { v4 as uuidv4 } from "../utils/uuid/src/index.js";
11
12
  /**
12
13
  * Sleep that can be interrupted by an AbortSignal.
@@ -364,10 +365,13 @@ export class SandboxClient {
364
365
  const resolvedOptions = typeof snapshotIdOrOptions === "object" && snapshotIdOrOptions !== null
365
366
  ? snapshotIdOrOptions
366
367
  : options;
367
- const { snapshotName, name, timeout = 30, waitForReady = true, idleTtlSeconds, deleteAfterStopSeconds, vCpus, memBytes, fsCapacityBytes, proxyConfig, } = resolvedOptions;
368
+ const { snapshotName, name, timeout = 30, waitForReady = true, idleTtlSeconds, deleteAfterStopSeconds, vCpus, memBytes, fsCapacityBytes, mountConfig, proxyConfig, } = resolvedOptions;
368
369
  if (snapshotId && snapshotName) {
369
370
  throw new LangSmithValidationError("At most one of snapshotId or options.snapshotName may be set", "snapshotId");
370
371
  }
372
+ if ("mounts" in resolvedOptions) {
373
+ throw new LangSmithValidationError("mounts is not a public createSandbox option; use mountConfig", "mounts");
374
+ }
371
375
  validateTtl(idleTtlSeconds, "idleTtlSeconds");
372
376
  validateTtl(deleteAfterStopSeconds, "deleteAfterStopSeconds");
373
377
  const url = `${this._baseUrl}/boxes`;
@@ -401,8 +405,12 @@ export class SandboxClient {
401
405
  if (fsCapacityBytes !== undefined) {
402
406
  payload.fs_capacity_bytes = fsCapacityBytes;
403
407
  }
404
- if (proxyConfig !== undefined) {
405
- payload.proxy_config = proxyConfig;
408
+ const effectiveProxyConfig = mergeProxyConfigs(mountConfig?.proxyConfig, proxyConfig);
409
+ if (mountConfig !== undefined) {
410
+ payload.mounts = mountConfig.mounts;
411
+ }
412
+ if (effectiveProxyConfig !== undefined) {
413
+ payload.proxy_config = effectiveProxyConfig;
406
414
  }
407
415
  const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
408
416
  const response = await this._fetch(url, {
@@ -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.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.workspaceSecret = exports.opaqueSecret = exports.awsAuthProxyConfig = 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.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.s3Mount = exports.mountConfig = exports.gcsMount = 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; } });
@@ -38,9 +38,15 @@ Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () {
38
38
  var command_handle_js_1 = require("./command_handle.cjs");
39
39
  Object.defineProperty(exports, "CommandHandle", { enumerable: true, get: function () { return command_handle_js_1.CommandHandle; } });
40
40
  var proxy_config_js_1 = require("./proxy_config.cjs");
41
- Object.defineProperty(exports, "awsAuthProxyConfig", { enumerable: true, get: function () { return proxy_config_js_1.awsAuthProxyConfig; } });
41
+ Object.defineProperty(exports, "awsAuth", { enumerable: true, get: function () { return proxy_config_js_1.awsAuth; } });
42
+ Object.defineProperty(exports, "gcpAuth", { enumerable: true, get: function () { return proxy_config_js_1.gcpAuth; } });
42
43
  Object.defineProperty(exports, "opaqueSecret", { enumerable: true, get: function () { return proxy_config_js_1.opaqueSecret; } });
44
+ Object.defineProperty(exports, "proxyConfig", { enumerable: true, get: function () { return proxy_config_js_1.proxyConfig; } });
43
45
  Object.defineProperty(exports, "workspaceSecret", { enumerable: true, get: function () { return proxy_config_js_1.workspaceSecret; } });
46
+ var mounts_js_1 = require("./mounts.cjs");
47
+ Object.defineProperty(exports, "gcsMount", { enumerable: true, get: function () { return mounts_js_1.gcsMount; } });
48
+ Object.defineProperty(exports, "mountConfig", { enumerable: true, get: function () { return mounts_js_1.mountConfig; } });
49
+ Object.defineProperty(exports, "s3Mount", { enumerable: true, get: function () { return mounts_js_1.s3Mount; } });
44
50
  // Errors
45
51
  var errors_js_1 = require("./errors.cjs");
46
52
  // Base and connection errors
@@ -30,6 +30,7 @@
30
30
  export { SandboxClient } from "./client.js";
31
31
  export { Sandbox } from "./sandbox.js";
32
32
  export { CommandHandle } from "./command_handle.js";
33
- export { awsAuthProxyConfig, opaqueSecret, workspaceSecret, } from "./proxy_config.js";
34
- export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxAwsAuthRule, SandboxProxyConfig, SandboxProxySecret, CreateSnapshotOptions, CreateDockerfileSnapshotOptions, CaptureSnapshotOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
33
+ export { awsAuth, gcpAuth, opaqueSecret, proxyConfig, workspaceSecret, } from "./proxy_config.js";
34
+ export { gcsMount, mountConfig, s3Mount } from "./mounts.js";
35
+ export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceStatus, Snapshot, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, SandboxAccessControl, SandboxAwsAuthRule, SandboxGcpAuthRule, SandboxMountConfig, SandboxProxyConfig, SandboxProxyRule, SandboxProxySecret, SandboxMount, MountCacheConfig, GCSMountConfig, GCSMountSpec, S3MountConfig, S3MountSpec, CreateSnapshotOptions, CreateDockerfileSnapshotOptions, CaptureSnapshotOptions, ListSnapshotsOptions, WaitForSnapshotOptions, StartSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, } from "./types.js";
35
36
  export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
@@ -31,7 +31,8 @@
31
31
  export { SandboxClient } from "./client.js";
32
32
  export { Sandbox } from "./sandbox.js";
33
33
  export { CommandHandle } from "./command_handle.js";
34
- export { awsAuthProxyConfig, opaqueSecret, workspaceSecret, } from "./proxy_config.js";
34
+ export { awsAuth, gcpAuth, opaqueSecret, proxyConfig, workspaceSecret, } from "./proxy_config.js";
35
+ export { gcsMount, mountConfig, s3Mount } from "./mounts.js";
35
36
  // Errors
36
37
  export {
37
38
  // Base and connection errors
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.s3Mount = s3Mount;
4
+ exports.gcsMount = gcsMount;
5
+ exports.mountConfig = mountConfig;
6
+ const proxy_config_js_1 = require("./proxy_config.cjs");
7
+ function requireNonEmptyString(value, field) {
8
+ if (typeof value !== "string" || value.trim() === "") {
9
+ throw new Error(`${field} must be a non-empty string`);
10
+ }
11
+ return value.trim();
12
+ }
13
+ function s3Mount({ id, mountPath, bucket, region = "us-east-1", prefix, endpointUrl = "https://s3.amazonaws.com", pathStyle = false, readOnly, cache, }) {
14
+ const mount = {
15
+ id: requireNonEmptyString(id, "id"),
16
+ type: "s3",
17
+ mount_path: requireNonEmptyString(mountPath, "mountPath"),
18
+ s3: {
19
+ endpoint_url: requireNonEmptyString(endpointUrl, "endpointUrl"),
20
+ region: requireNonEmptyString(region, "region"),
21
+ bucket: requireNonEmptyString(bucket, "bucket"),
22
+ path_style: pathStyle,
23
+ },
24
+ };
25
+ if (prefix !== undefined) {
26
+ mount.s3.prefix = requireNonEmptyString(prefix, "prefix");
27
+ }
28
+ if (readOnly !== undefined) {
29
+ mount.read_only = readOnly;
30
+ }
31
+ if (cache !== undefined) {
32
+ mount.cache = { ...cache };
33
+ }
34
+ return mount;
35
+ }
36
+ function gcsMount({ id, mountPath, bucket, prefix, readOnly, cache, }) {
37
+ const mount = {
38
+ id: requireNonEmptyString(id, "id"),
39
+ type: "gcs",
40
+ mount_path: requireNonEmptyString(mountPath, "mountPath"),
41
+ gcs: {
42
+ bucket: requireNonEmptyString(bucket, "bucket"),
43
+ },
44
+ };
45
+ if (prefix !== undefined) {
46
+ mount.gcs.prefix = requireNonEmptyString(prefix, "prefix");
47
+ }
48
+ if (readOnly !== undefined) {
49
+ mount.read_only = readOnly;
50
+ }
51
+ if (cache !== undefined) {
52
+ mount.cache = { ...cache };
53
+ }
54
+ return mount;
55
+ }
56
+ function normalizeMounts(mounts) {
57
+ if (!Array.isArray(mounts) || mounts.length === 0) {
58
+ throw new Error("mounts must be a non-empty array of mount objects");
59
+ }
60
+ return mounts.map((mount) => {
61
+ if (mount === null || typeof mount !== "object" || Array.isArray(mount)) {
62
+ throw new Error("mounts must be a non-empty array of mount objects");
63
+ }
64
+ if (mount.type !== "s3" && mount.type !== "gcs") {
65
+ throw new Error("mountConfig only supports s3 and gcs mounts");
66
+ }
67
+ return mount;
68
+ });
69
+ }
70
+ function normalizeAuthRules(auth) {
71
+ if (!Array.isArray(auth)) {
72
+ throw new Error("auth must be an array of provider auth rules");
73
+ }
74
+ const byProvider = {};
75
+ for (const rule of auth) {
76
+ if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
77
+ throw new Error("auth must be an array of provider auth rules");
78
+ }
79
+ const provider = rule.type;
80
+ if (provider !== "aws" && provider !== "gcp") {
81
+ throw new Error("mountConfig auth only supports aws and gcp rules");
82
+ }
83
+ if (byProvider[provider] !== undefined) {
84
+ throw new Error(`duplicate ${provider} auth rule in mountConfig`);
85
+ }
86
+ byProvider[provider] = rule;
87
+ }
88
+ return byProvider;
89
+ }
90
+ function mountConfig({ auth, mounts, }) {
91
+ const normalizedMounts = normalizeMounts(mounts);
92
+ const authByProvider = normalizeAuthRules(auth);
93
+ const mountProviders = new Set(normalizedMounts.map((mount) => mount.type));
94
+ if (mountProviders.has("s3") && authByProvider.aws === undefined) {
95
+ throw new Error("s3 mounts require aws auth in mountConfig");
96
+ }
97
+ if (mountProviders.has("gcs") && authByProvider.gcp === undefined) {
98
+ throw new Error("gcs mounts require gcp auth in mountConfig");
99
+ }
100
+ if (authByProvider.aws !== undefined && !mountProviders.has("s3")) {
101
+ throw new Error("aws auth requires at least one s3 mount in mountConfig");
102
+ }
103
+ if (authByProvider.gcp !== undefined && !mountProviders.has("gcs")) {
104
+ throw new Error("gcp auth requires at least one gcs mount in mountConfig");
105
+ }
106
+ return {
107
+ mounts: normalizedMounts,
108
+ proxyConfig: (0, proxy_config_js_1.proxyConfig)({
109
+ rules: ["aws", "gcp"]
110
+ .map((provider) => authByProvider[provider])
111
+ .filter((rule) => rule !== undefined),
112
+ }),
113
+ };
114
+ }
@@ -0,0 +1,24 @@
1
+ import type { GCSMountSpec, MountCacheConfig, S3MountSpec, SandboxMount, SandboxMountConfig, SandboxProxyRule } from "./types.js";
2
+ export declare function s3Mount({ id, mountPath, bucket, region, prefix, endpointUrl, pathStyle, readOnly, cache, }: {
3
+ id: string;
4
+ mountPath: string;
5
+ bucket: string;
6
+ region?: string;
7
+ prefix?: string;
8
+ endpointUrl?: string;
9
+ pathStyle?: boolean;
10
+ readOnly?: boolean;
11
+ cache?: MountCacheConfig;
12
+ }): S3MountSpec;
13
+ export declare function gcsMount({ id, mountPath, bucket, prefix, readOnly, cache, }: {
14
+ id: string;
15
+ mountPath: string;
16
+ bucket: string;
17
+ prefix?: string;
18
+ readOnly?: boolean;
19
+ cache?: MountCacheConfig;
20
+ }): GCSMountSpec;
21
+ export declare function mountConfig({ auth, mounts, }: {
22
+ auth: SandboxProxyRule[];
23
+ mounts: SandboxMount[];
24
+ }): SandboxMountConfig;
@@ -0,0 +1,109 @@
1
+ import { proxyConfig } from "./proxy_config.js";
2
+ function requireNonEmptyString(value, field) {
3
+ if (typeof value !== "string" || value.trim() === "") {
4
+ throw new Error(`${field} must be a non-empty string`);
5
+ }
6
+ return value.trim();
7
+ }
8
+ export function s3Mount({ id, mountPath, bucket, region = "us-east-1", prefix, endpointUrl = "https://s3.amazonaws.com", pathStyle = false, readOnly, cache, }) {
9
+ const mount = {
10
+ id: requireNonEmptyString(id, "id"),
11
+ type: "s3",
12
+ mount_path: requireNonEmptyString(mountPath, "mountPath"),
13
+ s3: {
14
+ endpoint_url: requireNonEmptyString(endpointUrl, "endpointUrl"),
15
+ region: requireNonEmptyString(region, "region"),
16
+ bucket: requireNonEmptyString(bucket, "bucket"),
17
+ path_style: pathStyle,
18
+ },
19
+ };
20
+ if (prefix !== undefined) {
21
+ mount.s3.prefix = requireNonEmptyString(prefix, "prefix");
22
+ }
23
+ if (readOnly !== undefined) {
24
+ mount.read_only = readOnly;
25
+ }
26
+ if (cache !== undefined) {
27
+ mount.cache = { ...cache };
28
+ }
29
+ return mount;
30
+ }
31
+ export function gcsMount({ id, mountPath, bucket, prefix, readOnly, cache, }) {
32
+ const mount = {
33
+ id: requireNonEmptyString(id, "id"),
34
+ type: "gcs",
35
+ mount_path: requireNonEmptyString(mountPath, "mountPath"),
36
+ gcs: {
37
+ bucket: requireNonEmptyString(bucket, "bucket"),
38
+ },
39
+ };
40
+ if (prefix !== undefined) {
41
+ mount.gcs.prefix = requireNonEmptyString(prefix, "prefix");
42
+ }
43
+ if (readOnly !== undefined) {
44
+ mount.read_only = readOnly;
45
+ }
46
+ if (cache !== undefined) {
47
+ mount.cache = { ...cache };
48
+ }
49
+ return mount;
50
+ }
51
+ function normalizeMounts(mounts) {
52
+ if (!Array.isArray(mounts) || mounts.length === 0) {
53
+ throw new Error("mounts must be a non-empty array of mount objects");
54
+ }
55
+ return mounts.map((mount) => {
56
+ if (mount === null || typeof mount !== "object" || Array.isArray(mount)) {
57
+ throw new Error("mounts must be a non-empty array of mount objects");
58
+ }
59
+ if (mount.type !== "s3" && mount.type !== "gcs") {
60
+ throw new Error("mountConfig only supports s3 and gcs mounts");
61
+ }
62
+ return mount;
63
+ });
64
+ }
65
+ function normalizeAuthRules(auth) {
66
+ if (!Array.isArray(auth)) {
67
+ throw new Error("auth must be an array of provider auth rules");
68
+ }
69
+ const byProvider = {};
70
+ for (const rule of auth) {
71
+ if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
72
+ throw new Error("auth must be an array of provider auth rules");
73
+ }
74
+ const provider = rule.type;
75
+ if (provider !== "aws" && provider !== "gcp") {
76
+ throw new Error("mountConfig auth only supports aws and gcp rules");
77
+ }
78
+ if (byProvider[provider] !== undefined) {
79
+ throw new Error(`duplicate ${provider} auth rule in mountConfig`);
80
+ }
81
+ byProvider[provider] = rule;
82
+ }
83
+ return byProvider;
84
+ }
85
+ export function mountConfig({ auth, mounts, }) {
86
+ const normalizedMounts = normalizeMounts(mounts);
87
+ const authByProvider = normalizeAuthRules(auth);
88
+ const mountProviders = new Set(normalizedMounts.map((mount) => mount.type));
89
+ if (mountProviders.has("s3") && authByProvider.aws === undefined) {
90
+ throw new Error("s3 mounts require aws auth in mountConfig");
91
+ }
92
+ if (mountProviders.has("gcs") && authByProvider.gcp === undefined) {
93
+ throw new Error("gcs mounts require gcp auth in mountConfig");
94
+ }
95
+ if (authByProvider.aws !== undefined && !mountProviders.has("s3")) {
96
+ throw new Error("aws auth requires at least one s3 mount in mountConfig");
97
+ }
98
+ if (authByProvider.gcp !== undefined && !mountProviders.has("gcs")) {
99
+ throw new Error("gcp auth requires at least one gcs mount in mountConfig");
100
+ }
101
+ return {
102
+ mounts: normalizedMounts,
103
+ proxyConfig: proxyConfig({
104
+ rules: ["aws", "gcp"]
105
+ .map((provider) => authByProvider[provider])
106
+ .filter((rule) => rule !== undefined),
107
+ }),
108
+ };
109
+ }
@@ -2,13 +2,41 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.workspaceSecret = workspaceSecret;
4
4
  exports.opaqueSecret = opaqueSecret;
5
- exports.awsAuthProxyConfig = awsAuthProxyConfig;
5
+ exports.proxyConfig = proxyConfig;
6
+ exports.mergeProxyConfigs = mergeProxyConfigs;
7
+ exports.awsAuth = awsAuth;
8
+ exports.gcpAuth = gcpAuth;
9
+ const DEFAULT_GCP_AUTH_MATCH_HOSTS = [
10
+ "storage.googleapis.com",
11
+ "www.googleapis.com",
12
+ ];
13
+ const PROVIDER_RULE_TYPES = new Set(["aws", "gcp"]);
6
14
  function requireNonEmptyString(value, field) {
7
15
  if (typeof value !== "string" || value.trim() === "") {
8
16
  throw new Error(`${field} must be a non-empty string`);
9
17
  }
10
18
  return value.trim();
11
19
  }
20
+ function requireNonEmptyStringArray(values, field) {
21
+ if (!Array.isArray(values) || values.length === 0) {
22
+ throw new Error(`${field} must be a non-empty array of strings`);
23
+ }
24
+ return values.map((value) => requireNonEmptyString(value, field));
25
+ }
26
+ function requireProxyRules(rules) {
27
+ if (rules === undefined) {
28
+ return [];
29
+ }
30
+ if (!Array.isArray(rules)) {
31
+ throw new Error("rules must be an array of proxy rule objects");
32
+ }
33
+ return rules.map((rule) => {
34
+ if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
35
+ throw new Error("rules must be an array of proxy rule objects");
36
+ }
37
+ return rule;
38
+ });
39
+ }
12
40
  /** Reference a LangSmith workspace secret in a sandbox proxy configuration. */
13
41
  function workspaceSecret(name) {
14
42
  const normalized = requireNonEmptyString(name, "name");
@@ -32,9 +60,54 @@ function opaqueSecret(value) {
32
60
  value: requireNonEmptyString(value, "value"),
33
61
  };
34
62
  }
35
- /** Build a sandbox proxy config that signs AWS HTTPS requests with SigV4. */
36
- function awsAuthProxyConfig({ accessKeyId, secretAccessKey, name = "aws", enabled = true, }) {
37
- const rule = {
63
+ /** Build a sandbox proxy config from one or more proxy rules. */
64
+ function proxyConfig({ rules, noProxy, accessControl, } = {}) {
65
+ const config = {
66
+ rules: requireProxyRules(rules),
67
+ };
68
+ if (noProxy !== undefined) {
69
+ config.no_proxy = requireNonEmptyStringArray(noProxy, "noProxy");
70
+ }
71
+ if (accessControl !== undefined) {
72
+ config.access_control = { ...accessControl };
73
+ }
74
+ return config;
75
+ }
76
+ function providerRuleTypes(config) {
77
+ const providers = new Set();
78
+ for (const rule of config.rules ?? []) {
79
+ if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
80
+ continue;
81
+ }
82
+ const ruleType = rule.type;
83
+ if (typeof ruleType === "string" && PROVIDER_RULE_TYPES.has(ruleType)) {
84
+ providers.add(ruleType);
85
+ }
86
+ }
87
+ return providers;
88
+ }
89
+ function mergeProxyConfigs(generatedConfig, explicitConfig) {
90
+ if (generatedConfig === undefined) {
91
+ return explicitConfig;
92
+ }
93
+ if (explicitConfig === undefined) {
94
+ return generatedConfig;
95
+ }
96
+ const generatedProviders = providerRuleTypes(generatedConfig);
97
+ for (const provider of providerRuleTypes(explicitConfig)) {
98
+ if (generatedProviders.has(provider)) {
99
+ throw new Error(`${provider} auth cannot be provided in both mountConfig and proxyConfig`);
100
+ }
101
+ }
102
+ return {
103
+ ...generatedConfig,
104
+ ...explicitConfig,
105
+ rules: [...(generatedConfig.rules ?? []), ...(explicitConfig.rules ?? [])],
106
+ };
107
+ }
108
+ /** Build a sandbox proxy rule that signs AWS HTTPS requests with SigV4. */
109
+ function awsAuth({ accessKeyId, secretAccessKey, name = "aws", enabled = true, }) {
110
+ return {
38
111
  name: requireNonEmptyString(name, "name"),
39
112
  type: "aws",
40
113
  enabled,
@@ -43,5 +116,17 @@ function awsAuthProxyConfig({ accessKeyId, secretAccessKey, name = "aws", enable
43
116
  secret_access_key: secretAccessKey,
44
117
  },
45
118
  };
46
- return { rules: [rule] };
119
+ }
120
+ /** Build a sandbox proxy rule that injects GCP OAuth bearer auth. */
121
+ function gcpAuth({ serviceAccountJson, scopes, matchHosts = DEFAULT_GCP_AUTH_MATCH_HOSTS, name = "gcp", enabled = true, }) {
122
+ return {
123
+ name: requireNonEmptyString(name, "name"),
124
+ type: "gcp",
125
+ enabled,
126
+ match_hosts: requireNonEmptyStringArray(matchHosts, "matchHosts"),
127
+ gcp: {
128
+ service_account_json: serviceAccountJson,
129
+ scopes: requireNonEmptyStringArray(scopes, "scopes"),
130
+ },
131
+ };
47
132
  }
@@ -1,12 +1,27 @@
1
- import type { SandboxProxyConfig, SandboxProxySecret } from "./types.js";
1
+ import type { SandboxAccessControl, SandboxAwsAuthRule, SandboxGcpAuthRule, SandboxProxyConfig, SandboxProxyRule, SandboxProxySecret } from "./types.js";
2
2
  /** Reference a LangSmith workspace secret in a sandbox proxy configuration. */
3
3
  export declare function workspaceSecret(name: string): SandboxProxySecret;
4
4
  /** Provide a write-only secret value for a sandbox proxy configuration. */
5
5
  export declare function opaqueSecret(value: string): SandboxProxySecret;
6
- /** Build a sandbox proxy config that signs AWS HTTPS requests with SigV4. */
7
- export declare function awsAuthProxyConfig({ accessKeyId, secretAccessKey, name, enabled, }: {
6
+ /** Build a sandbox proxy config from one or more proxy rules. */
7
+ export declare function proxyConfig({ rules, noProxy, accessControl, }?: {
8
+ rules?: SandboxProxyRule[];
9
+ noProxy?: string[];
10
+ accessControl?: SandboxAccessControl;
11
+ }): SandboxProxyConfig;
12
+ export declare function mergeProxyConfigs(generatedConfig: SandboxProxyConfig | undefined, explicitConfig: SandboxProxyConfig | undefined): SandboxProxyConfig | undefined;
13
+ /** Build a sandbox proxy rule that signs AWS HTTPS requests with SigV4. */
14
+ export declare function awsAuth({ accessKeyId, secretAccessKey, name, enabled, }: {
8
15
  accessKeyId: SandboxProxySecret;
9
16
  secretAccessKey: SandboxProxySecret;
10
17
  name?: string;
11
18
  enabled?: boolean;
12
- }): SandboxProxyConfig;
19
+ }): SandboxAwsAuthRule;
20
+ /** Build a sandbox proxy rule that injects GCP OAuth bearer auth. */
21
+ export declare function gcpAuth({ serviceAccountJson, scopes, matchHosts, name, enabled, }: {
22
+ serviceAccountJson: SandboxProxySecret;
23
+ scopes: string[];
24
+ matchHosts?: string[];
25
+ name?: string;
26
+ enabled?: boolean;
27
+ }): SandboxGcpAuthRule;