braintrust 3.4.0 → 3.6.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 (58) hide show
  1. package/dev/dist/index.d.mts +49 -7
  2. package/dev/dist/index.d.ts +49 -7
  3. package/dev/dist/index.js +2383 -494
  4. package/dev/dist/index.mjs +2213 -324
  5. package/dist/auto-instrumentations/bundler/esbuild.cjs +289 -10
  6. package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
  7. package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/rollup.cjs +289 -10
  10. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  11. package/dist/auto-instrumentations/bundler/vite.cjs +289 -10
  12. package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
  14. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  15. package/dist/auto-instrumentations/bundler/webpack.cjs +289 -10
  16. package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
  17. package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
  18. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  19. package/dist/auto-instrumentations/chunk-EVUKFMHG.mjs +41 -0
  20. package/dist/auto-instrumentations/{chunk-LVWWLUMN.mjs → chunk-F7WAXFNM.mjs} +290 -11
  21. package/dist/auto-instrumentations/chunk-VLEJ5AEK.mjs +41 -0
  22. package/dist/auto-instrumentations/{chunk-D5ZPIUEL.mjs → chunk-WOUC73KB.mjs} +3 -1
  23. package/dist/auto-instrumentations/hook.mjs +358 -48
  24. package/dist/auto-instrumentations/index.cjs +290 -10
  25. package/dist/auto-instrumentations/index.d.mts +3 -1
  26. package/dist/auto-instrumentations/index.d.ts +3 -1
  27. package/dist/auto-instrumentations/index.mjs +3 -1
  28. package/dist/auto-instrumentations/loader/cjs-patch.cjs +32 -10
  29. package/dist/auto-instrumentations/loader/cjs-patch.mjs +10 -5
  30. package/dist/auto-instrumentations/loader/esm-hook.mjs +4 -4
  31. package/dist/auto-instrumentations/loader/get-package-version.cjs +28 -8
  32. package/dist/auto-instrumentations/loader/get-package-version.d.mts +2 -1
  33. package/dist/auto-instrumentations/loader/get-package-version.d.ts +2 -1
  34. package/dist/auto-instrumentations/loader/get-package-version.mjs +3 -1
  35. package/dist/browser.d.mts +357 -271
  36. package/dist/browser.d.ts +357 -271
  37. package/dist/browser.js +2345 -343
  38. package/dist/browser.mjs +2345 -343
  39. package/dist/cli.js +2296 -414
  40. package/dist/edge-light.d.mts +1 -1
  41. package/dist/edge-light.d.ts +1 -1
  42. package/dist/edge-light.js +2292 -315
  43. package/dist/edge-light.mjs +2292 -315
  44. package/dist/index.d.mts +370 -284
  45. package/dist/index.d.ts +370 -284
  46. package/dist/index.js +2642 -638
  47. package/dist/index.mjs +2385 -381
  48. package/dist/instrumentation/index.d.mts +3 -0
  49. package/dist/instrumentation/index.d.ts +3 -0
  50. package/dist/instrumentation/index.js +1955 -198
  51. package/dist/instrumentation/index.mjs +1955 -198
  52. package/dist/workerd.d.mts +1 -1
  53. package/dist/workerd.d.ts +1 -1
  54. package/dist/workerd.js +2292 -315
  55. package/dist/workerd.mjs +2292 -315
  56. package/package.json +22 -6
  57. package/dist/auto-instrumentations/chunk-XDBPUTVE.mjs +0 -22
  58. package/dist/auto-instrumentations/chunk-ZEC7BCL4.mjs +0 -22
@@ -55,8 +55,54 @@ var DefaultAsyncLocalStorage = class {
55
55
  return void 0;
56
56
  }
57
57
  };
