braintrust 3.28.0 → 3.29.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 (50) hide show
  1. package/README.md +1 -1
  2. package/dev/dist/index.d.mts +356 -7
  3. package/dev/dist/index.d.ts +356 -7
  4. package/dev/dist/index.js +1815 -1548
  5. package/dev/dist/index.mjs +1054 -787
  6. package/dist/apply-auto-instrumentation.js +297 -264
  7. package/dist/apply-auto-instrumentation.mjs +84 -51
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +43 -5
  9. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  10. package/dist/auto-instrumentations/bundler/next.cjs +43 -5
  11. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  12. package/dist/auto-instrumentations/bundler/rollup.cjs +43 -5
  13. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  14. package/dist/auto-instrumentations/bundler/vite.cjs +43 -5
  15. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  16. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +43 -5
  17. package/dist/auto-instrumentations/bundler/webpack.cjs +43 -5
  18. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  19. package/dist/auto-instrumentations/{chunk-NP7V4XB2.mjs → chunk-AOIYCVEL.mjs} +32 -2
  20. package/dist/auto-instrumentations/{chunk-26PKVUKB.mjs → chunk-DKTGDNA7.mjs} +12 -4
  21. package/dist/auto-instrumentations/{chunk-HD35AM3M.mjs → chunk-OMCZ3MV2.mjs} +1 -1
  22. package/dist/auto-instrumentations/hook.mjs +952 -133
  23. package/dist/auto-instrumentations/index.cjs +32 -2
  24. package/dist/auto-instrumentations/index.mjs +1 -1
  25. package/dist/browser.d.mts +760 -22
  26. package/dist/browser.d.ts +760 -22
  27. package/dist/browser.js +1661 -848
  28. package/dist/browser.mjs +1661 -848
  29. package/dist/{chunk-BBE7SNRV.js → chunk-6Z5S7VOU.js} +143 -23
  30. package/dist/{chunk-ZHUHZWFY.mjs → chunk-7FA6VP2S.mjs} +140 -20
  31. package/dist/{chunk-UPFNQCGB.mjs → chunk-M6XPNJC4.mjs} +1144 -931
  32. package/dist/{chunk-OBBWQW6K.js → chunk-XLLGRXGR.js} +2335 -2122
  33. package/dist/cli.js +5134 -1090
  34. package/dist/edge-light.js +1661 -848
  35. package/dist/edge-light.mjs +1661 -848
  36. package/dist/index.d.mts +760 -22
  37. package/dist/index.d.ts +760 -22
  38. package/dist/index.js +1054 -567
  39. package/dist/index.mjs +514 -27
  40. package/dist/instrumentation/index.d.mts +548 -9
  41. package/dist/instrumentation/index.d.ts +548 -9
  42. package/dist/instrumentation/index.js +1975 -765
  43. package/dist/instrumentation/index.mjs +1975 -765
  44. package/dist/vitest-evals-reporter.js +16 -16
  45. package/dist/vitest-evals-reporter.mjs +2 -2
  46. package/dist/workerd.js +1661 -848
  47. package/dist/workerd.mjs +1661 -848
  48. package/package.json +1 -1
  49. package/util/dist/index.d.mts +42 -0
  50. package/util/dist/index.d.ts +42 -0
