braintrust 0.3.6 → 0.3.7

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);
@@ -5523,14 +6487,14 @@ var NoopSpan = class {
5523
6487
  };
5524
6488
  var NOOP_SPAN = new NoopSpan();
5525
6489
  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(),
6490
+ var loginSchema = z7.strictObject({
6491
+ appUrl: z7.string(),
6492
+ appPublicUrl: z7.string(),
6493
+ orgName: z7.string(),
6494
+ apiUrl: z7.string(),
6495
+ proxyUrl: z7.string(),
6496
+ loginToken: z7.string(),
6497
+ orgId: z7.string().nullish(),
5534
6498
  gitMetadataSettings: GitMetadataSettings.nullish()
5535
6499
  });
5536
6500
  var stateNonce = 0;
@@ -6007,9 +6971,9 @@ var Attachment = class extends BaseAttachment {
6007
6971
  let signedUrl;
6008
6972
  let headers;
6009
6973
  try {
6010
- ({ signedUrl, headers } = z3.object({
6011
- signedUrl: z3.string().url(),
6012
- headers: z3.record(z3.string())
6974
+ ({ signedUrl, headers } = z7.object({
6975
+ signedUrl: z7.string().url(),
6976
+ headers: z7.record(z7.string())
6013
6977
  }).parse(await metadataResponse.json()));
6014
6978
  } catch (error2) {
6015
6979
  if (error2 instanceof ZodError) {
@@ -6164,8 +7128,8 @@ var ExternalAttachment = class extends BaseAttachment {
6164
7128
  });
6165
7129
  }
6166
7130
  };
6167
- var attachmentMetadataSchema = z3.object({
6168
- downloadUrl: z3.string(),
7131
+ var attachmentMetadataSchema = z7.object({
7132
+ downloadUrl: z7.string(),
6169
7133
  status: AttachmentStatus
6170
7134
  });
6171
7135
  var ReadonlyAttachment = class {
@@ -6377,15 +7341,15 @@ function spanComponentsToObjectIdLambda(state, components) {
6377
7341
  );
6378
7342
  }
6379
7343
  switch (components.data.object_type) {
6380
- case SpanObjectTypeV3.EXPERIMENT:
7344
+ case 1 /* EXPERIMENT */:
6381
7345
  throw new Error(
6382
7346
  "Impossible: computeObjectMetadataArgs not supported for experiments"
6383
7347
  );
6384
- case SpanObjectTypeV3.PLAYGROUND_LOGS:
7348
+ case 3 /* PLAYGROUND_LOGS */:
6385
7349
  throw new Error(
6386
7350
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
6387
7351
  );
6388
- case SpanObjectTypeV3.PROJECT_LOGS:
7352
+ case 2 /* PROJECT_LOGS */:
6389
7353
  return async () => (await computeLoggerMetadata(state, {
6390
7354
  ...components.data.compute_object_metadata_args
6391
7355
  })).project.id;
@@ -6537,7 +7501,7 @@ var Logger = class {
6537
7501
  return (async () => (await this.project).id)();
6538
7502
  }
6539
7503
  parentObjectType() {
6540
- return SpanObjectTypeV3.PROJECT_LOGS;
7504
+ return 2 /* PROJECT_LOGS */;
6541
7505
  }
6542
7506
  /**
6543
7507
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -6631,7 +7595,7 @@ var Logger = class {
6631
7595
  parentSpanIds: args?.parentSpanIds,
6632
7596
  propagatedEvent: args?.propagatedEvent
6633
7597
  }),
6634
- defaultRootType: SpanTypeAttribute.TASK
7598
+ defaultRootType: "task" /* TASK */
6635
7599
  });
6636
7600
  }
6637
7601
  /**
@@ -7749,6 +8713,8 @@ function getSpanParentObject(options) {
7749
8713
  if (!Object.is(parentSpan, NOOP_SPAN)) {
7750
8714
  return parentSpan;
7751
8715
  }
8716
+ const parentStr = options?.parent ?? state.currentParent.getStore();
8717
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
7752
8718
  const experiment = currentExperiment();
7753
8719
  if (experiment) {
7754
8720
  return experiment;
@@ -7965,35 +8931,35 @@ function setFetch(fetch2) {
7965
8931
  }
7966
8932
  function startSpanAndIsLogger(args) {
7967
8933
  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
8934
+ const parentObject = getSpanParentObject({
8935
+ asyncFlush: args?.asyncFlush,
8936
+ parent: args?.parent,
8937
+ state
8938
+ });
8939
+ if (parentObject instanceof SpanComponentsV3) {
8940
+ const parentSpanIds = parentObject.data.row_id ? {
8941
+ spanId: parentObject.data.span_id,
8942
+ rootSpanId: parentObject.data.root_span_id
7974
8943
  } : void 0;
7975
8944
  const span = new SpanImpl({
7976
8945
  state,
7977
8946
  ...args,
7978
- parentObjectType: components.data.object_type,
8947
+ parentObjectType: parentObject.data.object_type,
7979
8948
  parentObjectId: new LazyValue(
7980
- spanComponentsToObjectIdLambda(state, components)
8949
+ spanComponentsToObjectIdLambda(state, parentObject)
7981
8950
  ),
7982
- parentComputeObjectMetadataArgs: components.data.compute_object_metadata_args ?? void 0,
8951
+ parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
7983
8952
  parentSpanIds,
7984
8953
  propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
7985
- (components.data.propagated_event ?? void 0)
8954
+ (parentObject.data.propagated_event ?? void 0)
7986
8955
  });
7987
8956
  return {
7988
8957
  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
8958
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
7990
8959
  // behavior, and therefore propagate along whatever we get from the arguments
7991
8960
  args?.asyncFlush === false
7992
8961
  };
7993
8962
  } else {
7994
- const parentObject = getSpanParentObject({
7995
- asyncFlush: args?.asyncFlush
7996
- });
7997
8963
  const span = parentObject.startSpan(args);
7998
8964
  return {
7999
8965
  span,
@@ -8143,7 +9109,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
8143
9109
  function deepCopyEvent(event) {
8144
9110
  const attachments = [];
8145
9111
  const IDENTIFIER = "_bt_internal_saved_attachment";
8146
- const savedAttachmentSchema = z3.strictObject({ [IDENTIFIER]: z3.number() });
9112
+ const savedAttachmentSchema = z7.strictObject({ [IDENTIFIER]: z7.number() });
8147
9113
  const serialized = JSON.stringify(event, (_k, v) => {
8148
9114
  if (v instanceof SpanImpl || v instanceof NoopSpan) {
8149
9115
  return `<span>`;
@@ -8378,7 +9344,7 @@ var Experiment2 = class extends ObjectFetcher {
8378
9344
  })();
8379
9345
  }
8380
9346
  parentObjectType() {
8381
- return SpanObjectTypeV3.EXPERIMENT;
9347
+ return 1 /* EXPERIMENT */;
8382
9348
  }
8383
9349
  async getState() {
8384
9350
  await this.lazyMetadata.get();
@@ -8462,7 +9428,7 @@ var Experiment2 = class extends ObjectFetcher {
8462
9428
  parentSpanIds: void 0,
8463
9429
  propagatedEvent: args?.propagatedEvent
8464
9430
  }),
8465
- defaultRootType: SpanTypeAttribute.EVAL
9431
+ defaultRootType: "eval" /* EVAL */
8466
9432
  });
