braintrust 3.24.0 → 3.26.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/NOTICE +6 -0
- package/dev/dist/index.d.mts +135 -2
- package/dev/dist/index.d.ts +135 -2
- package/dev/dist/index.js +4426 -2040
- package/dev/dist/index.mjs +3594 -1208
- package/dist/apply-auto-instrumentation.js +445 -403
- package/dist/apply-auto-instrumentation.mjs +249 -207
- package/dist/auto-instrumentations/bundler/esbuild.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
- package/dist/auto-instrumentations/bundler/next.cjs +1448 -818
- package/dist/auto-instrumentations/bundler/next.mjs +6 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1602 -728
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
- package/dist/auto-instrumentations/{chunk-GSZHTAQW.mjs → chunk-6E22MYSW.mjs} +194 -93
- package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
- package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
- package/dist/auto-instrumentations/{chunk-BURMPO7L.mjs → chunk-V5LEODRX.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
- package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-XZHHE4Y3.mjs} +646 -510
- package/dist/auto-instrumentations/hook.mjs +894 -657
- package/dist/auto-instrumentations/index.cjs +1125 -490
- package/dist/auto-instrumentations/index.d.mts +6 -2
- package/dist/auto-instrumentations/index.d.ts +6 -2
- package/dist/auto-instrumentations/index.mjs +6 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
- package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
- package/dist/browser.d.mts +824 -197
- package/dist/browser.d.ts +824 -197
- package/dist/browser.js +3897 -1228
- package/dist/browser.mjs +3897 -1228
- package/dist/chunk-PN7EWK66.mjs +1784 -0
- package/dist/{chunk-SU6EHKJV.js → chunk-VRZZQPAA.js} +3289 -1577
- package/dist/chunk-VYNNEKSA.js +1784 -0
- package/dist/{chunk-XE5FS7QY.mjs → chunk-XIZOM2HO.mjs} +2470 -758
- package/dist/cli.js +3596 -1211
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +3897 -1231
- package/dist/edge-light.mjs +3897 -1231
- package/dist/index.d.mts +824 -197
- package/dist/index.d.ts +824 -197
- package/dist/index.js +750 -445
- package/dist/index.mjs +334 -29
- package/dist/instrumentation/index.d.mts +135 -6
- package/dist/instrumentation/index.d.ts +135 -6
- package/dist/instrumentation/index.js +3696 -1257
- package/dist/instrumentation/index.mjs +3696 -1257
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +3897 -1231
- package/dist/workerd.mjs +3897 -1231
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
- package/dist/chunk-7AUY2XWX.js +0 -1090
- package/dist/chunk-7F6GCRHH.mjs +0 -1090
package/dist/chunk-7F6GCRHH.mjs
DELETED
|
@@ -1,1090 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/auto-instrumentations/patch-tracing-channel.ts
|
|
8
|
-
function patchTracingChannel(tracingChannelFn) {
|
|
9
|
-
const dummyChannel = tracingChannelFn("__braintrust_probe__");
|
|
10
|
-
const TracingChannel = dummyChannel?.constructor;
|
|
11
|
-
if (!TracingChannel?.prototype) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) {
|
|
15
|
-
Object.defineProperty(TracingChannel.prototype, "hasSubscribers", {
|
|
16
|
-
configurable: true,
|
|
17
|
-
enumerable: false,
|
|
18
|
-
get() {
|
|
19
|
-
return Boolean(
|
|
20
|
-
this.start?.hasSubscribers || this.end?.hasSubscribers || this.asyncStart?.hasSubscribers || this.asyncEnd?.hasSubscribers || this.error?.hasSubscribers
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
if (TracingChannel.prototype.tracePromise) {
|
|
26
|
-
TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) {
|
|
27
|
-
const start = this.start;
|
|
28
|
-
const end = this.end;
|
|
29
|
-
const asyncStart = this.asyncStart;
|
|
30
|
-
const asyncEnd = this.asyncEnd;
|
|
31
|
-
const error = this.error;
|
|
32
|
-
function publishRejected(err) {
|
|
33
|
-
context.error = err;
|
|
34
|
-
error?.publish(context);
|
|
35
|
-
asyncStart?.publish(context);
|
|
36
|
-
asyncEnd?.publish(context);
|
|
37
|
-
}
|
|
38
|
-
function publishResolved(result) {
|
|
39
|
-
context.result = result;
|
|
40
|
-
asyncStart?.publish(context);
|
|
41
|
-
asyncEnd?.publish(context);
|
|
42
|
-
}
|
|
43
|
-
return start.runStores(context, () => {
|
|
44
|
-
try {
|
|
45
|
-
const result = Reflect.apply(fn, thisArg, args);
|
|
46
|
-
end?.publish(context);
|
|
47
|
-
if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") {
|
|
48
|
-
if (result.constructor === Promise) {
|
|
49
|
-
return result.then(
|
|
50
|
-
(res) => {
|
|
51
|
-
publishResolved(res);
|
|
52
|
-
return res;
|
|
53
|
-
},
|
|
54
|
-
(err) => {
|
|
55
|
-
publishRejected(err);
|
|
56
|
-
return Promise.reject(err);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
void result.then(
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
(resolved) => {
|
|
63
|
-
try {
|
|
64
|
-
publishResolved(resolved);
|
|
65
|
-
} catch {
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
-
(err) => {
|
|
70
|
-
try {
|
|
71
|
-
publishRejected(err);
|
|
72
|
-
} catch {
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
context.result = result;
|
|
79
|
-
asyncStart?.publish(context);
|
|
80
|
-
asyncEnd?.publish(context);
|
|
81
|
-
return result;
|
|
82
|
-
} catch (err) {
|
|
83
|
-
context.error = err;
|
|
84
|
-
error?.publish(context);
|
|
85
|
-
end?.publish(context);
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// src/isomorph.ts
|
|
94
|
-
var DefaultAsyncLocalStorage = class {
|
|
95
|
-
constructor() {
|
|
96
|
-
}
|
|
97
|
-
enterWith(_) {
|
|
98
|
-
}
|
|
99
|
-
run(_, callback) {
|
|
100
|
-
return callback();
|
|
101
|
-
}
|
|
102
|
-
getStore() {
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var DefaultChannel = class {
|
|
107
|
-
constructor(name) {
|
|
108
|
-
this.name = name;
|
|
109
|
-
}
|
|
110
|
-
name;
|
|
111
|
-
hasSubscribers = false;
|
|
112
|
-
subscribe(_subscription) {
|
|
113
|
-
}
|
|
114
|
-
unsubscribe(_subscription) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
bindStore(_store, _transform) {
|
|
118
|
-
}
|
|
119
|
-
unbindStore(_store) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
publish(_message) {
|
|
123
|
-
}
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
-
runStores(_message, fn, thisArg, ...args) {
|
|
126
|
-
return fn.apply(thisArg, args);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var DefaultTracingChannel = class {
|
|
130
|
-
start;
|
|
131
|
-
end;
|
|
132
|
-
asyncStart;
|
|
133
|
-
asyncEnd;
|
|
134
|
-
error;
|
|
135
|
-
constructor(nameOrChannels) {
|
|
136
|
-
if (typeof nameOrChannels === "string") {
|
|
137
|
-
this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`);
|
|
138
|
-
this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`);
|
|
139
|
-
this.asyncStart = new DefaultChannel(
|
|
140
|
-
`tracing:${nameOrChannels}:asyncStart`
|
|
141
|
-
);
|
|
142
|
-
this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
|
|
143
|
-
this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start");
|
|
147
|
-
this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end");
|
|
148
|
-
this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart");
|
|
149
|
-
this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd");
|
|
150
|
-
this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error");
|
|
151
|
-
}
|
|
152
|
-
get hasSubscribers() {
|
|
153
|
-
return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
|
|
154
|
-
}
|
|
155
|
-
subscribe(_handlers) {
|
|
156
|
-
}
|
|
157
|
-
unsubscribe(_handlers) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
-
traceSync(fn, _message, thisArg, ...args) {
|
|
162
|
-
return fn.apply(thisArg, args);
|
|
163
|
-
}
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
-
tracePromise(fn, _message, thisArg, ...args) {
|
|
166
|
-
return fn.apply(thisArg, args);
|
|
167
|
-
}
|
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
-
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
170
|
-
return fn.apply(thisArg, args);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var iso = {
|
|
174
|
-
buildType: "unknown",
|
|
175
|
-
// Will be set by configureBrowser() or configureNode()
|
|
176
|
-
getRepoInfo: async (_settings) => void 0,
|
|
177
|
-
getPastNAncestors: async () => [],
|
|
178
|
-
getEnv: (_name) => void 0,
|
|
179
|
-
getBraintrustApiKey: async () => void 0,
|
|
180
|
-
getCallerLocation: () => void 0,
|
|
181
|
-
newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
|
|
182
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
-
newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels),
|
|
184
|
-
processOn: (_0, _1) => {
|
|
185
|
-
},
|
|
186
|
-
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
187
|
-
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
|
|
188
|
-
writeln: (text) => console.log(text)
|
|
189
|
-
};
|
|
190
|
-
var isomorph_default = iso;
|
|
191
|
-
|
|
192
|
-
// src/instrumentation/core/channel-definitions.ts
|
|
193
|
-
function channel(spec) {
|
|
194
|
-
return spec;
|
|
195
|
-
}
|
|
196
|
-
function defineChannels(pkg, channels) {
|
|
197
|
-
return Object.fromEntries(
|
|
198
|
-
Object.entries(channels).map(([key, spec]) => {
|
|
199
|
-
const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`;
|
|
200
|
-
if (spec.kind === "async") {
|
|
201
|
-
const asyncSpec = spec;
|
|
202
|
-
const tracingChannel2 = () => isomorph_default.newTracingChannel(
|
|
203
|
-
fullChannelName
|
|
204
|
-
);
|
|
205
|
-
return [
|
|
206
|
-
key,
|
|
207
|
-
{
|
|
208
|
-
...asyncSpec,
|
|
209
|
-
tracingChannel: tracingChannel2,
|
|
210
|
-
tracePromise: (fn, context) => tracingChannel2().tracePromise(
|
|
211
|
-
fn,
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
213
|
-
context
|
|
214
|
-
)
|
|
215
|
-
}
|
|
216
|
-
];
|
|
217
|
-
}
|
|
218
|
-
const syncSpec = spec;
|
|
219
|
-
const tracingChannel = () => isomorph_default.newTracingChannel(
|
|
220
|
-
fullChannelName
|
|
221
|
-
);
|
|
222
|
-
return [
|
|
223
|
-
key,
|
|
224
|
-
{
|
|
225
|
-
...syncSpec,
|
|
226
|
-
tracingChannel,
|
|
227
|
-
traceSync: (fn, context) => tracingChannel().traceSync(
|
|
228
|
-
fn,
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
230
|
-
context
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
];
|
|
234
|
-
})
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// src/instrumentation/plugins/openai-channels.ts
|
|
239
|
-
var openAIChannels = defineChannels("openai", {
|
|
240
|
-
chatCompletionsCreate: channel({
|
|
241
|
-
channelName: "chat.completions.create",
|
|
242
|
-
kind: "async"
|
|
243
|
-
}),
|
|
244
|
-
embeddingsCreate: channel({
|
|
245
|
-
channelName: "embeddings.create",
|
|
246
|
-
kind: "async"
|
|
247
|
-
}),
|
|
248
|
-
betaChatCompletionsParse: channel({
|
|
249
|
-
channelName: "beta.chat.completions.parse",
|
|
250
|
-
kind: "async"
|
|
251
|
-
}),
|
|
252
|
-
betaChatCompletionsStream: channel({
|
|
253
|
-
channelName: "beta.chat.completions.stream",
|
|
254
|
-
kind: "sync-stream"
|
|
255
|
-
}),
|
|
256
|
-
moderationsCreate: channel({
|
|
257
|
-
channelName: "moderations.create",
|
|
258
|
-
kind: "async"
|
|
259
|
-
}),
|
|
260
|
-
responsesCreate: channel({
|
|
261
|
-
channelName: "responses.create",
|
|
262
|
-
kind: "async"
|
|
263
|
-
}),
|
|
264
|
-
responsesStream: channel({
|
|
265
|
-
channelName: "responses.stream",
|
|
266
|
-
kind: "sync-stream"
|
|
267
|
-
}),
|
|
268
|
-
responsesParse: channel({
|
|
269
|
-
channelName: "responses.parse",
|
|
270
|
-
kind: "async"
|
|
271
|
-
}),
|
|
272
|
-
responsesCompact: channel({
|
|
273
|
-
channelName: "responses.compact",
|
|
274
|
-
kind: "async"
|
|
275
|
-
})
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
// src/instrumentation/plugins/openai-codex-channels.ts
|
|
279
|
-
var openAICodexChannels = defineChannels("@openai/codex-sdk", {
|
|
280
|
-
run: channel({
|
|
281
|
-
channelName: "Thread.run",
|
|
282
|
-
kind: "async"
|
|
283
|
-
}),
|
|
284
|
-
runStreamed: channel({
|
|
285
|
-
channelName: "Thread.runStreamed",
|
|
286
|
-
kind: "async"
|
|
287
|
-
})
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
// src/instrumentation/plugins/anthropic-channels.ts
|
|
291
|
-
var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
|
|
292
|
-
messagesCreate: channel({
|
|
293
|
-
channelName: "messages.create",
|
|
294
|
-
kind: "async"
|
|
295
|
-
}),
|
|
296
|
-
betaMessagesCreate: channel({
|
|
297
|
-
channelName: "beta.messages.create",
|
|
298
|
-
kind: "async"
|
|
299
|
-
}),
|
|
300
|
-
betaMessagesToolRunner: channel({
|
|
301
|
-
channelName: "beta.messages.toolRunner",
|
|
302
|
-
kind: "sync-stream"
|
|
303
|
-
})
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// src/instrumentation/plugins/ai-sdk-channels.ts
|
|
307
|
-
var aiSDKChannels = defineChannels("ai", {
|
|
308
|
-
generateText: channel({
|
|
309
|
-
channelName: "generateText",
|
|
310
|
-
kind: "async"
|
|
311
|
-
}),
|
|
312
|
-
streamText: channel({
|
|
313
|
-
channelName: "streamText",
|
|
314
|
-
kind: "async"
|
|
315
|
-
}),
|
|
316
|
-
streamTextSync: channel({
|
|
317
|
-
channelName: "streamText.sync",
|
|
318
|
-
kind: "sync-stream"
|
|
319
|
-
}),
|
|
320
|
-
generateObject: channel({
|
|
321
|
-
channelName: "generateObject",
|
|
322
|
-
kind: "async"
|
|
323
|
-
}),
|
|
324
|
-
streamObject: channel({
|
|
325
|
-
channelName: "streamObject",
|
|
326
|
-
kind: "async"
|
|
327
|
-
}),
|
|
328
|
-
streamObjectSync: channel({
|
|
329
|
-
channelName: "streamObject.sync",
|
|
330
|
-
kind: "sync-stream"
|
|
331
|
-
}),
|
|
332
|
-
embed: channel(
|
|
333
|
-
{
|
|
334
|
-
channelName: "embed",
|
|
335
|
-
kind: "async"
|
|
336
|
-
}
|
|
337
|
-
),
|
|
338
|
-
embedMany: channel({
|
|
339
|
-
channelName: "embedMany",
|
|
340
|
-
kind: "async"
|
|
341
|
-
}),
|
|
342
|
-
rerank: channel({
|
|
343
|
-
channelName: "rerank",
|
|
344
|
-
kind: "async"
|
|
345
|
-
}),
|
|
346
|
-
agentGenerate: channel({
|
|
347
|
-
channelName: "Agent.generate",
|
|
348
|
-
kind: "async"
|
|
349
|
-
}),
|
|
350
|
-
agentStream: channel({
|
|
351
|
-
channelName: "Agent.stream",
|
|
352
|
-
kind: "async"
|
|
353
|
-
}),
|
|
354
|
-
agentStreamSync: channel({
|
|
355
|
-
channelName: "Agent.stream.sync",
|
|
356
|
-
kind: "sync-stream"
|
|
357
|
-
}),
|
|
358
|
-
toolLoopAgentGenerate: channel({
|
|
359
|
-
channelName: "ToolLoopAgent.generate",
|
|
360
|
-
kind: "async"
|
|
361
|
-
}),
|
|
362
|
-
toolLoopAgentStream: channel({
|
|
363
|
-
channelName: "ToolLoopAgent.stream",
|
|
364
|
-
kind: "async"
|
|
365
|
-
}),
|
|
366
|
-
workflowAgentStream: channel({
|
|
367
|
-
channelName: "WorkflowAgent.stream",
|
|
368
|
-
kind: "async"
|
|
369
|
-
}),
|
|
370
|
-
v7CreateTelemetryDispatcher: channel({
|
|
371
|
-
channelName: "createTelemetryDispatcher",
|
|
372
|
-
kind: "sync-stream"
|
|
373
|
-
})
|
|
374
|
-
});
|
|
375
|
-
var harnessAgentChannels = defineChannels("@ai-sdk/harness", {
|
|
376
|
-
generate: channel({
|
|
377
|
-
channelName: "HarnessAgent.generate",
|
|
378
|
-
kind: "async"
|
|
379
|
-
}),
|
|
380
|
-
stream: channel({
|
|
381
|
-
channelName: "HarnessAgent.stream",
|
|
382
|
-
kind: "async"
|
|
383
|
-
}),
|
|
384
|
-
continueGenerate: channel({
|
|
385
|
-
channelName: "HarnessAgent.continueGenerate",
|
|
386
|
-
kind: "async"
|
|
387
|
-
}),
|
|
388
|
-
continueStream: channel({
|
|
389
|
-
channelName: "HarnessAgent.continueStream",
|
|
390
|
-
kind: "async"
|
|
391
|
-
})
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
// src/instrumentation/plugins/claude-agent-sdk-channels.ts
|
|
395
|
-
var claudeAgentSDKChannels = defineChannels(
|
|
396
|
-
"@anthropic-ai/claude-agent-sdk",
|
|
397
|
-
{
|
|
398
|
-
query: channel({
|
|
399
|
-
channelName: "query",
|
|
400
|
-
kind: "sync-stream"
|
|
401
|
-
})
|
|
402
|
-
}
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
// src/instrumentation/plugins/cursor-sdk-channels.ts
|
|
406
|
-
var cursorSDKChannels = defineChannels("@cursor/sdk", {
|
|
407
|
-
create: channel({
|
|
408
|
-
channelName: "Agent.create",
|
|
409
|
-
kind: "async"
|
|
410
|
-
}),
|
|
411
|
-
resume: channel({
|
|
412
|
-
channelName: "Agent.resume",
|
|
413
|
-
kind: "async"
|
|
414
|
-
}),
|
|
415
|
-
prompt: channel({
|
|
416
|
-
channelName: "Agent.prompt",
|
|
417
|
-
kind: "async"
|
|
418
|
-
}),
|
|
419
|
-
send: channel({
|
|
420
|
-
channelName: "agent.send",
|
|
421
|
-
kind: "async"
|
|
422
|
-
})
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// src/instrumentation/plugins/google-genai-channels.ts
|
|
426
|
-
var googleGenAIChannels = defineChannels("@google/genai", {
|
|
427
|
-
generateContent: channel({
|
|
428
|
-
channelName: "models.generateContent",
|
|
429
|
-
kind: "async"
|
|
430
|
-
}),
|
|
431
|
-
generateContentStream: channel({
|
|
432
|
-
channelName: "models.generateContentStream",
|
|
433
|
-
kind: "async"
|
|
434
|
-
}),
|
|
435
|
-
embedContent: channel({
|
|
436
|
-
channelName: "models.embedContent",
|
|
437
|
-
kind: "async"
|
|
438
|
-
}),
|
|
439
|
-
interactionsCreate: channel({
|
|
440
|
-
channelName: "interactions.create",
|
|
441
|
-
kind: "async"
|
|
442
|
-
})
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
// src/instrumentation/plugins/huggingface-channels.ts
|
|
446
|
-
var huggingFaceChannels = defineChannels("@huggingface/inference", {
|
|
447
|
-
chatCompletion: channel({
|
|
448
|
-
channelName: "chatCompletion",
|
|
449
|
-
kind: "async"
|
|
450
|
-
}),
|
|
451
|
-
chatCompletionStream: channel({
|
|
452
|
-
channelName: "chatCompletionStream",
|
|
453
|
-
kind: "sync-stream"
|
|
454
|
-
}),
|
|
455
|
-
textGeneration: channel({
|
|
456
|
-
channelName: "textGeneration",
|
|
457
|
-
kind: "async"
|
|
458
|
-
}),
|
|
459
|
-
textGenerationStream: channel({
|
|
460
|
-
channelName: "textGenerationStream",
|
|
461
|
-
kind: "sync-stream"
|
|
462
|
-
}),
|
|
463
|
-
featureExtraction: channel({
|
|
464
|
-
channelName: "featureExtraction",
|
|
465
|
-
kind: "async"
|
|
466
|
-
})
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
// src/instrumentation/plugins/openrouter-agent-channels.ts
|
|
470
|
-
var openRouterAgentChannels = defineChannels("@openrouter/agent", {
|
|
471
|
-
callModel: channel({
|
|
472
|
-
channelName: "callModel",
|
|
473
|
-
kind: "sync-stream"
|
|
474
|
-
}),
|
|
475
|
-
callModelTurn: channel({
|
|
476
|
-
channelName: "callModel.turn",
|
|
477
|
-
kind: "async"
|
|
478
|
-
}),
|
|
479
|
-
toolExecute: channel({
|
|
480
|
-
channelName: "tool.execute",
|
|
481
|
-
kind: "async"
|
|
482
|
-
})
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
// src/instrumentation/plugins/openrouter-channels.ts
|
|
486
|
-
var openRouterChannels = defineChannels("@openrouter/sdk", {
|
|
487
|
-
chatSend: channel({
|
|
488
|
-
channelName: "chat.send",
|
|
489
|
-
kind: "async"
|
|
490
|
-
}),
|
|
491
|
-
embeddingsGenerate: channel({
|
|
492
|
-
channelName: "embeddings.generate",
|
|
493
|
-
kind: "async"
|
|
494
|
-
}),
|
|
495
|
-
rerankRerank: channel(
|
|
496
|
-
{
|
|
497
|
-
channelName: "rerank.rerank",
|
|
498
|
-
kind: "async"
|
|
499
|
-
}
|
|
500
|
-
),
|
|
501
|
-
betaResponsesSend: channel({
|
|
502
|
-
channelName: "beta.responses.send",
|
|
503
|
-
kind: "async"
|
|
504
|
-
}),
|
|
505
|
-
callModel: channel({
|
|
506
|
-
channelName: "callModel",
|
|
507
|
-
kind: "sync-stream"
|
|
508
|
-
}),
|
|
509
|
-
callModelTurn: channel({
|
|
510
|
-
channelName: "callModel.turn",
|
|
511
|
-
kind: "async"
|
|
512
|
-
}),
|
|
513
|
-
toolExecute: channel({
|
|
514
|
-
channelName: "tool.execute",
|
|
515
|
-
kind: "async"
|
|
516
|
-
})
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
// src/instrumentation/plugins/mistral-channels.ts
|
|
520
|
-
var mistralChannels = defineChannels("@mistralai/mistralai", {
|
|
521
|
-
chatComplete: channel({
|
|
522
|
-
channelName: "chat.complete",
|
|
523
|
-
kind: "async"
|
|
524
|
-
}),
|
|
525
|
-
chatStream: channel({
|
|
526
|
-
channelName: "chat.stream",
|
|
527
|
-
kind: "async"
|
|
528
|
-
}),
|
|
529
|
-
embeddingsCreate: channel({
|
|
530
|
-
channelName: "embeddings.create",
|
|
531
|
-
kind: "async"
|
|
532
|
-
}),
|
|
533
|
-
classifiersModerate: channel({
|
|
534
|
-
channelName: "classifiers.moderate",
|
|
535
|
-
kind: "async"
|
|
536
|
-
}),
|
|
537
|
-
classifiersModerateChat: channel({
|
|
538
|
-
channelName: "classifiers.moderateChat",
|
|
539
|
-
kind: "async"
|
|
540
|
-
}),
|
|
541
|
-
classifiersClassify: channel({
|
|
542
|
-
channelName: "classifiers.classify",
|
|
543
|
-
kind: "async"
|
|
544
|
-
}),
|
|
545
|
-
classifiersClassifyChat: channel({
|
|
546
|
-
channelName: "classifiers.classifyChat",
|
|
547
|
-
kind: "async"
|
|
548
|
-
}),
|
|
549
|
-
fimComplete: channel({
|
|
550
|
-
channelName: "fim.complete",
|
|
551
|
-
kind: "async"
|
|
552
|
-
}),
|
|
553
|
-
fimStream: channel({
|
|
554
|
-
channelName: "fim.stream",
|
|
555
|
-
kind: "async"
|
|
556
|
-
}),
|
|
557
|
-
agentsComplete: channel({
|
|
558
|
-
channelName: "agents.complete",
|
|
559
|
-
kind: "async"
|
|
560
|
-
}),
|
|
561
|
-
agentsStream: channel({
|
|
562
|
-
channelName: "agents.stream",
|
|
563
|
-
kind: "async"
|
|
564
|
-
})
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
// src/instrumentation/plugins/google-adk-channels.ts
|
|
568
|
-
var googleADKChannels = defineChannels("@google/adk", {
|
|
569
|
-
runnerRunAsync: channel({
|
|
570
|
-
channelName: "runner.runAsync",
|
|
571
|
-
kind: "sync-stream"
|
|
572
|
-
}),
|
|
573
|
-
agentRunAsync: channel({
|
|
574
|
-
channelName: "agent.runAsync",
|
|
575
|
-
kind: "sync-stream"
|
|
576
|
-
}),
|
|
577
|
-
toolRunAsync: channel({
|
|
578
|
-
channelName: "tool.runAsync",
|
|
579
|
-
kind: "async"
|
|
580
|
-
})
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
// src/instrumentation/plugins/cohere-channels.ts
|
|
584
|
-
var cohereChannels = defineChannels("cohere-ai", {
|
|
585
|
-
chat: channel({
|
|
586
|
-
channelName: "chat",
|
|
587
|
-
kind: "async"
|
|
588
|
-
}),
|
|
589
|
-
chatStream: channel({
|
|
590
|
-
channelName: "chatStream",
|
|
591
|
-
kind: "async"
|
|
592
|
-
}),
|
|
593
|
-
embed: channel({
|
|
594
|
-
channelName: "embed",
|
|
595
|
-
kind: "async"
|
|
596
|
-
}),
|
|
597
|
-
rerank: channel({
|
|
598
|
-
channelName: "rerank",
|
|
599
|
-
kind: "async"
|
|
600
|
-
})
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
// src/instrumentation/plugins/groq-channels.ts
|
|
604
|
-
var groqChannels = defineChannels("groq-sdk", {
|
|
605
|
-
chatCompletionsCreate: channel({
|
|
606
|
-
channelName: "chat.completions.create",
|
|
607
|
-
kind: "async"
|
|
608
|
-
}),
|
|
609
|
-
embeddingsCreate: channel(
|
|
610
|
-
{
|
|
611
|
-
channelName: "embeddings.create",
|
|
612
|
-
kind: "async"
|
|
613
|
-
}
|
|
614
|
-
)
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
// src/instrumentation/plugins/bedrock-runtime-channels.ts
|
|
618
|
-
var clientSendChannel = channel({
|
|
619
|
-
channelName: "client.send",
|
|
620
|
-
kind: "async"
|
|
621
|
-
});
|
|
622
|
-
var bedrockRuntimeChannels = defineChannels("aws-bedrock-runtime", {
|
|
623
|
-
clientSend: clientSendChannel
|
|
624
|
-
});
|
|
625
|
-
var smithyCoreChannels = defineChannels("@smithy/core", {
|
|
626
|
-
clientSend: clientSendChannel
|
|
627
|
-
});
|
|
628
|
-
var smithyClientChannels = defineChannels("@smithy/smithy-client", {
|
|
629
|
-
clientSend: clientSendChannel
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// src/instrumentation/plugins/genkit-channels.ts
|
|
633
|
-
var genkitChannels = defineChannels("@genkit-ai/ai", {
|
|
634
|
-
generate: channel({
|
|
635
|
-
channelName: "generate",
|
|
636
|
-
kind: "async"
|
|
637
|
-
}),
|
|
638
|
-
generateStream: channel({
|
|
639
|
-
channelName: "generateStream",
|
|
640
|
-
kind: "sync-stream"
|
|
641
|
-
}),
|
|
642
|
-
embed: channel({
|
|
643
|
-
channelName: "embed",
|
|
644
|
-
kind: "async"
|
|
645
|
-
}),
|
|
646
|
-
embedMany: channel({
|
|
647
|
-
channelName: "embedMany",
|
|
648
|
-
kind: "async"
|
|
649
|
-
}),
|
|
650
|
-
actionRun: channel({
|
|
651
|
-
channelName: "action.run",
|
|
652
|
-
kind: "async"
|
|
653
|
-
}),
|
|
654
|
-
actionStream: channel({
|
|
655
|
-
channelName: "action.stream",
|
|
656
|
-
kind: "sync-stream"
|
|
657
|
-
})
|
|
658
|
-
});
|
|
659
|
-
var genkitCoreChannels = defineChannels("@genkit-ai/core", {
|
|
660
|
-
actionSpan: channel({
|
|
661
|
-
channelName: "action.span",
|
|
662
|
-
kind: "async"
|
|
663
|
-
})
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
// src/instrumentation/plugins/github-copilot-channels.ts
|
|
667
|
-
var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", {
|
|
668
|
-
createSession: channel({
|
|
669
|
-
channelName: "client.createSession",
|
|
670
|
-
kind: "async"
|
|
671
|
-
}),
|
|
672
|
-
resumeSession: channel({
|
|
673
|
-
channelName: "client.resumeSession",
|
|
674
|
-
kind: "async"
|
|
675
|
-
}),
|
|
676
|
-
sendAndWait: channel({
|
|
677
|
-
channelName: "session.sendAndWait",
|
|
678
|
-
kind: "async"
|
|
679
|
-
})
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
// src/instrumentation/plugins/flue-channels.ts
|
|
683
|
-
var flueChannels = defineChannels("@flue/runtime", {
|
|
684
|
-
createContext: channel({
|
|
685
|
-
channelName: "createFlueContext",
|
|
686
|
-
kind: "sync-stream"
|
|
687
|
-
})
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
// src/instrumentation/plugins/langsmith-channels.ts
|
|
691
|
-
var langSmithChannels = defineChannels("langsmith", {
|
|
692
|
-
createRun: channel({
|
|
693
|
-
channelName: "Client.createRun",
|
|
694
|
-
kind: "async"
|
|
695
|
-
}),
|
|
696
|
-
updateRun: channel({
|
|
697
|
-
channelName: "Client.updateRun",
|
|
698
|
-
kind: "async"
|
|
699
|
-
}),
|
|
700
|
-
batchIngestRuns: channel({
|
|
701
|
-
channelName: "Client.batchIngestRuns",
|
|
702
|
-
kind: "async"
|
|
703
|
-
})
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
// src/instrumentation/plugins/pi-coding-agent-channels.ts
|
|
707
|
-
var piCodingAgentChannels = defineChannels(
|
|
708
|
-
"@earendil-works/pi-coding-agent",
|
|
709
|
-
{
|
|
710
|
-
prompt: channel({
|
|
711
|
-
channelName: "AgentSession.prompt",
|
|
712
|
-
kind: "async"
|
|
713
|
-
})
|
|
714
|
-
}
|
|
715
|
-
);
|
|
716
|
-
|
|
717
|
-
// src/instrumentation/plugins/strands-agent-sdk-channels.ts
|
|
718
|
-
var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", {
|
|
719
|
-
agentStream: channel({
|
|
720
|
-
channelName: "Agent.stream",
|
|
721
|
-
kind: "sync-stream"
|
|
722
|
-
}),
|
|
723
|
-
graphStream: channel({
|
|
724
|
-
channelName: "Graph.stream",
|
|
725
|
-
kind: "sync-stream"
|
|
726
|
-
}),
|
|
727
|
-
swarmStream: channel({
|
|
728
|
-
channelName: "Swarm.stream",
|
|
729
|
-
kind: "sync-stream"
|
|
730
|
-
})
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
// src/instrumentation/config.ts
|
|
734
|
-
var envIntegrationAliases = {
|
|
735
|
-
openai: "openai",
|
|
736
|
-
"openai-codex": "openaiCodexSDK",
|
|
737
|
-
"openai-codex-sdk": "openaiCodexSDK",
|
|
738
|
-
openaicodexsdk: "openaiCodexSDK",
|
|
739
|
-
codex: "openaiCodexSDK",
|
|
740
|
-
"codex-sdk": "openaiCodexSDK",
|
|
741
|
-
"pi-coding-agent": "piCodingAgent",
|
|
742
|
-
"pi-coding-agent-sdk": "piCodingAgent",
|
|
743
|
-
picodingagent: "piCodingAgent",
|
|
744
|
-
picodingagentsdk: "piCodingAgent",
|
|
745
|
-
"@earendil-works/pi-coding-agent": "piCodingAgent",
|
|
746
|
-
strandsAgentSDK: "strandsAgentSDK",
|
|
747
|
-
strandsagentsdk: "strandsAgentSDK",
|
|
748
|
-
"strands-agent-sdk": "strandsAgentSDK",
|
|
749
|
-
"@strands-agents/sdk": "strandsAgentSDK",
|
|
750
|
-
anthropic: "anthropic",
|
|
751
|
-
aisdk: "aisdk",
|
|
752
|
-
"ai-sdk": "aisdk",
|
|
753
|
-
"vercel-ai": "aisdk",
|
|
754
|
-
vercel: "vercel",
|
|
755
|
-
claudeagentsdk: "claudeAgentSDK",
|
|
756
|
-
"claude-agent-sdk": "claudeAgentSDK",
|
|
757
|
-
cursor: "cursor",
|
|
758
|
-
"cursor-sdk": "cursorSDK",
|
|
759
|
-
cursorsdk: "cursorSDK",
|
|
760
|
-
flue: "flue",
|
|
761
|
-
"flue-runtime": "flue",
|
|
762
|
-
mastra: "mastra",
|
|
763
|
-
"openai-agents": "openAIAgents",
|
|
764
|
-
openaiagents: "openAIAgents",
|
|
765
|
-
"openai-agents-core": "openAIAgents",
|
|
766
|
-
openaiagentscore: "openAIAgents",
|
|
767
|
-
google: "google",
|
|
768
|
-
"google-genai": "googleGenAI",
|
|
769
|
-
googlegenai: "googleGenAI",
|
|
770
|
-
huggingface: "huggingface",
|
|
771
|
-
openrouter: "openrouter",
|
|
772
|
-
openrouteragent: "openrouterAgent",
|
|
773
|
-
"openrouter-agent": "openrouterAgent",
|
|
774
|
-
mistral: "mistral",
|
|
775
|
-
googleadk: "googleADK",
|
|
776
|
-
"google-adk": "googleADK",
|
|
777
|
-
cohere: "cohere",
|
|
778
|
-
groq: "groq",
|
|
779
|
-
"groq-sdk": "groq",
|
|
780
|
-
bedrock: "bedrock",
|
|
781
|
-
"aws-bedrock": "awsBedrock",
|
|
782
|
-
awsbedrock: "awsBedrock",
|
|
783
|
-
"aws-bedrock-runtime": "awsBedrockRuntime",
|
|
784
|
-
awsbedrockruntime: "awsBedrockRuntime",
|
|
785
|
-
"@aws-sdk/client-bedrock-runtime": "awsBedrockRuntime",
|
|
786
|
-
genkit: "genkit",
|
|
787
|
-
"firebase-genkit": "genkit",
|
|
788
|
-
githubcopilot: "gitHubCopilot",
|
|
789
|
-
"github-copilot": "gitHubCopilot",
|
|
790
|
-
"copilot-sdk": "gitHubCopilot",
|
|
791
|
-
langchain: "langchain",
|
|
792
|
-
"langchain-js": "langchain",
|
|
793
|
-
"@langchain": "langchain",
|
|
794
|
-
langgraph: "langgraph",
|
|
795
|
-
langsmith: "langsmith"
|
|
796
|
-
};
|
|
797
|
-
function getDefaultInstrumentationIntegrations() {
|
|
798
|
-
return {
|
|
799
|
-
openai: true,
|
|
800
|
-
openaiCodexSDK: true,
|
|
801
|
-
anthropic: true,
|
|
802
|
-
vercel: true,
|
|
803
|
-
aisdk: true,
|
|
804
|
-
google: true,
|
|
805
|
-
googleGenAI: true,
|
|
806
|
-
googleADK: true,
|
|
807
|
-
huggingface: true,
|
|
808
|
-
claudeAgentSDK: true,
|
|
809
|
-
cursor: true,
|
|
810
|
-
cursorSDK: true,
|
|
811
|
-
flue: true,
|
|
812
|
-
mastra: true,
|
|
813
|
-
openAIAgents: true,
|
|
814
|
-
openrouter: true,
|
|
815
|
-
openrouterAgent: true,
|
|
816
|
-
mistral: true,
|
|
817
|
-
cohere: true,
|
|
818
|
-
groq: true,
|
|
819
|
-
bedrock: true,
|
|
820
|
-
awsBedrock: true,
|
|
821
|
-
awsBedrockRuntime: true,
|
|
822
|
-
genkit: true,
|
|
823
|
-
gitHubCopilot: true,
|
|
824
|
-
langchain: true,
|
|
825
|
-
langgraph: true,
|
|
826
|
-
langsmith: true,
|
|
827
|
-
piCodingAgent: true,
|
|
828
|
-
strandsAgentSDK: true
|
|
829
|
-
};
|
|
830
|
-
}
|
|
831
|
-
function readDisabledInstrumentationEnvConfig(disabledList) {
|
|
832
|
-
const integrations = {};
|
|
833
|
-
if (disabledList) {
|
|
834
|
-
for (const value of disabledList.split(",")) {
|
|
835
|
-
const rawSdk = value.trim();
|
|
836
|
-
const sdk = rawSdk.toLowerCase();
|
|
837
|
-
if (sdk.length > 0) {
|
|
838
|
-
integrations[envIntegrationAliases[rawSdk] ?? envIntegrationAliases[sdk] ?? sdk] = false;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
return { integrations };
|
|
843
|
-
}
|
|
844
|
-
function isInstrumentationIntegrationDisabled(integrations, ...names) {
|
|
845
|
-
return names.some((name) => integrations?.[name] === false);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
// src/auto-instrumentations/loader/mastra-observability-patch.ts
|
|
849
|
-
var MASTRA_EXPORTER_FACTORY_GLOBAL = "__braintrustMastraExporterFactory";
|
|
850
|
-
function installMastraExporterFactory(factory) {
|
|
851
|
-
const globals = globalThis;
|
|
852
|
-
globals[MASTRA_EXPORTER_FACTORY_GLOBAL] ??= factory;
|
|
853
|
-
}
|
|
854
|
-
var MASTRA_CORE_PACKAGE = "@mastra/core";
|
|
855
|
-
var MASTRA_OBSERVABILITY_PACKAGE = "@mastra/observability";
|
|
856
|
-
var MASTRA_CORE_ENTRY_PATHS = /* @__PURE__ */ new Set([
|
|
857
|
-
"dist/index.js",
|
|
858
|
-
"dist/index.cjs",
|
|
859
|
-
"dist/mastra/index.js",
|
|
860
|
-
"dist/mastra/index.cjs"
|
|
861
|
-
]);
|
|
862
|
-
var MASTRA_OBSERVABILITY_ENTRY_PATHS = /* @__PURE__ */ new Set([
|
|
863
|
-
"dist/index.js",
|
|
864
|
-
"dist/index.cjs"
|
|
865
|
-
]);
|
|
866
|
-
function classifyMastraTarget(packageName, modulePath) {
|
|
867
|
-
if (packageName === MASTRA_CORE_PACKAGE && MASTRA_CORE_ENTRY_PATHS.has(modulePath)) {
|
|
868
|
-
return "core";
|
|
869
|
-
}
|
|
870
|
-
if (packageName === MASTRA_OBSERVABILITY_PACKAGE && MASTRA_OBSERVABILITY_ENTRY_PATHS.has(modulePath)) {
|
|
871
|
-
return "observability";
|
|
872
|
-
}
|
|
873
|
-
return null;
|
|
874
|
-
}
|
|
875
|
-
function extractChunkPath(source) {
|
|
876
|
-
const esmMatch = source.match(
|
|
877
|
-
/export\s*\{\s*Mastra(?:\s+as\s+\w+)?\s*\}\s*from\s*['"]([^'"]+)['"]/
|
|
878
|
-
);
|
|
879
|
-
if (esmMatch) return esmMatch[1];
|
|
880
|
-
const cjsMatch = source.match(
|
|
881
|
-
/require\s*\(\s*['"]([^'"]+chunk-[^'"]+)['"]\s*\)/
|
|
882
|
-
);
|
|
883
|
-
if (cjsMatch) return cjsMatch[1];
|
|
884
|
-
return null;
|
|
885
|
-
}
|
|
886
|
-
var EXPORTER_FACTORY_KEY = JSON.stringify(MASTRA_EXPORTER_FACTORY_GLOBAL);
|
|
887
|
-
var MASTRA_PROXY_HANDLER_BODY = `
|
|
888
|
-
{
|
|
889
|
-
construct(target, args, newTarget) {
|
|
890
|
-
var firstArg = args[0];
|
|
891
|
-
if (
|
|
892
|
-
(!firstArg || typeof firstArg !== "object" || !firstArg.observability) &&
|
|
893
|
-
__braintrustObservabilityClass
|
|
894
|
-
) {
|
|
895
|
-
try {
|
|
896
|
-
// serviceName is required by Mastra's Observability validator; pass
|
|
897
|
-
// something sensible by default. Users who want a different name
|
|
898
|
-
// should construct Observability themselves.
|
|
899
|
-
var observability = new __braintrustObservabilityClass({
|
|
900
|
-
configs: { default: { serviceName: "mastra" } },
|
|
901
|
-
});
|
|
902
|
-
args = args.slice();
|
|
903
|
-
args[0] = Object.assign({}, firstArg, { observability: observability });
|
|
904
|
-
} catch (e) {
|
|
905
|
-
// Fall through. Mastra will use its own NoOp; user code still works,
|
|
906
|
-
// just without auto-instrumentation.
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
return Reflect.construct(target, args, newTarget);
|
|
910
|
-
},
|
|
911
|
-
}`;
|
|
912
|
-
function buildMastraEsmWrapper(chunkPath) {
|
|
913
|
-
const chunk = JSON.stringify(chunkPath);
|
|
914
|
-
return `import { Mastra as __braintrustOrigMastra } from ${chunk};
|
|
915
|
-
import { createRequire as __braintrustCreateRequire } from "node:module";
|
|
916
|
-
|
|
917
|
-
let __braintrustObservabilityClass = null;
|
|
918
|
-
try {
|
|
919
|
-
// Resolve @mastra/observability relative to this module (the Mastra entry),
|
|
920
|
-
// so it's looked up from the user's node_modules tree.
|
|
921
|
-
const __braintrustRequire = __braintrustCreateRequire(import.meta.url);
|
|
922
|
-
__braintrustObservabilityClass =
|
|
923
|
-
__braintrustRequire("@mastra/observability").Observability;
|
|
924
|
-
} catch (e) {
|
|
925
|
-
// @mastra/observability isn't installed; the construct trap will skip the
|
|
926
|
-
// auto-construct branch and Mastra falls back to its own NoOp.
|
|
927
|
-
}
|
|
928
|
-
const Mastra = new Proxy(__braintrustOrigMastra, ${MASTRA_PROXY_HANDLER_BODY});
|
|
929
|
-
export { Mastra };
|
|
930
|
-
`;
|
|
931
|
-
}
|
|
932
|
-
function buildMastraCjsWrapper(chunkPath) {
|
|
933
|
-
const chunk = JSON.stringify(chunkPath);
|
|
934
|
-
return `'use strict';
|
|
935
|
-
const __braintrustChunk = require(${chunk});
|
|
936
|
-
|
|
937
|
-
let __braintrustObservabilityClass = null;
|
|
938
|
-
try {
|
|
939
|
-
__braintrustObservabilityClass = require("@mastra/observability").Observability;
|
|
940
|
-
} catch (e) {
|
|
941
|
-
// @mastra/observability isn't installed; same fallback as the ESM wrapper.
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
const __braintrustWrappedMastra = new Proxy(
|
|
945
|
-
__braintrustChunk.Mastra,
|
|
946
|
-
${MASTRA_PROXY_HANDLER_BODY},
|
|
947
|
-
);
|
|
948
|
-
Object.defineProperty(exports, "Mastra", {
|
|
949
|
-
enumerable: true,
|
|
950
|
-
configurable: true,
|
|
951
|
-
get: function () { return __braintrustWrappedMastra; }
|
|
952
|
-
});
|
|
953
|
-
`;
|
|
954
|
-
}
|
|
955
|
-
var OBSERVABILITY_APPEND_BODY = `
|
|
956
|
-
;(function __braintrustWrapObservability() {
|
|
957
|
-
// Top-level so we can both read and reassign the var binding the original
|
|
958
|
-
// entry declared.
|
|
959
|
-
if (typeof Observability === "undefined") return;
|
|
960
|
-
if (Observability.__braintrustWrapped) return;
|
|
961
|
-
function __braintrustEnsureExporter(rawConfig) {
|
|
962
|
-
try {
|
|
963
|
-
var factory = globalThis[${EXPORTER_FACTORY_KEY}];
|
|
964
|
-
if (typeof factory !== "function") return rawConfig;
|
|
965
|
-
var config = rawConfig && typeof rawConfig === "object" ? rawConfig : {};
|
|
966
|
-
var configsIn = config.configs && typeof config.configs === "object" ? config.configs : null;
|
|
967
|
-
var configsOut = {};
|
|
968
|
-
var hadEntries = false;
|
|
969
|
-
if (configsIn) {
|
|
970
|
-
for (var name in configsIn) {
|
|
971
|
-
if (!Object.prototype.hasOwnProperty.call(configsIn, name)) continue;
|
|
972
|
-
hadEntries = true;
|
|
973
|
-
var inst = configsIn[name] || {};
|
|
974
|
-
var existing = Array.isArray(inst.exporters) ? inst.exporters : [];
|
|
975
|
-
var hasOurs = existing.some(function (e) { return e && e.name === "braintrust"; });
|
|
976
|
-
configsOut[name] = Object.assign({}, inst, {
|
|
977
|
-
exporters: hasOurs ? existing : existing.concat([factory()]),
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
if (!hadEntries) {
|
|
982
|
-
configsOut.default = {
|
|
983
|
-
serviceName: "mastra",
|
|
984
|
-
exporters: [factory()],
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
return Object.assign({}, config, { configs: configsOut });
|
|
988
|
-
} catch (e) {
|
|
989
|
-
return rawConfig;
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
var __OriginalObservability = Observability;
|
|
993
|
-
Observability = new Proxy(__OriginalObservability, {
|
|
994
|
-
construct: function (target, args, newTarget) {
|
|
995
|
-
var nextArgs = args.slice();
|
|
996
|
-
nextArgs[0] = __braintrustEnsureExporter(nextArgs[0]);
|
|
997
|
-
return Reflect.construct(target, nextArgs, newTarget);
|
|
998
|
-
},
|
|
999
|
-
});
|
|
1000
|
-
Observability.__braintrustWrapped = true;
|
|
1001
|
-
if (typeof exports !== "undefined" && exports && typeof exports === "object") {
|
|
1002
|
-
try {
|
|
1003
|
-
Object.defineProperty(exports, "Observability", {
|
|
1004
|
-
enumerable: true,
|
|
1005
|
-
configurable: true,
|
|
1006
|
-
get: function () { return Observability; },
|
|
1007
|
-
});
|
|
1008
|
-
} catch (e) {}
|
|
1009
|
-
}
|
|
1010
|
-
})();
|
|
1011
|
-
`;
|
|
1012
|
-
function patchMastraSource(source, target, format) {
|
|
1013
|
-
if (target === "core") {
|
|
1014
|
-
const chunkPath = extractChunkPath(source);
|
|
1015
|
-
if (!chunkPath) return source;
|
|
1016
|
-
return format === "esm" ? buildMastraEsmWrapper(chunkPath) : buildMastraCjsWrapper(chunkPath);
|
|
1017
|
-
}
|
|
1018
|
-
return source + OBSERVABILITY_APPEND_BODY;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
// src/instrumentation/plugins/openai-agents-channels.ts
|
|
1022
|
-
var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
|
|
1023
|
-
onTraceStart: channel({
|
|
1024
|
-
channelName: "tracing.processor.onTraceStart",
|
|
1025
|
-
kind: "async"
|
|
1026
|
-
}),
|
|
1027
|
-
onTraceEnd: channel({
|
|
1028
|
-
channelName: "tracing.processor.onTraceEnd",
|
|
1029
|
-
kind: "async"
|
|
1030
|
-
}),
|
|
1031
|
-
onSpanStart: channel({
|
|
1032
|
-
channelName: "tracing.processor.onSpanStart",
|
|
1033
|
-
kind: "async"
|
|
1034
|
-
}),
|
|
1035
|
-
onSpanEnd: channel({
|
|
1036
|
-
channelName: "tracing.processor.onSpanEnd",
|
|
1037
|
-
kind: "async"
|
|
1038
|
-
})
|
|
1039
|
-
});
|
|
1040
|
-
|
|
1041
|
-
// src/instrumentation/plugins/langchain-channels.ts
|
|
1042
|
-
var langChainChannels = defineChannels("@langchain/core", {
|
|
1043
|
-
configure: channel({
|
|
1044
|
-
channelName: "CallbackManager.configure",
|
|
1045
|
-
kind: "sync-stream"
|
|
1046
|
-
}),
|
|
1047
|
-
configureSync: channel({
|
|
1048
|
-
channelName: "CallbackManager._configureSync",
|
|
1049
|
-
kind: "sync-stream"
|
|
1050
|
-
})
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
export {
|
|
1054
|
-
__export,
|
|
1055
|
-
patchTracingChannel,
|
|
1056
|
-
isomorph_default,
|
|
1057
|
-
openAIChannels,
|
|
1058
|
-
openAICodexChannels,
|
|
1059
|
-
anthropicChannels,
|
|
1060
|
-
aiSDKChannels,
|
|
1061
|
-
harnessAgentChannels,
|
|
1062
|
-
claudeAgentSDKChannels,
|
|
1063
|
-
cursorSDKChannels,
|
|
1064
|
-
openAIAgentsCoreChannels,
|
|
1065
|
-
googleGenAIChannels,
|
|
1066
|
-
huggingFaceChannels,
|
|
1067
|
-
openRouterAgentChannels,
|
|
1068
|
-
openRouterChannels,
|
|
1069
|
-
mistralChannels,
|
|
1070
|
-
googleADKChannels,
|
|
1071
|
-
cohereChannels,
|
|
1072
|
-
groqChannels,
|
|
1073
|
-
bedrockRuntimeChannels,
|
|
1074
|
-
smithyCoreChannels,
|
|
1075
|
-
smithyClientChannels,
|
|
1076
|
-
genkitChannels,
|
|
1077
|
-
genkitCoreChannels,
|
|
1078
|
-
gitHubCopilotChannels,
|
|
1079
|
-
flueChannels,
|
|
1080
|
-
langChainChannels,
|
|
1081
|
-
langSmithChannels,
|
|
1082
|
-
piCodingAgentChannels,
|
|
1083
|
-
strandsAgentSDKChannels,
|
|
1084
|
-
getDefaultInstrumentationIntegrations,
|
|
1085
|
-
readDisabledInstrumentationEnvConfig,
|
|
1086
|
-
isInstrumentationIntegrationDisabled,
|
|
1087
|
-
installMastraExporterFactory,
|
|
1088
|
-
classifyMastraTarget,
|
|
1089
|
-
patchMastraSource
|
|
1090
|
-
};
|