@@ -659,8 +659,6 @@ function newGlobalTracingChannel(nameOrChannels) {
659
659
  var DefaultAsyncLocalStorage = class {
660
660
  constructor() {
661
661
  }
662
- enterWith(_) {
663
- }
664
662
  run(_, callback) {
665
663
  return callback();
666
664
  }
@@ -687,6 +685,118 @@ var iso = {
687
685
  };
688
686
  var isomorph_default = iso;
689
687
 
688
+ // src/debug-logger.ts
689
+ var PREFIX = "[braintrust]";
690
+ var DEBUG_LOG_LEVEL_SYMBOL = /* @__PURE__ */ Symbol.for("braintrust-debug-log-level");
691
+ var LOG_LEVEL_PRIORITY = {
692
+ error: 0,
693
+ warn: 1,
694
+ info: 2,
695
+ debug: 3
696
+ };
697
+ var hasWarnedAboutInvalidEnvValue = false;
698
+ var debugLogStateResolver = void 0;
699
+ function warnInvalidEnvValue(value) {
700
+ if (hasWarnedAboutInvalidEnvValue) {
701
+ return;
702
+ }
703
+ hasWarnedAboutInvalidEnvValue = true;
704
+ console.warn(
705
+ PREFIX,
706
+ `Invalid BRAINTRUST_DEBUG_LOG_LEVEL value "${value}". Expected "error", "warn", "info", or "debug".`
707
+ );
708
+ }
709
+ function normalizeDebugLogLevelOption(option) {
710
+ if (option === false) {
711
+ return void 0;
712
+ }
713
+ if (option === "error" || option === "warn" || option === "info" || option === "debug") {
714
+ return option;
715
+ }
716
+ throw new Error(
717
+ `Invalid debugLogLevel value "${option}". Expected false, "error", "warn", "info", or "debug".`
718
+ );
719
+ }
720
+ function parseDebugLogLevelEnv(value) {
721
+ if (!value) {
722
+ return void 0;
723
+ }
724
+ if (value === "error" || value === "warn" || value === "info" || value === "debug") {
725
+ return value;
726
+ }
727
+ warnInvalidEnvValue(value);
728
+ return void 0;
729
+ }
730
+ function getEnvDebugLogLevel() {
731
+ return parseDebugLogLevelEnv(isomorph_default.getEnv("BRAINTRUST_DEBUG_LOG_LEVEL"));
732
+ }
733
+ function setGlobalDebugLogLevel(level) {
734
+ globalThis[DEBUG_LOG_LEVEL_SYMBOL] = level;
735
+ }
736
+ function resetDebugLoggerForTests() {
737
+ hasWarnedAboutInvalidEnvValue = false;
738
+ setGlobalDebugLogLevel(void 0);
739
+ }
740
+ function setDebugLogStateResolver(resolver) {
741
+ debugLogStateResolver = resolver;
742
+ }
743
+ function resolveDebugLogLevel(state) {
744
+ const stateLevel = _optionalChain([state, 'optionalAccess', _3 => _3.getDebugLogLevel, 'optionalCall', _4 => _4()]);
745
+ const hasStateOverride = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _5 => _5.hasDebugLogLevelOverride, 'optionalCall', _6 => _6()]), () => ( false));
746
+ if (hasStateOverride) {
747
+ return stateLevel;
748
+ }
749
+ const globalLevel = (
750
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
751
+ globalThis[DEBUG_LOG_LEVEL_SYMBOL]
752
+ );
753
+ if (globalLevel !== void 0) {
754
+ return globalLevel === false ? void 0 : globalLevel;
755
+ }
756
+ return getEnvDebugLogLevel();
757
+ }
758
+ function emit(method, state, args) {
759
+ const level = resolveDebugLogLevel(state);
760
+ if (!level || LOG_LEVEL_PRIORITY[method] > LOG_LEVEL_PRIORITY[level]) {
761
+ return;
762
+ }
763
+ if (method === "info") {
764
+ console.log(PREFIX, ...args);
765
+ } else if (method === "debug") {
766
+ console.debug(PREFIX, ...args);
767
+ } else if (method === "warn") {
768
+ console.warn(PREFIX, ...args);
769
+ } else {
770
+ console.error(PREFIX, ...args);
771
+ }
772
+ }
773
+ function createDebugLogger(state) {
774
+ const resolveState = () => _nullishCoalesce(state, () => ( _optionalChain([debugLogStateResolver, 'optionalCall', _7 => _7()])));
775
+ return {
776
+ info(...args) {
777
+ emit("info", resolveState(), args);
778
+ },
779
+ debug(...args) {
780
+ emit("debug", resolveState(), args);
781
+ },
782
+ warn(...args) {
783
+ emit("warn", resolveState(), args);
784
+ },
785
+ error(...args) {
786
+ emit("error", resolveState(), args);
787
+ }
788
+ };
789
+ }
790
+ var debugLogger = {
791
+ ...createDebugLogger(),
792
+ forState(state) {
793
+ return createDebugLogger(state);
794
+ }
795
+ };
796
+ setGlobalHookErrorReporter((error) => {
797
+ debugLogger.error("Global instrumentation hook error:", error);
798
+ });
799
+
690
800
  // src/span-origin.ts
