langsmith 0.7.10 → 0.7.12

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 (103) hide show
  1. package/README.md +46 -15
  2. package/dist/_openapi_client/client.cjs +0 -80
  3. package/dist/_openapi_client/client.d.ts +2 -32
  4. package/dist/_openapi_client/client.js +0 -80
  5. package/dist/_openapi_client/core/pagination.cjs +2 -2
  6. package/dist/_openapi_client/core/pagination.js +2 -2
  7. package/dist/_openapi_client/internal/utils/query.cjs +1 -1
  8. package/dist/_openapi_client/internal/utils/query.js +1 -1
  9. package/dist/_openapi_client/resources/datasets/datasets.d.ts +52 -4
  10. package/dist/_openapi_client/resources/index.cjs +1 -21
  11. package/dist/_openapi_client/resources/index.d.ts +1 -11
  12. package/dist/_openapi_client/resources/index.js +0 -10
  13. package/dist/_openapi_client/resources/runs/index.cjs +9 -0
  14. package/dist/_openapi_client/resources/runs/index.d.ts +2 -0
  15. package/dist/_openapi_client/resources/runs/index.js +4 -0
  16. package/dist/_openapi_client/resources/runs/runs.cjs +54 -41
  17. package/dist/_openapi_client/resources/runs/runs.d.ts +571 -313
  18. package/dist/_openapi_client/resources/runs/runs.js +54 -41
  19. package/dist/_openapi_client/resources/runs.cjs +19 -0
  20. package/dist/_openapi_client/resources/runs.d.ts +1 -0
  21. package/dist/_openapi_client/resources/runs.js +3 -0
  22. package/dist/anonymizer/index.cjs +142 -0
  23. package/dist/anonymizer/index.d.ts +45 -0
  24. package/dist/anonymizer/index.js +140 -0
  25. package/dist/client.cjs +29 -1
  26. package/dist/client.d.ts +6 -1
  27. package/dist/client.js +28 -1
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/sandbox/client.cjs +5 -8
  32. package/dist/sandbox/client.js +5 -8
  33. package/dist/sandbox/index.cjs +2 -1
  34. package/dist/sandbox/index.d.ts +2 -2
  35. package/dist/sandbox/index.js +1 -1
  36. package/dist/sandbox/mounts.cjs +157 -18
  37. package/dist/sandbox/mounts.d.ts +10 -2
  38. package/dist/sandbox/mounts.js +155 -18
  39. package/dist/sandbox/proxy_config.cjs +19 -44
  40. package/dist/sandbox/proxy_config.d.ts +2 -4
  41. package/dist/sandbox/proxy_config.js +19 -43
  42. package/dist/sandbox/types.d.ts +56 -15
  43. package/dist/utils/constants.cjs +4 -0
  44. package/dist/utils/constants.d.ts +1 -0
  45. package/dist/utils/constants.js +1 -0
  46. package/package.json +5 -5
  47. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.cjs +0 -138
  48. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.d.ts +0 -367
  49. package/dist/_openapi_client/resources/annotation-queues/annotation-queues.js +0 -101
  50. package/dist/_openapi_client/resources/annotation-queues/runs.cjs +0 -46
  51. package/dist/_openapi_client/resources/annotation-queues/runs.d.ts +0 -128
  52. package/dist/_openapi_client/resources/annotation-queues/runs.js +0 -42
  53. package/dist/_openapi_client/resources/commits.cjs +0 -44
  54. package/dist/_openapi_client/resources/commits.d.ts +0 -204
  55. package/dist/_openapi_client/resources/commits.js +0 -40
  56. package/dist/_openapi_client/resources/evaluators.cjs +0 -15
  57. package/dist/_openapi_client/resources/evaluators.d.ts +0 -125
  58. package/dist/_openapi_client/resources/evaluators.js +0 -11
  59. package/dist/_openapi_client/resources/examples/bulk.cjs +0 -24
  60. package/dist/_openapi_client/resources/examples/bulk.d.ts +0 -78
  61. package/dist/_openapi_client/resources/examples/bulk.js +0 -20
  62. package/dist/_openapi_client/resources/examples/examples.cjs +0 -124
  63. package/dist/_openapi_client/resources/examples/examples.d.ts +0 -182
  64. package/dist/_openapi_client/resources/examples/examples.js +0 -87
  65. package/dist/_openapi_client/resources/examples/validate.cjs +0 -21
  66. package/dist/_openapi_client/resources/examples/validate.d.ts +0 -38
  67. package/dist/_openapi_client/resources/examples/validate.js +0 -17
  68. package/dist/_openapi_client/resources/feedback/configs.cjs +0 -24
  69. package/dist/_openapi_client/resources/feedback/configs.d.ts +0 -18
  70. package/dist/_openapi_client/resources/feedback/configs.js +0 -20
  71. package/dist/_openapi_client/resources/feedback/feedback.cjs +0 -98
  72. package/dist/_openapi_client/resources/feedback/feedback.d.ts +0 -275
  73. package/dist/_openapi_client/resources/feedback/feedback.js +0 -61
  74. package/dist/_openapi_client/resources/feedback/tokens.cjs +0 -35
  75. package/dist/_openapi_client/resources/feedback/tokens.d.ts +0 -130
  76. package/dist/_openapi_client/resources/feedback/tokens.js +0 -31
  77. package/dist/_openapi_client/resources/public/datasets.cjs +0 -47
  78. package/dist/_openapi_client/resources/public/datasets.d.ts +0 -152
  79. package/dist/_openapi_client/resources/public/datasets.js +0 -43
  80. package/dist/_openapi_client/resources/public/public.cjs +0 -62
  81. package/dist/_openapi_client/resources/public/public.d.ts +0 -32
  82. package/dist/_openapi_client/resources/public/public.js +0 -25
  83. package/dist/_openapi_client/resources/repos/directories.cjs +0 -40
  84. package/dist/_openapi_client/resources/repos/directories.d.ts +0 -72
  85. package/dist/_openapi_client/resources/repos/directories.js +0 -36
  86. package/dist/_openapi_client/resources/repos/repos.cjs +0 -93
  87. package/dist/_openapi_client/resources/repos/repos.d.ts +0 -188
  88. package/dist/_openapi_client/resources/repos/repos.js +0 -56
  89. package/dist/_openapi_client/resources/sandboxes/boxes.cjs +0 -86
  90. package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +0 -1121
  91. package/dist/_openapi_client/resources/sandboxes/boxes.js +0 -82
  92. package/dist/_openapi_client/resources/sandboxes/sandboxes.cjs +0 -63
  93. package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +0 -13
  94. package/dist/_openapi_client/resources/sandboxes/sandboxes.js +0 -26
  95. package/dist/_openapi_client/resources/sandboxes/snapshots.cjs +0 -39
  96. package/dist/_openapi_client/resources/sandboxes/snapshots.d.ts +0 -130
  97. package/dist/_openapi_client/resources/sandboxes/snapshots.js +0 -35
  98. package/dist/_openapi_client/resources/settings.cjs +0 -15
  99. package/dist/_openapi_client/resources/settings.d.ts +0 -18
  100. package/dist/_openapi_client/resources/settings.js +0 -11
  101. package/dist/_openapi_client/resources/workspaces.cjs +0 -35
  102. package/dist/_openapi_client/resources/workspaces.d.ts +0 -84
  103. package/dist/_openapi_client/resources/workspaces.js +0 -31
