braintrust 3.11.0 → 3.13.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 (77) hide show
  1. package/README.md +8 -8
  2. package/dev/dist/index.d.mts +26 -7
  3. package/dev/dist/index.d.ts +26 -7
  4. package/dev/dist/index.js +2717 -335
  5. package/dev/dist/index.mjs +2499 -117
  6. package/dist/apply-auto-instrumentation.browser.d.mts +2 -0
  7. package/dist/apply-auto-instrumentation.browser.d.ts +2 -0
  8. package/dist/apply-auto-instrumentation.browser.js +18 -0
  9. package/dist/apply-auto-instrumentation.browser.mjs +0 -0
  10. package/dist/apply-auto-instrumentation.d.mts +2 -0
  11. package/dist/apply-auto-instrumentation.d.ts +2 -0
  12. package/dist/apply-auto-instrumentation.js +2534 -0
  13. package/dist/apply-auto-instrumentation.mjs +2534 -0
  14. package/dist/auto-instrumentations/bundler/esbuild.cjs +1803 -1283
  15. package/dist/auto-instrumentations/bundler/esbuild.d.mts +9 -5
  16. package/dist/auto-instrumentations/bundler/esbuild.d.ts +9 -5
  17. package/dist/auto-instrumentations/bundler/esbuild.mjs +10 -2
  18. package/dist/auto-instrumentations/bundler/next.cjs +3269 -0
  19. package/dist/auto-instrumentations/bundler/next.d.mts +3 -0
  20. package/dist/auto-instrumentations/bundler/next.d.ts +3 -0
  21. package/dist/auto-instrumentations/bundler/next.mjs +189 -0
  22. package/dist/auto-instrumentations/bundler/rollup.cjs +1803 -1283
  23. package/dist/auto-instrumentations/bundler/rollup.d.mts +9 -5
  24. package/dist/auto-instrumentations/bundler/rollup.d.ts +9 -5
  25. package/dist/auto-instrumentations/bundler/rollup.mjs +10 -2
  26. package/dist/auto-instrumentations/bundler/vite.cjs +1803 -1283
  27. package/dist/auto-instrumentations/bundler/vite.d.mts +9 -5
  28. package/dist/auto-instrumentations/bundler/vite.d.ts +9 -5
  29. package/dist/auto-instrumentations/bundler/vite.mjs +10 -2
  30. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1861 -1308
  31. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +3 -3
  32. package/dist/auto-instrumentations/bundler/webpack.cjs +1803 -1283
  33. package/dist/auto-instrumentations/bundler/webpack.d.mts +9 -5
  34. package/dist/auto-instrumentations/bundler/webpack.d.ts +9 -5
  35. package/dist/auto-instrumentations/bundler/webpack.mjs +6 -6
  36. package/dist/auto-instrumentations/{chunk-DIV5TO4S.mjs → chunk-E5DUYJWK.mjs} +338 -1
  37. package/dist/auto-instrumentations/chunk-GJOO4ESL.mjs +300 -0
  38. package/dist/auto-instrumentations/chunk-WFEUJACP.mjs +18 -0
  39. package/dist/auto-instrumentations/hook.mjs +1713 -1460
  40. package/dist/auto-instrumentations/index.cjs +94 -0
  41. package/dist/auto-instrumentations/index.d.mts +5 -1
  42. package/dist/auto-instrumentations/index.d.ts +5 -1
  43. package/dist/auto-instrumentations/index.mjs +6 -247
  44. package/dist/auto-instrumentations/loader/esm-hook.mjs +19 -2
  45. package/dist/auto-instrumentations/plugin-D7nDswtC.d.mts +44 -0
  46. package/dist/auto-instrumentations/plugin-D7nDswtC.d.ts +44 -0
  47. package/dist/browser.d.mts +264 -47
  48. package/dist/browser.d.ts +264 -47
  49. package/dist/browser.js +2521 -159
  50. package/dist/browser.mjs +2521 -159
  51. package/dist/chunk-26JGOELH.js +817 -0
  52. package/dist/chunk-75IQCUB2.mjs +817 -0
  53. package/dist/cli.js +2510 -122
  54. package/dist/edge-light.d.mts +1 -1
  55. package/dist/edge-light.d.ts +1 -1
  56. package/dist/edge-light.js +2521 -159
  57. package/dist/edge-light.mjs +2521 -159
  58. package/dist/index.d.mts +264 -47
  59. package/dist/index.d.ts +264 -47
  60. package/dist/index.js +3498 -1850
  61. package/dist/index.mjs +2635 -987
  62. package/dist/instrumentation/index.d.mts +7897 -48
  63. package/dist/instrumentation/index.d.ts +7897 -48
  64. package/dist/instrumentation/index.js +2408 -95
  65. package/dist/instrumentation/index.mjs +2407 -95
  66. package/dist/workerd.d.mts +1 -1
  67. package/dist/workerd.d.ts +1 -1
  68. package/dist/workerd.js +2521 -159
  69. package/dist/workerd.mjs +2521 -159
  70. package/package.json +23 -17
  71. package/util/dist/index.d.mts +3 -1
  72. package/util/dist/index.d.ts +3 -1
  73. package/util/dist/index.js +6 -0
  74. package/util/dist/index.mjs +6 -0
  75. package/dist/auto-instrumentations/chunk-G6ZWXGZB.mjs +0 -116
  76. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.mts +0 -22
  77. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.ts +0 -22
