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.
Files changed (80) hide show
  1. package/NOTICE +6 -0
  2. package/dev/dist/index.d.mts +135 -2
  3. package/dev/dist/index.d.ts +135 -2
  4. package/dev/dist/index.js +4426 -2040
  5. package/dev/dist/index.mjs +3594 -1208
  6. package/dist/apply-auto-instrumentation.js +445 -403
  7. package/dist/apply-auto-instrumentation.mjs +249 -207
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +1449 -799
  9. package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
  10. package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
  11. package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
  12. package/dist/auto-instrumentations/bundler/next.cjs +1448 -818
  13. package/dist/auto-instrumentations/bundler/next.mjs +6 -29
  14. package/dist/auto-instrumentations/bundler/rollup.cjs +1449 -799
  15. package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
  16. package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
  17. package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
  18. package/dist/auto-instrumentations/bundler/vite.cjs +1449 -799
  19. package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
  20. package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
  21. package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
  22. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1602 -728
  23. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
  24. package/dist/auto-instrumentations/bundler/webpack.cjs +1449 -799
  25. package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
  26. package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
  27. package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
  28. package/dist/auto-instrumentations/{chunk-GSZHTAQW.mjs → chunk-6E22MYSW.mjs} +194 -93
  29. package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
  30. package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
  31. package/dist/auto-instrumentations/{chunk-BURMPO7L.mjs → chunk-V5LEODRX.mjs} +2 -6
  32. package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
  33. package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-XZHHE4Y3.mjs} +646 -510
  34. package/dist/auto-instrumentations/hook.mjs +894 -657
  35. package/dist/auto-instrumentations/index.cjs +1125 -490
  36. package/dist/auto-instrumentations/index.d.mts +6 -2
  37. package/dist/auto-instrumentations/index.d.ts +6 -2
  38. package/dist/auto-instrumentations/index.mjs +6 -1
  39. package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
  40. package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
  41. package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
  42. package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
  43. package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
  44. package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
  45. package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
  46. package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
  47. package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
  48. package/dist/browser.d.mts +824 -197
  49. package/dist/browser.d.ts +824 -197
  50. package/dist/browser.js +3897 -1228
  51. package/dist/browser.mjs +3897 -1228
  52. package/dist/chunk-PN7EWK66.mjs +1784 -0
  53. package/dist/{chunk-SU6EHKJV.js → chunk-VRZZQPAA.js} +3289 -1577
  54. package/dist/chunk-VYNNEKSA.js +1784 -0
  55. package/dist/{chunk-XE5FS7QY.mjs → chunk-XIZOM2HO.mjs} +2470 -758
  56. package/dist/cli.js +3596 -1211
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +3897 -1231
  60. package/dist/edge-light.mjs +3897 -1231
  61. package/dist/index.d.mts +824 -197
  62. package/dist/index.d.ts +824 -197
  63. package/dist/index.js +750 -445
  64. package/dist/index.mjs +334 -29
  65. package/dist/instrumentation/index.d.mts +135 -6
  66. package/dist/instrumentation/index.d.ts +135 -6
  67. package/dist/instrumentation/index.js +3696 -1257
  68. package/dist/instrumentation/index.mjs +3696 -1257
  69. package/dist/vitest-evals-reporter.js +16 -16
  70. package/dist/vitest-evals-reporter.mjs +2 -2
  71. package/dist/workerd.d.mts +1 -1
  72. package/dist/workerd.d.ts +1 -1
  73. package/dist/workerd.js +3897 -1231
  74. package/dist/workerd.mjs +3897 -1231
  75. package/licenses/node-diagnostics-channel/LICENSE +19 -0
  76. package/package.json +34 -35
  77. package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
  78. package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
  79. package/dist/chunk-7AUY2XWX.js +0 -1090
  80. package/dist/chunk-7F6GCRHH.mjs +0 -1090
@@ -34,52 +34,583 @@ var import_source_map = require("source-map");
34
34
  // src/auto-instrumentations/orchestrion-js/transforms.ts
35
35
  var import_esquery = __toESM(require("esquery"));
36
36
  var import_meriyah = require("meriyah");