package/dist/client.js CHANGED
@@ -8,6 +8,7 @@ import { __version__ } from "./index.js";
8
8
  import { Langsmith as OpenAPILangsmith } from "./_openapi_client/index.js";
9
9
  import { assertUuid } from "./utils/_uuid.js";
10
10
  import { warnOnce } from "./utils/warn.js";
11
+ import { _MIN_BACKEND_VERSION } from "./utils/constants.js";
11
12
  import { parseHubIdentifier } from "./utils/prompts.js";
12
13
  import { raiseForStatus, isLangSmithNotFoundError, isLangSmithConflictError, } from "./utils/error.js";
13
14
  import { promptCacheSingleton, } from "./utils/prompt_cache/index.js";
@@ -122,6 +123,25 @@ function _formatFeedbackScore(score) {
122
123
  }
123
124
  return score;
124
125
  }
126
+ export function _checkBackendVersion(version, minVersion = _MIN_BACKEND_VERSION) {
127
+ const parse = (v) => v.split(".").map((s) => parseInt(s, 10));
128
+ const [maj, min, pat] = parse(version);
129
+ const [rMaj, rMin, rPat] = parse(minVersion);
130
+ if (isNaN(maj) ||
131
+ isNaN(min) ||
132
+ isNaN(pat) ||
133
+ isNaN(rMaj) ||
134
+ isNaN(rMin) ||
135
+ isNaN(rPat)) {
136
+ console.warn(`[LANGSMITH]: Could not parse backend version ${JSON.stringify(version)} for compatibility check.`);
137
+ return;
138
+ }
139
+ if (maj < rMaj ||
140
+ (maj === rMaj && min < rMin) ||
141
+ (maj === rMaj && min === rMin && pat < rPat)) {
142
+ console.warn(`[LANGSMITH]: Backend version ${JSON.stringify(version)} is older than the minimum version required by this SDK (${JSON.stringify(minVersion)}). Some features may not work as expected.`);
143
+ }
144
+ }
125
145
  export const DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES = 24 * 1024 * 1024;