8467
9433
  }
8468
9434
  async fetchBaseExperiment() {
@@ -8881,7 +9847,7 @@ var SpanImpl = class _SpanImpl {
8881
9847
  const baseUrl = `${appUrl}/app/${orgName}`;
8882
9848
  const args = this.parentComputeObjectMetadataArgs;
8883
9849
  switch (this.parentObjectType) {
8884
- case SpanObjectTypeV3.PROJECT_LOGS: {
9850
+ case 2 /* PROJECT_LOGS */: {
8885
9851
  const projectID = args?.project_id || this.parentObjectId.getSync().value;
8886
9852
  const projectName = args?.project_name;
8887
9853
  if (projectID) {
@@ -8892,7 +9858,7 @@ var SpanImpl = class _SpanImpl {
8892
9858
  return getErrPermlink("provide-project-name-or-id");
8893
9859
  }
8894
9860
  }
8895
- case SpanObjectTypeV3.EXPERIMENT: {
9861
+ case 1 /* EXPERIMENT */: {
8896
9862
  const expID = args?.experiment_id || this.parentObjectId?.getSync()?.value;
8897
9863
  if (!expID) {
8898
9864
  return getErrPermlink("provide-experiment-id");
@@ -8900,7 +9866,7 @@ var SpanImpl = class _SpanImpl {
8900
9866
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
8901
9867
  }
8902
9868
  }
8903
- case SpanObjectTypeV3.PLAYGROUND_LOGS: {
9869
+ case 3 /* PLAYGROUND_LOGS */: {
8904
9870
  return NOOP_SPAN_PERMALINK;
8905
9871
  }
8906
9872
  default: {
@@ -9148,8 +10114,8 @@ var Dataset2 = class extends ObjectFetcher {
9148
10114
  )}`;
9149
10115
  let dataSummary;
9150
10116
  if (summarizeData) {
9151
- const rawDataSummary = z3.object({
9152
- total_records: z3.number()
10117
+ const rawDataSummary = z7.object({
10118
+ total_records: z7.number()
9153
10119
  }).parse(
9154
10120
  await state.apiConn().get_json(
9155
10121
  "dataset-summary",
@@ -9272,11 +10238,11 @@ function renderTemplatedObject(obj, args, options) {
9272
10238
  return obj;
9273
10239
  }
9274
10240
  function renderPromptParams(params, args, options) {
9275
- const schemaParsed = z3.object({
9276
- response_format: z3.object({
9277
- type: z3.literal("json_schema"),
10241
+ const schemaParsed = z7.object({
10242
+ response_format: z7.object({
10243
+ type: z7.literal("json_schema"),
9278
10244
  json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
9279
- schema: z3.unknown()
10245
+ schema: z7.unknown()
9280
10246
  })
9281
10247
  })
9282
10248
  }).safeParse(params);
@@ -9394,7 +10360,7 @@ var Prompt2 = class _Prompt {
9394
10360
  if (!prompt) {
9395
10361
  throw new Error("Empty prompt");
9396
10362
  }
9397
- const dictArgParsed = z3.record(z3.unknown()).safeParse(buildArgs);
10363
+ const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
9398
10364
  const variables = {
9399
10365
  input: buildArgs,
9400
10366
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -9449,7 +10415,7 @@ var Prompt2 = class _Prompt {
9449
10415
  return JSON.stringify(v);
9450
10416
  }
9451
10417
  };
9452
- const dictArgParsed = z3.record(z3.unknown()).safeParse(buildArgs);
10418
+ const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
9453
10419
  const variables = {
9454
10420
  input: buildArgs,
9455
10421
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -9725,6 +10691,7 @@ __export(exports_node_exports, {
9725
10691
  withExperiment: () => withExperiment,
9726
10692
  withLogger: () => withLogger,
9727
10693
  withParent: () => withParent,
10694
+ wrapAISDK: () => wrapAISDK,
9728
10695
  wrapAISDKModel: () => wrapAISDKModel,
9729
10696
  wrapAnthropic: () => wrapAnthropic,
9730
10697
  wrapOpenAI: () => wrapOpenAI,
@@ -9820,9 +10787,6 @@ function initFunction({
9820
10787
  return f;
9821
10788
  }
9822
10789
 
9823
- // src/framework.ts
9824
- import { SpanTypeAttribute as SpanTypeAttribute2, mergeDicts as mergeDicts2 } from "@braintrust/core";
9825
-
9826
10790
  // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
9827
10791
  function initialParams(fn) {
9828
10792
  return function(...args) {
@@ -10902,13 +11866,12 @@ var BarProgressReporter = class {
10902
11866
  };
10903
11867
 
10904
11868
  // src/eval-parameters.ts
10905
- import { z as z5 } from "zod";
11869
+ import { z as z9 } from "zod/v3";
10906
11870
 
10907
11871
  // src/framework2.ts
10908
11872
  import path2 from "path";
10909
11873
  import slugifyLib from "slugify";
10910
- import { z as z4 } from "zod";
10911
- import { loadPrettyXact } from "@braintrust/core";
11874
+ import { z as z8 } from "zod/v3";
10912
11875
  var ProjectBuilder = class {
10913
11876
  create(opts) {
10914
11877
  return new Project2(opts);
@@ -11142,23 +12105,23 @@ var CodePrompt = class {
11142
12105
  };
11143
12106
  }
11144
12107
  };
11145
- var promptContentsSchema = z4.union([
11146
- z4.object({
11147
- prompt: z4.string()
12108
+ var promptContentsSchema = z8.union([
12109
+ z8.object({
12110
+ prompt: z8.string()
11148
12111
  }),
11149
- z4.object({
11150
- messages: z4.array(ChatCompletionMessageParam)
12112
+ z8.object({
12113
+ messages: z8.array(ChatCompletionMessageParam)
11151
12114
  })
11152
12115
  ]);
11153
12116
  var promptDefinitionSchema = promptContentsSchema.and(
11154
- z4.object({
11155
- model: z4.string(),
12117
+ z8.object({
12118
+ model: z8.string(),
11156
12119
  params: ModelParams.optional()
11157
12120
  })
11158
12121
  );
11159
12122
  var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
11160
- z4.object({
11161
- tools: z4.array(ToolFunctionDefinition).optional()
12123
+ z8.object({
12124
+ tools: z8.array(ToolFunctionDefinition).optional()
11162
12125
  })
11163
12126
  );
11164
12127
  var PromptBuilder = class {
@@ -11226,7 +12189,7 @@ var ProjectNameIdMap = class {
11226
12189
  const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
11227
12190
  project_name: projectName
11228
12191
  });
11229
- const result = z4.object({
12192
+ const result = z8.object({
11230
12193
  project: Project
11231
12194
  }).parse(response);
11232
12195
  const projectId = result.project.id;
@@ -11240,7 +12203,7 @@ var ProjectNameIdMap = class {
11240
12203
  const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
11241
12204
  id: projectId
11242
12205
  });
11243
- const result = z4.array(Project).nonempty().parse(response);
12206
+ const result = z8.array(Project).nonempty().parse(response);
11244
12207
  const projectName = result[0].name;
11245
12208
  this.idToName[projectId] = projectName;
11246
12209
  this.nameToId[projectName] = projectId;
@@ -11256,15 +12219,15 @@ var ProjectNameIdMap = class {
11256
12219
  };
11257
12220
 
11258
12221
  // src/eval-parameters.ts
11259
- var evalParametersSchema = z5.record(
11260
- z5.string(),
11261
- z5.union([
11262
- z5.object({
11263
- type: z5.literal("prompt"),
12222
+ var evalParametersSchema = z9.record(
12223
+ z9.string(),
12224
+ z9.union([
12225
+ z9.object({
12226
+ type: z9.literal("prompt"),
11264
12227
  default: promptDefinitionWithToolsSchema.optional(),
11265
- description: z5.string().optional()
12228
+ description: z9.string().optional()
11266
12229
  }),
11267
- z5.instanceof(z5.ZodType)
12230
+ z9.instanceof(z9.ZodType)
11268
12231
  // For Zod schemas
11269
12232
  ])
11270
12233
  );
@@ -11566,7 +12529,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11566
12529
  const baseEvent = {
11567
12530
  name: "eval",
11568
12531
  spanAttributes: {
11569
- type: SpanTypeAttribute2.EVAL
12532
+ type: "eval" /* EVAL */
11570
12533
  },
11571
12534
  event: {
11572
12535
  input: datum.input,
@@ -11626,7 +12589,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11626
12589
  },
11627
12590
  {
11628
12591
  name: "task",
11629
- spanAttributes: { type: SpanTypeAttribute2.TASK },
12592
+ spanAttributes: { type: "task" /* TASK */ },
11630
12593
  event: { input: datum.input }
11631
12594
  }
11632
12595
  );
@@ -11672,17 +12635,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11672
12635
  return rest;
11673
12636
  };
11674
12637
  const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
11675
- (prev, s) => mergeDicts2(prev, {
12638
+ (prev, s) => mergeDicts(prev, {
11676
12639
  [s.name]: s.metadata
11677
12640
  }),
11678
12641
  {}
11679
12642
  );
11680
12643
  const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
11681
- (prev, s) => mergeDicts2(prev, { [s.name]: getOtherFields(s) }),
12644
+ (prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
11682
12645
  {}
11683
12646
  );
11684
12647
  const scores2 = results3.reduce(
11685
- (prev, s) => mergeDicts2(prev, { [s.name]: s.score }),
12648
+ (prev, s) => mergeDicts(prev, { [s.name]: s.score }),
11686
12649
  {}
11687
12650
  );
11688
12651
  span.log({
@@ -11695,7 +12658,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
11695
12658
  const results2 = await rootSpan.traced(runScorer, {
11696
12659
  name: scorerNames[score_idx],
11697
12660
  spanAttributes: {
11698
- type: SpanTypeAttribute2.SCORE
12661
+ type: "score" /* SCORE */
11699
12662
  },
11700
12663
  event: { input: scoringArgs }
11701
12664
  });
@@ -12038,11 +13001,11 @@ var GraphBuilder = class {
12038
13001
  // }
12039
13002
  // Helper to generate node IDs
12040
13003
  generateId(name) {
12041
- const uuid = newId();
13004
+ const uuid4 = newId();
12042
13005
  if (name) {
12043
- return `${name}-${uuid.slice(0, 8)}`;
13006
+ return `${name}-${uuid4.slice(0, 8)}`;
12044
13007
  } else {
12045
- return uuid;
13008
+ return uuid4;
12046
13009
  }
12047
13010
  }
12048
13011
  // Create an input node
@@ -12195,12 +13158,7 @@ function unescapePath(path3) {
12195
13158
  }
12196
13159
  var graph_framework_default = { createGraph };
12197
13160
 
12198
- // src/wrappers/oai.ts
12199
- import { SpanTypeAttribute as SpanTypeAttribute3 } from "@braintrust/core";
12200
- import { mergeDicts as mergeDicts3 } from "@braintrust/core";
12201
-
12202
13161
  // src/wrappers/oai_responses.ts
12203
- import { isObject as isObject2 } from "@braintrust/core";
12204
13162
  function responsesProxy(openai) {
12205
13163
  if (!openai.responses) {
12206
13164
  return openai;
@@ -12398,7 +13356,7 @@ function parseMetricsFromUsage(usage) {
12398
13356
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
12399
13357
  metrics[metricName] = value;
12400
13358
  } else if (oai_name.endsWith("_tokens_details")) {
12401
- if (!isObject2(value)) {
13359
+ if (!isObject(value)) {
12402
13360
  continue;
12403
13361
  }
12404
13362
  const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
@@ -12580,11 +13538,11 @@ function wrapBetaChatCompletionParse(completion) {
12580
13538
  return async (allParams) => {
12581
13539
  const { span_info: _, ...params } = allParams;
12582
13540
  const span = startSpan(
12583
- mergeDicts3(
13541
+ mergeDicts(
12584
13542
  {
12585
13543
  name: "Chat Completion",
12586
13544
  spanAttributes: {
12587
- type: SpanTypeAttribute3.LLM
13545
+ type: "llm" /* LLM */
12588
13546
  }
12589
13547
  },
12590
13548
  parseChatCompletionParams(allParams)
@@ -12604,11 +13562,11 @@ function wrapBetaChatCompletionStream(completion) {
12604
13562
  return (allParams) => {
12605
13563
  const { span_info: _, ...params } = allParams;
12606
13564
  const span = startSpan(
12607
- mergeDicts3(
13565
+ mergeDicts(
12608
13566
  {
12609
13567
  name: "Chat Completion",
12610
13568
  spanAttributes: {
12611
- type: SpanTypeAttribute3.LLM
13569
+ type: "llm" /* LLM */
12612
13570
  }
12613
13571
  },
12614
13572
  parseChatCompletionParams(allParams)
@@ -12667,15 +13625,16 @@ function wrapChatCompletion(completion) {
12667
13625
  return (allParams, options) => {
12668
13626
  const { span_info: _, ...params } = allParams;
12669
13627
  let executionPromise = null;
12670
- const executeWrapped = () => {
13628
+ let dataPromise = null;
13629
+ const ensureExecuted = () => {
12671
13630
  if (!executionPromise) {
12672
13631
  executionPromise = (async () => {
12673
13632
  const span = startSpan(
12674
- mergeDicts3(
13633
+ mergeDicts(
12675
13634
  {
12676
13635
  name: "Chat Completion",
12677
13636
  spanAttributes: {
12678
- type: SpanTypeAttribute3.LLM
13637
+ type: "llm" /* LLM */
12679
13638
  }
12680
13639
  },
12681
13640
  parseChatCompletionParams(allParams)
@@ -12725,17 +13684,19 @@ function wrapChatCompletion(completion) {
12725
13684
  }
12726
13685
  return executionPromise;
12727
13686
  };
12728
- const dataPromise = executeWrapped().then((result) => result.data);
12729
- return new Proxy(dataPromise, {
13687
+ return new Proxy({}, {
12730
13688
  get(target, prop, receiver) {
12731
13689
  if (prop === "withResponse") {
12732
- return executeWrapped;
13690
+ return () => ensureExecuted();
12733
13691
  }
12734
- const value = Reflect.get(target, prop, receiver);
12735
- if (typeof value === "function") {
12736
- return value.bind(target);
13692
+ if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
13693
+ if (!dataPromise) {
13694
+ dataPromise = ensureExecuted().then((result) => result.data);
13695
+ }
13696
+ const value = Reflect.get(dataPromise, prop, receiver);
13697
+ return typeof value === "function" ? value.bind(dataPromise) : value;
12737
13698
  }
12738
- return value;
13699
+ return Reflect.get(target, prop, receiver);
12739
13700
  }
12740
13701
  });
12741
13702
  };
@@ -12752,7 +13713,7 @@ function parseBaseParams(allParams, inputField) {
12752
13713
  const input = params[inputField];
12753
13714
  const paramsRest = { ...params, provider: "openai" };
12754
13715
  delete paramsRest[inputField];
12755
- return mergeDicts3(ret, { event: { input, metadata: paramsRest } });
13716
+ return mergeDicts(ret, { event: { input, metadata: paramsRest } });
12756
13717
  }
12757
13718
  function createApiWrapper(name, create, processResponse, parseParams) {
12758
13719
  return async (allParams, options) => {
@@ -12767,11 +13728,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
12767
13728
  processResponse(result, span);
12768
13729
  return result;
12769
13730
  },
12770
- mergeDicts3(
13731
+ mergeDicts(
12771
13732
  {
12772
13733
  name,
12773
13734
  spanAttributes: {
12774
- type: SpanTypeAttribute3.LLM
13735
+ type: "llm" /* LLM */
12775
13736
  }
12776
13737
  },
12777
13738
  parseParams(allParams)
@@ -12909,9 +13870,6 @@ var WrapperStream = class {
12909
13870
  }
12910
13871
  };
12911
13872
 
12912
- // src/wrappers/ai-sdk-v2.ts
12913
- import { SpanTypeAttribute as SpanTypeAttribute4 } from "@braintrust/core";
12914
-
12915
13873
  // src/wrappers/anthropic-tokens-util.ts
12916
13874
  function finalizeAnthropicTokens(metrics) {
12917
13875
  const prompt_tokens = (metrics.prompt_tokens || 0) + (metrics.prompt_cached_tokens || 0) + (metrics.prompt_cache_creation_tokens || 0);
@@ -12932,7 +13890,7 @@ function extractAnthropicCacheTokens(cacheReadTokens = 0, cacheCreationTokens =
12932
13890
  return cacheTokens;
12933
13891
  }
12934
13892
 
12935
- // src/wrappers/ai-sdk-v2.ts
13893
+ // src/wrappers/ai-sdk-shared.ts
12936
13894
  function detectProviderFromResult(result) {
12937
13895
  if (!result?.providerMetadata) {
12938
13896
  return void 0;
@@ -12952,20 +13910,8 @@ function extractModelFromResult(result) {
12952
13910
  function camelToSnake(str) {
12953
13911
  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
12954
13912
  }
12955
- function extractModelParameters(params) {
13913
+ function extractModelParameters(params, excludeKeys) {
12956
13914
  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
13915
  for (const [key, value] of Object.entries(params)) {
12970
13916
  if (value !== void 0 && !excludeKeys.has(key)) {
12971
13917
  const snakeKey = camelToSnake(key);
@@ -13021,18 +13967,128 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
13021
13967
  }
13022
13968
  return metrics;
13023
13969
  }
13970
+ function normalizeFinishReason(reason) {
13971
+ if (typeof reason !== "string") return void 0;
13972
+ return reason.replace(/-/g, "_");
13973
+ }
13974
+ function extractToolCallsFromSteps(steps) {
13975
+ const toolCalls = [];
13976
+ if (!Array.isArray(steps)) return toolCalls;
13977
+ let idx = 0;
13978
+ for (const step of steps) {
13979
+ const blocks = step?.content;
13980
+ if (!Array.isArray(blocks)) continue;
13981
+ for (const block of blocks) {
13982
+ if (block && typeof block === "object" && block.type === "tool-call") {
13983
+ toolCalls.push({
13984
+ id: block.toolCallId,
13985
+ type: "function",
13986
+ index: idx++,
13987
+ function: {
13988
+ name: block.toolName,
13989
+ arguments: typeof block.input === "string" ? block.input : JSON.stringify(block.input ?? {})
13990
+ }
13991
+ });
13992
+ }
13993
+ }
13994
+ }
13995
+ return toolCalls;
13996
+ }
13997
+ function buildAssistantOutputWithToolCalls(result, toolCalls) {
13998
+ return [
13999
+ {
14000
+ index: 0,
14001
+ logprobs: null,
14002
+ finish_reason: normalizeFinishReason(result?.finishReason) ?? (toolCalls.length ? "tool_calls" : void 0),
14003
+ message: {
14004
+ role: "assistant",
14005
+ tool_calls: toolCalls.length > 0 ? toolCalls : void 0
14006
+ }
14007
+ }
14008
+ ];
14009
+ }
14010
+ function extractToolCallsFromBlocks(blocks) {
14011
+ if (!Array.isArray(blocks)) return [];
14012
+ return extractToolCallsFromSteps([{ content: blocks }]);
14013
+ }
14014
+ function wrapTools(tools) {
14015
+ if (!tools) return tools;
14016
+ const inferName = (tool, fallback2) => tool && (tool.name || tool.toolName || tool.id) || fallback2;
14017
+ if (Array.isArray(tools)) {
14018
+ const arr = tools;
14019
+ const out = arr.map((tool, idx) => {
14020
+ if (tool != null && typeof tool === "object" && "execute" in tool && typeof tool.execute === "function") {
14021
+ const name = inferName(tool, `tool[${idx}]`);
14022
+ return {
14023
+ ...tool,
14024
+ execute: wrapTraced(tool.execute.bind(tool), {
14025
+ name,
14026
+ type: "tool"
14027
+ })
14028
+ };
14029
+ }
14030
+ return tool;
14031
+ });
14032
+ return out;
14033
+ }
14034
+ const wrappedTools = {};
14035
+ for (const [key, tool] of Object.entries(tools)) {
14036
+ if (tool != null && typeof tool === "object" && "execute" in tool && typeof tool.execute === "function") {
14037
+ wrappedTools[key] = {
14038
+ ...tool,
14039
+ execute: wrapTraced(tool.execute.bind(tool), {
14040
+ name: key,
14041
+ type: "tool"
14042
+ })
14043
+ };
14044
+ } else {
14045
+ wrappedTools[key] = tool;
14046
+ }
14047
+ }
14048
+ return wrappedTools;
14049
+ }
14050
+ function extractInput(params) {
14051
+ return params?.prompt ?? params?.messages ?? params?.system;
14052
+ }
14053
+ function wrapStreamObject(iterable, onFirst) {
14054
+ let sawFirst = false;
14055
+ async function* wrapStream() {
14056
+ for await (const chunk of iterable) {
14057
+ if (!sawFirst) {
14058
+ sawFirst = true;
14059
+ onFirst();
14060
+ }
14061
+ yield chunk;
14062
+ }
14063
+ }
14064
+ return wrapStream();
14065
+ }
14066
+
14067
+ // src/wrappers/ai-sdk-v2.ts
14068
+ var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
14069
+ "prompt",
14070
+ // Already captured as input
14071
+ "system",
14072
+ // Already captured as input
14073
+ "messages",
14074
+ // Already captured as input
14075
+ "model",
14076
+ // Already captured in metadata.model
14077
+ "providerOptions"
14078
+ // Internal AI SDK configuration
14079
+ ]);
13024
14080
  function BraintrustMiddleware(config = {}) {
13025
14081
  return {
13026
14082
  wrapGenerate: async ({ doGenerate, params }) => {
13027
14083
  const spanArgs = {
13028
14084
  name: "ai-sdk.generateText",
13029
14085
  spanAttributes: {
13030
- type: SpanTypeAttribute4.LLM
14086
+ type: "llm" /* LLM */
13031
14087
  },
13032
14088
  event: {
13033
14089
  input: params.prompt,
13034
14090
  metadata: {
13035
- ...extractModelParameters(params)
14091
+ ...extractModelParameters(params, V2_EXCLUDE_KEYS)
13036
14092
  }
13037
14093
  }
13038
14094
  };
@@ -13051,8 +14107,12 @@ function BraintrustMiddleware(config = {}) {
13051
14107
  if (model !== void 0) {
13052
14108
  metadata.model = model;
13053
14109
  }
14110
+ let toolCalls = extractToolCallsFromSteps(result?.steps);
14111
+ if (!toolCalls || toolCalls.length === 0) {
14112
+ toolCalls = extractToolCallsFromBlocks(result?.content);
14113
+ }
13054
14114
  span.log({
13055
- output: result.content,
14115
+ output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : result?.content,
13056
14116
  metadata,
13057
14117
  metrics: normalizeUsageMetrics(
13058
14118
  result.usage,
@@ -13074,12 +14134,12 @@ function BraintrustMiddleware(config = {}) {
13074
14134
  const spanArgs = {
13075
14135
  name: "ai-sdk.streamText",
13076
14136
  spanAttributes: {
13077
- type: SpanTypeAttribute4.LLM
14137
+ type: "llm" /* LLM */
13078
14138
  },
13079
14139
  event: {
13080
14140
  input: params.prompt,
13081
14141
  metadata: {
13082
- ...extractModelParameters(params)
14142
+ ...extractModelParameters(params, V2_EXCLUDE_KEYS)
13083
14143
  }
13084
14144
  }
13085
14145
  };
@@ -13087,6 +14147,7 @@ function BraintrustMiddleware(config = {}) {
13087
14147
  try {
13088
14148
  const { stream, ...rest } = await doStream();
13089
14149
  const textChunks = [];
14150
+ const toolBlocks = [];
13090
14151
  let finalUsage = {};
13091
14152
  let finalFinishReason = void 0;
13092
14153
  let providerMetadata = {};
@@ -13097,6 +14158,9 @@ function BraintrustMiddleware(config = {}) {
13097
14158
  if (chunk.type === "text-delta" && chunk.delta) {
13098
14159
  textChunks.push(chunk.delta);
13099
14160
  }
14161
+ if (chunk.type === "tool-call" || chunk.type === "tool-result") {
14162
+ toolBlocks.push(chunk);
14163
+ }
13100
14164
  if (chunk.type === "finish") {
13101
14165
  finalFinishReason = chunk.finishReason;
13102
14166
  finalUsage = chunk.usage || {};
@@ -13114,11 +14178,12 @@ function BraintrustMiddleware(config = {}) {
13114
14178
  flush() {
13115
14179
  try {
13116
14180
  const generatedText = textChunks.join("");
13117
- const output = generatedText ? [{ type: "text", text: generatedText }] : [];
14181
+ let output = generatedText ? [{ type: "text", text: generatedText }] : [];
13118
14182
  const resultForDetection = {
13119
14183
  providerMetadata,
13120
14184
  response: rest.response,
13121
- ...rest
14185
+ ...rest,
14186
+ finishReason: finalFinishReason
13122
14187
  };
13123
14188
  const metadata = {};
13124
14189
  const provider = detectProviderFromResult(resultForDetection);
@@ -13132,6 +14197,17 @@ function BraintrustMiddleware(config = {}) {
13132
14197
  if (model !== void 0) {
13133
14198
  metadata.model = model;
13134
14199
  }
14200
+ if (toolBlocks.length > 0) {
14201
+ const toolCalls = extractToolCallsFromSteps([
14202
+ { content: toolBlocks }
14203
+ ]);
14204
+ if (toolCalls.length > 0) {
14205
+ output = buildAssistantOutputWithToolCalls(
14206
+ resultForDetection,
14207
+ toolCalls
14208
+ );
14209
+ }
14210
+ }
13135
14211
  span.log({
13136
14212
  output,
13137
14213
  metadata,
@@ -13441,8 +14517,245 @@ function postProcessOutput(text, toolCalls, finishReason) {
13441
14517
  ];
13442
14518
  }
13443
14519
 
14520
+ // src/wrappers/ai-sdk-v3.ts
14521
+ var V3_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
14522
+ "prompt",
14523
+ // Already captured as input
14524
+ "system",
14525
+ // Already captured as input
14526
+ "messages",
14527
+ // Already captured as input
14528
+ "model",
14529
+ // Already captured in metadata.model
14530
+ "providerOptions",
14531
+ // Internal AI SDK configuration
14532
+ "tools"
14533
+ // Already captured in metadata.tools
14534
+ ]);
14535
+ function wrapAISDK(ai) {
14536
+ const {
14537
+ wrapLanguageModel,
14538
+ generateText,
14539
+ streamText,
14540
+ generateObject,
14541
+ streamObject
14542
+ } = ai;
14543
+ const wrappedGenerateText = (params) => {
14544
+ return traced(
14545
+ async (span) => {
14546
+ const wrappedModel = wrapLanguageModel({
14547
+ model: params.model,
14548
+ middleware: BraintrustMiddleware()
14549
+ });
14550
+ const result = await generateText({
14551
+ ...params,
14552
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14553
+ model: wrappedModel
14554
+ });
14555
+ const provider = detectProviderFromResult(result);
14556
+ const model = extractModelFromResult(result);
14557
+ const finishReason = normalizeFinishReason(result?.finishReason);
14558
+ span.log({
14559
+ input: extractInput(params),
14560
+ output: result.text,
14561
+ metadata: {
14562
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14563
+ ...provider ? { provider } : {},
14564
+ ...model ? { model } : {},
14565
+ ...finishReason ? { finish_reason: finishReason } : {}
14566
+ }
14567
+ });
14568
+ return result;
14569
+ },
14570
+ {
14571
+ name: "ai-sdk.generateText"
14572
+ }
14573
+ );
14574
+ };
14575
+ const wrappedGenerateObject = (params) => {
14576
+ return traced(
14577
+ async (span) => {
14578
+ const wrappedModel = wrapLanguageModel({
14579
+ model: params.model,
14580
+ middleware: BraintrustMiddleware()
14581
+ });
14582
+ const result = await generateObject({
14583
+ ...params,
14584
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14585
+ model: wrappedModel
14586
+ });
14587
+ const provider = detectProviderFromResult(result);
14588
+ const model = extractModelFromResult(result);
14589
+ const finishReason = normalizeFinishReason(result.finishReason);
14590
+ span.log({
14591
+ input: extractInput(params),
14592
+ output: result.object,
14593
+ metadata: {
14594
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14595
+ ...provider ? { provider } : {},
14596
+ ...model ? { model } : {},
14597
+ ...finishReason ? { finish_reason: finishReason } : {}
14598
+ }
14599
+ });
14600
+ return result;
14601
+ },
14602
+ {
14603
+ name: "ai-sdk.generateObject"
14604
+ }
14605
+ );
14606
+ };
14607
+ const wrappedStreamText = (params) => {
14608
+ const span = startSpan({
14609
+ name: "ai-sdk.streamText",
14610
+ event: {
14611
+ input: extractInput(params),
14612
+ metadata: extractModelParameters(params, V3_EXCLUDE_KEYS)
14613
+ }
14614
+ });
14615
+ const userOnFinish = params.onFinish;
14616
+ const userOnError = params.onError;
14617
+ const userOnChunk = params.onChunk;
14618
+ try {
14619
+ const wrappedModel = wrapLanguageModel({
14620
+ model: params.model,
14621
+ middleware: BraintrustMiddleware()
14622
+ });
14623
+ const startTime = Date.now();
14624
+ let receivedFirst = false;
14625
+ const result = withCurrent(
14626
+ span,
14627
+ () => streamText({
14628
+ ...params,
14629
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14630
+ model: wrappedModel,
14631
+ onChunk: (chunk) => {
14632
+ if (!receivedFirst) {
14633
+ receivedFirst = true;
14634
+ span.log({
14635
+ metrics: {
14636
+ time_to_first_token: (Date.now() - startTime) / 1e3
14637
+ }
14638
+ });
14639
+ }
14640
+ if (typeof userOnChunk === "function") {
14641
+ userOnChunk(chunk);
14642
+ }
14643
+ },
14644
+ onFinish: async (event) => {
14645
+ if (typeof userOnFinish === "function") {
14646
+ await userOnFinish(event);
14647
+ }
14648
+ const provider = detectProviderFromResult(event);
14649
+ const model = extractModelFromResult(event);
14650
+ const finishReason = normalizeFinishReason(event?.finishReason);
14651
+ span.log({
14652
+ output: event?.text,
14653
+ metadata: {
14654
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14655
+ ...provider ? { provider } : {},
14656
+ ...model ? { model } : {},
14657
+ ...finishReason ? { finish_reason: finishReason } : {}
14658
+ }
14659
+ });
14660
+ span.end();
14661
+ },
14662
+ onError: async (err) => {
14663
+ if (typeof userOnError === "function") {
14664
+ await userOnError(err);
14665
+ }
14666
+ span.log({
14667
+ error: err instanceof Error ? err.message : String(err)
14668
+ });
14669
+ span.end();
14670
+ }
14671
+ })
14672
+ );
14673
+ return result;
14674
+ } catch (error2) {
14675
+ span.log({
14676
+ error: error2 instanceof Error ? error2.message : String(error2)
14677
+ });
14678
+ span.end();
14679
+ throw error2;
14680
+ }
14681
+ };
14682
+ const wrappedStreamObject = (params) => {
14683
+ const span = startSpan({
14684
+ name: "ai-sdk.streamObject",
14685
+ event: {
14686
+ input: extractInput(params),
14687
+ metadata: extractModelParameters(params, V3_EXCLUDE_KEYS)
14688
+ }
14689
+ });
14690
+ const userOnFinish = params.onFinish;
14691
+ const userOnError = params.onError;
14692
+ try {
14693
+ const wrappedModel = wrapLanguageModel({
14694
+ model: params.model,
14695
+ middleware: BraintrustMiddleware()
14696
+ });
14697
+ const startTime = Date.now();
14698
+ const result = withCurrent(
14699
+ span,
14700
+ () => streamObject({
14701
+ ...params,
14702
+ tools: params.tools ? wrapTools(params.tools) : void 0,
14703
+ model: wrappedModel,
14704
+ onFinish: async (event) => {
14705
+ if (typeof userOnFinish === "function") {
14706
+ await userOnFinish(event);
14707
+ }
14708
+ const provider = detectProviderFromResult(event);
14709
+ const model = extractModelFromResult(event);
14710
+ const finishReason = normalizeFinishReason(event?.finishReason);
14711
+ span.log({
14712
+ output: event?.object,
14713
+ metadata: {
14714
+ ...extractModelParameters(params, V3_EXCLUDE_KEYS),
14715
+ ...provider ? { provider } : {},
14716
+ ...model ? { model } : {},
14717
+ ...finishReason ? { finish_reason: finishReason } : {}
14718
+ }
14719
+ });
14720
+ span.end();
14721
+ },
14722
+ onError: async (err) => {
14723
+ if (typeof userOnError === "function") {
14724
+ await userOnError(err);
14725
+ }
14726
+ span.log({
14727
+ error: err instanceof Error ? err.message : String(err)
14728
+ });
14729
+ span.end();
14730
+ }
14731
+ })
14732
+ );
14733
+ const wrapStream = wrapStreamObject(result.partialObjectStream, () => {
14734
+ span.log({
14735
+ metrics: { time_to_first_token: (Date.now() - startTime) / 1e3 }
14736
+ });
14737
+ });
14738
+ return {
14739
+ ...result,
14740
+ partialObjectStream: wrapStream
14741
+ };
14742
+ } catch (error2) {
14743
+ span.log({
14744
+ error: error2 instanceof Error ? error2.message : String(error2)
14745
+ });
14746
+ span.end();
14747
+ throw error2;
14748
+ }
14749
+ };
14750
+ return {
14751
+ generateText: wrappedGenerateText,
14752
+ generateObject: wrappedGenerateObject,
14753
+ streamText: wrappedStreamText,
14754
+ streamObject: wrappedStreamObject
14755
+ };
14756
+ }
14757
+
13444
14758
  // src/wrappers/anthropic.ts
13445
- import { SpanTypeAttribute as SpanTypeAttribute5 } from "@braintrust/core";
13446
14759
  function wrapAnthropic(anthropic) {
13447
14760
  const au = anthropic;
13448
14761
  if (au && typeof au === "object" && "messages" in au && typeof au.messages === "object" && au.messages && "create" in au.messages) {
@@ -13500,7 +14813,7 @@ function createProxy(create) {
13500
14813
  const spanArgs = {
13501
14814
  name: "anthropic.messages.create",
13502
14815
  spanAttributes: {
13503
- type: SpanTypeAttribute5.LLM
14816
+ type: "llm" /* LLM */
13504
14817
  },
13505
14818
  event: {
13506
14819
  input,
@@ -13844,6 +15157,15 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
13844
15157
  if (!span.instrumentationScope && span.instrumentationLibrary) {
13845
15158
  span.instrumentationScope = span.instrumentationLibrary;
13846
15159
  }
15160
+ if (!span.parentSpanContext && span.parentSpanId) {
15161
+ const spanContext = span.spanContext?.();
15162
+ if (spanContext?.traceId) {
15163
+ span.parentSpanContext = {
15164
+ spanId: span.parentSpanId,
15165
+ traceId: spanContext.traceId
15166
+ };
15167
+ }
15168
+ }
13847
15169
  return span;
13848
15170
  });
13849
15171
  return Reflect.apply(target.export, target, [
@@ -13934,44 +15256,44 @@ var BraintrustExporter = class _BraintrustExporter {
13934
15256
  };
13935
15257
 
13936
15258
  // 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(),
15259
+ import { z as z10 } from "zod/v3";
15260
+ var evalBodySchema = z10.object({
15261
+ name: z10.string(),
15262
+ parameters: z10.record(z10.string(), z10.unknown()).nullish(),
13941
15263
  data: RunEval.shape.data,
13942
- scores: z6.array(
13943
- z6.object({
15264
+ scores: z10.array(
15265
+ z10.object({
13944
15266
  function_id: FunctionId,
13945
- name: z6.string()
15267
+ name: z10.string()
13946
15268
  })
13947
15269
  ).nullish(),
13948
- experiment_name: z6.string().nullish(),
13949
- project_id: z6.string().nullish(),
15270
+ experiment_name: z10.string().nullish(),
15271
+ project_id: z10.string().nullish(),
13950
15272
  parent: InvokeParent.optional(),
13951
- stream: z6.boolean().optional()
15273
+ stream: z10.boolean().optional()
13952
15274
  });
13953
- var evalParametersSerializedSchema = z6.record(
13954
- z6.string(),
13955
- z6.union([
13956
- z6.object({
13957
- type: z6.literal("prompt"),
15275
+ var evalParametersSerializedSchema = z10.record(
15276
+ z10.string(),
15277
+ z10.union([
15278
+ z10.object({
15279
+ type: z10.literal("prompt"),
13958
15280
  default: PromptData.optional(),
13959
- description: z6.string().optional()
15281
+ description: z10.string().optional()
13960
15282
  }),
13961
- z6.object({
13962
- type: z6.literal("data"),
13963
- schema: z6.record(z6.unknown()),
15283
+ z10.object({
15284
+ type: z10.literal("data"),
15285
+ schema: z10.record(z10.unknown()),
13964
15286
  // JSON Schema
13965
- default: z6.unknown().optional(),
13966
- description: z6.string().optional()
15287
+ default: z10.unknown().optional(),
15288
+ description: z10.string().optional()
13967
15289
  })
13968
15290
  ])
13969
15291
  );
13970
- var evaluatorDefinitionSchema = z6.object({
15292
+ var evaluatorDefinitionSchema = z10.object({
13971
15293
  parameters: evalParametersSerializedSchema.optional()
13972
15294
  });
13973
- var evaluatorDefinitionsSchema = z6.record(
13974
- z6.string(),
15295
+ var evaluatorDefinitionsSchema = z10.record(
15296
+ z10.string(),
13975
15297
  evaluatorDefinitionSchema
13976
15298
  );
13977
15299
 
@@ -14072,6 +15394,7 @@ export {
14072
15394
  withExperiment,
14073
15395
  withLogger,
14074
15396
  withParent,
15397
+ wrapAISDK,
14075
15398
  wrapAISDKModel,
14076
15399
  wrapAnthropic,
14077
15400
  wrapOpenAI,