@@ -0,0 +1,817 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/auto-instrumentations/patch-tracing-channel.ts
8
+ function patchTracingChannel(tracingChannelFn) {
9
+ const dummyChannel = tracingChannelFn("__braintrust_probe__");
10
+ const TracingChannel = dummyChannel?.constructor;
11
+ if (!TracingChannel?.prototype) {
12
+ return;
13
+ }
14
+ if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) {
15
+ Object.defineProperty(TracingChannel.prototype, "hasSubscribers", {
16
+ configurable: true,
17
+ enumerable: false,
18
+ get() {
19
+ return Boolean(
20
+ this.start?.hasSubscribers || this.end?.hasSubscribers || this.asyncStart?.hasSubscribers || this.asyncEnd?.hasSubscribers || this.error?.hasSubscribers
21
+ );
22
+ }
23
+ });
24
+ }
25
+ if (TracingChannel.prototype.tracePromise) {
26
+ TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) {
27
+ const start = this.start;
28
+ const end = this.end;
29
+ const asyncStart = this.asyncStart;
30
+ const asyncEnd = this.asyncEnd;
31
+ const error = this.error;
32
+ function publishRejected(err) {
33
+ context.error = err;
34
+ error?.publish(context);
35
+ asyncStart?.publish(context);
36
+ asyncEnd?.publish(context);
37
+ }
38
+ function publishResolved(result) {
39
+ context.result = result;
40
+ asyncStart?.publish(context);
41
+ asyncEnd?.publish(context);
42
+ }
43
+ return start.runStores(context, () => {
44
+ try {
45
+ const result = Reflect.apply(fn, thisArg, args);
46
+ end?.publish(context);
47
+ if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") {
48
+ if (result.constructor === Promise) {
49
+ return result.then(
50
+ (res) => {
51
+ publishResolved(res);
52
+ return res;
53
+ },
54
+ (err) => {
55
+ publishRejected(err);
56
+ return Promise.reject(err);
57
+ }
58
+ );
59
+ }
60
+ void result.then(
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ (resolved) => {
63
+ try {
64
+ publishResolved(resolved);
65
+ } catch {
66
+ }
67
+ },
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ (err) => {
70
+ try {
71
+ publishRejected(err);
72
+ } catch {
73
+ }
74
+ }
75
+ );
76
+ return result;
77
+ }
78
+ context.result = result;
79
+ asyncStart?.publish(context);
80
+ asyncEnd?.publish(context);
81
+ return result;
82
+ } catch (err) {
83
+ context.error = err;
84
+ error?.publish(context);
85
+ end?.publish(context);
86
+ throw err;
87
+ }
88
+ });
89
+ };
90
+ }
91
+ }
92
+
93
+ // src/isomorph.ts
94
+ var DefaultAsyncLocalStorage = class {
95
+ constructor() {
96
+ }
97
+ enterWith(_) {
98
+ }
99
+ run(_, callback) {
100
+ return callback();
101
+ }
102
+ getStore() {
103
+ return void 0;
104
+ }
105
+ };
106
+ var DefaultChannel = class {
107
+ constructor(name) {
108
+ this.name = name;
109
+ }
110
+ hasSubscribers = false;
111
+ subscribe(_subscription) {
112
+ }
113
+ unsubscribe(_subscription) {
114
+ return false;
115
+ }
116
+ bindStore(_store, _transform) {
117
+ }
118
+ unbindStore(_store) {
119
+ return false;
120
+ }
121
+ publish(_message) {
122
+ }
123
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
+ runStores(_message, fn, thisArg, ...args) {
125
+ return fn.apply(thisArg, args);
126
+ }
127
+ };
128
+ var DefaultTracingChannel = class {
129
+ start;
130
+ end;
131
+ asyncStart;
132
+ asyncEnd;
133
+ error;
134
+ constructor(nameOrChannels) {
135
+ if (typeof nameOrChannels === "string") {
136
+ this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`);
137
+ this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`);
138
+ this.asyncStart = new DefaultChannel(
139
+ `tracing:${nameOrChannels}:asyncStart`
140
+ );
141
+ this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
142
+ this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
143
+ return;
144
+ }
145
+ this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start");
146
+ this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end");
147
+ this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart");
148
+ this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd");
149
+ this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error");
150
+ }
151
+ get hasSubscribers() {
152
+ return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
153
+ }
154
+ subscribe(_handlers) {
155
+ }
156
+ unsubscribe(_handlers) {
157
+ return false;
158
+ }
159
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
160
+ traceSync(fn, _message, thisArg, ...args) {
161
+ return fn.apply(thisArg, args);
162
+ }
163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
+ tracePromise(fn, _message, thisArg, ...args) {
165
+ return fn.apply(thisArg, args);
166
+ }
167
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
+ traceCallback(fn, _position, _message, thisArg, ...args) {
169
+ return fn.apply(thisArg, args);
170
+ }
171
+ };
172
+ var iso = {
173
+ buildType: "unknown",
174
+ // Will be set by configureBrowser() or configureNode()
175
+ getRepoInfo: async (_settings) => void 0,
176
+ getPastNAncestors: async () => [],
177
+ getEnv: (_name) => void 0,
178
+ getBraintrustApiKey: async () => void 0,
179
+ getCallerLocation: () => void 0,
180
+ newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
181
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
182
+ newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels),
183
+ processOn: (_0, _1) => {
184
+ },
185
+ basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
186
+ // eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
187
+ writeln: (text) => console.log(text)
188
+ };
189
+ var isomorph_default = iso;
190
+
191
+ // src/instrumentation/core/channel-definitions.ts
192
+ function channel(spec) {
193
+ return spec;
194
+ }
195
+ function defineChannels(pkg, channels) {
196
+ return Object.fromEntries(
197
+ Object.entries(channels).map(([key, spec]) => {
198
+ const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`;
199
+ if (spec.kind === "async") {
200
+ const asyncSpec = spec;
201
+ const tracingChannel2 = () => isomorph_default.newTracingChannel(
202
+ fullChannelName
203
+ );
204
+ return [
205
+ key,
206
+ {
207
+ ...asyncSpec,
208
+ tracingChannel: tracingChannel2,
209
+ tracePromise: (fn, context) => tracingChannel2().tracePromise(
210
+ fn,
211
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
212
+ context
213
+ )
214
+ }
215
+ ];
216
+ }
217
+ const syncSpec = spec;
218
+ const tracingChannel = () => isomorph_default.newTracingChannel(
219
+ fullChannelName
220
+ );
221
+ return [
222
+ key,
223
+ {
224
+ ...syncSpec,
225
+ tracingChannel,
226
+ traceSync: (fn, context) => tracingChannel().traceSync(
227
+ fn,
228
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
229
+ context
230
+ )
231
+ }
232
+ ];
233
+ })
234
+ );
235
+ }
236
+
237
+ // src/instrumentation/plugins/openai-channels.ts
238
+ var openAIChannels = defineChannels("openai", {
239
+ chatCompletionsCreate: channel({
240
+ channelName: "chat.completions.create",
241
+ kind: "async"
242
+ }),
243
+ embeddingsCreate: channel({
244
+ channelName: "embeddings.create",
245
+ kind: "async"
246
+ }),
247
+ betaChatCompletionsParse: channel({
248
+ channelName: "beta.chat.completions.parse",
249
+ kind: "async"
250
+ }),
251
+ betaChatCompletionsStream: channel({
252
+ channelName: "beta.chat.completions.stream",
253
+ kind: "sync-stream"
254
+ }),
255
+ moderationsCreate: channel({
256
+ channelName: "moderations.create",
257
+ kind: "async"
258
+ }),
259
+ responsesCreate: channel({
260
+ channelName: "responses.create",
261
+ kind: "async"
262
+ }),
263
+ responsesStream: channel({
264
+ channelName: "responses.stream",
265
+ kind: "sync-stream"
266
+ }),
267
+ responsesParse: channel({
268
+ channelName: "responses.parse",
269
+ kind: "async"
270
+ }),
271
+ responsesCompact: channel({
272
+ channelName: "responses.compact",
273
+ kind: "async"
274
+ })
275
+ });
276
+
277
+ // src/instrumentation/plugins/openai-codex-channels.ts
278
+ var openAICodexChannels = defineChannels("@openai/codex-sdk", {
279
+ run: channel({
280
+ channelName: "Thread.run",
281
+ kind: "async"
282
+ }),
283
+ runStreamed: channel({
284
+ channelName: "Thread.runStreamed",
285
+ kind: "async"
286
+ })
287
+ });
288
+
289
+ // src/instrumentation/plugins/anthropic-channels.ts
290
+ var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
291
+ messagesCreate: channel({
292
+ channelName: "messages.create",
293
+ kind: "async"
294
+ }),
295
+ betaMessagesCreate: channel({
296
+ channelName: "beta.messages.create",
297
+ kind: "async"
298
+ }),
299
+ betaMessagesToolRunner: channel({
300
+ channelName: "beta.messages.toolRunner",
301
+ kind: "sync-stream"
302
+ })
303
+ });
304
+
305
+ // src/instrumentation/plugins/ai-sdk-channels.ts
306
+ var aiSDKChannels = defineChannels("ai", {
307
+ generateText: channel({
308
+ channelName: "generateText",
309
+ kind: "async"
310
+ }),
311
+ streamText: channel({
312
+ channelName: "streamText",
313
+ kind: "async"
314
+ }),
315
+ streamTextSync: channel({
316
+ channelName: "streamText.sync",
317
+ kind: "sync-stream"
318
+ }),
319
+ generateObject: channel({
320
+ channelName: "generateObject",
321
+ kind: "async"
322
+ }),
323
+ streamObject: channel({
324
+ channelName: "streamObject",
325
+ kind: "async"
326
+ }),
327
+ streamObjectSync: channel({
328
+ channelName: "streamObject.sync",
329
+ kind: "sync-stream"
330
+ }),
331
+ embed: channel(
332
+ {
333
+ channelName: "embed",
334
+ kind: "async"
335
+ }
336
+ ),
337
+ embedMany: channel({
338
+ channelName: "embedMany",
339
+ kind: "async"
340
+ }),
341
+ rerank: channel({
342
+ channelName: "rerank",
343
+ kind: "async"
344
+ }),
345
+ agentGenerate: channel({
346
+ channelName: "Agent.generate",
347
+ kind: "async"
348
+ }),
349
+ agentStream: channel({
350
+ channelName: "Agent.stream",
351
+ kind: "async"
352
+ }),
353
+ agentStreamSync: channel({
354
+ channelName: "Agent.stream.sync",
355
+ kind: "sync-stream"
356
+ }),
357
+ toolLoopAgentGenerate: channel({
358
+ channelName: "ToolLoopAgent.generate",
359
+ kind: "async"
360
+ }),
361
+ toolLoopAgentStream: channel({
362
+ channelName: "ToolLoopAgent.stream",
363
+ kind: "async"
364
+ })
365
+ });
366
+
367
+ // src/instrumentation/plugins/claude-agent-sdk-channels.ts
368
+ var claudeAgentSDKChannels = defineChannels(
369
+ "@anthropic-ai/claude-agent-sdk",
370
+ {
371
+ query: channel({
372
+ channelName: "query",
373
+ kind: "sync-stream"
374
+ })
375
+ }
376
+ );
377
+
378
+ // src/instrumentation/plugins/cursor-sdk-channels.ts
379
+ var cursorSDKChannels = defineChannels("@cursor/sdk", {
380
+ create: channel({
381
+ channelName: "Agent.create",
382
+ kind: "async"
383
+ }),
384
+ resume: channel({
385
+ channelName: "Agent.resume",
386
+ kind: "async"
387
+ }),
388
+ prompt: channel({
389
+ channelName: "Agent.prompt",
390
+ kind: "async"
391
+ }),
392
+ send: channel({
393
+ channelName: "agent.send",
394
+ kind: "async"
395
+ })
396
+ });
397
+
398
+ // src/instrumentation/plugins/google-genai-channels.ts
399
+ var googleGenAIChannels = defineChannels("@google/genai", {
400
+ generateContent: channel({
401
+ channelName: "models.generateContent",
402
+ kind: "async"
403
+ }),
404
+ generateContentStream: channel({
405
+ channelName: "models.generateContentStream",
406
+ kind: "async"
407
+ }),
408
+ embedContent: channel({
409
+ channelName: "models.embedContent",
410
+ kind: "async"
411
+ })
412
+ });
413
+
414
+ // src/instrumentation/plugins/huggingface-channels.ts
415
+ var huggingFaceChannels = defineChannels("@huggingface/inference", {
416
+ chatCompletion: channel({
417
+ channelName: "chatCompletion",
418
+ kind: "async"
419
+ }),
420
+ chatCompletionStream: channel({
421
+ channelName: "chatCompletionStream",
422
+ kind: "sync-stream"
423
+ }),
424
+ textGeneration: channel({
425
+ channelName: "textGeneration",
426
+ kind: "async"
427
+ }),
428
+ textGenerationStream: channel({
429
+ channelName: "textGenerationStream",
430
+ kind: "sync-stream"
431
+ }),
432
+ featureExtraction: channel({
433
+ channelName: "featureExtraction",
434
+ kind: "async"
435
+ })
436
+ });
437
+
438
+ // src/instrumentation/plugins/openrouter-agent-channels.ts
439
+ var openRouterAgentChannels = defineChannels("@openrouter/agent", {
440
+ callModel: channel({
441
+ channelName: "callModel",
442
+ kind: "sync-stream"
443
+ }),
444
+ callModelTurn: channel({
445
+ channelName: "callModel.turn",
446
+ kind: "async"
447
+ }),
448
+ toolExecute: channel({
449
+ channelName: "tool.execute",
450
+ kind: "async"
451
+ })
452
+ });
453
+
454
+ // src/instrumentation/plugins/openrouter-channels.ts
455
+ var openRouterChannels = defineChannels("@openrouter/sdk", {
456
+ chatSend: channel({
457
+ channelName: "chat.send",
458
+ kind: "async"
459
+ }),
460
+ embeddingsGenerate: channel({
461
+ channelName: "embeddings.generate",
462
+ kind: "async"
463
+ }),
464
+ rerankRerank: channel(
465
+ {
466
+ channelName: "rerank.rerank",
467
+ kind: "async"
468
+ }
469
+ ),
470
+ betaResponsesSend: channel({
471
+ channelName: "beta.responses.send",
472
+ kind: "async"
473
+ }),
474
+ callModel: channel({
475
+ channelName: "callModel",
476
+ kind: "sync-stream"
477
+ }),
478
+ callModelTurn: channel({
479
+ channelName: "callModel.turn",
480
+ kind: "async"
481
+ }),
482
+ toolExecute: channel({
483
+ channelName: "tool.execute",
484
+ kind: "async"
485
+ })
486
+ });
487
+
488
+ // src/instrumentation/plugins/mistral-channels.ts
489
+ var mistralChannels = defineChannels("@mistralai/mistralai", {
490
+ chatComplete: channel({
491
+ channelName: "chat.complete",
492
+ kind: "async"
493
+ }),
494
+ chatStream: channel({
495
+ channelName: "chat.stream",
496
+ kind: "async"
497
+ }),
498
+ embeddingsCreate: channel({
499
+ channelName: "embeddings.create",
500
+ kind: "async"
501
+ }),
502
+ classifiersModerate: channel({
503
+ channelName: "classifiers.moderate",
504
+ kind: "async"
505
+ }),
506
+ classifiersModerateChat: channel({
507
+ channelName: "classifiers.moderateChat",
508
+ kind: "async"
509
+ }),
510
+ classifiersClassify: channel({
511
+ channelName: "classifiers.classify",
512
+ kind: "async"
513
+ }),
514
+ classifiersClassifyChat: channel({
515
+ channelName: "classifiers.classifyChat",
516
+ kind: "async"
517
+ }),
518
+ fimComplete: channel({
519
+ channelName: "fim.complete",
520
+ kind: "async"
521
+ }),
522
+ fimStream: channel({
523
+ channelName: "fim.stream",
524
+ kind: "async"
525
+ }),
526
+ agentsComplete: channel({
527
+ channelName: "agents.complete",
528
+ kind: "async"
529
+ }),
530
+ agentsStream: channel({
531
+ channelName: "agents.stream",
532
+ kind: "async"
533
+ })
534
+ });
535
+
536
+ // src/instrumentation/plugins/google-adk-channels.ts
537
+ var googleADKChannels = defineChannels("@google/adk", {
538
+ runnerRunAsync: channel({
539
+ channelName: "runner.runAsync",
540
+ kind: "sync-stream"
541
+ }),
542
+ agentRunAsync: channel({
543
+ channelName: "agent.runAsync",
544
+ kind: "sync-stream"
545
+ }),
546
+ toolRunAsync: channel({
547
+ channelName: "tool.runAsync",
548
+ kind: "async"
549
+ })
550
+ });
551
+
552
+ // src/instrumentation/plugins/cohere-channels.ts
553
+ var cohereChannels = defineChannels("cohere-ai", {
554
+ chat: channel({
555
+ channelName: "chat",
556
+ kind: "async"
557
+ }),
558
+ chatStream: channel({
559
+ channelName: "chatStream",
560
+ kind: "async"
561
+ }),
562
+ embed: channel({
563
+ channelName: "embed",
564
+ kind: "async"
565
+ }),
566
+ rerank: channel({
567
+ channelName: "rerank",
568
+ kind: "async"
569
+ })
570
+ });
571
+
572
+ // src/instrumentation/plugins/groq-channels.ts
573
+ var groqChannels = defineChannels("groq-sdk", {
574
+ chatCompletionsCreate: channel({
575
+ channelName: "chat.completions.create",
576
+ kind: "async"
577
+ }),
578
+ embeddingsCreate: channel(
579
+ {
580
+ channelName: "embeddings.create",
581
+ kind: "async"
582
+ }
583
+ )
584
+ });
585
+
586
+ // src/instrumentation/plugins/genkit-channels.ts
587
+ var genkitChannels = defineChannels("@genkit-ai/ai", {
588
+ generate: channel({
589
+ channelName: "generate",
590
+ kind: "async"
591
+ }),
592
+ generateStream: channel({
593
+ channelName: "generateStream",
594
+ kind: "sync-stream"
595
+ }),
596
+ embed: channel({
597
+ channelName: "embed",
598
+ kind: "async"
599
+ }),
600
+ embedMany: channel({
601
+ channelName: "embedMany",
602
+ kind: "async"
603
+ }),
604
+ actionRun: channel({
605
+ channelName: "action.run",
606
+ kind: "async"
607
+ }),
608
+ actionStream: channel({
609
+ channelName: "action.stream",
610
+ kind: "sync-stream"
611
+ })
612
+ });
613
+ var genkitCoreChannels = defineChannels("@genkit-ai/core", {
614
+ actionSpan: channel({
615
+ channelName: "action.span",
616
+ kind: "async"
617
+ })
618
+ });
619
+
620
+ // src/instrumentation/plugins/github-copilot-channels.ts
621
+ var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", {
622
+ createSession: channel({
623
+ channelName: "client.createSession",
624
+ kind: "async"
625
+ }),
626
+ resumeSession: channel({
627
+ channelName: "client.resumeSession",
628
+ kind: "async"
629
+ }),
630
+ sendAndWait: channel({
631
+ channelName: "session.sendAndWait",
632
+ kind: "async"
633
+ })
634
+ });
635
+
636
+ // src/instrumentation/plugins/flue-channels.ts
637
+ var flueChannels = defineChannels("@flue/runtime", {
638
+ createContext: channel({
639
+ channelName: "createFlueContext",
640
+ kind: "sync-stream"
641
+ }),
642
+ openSession: channel({
643
+ channelName: "Harness.openSession",
644
+ kind: "async"
645
+ }),
646
+ contextEvent: channel({
647
+ channelName: "context.event",
648
+ kind: "sync-stream"
649
+ }),
650
+ prompt: channel({
651
+ channelName: "session.prompt",
652
+ kind: "async"
653
+ }),
654
+ skill: channel({
655
+ channelName: "session.skill",
656
+ kind: "async"
657
+ }),
658
+ task: channel({
659
+ channelName: "session.task",
660
+ kind: "async"
661
+ }),
662
+ compact: channel({
663
+ channelName: "session.compact",
664
+ kind: "async"
665
+ })
666
+ });
667
+
668
+ // src/instrumentation/config.ts
669
+ var envIntegrationAliases = {
670
+ openai: "openai",
671
+ "openai-codex": "openaiCodexSDK",
672
+ "openai-codex-sdk": "openaiCodexSDK",
673
+ openaicodexsdk: "openaiCodexSDK",
674
+ codex: "openaiCodexSDK",
675
+ "codex-sdk": "openaiCodexSDK",
676
+ anthropic: "anthropic",
677
+ aisdk: "aisdk",
678
+ "ai-sdk": "aisdk",
679
+ "vercel-ai": "aisdk",
680
+ vercel: "vercel",
681
+ claudeagentsdk: "claudeAgentSDK",
682
+ "claude-agent-sdk": "claudeAgentSDK",
683
+ cursor: "cursor",
684
+ "cursor-sdk": "cursorSDK",
685
+ cursorsdk: "cursorSDK",
686
+ flue: "flue",
687
+ "flue-runtime": "flue",
688
+ "openai-agents": "openAIAgents",
689
+ openaiagents: "openAIAgents",
690
+ "openai-agents-core": "openAIAgents",
691
+ openaiagentscore: "openAIAgents",
692
+ google: "google",
693
+ "google-genai": "googleGenAI",
694
+ googlegenai: "googleGenAI",
695
+ huggingface: "huggingface",
696
+ openrouter: "openrouter",
697
+ openrouteragent: "openrouterAgent",
698
+ "openrouter-agent": "openrouterAgent",
699
+ mistral: "mistral",
700
+ googleadk: "googleADK",
701
+ "google-adk": "googleADK",
702
+ cohere: "cohere",
703
+ groq: "groq",
704
+ "groq-sdk": "groq",
705
+ genkit: "genkit",
706
+ "firebase-genkit": "genkit",
707
+ githubcopilot: "gitHubCopilot",
708
+ "github-copilot": "gitHubCopilot",
709
+ "copilot-sdk": "gitHubCopilot",
710
+ langchain: "langchain",
711
+ "langchain-js": "langchain",
712
+ "@langchain": "langchain",
713
+ langgraph: "langgraph"
714
+ };
715
+ function getDefaultInstrumentationIntegrations() {
716
+ return {
717
+ openai: true,
718
+ openaiCodexSDK: true,
719
+ anthropic: true,
720
+ vercel: true,
721
+ aisdk: true,
722
+ google: true,
723
+ googleGenAI: true,
724
+ googleADK: true,
725
+ huggingface: true,
726
+ claudeAgentSDK: true,
727
+ cursor: true,
728
+ cursorSDK: true,
729
+ flue: true,
730
+ openAIAgents: true,
731
+ openrouter: true,
732
+ openrouterAgent: true,
733
+ mistral: true,
734
+ cohere: true,
735
+ groq: true,
736
+ genkit: true,
737
+ gitHubCopilot: true,
738
+ langchain: true,
739
+ langgraph: true
740
+ };
741
+ }
742
+ function readDisabledInstrumentationEnvConfig(disabledList) {
743
+ const integrations = {};
744
+ if (disabledList) {
745
+ for (const value of disabledList.split(",")) {
746
+ const sdk = value.trim().toLowerCase();
747
+ if (sdk.length > 0) {
748
+ integrations[envIntegrationAliases[sdk] ?? sdk] = false;
749
+ }
750
+ }
751
+ }
752
+ return { integrations };
753
+ }
754
+ function isInstrumentationIntegrationDisabled(integrations, ...names) {
755
+ return names.some((name) => integrations?.[name] === false);
756
+ }
757
+
758
+ // src/instrumentation/plugins/openai-agents-channels.ts
759
+ var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
760
+ onTraceStart: channel({
761
+ channelName: "tracing.processor.onTraceStart",
762
+ kind: "async"
763
+ }),
764
+ onTraceEnd: channel({
765
+ channelName: "tracing.processor.onTraceEnd",
766
+ kind: "async"
767
+ }),
768
+ onSpanStart: channel({
769
+ channelName: "tracing.processor.onSpanStart",
770
+ kind: "async"
771
+ }),
772
+ onSpanEnd: channel({
773
+ channelName: "tracing.processor.onSpanEnd",
774
+ kind: "async"
775
+ })
776
+ });
777
+
778
+ // src/instrumentation/plugins/langchain-channels.ts
779
+ var langChainChannels = defineChannels("@langchain/core", {
780
+ configure: channel({
781
+ channelName: "CallbackManager.configure",
782
+ kind: "sync-stream"
783
+ }),
784
+ configureSync: channel({
785
+ channelName: "CallbackManager._configureSync",
786
+ kind: "sync-stream"
787
+ })
788
+ });
789
+
790
+ export {
791
+ __export,
792
+ patchTracingChannel,
793
+ isomorph_default,
794
+ openAIChannels,
795
+ openAICodexChannels,
796
+ anthropicChannels,
797
+ aiSDKChannels,
798
+ claudeAgentSDKChannels,
799
+ cursorSDKChannels,
800
+ openAIAgentsCoreChannels,
801
+ googleGenAIChannels,
802
+ huggingFaceChannels,
803
+ openRouterAgentChannels,
804
+ openRouterChannels,
805
+ mistralChannels,
806
+ googleADKChannels,
807
+ cohereChannels,
808
+ groqChannels,
809
+ genkitChannels,
810
+ genkitCoreChannels,
811
+ gitHubCopilotChannels,
812
+ flueChannels,
813
+ langChainChannels,
814
+ getDefaultInstrumentationIntegrations,
815
+ readDisabledInstrumentationEnvConfig,
816
+ isInstrumentationIntegrationDisabled
817
+ };