braintrust 3.12.0 → 3.14.0
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.
- package/dev/dist/index.d.mts +31 -14
- package/dev/dist/index.d.ts +31 -14
- package/dev/dist/index.js +919 -485
- package/dev/dist/index.mjs +480 -46
- package/dist/apply-auto-instrumentation.js +204 -174
- package/dist/apply-auto-instrumentation.mjs +35 -5
- package/dist/auto-instrumentations/bundler/esbuild.cjs +226 -1
- package/dist/auto-instrumentations/bundler/esbuild.mjs +3 -2
- package/dist/auto-instrumentations/bundler/next.cjs +226 -1
- package/dist/auto-instrumentations/bundler/next.mjs +4 -3
- package/dist/auto-instrumentations/bundler/rollup.cjs +226 -1
- package/dist/auto-instrumentations/bundler/rollup.mjs +3 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +226 -1
- package/dist/auto-instrumentations/bundler/vite.mjs +3 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +9 -0
- package/dist/auto-instrumentations/bundler/webpack.cjs +226 -1
- package/dist/auto-instrumentations/bundler/webpack.mjs +4 -3
- package/dist/auto-instrumentations/{chunk-2DPA74KK.mjs → chunk-E5DUYJWK.mjs} +1 -0
- package/dist/auto-instrumentations/chunk-J57YF7WS.mjs +208 -0
- package/dist/auto-instrumentations/{chunk-AFXRW7I7.mjs → chunk-OTUQ7KH5.mjs} +1 -1
- package/dist/auto-instrumentations/chunk-QFMACSOL.mjs +280 -0
- package/dist/auto-instrumentations/{chunk-73BZUKVI.mjs → chunk-XKAAVWT6.mjs} +24 -2
- package/dist/auto-instrumentations/hook.mjs +7981 -7
- package/dist/auto-instrumentations/index.cjs +1 -0
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +194 -4
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +13 -27
- package/dist/auto-instrumentations/loader/esm-hook.mjs +24 -10
- package/dist/browser.d.mts +274 -30
- package/dist/browser.d.ts +274 -30
- package/dist/browser.js +407 -48
- package/dist/browser.mjs +407 -48
- package/dist/{chunk-BW4DF4CY.js → chunk-NKD77KGB.js} +180 -1
- package/dist/{chunk-MSLBGITU.mjs → chunk-NU2GSPHX.mjs} +180 -1
- package/dist/cli.js +494 -94
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +407 -48
- package/dist/edge-light.mjs +407 -48
- package/dist/index.d.mts +274 -30
- package/dist/index.d.ts +274 -30
- package/dist/index.js +1267 -857
- package/dist/index.mjs +465 -55
- package/dist/instrumentation/index.d.mts +47 -11
- package/dist/instrumentation/index.d.ts +47 -11
- package/dist/instrumentation/index.js +116 -26
- package/dist/instrumentation/index.mjs +116 -26
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +407 -48
- package/dist/workerd.mjs +407 -48
- package/package.json +3 -23
- package/util/dist/index.d.mts +3 -1
- package/util/dist/index.d.ts +3 -1
- package/dist/auto-instrumentations/chunk-MWZXZQUO.mjs +0 -81
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braintrust",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
4
4
|
"description": "SDK for integrating Braintrust",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -138,29 +138,16 @@
|
|
|
138
138
|
"test": "vitest run --exclude \"src/wrappers/**/*.test.ts\" --exclude \"src/otel/**/*.test.ts\" --exclude \"smoke/**/*.test.ts\" --exclude \"src/zod/**/*.test.ts\" --exclude \"tests/api-compatibility/**\"",
|
|
139
139
|
"test:core": "pnpm prune && pnpm test",
|
|
140
140
|
"test:checks": "pnpm run test:core && pnpm run test:vitest",
|
|
141
|
-
"test:
|
|
142
|
-
"test:external:sequential": "pnpm run test:external:openai && pnpm run test:external:anthropic && pnpm run test:external:google-genai",
|
|
143
|
-
"test:external:openai": "bash scripts/test-provider.sh test:openai openai",
|
|
144
|
-
"test:external:anthropic": "bash scripts/test-provider.sh test:anthropic @anthropic-ai/sdk",
|
|
145
|
-
"test:external:google-genai": "bash scripts/test-provider.sh test:google-genai @google/genai",
|
|
146
|
-
"test:external:ai-sdk": "pnpm run test:external:ai-sdk-v5 && pnpm run test:external:ai-sdk-v6",
|
|
147
|
-
"test:external:ai-sdk-v5": "cd src/wrappers/ai-sdk/tests/v5 && pnpm install --ignore-workspace && pnpm test",
|
|
148
|
-
"test:external:ai-sdk-v6": "cd src/wrappers/ai-sdk/tests/v6 && pnpm install --ignore-workspace && pnpm test",
|
|
149
|
-
"test:external:claude-agent-sdk": "cd src/wrappers/claude-agent-sdk && pnpm install && pnpm test",
|
|
150
|
-
"test:all": "pnpm run test:checks && pnpm run test:external",
|
|
141
|
+
"test:all": "pnpm run test:checks",
|
|
151
142
|
"test:api-compat": "vitest run tests/api-compatibility/api-compatibility.test.ts",
|
|
152
|
-
"test:anthropic": "vitest run src/wrappers/anthropic.test.ts",
|
|
153
|
-
"test:openai": "vitest run src/wrappers/oai.test.ts",
|
|
154
143
|
"test:otel": "vitest run --dir src/otel",
|
|
155
144
|
"test:otel-no-deps": "vitest run src/otel/otel-no-deps.test.ts --reporter=verbose",
|
|
156
|
-
"test:google-genai": "vitest run src/wrappers/google-genai.test.ts",
|
|
157
145
|
"test:ai-sdk-v1": "vitest run src/wrappers/ai-sdk-v1.test.ts",
|
|
158
146
|
"test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts",
|
|
159
147
|
"test:ai-sdk-v3": "vitest run src/wrappers/ai-sdk-v3.test.ts",
|
|
160
148
|
"test:zod-v3": "vitest run src/zod/zod-v3-serialization.test.ts",
|
|
161
149
|
"test:zod-v4": "vitest run src/zod/zod-v4-serialization.test.ts",
|
|
162
150
|
"test:mastra": "vitest run src/wrappers/mastra.test.ts",
|
|
163
|
-
"test:claude-agent-sdk": "pnpm --filter @braintrust/claude-agent-sdk-tests test",
|
|
164
151
|
"test:vitest": "pnpm --filter @braintrust/vitest-wrapper-tests test",
|
|
165
152
|
"test:output": "tsx scripts/test-output.ts --with-comparison --with-metrics --with-progress",
|
|
166
153
|
"bench": "tsx src/queue.bench.ts",
|
|
@@ -175,28 +162,22 @@
|
|
|
175
162
|
"author": "",
|
|
176
163
|
"license": "MIT",
|
|
177
164
|
"devDependencies": {
|
|
178
|
-
"@ai-sdk/anthropic": "2.0.37",
|
|
179
165
|
"@anthropic-ai/sdk": "^0.60.0",
|
|
180
|
-
"@google/adk": "^0.6.1",
|
|
181
|
-
"@google/genai": "^1.25.0",
|
|
182
166
|
"@nodelib/fs.walk": "^1.2.8",
|
|
183
167
|
"@types/argparse": "^2.0.14",
|
|
184
168
|
"@types/async": "^3.2.24",
|
|
185
169
|
"@types/cli-progress": "^3.11.5",
|
|
186
170
|
"@types/cors": "^2.8.17",
|
|
187
171
|
"@types/express": "^5.0.0",
|
|
188
|
-
"@types/graceful-fs": "^4.1.9",
|
|
189
172
|
"@types/http-errors": "^2.0.4",
|
|
190
173
|
"@types/mustache": "^4.2.5",
|
|
191
174
|
"@types/node": "^20.10.5",
|
|
192
175
|
"@types/pluralize": "^0.0.30",
|
|
193
176
|
"@types/tar": "^6.1.13",
|
|
194
|
-
"@types/uuid": "^9.0.7",
|
|
195
177
|
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
196
178
|
"@typescript-eslint/parser": "^8.49.0",
|
|
197
179
|
"ai": "^6.0.0",
|
|
198
180
|
"async": "^3.2.5",
|
|
199
|
-
"autoevals": "^0.0.131",
|
|
200
181
|
"cross-env": "^7.0.3",
|
|
201
182
|
"eslint-plugin-node-import": "^1.0.5",
|
|
202
183
|
"openai": "6.25.0",
|
|
@@ -228,7 +209,6 @@
|
|
|
228
209
|
"esbuild": "0.28.0",
|
|
229
210
|
"eventsource-parser": "^1.1.2",
|
|
230
211
|
"express": "^5.2.1",
|
|
231
|
-
"graceful-fs": "^4.2.11",
|
|
232
212
|
"http-errors": "^2.0.0",
|
|
233
213
|
"minimatch": "^10.2.5",
|
|
234
214
|
"module-details-from-path": "^1.0.4",
|
|
@@ -238,7 +218,7 @@
|
|
|
238
218
|
"source-map": "^0.7.4",
|
|
239
219
|
"termi-link": "^1.0.1",
|
|
240
220
|
"unplugin": "^2.3.5",
|
|
241
|
-
"uuid": "^
|
|
221
|
+
"uuid": "^11.1.1",
|
|
242
222
|
"zod-to-json-schema": "^3.25.0"
|
|
243
223
|
},
|
|
244
224
|
"peerDependencies": {
|
package/util/dist/index.d.mts
CHANGED
|
@@ -4842,6 +4842,7 @@ declare const ObjectReference: z.ZodObject<{
|
|
|
4842
4842
|
_xact_id?: string | null | undefined;
|
|
4843
4843
|
created?: string | null | undefined;
|
|
4844
4844
|
}>;
|
|
4845
|
+
type ObjectReferenceType = z.infer<typeof ObjectReference>;
|
|
4845
4846
|
|
|
4846
4847
|
type IdField = {
|
|
4847
4848
|
id: string;
|
|
@@ -4862,7 +4863,7 @@ type OtherExperimentLogFields = {
|
|
|
4862
4863
|
metadata: Record<string, unknown>;
|
|
4863
4864
|
metrics: Record<string, unknown>;
|
|
4864
4865
|
datasetRecordId: string;
|
|
4865
|
-
origin:
|
|
4866
|
+
origin: ObjectReferenceType;
|
|
4866
4867
|
span_attributes: Record<string, unknown>;
|
|
4867
4868
|
[ASYNC_SCORING_CONTROL_FIELD]: AsyncScoringControlType;
|
|
4868
4869
|
[MERGE_PATHS_FIELD]: string[][];
|
|
@@ -4916,6 +4917,7 @@ type DatasetEvent = {
|
|
|
4916
4917
|
tags?: string[];
|
|
4917
4918
|
metadata?: unknown;
|
|
4918
4919
|
created?: string;
|
|
4920
|
+
origin?: ObjectReferenceType;
|
|
4919
4921
|
id: string;
|
|
4920
4922
|
dataset_id: string;
|
|
4921
4923
|
} & ({
|
package/util/dist/index.d.ts
CHANGED
|
@@ -4842,6 +4842,7 @@ declare const ObjectReference: z.ZodObject<{
|
|
|
4842
4842
|
_xact_id?: string | null | undefined;
|
|
4843
4843
|
created?: string | null | undefined;
|
|
4844
4844
|
}>;
|
|
4845
|
+
type ObjectReferenceType = z.infer<typeof ObjectReference>;
|
|
4845
4846
|
|
|
4846
4847
|
type IdField = {
|
|
4847
4848
|
id: string;
|
|
@@ -4862,7 +4863,7 @@ type OtherExperimentLogFields = {
|
|
|
4862
4863
|
metadata: Record<string, unknown>;
|
|
4863
4864
|
metrics: Record<string, unknown>;
|
|
4864
4865
|
datasetRecordId: string;
|
|
4865
|
-
origin:
|
|
4866
|
+
origin: ObjectReferenceType;
|
|
4866
4867
|
span_attributes: Record<string, unknown>;
|
|
4867
4868
|
[ASYNC_SCORING_CONTROL_FIELD]: AsyncScoringControlType;
|
|
4868
4869
|
[MERGE_PATHS_FIELD]: string[][];
|
|
@@ -4916,6 +4917,7 @@ type DatasetEvent = {
|
|
|
4916
4917
|
tags?: string[];
|
|
4917
4918
|
metadata?: unknown;
|
|
4918
4919
|
created?: string;
|
|
4920
|
+
origin?: ObjectReferenceType;
|
|
4919
4921
|
id: string;
|
|
4920
4922
|
dataset_id: string;
|
|
4921
4923
|
} & ({
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// src/auto-instrumentations/loader/get-package-version.ts
|
|
2
|
-
import { readFileSync, realpathSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
var packageVersions = /* @__PURE__ */ new Map();
|
|
5
|
-
var packageNames = /* @__PURE__ */ new Map();
|
|
6
|
-
function readPackageJson(baseDir) {
|
|
7
|
-
try {
|
|
8
|
-
const packageJsonPath = join(baseDir, "package.json");
|
|
9
|
-
const jsonFile = readFileSync(packageJsonPath, "utf8");
|
|
10
|
-
return JSON.parse(jsonFile);
|
|
11
|
-
} catch {
|
|
12
|
-
return void 0;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function resolvePackageBaseDir(baseDir) {
|
|
16
|
-
try {
|
|
17
|
-
return realpathSync(baseDir);
|
|
18
|
-
} catch {
|
|
19
|
-
return baseDir;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function readPackageJsonWithFallback(baseDir) {
|
|
23
|
-
const packageJson = readPackageJson(baseDir);
|
|
24
|
-
if (packageJson) {
|
|
25
|
-
return packageJson;
|
|
26
|
-
}
|
|
27
|
-
const resolvedBaseDir = resolvePackageBaseDir(baseDir);
|
|
28
|
-
if (resolvedBaseDir === baseDir) {
|
|
29
|
-
return void 0;
|
|
30
|
-
}
|
|
31
|
-
return readPackageJson(resolvedBaseDir);
|
|
32
|
-
}
|
|
33
|
-
function getPackageVersion(baseDir) {
|
|
34
|
-
if (packageVersions.has(baseDir)) {
|
|
35
|
-
return packageVersions.get(baseDir);
|
|
36
|
-
}
|
|
37
|
-
const packageJson = readPackageJsonWithFallback(baseDir);
|
|
38
|
-
if (typeof packageJson?.version === "string") {
|
|
39
|
-
packageVersions.set(baseDir, packageJson.version);
|
|
40
|
-
return packageJson.version;
|
|
41
|
-
}
|
|
42
|
-
return process.version.slice(1);
|
|
43
|
-
}
|
|
44
|
-
function getPackageName(baseDir) {
|
|
45
|
-
if (packageNames.has(baseDir)) {
|
|
46
|
-
return packageNames.get(baseDir);
|
|
47
|
-
}
|
|
48
|
-
const packageJson = readPackageJsonWithFallback(baseDir);
|
|
49
|
-
if (typeof packageJson?.name === "string") {
|
|
50
|
-
packageNames.set(baseDir, packageJson.name);
|
|
51
|
-
return packageJson.name;
|
|
52
|
-
}
|
|
53
|
-
return void 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/auto-instrumentations/loader/openai-api-promise-patch.ts
|
|
57
|
-
var OPENAI_API_PROMISE_PATCH = `
|
|
58
|
-
;(function __btPatchAPIPromise() {
|
|
59
|
-
if (typeof APIPromise === "undefined" || APIPromise.prototype.__btParsePatched) return;
|
|
60
|
-
APIPromise.prototype.__btParsePatched = true;
|
|
61
|
-
var _origThen = APIPromise.prototype.then;
|
|
62
|
-
APIPromise.prototype.then = function __btThen(onfulfilled, onrejected) {
|
|
63
|
-
if (!this.__btParseWrapped && Object.prototype.hasOwnProperty.call(this, "parseResponse")) {
|
|
64
|
-
this.__btParseWrapped = true;
|
|
65
|
-
var _origParse = this.parseResponse;
|
|
66
|
-
var _cached;
|
|
67
|
-
this.parseResponse = function() {
|
|
68
|
-
if (!_cached) _cached = _origParse.apply(this, arguments);
|
|
69
|
-
return _cached;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return _origThen.call(this, onfulfilled, onrejected);
|
|
73
|
-
};
|
|
74
|
-
})();
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
getPackageVersion,
|
|
79
|
-
getPackageName,
|
|
80
|
-
OPENAI_API_PROMISE_PATCH
|
|
81
|
-
};
|