691
801
  var INSTRUMENTATION_NAMES = {
692
802
  AI_SDK: "ai-sdk",
@@ -699,6 +809,7 @@ var INSTRUMENTATION_NAMES = {
699
809
  CLOUDFLARE_THINK: "cloudflare-think",
700
810
  COHERE: "cohere",
701
811
  CURSOR_SDK: "cursor-sdk",
812
+ DEEPSEEK_HARNESS: "deepseek-harness",
702
813
  EVE: "eve",
703
814
  FLUE: "flue",
704
815
  GENKIT: "genkit",
@@ -724,7 +835,7 @@ var INSTRUMENTATION_NAMES = {
724
835
  var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
725
836
  "braintrust.spanInstrumentationName"
726
837
  );
727
- var SDK_VERSION = true ? "3.28.0" : "0.0.0";
838
+ var SDK_VERSION = true ? "3.29.0" : "0.0.0";
728
839
  function withSpanInstrumentationName(args, instrumentationName) {
729
840
  return {
730
841
  ...args,
@@ -771,10 +882,10 @@ function detectSpanOriginEnvironment(explicit) {
771
882
  return { type: "server", name: "ecs" };
772
883
  }
773
884
  const awsExecutionEnv = isomorph_default.getEnv("AWS_EXECUTION_ENV");
774
- if (_optionalChain([awsExecutionEnv, 'optionalAccess', _3 => _3.startsWith, 'call', _4 => _4("AWS_ECS_")])) {
885
+ if (_optionalChain([awsExecutionEnv, 'optionalAccess', _8 => _8.startsWith, 'call', _9 => _9("AWS_ECS_")])) {
775
886
  return { type: "server", name: "ecs" };
776
887
  }
777
- if (_optionalChain([awsExecutionEnv, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("AWS_Lambda_")])) {
888
+ if (_optionalChain([awsExecutionEnv, 'optionalAccess', _10 => _10.startsWith, 'call', _11 => _11("AWS_Lambda_")])) {
778
889
  return { type: "server", name: "aws_lambda" };
779
890
  }
780
891
  if (isomorph_default.getEnv("AWS_LAMBDA_FUNCTION_NAME")) {
@@ -813,7 +924,7 @@ function isSpanInstrumentationName(value) {
813
924
  return Object.values(INSTRUMENTATION_NAMES).some((name) => name === value);
814
925
  }
815
926
  function firstPresent(entries) {
816
- return _optionalChain([entries, 'access', _7 => _7.find, 'call', _8 => _8(([key]) => Boolean(isomorph_default.getEnv(key))), 'optionalAccess', _9 => _9[1]]);
927
+ return _optionalChain([entries, 'access', _12 => _12.find, 'call', _13 => _13(([key]) => Boolean(isomorph_default.getEnv(key))), 'optionalAccess', _14 => _14[1]]);
817
928
  }
818
929
  function deploymentModeEnvironment(_key, value) {
819
930
  if (!value) return void 0;
@@ -995,6 +1106,10 @@ var aiSDKChannels = defineChannels(
995
1106
  channelName: "generateText",
996
1107
  kind: "async"
997
1108
  }),
1109
+ generateImage: channel({
1110
+ channelName: "generateImage",
1111
+ kind: "async"
1112
+ }),
998
1113
  streamText: channel({
999
1114
  channelName: "streamText",
1000
1115
  kind: "async"
@@ -1732,7 +1847,7 @@ function readDisabledInstrumentationEnvConfig(disabledList) {
1732
1847
  return { integrations };
1733
1848
  }
1734
1849
  function isInstrumentationIntegrationDisabled(integrations, ...names) {
1735
- return names.some((name) => _optionalChain([integrations, 'optionalAccess', _10 => _10[name]]) === false);
1850
+ return names.some((name) => _optionalChain([integrations, 'optionalAccess', _15 => _15[name]]) === false);
1736
1851
  }
1737
1852
 
1738
1853
  // src/auto-instrumentations/loader/mastra-observability-patch.ts
@@ -1908,6 +2023,22 @@ function patchMastraSource(source, target, format) {
1908
2023
  return source + OBSERVABILITY_APPEND_BODY;
1909
2024
  }
1910
2025
 
2026
+ // src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
2027
+ var cloudflareAIChatChannels = defineChannels(
2028
+ "@cloudflare/ai-chat",
2029
+ {
2030
+ runExclusiveChatTurn: channel({
2031
+ channelName: "AIChatAgent._runExclusiveChatTurn",
2032
+ kind: "async"
2033
+ }),
2034
+ onChatResponse: channel({
2035
+ channelName: "AIChatAgent.onChatResponse",
2036
+ kind: "sync-stream"
2037
+ })
2038
+ },
2039
+ { instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
2040
+ );
2041
+
1911
2042
  // src/instrumentation/plugins/openai-agents-channels.ts
1912
2043
  var openAIAgentsCoreChannels = defineChannels(
1913
2044
  "@openai/agents-core",
@@ -1948,21 +2079,6 @@ var langChainChannels = defineChannels(
1948
2079
  { instrumentationName: INSTRUMENTATION_NAMES.LANGCHAIN }
1949
2080
  );
1950
2081
 
1951
- // src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
1952
- var cloudflareAIChatChannels = defineChannels(
1953
- "@cloudflare/ai-chat",
1954
- {
1955
- runExclusiveChatTurn: channel({
1956
- channelName: "AIChatAgent._runExclusiveChatTurn",
1957
- kind: "async"
1958
- }),
1959
- onChatResponse: channel({
1960
- channelName: "AIChatAgent.onChatResponse",
1961
- kind: "sync-stream"
1962
- })
1963
- },
1964
- { instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
1965
- );
1966
2082
 
1967
2083
 
1968
2084
 
@@ -2019,4 +2135,8 @@ var cloudflareAIChatChannels = defineChannels(
2019
2135
 
2020
2136
 
2021
2137
 
2022
- exports.__export = __export; exports.GLOBAL_INSTRUMENTATION_HOOKS_KEY = GLOBAL_INSTRUMENTATION_HOOKS_KEY; exports.GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION = GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION; exports.GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND = GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND; exports.GLOBAL_INSTRUMENTATION_HOOK_BRAND = GLOBAL_INSTRUMENTATION_HOOK_BRAND; exports.setGlobalHookErrorReporter = setGlobalHookErrorReporter; exports.isomorph_default = isomorph_default; exports.INSTRUMENTATION_NAMES = INSTRUMENTATION_NAMES; exports.withSpanInstrumentationName = withSpanInstrumentationName; exports.getSpanInstrumentationName = getSpanInstrumentationName; exports.detectSpanOriginEnvironment = detectSpanOriginEnvironment; exports.mergeSpanOriginContext = mergeSpanOriginContext; exports.openAIChannels = openAIChannels; exports.openAICodexChannels = openAICodexChannels; exports.anthropicChannels = anthropicChannels; exports.aiSDKChannels = aiSDKChannels; exports.harnessAgentChannels = harnessAgentChannels; exports.claudeAgentSDKChannels = claudeAgentSDKChannels; exports.cloudflareThinkChannels = cloudflareThinkChannels; exports.cursorSDKChannels = cursorSDKChannels; exports.openAIAgentsCoreChannels = openAIAgentsCoreChannels; exports.googleGenAIChannels = googleGenAIChannels; exports.huggingFaceChannels = huggingFaceChannels; exports.isSupportedHuggingFaceTransformersTask = isSupportedHuggingFaceTransformersTask; exports.registerHuggingFaceTransformersPipeline = registerHuggingFaceTransformersPipeline; exports.getHuggingFaceTransformersPipelineInfo = getHuggingFaceTransformersPipelineInfo; exports.huggingFaceTransformersChannels = huggingFaceTransformersChannels; exports.openRouterAgentChannels = openRouterAgentChannels; exports.openRouterChannels = openRouterChannels; exports.mistralChannels = mistralChannels; exports.ollamaChannels = ollamaChannels; exports.googleADKChannels = googleADKChannels; exports.cohereChannels = cohereChannels; exports.groqChannels = groqChannels; exports.bedrockRuntimeChannels = bedrockRuntimeChannels; exports.smithyCoreChannels = smithyCoreChannels; exports.smithyClientChannels = smithyClientChannels; exports.genkitChannels = genkitChannels; exports.genkitCoreChannels = genkitCoreChannels; exports.gitHubCopilotChannels = gitHubCopilotChannels; exports.flueChannels = flueChannels; exports.langChainChannels = langChainChannels; exports.langSmithChannels = langSmithChannels; exports.piCodingAgentChannels = piCodingAgentChannels; exports.strandsAgentSDKChannels = strandsAgentSDKChannels; exports.voyageAIChannels = voyageAIChannels; exports.cloudflareAIChatChannels = cloudflareAIChatChannels; exports.cloudflareAgentsChannels = cloudflareAgentsChannels; exports.getDefaultInstrumentationIntegrations = getDefaultInstrumentationIntegrations; exports.readDisabledInstrumentationEnvConfig = readDisabledInstrumentationEnvConfig; exports.isInstrumentationIntegrationDisabled = isInstrumentationIntegrationDisabled; exports.installMastraExporterFactory = installMastraExporterFactory; exports.classifyMastraTarget = classifyMastraTarget; exports.patchMastraSource = patchMastraSource;
2138
+
2139
+
2140
+
2141
+
2142
+ exports.__export = __export; exports.GLOBAL_INSTRUMENTATION_HOOKS_KEY = GLOBAL_INSTRUMENTATION_HOOKS_KEY; exports.GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION = GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION; exports.GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND = GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND; exports.GLOBAL_INSTRUMENTATION_HOOK_BRAND = GLOBAL_INSTRUMENTATION_HOOK_BRAND; exports.isomorph_default = isomorph_default; exports.normalizeDebugLogLevelOption = normalizeDebugLogLevelOption; exports.getEnvDebugLogLevel = getEnvDebugLogLevel; exports.setGlobalDebugLogLevel = setGlobalDebugLogLevel; exports.resetDebugLoggerForTests = resetDebugLoggerForTests; exports.setDebugLogStateResolver = setDebugLogStateResolver; exports.debugLogger = debugLogger; exports.INSTRUMENTATION_NAMES = INSTRUMENTATION_NAMES; exports.withSpanInstrumentationName = withSpanInstrumentationName; exports.getSpanInstrumentationName = getSpanInstrumentationName; exports.detectSpanOriginEnvironment = detectSpanOriginEnvironment; exports.mergeSpanOriginContext = mergeSpanOriginContext; exports.openAIChannels = openAIChannels; exports.openAICodexChannels = openAICodexChannels; exports.anthropicChannels = anthropicChannels; exports.aiSDKChannels = aiSDKChannels; exports.harnessAgentChannels = harnessAgentChannels; exports.claudeAgentSDKChannels = claudeAgentSDKChannels; exports.cloudflareThinkChannels = cloudflareThinkChannels; exports.cursorSDKChannels = cursorSDKChannels; exports.openAIAgentsCoreChannels = openAIAgentsCoreChannels; exports.googleGenAIChannels = googleGenAIChannels; exports.huggingFaceChannels = huggingFaceChannels; exports.isSupportedHuggingFaceTransformersTask = isSupportedHuggingFaceTransformersTask; exports.registerHuggingFaceTransformersPipeline = registerHuggingFaceTransformersPipeline; exports.getHuggingFaceTransformersPipelineInfo = getHuggingFaceTransformersPipelineInfo; exports.huggingFaceTransformersChannels = huggingFaceTransformersChannels; exports.openRouterAgentChannels = openRouterAgentChannels; exports.openRouterChannels = openRouterChannels; exports.mistralChannels = mistralChannels; exports.ollamaChannels = ollamaChannels; exports.googleADKChannels = googleADKChannels; exports.cohereChannels = cohereChannels; exports.groqChannels = groqChannels; exports.bedrockRuntimeChannels = bedrockRuntimeChannels; exports.smithyCoreChannels = smithyCoreChannels; exports.smithyClientChannels = smithyClientChannels; exports.genkitChannels = genkitChannels; exports.genkitCoreChannels = genkitCoreChannels; exports.gitHubCopilotChannels = gitHubCopilotChannels; exports.flueChannels = flueChannels; exports.langChainChannels = langChainChannels; exports.langSmithChannels = langSmithChannels; exports.piCodingAgentChannels = piCodingAgentChannels; exports.strandsAgentSDKChannels = strandsAgentSDKChannels; exports.voyageAIChannels = voyageAIChannels; exports.cloudflareAIChatChannels = cloudflareAIChatChannels; exports.cloudflareAgentsChannels = cloudflareAgentsChannels; exports.getDefaultInstrumentationIntegrations = getDefaultInstrumentationIntegrations; exports.readDisabledInstrumentationEnvConfig = readDisabledInstrumentationEnvConfig; exports.isInstrumentationIntegrationDisabled = isInstrumentationIntegrationDisabled; exports.installMastraExporterFactory = installMastraExporterFactory; exports.classifyMastraTarget = classifyMastraTarget; exports.patchMastraSource = patchMastraSource;
@@ -659,8 +659,6 @@ function newGlobalTracingChannel(nameOrChannels) {
659
659
  var DefaultAsyncLocalStorage = class {
660
660
  constructor() {
661
661
  }
662
- enterWith(_) {
663
- }
664
662
  run(_, callback) {
665
663
  return callback();
666
664
  }
@@ -687,6 +685,118 @@ var iso = {
687
685
  };
688
686
  var isomorph_default = iso;
689
687
 
688
+ // src/debug-logger.ts
689
+ var PREFIX = "[braintrust]";
690
+ var DEBUG_LOG_LEVEL_SYMBOL = /* @__PURE__ */ Symbol.for("braintrust-debug-log-level");
691
+ var LOG_LEVEL_PRIORITY = {
692
+ error: 0,
693
+ warn: 1,
694
+ info: 2,
695
+ debug: 3
696
+ };
697
+ var hasWarnedAboutInvalidEnvValue = false;
698
+ var debugLogStateResolver = void 0;
699
+ function warnInvalidEnvValue(value) {
700
+ if (hasWarnedAboutInvalidEnvValue) {
701
+ return;
702
+ }
703
+ hasWarnedAboutInvalidEnvValue = true;
704
+ console.warn(
705
+ PREFIX,
706
+ `Invalid BRAINTRUST_DEBUG_LOG_LEVEL value "${value}". Expected "error", "warn", "info", or "debug".`
707
+ );
708
+ }
709
+ function normalizeDebugLogLevelOption(option) {
710
+ if (option === false) {
711
+ return void 0;
712
+ }
713
+ if (option === "error" || option === "warn" || option === "info" || option === "debug") {
714
+ return option;
715
+ }
716
+ throw new Error(
717
+ `Invalid debugLogLevel value "${option}". Expected false, "error", "warn", "info", or "debug".`
718
+ );
719
+ }
720
+ function parseDebugLogLevelEnv(value) {
721
+ if (!value) {
722
+ return void 0;
723
+ }
724
+ if (value === "error" || value === "warn" || value === "info" || value === "debug") {
725
+ return value;
726
+ }
727
+ warnInvalidEnvValue(value);
728
+ return void 0;
729
+ }
730
+ function getEnvDebugLogLevel() {
731
+ return parseDebugLogLevelEnv(isomorph_default.getEnv("BRAINTRUST_DEBUG_LOG_LEVEL"));
732
+ }
733
+ function setGlobalDebugLogLevel(level) {
734
+ globalThis[DEBUG_LOG_LEVEL_SYMBOL] = level;
735
+ }
736
+ function resetDebugLoggerForTests() {
737
+ hasWarnedAboutInvalidEnvValue = false;
738
+ setGlobalDebugLogLevel(void 0);
739
+ }
740
+ function setDebugLogStateResolver(resolver) {
741
+ debugLogStateResolver = resolver;
742
+ }
743
+ function resolveDebugLogLevel(state) {
744
+ const stateLevel = state?.getDebugLogLevel?.();
745
+ const hasStateOverride = state?.hasDebugLogLevelOverride?.() ?? false;
746
+ if (hasStateOverride) {
747
+ return stateLevel;
748
+ }
749
+ const globalLevel = (
750
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
751
+ globalThis[DEBUG_LOG_LEVEL_SYMBOL]
752
+ );
753
+ if (globalLevel !== void 0) {
754
+ return globalLevel === false ? void 0 : globalLevel;
755
+ }
756
+ return getEnvDebugLogLevel();
757
+ }
758
+ function emit(method, state, args) {
759
+ const level = resolveDebugLogLevel(state);
760
+ if (!level || LOG_LEVEL_PRIORITY[method] > LOG_LEVEL_PRIORITY[level]) {
761
+ return;
762
+ }
763
+ if (method === "info") {
764
+ console.log(PREFIX, ...args);
765
+ } else if (method === "debug") {
766
+ console.debug(PREFIX, ...args);
767
+ } else if (method === "warn") {
768
+ console.warn(PREFIX, ...args);
769
+ } else {
770
+ console.error(PREFIX, ...args);
771
+ }
772
+ }
773
+ function createDebugLogger(state) {
774
+ const resolveState = () => state ?? debugLogStateResolver?.();
775
+ return {
776
+ info(...args) {
777
+ emit("info", resolveState(), args);
778
+ },
779
+ debug(...args) {
780
+ emit("debug", resolveState(), args);
781
+ },
782
+ warn(...args) {
783
+ emit("warn", resolveState(), args);
784
+ },
785
+ error(...args) {
786
+ emit("error", resolveState(), args);
787
+ }
788
+ };
789
+ }
790
+ var debugLogger = {
791
+ ...createDebugLogger(),
792
+ forState(state) {
793
+ return createDebugLogger(state);
794
+ }
795
+ };
796
+ setGlobalHookErrorReporter((error) => {
797
+ debugLogger.error("Global instrumentation hook error:", error);
798
+ });
799
+
690
800
  // src/span-origin.ts
691
801
  var INSTRUMENTATION_NAMES = {
692
802
  AI_SDK: "ai-sdk",
@@ -699,6 +809,7 @@ var INSTRUMENTATION_NAMES = {
699
809
  CLOUDFLARE_THINK: "cloudflare-think",
700
810
  COHERE: "cohere",
701
811
  CURSOR_SDK: "cursor-sdk",
812
+ DEEPSEEK_HARNESS: "deepseek-harness",
702
813
  EVE: "eve",
703
814
  FLUE: "flue",
704
815
  GENKIT: "genkit",
@@ -724,7 +835,7 @@ var INSTRUMENTATION_NAMES = {
724
835
  var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
725
836
  "braintrust.spanInstrumentationName"
726
837
  );
727
- var SDK_VERSION = true ? "3.28.0" : "0.0.0";
838
+ var SDK_VERSION = true ? "3.29.0" : "0.0.0";
728
839
  function withSpanInstrumentationName(args, instrumentationName) {
729
840
  return {
730
841
  ...args,
@@ -995,6 +1106,10 @@ var aiSDKChannels = defineChannels(
995
1106
  channelName: "generateText",
996
1107
  kind: "async"
997
1108
  }),
1109
+ generateImage: channel({
1110
+ channelName: "generateImage",
1111
+ kind: "async"
1112
+ }),
998
1113
  streamText: channel({
999
1114
  channelName: "streamText",
1000
1115
  kind: "async"
@@ -1908,6 +2023,22 @@ function patchMastraSource(source, target, format) {
1908
2023
  return source + OBSERVABILITY_APPEND_BODY;
1909
2024
  }
1910
2025
 
2026
+ // src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
2027
+ var cloudflareAIChatChannels = defineChannels(
2028
+ "@cloudflare/ai-chat",
2029
+ {
2030
+ runExclusiveChatTurn: channel({
2031
+ channelName: "AIChatAgent._runExclusiveChatTurn",
2032
+ kind: "async"
2033
+ }),
2034
+ onChatResponse: channel({
2035
+ channelName: "AIChatAgent.onChatResponse",
2036
+ kind: "sync-stream"
2037
+ })
2038
+ },
2039
+ { instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
2040
+ );
2041
+
1911
2042
  // src/instrumentation/plugins/openai-agents-channels.ts
1912
2043
  var openAIAgentsCoreChannels = defineChannels(
1913
2044
  "@openai/agents-core",
@@ -1948,30 +2079,19 @@ var langChainChannels = defineChannels(
1948
2079
  { instrumentationName: INSTRUMENTATION_NAMES.LANGCHAIN }
1949
2080
  );
1950
2081
 
1951
- // src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
1952
- var cloudflareAIChatChannels = defineChannels(
1953
- "@cloudflare/ai-chat",
1954
- {
1955
- runExclusiveChatTurn: channel({
1956
- channelName: "AIChatAgent._runExclusiveChatTurn",
1957
- kind: "async"
1958
- }),
1959
- onChatResponse: channel({
1960
- channelName: "AIChatAgent.onChatResponse",
1961
- kind: "sync-stream"
1962
- })
1963
- },
1964
- { instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
1965
- );
1966
-
1967
2082
  export {
1968
2083
  __export,
1969
2084
  GLOBAL_INSTRUMENTATION_HOOKS_KEY,
1970
2085
  GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
1971
2086
  GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND,
1972
2087
  GLOBAL_INSTRUMENTATION_HOOK_BRAND,
1973
- setGlobalHookErrorReporter,
1974
2088
  isomorph_default,
2089
+ normalizeDebugLogLevelOption,
2090
+ getEnvDebugLogLevel,
2091
+ setGlobalDebugLogLevel,
2092
+ resetDebugLoggerForTests,
2093
+ setDebugLogStateResolver,
2094
+ debugLogger,
1975
2095
  INSTRUMENTATION_NAMES,
1976
2096
  withSpanInstrumentationName,
1977
2097
  getSpanInstrumentationName,