126
146
  /** Default maximum memory (1GB) for queue size limits. */
127
147
  export const DEFAULT_MAX_SIZE_BYTES = 1024 * 1024 * 1024; // 1GB
@@ -909,6 +929,9 @@ export class Client {
909
929
  get onlineEvaluators() {
910
930
  return this.openAPIClient.onlineEvaluators;
911
931
  }
932
+ get runs() {
933
+ return this.openAPIClient.runs;
934
+ }
912
935
  async processInputs(inputs) {
913
936
  if (this.hideInputs === false) {
914
937
  return inputs;
@@ -1370,6 +1393,9 @@ export class Client {
1370
1393
  if (this._serverInfo === undefined) {
1371
1394
  try {
1372
1395
  this._serverInfo = await this._getServerInfo();
1396
+ if (this._serverInfo?.version) {
1397
+ _checkBackendVersion(this._serverInfo.version);
1398
+ }
1373
1399
  }
1374
1400
  catch (e) {
1375
1401
  console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${e.status ?? "Unspecified status code"} ${e.message}`);
@@ -3464,7 +3490,7 @@ export class Client {
3464
3490
  return res;
3465
3491
  });
3466
3492
  }
3467
- async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, feedbackConfig, projectId, comparativeExperimentId, sessionId, startTime, }) {
3493
+ async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, feedbackConfig, projectId, comparativeExperimentId, sessionId, startTime, extendTraceRetention, }) {
3468
3494
  if (!runId && !projectId) {
3469
3495
  throw new Error("One of runId or projectId must be provided");
3470
3496
  }
@@ -3497,6 +3523,7 @@ export class Client {
3497
3523
  feedbackConfig,
3498
3524
  session_id: sessionId ?? projectId,
3499
3525
  start_time: startTime,
3526
+ extend_trace_retention: extendTraceRetention,
3500
3527
  };
3501
3528
  const body = JSON.stringify(feedback);
3502
3529
  const url = `${this.apiUrl}/feedback`;
package/dist/index.cjs CHANGED
@@ -20,6 +20,6 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
20
20
  Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
21
21
  Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
22
22
  // Update using pnpm bump-version
23
- exports.__version__ = "0.7.10";
23
+ exports.__version__ = "0.7.12";
24
24
  // Metadata key to hide a traced run from LangSmith's Messages View.
25
25
  exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@ export { getDefaultProjectName } from "./utils/project.js";
6
6
  export { uuid7, uuid7FromTime } from "./uuid.js";
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
- export declare const __version__ = "0.7.10";
9
+ export declare const __version__ = "0.7.12";
10
10
  export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
package/dist/index.js CHANGED
@@ -6,6 +6,6 @@ export { uuid7, uuid7FromTime } from "./uuid.js";
6
6
  export { isTracingEnabled } from "./utils/guard.js";
7
7
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
8
  // Update using pnpm bump-version
9
- export const __version__ = "0.7.10";
9
+ export const __version__ = "0.7.12";
10
10
  // Metadata key to hide a traced run from LangSmith's Messages View.
11
11
  export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
@@ -10,7 +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
+ const mounts_js_1 = require("./mounts.cjs");
14
14
  const index_js_1 = require("../utils/uuid/src/index.cjs");
15
15
  /**
16
16
  * Sleep that can be interrupted by an AbortSignal.
@@ -372,9 +372,6 @@ class SandboxClient {
372
372
  if (snapshotId && snapshotName) {
373
373
  throw new errors_js_1.LangSmithValidationError("At most one of snapshotId or options.snapshotName may be set", "snapshotId");
374
374
  }
375
- if ("mounts" in resolvedOptions) {
376
- throw new errors_js_1.LangSmithValidationError("mounts is not a public createSandbox option; use mountConfig", "mounts");
377
- }
378
375
  (0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
379
376
  (0, helpers_js_1.validateTtl)(deleteAfterStopSeconds, "deleteAfterStopSeconds");
380
377
  const url = `${this._baseUrl}/boxes`;
@@ -408,12 +405,12 @@ class SandboxClient {
408
405
  if (fsCapacityBytes !== undefined) {
409
406
  payload.fs_capacity_bytes = fsCapacityBytes;
410
407
  }
411
- const effectiveProxyConfig = (0, proxy_config_js_1.mergeProxyConfigs)(mountConfig?.proxyConfig, proxyConfig);
412
408
  if (mountConfig !== undefined) {
413
- payload.mounts = mountConfig.mounts;
409
+ (0, mounts_js_1.validateMountConfigProxyConfig)(mountConfig, proxyConfig);
410
+ payload.mount_config = mountConfig;
414
411
  }
415
- if (effectiveProxyConfig !== undefined) {
416
- payload.proxy_config = effectiveProxyConfig;
412
+ if (proxyConfig !== undefined) {
413
+ payload.proxy_config = proxyConfig;
417
414
  }
418
415
  const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
419
416
  const response = await this._fetch(url, {
@@ -7,7 +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
+ import { validateMountConfigProxyConfig } from "./mounts.js";
11
11
  import { v4 as uuidv4 } from "../utils/uuid/src/index.js";
12
12
  /**
13
13
  * Sleep that can be interrupted by an AbortSignal.
@@ -369,9 +369,6 @@ export class SandboxClient {
369
369
  if (snapshotId && snapshotName) {
370
370
  throw new LangSmithValidationError("At most one of snapshotId or options.snapshotName may be set", "snapshotId");
371
371
  }
372
- if ("mounts" in resolvedOptions) {
373
- throw new LangSmithValidationError("mounts is not a public createSandbox option; use mountConfig", "mounts");
374
- }
375
372
  validateTtl(idleTtlSeconds, "idleTtlSeconds");
376
373
  validateTtl(deleteAfterStopSeconds, "deleteAfterStopSeconds");
377
374
  const url = `${this._baseUrl}/boxes`;
@@ -405,12 +402,12 @@ export class SandboxClient {
405
402
  if (fsCapacityBytes !== undefined) {
406
403
  payload.fs_capacity_bytes = fsCapacityBytes;
407
404
  }
408
- const effectiveProxyConfig = mergeProxyConfigs(mountConfig?.proxyConfig, proxyConfig);
409
405
  if (mountConfig !== undefined) {
410
- payload.mounts = mountConfig.mounts;
406
+ validateMountConfigProxyConfig(mountConfig, proxyConfig);
407
+ payload.mount_config = mountConfig;
411
408
  }
412
- if (effectiveProxyConfig !== undefined) {
413
- payload.proxy_config = effectiveProxyConfig;
409
+ if (proxyConfig !== undefined) {
410
+ payload.proxy_config = proxyConfig;
414
411
  }
415
412
  const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
416
413
  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.s3Mount = exports.mountConfig = 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.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;
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; } });
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "proxyConfig", { enumerable: true, get: function
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
47
  Object.defineProperty(exports, "gcsMount", { enumerable: true, get: function () { return mounts_js_1.gcsMount; } });
48
+ Object.defineProperty(exports, "gitMount", { enumerable: true, get: function () { return mounts_js_1.gitMount; } });
48
49
  Object.defineProperty(exports, "mountConfig", { enumerable: true, get: function () { return mounts_js_1.mountConfig; } });
49
50
  Object.defineProperty(exports, "s3Mount", { enumerable: true, get: function () { return mounts_js_1.s3Mount; } });
50
51
  // Errors
@@ -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, 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";
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";
36
36
  export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, 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, mountConfig, s3Mount } from "./mounts.js";
35
+ export { gcsMount, gitMount, mountConfig, s3Mount } from "./mounts.js";
36
36
  // Errors
37
37
  export {
38
38
  // Base and connection errors
@@ -1,15 +1,74 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.s3Mount = s3Mount;
4
+ exports.gitMount = gitMount;
4
5
  exports.gcsMount = gcsMount;
5
6
  exports.mountConfig = mountConfig;
6
- const proxy_config_js_1 = require("./proxy_config.cjs");
7
+ exports.validateMountConfigProxyConfig = validateMountConfigProxyConfig;
7
8
  function requireNonEmptyString(value, field) {
8
9
  if (typeof value !== "string" || value.trim() === "") {
9
10
  throw new Error(`${field} must be a non-empty string`);
10
11
  }
11
12
  return value.trim();
12
13
  }
14
+ function copyMountSecret(secret, field) {
15
+ if (secret === null || typeof secret !== "object" || Array.isArray(secret)) {
16
+ throw new Error(`${field} must be a sandbox secret`);
17
+ }
18
+ const candidate = secret;
19
+ if (candidate.type !== "workspace_secret" && candidate.type !== "opaque") {
20
+ throw new Error(`${field} must use workspace_secret or opaque`);
21
+ }
22
+ if (typeof candidate.value !== "string" || candidate.value.trim() === "") {
23
+ throw new Error(`${field}.value must be a non-empty string`);
24
+ }
25
+ return {
26
+ type: candidate.type,
27
+ value: candidate.value,
28
+ };
29
+ }
30
+ function requireGitRemoteUrl(remoteUrl) {
31
+ if (typeof remoteUrl !== "string" || remoteUrl === "") {
32
+ throw new Error("remoteUrl must be a non-empty string");
33
+ }
34
+ if (remoteUrl.trim() !== remoteUrl ||
35
+ /\s/u.test(remoteUrl) ||
36
+ remoteUrl.includes(String.fromCharCode(0))) {
37
+ throw new Error("remoteUrl must not contain whitespace or NUL bytes");
38
+ }
39
+ let parsed;
40
+ try {
41
+ parsed = new URL(remoteUrl);
42
+ }
43
+ catch {
44
+ throw new Error("remoteUrl must be an absolute HTTPS URL");
45
+ }
46
+ if (parsed.protocol !== "https:" || parsed.host === "") {
47
+ throw new Error("remoteUrl must be an absolute HTTPS URL");
48
+ }
49
+ if (parsed.username !== "" || parsed.password !== "") {
50
+ throw new Error("remoteUrl must not include embedded credentials");
51
+ }
52
+ if (parsed.pathname === "" || parsed.pathname === "/") {
53
+ throw new Error("remoteUrl must include a repository path");
54
+ }
55
+ if (parsed.search !== "" || parsed.hash !== "") {
56
+ throw new Error("remoteUrl must not include query or fragment");
57
+ }
58
+ return remoteUrl;
59
+ }
60
+ function copyGitRef(ref) {
61
+ if (ref === null || typeof ref !== "object" || Array.isArray(ref)) {
62
+ throw new Error("ref must be an object");
63
+ }
64
+ if (ref.type !== "branch" && ref.type !== "tag") {
65
+ throw new Error("ref.type must be branch or tag");
66
+ }
67
+ return {
68
+ type: ref.type,
69
+ name: requireNonEmptyString(ref.name, "ref.name"),
70
+ };
71
+ }
13
72
  function s3Mount({ id, mountPath, bucket, region = "us-east-1", prefix, endpointUrl = "https://s3.amazonaws.com", pathStyle = false, readOnly, cache, }) {
14
73
  const mount = {
15
74
  id: requireNonEmptyString(id, "id"),
@@ -33,6 +92,26 @@ function s3Mount({ id, mountPath, bucket, region = "us-east-1", prefix, endpoint
33
92
  }
34
93
  return mount;
35
94
  }
95
+ function gitMount({ id, mountPath, remoteUrl, ref, refreshIntervalSeconds, }) {
96
+ const mount = {
97
+ id: requireNonEmptyString(id, "id"),
98
+ type: "git",
99
+ mount_path: requireNonEmptyString(mountPath, "mountPath"),
100
+ git: {
101
+ remote_url: requireGitRemoteUrl(remoteUrl),
102
+ },
103
+ };
104
+ if (ref !== undefined) {
105
+ mount.git.ref = copyGitRef(ref);
106
+ }
107
+ if (refreshIntervalSeconds !== undefined) {
108
+ if (refreshIntervalSeconds < 1) {
109
+ throw new Error("refreshIntervalSeconds must be at least 1");
110
+ }
111
+ mount.git.refresh_interval_seconds = refreshIntervalSeconds;
112
+ }
113
+ return mount;
114
+ }
36
115
  function gcsMount({ id, mountPath, bucket, prefix, readOnly, cache, }) {
37
116
  const mount = {
38
117
  id: requireNonEmptyString(id, "id"),
@@ -61,35 +140,80 @@ function normalizeMounts(mounts) {
61
140
  if (mount === null || typeof mount !== "object" || Array.isArray(mount)) {
62
141
  throw new Error("mounts must be a non-empty array of mount objects");
63
142
  }
64
- if (mount.type !== "s3" && mount.type !== "gcs") {
65
- throw new Error("mountConfig only supports s3 and gcs mounts");
143
+ if (mount.type !== "s3" && mount.type !== "gcs" && mount.type !== "git") {
144
+ throw new Error("mountConfig only supports s3, gcs, and git mounts");
66
145
  }
146
+ rejectProviderCredentialsInMount(mount);
67
147
  return mount;
68
148
  });
69
149
  }
70
- function normalizeAuthRules(auth) {
150
+ const FORBIDDEN_MOUNT_CREDENTIAL_FIELDS = new Set([
151
+ "access_key_id",
152
+ "secret_access_key",
153
+ "session_token",
154
+ "service_account_json",
155
+ "access_token",
156
+ "refresh_token",
157
+ "credentials",
158
+ "credential",
159
+ ]);
160
+ function rejectProviderCredentialsInMount(value) {
161
+ if (Array.isArray(value)) {
162
+ for (const child of value) {
163
+ rejectProviderCredentialsInMount(child);
164
+ }
165
+ return;
166
+ }
167
+ if (value !== null && typeof value === "object") {
168
+ for (const [key, child] of Object.entries(value)) {
169
+ if (FORBIDDEN_MOUNT_CREDENTIAL_FIELDS.has(key)) {
170
+ throw new Error("provider credentials must be supplied in mountConfig.auth, not individual mount specs");
171
+ }
172
+ rejectProviderCredentialsInMount(child);
173
+ }
174
+ }
175
+ }
176
+ function normalizeMountAuth(auth) {
71
177
  if (!Array.isArray(auth)) {
72
- throw new Error("auth must be an array of provider auth rules");
178
+ throw new Error("auth must be an array of provider auth blocks");
73
179
  }
74
180
  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");
181
+ for (const block of auth) {
182
+ if (block === null || typeof block !== "object" || Array.isArray(block)) {
183
+ throw new Error("auth must be an array of provider auth blocks");
78
184
  }
79
- const provider = rule.type;
185
+ const provider = block.type;
80
186
  if (provider !== "aws" && provider !== "gcp") {
81
- throw new Error("mountConfig auth only supports aws and gcp rules");
187
+ throw new Error("mountConfig auth only supports aws and gcp blocks");
82
188
  }
83
189
  if (byProvider[provider] !== undefined) {
84
190
  throw new Error(`duplicate ${provider} auth rule in mountConfig`);
85
191
  }
86
- byProvider[provider] = rule;
192
+ if (provider === "aws") {
193
+ const aws = block.aws;
194
+ if (aws === undefined) {
195
+ throw new Error("aws mount auth must include an aws block");
196
+ }
197
+ byProvider.aws = {
198
+ access_key_id: copyMountSecret(aws.access_key_id, "accessKeyId"),
199
+ secret_access_key: copyMountSecret(aws.secret_access_key, "secretAccessKey"),
200
+ };
201
+ }
202
+ else {
203
+ const gcp = block.gcp;
204
+ if (gcp === undefined) {
205
+ throw new Error("gcp mount auth must include a gcp block");
206
+ }
207
+ byProvider.gcp = {
208
+ service_account_json: copyMountSecret(gcp.service_account_json, "serviceAccountJson"),
209
+ };
210
+ }
87
211
  }
88
212
  return byProvider;
89
213
  }
90
- function mountConfig({ auth, mounts, }) {
214
+ function mountConfig({ auth = [], mounts, }) {
91
215
  const normalizedMounts = normalizeMounts(mounts);
92
- const authByProvider = normalizeAuthRules(auth);
216
+ const authByProvider = normalizeMountAuth(auth);
93
217
  const mountProviders = new Set(normalizedMounts.map((mount) => mount.type));
94
218
  if (mountProviders.has("s3") && authByProvider.aws === undefined) {
95
219
  throw new Error("s3 mounts require aws auth in mountConfig");
@@ -104,11 +228,26 @@ function mountConfig({ auth, mounts, }) {
104
228
  throw new Error("gcp auth requires at least one gcs mount in mountConfig");
105
229
  }
106
230
  return {
231
+ auth: authByProvider,
107
232
  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
233
  };
114
234
  }
235
+ function validateMountConfigProxyConfig(mountConfig, proxyConfig) {
236
+ if (proxyConfig === undefined) {
237
+ return;
238
+ }
239
+ const rules = proxyConfig.rules ?? [];
240
+ if (!Array.isArray(rules)) {
241
+ throw new Error("proxyConfig rules must be an array");
242
+ }
243
+ for (const rule of rules) {
244
+ if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
245
+ continue;
246
+ }
247
+ const ruleType = rule.type;
248
+ if ((ruleType === "aws" || ruleType === "gcp") &&
249
+ mountConfig.auth[ruleType] !== undefined) {
250
+ throw new Error(`${ruleType} auth cannot be provided in both mountConfig and proxyConfig`);
251
+ }
252
+ }
253
+ }
@@ -1,4 +1,4 @@
1
- import type { GCSMountSpec, MountCacheConfig, S3MountSpec, SandboxMount, SandboxMountConfig, SandboxProxyRule } from "./types.js";
1
+ import type { GCSMountSpec, GitMountRefSpec, GitMountSpec, MountCacheConfig, S3MountSpec, SandboxMount, SandboxMountAuth, SandboxMountConfig, SandboxProxyConfig } from "./types.js";
2
2
  export declare function s3Mount({ id, mountPath, bucket, region, prefix, endpointUrl, pathStyle, readOnly, cache, }: {
3
3
  id: string;
4
4
  mountPath: string;
@@ -10,6 +10,13 @@ export declare function s3Mount({ id, mountPath, bucket, region, prefix, endpoin
10
10
  readOnly?: boolean;
11
11
  cache?: MountCacheConfig;
12
12
  }): S3MountSpec;
13
+ export declare function gitMount({ id, mountPath, remoteUrl, ref, refreshIntervalSeconds, }: {
14
+ id: string;
15
+ mountPath: string;
16
+ remoteUrl: string;
17
+ ref?: GitMountRefSpec;
18
+ refreshIntervalSeconds?: number;
19
+ }): GitMountSpec;
13
20
  export declare function gcsMount({ id, mountPath, bucket, prefix, readOnly, cache, }: {
14
21
  id: string;
15
22
  mountPath: string;
@@ -19,6 +26,7 @@ export declare function gcsMount({ id, mountPath, bucket, prefix, readOnly, cach
19
26
  cache?: MountCacheConfig;
20
27
  }): GCSMountSpec;
21
28
  export declare function mountConfig({ auth, mounts, }: {
22
- auth: SandboxProxyRule[];
29
+ auth?: SandboxMountAuth[];
23
30
  mounts: SandboxMount[];
24
31
  }): SandboxMountConfig;
32
+ export declare function validateMountConfigProxyConfig(mountConfig: SandboxMountConfig, proxyConfig: SandboxProxyConfig | undefined): void;