braintrust 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -481,15 +481,15 @@ function mergeTwoObjects(one, two, level = 0, objects) {
481
481
  for (let i = 0, j = two.length; i < j; i++) {
482
482
  result.push(takeValue(two[i]));
483
483
  }
484
- } else if (isObject3(two)) {
484
+ } else if (isObject2(two)) {
485
485
  const keys = Object.keys(two);
486
486
  for (let i = 0, j = keys.length; i < j; i++) {
487
487
  const key = keys[i];
488
488
  result[key] = takeValue(two[key]);
489
489
  }
490
490
  }
491
- } else if (isObject3(one)) {
492
- if (isObject3(two)) {
491
+ } else if (isObject2(one)) {
492
+ if (isObject2(two)) {
493
493
  if (!shouldMerge(one, two)) {
494
494
  return two;
495
495
  }
@@ -510,7 +510,7 @@ function mergeTwoObjects(one, two, level = 0, objects) {
510
510
  if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
511
511
  delete result[key];
512
512
  } else {
513
- if (isObject3(obj1) && isObject3(obj2)) {
513
+ if (isObject2(obj1) && isObject2(obj2)) {
514
514
  const arr1 = objects.get(obj1) || [];
515
515
  const arr2 = objects.get(obj2) || [];
516
516
  arr1.push({ obj: one, key });
@@ -544,7 +544,7 @@ function isArray2(value) {
544
544
  function isFunction(value) {
545
545
  return typeof value === "function";
546
546
  }
547
- function isObject3(value) {
547
+ function isObject2(value) {
548
548
  return !isPrimitive(value) && !isArray2(value) && !isFunction(value) && typeof value === "object";
549
549
  }
550
550
  function isPrimitive(value) {
@@ -3498,33 +3498,999 @@ var Queue = class {
3498
3498
  }
3499
3499
  };
3500
3500
 
3501
- // src/logger.ts
3502
- import {
3503
- _urljoin,
3504
- AUDIT_METADATA_FIELD,
3505
- AUDIT_SOURCE_FIELD,
3506
- batchItems,
3507
- constructJsonArray,
3508
- DEFAULT_IS_LEGACY_DATASET,
3509
- ensureDatasetRecord,
3510
- IS_MERGE_FIELD,
3511
- mergeDicts,
3512
- mergeGitMetadataSettings,
3513
- mergeRowBatch,
3514
- SpanComponentsV3,
3515
- SpanObjectTypeV3,
3516
- spanObjectTypeV3ToString,
3517
- SpanTypeAttribute,
3518
- TRANSACTION_ID_FIELD,
3519
- VALID_SOURCES,
3520
- isArray,
3521
- isObject
3522
- } from "@braintrust/core";
3501
+ // util/db_fields.ts
3502
+ var TRANSACTION_ID_FIELD = "_xact_id";
3503
+ var IS_MERGE_FIELD = "_is_merge";
3504
+ var AUDIT_SOURCE_FIELD = "_audit_source";
3505
+ var AUDIT_METADATA_FIELD = "_audit_metadata";
3506
+ var VALID_SOURCES = ["app", "api", "external"];
3507
+ var PARENT_ID_FIELD = "_parent_id";
3508
+
3509
+ // util/span_identifier_v3.ts
3510
+ import * as uuid3 from "uuid";
3511
+
3512
+ // util/span_identifier_v2.ts
3513
+ import * as uuid2 from "uuid";
3514
+
3515
+ // util/span_identifier_v1.ts
3516
+ import * as uuid from "uuid";
3517
+ import { z } from "zod/v3";
3518
+ function tryMakeUuid(s) {
3519
+ try {
3520
+ const ret = uuid.parse(s);
3521
+ if (ret.length !== 16) {
3522
+ throw new Error();
3523
+ }
3524
+ return { bytes: Buffer.from(ret), isUUID: true };
3525
+ } catch (e) {
3526
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
3527
+ }
3528
+ }
3529
+ var ENCODING_VERSION_NUMBER = 1;
3530
+ var INVALID_ENCODING_ERRMSG = "SpanComponents string is not properly encoded. This may be due to a version mismatch between the SDK library used to export the span and the library used to decode it. Please make sure you are using the same SDK version across the board";
3531
+ var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
3532
+ SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
3533
+ SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
3534
+ return SpanObjectTypeV12;
3535
+ })(SpanObjectTypeV1 || {});
3536
+ var SpanObjectTypeV1EnumSchema = z.nativeEnum(SpanObjectTypeV1);
3537
+ var SpanRowIdsV1 = class {
3538
+ rowId;
3539
+ spanId;
3540
+ rootSpanId;
3541
+ constructor(args) {
3542
+ this.rowId = args.rowId;
3543
+ this.spanId = args.spanId;
3544
+ this.rootSpanId = args.rootSpanId;
3545
+ if (!this.rowId) {
3546
+ throw new Error("rowId must be nonempty string");
3547
+ }
3548
+ if (!this.spanId) {
3549
+ throw new Error("spanId must be nonempty string");
3550
+ }
3551
+ if (!this.rootSpanId) {
3552
+ throw new Error("rootSpanId must be nonempty string");
3553
+ }
3554
+ }
3555
+ toObject() {
3556
+ return {
3557
+ rowId: this.rowId,
3558
+ spanId: this.spanId,
3559
+ rootSpanId: this.rootSpanId
3560
+ };
3561
+ }
3562
+ };
3563
+ var SpanComponentsV1 = class _SpanComponentsV1 {
3564
+ objectType;
3565
+ objectId;
3566
+ rowIds;
3567
+ constructor(args) {
3568
+ this.objectType = args.objectType;
3569
+ this.objectId = args.objectId;
3570
+ this.rowIds = args.rowIds;
3571
+ }
3572
+ toStr() {
3573
+ const allBuffers = [];
3574
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
3575
+ allBuffers.push(
3576
+ Buffer.from([
3577
+ ENCODING_VERSION_NUMBER,
3578
+ this.objectType,
3579
+ this.rowIds ? 1 : 0,
3580
+ rowIdIsUUID ? 1 : 0
3581
+ ])
3582
+ );
3583
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
3584
+ this.objectId
3585
+ );
3586
+ if (!objectIdIsUUID) {
3587
+ throw new Error("object_id component must be a valid UUID");
3588
+ }
3589
+ allBuffers.push(objectIdBytes);
3590
+ if (this.rowIds) {
3591
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
3592
+ this.rowIds.spanId
3593
+ );
3594
+ if (!spanIdIsUUID) {
3595
+ throw new Error("span_id component must be a valid UUID");
3596
+ }
3597
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
3598
+ this.rowIds.rootSpanId
3599
+ );
3600
+ if (!rootSpanIdIsUUID) {
3601
+ throw new Error("root_span_id component must be a valid UUID");
3602
+ }
3603
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
3604
+ }
3605
+ return Buffer.concat(allBuffers).toString("base64");
3606
+ }
3607
+ static fromStr(s) {
3608
+ try {
3609
+ const rawBytes = Buffer.from(s, "base64");
3610
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
3611
+ throw new Error();
3612
+ }
3613
+ const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
3614
+ if (![0, 1].includes(rawBytes[2])) {
3615
+ throw new Error();
3616
+ }
3617
+ if (![0, 1].includes(rawBytes[3])) {
3618
+ throw new Error();
3619
+ }
3620
+ const hasRowId = rawBytes[2] == 1;
3621
+ const rowIdIsUUID = rawBytes[3] == 1;
3622
+ const objectId = uuid.stringify(rawBytes.subarray(4, 20));
3623
+ const rowIds = (() => {
3624
+ if (!hasRowId) {
3625
+ return void 0;
3626
+ }
3627
+ const spanId = uuid.stringify(rawBytes.subarray(20, 36));
3628
+ const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
3629
+ const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
3630
+ return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
3631
+ })();
3632
+ return new _SpanComponentsV1({ objectType, objectId, rowIds });
3633
+ } catch (e) {
3634
+ throw new Error(INVALID_ENCODING_ERRMSG);
3635
+ }
3636
+ }
3637
+ objectIdFields() {
3638
+ switch (this.objectType) {
3639
+ case 1 /* EXPERIMENT */:
3640
+ return { experiment_id: this.objectId };
3641
+ case 2 /* PROJECT_LOGS */:
3642
+ return { project_id: this.objectId, log_id: "g" };
3643
+ default:
3644
+ throw new Error("Impossible");
3645
+ }
3646
+ }
3647
+ toObject() {
3648
+ return {
3649
+ objectType: this.objectType,
3650
+ objectId: this.objectId,
3651
+ rowIds: this.rowIds?.toObject()
3652
+ };
3653
+ }
3654
+ };
3655
+
3656
+ // util/span_identifier_v2.ts
3657
+ import { z as z2 } from "zod/v3";
3658
+ function tryMakeUuid2(s) {
3659
+ try {
3660
+ const ret = uuid2.parse(s);
3661
+ if (ret.length !== 16) {
3662
+ throw new Error();
3663
+ }
3664
+ return { bytes: Buffer.from(ret), isUUID: true };
3665
+ } catch (e) {
3666
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
3667
+ }
3668
+ }
3669
+ var ENCODING_VERSION_NUMBER2 = 2;
3670
+ var INVALID_ENCODING_ERRMSG2 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER2}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
3671
+ var INTEGER_ENCODING_NUM_BYTES = 4;
3672
+ var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
3673
+ SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
3674
+ SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
3675
+ return SpanObjectTypeV22;
3676
+ })(SpanObjectTypeV2 || {});
3677
+ var SpanObjectTypeV2EnumSchema = z2.nativeEnum(SpanObjectTypeV2);
3678
+ var SpanRowIdsV2 = class {
3679
+ rowId;
3680
+ spanId;
3681
+ rootSpanId;
3682
+ constructor(args) {
3683
+ this.rowId = args.rowId;
3684
+ this.spanId = args.spanId;
3685
+ this.rootSpanId = args.rootSpanId;
3686
+ if (!this.rowId) {
3687
+ throw new Error("rowId must be nonempty string");
3688
+ }
3689
+ if (!this.spanId) {
3690
+ throw new Error("spanId must be nonempty string");
3691
+ }
3692
+ if (!this.rootSpanId) {
3693
+ throw new Error("rootSpanId must be nonempty string");
3694
+ }
3695
+ }
3696
+ toObject() {
3697
+ return {
3698
+ rowId: this.rowId,
3699
+ spanId: this.spanId,
3700
+ rootSpanId: this.rootSpanId
3701
+ };
3702
+ }
3703
+ };
3704
+ var SpanComponentsV2 = class _SpanComponentsV2 {
3705
+ objectType;
3706
+ objectId;
3707
+ computeObjectMetadataArgs;
3708
+ rowIds;
3709
+ constructor(args) {
3710
+ this.objectType = args.objectType;
3711
+ this.objectId = args.objectId;
3712
+ this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
3713
+ this.rowIds = args.rowIds;
3714
+ if (!(this.objectId || this.computeObjectMetadataArgs)) {
3715
+ throw new Error(
3716
+ "Must provide either objectId or computeObjectMetadataArgs"
3717
+ );
3718
+ }
3719
+ }
3720
+ toStr() {
3721
+ const allBuffers = [];
3722
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
3723
+ allBuffers.push(
3724
+ Buffer.from([
3725
+ ENCODING_VERSION_NUMBER2,
3726
+ this.objectType,
3727
+ this.objectId ? 1 : 0,
3728
+ this.computeObjectMetadataArgs ? 1 : 0,
3729
+ this.rowIds ? 1 : 0,
3730
+ rowIdIsUUID ? 1 : 0
3731
+ ])
3732
+ );
3733
+ if (this.objectId) {
3734
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
3735
+ this.objectId
3736
+ );
3737
+ if (!objectIdIsUUID) {
3738
+ throw new Error("object_id component must be a valid UUID");
3739
+ }
3740
+ allBuffers.push(objectIdBytes);
3741
+ }
3742
+ if (this.computeObjectMetadataArgs) {
3743
+ const computeObjectMetadataBytes = Buffer.from(
3744
+ JSON.stringify(this.computeObjectMetadataArgs),
3745
+ "utf-8"
3746
+ );
3747
+ const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
3748
+ serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
3749
+ allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
3750
+ }
3751
+ if (this.rowIds) {
3752
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
3753
+ this.rowIds.spanId
3754
+ );
3755
+ if (!spanIdIsUUID) {
3756
+ throw new Error("span_id component must be a valid UUID");
3757
+ }
3758
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
3759
+ this.rowIds.rootSpanId
3760
+ );
3761
+ if (!rootSpanIdIsUUID) {
3762
+ throw new Error("root_span_id component must be a valid UUID");
3763
+ }
3764
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
3765
+ }
3766
+ return Buffer.concat(allBuffers).toString("base64");
3767
+ }
3768
+ static fromStr(s) {
3769
+ try {
3770
+ const rawBytes = Buffer.from(s, "base64");
3771
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
3772
+ const spanComponentsOld = SpanComponentsV1.fromStr(s);
3773
+ return new _SpanComponentsV2({
3774
+ objectType: SpanObjectTypeV2EnumSchema.parse(
3775
+ spanComponentsOld.objectType
3776
+ ),
3777
+ objectId: spanComponentsOld.objectId,
3778
+ rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
3779
+ rowId: spanComponentsOld.rowIds.rowId,
3780
+ spanId: spanComponentsOld.rowIds.spanId,
3781
+ rootSpanId: spanComponentsOld.rowIds.rootSpanId
3782
+ }) : void 0
3783
+ });
3784
+ }
3785
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
3786
+ throw new Error();
3787
+ }
3788
+ const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
3789
+ for (let i = 2; i < 6; ++i) {
3790
+ if (![0, 1].includes(rawBytes[i])) {
3791
+ throw new Error();
3792
+ }
3793
+ }
3794
+ const hasObjectId = rawBytes[2] == 1;
3795
+ const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
3796
+ const hasRowId = rawBytes[4] == 1;
3797
+ const rowIdIsUUID = rawBytes[5] == 1;
3798
+ let byteCursor = 6;
3799
+ let objectId = void 0;
3800
+ if (hasObjectId) {
3801
+ const nextByteCursor = byteCursor + 16;
3802
+ objectId = uuid2.stringify(
3803
+ rawBytes.subarray(byteCursor, nextByteCursor)
3804
+ );
3805
+ byteCursor = nextByteCursor;
3806
+ }
3807
+ let computeObjectMetadataArgs;
3808
+ if (hasComputeObjectMetadataArgs) {
3809
+ let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
3810
+ const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
3811
+ byteCursor = nextByteCursor;
3812
+ nextByteCursor = byteCursor + serializedLenBytes;
3813
+ computeObjectMetadataArgs = JSON.parse(
3814
+ rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
3815
+ );
3816
+ byteCursor = nextByteCursor;
3817
+ }
3818
+ const rowIds = (() => {
3819
+ if (!hasRowId) {
3820
+ return void 0;
3821
+ }
3822
+ let nextByteCursor = byteCursor + 16;
3823
+ const spanId = uuid2.stringify(
3824
+ rawBytes.subarray(byteCursor, nextByteCursor)
3825
+ );
3826
+ byteCursor = nextByteCursor;
3827
+ nextByteCursor = byteCursor + 16;
3828
+ const rootSpanId = uuid2.stringify(
3829
+ rawBytes.subarray(byteCursor, nextByteCursor)
3830
+ );
3831
+ byteCursor = nextByteCursor;
3832
+ const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
3833
+ return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
3834
+ })();
3835
+ return new _SpanComponentsV2({
3836
+ objectType,
3837
+ objectId,
3838
+ computeObjectMetadataArgs,
3839
+ rowIds
3840
+ });
3841
+ } catch (e) {
3842
+ throw new Error(INVALID_ENCODING_ERRMSG2);
3843
+ }
3844
+ }
3845
+ objectIdFields() {
3846
+ if (!this.objectId) {
3847
+ throw new Error(
3848
+ "Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
3849
+ );
3850
+ }
3851
+ switch (this.objectType) {
3852
+ case 1 /* EXPERIMENT */:
3853
+ return { experiment_id: this.objectId };
3854
+ case 2 /* PROJECT_LOGS */:
3855
+ return { project_id: this.objectId, log_id: "g" };
3856
+ default:
3857
+ throw new Error("Impossible");
3858
+ }
3859
+ }
3860
+ toObject() {
3861
+ return {
3862
+ objectType: this.objectType,
3863
+ objectId: this.objectId,
3864
+ computeObjectMetadataArgs: this.computeObjectMetadataArgs,
3865
+ rowIds: this.rowIds?.toObject()
3866
+ };
3867
+ }
3868
+ };
3869
+
3870
+ // util/span_identifier_v3.ts
3871
+ import { z as z3 } from "zod/v3";
3872
+
3873
+ // util/bytes.ts
3874
+ function concatUint8Arrays(...arrays) {
3875
+ const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
3876
+ const result = new Uint8Array(totalLength);
3877
+ let offset = 0;
3878
+ for (const arr of arrays) {
3879
+ result.set(arr, offset);
3880
+ offset += arr.length;
3881
+ }
3882
+ return result;
3883
+ }
3884
+ function uint8ArrayToBase64(uint8Array) {
3885
+ let binary = "";
3886
+ for (let i = 0; i < uint8Array.length; i++) {
3887
+ binary += String.fromCharCode(uint8Array[i]);
3888
+ }
3889
+ return btoa(binary);
3890
+ }
3891
+ function base64ToUint8Array(base64) {
3892
+ const binary = atob(base64);
3893
+ const uint8Array = new Uint8Array(binary.length);
3894
+ for (let i = 0; i < binary.length; i++) {
3895
+ uint8Array[i] = binary.charCodeAt(i);
3896
+ }
3897
+ return uint8Array;
3898
+ }
3899
+ function uint8ArrayToString(uint8Array) {
3900
+ const decoder = new TextDecoder("utf-8");
3901
+ return decoder.decode(uint8Array);
3902
+ }
3903
+ function stringToUint8Array(str) {
3904
+ const encoder = new TextEncoder();
3905
+ return encoder.encode(str);
3906
+ }
3907
+
3908
+ // util/span_identifier_v3.ts
3909
+ function tryMakeUuid3(s) {
3910
+ try {
3911
+ const ret = uuid3.parse(s);
3912
+ if (ret.length !== 16) {
3913
+ throw new Error();
3914
+ }
3915
+ return { bytes: new Uint8Array(ret), isUUID: true };
3916
+ } catch {
3917
+ return { bytes: void 0, isUUID: false };
3918
+ }
3919
+ }
3920
+ var ENCODING_VERSION_NUMBER3 = 3;
3921
+ var INVALID_ENCODING_ERRMSG3 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER3}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
3922
+ var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
3923
+ SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
3924
+ SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
3925
+ SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
3926
+ return SpanObjectTypeV32;
3927
+ })(SpanObjectTypeV3 || {});
3928
+ var spanObjectTypeV3EnumSchema = z3.nativeEnum(SpanObjectTypeV3);
3929
+ function spanObjectTypeV3ToString(objectType) {
3930
+ switch (objectType) {
3931
+ case 1 /* EXPERIMENT */:
3932
+ return "experiment";
3933
+ case 2 /* PROJECT_LOGS */:
3934
+ return "project_logs";
3935
+ case 3 /* PLAYGROUND_LOGS */:
3936
+ return "playground_logs";
3937
+ default:
3938
+ const x = objectType;
3939
+ throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
3940
+ }
3941
+ }
3942
+ var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
3943
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
3944
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
3945
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
3946
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
3947
+ return InternalSpanComponentUUIDFields2;
3948
+ })(InternalSpanComponentUUIDFields || {});
3949
+ var internalSpanComponentUUIDFieldsEnumSchema = z3.nativeEnum(
3950
+ InternalSpanComponentUUIDFields
3951
+ );
3952
+ var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
3953
+ [1 /* OBJECT_ID */]: "object_id",
3954
+ [2 /* ROW_ID */]: "row_id",
3955
+ [3 /* SPAN_ID */]: "span_id",
3956
+ [4 /* ROOT_SPAN_ID */]: "root_span_id"
3957
+ };
3958
+ var spanComponentsV3Schema = z3.object({
3959
+ object_type: spanObjectTypeV3EnumSchema,
3960
+ // TODO(manu): We should have a more elaborate zod schema for
3961
+ // `propagated_event`. This will required zod-ifying the contents of
3962
+ // sdk/js/util/object.ts.
3963
+ propagated_event: z3.record(z3.unknown()).nullish()
3964
+ }).and(
3965
+ z3.union([
3966
+ // Must provide one or the other.
3967
+ z3.object({
3968
+ object_id: z3.string().nullish(),
3969
+ compute_object_metadata_args: z3.optional(z3.null())
3970
+ }),
3971
+ z3.object({
3972
+ object_id: z3.optional(z3.null()),
3973
+ compute_object_metadata_args: z3.record(z3.unknown())
3974
+ })
3975
+ ])
3976
+ ).and(
3977
+ z3.union([
3978
+ // Either all of these must be provided or none.
3979
+ z3.object({
3980
+ row_id: z3.string(),
3981
+ span_id: z3.string(),
3982
+ root_span_id: z3.string()
3983
+ }),
3984
+ z3.object({
3985
+ row_id: z3.optional(z3.null()),
3986
+ span_id: z3.optional(z3.null()),
3987
+ root_span_id: z3.optional(z3.null())
3988
+ })
3989
+ ])
3990
+ );
3991
+ var SpanComponentsV3 = class _SpanComponentsV3 {
3992
+ constructor(data) {
3993
+ this.data = data;
3994
+ }
3995
+ toStr() {
3996
+ const jsonObj = {
3997
+ compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
3998
+ propagated_event: this.data.propagated_event || void 0
3999
+ };
4000
+ const allBuffers = [];
4001
+ allBuffers.push(
4002
+ new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
4003
+ );
4004
+ const uuidEntries = [];
4005
+ function addUuidField(origVal, fieldId) {
4006
+ const ret = tryMakeUuid3(origVal);
4007
+ if (ret.isUUID) {
4008
+ uuidEntries.push(
4009
+ concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
4010
+ );
4011
+ } else {
4012
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
4013
+ }
4014
+ }
4015
+ if (this.data.object_id) {
4016
+ addUuidField(
4017
+ this.data.object_id,
4018
+ 1 /* OBJECT_ID */
4019
+ );
4020
+ }
4021
+ if (this.data.row_id) {
4022
+ addUuidField(this.data.row_id, 2 /* ROW_ID */);
4023
+ }
4024
+ if (this.data.span_id) {
4025
+ addUuidField(this.data.span_id, 3 /* SPAN_ID */);
4026
+ }
4027
+ if (this.data.root_span_id) {
4028
+ addUuidField(
4029
+ this.data.root_span_id,
4030
+ 4 /* ROOT_SPAN_ID */
4031
+ );
4032
+ }
4033
+ if (uuidEntries.length > 255) {
4034
+ throw new Error("Impossible: too many UUID entries to encode");
4035
+ }
4036
+ allBuffers.push(new Uint8Array([uuidEntries.length]));
4037
+ allBuffers.push(...uuidEntries);
4038
+ if (Object.keys(jsonObj).length > 0) {
4039
+ allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
4040
+ }
4041
+ return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
4042
+ }
4043
+ static fromStr(s) {
4044
+ try {
4045
+ const rawBytes = base64ToUint8Array(s);
4046
+ const jsonObj = {};
4047
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
4048
+ const spanComponentsOld = SpanComponentsV2.fromStr(s);
4049
+ jsonObj["object_type"] = spanComponentsOld.objectType;
4050
+ jsonObj["object_id"] = spanComponentsOld.objectId;
4051
+ jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
4052
+ if (spanComponentsOld.rowIds) {
4053
+ jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
4054
+ jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
4055
+ jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
4056
+ }
4057
+ } else {
4058
+ jsonObj["object_type"] = rawBytes[1];
4059
+ const numUuidEntries = rawBytes[2];
4060
+ let byteOffset = 3;
4061
+ for (let i = 0; i < numUuidEntries; ++i) {
4062
+ const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
4063
+ rawBytes[byteOffset]
4064
+ );
4065
+ const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
4066
+ byteOffset += 17;
4067
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
4068
+ }
4069
+ if (byteOffset < rawBytes.length) {
4070
+ const remainingJsonObj = JSON.parse(
4071
+ uint8ArrayToString(rawBytes.subarray(byteOffset))
4072
+ );
4073
+ Object.assign(jsonObj, remainingJsonObj);
4074
+ }
4075
+ }
4076
+ return _SpanComponentsV3.fromJsonObj(jsonObj);
4077
+ } catch {
4078
+ throw new Error(INVALID_ENCODING_ERRMSG3);
4079
+ }
4080
+ }
4081
+ objectIdFields() {
4082
+ if (!this.data.object_id) {
4083
+ throw new Error(
4084
+ "Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
4085
+ );
4086
+ }
4087
+ switch (this.data.object_type) {
4088
+ case 1 /* EXPERIMENT */:
4089
+ return { experiment_id: this.data.object_id };
4090
+ case 2 /* PROJECT_LOGS */:
4091
+ return { project_id: this.data.object_id, log_id: "g" };
4092
+ case 3 /* PLAYGROUND_LOGS */:
4093
+ return { prompt_session_id: this.data.object_id, log_id: "x" };
4094
+ default:
4095
+ const _ = this.data.object_type;
4096
+ throw new Error("Impossible");
4097
+ }
4098
+ }
4099
+ async export() {
4100
+ return this.toStr();
4101
+ }
4102
+ static fromJsonObj(jsonObj) {
4103
+ return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
4104
+ }
4105
+ };
4106
+
4107
+ // util/type_util.ts
4108
+ function isObject(value) {
4109
+ return value instanceof Object && !(value instanceof Array);
4110
+ }
4111
+ function isArray(value) {
4112
+ return value instanceof Array;
4113
+ }
4114
+ function isObjectOrArray(value) {
4115
+ return value instanceof Object;
4116
+ }
4117
+
4118
+ // util/object_util.ts
4119
+ function mergeDictsWithPaths({
4120
+ mergeInto,
4121
+ mergeFrom,
4122
+ mergePaths
4123
+ }) {
4124
+ const mergePathsSerialized = new Set(
4125
+ mergePaths.map((p) => JSON.stringify(p))
4126
+ );
4127
+ return mergeDictsWithPathsHelper({
4128
+ mergeInto,
4129
+ mergeFrom,
4130
+ path: [],
4131
+ mergePaths: mergePathsSerialized
4132
+ });
4133
+ }
4134
+ function mergeDictsWithPathsHelper({
4135
+ mergeInto,
4136
+ mergeFrom,
4137
+ path: path3,
4138
+ mergePaths
4139
+ }) {
4140
+ Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
4141
+ const fullPath = path3.concat([k]);
4142
+ const fullPathSerialized = JSON.stringify(fullPath);
4143
+ const mergeIntoV = recordFind(mergeInto, k);
4144
+ if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
4145
+ mergeDictsWithPathsHelper({
4146
+ mergeInto: mergeIntoV,
4147
+ mergeFrom: mergeFromV,
4148
+ path: fullPath,
4149
+ mergePaths
4150
+ });
4151
+ } else {
4152
+ mergeInto[k] = mergeFromV;
4153
+ }
4154
+ });
4155
+ return mergeInto;
4156
+ }
4157
+ function mergeDicts(mergeInto, mergeFrom) {
4158
+ return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
4159
+ }
4160
+ function mapAt(m, k) {
4161
+ const ret = m.get(k);
4162
+ if (ret === void 0) {
4163
+ throw new Error(`Map does not contain key ${k}`);
4164
+ }
4165
+ return ret;
4166
+ }
4167
+ function recordFind(m, k) {
4168
+ return m[k];
4169
+ }
4170
+ function getObjValueByPath(row, path3) {
4171
+ let curr = row;
4172
+ for (const p of path3) {
4173
+ if (!isObjectOrArray(curr)) {
4174
+ return null;
4175
+ }
4176
+ curr = curr[p];
4177
+ }
4178
+ return curr;
4179
+ }
4180
+
4181
+ // util/graph_util.ts
4182
+ function depthFirstSearch(args) {
4183
+ const { graph, firstVisitF, lastVisitF } = args;
4184
+ for (const vs of graph.values()) {
4185
+ for (const v of vs.values()) {
4186
+ if (!graph.has(v)) {
4187
+ throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
4188
+ }
4189
+ }
4190
+ }
4191
+ const firstVisitedVertices = /* @__PURE__ */ new Set();
4192
+ const visitationOrder = args.visitationOrder ?? [...graph.keys()];
4193
+ const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
4194
+ while (events.length) {
4195
+ const { eventType, vertex, extras } = events.pop();
4196
+ if (eventType === "last") {
4197
+ lastVisitF?.(vertex);
4198
+ continue;
4199
+ }
4200
+ if (firstVisitedVertices.has(vertex)) {
4201
+ continue;
4202
+ }
4203
+ firstVisitedVertices.add(vertex);
4204
+ firstVisitF?.(vertex, { parentVertex: extras.parentVertex });
4205
+ events.push({ eventType: "last", vertex, extras: {} });
4206
+ mapAt(graph, vertex).forEach((child) => {
4207
+ events.push({
4208
+ eventType: "first",
4209
+ vertex: child,
4210
+ extras: { parentVertex: vertex }
4211
+ });
4212
+ });
4213
+ }
4214
+ }
4215
+ function undirectedConnectedComponents(graph) {
4216
+ const directedGraph = new Map(
4217
+ [...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
4218
+ );
4219
+ for (const [i, j] of graph.edges) {
4220
+ mapAt(directedGraph, i).add(j);
4221
+ mapAt(directedGraph, j).add(i);
4222
+ }
4223
+ let labelCounter = 0;
4224
+ const vertexLabels = /* @__PURE__ */ new Map();
4225
+ const firstVisitF = (vertex, args) => {
4226
+ const label = args?.parentVertex !== void 0 ? mapAt(vertexLabels, args?.parentVertex) : labelCounter++;
4227
+ vertexLabels.set(vertex, label);
4228
+ };
4229
+ depthFirstSearch({ graph: directedGraph, firstVisitF });
4230
+ const output = Array.from({ length: labelCounter }).map(() => []);
4231
+ for (const [vertex, label] of vertexLabels.entries()) {
4232
+ output[label].push(vertex);
4233
+ }
4234
+ return output;
4235
+ }
4236
+ function topologicalSort(graph, visitationOrder) {
4237
+ const reverseOrdering = [];
4238
+ const lastVisitF = (vertex) => {
4239
+ reverseOrdering.push(vertex);
4240
+ };
4241
+ depthFirstSearch({ graph, lastVisitF, visitationOrder });
4242
+ return reverseOrdering.reverse();
4243
+ }
4244
+
4245
+ // util/merge_row_batch.ts
4246
+ function generateMergedRowKey(row, useParentIdForId) {
4247
+ return JSON.stringify(
4248
+ [
4249
+ "org_id",
4250
+ "project_id",
4251
+ "experiment_id",
4252
+ "dataset_id",
4253
+ "prompt_session_id",
4254
+ "log_id",
4255
+ useParentIdForId ?? false ? PARENT_ID_FIELD : "id"
4256
+ ].map((k) => row[k])
4257
+ );
4258
+ }
4259
+ var MERGE_ROW_SKIP_FIELDS = [
4260
+ "created",
4261
+ "span_id",
4262
+ "root_span_id",
4263
+ "span_parents",
4264
+ "_parent_id"
4265
+ // TODO: handle merge paths.
4266
+ ];
4267
+ function popMergeRowSkipFields(row) {
4268
+ const popped = {};
4269
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
4270
+ if (field in row) {
4271
+ popped[field] = row[field];
4272
+ delete row[field];
4273
+ }
4274
+ }
4275
+ return popped;
4276
+ }
4277
+ function restoreMergeRowSkipFields(row, skipFields) {
4278
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
4279
+ delete row[field];
4280
+ if (field in skipFields) {
4281
+ row[field] = skipFields[field];
4282
+ }
4283
+ }
4284
+ }
4285
+ function mergeRowBatch(rows) {
4286
+ for (const row of rows) {
4287
+ if (row.id === void 0) {
4288
+ throw new Error(
4289
+ "Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
4290
+ );
4291
+ }
4292
+ }
4293
+ const rowGroups = /* @__PURE__ */ new Map();
4294
+ for (const row of rows) {
4295
+ const key = generateMergedRowKey(row);
4296
+ const existingRow = rowGroups.get(key);
4297
+ if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
4298
+ const skipFields = popMergeRowSkipFields(existingRow);
4299
+ const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
4300
+ mergeDicts(existingRow, row);
4301
+ restoreMergeRowSkipFields(existingRow, skipFields);
4302
+ if (preserveNoMerge) {
4303
+ delete existingRow[IS_MERGE_FIELD];
4304
+ }
4305
+ } else {
4306
+ rowGroups.set(key, row);
4307
+ }
4308
+ }
4309
+ const merged = [...rowGroups.values()];
4310
+ const rowToLabel = new Map(
4311
+ merged.map((r, i) => [generateMergedRowKey(r), i])
4312
+ );
4313
+ const graph = new Map(
4314
+ Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
4315
+ );
4316
+ merged.forEach((r, i) => {
4317
+ const parentId = r[PARENT_ID_FIELD];
4318
+ if (!parentId) {
4319
+ return;
4320
+ }
4321
+ const parentRowKey = generateMergedRowKey(
4322
+ r,
4323
+ true
4324
+ /* useParentIdForId */
4325
+ );
4326
+ const parentLabel = rowToLabel.get(parentRowKey);
4327
+ if (parentLabel !== void 0) {
4328
+ mapAt(graph, parentLabel).add(i);
4329
+ }
4330
+ });
4331
+ const connectedComponents = undirectedConnectedComponents({
4332
+ vertices: new Set(graph.keys()),
4333
+ edges: new Set(
4334
+ [...graph.entries()].flatMap(
4335
+ ([k, vs]) => [...vs].map((v) => {
4336
+ const ret = [k, v];
4337
+ return ret;
4338
+ })
4339
+ )
4340
+ )
4341
+ });
4342
+ const buckets = connectedComponents.map(
4343
+ (cc) => topologicalSort(
4344
+ graph,
4345
+ cc
4346
+ /* visitationOrder */
4347
+ )
4348
+ );
4349
+ return buckets.map((bucket) => bucket.map((i) => merged[i]));
4350
+ }
4351
+ function batchItems(args) {
4352
+ let { items } = args;
4353
+ const batchMaxNumItems = args.batchMaxNumItems ?? Number.POSITIVE_INFINITY;
4354
+ const batchMaxNumBytes = args.batchMaxNumBytes ?? Number.POSITIVE_INFINITY;
4355
+ const output = [];
4356
+ let nextItems = [];
4357
+ let batchSet = [];
4358
+ let batch = [];
4359
+ let batchLen = 0;
4360
+ function addToBatch(item) {
4361
+ batch.push(item);
4362
+ batchLen += item.length;
4363
+ }
4364
+ function flushBatch() {
4365
+ batchSet.push(batch);
4366
+ batch = [];
4367
+ batchLen = 0;
4368
+ }
4369
+ while (items.length) {
4370
+ for (const bucket of items) {
4371
+ let i = 0;
4372
+ for (const item of bucket) {
4373
+ if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
4374
+ addToBatch(item);
4375
+ } else if (i === 0) {
4376
+ flushBatch();
4377
+ addToBatch(item);
4378
+ } else {
4379
+ break;
4380
+ }
4381
+ ++i;
4382
+ }
4383
+ if (i < bucket.length) {
4384
+ nextItems.push(bucket.slice(i));
4385
+ }
4386
+ if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
4387
+ flushBatch();
4388
+ }
4389
+ }
4390
+ if (batch.length) {
4391
+ flushBatch();
4392
+ }
4393
+ if (batchSet.length) {
4394
+ output.push(batchSet);
4395
+ batchSet = [];
4396
+ }
4397
+ items = nextItems;
4398
+ nextItems = [];
4399
+ }
4400
+ return output;
4401
+ }
4402
+
4403
+ // util/object.ts
4404
+ var DEFAULT_IS_LEGACY_DATASET = false;
4405
+ function ensureDatasetRecord(r, legacy) {
4406
+ if (legacy) {
4407
+ return ensureLegacyDatasetRecord(r);
4408
+ } else {
4409
+ return ensureNewDatasetRecord(r);
4410
+ }
4411
+ }
4412
+ function ensureLegacyDatasetRecord(r) {
4413
+ if ("output" in r) {
4414
+ return r;
4415
+ }
4416
+ const row = {
4417
+ ...r,
4418
+ output: r.expected
4419
+ };
4420
+ delete row.expected;
4421
+ return row;
4422
+ }
4423
+ function ensureNewDatasetRecord(r) {
4424
+ if ("expected" in r) {
4425
+ return r;
4426
+ }
4427
+ const row = {
4428
+ ...r,
4429
+ tags: null,
4430
+ expected: r.output
4431
+ };
4432
+ delete row.output;
4433
+ return row;
4434
+ }
4435
+
4436
+ // util/json_util.ts
4437
+ function constructJsonArray(items) {
4438
+ return `[${items.join(",")}]`;
4439
+ }
4440
+
4441
+ // util/string_util.ts
4442
+ function _urljoin(...parts) {
4443
+ return parts.map(
4444
+ (x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
4445
+ ).filter((x) => x.trim() !== "").join("/");
4446
+ }
4447
+
4448
+ // util/git_fields.ts
4449
+ function mergeGitMetadataSettings(s1, s2) {
4450
+ if (s1.collect === "all") {
4451
+ return s2;
4452
+ } else if (s2.collect === "all") {
4453
+ return s1;
4454
+ } else if (s1.collect === "none") {
4455
+ return s1;
4456
+ } else if (s2.collect === "none") {
4457
+ return s2;
4458
+ }
4459
+ const fields = (s1.fields ?? []).filter((f) => (s2.fields ?? []).includes(f));
4460
+ const collect = fields.length > 0 ? "some" : "none";
4461
+ return { collect, fields };
4462
+ }
4463
+
4464
+ // util/xact-ids.ts
4465
+ var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
4466
+ var MOD = BigInt(1) << BigInt(64);
4467
+ var COPRIME = BigInt("205891132094649");
4468
+ var COPRIME_INVERSE = BigInt("1522336535492693385");
4469
+ function modularMultiply(value, prime) {
4470
+ return value * prime % MOD;
4471
+ }
4472
+ function prettifyXact(valueString) {
4473
+ const value = BigInt(valueString);
4474
+ const encoded = modularMultiply(value, COPRIME);
4475
+ return encoded.toString(16).padStart(16, "0");
4476
+ }
4477
+ function loadPrettyXact(encodedHex) {
4478
+ if (encodedHex.length !== 16) {
4479
+ return encodedHex;
4480
+ }
4481
+ const value = BigInt(`0x${encodedHex}`);
4482
+ const multipliedInverse = modularMultiply(value, COPRIME_INVERSE);
4483
+ const withTopBits = TOP_BITS | multipliedInverse;
4484
+ return withTopBits.toString();
4485
+ }
4486
+
4487
+ // util/zod_util.ts
4488
+ import { z as z4 } from "zod/v3";
3523
4489
 
3524
4490
  // src/generated_types.ts
3525
- import { z } from "zod";
3526
- var AclObjectType = z.union([
3527
- z.enum([
4491
+ import { z as z5 } from "zod/v3";
4492
+ var AclObjectType = z5.union([
4493
+ z5.enum([
3528
4494
  "organization",
3529
4495
  "project",
3530
4496
  "experiment",
@@ -3537,9 +4503,9 @@ var AclObjectType = z.union([
3537
4503
  "project_log",
3538
4504
  "org_project"
3539
4505
  ]),
3540
- z.null()
4506
+ z5.null()
3541
4507
  ]);
3542
- var Permission = z.enum([
4508
+ var Permission = z5.enum([
3543
4509
  "create",
3544
4510
  "read",
3545
4511
  "update",
@@ -3549,310 +4515,310 @@ var Permission = z.enum([
3549
4515
  "update_acls",
3550
4516
  "delete_acls"
3551
4517
  ]);
3552
- var Acl = z.object({
3553
- id: z.string().uuid(),
3554
- object_type: AclObjectType.and(z.string()),
3555
- object_id: z.string().uuid(),
3556
- user_id: z.union([z.string(), z.null()]).optional(),
3557
- group_id: z.union([z.string(), z.null()]).optional(),
3558
- permission: Permission.and(z.union([z.string(), z.null()])).optional(),
3559
- restrict_object_type: AclObjectType.and(z.unknown()).optional(),
3560
- role_id: z.union([z.string(), z.null()]).optional(),
3561
- _object_org_id: z.string().uuid(),
3562
- created: z.union([z.string(), z.null()]).optional()
3563
- });
3564
- var AISecret = z.object({
3565
- id: z.string().uuid(),
3566
- created: z.union([z.string(), z.null()]).optional(),
3567
- updated_at: z.union([z.string(), z.null()]).optional(),
3568
- org_id: z.string().uuid(),
3569
- name: z.string(),
3570
- type: z.union([z.string(), z.null()]).optional(),
3571
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
3572
- preview_secret: z.union([z.string(), z.null()]).optional()
3573
- });
3574
- var ResponseFormatJsonSchema = z.object({
3575
- name: z.string(),
3576
- description: z.string().optional(),
3577
- schema: z.union([z.object({}).partial().passthrough(), z.string()]).optional(),
3578
- strict: z.union([z.boolean(), z.null()]).optional()
3579
- });
3580
- var ResponseFormatNullish = z.union([
3581
- z.object({ type: z.literal("json_object") }),
3582
- z.object({
3583
- type: z.literal("json_schema"),
4518
+ var Acl = z5.object({
4519
+ id: z5.string().uuid(),
4520
+ object_type: AclObjectType.and(z5.string()),
4521
+ object_id: z5.string().uuid(),
4522
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
4523
+ group_id: z5.union([z5.string(), z5.null()]).optional(),
4524
+ permission: Permission.and(z5.union([z5.string(), z5.null()])).optional(),
4525
+ restrict_object_type: AclObjectType.and(z5.unknown()).optional(),
4526
+ role_id: z5.union([z5.string(), z5.null()]).optional(),
4527
+ _object_org_id: z5.string().uuid(),
4528
+ created: z5.union([z5.string(), z5.null()]).optional()
4529
+ });
4530
+ var AISecret = z5.object({
4531
+ id: z5.string().uuid(),
4532
+ created: z5.union([z5.string(), z5.null()]).optional(),
4533
+ updated_at: z5.union([z5.string(), z5.null()]).optional(),
4534
+ org_id: z5.string().uuid(),
4535
+ name: z5.string(),
4536
+ type: z5.union([z5.string(), z5.null()]).optional(),
4537
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
4538
+ preview_secret: z5.union([z5.string(), z5.null()]).optional()
4539
+ });
4540
+ var ResponseFormatJsonSchema = z5.object({
4541
+ name: z5.string(),
4542
+ description: z5.string().optional(),
4543
+ schema: z5.union([z5.object({}).partial().passthrough(), z5.string()]).optional(),
4544
+ strict: z5.union([z5.boolean(), z5.null()]).optional()
4545
+ });
4546
+ var ResponseFormatNullish = z5.union([
4547
+ z5.object({ type: z5.literal("json_object") }),
4548
+ z5.object({
4549
+ type: z5.literal("json_schema"),
3584
4550
  json_schema: ResponseFormatJsonSchema
3585
4551
  }),
3586
- z.object({ type: z.literal("text") }),
3587
- z.null()
4552
+ z5.object({ type: z5.literal("text") }),
4553
+ z5.null()
3588
4554
  ]);
3589
- var AnyModelParams = z.object({
3590
- temperature: z.number().optional(),
3591
- top_p: z.number().optional(),
3592
- max_tokens: z.number(),
3593
- max_completion_tokens: z.number().optional(),
3594
- frequency_penalty: z.number().optional(),
3595
- presence_penalty: z.number().optional(),
4555
+ var AnyModelParams = z5.object({
4556
+ temperature: z5.number().optional(),
4557
+ top_p: z5.number().optional(),
4558
+ max_tokens: z5.number(),
4559
+ max_completion_tokens: z5.number().optional(),
4560
+ frequency_penalty: z5.number().optional(),
4561
+ presence_penalty: z5.number().optional(),
3596
4562
  response_format: ResponseFormatNullish.optional(),
3597
- tool_choice: z.union([
3598
- z.literal("auto"),
3599
- z.literal("none"),
3600
- z.literal("required"),
3601
- z.object({
3602
- type: z.literal("function"),
3603
- function: z.object({ name: z.string() })
4563
+ tool_choice: z5.union([
4564
+ z5.literal("auto"),
4565
+ z5.literal("none"),
4566
+ z5.literal("required"),
4567
+ z5.object({
4568
+ type: z5.literal("function"),
4569
+ function: z5.object({ name: z5.string() })
3604
4570
  })
3605
4571
  ]).optional(),
3606
- function_call: z.union([
3607
- z.literal("auto"),
3608
- z.literal("none"),
3609
- z.object({ name: z.string() })
4572
+ function_call: z5.union([
4573
+ z5.literal("auto"),
4574
+ z5.literal("none"),
4575
+ z5.object({ name: z5.string() })
3610
4576
  ]).optional(),
3611
- n: z.number().optional(),
3612
- stop: z.array(z.string()).optional(),
3613
- reasoning_effort: z.enum(["minimal", "low", "medium", "high"]).optional(),
3614
- verbosity: z.enum(["low", "medium", "high"]).optional(),
3615
- top_k: z.number().optional(),
3616
- stop_sequences: z.array(z.string()).optional(),
3617
- max_tokens_to_sample: z.number().optional(),
3618
- maxOutputTokens: z.number().optional(),
3619
- topP: z.number().optional(),
3620
- topK: z.number().optional(),
3621
- use_cache: z.boolean().optional()
3622
- });
3623
- var ApiKey = z.object({
3624
- id: z.string().uuid(),
3625
- created: z.union([z.string(), z.null()]).optional(),
3626
- name: z.string(),
3627
- preview_name: z.string(),
3628
- user_id: z.union([z.string(), z.null()]).optional(),
3629
- user_email: z.union([z.string(), z.null()]).optional(),
3630
- user_given_name: z.union([z.string(), z.null()]).optional(),
3631
- user_family_name: z.union([z.string(), z.null()]).optional(),
3632
- org_id: z.union([z.string(), z.null()]).optional()
3633
- });
3634
- var AsyncScoringState = z.union([
3635
- z.object({
3636
- status: z.literal("enabled"),
3637
- token: z.string(),
3638
- function_ids: z.array(z.unknown()).min(1),
3639
- skip_logging: z.union([z.boolean(), z.null()]).optional()
4577
+ n: z5.number().optional(),
4578
+ stop: z5.array(z5.string()).optional(),
4579
+ reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]).optional(),
4580
+ verbosity: z5.enum(["low", "medium", "high"]).optional(),
4581
+ top_k: z5.number().optional(),
4582
+ stop_sequences: z5.array(z5.string()).optional(),
4583
+ max_tokens_to_sample: z5.number().optional(),
4584
+ maxOutputTokens: z5.number().optional(),
4585
+ topP: z5.number().optional(),
4586
+ topK: z5.number().optional(),
4587
+ use_cache: z5.boolean().optional()
4588
+ });
4589
+ var ApiKey = z5.object({
4590
+ id: z5.string().uuid(),
4591
+ created: z5.union([z5.string(), z5.null()]).optional(),
4592
+ name: z5.string(),
4593
+ preview_name: z5.string(),
4594
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
4595
+ user_email: z5.union([z5.string(), z5.null()]).optional(),
4596
+ user_given_name: z5.union([z5.string(), z5.null()]).optional(),
4597
+ user_family_name: z5.union([z5.string(), z5.null()]).optional(),
4598
+ org_id: z5.union([z5.string(), z5.null()]).optional()
4599
+ });
4600
+ var AsyncScoringState = z5.union([
4601
+ z5.object({
4602
+ status: z5.literal("enabled"),
4603
+ token: z5.string(),
4604
+ function_ids: z5.array(z5.unknown()).min(1),
4605
+ skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
3640
4606
  }),
3641
- z.object({ status: z.literal("disabled") }),
3642
- z.null(),
3643
- z.null()
4607
+ z5.object({ status: z5.literal("disabled") }),
4608
+ z5.null(),
4609
+ z5.null()
3644
4610
  ]);
3645
- var AsyncScoringControl = z.union([
3646
- z.object({ kind: z.literal("score_update"), token: z.string() }),
3647
- z.object({ kind: z.literal("state_override"), state: AsyncScoringState }),
3648
- z.object({ kind: z.literal("state_force_reselect") }),
3649
- z.object({ kind: z.literal("state_enabled_force_rescore") })
4611
+ var AsyncScoringControl = z5.union([
4612
+ z5.object({ kind: z5.literal("score_update"), token: z5.string() }),
4613
+ z5.object({ kind: z5.literal("state_override"), state: AsyncScoringState }),
4614
+ z5.object({ kind: z5.literal("state_force_reselect") }),
4615
+ z5.object({ kind: z5.literal("state_enabled_force_rescore") })
3650
4616
  ]);
3651
- var BraintrustAttachmentReference = z.object({
3652
- type: z.literal("braintrust_attachment"),
3653
- filename: z.string().min(1),
3654
- content_type: z.string().min(1),
3655
- key: z.string().min(1)
3656
- });
3657
- var ExternalAttachmentReference = z.object({
3658
- type: z.literal("external_attachment"),
3659
- filename: z.string().min(1),
3660
- content_type: z.string().min(1),
3661
- url: z.string().min(1)
3662
- });
3663
- var AttachmentReference = z.discriminatedUnion("type", [
4617
+ var BraintrustAttachmentReference = z5.object({
4618
+ type: z5.literal("braintrust_attachment"),
4619
+ filename: z5.string().min(1),
4620
+ content_type: z5.string().min(1),
4621
+ key: z5.string().min(1)
4622
+ });
4623
+ var ExternalAttachmentReference = z5.object({
4624
+ type: z5.literal("external_attachment"),
4625
+ filename: z5.string().min(1),
4626
+ content_type: z5.string().min(1),
4627
+ url: z5.string().min(1)
4628
+ });
4629
+ var AttachmentReference = z5.discriminatedUnion("type", [
3664
4630
  BraintrustAttachmentReference,
3665
4631
  ExternalAttachmentReference
3666
4632
  ]);
3667
- var UploadStatus = z.enum(["uploading", "done", "error"]);
3668
- var AttachmentStatus = z.object({
4633
+ var UploadStatus = z5.enum(["uploading", "done", "error"]);
4634
+ var AttachmentStatus = z5.object({
3669
4635
  upload_status: UploadStatus,
3670
- error_message: z.string().optional()
3671
- });
3672
- var BraintrustModelParams = z.object({ use_cache: z.boolean() }).partial();
3673
- var CallEvent = z.union([
3674
- z.object({
3675
- id: z.string().optional(),
3676
- data: z.string(),
3677
- event: z.literal("text_delta")
4636
+ error_message: z5.string().optional()
4637
+ });
4638
+ var BraintrustModelParams = z5.object({ use_cache: z5.boolean() }).partial();
4639
+ var CallEvent = z5.union([
4640
+ z5.object({
4641
+ id: z5.string().optional(),
4642
+ data: z5.string(),
4643
+ event: z5.literal("text_delta")
3678
4644
  }),
3679
- z.object({
3680
- id: z.string().optional(),
3681
- data: z.string(),
3682
- event: z.literal("reasoning_delta")
4645
+ z5.object({
4646
+ id: z5.string().optional(),
4647
+ data: z5.string(),
4648
+ event: z5.literal("reasoning_delta")
3683
4649
  }),
3684
- z.object({
3685
- id: z.string().optional(),
3686
- data: z.string(),
3687
- event: z.literal("json_delta")
4650
+ z5.object({
4651
+ id: z5.string().optional(),
4652
+ data: z5.string(),
4653
+ event: z5.literal("json_delta")
3688
4654
  }),
3689
- z.object({
3690
- id: z.string().optional(),
3691
- data: z.string(),
3692
- event: z.literal("progress")
4655
+ z5.object({
4656
+ id: z5.string().optional(),
4657
+ data: z5.string(),
4658
+ event: z5.literal("progress")
3693
4659
  }),
3694
- z.object({
3695
- id: z.string().optional(),
3696
- data: z.string(),
3697
- event: z.literal("error")
4660
+ z5.object({
4661
+ id: z5.string().optional(),
4662
+ data: z5.string(),
4663
+ event: z5.literal("error")
3698
4664
  }),
3699
- z.object({
3700
- id: z.string().optional(),
3701
- data: z.string(),
3702
- event: z.literal("console")
4665
+ z5.object({
4666
+ id: z5.string().optional(),
4667
+ data: z5.string(),
4668
+ event: z5.literal("console")
3703
4669
  }),
3704
- z.object({
3705
- id: z.string().optional(),
3706
- event: z.literal("start"),
3707
- data: z.literal("")
4670
+ z5.object({
4671
+ id: z5.string().optional(),
4672
+ event: z5.literal("start"),
4673
+ data: z5.literal("")
3708
4674
  }),
3709
- z.object({
3710
- id: z.string().optional(),
3711
- event: z.literal("done"),
3712
- data: z.literal("")
4675
+ z5.object({
4676
+ id: z5.string().optional(),
4677
+ event: z5.literal("done"),
4678
+ data: z5.literal("")
3713
4679
  })
3714
4680
  ]);
3715
- var ChatCompletionContentPartTextWithTitle = z.object({
3716
- text: z.string().default(""),
3717
- type: z.literal("text"),
3718
- cache_control: z.object({ type: z.literal("ephemeral") }).optional()
3719
- });
3720
- var ChatCompletionContentPartImageWithTitle = z.object({
3721
- image_url: z.object({
3722
- url: z.string(),
3723
- detail: z.union([z.literal("auto"), z.literal("low"), z.literal("high")]).optional()
4681
+ var ChatCompletionContentPartTextWithTitle = z5.object({
4682
+ text: z5.string().default(""),
4683
+ type: z5.literal("text"),
4684
+ cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
4685
+ });
4686
+ var ChatCompletionContentPartImageWithTitle = z5.object({
4687
+ image_url: z5.object({
4688
+ url: z5.string(),
4689
+ detail: z5.union([z5.literal("auto"), z5.literal("low"), z5.literal("high")]).optional()
3724
4690
  }),
3725
- type: z.literal("image_url")
4691
+ type: z5.literal("image_url")
3726
4692
  });
3727
- var ChatCompletionContentPart = z.union([
4693
+ var ChatCompletionContentPart = z5.union([
3728
4694
  ChatCompletionContentPartTextWithTitle,
3729
4695
  ChatCompletionContentPartImageWithTitle
3730
4696
  ]);
3731
- var ChatCompletionContentPartText = z.object({
3732
- text: z.string().default(""),
3733
- type: z.literal("text"),
3734
- cache_control: z.object({ type: z.literal("ephemeral") }).optional()
3735
- });
3736
- var ChatCompletionMessageToolCall = z.object({
3737
- id: z.string(),
3738
- function: z.object({ arguments: z.string(), name: z.string() }),
3739
- type: z.literal("function")
3740
- });
3741
- var ChatCompletionMessageReasoning = z.object({ id: z.string(), content: z.string() }).partial();
3742
- var ChatCompletionMessageParam = z.union([
3743
- z.object({
3744
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
3745
- role: z.literal("system"),
3746
- name: z.string().optional()
4697
+ var ChatCompletionContentPartText = z5.object({
4698
+ text: z5.string().default(""),
4699
+ type: z5.literal("text"),
4700
+ cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
4701
+ });
4702
+ var ChatCompletionMessageToolCall = z5.object({
4703
+ id: z5.string(),
4704
+ function: z5.object({ arguments: z5.string(), name: z5.string() }),
4705
+ type: z5.literal("function")
4706
+ });
4707
+ var ChatCompletionMessageReasoning = z5.object({ id: z5.string(), content: z5.string() }).partial();
4708
+ var ChatCompletionMessageParam = z5.union([
4709
+ z5.object({
4710
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4711
+ role: z5.literal("system"),
4712
+ name: z5.string().optional()
3747
4713
  }),
3748
- z.object({
3749
- content: z.union([z.string(), z.array(ChatCompletionContentPart)]),
3750
- role: z.literal("user"),
3751
- name: z.string().optional()
4714
+ z5.object({
4715
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
4716
+ role: z5.literal("user"),
4717
+ name: z5.string().optional()
3752
4718
  }),
3753
- z.object({
3754
- role: z.literal("assistant"),
3755
- content: z.union([z.string(), z.array(ChatCompletionContentPartText), z.null()]).optional(),
3756
- function_call: z.object({ arguments: z.string(), name: z.string() }).optional(),
3757
- name: z.string().optional(),
3758
- tool_calls: z.array(ChatCompletionMessageToolCall).optional(),
3759
- reasoning: z.array(ChatCompletionMessageReasoning).optional()
4719
+ z5.object({
4720
+ role: z5.literal("assistant"),
4721
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
4722
+ function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
4723
+ name: z5.string().optional(),
4724
+ tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
4725
+ reasoning: z5.array(ChatCompletionMessageReasoning).optional()
3760
4726
  }),
3761
- z.object({
3762
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
3763
- role: z.literal("tool"),
3764
- tool_call_id: z.string().default("")
4727
+ z5.object({
4728
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4729
+ role: z5.literal("tool"),
4730
+ tool_call_id: z5.string().default("")
3765
4731
  }),
3766
- z.object({
3767
- content: z.union([z.string(), z.null()]),
3768
- name: z.string(),
3769
- role: z.literal("function")
4732
+ z5.object({
4733
+ content: z5.union([z5.string(), z5.null()]),
4734
+ name: z5.string(),
4735
+ role: z5.literal("function")
3770
4736
  }),
3771
- z.object({
3772
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
3773
- role: z.literal("developer"),
3774
- name: z.string().optional()
4737
+ z5.object({
4738
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4739
+ role: z5.literal("developer"),
4740
+ name: z5.string().optional()
3775
4741
  }),
3776
- z.object({
3777
- role: z.literal("model"),
3778
- content: z.union([z.string(), z.null()]).optional()
4742
+ z5.object({
4743
+ role: z5.literal("model"),
4744
+ content: z5.union([z5.string(), z5.null()]).optional()
3779
4745
  })
3780
4746
  ]);
3781
- var ChatCompletionOpenAIMessageParam = z.union([
3782
- z.object({
3783
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
3784
- role: z.literal("system"),
3785
- name: z.string().optional()
4747
+ var ChatCompletionOpenAIMessageParam = z5.union([
4748
+ z5.object({
4749
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4750
+ role: z5.literal("system"),
4751
+ name: z5.string().optional()
3786
4752
  }),
3787
- z.object({
3788
- content: z.union([z.string(), z.array(ChatCompletionContentPart)]),
3789
- role: z.literal("user"),
3790
- name: z.string().optional()
4753
+ z5.object({
4754
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
4755
+ role: z5.literal("user"),
4756
+ name: z5.string().optional()
3791
4757
  }),
3792
- z.object({
3793
- role: z.literal("assistant"),
3794
- content: z.union([z.string(), z.array(ChatCompletionContentPartText), z.null()]).optional(),
3795
- function_call: z.object({ arguments: z.string(), name: z.string() }).optional(),
3796
- name: z.string().optional(),
3797
- tool_calls: z.array(ChatCompletionMessageToolCall).optional(),
3798
- reasoning: z.array(ChatCompletionMessageReasoning).optional()
4758
+ z5.object({
4759
+ role: z5.literal("assistant"),
4760
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
4761
+ function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
4762
+ name: z5.string().optional(),
4763
+ tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
4764
+ reasoning: z5.array(ChatCompletionMessageReasoning).optional()
3799
4765
  }),
3800
- z.object({
3801
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
3802
- role: z.literal("tool"),
3803
- tool_call_id: z.string().default("")
4766
+ z5.object({
4767
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4768
+ role: z5.literal("tool"),
4769
+ tool_call_id: z5.string().default("")
3804
4770
  }),
3805
- z.object({
3806
- content: z.union([z.string(), z.null()]),
3807
- name: z.string(),
3808
- role: z.literal("function")
4771
+ z5.object({
4772
+ content: z5.union([z5.string(), z5.null()]),
4773
+ name: z5.string(),
4774
+ role: z5.literal("function")
3809
4775
  }),
3810
- z.object({
3811
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
3812
- role: z.literal("developer"),
3813
- name: z.string().optional()
4776
+ z5.object({
4777
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4778
+ role: z5.literal("developer"),
4779
+ name: z5.string().optional()
3814
4780
  })
3815
4781
  ]);
3816
- var ChatCompletionTool = z.object({
3817
- function: z.object({
3818
- name: z.string(),
3819
- description: z.string().optional(),
3820
- parameters: z.object({}).partial().passthrough().optional()
4782
+ var ChatCompletionTool = z5.object({
4783
+ function: z5.object({
4784
+ name: z5.string(),
4785
+ description: z5.string().optional(),
4786
+ parameters: z5.object({}).partial().passthrough().optional()
3821
4787
  }),
3822
- type: z.literal("function")
4788
+ type: z5.literal("function")
3823
4789
  });
3824
- var CodeBundle = z.object({
3825
- runtime_context: z.object({
3826
- runtime: z.enum(["node", "python"]),
3827
- version: z.string()
4790
+ var CodeBundle = z5.object({
4791
+ runtime_context: z5.object({
4792
+ runtime: z5.enum(["node", "python"]),
4793
+ version: z5.string()
3828
4794
  }),
3829
- location: z.union([
3830
- z.object({
3831
- type: z.literal("experiment"),
3832
- eval_name: z.string(),
3833
- position: z.union([
3834
- z.object({ type: z.literal("task") }),
3835
- z.object({ type: z.literal("scorer"), index: z.number().int().gte(0) })
4795
+ location: z5.union([
4796
+ z5.object({
4797
+ type: z5.literal("experiment"),
4798
+ eval_name: z5.string(),
4799
+ position: z5.union([
4800
+ z5.object({ type: z5.literal("task") }),
4801
+ z5.object({ type: z5.literal("scorer"), index: z5.number().int().gte(0) })
3836
4802
  ])
3837
4803
  }),
3838
- z.object({ type: z.literal("function"), index: z.number().int().gte(0) })
4804
+ z5.object({ type: z5.literal("function"), index: z5.number().int().gte(0) })
3839
4805
  ]),
3840
- bundle_id: z.string(),
3841
- preview: z.union([z.string(), z.null()]).optional()
3842
- });
3843
- var Dataset = z.object({
3844
- id: z.string().uuid(),
3845
- project_id: z.string().uuid(),
3846
- name: z.string(),
3847
- description: z.union([z.string(), z.null()]).optional(),
3848
- created: z.union([z.string(), z.null()]).optional(),
3849
- deleted_at: z.union([z.string(), z.null()]).optional(),
3850
- user_id: z.union([z.string(), z.null()]).optional(),
3851
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
3852
- });
3853
- var ObjectReferenceNullish = z.union([
3854
- z.object({
3855
- object_type: z.enum([
4806
+ bundle_id: z5.string(),
4807
+ preview: z5.union([z5.string(), z5.null()]).optional()
4808
+ });
4809
+ var Dataset = z5.object({
4810
+ id: z5.string().uuid(),
4811
+ project_id: z5.string().uuid(),
4812
+ name: z5.string(),
4813
+ description: z5.union([z5.string(), z5.null()]).optional(),
4814
+ created: z5.union([z5.string(), z5.null()]).optional(),
4815
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
4816
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
4817
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
4818
+ });
4819
+ var ObjectReferenceNullish = z5.union([
4820
+ z5.object({
4821
+ object_type: z5.enum([
3856
4822
  "project_logs",
3857
4823
  "experiment",
3858
4824
  "dataset",
@@ -3860,399 +4826,399 @@ var ObjectReferenceNullish = z.union([
3860
4826
  "function",
3861
4827
  "prompt_session"
3862
4828
  ]),
3863
- object_id: z.string().uuid(),
3864
- id: z.string(),
3865
- _xact_id: z.union([z.string(), z.null()]).optional(),
3866
- created: z.union([z.string(), z.null()]).optional()
4829
+ object_id: z5.string().uuid(),
4830
+ id: z5.string(),
4831
+ _xact_id: z5.union([z5.string(), z5.null()]).optional(),
4832
+ created: z5.union([z5.string(), z5.null()]).optional()
3867
4833
  }),
3868
- z.null()
4834
+ z5.null()
3869
4835
  ]);
3870
- var DatasetEvent = z.object({
3871
- id: z.string(),
3872
- _xact_id: z.string(),
3873
- created: z.string().datetime({ offset: true }),
3874
- _pagination_key: z.union([z.string(), z.null()]).optional(),
3875
- project_id: z.string().uuid(),
3876
- dataset_id: z.string().uuid(),
3877
- input: z.unknown().optional(),
3878
- expected: z.unknown().optional(),
3879
- metadata: z.union([
3880
- z.object({ model: z.union([z.string(), z.null()]) }).partial().passthrough(),
3881
- z.null()
4836
+ var DatasetEvent = z5.object({
4837
+ id: z5.string(),
4838
+ _xact_id: z5.string(),
4839
+ created: z5.string().datetime({ offset: true }),
4840
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
4841
+ project_id: z5.string().uuid(),
4842
+ dataset_id: z5.string().uuid(),
4843
+ input: z5.unknown().optional(),
4844
+ expected: z5.unknown().optional(),
4845
+ metadata: z5.union([
4846
+ z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
4847
+ z5.null()
3882
4848
  ]).optional(),
3883
- tags: z.union([z.array(z.string()), z.null()]).optional(),
3884
- span_id: z.string(),
3885
- root_span_id: z.string(),
3886
- is_root: z.union([z.boolean(), z.null()]).optional(),
4849
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
4850
+ span_id: z5.string(),
4851
+ root_span_id: z5.string(),
4852
+ is_root: z5.union([z5.boolean(), z5.null()]).optional(),
3887
4853
  origin: ObjectReferenceNullish.optional()
3888
4854
  });
3889
- var EnvVar = z.object({
3890
- id: z.string().uuid(),
3891
- object_type: z.enum(["organization", "project", "function"]),
3892
- object_id: z.string().uuid(),
3893
- name: z.string(),
3894
- created: z.union([z.string(), z.null()]).optional(),
3895
- used: z.union([z.string(), z.null()]).optional()
3896
- });
3897
- var RepoInfo = z.union([
3898
- z.object({
3899
- commit: z.union([z.string(), z.null()]),
3900
- branch: z.union([z.string(), z.null()]),
3901
- tag: z.union([z.string(), z.null()]),
3902
- dirty: z.union([z.boolean(), z.null()]),
3903
- author_name: z.union([z.string(), z.null()]),
3904
- author_email: z.union([z.string(), z.null()]),
3905
- commit_message: z.union([z.string(), z.null()]),
3906
- commit_time: z.union([z.string(), z.null()]),
3907
- git_diff: z.union([z.string(), z.null()])
4855
+ var EnvVar = z5.object({
4856
+ id: z5.string().uuid(),
4857
+ object_type: z5.enum(["organization", "project", "function"]),
4858
+ object_id: z5.string().uuid(),
4859
+ name: z5.string(),
4860
+ created: z5.union([z5.string(), z5.null()]).optional(),
4861
+ used: z5.union([z5.string(), z5.null()]).optional()
4862
+ });
4863
+ var RepoInfo = z5.union([
4864
+ z5.object({
4865
+ commit: z5.union([z5.string(), z5.null()]),
4866
+ branch: z5.union([z5.string(), z5.null()]),
4867
+ tag: z5.union([z5.string(), z5.null()]),
4868
+ dirty: z5.union([z5.boolean(), z5.null()]),
4869
+ author_name: z5.union([z5.string(), z5.null()]),
4870
+ author_email: z5.union([z5.string(), z5.null()]),
4871
+ commit_message: z5.union([z5.string(), z5.null()]),
4872
+ commit_time: z5.union([z5.string(), z5.null()]),
4873
+ git_diff: z5.union([z5.string(), z5.null()])
3908
4874
  }).partial(),
3909
- z.null()
4875
+ z5.null()
3910
4876
  ]);
3911
- var Experiment = z.object({
3912
- id: z.string().uuid(),
3913
- project_id: z.string().uuid(),
3914
- name: z.string(),
3915
- description: z.union([z.string(), z.null()]).optional(),
3916
- created: z.union([z.string(), z.null()]).optional(),
4877
+ var Experiment = z5.object({
4878
+ id: z5.string().uuid(),
4879
+ project_id: z5.string().uuid(),
4880
+ name: z5.string(),
4881
+ description: z5.union([z5.string(), z5.null()]).optional(),
4882
+ created: z5.union([z5.string(), z5.null()]).optional(),
3917
4883
  repo_info: RepoInfo.optional(),
3918
- commit: z.union([z.string(), z.null()]).optional(),
3919
- base_exp_id: z.union([z.string(), z.null()]).optional(),
3920
- deleted_at: z.union([z.string(), z.null()]).optional(),
3921
- dataset_id: z.union([z.string(), z.null()]).optional(),
3922
- dataset_version: z.union([z.string(), z.null()]).optional(),
3923
- public: z.boolean(),
3924
- user_id: z.union([z.string(), z.null()]).optional(),
3925
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
3926
- tags: z.union([z.array(z.string()), z.null()]).optional()
3927
- });
3928
- var SpanType = z.union([
3929
- z.enum(["llm", "score", "function", "eval", "task", "tool"]),
3930
- z.null()
4884
+ commit: z5.union([z5.string(), z5.null()]).optional(),
4885
+ base_exp_id: z5.union([z5.string(), z5.null()]).optional(),
4886
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
4887
+ dataset_id: z5.union([z5.string(), z5.null()]).optional(),
4888
+ dataset_version: z5.union([z5.string(), z5.null()]).optional(),
4889
+ public: z5.boolean(),
4890
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
4891
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
4892
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
4893
+ });
4894
+ var SpanType = z5.union([
4895
+ z5.enum(["llm", "score", "function", "eval", "task", "tool"]),
4896
+ z5.null()
3931
4897
  ]);
3932
- var SpanAttributes = z.union([
3933
- z.object({ name: z.union([z.string(), z.null()]), type: SpanType }).partial().passthrough(),
3934
- z.null()
4898
+ var SpanAttributes = z5.union([
4899
+ z5.object({ name: z5.union([z5.string(), z5.null()]), type: SpanType }).partial().passthrough(),
4900
+ z5.null()
3935
4901
  ]);
3936
- var ExperimentEvent = z.object({
3937
- id: z.string(),
3938
- _xact_id: z.string(),
3939
- created: z.string().datetime({ offset: true }),
3940
- _pagination_key: z.union([z.string(), z.null()]).optional(),
3941
- project_id: z.string().uuid(),
3942
- experiment_id: z.string().uuid(),
3943
- input: z.unknown().optional(),
3944
- output: z.unknown().optional(),
3945
- expected: z.unknown().optional(),
3946
- error: z.unknown().optional(),
3947
- scores: z.union([z.record(z.union([z.number(), z.null()])), z.null()]).optional(),
3948
- metadata: z.union([
3949
- z.object({ model: z.union([z.string(), z.null()]) }).partial().passthrough(),
3950
- z.null()
4902
+ var ExperimentEvent = z5.object({
4903
+ id: z5.string(),
4904
+ _xact_id: z5.string(),
4905
+ created: z5.string().datetime({ offset: true }),
4906
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
4907
+ project_id: z5.string().uuid(),
4908
+ experiment_id: z5.string().uuid(),
4909
+ input: z5.unknown().optional(),
4910
+ output: z5.unknown().optional(),
4911
+ expected: z5.unknown().optional(),
4912
+ error: z5.unknown().optional(),
4913
+ scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
4914
+ metadata: z5.union([
4915
+ z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
4916
+ z5.null()
3951
4917
  ]).optional(),
3952
- tags: z.union([z.array(z.string()), z.null()]).optional(),
3953
- metrics: z.union([z.record(z.number()), z.null()]).optional(),
3954
- context: z.union([
3955
- z.object({
3956
- caller_functionname: z.union([z.string(), z.null()]),
3957
- caller_filename: z.union([z.string(), z.null()]),
3958
- caller_lineno: z.union([z.number(), z.null()])
4918
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
4919
+ metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
4920
+ context: z5.union([
4921
+ z5.object({
4922
+ caller_functionname: z5.union([z5.string(), z5.null()]),
4923
+ caller_filename: z5.union([z5.string(), z5.null()]),
4924
+ caller_lineno: z5.union([z5.number(), z5.null()])
3959
4925
  }).partial().passthrough(),
3960
- z.null()
4926
+ z5.null()
3961
4927
  ]).optional(),
3962
- span_id: z.string(),
3963
- span_parents: z.union([z.array(z.string()), z.null()]).optional(),
3964
- root_span_id: z.string(),
4928
+ span_id: z5.string(),
4929
+ span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
4930
+ root_span_id: z5.string(),
3965
4931
  span_attributes: SpanAttributes.optional(),
3966
- is_root: z.union([z.boolean(), z.null()]).optional(),
4932
+ is_root: z5.union([z5.boolean(), z5.null()]).optional(),
3967
4933
  origin: ObjectReferenceNullish.optional()
3968
4934
  });
3969
- var ExtendedSavedFunctionId = z.union([
3970
- z.object({ type: z.literal("function"), id: z.string() }),
3971
- z.object({ type: z.literal("global"), name: z.string() }),
3972
- z.object({
3973
- type: z.literal("slug"),
3974
- project_id: z.string(),
3975
- slug: z.string()
4935
+ var ExtendedSavedFunctionId = z5.union([
4936
+ z5.object({ type: z5.literal("function"), id: z5.string() }),
4937
+ z5.object({ type: z5.literal("global"), name: z5.string() }),
4938
+ z5.object({
4939
+ type: z5.literal("slug"),
4940
+ project_id: z5.string(),
4941
+ slug: z5.string()
3976
4942
  })
3977
4943
  ]);
3978
- var PromptBlockDataNullish = z.union([
3979
- z.object({ type: z.literal("completion"), content: z.string() }),
3980
- z.object({
3981
- type: z.literal("chat"),
3982
- messages: z.array(ChatCompletionMessageParam),
3983
- tools: z.string().optional()
4944
+ var PromptBlockDataNullish = z5.union([
4945
+ z5.object({ type: z5.literal("completion"), content: z5.string() }),
4946
+ z5.object({
4947
+ type: z5.literal("chat"),
4948
+ messages: z5.array(ChatCompletionMessageParam),
4949
+ tools: z5.string().optional()
3984
4950
  }),
3985
- z.null()
4951
+ z5.null()
3986
4952
  ]);
3987
- var ModelParams = z.union([
3988
- z.object({
3989
- use_cache: z.boolean(),
3990
- temperature: z.number(),
3991
- top_p: z.number(),
3992
- max_tokens: z.number(),
3993
- max_completion_tokens: z.number(),
3994
- frequency_penalty: z.number(),
3995
- presence_penalty: z.number(),
4953
+ var ModelParams = z5.union([
4954
+ z5.object({
4955
+ use_cache: z5.boolean(),
4956
+ temperature: z5.number(),
4957
+ top_p: z5.number(),
4958
+ max_tokens: z5.number(),
4959
+ max_completion_tokens: z5.number(),
4960
+ frequency_penalty: z5.number(),
4961
+ presence_penalty: z5.number(),
3996
4962
  response_format: ResponseFormatNullish,
3997
- tool_choice: z.union([
3998
- z.literal("auto"),
3999
- z.literal("none"),
4000
- z.literal("required"),
4001
- z.object({
4002
- type: z.literal("function"),
4003
- function: z.object({ name: z.string() })
4963
+ tool_choice: z5.union([
4964
+ z5.literal("auto"),
4965
+ z5.literal("none"),
4966
+ z5.literal("required"),
4967
+ z5.object({
4968
+ type: z5.literal("function"),
4969
+ function: z5.object({ name: z5.string() })
4004
4970
  })
4005
4971
  ]),
4006
- function_call: z.union([
4007
- z.literal("auto"),
4008
- z.literal("none"),
4009
- z.object({ name: z.string() })
4972
+ function_call: z5.union([
4973
+ z5.literal("auto"),
4974
+ z5.literal("none"),
4975
+ z5.object({ name: z5.string() })
4010
4976
  ]),
4011
- n: z.number(),
4012
- stop: z.array(z.string()),
4013
- reasoning_effort: z.enum(["minimal", "low", "medium", "high"]),
4014
- verbosity: z.enum(["low", "medium", "high"])
4977
+ n: z5.number(),
4978
+ stop: z5.array(z5.string()),
4979
+ reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]),
4980
+ verbosity: z5.enum(["low", "medium", "high"])
4015
4981
  }).partial().passthrough(),
4016
- z.object({
4017
- use_cache: z.boolean().optional(),
4018
- max_tokens: z.number(),
4019
- temperature: z.number(),
4020
- top_p: z.number().optional(),
4021
- top_k: z.number().optional(),
4022
- stop_sequences: z.array(z.string()).optional(),
4023
- max_tokens_to_sample: z.number().optional()
4982
+ z5.object({
4983
+ use_cache: z5.boolean().optional(),
4984
+ max_tokens: z5.number(),
4985
+ temperature: z5.number(),
4986
+ top_p: z5.number().optional(),
4987
+ top_k: z5.number().optional(),
4988
+ stop_sequences: z5.array(z5.string()).optional(),
4989
+ max_tokens_to_sample: z5.number().optional()
4024
4990
  }).passthrough(),
4025
- z.object({
4026
- use_cache: z.boolean(),
4027
- temperature: z.number(),
4028
- maxOutputTokens: z.number(),
4029
- topP: z.number(),
4030
- topK: z.number()
4991
+ z5.object({
4992
+ use_cache: z5.boolean(),
4993
+ temperature: z5.number(),
4994
+ maxOutputTokens: z5.number(),
4995
+ topP: z5.number(),
4996
+ topK: z5.number()
4031
4997
  }).partial().passthrough(),
4032
- z.object({
4033
- use_cache: z.boolean(),
4034
- temperature: z.number(),
4035
- topK: z.number()
4998
+ z5.object({
4999
+ use_cache: z5.boolean(),
5000
+ temperature: z5.number(),
5001
+ topK: z5.number()
4036
5002
  }).partial().passthrough(),
4037
- z.object({ use_cache: z.boolean() }).partial().passthrough()
5003
+ z5.object({ use_cache: z5.boolean() }).partial().passthrough()
4038
5004
  ]);
4039
- var PromptOptionsNullish = z.union([
4040
- z.object({ model: z.string(), params: ModelParams, position: z.string() }).partial(),
4041
- z.null()
5005
+ var PromptOptionsNullish = z5.union([
5006
+ z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial(),
5007
+ z5.null()
4042
5008
  ]);
4043
- var PromptParserNullish = z.union([
4044
- z.object({
4045
- type: z.literal("llm_classifier"),
4046
- use_cot: z.boolean(),
4047
- choice_scores: z.record(z.number().gte(0).lte(1))
5009
+ var PromptParserNullish = z5.union([
5010
+ z5.object({
5011
+ type: z5.literal("llm_classifier"),
5012
+ use_cot: z5.boolean(),
5013
+ choice_scores: z5.record(z5.number().gte(0).lte(1))
4048
5014
  }),
4049
- z.null()
5015
+ z5.null()
4050
5016
  ]);
4051
- var SavedFunctionId = z.union([
4052
- z.object({ type: z.literal("function"), id: z.string() }),
4053
- z.object({ type: z.literal("global"), name: z.string() })
5017
+ var SavedFunctionId = z5.union([
5018
+ z5.object({ type: z5.literal("function"), id: z5.string() }),
5019
+ z5.object({ type: z5.literal("global"), name: z5.string() })
4054
5020
  ]);
4055
- var PromptDataNullish = z.union([
4056
- z.object({
5021
+ var PromptDataNullish = z5.union([
5022
+ z5.object({
4057
5023
  prompt: PromptBlockDataNullish,
4058
5024
  options: PromptOptionsNullish,
4059
5025
  parser: PromptParserNullish,
4060
- tool_functions: z.union([z.array(SavedFunctionId), z.null()]),
4061
- origin: z.union([
4062
- z.object({
4063
- prompt_id: z.string(),
4064
- project_id: z.string(),
4065
- prompt_version: z.string()
5026
+ tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
5027
+ origin: z5.union([
5028
+ z5.object({
5029
+ prompt_id: z5.string(),
5030
+ project_id: z5.string(),
5031
+ prompt_version: z5.string()
4066
5032
  }).partial(),
4067
- z.null()
5033
+ z5.null()
4068
5034
  ])
4069
5035
  }).partial(),
4070
- z.null()
5036
+ z5.null()
4071
5037
  ]);
4072
- var FunctionTypeEnumNullish = z.union([
4073
- z.enum(["llm", "scorer", "task", "tool"]),
4074
- z.null()
5038
+ var FunctionTypeEnumNullish = z5.union([
5039
+ z5.enum(["llm", "scorer", "task", "tool"]),
5040
+ z5.null()
4075
5041
  ]);
4076
- var FunctionIdRef = z.object({}).partial().passthrough();
4077
- var PromptBlockData = z.union([
4078
- z.object({ type: z.literal("completion"), content: z.string() }),
4079
- z.object({
4080
- type: z.literal("chat"),
4081
- messages: z.array(ChatCompletionMessageParam),
4082
- tools: z.string().optional()
5042
+ var FunctionIdRef = z5.object({}).partial().passthrough();
5043
+ var PromptBlockData = z5.union([
5044
+ z5.object({ type: z5.literal("completion"), content: z5.string() }),
5045
+ z5.object({
5046
+ type: z5.literal("chat"),
5047
+ messages: z5.array(ChatCompletionMessageParam),
5048
+ tools: z5.string().optional()
4083
5049
  })
4084
5050
  ]);
4085
- var GraphNode = z.union([
4086
- z.object({
4087
- description: z.union([z.string(), z.null()]).optional(),
4088
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4089
- type: z.literal("function"),
5051
+ var GraphNode = z5.union([
5052
+ z5.object({
5053
+ description: z5.union([z5.string(), z5.null()]).optional(),
5054
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5055
+ type: z5.literal("function"),
4090
5056
  function: FunctionIdRef
4091
5057
  }),
4092
- z.object({
4093
- description: z.union([z.string(), z.null()]).optional(),
4094
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4095
- type: z.literal("input")
5058
+ z5.object({
5059
+ description: z5.union([z5.string(), z5.null()]).optional(),
5060
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5061
+ type: z5.literal("input")
4096
5062
  }),
4097
- z.object({
4098
- description: z.union([z.string(), z.null()]).optional(),
4099
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4100
- type: z.literal("output")
5063
+ z5.object({
5064
+ description: z5.union([z5.string(), z5.null()]).optional(),
5065
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5066
+ type: z5.literal("output")
4101
5067
  }),
4102
- z.object({
4103
- description: z.union([z.string(), z.null()]).optional(),
4104
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4105
- type: z.literal("literal"),
4106
- value: z.unknown().optional()
5068
+ z5.object({
5069
+ description: z5.union([z5.string(), z5.null()]).optional(),
5070
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5071
+ type: z5.literal("literal"),
5072
+ value: z5.unknown().optional()
4107
5073
  }),
4108
- z.object({
4109
- description: z.union([z.string(), z.null()]).optional(),
4110
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4111
- type: z.literal("btql"),
4112
- expr: z.string()
5074
+ z5.object({
5075
+ description: z5.union([z5.string(), z5.null()]).optional(),
5076
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5077
+ type: z5.literal("btql"),
5078
+ expr: z5.string()
4113
5079
  }),
4114
- z.object({
4115
- description: z.union([z.string(), z.null()]).optional(),
4116
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4117
- type: z.literal("gate"),
4118
- condition: z.union([z.string(), z.null()]).optional()
5080
+ z5.object({
5081
+ description: z5.union([z5.string(), z5.null()]).optional(),
5082
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5083
+ type: z5.literal("gate"),
5084
+ condition: z5.union([z5.string(), z5.null()]).optional()
4119
5085
  }),
4120
- z.object({
4121
- description: z.union([z.string(), z.null()]).optional(),
4122
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4123
- type: z.literal("aggregator")
5086
+ z5.object({
5087
+ description: z5.union([z5.string(), z5.null()]).optional(),
5088
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5089
+ type: z5.literal("aggregator")
4124
5090
  }),
4125
- z.object({
4126
- description: z.union([z.string(), z.null()]).optional(),
4127
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
4128
- type: z.literal("prompt_template"),
5091
+ z5.object({
5092
+ description: z5.union([z5.string(), z5.null()]).optional(),
5093
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5094
+ type: z5.literal("prompt_template"),
4129
5095
  prompt: PromptBlockData
4130
5096
  })
4131
5097
  ]);
4132
- var GraphEdge = z.object({
4133
- source: z.object({ node: z.string().max(1024), variable: z.string() }),
4134
- target: z.object({ node: z.string().max(1024), variable: z.string() }),
4135
- purpose: z.enum(["control", "data", "messages"])
4136
- });
4137
- var GraphData = z.object({
4138
- type: z.literal("graph"),
4139
- nodes: z.record(GraphNode),
4140
- edges: z.record(GraphEdge)
4141
- });
4142
- var FunctionData = z.union([
4143
- z.object({ type: z.literal("prompt") }),
4144
- z.object({
4145
- type: z.literal("code"),
4146
- data: z.union([
4147
- z.object({ type: z.literal("bundle") }).and(CodeBundle),
4148
- z.object({
4149
- type: z.literal("inline"),
4150
- runtime_context: z.object({
4151
- runtime: z.enum(["node", "python"]),
4152
- version: z.string()
5098
+ var GraphEdge = z5.object({
5099
+ source: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
5100
+ target: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
5101
+ purpose: z5.enum(["control", "data", "messages"])
5102
+ });
5103
+ var GraphData = z5.object({
5104
+ type: z5.literal("graph"),
5105
+ nodes: z5.record(GraphNode),
5106
+ edges: z5.record(GraphEdge)
5107
+ });
5108
+ var FunctionData = z5.union([
5109
+ z5.object({ type: z5.literal("prompt") }),
5110
+ z5.object({
5111
+ type: z5.literal("code"),
5112
+ data: z5.union([
5113
+ z5.object({ type: z5.literal("bundle") }).and(CodeBundle),
5114
+ z5.object({
5115
+ type: z5.literal("inline"),
5116
+ runtime_context: z5.object({
5117
+ runtime: z5.enum(["node", "python"]),
5118
+ version: z5.string()
4153
5119
  }),
4154
- code: z.string()
5120
+ code: z5.string()
4155
5121
  })
4156
5122
  ])
4157
5123
  }),
4158
5124
  GraphData,
4159
- z.object({
4160
- type: z.literal("remote_eval"),
4161
- endpoint: z.string(),
4162
- eval_name: z.string(),
4163
- parameters: z.object({}).partial().passthrough()
5125
+ z5.object({
5126
+ type: z5.literal("remote_eval"),
5127
+ endpoint: z5.string(),
5128
+ eval_name: z5.string(),
5129
+ parameters: z5.object({}).partial().passthrough()
4164
5130
  }),
4165
- z.object({ type: z.literal("global"), name: z.string() })
5131
+ z5.object({ type: z5.literal("global"), name: z5.string() })
4166
5132
  ]);
4167
- var Function2 = z.object({
4168
- id: z.string().uuid(),
4169
- _xact_id: z.string(),
4170
- project_id: z.string().uuid(),
4171
- log_id: z.literal("p"),
4172
- org_id: z.string().uuid(),
4173
- name: z.string(),
4174
- slug: z.string(),
4175
- description: z.union([z.string(), z.null()]).optional(),
4176
- created: z.union([z.string(), z.null()]).optional(),
5133
+ var Function2 = z5.object({
5134
+ id: z5.string().uuid(),
5135
+ _xact_id: z5.string(),
5136
+ project_id: z5.string().uuid(),
5137
+ log_id: z5.literal("p"),
5138
+ org_id: z5.string().uuid(),
5139
+ name: z5.string(),
5140
+ slug: z5.string(),
5141
+ description: z5.union([z5.string(), z5.null()]).optional(),
5142
+ created: z5.union([z5.string(), z5.null()]).optional(),
4177
5143
  prompt_data: PromptDataNullish.optional(),
4178
- tags: z.union([z.array(z.string()), z.null()]).optional(),
4179
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
5144
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5145
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
4180
5146
  function_type: FunctionTypeEnumNullish.optional(),
4181
5147
  function_data: FunctionData,
4182
- origin: z.union([
4183
- z.object({
4184
- object_type: AclObjectType.and(z.string()),
4185
- object_id: z.string().uuid(),
4186
- internal: z.union([z.boolean(), z.null()]).optional()
5148
+ origin: z5.union([
5149
+ z5.object({
5150
+ object_type: AclObjectType.and(z5.string()),
5151
+ object_id: z5.string().uuid(),
5152
+ internal: z5.union([z5.boolean(), z5.null()]).optional()
4187
5153
  }),
4188
- z.null()
5154
+ z5.null()
4189
5155
  ]).optional(),
4190
- function_schema: z.union([
4191
- z.object({ parameters: z.unknown(), returns: z.unknown() }).partial(),
4192
- z.null()
5156
+ function_schema: z5.union([
5157
+ z5.object({ parameters: z5.unknown(), returns: z5.unknown() }).partial(),
5158
+ z5.null()
4193
5159
  ]).optional()
4194
5160
  });
4195
- var FunctionFormat = z.enum(["llm", "code", "global", "graph"]);
4196
- var PromptData = z.object({
5161
+ var FunctionFormat = z5.enum(["llm", "code", "global", "graph"]);
5162
+ var PromptData = z5.object({
4197
5163
  prompt: PromptBlockDataNullish,
4198
5164
  options: PromptOptionsNullish,
4199
5165
  parser: PromptParserNullish,
4200
- tool_functions: z.union([z.array(SavedFunctionId), z.null()]),
4201
- origin: z.union([
4202
- z.object({
4203
- prompt_id: z.string(),
4204
- project_id: z.string(),
4205
- prompt_version: z.string()
5166
+ tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
5167
+ origin: z5.union([
5168
+ z5.object({
5169
+ prompt_id: z5.string(),
5170
+ project_id: z5.string(),
5171
+ prompt_version: z5.string()
4206
5172
  }).partial(),
4207
- z.null()
5173
+ z5.null()
4208
5174
  ])
4209
5175
  }).partial();
4210
- var FunctionTypeEnum = z.enum(["llm", "scorer", "task", "tool"]);
4211
- var FunctionId = z.union([
4212
- z.object({ function_id: z.string(), version: z.string().optional() }),
4213
- z.object({
4214
- project_name: z.string(),
4215
- slug: z.string(),
4216
- version: z.string().optional()
5176
+ var FunctionTypeEnum = z5.enum(["llm", "scorer", "task", "tool"]);
5177
+ var FunctionId = z5.union([
5178
+ z5.object({ function_id: z5.string(), version: z5.string().optional() }),
5179
+ z5.object({
5180
+ project_name: z5.string(),
5181
+ slug: z5.string(),
5182
+ version: z5.string().optional()
4217
5183
  }),
4218
- z.object({ global_function: z.string() }),
4219
- z.object({
4220
- prompt_session_id: z.string(),
4221
- prompt_session_function_id: z.string(),
4222
- version: z.string().optional()
5184
+ z5.object({ global_function: z5.string() }),
5185
+ z5.object({
5186
+ prompt_session_id: z5.string(),
5187
+ prompt_session_function_id: z5.string(),
5188
+ version: z5.string().optional()
4223
5189
  }),
4224
- z.object({
4225
- inline_context: z.object({
4226
- runtime: z.enum(["node", "python"]),
4227
- version: z.string()
5190
+ z5.object({
5191
+ inline_context: z5.object({
5192
+ runtime: z5.enum(["node", "python"]),
5193
+ version: z5.string()
4228
5194
  }),
4229
- code: z.string(),
4230
- name: z.union([z.string(), z.null()]).optional()
5195
+ code: z5.string(),
5196
+ name: z5.union([z5.string(), z5.null()]).optional()
4231
5197
  }),
4232
- z.object({
5198
+ z5.object({
4233
5199
  inline_prompt: PromptData.optional(),
4234
- inline_function: z.object({}).partial().passthrough(),
5200
+ inline_function: z5.object({}).partial().passthrough(),
4235
5201
  function_type: FunctionTypeEnum.optional(),
4236
- name: z.union([z.string(), z.null()]).optional()
5202
+ name: z5.union([z5.string(), z5.null()]).optional()
4237
5203
  }),
4238
- z.object({
5204
+ z5.object({
4239
5205
  inline_prompt: PromptData,
4240
5206
  function_type: FunctionTypeEnum.optional(),
4241
- name: z.union([z.string(), z.null()]).optional()
5207
+ name: z5.union([z5.string(), z5.null()]).optional()
4242
5208
  })
4243
5209
  ]);
4244
- var FunctionObjectType = z.enum([
5210
+ var FunctionObjectType = z5.enum([
4245
5211
  "prompt",
4246
5212
  "tool",
4247
5213
  "scorer",
4248
5214
  "task",
4249
5215
  "agent"
4250
5216
  ]);
4251
- var FunctionOutputType = z.enum(["completion", "score", "any"]);
4252
- var GitMetadataSettings = z.object({
4253
- collect: z.enum(["all", "none", "some"]),
4254
- fields: z.array(
4255
- z.enum([
5217
+ var FunctionOutputType = z5.enum(["completion", "score", "any"]);
5218
+ var GitMetadataSettings = z5.object({
5219
+ collect: z5.enum(["all", "none", "some"]),
5220
+ fields: z5.array(
5221
+ z5.enum([
4256
5222
  "commit",
4257
5223
  "branch",
4258
5224
  "tag",
@@ -4265,49 +5231,49 @@ var GitMetadataSettings = z.object({
4265
5231
  ])
4266
5232
  ).optional()
4267
5233
  });
4268
- var Group = z.object({
4269
- id: z.string().uuid(),
4270
- org_id: z.string().uuid(),
4271
- user_id: z.union([z.string(), z.null()]).optional(),
4272
- created: z.union([z.string(), z.null()]).optional(),
4273
- name: z.string(),
4274
- description: z.union([z.string(), z.null()]).optional(),
4275
- deleted_at: z.union([z.string(), z.null()]).optional(),
4276
- member_users: z.union([z.array(z.string().uuid()), z.null()]).optional(),
4277
- member_groups: z.union([z.array(z.string().uuid()), z.null()]).optional()
4278
- });
4279
- var IfExists = z.enum(["error", "ignore", "replace"]);
4280
- var InvokeParent = z.union([
4281
- z.object({
4282
- object_type: z.enum(["project_logs", "experiment", "playground_logs"]),
4283
- object_id: z.string(),
4284
- row_ids: z.union([
4285
- z.object({
4286
- id: z.string(),
4287
- span_id: z.string(),
4288
- root_span_id: z.string()
5234
+ var Group = z5.object({
5235
+ id: z5.string().uuid(),
5236
+ org_id: z5.string().uuid(),
5237
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
5238
+ created: z5.union([z5.string(), z5.null()]).optional(),
5239
+ name: z5.string(),
5240
+ description: z5.union([z5.string(), z5.null()]).optional(),
5241
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5242
+ member_users: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional(),
5243
+ member_groups: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
5244
+ });
5245
+ var IfExists = z5.enum(["error", "ignore", "replace"]);
5246
+ var InvokeParent = z5.union([
5247
+ z5.object({
5248
+ object_type: z5.enum(["project_logs", "experiment", "playground_logs"]),
5249
+ object_id: z5.string(),
5250
+ row_ids: z5.union([
5251
+ z5.object({
5252
+ id: z5.string(),
5253
+ span_id: z5.string(),
5254
+ root_span_id: z5.string()
4289
5255
  }),
4290
- z.null()
5256
+ z5.null()
4291
5257
  ]).optional(),
4292
- propagated_event: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
5258
+ propagated_event: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
4293
5259
  }),
4294
- z.string()
5260
+ z5.string()
4295
5261
  ]);
4296
- var StreamingMode = z.union([z.enum(["auto", "parallel"]), z.null()]);
5262
+ var StreamingMode = z5.union([z5.enum(["auto", "parallel"]), z5.null()]);
4297
5263
  var InvokeFunction = FunctionId.and(
4298
- z.object({
4299
- input: z.unknown(),
4300
- expected: z.unknown(),
4301
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]),
4302
- tags: z.union([z.array(z.string()), z.null()]),
4303
- messages: z.array(ChatCompletionMessageParam),
5264
+ z5.object({
5265
+ input: z5.unknown(),
5266
+ expected: z5.unknown(),
5267
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]),
5268
+ tags: z5.union([z5.array(z5.string()), z5.null()]),
5269
+ messages: z5.array(ChatCompletionMessageParam),
4304
5270
  parent: InvokeParent,
4305
- stream: z.union([z.boolean(), z.null()]),
5271
+ stream: z5.union([z5.boolean(), z5.null()]),
4306
5272
  mode: StreamingMode,
4307
- strict: z.union([z.boolean(), z.null()])
5273
+ strict: z5.union([z5.boolean(), z5.null()])
4308
5274
  }).partial()
4309
5275
  );
4310
- var MessageRole = z.enum([
5276
+ var MessageRole = z5.enum([
4311
5277
  "system",
4312
5278
  "user",
4313
5279
  "assistant",
@@ -4316,8 +5282,8 @@ var MessageRole = z.enum([
4316
5282
  "model",
4317
5283
  "developer"
4318
5284
  ]);
4319
- var ObjectReference = z.object({
4320
- object_type: z.enum([
5285
+ var ObjectReference = z5.object({
5286
+ object_type: z5.enum([
4321
5287
  "project_logs",
4322
5288
  "experiment",
4323
5289
  "dataset",
@@ -4325,146 +5291,146 @@ var ObjectReference = z.object({
4325
5291
  "function",
4326
5292
  "prompt_session"
4327
5293
  ]),
4328
- object_id: z.string().uuid(),
4329
- id: z.string(),
4330
- _xact_id: z.union([z.string(), z.null()]).optional(),
4331
- created: z.union([z.string(), z.null()]).optional()
4332
- });
4333
- var OnlineScoreConfig = z.union([
4334
- z.object({
4335
- sampling_rate: z.number().gte(0).lte(1),
4336
- scorers: z.array(SavedFunctionId),
4337
- btql_filter: z.union([z.string(), z.null()]).optional(),
4338
- apply_to_root_span: z.union([z.boolean(), z.null()]).optional(),
4339
- apply_to_span_names: z.union([z.array(z.string()), z.null()]).optional(),
4340
- skip_logging: z.union([z.boolean(), z.null()]).optional()
5294
+ object_id: z5.string().uuid(),
5295
+ id: z5.string(),
5296
+ _xact_id: z5.union([z5.string(), z5.null()]).optional(),
5297
+ created: z5.union([z5.string(), z5.null()]).optional()
5298
+ });
5299
+ var OnlineScoreConfig = z5.union([
5300
+ z5.object({
5301
+ sampling_rate: z5.number().gte(0).lte(1),
5302
+ scorers: z5.array(SavedFunctionId),
5303
+ btql_filter: z5.union([z5.string(), z5.null()]).optional(),
5304
+ apply_to_root_span: z5.union([z5.boolean(), z5.null()]).optional(),
5305
+ apply_to_span_names: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5306
+ skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
4341
5307
  }),
4342
- z.null()
5308
+ z5.null()
4343
5309
  ]);
4344
- var Organization = z.object({
4345
- id: z.string().uuid(),
4346
- name: z.string(),
4347
- api_url: z.union([z.string(), z.null()]).optional(),
4348
- is_universal_api: z.union([z.boolean(), z.null()]).optional(),
4349
- proxy_url: z.union([z.string(), z.null()]).optional(),
4350
- realtime_url: z.union([z.string(), z.null()]).optional(),
4351
- created: z.union([z.string(), z.null()]).optional()
4352
- });
4353
- var ProjectSettings = z.union([
4354
- z.object({
4355
- comparison_key: z.union([z.string(), z.null()]),
4356
- baseline_experiment_id: z.union([z.string(), z.null()]),
4357
- spanFieldOrder: z.union([
4358
- z.array(
4359
- z.object({
4360
- object_type: z.string(),
4361
- column_id: z.string(),
4362
- position: z.string(),
4363
- layout: z.union([z.literal("full"), z.literal("two_column"), z.null()]).optional()
5310
+ var Organization = z5.object({
5311
+ id: z5.string().uuid(),
5312
+ name: z5.string(),
5313
+ api_url: z5.union([z5.string(), z5.null()]).optional(),
5314
+ is_universal_api: z5.union([z5.boolean(), z5.null()]).optional(),
5315
+ proxy_url: z5.union([z5.string(), z5.null()]).optional(),
5316
+ realtime_url: z5.union([z5.string(), z5.null()]).optional(),
5317
+ created: z5.union([z5.string(), z5.null()]).optional()
5318
+ });
5319
+ var ProjectSettings = z5.union([
5320
+ z5.object({
5321
+ comparison_key: z5.union([z5.string(), z5.null()]),
5322
+ baseline_experiment_id: z5.union([z5.string(), z5.null()]),
5323
+ spanFieldOrder: z5.union([
5324
+ z5.array(
5325
+ z5.object({
5326
+ object_type: z5.string(),
5327
+ column_id: z5.string(),
5328
+ position: z5.string(),
5329
+ layout: z5.union([z5.literal("full"), z5.literal("two_column"), z5.null()]).optional()
4364
5330
  })
4365
5331
  ),
4366
- z.null()
5332
+ z5.null()
4367
5333
  ]),
4368
- remote_eval_sources: z.union([
4369
- z.array(
4370
- z.object({
4371
- url: z.string(),
4372
- name: z.string(),
4373
- description: z.union([z.string(), z.null()]).optional()
5334
+ remote_eval_sources: z5.union([
5335
+ z5.array(
5336
+ z5.object({
5337
+ url: z5.string(),
5338
+ name: z5.string(),
5339
+ description: z5.union([z5.string(), z5.null()]).optional()
4374
5340
  })
4375
5341
  ),
4376
- z.null()
5342
+ z5.null()
4377
5343
  ])
4378
5344
  }).partial(),
4379
- z.null()
5345
+ z5.null()
4380
5346
  ]);
4381
- var Project = z.object({
4382
- id: z.string().uuid(),
4383
- org_id: z.string().uuid(),
4384
- name: z.string(),
4385
- created: z.union([z.string(), z.null()]).optional(),
4386
- deleted_at: z.union([z.string(), z.null()]).optional(),
4387
- user_id: z.union([z.string(), z.null()]).optional(),
5347
+ var Project = z5.object({
5348
+ id: z5.string().uuid(),
5349
+ org_id: z5.string().uuid(),
5350
+ name: z5.string(),
5351
+ created: z5.union([z5.string(), z5.null()]).optional(),
5352
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5353
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
4388
5354
  settings: ProjectSettings.optional()
4389
5355
  });
4390
- var RetentionObjectType = z.enum([
5356
+ var RetentionObjectType = z5.enum([
4391
5357
  "project_logs",
4392
5358
  "experiment",
4393
5359
  "dataset"
4394
5360
  ]);
4395
- var ProjectAutomation = z.object({
4396
- id: z.string().uuid(),
4397
- project_id: z.string().uuid(),
4398
- user_id: z.union([z.string(), z.null()]).optional(),
4399
- created: z.union([z.string(), z.null()]).optional(),
4400
- name: z.string(),
4401
- description: z.union([z.string(), z.null()]).optional(),
4402
- config: z.union([
4403
- z.object({
4404
- event_type: z.literal("logs"),
4405
- btql_filter: z.string(),
4406
- interval_seconds: z.number().gte(1).lte(2592e3),
4407
- action: z.object({ type: z.literal("webhook"), url: z.string() })
5361
+ var ProjectAutomation = z5.object({
5362
+ id: z5.string().uuid(),
5363
+ project_id: z5.string().uuid(),
5364
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
5365
+ created: z5.union([z5.string(), z5.null()]).optional(),
5366
+ name: z5.string(),
5367
+ description: z5.union([z5.string(), z5.null()]).optional(),
5368
+ config: z5.union([
5369
+ z5.object({
5370
+ event_type: z5.literal("logs"),
5371
+ btql_filter: z5.string(),
5372
+ interval_seconds: z5.number().gte(1).lte(2592e3),
5373
+ action: z5.object({ type: z5.literal("webhook"), url: z5.string() })
4408
5374
  }),
4409
- z.object({
4410
- event_type: z.literal("btql_export"),
4411
- export_definition: z.union([
4412
- z.object({ type: z.literal("log_traces") }),
4413
- z.object({ type: z.literal("log_spans") }),
4414
- z.object({ type: z.literal("btql_query"), btql_query: z.string() })
5375
+ z5.object({
5376
+ event_type: z5.literal("btql_export"),
5377
+ export_definition: z5.union([
5378
+ z5.object({ type: z5.literal("log_traces") }),
5379
+ z5.object({ type: z5.literal("log_spans") }),
5380
+ z5.object({ type: z5.literal("btql_query"), btql_query: z5.string() })
4415
5381
  ]),
4416
- export_path: z.string(),
4417
- format: z.enum(["jsonl", "parquet"]),
4418
- interval_seconds: z.number().gte(1).lte(2592e3),
4419
- credentials: z.object({
4420
- type: z.literal("aws_iam"),
4421
- role_arn: z.string(),
4422
- external_id: z.string()
5382
+ export_path: z5.string(),
5383
+ format: z5.enum(["jsonl", "parquet"]),
5384
+ interval_seconds: z5.number().gte(1).lte(2592e3),
5385
+ credentials: z5.object({
5386
+ type: z5.literal("aws_iam"),
5387
+ role_arn: z5.string(),
5388
+ external_id: z5.string()
4423
5389
  }),
4424
- batch_size: z.union([z.number(), z.null()]).optional()
5390
+ batch_size: z5.union([z5.number(), z5.null()]).optional()
4425
5391
  }),
4426
- z.object({
4427
- event_type: z.literal("retention"),
5392
+ z5.object({
5393
+ event_type: z5.literal("retention"),
4428
5394
  object_type: RetentionObjectType,
4429
- retention_days: z.number().gte(0)
5395
+ retention_days: z5.number().gte(0)
4430
5396
  })
4431
5397
  ])
4432
5398
  });
4433
- var ProjectLogsEvent = z.object({
4434
- id: z.string(),
4435
- _xact_id: z.string(),
4436
- _pagination_key: z.union([z.string(), z.null()]).optional(),
4437
- created: z.string().datetime({ offset: true }),
4438
- org_id: z.string().uuid(),
4439
- project_id: z.string().uuid(),
4440
- log_id: z.literal("g"),
4441
- input: z.unknown().optional(),
4442
- output: z.unknown().optional(),
4443
- expected: z.unknown().optional(),
4444
- error: z.unknown().optional(),
4445
- scores: z.union([z.record(z.union([z.number(), z.null()])), z.null()]).optional(),
4446
- metadata: z.union([
4447
- z.object({ model: z.union([z.string(), z.null()]) }).partial().passthrough(),
4448
- z.null()
5399
+ var ProjectLogsEvent = z5.object({
5400
+ id: z5.string(),
5401
+ _xact_id: z5.string(),
5402
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
5403
+ created: z5.string().datetime({ offset: true }),
5404
+ org_id: z5.string().uuid(),
5405
+ project_id: z5.string().uuid(),
5406
+ log_id: z5.literal("g"),
5407
+ input: z5.unknown().optional(),
5408
+ output: z5.unknown().optional(),
5409
+ expected: z5.unknown().optional(),
5410
+ error: z5.unknown().optional(),
5411
+ scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
5412
+ metadata: z5.union([
5413
+ z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
5414
+ z5.null()
4449
5415
  ]).optional(),
4450
- tags: z.union([z.array(z.string()), z.null()]).optional(),
4451
- metrics: z.union([z.record(z.number()), z.null()]).optional(),
4452
- context: z.union([
4453
- z.object({
4454
- caller_functionname: z.union([z.string(), z.null()]),
4455
- caller_filename: z.union([z.string(), z.null()]),
4456
- caller_lineno: z.union([z.number(), z.null()])
5416
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5417
+ metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
5418
+ context: z5.union([
5419
+ z5.object({
5420
+ caller_functionname: z5.union([z5.string(), z5.null()]),
5421
+ caller_filename: z5.union([z5.string(), z5.null()]),
5422
+ caller_lineno: z5.union([z5.number(), z5.null()])
4457
5423
  }).partial().passthrough(),
4458
- z.null()
5424
+ z5.null()
4459
5425
  ]).optional(),
4460
- span_id: z.string(),
4461
- span_parents: z.union([z.array(z.string()), z.null()]).optional(),
4462
- root_span_id: z.string(),
4463
- is_root: z.union([z.boolean(), z.null()]).optional(),
5426
+ span_id: z5.string(),
5427
+ span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5428
+ root_span_id: z5.string(),
5429
+ is_root: z5.union([z5.boolean(), z5.null()]).optional(),
4464
5430
  span_attributes: SpanAttributes.optional(),
4465
5431
  origin: ObjectReferenceNullish.optional()
4466
5432
  });
4467
- var ProjectScoreType = z.enum([
5433
+ var ProjectScoreType = z5.enum([
4468
5434
  "slider",
4469
5435
  "categorical",
4470
5436
  "weighted",
@@ -4473,172 +5439,172 @@ var ProjectScoreType = z.enum([
4473
5439
  "online",
4474
5440
  "free-form"
4475
5441
  ]);
4476
- var ProjectScoreCategory = z.object({
4477
- name: z.string(),
4478
- value: z.number()
4479
- });
4480
- var ProjectScoreCategories = z.union([
4481
- z.array(ProjectScoreCategory),
4482
- z.record(z.number()),
4483
- z.array(z.string()),
4484
- z.null()
5442
+ var ProjectScoreCategory = z5.object({
5443
+ name: z5.string(),
5444
+ value: z5.number()
5445
+ });
5446
+ var ProjectScoreCategories = z5.union([
5447
+ z5.array(ProjectScoreCategory),
5448
+ z5.record(z5.number()),
5449
+ z5.array(z5.string()),
5450
+ z5.null()
4485
5451
  ]);
4486
- var ProjectScoreConfig = z.union([
4487
- z.object({
4488
- multi_select: z.union([z.boolean(), z.null()]),
4489
- destination: z.union([z.string(), z.null()]),
5452
+ var ProjectScoreConfig = z5.union([
5453
+ z5.object({
5454
+ multi_select: z5.union([z5.boolean(), z5.null()]),
5455
+ destination: z5.union([z5.string(), z5.null()]),
4490
5456
  online: OnlineScoreConfig
4491
5457
  }).partial(),
4492
- z.null()
5458
+ z5.null()
4493
5459
  ]);
4494
- var ProjectScore = z.object({
4495
- id: z.string().uuid(),
4496
- project_id: z.string().uuid(),
4497
- user_id: z.string().uuid(),
4498
- created: z.union([z.string(), z.null()]).optional(),
4499
- name: z.string(),
4500
- description: z.union([z.string(), z.null()]).optional(),
5460
+ var ProjectScore = z5.object({
5461
+ id: z5.string().uuid(),
5462
+ project_id: z5.string().uuid(),
5463
+ user_id: z5.string().uuid(),
5464
+ created: z5.union([z5.string(), z5.null()]).optional(),
5465
+ name: z5.string(),
5466
+ description: z5.union([z5.string(), z5.null()]).optional(),
4501
5467
  score_type: ProjectScoreType,
4502
5468
  categories: ProjectScoreCategories.optional(),
4503
5469
  config: ProjectScoreConfig.optional(),
4504
- position: z.union([z.string(), z.null()]).optional()
4505
- });
4506
- var ProjectTag = z.object({
4507
- id: z.string().uuid(),
4508
- project_id: z.string().uuid(),
4509
- user_id: z.string().uuid(),
4510
- created: z.union([z.string(), z.null()]).optional(),
4511
- name: z.string(),
4512
- description: z.union([z.string(), z.null()]).optional(),
4513
- color: z.union([z.string(), z.null()]).optional(),
4514
- position: z.union([z.string(), z.null()]).optional()
4515
- });
4516
- var Prompt = z.object({
4517
- id: z.string().uuid(),
4518
- _xact_id: z.string(),
4519
- project_id: z.string().uuid(),
4520
- log_id: z.literal("p"),
4521
- org_id: z.string().uuid(),
4522
- name: z.string(),
4523
- slug: z.string(),
4524
- description: z.union([z.string(), z.null()]).optional(),
4525
- created: z.union([z.string(), z.null()]).optional(),
5470
+ position: z5.union([z5.string(), z5.null()]).optional()
5471
+ });
5472
+ var ProjectTag = z5.object({
5473
+ id: z5.string().uuid(),
5474
+ project_id: z5.string().uuid(),
5475
+ user_id: z5.string().uuid(),
5476
+ created: z5.union([z5.string(), z5.null()]).optional(),
5477
+ name: z5.string(),
5478
+ description: z5.union([z5.string(), z5.null()]).optional(),
5479
+ color: z5.union([z5.string(), z5.null()]).optional(),
5480
+ position: z5.union([z5.string(), z5.null()]).optional()
5481
+ });
5482
+ var Prompt = z5.object({
5483
+ id: z5.string().uuid(),
5484
+ _xact_id: z5.string(),
5485
+ project_id: z5.string().uuid(),
5486
+ log_id: z5.literal("p"),
5487
+ org_id: z5.string().uuid(),
5488
+ name: z5.string(),
5489
+ slug: z5.string(),
5490
+ description: z5.union([z5.string(), z5.null()]).optional(),
5491
+ created: z5.union([z5.string(), z5.null()]).optional(),
4526
5492
  prompt_data: PromptDataNullish.optional(),
4527
- tags: z.union([z.array(z.string()), z.null()]).optional(),
4528
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
5493
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5494
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
4529
5495
  function_type: FunctionTypeEnumNullish.optional()
4530
5496
  });
4531
- var PromptOptions = z.object({ model: z.string(), params: ModelParams, position: z.string() }).partial();
4532
- var PromptSessionEvent = z.object({
4533
- id: z.string(),
4534
- _xact_id: z.string(),
4535
- created: z.string().datetime({ offset: true }),
4536
- _pagination_key: z.union([z.string(), z.null()]).optional(),
4537
- project_id: z.string().uuid(),
4538
- prompt_session_id: z.string().uuid(),
4539
- prompt_session_data: z.unknown().optional(),
4540
- prompt_data: z.unknown().optional(),
4541
- function_data: z.unknown().optional(),
5497
+ var PromptOptions = z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial();
5498
+ var PromptSessionEvent = z5.object({
5499
+ id: z5.string(),
5500
+ _xact_id: z5.string(),
5501
+ created: z5.string().datetime({ offset: true }),
5502
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
5503
+ project_id: z5.string().uuid(),
5504
+ prompt_session_id: z5.string().uuid(),
5505
+ prompt_session_data: z5.unknown().optional(),
5506
+ prompt_data: z5.unknown().optional(),
5507
+ function_data: z5.unknown().optional(),
4542
5508
  function_type: FunctionTypeEnumNullish.optional(),
4543
- object_data: z.unknown().optional(),
4544
- completion: z.unknown().optional(),
4545
- tags: z.union([z.array(z.string()), z.null()]).optional()
4546
- });
4547
- var ResponseFormat = z.union([
4548
- z.object({ type: z.literal("json_object") }),
4549
- z.object({
4550
- type: z.literal("json_schema"),
5509
+ object_data: z5.unknown().optional(),
5510
+ completion: z5.unknown().optional(),
5511
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
5512
+ });
5513
+ var ResponseFormat = z5.union([
5514
+ z5.object({ type: z5.literal("json_object") }),
5515
+ z5.object({
5516
+ type: z5.literal("json_schema"),
4551
5517
  json_schema: ResponseFormatJsonSchema
4552
5518
  }),
4553
- z.object({ type: z.literal("text") })
5519
+ z5.object({ type: z5.literal("text") })
4554
5520
  ]);
4555
- var Role = z.object({
4556
- id: z.string().uuid(),
4557
- org_id: z.union([z.string(), z.null()]).optional(),
4558
- user_id: z.union([z.string(), z.null()]).optional(),
4559
- created: z.union([z.string(), z.null()]).optional(),
4560
- name: z.string(),
4561
- description: z.union([z.string(), z.null()]).optional(),
4562
- deleted_at: z.union([z.string(), z.null()]).optional(),
4563
- member_permissions: z.union([
4564
- z.array(
4565
- z.object({
5521
+ var Role = z5.object({
5522
+ id: z5.string().uuid(),
5523
+ org_id: z5.union([z5.string(), z5.null()]).optional(),
5524
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
5525
+ created: z5.union([z5.string(), z5.null()]).optional(),
5526
+ name: z5.string(),
5527
+ description: z5.union([z5.string(), z5.null()]).optional(),
5528
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5529
+ member_permissions: z5.union([
5530
+ z5.array(
5531
+ z5.object({
4566
5532
  permission: Permission,
4567
5533
  restrict_object_type: AclObjectType.optional()
4568
5534
  })
4569
5535
  ),
4570
- z.null()
5536
+ z5.null()
4571
5537
  ]).optional(),
4572
- member_roles: z.union([z.array(z.string().uuid()), z.null()]).optional()
4573
- });
4574
- var RunEval = z.object({
4575
- project_id: z.string(),
4576
- data: z.union([
4577
- z.object({
4578
- dataset_id: z.string(),
4579
- _internal_btql: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
5538
+ member_roles: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
5539
+ });
5540
+ var RunEval = z5.object({
5541
+ project_id: z5.string(),
5542
+ data: z5.union([
5543
+ z5.object({
5544
+ dataset_id: z5.string(),
5545
+ _internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
4580
5546
  }),
4581
- z.object({
4582
- project_name: z.string(),
4583
- dataset_name: z.string(),
4584
- _internal_btql: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
5547
+ z5.object({
5548
+ project_name: z5.string(),
5549
+ dataset_name: z5.string(),
5550
+ _internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
4585
5551
  }),
4586
- z.object({ data: z.array(z.unknown()) })
5552
+ z5.object({ data: z5.array(z5.unknown()) })
4587
5553
  ]),
4588
- task: FunctionId.and(z.unknown()),
4589
- scores: z.array(FunctionId),
4590
- experiment_name: z.string().optional(),
4591
- metadata: z.object({}).partial().passthrough().optional(),
4592
- parent: InvokeParent.and(z.unknown()).optional(),
4593
- stream: z.boolean().optional(),
4594
- trial_count: z.union([z.number(), z.null()]).optional(),
4595
- is_public: z.union([z.boolean(), z.null()]).optional(),
4596
- timeout: z.union([z.number(), z.null()]).optional(),
4597
- max_concurrency: z.union([z.number(), z.null()]).optional().default(10),
4598
- base_experiment_name: z.union([z.string(), z.null()]).optional(),
4599
- base_experiment_id: z.union([z.string(), z.null()]).optional(),
5554
+ task: FunctionId.and(z5.unknown()),
5555
+ scores: z5.array(FunctionId),
5556
+ experiment_name: z5.string().optional(),
5557
+ metadata: z5.object({}).partial().passthrough().optional(),
5558
+ parent: InvokeParent.and(z5.unknown()).optional(),
5559
+ stream: z5.boolean().optional(),
5560
+ trial_count: z5.union([z5.number(), z5.null()]).optional(),
5561
+ is_public: z5.union([z5.boolean(), z5.null()]).optional(),
5562
+ timeout: z5.union([z5.number(), z5.null()]).optional(),
5563
+ max_concurrency: z5.union([z5.number(), z5.null()]).optional().default(10),
5564
+ base_experiment_name: z5.union([z5.string(), z5.null()]).optional(),
5565
+ base_experiment_id: z5.union([z5.string(), z5.null()]).optional(),
4600
5566
  git_metadata_settings: GitMetadataSettings.and(
4601
- z.union([z.object({}).partial(), z.null()])
5567
+ z5.union([z5.object({}).partial(), z5.null()])
4602
5568
  ).optional(),
4603
- repo_info: RepoInfo.and(z.unknown()).optional(),
4604
- strict: z.union([z.boolean(), z.null()]).optional(),
4605
- stop_token: z.union([z.string(), z.null()]).optional(),
4606
- extra_messages: z.string().optional(),
4607
- tags: z.array(z.string()).optional()
4608
- });
4609
- var ServiceToken = z.object({
4610
- id: z.string().uuid(),
4611
- created: z.union([z.string(), z.null()]).optional(),
4612
- name: z.string(),
4613
- preview_name: z.string(),
4614
- service_account_id: z.union([z.string(), z.null()]).optional(),
4615
- service_account_email: z.union([z.string(), z.null()]).optional(),
4616
- service_account_name: z.union([z.string(), z.null()]).optional(),
4617
- org_id: z.union([z.string(), z.null()]).optional()
4618
- });
4619
- var SpanIFrame = z.object({
4620
- id: z.string().uuid(),
4621
- project_id: z.string().uuid(),
4622
- user_id: z.union([z.string(), z.null()]).optional(),
4623
- created: z.union([z.string(), z.null()]).optional(),
4624
- deleted_at: z.union([z.string(), z.null()]).optional(),
4625
- name: z.string(),
4626
- description: z.union([z.string(), z.null()]).optional(),
4627
- url: z.string(),
4628
- post_message: z.union([z.boolean(), z.null()]).optional()
4629
- });
4630
- var SSEConsoleEventData = z.object({
4631
- stream: z.enum(["stderr", "stdout"]),
4632
- message: z.string()
4633
- });
4634
- var SSEProgressEventData = z.object({
4635
- id: z.string(),
5569
+ repo_info: RepoInfo.and(z5.unknown()).optional(),
5570
+ strict: z5.union([z5.boolean(), z5.null()]).optional(),
5571
+ stop_token: z5.union([z5.string(), z5.null()]).optional(),
5572
+ extra_messages: z5.string().optional(),
5573
+ tags: z5.array(z5.string()).optional()
5574
+ });
5575
+ var ServiceToken = z5.object({
5576
+ id: z5.string().uuid(),
5577
+ created: z5.union([z5.string(), z5.null()]).optional(),
5578
+ name: z5.string(),
5579
+ preview_name: z5.string(),
5580
+ service_account_id: z5.union([z5.string(), z5.null()]).optional(),
5581
+ service_account_email: z5.union([z5.string(), z5.null()]).optional(),
5582
+ service_account_name: z5.union([z5.string(), z5.null()]).optional(),
5583
+ org_id: z5.union([z5.string(), z5.null()]).optional()
5584
+ });
5585
+ var SpanIFrame = z5.object({
5586
+ id: z5.string().uuid(),
5587
+ project_id: z5.string().uuid(),
5588
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
5589
+ created: z5.union([z5.string(), z5.null()]).optional(),
5590
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5591
+ name: z5.string(),
5592
+ description: z5.union([z5.string(), z5.null()]).optional(),
5593
+ url: z5.string(),
5594
+ post_message: z5.union([z5.boolean(), z5.null()]).optional()
5595
+ });
5596
+ var SSEConsoleEventData = z5.object({
5597
+ stream: z5.enum(["stderr", "stdout"]),
5598
+ message: z5.string()
5599
+ });
5600
+ var SSEProgressEventData = z5.object({
5601
+ id: z5.string(),
4636
5602
  object_type: FunctionObjectType,
4637
- origin: ObjectReferenceNullish.and(z.unknown()).optional(),
5603
+ origin: ObjectReferenceNullish.and(z5.unknown()).optional(),
4638
5604
  format: FunctionFormat,
4639
5605
  output_type: FunctionOutputType,
4640
- name: z.string(),
4641
- event: z.enum([
5606
+ name: z5.string(),
5607
+ event: z5.enum([
4642
5608
  "reasoning_delta",
4643
5609
  "text_delta",
4644
5610
  "json_delta",
@@ -4648,110 +5614,110 @@ var SSEProgressEventData = z.object({
4648
5614
  "done",
4649
5615
  "progress"
4650
5616
  ]),
4651
- data: z.string()
4652
- });
4653
- var ToolFunctionDefinition = z.object({
4654
- type: z.literal("function"),
4655
- function: z.object({
4656
- name: z.string(),
4657
- description: z.string().optional(),
4658
- parameters: z.object({}).partial().passthrough().optional(),
4659
- strict: z.union([z.boolean(), z.null()]).optional()
5617
+ data: z5.string()
5618
+ });
5619
+ var ToolFunctionDefinition = z5.object({
5620
+ type: z5.literal("function"),
5621
+ function: z5.object({
5622
+ name: z5.string(),
5623
+ description: z5.string().optional(),
5624
+ parameters: z5.object({}).partial().passthrough().optional(),
5625
+ strict: z5.union([z5.boolean(), z5.null()]).optional()
4660
5626
  })
4661
5627
  });
4662
- var User = z.object({
4663
- id: z.string().uuid(),
4664
- given_name: z.union([z.string(), z.null()]).optional(),
4665
- family_name: z.union([z.string(), z.null()]).optional(),
4666
- email: z.union([z.string(), z.null()]).optional(),
4667
- avatar_url: z.union([z.string(), z.null()]).optional(),
4668
- created: z.union([z.string(), z.null()]).optional()
4669
- });
4670
- var ViewDataSearch = z.union([
4671
- z.object({
4672
- filter: z.union([z.array(z.unknown()), z.null()]),
4673
- tag: z.union([z.array(z.unknown()), z.null()]),
4674
- match: z.union([z.array(z.unknown()), z.null()]),
4675
- sort: z.union([z.array(z.unknown()), z.null()])
5628
+ var User = z5.object({
5629
+ id: z5.string().uuid(),
5630
+ given_name: z5.union([z5.string(), z5.null()]).optional(),
5631
+ family_name: z5.union([z5.string(), z5.null()]).optional(),
5632
+ email: z5.union([z5.string(), z5.null()]).optional(),
5633
+ avatar_url: z5.union([z5.string(), z5.null()]).optional(),
5634
+ created: z5.union([z5.string(), z5.null()]).optional()
5635
+ });
5636
+ var ViewDataSearch = z5.union([
5637
+ z5.object({
5638
+ filter: z5.union([z5.array(z5.unknown()), z5.null()]),
5639
+ tag: z5.union([z5.array(z5.unknown()), z5.null()]),
5640
+ match: z5.union([z5.array(z5.unknown()), z5.null()]),
5641
+ sort: z5.union([z5.array(z5.unknown()), z5.null()])
4676
5642
  }).partial(),
4677
- z.null()
5643
+ z5.null()
4678
5644
  ]);
4679
- var ViewData = z.union([
4680
- z.object({ search: ViewDataSearch }).partial(),
4681
- z.null()
5645
+ var ViewData = z5.union([
5646
+ z5.object({ search: ViewDataSearch }).partial(),
5647
+ z5.null()
4682
5648
  ]);
4683
- var ViewOptions = z.union([
4684
- z.object({
4685
- viewType: z.literal("monitor"),
4686
- options: z.object({
4687
- spanType: z.union([z.enum(["range", "frame"]), z.null()]),
4688
- rangeValue: z.union([z.string(), z.null()]),
4689
- frameStart: z.union([z.string(), z.null()]),
4690
- frameEnd: z.union([z.string(), z.null()]),
4691
- tzUTC: z.union([z.boolean(), z.null()]),
4692
- chartVisibility: z.union([z.record(z.boolean()), z.null()]),
4693
- projectId: z.union([z.string(), z.null()]),
4694
- type: z.union([z.enum(["project", "experiment"]), z.null()]),
4695
- groupBy: z.union([z.string(), z.null()])
5649
+ var ViewOptions = z5.union([
5650
+ z5.object({
5651
+ viewType: z5.literal("monitor"),
5652
+ options: z5.object({
5653
+ spanType: z5.union([z5.enum(["range", "frame"]), z5.null()]),
5654
+ rangeValue: z5.union([z5.string(), z5.null()]),
5655
+ frameStart: z5.union([z5.string(), z5.null()]),
5656
+ frameEnd: z5.union([z5.string(), z5.null()]),
5657
+ tzUTC: z5.union([z5.boolean(), z5.null()]),
5658
+ chartVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
5659
+ projectId: z5.union([z5.string(), z5.null()]),
5660
+ type: z5.union([z5.enum(["project", "experiment"]), z5.null()]),
5661
+ groupBy: z5.union([z5.string(), z5.null()])
4696
5662
  }).partial()
4697
5663
  }),
4698
- z.object({
4699
- columnVisibility: z.union([z.record(z.boolean()), z.null()]),
4700
- columnOrder: z.union([z.array(z.string()), z.null()]),
4701
- columnSizing: z.union([z.record(z.number()), z.null()]),
4702
- grouping: z.union([z.string(), z.null()]),
4703
- rowHeight: z.union([z.string(), z.null()]),
4704
- tallGroupRows: z.union([z.boolean(), z.null()]),
4705
- layout: z.union([z.string(), z.null()]),
4706
- chartHeight: z.union([z.number(), z.null()]),
4707
- excludedMeasures: z.union([
4708
- z.array(
4709
- z.object({
4710
- type: z.enum(["none", "score", "metric", "metadata"]),
4711
- value: z.string()
5664
+ z5.object({
5665
+ columnVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
5666
+ columnOrder: z5.union([z5.array(z5.string()), z5.null()]),
5667
+ columnSizing: z5.union([z5.record(z5.number()), z5.null()]),
5668
+ grouping: z5.union([z5.string(), z5.null()]),
5669
+ rowHeight: z5.union([z5.string(), z5.null()]),
5670
+ tallGroupRows: z5.union([z5.boolean(), z5.null()]),
5671
+ layout: z5.union([z5.string(), z5.null()]),
5672
+ chartHeight: z5.union([z5.number(), z5.null()]),
5673
+ excludedMeasures: z5.union([
5674
+ z5.array(
5675
+ z5.object({
5676
+ type: z5.enum(["none", "score", "metric", "metadata"]),
5677
+ value: z5.string()
4712
5678
  })
4713
5679
  ),
4714
- z.null()
5680
+ z5.null()
4715
5681
  ]),
4716
- yMetric: z.union([
4717
- z.object({
4718
- type: z.enum(["none", "score", "metric", "metadata"]),
4719
- value: z.string()
5682
+ yMetric: z5.union([
5683
+ z5.object({
5684
+ type: z5.enum(["none", "score", "metric", "metadata"]),
5685
+ value: z5.string()
4720
5686
  }),
4721
- z.null()
5687
+ z5.null()
4722
5688
  ]),
4723
- xAxis: z.union([
4724
- z.object({
4725
- type: z.enum(["none", "score", "metric", "metadata"]),
4726
- value: z.string()
5689
+ xAxis: z5.union([
5690
+ z5.object({
5691
+ type: z5.enum(["none", "score", "metric", "metadata"]),
5692
+ value: z5.string()
4727
5693
  }),
4728
- z.null()
5694
+ z5.null()
4729
5695
  ]),
4730
- symbolGrouping: z.union([
4731
- z.object({
4732
- type: z.enum(["none", "score", "metric", "metadata"]),
4733
- value: z.string()
5696
+ symbolGrouping: z5.union([
5697
+ z5.object({
5698
+ type: z5.enum(["none", "score", "metric", "metadata"]),
5699
+ value: z5.string()
4734
5700
  }),
4735
- z.null()
5701
+ z5.null()
4736
5702
  ]),
4737
- xAxisAggregation: z.union([z.string(), z.null()]),
4738
- chartAnnotations: z.union([
4739
- z.array(z.object({ id: z.string(), text: z.string() })),
4740
- z.null()
5703
+ xAxisAggregation: z5.union([z5.string(), z5.null()]),
5704
+ chartAnnotations: z5.union([
5705
+ z5.array(z5.object({ id: z5.string(), text: z5.string() })),
5706
+ z5.null()
4741
5707
  ]),
4742
- timeRangeFilter: z.union([
4743
- z.string(),
4744
- z.object({ from: z.string(), to: z.string() }),
4745
- z.null()
5708
+ timeRangeFilter: z5.union([
5709
+ z5.string(),
5710
+ z5.object({ from: z5.string(), to: z5.string() }),
5711
+ z5.null()
4746
5712
  ])
4747
5713
  }).partial(),
4748
- z.null()
5714
+ z5.null()
4749
5715
  ]);
4750
- var View = z.object({
4751
- id: z.string().uuid(),
4752
- object_type: AclObjectType.and(z.string()),
4753
- object_id: z.string().uuid(),
4754
- view_type: z.enum([
5716
+ var View = z5.object({
5717
+ id: z5.string().uuid(),
5718
+ object_type: AclObjectType.and(z5.string()),
5719
+ object_id: z5.string().uuid(),
5720
+ view_type: z5.enum([
4755
5721
  "projects",
4756
5722
  "experiments",
4757
5723
  "experiment",
@@ -4766,56 +5732,56 @@ var View = z.object({
4766
5732
  "agents",
4767
5733
  "monitor"
4768
5734
  ]),
4769
- name: z.string(),
4770
- created: z.union([z.string(), z.null()]).optional(),
5735
+ name: z5.string(),
5736
+ created: z5.union([z5.string(), z5.null()]).optional(),
4771
5737
  view_data: ViewData.optional(),
4772
5738
  options: ViewOptions.optional(),
4773
- user_id: z.union([z.string(), z.null()]).optional(),
4774
- deleted_at: z.union([z.string(), z.null()]).optional()
5739
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
5740
+ deleted_at: z5.union([z5.string(), z5.null()]).optional()
4775
5741
  });
4776
5742
 
4777
5743
  // src/logger.ts
4778
5744
  import { waitUntil } from "@vercel/functions";
4779
5745
  import Mustache2 from "mustache";
4780
- import { z as z3, ZodError } from "zod";
5746
+ import { z as z7, ZodError } from "zod";
4781
5747
 
4782
5748
  // src/functions/stream.ts
4783
5749
  import {
4784
5750
  createParser
4785
5751
  } from "eventsource-parser";
4786
- import { z as z2 } from "zod";
4787
- var braintrustStreamChunkSchema = z2.union([
4788
- z2.object({
4789
- type: z2.literal("text_delta"),
4790
- data: z2.string()
5752
+ import { z as z6 } from "zod/v3";
5753
+ var braintrustStreamChunkSchema = z6.union([
5754
+ z6.object({
5755
+ type: z6.literal("text_delta"),
5756
+ data: z6.string()
4791
5757
  }),
4792
- z2.object({
4793
- type: z2.literal("reasoning_delta"),
4794
- data: z2.string()
5758
+ z6.object({
5759
+ type: z6.literal("reasoning_delta"),
5760
+ data: z6.string()
4795
5761
  }),
4796
- z2.object({
4797
- type: z2.literal("json_delta"),
4798
- data: z2.string()
5762
+ z6.object({
5763
+ type: z6.literal("json_delta"),
5764
+ data: z6.string()
4799
5765
  }),
4800
- z2.object({
4801
- type: z2.literal("error"),
4802
- data: z2.string()
5766
+ z6.object({
5767
+ type: z6.literal("error"),
5768
+ data: z6.string()
4803
5769
  }),
4804
- z2.object({
4805
- type: z2.literal("console"),
5770
+ z6.object({
5771
+ type: z6.literal("console"),
4806
5772
  data: SSEConsoleEventData
4807
5773
  }),
4808
- z2.object({
4809
- type: z2.literal("progress"),
5774
+ z6.object({
5775
+ type: z6.literal("progress"),
4810
5776
  data: SSEProgressEventData
4811
5777
  }),
4812
- z2.object({
4813
- type: z2.literal("start"),
4814
- data: z2.string()
5778
+ z6.object({
5779
+ type: z6.literal("start"),
5780
+ data: z6.string()
4815
5781
  }),
4816
- z2.object({
4817
- type: z2.literal("done"),
4818
- data: z2.string()
5782
+ z6.object({
5783
+ type: z6.literal("done"),
5784
+ data: z6.string()
4819
5785
  })
4820
5786
  ]);
4821
5787
  var BraintrustStream = class _BraintrustStream {
@@ -5412,7 +6378,6 @@ function objectIsEmpty(obj) {
5412
6378
  }
5413
6379
 
5414
6380
  // src/mustache-utils.ts
5415
- import { getObjValueByPath } from "@braintrust/core";
5416
6381
  import Mustache from "mustache";
5417
6382
  function lintTemplate(template, context2) {
5418
6383
  const variables = getMustacheVars(template);
@@ -5435,7 +6400,6 @@ function getMustacheVars(prompt) {
5435
6400
  }
5436
6401
 
5437
6402
  // src/logger.ts
5438
- import { prettifyXact } from "@braintrust/core";
5439
6403
  var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
5440
6404
  var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
5441
6405
  var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
@@ -5520,17 +6484,31 @@ var NoopSpan = class {
5520
6484
  state() {
5521
6485
  return _internalGetGlobalState();
5522
6486
  }
6487
+ // Custom inspect for Node.js console.log
6488
+ [Symbol.for("nodejs.util.inspect.custom")]() {
6489
+ return `NoopSpan {
6490
+ kind: '${this.kind}',
6491
+ id: '${this.id}',
6492
+ spanId: '${this.spanId}',
6493
+ rootSpanId: '${this.rootSpanId}',
6494
+ spanParents: ${JSON.stringify(this.spanParents)}
6495
+ }`;
6496
+ }
6497
+ // Custom toString
6498
+ toString() {
6499
+ return `NoopSpan(id=${this.id}, spanId=${this.spanId})`;
6500
+ }
5523
6501
  };
5524
6502
  var NOOP_SPAN = new NoopSpan();
5525
6503
  var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
5526
- var loginSchema = z3.strictObject({
5527
- appUrl: z3.string(),
5528
- appPublicUrl: z3.string(),
5529
- orgName: z3.string(),
5530
- apiUrl: z3.string(),
5531
- proxyUrl: z3.string(),
5532
- loginToken: z3.string(),
5533
- orgId: z3.string().nullish(),
6504
+ var loginSchema = z7.strictObject({
6505
+ appUrl: z7.string(),
6506
+ appPublicUrl: z7.string(),
6507
+ orgName: z7.string(),
6508
+ apiUrl: z7.string(),
6509
+ proxyUrl: z7.string(),
6510
+ loginToken: z7.string(),
6511
+ orgId: z7.string().nullish(),
5534
6512
  gitMetadataSettings: GitMetadataSettings.nullish()
5535
6513
  });
5536
6514
  var stateNonce = 0;
@@ -5740,6 +6718,37 @@ var BraintrustState = class _BraintrustState {
5740
6718
  enforceQueueSizeLimit(enforce) {
5741
6719
  this._bgLogger.get().enforceQueueSizeLimit(enforce);
5742
6720
  }
6721
+ // Custom serialization to avoid logging sensitive data
6722
+ toJSON() {
6723
+ return {
6724
+ id: this.id,
6725
+ orgId: this.orgId,
6726
+ orgName: this.orgName,
6727
+ appUrl: this.appUrl,
6728
+ appPublicUrl: this.appPublicUrl,
6729
+ apiUrl: this.apiUrl,
6730
+ proxyUrl: this.proxyUrl,
6731
+ loggedIn: this.loggedIn
6732
+ // Explicitly exclude loginToken, _apiConn, _appConn, _proxyConn and other sensitive fields
6733
+ };
6734
+ }
6735
+ // Custom inspect for Node.js console.log
6736
+ [Symbol.for("nodejs.util.inspect.custom")]() {
6737
+ return `BraintrustState {
6738
+ id: '${this.id}',
6739
+ orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
6740
+ orgName: ${this.orgName ? `'${this.orgName}'` : "null"},
6741
+ appUrl: ${this.appUrl ? `'${this.appUrl}'` : "null"},
6742
+ apiUrl: ${this.apiUrl ? `'${this.apiUrl}'` : "null"},
6743
+ proxyUrl: ${this.proxyUrl ? `'${this.proxyUrl}'` : "null"},
6744
+ loggedIn: ${this.loggedIn},
6745
+ loginToken: '[REDACTED]'
6746
+ }`;
6747
+ }
6748
+ // Custom toString
6749
+ toString() {
6750
+ return `BraintrustState(id=${this.id}, org=${this.orgName || "none"}, loggedIn=${this.loggedIn})`;
6751
+ }
5743
6752
  };
5744
6753
  var _globalState;
5745
6754
  function useTestBackgroundLogger() {
@@ -5907,6 +6916,17 @@ var HTTPConnection = class _HTTPConnection {
5907
6916
  });
5908
6917
  return await resp.json();
5909
6918
  }
6919
+ // Custom inspect for Node.js console.log
6920
+ [Symbol.for("nodejs.util.inspect.custom")]() {
6921
+ return `HTTPConnection {
6922
+ base_url: '${this.base_url}',
6923
+ token: '[REDACTED]'
6924
+ }`;
6925
+ }
6926
+ // Custom toString
6927
+ toString() {
6928
+ return `HTTPConnection(${this.base_url})`;
6929
+ }
5910
6930
  };
5911
6931
  var BaseAttachment = class {
5912
6932
  reference;
@@ -6007,9 +7027,9 @@ var Attachment = class extends BaseAttachment {
6007
7027
  let signedUrl;
6008
7028
  let headers;
6009
7029
  try {
6010
- ({ signedUrl, headers } = z3.object({
6011
- signedUrl: z3.string().url(),
6012
- headers: z3.record(z3.string())
7030
+ ({ signedUrl, headers } = z7.object({
7031
+ signedUrl: z7.string().url(),
7032
+ headers: z7.record(z7.string())
6013
7033
  }).parse(await metadataResponse.json()));
6014
7034
  } catch (error2) {
6015
7035
  if (error2 instanceof ZodError) {
@@ -6164,8 +7184,8 @@ var ExternalAttachment = class extends BaseAttachment {
6164
7184
  });
6165
7185
  }
6166
7186
  };
6167
- var attachmentMetadataSchema = z3.object({
6168
- downloadUrl: z3.string(),
7187
+ var attachmentMetadataSchema = z7.object({
7188
+ downloadUrl: z7.string(),
6169
7189
  status: AttachmentStatus
6170
7190
  });
6171
7191
  var ReadonlyAttachment = class {
@@ -6377,15 +7397,15 @@ function spanComponentsToObjectIdLambda(state, components) {
6377
7397
  );
6378
7398
  }
6379
7399
  switch (components.data.object_type) {
6380
- case SpanObjectTypeV3.EXPERIMENT:
7400
+ case 1 /* EXPERIMENT */:
6381
7401
  throw new Error(
6382
7402
  "Impossible: computeObjectMetadataArgs not supported for experiments"
6383
7403
  );
6384
- case SpanObjectTypeV3.PLAYGROUND_LOGS:
7404
+ case 3 /* PLAYGROUND_LOGS */:
6385
7405
  throw new Error(
6386
7406
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
6387
7407
  );
6388
- case SpanObjectTypeV3.PROJECT_LOGS:
7408
+ case 2 /* PROJECT_LOGS */:
6389
7409
  return async () => (await computeLoggerMetadata(state, {
6390
7410
  ...components.data.compute_object_metadata_args
6391
7411
  })).project.id;
@@ -6537,7 +7557,7 @@ var Logger = class {
6537
7557
  return (async () => (await this.project).id)();
6538
7558
  }
6539
7559
  parentObjectType() {
6540
- return SpanObjectTypeV3.PROJECT_LOGS;
7560
+ return 2 /* PROJECT_LOGS */;
6541
7561
  }
6542
7562
  /**
6543
7563
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -6631,7 +7651,7 @@ var Logger = class {
6631
7651
  parentSpanIds: args?.parentSpanIds,
6632
7652
  propagatedEvent: args?.propagatedEvent
6633
7653
  }),
6634
- defaultRootType: SpanTypeAttribute.TASK
7654
+ defaultRootType: "task" /* TASK */
6635
7655
  });
6636
7656
  }
6637
7657
  /**
@@ -7749,6 +8769,8 @@ function getSpanParentObject(options) {
7749
8769
  if (!Object.is(parentSpan, NOOP_SPAN)) {
7750
8770
  return parentSpan;
7751
8771
  }
8772
+ const parentStr = options?.parent ?? state.currentParent.getStore();
8773
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
7752
8774
  const experiment = currentExperiment();
7753
8775
  if (experiment) {
7754
8776
  return experiment;
@@ -7965,35 +8987,35 @@ function setFetch(fetch2) {
7965
8987
  }
7966
8988
  function startSpanAndIsLogger(args) {
7967
8989
  const state = args?.state ?? _globalState;
7968
- const parentStr = args?.parent ?? state.currentParent.getStore();
7969
- const components = parentStr ? SpanComponentsV3.fromStr(parentStr) : void 0;
7970
- if (components) {
7971
- const parentSpanIds = components.data.row_id ? {
7972
- spanId: components.data.span_id,
7973
- rootSpanId: components.data.root_span_id
8990
+ const parentObject = getSpanParentObject({
8991
+ asyncFlush: args?.asyncFlush,
8992
+ parent: args?.parent,
8993
+ state
8994
+ });
8995
+ if (parentObject instanceof SpanComponentsV3) {
8996
+ const parentSpanIds = parentObject.data.row_id ? {
8997
+ spanId: parentObject.data.span_id,
8998
+ rootSpanId: parentObject.data.root_span_id
7974
8999
  } : void 0;
7975
9000
  const span = new SpanImpl({
7976
9001
  state,
7977
9002
  ...args,
7978
- parentObjectType: components.data.object_type,
9003
+ parentObjectType: parentObject.data.object_type,
7979
9004
  parentObjectId: new LazyValue(
7980
- spanComponentsToObjectIdLambda(state, components)
9005
+ spanComponentsToObjectIdLambda(state, parentObject)
7981
9006
  ),
7982
- parentComputeObjectMetadataArgs: components.data.compute_object_metadata_args ?? void 0,
9007
+ parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
7983
9008
  parentSpanIds,
7984
9009
  propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
7985
- (components.data.propagated_event ?? void 0)
9010
+ (parentObject.data.propagated_event ?? void 0)
7986
9011
  });
7987
9012
  return {
7988
9013
  span,
7989
- isSyncFlushLogger: components.data.object_type === SpanObjectTypeV3.PROJECT_LOGS && // Since there's no parent logger here, we're free to choose the async flush
9014
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
7990
9015
  // behavior, and therefore propagate along whatever we get from the arguments
7991
9016
  args?.asyncFlush === false
7992
9017
  };
7993
9018
  } else {
7994
- const parentObject = getSpanParentObject({
7995
- asyncFlush: args?.asyncFlush
7996
- });
7997
9019
  const span = parentObject.startSpan(args);
7998
9020
  return {
7999
9021
  span,
@@ -8143,7 +9165,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
8143
9165
  function deepCopyEvent(event) {
8144
9166
  const attachments = [];
8145
9167
  const IDENTIFIER = "_bt_internal_saved_attachment";
8146
- const savedAttachmentSchema = z3.strictObject({ [IDENTIFIER]: z3.number() });
9168
+ const savedAttachmentSchema = z7.strictObject({ [IDENTIFIER]: z7.number() });
8147
9169
  const serialized = JSON.stringify(event, (_k, v) => {
8148
9170
  if (v instanceof SpanImpl || v instanceof NoopSpan) {
8149
9171
  return `<span>`;
@@ -8378,7 +9400,7 @@ var Experiment2 = class extends ObjectFetcher {
8378
9400
  })();
8379
9401
  }
8380
9402
  parentObjectType() {
8381
- return SpanObjectTypeV3.EXPERIMENT;
9403
+ return 1 /* EXPERIMENT */;
8382
9404
  }
8383
9405
  async getState() {
8384
9406
  await this.lazyMetadata.get();
@@ -8462,7 +9484,7 @@ var Experiment2 = class extends ObjectFetcher {
8462
9484
  parentSpanIds: void 0,
8463
9485
  propagatedEvent: args?.propagatedEvent
8464
9486
  }),
8465
- defaultRootType: SpanTypeAttribute.EVAL
9487
+ defaultRootType: "eval" /* EVAL */
8466
9488
  });
8467
9489
  }
8468
9490
  async fetchBaseExperiment() {
@@ -8881,7 +9903,7 @@ var SpanImpl = class _SpanImpl {
8881
9903
  const baseUrl = `${appUrl}/app/${orgName}`;
8882
9904
  const args = this.parentComputeObjectMetadataArgs;
8883
9905
  switch (this.parentObjectType) {
8884
- case SpanObjectTypeV3.PROJECT_LOGS: {
9906
+ case 2 /* PROJECT_LOGS */: {
8885
9907
  const projectID = args?.project_id || this.parentObjectId.getSync().value;
8886
9908
  const projectName = args?.project_name;
8887
9909
  if (projectID) {
@@ -8892,7 +9914,7 @@ var SpanImpl = class _SpanImpl {
8892
9914
  return getErrPermlink("provide-project-name-or-id");
8893
9915
  }
8894
9916
  }
8895
- case SpanObjectTypeV3.EXPERIMENT: {
9917
+ case 1 /* EXPERIMENT */: {
8896
9918
  const expID = args?.experiment_id || this.parentObjectId?.getSync()?.value;
8897
9919
  if (!expID) {
8898
9920
  return getErrPermlink("provide-experiment-id");
@@ -8900,7 +9922,7 @@ var SpanImpl = class _SpanImpl {
8900
9922
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
8901
9923
  }
8902
9924
  }
8903
- case SpanObjectTypeV3.PLAYGROUND_LOGS: {
9925
+ case 3 /* PLAYGROUND_LOGS */: {
8904
9926
  return NOOP_SPAN_PERMALINK;
8905
9927
  }
8906
9928
  default: {
@@ -8919,6 +9941,20 @@ var SpanImpl = class _SpanImpl {
8919
9941
  state() {
8920
9942
  return this._state;
8921
9943
  }
9944
+ // Custom inspect for Node.js console.log
9945
+ [Symbol.for("nodejs.util.inspect.custom")]() {
9946
+ return `SpanImpl {
9947
+ kind: '${this.kind}',
9948
+ id: '${this.id}',
9949
+ spanId: '${this.spanId}',
9950
+ rootSpanId: '${this.rootSpanId}',
9951
+ spanParents: ${JSON.stringify(this.spanParents)}
9952
+ }`;
9953
+ }
9954
+ // Custom toString
9955
+ toString() {
9956
+ return `SpanImpl(id=${this.id}, spanId=${this.spanId})`;
9957
+ }
8922
9958
  };
8923
9959
  function splitLoggingData({
8924
9960
  event,
@@ -9148,8 +10184,8 @@ var Dataset2 = class extends ObjectFetcher {
9148
10184
  )}`;
9149
10185
  let dataSummary;
9150
10186
  if (summarizeData) {
9151
- const rawDataSummary = z3.object({
9152
- total_records: z3.number()
10187
+ const rawDataSummary = z7.object({
10188
+ total_records: z7.number()
9153
10189
  }).parse(
9154
10190
  await state.apiConn().get_json(
9155
10191
  "dataset-summary",
@@ -9272,11 +10308,11 @@ function renderTemplatedObject(obj, args, options) {
9272
10308
  return obj;
9273
10309
  }
9274
10310
  function renderPromptParams(params, args, options) {
9275
- const schemaParsed = z3.object({
9276
- response_format: z3.object({
9277
- type: z3.literal("json_schema"),
10311
+ const schemaParsed = z7.object({
10312
+ response_format: z7.object({
10313
+ type: z7.literal("json_schema"),
9278
10314
  json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
9279
- schema: z3.unknown()
10315
+ schema: z7.unknown()
9280
10316
  })
9281
10317
  })
9282
10318
  }).safeParse(params);
@@ -9394,7 +10430,7 @@ var Prompt2 = class _Prompt {
9394
10430
  if (!prompt) {
9395
10431
  throw new Error("Empty prompt");
9396
10432
  }
9397
- const dictArgParsed = z3.record(z3.unknown()).safeParse(buildArgs);
10433
+ const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
9398
10434
  const variables = {
9399
10435
  input: buildArgs,
9400
10436
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -9449,7 +10485,7 @@ var Prompt2 = class _Prompt {
9449
10485
  return JSON.stringify(v);
9450
10486
  }
9451
10487
  };
9452
- const dictArgParsed = z3.record(z3.unknown()).safeParse(buildArgs);
10488
+ const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
9453
10489
  const variables = {
9454
10490
  input: buildArgs,
9455
10491
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -9681,6 +10717,7 @@ __export(exports_node_exports, {
9681
10717
  currentExperiment: () => currentExperiment,
9682
10718
  currentLogger: () => currentLogger,
9683
10719
  currentSpan: () => currentSpan,
10720
+ deepCopyEvent: () => deepCopyEvent,
9684
10721
  defaultErrorScoreHandler: () => defaultErrorScoreHandler,
9685
10722
  deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
9686
10723
  devNullWritableStream: () => devNullWritableStream,
@@ -9725,8 +10762,10 @@ __export(exports_node_exports, {
9725
10762
  withExperiment: () => withExperiment,
9726
10763
  withLogger: () => withLogger,
9727
10764
  withParent: () => withParent,
10765
+ wrapAISDK: () => wrapAISDK,
9728
10766
  wrapAISDKModel: () => wrapAISDKModel,
9729
10767
  wrapAnthropic: () => wrapAnthropic,
10768
+ wrapMastraAgent: () => wrapMastraAgent,
9730
10769
  wrapOpenAI: () => wrapOpenAI,
9731
10770
  wrapOpenAIv4: () => wrapOpenAIv4,
9732
10771
  wrapTraced: () => wrapTraced
@@ -9820,10 +10859,7 @@ function initFunction({
9820
10859
  return f;
9821
10860
  }
9822
10861
 
9823
- // src/framework.ts
9824
- import { SpanTypeAttribute as SpanTypeAttribute2, mergeDicts as mergeDicts2 } from "@braintrust/core";
9825
-
9826
- // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
10862
+ // ../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
9827
10863
  function initialParams(fn) {
9828
10864
  return function(...args) {
9829
10865
  var callback = args.pop();
@@ -10902,13 +11938,12 @@ var BarProgressReporter = class {
10902
11938
  };
10903
11939
 
10904
11940
  // src/eval-parameters.ts
10905
- import { z as z5 } from "zod";
11941
+ import { z as z9 } from "zod/v3";
10906
11942
 
10907
11943
  // src/framework2.ts
10908
11944
  import path2 from "path";
10909
11945
  import slugifyLib from "slugify";
10910
- import { z as z4 } from "zod";
10911
- import { loadPrettyXact } from "@braintrust/core";
11946
+ import { z as z8 } from "zod/v3";
10912
11947
  var ProjectBuilder = class {
10913
11948
  create(opts) {
10914
11949
  return new Project2(opts);
@@ -11142,23 +12177,23 @@ var CodePrompt = class {
11142
12177
  };
11143
12178
  }
11144
12179
  };
11145
- var promptContentsSchema = z4.union([
11146
- z4.object({
11147
- prompt: z4.string()
12180
+ var promptContentsSchema = z8.union([
12181
+ z8.object({
12182
+ prompt: z8.string()
11148
12183
  }),
11149
- z4.object({
11150
- messages: z4.array(ChatCompletionMessageParam)
12184
+ z8.object({
12185
+ messages: z8.array(ChatCompletionMessageParam)
11151
12186
  })
11152
12187
  ]);
11153
12188
  var promptDefinitionSchema = promptContentsSchema.and(
11154
- z4.object({
11155
- model: z4.string(),
12189
+ z8.object({
12190
+ model: z8.string(),
11156
12191
  params: ModelParams.optional()
11157
12192
  })
11158
12193
  );
11159
12194
  var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
11160
- z4.object({
11161
- tools: z4.array(ToolFunctionDefinition).optional()
12195
+ z8.object({
12196
+ tools: z8.array(ToolFunctionDefinition).optional()
11162
12197
  })
11163
12198
  );
11164
12199
  var PromptBuilder = class {
@@ -11226,7 +12261,7 @@ var ProjectNameIdMap = class {
11226
12261
  const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
11227
12262
  project_name: projectName
11228
12263
  });
11229
- const result = z4.object({
12264
+ const result = z8.object({
11230
12265
  project: Project
11231
12266
  }).parse(response);
11232
12267
  const projectId = result.project.id;
@@ -11240,7 +12275,7 @@ var ProjectNameIdMap = class {
11240
12275
  const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
11241
12276
  id: projectId
11242
12277
  });
11243
- const result = z4.array(Project).nonempty().parse(response);
12278
+ const result = z8.array(Project).nonempty().parse(response);
11244
12279
  const projectName = result[0].name;
11245
12280
  this.idToName[projectId] = projectName;
11246
12281
  this.nameToId[projectName] = projectId;
@@ -11256,15 +12291,15 @@ var ProjectNameIdMap = class {
11256
12291
  };
11257
12292
 
11258
12293
  // src/eval-parameters.ts
11259
- var evalParametersSchema = z5.record(
11260
- z5.string(),
11261
- z5.union([
11262
- z5.object({
11263
- type: z5.literal("prompt"),
12294
+ var evalParametersSchema = z9.record(
12295
+ z9.string(),
12296
+ z9.union([
12297
+ z9.object({
12298
+ type: z9.literal("prompt"),
11264
12299
  default: promptDefinitionWithToolsSchema.optional(),
11265
- description: z5.string().optional()
12300
+ description: z9.string().optional()
11266
12301
  }),
11267
- z5.instanceof(z5.ZodType)
12302
+ z9.instanceof(z9.ZodType)
11268
12303
  // For Zod schemas
11269
12304
  ])
11270
12305
  );
@@ -11566,7 +12601,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11566
12601
  const baseEvent = {
11567
12602
  name: "eval",
11568
12603
  spanAttributes: {
11569
- type: SpanTypeAttribute2.EVAL
12604
+ type: "eval" /* EVAL */
11570
12605
  },
11571
12606
  event: {
11572
12607
  input: datum.input,
@@ -11626,7 +12661,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11626
12661
  },
11627
12662
  {
11628
12663
  name: "task",
11629
- spanAttributes: { type: SpanTypeAttribute2.TASK },
12664
+ spanAttributes: { type: "task" /* TASK */ },
11630
12665
  event: { input: datum.input }
11631
12666
  }
11632
12667
  );
@@ -11672,17 +12707,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11672
12707
  return rest;
11673
12708
  };
11674
12709
  const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
11675
- (prev, s) => mergeDicts2(prev, {
12710
+ (prev, s) => mergeDicts(prev, {
11676
12711
  [s.name]: s.metadata
11677
12712
  }),
11678
12713
  {}
11679
12714
  );
11680
12715
  const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
11681
- (prev, s) => mergeDicts2(prev, { [s.name]: getOtherFields(s) }),
12716
+ (prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
11682
12717
  {}
11683
12718
  );
11684
12719
  const scores2 = results3.reduce(
11685
- (prev, s) => mergeDicts2(prev, { [s.name]: s.score }),
12720
+ (prev, s) => mergeDicts(prev, { [s.name]: s.score }),
11686
12721
  {}
11687
12722
  );
11688
12723
  span.log({
@@ -11695,7 +12730,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11695
12730
  const results2 = await rootSpan.traced(runScorer, {
11696
12731
  name: scorerNames[score_idx],
11697
12732
  spanAttributes: {
11698
- type: SpanTypeAttribute2.SCORE
12733
+ type: "score" /* SCORE */
11699
12734
  },
11700
12735
  event: { input: scoringArgs }
11701
12736
  });
@@ -12038,11 +13073,11 @@ var GraphBuilder = class {
12038
13073
  // }
12039
13074
  // Helper to generate node IDs
12040
13075
  generateId(name) {
12041
- const uuid = newId();
13076
+ const uuid4 = newId();
12042
13077
  if (name) {
12043
- return `${name}-${uuid.slice(0, 8)}`;
13078
+ return `${name}-${uuid4.slice(0, 8)}`;
12044
13079
  } else {
12045
- return uuid;
13080
+ return uuid4;
12046
13081
  }
12047
13082
  }
12048
13083
  // Create an input node
@@ -12195,12 +13230,7 @@ function unescapePath(path3) {
12195
13230
  }
12196
13231
  var graph_framework_default = { createGraph };
12197
13232
 
12198
- // src/wrappers/oai.ts
12199
- import { SpanTypeAttribute as SpanTypeAttribute3 } from "@braintrust/core";
12200
- import { mergeDicts as mergeDicts3 } from "@braintrust/core";
12201
-
12202
13233
  // src/wrappers/oai_responses.ts
12203
- import { isObject as isObject2 } from "@braintrust/core";
12204
13234
  function responsesProxy(openai) {
12205
13235
  if (!openai.responses) {
12206
13236
  return openai;
@@ -12250,7 +13280,7 @@ function parseSpanFromResponseCreateParams(params) {
12250
13280
  function parseEventFromResponseCreateResult(result) {
12251
13281
  const data = {};
12252
13282
  if (result?.output !== void 0) {
12253
- data.output = result.output;
13283
+ data.output = processImagesInOutput(result.output);
12254
13284
  }
12255
13285
  if (result) {
12256
13286
  const { output, usage, ...metadata } = result;
@@ -12261,6 +13291,35 @@ function parseEventFromResponseCreateResult(result) {
12261
13291
  data.metrics = parseMetricsFromUsage(result?.usage);
12262
13292
  return data;
12263
13293
  }
13294
+ function processImagesInOutput(output) {
13295
+ if (Array.isArray(output)) {
13296
+ return output.map(processImagesInOutput);
13297
+ }
13298
+ if (isObject(output)) {
13299
+ if (output.type === "image_generation_call" && output.result && typeof output.result === "string") {
13300
+ const fileExtension = output.output_format || "png";
13301
+ const contentType = `image/${fileExtension}`;
13302
+ const baseFilename = output.revised_prompt && typeof output.revised_prompt === "string" ? output.revised_prompt.slice(0, 50).replace(/[^a-zA-Z0-9]/g, "_") : "generated_image";
13303
+ const filename = `${baseFilename}.${fileExtension}`;
13304
+ const binaryString = atob(output.result);
13305
+ const bytes = new Uint8Array(binaryString.length);
13306
+ for (let i = 0; i < binaryString.length; i++) {
13307
+ bytes[i] = binaryString.charCodeAt(i);
13308
+ }
13309
+ const blob = new Blob([bytes], { type: contentType });
13310
+ const attachment = new Attachment({
13311
+ data: blob,
13312
+ filename,
13313
+ contentType
13314
+ });
13315
+ return {
13316
+ ...output,
13317
+ result: attachment
13318
+ };
13319
+ }
13320
+ }
13321
+ return output;
13322
+ }
12264
13323
  function parseSpanFromResponseParseParams(params) {
12265
13324
  const spanArgs = {
12266
13325
  name: "openai.responses.parse",
@@ -12284,7 +13343,7 @@ function parseSpanFromResponseParseParams(params) {
12284
13343
  function parseEventFromResponseParseResult(result) {
12285
13344
  const data = {};
12286
13345
  if (result?.output !== void 0) {
12287
- data.output = result.output;
13346
+ data.output = processImagesInOutput(result.output);
12288
13347
  }
12289
13348
  if (result) {
12290
13349
  const { output, usage, ...metadata } = result;
@@ -12328,7 +13387,7 @@ function parseLogFromItem(item) {
12328
13387
  case "response.completed":
12329
13388
  const data = {};
12330
13389
  if (response?.output !== void 0) {
12331
- data.output = response.output;
13390
+ data.output = processImagesInOutput(response.output);
12332
13391
  }
12333
13392
  if (response) {
12334
13393
  const { usage, output, ...metadata } = response;
@@ -12398,7 +13457,7 @@ function parseMetricsFromUsage(usage) {
12398
13457
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
12399
13458
  metrics[metricName] = value;
12400
13459
  } else if (oai_name.endsWith("_tokens_details")) {
12401
- if (!isObject2(value)) {
13460
+ if (!isObject(value)) {
12402
13461
  continue;
12403
13462
  }
12404
13463
  const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
@@ -12580,11 +13639,11 @@ function wrapBetaChatCompletionParse(completion) {
12580
13639
  return async (allParams) => {
12581
13640
  const { span_info: _, ...params } = allParams;
12582
13641
  const span = startSpan(
12583
- mergeDicts3(
13642
+ mergeDicts(
12584
13643
  {
12585
13644
  name: "Chat Completion",
12586
13645
  spanAttributes: {
12587
- type: SpanTypeAttribute3.LLM
13646
+ type: "llm" /* LLM */
12588
13647
  }
12589
13648
  },
12590
13649
  parseChatCompletionParams(allParams)
@@ -12604,11 +13663,11 @@ function wrapBetaChatCompletionStream(completion) {
12604
13663
  return (allParams) => {
12605
13664
  const { span_info: _, ...params } = allParams;
12606
13665
  const span = startSpan(
12607
- mergeDicts3(
13666
+ mergeDicts(
12608
13667
  {
12609
13668
  name: "Chat Completion",
12610
13669
  spanAttributes: {
12611
- type: SpanTypeAttribute3.LLM
13670
+ type: "llm" /* LLM */
12612
13671
  }
12613
13672
  },
12614
13673
  parseChatCompletionParams(allParams)
@@ -12667,15 +13726,16 @@ function wrapChatCompletion(completion) {
12667
13726
  return (allParams, options) => {
12668
13727
  const { span_info: _, ...params } = allParams;
12669
13728
  let executionPromise = null;
12670
- const executeWrapped = () => {
13729
+ let dataPromise = null;
13730
+ const ensureExecuted = () => {
12671
13731
  if (!executionPromise) {
12672
13732
  executionPromise = (async () => {
12673
13733
  const span = startSpan(
12674
- mergeDicts3(
13734
+ mergeDicts(
12675
13735
  {
12676
13736
  name: "Chat Completion",
12677
13737
  spanAttributes: {
12678
- type: SpanTypeAttribute3.LLM
13738
+ type: "llm" /* LLM */
12679
13739
  }
12680
13740
  },
12681
13741
  parseChatCompletionParams(allParams)
@@ -12725,17 +13785,19 @@ function wrapChatCompletion(completion) {
12725
13785
  }
12726
13786
  return executionPromise;
12727
13787
  };
12728
- const dataPromise = executeWrapped().then((result) => result.data);
12729
- return new Proxy(dataPromise, {
13788
+ return new Proxy({}, {
12730
13789
  get(target, prop, receiver) {
12731
13790
  if (prop === "withResponse") {
12732
- return executeWrapped;
13791
+ return () => ensureExecuted();
12733
13792
  }
12734
- const value = Reflect.get(target, prop, receiver);
12735
- if (typeof value === "function") {
12736
- return value.bind(target);
13793
+ if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
13794
+ if (!dataPromise) {
13795
+ dataPromise = ensureExecuted().then((result) => result.data);
13796
+ }
13797
+ const value = Reflect.get(dataPromise, prop, receiver);
13798
+ return typeof value === "function" ? value.bind(dataPromise) : value;
12737
13799
  }
12738
- return value;
13800
+ return Reflect.get(target, prop, receiver);
12739
13801
  }
12740
13802
  });
12741
13803
  };
@@ -12752,7 +13814,7 @@ function parseBaseParams(allParams, inputField) {
12752
13814
  const input = params[inputField];
12753
13815
  const paramsRest = { ...params, provider: "openai" };
12754
13816
  delete paramsRest[inputField];
12755
- return mergeDicts3(ret, { event: { input, metadata: paramsRest } });
13817
+ return mergeDicts(ret, { event: { input, metadata: paramsRest } });
12756
13818
  }
12757
13819
  function createApiWrapper(name, create, processResponse, parseParams) {
12758
13820
  return async (allParams, options) => {
@@ -12767,11 +13829,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
12767
13829
  processResponse(result, span);
12768
13830
  return result;
12769
13831
  },
12770
- mergeDicts3(
13832
+ mergeDicts(
12771
13833
  {
12772
13834
  name,
12773
13835
  spanAttributes: {
12774
- type: SpanTypeAttribute3.LLM
13836
+ type: "llm" /* LLM */
12775
13837
  }
12776
13838
  },
12777
13839
  parseParams(allParams)
@@ -12909,9 +13971,6 @@ var WrapperStream = class {
12909
13971
  }
12910
13972
  };
12911
13973
 
12912
- // src/wrappers/ai-sdk-v2.ts
12913
- import { SpanTypeAttribute as SpanTypeAttribute4 } from "@braintrust/core";
12914
-
12915
13974
  // src/wrappers/anthropic-tokens-util.ts
12916
13975
  function finalizeAnthropicTokens(metrics) {
12917
13976
  const prompt_tokens = (metrics.prompt_tokens || 0) + (metrics.prompt_cached_tokens || 0) + (metrics.prompt_cache_creation_tokens || 0);
@@ -12932,7 +13991,7 @@ function extractAnthropicCacheTokens(cacheReadTokens = 0, cacheCreationTokens =
12932
13991
  return cacheTokens;
12933
13992
  }
12934
13993
 
12935
- // src/wrappers/ai-sdk-v2.ts
13994
+ // src/wrappers/ai-sdk-shared.ts
12936
13995
  function detectProviderFromResult(result) {
12937
13996
  if (!result?.providerMetadata) {
12938
13997
  return void 0;
@@ -12952,20 +14011,8 @@ function extractModelFromResult(result) {
12952
14011
  function camelToSnake(str) {
12953
14012
  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
12954
14013
  }
12955
- function extractModelParameters(params) {
14014
+ function extractModelParameters(params, excludeKeys) {
12956
14015
  const modelParams = {};
12957
- const excludeKeys = /* @__PURE__ */ new Set([
12958
- "prompt",
12959
- // Already captured as input
12960
- "system",
12961
- // Already captured as input
12962
- "messages",
12963
- // Already captured as input
12964
- "model",
12965
- // Already captured in metadata.model
12966
- "providerOptions"
12967
- // Internal AI SDK configuration
12968
- ]);
12969
14016
  for (const [key, value] of Object.entries(params)) {
12970
14017
  if (value !== void 0 && !excludeKeys.has(key)) {
12971
14018
  const snakeKey = camelToSnake(key);
@@ -13021,18 +14068,128 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
13021
14068
  }
13022
14069
  return metrics;
13023
14070
  }
14071
+ function normalizeFinishReason(reason) {
14072
+ if (typeof reason !== "string") return void 0;
14073
+ return reason.replace(/-/g, "_");
14074
+ }
14075
+ function extractToolCallsFromSteps(steps) {
14076
+ const toolCalls = [];
14077
+ if (!Array.isArray(steps)) return toolCalls;
14078
+ let idx = 0;
14079
+ for (const step of steps) {
14080
+ const blocks = step?.content;
14081
+ if (!Array.isArray(blocks)) continue;
14082
+ for (const block of blocks) {
14083
+ if (block && typeof block === "object" && block.type === "tool-call") {
14084
+ toolCalls.push({
14085
+ id: block.toolCallId,
14086
+ type: "function",
14087
+ index: idx++,
14088
+ function: {
14089
+ name: block.toolName,
14090
+ arguments: typeof block.input === "string" ? block.input : JSON.stringify(block.input ?? {})
14091
+ }
14092
+ });
14093
+ }
14094
+ }
14095
+ }
14096
+ return toolCalls;
14097
+ }
14098
+ function buildAssistantOutputWithToolCalls(result, toolCalls) {
14099
+ return [
14100
+ {
14101
+ index: 0,
14102
+ logprobs: null,
14103
+ finish_reason: normalizeFinishReason(result?.finishReason) ?? (toolCalls.length ? "tool_calls" : void 0),
14104
+ message: {
14105
+ role: "assistant",
14106
+ tool_calls: toolCalls.length > 0 ? toolCalls : void 0
14107
+ }
14108
+ }
14109
+ ];
14110
+ }
14111
+ function extractToolCallsFromBlocks(blocks) {
14112
+ if (!Array.isArray(blocks)) return [];
14113
+ return extractToolCallsFromSteps([{ content: blocks }]);
14114
+ }
14115
+ function wrapTools(tools) {
14116
+ if (!tools) return tools;
14117
+ const inferName = (tool, fallback2) => tool && (tool.name || tool.toolName || tool.id) || fallback2;
14118
+ if (Array.isArray(tools)) {
14119
+ const arr = tools;
14120
+ const out = arr.map((tool, idx) => {
14121
+ if (tool != null && typeof tool === "object" && "execute" in tool && typeof tool.execute === "function") {
14122
+ const name = inferName(tool, `tool[${idx}]`);
14123
+ return {
14124
+ ...tool,
14125
+ execute: wrapTraced(tool.execute.bind(tool), {
14126
+ name,
14127
+ type: "tool"
14128
+ })
14129
+ };
14130
+ }
14131
+ return tool;
14132
+ });
14133
+ return out;
14134
+ }
14135
+ const wrappedTools = {};
14136
+ for (const [key, tool] of Object.entries(tools)) {
14137
+ if (tool != null && typeof tool === "object" && "execute" in tool && typeof tool.execute === "function") {
14138
+ wrappedTools[key] = {
14139
+ ...tool,
14140
+ execute: wrapTraced(tool.execute.bind(tool), {
14141
+ name: key,
14142
+ type: "tool"
14143
+ })
14144
+ };
14145
+ } else {
14146
+ wrappedTools[key] = tool;
14147
+ }
14148
+ }
14149
+ return wrappedTools;
14150
+ }
14151
+ function extractInput(params) {
14152
+ return params?.prompt ?? params?.messages ?? params?.system;
14153
+ }
14154
+ function wrapStreamObject(iterable, onFirst) {
14155
+ let sawFirst = false;
14156
+ async function* wrapStream() {
14157
+ for await (const chunk of iterable) {
14158
+ if (!sawFirst) {
14159
+ sawFirst = true;
14160
+ onFirst();
14161
+ }
14162
+ yield chunk;
14163
+ }
14164
+ }
14165
+ return wrapStream();
14166
+ }
14167
+
14168
+ // src/wrappers/ai-sdk-v2.ts
14169
+ var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
14170
+ "prompt",
14171
+ // Already captured as input
14172
+ "system",
14173
+ // Already captured as input
14174
+ "messages",
14175
+ // Already captured as input
14176
+ "model",
14177
+ // Already captured in metadata.model
14178
+ "providerOptions"
14179
+ // Internal AI SDK configuration
14180
+ ]);
13024
14181
  function BraintrustMiddleware(config = {}) {
13025
14182
  return {
13026
14183
  wrapGenerate: async ({ doGenerate, params }) => {
13027
14184
  const spanArgs = {
13028
14185
  name: "ai-sdk.generateText",
13029
14186
  spanAttributes: {
13030
- type: SpanTypeAttribute4.LLM
14187
+ type: "llm" /* LLM */
13031
14188
  },
13032
14189
  event: {
13033
14190
  input: params.prompt,
13034
14191
  metadata: {
13035
- ...extractModelParameters(params)
14192
+ ...extractModelParameters(params, V2_EXCLUDE_KEYS)
13036
14193
  }
13037
14194
  }
13038
14195
  };
@@ -13051,8 +14208,12 @@ function BraintrustMiddleware(config = {}) {
13051
14208
  if (model !== void 0) {
13052
14209
  metadata.model = model;
13053
14210
  }
14211
+ let toolCalls = extractToolCallsFromSteps(result?.steps);
14212
+ if (!toolCalls || toolCalls.length === 0) {
14213
+ toolCalls = extractToolCallsFromBlocks(result?.content);
14214
+ }
13054
14215
  span.log({
13055
- output: result.content,
14216
+ output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : result?.content,
13056
14217
  metadata,
13057
14218
  metrics: normalizeUsageMetrics(
13058
14219
  result.usage,
@@ -13074,12 +14235,12 @@ function BraintrustMiddleware(config = {}) {
13074
14235
  const spanArgs = {
13075
14236
  name: "ai-sdk.streamText",
13076
14237
  spanAttributes: {
13077
- type: SpanTypeAttribute4.LLM
14238
+ type: "llm" /* LLM */
13078
14239
  },
13079
14240
  event: {
13080
14241
  input: params.prompt,
13081
14242
  metadata: {
13082
- ...extractModelParameters(params)
14243
+ ...extractModelParameters(params, V2_EXCLUDE_KEYS)
13083
14244
  }
13084
14245
  }
13085
14246
  };
@@ -13087,6 +14248,7 @@ function BraintrustMiddleware(config = {}) {
13087
14248
  try {
13088
14249
  const { stream, ...rest } = await doStream();
13089
14250
  const textChunks = [];
14251
+ const toolBlocks = [];
13090
14252
  let finalUsage = {};
13091
14253
  let finalFinishReason = void 0;
13092
14254
  let providerMetadata = {};
@@ -13097,6 +14259,9 @@ function BraintrustMiddleware(config = {}) {
13097
14259
  if (chunk.type === "text-delta" && chunk.delta) {
13098
14260
  textChunks.push(chunk.delta);
13099
14261
  }
14262
+ if (chunk.type === "tool-call" || chunk.type === "tool-result") {
14263
+ toolBlocks.push(chunk);
14264
+ }
13100
14265
  if (chunk.type === "finish") {
13101
14266
  finalFinishReason = chunk.finishReason;
13102
14267
  finalUsage = chunk.usage || {};
@@ -13114,11 +14279,12 @@ function BraintrustMiddleware(config = {}) {
13114
14279
  flush() {
13115
14280
  try {
13116
14281
  const generatedText = textChunks.join("");
13117
- const output = generatedText ? [{ type: "text", text: generatedText }] : [];
14282
+ let output = generatedText ? [{ type: "text", text: generatedText }] : [];
13118
14283
  const resultForDetection = {
13119
14284
  providerMetadata,
13120
14285
  response: rest.response,
13121
- ...rest
14286
+ ...rest,
14287
+ finishReason: finalFinishReason
13122
14288
  };
13123
14289
  const metadata = {};
13124
14290
  const provider = detectProviderFromResult(resultForDetection);
@@ -13132,6 +14298,17 @@ function BraintrustMiddleware(config = {}) {
13132
14298
  if (model !== void 0) {
13133
14299
  metadata.model = model;
13134
14300
  }
14301
+ if (toolBlocks.length > 0) {
14302
+ const toolCalls = extractToolCallsFromSteps([
14303
+ { content: toolBlocks }
14304
+ ]);
14305
+ if (toolCalls.length > 0) {
14306
+ output = buildAssistantOutputWithToolCalls(
14307
+ resultForDetection,
14308
+ toolCalls
14309
+ );
14310
+ }
14311
+ }
13135
14312
  span.log({
13136
14313
  output,
13137
14314
  metadata,
@@ -13441,8 +14618,385 @@ function postProcessOutput(text, toolCalls, finishReason) {
13441
14618
  ];
13442
14619
  }
13443
14620
 
14621
+ // src/wrappers/ai-sdk-v3.ts
14622
+ var V3_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
14623
+ "prompt",
14624
+ // Already captured as input
14625
+ "system",
14626
+ // Already captured as input
14627
+ "messages",
14628
+ // Already captured as input
14629
+ "model",
14630
+ // Already captured in metadata.model
14631
+ "providerOptions",
14632
+ // Internal AI SDK configuration
14633
+ "tools"
14634
+ // Already captured in metadata.tools
14635
+ ]);
14636
+ function wrapAISDK(ai) {
14637
+ const {
14638
+ wrapLanguageModel,
14639
+ generateText,
14640
+ streamText,
14641
+ generateObject,
14642
+ streamObject
14643
+ } = ai;
14644
+ const wrappedGenerateText = (params) => {
14645
+ return traced(
14646
+ async (span) => {
14647
+ const wrappedModel = wrapLanguageModel({
14648
+ model: params.model,
14649
+ middleware: BraintrustMiddleware()
14650
+ });
14651
+ const result = await generateText({
14652
+ ...params,
14653
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14654
+ model: wrappedModel
14655
+ });
14656
+ const provider = detectProviderFromResult(result);
14657
+ const model = extractModelFromResult(result);
14658
+ const finishReason = normalizeFinishReason(result?.finishReason);
14659
+ span.log({
14660
+ input: extractInput(params),
14661
+ output: result.text,
14662
+ metadata: {
14663
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14664
+ ...provider ? { provider } : {},
14665
+ ...model ? { model } : {},
14666
+ ...finishReason ? { finish_reason: finishReason } : {}
14667
+ }
14668
+ });
14669
+ return result;
14670
+ },
14671
+ {
14672
+ name: "ai-sdk.generateText"
14673
+ }
14674
+ );
14675
+ };
14676
+ const wrappedGenerateObject = (params) => {
14677
+ return traced(
14678
+ async (span) => {
14679
+ const wrappedModel = wrapLanguageModel({
14680
+ model: params.model,
14681
+ middleware: BraintrustMiddleware()
14682
+ });
14683
+ const result = await generateObject({
14684
+ ...params,
14685
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14686
+ model: wrappedModel
14687
+ });
14688
+ const provider = detectProviderFromResult(result);
14689
+ const model = extractModelFromResult(result);
14690
+ const finishReason = normalizeFinishReason(result.finishReason);
14691
+ span.log({
14692
+ input: extractInput(params),
14693
+ output: result.object,
14694
+ metadata: {
14695
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14696
+ ...provider ? { provider } : {},
14697
+ ...model ? { model } : {},
14698
+ ...finishReason ? { finish_reason: finishReason } : {}
14699
+ }
14700
+ });
14701
+ return result;
14702
+ },
14703
+ {
14704
+ name: "ai-sdk.generateObject"
14705
+ }
14706
+ );
14707
+ };
14708
+ const wrappedStreamText = (params) => {
14709
+ const span = startSpan({
14710
+ name: "ai-sdk.streamText",
14711
+ event: {
14712
+ input: extractInput(params),
14713
+ metadata: extractModelParameters(params, V3_EXCLUDE_KEYS)
14714
+ }
14715
+ });
14716
+ const userOnFinish = params.onFinish;
14717
+ const userOnError = params.onError;
14718
+ const userOnChunk = params.onChunk;
14719
+ try {
14720
+ const wrappedModel = wrapLanguageModel({
14721
+ model: params.model,
14722
+ middleware: BraintrustMiddleware()
14723
+ });
14724
+ const startTime = Date.now();
14725
+ let receivedFirst = false;
14726
+ const result = withCurrent(
14727
+ span,
14728
+ () => streamText({
14729
+ ...params,
14730
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14731
+ model: wrappedModel,
14732
+ onChunk: (chunk) => {
14733
+ if (!receivedFirst) {
14734
+ receivedFirst = true;
14735
+ span.log({
14736
+ metrics: {
14737
+ time_to_first_token: (Date.now() - startTime) / 1e3
14738
+ }
14739
+ });
14740
+ }
14741
+ if (typeof userOnChunk === "function") {
14742
+ userOnChunk(chunk);
14743
+ }
14744
+ },
14745
+ onFinish: async (event) => {
14746
+ if (typeof userOnFinish === "function") {
14747
+ await userOnFinish(event);
14748
+ }
14749
+ const provider = detectProviderFromResult(event);
14750
+ const model = extractModelFromResult(event);
14751
+ const finishReason = normalizeFinishReason(event?.finishReason);
14752
+ span.log({
14753
+ output: event?.text,
14754
+ metadata: {
14755
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14756
+ ...provider ? { provider } : {},
14757
+ ...model ? { model } : {},
14758
+ ...finishReason ? { finish_reason: finishReason } : {}
14759
+ }
14760
+ });
14761
+ span.end();
14762
+ },
14763
+ onError: async (err) => {
14764
+ if (typeof userOnError === "function") {
14765
+ await userOnError(err);
14766
+ }
14767
+ span.log({
14768
+ error: err instanceof Error ? err.message : String(err)
14769
+ });
14770
+ span.end();
14771
+ }
14772
+ })
14773
+ );
14774
+ return result;
14775
+ } catch (error2) {
14776
+ span.log({
14777
+ error: error2 instanceof Error ? error2.message : String(error2)
14778
+ });
14779
+ span.end();
14780
+ throw error2;
14781
+ }
14782
+ };
14783
+ const wrappedStreamObject = (params) => {
14784
+ const span = startSpan({
14785
+ name: "ai-sdk.streamObject",
14786
+ event: {
14787
+ input: extractInput(params),
14788
+ metadata: extractModelParameters(params, V3_EXCLUDE_KEYS)
14789
+ }
14790
+ });
14791
+ const userOnFinish = params.onFinish;
14792
+ const userOnError = params.onError;
14793
+ try {
14794
+ const wrappedModel = wrapLanguageModel({
14795
+ model: params.model,
14796
+ middleware: BraintrustMiddleware()
14797
+ });
14798
+ const startTime = Date.now();
14799
+ const result = withCurrent(
14800
+ span,
14801
+ () => streamObject({
14802
+ ...params,
14803
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14804
+ model: wrappedModel,
14805
+ onFinish: async (event) => {
14806
+ if (typeof userOnFinish === "function") {
14807
+ await userOnFinish(event);
14808
+ }
14809
+ const provider = detectProviderFromResult(event);
14810
+ const model = extractModelFromResult(event);
14811
+ const finishReason = normalizeFinishReason(event?.finishReason);
14812
+ span.log({
14813
+ output: event?.object,
14814
+ metadata: {
14815
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14816
+ ...provider ? { provider } : {},
14817
+ ...model ? { model } : {},
14818
+ ...finishReason ? { finish_reason: finishReason } : {}
14819
+ }
14820
+ });
14821
+ span.end();
14822
+ },
14823
+ onError: async (err) => {
14824
+ if (typeof userOnError === "function") {
14825
+ await userOnError(err);
14826
+ }
14827
+ span.log({
14828
+ error: err instanceof Error ? err.message : String(err)
14829
+ });
14830
+ span.end();
14831
+ }
14832
+ })
14833
+ );
14834
+ const wrapStream = wrapStreamObject(result.partialObjectStream, () => {
14835
+ span.log({
14836
+ metrics: { time_to_first_token: (Date.now() - startTime) / 1e3 }
14837
+ });
14838
+ });
14839
+ return {
14840
+ ...result,
14841
+ partialObjectStream: wrapStream
14842
+ };
14843
+ } catch (error2) {
14844
+ span.log({
14845
+ error: error2 instanceof Error ? error2.message : String(error2)
14846
+ });
14847
+ span.end();
14848
+ throw error2;
14849
+ }
14850
+ };
14851
+ return {
14852
+ generateText: wrappedGenerateText,
14853
+ generateObject: wrappedGenerateObject,
14854
+ streamText: wrappedStreamText,
14855
+ streamObject: wrappedStreamObject
14856
+ };
14857
+ }
14858
+
14859
+ // src/wrappers/mastra.ts
14860
+ var aiSDKFormatWarning = false;
14861
+ function wrapMastraAgent(agent, options) {
14862
+ const prefix = options?.name ?? options?.span_name ?? agent.name ?? "Agent";
14863
+ if (!hasAllMethods(agent)) {
14864
+ return agent;
14865
+ }
14866
+ if (agent.tools) {
14867
+ agent.__setTools(wrapTools(agent.tools));
14868
+ }
14869
+ return new Proxy(agent, {
14870
+ get(target, prop, receiver) {
14871
+ const value = Reflect.get(target, prop, receiver);
14872
+ if (prop === "generateVNext" && typeof value === "function") {
14873
+ return wrapGenerateVNext(value, target, prefix);
14874
+ }
14875
+ if (prop === "streamVNext" && typeof value === "function") {
14876
+ return wrapStreamVNext(value, target, prefix);
14877
+ }
14878
+ if (typeof value === "function") {
14879
+ return value.bind(target);
14880
+ }
14881
+ return value;
14882
+ }
14883
+ });
14884
+ }
14885
+ function hasAllMethods(a) {
14886
+ return typeof a.generateVNext === "function" && typeof a.streamVNext === "function";
14887
+ }
14888
+ function wrapGenerateVNext(original, target, prefix) {
14889
+ return function(...args) {
14890
+ const input = args[0];
14891
+ return traced(
14892
+ async (span) => {
14893
+ const result = await original.apply(target, args);
14894
+ const provider = detectProviderFromResult(result);
14895
+ const model = extractModelFromResult(result);
14896
+ const finishReason = normalizeFinishReason(result?.finishReason);
14897
+ const metrics = result?.usage ? normalizeUsageMetrics(
14898
+ result.usage,
14899
+ provider,
14900
+ result.providerMetadata
14901
+ ) : {};
14902
+ span.log({
14903
+ input,
14904
+ output: result,
14905
+ metadata: {
14906
+ agent_name: target.name ?? prefix,
14907
+ ...provider ? { provider } : {},
14908
+ ...model ? { model } : {},
14909
+ ...finishReason ? { finish_reason: finishReason } : {}
14910
+ },
14911
+ metrics
14912
+ });
14913
+ return result;
14914
+ },
14915
+ {
14916
+ name: `${prefix}.generateVNext`
14917
+ }
14918
+ );
14919
+ };
14920
+ }
14921
+ function wrapStreamVNext(original, target, prefix) {
14922
+ return function(...args) {
14923
+ const input = args[0];
14924
+ const span = startSpan({
14925
+ name: `${prefix}.streamVNext`,
14926
+ event: {
14927
+ input,
14928
+ metadata: {
14929
+ agent_name: target.name ?? prefix
14930
+ }
14931
+ }
14932
+ });
14933
+ const baseOpts = typeof args[1] === "object" && args[1] !== null ? args[1] : {};
14934
+ if (baseOpts.format && baseOpts.format !== "aisdk" && !aiSDKFormatWarning) {
14935
+ aiSDKFormatWarning = true;
14936
+ console.warn(
14937
+ `Braintrust Mastra wrapper: For best compatibility, use { format: 'aisdk' } (AI SDK v5) instead of format: '${baseOpts.format}'. See https://mastra.ai/en/docs/frameworks/agentic-uis/ai-sdk for more details.`
14938
+ );
14939
+ }
14940
+ const wrappedOpts = {
14941
+ ...baseOpts,
14942
+ format: baseOpts.format || "aisdk"
14943
+ // Default to AI SDK v5 format if not specified
14944
+ };
14945
+ const userOnChunk = baseOpts?.onChunk;
14946
+ const userOnFinish = baseOpts?.onFinish;
14947
+ const userOnError = baseOpts?.onError;
14948
+ const startTime = Date.now();
14949
+ let receivedFirst = false;
14950
+ wrappedOpts.onChunk = (chunk) => {
14951
+ try {
14952
+ userOnChunk?.(chunk);
14953
+ } finally {
14954
+ if (!receivedFirst) {
14955
+ receivedFirst = true;
14956
+ span.log({
14957
+ metrics: { time_to_first_token: (Date.now() - startTime) / 1e3 }
14958
+ });
14959
+ }
14960
+ }
14961
+ };
14962
+ wrappedOpts.onFinish = async (event) => {
14963
+ try {
14964
+ await userOnFinish?.(event);
14965
+ } finally {
14966
+ const e = event;
14967
+ const provider = detectProviderFromResult(e);
14968
+ const model = extractModelFromResult(e);
14969
+ const finishReason = normalizeFinishReason(e?.finishReason);
14970
+ const metrics = e?.usage ? normalizeUsageMetrics(e.usage, provider, e.providerMetadata) : {};
14971
+ span.log({
14972
+ output: e.text ?? e.content ?? e,
14973
+ metadata: {
14974
+ agent_name: target.name ?? prefix,
14975
+ ...provider ? { provider } : {},
14976
+ ...model ? { model } : {},
14977
+ ...finishReason ? { finish_reason: finishReason } : {}
14978
+ },
14979
+ metrics
14980
+ });
14981
+ span.end();
14982
+ }
14983
+ };
14984
+ wrappedOpts.onError = async (err) => {
14985
+ try {
14986
+ await userOnError?.(err);
14987
+ } finally {
14988
+ logError(span, err);
14989
+ span.end();
14990
+ }
14991
+ };
14992
+ return withCurrent(
14993
+ span,
14994
+ () => original.apply(target, [args[0], wrappedOpts, ...args.slice(2)])
14995
+ );
14996
+ };
14997
+ }
14998
+
13444
14999
  // src/wrappers/anthropic.ts
13445
- import { SpanTypeAttribute as SpanTypeAttribute5 } from "@braintrust/core";
13446
15000
  function wrapAnthropic(anthropic) {
13447
15001
  const au = anthropic;
13448
15002
  if (au && typeof au === "object" && "messages" in au && typeof au.messages === "object" && au.messages && "create" in au.messages) {
@@ -13500,7 +15054,7 @@ function createProxy(create) {
13500
15054
  const spanArgs = {
13501
15055
  name: "anthropic.messages.create",
13502
15056
  spanAttributes: {
13503
- type: SpanTypeAttribute5.LLM
15057
+ type: "llm" /* LLM */
13504
15058
  },
13505
15059
  event: {
13506
15060
  input,
@@ -13844,6 +15398,15 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
13844
15398
  if (!span.instrumentationScope && span.instrumentationLibrary) {
13845
15399
  span.instrumentationScope = span.instrumentationLibrary;
13846
15400
  }
15401
+ if (!span.parentSpanContext && span.parentSpanId) {
15402
+ const spanContext = span.spanContext?.();
15403
+ if (spanContext?.traceId) {
15404
+ span.parentSpanContext = {
15405
+ spanId: span.parentSpanId,
15406
+ traceId: spanContext.traceId
15407
+ };
15408
+ }
15409
+ }
13847
15410
  return span;
13848
15411
  });
13849
15412
  return Reflect.apply(target.export, target, [
@@ -13934,44 +15497,44 @@ var BraintrustExporter = class _BraintrustExporter {
13934
15497
  };
13935
15498
 
13936
15499
  // dev/types.ts
13937
- import { z as z6 } from "zod";
13938
- var evalBodySchema = z6.object({
13939
- name: z6.string(),
13940
- parameters: z6.record(z6.string(), z6.unknown()).nullish(),
15500
+ import { z as z10 } from "zod/v3";
15501
+ var evalBodySchema = z10.object({
15502
+ name: z10.string(),
15503
+ parameters: z10.record(z10.string(), z10.unknown()).nullish(),
13941
15504
  data: RunEval.shape.data,
13942
- scores: z6.array(
13943
- z6.object({
15505
+ scores: z10.array(
15506
+ z10.object({
13944
15507
  function_id: FunctionId,
13945
- name: z6.string()
15508
+ name: z10.string()
13946
15509
  })
13947
15510
  ).nullish(),
13948
- experiment_name: z6.string().nullish(),
13949
- project_id: z6.string().nullish(),
15511
+ experiment_name: z10.string().nullish(),
15512
+ project_id: z10.string().nullish(),
13950
15513
  parent: InvokeParent.optional(),
13951
- stream: z6.boolean().optional()
15514
+ stream: z10.boolean().optional()
13952
15515
  });
13953
- var evalParametersSerializedSchema = z6.record(
13954
- z6.string(),
13955
- z6.union([
13956
- z6.object({
13957
- type: z6.literal("prompt"),
15516
+ var evalParametersSerializedSchema = z10.record(
15517
+ z10.string(),
15518
+ z10.union([
15519
+ z10.object({
15520
+ type: z10.literal("prompt"),
13958
15521
  default: PromptData.optional(),
13959
- description: z6.string().optional()
15522
+ description: z10.string().optional()
13960
15523
  }),
13961
- z6.object({
13962
- type: z6.literal("data"),
13963
- schema: z6.record(z6.unknown()),
15524
+ z10.object({
15525
+ type: z10.literal("data"),
15526
+ schema: z10.record(z10.unknown()),
13964
15527
  // JSON Schema
13965
- default: z6.unknown().optional(),
13966
- description: z6.string().optional()
15528
+ default: z10.unknown().optional(),
15529
+ description: z10.string().optional()
13967
15530
  })
13968
15531
  ])
13969
15532
  );
13970
- var evaluatorDefinitionSchema = z6.object({
15533
+ var evaluatorDefinitionSchema = z10.object({
13971
15534
  parameters: evalParametersSerializedSchema.optional()
13972
15535
  });
13973
- var evaluatorDefinitionsSchema = z6.record(
13974
- z6.string(),
15536
+ var evaluatorDefinitionsSchema = z10.record(
15537
+ z10.string(),
13975
15538
  evaluatorDefinitionSchema
13976
15539
  );
13977
15540
 
@@ -14025,6 +15588,7 @@ export {
14025
15588
  currentExperiment,
14026
15589
  currentLogger,
14027
15590
  currentSpan,
15591
+ deepCopyEvent,
14028
15592
  index_default as default,
14029
15593
  defaultErrorScoreHandler,
14030
15594
  deserializePlainStringAsJSON,
@@ -14072,8 +15636,10 @@ export {
14072
15636
  withExperiment,
14073
15637
  withLogger,
14074
15638
  withParent,
15639
+ wrapAISDK,
14075
15640
  wrapAISDKModel,
14076
15641
  wrapAnthropic,
15642
+ wrapMastraAgent,
14077
15643
  wrapOpenAI,
14078
15644
  wrapOpenAIv4,
14079
15645
  wrapTraced