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/dev/dist/index.d.mts +4 -1
- package/dev/dist/index.d.ts +4 -1
- package/dev/dist/index.js +28 -7
- package/dev/dist/index.mjs +28 -7
- package/dist/apply-auto-instrumentation.js +216 -216
- package/dist/apply-auto-instrumentation.mjs +1 -1
- package/dist/auto-instrumentations/bundler/next.cjs +9 -3
- package/dist/auto-instrumentations/bundler/next.mjs +9 -3
- package/dist/auto-instrumentations/hook.mjs +3 -1
- package/dist/browser.d.mts +481 -478
- package/dist/browser.d.ts +481 -478
- package/dist/browser.js +30 -9
- package/dist/browser.mjs +30 -9
- package/dist/{chunk-2XDW3UCG.js → chunk-4AQGZS6X.js} +1 -1
- package/dist/{chunk-BU6SM54N.mjs → chunk-AJT4FR25.mjs} +17 -6
- package/dist/{chunk-N3JKQ3D3.mjs → chunk-CE3BLB2L.mjs} +1 -1
- package/dist/{chunk-TWCDSYJN.js → chunk-V32LW47Z.js} +535 -524
- package/dist/cli.js +29 -8
- package/dist/edge-light.js +30 -9
- package/dist/edge-light.mjs +30 -9
- package/dist/index.d.mts +481 -478
- package/dist/index.d.ts +481 -478
- package/dist/index.js +460 -450
- package/dist/index.mjs +15 -5
- package/dist/instrumentation/index.js +17 -6
- package/dist/instrumentation/index.mjs +17 -6
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.js +30 -9
- package/dist/workerd.mjs +30 -9
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -143,7 +143,7 @@ import {
|
|
|
143
143
|
wrapMastraAgent,
|
|
144
144
|
wrapTraced,
|
|
145
145
|
zodToJsonSchema
|
|
146
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-AJT4FR25.mjs";
|
|
147
147
|
import {
|
|
148
148
|
INSTRUMENTATION_NAMES,
|
|
149
149
|
__export,
|
|
@@ -177,7 +177,7 @@ import {
|
|
|
177
177
|
strandsAgentSDKChannels,
|
|
178
178
|
voyageAIChannels,
|
|
179
179
|
withSpanInstrumentationName
|
|
180
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-CE3BLB2L.mjs";
|
|
181
181
|
|
|
182
182
|
// src/exports.ts
|
|
183
183
|
var exports_exports = {};
|
|
@@ -7170,8 +7170,8 @@ function normalizeScores(result) {
|
|
|
7170
7170
|
(s) => s !== null && s !== void 0 && typeof s === "object" && isScore(s)
|
|
7171
7171
|
);
|
|
7172
7172
|
}
|
|
7173
|
-
if (typeof result === "object" && result !== null &&
|
|
7174
|
-
return [result];
|
|
7173
|
+
if (typeof result === "object" && result !== null && "score" in result) {
|
|
7174
|
+
return [{ ...result, name: result.name ?? "score" }];
|
|
7175
7175
|
}
|
|
7176
7176
|
return [];
|
|
7177
7177
|
}
|
|
@@ -9754,19 +9754,29 @@ function buildSpanScores(results) {
|
|
|
9754
9754
|
function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
9755
9755
|
if (scoreValue === null) return { results: null };
|
|
9756
9756
|
if (Array.isArray(scoreValue)) {
|
|
9757
|
+
const names = /* @__PURE__ */ new Set();
|
|
9757
9758
|
for (const score of scoreValue) {
|
|
9758
9759
|
if (!(typeof score === "object" && !isEmpty(score))) {
|
|
9759
9760
|
throw new Error(
|
|
9760
9761
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
|
|
9761
9762
|
);
|
|
9762
9763
|
}
|
|
9764
|
+
if (typeof score.name !== "string") {
|
|
9765
|
+
throw new Error(
|
|
9766
|
+
`When returning an array of scores, each score must have a name. Got: ${JSON.stringify(score)}`
|
|
9767
|
+
);
|
|
9768
|
+
}
|
|
9769
|
+
if (names.has(score.name)) {
|
|
9770
|
+
throw new Error(`Duplicate score name '${score.name}' in score array`);
|
|
9771
|
+
}
|
|
9772
|
+
names.add(score.name);
|
|
9763
9773
|
}
|
|
9764
9774
|
}
|
|
9765
9775
|
let results;
|
|
9766
9776
|
if (Array.isArray(scoreValue)) {
|
|
9767
9777
|
results = scoreValue;
|
|
9768
9778
|
} else if (typeof scoreValue === "object" && !isEmpty(scoreValue)) {
|
|
9769
|
-
results = [scoreValue];
|
|
9779
|
+
results = [{ ...scoreValue, name: scoreValue.name ?? name }];
|
|
9770
9780
|
} else {
|
|
9771
9781
|
results = [{ name, score: scoreValue }];
|
|
9772
9782
|
}
|
|
@@ -3963,6 +3963,7 @@ var ProjectSettings = import_v36.z.union([
|
|
|
3963
3963
|
]),
|
|
3964
3964
|
disable_realtime_queries: import_v36.z.union([import_v36.z.boolean(), import_v36.z.null()]),
|
|
3965
3965
|
monitor_charts_use_metrics_start: import_v36.z.union([import_v36.z.boolean(), import_v36.z.null()]),
|
|
3966
|
+
blind_reviews: import_v36.z.union([import_v36.z.boolean(), import_v36.z.null()]),
|
|
3966
3967
|
default_preprocessor: NullableSavedFunctionId
|
|
3967
3968
|
}).partial(),
|
|
3968
3969
|
import_v36.z.null()
|
|
@@ -4024,6 +4025,7 @@ var WindowedAutomationConfig = import_v36.z.object({
|
|
|
4024
4025
|
auto_approve_tools: import_v36.z.array(import_v36.z.string().min(1)).optional().default([]),
|
|
4025
4026
|
harness: import_v36.z.enum(["native", "codex", "claude-code"]).optional(),
|
|
4026
4027
|
model: import_v36.z.string().min(1).optional(),
|
|
4028
|
+
endpoint_name: import_v36.z.string().min(1).optional(),
|
|
4027
4029
|
reasoning_effort: import_v36.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional()
|
|
4028
4030
|
}).optional(),
|
|
4029
4031
|
actions: import_v36.z.array(
|
|
@@ -5815,7 +5817,7 @@ var INSTRUMENTATION_NAMES = {
|
|
|
5815
5817
|
var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
|
|
5816
5818
|
"braintrust.spanInstrumentationName"
|
|
5817
5819
|
);
|
|
5818
|
-
var SDK_VERSION = true ? "3.
|
|
5820
|
+
var SDK_VERSION = true ? "3.31.0" : "0.0.0";
|
|
5819
5821
|
function withSpanInstrumentationName(args, instrumentationName) {
|
|
5820
5822
|
return {
|
|
5821
5823
|
...args,
|
|
@@ -18220,6 +18222,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
18220
18222
|
if (!activeEntry) {
|
|
18221
18223
|
return result;
|
|
18222
18224
|
}
|
|
18225
|
+
const executionOptions = args[1];
|
|
18226
|
+
const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
|
|
18227
|
+
const toolInput = {
|
|
18228
|
+
input: serializeToolExecutionInput(args),
|
|
18229
|
+
...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
|
|
18230
|
+
};
|
|
18223
18231
|
if (isAsyncGenerator(result)) {
|
|
18224
18232
|
return (async function* () {
|
|
18225
18233
|
const span = activeEntry.parentSpan.startSpan(
|
|
@@ -18233,7 +18241,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
18233
18241
|
INSTRUMENTATION_NAMES.AI_SDK
|
|
18234
18242
|
)
|
|
18235
18243
|
);
|
|
18236
|
-
span.log(
|
|
18244
|
+
span.log(toolInput);
|
|
18237
18245
|
try {
|
|
18238
18246
|
let lastValue;
|
|
18239
18247
|
for await (const value of result) {
|
|
@@ -18251,7 +18259,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
18251
18259
|
}
|
|
18252
18260
|
return activeEntry.parentSpan.traced(
|
|
18253
18261
|
async (span) => {
|
|
18254
|
-
span.log(
|
|
18262
|
+
span.log(toolInput);
|
|
18255
18263
|
const awaitedResult = await result;
|
|
18256
18264
|
span.log({ output: awaitedResult });
|
|
18257
18265
|
return awaitedResult;
|
|
@@ -32373,14 +32381,17 @@ function getMetricsFromResponse(response) {
|
|
|
32373
32381
|
if (!isRecord(usageMetadata)) {
|
|
32374
32382
|
continue;
|
|
32375
32383
|
}
|
|
32376
|
-
const inputTokenDetails = usageMetadata.input_token_details;
|
|
32384
|
+
const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
|
|
32377
32385
|
const outputTokenDetails = usageMetadata.output_token_details;
|
|
32378
32386
|
return normalizeTokenMetrics({
|
|
32379
32387
|
total_tokens: usageMetadata.total_tokens,
|
|
32380
32388
|
prompt_tokens: usageMetadata.input_tokens,
|
|
32381
32389
|
completion_tokens: usageMetadata.output_tokens,
|
|
32382
|
-
|
|
32383
|
-
|
|
32390
|
+
// Prefer TTL-specific cache writes over the aggregate when available.
|
|
32391
|
+
prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
|
|
32392
|
+
prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
|
|
32393
|
+
prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
|
|
32394
|
+
prompt_cached_tokens: inputTokenDetails.cache_read,
|
|
32384
32395
|
completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
|
|
32385
32396
|
});
|
|
32386
32397
|
}
|
|
@@ -3917,6 +3917,7 @@ var ProjectSettings = z6.union([
|
|
|
3917
3917
|
]),
|
|
3918
3918
|
disable_realtime_queries: z6.union([z6.boolean(), z6.null()]),
|
|
3919
3919
|
monitor_charts_use_metrics_start: z6.union([z6.boolean(), z6.null()]),
|
|
3920
|
+
blind_reviews: z6.union([z6.boolean(), z6.null()]),
|
|
3920
3921
|
default_preprocessor: NullableSavedFunctionId
|
|
3921
3922
|
}).partial(),
|
|
3922
3923
|
z6.null()
|
|
@@ -3978,6 +3979,7 @@ var WindowedAutomationConfig = z6.object({
|
|
|
3978
3979
|
auto_approve_tools: z6.array(z6.string().min(1)).optional().default([]),
|
|
3979
3980
|
harness: z6.enum(["native", "codex", "claude-code"]).optional(),
|
|
3980
3981
|
model: z6.string().min(1).optional(),
|
|
3982
|
+
endpoint_name: z6.string().min(1).optional(),
|
|
3981
3983
|
reasoning_effort: z6.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional()
|
|
3982
3984
|
}).optional(),
|
|
3983
3985
|
actions: z6.array(
|
|
@@ -5771,7 +5773,7 @@ var INSTRUMENTATION_NAMES = {
|
|
|
5771
5773
|
var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
|
|
5772
5774
|
"braintrust.spanInstrumentationName"
|
|
5773
5775
|
);
|
|
5774
|
-
var SDK_VERSION = true ? "3.
|
|
5776
|
+
var SDK_VERSION = true ? "3.31.0" : "0.0.0";
|
|
5775
5777
|
function withSpanInstrumentationName(args, instrumentationName) {
|
|
5776
5778
|
return {
|
|
5777
5779
|
...args,
|
|
@@ -18176,6 +18178,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
18176
18178
|
if (!activeEntry) {
|
|
18177
18179
|
return result;
|
|
18178
18180
|
}
|
|
18181
|
+
const executionOptions = args[1];
|
|
18182
|
+
const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
|
|
18183
|
+
const toolInput = {
|
|
18184
|
+
input: serializeToolExecutionInput(args),
|
|
18185
|
+
...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
|
|
18186
|
+
};
|
|
18179
18187
|
if (isAsyncGenerator(result)) {
|
|
18180
18188
|
return (async function* () {
|
|
18181
18189
|
const span = activeEntry.parentSpan.startSpan(
|
|
@@ -18189,7 +18197,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
18189
18197
|
INSTRUMENTATION_NAMES.AI_SDK
|
|
18190
18198
|
)
|
|
18191
18199
|
);
|
|
18192
|
-
span.log(
|
|
18200
|
+
span.log(toolInput);
|
|
18193
18201
|
try {
|
|
18194
18202
|
let lastValue;
|
|
18195
18203
|
for await (const value of result) {
|
|
@@ -18207,7 +18215,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
18207
18215
|
}
|
|
18208
18216
|
return activeEntry.parentSpan.traced(
|
|
18209
18217
|
async (span) => {
|
|
18210
|
-
span.log(
|
|
18218
|
+
span.log(toolInput);
|
|
18211
18219
|
const awaitedResult = await result;
|
|
18212
18220
|
span.log({ output: awaitedResult });
|
|
18213
18221
|
return awaitedResult;
|
|
@@ -32329,14 +32337,17 @@ function getMetricsFromResponse(response) {
|
|
|
32329
32337
|
if (!isRecord(usageMetadata)) {
|
|
32330
32338
|
continue;
|
|
32331
32339
|
}
|
|
32332
|
-
const inputTokenDetails = usageMetadata.input_token_details;
|
|
32340
|
+
const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
|
|
32333
32341
|
const outputTokenDetails = usageMetadata.output_token_details;
|
|
32334
32342
|
return normalizeTokenMetrics({
|
|
32335
32343
|
total_tokens: usageMetadata.total_tokens,
|
|
32336
32344
|
prompt_tokens: usageMetadata.input_tokens,
|
|
32337
32345
|
completion_tokens: usageMetadata.output_tokens,
|
|
32338
|
-
|
|
32339
|
-
|
|
32346
|
+
// Prefer TTL-specific cache writes over the aggregate when available.
|
|
32347
|
+
prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
|
|
32348
|
+
prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
|
|
32349
|
+
prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
|
|
32350
|
+
prompt_cached_tokens: inputTokenDetails.cache_read,
|
|
32340
32351
|
completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
|
|
32341
32352
|
});
|
|
32342
32353
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
7
|
+
var _chunkV32LW47Zjs = require('./chunk-V32LW47Z.js');
|
|
8
|
+
require('./chunk-4AQGZS6X.js');
|
|
9
9
|
|
|
10
10
|
// src/wrappers/vitest-evals/reporter.ts
|
|
11
|
-
|
|
11
|
+
_chunkV32LW47Zjs.configureNode.call(void 0, );
|
|
12
12
|
var RESERVED_NORMALIZED_SPAN_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
|
|
13
13
|
"name",
|
|
14
14
|
"type",
|
|
@@ -43,7 +43,7 @@ var BraintrustVitestEvalsReporter = class {
|
|
|
43
43
|
for (const { test, meta } of evalTests) {
|
|
44
44
|
logEvalTest(experiment, test, meta);
|
|
45
45
|
}
|
|
46
|
-
await
|
|
46
|
+
await _chunkV32LW47Zjs.summarizeAndFlush.call(void 0, experiment, {
|
|
47
47
|
displaySummary: this.options.displaySummary
|
|
48
48
|
});
|
|
49
49
|
this.experiment = void 0;
|
|
@@ -59,7 +59,7 @@ var BraintrustVitestEvalsReporter = class {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
const experimentName = _nullishCoalesce(this.options.experimentName, () => ( `vitest-evals-${(/* @__PURE__ */ new Date()).toISOString()}`));
|
|
62
|
-
this.experiment =
|
|
62
|
+
this.experiment = _chunkV32LW47Zjs.initExperiment.call(void 0, {
|
|
63
63
|
...projectId ? { projectId } : { project: projectName },
|
|
64
64
|
experiment: experimentName,
|
|
65
65
|
metadata: this.options.metadata,
|
|
@@ -274,7 +274,7 @@ function logToolCallSpans(rootSpan, calls) {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
function readEvalTaskMeta(input) {
|
|
277
|
-
if (!
|
|
277
|
+
if (!_chunkV32LW47Zjs.isObject.call(void 0, input)) return void 0;
|
|
278
278
|
const evalMeta = readEvalMeta(input.eval);
|
|
279
279
|
const harnessMeta = readHarnessMeta(input.harness);
|
|
280
280
|
if (!evalMeta && !harnessMeta) return void 0;
|
|
@@ -284,7 +284,7 @@ function readEvalTaskMeta(input) {
|
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
286
|
function readEvalMeta(input) {
|
|
287
|
-
if (!
|
|
287
|
+
if (!_chunkV32LW47Zjs.isObject.call(void 0, input)) return void 0;
|
|
288
288
|
const avgScore = readFiniteOrNull(input.avgScore);
|
|
289
289
|
const scores = Array.isArray(input.scores) ? input.scores.map(readEvalScore).filter(isDefined) : void 0;
|
|
290
290
|
const toolCalls = Array.isArray(input.toolCalls) ? input.toolCalls.map(readToolCall).filter(isDefined) : void 0;
|
|
@@ -298,23 +298,23 @@ function readEvalMeta(input) {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
function readEvalScore(input) {
|
|
301
|
-
if (!
|
|
301
|
+
if (!_chunkV32LW47Zjs.isObject.call(void 0, input)) return void 0;
|
|
302
302
|
const score = readFiniteOrNull(input.score);
|
|
303
303
|
return {
|
|
304
304
|
...typeof input.name === "string" ? { name: input.name } : {},
|
|
305
305
|
...score !== void 0 ? { score } : {},
|
|
306
|
-
...
|
|
306
|
+
..._chunkV32LW47Zjs.isObject.call(void 0, input.metadata) ? { metadata: input.metadata } : {}
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
function readHarnessMeta(input) {
|
|
310
|
-
if (!
|
|
310
|
+
if (!_chunkV32LW47Zjs.isObject.call(void 0, input)) return void 0;
|
|
311
311
|
return {
|
|
312
312
|
...typeof input.name === "string" ? { name: input.name } : {},
|
|
313
|
-
...
|
|
313
|
+
..._chunkV32LW47Zjs.isObject.call(void 0, input.run) ? { run: input.run } : {}
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
function readToolCall(input) {
|
|
317
|
-
if (!
|
|
317
|
+
if (!_chunkV32LW47Zjs.isObject.call(void 0, input)) return void 0;
|
|
318
318
|
return input;
|
|
319
319
|
}
|
|
320
320
|
function filteredNormalizedSpanAttributes(attributes) {
|
|
@@ -374,10 +374,10 @@ function epochSeconds(value) {
|
|
|
374
374
|
}
|
|
375
375
|
function logReporterError(span, error) {
|
|
376
376
|
if (error instanceof Error) {
|
|
377
|
-
|
|
377
|
+
_chunkV32LW47Zjs.logError.call(void 0, span, error);
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
|
-
if (
|
|
380
|
+
if (_chunkV32LW47Zjs.isObject.call(void 0, error)) {
|
|
381
381
|
const message = typeof error.message === "string" ? error.message : void 0;
|
|
382
382
|
const stack = typeof error.stack === "string" ? error.stack : void 0;
|
|
383
383
|
if (message !== void 0 || stack !== void 0) {
|
|
@@ -389,10 +389,10 @@ ${stack}` : message
|
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
|
|
392
|
+
_chunkV32LW47Zjs.logError.call(void 0, span, error);
|
|
393
393
|
}
|
|
394
394
|
function formatErrorMessage(error) {
|
|
395
|
-
if (
|
|
395
|
+
if (_chunkV32LW47Zjs.isObject.call(void 0, error)) {
|
|
396
396
|
if (typeof error.message === "string") return error.message;
|
|
397
397
|
if (typeof error.stack === "string") return error.stack;
|
|
398
398
|
}
|
package/dist/workerd.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.
|
|
5888
|
+
var SDK_VERSION = true ? "3.31.0" : "0.0.0";
|
|
5887
5889
|
function withSpanInstrumentationName(args, instrumentationName) {
|
|
5888
5890
|
return {
|
|
5889
5891
|
...args,
|
|
@@ -20034,6 +20036,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
20034
20036
|
if (!activeEntry) {
|
|
20035
20037
|
return result;
|
|
20036
20038
|
}
|
|
20039
|
+
const executionOptions = args[1];
|
|
20040
|
+
const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
|
|
20041
|
+
const toolInput = {
|
|
20042
|
+
input: serializeToolExecutionInput(args),
|
|
20043
|
+
...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
|
|
20044
|
+
};
|
|
20037
20045
|
if (isAsyncGenerator(result)) {
|
|
20038
20046
|
return (async function* () {
|
|
20039
20047
|
const span = activeEntry.parentSpan.startSpan(
|
|
@@ -20047,7 +20055,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
20047
20055
|
INSTRUMENTATION_NAMES.AI_SDK
|
|
20048
20056
|
)
|
|
20049
20057
|
);
|
|
20050
|
-
span.log(
|
|
20058
|
+
span.log(toolInput);
|
|
20051
20059
|
try {
|
|
20052
20060
|
let lastValue;
|
|
20053
20061
|
for await (const value of result) {
|
|
@@ -20065,7 +20073,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
20065
20073
|
}
|
|
20066
20074
|
return activeEntry.parentSpan.traced(
|
|
20067
20075
|
async (span) => {
|
|
20068
|
-
span.log(
|
|
20076
|
+
span.log(toolInput);
|
|
20069
20077
|
const awaitedResult = await result;
|
|
20070
20078
|
span.log({ output: awaitedResult });
|
|
20071
20079
|
return awaitedResult;
|
|
@@ -34187,14 +34195,17 @@ function getMetricsFromResponse(response) {
|
|
|
34187
34195
|
if (!isRecord(usageMetadata)) {
|
|
34188
34196
|
continue;
|
|
34189
34197
|
}
|
|
34190
|
-
const inputTokenDetails = usageMetadata.input_token_details;
|
|
34198
|
+
const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
|
|
34191
34199
|
const outputTokenDetails = usageMetadata.output_token_details;
|
|
34192
34200
|
return normalizeTokenMetrics({
|
|
34193
34201
|
total_tokens: usageMetadata.total_tokens,
|
|
34194
34202
|
prompt_tokens: usageMetadata.input_tokens,
|
|
34195
34203
|
completion_tokens: usageMetadata.output_tokens,
|
|
34196
|
-
|
|
34197
|
-
|
|
34204
|
+
// Prefer TTL-specific cache writes over the aggregate when available.
|
|
34205
|
+
prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
|
|
34206
|
+
prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
|
|
34207
|
+
prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
|
|
34208
|
+
prompt_cached_tokens: inputTokenDetails.cache_read,
|
|
34198
34209
|
completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
|
|
34199
34210
|
});
|
|
34200
34211
|
}
|
|
@@ -45206,8 +45217,8 @@ function normalizeScores(result) {
|
|
|
45206
45217
|
(s) => s !== null && s !== void 0 && typeof s === "object" && isScore(s)
|
|
45207
45218
|
);
|
|
45208
45219
|
}
|
|
45209
|
-
if (typeof result === "object" && result !== null &&
|
|
45210
|
-
return [result];
|
|
45220
|
+
if (typeof result === "object" && result !== null && "score" in result) {
|
|
45221
|
+
return [{ ...result, name: result.name ?? "score" }];
|
|
45211
45222
|
}
|
|
45212
45223
|
return [];
|
|
45213
45224
|
}
|
|
@@ -47790,19 +47801,29 @@ function buildSpanScores(results) {
|
|
|
47790
47801
|
function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
47791
47802
|
if (scoreValue === null) return { results: null };
|
|
47792
47803
|
if (Array.isArray(scoreValue)) {
|
|
47804
|
+
const names = /* @__PURE__ */ new Set();
|
|
47793
47805
|
for (const score of scoreValue) {
|
|
47794
47806
|
if (!(typeof score === "object" && !isEmpty2(score))) {
|
|
47795
47807
|
throw new Error(
|
|
47796
47808
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
|
|
47797
47809
|
);
|
|
47798
47810
|
}
|
|
47811
|
+
if (typeof score.name !== "string") {
|
|
47812
|
+
throw new Error(
|
|
47813
|
+
`When returning an array of scores, each score must have a name. Got: ${JSON.stringify(score)}`
|
|
47814
|
+
);
|
|
47815
|
+
}
|
|
47816
|
+
if (names.has(score.name)) {
|
|
47817
|
+
throw new Error(`Duplicate score name '${score.name}' in score array`);
|
|
47818
|
+
}
|
|
47819
|
+
names.add(score.name);
|
|
47799
47820
|
}
|
|
47800
47821
|
}
|
|
47801
47822
|
let results;
|
|
47802
47823
|
if (Array.isArray(scoreValue)) {
|
|
47803
47824
|
results = scoreValue;
|
|
47804
47825
|
} else if (typeof scoreValue === "object" && !isEmpty2(scoreValue)) {
|
|
47805
|
-
results = [scoreValue];
|
|
47826
|
+
results = [{ ...scoreValue, name: scoreValue.name ?? name }];
|
|
47806
47827
|
} else {
|
|
47807
47828
|
results = [{ name, score: scoreValue }];
|
|
47808
47829
|
}
|
package/dist/workerd.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.
|
|
5677
|
+
var SDK_VERSION = true ? "3.31.0" : "0.0.0";
|
|
5676
5678
|
function withSpanInstrumentationName(args, instrumentationName) {
|
|
5677
5679
|
return {
|
|
5678
5680
|
...args,
|
|
@@ -19823,6 +19825,12 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
19823
19825
|
if (!activeEntry) {
|
|
19824
19826
|
return result;
|
|
19825
19827
|
}
|
|
19828
|
+
const executionOptions = args[1];
|
|
19829
|
+
const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
|
|
19830
|
+
const toolInput = {
|
|
19831
|
+
input: serializeToolExecutionInput(args),
|
|
19832
|
+
...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
|
|
19833
|
+
};
|
|
19826
19834
|
if (isAsyncGenerator(result)) {
|
|
19827
19835
|
return (async function* () {
|
|
19828
19836
|
const span = activeEntry.parentSpan.startSpan(
|
|
@@ -19836,7 +19844,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
19836
19844
|
INSTRUMENTATION_NAMES.AI_SDK
|
|
19837
19845
|
)
|
|
19838
19846
|
);
|
|
19839
|
-
span.log(
|
|
19847
|
+
span.log(toolInput);
|
|
19840
19848
|
try {
|
|
19841
19849
|
let lastValue;
|
|
19842
19850
|
for await (const value of result) {
|
|
@@ -19854,7 +19862,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
19854
19862
|
}
|
|
19855
19863
|
return activeEntry.parentSpan.traced(
|
|
19856
19864
|
async (span) => {
|
|
19857
|
-
span.log(
|
|
19865
|
+
span.log(toolInput);
|
|
19858
19866
|
const awaitedResult = await result;
|
|
19859
19867
|
span.log({ output: awaitedResult });
|
|
19860
19868
|
return awaitedResult;
|
|
@@ -33976,14 +33984,17 @@ function getMetricsFromResponse(response) {
|
|
|
33976
33984
|
if (!isRecord(usageMetadata)) {
|
|
33977
33985
|
continue;
|
|
33978
33986
|
}
|
|
33979
|
-
const inputTokenDetails = usageMetadata.input_token_details;
|
|
33987
|
+
const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
|
|
33980
33988
|
const outputTokenDetails = usageMetadata.output_token_details;
|
|
33981
33989
|
return normalizeTokenMetrics({
|
|
33982
33990
|
total_tokens: usageMetadata.total_tokens,
|
|
33983
33991
|
prompt_tokens: usageMetadata.input_tokens,
|
|
33984
33992
|
completion_tokens: usageMetadata.output_tokens,
|
|
33985
|
-
|
|
33986
|
-
|
|
33993
|
+
// Prefer TTL-specific cache writes over the aggregate when available.
|
|
33994
|
+
prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
|
|
33995
|
+
prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
|
|
33996
|
+
prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
|
|
33997
|
+
prompt_cached_tokens: inputTokenDetails.cache_read,
|
|
33987
33998
|
completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
|
|
33988
33999
|
});
|
|
33989
34000
|
}
|
|
@@ -44995,8 +45006,8 @@ function normalizeScores(result) {
|
|
|
44995
45006
|
(s) => s !== null && s !== void 0 && typeof s === "object" && isScore(s)
|
|
44996
45007
|
);
|
|
44997
45008
|
}
|
|
44998
|
-
if (typeof result === "object" && result !== null &&
|
|
44999
|
-
return [result];
|
|
45009
|
+
if (typeof result === "object" && result !== null && "score" in result) {
|
|
45010
|
+
return [{ ...result, name: result.name ?? "score" }];
|
|
45000
45011
|
}
|
|
45001
45012
|
return [];
|
|
45002
45013
|
}
|
|
@@ -47579,19 +47590,29 @@ function buildSpanScores(results) {
|
|
|
47579
47590
|
function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
47580
47591
|
if (scoreValue === null) return { results: null };
|
|
47581
47592
|
if (Array.isArray(scoreValue)) {
|
|
47593
|
+
const names = /* @__PURE__ */ new Set();
|
|
47582
47594
|
for (const score of scoreValue) {
|
|
47583
47595
|
if (!(typeof score === "object" && !isEmpty2(score))) {
|
|
47584
47596
|
throw new Error(
|
|
47585
47597
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
|
|
47586
47598
|
);
|
|
47587
47599
|
}
|
|
47600
|
+
if (typeof score.name !== "string") {
|
|
47601
|
+
throw new Error(
|
|
47602
|
+
`When returning an array of scores, each score must have a name. Got: ${JSON.stringify(score)}`
|
|
47603
|
+
);
|
|
47604
|
+
}
|
|
47605
|
+
if (names.has(score.name)) {
|
|
47606
|
+
throw new Error(`Duplicate score name '${score.name}' in score array`);
|
|
47607
|
+
}
|
|
47608
|
+
names.add(score.name);
|
|
47588
47609
|
}
|
|
47589
47610
|
}
|
|
47590
47611
|
let results;
|
|
47591
47612
|
if (Array.isArray(scoreValue)) {
|
|
47592
47613
|
results = scoreValue;
|
|
47593
47614
|
} else if (typeof scoreValue === "object" && !isEmpty2(scoreValue)) {
|
|
47594
|
-
results = [scoreValue];
|
|
47615
|
+
results = [{ ...scoreValue, name: scoreValue.name ?? name }];
|
|
47595
47616
|
} else {
|
|
47596
47617
|
results = [{ name, score: scoreValue }];
|
|
47597
47618
|
}
|