braintrust 3.30.0 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -4031,6 +4031,7 @@ var ProjectSettings = import_v36.z.union([
4031
4031
  ]),
4032
4032
  disable_realtime_queries: import_v36.z.union([import_v36.z.boolean(), import_v36.z.null()]),
4033
4033
  monitor_charts_use_metrics_start: import_v36.z.union([import_v36.z.boolean(), import_v36.z.null()]),
4034
+ blind_reviews: import_v36.z.union([import_v36.z.boolean(), import_v36.z.null()]),
4034
4035
  default_preprocessor: NullableSavedFunctionId
4035
4036
  }).partial(),
4036
4037
  import_v36.z.null()
@@ -4092,6 +4093,7 @@ var WindowedAutomationConfig = import_v36.z.object({
4092
4093
  auto_approve_tools: import_v36.z.array(import_v36.z.string().min(1)).optional().default([]),
4093
4094
  harness: import_v36.z.enum(["native", "codex", "claude-code"]).optional(),
4094
4095
  model: import_v36.z.string().min(1).optional(),
4096
+ endpoint_name: import_v36.z.string().min(1).optional(),
4095
4097
  reasoning_effort: import_v36.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional()
4096
4098
  }).optional(),
4097
4099
  actions: import_v36.z.array(
@@ -5883,7 +5885,7 @@ var INSTRUMENTATION_NAMES = {
5883
5885
  var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
5884
5886
  "braintrust.spanInstrumentationName"
5885
5887
  );
5886
- var SDK_VERSION = true ? "3.30.0" : "0.0.0";
5888
+ var SDK_VERSION = true ? "3.31.0" : "0.0.0";
5887
5889
  function withSpanInstrumentationName(args, instrumentationName) {
5888
5890
  return {
5889
5891
  ...args,
@@ -20000,6 +20002,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
20000
20002
  if (!activeEntry) {
20001
20003
  return result;
20002
20004
  }
20005
+ const executionOptions = args[1];
20006
+ const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
20007
+ const toolInput = {
20008
+ input: serializeToolExecutionInput(args),
20009
+ ...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
20010
+ };
20003
20011
  if (isAsyncGenerator(result)) {
20004
20012
  return (async function* () {
20005
20013
  const span = activeEntry.parentSpan.startSpan(
@@ -20013,7 +20021,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
20013
20021
  INSTRUMENTATION_NAMES.AI_SDK
20014
20022
  )
20015
20023
  );
20016
- span.log({ input: serializeToolExecutionInput(args) });
20024
+ span.log(toolInput);
20017
20025
  try {
20018
20026
  let lastValue;
20019
20027
  for await (const value of result) {
@@ -20031,7 +20039,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
20031
20039
  }
20032
20040
  return activeEntry.parentSpan.traced(
20033
20041
  async (span) => {
20034
- span.log({ input: serializeToolExecutionInput(args) });
20042
+ span.log(toolInput);
20035
20043
  const awaitedResult = await result;
20036
20044
  span.log({ output: awaitedResult });
20037
20045
  return awaitedResult;
@@ -34153,14 +34161,17 @@ function getMetricsFromResponse(response) {
34153
34161
  if (!isRecord(usageMetadata)) {
34154
34162
  continue;
34155
34163
  }
34156
- const inputTokenDetails = usageMetadata.input_token_details;
34164
+ const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
34157
34165
  const outputTokenDetails = usageMetadata.output_token_details;
34158
34166
  return normalizeTokenMetrics({
34159
34167
  total_tokens: usageMetadata.total_tokens,
34160
34168
  prompt_tokens: usageMetadata.input_tokens,
34161
34169
  completion_tokens: usageMetadata.output_tokens,
34162
- prompt_cache_creation_tokens: isRecord(inputTokenDetails) ? inputTokenDetails.cache_creation : void 0,
34163
- prompt_cached_tokens: isRecord(inputTokenDetails) ? inputTokenDetails.cache_read : void 0,
34170
+ // Prefer TTL-specific cache writes over the aggregate when available.
34171
+ prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
34172
+ prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
34173
+ prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
34174
+ prompt_cached_tokens: inputTokenDetails.cache_read,
34164
34175
  completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
34165
34176
  });
34166
34177
  }
@@ -45174,8 +45185,8 @@ function normalizeScores(result) {
45174
45185
  (s) => s !== null && s !== void 0 && typeof s === "object" && isScore(s)
45175
45186
  );
45176
45187
  }
45177
- if (typeof result === "object" && result !== null && isScore(result)) {
45178
- return [result];
45188
+ if (typeof result === "object" && result !== null && "score" in result) {
45189
+ return [{ ...result, name: result.name ?? "score" }];
45179
45190
  }
45180
45191
  return [];
45181
45192
  }
@@ -47758,19 +47769,29 @@ function buildSpanScores(results) {
47758
47769
  function _internalPrepareEvaluatorScore(scoreValue, name) {
47759
47770
  if (scoreValue === null) return { results: null };
47760
47771
  if (Array.isArray(scoreValue)) {
47772
+ const names = /* @__PURE__ */ new Set();
47761
47773
  for (const score of scoreValue) {
47762
47774
  if (!(typeof score === "object" && !isEmpty2(score))) {
47763
47775
  throw new Error(
47764
47776
  `When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
47765
47777
  );
47766
47778
  }
47779
+ if (typeof score.name !== "string") {
47780
+ throw new Error(
47781
+ `When returning an array of scores, each score must have a name. Got: ${JSON.stringify(score)}`
47782
+ );
47783
+ }
47784
+ if (names.has(score.name)) {
47785
+ throw new Error(`Duplicate score name '${score.name}' in score array`);
47786
+ }
47787
+ names.add(score.name);
47767
47788
  }
47768
47789
  }
47769
47790
  let results;
47770
47791
  if (Array.isArray(scoreValue)) {
47771
47792
  results = scoreValue;
47772
47793
  } else if (typeof scoreValue === "object" && !isEmpty2(scoreValue)) {
47773
- results = [scoreValue];
47794
+ results = [{ ...scoreValue, name: scoreValue.name ?? name }];
47774
47795
  } else {
47775
47796
  results = [{ name, score: scoreValue }];
47776
47797
  }
package/dist/browser.mjs CHANGED
@@ -3818,6 +3818,7 @@ var ProjectSettings = z6.union([
3818
3818
  ]),
3819
3819
  disable_realtime_queries: z6.union([z6.boolean(), z6.null()]),
3820
3820
  monitor_charts_use_metrics_start: z6.union([z6.boolean(), z6.null()]),
3821
+ blind_reviews: z6.union([z6.boolean(), z6.null()]),
3821
3822
  default_preprocessor: NullableSavedFunctionId
3822
3823
  }).partial(),
3823
3824
  z6.null()
@@ -3879,6 +3880,7 @@ var WindowedAutomationConfig = z6.object({
3879
3880
  auto_approve_tools: z6.array(z6.string().min(1)).optional().default([]),
3880
3881
  harness: z6.enum(["native", "codex", "claude-code"]).optional(),
3881
3882
  model: z6.string().min(1).optional(),
3883
+ endpoint_name: z6.string().min(1).optional(),
3882
3884
  reasoning_effort: z6.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional()
3883
3885
  }).optional(),
3884
3886
  actions: z6.array(
@@ -5672,7 +5674,7 @@ var INSTRUMENTATION_NAMES = {
5672
5674
  var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
5673
5675
  "braintrust.spanInstrumentationName"
5674
5676
  );
5675
- var SDK_VERSION = true ? "3.30.0" : "0.0.0";
5677
+ var SDK_VERSION = true ? "3.31.0" : "0.0.0";
5676
5678
  function withSpanInstrumentationName(args, instrumentationName) {
5677
5679
  return {
5678
5680
  ...args,
@@ -19789,6 +19791,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
19789
19791
  if (!activeEntry) {
19790
19792
  return result;
19791
19793
  }
19794
+ const executionOptions = args[1];
19795
+ const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
19796
+ const toolInput = {
19797
+ input: serializeToolExecutionInput(args),
19798
+ ...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
19799
+ };
19792
19800
  if (isAsyncGenerator(result)) {
19793
19801
  return (async function* () {
19794
19802
  const span = activeEntry.parentSpan.startSpan(
@@ -19802,7 +19810,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
19802
19810
  INSTRUMENTATION_NAMES.AI_SDK
19803
19811
  )
19804
19812
  );
19805
- span.log({ input: serializeToolExecutionInput(args) });
19813
+ span.log(toolInput);
19806
19814
  try {
19807
19815
  let lastValue;
19808
19816
  for await (const value of result) {
@@ -19820,7 +19828,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
19820
19828
  }
19821
19829
  return activeEntry.parentSpan.traced(
19822
19830
  async (span) => {
19823
- span.log({ input: serializeToolExecutionInput(args) });
19831
+ span.log(toolInput);
19824
19832
  const awaitedResult = await result;
19825
19833
  span.log({ output: awaitedResult });
19826
19834
  return awaitedResult;
@@ -33942,14 +33950,17 @@ function getMetricsFromResponse(response) {
33942
33950
  if (!isRecord(usageMetadata)) {
33943
33951
  continue;
33944
33952
  }
33945
- const inputTokenDetails = usageMetadata.input_token_details;
33953
+ const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
33946
33954
  const outputTokenDetails = usageMetadata.output_token_details;
33947
33955
  return normalizeTokenMetrics({
33948
33956
  total_tokens: usageMetadata.total_tokens,
33949
33957
  prompt_tokens: usageMetadata.input_tokens,
33950
33958
  completion_tokens: usageMetadata.output_tokens,
33951
- prompt_cache_creation_tokens: isRecord(inputTokenDetails) ? inputTokenDetails.cache_creation : void 0,
33952
- prompt_cached_tokens: isRecord(inputTokenDetails) ? inputTokenDetails.cache_read : void 0,
33959
+ // Prefer TTL-specific cache writes over the aggregate when available.
33960
+ prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
33961
+ prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
33962
+ prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
33963
+ prompt_cached_tokens: inputTokenDetails.cache_read,
33953
33964
  completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
33954
33965
  });
33955
33966
  }
@@ -44963,8 +44974,8 @@ function normalizeScores(result) {
44963
44974
  (s) => s !== null && s !== void 0 && typeof s === "object" && isScore(s)
44964
44975
  );
44965
44976
  }
44966
- if (typeof result === "object" && result !== null && isScore(result)) {
44967
- return [result];
44977
+ if (typeof result === "object" && result !== null && "score" in result) {
44978
+ return [{ ...result, name: result.name ?? "score" }];
44968
44979
  }
44969
44980
  return [];
44970
44981
  }
@@ -47547,19 +47558,29 @@ function buildSpanScores(results) {
47547
47558
  function _internalPrepareEvaluatorScore(scoreValue, name) {
47548
47559
  if (scoreValue === null) return { results: null };
47549
47560
  if (Array.isArray(scoreValue)) {
47561
+ const names = /* @__PURE__ */ new Set();
47550
47562
  for (const score of scoreValue) {
47551
47563
  if (!(typeof score === "object" && !isEmpty2(score))) {
47552
47564
  throw new Error(
47553
47565
  `When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
47554
47566
  );
47555
47567
  }
47568
+ if (typeof score.name !== "string") {
47569
+ throw new Error(
47570
+ `When returning an array of scores, each score must have a name. Got: ${JSON.stringify(score)}`
47571
+ );
47572
+ }
47573
+ if (names.has(score.name)) {
47574
+ throw new Error(`Duplicate score name '${score.name}' in score array`);
47575
+ }
47576
+ names.add(score.name);
47556
47577
  }
47557
47578
  }
47558
47579
  let results;
47559
47580
  if (Array.isArray(scoreValue)) {
47560
47581
  results = scoreValue;
47561
47582
  } else if (typeof scoreValue === "object" && !isEmpty2(scoreValue)) {
47562
- results = [scoreValue];
47583
+ results = [{ ...scoreValue, name: scoreValue.name ?? name }];
47563
47584
  } else {
47564
47585
  results = [{ name, score: scoreValue }];
47565
47586
  }
@@ -835,7 +835,7 @@ var INSTRUMENTATION_NAMES = {
835
835
  var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
836
836
  "braintrust.spanInstrumentationName"
837
837
  );
838
- var SDK_VERSION = true ? "3.30.0" : "0.0.0";
838
+ var SDK_VERSION = true ? "3.31.0" : "0.0.0";
839
839
  function withSpanInstrumentationName(args, instrumentationName) {
840
840
  return {
841
841
  ...args,
@@ -52,7 +52,7 @@ import {
52
52
  strandsAgentSDKChannels,
53
53
  voyageAIChannels,
54
54
  withSpanInstrumentationName
55
- } from "./chunk-N3JKQ3D3.mjs";
55
+ } from "./chunk-CE3BLB2L.mjs";
56
56
 
57
57
  // src/id-gen.ts
58
58
  import { v4 as uuidv4 } from "uuid";
@@ -3016,6 +3016,7 @@ var ProjectSettings = z6.union([
3016
3016
  ]),
3017
3017
  disable_realtime_queries: z6.union([z6.boolean(), z6.null()]),
3018
3018
  monitor_charts_use_metrics_start: z6.union([z6.boolean(), z6.null()]),
3019
+ blind_reviews: z6.union([z6.boolean(), z6.null()]),
3019
3020
  default_preprocessor: NullableSavedFunctionId
3020
3021
  }).partial(),
3021
3022
  z6.null()
@@ -3077,6 +3078,7 @@ var WindowedAutomationConfig = z6.object({
3077
3078
  auto_approve_tools: z6.array(z6.string().min(1)).optional().default([]),
3078
3079
  harness: z6.enum(["native", "codex", "claude-code"]).optional(),
3079
3080
  model: z6.string().min(1).optional(),
3081
+ endpoint_name: z6.string().min(1).optional(),
3080
3082
  reasoning_effort: z6.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional()
3081
3083
  }).optional(),
3082
3084
  actions: z6.array(
@@ -14987,6 +14989,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
14987
14989
  if (!activeEntry) {
14988
14990
  return result;
14989
14991
  }
14992
+ const executionOptions = args[1];
14993
+ const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
14994
+ const toolInput = {
14995
+ input: serializeToolExecutionInput(args),
14996
+ ...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
14997
+ };
14990
14998
  if (isAsyncGenerator(result)) {
14991
14999
  return (async function* () {
14992
15000
  const span = activeEntry.parentSpan.startSpan(
@@ -15000,7 +15008,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
15000
15008
  INSTRUMENTATION_NAMES.AI_SDK
15001
15009
  )
15002
15010
  );
15003
- span.log({ input: serializeToolExecutionInput(args) });
15011
+ span.log(toolInput);
15004
15012
  try {
15005
15013
  let lastValue;
15006
15014
  for await (const value of result) {
@@ -15018,7 +15026,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
15018
15026
  }
15019
15027
  return activeEntry.parentSpan.traced(
15020
15028
  async (span) => {
15021
- span.log({ input: serializeToolExecutionInput(args) });
15029
+ span.log(toolInput);
15022
15030
  const awaitedResult = await result;
15023
15031
  span.log({ output: awaitedResult });
15024
15032
  return awaitedResult;
@@ -18572,14 +18580,17 @@ function getMetricsFromResponse(response) {
18572
18580
  if (!isRecord(usageMetadata)) {
18573
18581
  continue;
18574
18582
  }
18575
- const inputTokenDetails = usageMetadata.input_token_details;
18583
+ const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
18576
18584
  const outputTokenDetails = usageMetadata.output_token_details;
18577
18585
  return normalizeTokenMetrics({
18578
18586
  total_tokens: usageMetadata.total_tokens,
18579
18587
  prompt_tokens: usageMetadata.input_tokens,
18580
18588
  completion_tokens: usageMetadata.output_tokens,
18581
- prompt_cache_creation_tokens: isRecord(inputTokenDetails) ? inputTokenDetails.cache_creation : void 0,
18582
- prompt_cached_tokens: isRecord(inputTokenDetails) ? inputTokenDetails.cache_read : void 0,
18589
+ // Prefer TTL-specific cache writes over the aggregate when available.
18590
+ prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
18591
+ prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
18592
+ prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
18593
+ prompt_cached_tokens: inputTokenDetails.cache_read,
18583
18594
  completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
18584
18595
  });
18585
18596
  }
@@ -835,7 +835,7 @@ var INSTRUMENTATION_NAMES = {
835
835
  var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
836
836
  "braintrust.spanInstrumentationName"
837
837
  );
838
- var SDK_VERSION = true ? "3.30.0" : "0.0.0";
838
+ var SDK_VERSION = true ? "3.31.0" : "0.0.0";
839
839
  function withSpanInstrumentationName(args, instrumentationName) {
840
840
  return {
841
841
  ...args,