braintrust 3.1.0 → 3.2.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/README.md +73 -0
- package/dev/dist/index.d.mts +187 -903
- package/dev/dist/index.d.ts +187 -903
- package/dev/dist/index.js +2942 -323
- package/dev/dist/index.mjs +2704 -85
- package/dist/auto-instrumentations/bundler/esbuild.cjs +401 -0
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +8 -0
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +8 -0
- package/dist/auto-instrumentations/bundler/esbuild.mjs +10 -0
- package/dist/auto-instrumentations/bundler/rollup.cjs +401 -0
- package/dist/auto-instrumentations/bundler/rollup.d.mts +8 -0
- package/dist/auto-instrumentations/bundler/rollup.d.ts +8 -0
- package/dist/auto-instrumentations/bundler/rollup.mjs +10 -0
- package/dist/auto-instrumentations/bundler/vite.cjs +401 -0
- package/dist/auto-instrumentations/bundler/vite.d.mts +8 -0
- package/dist/auto-instrumentations/bundler/vite.d.ts +8 -0
- package/dist/auto-instrumentations/bundler/vite.mjs +10 -0
- package/dist/auto-instrumentations/bundler/webpack.cjs +401 -0
- package/dist/auto-instrumentations/bundler/webpack.d.mts +8 -0
- package/dist/auto-instrumentations/bundler/webpack.d.ts +8 -0
- package/dist/auto-instrumentations/bundler/webpack.mjs +10 -0
- package/dist/auto-instrumentations/chunk-KVX7OFPD.mjs +288 -0
- package/dist/auto-instrumentations/chunk-OLOPGWTJ.mjs +89 -0
- package/dist/auto-instrumentations/chunk-XDBPUTVE.mjs +22 -0
- package/dist/auto-instrumentations/chunk-ZEC7BCL4.mjs +22 -0
- package/dist/auto-instrumentations/hook.mjs +378 -0
- package/dist/auto-instrumentations/index.cjs +318 -0
- package/dist/auto-instrumentations/index.d.mts +69 -0
- package/dist/auto-instrumentations/index.d.ts +69 -0
- package/dist/auto-instrumentations/index.mjs +14 -0
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +116 -0
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +28 -0
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +28 -0
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +66 -0
- package/dist/auto-instrumentations/loader/esm-hook.mjs +72 -0
- package/dist/auto-instrumentations/loader/get-package-version.cjs +46 -0
- package/dist/auto-instrumentations/loader/get-package-version.d.mts +7 -0
- package/dist/auto-instrumentations/loader/get-package-version.d.ts +7 -0
- package/dist/auto-instrumentations/loader/get-package-version.mjs +6 -0
- package/dist/auto-instrumentations/plugin-Df3qKIl2.d.mts +22 -0
- package/dist/auto-instrumentations/plugin-Df3qKIl2.d.ts +22 -0
- package/dist/browser.d.mts +484 -980
- package/dist/browser.d.ts +484 -980
- package/dist/browser.js +3437 -386
- package/dist/browser.mjs +3437 -386
- package/dist/cli.js +2890 -228
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +3134 -86
- package/dist/edge-light.mjs +3134 -86
- package/dist/index.d.mts +484 -980
- package/dist/index.d.ts +484 -980
- package/dist/index.js +3754 -703
- package/dist/index.mjs +3615 -564
- package/dist/instrumentation/index.d.mts +323 -0
- package/dist/instrumentation/index.d.ts +323 -0
- package/dist/instrumentation/index.js +9942 -0
- package/dist/instrumentation/index.mjs +9902 -0
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +3134 -86
- package/dist/workerd.mjs +3134 -86
- package/package.json +46 -7
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPackageVersion
|
|
3
|
+
} from "./chunk-ZEC7BCL4.mjs";
|
|
4
|
+
|
|
5
|
+
// src/auto-instrumentations/hook.mts
|
|
6
|
+
import { register } from "node:module";
|
|
7
|
+
|
|
8
|
+
// src/auto-instrumentations/configs/openai.ts
|
|
9
|
+
var openaiConfigs = [
|
|
10
|
+
// Chat Completions
|
|
11
|
+
{
|
|
12
|
+
channelName: "chat.completions.create",
|
|
13
|
+
module: {
|
|
14
|
+
name: "openai",
|
|
15
|
+
versionRange: ">=4.0.0",
|
|
16
|
+
filePath: "resources/chat/completions.mjs"
|
|
17
|
+
},
|
|
18
|
+
functionQuery: {
|
|
19
|
+
className: "Completions",
|
|
20
|
+
methodName: "create",
|
|
21
|
+
kind: "Async"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Embeddings
|
|
25
|
+
{
|
|
26
|
+
channelName: "embeddings.create",
|
|
27
|
+
module: {
|
|
28
|
+
name: "openai",
|
|
29
|
+
versionRange: ">=4.0.0",
|
|
30
|
+
filePath: "resources/embeddings.mjs"
|
|
31
|
+
},
|
|
32
|
+
functionQuery: {
|
|
33
|
+
className: "Embeddings",
|
|
34
|
+
methodName: "create",
|
|
35
|
+
kind: "Async"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
// Beta Chat Completions Parse
|
|
39
|
+
{
|
|
40
|
+
channelName: "beta.chat.completions.parse",
|
|
41
|
+
module: {
|
|
42
|
+
name: "openai",
|
|
43
|
+
versionRange: ">=4.0.0",
|
|
44
|
+
filePath: "resources/beta/chat/completions.mjs"
|
|
45
|
+
},
|
|
46
|
+
functionQuery: {
|
|
47
|
+
className: "Completions",
|
|
48
|
+
methodName: "parse",
|
|
49
|
+
kind: "Async"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
// Moderations
|
|
53
|
+
{
|
|
54
|
+
channelName: "moderations.create",
|
|
55
|
+
module: {
|
|
56
|
+
name: "openai",
|
|
57
|
+
versionRange: ">=4.0.0",
|
|
58
|
+
filePath: "resources/moderations.mjs"
|
|
59
|
+
},
|
|
60
|
+
functionQuery: {
|
|
61
|
+
className: "Moderations",
|
|
62
|
+
methodName: "create",
|
|
63
|
+
kind: "Async"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
// Beta Chat Completions Stream
|
|
67
|
+
{
|
|
68
|
+
channelName: "beta.chat.completions.stream",
|
|
69
|
+
module: {
|
|
70
|
+
name: "openai",
|
|
71
|
+
versionRange: ">=4.0.0",
|
|
72
|
+
filePath: "resources/beta/chat/completions.mjs"
|
|
73
|
+
},
|
|
74
|
+
functionQuery: {
|
|
75
|
+
className: "Completions",
|
|
76
|
+
methodName: "stream",
|
|
77
|
+
kind: "Sync"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
// Responses API (v4.87.0+)
|
|
81
|
+
{
|
|
82
|
+
channelName: "responses.create",
|
|
83
|
+
module: {
|
|
84
|
+
name: "openai",
|
|
85
|
+
versionRange: ">=4.87.0",
|
|
86
|
+
filePath: "resources/responses/responses.mjs"
|
|
87
|
+
},
|
|
88
|
+
functionQuery: {
|
|
89
|
+
className: "Responses",
|
|
90
|
+
methodName: "create",
|
|
91
|
+
kind: "Async"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
channelName: "responses.stream",
|
|
96
|
+
module: {
|
|
97
|
+
name: "openai",
|
|
98
|
+
versionRange: ">=4.87.0",
|
|
99
|
+
filePath: "resources/responses/responses.mjs"
|
|
100
|
+
},
|
|
101
|
+
functionQuery: {
|
|
102
|
+
className: "Responses",
|
|
103
|
+
methodName: "stream",
|
|
104
|
+
kind: "Sync"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
channelName: "responses.parse",
|
|
109
|
+
module: {
|
|
110
|
+
name: "openai",
|
|
111
|
+
versionRange: ">=4.87.0",
|
|
112
|
+
filePath: "resources/responses/responses.mjs"
|
|
113
|
+
},
|
|
114
|
+
functionQuery: {
|
|
115
|
+
className: "Responses",
|
|
116
|
+
methodName: "parse",
|
|
117
|
+
kind: "Async"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
// src/auto-instrumentations/configs/anthropic.ts
|
|
123
|
+
var anthropicConfigs = [
|
|
124
|
+
// Messages API - create (supports streaming via stream=true parameter)
|
|
125
|
+
{
|
|
126
|
+
channelName: "messages.create",
|
|
127
|
+
module: {
|
|
128
|
+
name: "@anthropic-ai/sdk",
|
|
129
|
+
versionRange: ">=0.60.0",
|
|
130
|
+
filePath: "resources/messages.mjs"
|
|
131
|
+
},
|
|
132
|
+
functionQuery: {
|
|
133
|
+
className: "Messages",
|
|
134
|
+
methodName: "create",
|
|
135
|
+
kind: "Async"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
// Beta Messages API - create (supports streaming via stream=true parameter)
|
|
139
|
+
{
|
|
140
|
+
channelName: "beta.messages.create",
|
|
141
|
+
module: {
|
|
142
|
+
name: "@anthropic-ai/sdk",
|
|
143
|
+
versionRange: ">=0.60.0",
|
|
144
|
+
filePath: "resources/beta/messages/messages.mjs"
|
|
145
|
+
},
|
|
146
|
+
functionQuery: {
|
|
147
|
+
className: "Messages",
|
|
148
|
+
methodName: "create",
|
|
149
|
+
kind: "Async"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
// src/auto-instrumentations/configs/ai-sdk.ts
|
|
155
|
+
var aiSDKConfigs = [
|
|
156
|
+
// generateText - async function
|
|
157
|
+
{
|
|
158
|
+
channelName: "generateText",
|
|
159
|
+
module: {
|
|
160
|
+
name: "ai",
|
|
161
|
+
versionRange: ">=3.0.0",
|
|
162
|
+
filePath: "dist/index.mjs"
|
|
163
|
+
},
|
|
164
|
+
functionQuery: {
|
|
165
|
+
functionName: "generateText",
|
|
166
|
+
kind: "Async"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
// streamText - async function
|
|
170
|
+
{
|
|
171
|
+
channelName: "streamText",
|
|
172
|
+
module: {
|
|
173
|
+
name: "ai",
|
|
174
|
+
versionRange: ">=3.0.0",
|
|
175
|
+
filePath: "dist/index.mjs"
|
|
176
|
+
},
|
|
177
|
+
functionQuery: {
|
|
178
|
+
functionName: "streamText",
|
|
179
|
+
kind: "Async"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
// generateObject - async function
|
|
183
|
+
{
|
|
184
|
+
channelName: "generateObject",
|
|
185
|
+
module: {
|
|
186
|
+
name: "ai",
|
|
187
|
+
versionRange: ">=3.0.0",
|
|
188
|
+
filePath: "dist/index.mjs"
|
|
189
|
+
},
|
|
190
|
+
functionQuery: {
|
|
191
|
+
functionName: "generateObject",
|
|
192
|
+
kind: "Async"
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
// streamObject - async function
|
|
196
|
+
{
|
|
197
|
+
channelName: "streamObject",
|
|
198
|
+
module: {
|
|
199
|
+
name: "ai",
|
|
200
|
+
versionRange: ">=3.0.0",
|
|
201
|
+
filePath: "dist/index.mjs"
|
|
202
|
+
},
|
|
203
|
+
functionQuery: {
|
|
204
|
+
functionName: "streamObject",
|
|
205
|
+
kind: "Async"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
// Agent.generate - async method (v3-v5 only, Agent structure changed in v6)
|
|
209
|
+
{
|
|
210
|
+
channelName: "Agent.generate",
|
|
211
|
+
module: {
|
|
212
|
+
name: "ai",
|
|
213
|
+
versionRange: ">=3.0.0 <6.0.0",
|
|
214
|
+
filePath: "dist/index.mjs"
|
|
215
|
+
},
|
|
216
|
+
functionQuery: {
|
|
217
|
+
className: "Agent",
|
|
218
|
+
methodName: "generate",
|
|
219
|
+
kind: "Async"
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
// Agent.stream - async method (v3-v5 only, Agent structure changed in v6)
|
|
223
|
+
{
|
|
224
|
+
channelName: "Agent.stream",
|
|
225
|
+
module: {
|
|
226
|
+
name: "ai",
|
|
227
|
+
versionRange: ">=3.0.0 <6.0.0",
|
|
228
|
+
filePath: "dist/index.mjs"
|
|
229
|
+
},
|
|
230
|
+
functionQuery: {
|
|
231
|
+
className: "Agent",
|
|
232
|
+
methodName: "stream",
|
|
233
|
+
kind: "Async"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
// src/auto-instrumentations/configs/claude-agent-sdk.ts
|
|
239
|
+
var claudeAgentSDKConfigs = [
|
|
240
|
+
// query - Main entry point for agent interactions (top-level exported async generator function)
|
|
241
|
+
{
|
|
242
|
+
channelName: "query",
|
|
243
|
+
module: {
|
|
244
|
+
name: "@anthropic-ai/claude-agent-sdk",
|
|
245
|
+
versionRange: ">=0.1.0",
|
|
246
|
+
filePath: "sdk.mjs"
|
|
247
|
+
},
|
|
248
|
+
functionQuery: {
|
|
249
|
+
functionName: "query",
|
|
250
|
+
kind: "Async"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
// src/auto-instrumentations/configs/google-genai.ts
|
|
256
|
+
var googleGenAIConfigs = [
|
|
257
|
+
// Models.generateContentInternal - The actual class method (Node.js entry point)
|
|
258
|
+
// Note: generateContent is an arrow function property that calls this internal method
|
|
259
|
+
{
|
|
260
|
+
channelName: "models.generateContent",
|
|
261
|
+
module: {
|
|
262
|
+
name: "@google/genai",
|
|
263
|
+
versionRange: ">=1.0.0",
|
|
264
|
+
filePath: "dist/node/index.mjs"
|
|
265
|
+
},
|
|
266
|
+
functionQuery: {
|
|
267
|
+
className: "Models",
|
|
268
|
+
methodName: "generateContentInternal",
|
|
269
|
+
kind: "Async"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
// Models.generateContentStreamInternal - The actual class method (Node.js entry point)
|
|
273
|
+
// Note: generateContentStream is an arrow function property that calls this internal method
|
|
274
|
+
{
|
|
275
|
+
channelName: "models.generateContentStream",
|
|
276
|
+
module: {
|
|
277
|
+
name: "@google/genai",
|
|
278
|
+
versionRange: ">=1.0.0",
|
|
279
|
+
filePath: "dist/node/index.mjs"
|
|
280
|
+
},
|
|
281
|
+
functionQuery: {
|
|
282
|
+
className: "Models",
|
|
283
|
+
methodName: "generateContentStreamInternal",
|
|
284
|
+
kind: "Async"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
|
|
289
|
+
// src/auto-instrumentations/loader/cjs-patch.ts
|
|
290
|
+
import {
|
|
291
|
+
create
|
|
292
|
+
} from "@apm-js-collab/code-transformer";
|
|
293
|
+
import * as Module from "node:module";
|
|
294
|
+
import { sep } from "node:path";
|
|
295
|
+
import moduleDetailsFromPath from "module-details-from-path";
|
|
296
|
+
var ModulePatch = class {
|
|
297
|
+
packages;
|
|
298
|
+
instrumentator;
|
|
299
|
+
originalCompile;
|
|
300
|
+
constructor({
|
|
301
|
+
instrumentations = []
|
|
302
|
+
} = {}) {
|
|
303
|
+
this.packages = new Set(instrumentations.map((i) => i.module.name));
|
|
304
|
+
this.instrumentator = create(instrumentations);
|
|
305
|
+
this.originalCompile = Module.prototype._compile;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Patches the Node.js module class method that is responsible for compiling code.
|
|
309
|
+
* If a module is found that has an instrumentator, it will transform the code before compiling it
|
|
310
|
+
* with tracing channel methods.
|
|
311
|
+
*/
|
|
312
|
+
patch() {
|
|
313
|
+
const self = this;
|
|
314
|
+
Module.prototype._compile = function wrappedCompile(...args) {
|
|
315
|
+
const [content, filename] = args;
|
|
316
|
+
const normalizedForPlatform = filename.split("/").join(sep);
|
|
317
|
+
const resolvedModule = moduleDetailsFromPath(normalizedForPlatform);
|
|
318
|
+
if (resolvedModule && self.packages.has(resolvedModule.name)) {
|
|
319
|
+
const version = getPackageVersion(resolvedModule.basedir);
|
|
320
|
+
const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
|
|
321
|
+
const transformer = self.instrumentator.getTransformer(
|
|
322
|
+
resolvedModule.name,
|
|
323
|
+
version,
|
|
324
|
+
normalizedModulePath
|
|
325
|
+
);
|
|
326
|
+
if (transformer) {
|
|
327
|
+
try {
|
|
328
|
+
const transformedCode = transformer.transform(content, "unknown");
|
|
329
|
+
args[0] = transformedCode?.code;
|
|
330
|
+
} catch (error) {
|
|
331
|
+
console.warn(`Error transforming module ${filename}:`, error);
|
|
332
|
+
} finally {
|
|
333
|
+
transformer.free();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return self.originalCompile.apply(this, args);
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Restores the original Module.prototype._compile method
|
|
342
|
+
* **Note**: This is intended to be used in testing only.
|
|
343
|
+
*/
|
|
344
|
+
unpatch() {
|
|
345
|
+
Module.prototype._compile = this.originalCompile;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// src/auto-instrumentations/hook.mts
|
|
350
|
+
var allConfigs = [
|
|
351
|
+
...openaiConfigs,
|
|
352
|
+
...anthropicConfigs,
|
|
353
|
+
...aiSDKConfigs,
|
|
354
|
+
...claudeAgentSDKConfigs,
|
|
355
|
+
...googleGenAIConfigs
|
|
356
|
+
];
|
|
357
|
+
register("./loader/esm-hook.mjs", {
|
|
358
|
+
parentURL: import.meta.url,
|
|
359
|
+
data: { instrumentations: allConfigs }
|
|
360
|
+
});
|
|
361
|
+
try {
|
|
362
|
+
const patch = new ModulePatch({ instrumentations: allConfigs });
|
|
363
|
+
patch.patch();
|
|
364
|
+
if (process.env.DEBUG === "@braintrust*" || process.env.DEBUG === "*") {
|
|
365
|
+
console.log(
|
|
366
|
+
"[Braintrust] Auto-instrumentation active (ESM + CJS) for:",
|
|
367
|
+
allConfigs.map((c) => c.channelName).join(", ")
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
} catch (err) {
|
|
371
|
+
if (process.env.DEBUG === "@braintrust*" || process.env.DEBUG === "*") {
|
|
372
|
+
console.log(
|
|
373
|
+
"[Braintrust] Auto-instrumentation active (ESM only) for:",
|
|
374
|
+
allConfigs.map((c) => c.channelName).join(", ")
|
|
375
|
+
);
|
|
376
|
+
console.error("[Braintrust] CJS patch failed:", err);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/auto-instrumentations/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
aiSDKConfigs: () => aiSDKConfigs,
|
|
24
|
+
anthropicConfigs: () => anthropicConfigs,
|
|
25
|
+
claudeAgentSDKConfigs: () => claudeAgentSDKConfigs,
|
|
26
|
+
googleGenAIConfigs: () => googleGenAIConfigs,
|
|
27
|
+
openaiConfigs: () => openaiConfigs
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/auto-instrumentations/configs/openai.ts
|
|
32
|
+
var openaiConfigs = [
|
|
33
|
+
// Chat Completions
|
|
34
|
+
{
|
|
35
|
+
channelName: "chat.completions.create",
|
|
36
|
+
module: {
|
|
37
|
+
name: "openai",
|
|
38
|
+
versionRange: ">=4.0.0",
|
|
39
|
+
filePath: "resources/chat/completions.mjs"
|
|
40
|
+
},
|
|
41
|
+
functionQuery: {
|
|
42
|
+
className: "Completions",
|
|
43
|
+
methodName: "create",
|
|
44
|
+
kind: "Async"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
// Embeddings
|
|
48
|
+
{
|
|
49
|
+
channelName: "embeddings.create",
|
|
50
|
+
module: {
|
|
51
|
+
name: "openai",
|
|
52
|
+
versionRange: ">=4.0.0",
|
|
53
|
+
filePath: "resources/embeddings.mjs"
|
|
54
|
+
},
|
|
55
|
+
functionQuery: {
|
|
56
|
+
className: "Embeddings",
|
|
57
|
+
methodName: "create",
|
|
58
|
+
kind: "Async"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
// Beta Chat Completions Parse
|
|
62
|
+
{
|
|
63
|
+
channelName: "beta.chat.completions.parse",
|
|
64
|
+
module: {
|
|
65
|
+
name: "openai",
|
|
66
|
+
versionRange: ">=4.0.0",
|
|
67
|
+
filePath: "resources/beta/chat/completions.mjs"
|
|
68
|
+
},
|
|
69
|
+
functionQuery: {
|
|
70
|
+
className: "Completions",
|
|
71
|
+
methodName: "parse",
|
|
72
|
+
kind: "Async"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
// Moderations
|
|
76
|
+
{
|
|
77
|
+
channelName: "moderations.create",
|
|
78
|
+
module: {
|
|
79
|
+
name: "openai",
|
|
80
|
+
versionRange: ">=4.0.0",
|
|
81
|
+
filePath: "resources/moderations.mjs"
|
|
82
|
+
},
|
|
83
|
+
functionQuery: {
|
|
84
|
+
className: "Moderations",
|
|
85
|
+
methodName: "create",
|
|
86
|
+
kind: "Async"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
// Beta Chat Completions Stream
|
|
90
|
+
{
|
|
91
|
+
channelName: "beta.chat.completions.stream",
|
|
92
|
+
module: {
|
|
93
|
+
name: "openai",
|
|
94
|
+
versionRange: ">=4.0.0",
|
|
95
|
+
filePath: "resources/beta/chat/completions.mjs"
|
|
96
|
+
},
|
|
97
|
+
functionQuery: {
|
|
98
|
+
className: "Completions",
|
|
99
|
+
methodName: "stream",
|
|
100
|
+
kind: "Sync"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
// Responses API (v4.87.0+)
|
|
104
|
+
{
|
|
105
|
+
channelName: "responses.create",
|
|
106
|
+
module: {
|
|
107
|
+
name: "openai",
|
|
108
|
+
versionRange: ">=4.87.0",
|
|
109
|
+
filePath: "resources/responses/responses.mjs"
|
|
110
|
+
},
|
|
111
|
+
functionQuery: {
|
|
112
|
+
className: "Responses",
|
|
113
|
+
methodName: "create",
|
|
114
|
+
kind: "Async"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
channelName: "responses.stream",
|
|
119
|
+
module: {
|
|
120
|
+
name: "openai",
|
|
121
|
+
versionRange: ">=4.87.0",
|
|
122
|
+
filePath: "resources/responses/responses.mjs"
|
|
123
|
+
},
|
|
124
|
+
functionQuery: {
|
|
125
|
+
className: "Responses",
|
|
126
|
+
methodName: "stream",
|
|
127
|
+
kind: "Sync"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
channelName: "responses.parse",
|
|
132
|
+
module: {
|
|
133
|
+
name: "openai",
|
|
134
|
+
versionRange: ">=4.87.0",
|
|
135
|
+
filePath: "resources/responses/responses.mjs"
|
|
136
|
+
},
|
|
137
|
+
functionQuery: {
|
|
138
|
+
className: "Responses",
|
|
139
|
+
methodName: "parse",
|
|
140
|
+
kind: "Async"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
// src/auto-instrumentations/configs/anthropic.ts
|
|
146
|
+
var anthropicConfigs = [
|
|
147
|
+
// Messages API - create (supports streaming via stream=true parameter)
|
|
148
|
+
{
|
|
149
|
+
channelName: "messages.create",
|
|
150
|
+
module: {
|
|
151
|
+
name: "@anthropic-ai/sdk",
|
|
152
|
+
versionRange: ">=0.60.0",
|
|
153
|
+
filePath: "resources/messages.mjs"
|
|
154
|
+
},
|
|
155
|
+
functionQuery: {
|
|
156
|
+
className: "Messages",
|
|
157
|
+
methodName: "create",
|
|
158
|
+
kind: "Async"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
// Beta Messages API - create (supports streaming via stream=true parameter)
|
|
162
|
+
{
|
|
163
|
+
channelName: "beta.messages.create",
|
|
164
|
+
module: {
|
|
165
|
+
name: "@anthropic-ai/sdk",
|
|
166
|
+
versionRange: ">=0.60.0",
|
|
167
|
+
filePath: "resources/beta/messages/messages.mjs"
|
|
168
|
+
},
|
|
169
|
+
functionQuery: {
|
|
170
|
+
className: "Messages",
|
|
171
|
+
methodName: "create",
|
|
172
|
+
kind: "Async"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
// src/auto-instrumentations/configs/ai-sdk.ts
|
|
178
|
+
var aiSDKConfigs = [
|
|
179
|
+
// generateText - async function
|
|
180
|
+
{
|
|
181
|
+
channelName: "generateText",
|
|
182
|
+
module: {
|
|
183
|
+
name: "ai",
|
|
184
|
+
versionRange: ">=3.0.0",
|
|
185
|
+
filePath: "dist/index.mjs"
|
|
186
|
+
},
|
|
187
|
+
functionQuery: {
|
|
188
|
+
functionName: "generateText",
|
|
189
|
+
kind: "Async"
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
// streamText - async function
|
|
193
|
+
{
|
|
194
|
+
channelName: "streamText",
|
|
195
|
+
module: {
|
|
196
|
+
name: "ai",
|
|
197
|
+
versionRange: ">=3.0.0",
|
|
198
|
+
filePath: "dist/index.mjs"
|
|
199
|
+
},
|
|
200
|
+
functionQuery: {
|
|
201
|
+
functionName: "streamText",
|
|
202
|
+
kind: "Async"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
// generateObject - async function
|
|
206
|
+
{
|
|
207
|
+
channelName: "generateObject",
|
|
208
|
+
module: {
|
|
209
|
+
name: "ai",
|
|
210
|
+
versionRange: ">=3.0.0",
|
|
211
|
+
filePath: "dist/index.mjs"
|
|
212
|
+
},
|
|
213
|
+
functionQuery: {
|
|
214
|
+
functionName: "generateObject",
|
|
215
|
+
kind: "Async"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
// streamObject - async function
|
|
219
|
+
{
|
|
220
|
+
channelName: "streamObject",
|
|
221
|
+
module: {
|
|
222
|
+
name: "ai",
|
|
223
|
+
versionRange: ">=3.0.0",
|
|
224
|
+
filePath: "dist/index.mjs"
|
|
225
|
+
},
|
|
226
|
+
functionQuery: {
|
|
227
|
+
functionName: "streamObject",
|
|
228
|
+
kind: "Async"
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
// Agent.generate - async method (v3-v5 only, Agent structure changed in v6)
|
|
232
|
+
{
|
|
233
|
+
channelName: "Agent.generate",
|
|
234
|
+
module: {
|
|
235
|
+
name: "ai",
|
|
236
|
+
versionRange: ">=3.0.0 <6.0.0",
|
|
237
|
+
filePath: "dist/index.mjs"
|
|
238
|
+
},
|
|
239
|
+
functionQuery: {
|
|
240
|
+
className: "Agent",
|
|
241
|
+
methodName: "generate",
|
|
242
|
+
kind: "Async"
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
// Agent.stream - async method (v3-v5 only, Agent structure changed in v6)
|
|
246
|
+
{
|
|
247
|
+
channelName: "Agent.stream",
|
|
248
|
+
module: {
|
|
249
|
+
name: "ai",
|
|
250
|
+
versionRange: ">=3.0.0 <6.0.0",
|
|
251
|
+
filePath: "dist/index.mjs"
|
|
252
|
+
},
|
|
253
|
+
functionQuery: {
|
|
254
|
+
className: "Agent",
|
|
255
|
+
methodName: "stream",
|
|
256
|
+
kind: "Async"
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
// src/auto-instrumentations/configs/claude-agent-sdk.ts
|
|
262
|
+
var claudeAgentSDKConfigs = [
|
|
263
|
+
// query - Main entry point for agent interactions (top-level exported async generator function)
|
|
264
|
+
{
|
|
265
|
+
channelName: "query",
|
|
266
|
+
module: {
|
|
267
|
+
name: "@anthropic-ai/claude-agent-sdk",
|
|
268
|
+
versionRange: ">=0.1.0",
|
|
269
|
+
filePath: "sdk.mjs"
|
|
270
|
+
},
|
|
271
|
+
functionQuery: {
|
|
272
|
+
functionName: "query",
|
|
273
|
+
kind: "Async"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
];
|
|
277
|
+
|
|
278
|
+
// src/auto-instrumentations/configs/google-genai.ts
|
|
279
|
+
var googleGenAIConfigs = [
|
|
280
|
+
// Models.generateContentInternal - The actual class method (Node.js entry point)
|
|
281
|
+
// Note: generateContent is an arrow function property that calls this internal method
|
|
282
|
+
{
|
|
283
|
+
channelName: "models.generateContent",
|
|
284
|
+
module: {
|
|
285
|
+
name: "@google/genai",
|
|
286
|
+
versionRange: ">=1.0.0",
|
|
287
|
+
filePath: "dist/node/index.mjs"
|
|
288
|
+
},
|
|
289
|
+
functionQuery: {
|
|
290
|
+
className: "Models",
|
|
291
|
+
methodName: "generateContentInternal",
|
|
292
|
+
kind: "Async"
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
// Models.generateContentStreamInternal - The actual class method (Node.js entry point)
|
|
296
|
+
// Note: generateContentStream is an arrow function property that calls this internal method
|
|
297
|
+
{
|
|
298
|
+
channelName: "models.generateContentStream",
|
|
299
|
+
module: {
|
|
300
|
+
name: "@google/genai",
|
|
301
|
+
versionRange: ">=1.0.0",
|
|
302
|
+
filePath: "dist/node/index.mjs"
|
|
303
|
+
},
|
|
304
|
+
functionQuery: {
|
|
305
|
+
className: "Models",
|
|
306
|
+
methodName: "generateContentStreamInternal",
|
|
307
|
+
kind: "Async"
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
];
|
|
311
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
312
|
+
0 && (module.exports = {
|
|
313
|
+
aiSDKConfigs,
|
|
314
|
+
anthropicConfigs,
|
|
315
|
+
claudeAgentSDKConfigs,
|
|
316
|
+
googleGenAIConfigs,
|
|
317
|
+
openaiConfigs
|
|
318
|
+
});
|