37
- var tracingChannelPredicate = (node) => node.declarations?.[0]?.id?.properties?.[0]?.value?.name === "tr_ch_apm_tracingChannel";
38
- var CHANNEL_REGEX = /[^\w]/g;
39
- function formatChannelVariable(channelName) {
40
- return `tr_ch_apm$${channelName.replace(CHANNEL_REGEX, "_")}`;
37
+
38
+ // src/global-instrumentation-hooks.ts
39
+ var GLOBAL_INSTRUMENTATION_HOOKS_KEY = "__braintrust_instrumentation_hooks";
40
+ var GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION = 1;
41
+ var GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND = "braintrust.global-instrumentation-hooks.registry";
42
+ var GLOBAL_INSTRUMENTATION_HOOK_BRAND = "braintrust.global-instrumentation-hooks.hook";
43
+ var registryBrand = Symbol.for(GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND);
44
+ var hookBrand = Symbol.for(GLOBAL_INSTRUMENTATION_HOOK_BRAND);
45
+ var errorReporter;
46
+ function reportError(error) {
47
+ try {
48
+ errorReporter?.(error);
49
+ } catch {
50
+ }
41
51
  }
42
- var transforms = {
43
- tracingChannelImport({ dcModule, moduleType }, node) {
44
- if (node.body.some(tracingChannelPredicate)) {
52
+ function setContextValue(context, key, value) {
53
+ try {
54
+ context[key] = value;
55
+ } catch (error) {
56
+ reportError(error);
57
+ }
58
+ }
59
+ function wrapStoreRun(store, message, next, transform) {
60
+ return () => {
61
+ let context;
62
+ try {
63
+ context = transform ? transform(message) : message;
64
+ } catch (error) {
65
+ reportError(error);
66
+ return next();
67
+ }
68
+ let called = false;
69
+ let result;
70
+ let providerError;
71
+ let providerThrew = false;
72
+ const runNext = () => {
73
+ if (called) {
74
+ reportError(
75
+ new Error(
76
+ "Instrumentation store invoked its callback more than once"
77
+ )
78
+ );
79
+ if (providerThrew) {
80
+ throw providerError;
81
+ }
82
+ return result;
83
+ }
84
+ called = true;
85
+ try {
86
+ result = next();
87
+ return result;
88
+ } catch (error) {
89
+ providerThrew = true;
90
+ providerError = error;
91
+ throw error;
92
+ }
93
+ };
94
+ try {
95
+ store.run(context, runNext);
96
+ } catch (error) {
97
+ if (!providerThrew || error !== providerError) {
98
+ reportError(error);
99
+ }
100
+ }
101
+ if (!called) {
102
+ reportError(
103
+ new Error("Instrumentation store did not invoke its callback")
104
+ );
105
+ return runNext();
106
+ }
107
+ if (providerThrew) {
108
+ throw providerError;
109
+ }
110
+ return result;
111
+ };
112
+ }
113
+ var HookChannel = class {
114
+ constructor(name) {
115
+ this.name = name;
116
+ }
117
+ name;
118
+ subscribers = [];
119
+ stores = /* @__PURE__ */ new Map();
120
+ get hasSubscribers() {
121
+ return this.subscribers.length > 0 || this.stores.size > 0;
122
+ }
123
+ subscribe(subscription) {
124
+ if (typeof subscription !== "function") {
125
+ throw new TypeError("subscription must be a function");
126
+ }
127
+ this.subscribers = [...this.subscribers, subscription];
128
+ }
129
+ unsubscribe(subscription) {
130
+ const index = this.subscribers.indexOf(subscription);
131
+ if (index === -1) {
132
+ return false;
133
+ }
134
+ this.subscribers = [
135
+ ...this.subscribers.slice(0, index),
136
+ ...this.subscribers.slice(index + 1)
137
+ ];
138
+ return true;
139
+ }
140
+ bindStore(store, transform) {
141
+ if (!store || typeof store.run !== "function") {
142
+ throw new TypeError("store must have a run method");
143
+ }
144
+ this.stores.set(
145
+ store,
146
+ transform
147
+ );
148
+ }
149
+ unbindStore(store) {
150
+ return this.stores.delete(store);
151
+ }
152
+ publish(message) {
153
+ const subscribers = this.subscribers;
154
+ for (const subscriber of subscribers) {
155
+ try {
156
+ subscriber(message, this.name);
157
+ } catch (error) {
158
+ reportError(error);
159
+ }
160
+ }
161
+ }
162
+ runStores(message, fn, thisArg, ...args) {
163
+ let run = () => {
164
+ this.publish(message);
165
+ return Reflect.apply(fn, thisArg, args);
166
+ };
167
+ for (const [store, transform] of this.stores.entries()) {
168
+ run = wrapStoreRun(store, message, run, transform);
169
+ }
170
+ return run();
171
+ }
172
+ };
173
+ var traceEvents = [
174
+ "start",
175
+ "end",
176
+ "asyncStart",
177
+ "asyncEnd",
178
+ "error"
179
+ ];
180
+ var TracingHook = class {
181
+ start;
182
+ end;
183
+ asyncStart;
184
+ asyncEnd;
185
+ error;
186
+ constructor(nameOrChannels) {
187
+ Object.defineProperty(this, hookBrand, {
188
+ configurable: false,
189
+ enumerable: false,
190
+ value: GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
191
+ writable: false
192
+ });
193
+ if (typeof nameOrChannels === "string") {
194
+ this.start = new HookChannel(`tracing:${nameOrChannels}:start`);
195
+ this.end = new HookChannel(`tracing:${nameOrChannels}:end`);
196
+ this.asyncStart = new HookChannel(`tracing:${nameOrChannels}:asyncStart`);
197
+ this.asyncEnd = new HookChannel(`tracing:${nameOrChannels}:asyncEnd`);
198
+ this.error = new HookChannel(`tracing:${nameOrChannels}:error`);
45
199
  return;
46
200
  }
47
- const options = { module: moduleType === "esm" };
48
- const index = node.body.findIndex(
49
- (child) => child.directive === "use strict"
201
+ this.start = nameOrChannels.start ?? new HookChannel("tracing:start");
202
+ this.end = nameOrChannels.end ?? new HookChannel("tracing:end");
203
+ this.asyncStart = nameOrChannels.asyncStart ?? new HookChannel("tracing:asyncStart");
204
+ this.asyncEnd = nameOrChannels.asyncEnd ?? new HookChannel("tracing:asyncEnd");
205
+ this.error = nameOrChannels.error ?? new HookChannel("tracing:error");
206
+ }
207
+ get hasSubscribers() {
208
+ return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
209
+ }
210
+ subscribe(handlers) {
211
+ for (const eventName of traceEvents) {
212
+ const handler = handlers[eventName];
213
+ if (handler) {
214
+ this[eventName].subscribe(handler);
215
+ }
216
+ }
217
+ }
218
+ unsubscribe(handlers) {
219
+ let done = true;
220
+ for (const eventName of traceEvents) {
221
+ const handler = handlers[eventName];
222
+ if (handler && !this[eventName].unsubscribe(handler)) {
223
+ done = false;
224
+ }
225
+ }
226
+ return done;
227
+ }
228
+ traceSync(fn, message = {}, thisArg, ...args) {
229
+ if (!this.hasSubscribers) {
230
+ return Reflect.apply(fn, thisArg, args);
231
+ }
232
+ const context = message;
233
+ return this.start.runStores(message, () => {
234
+ try {
235
+ const result = Reflect.apply(fn, thisArg, args);
236
+ setContextValue(context, "result", result);
237
+ return result;
238
+ } catch (error) {
239
+ setContextValue(context, "error", error);
240
+ this.error.publish(message);
241
+ throw error;
242
+ } finally {
243
+ this.end.publish(message);
244
+ }
245
+ });
246
+ }
247
+ tracePromise(fn, message = {}, thisArg, ...args) {
248
+ if (!this.hasSubscribers) {
249
+ return Reflect.apply(fn, thisArg, args);
250
+ }
251
+ const context = message;
252
+ return this.start.runStores(message, () => {
253
+ let result;
254
+ try {
255
+ result = Reflect.apply(fn, thisArg, args);
256
+ } catch (error) {
257
+ setContextValue(context, "error", error);
258
+ this.error.publish(message);
259
+ this.end.publish(message);
260
+ throw error;
261
+ }
262
+ this.end.publish(message);
263
+ if (!result || typeof result !== "object" && typeof result !== "function") {
264
+ setContextValue(context, "result", result);
265
+ this.asyncStart.publish(message);
266
+ this.asyncEnd.publish(message);
267
+ return result;
268
+ }
269
+ let terminalPublished = false;
270
+ const finishUnobservedResult = (error) => {
271
+ reportError(error);
272
+ if (!terminalPublished) {
273
+ terminalPublished = true;
274
+ setContextValue(context, "result", result);
275
+ this.asyncStart.publish(message);
276
+ this.asyncEnd.publish(message);
277
+ }
278
+ return result;
279
+ };
280
+ let then;
281
+ try {
282
+ then = result.then;
283
+ } catch (error) {
284
+ return finishUnobservedResult(error);
285
+ }
286
+ if (typeof then !== "function") {
287
+ setContextValue(context, "result", result);
288
+ this.asyncStart.publish(message);
289
+ this.asyncEnd.publish(message);
290
+ return result;
291
+ }
292
+ const resolve = (resolved) => {
293
+ if (!terminalPublished) {
294
+ terminalPublished = true;
295
+ setContextValue(context, "result", resolved);
296
+ this.asyncStart.publish(message);
297
+ this.asyncEnd.publish(message);
298
+ }
299
+ return resolved;
300
+ };
301
+ let rejectionThrown = false;
302
+ let rejectionError;
303
+ const reject = (error) => {
304
+ if (!terminalPublished) {
305
+ terminalPublished = true;
306
+ setContextValue(context, "error", error);
307
+ this.error.publish(message);
308
+ this.asyncStart.publish(message);
309
+ this.asyncEnd.publish(message);
310
+ }
311
+ rejectionThrown = true;
312
+ rejectionError = error;
313
+ throw error;
314
+ };
315
+ let isPlainPromise;
316
+ try {
317
+ isPlainPromise = result instanceof Promise && result.constructor === Promise;
318
+ } catch (error) {
319
+ return finishUnobservedResult(error);
320
+ }
321
+ try {
322
+ if (isPlainPromise) {
323
+ return Reflect.apply(then, result, [resolve, reject]);
324
+ }
325
+ Reflect.apply(then, result, [
326
+ resolve,
327
+ (error) => {
328
+ try {
329
+ reject(error);
330
+ } catch {
331
+ }
332
+ }
333
+ ]);
334
+ } catch (error) {
335
+ if (rejectionThrown && error === rejectionError) {
336
+ return result;
337
+ }
338
+ return finishUnobservedResult(error);
339
+ }
340
+ return result;
341
+ });
342
+ }
343
+ traceCallback(fn, position = -1, message = {}, thisArg, ...args) {
344
+ if (!this.hasSubscribers) {
345
+ return Reflect.apply(fn, thisArg, args);
346
+ }
347
+ const context = message;
348
+ const callArgs = args.length > 0 ? args : context.arguments ?? args;
349
+ const callback = Array.prototype.at.call(callArgs, position);
350
+ if (typeof callback !== "function") {
351
+ return Reflect.apply(fn, thisArg, args);
352
+ }
353
+ const { asyncStart, asyncEnd, error: errorChannel } = this;
354
+ function wrappedCallback(error, result) {
355
+ if (error) {
356
+ setContextValue(context, "error", error);
357
+ errorChannel.publish(message);
358
+ } else {
359
+ setContextValue(context, "result", result);
360
+ }
361
+ return asyncStart.runStores(message, () => {
362
+ try {
363
+ return Reflect.apply(callback, this, arguments);
364
+ } finally {
365
+ asyncEnd.publish(message);
366
+ }
367
+ });
368
+ }
369
+ Array.prototype.splice.call(callArgs, position, 1, wrappedCallback);
370
+ return this.start.runStores(message, () => {
371
+ try {
372
+ return Reflect.apply(fn, thisArg, args);
373
+ } catch (error) {
374
+ setContextValue(context, "error", error);
375
+ this.error.publish(message);
376
+ throw error;
377
+ } finally {
378
+ this.end.publish(message);
379
+ }
380
+ });
381
+ }
382
+ };
383
+ var inertChannel = Object.freeze({
384
+ name: "braintrust:inert",
385
+ hasSubscribers: false,
386
+ subscribe() {
387
+ },
388
+ unsubscribe() {
389
+ return false;
390
+ },
391
+ bindStore() {
392
+ },
393
+ unbindStore() {
394
+ return false;
395
+ },
396
+ publish() {
397
+ },
398
+ runStores(_message, fn, thisArg, ...args) {
399
+ return Reflect.apply(fn, thisArg, args);
400
+ }
401
+ });
402
+ var inertTracingHook = new TracingHook({
403
+ start: inertChannel,
404
+ end: inertChannel,
405
+ asyncStart: inertChannel,
406
+ asyncEnd: inertChannel,
407
+ error: inertChannel
408
+ });
409
+ function isHookChannel(value) {
410
+ if (typeof value !== "object" && typeof value !== "function" || value === null) {
411
+ return false;
412
+ }
413
+ try {
414
+ const channel2 = value;
415
+ return typeof channel2.hasSubscribers === "boolean" && typeof channel2.subscribe === "function" && typeof channel2.unsubscribe === "function" && typeof channel2.bindStore === "function" && typeof channel2.unbindStore === "function" && typeof channel2.publish === "function" && typeof channel2.runStores === "function";
416
+ } catch {
417
+ return false;
418
+ }
419
+ }
420
+ function hasTracingHookShape(value) {
421
+ if (typeof value !== "object" && typeof value !== "function" || value === null) {
422
+ return false;
423
+ }
424
+ try {
425
+ const hook = value;
426
+ return typeof hook.hasSubscribers === "boolean" && typeof hook.subscribe === "function" && typeof hook.unsubscribe === "function" && typeof hook.traceSync === "function" && typeof hook.tracePromise === "function" && typeof hook.traceCallback === "function" && isHookChannel(hook.start) && isHookChannel(hook.end) && isHookChannel(hook.asyncStart) && isHookChannel(hook.asyncEnd) && isHookChannel(hook.error);
427
+ } catch {
428
+ return false;
429
+ }
430
+ }
431
+ function isCompatibleTracingHook(value) {
432
+ try {
433
+ return value[hookBrand] === GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION && hasTracingHookShape(value);
434
+ } catch {
435
+ return false;
436
+ }
437
+ }
438
+ function isCompatibleHookRegistry(value) {
439
+ try {
440
+ return value instanceof Map && value[registryBrand] === GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION;
441
+ } catch {
442
+ return false;
443
+ }
444
+ }
445
+ function getHookRegistry() {
446
+ let descriptor;
447
+ try {
448
+ descriptor = Object.getOwnPropertyDescriptor(
449
+ globalThis,
450
+ GLOBAL_INSTRUMENTATION_HOOKS_KEY
50
451
  );
51
- const dc = moduleType === "esm" ? `import tr_ch_apm_dc from "${dcModule}"` : `const tr_ch_apm_dc = ${"require"}("${dcModule}")`;
52
- const tracingChannel = "const { tracingChannel: tr_ch_apm_tracingChannel } = tr_ch_apm_dc";
53
- const hasSubscribers = `const tr_ch_apm_hasSubscribers = ch => ch.start.hasSubscribers
54
- || ch.end.hasSubscribers
55
- || ch.asyncStart.hasSubscribers
56
- || ch.asyncEnd.hasSubscribers
57
- || ch.error.hasSubscribers`;
58
- node.body.splice(
59
- index + 1,
60
- 0,
61
- (0, import_meriyah.parse)(dc, options).body[0],
62
- (0, import_meriyah.parse)(tracingChannel, options).body[0],
63
- (0, import_meriyah.parse)(hasSubscribers, options).body[0]
452
+ } catch (error) {
453
+ reportError(error);
454
+ return void 0;
455
+ }
456
+ if (descriptor && "value" in descriptor && isCompatibleHookRegistry(descriptor.value) && (descriptor.configurable || descriptor.enumerable === false)) {
457
+ if (descriptor.configurable || descriptor.writable) {
458
+ try {
459
+ Object.defineProperty(globalThis, GLOBAL_INSTRUMENTATION_HOOKS_KEY, {
460
+ configurable: false,
461
+ enumerable: false,
462
+ value: descriptor.value,
463
+ writable: false
464
+ });
465
+ } catch (error) {
466
+ reportError(error);
467
+ return void 0;
468
+ }
469
+ }
470
+ return descriptor.value;
471
+ }
472
+ if (descriptor && !descriptor.configurable) {
473
+ reportError(new Error("Incompatible global instrumentation hook registry"));
474
+ return void 0;
475
+ }
476
+ const registry = /* @__PURE__ */ new Map();
477
+ try {
478
+ Object.defineProperty(registry, registryBrand, {
479
+ configurable: false,
480
+ enumerable: false,
481
+ value: GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
482
+ writable: false
483
+ });
484
+ } catch (error) {
485
+ reportError(error);
486
+ return void 0;
487
+ }
488
+ try {
489
+ Object.defineProperty(globalThis, GLOBAL_INSTRUMENTATION_HOOKS_KEY, {
490
+ configurable: false,
491
+ enumerable: false,
492
+ value: registry,
493
+ writable: false
494
+ });
495
+ return registry;
496
+ } catch (error) {
497
+ reportError(error);
498
+ return void 0;
499
+ }
500
+ }
501
+ function newGlobalTracingChannel(nameOrChannels) {
502
+ if (typeof nameOrChannels !== "string") {
503
+ return new TracingHook(nameOrChannels);
504
+ }
505
+ const registry = getHookRegistry();
506
+ if (!registry) {
507
+ return inertTracingHook;
508
+ }
509
+ let existing;
510
+ try {
511
+ existing = Map.prototype.get.call(registry, nameOrChannels);
512
+ } catch (error) {
513
+ reportError(error);
514
+ return inertTracingHook;
515
+ }
516
+ if (isCompatibleTracingHook(existing)) {
517
+ return existing;
518
+ }
519
+ if (existing !== void 0) {
520
+ reportError(
521
+ new Error(`Invalid global instrumentation hook: ${nameOrChannels}`)
64
522
  );
65
- },
66
- tracingChannelDeclaration(state, node) {
523
+ try {
524
+ Map.prototype.delete.call(registry, nameOrChannels);
525
+ } catch (error) {
526
+ reportError(error);
527
+ return inertTracingHook;
528
+ }
529
+ }
530
+ const hook = new TracingHook(nameOrChannels);
531
+ try {
532
+ Map.prototype.set.call(registry, nameOrChannels, hook);
533
+ } catch (error) {
534
+ reportError(error);
535
+ return inertTracingHook;
536
+ }
537
+ return hook;
538
+ }
539
+
540
+ // src/auto-instrumentations/orchestrion-js/transforms.ts
541
+ var CHANNEL_REGEX = /[^\w]/g;
542
+ var SHARED_HOOK_LOOKUP = "tr_ch_bt$get_hook";
543
+ function formatChannelVariable(channelName) {
544
+ return `tr_ch_bt$${channelName.replace(CHANNEL_REGEX, "_")}`;
545
+ }
546
+ function formatChannelGetter(channelName) {
547
+ return `tr_ch_bt$get_${channelName.replace(CHANNEL_REGEX, "_")}`;
548
+ }
549
+ var transforms = {
550
+ tracingHookDeclaration(state, node) {
67
551
  const {
68
552
  channelName,
69
- module: { name }
553
+ module: { name },
554
+ operator
70
555
  } = state;
71
556
  const channelVariable = formatChannelVariable(channelName);
557
+ const channelGetter = formatChannelGetter(channelName);
558
+ const hasSharedHookLookup = node.body.some(
559
+ (child) => child.declarations?.[0]?.id?.name === SHARED_HOOK_LOOKUP
560
+ );
72
561
  if (node.body.some(
73
- (child) => child.declarations?.[0]?.id?.name === channelVariable
562
+ (child) => child.declarations?.[0]?.id?.name === channelGetter
74
563
  )) {
75
564
  return;
76
565
  }
77
- transforms.tracingChannelImport(state, node, null, []);
78
- const index = node.body.findIndex(tracingChannelPredicate);
566
+ const sharedHookLookup = hasSharedHookLookup ? "" : `
567
+ const ${SHARED_HOOK_LOOKUP} = (__bt$hookName, __bt$operator) => {
568
+ try {
569
+ const __bt$hooks = globalThis[${JSON.stringify(
570
+ GLOBAL_INSTRUMENTATION_HOOKS_KEY
571
+ )}];
572
+ if (
573
+ !(__bt$hooks instanceof Map) ||
574
+ __bt$hooks[Symbol.for(${JSON.stringify(
575
+ GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND
576
+ )})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION}
577
+ ) return undefined;
578
+ const __bt$hook = Map.prototype.get.call(
579
+ __bt$hooks,
580
+ __bt$hookName
581
+ );
582
+ if (
583
+ (__bt$hook === null ||
584
+ (typeof __bt$hook !== "object" &&
585
+ typeof __bt$hook !== "function")) ||
586
+ __bt$hook[Symbol.for(${JSON.stringify(
587
+ GLOBAL_INSTRUMENTATION_HOOK_BRAND
588
+ )})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION} ||
589
+ typeof __bt$hook.hasSubscribers !== "boolean" ||
590
+ typeof __bt$hook[__bt$operator] !== "function"
591
+ ) return undefined;
592
+ return __bt$hook;
593
+ } catch {
594
+ return undefined;
595
+ }
596
+ };
597
+ `;
79
598
  const code = `
80
- const ${channelVariable} = tr_ch_apm_tracingChannel("orchestrion:${name}:${channelName}")
599
+ ${sharedHookLookup}
600
+ let ${channelVariable};
601
+ const ${channelGetter} = () =>
602
+ ${channelVariable} ??= ${SHARED_HOOK_LOOKUP}(
603
+ ${JSON.stringify(`orchestrion:${name}:${channelName}`)},
604
+ ${JSON.stringify(operator)}
605
+ );
81
606
  `;
82
- node.body.splice(index + 1, 0, (0, import_meriyah.parse)(code).body[0]);
607
+ const sharedHookLookupIndex = node.body.findIndex(
608
+ (child) => child.declarations?.[0]?.id?.name === SHARED_HOOK_LOOKUP
609
+ );
610
+ const index = sharedHookLookupIndex === -1 ? node.body.findIndex(
611
+ (child) => child.directive === "use strict"
612
+ ) : sharedHookLookupIndex;
613
+ node.body.splice(index + 1, 0, ...(0, import_meriyah.parse)(code).body);
83
614
  },
84
615
  traceCallback: traceAny,
85
616
  tracePromise: traceAny,
@@ -94,25 +625,21 @@ function traceAny(state, node, _parent, ancestry) {
94
625
  }
95
626
  }
96
627
  function traceFunction(state, node, program) {
97
- transforms.tracingChannelDeclaration(state, program, null, []);
628
+ transforms.tracingHookDeclaration(state, program, null, []);
98
629
  const { functionQuery } = state;
99
630
  const methodName = "methodName" in functionQuery ? functionQuery.methodName : void 0;
100
631
  const privateMethodName = "privateMethodName" in functionQuery ? functionQuery.privateMethodName : void 0;
101
632
  const functionName = "functionName" in functionQuery ? functionQuery.functionName : void 0;
102
633
  const isConstructor = methodName === "constructor" || !methodName && !privateMethodName && !functionName;
103
634
  const type = isConstructor ? "ArrowFunctionExpression" : "FunctionExpression";
104
- node.body = wrap(
105
- state,
106
- {
107
- type,
108
- params: node.params,
109
- body: node.body,
110
- async: node.async,
111
- expression: false,
112
- generator: node.generator
113
- },
114
- program
115
- );
635
+ node.body = wrap(state, {
636
+ type,
637
+ params: node.params,
638
+ body: node.body,
639
+ async: node.async,
640
+ expression: false,
641
+ generator: node.generator
642
+ });
116
643
  node.generator = false;
117
644
  node.async = false;
118
645
  wrapSuper(node);
@@ -124,11 +651,11 @@ function traceInstanceMethod(state, node, program) {
124
651
  return;
125
652
  }
126
653
  const classBody = node.body;
127
- if (classBody.body.some(({ key }) => key.name === methodName)) {
654
+ if (classBody.body.some(({ key }) => key?.name === methodName)) {
128
655
  return;
129
656
  }
130
657
  let ctor = classBody.body.find(({ kind }) => kind === "constructor");
131
- transforms.tracingChannelDeclaration(state, program, null, []);
658
+ transforms.tracingHookDeclaration(state, program, null, []);
132
659
  if (!ctor) {
133
660
  ctor = (0, import_meriyah.parse)(
134
661
  node.superClass ? "class A extends Object { constructor (...args) { super(...args) } }" : "class A { constructor () {} }"
@@ -136,47 +663,46 @@ function traceInstanceMethod(state, node, program) {
136
663
  classBody.body.unshift(ctor);
137
664
  }
138
665
  const ctorBody = (0, import_meriyah.parse)(`
139
- const __apm$${methodName} = this["${methodName}"]
666
+ const __bt$${methodName} = this["${methodName}"]
140
667
  this["${methodName}"] = function () {}
141
668
  `).body;
142
669
  const fn = ctorBody[1].expression.right;
143
670
  fn.async = operator === "tracePromise";
144
- fn.body = wrap(
145
- state,
146
- { type: "Identifier", name: `__apm$${methodName}` },
147
- program
148
- );
671
+ fn.body = wrap(state, {
672
+ type: "Identifier",
673
+ name: `__bt$${methodName}`
674
+ });
149
675
  wrapSuper(fn);
150
676
  ctor.value.body.body.push(...ctorBody);
151
677
  }
152
- function wrap(state, node, program) {
678
+ function wrap(state, node) {
153
679
  const { operator, moduleVersion } = state;
154
680
  const wrapper = operator === "traceCallback" ? wrapCallback(state) : operator === "tracePromise" ? wrapPromise(state) : wrapSync(state);
155
681
  const block = wrapper.body[0].body;
156
682
  const common = (0, import_meriyah.parse)(
157
683
  node.type === "ArrowFunctionExpression" ? `
158
- const __apm$ctx = {
684
+ const __bt$ctx = {
159
685
  arguments,
160
686
  moduleVersion: ${JSON.stringify(moduleVersion)}
161
687
  };
162
- const __apm$traced = () => {
163
- const __apm$wrapped = () => {};
164
- return __apm$wrapped(...arguments);
688
+ const __bt$traced = () => {
689
+ const __bt$wrapped = () => {};
690
+ return __bt$wrapped(...arguments);
165
691
  };
166
692
  ` : `
167
- const __apm$ctx = {
693
+ const __bt$ctx = {
168
694
  arguments,
169
695
  self: this,
170
696
  moduleVersion: ${JSON.stringify(moduleVersion)}
171
697
  };
172
- const __apm$traced = () => {
173
- const __apm$wrapped = () => {};
174
- return __apm$wrapped.apply(this, arguments);
698
+ const __bt$traced = () => {
699
+ const __bt$wrapped = () => {};
700
+ return __bt$wrapped.apply(this, arguments);
175
701
  };
176
702
  `
177
703
  ).body;
178
704
  block.body.unshift(...common);
179
- import_esquery.default.query(block, "[id.name=__apm$wrapped]")[0].init = node;
705
+ import_esquery.default.query(block, "[id.name=__bt$wrapped]")[0].init = node;
180
706
  return block;
181
707
  }
182
708
  function wrapSuper(node) {
@@ -188,11 +714,11 @@ function wrapSuper(node) {
188
714
  const { name } = node2.property;
189
715
  let child;
190
716
  if (parent.callee) {
191
- const { expression } = (0, import_meriyah.parse)(`__apm$super['${name}'].call(this)`).body[0];
717
+ const { expression } = (0, import_meriyah.parse)(`__bt$super['${name}'].call(this)`).body[0];
192
718
  parent.callee = child = expression.callee;
193
719
  parent.arguments.unshift(...expression.arguments);
194
720
  } else {
195
- parent.expression = child = (0, import_meriyah.parse)(`__apm$super['${name}']`).body[0];
721
+ parent.expression = child = (0, import_meriyah.parse)(`__bt$super['${name}']`).body[0];
196
722
  }
197
723
  child.computed = parent.callee.computed;
198
724
  child.optional = parent.callee.optional;
@@ -203,14 +729,14 @@ function wrapSuper(node) {
203
729
  const member = (0, import_meriyah.parse)(`
204
730
  class Wrapper {
205
731
  wrapper () {
206
- __apm$super['${name}'] = super['${name}']
732
+ __bt$super['${name}'] = super['${name}']
207
733
  }
208
734
  }
209
735
  `).body[0].body.body[0].value.body.body[0];
210
736
  node.body.body.unshift(member);
211
737
  }
212
738
  if (members.size > 0) {
213
- node.body.body.unshift((0, import_meriyah.parse)("const __apm$super = {}").body[0]);
739
+ node.body.body.unshift((0, import_meriyah.parse)("const __bt$super = {}").body[0]);
214
740
  }
215
741
  }
216
742
  function wrapCallback(state) {
@@ -218,136 +744,41 @@ function wrapCallback(state) {
218
744
  channelName,
219
745
  functionQuery: { callbackIndex = -1 }
220
746
  } = state;
221
- const channelVariable = formatChannelVariable(channelName);
747
+ const channelGetter = formatChannelGetter(channelName);
222
748
  return (0, import_meriyah.parse)(`
223
749
  function wrapper () {
224
- const __apm$cb = Array.prototype.at.call(arguments, ${callbackIndex});
225
-
226
- if (!${channelVariable}.start.hasSubscribers) return __apm$traced();
227
-
228
- function __apm$wrappedCb(err, res) {
229
- if (err) {
230
- __apm$ctx.error = err;
231
- ${channelVariable}.error.publish(__apm$ctx);
232
- } else {
233
- __apm$ctx.result = res;
234
- }
235
-
236
- ${channelVariable}.asyncStart.runStores(__apm$ctx, () => {
237
- try {
238
- if (__apm$cb) {
239
- return __apm$cb.apply(this, arguments);
240
- }
241
- } finally {
242
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
243
- }
244
- });
245
- }
246
-
247
- if (typeof __apm$cb !== 'function') {
248
- return __apm$traced();
249
- }
250
- Array.prototype.splice.call(arguments, ${callbackIndex}, 1, __apm$wrappedCb);
251
-
252
- return ${channelVariable}.start.runStores(__apm$ctx, () => {
253
- try {
254
- return __apm$traced();
255
- } catch (err) {
256
- __apm$ctx.error = err;
257
- ${channelVariable}.error.publish(__apm$ctx);
258
- throw err;
259
- } finally {
260
- __apm$ctx.self ??= this;
261
- ${channelVariable}.end.publish(__apm$ctx);
262
- }
263
- });
750
+ const __bt$hook = ${channelGetter}();
751
+ if (!__bt$hook?.hasSubscribers) return __bt$traced();
752
+ __bt$ctx.self ??= this;
753
+ return __bt$hook.traceCallback(
754
+ __bt$traced,
755
+ ${callbackIndex},
756
+ __bt$ctx
757
+ );
264
758
  }
265
759
  `);
266
760
  }
267
761
  function wrapPromise(state) {
268
762
  const { channelName } = state;
269
- const channelVariable = formatChannelVariable(channelName);
763
+ const channelGetter = formatChannelGetter(channelName);
270
764
  return (0, import_meriyah.parse)(`
271
765
  function wrapper () {
272
- if (!tr_ch_apm_hasSubscribers(${channelVariable})) return __apm$traced();
273
-
274
- return ${channelVariable}.start.runStores(__apm$ctx, () => {
275
- try {
276
- let promise = __apm$traced();
277
- if (typeof promise?.then !== 'function') {
278
- __apm$ctx.result = promise;
279
- return promise;
280
- }
281
- // Mirror Node.js core diagnostics_channel behaviour: for native Promise
282
- // instances, chain normally (safe since there is no subclass API to
283
- // preserve). For Promise subclasses and other thenables, side-chain the
284
- // callbacks for event publishing and return the original so that any
285
- // subclass-specific methods (e.g. APIPromise.withResponse()) remain
286
- // accessible to the caller.
287
- if (promise instanceof Promise && promise.constructor === Promise) {
288
- return promise.then(
289
- result => {
290
- __apm$ctx.result = result;
291
- ${channelVariable}.asyncStart.publish(__apm$ctx);
292
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
293
- return result;
294
- },
295
- err => {
296
- __apm$ctx.error = err;
297
- ${channelVariable}.error.publish(__apm$ctx);
298
- ${channelVariable}.asyncStart.publish(__apm$ctx);
299
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
300
- throw err;
301
- }
302
- );
303
- }
304
- promise.then(
305
- result => {
306
- __apm$ctx.result = result;
307
- ${channelVariable}.asyncStart.publish(__apm$ctx);
308
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
309
- },
310
- err => {
311
- __apm$ctx.error = err;
312
- ${channelVariable}.error.publish(__apm$ctx);
313
- ${channelVariable}.asyncStart.publish(__apm$ctx);
314
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
315
- }
316
- );
317
- return promise;
318
- } catch (err) {
319
- __apm$ctx.error = err;
320
- ${channelVariable}.error.publish(__apm$ctx);
321
- throw err;
322
- } finally {
323
- __apm$ctx.self ??= this;
324
- ${channelVariable}.end.publish(__apm$ctx);
325
- }
326
- });
766
+ const __bt$hook = ${channelGetter}();
767
+ if (!__bt$hook?.hasSubscribers) return __bt$traced();
768
+ __bt$ctx.self ??= this;
769
+ return __bt$hook.tracePromise(__bt$traced, __bt$ctx);
327
770
  }
328
771
  `);
329
772
  }
330
773
  function wrapSync(state) {
331
774
  const { channelName } = state;
332
- const channelVariable = formatChannelVariable(channelName);
775
+ const channelGetter = formatChannelGetter(channelName);
333
776
  return (0, import_meriyah.parse)(`
334
777
  function wrapper () {
335
- if (!tr_ch_apm_hasSubscribers(${channelVariable})) return __apm$traced();
336
-
337
- return ${channelVariable}.start.runStores(__apm$ctx, () => {
338
- try {
339
- const result = __apm$traced();
340
- __apm$ctx.result = result;
341
- return result;
342
- } catch (err) {
343
- __apm$ctx.error = err;
344
- ${channelVariable}.error.publish(__apm$ctx);
345
- throw err;
346
- } finally {
347
- __apm$ctx.self ??= this;
348
- ${channelVariable}.end.publish(__apm$ctx);
349
- }
350
- });
778
+ const __bt$hook = ${channelGetter}();
779
+ if (!__bt$hook?.hasSubscribers) return __bt$traced();
780
+ __bt$ctx.self ??= this;
781
+ return __bt$hook.traceSync(__bt$traced, __bt$ctx);
351
782
  }
352
783
  `);
353
784
  }
@@ -358,16 +789,14 @@ var Transformer = class {
358
789
  version;
359
790
  filePath;
360
791
  configs = [];
361
- dcModule;
362
- constructor(moduleName, version, filePath, configs, dcModule) {
792
+ constructor(moduleName, version, filePath, configs) {
363
793
  this.moduleName = moduleName;
364
794
  this.version = version;
365
795
  this.filePath = filePath;
366
796
  this.configs = configs;
367
- this.dcModule = dcModule;
368
797
  }
369
798
  /**
370
- * Instruments `code` by injecting diagnostics_channel tracing around the
799
+ * Instruments `code` by injecting global tracing hooks around the
371
800
  * target functions defined by this transformer's configs.
372
801
  */
373
802
  transform(code, moduleType) {
@@ -405,8 +834,6 @@ var Transformer = class {
405
834
  const query = astQuery || this.fromFunctionQuery(resolvedFunctionQuery);
406
835
  const state = {
407
836
  ...config,
408
- dcModule: this.dcModule,
409
- moduleType,
410
837
  moduleVersion: this.version,
411
838
  functionQuery: resolvedFunctionQuery,
412
839
  operator: this.getOperator(resolvedFunctionQuery.kind)
@@ -556,11 +983,9 @@ var Transformer = class {
556
983
  // src/auto-instrumentations/orchestrion-js/matcher.ts
557
984
  var InstrumentationMatcher = class {
558
985
  configs = [];
559
- dcModule;
560
986
  transformers = {};
561
- constructor(configs, dcModule) {
987
+ constructor(configs) {
562
988
  this.configs = configs;
563
- this.dcModule = dcModule || "diagnostics_channel";
564
989
  }
565
990
  /**
566
991
  * Returns a Transformer for the given module/file/version, or undefined if no
@@ -582,8 +1007,7 @@ var InstrumentationMatcher = class {
582
1007
  moduleName,
583
1008
  version,
584
1009
  filePath,
585
- configs,
586
- this.dcModule
1010
+ configs
587
1011
  );
588
1012
  return this.transformers[id];
589
1013
  }
@@ -593,8 +1017,8 @@ var InstrumentationMatcher = class {
593
1017
  };
594
1018
 
595
1019
  // src/auto-instrumentations/orchestrion-js/index.ts
596
- function create(configs, dcModule) {
597
- return new InstrumentationMatcher(configs, dcModule);
1020
+ function create(configs) {
1021
+ return new InstrumentationMatcher(configs);
598
1022
  }
599
1023
 
600
1024
  // src/auto-instrumentations/bundler/webpack-loader.ts
@@ -619,6 +1043,9 @@ var envIntegrationAliases = {
619
1043
  strandsagentsdk: "strandsAgentSDK",
620
1044
  "strands-agent-sdk": "strandsAgentSDK",
621
1045
  "@strands-agents/sdk": "strandsAgentSDK",
1046
+ agents: "cloudflareAgents",
1047
+ "cloudflare-agents": "cloudflareAgents",
1048
+ cloudflareagents: "cloudflareAgents",
622
1049
  anthropic: "anthropic",
623
1050
  aisdk: "aisdk",
624
1051
  "ai-sdk": "aisdk",
@@ -626,6 +1053,9 @@ var envIntegrationAliases = {
626
1053
  vercel: "vercel",
627
1054
  claudeagentsdk: "claudeAgentSDK",
628
1055
  "claude-agent-sdk": "claudeAgentSDK",
1056
+ cloudflareaichat: "cloudflareAIChat",
1057
+ "cloudflare-ai-chat": "cloudflareAIChat",
1058
+ "@cloudflare/ai-chat": "cloudflareAIChat",
629
1059
  cursor: "cursor",
630
1060
  "cursor-sdk": "cursorSDK",
631
1061
  cursorsdk: "cursorSDK",
@@ -640,6 +1070,8 @@ var envIntegrationAliases = {
640
1070
  "google-genai": "googleGenAI",
641
1071
  googlegenai: "googleGenAI",
642
1072
  huggingface: "huggingface",
1073
+ "@huggingface/transformers": "huggingface",
1074
+ transformers: "huggingface",
643
1075
  openrouter: "openrouter",
644
1076
  openrouteragent: "openrouterAgent",
645
1077
  "openrouter-agent": "openrouterAgent",
@@ -696,73 +1128,6 @@ var DefaultAsyncLocalStorage = class {
696
1128
  return void 0;
697
1129
  }
698
1130
  };
699
- var DefaultChannel = class {
700
- constructor(name) {
701
- this.name = name;
702
- }
703
- name;
704
- hasSubscribers = false;
705
- subscribe(_subscription) {
706
- }
707
- unsubscribe(_subscription) {
708
- return false;
709
- }
710
- bindStore(_store, _transform) {
711
- }
712
- unbindStore(_store) {
713
- return false;
714
- }
715
- publish(_message) {
716
- }
717
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
718
- runStores(_message, fn, thisArg, ...args) {
719
- return fn.apply(thisArg, args);
720
- }
721
- };
722
- var DefaultTracingChannel = class {
723
- start;
724
- end;
725
- asyncStart;
726
- asyncEnd;
727
- error;
728
- constructor(nameOrChannels) {
729
- if (typeof nameOrChannels === "string") {
730
- this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`);
731
- this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`);
732
- this.asyncStart = new DefaultChannel(
733
- `tracing:${nameOrChannels}:asyncStart`
734
- );
735
- this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
736
- this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
737
- return;
738
- }
739
- this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start");
740
- this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end");
741
- this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart");
742
- this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd");
743
- this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error");
744
- }
745
- get hasSubscribers() {
746
- return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
747
- }
748
- subscribe(_handlers) {
749
- }
750
- unsubscribe(_handlers) {
751
- return false;
752
- }
753
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
754
- traceSync(fn, _message, thisArg, ...args) {
755
- return fn.apply(thisArg, args);
756
- }
757
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
758
- tracePromise(fn, _message, thisArg, ...args) {
759
- return fn.apply(thisArg, args);
760
- }
761
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
762
- traceCallback(fn, _position, _message, thisArg, ...args) {
763
- return fn.apply(thisArg, args);
764
- }
765
- };
766
1131
  var iso = {
767
1132
  buildType: "unknown",
768
1133
  // Will be set by configureBrowser() or configureNode()
@@ -773,7 +1138,7 @@ var iso = {
773
1138
  getCallerLocation: () => void 0,
774
1139
  newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
775
1140
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
776
- newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels),
1141
+ newTracingChannel: (nameOrChannels) => newGlobalTracingChannel(nameOrChannels),
777
1142
  processOn: (_0, _1) => {
778
1143
  },
779
1144
  basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
@@ -786,7 +1151,8 @@ var isomorph_default = iso;
786
1151
  function channel(spec) {
787
1152
  return spec;
788
1153
  }
789
- function defineChannels(pkg, channels) {
1154
+ function defineChannels(pkg, channels, options) {
1155
+ const { instrumentationName } = options;
790
1156
  return Object.fromEntries(
791
1157
  Object.entries(channels).map(([key, spec]) => {
792
1158
  const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`;
@@ -799,6 +1165,7 @@ function defineChannels(pkg, channels) {
799
1165
  key,
800
1166
  {
801
1167
  ...asyncSpec,
1168
+ instrumentationName,
802
1169
  tracingChannel: tracingChannel2,
803
1170
  tracePromise: (fn, context) => tracingChannel2().tracePromise(
804
1171
  fn,
@@ -816,6 +1183,7 @@ function defineChannels(pkg, channels) {
816
1183
  key,
817
1184
  {
818
1185
  ...syncSpec,
1186
+ instrumentationName,
819
1187
  tracingChannel,
820
1188
  traceSync: (fn, context) => tracingChannel().traceSync(
821
1189
  fn,
@@ -828,93 +1196,135 @@ function defineChannels(pkg, channels) {
828
1196
  );
829
1197
  }
830
1198
 
1199
+ // src/span-origin.ts
1200
+ var INSTRUMENTATION_NAMES = {
1201
+ AI_SDK: "ai-sdk",
1202
+ ANTHROPIC: "anthropic",
1203
+ BEDROCK_RUNTIME: "bedrock-runtime",
1204
+ BRAINTRUST_JS_LOGGER: "braintrust-js-logger",
1205
+ CLAUDE_AGENT_SDK: "claude-agent-sdk",
1206
+ CLOUDFLARE_AI_CHAT: "cloudflare-ai-chat",
1207
+ CLOUDFLARE_AGENTS: "cloudflare-agents",
1208
+ COHERE: "cohere",
1209
+ CURSOR_SDK: "cursor-sdk",
1210
+ EVE: "eve",
1211
+ FLUE: "flue",
1212
+ GENKIT: "genkit",
1213
+ GITHUB_COPILOT: "github-copilot",
1214
+ GOOGLE_ADK: "google-adk",
1215
+ GOOGLE_GENAI: "google-genai",
1216
+ GROQ: "groq",
1217
+ HUGGINGFACE: "huggingface",
1218
+ LANGCHAIN: "langchain",
1219
+ LANGSMITH: "langsmith",
1220
+ MASTRA: "mastra",
1221
+ MISTRAL: "mistral",
1222
+ OPENAI: "openai",
1223
+ OPENAI_AGENTS: "openai-agents",
1224
+ OPENAI_CODEX: "openai-codex",
1225
+ OPENROUTER: "openrouter",
1226
+ OPENROUTER_AGENT: "openrouter-agent",
1227
+ PI_CODING_AGENT: "pi-coding-agent",
1228
+ STRANDS_AGENT_SDK: "strands-agent-sdk"
1229
+ };
1230
+
831
1231
  // src/instrumentation/plugins/ai-sdk-channels.ts
832
- var aiSDKChannels = defineChannels("ai", {
833
- generateText: channel({
834
- channelName: "generateText",
835
- kind: "async"
836
- }),
837
- streamText: channel({
838
- channelName: "streamText",
839
- kind: "async"
840
- }),
841
- streamTextSync: channel({
842
- channelName: "streamText.sync",
843
- kind: "sync-stream"
844
- }),
845
- generateObject: channel({
846
- channelName: "generateObject",
847
- kind: "async"
848
- }),
849
- streamObject: channel({
850
- channelName: "streamObject",
851
- kind: "async"
852
- }),
853
- streamObjectSync: channel({
854
- channelName: "streamObject.sync",
855
- kind: "sync-stream"
856
- }),
857
- embed: channel(
858
- {
1232
+ var aiSDKChannels = defineChannels(
1233
+ "ai",
1234
+ {
1235
+ generateText: channel({
1236
+ channelName: "generateText",
1237
+ kind: "async"
1238
+ }),
1239
+ streamText: channel({
1240
+ channelName: "streamText",
1241
+ kind: "async"
1242
+ }),
1243
+ streamTextSync: channel({
1244
+ channelName: "streamText.sync",
1245
+ kind: "sync-stream"
1246
+ }),
1247
+ generateObject: channel({
1248
+ channelName: "generateObject",
1249
+ kind: "async"
1250
+ }),
1251
+ streamObject: channel({
1252
+ channelName: "streamObject",
1253
+ kind: "async"
1254
+ }),
1255
+ streamObjectSync: channel({
1256
+ channelName: "streamObject.sync",
1257
+ kind: "sync-stream"
1258
+ }),
1259
+ embed: channel({
859
1260
  channelName: "embed",
860
1261
  kind: "async"
861
- }
862
- ),
863
- embedMany: channel({
864
- channelName: "embedMany",
865
- kind: "async"
866
- }),
867
- rerank: channel({
868
- channelName: "rerank",
869
- kind: "async"
870
- }),
871
- agentGenerate: channel({
872
- channelName: "Agent.generate",
873
- kind: "async"
874
- }),
875
- agentStream: channel({
876
- channelName: "Agent.stream",
877
- kind: "async"
878
- }),
879
- agentStreamSync: channel({
880
- channelName: "Agent.stream.sync",
881
- kind: "sync-stream"
882
- }),
883
- toolLoopAgentGenerate: channel({
884
- channelName: "ToolLoopAgent.generate",
885
- kind: "async"
886
- }),
887
- toolLoopAgentStream: channel({
888
- channelName: "ToolLoopAgent.stream",
889
- kind: "async"
890
- }),
891
- workflowAgentStream: channel({
892
- channelName: "WorkflowAgent.stream",
893
- kind: "async"
894
- }),
895
- v7CreateTelemetryDispatcher: channel({
896
- channelName: "createTelemetryDispatcher",
897
- kind: "sync-stream"
898
- })
899
- });
900
- var harnessAgentChannels = defineChannels("@ai-sdk/harness", {
901
- generate: channel({
902
- channelName: "HarnessAgent.generate",
903
- kind: "async"
904
- }),
905
- stream: channel({
906
- channelName: "HarnessAgent.stream",
907
- kind: "async"
908
- }),
909
- continueGenerate: channel({
910
- channelName: "HarnessAgent.continueGenerate",
911
- kind: "async"
912
- }),
913
- continueStream: channel({
914
- channelName: "HarnessAgent.continueStream",
915
- kind: "async"
916
- })
917
- });
1262
+ }),
1263
+ embedMany: channel({
1264
+ channelName: "embedMany",
1265
+ kind: "async"
1266
+ }),
1267
+ rerank: channel({
1268
+ channelName: "rerank",
1269
+ kind: "async"
1270
+ }),
1271
+ agentGenerate: channel({
1272
+ channelName: "Agent.generate",
1273
+ kind: "async"
1274
+ }),
1275
+ agentStream: channel({
1276
+ channelName: "Agent.stream",
1277
+ kind: "async"
1278
+ }),
1279
+ agentStreamSync: channel({
1280
+ channelName: "Agent.stream.sync",
1281
+ kind: "sync-stream"
1282
+ }),
1283
+ toolLoopAgentGenerate: channel({
1284
+ channelName: "ToolLoopAgent.generate",
1285
+ kind: "async"
1286
+ }),
1287
+ toolLoopAgentStream: channel({
1288
+ channelName: "ToolLoopAgent.stream",
1289
+ kind: "async"
1290
+ }),
1291
+ workflowAgentStream: channel({
1292
+ channelName: "WorkflowAgent.stream",
1293
+ kind: "async"
1294
+ }),
1295
+ v7CreateTelemetryDispatcher: channel({
1296
+ channelName: "createTelemetryDispatcher",
1297
+ kind: "sync-stream"
1298
+ })
1299
+ },
1300
+ { instrumentationName: INSTRUMENTATION_NAMES.AI_SDK }
1301
+ );
1302
+ var harnessAgentChannels = defineChannels(
1303
+ "@ai-sdk/harness",
1304
+ {
1305
+ createSession: channel({
1306
+ channelName: "HarnessAgent.createSession",
1307
+ kind: "async"
1308
+ }),
1309
+ generate: channel({
1310
+ channelName: "HarnessAgent.generate",
1311
+ kind: "async"
1312
+ }),
1313
+ stream: channel({
1314
+ channelName: "HarnessAgent.stream",
1315
+ kind: "async"
1316
+ }),
1317
+ continueGenerate: channel({
1318
+ channelName: "HarnessAgent.continueGenerate",
1319
+ kind: "async"
1320
+ }),
1321
+ continueStream: channel({
1322
+ channelName: "HarnessAgent.continueStream",
1323
+ kind: "async"
1324
+ })
1325
+ },
1326
+ { instrumentationName: INSTRUMENTATION_NAMES.AI_SDK }
1327
+ );
918
1328
 
919
1329
  // src/auto-instrumentations/configs/ai-sdk.ts
920
1330
  var aiSDKConfigs = [
@@ -922,6 +1332,7 @@ var aiSDKConfigs = [
922
1332
  // `./agent` entrypoint. The compiled class expression is anonymous, so match
923
1333
  // the first async method with each public name instead of a class name.
924
1334
  ...[
1335
+ ["createSession", harnessAgentChannels.createSession.channelName],
925
1336
  ["generate", harnessAgentChannels.generate.channelName],
926
1337
  ["stream", harnessAgentChannels.stream.channelName],
927
1338
  ["continueGenerate", harnessAgentChannels.continueGenerate.channelName],
@@ -1310,20 +1721,24 @@ var aiSDKConfigs = [
1310
1721
  ];
1311
1722
 
1312
1723
  // src/instrumentation/plugins/anthropic-channels.ts
1313
- var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
1314
- messagesCreate: channel({
1315
- channelName: "messages.create",
1316
- kind: "async"
1317
- }),
1318
- betaMessagesCreate: channel({
1319
- channelName: "beta.messages.create",
1320
- kind: "async"
1321
- }),
1322
- betaMessagesToolRunner: channel({
1323
- channelName: "beta.messages.toolRunner",
1324
- kind: "sync-stream"
1325
- })
1326
- });
1724
+ var anthropicChannels = defineChannels(
1725
+ "@anthropic-ai/sdk",
1726
+ {
1727
+ messagesCreate: channel({
1728
+ channelName: "messages.create",
1729
+ kind: "async"
1730
+ }),
1731
+ betaMessagesCreate: channel({
1732
+ channelName: "beta.messages.create",
1733
+ kind: "async"
1734
+ }),
1735
+ betaMessagesToolRunner: channel({
1736
+ channelName: "beta.messages.toolRunner",
1737
+ kind: "sync-stream"
1738
+ })
1739
+ },
1740
+ { instrumentationName: INSTRUMENTATION_NAMES.ANTHROPIC }
1741
+ );
1327
1742
 
1328
1743
  // src/auto-instrumentations/configs/anthropic.ts
1329
1744
  var anthropicConfigs = [
@@ -1446,15 +1861,27 @@ var clientSendChannel = channel({
1446
1861
  channelName: "client.send",
1447
1862
  kind: "async"
1448
1863
  });
1449
- var bedrockRuntimeChannels = defineChannels("aws-bedrock-runtime", {
1450
- clientSend: clientSendChannel
1451
- });
1452
- var smithyCoreChannels = defineChannels("@smithy/core", {
1453
- clientSend: clientSendChannel
1454
- });
1455
- var smithyClientChannels = defineChannels("@smithy/smithy-client", {
1456
- clientSend: clientSendChannel
1457
- });
1864
+ var bedrockRuntimeChannels = defineChannels(
1865
+ "aws-bedrock-runtime",
1866
+ {
1867
+ clientSend: clientSendChannel
1868
+ },
1869
+ { instrumentationName: INSTRUMENTATION_NAMES.BEDROCK_RUNTIME }
1870
+ );
1871
+ var smithyCoreChannels = defineChannels(
1872
+ "@smithy/core",
1873
+ {
1874
+ clientSend: clientSendChannel
1875
+ },
1876
+ { instrumentationName: INSTRUMENTATION_NAMES.BEDROCK_RUNTIME }
1877
+ );
1878
+ var smithyClientChannels = defineChannels(
1879
+ "@smithy/smithy-client",
1880
+ {
1881
+ clientSend: clientSendChannel
1882
+ },
1883
+ { instrumentationName: INSTRUMENTATION_NAMES.BEDROCK_RUNTIME }
1884
+ );
1458
1885
 
1459
1886
  // src/auto-instrumentations/configs/bedrock-runtime.ts
1460
1887
  var bedrockRuntimeConfigs = [
@@ -1520,7 +1947,8 @@ var claudeAgentSDKChannels = defineChannels(
1520
1947
  channelName: "query",
1521
1948
  kind: "sync-stream"
1522
1949
  })
1523
- }
1950
+ },
1951
+ { instrumentationName: INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK }
1524
1952
  );
1525
1953
 
1526
1954
  // src/auto-instrumentations/configs/claude-agent-sdk.ts
@@ -1554,25 +1982,97 @@ var claudeAgentSDKConfigs = [
1554
1982
  }
1555
1983
  ];
1556
1984
 
1985
+ // src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
1986
+ var cloudflareAIChatChannels = defineChannels(
1987
+ "@cloudflare/ai-chat",
1988
+ {
1989
+ runExclusiveChatTurn: channel({
1990
+ channelName: "AIChatAgent._runExclusiveChatTurn",
1991
+ kind: "async"
1992
+ }),
1993
+ onChatResponse: channel({
1994
+ channelName: "AIChatAgent.onChatResponse",
1995
+ kind: "sync-stream"
1996
+ })
1997
+ },
1998
+ { instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
1999
+ );
2000
+
2001
+ // src/auto-instrumentations/configs/cloudflare-ai-chat.ts
2002
+ var cloudflareAIChatVersionRange = ">=0.9.0 <0.10.0";
2003
+ var cloudflareAIChatConfigs = [
2004
+ {
2005
+ // AIChatAgent subclasses replace onChatMessage, so there is no stable
2006
+ // public implementation for the transformer to target. This runner is
2007
+ // the narrowest shared boundary around every chat turn; keep the version
2008
+ // range tight because it is an internal method.
2009
+ channelName: cloudflareAIChatChannels.runExclusiveChatTurn.channelName,
2010
+ module: {
2011
+ name: "@cloudflare/ai-chat",
2012
+ versionRange: cloudflareAIChatVersionRange,
2013
+ filePath: "dist/index.js"
2014
+ },
2015
+ functionQuery: {
2016
+ className: "AIChatAgent",
2017
+ methodName: "_runExclusiveChatTurn",
2018
+ kind: "Async"
2019
+ }
2020
+ }
2021
+ ];
2022
+
2023
+ // src/instrumentation/plugins/cloudflare-agents-channels.ts
2024
+ var cloudflareAgentsChannels = defineChannels(
2025
+ "agents",
2026
+ {
2027
+ runAgentTool: channel({
2028
+ channelName: "Agent.runAgentTool",
2029
+ kind: "async"
2030
+ })
2031
+ },
2032
+ { instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AGENTS }
2033
+ );
2034
+
2035
+ // src/auto-instrumentations/configs/cloudflare-agents.ts
2036
+ var cloudflareAgentsVersionRange = ">=0.17.0 <0.18.0";
2037
+ var cloudflareAgentsConfigs = [
2038
+ {
2039
+ channelName: cloudflareAgentsChannels.runAgentTool.channelName,
2040
+ module: {
2041
+ name: "agents",
2042
+ versionRange: cloudflareAgentsVersionRange,
2043
+ filePath: "dist/index.js"
2044
+ },
2045
+ functionQuery: {
2046
+ className: "Agent",
2047
+ methodName: "runAgentTool",
2048
+ kind: "Async"
2049
+ }
2050
+ }
2051
+ ];
2052
+
1557
2053
  // src/instrumentation/plugins/cohere-channels.ts
1558
- var cohereChannels = defineChannels("cohere-ai", {
1559
- chat: channel({
1560
- channelName: "chat",
1561
- kind: "async"
1562
- }),
1563
- chatStream: channel({
1564
- channelName: "chatStream",
1565
- kind: "async"
1566
- }),
1567
- embed: channel({
1568
- channelName: "embed",
1569
- kind: "async"
1570
- }),
1571
- rerank: channel({
1572
- channelName: "rerank",
1573
- kind: "async"
1574
- })
1575
- });
2054
+ var cohereChannels = defineChannels(
2055
+ "cohere-ai",
2056
+ {
2057
+ chat: channel({
2058
+ channelName: "chat",
2059
+ kind: "async"
2060
+ }),
2061
+ chatStream: channel({
2062
+ channelName: "chatStream",
2063
+ kind: "async"
2064
+ }),
2065
+ embed: channel({
2066
+ channelName: "embed",
2067
+ kind: "async"
2068
+ }),
2069
+ rerank: channel({
2070
+ channelName: "rerank",
2071
+ kind: "async"
2072
+ })
2073
+ },
2074
+ { instrumentationName: INSTRUMENTATION_NAMES.COHERE }
2075
+ );
1576
2076
 
1577
2077
  // src/auto-instrumentations/configs/cohere.ts
1578
2078
  var cohereConfigs = [
@@ -1839,24 +2339,28 @@ var cohereConfigs = [
1839
2339
  ];
1840
2340
 
1841
2341
  // src/instrumentation/plugins/cursor-sdk-channels.ts
1842
- var cursorSDKChannels = defineChannels("@cursor/sdk", {
1843
- create: channel({
1844
- channelName: "Agent.create",
1845
- kind: "async"
1846
- }),
1847
- resume: channel({
1848
- channelName: "Agent.resume",
1849
- kind: "async"
1850
- }),
1851
- prompt: channel({
1852
- channelName: "Agent.prompt",
1853
- kind: "async"
1854
- }),
1855
- send: channel({
1856
- channelName: "agent.send",
1857
- kind: "async"
1858
- })
1859
- });
2342
+ var cursorSDKChannels = defineChannels(
2343
+ "@cursor/sdk",
2344
+ {
2345
+ create: channel({
2346
+ channelName: "Agent.create",
2347
+ kind: "async"
2348
+ }),
2349
+ resume: channel({
2350
+ channelName: "Agent.resume",
2351
+ kind: "async"
2352
+ }),
2353
+ prompt: channel({
2354
+ channelName: "Agent.prompt",
2355
+ kind: "async"
2356
+ }),
2357
+ send: channel({
2358
+ channelName: "agent.send",
2359
+ kind: "async"
2360
+ })
2361
+ },
2362
+ { instrumentationName: INSTRUMENTATION_NAMES.CURSOR_SDK }
2363
+ );
1860
2364
 
1861
2365
  // src/auto-instrumentations/configs/cursor-sdk.ts
1862
2366
  var cursorSDKVersionRange = ">=1.0.7 <2.0.0";
@@ -1904,12 +2408,16 @@ var cursorSDKConfigs = cursorSDKEntrypoints.flatMap((filePath) => [
1904
2408
  ]);
1905
2409
 
1906
2410
  // src/instrumentation/plugins/flue-channels.ts
1907
- var flueChannels = defineChannels("@flue/runtime", {
1908
- createContext: channel({
1909
- channelName: "createFlueContext",
1910
- kind: "sync-stream"
1911
- })
1912
- });
2411
+ var flueChannels = defineChannels(
2412
+ "@flue/runtime",
2413
+ {
2414
+ createContext: channel({
2415
+ channelName: "createFlueContext",
2416
+ kind: "sync-stream"
2417
+ })
2418
+ },
2419
+ { instrumentationName: INSTRUMENTATION_NAMES.FLUE }
2420
+ );
1913
2421
 
1914
2422
  // src/auto-instrumentations/configs/flue.ts
1915
2423
  var flueVersionRange = ">=0.8.0 <1.0.0";
@@ -1929,38 +2437,46 @@ var flueConfigs = [
1929
2437
  ];
1930
2438
 
1931
2439
  // src/instrumentation/plugins/genkit-channels.ts
1932
- var genkitChannels = defineChannels("@genkit-ai/ai", {
1933
- generate: channel({
1934
- channelName: "generate",
1935
- kind: "async"
1936
- }),
1937
- generateStream: channel({
1938
- channelName: "generateStream",
1939
- kind: "sync-stream"
1940
- }),
1941
- embed: channel({
1942
- channelName: "embed",
1943
- kind: "async"
1944
- }),
1945
- embedMany: channel({
1946
- channelName: "embedMany",
1947
- kind: "async"
1948
- }),
1949
- actionRun: channel({
1950
- channelName: "action.run",
1951
- kind: "async"
1952
- }),
1953
- actionStream: channel({
1954
- channelName: "action.stream",
1955
- kind: "sync-stream"
1956
- })
1957
- });
1958
- var genkitCoreChannels = defineChannels("@genkit-ai/core", {
1959
- actionSpan: channel({
1960
- channelName: "action.span",
1961
- kind: "async"
1962
- })
1963
- });
2440
+ var genkitChannels = defineChannels(
2441
+ "@genkit-ai/ai",
2442
+ {
2443
+ generate: channel({
2444
+ channelName: "generate",
2445
+ kind: "async"
2446
+ }),
2447
+ generateStream: channel({
2448
+ channelName: "generateStream",
2449
+ kind: "sync-stream"
2450
+ }),
2451
+ embed: channel({
2452
+ channelName: "embed",
2453
+ kind: "async"
2454
+ }),
2455
+ embedMany: channel({
2456
+ channelName: "embedMany",
2457
+ kind: "async"
2458
+ }),
2459
+ actionRun: channel({
2460
+ channelName: "action.run",
2461
+ kind: "async"
2462
+ }),
2463
+ actionStream: channel({
2464
+ channelName: "action.stream",
2465
+ kind: "sync-stream"
2466
+ })
2467
+ },
2468
+ { instrumentationName: INSTRUMENTATION_NAMES.GENKIT }
2469
+ );
2470
+ var genkitCoreChannels = defineChannels(
2471
+ "@genkit-ai/core",
2472
+ {
2473
+ actionSpan: channel({
2474
+ channelName: "action.span",
2475
+ kind: "async"
2476
+ })
2477
+ },
2478
+ { instrumentationName: INSTRUMENTATION_NAMES.GENKIT }
2479
+ );
1964
2480
 
1965
2481
  // src/auto-instrumentations/configs/genkit.ts
1966
2482
  var genkitVersionRange = ">=1.0.0 <2.0.0";
@@ -2122,20 +2638,24 @@ var genkitConfigs = [
2122
2638
  ];
2123
2639
 
2124
2640
  // src/instrumentation/plugins/github-copilot-channels.ts
2125
- var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", {
2126
- createSession: channel({
2127
- channelName: "client.createSession",
2128
- kind: "async"
2129
- }),
2130
- resumeSession: channel({
2131
- channelName: "client.resumeSession",
2132
- kind: "async"
2133
- }),
2134
- sendAndWait: channel({
2135
- channelName: "session.sendAndWait",
2136
- kind: "async"
2137
- })
2138
- });
2641
+ var gitHubCopilotChannels = defineChannels(
2642
+ "@github/copilot-sdk",
2643
+ {
2644
+ createSession: channel({
2645
+ channelName: "client.createSession",
2646
+ kind: "async"
2647
+ }),
2648
+ resumeSession: channel({
2649
+ channelName: "client.resumeSession",
2650
+ kind: "async"
2651
+ }),
2652
+ sendAndWait: channel({
2653
+ channelName: "session.sendAndWait",
2654
+ kind: "async"
2655
+ })
2656
+ },
2657
+ { instrumentationName: INSTRUMENTATION_NAMES.GITHUB_COPILOT }
2658
+ );
2139
2659
 
2140
2660
  // src/auto-instrumentations/configs/github-copilot.ts
2141
2661
  var gitHubCopilotConfigs = [
@@ -2226,20 +2746,24 @@ var gitHubCopilotConfigs = [
2226
2746
  ];
2227
2747
 
2228
2748
  // src/instrumentation/plugins/google-adk-channels.ts
2229
- var googleADKChannels = defineChannels("@google/adk", {
2230
- runnerRunAsync: channel({
2231
- channelName: "runner.runAsync",
2232
- kind: "sync-stream"
2233
- }),
2234
- agentRunAsync: channel({
2235
- channelName: "agent.runAsync",
2236
- kind: "sync-stream"
2237
- }),
2238
- toolRunAsync: channel({
2239
- channelName: "tool.runAsync",
2240
- kind: "async"
2241
- })
2242
- });
2749
+ var googleADKChannels = defineChannels(
2750
+ "@google/adk",
2751
+ {
2752
+ runnerRunAsync: channel({
2753
+ channelName: "runner.runAsync",
2754
+ kind: "sync-stream"
2755
+ }),
2756
+ agentRunAsync: channel({
2757
+ channelName: "agent.runAsync",
2758
+ kind: "sync-stream"
2759
+ }),
2760
+ toolRunAsync: channel({
2761
+ channelName: "tool.runAsync",
2762
+ kind: "async"
2763
+ })
2764
+ },
2765
+ { instrumentationName: INSTRUMENTATION_NAMES.GOOGLE_ADK }
2766
+ );
2243
2767
 
2244
2768
  // src/auto-instrumentations/configs/google-adk.ts
2245
2769
  var googleADKVersionRange = ">=0.1.0";
@@ -2470,24 +2994,28 @@ var googleADKConfigs = [
2470
2994
  ];
2471
2995
 
2472
2996
  // src/instrumentation/plugins/google-genai-channels.ts
2473
- var googleGenAIChannels = defineChannels("@google/genai", {
2474
- generateContent: channel({
2475
- channelName: "models.generateContent",
2476
- kind: "async"
2477
- }),
2478
- generateContentStream: channel({
2479
- channelName: "models.generateContentStream",
2480
- kind: "async"
2481
- }),
2482
- embedContent: channel({
2483
- channelName: "models.embedContent",
2484
- kind: "async"
2485
- }),
2486
- interactionsCreate: channel({
2487
- channelName: "interactions.create",
2488
- kind: "async"
2489
- })
2490
- });
2997
+ var googleGenAIChannels = defineChannels(
2998
+ "@google/genai",
2999
+ {
3000
+ generateContent: channel({
3001
+ channelName: "models.generateContent",
3002
+ kind: "async"
3003
+ }),
3004
+ generateContentStream: channel({
3005
+ channelName: "models.generateContentStream",
3006
+ kind: "async"
3007
+ }),
3008
+ embedContent: channel({
3009
+ channelName: "models.embedContent",
3010
+ kind: "async"
3011
+ }),
3012
+ interactionsCreate: channel({
3013
+ channelName: "interactions.create",
3014
+ kind: "async"
3015
+ })
3016
+ },
3017
+ { instrumentationName: INSTRUMENTATION_NAMES.GOOGLE_GENAI }
3018
+ );
2491
3019
 
2492
3020
  // src/auto-instrumentations/configs/google-genai.ts
2493
3021
  var googleGenAIConfigs = [
@@ -2567,18 +3095,20 @@ var googleGenAIConfigs = [
2567
3095
  ];
2568
3096
 
2569
3097
  // src/instrumentation/plugins/groq-channels.ts
2570
- var groqChannels = defineChannels("groq-sdk", {
2571
- chatCompletionsCreate: channel({
2572
- channelName: "chat.completions.create",
2573
- kind: "async"
2574
- }),
2575
- embeddingsCreate: channel(
2576
- {
3098
+ var groqChannels = defineChannels(
3099
+ "groq-sdk",
3100
+ {
3101
+ chatCompletionsCreate: channel({
3102
+ channelName: "chat.completions.create",
3103
+ kind: "async"
3104
+ }),
3105
+ embeddingsCreate: channel({
2577
3106
  channelName: "embeddings.create",
2578
3107
  kind: "async"
2579
- }
2580
- )
2581
- });
3108
+ })
3109
+ },
3110
+ { instrumentationName: INSTRUMENTATION_NAMES.GROQ }
3111
+ );
2582
3112
 
2583
3113
  // src/auto-instrumentations/configs/groq.ts
2584
3114
  var groqConfigs = [
@@ -2611,28 +3141,32 @@ var groqConfigs = [
2611
3141
  ];
2612
3142
 
2613
3143
  // src/instrumentation/plugins/huggingface-channels.ts
2614
- var huggingFaceChannels = defineChannels("@huggingface/inference", {
2615
- chatCompletion: channel({
2616
- channelName: "chatCompletion",
2617
- kind: "async"
2618
- }),
2619
- chatCompletionStream: channel({
2620
- channelName: "chatCompletionStream",
2621
- kind: "sync-stream"
2622
- }),
2623
- textGeneration: channel({
2624
- channelName: "textGeneration",
2625
- kind: "async"
2626
- }),
2627
- textGenerationStream: channel({
2628
- channelName: "textGenerationStream",
2629
- kind: "sync-stream"
2630
- }),
2631
- featureExtraction: channel({
2632
- channelName: "featureExtraction",
2633
- kind: "async"
2634
- })
2635
- });
3144
+ var huggingFaceChannels = defineChannels(
3145
+ "@huggingface/inference",
3146
+ {
3147
+ chatCompletion: channel({
3148
+ channelName: "chatCompletion",
3149
+ kind: "async"
3150
+ }),
3151
+ chatCompletionStream: channel({
3152
+ channelName: "chatCompletionStream",
3153
+ kind: "sync-stream"
3154
+ }),
3155
+ textGeneration: channel({
3156
+ channelName: "textGeneration",
3157
+ kind: "async"
3158
+ }),
3159
+ textGenerationStream: channel({
3160
+ channelName: "textGenerationStream",
3161
+ kind: "sync-stream"
3162
+ }),
3163
+ featureExtraction: channel({
3164
+ channelName: "featureExtraction",
3165
+ kind: "async"
3166
+ })
3167
+ },
3168
+ { instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
3169
+ );
2636
3170
 
2637
3171
  // src/auto-instrumentations/configs/huggingface.ts
2638
3172
  var huggingFaceConfigs = [
@@ -2878,17 +3412,98 @@ var huggingFaceConfigs = [
2878
3412
  }
2879
3413
  ];
2880
3414
 
3415
+ // src/instrumentation/plugins/huggingface-transformers-channels.ts
3416
+ var huggingFaceTransformersChannels = defineChannels(
3417
+ "@huggingface/transformers",
3418
+ {
3419
+ pipeline: channel({
3420
+ channelName: "pipeline",
3421
+ kind: "async"
3422
+ }),
3423
+ pipelineCall: channel({
3424
+ channelName: "pipeline.call",
3425
+ kind: "async"
3426
+ })
3427
+ },
3428
+ { instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
3429
+ );
3430
+
3431
+ // src/auto-instrumentations/configs/huggingface-transformers.ts
3432
+ var moduleFiles = [
3433
+ {
3434
+ filePath: "dist/transformers.mjs",
3435
+ versionRange: ">=3.0.0 <3.4.0"
3436
+ },
3437
+ {
3438
+ filePath: "dist/transformers.cjs",
3439
+ versionRange: ">=3.0.0 <3.4.0"
3440
+ },
3441
+ {
3442
+ filePath: "dist/transformers.js",
3443
+ versionRange: ">=3.0.0 <3.4.0"
3444
+ },
3445
+ {
3446
+ filePath: "dist/transformers.node.mjs",
3447
+ versionRange: ">=3.4.0 <5.0.0"
3448
+ },
3449
+ {
3450
+ filePath: "dist/transformers.node.cjs",
3451
+ versionRange: ">=3.4.0 <5.0.0"
3452
+ },
3453
+ {
3454
+ filePath: "dist/transformers.web.js",
3455
+ versionRange: ">=3.4.0 <5.0.0"
3456
+ }
3457
+ ];
3458
+ var pipelineClasses = [
3459
+ "TextGenerationPipeline",
3460
+ "Text2TextGenerationPipeline",
3461
+ "FeatureExtractionPipeline",
3462
+ "QuestionAnsweringPipeline"
3463
+ ];
3464
+ var huggingFaceTransformersConfigs = moduleFiles.flatMap(({ filePath, versionRange: versionRange2 }) => [
3465
+ {
3466
+ channelName: huggingFaceTransformersChannels.pipeline.channelName,
3467
+ module: {
3468
+ name: "@huggingface/transformers",
3469
+ versionRange: versionRange2,
3470
+ filePath
3471
+ },
3472
+ functionQuery: {
3473
+ functionName: "pipeline",
3474
+ kind: "Async"
3475
+ }
3476
+ },
3477
+ ...pipelineClasses.map((className) => ({
3478
+ channelName: huggingFaceTransformersChannels.pipelineCall.channelName,
3479
+ module: {
3480
+ name: "@huggingface/transformers",
3481
+ versionRange: versionRange2,
3482
+ filePath
3483
+ },
3484
+ functionQuery: {
3485
+ className,
3486
+ methodName: "_call",
3487
+ kind: "Async"
3488
+ }
3489
+ }))
3490
+ ]);
3491
+
2881
3492
  // src/instrumentation/plugins/langchain-channels.ts
2882
- var langChainChannels = defineChannels("@langchain/core", {
2883
- configure: channel({
2884
- channelName: "CallbackManager.configure",
2885
- kind: "sync-stream"
2886
- }),
2887
- configureSync: channel({
2888
- channelName: "CallbackManager._configureSync",
2889
- kind: "sync-stream"
2890
- })
2891
- });
3493
+ var langChainChannels = defineChannels(
3494
+ "@langchain/core",
3495
+ {
3496
+ configure: channel({
3497
+ channelName: "CallbackManager.configure",
3498
+ kind: "sync-stream"
3499
+ }),
3500
+ configureSync: channel({
3501
+ channelName: "CallbackManager._configureSync",
3502
+ kind: "sync-stream"
3503
+ })
3504
+ },
3505
+ { instrumentationName: INSTRUMENTATION_NAMES.LANGCHAIN }
3506
+ );
2892
3507
 
2893
3508
  // src/auto-instrumentations/configs/langchain.ts
2894
3509
  var langChainCoreVersionRange = ">=0.3.42";
@@ -2923,20 +3538,24 @@ var langchainConfigs = [
2923
3538
  ];
2924
3539
 
2925
3540
  // src/instrumentation/plugins/langsmith-channels.ts
2926
- var langSmithChannels = defineChannels("langsmith", {
2927
- createRun: channel({
2928
- channelName: "Client.createRun",
2929
- kind: "async"
2930
- }),
2931
- updateRun: channel({
2932
- channelName: "Client.updateRun",
2933
- kind: "async"
2934
- }),
2935
- batchIngestRuns: channel({
2936
- channelName: "Client.batchIngestRuns",
2937
- kind: "async"
2938
- })
2939
- });
3541
+ var langSmithChannels = defineChannels(
3542
+ "langsmith",
3543
+ {
3544
+ createRun: channel({
3545
+ channelName: "Client.createRun",
3546
+ kind: "async"
3547
+ }),
3548
+ updateRun: channel({
3549
+ channelName: "Client.updateRun",
3550
+ kind: "async"
3551
+ }),
3552
+ batchIngestRuns: channel({
3553
+ channelName: "Client.batchIngestRuns",
3554
+ kind: "async"
3555
+ })
3556
+ },
3557
+ { instrumentationName: INSTRUMENTATION_NAMES.LANGSMITH }
3558
+ );
2940
3559
 
2941
3560
  // src/auto-instrumentations/configs/langsmith.ts
2942
3561
  var versionRange = ">=0.3.30 <1.0.0";
@@ -2973,52 +3592,56 @@ var langSmithConfigs = [
2973
3592
  ];
2974
3593
 
2975
3594
  // src/instrumentation/plugins/mistral-channels.ts
2976
- var mistralChannels = defineChannels("@mistralai/mistralai", {
2977
- chatComplete: channel({
2978
- channelName: "chat.complete",
2979
- kind: "async"
2980
- }),
2981
- chatStream: channel({
2982
- channelName: "chat.stream",
2983
- kind: "async"
2984
- }),
2985
- embeddingsCreate: channel({
2986
- channelName: "embeddings.create",
2987
- kind: "async"
2988
- }),
2989
- classifiersModerate: channel({
2990
- channelName: "classifiers.moderate",
2991
- kind: "async"
2992
- }),
2993
- classifiersModerateChat: channel({
2994
- channelName: "classifiers.moderateChat",
2995
- kind: "async"
2996
- }),
2997
- classifiersClassify: channel({
2998
- channelName: "classifiers.classify",
2999
- kind: "async"
3000
- }),
3001
- classifiersClassifyChat: channel({
3002
- channelName: "classifiers.classifyChat",
3003
- kind: "async"
3004
- }),
3005
- fimComplete: channel({
3006
- channelName: "fim.complete",
3007
- kind: "async"
3008
- }),
3009
- fimStream: channel({
3010
- channelName: "fim.stream",
3011
- kind: "async"
3012
- }),
3013
- agentsComplete: channel({
3014
- channelName: "agents.complete",
3015
- kind: "async"
3016
- }),
3017
- agentsStream: channel({
3018
- channelName: "agents.stream",
3019
- kind: "async"
3020
- })
3021
- });
3595
+ var mistralChannels = defineChannels(
3596
+ "@mistralai/mistralai",
3597
+ {
3598
+ chatComplete: channel({
3599
+ channelName: "chat.complete",
3600
+ kind: "async"
3601
+ }),
3602
+ chatStream: channel({
3603
+ channelName: "chat.stream",
3604
+ kind: "async"
3605
+ }),
3606
+ embeddingsCreate: channel({
3607
+ channelName: "embeddings.create",
3608
+ kind: "async"
3609
+ }),
3610
+ classifiersModerate: channel({
3611
+ channelName: "classifiers.moderate",
3612
+ kind: "async"
3613
+ }),
3614
+ classifiersModerateChat: channel({
3615
+ channelName: "classifiers.moderateChat",
3616
+ kind: "async"
3617
+ }),
3618
+ classifiersClassify: channel({
3619
+ channelName: "classifiers.classify",
3620
+ kind: "async"
3621
+ }),
3622
+ classifiersClassifyChat: channel({
3623
+ channelName: "classifiers.classifyChat",
3624
+ kind: "async"
3625
+ }),
3626
+ fimComplete: channel({
3627
+ channelName: "fim.complete",
3628
+ kind: "async"
3629
+ }),
3630
+ fimStream: channel({
3631
+ channelName: "fim.stream",
3632
+ kind: "async"
3633
+ }),
3634
+ agentsComplete: channel({
3635
+ channelName: "agents.complete",
3636
+ kind: "async"
3637
+ }),
3638
+ agentsStream: channel({
3639
+ channelName: "agents.stream",
3640
+ kind: "async"
3641
+ })
3642
+ },
3643
+ { instrumentationName: INSTRUMENTATION_NAMES.MISTRAL }
3644
+ );
3022
3645
 
3023
3646
  // src/auto-instrumentations/configs/mistral.ts
3024
3647
  var mistralConfigs = [
@@ -3311,24 +3934,28 @@ var mistralConfigs = [
3311
3934
  ];
3312
3935
 
3313
3936
  // src/instrumentation/plugins/openai-agents-channels.ts
3314
- var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
3315
- onTraceStart: channel({
3316
- channelName: "tracing.processor.onTraceStart",
3317
- kind: "async"
3318
- }),
3319
- onTraceEnd: channel({
3320
- channelName: "tracing.processor.onTraceEnd",
3321
- kind: "async"
3322
- }),
3323
- onSpanStart: channel({
3324
- channelName: "tracing.processor.onSpanStart",
3325
- kind: "async"
3326
- }),
3327
- onSpanEnd: channel({
3328
- channelName: "tracing.processor.onSpanEnd",
3329
- kind: "async"
3330
- })
3331
- });
3937
+ var openAIAgentsCoreChannels = defineChannels(
3938
+ "@openai/agents-core",
3939
+ {
3940
+ onTraceStart: channel({
3941
+ channelName: "tracing.processor.onTraceStart",
3942
+ kind: "async"
3943
+ }),
3944
+ onTraceEnd: channel({
3945
+ channelName: "tracing.processor.onTraceEnd",
3946
+ kind: "async"
3947
+ }),
3948
+ onSpanStart: channel({
3949
+ channelName: "tracing.processor.onSpanStart",
3950
+ kind: "async"
3951
+ }),
3952
+ onSpanEnd: channel({
3953
+ channelName: "tracing.processor.onSpanEnd",
3954
+ kind: "async"
3955
+ })
3956
+ },
3957
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENAI_AGENTS }
3958
+ );
3332
3959
 
3333
3960
  // src/auto-instrumentations/configs/openai-agents.ts
3334
3961
  var lifecycleMethods = [
@@ -3356,44 +3983,48 @@ var openAIAgentsCoreConfigs = lifecycleMethods.flatMap(
3356
3983
  );
3357
3984
 
3358
3985
  // src/instrumentation/plugins/openai-channels.ts
3359
- var openAIChannels = defineChannels("openai", {
3360
- chatCompletionsCreate: channel({
3361
- channelName: "chat.completions.create",
3362
- kind: "async"
3363
- }),
3364
- embeddingsCreate: channel({
3365
- channelName: "embeddings.create",
3366
- kind: "async"
3367
- }),
3368
- betaChatCompletionsParse: channel({
3369
- channelName: "beta.chat.completions.parse",
3370
- kind: "async"
3371
- }),
3372
- betaChatCompletionsStream: channel({
3373
- channelName: "beta.chat.completions.stream",
3374
- kind: "sync-stream"
3375
- }),
3376
- moderationsCreate: channel({
3377
- channelName: "moderations.create",
3378
- kind: "async"
3379
- }),
3380
- responsesCreate: channel({
3381
- channelName: "responses.create",
3382
- kind: "async"
3383
- }),
3384
- responsesStream: channel({
3385
- channelName: "responses.stream",
3386
- kind: "sync-stream"
3387
- }),
3388
- responsesParse: channel({
3389
- channelName: "responses.parse",
3390
- kind: "async"
3391
- }),
3392
- responsesCompact: channel({
3393
- channelName: "responses.compact",
3394
- kind: "async"
3395
- })
3396
- });
3986
+ var openAIChannels = defineChannels(
3987
+ "openai",
3988
+ {
3989
+ chatCompletionsCreate: channel({
3990
+ channelName: "chat.completions.create",
3991
+ kind: "async"
3992
+ }),
3993
+ embeddingsCreate: channel({
3994
+ channelName: "embeddings.create",
3995
+ kind: "async"
3996
+ }),
3997
+ betaChatCompletionsParse: channel({
3998
+ channelName: "beta.chat.completions.parse",
3999
+ kind: "async"
4000
+ }),
4001
+ betaChatCompletionsStream: channel({
4002
+ channelName: "beta.chat.completions.stream",
4003
+ kind: "sync-stream"
4004
+ }),
4005
+ moderationsCreate: channel({
4006
+ channelName: "moderations.create",
4007
+ kind: "async"
4008
+ }),
4009
+ responsesCreate: channel({
4010
+ channelName: "responses.create",
4011
+ kind: "async"
4012
+ }),
4013
+ responsesStream: channel({
4014
+ channelName: "responses.stream",
4015
+ kind: "sync-stream"
4016
+ }),
4017
+ responsesParse: channel({
4018
+ channelName: "responses.parse",
4019
+ kind: "async"
4020
+ }),
4021
+ responsesCompact: channel({
4022
+ channelName: "responses.compact",
4023
+ kind: "async"
4024
+ })
4025
+ },
4026
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENAI }
4027
+ );
3397
4028
 
3398
4029
  // src/auto-instrumentations/configs/openai.ts
3399
4030
  var openaiConfigs = [
@@ -3575,16 +4206,20 @@ var openaiConfigs = [
3575
4206
  ];
3576
4207
 
3577
4208
  // src/instrumentation/plugins/openai-codex-channels.ts
3578
- var openAICodexChannels = defineChannels("@openai/codex-sdk", {
3579
- run: channel({
3580
- channelName: "Thread.run",
3581
- kind: "async"
3582
- }),
3583
- runStreamed: channel({
3584
- channelName: "Thread.runStreamed",
3585
- kind: "async"
3586
- })
3587
- });
4209
+ var openAICodexChannels = defineChannels(
4210
+ "@openai/codex-sdk",
4211
+ {
4212
+ run: channel({
4213
+ channelName: "Thread.run",
4214
+ kind: "async"
4215
+ }),
4216
+ runStreamed: channel({
4217
+ channelName: "Thread.runStreamed",
4218
+ kind: "async"
4219
+ })
4220
+ },
4221
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENAI_CODEX }
4222
+ );
3588
4223
 
3589
4224
  // src/auto-instrumentations/configs/openai-codex.ts
3590
4225
  var openAICodexVersionRange = ">=0.128.0 <1.0.0";
@@ -3618,38 +4253,40 @@ var openAICodexConfigs = [
3618
4253
  ];
3619
4254
 
3620
4255
  // src/instrumentation/plugins/openrouter-channels.ts
3621
- var openRouterChannels = defineChannels("@openrouter/sdk", {
3622
- chatSend: channel({
3623
- channelName: "chat.send",
3624
- kind: "async"
3625
- }),
3626
- embeddingsGenerate: channel({
3627
- channelName: "embeddings.generate",
3628
- kind: "async"
3629
- }),
3630
- rerankRerank: channel(
3631
- {
4256
+ var openRouterChannels = defineChannels(
4257
+ "@openrouter/sdk",
4258
+ {
4259
+ chatSend: channel({
4260
+ channelName: "chat.send",
4261
+ kind: "async"
4262
+ }),
4263
+ embeddingsGenerate: channel({
4264
+ channelName: "embeddings.generate",
4265
+ kind: "async"
4266
+ }),
4267
+ rerankRerank: channel({
3632
4268
  channelName: "rerank.rerank",
3633
4269
  kind: "async"
3634
- }
3635
- ),
3636
- betaResponsesSend: channel({
3637
- channelName: "beta.responses.send",
3638
- kind: "async"
3639
- }),
3640
- callModel: channel({
3641
- channelName: "callModel",
3642
- kind: "sync-stream"
3643
- }),
3644
- callModelTurn: channel({
3645
- channelName: "callModel.turn",
3646
- kind: "async"
3647
- }),
3648
- toolExecute: channel({
3649
- channelName: "tool.execute",
3650
- kind: "async"
3651
- })
3652
- });
4270
+ }),
4271
+ betaResponsesSend: channel({
4272
+ channelName: "beta.responses.send",
4273
+ kind: "async"
4274
+ }),
4275
+ callModel: channel({
4276
+ channelName: "callModel",
4277
+ kind: "sync-stream"
4278
+ }),
4279
+ callModelTurn: channel({
4280
+ channelName: "callModel.turn",
4281
+ kind: "async"
4282
+ }),
4283
+ toolExecute: channel({
4284
+ channelName: "tool.execute",
4285
+ kind: "async"
4286
+ })
4287
+ },
4288
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENROUTER }
4289
+ );
3653
4290
 
3654
4291
  // src/auto-instrumentations/configs/openrouter.ts
3655
4292
  var openRouterConfigs = [
@@ -3657,7 +4294,7 @@ var openRouterConfigs = [
3657
4294
  channelName: openRouterChannels.chatSend.channelName,
3658
4295
  module: {
3659
4296
  name: "@openrouter/sdk",
3660
- versionRange: ">=0.9.11 <1.0.0",
4297
+ versionRange: ">=0.9.11 <2.0.0",
3661
4298
  filePath: "esm/sdk/chat.js"
3662
4299
  },
3663
4300
  functionQuery: {
@@ -3670,7 +4307,7 @@ var openRouterConfigs = [
3670
4307
  channelName: openRouterChannels.embeddingsGenerate.channelName,
3671
4308
  module: {
3672
4309
  name: "@openrouter/sdk",
3673
- versionRange: ">=0.9.11 <1.0.0",
4310
+ versionRange: ">=0.9.11 <2.0.0",
3674
4311
  filePath: "esm/sdk/embeddings.js"
3675
4312
  },
3676
4313
  functionQuery: {
@@ -3683,7 +4320,7 @@ var openRouterConfigs = [
3683
4320
  channelName: openRouterChannels.rerankRerank.channelName,
3684
4321
  module: {
3685
4322
  name: "@openrouter/sdk",
3686
- versionRange: ">=0.12.0 <1.0.0",
4323
+ versionRange: ">=0.12.0 <2.0.0",
3687
4324
  filePath: "esm/sdk/rerank.js"
3688
4325
  },
3689
4326
  functionQuery: {
@@ -3696,7 +4333,7 @@ var openRouterConfigs = [
3696
4333
  channelName: openRouterChannels.betaResponsesSend.channelName,
3697
4334
  module: {
3698
4335
  name: "@openrouter/sdk",
3699
- versionRange: ">=0.9.11 <1.0.0",
4336
+ versionRange: ">=0.9.11 <2.0.0",
3700
4337
  filePath: "esm/sdk/responses.js"
3701
4338
  },
3702
4339
  functionQuery: {
@@ -3709,7 +4346,7 @@ var openRouterConfigs = [
3709
4346
  channelName: openRouterChannels.callModel.channelName,
3710
4347
  module: {
3711
4348
  name: "@openrouter/sdk",
3712
- versionRange: ">=0.9.11 <1.0.0",
4349
+ versionRange: ">=0.9.11 <2.0.0",
3713
4350
  filePath: "esm/sdk/sdk.js"
3714
4351
  },
3715
4352
  functionQuery: {
@@ -3721,20 +4358,24 @@ var openRouterConfigs = [
3721
4358
  ];
3722
4359
 
3723
4360
  // src/instrumentation/plugins/openrouter-agent-channels.ts
3724
- var openRouterAgentChannels = defineChannels("@openrouter/agent", {
3725
- callModel: channel({
3726
- channelName: "callModel",
3727
- kind: "sync-stream"
3728
- }),
3729
- callModelTurn: channel({
3730
- channelName: "callModel.turn",
3731
- kind: "async"
3732
- }),
3733
- toolExecute: channel({
3734
- channelName: "tool.execute",
3735
- kind: "async"
3736
- })
3737
- });
4361
+ var openRouterAgentChannels = defineChannels(
4362
+ "@openrouter/agent",
4363
+ {
4364
+ callModel: channel({
4365
+ channelName: "callModel",
4366
+ kind: "sync-stream"
4367
+ }),
4368
+ callModelTurn: channel({
4369
+ channelName: "callModel.turn",
4370
+ kind: "async"
4371
+ }),
4372
+ toolExecute: channel({
4373
+ channelName: "tool.execute",
4374
+ kind: "async"
4375
+ })
4376
+ },
4377
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENROUTER_AGENT }
4378
+ );
3738
4379
 
3739
4380
  // src/auto-instrumentations/configs/openrouter-agent.ts
3740
4381
  var openRouterAgentConfigs = [
@@ -3760,11 +4401,12 @@ var piCodingAgentChannels = defineChannels(
3760
4401
  channelName: "AgentSession.prompt",
3761
4402
  kind: "async"
3762
4403
  })
3763
- }
4404
+ },
4405
+ { instrumentationName: INSTRUMENTATION_NAMES.PI_CODING_AGENT }
3764
4406
  );
3765
4407
 
3766
4408
  // src/auto-instrumentations/configs/pi-coding-agent.ts
3767
- var piCodingAgentVersionRange = ">=0.79.0 <0.80.0";
4409
+ var piCodingAgentVersionRange = ">=0.79.0 <0.82.0";
3768
4410
  var piCodingAgentConfigs = [
3769
4411
  {
3770
4412
  channelName: piCodingAgentChannels.prompt.channelName,
@@ -3782,20 +4424,24 @@ var piCodingAgentConfigs = [
3782
4424
  ];
3783
4425
 
3784
4426
  // src/instrumentation/plugins/strands-agent-sdk-channels.ts
3785
- var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", {
3786
- agentStream: channel({
3787
- channelName: "Agent.stream",
3788
- kind: "sync-stream"
3789
- }),
3790
- graphStream: channel({
3791
- channelName: "Graph.stream",
3792
- kind: "sync-stream"
3793
- }),
3794
- swarmStream: channel({
3795
- channelName: "Swarm.stream",
3796
- kind: "sync-stream"
3797
- })
3798
- });
4427
+ var strandsAgentSDKChannels = defineChannels(
4428
+ "@strands-agents/sdk",
4429
+ {
4430
+ agentStream: channel({
4431
+ channelName: "Agent.stream",
4432
+ kind: "sync-stream"
4433
+ }),
4434
+ graphStream: channel({
4435
+ channelName: "Graph.stream",
4436
+ kind: "sync-stream"
4437
+ }),
4438
+ swarmStream: channel({
4439
+ channelName: "Swarm.stream",
4440
+ kind: "sync-stream"
4441
+ })
4442
+ },
4443
+ { instrumentationName: INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK }
4444
+ );
3799
4445
 
3800
4446
  // src/auto-instrumentations/configs/strands-agent-sdk.ts
3801
4447
  var strandsAgentSDKVersionRange = ">=1.0.0 <2.0.0";
@@ -3861,6 +4507,14 @@ var defaultInstrumentationConfigGroups = [
3861
4507
  integrations: ["claudeAgentSDK"],
3862
4508
  configs: claudeAgentSDKConfigs
3863
4509
  },
4510
+ {
4511
+ integrations: ["cloudflareAIChat"],
4512
+ configs: cloudflareAIChatConfigs
4513
+ },
4514
+ {
4515
+ integrations: ["cloudflareAgents"],
4516
+ configs: cloudflareAgentsConfigs
4517
+ },
3864
4518
  { integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs },
3865
4519
  {
3866
4520
  integrations: ["openAIAgents"],
@@ -3870,7 +4524,10 @@ var defaultInstrumentationConfigGroups = [
3870
4524
  integrations: ["google", "googleGenAI"],
3871
4525
  configs: googleGenAIConfigs
3872
4526
  },
3873
- { integrations: ["huggingface"], configs: huggingFaceConfigs },
4527
+ {
4528
+ integrations: ["huggingface"],
4529
+ configs: [...huggingFaceConfigs, ...huggingFaceTransformersConfigs]
4530
+ },
3874
4531
  {
3875
4532
  integrations: ["langchain", "langgraph"],
3876
4533
  configs: langchainConfigs
@@ -3929,6 +4586,214 @@ function getDefaultInstrumentationConfigs({
3929
4586
  ];
3930
4587
  }
3931
4588
 
4589
+ // src/auto-instrumentations/loader/mastra-observability-patch.ts
4590
+ var MASTRA_EXPORTER_FACTORY_GLOBAL = "__braintrustMastraExporterFactory";
4591
+ var MASTRA_CORE_PACKAGE = "@mastra/core";
4592
+ var MASTRA_OBSERVABILITY_PACKAGE = "@mastra/observability";
4593
+ var MASTRA_CORE_ENTRY_PATHS = /* @__PURE__ */ new Set([
4594
+ "dist/index.js",
4595
+ "dist/index.cjs",
4596
+ "dist/mastra/index.js",
4597
+ "dist/mastra/index.cjs"
4598
+ ]);
4599
+ var MASTRA_OBSERVABILITY_ENTRY_PATHS = /* @__PURE__ */ new Set([
4600
+ "dist/index.js",
4601
+ "dist/index.cjs"
4602
+ ]);
4603
+ function classifyMastraTarget(packageName, modulePath) {
4604
+ if (packageName === MASTRA_CORE_PACKAGE && MASTRA_CORE_ENTRY_PATHS.has(modulePath)) {
4605
+ return "core";
4606
+ }
4607
+ if (packageName === MASTRA_OBSERVABILITY_PACKAGE && MASTRA_OBSERVABILITY_ENTRY_PATHS.has(modulePath)) {
4608
+ return "observability";
4609
+ }
4610
+ return null;
4611
+ }
4612
+ function extractChunkPath(source) {
4613
+ const esmMatch = source.match(
4614
+ /export\s*\{\s*Mastra(?:\s+as\s+\w+)?\s*\}\s*from\s*['"]([^'"]+)['"]/
4615
+ );
4616
+ if (esmMatch) return esmMatch[1];
4617
+ const cjsMatch = source.match(
4618
+ /require\s*\(\s*['"]([^'"]+chunk-[^'"]+)['"]\s*\)/
4619
+ );
4620
+ if (cjsMatch) return cjsMatch[1];
4621
+ return null;
4622
+ }
4623
+ var EXPORTER_FACTORY_KEY = JSON.stringify(MASTRA_EXPORTER_FACTORY_GLOBAL);
4624
+ var MASTRA_PROXY_HANDLER_BODY = `
4625
+ {
4626
+ construct(target, args, newTarget) {
4627
+ var firstArg = args[0];
4628
+ if (
4629
+ (!firstArg || typeof firstArg !== "object" || !firstArg.observability) &&
4630
+ __braintrustObservabilityClass
4631
+ ) {
4632
+ try {
4633
+ // serviceName is required by Mastra's Observability validator; pass
4634
+ // something sensible by default. Users who want a different name
4635
+ // should construct Observability themselves.
4636
+ var observability = new __braintrustObservabilityClass({
4637
+ configs: { default: { serviceName: "mastra" } },
4638
+ });
4639
+ args = args.slice();
4640
+ args[0] = Object.assign({}, firstArg, { observability: observability });
4641
+ } catch (e) {
4642
+ // Fall through. Mastra will use its own NoOp; user code still works,
4643
+ // just without auto-instrumentation.
4644
+ }
4645
+ }
4646
+ return Reflect.construct(target, args, newTarget);
4647
+ },
4648
+ }`;
4649
+ function buildMastraEsmWrapper(chunkPath) {
4650
+ const chunk = JSON.stringify(chunkPath);
4651
+ return `import { Mastra as __braintrustOrigMastra } from ${chunk};
4652
+ import { createRequire as __braintrustCreateRequire } from "node:module";
4653
+
4654
+ let __braintrustObservabilityClass = null;
4655
+ try {
4656
+ // Resolve @mastra/observability relative to this module (the Mastra entry),
4657
+ // so it's looked up from the user's node_modules tree.
4658
+ const __braintrustRequire = __braintrustCreateRequire(import.meta.url);
4659
+ __braintrustObservabilityClass =
4660
+ __braintrustRequire("@mastra/observability").Observability;
4661
+ } catch (e) {
4662
+ // @mastra/observability isn't installed; the construct trap will skip the
4663
+ // auto-construct branch and Mastra falls back to its own NoOp.
4664
+ }
4665
+ const Mastra = new Proxy(__braintrustOrigMastra, ${MASTRA_PROXY_HANDLER_BODY});
4666
+ export { Mastra };
4667
+ `;
4668
+ }
4669
+ function buildMastraCjsWrapper(chunkPath) {
4670
+ const chunk = JSON.stringify(chunkPath);
4671
+ return `'use strict';
4672
+ const __braintrustChunk = require(${chunk});
4673
+
4674
+ let __braintrustObservabilityClass = null;
4675
+ try {
4676
+ __braintrustObservabilityClass = require("@mastra/observability").Observability;
4677
+ } catch (e) {
4678
+ // @mastra/observability isn't installed; same fallback as the ESM wrapper.
4679
+ }
4680
+
4681
+ const __braintrustWrappedMastra = new Proxy(
4682
+ __braintrustChunk.Mastra,
4683
+ ${MASTRA_PROXY_HANDLER_BODY},
4684
+ );
4685
+ Object.defineProperty(exports, "Mastra", {
4686
+ enumerable: true,
4687
+ configurable: true,
4688
+ get: function () { return __braintrustWrappedMastra; }
4689
+ });
4690
+ `;
4691
+ }
4692
+ var OBSERVABILITY_APPEND_BODY = `
4693
+ ;(function __braintrustWrapObservability() {
4694
+ // Top-level so we can both read and reassign the var binding the original
4695
+ // entry declared.
4696
+ if (typeof Observability === "undefined") return;
4697
+ if (Observability.__braintrustWrapped) return;
4698
+ function __braintrustEnsureExporter(rawConfig) {
4699
+ try {
4700
+ var factory = globalThis[${EXPORTER_FACTORY_KEY}];
4701
+ if (typeof factory !== "function") return rawConfig;
4702
+ var config = rawConfig && typeof rawConfig === "object" ? rawConfig : {};
4703
+ var configsIn = config.configs && typeof config.configs === "object" ? config.configs : null;
4704
+ var configsOut = {};
4705
+ var hadEntries = false;
4706
+ if (configsIn) {
4707
+ for (var name in configsIn) {
4708
+ if (!Object.prototype.hasOwnProperty.call(configsIn, name)) continue;
4709
+ hadEntries = true;
4710
+ var inst = configsIn[name] || {};
4711
+ var existing = Array.isArray(inst.exporters) ? inst.exporters : [];
4712
+ var hasOurs = existing.some(function (e) { return e && e.name === "braintrust"; });
4713
+ configsOut[name] = Object.assign({}, inst, {
4714
+ exporters: hasOurs ? existing : existing.concat([factory()]),
4715
+ });
4716
+ }
4717
+ }
4718
+ if (!hadEntries) {
4719
+ configsOut.default = {
4720
+ serviceName: "mastra",
4721
+ exporters: [factory()],
4722
+ };
4723
+ }
4724
+ return Object.assign({}, config, { configs: configsOut });
4725
+ } catch (e) {
4726
+ return rawConfig;
4727
+ }
4728
+ }
4729
+ var __OriginalObservability = Observability;
4730
+ Observability = new Proxy(__OriginalObservability, {
4731
+ construct: function (target, args, newTarget) {
4732
+ var nextArgs = args.slice();
4733
+ nextArgs[0] = __braintrustEnsureExporter(nextArgs[0]);
4734
+ return Reflect.construct(target, nextArgs, newTarget);
4735
+ },
4736
+ });
4737
+ Observability.__braintrustWrapped = true;
4738
+ if (typeof exports !== "undefined" && exports && typeof exports === "object") {
4739
+ try {
4740
+ Object.defineProperty(exports, "Observability", {
4741
+ enumerable: true,
4742
+ configurable: true,
4743
+ get: function () { return Observability; },
4744
+ });
4745
+ } catch (e) {}
4746
+ }
4747
+ })();
4748
+ `;
4749
+ function patchMastraSource(source, target, format) {
4750
+ if (target === "core") {
4751
+ const chunkPath = extractChunkPath(source);
4752
+ if (!chunkPath) return source;
4753
+ return format === "esm" ? buildMastraEsmWrapper(chunkPath) : buildMastraCjsWrapper(chunkPath);
4754
+ }
4755
+ return source + OBSERVABILITY_APPEND_BODY;
4756
+ }
4757
+
4758
+ // src/auto-instrumentations/loader/openai-api-promise-patch.ts
4759
+ var OPENAI_API_PROMISE_PATCH = `
4760
+ ;(function __btPatchAPIPromise() {
4761
+ if (typeof APIPromise === "undefined" || APIPromise.prototype.__btParsePatched) return;
4762
+ APIPromise.prototype.__btParsePatched = true;
4763
+ var _origThen = APIPromise.prototype.then;
4764
+ APIPromise.prototype.then = function __btThen(onfulfilled, onrejected) {
4765
+ if (!this.__btParseWrapped && Object.prototype.hasOwnProperty.call(this, "parseResponse")) {
4766
+ this.__btParseWrapped = true;
4767
+ var _origParse = this.parseResponse;
4768
+ var _cached;
4769
+ this.parseResponse = function() {
4770
+ if (!_cached) _cached = _origParse.apply(this, arguments);
4771
+ return _cached;
4772
+ };
4773
+ }
4774
+ return _origThen.call(this, onfulfilled, onrejected);
4775
+ };
4776
+ })();
4777
+ `;
4778
+
4779
+ // src/auto-instrumentations/loader/special-case-patches.ts
4780
+ function applySpecialCasePatch(input) {
4781
+ if (input.packageName === "openai" && input.modulePath.includes("api-promise")) {
4782
+ return input.source + OPENAI_API_PROMISE_PATCH;
4783
+ }
4784
+ if (input.browser) {
4785
+ return null;
4786
+ }
4787
+ const mastraTarget = classifyMastraTarget(
4788
+ input.packageName,
4789
+ input.modulePath
4790
+ );
4791
+ if (mastraTarget) {
4792
+ return patchMastraSource(input.source, mastraTarget, input.format);
4793
+ }
4794
+ return null;
4795
+ }
4796
+
3932
4797
  // src/auto-instrumentations/bundler/webpack-loader.ts
3933
4798
  function getModuleVersion(basedir) {
3934
4799
  try {
@@ -3946,8 +4811,7 @@ function getMatcher(options) {
3946
4811
  const allInstrumentations = getDefaultInstrumentationConfigs({
3947
4812
  additionalInstrumentations: options.instrumentations
3948
4813
  });
3949
- const dcModule = options.browser ? "dc-browser" : void 0;
3950
- const configHash = JSON.stringify({ allInstrumentations, dcModule });
4814
+ const configHash = JSON.stringify({ allInstrumentations });
3951
4815
  if (matcherCache.has(configHash)) {
3952
4816
  return matcherCache.get(configHash);
3953
4817
  }
@@ -3956,7 +4820,7 @@ function getMatcher(options) {
3956
4820
  matcherCache.delete(hash);
3957
4821
  }
3958
4822
  }
3959
- const matcher = create(allInstrumentations, dcModule ?? null);
4823
+ const matcher = create(allInstrumentations);
3960
4824
  matcherCache.set(configHash, matcher);
3961
4825
  return matcher;
3962
4826
  }
@@ -3981,11 +4845,21 @@ function codeTransformerLoader(code, inputSourceMap) {
3981
4845
  return callback(null, code, inputSourceMap);
3982
4846
  }
3983
4847
  const moduleName = moduleDetails.name;
4848
+ const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
4849
+ const patched = applySpecialCasePatch({
4850
+ packageName: moduleName,
4851
+ modulePath: normalizedModulePath,
4852
+ source: code,
4853
+ format: isModule ? "esm" : "cjs",
4854
+ browser: options.browser ?? options.useDiagnosticChannelCompatShim ?? false
4855
+ });
4856
+ if (patched !== null) {
4857
+ return callback(null, patched);
4858
+ }
3984
4859
  const moduleVersion = getModuleVersion(moduleDetails.basedir);
3985
4860
  if (!moduleVersion) {
3986
4861
  return callback(null, code, inputSourceMap);
3987
4862
  }
3988
- const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
3989
4863
  const matcher = getMatcher(options);
3990
4864
  const transformer = matcher.getTransformer(
3991
4865
  moduleName,