58
- var DefaultTracingChannel = class {
58
+ var DefaultChannel = class {
59
+ constructor(name) {
60
+ this.name = name;
61
+ }
59
62
  hasSubscribers = false;
63
+ subscribe(_subscription) {
64
+ }
65
+ unsubscribe(_subscription) {
66
+ return false;
67
+ }
68
+ bindStore(_store, _transform) {
69
+ }
70
+ unbindStore(_store) {
71
+ return false;
72
+ }
73
+ publish(_message) {
74
+ }
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ runStores(_message, fn, thisArg, ...args) {
77
+ return fn.apply(thisArg, args);
78
+ }
79
+ };
80
+ var DefaultTracingChannel = class {
81
+ start;
82
+ end;
83
+ asyncStart;
84
+ asyncEnd;
85
+ error;
86
+ constructor(nameOrChannels) {
87
+ if (typeof nameOrChannels === "string") {
88
+ this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`);
89
+ this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`);
90
+ this.asyncStart = new DefaultChannel(
91
+ `tracing:${nameOrChannels}:asyncStart`
92
+ );
93
+ this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
94
+ this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
95
+ return;
96
+ }
97
+ this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start");
98
+ this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end");
99
+ this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart");
100
+ this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd");
101
+ this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error");
102
+ }
103
+ get hasSubscribers() {
104
+ return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
105
+ }
60
106
  subscribe(_handlers) {
61
107
  }
62
108
  unsubscribe(_handlers) {
@@ -84,7 +130,7 @@ var iso = {
84
130
  getCallerLocation: () => void 0,
85
131
  newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
86
132
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- newTracingChannel: (_nameOrChannels) => new DefaultTracingChannel(),
133
+ newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels),
88
134
  processOn: (_0, _1) => {
89
135
  },
90
136
  basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
@@ -394,6 +440,10 @@ var aiSDKChannels = defineChannels("ai", {
394
440
  channelName: "streamText",
395
441
  kind: "async"
396
442
  }),
443
+ streamTextSync: channel({
444
+ channelName: "streamText.sync",
445
+ kind: "sync-stream"
446
+ }),
397
447
  generateObject: channel({
398
448
  channelName: "generateObject",
399
449
  kind: "async"
@@ -402,6 +452,10 @@ var aiSDKChannels = defineChannels("ai", {
402
452
  channelName: "streamObject",
403
453
  kind: "async"
404
454
  }),
455
+ streamObjectSync: channel({
456
+ channelName: "streamObject.sync",
457
+ kind: "sync-stream"
458
+ }),
405
459
  agentGenerate: channel({
406
460
  channelName: "Agent.generate",
407
461
  kind: "async"
@@ -409,6 +463,14 @@ var aiSDKChannels = defineChannels("ai", {
409
463
  agentStream: channel({
410
464
  channelName: "Agent.stream",
411
465
  kind: "async"
466
+ }),
467
+ toolLoopAgentGenerate: channel({
468
+ channelName: "ToolLoopAgent.generate",
469
+ kind: "async"
470
+ }),
471
+ toolLoopAgentStream: channel({
472
+ channelName: "ToolLoopAgent.stream",
473
+ kind: "async"
412
474
  })
413
475
  });
414
476
 
@@ -427,6 +489,18 @@ var aiSDKConfigs = [
427
489
  kind: "Async"
428
490
  }
429
491
  },
492
+ {
493
+ channelName: aiSDKChannels.generateText.channelName,
494
+ module: {
495
+ name: "ai",
496
+ versionRange: ">=3.0.0",
497
+ filePath: "dist/index.js"
498
+ },
499
+ functionQuery: {
500
+ functionName: "generateText",
501
+ kind: "Async"
502
+ }
503
+ },
430
504
  // streamText - async function
431
505
  {
432
506
  channelName: aiSDKChannels.streamText.channelName,
@@ -440,6 +514,18 @@ var aiSDKConfigs = [
440
514
  kind: "Async"
441
515
  }
442
516
  },
517
+ {
518
+ channelName: aiSDKChannels.streamTextSync.channelName,
519
+ module: {
520
+ name: "ai",
521
+ versionRange: ">=3.0.0",
522
+ filePath: "dist/index.js"
523
+ },
524
+ functionQuery: {
525
+ functionName: "streamText",
526
+ kind: "Sync"
527
+ }
528
+ },
443
529
  // generateObject - async function
444
530
  {
445
531
  channelName: aiSDKChannels.generateObject.channelName,
@@ -453,6 +539,18 @@ var aiSDKConfigs = [
453
539
  kind: "Async"
454
540
  }
455
541
  },
542
+ {
543
+ channelName: aiSDKChannels.generateObject.channelName,
544
+ module: {
545
+ name: "ai",
546
+ versionRange: ">=3.0.0",
547
+ filePath: "dist/index.js"
548
+ },
549
+ functionQuery: {
550
+ functionName: "generateObject",
551
+ kind: "Async"
552
+ }
553
+ },
456
554
  // streamObject - async function
457
555
  {
458
556
  channelName: aiSDKChannels.streamObject.channelName,
@@ -466,32 +564,132 @@ var aiSDKConfigs = [
466
564
  kind: "Async"
467
565
  }
468
566
  },
469
- // Agent.generate - async method (v3-v5 only, Agent structure changed in v6)
567
+ {
568
+ channelName: aiSDKChannels.streamObjectSync.channelName,
569
+ module: {
570
+ name: "ai",
571
+ versionRange: ">=3.0.0",
572
+ filePath: "dist/index.js"
573
+ },
574
+ functionQuery: {
575
+ functionName: "streamObject",
576
+ kind: "Sync"
577
+ }
578
+ },
579
+ // Agent.generate - async method (v5 only)
580
+ // The compiled AI SDK bundle emits this as an anonymous class method, so we
581
+ // target the first async `generate` method in the file instead of a class name.
470
582
  {
471
583
  channelName: aiSDKChannels.agentGenerate.channelName,
472
584
  module: {
473
585
  name: "ai",
474
- versionRange: ">=3.0.0 <6.0.0",
586
+ versionRange: ">=5.0.0 <6.0.0",
475
587
  filePath: "dist/index.mjs"
476
588
  },
477
589
  functionQuery: {
478
- className: "Agent",
479
590
  methodName: "generate",
480
- kind: "Async"
591
+ kind: "Async",
592
+ index: 0
481
593
  }
482
594
  },
483
- // Agent.stream - async method (v3-v5 only, Agent structure changed in v6)
595
+ {
596
+ channelName: aiSDKChannels.agentGenerate.channelName,
597
+ module: {
598
+ name: "ai",
599
+ versionRange: ">=5.0.0 <6.0.0",
600
+ filePath: "dist/index.js"
601
+ },
602
+ functionQuery: {
603
+ methodName: "generate",
604
+ kind: "Async",
605
+ index: 0
606
+ }
607
+ },
608
+ // Agent.stream - async method (v5 only)
609
+ // The compiled AI SDK bundle emits this as an anonymous class method, so we
610
+ // target the first async `stream` method in the file instead of a class name.
484
611
  {
485
612
  channelName: aiSDKChannels.agentStream.channelName,
486
613
  module: {
487
614
  name: "ai",
488
- versionRange: ">=3.0.0 <6.0.0",
615
+ versionRange: ">=5.0.0 <6.0.0",
489
616
  filePath: "dist/index.mjs"
490
617
  },
491
618
  functionQuery: {
492
- className: "Agent",
493
619
  methodName: "stream",
494
- kind: "Async"
620
+ kind: "Async",
621
+ index: 0
622
+ }
623
+ },
624
+ {
625
+ channelName: aiSDKChannels.agentStream.channelName,
626
+ module: {
627
+ name: "ai",
628
+ versionRange: ">=5.0.0 <6.0.0",
629
+ filePath: "dist/index.js"
630
+ },
631
+ functionQuery: {
632
+ methodName: "stream",
633
+ kind: "Async",
634
+ index: 0
635
+ }
636
+ },
637
+ // ToolLoopAgent.generate - async method (v6 only, Experimental_Agent is an alias)
638
+ // The compiled AI SDK bundle emits this as an anonymous class method, so we
639
+ // target the first async `generate` method in the file instead of a class name.
640
+ {
641
+ channelName: aiSDKChannels.toolLoopAgentGenerate.channelName,
642
+ module: {
643
+ name: "ai",
644
+ versionRange: ">=6.0.0 <7.0.0",
645
+ filePath: "dist/index.mjs"
646
+ },
647
+ functionQuery: {
648
+ methodName: "generate",
649
+ kind: "Async",
650
+ index: 0
651
+ }
652
+ },
653
+ {
654
+ channelName: aiSDKChannels.toolLoopAgentGenerate.channelName,
655
+ module: {
656
+ name: "ai",
657
+ versionRange: ">=6.0.0 <7.0.0",
658
+ filePath: "dist/index.js"
659
+ },
660
+ functionQuery: {
661
+ methodName: "generate",
662
+ kind: "Async",
663
+ index: 0
664
+ }
665
+ },
666
+ // ToolLoopAgent.stream - async method (v6 only, Experimental_Agent is an alias)
667
+ // The compiled AI SDK bundle emits this as an anonymous class method, so we
668
+ // target the first async `stream` method in the file instead of a class name.
669
+ {
670
+ channelName: aiSDKChannels.toolLoopAgentStream.channelName,
671
+ module: {
672
+ name: "ai",
673
+ versionRange: ">=6.0.0 <7.0.0",
674
+ filePath: "dist/index.mjs"
675
+ },
676
+ functionQuery: {
677
+ methodName: "stream",
678
+ kind: "Async",
679
+ index: 0
680
+ }
681
+ },
682
+ {
683
+ channelName: aiSDKChannels.toolLoopAgentStream.channelName,
684
+ module: {
685
+ name: "ai",
686
+ versionRange: ">=6.0.0 <7.0.0",
687
+ filePath: "dist/index.js"
688
+ },
689
+ functionQuery: {
690
+ methodName: "stream",
691
+ kind: "Async",
692
+ index: 0
495
693
  }
496
694
  }
497
695
  ];
@@ -570,6 +768,86 @@ var googleGenAIConfigs = [
570
768
  }
571
769
  ];
572
770
 
771
+ // src/instrumentation/plugins/openrouter-channels.ts
772
+ var openRouterChannels = defineChannels("@openrouter/sdk", {
773
+ chatSend: channel({
774
+ channelName: "chat.send",
775
+ kind: "async"
776
+ }),
777
+ embeddingsGenerate: channel({
778
+ channelName: "embeddings.generate",
779
+ kind: "async"
780
+ }),
781
+ betaResponsesSend: channel({
782
+ channelName: "beta.responses.send",
783
+ kind: "async"
784
+ }),
785
+ callModel: channel({
786
+ channelName: "callModel",
787
+ kind: "sync-stream"
788
+ }),
789
+ toolExecute: channel({
790
+ channelName: "tool.execute",
791
+ kind: "async"
792
+ })
793
+ });
794
+
795
+ // src/auto-instrumentations/configs/openrouter.ts
796
+ var openRouterConfigs = [
797
+ {
798
+ channelName: openRouterChannels.chatSend.channelName,
799
+ module: {
800
+ name: "@openrouter/sdk",
801
+ versionRange: ">=0.9.11 <1.0.0",
802
+ filePath: "esm/sdk/chat.js"
803
+ },
804
+ functionQuery: {
805
+ className: "Chat",
806
+ methodName: "send",
807
+ kind: "Async"
808
+ }
809
+ },
810
+ {
811
+ channelName: openRouterChannels.embeddingsGenerate.channelName,
812
+ module: {
813
+ name: "@openrouter/sdk",
814
+ versionRange: ">=0.9.11 <1.0.0",
815
+ filePath: "esm/sdk/embeddings.js"
816
+ },
817
+ functionQuery: {
818
+ className: "Embeddings",
819
+ methodName: "generate",
820
+ kind: "Async"
821
+ }
822
+ },
823
+ {
824
+ channelName: openRouterChannels.betaResponsesSend.channelName,
825
+ module: {
826
+ name: "@openrouter/sdk",
827
+ versionRange: ">=0.9.11 <1.0.0",
828
+ filePath: "esm/sdk/responses.js"
829
+ },
830
+ functionQuery: {
831
+ className: "Responses",
832
+ methodName: "send",
833
+ kind: "Async"
834
+ }
835
+ },
836
+ {
837
+ channelName: openRouterChannels.callModel.channelName,
838
+ module: {
839
+ name: "@openrouter/sdk",
840
+ versionRange: ">=0.9.11 <1.0.0",
841
+ filePath: "esm/sdk/sdk.js"
842
+ },
843
+ functionQuery: {
844
+ className: "OpenRouter",
845
+ methodName: "callModel",
846
+ kind: "Sync"
847
+ }
848
+ }
849
+ ];
850
+
573
851
  // src/auto-instrumentations/bundler/plugin.ts
574
852
  function getModuleVersion(basedir) {
575
853
  try {
@@ -589,6 +867,7 @@ var unplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
589
867
  ...aiSDKConfigs,
590
868
  ...claudeAgentSDKConfigs,
591
869
  ...googleGenAIConfigs,
870
+ ...openRouterConfigs,
592
871
  ...options.instrumentations || []
593
872
  ];
594
873
  const dcModule = options.browser === false ? void 0 : "dc-browser";
@@ -1,8 +1,8 @@
1
- import * as vite from 'vite';
1
+ import * as unplugin from 'unplugin';
2
2
  import { B as BundlerPluginOptions } from '../plugin-Df3qKIl2.mjs';
3
3
  import '@apm-js-collab/code-transformer';
4
4
 
5
5
  type VitePluginOptions = BundlerPluginOptions;
6
- declare const vitePlugin: (options: BundlerPluginOptions) => vite.Plugin<any> | vite.Plugin<any>[];
6
+ declare const vitePlugin: (options: BundlerPluginOptions) => unplugin.VitePlugin<any> | unplugin.VitePlugin<any>[];
7
7
 
8
8
  export { type VitePluginOptions, vitePlugin };
@@ -1,8 +1,8 @@
1
- import * as vite from 'vite';
1
+ import * as unplugin from 'unplugin';
2
2
  import { B as BundlerPluginOptions } from '../plugin-Df3qKIl2.js';
3
3
  import '@apm-js-collab/code-transformer';
4
4
 
5
5
  type VitePluginOptions = BundlerPluginOptions;
6
- declare const vitePlugin: (options: BundlerPluginOptions) => vite.Plugin<any> | vite.Plugin<any>[];
6
+ declare const vitePlugin: (options: BundlerPluginOptions) => unplugin.VitePlugin<any> | unplugin.VitePlugin<any>[];
7
7
 
8
8
  export { type VitePluginOptions, vitePlugin };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin
3
- } from "../chunk-D5ZPIUEL.mjs";
4
- import "../chunk-LVWWLUMN.mjs";
3
+ } from "../chunk-WOUC73KB.mjs";
4
+ import "../chunk-F7WAXFNM.mjs";
5
5
 
6
6
  // src/auto-instrumentations/bundler/vite.ts
7
7
  var vitePlugin = unplugin.vite;