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/browser.mjs
CHANGED
|
@@ -1353,6 +1353,13 @@ var SpanComponentsV4 = class _SpanComponentsV4 {
|
|
|
1353
1353
|
return new _SpanComponentsV4(spanComponentsV4Schema.parse(jsonObj));
|
|
1354
1354
|
}
|
|
1355
1355
|
};
|
|
1356
|
+
function makeScorerPropagatedEvent(parent) {
|
|
1357
|
+
const parentPropagatedEvent = parent ? SpanComponentsV4.fromStr(parent).data.propagated_event ?? {} : {};
|
|
1358
|
+
return mergeDicts(
|
|
1359
|
+
{ ...parentPropagatedEvent },
|
|
1360
|
+
{ span_attributes: { purpose: "scorer" } }
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1356
1363
|
|
|
1357
1364
|
// util/git_fields.ts
|
|
1358
1365
|
function mergeGitMetadataSettings(s1, s2) {
|
|
@@ -1860,9 +1867,25 @@ var ExperimentEvent = z6.object({
|
|
|
1860
1867
|
comments: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
1861
1868
|
audit_data: z6.union([z6.array(z6.unknown()), z6.null()]).optional()
|
|
1862
1869
|
});
|
|
1870
|
+
var NullableFunctionTypeEnum = z6.union([
|
|
1871
|
+
z6.enum([
|
|
1872
|
+
"llm",
|
|
1873
|
+
"scorer",
|
|
1874
|
+
"task",
|
|
1875
|
+
"tool",
|
|
1876
|
+
"custom_view",
|
|
1877
|
+
"preprocessor",
|
|
1878
|
+
"facet"
|
|
1879
|
+
]),
|
|
1880
|
+
z6.null()
|
|
1881
|
+
]);
|
|
1863
1882
|
var ExtendedSavedFunctionId = z6.union([
|
|
1864
1883
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
1865
|
-
z6.object({
|
|
1884
|
+
z6.object({
|
|
1885
|
+
type: z6.literal("global"),
|
|
1886
|
+
name: z6.string(),
|
|
1887
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
1888
|
+
}),
|
|
1866
1889
|
z6.object({
|
|
1867
1890
|
type: z6.literal("slug"),
|
|
1868
1891
|
project_id: z6.string(),
|
|
@@ -1871,7 +1894,11 @@ var ExtendedSavedFunctionId = z6.union([
|
|
|
1871
1894
|
]);
|
|
1872
1895
|
var NullableSavedFunctionId = z6.union([
|
|
1873
1896
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
1874
|
-
z6.object({
|
|
1897
|
+
z6.object({
|
|
1898
|
+
type: z6.literal("global"),
|
|
1899
|
+
name: z6.string(),
|
|
1900
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
1901
|
+
}),
|
|
1875
1902
|
z6.null()
|
|
1876
1903
|
]);
|
|
1877
1904
|
var FacetData = z6.object({
|
|
@@ -1968,7 +1995,11 @@ var PromptParserNullish = z6.union([
|
|
|
1968
1995
|
]);
|
|
1969
1996
|
var SavedFunctionId = z6.union([
|
|
1970
1997
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
1971
|
-
z6.object({
|
|
1998
|
+
z6.object({
|
|
1999
|
+
type: z6.literal("global"),
|
|
2000
|
+
name: z6.string(),
|
|
2001
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2002
|
+
})
|
|
1972
2003
|
]);
|
|
1973
2004
|
var PromptDataNullish = z6.union([
|
|
1974
2005
|
z6.object({
|
|
@@ -2115,6 +2146,7 @@ var FunctionData = z6.union([
|
|
|
2115
2146
|
z6.object({
|
|
2116
2147
|
type: z6.literal("global"),
|
|
2117
2148
|
name: z6.string(),
|
|
2149
|
+
function_type: NullableFunctionTypeEnum.optional(),
|
|
2118
2150
|
config: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
2119
2151
|
}),
|
|
2120
2152
|
FacetData
|
|
@@ -2201,7 +2233,10 @@ var FunctionId = z6.union([
|
|
|
2201
2233
|
slug: z6.string(),
|
|
2202
2234
|
version: z6.string().optional()
|
|
2203
2235
|
}),
|
|
2204
|
-
z6.object({
|
|
2236
|
+
z6.object({
|
|
2237
|
+
global_function: z6.string(),
|
|
2238
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2239
|
+
}),
|
|
2205
2240
|
z6.object({
|
|
2206
2241
|
prompt_session_id: z6.string(),
|
|
2207
2242
|
prompt_session_function_id: z6.string(),
|
|
@@ -2412,6 +2447,7 @@ var Project = z6.object({
|
|
|
2412
2447
|
id: z6.string().uuid(),
|
|
2413
2448
|
org_id: z6.string().uuid(),
|
|
2414
2449
|
name: z6.string(),
|
|
2450
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
2415
2451
|
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
2416
2452
|
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
2417
2453
|
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
@@ -8247,6 +8283,7 @@ async function invoke(args) {
|
|
|
8247
8283
|
project_name: functionIdArgs.projectName,
|
|
8248
8284
|
slug: functionIdArgs.slug,
|
|
8249
8285
|
global_function: functionIdArgs.globalFunction,
|
|
8286
|
+
function_type: functionIdArgs.functionType,
|
|
8250
8287
|
prompt_session_id: functionIdArgs.promptSessionId,
|
|
8251
8288
|
prompt_session_function_id: functionIdArgs.promptSessionFunctionId,
|
|
8252
8289
|
version: functionIdArgs.version
|
|
@@ -9261,8 +9298,22 @@ function processInputAttachments(input) {
|
|
|
9261
9298
|
return input;
|
|
9262
9299
|
}
|
|
9263
9300
|
|
|
9301
|
+
// src/zod/utils.ts
|
|
9302
|
+
import { zodToJsonSchema as zodToJsonSchemaV3 } from "zod-to-json-schema";
|
|
9303
|
+
import * as z42 from "zod/v4";
|
|
9304
|
+
function isZodV4(zodObject) {
|
|
9305
|
+
return typeof zodObject === "object" && zodObject !== null && "_zod" in zodObject && zodObject._zod !== void 0;
|
|
9306
|
+
}
|
|
9307
|
+
function zodToJsonSchema(schema) {
|
|
9308
|
+
if (isZodV4(schema)) {
|
|
9309
|
+
return z42.toJSONSchema(schema, {
|
|
9310
|
+
target: "draft-7"
|
|
9311
|
+
});
|
|
9312
|
+
}
|
|
9313
|
+
return zodToJsonSchemaV3(schema);
|
|
9314
|
+
}
|
|
9315
|
+
|
|
9264
9316
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
9265
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
9266
9317
|
var DENY_OUTPUT_PATHS = [
|
|
9267
9318
|
// v3
|
|
9268
9319
|
"roundtrips[].request.body",
|
|
@@ -9338,8 +9389,14 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
9338
9389
|
)({ ...instance.settings, ...params });
|
|
9339
9390
|
};
|
|
9340
9391
|
var makeGenerateTextWrapper = (name, options, generateText, aiSDK) => {
|
|
9341
|
-
const wrapper = async function(
|
|
9342
|
-
const {
|
|
9392
|
+
const wrapper = async function(allParams) {
|
|
9393
|
+
const { span_info, ...params } = allParams;
|
|
9394
|
+
const {
|
|
9395
|
+
metadata: spanInfoMetadata,
|
|
9396
|
+
name: spanName,
|
|
9397
|
+
spanAttributes: spanInfoAttrs
|
|
9398
|
+
} = span_info ?? {};
|
|
9399
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9343
9400
|
return traced(
|
|
9344
9401
|
async (span) => {
|
|
9345
9402
|
const result = await generateText({
|
|
@@ -9363,15 +9420,17 @@ var makeGenerateTextWrapper = (name, options, generateText, aiSDK) => {
|
|
|
9363
9420
|
return result;
|
|
9364
9421
|
},
|
|
9365
9422
|
{
|
|
9366
|
-
name,
|
|
9423
|
+
name: spanName || name,
|
|
9367
9424
|
spanAttributes: {
|
|
9368
|
-
type: "llm" /* LLM
|
|
9425
|
+
type: "llm" /* LLM */,
|
|
9426
|
+
...spanInfoAttrs
|
|
9369
9427
|
},
|
|
9370
9428
|
event: {
|
|
9371
9429
|
input: processInputAttachments2(params),
|
|
9372
9430
|
metadata: {
|
|
9373
|
-
|
|
9374
|
-
|
|
9431
|
+
...spanInfoMetadata,
|
|
9432
|
+
model,
|
|
9433
|
+
...provider ? { provider } : {},
|
|
9375
9434
|
braintrust: {
|
|
9376
9435
|
integration_name: "ai-sdk",
|
|
9377
9436
|
sdk_language: "typescript"
|
|
@@ -9404,8 +9463,7 @@ var wrapModel = (model, ai) => {
|
|
|
9404
9463
|
}
|
|
9405
9464
|
const originalDoGenerate = resolvedModel.doGenerate.bind(resolvedModel);
|
|
9406
9465
|
const originalDoStream = resolvedModel.doStream?.bind(resolvedModel);
|
|
9407
|
-
const { model:
|
|
9408
|
-
const effectiveProvider = resolvedModel.provider || initialProvider;
|
|
9466
|
+
const { model: modelId, provider } = serializeModelWithProvider(resolvedModel);
|
|
9409
9467
|
const wrappedDoGenerate = async (options) => {
|
|
9410
9468
|
return traced(
|
|
9411
9469
|
async (span) => {
|
|
@@ -9418,6 +9476,9 @@ var wrapModel = (model, ai) => {
|
|
|
9418
9476
|
if (gatewayInfo?.model) {
|
|
9419
9477
|
resolvedMetadata.model = gatewayInfo.model;
|
|
9420
9478
|
}
|
|
9479
|
+
if (result.finishReason !== void 0) {
|
|
9480
|
+
resolvedMetadata.finish_reason = result.finishReason;
|
|
9481
|
+
}
|
|
9421
9482
|
span.log({
|
|
9422
9483
|
output: await processOutput(result),
|
|
9423
9484
|
metrics: extractTokenMetrics(result),
|
|
@@ -9433,8 +9494,8 @@ var wrapModel = (model, ai) => {
|
|
|
9433
9494
|
event: {
|
|
9434
9495
|
input: processInputAttachments2(options),
|
|
9435
9496
|
metadata: {
|
|
9436
|
-
model:
|
|
9437
|
-
...
|
|
9497
|
+
model: modelId,
|
|
9498
|
+
...provider ? { provider } : {},
|
|
9438
9499
|
braintrust: {
|
|
9439
9500
|
integration_name: "ai-sdk",
|
|
9440
9501
|
sdk_language: "typescript"
|
|
@@ -9455,8 +9516,8 @@ var wrapModel = (model, ai) => {
|
|
|
9455
9516
|
event: {
|
|
9456
9517
|
input: processInputAttachments2(options),
|
|
9457
9518
|
metadata: {
|
|
9458
|
-
model:
|
|
9459
|
-
...
|
|
9519
|
+
model: modelId,
|
|
9520
|
+
...provider ? { provider } : {},
|
|
9460
9521
|
braintrust: {
|
|
9461
9522
|
integration_name: "ai-sdk",
|
|
9462
9523
|
sdk_language: "typescript"
|
|
@@ -9535,6 +9596,9 @@ var wrapModel = (model, ai) => {
|
|
|
9535
9596
|
if (gatewayInfo?.model) {
|
|
9536
9597
|
resolvedMetadata.model = gatewayInfo.model;
|
|
9537
9598
|
}
|
|
9599
|
+
if (chunk.finishReason !== void 0) {
|
|
9600
|
+
resolvedMetadata.finish_reason = chunk.finishReason;
|
|
9601
|
+
}
|
|
9538
9602
|
span.log({
|
|
9539
9603
|
output: await processOutput(output),
|
|
9540
9604
|
metrics: extractTokenMetrics(output),
|
|
@@ -9570,8 +9634,14 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
9570
9634
|
return makeGenerateTextWrapper("generateText", options, generateText, aiSDK);
|
|
9571
9635
|
};
|
|
9572
9636
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
9573
|
-
return async function generateObjectWrapper(
|
|
9574
|
-
const {
|
|
9637
|
+
return async function generateObjectWrapper(allParams) {
|
|
9638
|
+
const { span_info, ...params } = allParams;
|
|
9639
|
+
const {
|
|
9640
|
+
metadata: spanInfoMetadata,
|
|
9641
|
+
name: spanName,
|
|
9642
|
+
spanAttributes: spanInfoAttrs
|
|
9643
|
+
} = span_info ?? {};
|
|
9644
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9575
9645
|
return traced(
|
|
9576
9646
|
async (span) => {
|
|
9577
9647
|
const result = await generateObject({
|
|
@@ -9596,15 +9666,17 @@ var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
|
9596
9666
|
return result;
|
|
9597
9667
|
},
|
|
9598
9668
|
{
|
|
9599
|
-
name: "generateObject",
|
|
9669
|
+
name: spanName || "generateObject",
|
|
9600
9670
|
spanAttributes: {
|
|
9601
|
-
type: "llm" /* LLM
|
|
9671
|
+
type: "llm" /* LLM */,
|
|
9672
|
+
...spanInfoAttrs
|
|
9602
9673
|
},
|
|
9603
9674
|
event: {
|
|
9604
9675
|
input: processInputAttachments2(params),
|
|
9605
9676
|
metadata: {
|
|
9606
|
-
|
|
9607
|
-
|
|
9677
|
+
...spanInfoMetadata,
|
|
9678
|
+
model,
|
|
9679
|
+
...provider ? { provider } : {},
|
|
9608
9680
|
braintrust: {
|
|
9609
9681
|
integration_name: "ai-sdk",
|
|
9610
9682
|
sdk_language: "typescript"
|
|
@@ -9616,18 +9688,26 @@ var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
|
9616
9688
|
};
|
|
9617
9689
|
};
|
|
9618
9690
|
var makeStreamTextWrapper = (name, options, streamText, aiSDK) => {
|
|
9619
|
-
const wrapper = function(
|
|
9620
|
-
const {
|
|
9691
|
+
const wrapper = function(allParams) {
|
|
9692
|
+
const { span_info, ...params } = allParams;
|
|
9693
|
+
const {
|
|
9694
|
+
metadata: spanInfoMetadata,
|
|
9695
|
+
name: spanName,
|
|
9696
|
+
spanAttributes: spanInfoAttrs
|
|
9697
|
+
} = span_info ?? {};
|
|
9698
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9621
9699
|
const span = startSpan({
|
|
9622
|
-
name,
|
|
9700
|
+
name: spanName || name,
|
|
9623
9701
|
spanAttributes: {
|
|
9624
|
-
type: "llm" /* LLM
|
|
9702
|
+
type: "llm" /* LLM */,
|
|
9703
|
+
...spanInfoAttrs
|
|
9625
9704
|
},
|
|
9626
9705
|
event: {
|
|
9627
9706
|
input: processInputAttachments2(params),
|
|
9628
9707
|
metadata: {
|
|
9629
|
-
|
|
9630
|
-
|
|
9708
|
+
...spanInfoMetadata,
|
|
9709
|
+
model,
|
|
9710
|
+
...provider ? { provider } : {},
|
|
9631
9711
|
braintrust: {
|
|
9632
9712
|
integration_name: "ai-sdk",
|
|
9633
9713
|
sdk_language: "typescript"
|
|
@@ -9725,18 +9805,26 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
9725
9805
|
return makeStreamTextWrapper("streamText", options, streamText, aiSDK);
|
|
9726
9806
|
};
|
|
9727
9807
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
9728
|
-
return function streamObjectWrapper(
|
|
9729
|
-
const {
|
|
9808
|
+
return function streamObjectWrapper(allParams) {
|
|
9809
|
+
const { span_info, ...params } = allParams;
|
|
9810
|
+
const {
|
|
9811
|
+
metadata: spanInfoMetadata,
|
|
9812
|
+
name: spanName,
|
|
9813
|
+
spanAttributes: spanInfoAttrs
|
|
9814
|
+
} = span_info ?? {};
|
|
9815
|
+
const { model, provider } = serializeModelWithProvider(params.model);
|
|
9730
9816
|
const span = startSpan({
|
|
9731
|
-
name: "streamObject",
|
|
9817
|
+
name: spanName || "streamObject",
|
|
9732
9818
|
spanAttributes: {
|
|
9733
|
-
type: "llm" /* LLM
|
|
9819
|
+
type: "llm" /* LLM */,
|
|
9820
|
+
...spanInfoAttrs
|
|
9734
9821
|
},
|
|
9735
9822
|
event: {
|
|
9736
9823
|
input: processInputAttachments2(params),
|
|
9737
9824
|
metadata: {
|
|
9738
|
-
|
|
9739
|
-
|
|
9825
|
+
...spanInfoMetadata,
|
|
9826
|
+
model,
|
|
9827
|
+
...provider ? { provider } : {},
|
|
9740
9828
|
braintrust: {
|
|
9741
9829
|
integration_name: "ai-sdk",
|
|
9742
9830
|
sdk_language: "typescript"
|
|
@@ -9964,10 +10052,15 @@ function parseGatewayModelString(modelString) {
|
|
|
9964
10052
|
}
|
|
9965
10053
|
function serializeModelWithProvider(model) {
|
|
9966
10054
|
const modelId = typeof model === "string" ? model : model?.modelId;
|
|
10055
|
+
const explicitProvider = typeof model === "object" ? model?.provider : void 0;
|
|
9967
10056
|
if (!modelId) {
|
|
9968
|
-
return { model: modelId };
|
|
10057
|
+
return { model: modelId, provider: explicitProvider };
|
|
9969
10058
|
}
|
|
9970
|
-
|
|
10059
|
+
const parsed = parseGatewayModelString(modelId);
|
|
10060
|
+
return {
|
|
10061
|
+
model: parsed.model,
|
|
10062
|
+
provider: explicitProvider || parsed.provider
|
|
10063
|
+
};
|
|
9971
10064
|
}
|
|
9972
10065
|
function extractGatewayRoutingInfo(result) {
|
|
9973
10066
|
if (result?.steps && Array.isArray(result.steps) && result.steps.length > 0) {
|
|
@@ -10045,6 +10138,9 @@ var processInputAttachments2 = (input) => {
|
|
|
10045
10138
|
if (input.tools) {
|
|
10046
10139
|
processed.tools = processTools(input.tools);
|
|
10047
10140
|
}
|
|
10141
|
+
if (input.schema && isZodSchema(input.schema)) {
|
|
10142
|
+
processed.schema = serializeZodSchema(input.schema);
|
|
10143
|
+
}
|
|
10048
10144
|
if (input.callOptionsSchema && isZodSchema(input.callOptionsSchema)) {
|
|
10049
10145
|
processed.callOptionsSchema = serializeZodSchema(input.callOptionsSchema);
|
|
10050
10146
|
}
|
|
@@ -14271,8 +14367,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
14271
14367
|
const results = await rootSpan.traced(runScorer, {
|
|
14272
14368
|
name: scorerNames[score_idx],
|
|
14273
14369
|
spanAttributes: {
|
|
14274
|
-
type: "score" /* SCORE
|
|
14370
|
+
type: "score" /* SCORE */,
|
|
14371
|
+
purpose: "scorer"
|
|
14275
14372
|
},
|
|
14373
|
+
propagatedEvent: makeScorerPropagatedEvent(
|
|
14374
|
+
await rootSpan.export()
|
|
14375
|
+
),
|
|
14276
14376
|
event: { input: scoringArgs }
|
|
14277
14377
|
});
|
|
14278
14378
|
return { kind: "score", value: results };
|
package/dist/cli.js
CHANGED
|
@@ -1275,7 +1275,7 @@ var require_package = __commonJS({
|
|
|
1275
1275
|
"package.json"(exports2, module2) {
|
|
1276
1276
|
module2.exports = {
|
|
1277
1277
|
name: "braintrust",
|
|
1278
|
-
version: "
|
|
1278
|
+
version: "2.0.0",
|
|
1279
1279
|
description: "SDK for integrating Braintrust",
|
|
1280
1280
|
repository: {
|
|
1281
1281
|
type: "git",
|
|
@@ -1331,7 +1331,7 @@ var require_package = __commonJS({
|
|
|
1331
1331
|
watch: "tsup --watch",
|
|
1332
1332
|
clean: "rm -r dist/* && rm -r dev/dist/*",
|
|
1333
1333
|
docs: "npx typedoc --options typedoc.json src/index.ts",
|
|
1334
|
-
test: 'vitest run --exclude "src/wrappers/**/*.test.ts" --exclude "src/otel/**/*.test.ts" --exclude "smoke/**/*.test.ts"',
|
|
1334
|
+
test: 'vitest run --exclude "src/wrappers/**/*.test.ts" --exclude "src/otel/**/*.test.ts" --exclude "smoke/**/*.test.ts" --exclude "src/zod/**/*.test.ts"',
|
|
1335
1335
|
"test:api-compat": "vitest run src/api-compatibility.test.ts",
|
|
1336
1336
|
"test:anthropic": "vitest run src/wrappers/anthropic.test.ts",
|
|
1337
1337
|
"test:openai": "vitest run src/wrappers/oai.test.ts",
|
|
@@ -1341,6 +1341,8 @@ var require_package = __commonJS({
|
|
|
1341
1341
|
"test:ai-sdk-v1": "vitest run src/wrappers/ai-sdk-v1.test.ts",
|
|
1342
1342
|
"test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts",
|
|
1343
1343
|
"test:ai-sdk-v3": "vitest run src/wrappers/ai-sdk-v3.test.ts",
|
|
1344
|
+
"test:zod-v3": "vitest run src/zod/zod-v3-serialization.test.ts",
|
|
1345
|
+
"test:zod-v4": "vitest run src/zod/zod-v4-serialization.test.ts",
|
|
1344
1346
|
"test:mastra": "vitest run src/wrappers/mastra.test.ts",
|
|
1345
1347
|
"test:claude-agent-sdk": "vitest run src/wrappers/claude-agent-sdk.test.ts",
|
|
1346
1348
|
"test:output": "tsx scripts/test-output.ts --with-comparison --with-metrics --with-progress"
|
|
@@ -1384,7 +1386,8 @@ var require_package = __commonJS({
|
|
|
1384
1386
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
1385
1387
|
typescript: "5.4.4",
|
|
1386
1388
|
"vite-tsconfig-paths": "^4.3.2",
|
|
1387
|
-
vitest: "^2.1.9"
|
|
1389
|
+
vitest: "^2.1.9",
|
|
1390
|
+
zod: "^3.25.34"
|
|
1388
1391
|
},
|
|
1389
1392
|
dependencies: {
|
|
1390
1393
|
"@ai-sdk/provider": "^1.1.3",
|
|
@@ -1411,11 +1414,10 @@ var require_package = __commonJS({
|
|
|
1411
1414
|
"source-map": "^0.7.4",
|
|
1412
1415
|
"termi-link": "^1.0.1",
|
|
1413
1416
|
uuid: "^9.0.1",
|
|
1414
|
-
zod: "^3.25.
|
|
1415
|
-
"zod-to-json-schema": "^3.22.5"
|
|
1417
|
+
"zod-to-json-schema": "^3.25.0"
|
|
1416
1418
|
},
|
|
1417
1419
|
peerDependencies: {
|
|
1418
|
-
zod: "^3.25.34"
|
|
1420
|
+
zod: "^3.25.34 || ^4.0"
|
|
1419
1421
|
}
|
|
1420
1422
|
};
|
|
1421
1423
|
}
|
|
@@ -2791,6 +2793,13 @@ function parseParent(parent) {
|
|
|
2791
2793
|
propagated_event: parent.propagated_event
|
|
2792
2794
|
}).toStr() : void 0;
|
|
2793
2795
|
}
|
|
2796
|
+
function makeScorerPropagatedEvent(parent) {
|
|
2797
|
+
const parentPropagatedEvent = parent ? SpanComponentsV4.fromStr(parent).data.propagated_event ?? {} : {};
|
|
2798
|
+
return mergeDicts(
|
|
2799
|
+
{ ...parentPropagatedEvent },
|
|
2800
|
+
{ span_attributes: { purpose: "scorer" } }
|
|
2801
|
+
);
|
|
2802
|
+
}
|
|
2794
2803
|
|
|
2795
2804
|
// util/git_fields.ts
|
|
2796
2805
|
function mergeGitMetadataSettings(s1, s2) {
|
|
@@ -3298,9 +3307,25 @@ var ExperimentEvent = import_v36.z.object({
|
|
|
3298
3307
|
comments: import_v36.z.union([import_v36.z.array(import_v36.z.unknown()), import_v36.z.null()]).optional(),
|
|
3299
3308
|
audit_data: import_v36.z.union([import_v36.z.array(import_v36.z.unknown()), import_v36.z.null()]).optional()
|
|
3300
3309
|
});
|
|
3310
|
+
var NullableFunctionTypeEnum = import_v36.z.union([
|
|
3311
|
+
import_v36.z.enum([
|
|
3312
|
+
"llm",
|
|
3313
|
+
"scorer",
|
|
3314
|
+
"task",
|
|
3315
|
+
"tool",
|
|
3316
|
+
"custom_view",
|
|
3317
|
+
"preprocessor",
|
|
3318
|
+
"facet"
|
|
3319
|
+
]),
|
|
3320
|
+
import_v36.z.null()
|
|
3321
|
+
]);
|
|
3301
3322
|
var ExtendedSavedFunctionId = import_v36.z.union([
|
|
3302
3323
|
import_v36.z.object({ type: import_v36.z.literal("function"), id: import_v36.z.string() }),
|
|
3303
|
-
import_v36.z.object({
|
|
3324
|
+
import_v36.z.object({
|
|
3325
|
+
type: import_v36.z.literal("global"),
|
|
3326
|
+
name: import_v36.z.string(),
|
|
3327
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
3328
|
+
}),
|
|
3304
3329
|
import_v36.z.object({
|
|
3305
3330
|
type: import_v36.z.literal("slug"),
|
|
3306
3331
|
project_id: import_v36.z.string(),
|
|
@@ -3309,7 +3334,11 @@ var ExtendedSavedFunctionId = import_v36.z.union([
|
|
|
3309
3334
|
]);
|
|
3310
3335
|
var NullableSavedFunctionId = import_v36.z.union([
|
|
3311
3336
|
import_v36.z.object({ type: import_v36.z.literal("function"), id: import_v36.z.string() }),
|
|
3312
|
-
import_v36.z.object({
|
|
3337
|
+
import_v36.z.object({
|
|
3338
|
+
type: import_v36.z.literal("global"),
|
|
3339
|
+
name: import_v36.z.string(),
|
|
3340
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
3341
|
+
}),
|
|
3313
3342
|
import_v36.z.null()
|
|
3314
3343
|
]);
|
|
3315
3344
|
var FacetData = import_v36.z.object({
|
|
@@ -3406,7 +3435,11 @@ var PromptParserNullish = import_v36.z.union([
|
|
|
3406
3435
|
]);
|
|
3407
3436
|
var SavedFunctionId = import_v36.z.union([
|
|
3408
3437
|
import_v36.z.object({ type: import_v36.z.literal("function"), id: import_v36.z.string() }),
|
|
3409
|
-
import_v36.z.object({
|
|
3438
|
+
import_v36.z.object({
|
|
3439
|
+
type: import_v36.z.literal("global"),
|
|
3440
|
+
name: import_v36.z.string(),
|
|
3441
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
3442
|
+
})
|
|
3410
3443
|
]);
|
|
3411
3444
|
var PromptDataNullish = import_v36.z.union([
|
|
3412
3445
|
import_v36.z.object({
|
|
@@ -3553,6 +3586,7 @@ var FunctionData = import_v36.z.union([
|
|
|
3553
3586
|
import_v36.z.object({
|
|
3554
3587
|
type: import_v36.z.literal("global"),
|
|
3555
3588
|
name: import_v36.z.string(),
|
|
3589
|
+
function_type: NullableFunctionTypeEnum.optional(),
|
|
3556
3590
|
config: import_v36.z.union([import_v36.z.object({}).partial().passthrough(), import_v36.z.null()]).optional()
|
|
3557
3591
|
}),
|
|
3558
3592
|
FacetData
|
|
@@ -3639,7 +3673,10 @@ var FunctionId = import_v36.z.union([
|
|
|
3639
3673
|
slug: import_v36.z.string(),
|
|
3640
3674
|
version: import_v36.z.string().optional()
|
|
3641
3675
|
}),
|
|
3642
|
-
import_v36.z.object({
|
|
3676
|
+
import_v36.z.object({
|
|
3677
|
+
global_function: import_v36.z.string(),
|
|
3678
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
3679
|
+
}),
|
|
3643
3680
|
import_v36.z.object({
|
|
3644
3681
|
prompt_session_id: import_v36.z.string(),
|
|
3645
3682
|
prompt_session_function_id: import_v36.z.string(),
|
|
@@ -3850,6 +3887,7 @@ var Project = import_v36.z.object({
|
|
|
3850
3887
|
id: import_v36.z.string().uuid(),
|
|
3851
3888
|
org_id: import_v36.z.string().uuid(),
|
|
3852
3889
|
name: import_v36.z.string(),
|
|
3890
|
+
description: import_v36.z.union([import_v36.z.string(), import_v36.z.null()]).optional(),
|
|
3853
3891
|
created: import_v36.z.union([import_v36.z.string(), import_v36.z.null()]).optional(),
|
|
3854
3892
|
deleted_at: import_v36.z.union([import_v36.z.string(), import_v36.z.null()]).optional(),
|
|
3855
3893
|
user_id: import_v36.z.union([import_v36.z.string(), import_v36.z.null()]).optional(),
|
|
@@ -10727,8 +10765,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
10727
10765
|
const results = await rootSpan.traced(runScorer, {
|
|
10728
10766
|
name: scorerNames[score_idx],
|
|
10729
10767
|
spanAttributes: {
|
|
10730
|
-
type: "score" /* SCORE
|
|
10768
|
+
type: "score" /* SCORE */,
|
|
10769
|
+
purpose: "scorer"
|
|
10731
10770
|
},
|
|
10771
|
+
propagatedEvent: makeScorerPropagatedEvent(
|
|
10772
|
+
await rootSpan.export()
|
|
10773
|
+
),
|
|
10732
10774
|
event: { input: scoringArgs }
|
|
10733
10775
|
});
|
|
10734
10776
|
return { kind: "score", value: results };
|
|
@@ -11728,8 +11770,22 @@ async function getTsModule() {
|
|
|
11728
11770
|
return tsModule;
|
|
11729
11771
|
}
|
|
11730
11772
|
|
|
11731
|
-
// src/
|
|
11773
|
+
// src/zod/utils.ts
|
|
11732
11774
|
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
11775
|
+
var z42 = __toESM(require("zod/v4"));
|
|
11776
|
+
function isZodV4(zodObject) {
|
|
11777
|
+
return typeof zodObject === "object" && zodObject !== null && "_zod" in zodObject && zodObject._zod !== void 0;
|
|
11778
|
+
}
|
|
11779
|
+
function zodToJsonSchema(schema) {
|
|
11780
|
+
if (isZodV4(schema)) {
|
|
11781
|
+
return z42.toJSONSchema(schema, {
|
|
11782
|
+
target: "draft-7"
|
|
11783
|
+
});
|
|
11784
|
+
}
|
|
11785
|
+
return (0, import_zod_to_json_schema.zodToJsonSchema)(schema);
|
|
11786
|
+
}
|
|
11787
|
+
|
|
11788
|
+
// src/cli/functions/upload.ts
|
|
11733
11789
|
var import_pluralize2 = __toESM(require("pluralize"));
|
|
11734
11790
|
var pathInfoSchema = import_v311.z.strictObject({
|
|
11735
11791
|
url: import_v311.z.string(),
|
|
@@ -11770,8 +11826,8 @@ async function uploadHandleBundles({
|
|
|
11770
11826
|
index: i
|
|
11771
11827
|
},
|
|
11772
11828
|
function_schema: fn.parameters || fn.returns ? {
|
|
11773
|
-
parameters: fn.parameters ?
|
|
11774
|
-
returns: fn.returns ?
|
|
11829
|
+
parameters: fn.parameters ? zodToJsonSchema(fn.parameters) : void 0,
|
|
11830
|
+
returns: fn.returns ? zodToJsonSchema(fn.returns) : void 0
|
|
11775
11831
|
} : void 0,
|
|
11776
11832
|
if_exists: fn.ifExists,
|
|
11777
11833
|
metadata: fn.metadata
|
|
@@ -12591,7 +12647,6 @@ var evaluatorDefinitionsSchema = import_v314.z.record(
|
|
|
12591
12647
|
|
|
12592
12648
|
// dev/server.ts
|
|
12593
12649
|
var import_v315 = require("zod/v3");
|
|
12594
|
-
var import_zod_to_json_schema2 = __toESM(require("zod-to-json-schema"));
|
|
12595
12650
|
function runDevServer(evaluators, opts) {
|
|
12596
12651
|
const allEvaluators = Object.fromEntries(
|
|
12597
12652
|
evaluators.map((evaluator) => [evaluator.evalName, evaluator])
|
|
@@ -12881,14 +12936,14 @@ function makeEvalParametersSchema(parameters) {
|
|
|
12881
12936
|
}
|
|
12882
12937
|
];
|
|
12883
12938
|
} else {
|
|
12884
|
-
const
|
|
12939
|
+
const schemaObj = zodToJsonSchema(value);
|
|
12885
12940
|
return [
|
|
12886
12941
|
name,
|
|
12887
12942
|
{
|
|
12888
12943
|
type: "data",
|
|
12889
|
-
schema,
|
|
12890
|
-
default:
|
|
12891
|
-
description:
|
|
12944
|
+
schema: schemaObj,
|
|
12945
|
+
default: schemaObj.default,
|
|
12946
|
+
description: schemaObj.description
|
|
12892
12947
|
}
|
|
12893
12948
|
];
|
|
12894
12949
|
}
|