braintrust 3.10.0 → 3.11.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 +50 -2
- package/dev/dist/index.d.ts +50 -2
- package/dev/dist/index.js +10333 -8401
- package/dev/dist/index.mjs +6512 -4580
- package/dist/auto-instrumentations/bundler/esbuild.cjs +524 -5
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/rollup.cjs +524 -5
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +524 -5
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +475 -4
- package/dist/auto-instrumentations/bundler/webpack.cjs +524 -5
- package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
- package/dist/auto-instrumentations/{chunk-GZNXBBPU.mjs → chunk-DIV5TO4S.mjs} +520 -5
- package/dist/auto-instrumentations/{chunk-XWEQQOQH.mjs → chunk-G6ZWXGZB.mjs} +12 -2
- package/dist/auto-instrumentations/{chunk-ITP7RAUY.mjs → chunk-MWZXZQUO.mjs} +23 -1
- package/dist/auto-instrumentations/hook.mjs +543 -8
- package/dist/auto-instrumentations/index.cjs +522 -4
- package/dist/auto-instrumentations/index.d.mts +14 -1
- package/dist/auto-instrumentations/index.d.ts +14 -1
- package/dist/auto-instrumentations/index.mjs +7 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +26 -1
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +28 -1
- package/dist/auto-instrumentations/loader/esm-hook.mjs +16 -1
- package/dist/browser.d.mts +465 -264
- package/dist/browser.d.ts +465 -264
- package/dist/browser.js +10454 -8029
- package/dist/browser.mjs +10454 -8029
- package/dist/cli.js +6214 -4274
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +10454 -8029
- package/dist/edge-light.mjs +10454 -8029
- package/dist/index.d.mts +478 -277
- package/dist/index.d.ts +478 -277
- package/dist/index.js +6836 -4411
- package/dist/index.mjs +10454 -8029
- package/dist/instrumentation/index.d.mts +12 -0
- package/dist/instrumentation/index.d.ts +12 -0
- package/dist/instrumentation/index.js +6503 -4574
- package/dist/instrumentation/index.mjs +6503 -4574
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +10454 -8029
- package/dist/workerd.mjs +10454 -8029
- package/package.json +11 -17
|
@@ -93,6 +93,27 @@ function getPackageName(baseDir) {
|
|
|
93
93
|
return void 0;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// src/auto-instrumentations/loader/openai-api-promise-patch.ts
|
|
97
|
+
var OPENAI_API_PROMISE_PATCH = `
|
|
98
|
+
;(function __btPatchAPIPromise() {
|
|
99
|
+
if (typeof APIPromise === "undefined" || APIPromise.prototype.__btParsePatched) return;
|
|
100
|
+
APIPromise.prototype.__btParsePatched = true;
|
|
101
|
+
var _origThen = APIPromise.prototype.then;
|
|
102
|
+
APIPromise.prototype.then = function __btThen(onfulfilled, onrejected) {
|
|
103
|
+
if (!this.__btParseWrapped && Object.prototype.hasOwnProperty.call(this, "parseResponse")) {
|
|
104
|
+
this.__btParseWrapped = true;
|
|
105
|
+
var _origParse = this.parseResponse;
|
|
106
|
+
var _cached;
|
|
107
|
+
this.parseResponse = function() {
|
|
108
|
+
if (!_cached) _cached = _origParse.apply(this, arguments);
|
|
109
|
+
return _cached;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return _origThen.call(this, onfulfilled, onrejected);
|
|
113
|
+
};
|
|
114
|
+
})();
|
|
115
|
+
`;
|
|
116
|
+
|
|
96
117
|
// src/auto-instrumentations/loader/cjs-patch.ts
|
|
97
118
|
var ModulePatch = class {
|
|
98
119
|
packages;
|
|
@@ -124,8 +145,12 @@ var ModulePatch = class {
|
|
|
124
145
|
if (!self.packages.has(packageName)) {
|
|
125
146
|
return self.originalCompile.apply(this, args);
|
|
126
147
|
}
|
|
127
|
-
const version = getPackageVersion(resolvedModule.basedir);
|
|
128
148
|
const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
|
|
149
|
+
if (packageName === "openai" && normalizedModulePath.includes("api-promise")) {
|
|
150
|
+
args[0] = content + OPENAI_API_PROMISE_PATCH;
|
|
151
|
+
return self.originalCompile.apply(this, args);
|
|
152
|
+
}
|
|
153
|
+
const version = getPackageVersion(resolvedModule.basedir);
|
|
129
154
|
const transformer = self.instrumentator.getTransformer(
|
|
130
155
|
packageName,
|
|
131
156
|
version,
|
|
@@ -10,6 +10,29 @@ import {
|
|
|
10
10
|
import * as NodeModule from "module";
|
|
11
11
|
import { sep } from "path";
|
|
12
12
|
import moduleDetailsFromPath from "module-details-from-path";
|
|
13
|
+
|
|
14
|
+
// src/auto-instrumentations/loader/openai-api-promise-patch.ts
|
|
15
|
+
var OPENAI_API_PROMISE_PATCH = `
|
|
16
|
+
;(function __btPatchAPIPromise() {
|
|
17
|
+
if (typeof APIPromise === "undefined" || APIPromise.prototype.__btParsePatched) return;
|
|
18
|
+
APIPromise.prototype.__btParsePatched = true;
|
|
19
|
+
var _origThen = APIPromise.prototype.then;
|
|
20
|
+
APIPromise.prototype.then = function __btThen(onfulfilled, onrejected) {
|
|
21
|
+
if (!this.__btParseWrapped && Object.prototype.hasOwnProperty.call(this, "parseResponse")) {
|
|
22
|
+
this.__btParseWrapped = true;
|
|
23
|
+
var _origParse = this.parseResponse;
|
|
24
|
+
var _cached;
|
|
25
|
+
this.parseResponse = function() {
|
|
26
|
+
if (!_cached) _cached = _origParse.apply(this, arguments);
|
|
27
|
+
return _cached;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return _origThen.call(this, onfulfilled, onrejected);
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
// src/auto-instrumentations/loader/cjs-patch.ts
|
|
13
36
|
var ModulePatch = class {
|
|
14
37
|
packages;
|
|
15
38
|
instrumentator;
|
|
@@ -40,8 +63,12 @@ var ModulePatch = class {
|
|
|
40
63
|
if (!self.packages.has(packageName)) {
|
|
41
64
|
return self.originalCompile.apply(this, args);
|
|
42
65
|
}
|
|
43
|
-
const version = getPackageVersion(resolvedModule.basedir);
|
|
44
66
|
const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
|
|
67
|
+
if (packageName === "openai" && normalizedModulePath.includes("api-promise")) {
|
|
68
|
+
args[0] = content + OPENAI_API_PROMISE_PATCH;
|
|
69
|
+
return self.originalCompile.apply(this, args);
|
|
70
|
+
}
|
|
71
|
+
const version = getPackageVersion(resolvedModule.basedir);
|
|
45
72
|
const transformer = self.instrumentator.getTransformer(
|
|
46
73
|
packageName,
|
|
47
74
|
version,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
OPENAI_API_PROMISE_PATCH,
|
|
2
3
|
getPackageName,
|
|
3
4
|
getPackageVersion
|
|
4
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-MWZXZQUO.mjs";
|
|
5
6
|
|
|
6
7
|
// src/auto-instrumentations/loader/esm-hook.mts
|
|
7
8
|
import { readFile } from "fs/promises";
|
|
@@ -42,8 +43,22 @@ async function resolve(specifier, context, nextResolve) {
|
|
|
42
43
|
}
|
|
43
44
|
return url;
|
|
44
45
|
}
|
|
46
|
+
function isOpenAIApiPromise(url) {
|
|
47
|
+
return url.includes("/openai") && url.includes("api-promise");
|
|
48
|
+
}
|
|
45
49
|
async function load(url, context, nextLoad) {
|
|
46
50
|
const result = await nextLoad(url, context);
|
|
51
|
+
if (isOpenAIApiPromise(url)) {
|
|
52
|
+
if (result.format === "commonjs") {
|
|
53
|
+
const parsedUrl = new URL(result.responseURL ?? url);
|
|
54
|
+
result.source ??= await readFile(parsedUrl);
|
|
55
|
+
}
|
|
56
|
+
if (result.source) {
|
|
57
|
+
result.source = result.source.toString("utf8") + OPENAI_API_PROMISE_PATCH;
|
|
58
|
+
result.shortCircuit = true;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
47
62
|
if (!transformers.has(url)) {
|
|
48
63
|
return result;
|
|
49
64
|
}
|