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
@@ -0,0 +1,130 @@
1
+ import { ReadableStreamFrom } from './shims.js';
2
+ export const checkFileSupport = () => {
3
+ if (typeof File === 'undefined') {
4
+ const { process } = globalThis;
5
+ const isOldNode = typeof process?.versions?.node === 'string' && parseInt(process.versions.node.split('.')) < 20;
6
+ throw new Error('`File` is not defined as a global, which is required for file uploads.' +
7
+ (isOldNode ?
8
+ " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`."
9
+ : ''));
10
+ }
11
+ };
12
+ /**
13
+ * Construct a `File` instance. This is used to ensure a helpful error is thrown
14
+ * for environments that don't define a global `File` yet.
15
+ */
16
+ export function makeFile(fileBits, fileName, options) {
17
+ checkFileSupport();
18
+ return new File(fileBits, fileName ?? 'unknown_file', options);
19
+ }
20
+ export function getName(value) {
21
+ return (((typeof value === 'object' &&
22
+ value !== null &&
23
+ (('name' in value && value.name && String(value.name)) ||
24
+ ('url' in value && value.url && String(value.url)) ||
25
+ ('filename' in value && value.filename && String(value.filename)) ||
26
+ ('path' in value && value.path && String(value.path)))) ||
27
+ '')
28
+ .split(/[\\/]/)
29
+ .pop() || undefined);
30
+ }
31
+ export const isAsyncIterable = (value) => value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
32
+ /**
33
+ * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
34
+ * Otherwise returns the request as is.
35
+ */
36
+ export const maybeMultipartFormRequestOptions = async (opts, fetch) => {
37
+ if (!hasUploadableValue(opts.body))
38
+ return opts;
39
+ return { ...opts, body: await createForm(opts.body, fetch) };
40
+ };
41
+ export const multipartFormRequestOptions = async (opts, fetch) => {
42
+ return { ...opts, body: await createForm(opts.body, fetch) };
43
+ };
44
+ const supportsFormDataMap = /* @__PURE__ */ new WeakMap();
45
+ /**
46
+ * node-fetch doesn't support the global FormData object in recent node versions. Instead of sending
47
+ * properly-encoded form data, it just stringifies the object, resulting in a request body of "[object FormData]".
48
+ * This function detects if the fetch function provided supports the global FormData object to avoid
49
+ * confusing error messages later on.
50
+ */
51
+ function supportsFormData(fetchObject) {
52
+ const fetch = typeof fetchObject === 'function' ? fetchObject : fetchObject.fetch;
53
+ const cached = supportsFormDataMap.get(fetch);
54
+ if (cached)
55
+ return cached;
56
+ const promise = (async () => {
57
+ try {
58
+ const FetchResponse = ('Response' in fetch ?
59
+ fetch.Response
60
+ : (await fetch('data:,')).constructor);
61
+ const data = new FormData();
62
+ if (data.toString() === (await new FetchResponse(data).text())) {
63
+ return false;
64
+ }
65
+ return true;
66
+ }
67
+ catch {
68
+ // avoid false negatives
69
+ return true;
70
+ }
71
+ })();
72
+ supportsFormDataMap.set(fetch, promise);
73
+ return promise;
74
+ }
75
+ export const createForm = async (body, fetch) => {
76
+ if (!(await supportsFormData(fetch))) {
77
+ throw new TypeError('The provided fetch function does not support file uploads with the current global FormData class.');
78
+ }
79
+ const form = new FormData();
80
+ await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
81
+ return form;
82
+ };
83
+ // We check for Blob not File because Bun.File doesn't inherit from File,
84
+ // but they both inherit from Blob and have a `name` property at runtime.
85
+ const isNamedBlob = (value) => value instanceof Blob && 'name' in value;
86
+ const isUploadable = (value) => typeof value === 'object' &&
87
+ value !== null &&
88
+ (value instanceof Response || isAsyncIterable(value) || isNamedBlob(value));
89
+ const hasUploadableValue = (value) => {
90
+ if (isUploadable(value))
91
+ return true;
92
+ if (Array.isArray(value))
93
+ return value.some(hasUploadableValue);
94
+ if (value && typeof value === 'object') {
95
+ for (const k in value) {
96
+ if (hasUploadableValue(value[k]))
97
+ return true;
98
+ }
99
+ }
100
+ return false;
101
+ };
102
+ const addFormValue = async (form, key, value) => {
103
+ if (value === undefined)
104
+ return;
105
+ if (value == null) {
106
+ throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
107
+ }
108
+ // TODO: make nested formats configurable
109
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
110
+ form.append(key, String(value));
111
+ }
112
+ else if (value instanceof Response) {
113
+ form.append(key, makeFile([await value.blob()], getName(value)));
114
+ }
115
+ else if (isAsyncIterable(value)) {
116
+ form.append(key, makeFile([await new Response(ReadableStreamFrom(value)).blob()], getName(value)));
117
+ }
118
+ else if (isNamedBlob(value)) {
119
+ form.append(key, value, getName(value));
120
+ }
121
+ else if (Array.isArray(value)) {
122
+ await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
123
+ }
124
+ else if (typeof value === 'object') {
125
+ await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
126
+ }
127
+ else {
128
+ throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
129
+ }
130
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.readEnv = void 0;
6
+ /**
7
+ * Read an environment variable.
8
+ *
9
+ * Trims beginning and trailing whitespace.
10
+ *
11
+ * Will return undefined if the environment variable doesn't exist or cannot be accessed.
12
+ */
13
+ const readEnv = (env) => {
14
+ if (typeof globalThis.process !== 'undefined') {
15
+ return globalThis.process.env?.[env]?.trim() || undefined;
16
+ }
17
+ if (typeof globalThis.Deno !== 'undefined') {
18
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
19
+ }
20
+ return undefined;
21
+ };
22
+ exports.readEnv = readEnv;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Read an environment variable.
3
+ *
4
+ * Trims beginning and trailing whitespace.
5
+ *
6
+ * Will return undefined if the environment variable doesn't exist or cannot be accessed.
7
+ */
8
+ export declare const readEnv: (env: string) => string | undefined;
@@ -0,0 +1,18 @@
1
+ // @ts-nocheck
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ /**
4
+ * Read an environment variable.
5
+ *
6
+ * Trims beginning and trailing whitespace.
7
+ *
8
+ * Will return undefined if the environment variable doesn't exist or cannot be accessed.
9
+ */
10
+ export const readEnv = (env) => {
11
+ if (typeof globalThis.process !== 'undefined') {
12
+ return globalThis.process.env?.[env]?.trim() || undefined;
13
+ }
14
+ if (typeof globalThis.Deno !== 'undefined') {
15
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
16
+ }
17
+ return undefined;
18
+ };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.formatRequestDetails = exports.parseLogLevel = void 0;
6
+ exports.loggerFor = loggerFor;
7
+ const values_js_1 = require("./values.cjs");
8
+ const levelNumbers = {
9
+ off: 0,
10
+ error: 200,
11
+ warn: 300,
12
+ info: 400,
13
+ debug: 500,
14
+ };
15
+ const parseLogLevel = (maybeLevel, sourceName, client) => {
16
+ if (!maybeLevel) {
17
+ return undefined;
18
+ }
19
+ if ((0, values_js_1.hasOwn)(levelNumbers, maybeLevel)) {
20
+ return maybeLevel;
21
+ }
22
+ loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`);
23
+ return undefined;
24
+ };
25
+ exports.parseLogLevel = parseLogLevel;
26
+ function noop() { }
27
+ function makeLogFn(fnLevel, logger, logLevel) {
28
+ if (!logger || levelNumbers[fnLevel] > levelNumbers[logLevel]) {
29
+ return noop;
30
+ }
31
+ else {
32
+ // Don't wrap logger functions, we want the stacktrace intact!
33
+ return logger[fnLevel].bind(logger);
34
+ }
35
+ }
36
+ const noopLogger = {
37
+ error: noop,
38
+ warn: noop,
39
+ info: noop,
40
+ debug: noop,
41
+ };
42
+ let cachedLoggers = /* @__PURE__ */ new WeakMap();
43
+ function loggerFor(client) {
44
+ const logger = client.logger;
45
+ const logLevel = client.logLevel ?? 'off';
46
+ if (!logger) {
47
+ return noopLogger;
48
+ }
49
+ const cachedLogger = cachedLoggers.get(logger);
50
+ if (cachedLogger && cachedLogger[0] === logLevel) {
51
+ return cachedLogger[1];
52
+ }
53
+ const levelLogger = {
54
+ error: makeLogFn('error', logger, logLevel),
55
+ warn: makeLogFn('warn', logger, logLevel),
56
+ info: makeLogFn('info', logger, logLevel),
57
+ debug: makeLogFn('debug', logger, logLevel),
58
+ };
59
+ cachedLoggers.set(logger, [logLevel, levelLogger]);
60
+ return levelLogger;
61
+ }
62
+ const formatRequestDetails = (details) => {
63
+ if (details.options) {
64
+ details.options = { ...details.options };
65
+ delete details.options['headers']; // redundant + leaks internals
66
+ }
67
+ if (details.headers) {
68
+ details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
69
+ name,
70
+ (name.toLowerCase() === 'authorization' ||
71
+ name.toLowerCase() === 'api-key' ||
72
+ name.toLowerCase() === 'x-api-key' ||
73
+ name.toLowerCase() === 'cookie' ||
74
+ name.toLowerCase() === 'set-cookie' ||
75
+ name.toLowerCase() === 'x-tenant-id') ?
76
+ '***'
77
+ : value,
78
+ ]));
79
+ }
80
+ if ('retryOfRequestLogID' in details) {
81
+ if (details.retryOfRequestLogID) {
82
+ details.retryOf = details.retryOfRequestLogID;
83
+ }
84
+ delete details.retryOfRequestLogID;
85
+ }
86
+ return details;
87
+ };
88
+ exports.formatRequestDetails = formatRequestDetails;
@@ -0,0 +1,36 @@
1
+ import { type Langsmith } from '../../client.js';
2
+ import { RequestOptions } from '../request-options.js';
3
+ type LogFn = (message: string, ...rest: unknown[]) => void;
4
+ export type Logger = {
5
+ error: LogFn;
6
+ warn: LogFn;
7
+ info: LogFn;
8
+ debug: LogFn;
9
+ };
10
+ export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
11
+ export declare const parseLogLevel: (maybeLevel: string | undefined, sourceName: string, client: Langsmith) => LogLevel | undefined;
12
+ export declare function loggerFor(client: Langsmith): Logger;
13
+ export declare const formatRequestDetails: (details: {
14
+ options?: RequestOptions | undefined;
15
+ headers?: Headers | Record<string, string> | undefined;
16
+ retryOfRequestLogID?: string | undefined;
17
+ retryOf?: string | undefined;
18
+ url?: string | undefined;
19
+ status?: number | undefined;
20
+ method?: string | undefined;
21
+ durationMs?: number | undefined;
22
+ message?: unknown;
23
+ body?: unknown;
24
+ }) => {
25
+ options?: RequestOptions | undefined;
26
+ headers?: Headers | Record<string, string> | undefined;
27
+ retryOfRequestLogID?: string | undefined;
28
+ retryOf?: string | undefined;
29
+ url?: string | undefined;
30
+ status?: number | undefined;
31
+ method?: string | undefined;
32
+ durationMs?: number | undefined;
33
+ message?: unknown;
34
+ body?: unknown;
35
+ };
36
+ export {};
@@ -0,0 +1,82 @@
1
+ // @ts-nocheck
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ import { hasOwn } from './values.js';
4
+ const levelNumbers = {
5
+ off: 0,
6
+ error: 200,
7
+ warn: 300,
8
+ info: 400,
9
+ debug: 500,
10
+ };
11
+ export const parseLogLevel = (maybeLevel, sourceName, client) => {
12
+ if (!maybeLevel) {
13
+ return undefined;
14
+ }
15
+ if (hasOwn(levelNumbers, maybeLevel)) {
16
+ return maybeLevel;
17
+ }
18
+ loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`);
19
+ return undefined;
20
+ };
21
+ function noop() { }
22
+ function makeLogFn(fnLevel, logger, logLevel) {
23
+ if (!logger || levelNumbers[fnLevel] > levelNumbers[logLevel]) {
24
+ return noop;
25
+ }
26
+ else {
27
+ // Don't wrap logger functions, we want the stacktrace intact!
28
+ return logger[fnLevel].bind(logger);
29
+ }
30
+ }
31
+ const noopLogger = {
32
+ error: noop,
33
+ warn: noop,
34
+ info: noop,
35
+ debug: noop,
36
+ };
37
+ let cachedLoggers = /* @__PURE__ */ new WeakMap();
38
+ export function loggerFor(client) {
39
+ const logger = client.logger;
40
+ const logLevel = client.logLevel ?? 'off';
41
+ if (!logger) {
42
+ return noopLogger;
43
+ }
44
+ const cachedLogger = cachedLoggers.get(logger);
45
+ if (cachedLogger && cachedLogger[0] === logLevel) {
46
+ return cachedLogger[1];
47
+ }
48
+ const levelLogger = {
49
+ error: makeLogFn('error', logger, logLevel),
50
+ warn: makeLogFn('warn', logger, logLevel),
51
+ info: makeLogFn('info', logger, logLevel),
52
+ debug: makeLogFn('debug', logger, logLevel),
53
+ };
54
+ cachedLoggers.set(logger, [logLevel, levelLogger]);
55
+ return levelLogger;
56
+ }
57
+ export const formatRequestDetails = (details) => {
58
+ if (details.options) {
59
+ details.options = { ...details.options };
60
+ delete details.options['headers']; // redundant + leaks internals
61
+ }
62
+ if (details.headers) {
63
+ details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
64
+ name,
65
+ (name.toLowerCase() === 'authorization' ||
66
+ name.toLowerCase() === 'api-key' ||
67
+ name.toLowerCase() === 'x-api-key' ||
68
+ name.toLowerCase() === 'cookie' ||
69
+ name.toLowerCase() === 'set-cookie' ||
70
+ name.toLowerCase() === 'x-tenant-id') ?
71
+ '***'
72
+ : value,
73
+ ]));
74
+ }
75
+ if ('retryOfRequestLogID' in details) {
76
+ if (details.retryOfRequestLogID) {
77
+ details.retryOf = details.retryOfRequestLogID;
78
+ }
79
+ delete details.retryOfRequestLogID;
80
+ }
81
+ return details;
82
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.path = exports.createPathTagFunction = void 0;
4
+ exports.encodeURIPath = encodeURIPath;
5
+ // @ts-nocheck
6
+ const error_js_1 = require("../../core/error.cjs");
7
+ /**
8
+ * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
9
+ *
10
+ * Taken from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3:
11
+ * > unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
12
+ * > sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
13
+ * > pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
14
+ */
15
+ function encodeURIPath(str) {
16
+ return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
17
+ }
18
+ const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
19
+ const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(statics, ...params) {
20
+ // If there are no params, no processing is needed.
21
+ if (statics.length === 1)
22
+ return statics[0];
23
+ let postPath = false;
24
+ const invalidSegments = [];
25
+ const path = statics.reduce((previousValue, currentValue, index) => {
26
+ if (/[?#]/.test(currentValue)) {
27
+ postPath = true;
28
+ }
29
+ const value = params[index];
30
+ let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
31
+ if (index !== params.length &&
32
+ (value == null ||
33
+ (typeof value === 'object' &&
34
+ // handle values from other realms
35
+ value.toString ===
36
+ Object.getPrototypeOf(Object.getPrototypeOf(value.hasOwnProperty ?? EMPTY) ?? EMPTY)
37
+ ?.toString))) {
38
+ encoded = value + '';
39
+ invalidSegments.push({
40
+ start: previousValue.length + currentValue.length,
41
+ length: encoded.length,
42
+ error: `Value of type ${Object.prototype.toString
43
+ .call(value)
44
+ .slice(8, -1)} is not a valid path parameter`,
45
+ });
46
+ }
47
+ return previousValue + currentValue + (index === params.length ? '' : encoded);
48
+ }, '');
49
+ const pathOnly = path.split(/[?#]/, 1)[0];
50
+ const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
51
+ let match;
52
+ // Find all invalid segments
53
+ while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
54
+ invalidSegments.push({
55
+ start: match.index,
56
+ length: match[0].length,
57
+ error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
58
+ });
59
+ }
60
+ invalidSegments.sort((a, b) => a.start - b.start);
61
+ if (invalidSegments.length > 0) {
62
+ let lastEnd = 0;
63
+ const underline = invalidSegments.reduce((acc, segment) => {
64
+ const spaces = ' '.repeat(segment.start - lastEnd);
65
+ const arrows = '^'.repeat(segment.length);
66
+ lastEnd = segment.start + segment.length;
67
+ return acc + spaces + arrows;
68
+ }, '');
69
+ throw new error_js_1.LangsmithError(`Path parameters result in path with invalid segments:\n${invalidSegments
70
+ .map((e) => e.error)
71
+ .join('\n')}\n${path}\n${underline}`);
72
+ }
73
+ return path;
74
+ };
75
+ exports.createPathTagFunction = createPathTagFunction;
76
+ /**
77
+ * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
78
+ */
79
+ exports.path = (0, exports.createPathTagFunction)(encodeURIPath);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
3
+ *
4
+ * Taken from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3:
5
+ * > unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
6
+ * > sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
7
+ * > pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
8
+ */
9
+ export declare function encodeURIPath(str: string): string;
10
+ export declare const createPathTagFunction: (pathEncoder?: typeof encodeURIPath) => (statics: readonly string[], ...params: readonly unknown[]) => string;
11
+ /**
12
+ * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
13
+ */
14
+ export declare const path: (statics: readonly string[], ...params: readonly unknown[]) => string;
@@ -0,0 +1,74 @@
1
+ // @ts-nocheck
2
+ import { LangsmithError } from '../../core/error.js';
3
+ /**
4
+ * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
5
+ *
6
+ * Taken from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3:
7
+ * > unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
8
+ * > sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
9
+ * > pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
10
+ */
11
+ export function encodeURIPath(str) {
12
+ return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
13
+ }
14
+ const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
15
+ export const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(statics, ...params) {
16
+ // If there are no params, no processing is needed.
17
+ if (statics.length === 1)
18
+ return statics[0];
19
+ let postPath = false;
20
+ const invalidSegments = [];
21
+ const path = statics.reduce((previousValue, currentValue, index) => {
22
+ if (/[?#]/.test(currentValue)) {
23
+ postPath = true;
24
+ }
25
+ const value = params[index];
26
+ let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
27
+ if (index !== params.length &&
28
+ (value == null ||
29
+ (typeof value === 'object' &&
30
+ // handle values from other realms
31
+ value.toString ===
32
+ Object.getPrototypeOf(Object.getPrototypeOf(value.hasOwnProperty ?? EMPTY) ?? EMPTY)
33
+ ?.toString))) {
34
+ encoded = value + '';
35
+ invalidSegments.push({
36
+ start: previousValue.length + currentValue.length,
37
+ length: encoded.length,
38
+ error: `Value of type ${Object.prototype.toString
39
+ .call(value)
40
+ .slice(8, -1)} is not a valid path parameter`,
41
+ });
42
+ }
43
+ return previousValue + currentValue + (index === params.length ? '' : encoded);
44
+ }, '');
45
+ const pathOnly = path.split(/[?#]/, 1)[0];
46
+ const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
47
+ let match;
48
+ // Find all invalid segments
49
+ while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
50
+ invalidSegments.push({
51
+ start: match.index,
52
+ length: match[0].length,
53
+ error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
54
+ });
55
+ }
56
+ invalidSegments.sort((a, b) => a.start - b.start);
57
+ if (invalidSegments.length > 0) {
58
+ let lastEnd = 0;
59
+ const underline = invalidSegments.reduce((acc, segment) => {
60
+ const spaces = ' '.repeat(segment.start - lastEnd);
61
+ const arrows = '^'.repeat(segment.length);
62
+ lastEnd = segment.start + segment.length;
63
+ return acc + spaces + arrows;
64
+ }, '');
65
+ throw new LangsmithError(`Path parameters result in path with invalid segments:\n${invalidSegments
66
+ .map((e) => e.error)
67
+ .join('\n')}\n${path}\n${underline}`);
68
+ }
69
+ return path;
70
+ };
71
+ /**
72
+ * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
73
+ */
74
+ export const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.stringifyQuery = stringifyQuery;
39
+ const qs = __importStar(require("../qs/stringify.cjs"));
40
+ function stringifyQuery(query) {
41
+ return qs.stringify(query, { arrayFormat: 'comma' });
42
+ }
@@ -0,0 +1 @@
1
+ export declare function stringifyQuery(query: object | Record<string, unknown>): string;
@@ -0,0 +1,6 @@
1
+ // @ts-nocheck
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ import * as qs from '../qs/stringify.js';
4
+ export function stringifyQuery(query) {
5
+ return qs.stringify(query, { arrayFormat: 'comma' });
6
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.sleep = void 0;
6
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7
+ exports.sleep = sleep;
@@ -0,0 +1 @@
1
+ export declare const sleep: (ms: number) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ // @ts-nocheck
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.uuid4 = void 0;
6
+ /**
7
+ * https://stackoverflow.com/a/2117523
8
+ */
9
+ let uuid4 = function () {
10
+ const { crypto } = globalThis;
11
+ if (crypto?.randomUUID) {
12
+ exports.uuid4 = crypto.randomUUID.bind(crypto);
13
+ return crypto.randomUUID();
14
+ }
15
+ const u8 = new Uint8Array(1);
16
+ const randomByte = crypto ? () => crypto.getRandomValues(u8)[0] : () => (Math.random() * 0xff) & 0xff;
17
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16));
18
+ };
19
+ exports.uuid4 = uuid4;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * https://stackoverflow.com/a/2117523
3
+ */
4
+ export declare let uuid4: () => any;