braintrust 1.1.1 → 2.0.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 +29 -6
- package/dev/dist/index.d.ts +29 -6
- package/dev/dist/index.js +66 -10
- package/dev/dist/index.mjs +66 -10
- package/dist/browser.d.mts +107 -18
- package/dist/browser.d.ts +107 -18
- package/dist/browser.js +201 -101
- package/dist/browser.mjs +138 -38
- package/dist/cli.js +74 -19
- package/dist/index.d.mts +107 -18
- package/dist/index.d.ts +107 -18
- package/dist/index.js +201 -101
- package/dist/index.mjs +138 -38
- package/package.json +8 -6
- package/util/dist/index.d.mts +10 -1
- package/util/dist/index.d.ts +10 -1
- package/util/dist/index.js +9 -1
- package/util/dist/index.mjs +8 -0
package/dist/index.mjs
CHANGED
|
@@ -1575,6 +1575,13 @@ var SpanComponentsV4 = class _SpanComponentsV4 {
|
|
|
1575
1575
|
return new _SpanComponentsV4(spanComponentsV4Schema.parse(jsonObj));
|
|
1576
1576
|
}
|
|
1577
1577
|
};
|
|
1578
|
+
function makeScorerPropagatedEvent(parent) {
|
|
1579
|
+
const parentPropagatedEvent = parent ? SpanComponentsV4.fromStr(parent).data.propagated_event ?? {} : {};
|
|
1580
|
+
return mergeDicts(
|
|
1581
|
+
{ ...parentPropagatedEvent },
|
|
1582
|
+
{ span_attributes: { purpose: "scorer" } }
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1578
1585
|
|
|
1579
1586
|
// util/git_fields.ts
|
|
1580
1587
|
function mergeGitMetadataSettings(s1, s2) {
|
|
@@ -2082,9 +2089,25 @@ var ExperimentEvent = z6.object({
|
|
|
2082
2089
|
comments: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2083
2090
|
audit_data: z6.union([z6.array(z6.unknown()), z6.null()]).optional()
|
|
2084
2091
|
});
|
|
2092
|
+
var NullableFunctionTypeEnum = z6.union([
|
|
2093
|
+
z6.enum([
|
|
2094
|
+
"llm",
|
|
2095
|
+
"scorer",
|
|
2096
|
+
"task",
|
|
2097
|
+
"tool",
|
|
2098
|
+
"custom_view",
|
|
2099
|
+
"preprocessor",
|
|
2100
|
+
"facet"
|
|
2101
|
+
]),
|
|
2102
|
+
z6.null()
|
|
2103
|
+
]);
|
|
2085
2104
|
var ExtendedSavedFunctionId = z6.union([
|
|
2086
2105
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
2087
|
-
z6.object({
|
|
2106
|
+
z6.object({
|
|
2107
|
+
type: z6.literal("global"),
|
|
2108
|
+
name: z6.string(),
|
|
2109
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2110
|
+
}),
|
|
2088
2111
|
z6.object({
|
|
2089
2112
|
type: z6.literal("slug"),
|
|
2090
2113
|
project_id: z6.string(),
|
|
@@ -2093,7 +2116,11 @@ var ExtendedSavedFunctionId = z6.union([
|
|
|
2093
2116
|
]);
|
|
2094
2117
|
var NullableSavedFunctionId = z6.union([
|
|
2095
2118
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
2096
|
-
z6.object({
|
|
2119
|
+
z6.object({
|
|
2120
|
+
type: z6.literal("global"),
|
|
2121
|
+
name: z6.string(),
|
|
2122
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2123
|
+
}),
|
|
2097
2124
|
z6.null()
|
|
2098
2125
|
]);
|
|
2099
2126
|
var FacetData = z6.object({
|
|
@@ -2190,7 +2217,11 @@ var PromptParserNullish = z6.union([
|
|
|
2190
2217
|
]);
|
|
2191
2218
|
var SavedFunctionId = z6.union([
|
|
2192
2219
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
2193
|
-
z6.object({
|
|
2220
|
+
z6.object({
|
|
2221
|
+
type: z6.literal("global"),
|
|
2222
|
+
name: z6.string(),
|
|
2223
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2224
|
+
})
|
|
2194
2225
|
]);
|
|
2195
2226
|
var PromptDataNullish = z6.union([
|
|
2196
2227
|
z6.object({
|
|
@@ -2337,6 +2368,7 @@ var FunctionData = z6.union([
|
|
|
2337
2368
|
z6.object({
|
|
2338
2369
|
type: z6.literal("global"),
|
|
2339
2370
|
name: z6.string(),
|
|
2371
|
+
function_type: NullableFunctionTypeEnum.optional(),
|
|
2340
2372
|
config: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
2341
2373
|
}),
|
|
2342
2374
|
FacetData
|
|
@@ -2423,7 +2455,10 @@ var FunctionId = z6.union([
|
|
|
2423
2455
|
slug: z6.string(),
|
|
2424
2456
|
version: z6.string().optional()
|
|
2425
2457
|
}),
|
|
2426
|
-
z6.object({
|
|
2458
|
+
z6.object({
|
|
2459
|
+
global_function: z6.string(),
|
|
2460
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2461
|
+
}),
|
|
2427
2462
|
z6.object({
|
|
2428
2463
|
prompt_session_id: z6.string(),
|
|
2429
2464
|
prompt_session_function_id: z6.string(),
|
|
@@ -2634,6 +2669,7 @@ var Project = z6.object({
|
|
|
2634
2669
|
id: z6.string().uuid(),
|
|
2635
2670
|
org_id: z6.string().uuid(),
|
|
2636
2671
|
name: z6.string(),
|
|
2672
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
2637
2673
|
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
2638
2674
|
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
2639
2675
|
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
@@ -8468,6 +8504,7 @@ async function invoke(args) {
|
|
|
8468
8504
|
project_name: functionIdArgs.projectName,
|
|
8469
8505
|
slug: functionIdArgs.slug,
|
|
8470
8506
|
global_function: functionIdArgs.globalFunction,
|
|
8507
|
+
function_type: functionIdArgs.functionType,
|
|
8471
8508
|
prompt_session_id: functionIdArgs.promptSessionId,
|
|
8472
8509
|
prompt_session_function_id: functionIdArgs.promptSessionFunctionId,
|
|
8473
8510
|
version: functionIdArgs.version
|
|
@@ -9482,8 +9519,22 @@ function processInputAttachments(input) {
|
|
|
9482
9519
|
return input;
|
|
9483
9520
|
}
|
|
9484
9521
|
|
|
9522
|
+
// src/zod/utils.ts
|
|
9523
|
+
import { zodToJsonSchema as zodToJsonSchemaV3 } from "zod-to-json-schema";
|
|
9524
|
+
import * as z42 from "zod/v4";
|
|
9525
|
+
function isZodV4(zodObject) {
|
|
9526
|
+
return typeof zodObject === "object" && zodObject !== null && "_zod" in zodObject && zodObject._zod !== void 0;
|
|
9527
|
+
}
|
|
9528
|
+
function zodToJsonSchema(schema) {
|
|
9529
|
+
if (isZodV4(schema)) {
|
|
9530
|
+
return z42.toJSONSchema(schema, {
|
|
9531
|
+
target: "draft-7"
|
|
9532
|
+
});
|
|
9533
|
+
}
|
|
9534
|
+
return zodToJsonSchemaV3(schema);
|
|
9535
|
+
}
|
|
9536
|
+
|
|
9485
9537
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
9486
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
9487
9538
|
var DENY_OUTPUT_PATHS = [
|
|
9488
9539
|
// v3
|
|
9489
9540
|
"roundtrips[].request.body",
|
|
@@ -9559,8 +9610,14 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
9559
9610
|
)({ ...instance.settings, ...params });
|
|
9560
9611
|
};
|
|
9561
9612
|
var makeGenerateTextWrapper = (name, options, generateText, aiSDK) => {
|
|
9562
|
-
const wrapper = async function(
|
|
9563
|
-
const {
|
|
9613
|
+
const wrapper = async function(allParams) {
|
|
9614
|
+
const { span_info, ...params } = allParams;
|
|
9615
|
+
const {
|
|
9616
|
+
metadata: spanInfoMetadata,
|
|
9617
|
+
name: spanName,
|
|
9618
|
+
spanAttributes: spanInfoAttrs
|
|
9619
|
+
} = span_info ?? {};
|
|
9620
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9564
9621
|
return traced(
|
|
9565
9622
|
async (span) => {
|
|
9566
9623
|
const result = await generateText({
|
|
@@ -9584,15 +9641,17 @@ var makeGenerateTextWrapper = (name, options, generateText, aiSDK) => {
|
|
|
9584
9641
|
return result;
|
|
9585
9642
|
},
|
|
9586
9643
|
{
|
|
9587
|
-
name,
|
|
9644
|
+
name: spanName || name,
|
|
9588
9645
|
spanAttributes: {
|
|
9589
|
-
type: "llm" /* LLM
|
|
9646
|
+
type: "llm" /* LLM */,
|
|
9647
|
+
...spanInfoAttrs
|
|
9590
9648
|
},
|
|
9591
9649
|
event: {
|
|
9592
9650
|
input: processInputAttachments2(params),
|
|
9593
9651
|
metadata: {
|
|
9594
|
-
|
|
9595
|
-
|
|
9652
|
+
...spanInfoMetadata,
|
|
9653
|
+
model,
|
|
9654
|
+
...provider ? { provider } : {},
|
|
9596
9655
|
braintrust: {
|
|
9597
9656
|
integration_name: "ai-sdk",
|
|
9598
9657
|
sdk_language: "typescript"
|
|
@@ -9625,8 +9684,7 @@ var wrapModel = (model, ai) => {
|
|
|
9625
9684
|
}
|
|
9626
9685
|
const originalDoGenerate = resolvedModel.doGenerate.bind(resolvedModel);
|
|
9627
9686
|
const originalDoStream = resolvedModel.doStream?.bind(resolvedModel);
|
|
9628
|
-
const { model:
|
|
9629
|
-
const effectiveProvider = resolvedModel.provider || initialProvider;
|
|
9687
|
+
const { model: modelId, provider } = serializeModelWithProvider(resolvedModel);
|
|
9630
9688
|
const wrappedDoGenerate = async (options) => {
|
|
9631
9689
|
return traced(
|
|
9632
9690
|
async (span) => {
|
|
@@ -9639,6 +9697,9 @@ var wrapModel = (model, ai) => {
|
|
|
9639
9697
|
if (gatewayInfo?.model) {
|
|
9640
9698
|
resolvedMetadata.model = gatewayInfo.model;
|
|
9641
9699
|
}
|
|
9700
|
+
if (result.finishReason !== void 0) {
|
|
9701
|
+
resolvedMetadata.finish_reason = result.finishReason;
|
|
9702
|
+
}
|
|
9642
9703
|
span.log({
|
|
9643
9704
|
output: await processOutput(result),
|
|
9644
9705
|
metrics: extractTokenMetrics(result),
|
|
@@ -9654,8 +9715,8 @@ var wrapModel = (model, ai) => {
|
|
|
9654
9715
|
event: {
|
|
9655
9716
|
input: processInputAttachments2(options),
|
|
9656
9717
|
metadata: {
|
|
9657
|
-
model:
|
|
9658
|
-
...
|
|
9718
|
+
model: modelId,
|
|
9719
|
+
...provider ? { provider } : {},
|
|
9659
9720
|
braintrust: {
|
|
9660
9721
|
integration_name: "ai-sdk",
|
|
9661
9722
|
sdk_language: "typescript"
|
|
@@ -9676,8 +9737,8 @@ var wrapModel = (model, ai) => {
|
|
|
9676
9737
|
event: {
|
|
9677
9738
|
input: processInputAttachments2(options),
|
|
9678
9739
|
metadata: {
|
|
9679
|
-
model:
|
|
9680
|
-
...
|
|
9740
|
+
model: modelId,
|
|
9741
|
+
...provider ? { provider } : {},
|
|
9681
9742
|
braintrust: {
|
|
9682
9743
|
integration_name: "ai-sdk",
|
|
9683
9744
|
sdk_language: "typescript"
|
|
@@ -9756,6 +9817,9 @@ var wrapModel = (model, ai) => {
|
|
|
9756
9817
|
if (gatewayInfo?.model) {
|
|
9757
9818
|
resolvedMetadata.model = gatewayInfo.model;
|
|
9758
9819
|
}
|
|
9820
|
+
if (chunk.finishReason !== void 0) {
|
|
9821
|
+
resolvedMetadata.finish_reason = chunk.finishReason;
|
|
9822
|
+
}
|
|
9759
9823
|
span.log({
|
|
9760
9824
|
output: await processOutput(output),
|
|
9761
9825
|
metrics: extractTokenMetrics(output),
|
|
@@ -9791,8 +9855,14 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
9791
9855
|
return makeGenerateTextWrapper("generateText", options, generateText, aiSDK);
|
|
9792
9856
|
};
|
|
9793
9857
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
9794
|
-
return async function generateObjectWrapper(
|
|
9795
|
-
const {
|
|
9858
|
+
return async function generateObjectWrapper(allParams) {
|
|
9859
|
+
const { span_info, ...params } = allParams;
|
|
9860
|
+
const {
|
|
9861
|
+
metadata: spanInfoMetadata,
|
|
9862
|
+
name: spanName,
|
|
9863
|
+
spanAttributes: spanInfoAttrs
|
|
9864
|
+
} = span_info ?? {};
|
|
9865
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9796
9866
|
return traced(
|
|
9797
9867
|
async (span) => {
|
|
9798
9868
|
const result = await generateObject({
|
|
@@ -9817,15 +9887,17 @@ var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
|
9817
9887
|
return result;
|
|
9818
9888
|
},
|
|
9819
9889
|
{
|
|
9820
|
-
name: "generateObject",
|
|
9890
|
+
name: spanName || "generateObject",
|
|
9821
9891
|
spanAttributes: {
|
|
9822
|
-
type: "llm" /* LLM
|
|
9892
|
+
type: "llm" /* LLM */,
|
|
9893
|
+
...spanInfoAttrs
|
|
9823
9894
|
},
|
|
9824
9895
|
event: {
|
|
9825
9896
|
input: processInputAttachments2(params),
|
|
9826
9897
|
metadata: {
|
|
9827
|
-
|
|
9828
|
-
|
|
9898
|
+
...spanInfoMetadata,
|
|
9899
|
+
model,
|
|
9900
|
+
...provider ? { provider } : {},
|
|
9829
9901
|
braintrust: {
|
|
9830
9902
|
integration_name: "ai-sdk",
|
|
9831
9903
|
sdk_language: "typescript"
|
|
@@ -9837,18 +9909,26 @@ var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
|
9837
9909
|
};
|
|
9838
9910
|
};
|
|
9839
9911
|
var makeStreamTextWrapper = (name, options, streamText, aiSDK) => {
|
|
9840
|
-
const wrapper = function(
|
|
9841
|
-
const {
|
|
9912
|
+
const wrapper = function(allParams) {
|
|
9913
|
+
const { span_info, ...params } = allParams;
|
|
9914
|
+
const {
|
|
9915
|
+
metadata: spanInfoMetadata,
|
|
9916
|
+
name: spanName,
|
|
9917
|
+
spanAttributes: spanInfoAttrs
|
|
9918
|
+
} = span_info ?? {};
|
|
9919
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9842
9920
|
const span = startSpan({
|
|
9843
|
-
name,
|
|
9921
|
+
name: spanName || name,
|
|
9844
9922
|
spanAttributes: {
|
|
9845
|
-
type: "llm" /* LLM
|
|
9923
|
+
type: "llm" /* LLM */,
|
|
9924
|
+
...spanInfoAttrs
|
|
9846
9925
|
},
|
|
9847
9926
|
event: {
|
|
9848
9927
|
input: processInputAttachments2(params),
|
|
9849
9928
|
metadata: {
|
|
9850
|
-
|
|
9851
|
-
|
|
9929
|
+
...spanInfoMetadata,
|
|
9930
|
+
model,
|
|
9931
|
+
...provider ? { provider } : {},
|
|
9852
9932
|
braintrust: {
|
|
9853
9933
|
integration_name: "ai-sdk",
|
|
9854
9934
|
sdk_language: "typescript"
|
|
@@ -9946,18 +10026,26 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
9946
10026
|
return makeStreamTextWrapper("streamText", options, streamText, aiSDK);
|
|
9947
10027
|
};
|
|
9948
10028
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
9949
|
-
return function streamObjectWrapper(
|
|
9950
|
-
const {
|
|
10029
|
+
return function streamObjectWrapper(allParams) {
|
|
10030
|
+
const { span_info, ...params } = allParams;
|
|
10031
|
+
const {
|
|
10032
|
+
metadata: spanInfoMetadata,
|
|
10033
|
+
name: spanName,
|
|
10034
|
+
spanAttributes: spanInfoAttrs
|
|
10035
|
+
} = span_info ?? {};
|
|
10036
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9951
10037
|
const span = startSpan({
|
|
9952
|
-
name: "streamObject",
|
|
10038
|
+
name: spanName || "streamObject",
|
|
9953
10039
|
spanAttributes: {
|
|
9954
|
-
type: "llm" /* LLM
|
|
10040
|
+
type: "llm" /* LLM */,
|
|
10041
|
+
...spanInfoAttrs
|
|
9955
10042
|
},
|
|
9956
10043
|
event: {
|
|
9957
10044
|
input: processInputAttachments2(params),
|
|
9958
10045
|
metadata: {
|
|
9959
|
-
|
|
9960
|
-
|
|
10046
|
+
...spanInfoMetadata,
|
|
10047
|
+
model,
|
|
10048
|
+
...provider ? { provider } : {},
|
|
9961
10049
|
braintrust: {
|
|
9962
10050
|
integration_name: "ai-sdk",
|
|
9963
10051
|
sdk_language: "typescript"
|
|
@@ -10185,10 +10273,15 @@ function parseGatewayModelString(modelString) {
|
|
|
10185
10273
|
}
|
|
10186
10274
|
function serializeModelWithProvider(model) {
|
|
10187
10275
|
const modelId = typeof model === "string" ? model : model?.modelId;
|
|
10276
|
+
const explicitProvider = typeof model === "object" ? model?.provider : void 0;
|
|
10188
10277
|
if (!modelId) {
|
|
10189
|
-
return { model: modelId };
|
|
10278
|
+
return { model: modelId, provider: explicitProvider };
|
|
10190
10279
|
}
|
|
10191
|
-
|
|
10280
|
+
const parsed = parseGatewayModelString(modelId);
|
|
10281
|
+
return {
|
|
10282
|
+
model: parsed.model,
|
|
10283
|
+
provider: explicitProvider || parsed.provider
|
|
10284
|
+
};
|
|
10192
10285
|
}
|
|
10193
10286
|
function extractGatewayRoutingInfo(result) {
|
|
10194
10287
|
if (result?.steps && Array.isArray(result.steps) && result.steps.length > 0) {
|
|
@@ -10266,6 +10359,9 @@ var processInputAttachments2 = (input) => {
|
|
|
10266
10359
|
if (input.tools) {
|
|
10267
10360
|
processed.tools = processTools(input.tools);
|
|
10268
10361
|
}
|
|
10362
|
+
if (input.schema && isZodSchema(input.schema)) {
|
|
10363
|
+
processed.schema = serializeZodSchema(input.schema);
|
|
10364
|
+
}
|
|
10269
10365
|
if (input.callOptionsSchema && isZodSchema(input.callOptionsSchema)) {
|
|
10270
10366
|
processed.callOptionsSchema = serializeZodSchema(input.callOptionsSchema);
|
|
10271
10367
|
}
|
|
@@ -14492,8 +14588,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
14492
14588
|
const results = await rootSpan.traced(runScorer, {
|
|
14493
14589
|
name: scorerNames[score_idx],
|
|
14494
14590
|
spanAttributes: {
|
|
14495
|
-
type: "score" /* SCORE
|
|
14591
|
+
type: "score" /* SCORE */,
|
|
14592
|
+
purpose: "scorer"
|
|
14496
14593
|
},
|
|
14594
|
+
propagatedEvent: makeScorerPropagatedEvent(
|
|
14595
|
+
await rootSpan.export()
|
|
14596
|
+
),
|
|
14497
14597
|
event: { input: scoringArgs }
|
|
14498
14598
|
});
|
|
14499
14599
|
return { kind: "score", value: results };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braintrust",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "SDK for integrating Braintrust",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"watch": "tsup --watch",
|
|
57
57
|
"clean": "rm -r dist/* && rm -r dev/dist/*",
|
|
58
58
|
"docs": "npx typedoc --options typedoc.json src/index.ts",
|
|
59
|
-
"test": "vitest run --exclude \"src/wrappers/**/*.test.ts\" --exclude \"src/otel/**/*.test.ts\" --exclude \"smoke/**/*.test.ts\"",
|
|
59
|
+
"test": "vitest run --exclude \"src/wrappers/**/*.test.ts\" --exclude \"src/otel/**/*.test.ts\" --exclude \"smoke/**/*.test.ts\" --exclude \"src/zod/**/*.test.ts\"",
|
|
60
60
|
"test:api-compat": "vitest run src/api-compatibility.test.ts",
|
|
61
61
|
"test:anthropic": "vitest run src/wrappers/anthropic.test.ts",
|
|
62
62
|
"test:openai": "vitest run src/wrappers/oai.test.ts",
|
|
@@ -66,6 +66,8 @@
|
|
|
66
66
|
"test:ai-sdk-v1": "vitest run src/wrappers/ai-sdk-v1.test.ts",
|
|
67
67
|
"test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts",
|
|
68
68
|
"test:ai-sdk-v3": "vitest run src/wrappers/ai-sdk-v3.test.ts",
|
|
69
|
+
"test:zod-v3": "vitest run src/zod/zod-v3-serialization.test.ts",
|
|
70
|
+
"test:zod-v4": "vitest run src/zod/zod-v4-serialization.test.ts",
|
|
69
71
|
"test:mastra": "vitest run src/wrappers/mastra.test.ts",
|
|
70
72
|
"test:claude-agent-sdk": "vitest run src/wrappers/claude-agent-sdk.test.ts",
|
|
71
73
|
"test:output": "tsx scripts/test-output.ts --with-comparison --with-metrics --with-progress"
|
|
@@ -109,7 +111,8 @@
|
|
|
109
111
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
110
112
|
"typescript": "5.4.4",
|
|
111
113
|
"vite-tsconfig-paths": "^4.3.2",
|
|
112
|
-
"vitest": "^2.1.9"
|
|
114
|
+
"vitest": "^2.1.9",
|
|
115
|
+
"zod": "^3.25.34"
|
|
113
116
|
},
|
|
114
117
|
"dependencies": {
|
|
115
118
|
"@ai-sdk/provider": "^1.1.3",
|
|
@@ -136,10 +139,9 @@
|
|
|
136
139
|
"source-map": "^0.7.4",
|
|
137
140
|
"termi-link": "^1.0.1",
|
|
138
141
|
"uuid": "^9.0.1",
|
|
139
|
-
"zod": "^3.25.
|
|
140
|
-
"zod-to-json-schema": "^3.22.5"
|
|
142
|
+
"zod-to-json-schema": "^3.25.0"
|
|
141
143
|
},
|
|
142
144
|
"peerDependencies": {
|
|
143
|
-
"zod": "^3.25.34"
|
|
145
|
+
"zod": "^3.25.34 || ^4.0"
|
|
144
146
|
}
|
|
145
147
|
}
|
package/util/dist/index.d.mts
CHANGED
|
@@ -5256,6 +5256,15 @@ declare class SpanComponentsV4 {
|
|
|
5256
5256
|
private static fromJsonObj;
|
|
5257
5257
|
}
|
|
5258
5258
|
declare function parseParent(parent: InvokeFunctionType["parent"]): string | undefined;
|
|
5259
|
+
/**
|
|
5260
|
+
* Creates a propagatedEvent for scorer spans by merging the purpose into
|
|
5261
|
+
* any existing propagatedEvent from the parent span.
|
|
5262
|
+
*
|
|
5263
|
+
* @param parent - The parent span export string, or undefined if no parent
|
|
5264
|
+
* @returns A propagatedEvent with span_attributes.purpose set to "scorer",
|
|
5265
|
+
* merged with any existing propagatedEvent from the parent
|
|
5266
|
+
*/
|
|
5267
|
+
declare function makeScorerPropagatedEvent(parent: string | undefined): Record<string, unknown>;
|
|
5259
5268
|
|
|
5260
5269
|
declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
|
|
5261
5270
|
declare enum SpanTypeAttribute {
|
|
@@ -5289,4 +5298,4 @@ declare function base64ToUint8Array(base64: string): Uint8Array;
|
|
|
5289
5298
|
declare function uint8ArrayToString(uint8Array: Uint8Array): string;
|
|
5290
5299
|
declare function stringToUint8Array(str: string): Uint8Array;
|
|
5291
5300
|
|
|
5292
|
-
export { ASYNC_SCORING_CONTROL_FIELD, AUDIT_METADATA_FIELD, AUDIT_SOURCE_FIELD, type AnyDatasetRecord, BT_CURSOR_HEADER, BT_FOUND_EXISTING_HEADER, BT_IMPERSONATE_USER, BT_PARENT, type BackgroundLogEvent, CREATED_FIELD, type CommentEvent, DEFAULT_IS_LEGACY_DATASET, type DatasetEvent, type DatasetRecord, type ExperimentEvent, type ExperimentLogFullArgs, type ExperimentLogPartialArgs, ExtraFieldsError, ID_FIELD, IS_MERGE_FIELD, type IdField, type InputField, type LogCommentFullArgs, type LogFeedbackFullArgs, type LoggingEvent, MERGE_PATHS_FIELD, OBJECT_DELETE_FIELD, type OtherExperimentLogFields, PARENT_ID_FIELD, type ParentExperimentIds, type ParentPlaygroundLogIds, type ParentProjectLogIds, type PlaygroundLogEvent, SKIP_ASYNC_SCORING_FIELD, type SanitizedExperimentLogPartialArgs, type Score, type Scorer, type ScorerArgs, type Source, SpanComponentsV1, SpanComponentsV2, SpanComponentsV3, type SpanComponentsV3Data, SpanComponentsV4, type SpanComponentsV4Data, SpanObjectTypeV1, SpanObjectTypeV2, SpanObjectTypeV3, type SpanPurpose, SpanRowIdsV1, SpanRowIdsV2, type SpanType, SpanTypeAttribute, TRANSACTION_ID_FIELD, type TransactionId, VALID_SOURCES, _urljoin, base64ToUint8Array, batchItems, camelToSnakeCase, capitalize, concatUint8Arrays, constructJsonArray, deterministicReplacer, ensureDatasetRecord, ensureLegacyDatasetRecord, ensureNewDatasetRecord, forEachMissingKey, getObjValueByPath, getRecordKeys, isArray, isEmpty, isNumber, isObject, isObjectOrArray, loadPrettyXact, lowercase, mapAt, mapSetDefault, mapSetNotPresent, mergeDicts, mergeDictsWithPaths, mergeGitMetadataSettings, mergeRowBatch, notEmpty, objectNullish, parseNoStrip, parseParent, prettifyXact, recordAt, recordFind, recordSetDefault, resolveParentHeader, snakeToCamelCase, snakeToTitleCase, spanComponentsV3Schema, spanComponentsV4Schema, spanObjectTypeV3EnumSchema, spanObjectTypeV3ToString, spanPurposeAttributeValues, spanTypeAttributeValues, stringToUint8Array, uint8ArrayToBase64, uint8ArrayToString };
|
|
5301
|
+
export { ASYNC_SCORING_CONTROL_FIELD, AUDIT_METADATA_FIELD, AUDIT_SOURCE_FIELD, type AnyDatasetRecord, BT_CURSOR_HEADER, BT_FOUND_EXISTING_HEADER, BT_IMPERSONATE_USER, BT_PARENT, type BackgroundLogEvent, CREATED_FIELD, type CommentEvent, DEFAULT_IS_LEGACY_DATASET, type DatasetEvent, type DatasetRecord, type ExperimentEvent, type ExperimentLogFullArgs, type ExperimentLogPartialArgs, ExtraFieldsError, ID_FIELD, IS_MERGE_FIELD, type IdField, type InputField, type LogCommentFullArgs, type LogFeedbackFullArgs, type LoggingEvent, MERGE_PATHS_FIELD, OBJECT_DELETE_FIELD, type OtherExperimentLogFields, PARENT_ID_FIELD, type ParentExperimentIds, type ParentPlaygroundLogIds, type ParentProjectLogIds, type PlaygroundLogEvent, SKIP_ASYNC_SCORING_FIELD, type SanitizedExperimentLogPartialArgs, type Score, type Scorer, type ScorerArgs, type Source, SpanComponentsV1, SpanComponentsV2, SpanComponentsV3, type SpanComponentsV3Data, SpanComponentsV4, type SpanComponentsV4Data, SpanObjectTypeV1, SpanObjectTypeV2, SpanObjectTypeV3, type SpanPurpose, SpanRowIdsV1, SpanRowIdsV2, type SpanType, SpanTypeAttribute, TRANSACTION_ID_FIELD, type TransactionId, VALID_SOURCES, _urljoin, base64ToUint8Array, batchItems, camelToSnakeCase, capitalize, concatUint8Arrays, constructJsonArray, deterministicReplacer, ensureDatasetRecord, ensureLegacyDatasetRecord, ensureNewDatasetRecord, forEachMissingKey, getObjValueByPath, getRecordKeys, isArray, isEmpty, isNumber, isObject, isObjectOrArray, loadPrettyXact, lowercase, makeScorerPropagatedEvent, mapAt, mapSetDefault, mapSetNotPresent, mergeDicts, mergeDictsWithPaths, mergeGitMetadataSettings, mergeRowBatch, notEmpty, objectNullish, parseNoStrip, parseParent, prettifyXact, recordAt, recordFind, recordSetDefault, resolveParentHeader, snakeToCamelCase, snakeToTitleCase, spanComponentsV3Schema, spanComponentsV4Schema, spanObjectTypeV3EnumSchema, spanObjectTypeV3ToString, spanPurposeAttributeValues, spanTypeAttributeValues, stringToUint8Array, uint8ArrayToBase64, uint8ArrayToString };
|
package/util/dist/index.d.ts
CHANGED
|
@@ -5256,6 +5256,15 @@ declare class SpanComponentsV4 {
|
|
|
5256
5256
|
private static fromJsonObj;
|
|
5257
5257
|
}
|
|
5258
5258
|
declare function parseParent(parent: InvokeFunctionType["parent"]): string | undefined;
|
|
5259
|
+
/**
|
|
5260
|
+
* Creates a propagatedEvent for scorer spans by merging the purpose into
|
|
5261
|
+
* any existing propagatedEvent from the parent span.
|
|
5262
|
+
*
|
|
5263
|
+
* @param parent - The parent span export string, or undefined if no parent
|
|
5264
|
+
* @returns A propagatedEvent with span_attributes.purpose set to "scorer",
|
|
5265
|
+
* merged with any existing propagatedEvent from the parent
|
|
5266
|
+
*/
|
|
5267
|
+
declare function makeScorerPropagatedEvent(parent: string | undefined): Record<string, unknown>;
|
|
5259
5268
|
|
|
5260
5269
|
declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
|
|
5261
5270
|
declare enum SpanTypeAttribute {
|
|
@@ -5289,4 +5298,4 @@ declare function base64ToUint8Array(base64: string): Uint8Array;
|
|
|
5289
5298
|
declare function uint8ArrayToString(uint8Array: Uint8Array): string;
|
|
5290
5299
|
declare function stringToUint8Array(str: string): Uint8Array;
|
|
5291
5300
|
|
|
5292
|
-
export { ASYNC_SCORING_CONTROL_FIELD, AUDIT_METADATA_FIELD, AUDIT_SOURCE_FIELD, type AnyDatasetRecord, BT_CURSOR_HEADER, BT_FOUND_EXISTING_HEADER, BT_IMPERSONATE_USER, BT_PARENT, type BackgroundLogEvent, CREATED_FIELD, type CommentEvent, DEFAULT_IS_LEGACY_DATASET, type DatasetEvent, type DatasetRecord, type ExperimentEvent, type ExperimentLogFullArgs, type ExperimentLogPartialArgs, ExtraFieldsError, ID_FIELD, IS_MERGE_FIELD, type IdField, type InputField, type LogCommentFullArgs, type LogFeedbackFullArgs, type LoggingEvent, MERGE_PATHS_FIELD, OBJECT_DELETE_FIELD, type OtherExperimentLogFields, PARENT_ID_FIELD, type ParentExperimentIds, type ParentPlaygroundLogIds, type ParentProjectLogIds, type PlaygroundLogEvent, SKIP_ASYNC_SCORING_FIELD, type SanitizedExperimentLogPartialArgs, type Score, type Scorer, type ScorerArgs, type Source, SpanComponentsV1, SpanComponentsV2, SpanComponentsV3, type SpanComponentsV3Data, SpanComponentsV4, type SpanComponentsV4Data, SpanObjectTypeV1, SpanObjectTypeV2, SpanObjectTypeV3, type SpanPurpose, SpanRowIdsV1, SpanRowIdsV2, type SpanType, SpanTypeAttribute, TRANSACTION_ID_FIELD, type TransactionId, VALID_SOURCES, _urljoin, base64ToUint8Array, batchItems, camelToSnakeCase, capitalize, concatUint8Arrays, constructJsonArray, deterministicReplacer, ensureDatasetRecord, ensureLegacyDatasetRecord, ensureNewDatasetRecord, forEachMissingKey, getObjValueByPath, getRecordKeys, isArray, isEmpty, isNumber, isObject, isObjectOrArray, loadPrettyXact, lowercase, mapAt, mapSetDefault, mapSetNotPresent, mergeDicts, mergeDictsWithPaths, mergeGitMetadataSettings, mergeRowBatch, notEmpty, objectNullish, parseNoStrip, parseParent, prettifyXact, recordAt, recordFind, recordSetDefault, resolveParentHeader, snakeToCamelCase, snakeToTitleCase, spanComponentsV3Schema, spanComponentsV4Schema, spanObjectTypeV3EnumSchema, spanObjectTypeV3ToString, spanPurposeAttributeValues, spanTypeAttributeValues, stringToUint8Array, uint8ArrayToBase64, uint8ArrayToString };
|
|
5301
|
+
export { ASYNC_SCORING_CONTROL_FIELD, AUDIT_METADATA_FIELD, AUDIT_SOURCE_FIELD, type AnyDatasetRecord, BT_CURSOR_HEADER, BT_FOUND_EXISTING_HEADER, BT_IMPERSONATE_USER, BT_PARENT, type BackgroundLogEvent, CREATED_FIELD, type CommentEvent, DEFAULT_IS_LEGACY_DATASET, type DatasetEvent, type DatasetRecord, type ExperimentEvent, type ExperimentLogFullArgs, type ExperimentLogPartialArgs, ExtraFieldsError, ID_FIELD, IS_MERGE_FIELD, type IdField, type InputField, type LogCommentFullArgs, type LogFeedbackFullArgs, type LoggingEvent, MERGE_PATHS_FIELD, OBJECT_DELETE_FIELD, type OtherExperimentLogFields, PARENT_ID_FIELD, type ParentExperimentIds, type ParentPlaygroundLogIds, type ParentProjectLogIds, type PlaygroundLogEvent, SKIP_ASYNC_SCORING_FIELD, type SanitizedExperimentLogPartialArgs, type Score, type Scorer, type ScorerArgs, type Source, SpanComponentsV1, SpanComponentsV2, SpanComponentsV3, type SpanComponentsV3Data, SpanComponentsV4, type SpanComponentsV4Data, SpanObjectTypeV1, SpanObjectTypeV2, SpanObjectTypeV3, type SpanPurpose, SpanRowIdsV1, SpanRowIdsV2, type SpanType, SpanTypeAttribute, TRANSACTION_ID_FIELD, type TransactionId, VALID_SOURCES, _urljoin, base64ToUint8Array, batchItems, camelToSnakeCase, capitalize, concatUint8Arrays, constructJsonArray, deterministicReplacer, ensureDatasetRecord, ensureLegacyDatasetRecord, ensureNewDatasetRecord, forEachMissingKey, getObjValueByPath, getRecordKeys, isArray, isEmpty, isNumber, isObject, isObjectOrArray, loadPrettyXact, lowercase, makeScorerPropagatedEvent, mapAt, mapSetDefault, mapSetNotPresent, mergeDicts, mergeDictsWithPaths, mergeGitMetadataSettings, mergeRowBatch, notEmpty, objectNullish, parseNoStrip, parseParent, prettifyXact, recordAt, recordFind, recordSetDefault, resolveParentHeader, snakeToCamelCase, snakeToTitleCase, spanComponentsV3Schema, spanComponentsV4Schema, spanObjectTypeV3EnumSchema, spanObjectTypeV3ToString, spanPurposeAttributeValues, spanTypeAttributeValues, stringToUint8Array, uint8ArrayToBase64, uint8ArrayToString };
|
package/util/dist/index.js
CHANGED
|
@@ -1308,6 +1308,13 @@ function parseParent(parent) {
|
|
|
1308
1308
|
propagated_event: parent.propagated_event
|
|
1309
1309
|
}).toStr() : void 0;
|
|
1310
1310
|
}
|
|
1311
|
+
function makeScorerPropagatedEvent(parent) {
|
|
1312
|
+
const parentPropagatedEvent = parent ? _nullishCoalesce(SpanComponentsV4.fromStr(parent).data.propagated_event, () => ( {})) : {};
|
|
1313
|
+
return mergeDicts(
|
|
1314
|
+
{ ...parentPropagatedEvent },
|
|
1315
|
+
{ span_attributes: { purpose: "scorer" } }
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1311
1318
|
|
|
1312
1319
|
// util/span_types.ts
|
|
1313
1320
|
var spanTypeAttributeValues = [
|
|
@@ -1475,4 +1482,5 @@ function objectNullish(object) {
|
|
|
1475
1482
|
|
|
1476
1483
|
|
|
1477
1484
|
|
|
1478
|
-
|
|
1485
|
+
|
|
1486
|
+
exports.ASYNC_SCORING_CONTROL_FIELD = ASYNC_SCORING_CONTROL_FIELD; exports.AUDIT_METADATA_FIELD = AUDIT_METADATA_FIELD; exports.AUDIT_SOURCE_FIELD = AUDIT_SOURCE_FIELD; exports.BT_CURSOR_HEADER = BT_CURSOR_HEADER; exports.BT_FOUND_EXISTING_HEADER = BT_FOUND_EXISTING_HEADER; exports.BT_IMPERSONATE_USER = BT_IMPERSONATE_USER; exports.BT_PARENT = BT_PARENT; exports.CREATED_FIELD = CREATED_FIELD; exports.DEFAULT_IS_LEGACY_DATASET = DEFAULT_IS_LEGACY_DATASET; exports.ExtraFieldsError = ExtraFieldsError; exports.ID_FIELD = ID_FIELD; exports.IS_MERGE_FIELD = IS_MERGE_FIELD; exports.MERGE_PATHS_FIELD = MERGE_PATHS_FIELD; exports.OBJECT_DELETE_FIELD = OBJECT_DELETE_FIELD; exports.PARENT_ID_FIELD = PARENT_ID_FIELD; exports.SKIP_ASYNC_SCORING_FIELD = SKIP_ASYNC_SCORING_FIELD; exports.SpanComponentsV1 = SpanComponentsV1; exports.SpanComponentsV2 = SpanComponentsV2; exports.SpanComponentsV3 = SpanComponentsV3; exports.SpanComponentsV4 = SpanComponentsV4; exports.SpanObjectTypeV1 = SpanObjectTypeV1; exports.SpanObjectTypeV2 = SpanObjectTypeV2; exports.SpanObjectTypeV3 = SpanObjectTypeV3; exports.SpanRowIdsV1 = SpanRowIdsV1; exports.SpanRowIdsV2 = SpanRowIdsV2; exports.SpanTypeAttribute = SpanTypeAttribute; exports.TRANSACTION_ID_FIELD = TRANSACTION_ID_FIELD; exports.VALID_SOURCES = VALID_SOURCES; exports._urljoin = _urljoin; exports.base64ToUint8Array = base64ToUint8Array; exports.batchItems = batchItems; exports.camelToSnakeCase = camelToSnakeCase; exports.capitalize = capitalize; exports.concatUint8Arrays = concatUint8Arrays; exports.constructJsonArray = constructJsonArray; exports.deterministicReplacer = deterministicReplacer; exports.ensureDatasetRecord = ensureDatasetRecord; exports.ensureLegacyDatasetRecord = ensureLegacyDatasetRecord; exports.ensureNewDatasetRecord = ensureNewDatasetRecord; exports.forEachMissingKey = forEachMissingKey; exports.getObjValueByPath = getObjValueByPath; exports.getRecordKeys = getRecordKeys; exports.isArray = isArray; exports.isEmpty = isEmpty; exports.isNumber = isNumber; exports.isObject = isObject; exports.isObjectOrArray = isObjectOrArray; exports.loadPrettyXact = loadPrettyXact; exports.lowercase = lowercase; exports.makeScorerPropagatedEvent = makeScorerPropagatedEvent; exports.mapAt = mapAt; exports.mapSetDefault = mapSetDefault; exports.mapSetNotPresent = mapSetNotPresent; exports.mergeDicts = mergeDicts; exports.mergeDictsWithPaths = mergeDictsWithPaths; exports.mergeGitMetadataSettings = mergeGitMetadataSettings; exports.mergeRowBatch = mergeRowBatch; exports.notEmpty = notEmpty; exports.objectNullish = objectNullish; exports.parseNoStrip = parseNoStrip; exports.parseParent = parseParent; exports.prettifyXact = prettifyXact; exports.recordAt = recordAt; exports.recordFind = recordFind; exports.recordSetDefault = recordSetDefault; exports.resolveParentHeader = resolveParentHeader; exports.snakeToCamelCase = snakeToCamelCase; exports.snakeToTitleCase = snakeToTitleCase; exports.spanComponentsV3Schema = spanComponentsV3Schema; exports.spanComponentsV4Schema = spanComponentsV4Schema; exports.spanObjectTypeV3EnumSchema = spanObjectTypeV3EnumSchema; exports.spanObjectTypeV3ToString = spanObjectTypeV3ToString; exports.spanPurposeAttributeValues = spanPurposeAttributeValues; exports.spanTypeAttributeValues = spanTypeAttributeValues; exports.stringToUint8Array = stringToUint8Array; exports.uint8ArrayToBase64 = uint8ArrayToBase64; exports.uint8ArrayToString = uint8ArrayToString;
|
package/util/dist/index.mjs
CHANGED
|
@@ -1308,6 +1308,13 @@ function parseParent(parent) {
|
|
|
1308
1308
|
propagated_event: parent.propagated_event
|
|
1309
1309
|
}).toStr() : void 0;
|
|
1310
1310
|
}
|
|
1311
|
+
function makeScorerPropagatedEvent(parent) {
|
|
1312
|
+
const parentPropagatedEvent = parent ? SpanComponentsV4.fromStr(parent).data.propagated_event ?? {} : {};
|
|
1313
|
+
return mergeDicts(
|
|
1314
|
+
{ ...parentPropagatedEvent },
|
|
1315
|
+
{ span_attributes: { purpose: "scorer" } }
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1311
1318
|
|
|
1312
1319
|
// util/span_types.ts
|
|
1313
1320
|
var spanTypeAttributeValues = [
|
|
@@ -1448,6 +1455,7 @@ export {
|
|
|
1448
1455
|
isObjectOrArray,
|
|
1449
1456
|
loadPrettyXact,
|
|
1450
1457
|
lowercase,
|
|
1458
|
+
makeScorerPropagatedEvent,
|
|
1451
1459
|
mapAt,
|
|
1452
1460
|
mapSetDefault,
|
|
1453
1461
|
mapSetNotPresent,
|